feat(widgets): unregister core WP widgets; About guest signin-loader
Align widget area with zibll by removing default RSS/search/calendar widgets, and make About guest login buttons open auth modal classes.
This commit is contained in:
@@ -10,6 +10,16 @@ defined('ABSPATH') || exit;
|
||||
/**
|
||||
* Register custom widgets.
|
||||
*/
|
||||
function aksrt_unregister_default_widgets(): void {
|
||||
unregister_widget('WP_Widget_RSS');
|
||||
unregister_widget('WP_Widget_Recent_Posts');
|
||||
unregister_widget('WP_Widget_Recent_Comments');
|
||||
unregister_widget('WP_Widget_Pages');
|
||||
unregister_widget('WP_Widget_Search');
|
||||
unregister_widget('WP_Widget_Calendar');
|
||||
}
|
||||
add_action('widgets_init', 'aksrt_unregister_default_widgets', 1);
|
||||
|
||||
function aksrt_register_widgets() {
|
||||
register_widget('\AKSRT\Widgets\AboutWidget');
|
||||
register_widget('\AKSRT\Widgets\CategoriesWidget');
|
||||
|
||||
@@ -99,8 +99,13 @@ class AboutWidget extends \WP_Widget {
|
||||
$avatar = get_avatar_url(0, ['size' => 160, 'default' => 'mystery']);
|
||||
|
||||
$oauth_html = '';
|
||||
if (function_exists('\AKSRT\Auth\OAuth') && method_exists(\AKSRT\Auth\OAuth::get_instance(), 'get_login_buttons')) {
|
||||
$oauth_html = \AKSRT\Auth\OAuth::get_instance()->get_login_buttons();
|
||||
if (class_exists('\AKSRT\Auth\OAuth')) {
|
||||
$oauth = \AKSRT\Auth\OAuth::get_instance();
|
||||
if (method_exists($oauth, 'render_social_buttons')) {
|
||||
$oauth_html = (string) $oauth->render_social_buttons(__('社交账号登录', 'aksrt'));
|
||||
} elseif (method_exists($oauth, 'get_login_buttons')) {
|
||||
$oauth_html = (string) $oauth->get_login_buttons();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="aksrt-user-card">
|
||||
@@ -120,9 +125,9 @@ class AboutWidget extends \WP_Widget {
|
||||
</div>
|
||||
|
||||
<div class="aksrt-user-card__btns">
|
||||
<a class="aksrt-user-card__btn aksrt-user-card__btn--primary" href="<?php echo esc_url($login_url); ?>"><?php esc_html_e('登 录', 'aksrt'); ?></a>
|
||||
<a class="aksrt-user-card__btn aksrt-user-card__btn--primary signin-loader" href="<?php echo esc_url($login_url); ?>"><?php esc_html_e('登 录', 'aksrt'); ?></a>
|
||||
<?php if (get_option('users_can_register')) : ?>
|
||||
<a class="aksrt-user-card__btn aksrt-user-card__btn--outline" href="<?php echo esc_url($register_url); ?>"><?php esc_html_e('注 册', 'aksrt'); ?></a>
|
||||
<a class="aksrt-user-card__btn aksrt-user-card__btn--outline signup-loader" href="<?php echo esc_url($register_url); ?>"><?php esc_html_e('注 册', 'aksrt'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class CustomHtmlGapWidget extends \WP_Widget {
|
||||
$mode = sanitize_key($instance['mode'] ?? 'html');
|
||||
|
||||
if ($mode === 'gap') {
|
||||
$height = max(0, min(200, (int) ($instance['gap_height'] ?? 20)));
|
||||
$height = max(0, min(500, (int) ($instance['gap_height'] ?? 20)));
|
||||
echo '<div class="widget-custom-gap" style="height:' . (int) $height . 'px;" aria-hidden="true"></div>';
|
||||
return;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class CustomHtmlGapWidget extends \WP_Widget {
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id('gap_height'); ?>"><?php esc_html_e('间距高度(px,仅间距模式):', 'aksrt'); ?></label>
|
||||
<input class="tiny-text" type="number" min="0" max="200" id="<?php echo $this->get_field_id('gap_height'); ?>" name="<?php echo $this->get_field_name('gap_height'); ?>" value="<?php echo (int) ($instance['gap_height'] ?? 20); ?>">
|
||||
<input class="tiny-text" type="number" min="0" max="500" id="<?php echo $this->get_field_id('gap_height'); ?>" name="<?php echo $this->get_field_name('gap_height'); ?>" value="<?php echo (int) ($instance['gap_height'] ?? 20); ?>">
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class CustomHtmlGapWidget extends \WP_Widget {
|
||||
'mode' => in_array($new_instance['mode'] ?? '', ['html', 'gap'], true) ? $new_instance['mode'] : 'html',
|
||||
'title' => sanitize_text_field($new_instance['title'] ?? ''),
|
||||
'content' => wp_kses_post($new_instance['content'] ?? ''),
|
||||
'gap_height' => max(0, min(200, (int) ($new_instance['gap_height'] ?? 20))),
|
||||
'gap_height' => max(0, min(500, (int) ($new_instance['gap_height'] ?? 20))),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user