feat(widgets): search affix, mod apply, blur_bg, iframe null
Wire search sidebar affix, plate moderator apply entry, user-lists REST blur_bg, and iframe empty via aksrt_get_widget_null.
This commit is contained in:
@@ -240,6 +240,7 @@ class WidgetAjax {
|
||||
'include' => sanitize_text_field((string) ($request->get_param('include') ?? '')),
|
||||
'exclude' => sanitize_text_field((string) ($request->get_param('exclude') ?? '')),
|
||||
'hide_box' => (int) ($request->get_param('hide_box') ?? 0),
|
||||
'blur_bg' => (int) ($request->get_param('blur_bg') ?? 0),
|
||||
];
|
||||
$html = \AKSRT\Widgets\WidgetUserLists::render_html($instance);
|
||||
return new \WP_REST_Response(['success' => true, 'html' => $html], 200);
|
||||
|
||||
@@ -109,7 +109,7 @@ class SearchWidget extends \WP_Widget {
|
||||
|
||||
$uid = 'aksrt-sw-' . esc_attr($this->id);
|
||||
?>
|
||||
<div class="widget-search-box aksrt-search-widget search-input" id="<?php echo $uid; ?>">
|
||||
<div class="widget-search-box aksrt-search-widget search-input<?php echo !empty($instance['in_affix']) ? ' is-affix' : ''; ?>" id="<?php echo $uid; ?>"<?php echo !empty($instance['in_affix']) ? ' data-affix="true"' : ''; ?>>
|
||||
<form
|
||||
role="search"
|
||||
method="get"
|
||||
@@ -239,7 +239,8 @@ class SearchWidget extends \WP_Widget {
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('show_type')); ?>" value="1" <?php checked(!empty($instance['show_type']) || !isset($instance['show_type'])); ?>> <?php esc_html_e('显示类型切换(≥2 种时)', 'aksrt'); ?></label><br>
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('show_input_cat')); ?>" value="1" <?php checked(!empty($instance['show_input_cat'])); ?>> <?php esc_html_e('显示分类筛选', 'aksrt'); ?></label><br>
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('show_keywords')); ?>" value="1" <?php checked(!empty($instance['show_keywords'])); ?>> <?php esc_html_e('显示热门关键词', 'aksrt'); ?></label><br>
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('show_history')); ?>" value="1" <?php checked(!empty($instance['show_history'])); ?>> <?php esc_html_e('显示搜索历史', 'aksrt'); ?></label>
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('show_history')); ?>" value="1" <?php checked(!empty($instance['show_history'])); ?>> <?php esc_html_e('显示搜索历史', 'aksrt'); ?></label><br>
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('in_affix')); ?>" value="1" <?php checked(!empty($instance['in_affix'])); ?>> <?php esc_html_e('侧栏随动', 'aksrt'); ?></label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('默认类型', 'aksrt'); ?>
|
||||
@@ -298,6 +299,7 @@ class SearchWidget extends \WP_Widget {
|
||||
'keywords' => sanitize_textarea_field((string) ($new_instance['keywords'] ?? '')),
|
||||
'more_but' => sanitize_text_field((string) ($new_instance['more_but'] ?? '')),
|
||||
'more_but_url' => esc_url_raw(trim((string) ($new_instance['more_but_url'] ?? ''))),
|
||||
'in_affix' => !empty($new_instance['in_affix']) ? 1 : 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,10 +73,29 @@ class WidgetForumPlateModerator extends \WP_Widget {
|
||||
$style = 'list';
|
||||
}
|
||||
|
||||
$show_apply = !isset($instance['apply_btn']) || !empty($instance['apply_btn']);
|
||||
$apply_html = '';
|
||||
if ($show_apply && is_user_logged_in()) {
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$cuid = get_current_user_id();
|
||||
$can_apply = $forum && method_exists($forum, 'forum_user_can')
|
||||
? $forum->forum_user_can($cuid, 'moderator_apply')
|
||||
: true;
|
||||
$is_mod = $forum && method_exists($forum, 'is_board_moderator')
|
||||
? $forum->is_board_moderator($cuid, $id)
|
||||
: in_array($cuid, array_merge([$author_id], $mods, $super), true);
|
||||
if ($can_apply && !$is_mod) {
|
||||
$apply_url = add_query_arg(['aksrt_apply_moderator' => 1, 'plate' => $id], get_permalink($id));
|
||||
$apply_html = '<a class="but hollow c-blue p2-10 em09" href="' . esc_url($apply_url) . '">' . esc_html__('申请版主', 'aksrt') . '</a>';
|
||||
}
|
||||
}
|
||||
ob_start();
|
||||
echo '<div class="zib-widget moderator-box aksrt-plate-mods style-' . esc_attr($style) . ' ajax-item">';
|
||||
if ($title_text !== '') {
|
||||
echo '<div class="mb10 flex jsb ac aksrt-plate-mods__head"><div class="title-theme">' . esc_html($title_text) . '</div></div>';
|
||||
if ($title_text !== '' || $apply_html !== '') {
|
||||
echo '<div class="mb10 flex jsb ac aksrt-plate-mods__head">';
|
||||
echo $title_text !== '' ? '<div class="title-theme">' . esc_html($title_text) . '</div>' : '<div></div>';
|
||||
echo $apply_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div class="aksrt-plate-mods__list">';
|
||||
foreach ($people as $row) {
|
||||
@@ -144,7 +163,8 @@ class WidgetForumPlateModerator extends \WP_Widget {
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('show_avatar')); ?>" value="1" <?php checked(!isset($instance['show_avatar']) || !empty($instance['show_avatar'])); ?>> <?php esc_html_e('显示头像', 'aksrt'); ?></label>
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('show_avatar')); ?>" value="1" <?php checked(!isset($instance['show_avatar']) || !empty($instance['show_avatar'])); ?>> <?php esc_html_e('显示头像', 'aksrt'); ?></label><br>
|
||||
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('apply_btn')); ?>" value="1" <?php checked(!isset($instance['apply_btn']) || !empty($instance['apply_btn'])); ?>> <?php esc_html_e('显示申请版主入口', 'aksrt'); ?></label>
|
||||
</p>
|
||||
<p class="description"><?php esc_html_e('仅在版块/帖子页显示。', 'aksrt'); ?></p>
|
||||
<?php
|
||||
@@ -155,6 +175,7 @@ class WidgetForumPlateModerator extends \WP_Widget {
|
||||
'title_text' => sanitize_text_field((string) ($new_instance['title_text'] ?? '')),
|
||||
'style' => ($new_instance['style'] ?? '') === 'grid' ? 'grid' : 'list',
|
||||
'show_avatar' => !empty($new_instance['show_avatar']) ? 1 : 0,
|
||||
'apply_btn' => !empty($new_instance['apply_btn']) ? 1 : 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,9 @@ class WidgetIframe extends \WP_Widget {
|
||||
if ($raw === '') {
|
||||
if (current_user_can('manage_options')) {
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="c-red muted-box mb20"><b>' . esc_html__('超级嵌入:', 'aksrt') . '</b>' .
|
||||
esc_html__('请配置 URL 或 iframe 代码', 'aksrt') . '</div>';
|
||||
echo function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('请配置 URL 或 iframe 代码', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
: '<div class="c-red muted-box mb20"><b>' . esc_html__('超级嵌入:', 'aksrt') . '</b>' . esc_html__('请配置 URL 或 iframe 代码', 'aksrt') . '</div>';
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user