fix(float): inline panel warnings, drop add-button type picker, mirror reference more-button defaults
This commit is contained in:
@@ -18,9 +18,6 @@ class FloatButtons {
|
||||
/** 固定按钮类型(默认显示顺序)。 */
|
||||
public const TYPES = ['more', 'pay_vip', 'add', 'service_qq', 'service_wechat', 'theme_mode', 'qrcode', 'back_top'];
|
||||
|
||||
/** 发布按钮可选类型。 */
|
||||
public const ADD_BTNS = ['post'];
|
||||
|
||||
/**
|
||||
* 默认配置。
|
||||
*/
|
||||
@@ -35,10 +32,10 @@ class FloatButtons {
|
||||
'items' => [
|
||||
[
|
||||
'type' => 'more',
|
||||
'buttons' => [self::default_more_button()],
|
||||
'buttons' => [self::gift_more_button()],
|
||||
],
|
||||
['type' => 'pay_vip', 'pc_s' => true, 'm_s' => true, 'color' => ['color' => '#f2c97d', 'bg' => 'rgba(62,62,67,0.9)']],
|
||||
['type' => 'add', 'pc_s' => true, 'm_s' => false, 'color' => $empty_color, 'btns' => ['post'], 'icon' => 'fa fas fa-pencil-alt'],
|
||||
['type' => 'add', 'pc_s' => true, 'm_s' => false, 'color' => $empty_color, 'icon' => 'fa fas fa-pencil-alt'],
|
||||
['type' => 'service_qq', 'pc_s' => false, 'm_s' => false, 'color' => $empty_color, 'qq' => ''],
|
||||
['type' => 'service_wechat', 'pc_s' => true, 'm_s' => true, 'color' => $empty_color, 'wechat_img' => ''],
|
||||
['type' => 'theme_mode', 'pc_s' => false, 'm_s' => false, 'color' => $empty_color],
|
||||
@@ -49,18 +46,44 @@ class FloatButtons {
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认「更多按钮」子项。
|
||||
* 「更多按钮」出厂默认项(对齐参考主题 float_btn.more 默认值)。
|
||||
*/
|
||||
public static function default_more_button(): array {
|
||||
public static function gift_more_button(): array {
|
||||
$img = get_template_directory_uri() . '/assets/img/logo.png';
|
||||
return [
|
||||
'desc' => '本站同款主题模板',
|
||||
'icon' => 'zibsvg-gift-color',
|
||||
'link' => ['url' => '', 'target' => ''],
|
||||
'hover' => '<a href="https://www.zibll.com/" target="_blank">
|
||||
<div class="flex c-red">
|
||||
<img class="flex0" alt="zibll子比主题" src="' . esc_url($img) . '" height="30">
|
||||
<div class="flex1 ml10">
|
||||
<dt>本站同款主题模板</dt>
|
||||
<div class="px12 mt10 muted-color">zibll子比主题是一款漂亮优雅的网站主题模板,功能强大,配置简单。</div>
|
||||
<div class="but mt10 p2-10 c-blue btn-block px12">查看详情</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>',
|
||||
'hover_width' => 240,
|
||||
'pc_s' => true,
|
||||
'm_s' => true,
|
||||
'color' => ['color' => '', 'bg' => 'rgba(255, 111, 6, 0.2)'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 「添加按钮」新增项默认值(参考主题 group 字段默认值)。
|
||||
*/
|
||||
public static function new_more_button(): array {
|
||||
return [
|
||||
'desc' => '',
|
||||
'icon' => 'fa fas fa-heart',
|
||||
'link' => ['url' => '', 'target' => ''],
|
||||
'hover' => '',
|
||||
'hover_width' => 200,
|
||||
'pc_s' => false,
|
||||
'm_s' => false,
|
||||
'color' => ['color' => '', 'bg' => 'rgba(255, 111, 6, 0.2)'],
|
||||
'pc_s' => true,
|
||||
'm_s' => true,
|
||||
'color' => ['color' => '', 'bg' => ''],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -139,7 +162,7 @@ class FloatButtons {
|
||||
}
|
||||
// 参考主题:至少保留一个。
|
||||
if ($buttons === []) {
|
||||
$buttons[] = self::default_more_button();
|
||||
$buttons[] = self::new_more_button();
|
||||
}
|
||||
return ['type' => 'more', 'buttons' => $buttons];
|
||||
}
|
||||
@@ -153,14 +176,6 @@ class FloatButtons {
|
||||
|
||||
switch ($type) {
|
||||
case 'add':
|
||||
$btns = [];
|
||||
foreach ((array) ($item['btns'] ?? []) as $btn) {
|
||||
$btn = (string) $btn;
|
||||
if (in_array($btn, self::ADD_BTNS, true) && !in_array($btn, $btns, true)) {
|
||||
$btns[] = $btn;
|
||||
}
|
||||
}
|
||||
$out['btns'] = $btns;
|
||||
$out['icon'] = aksrt_sanitize_icon_value((string) ($item['icon'] ?? ''));
|
||||
break;
|
||||
case 'service_qq':
|
||||
|
||||
Reference in New Issue
Block a user