feat(phase2): shared common-form layer + CommonWidgetFields trait for all widgets
- Extract Zibll CSF_Widget::params() common-field parity into inc/modules/widget-common.php (required by widgets-register.php to keep both files <1000 lines): subtitle, title_style(simple/big), title_highlight +color, title_link x3, title_link_style colors, sidebar_affix, show_type (all/only_pc/only_sm), show_id_type(show/hide), show_ids, animation_in, animation_repeat, layout_pin_pc/m, layout_bg(white/dark). Adds normalize_link/normalize_bg helpers, affix_attrs, common_wrapper_attr, render_title, animation_class. Back-compat normalizes legacy tokens (in_affix->sidebar_affix, pc/only_pc, include/exclude->show/hide). - Add src/AKSRT/Widgets/Traits/CommonWidgetFields.php trait (render_common_form_section + update_common_fields). - Wire all 57 widgets to use the trait; migrate the 16 hand-rolled in_affix implementations to shared sidebar_affix (fixes 6 latent bugs where in_affix was never persisted). SearchWidget intentionally skips the shared form section (its business show_type collides) but adopts the affix helper. - widget_display_callback parity verified via tmp assertion script. Refs .specs/plans/zibll-widgets-1to1.md Phase 2 (US1/US5) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
98aeee3cc1
commit
d975ff4ce6
60 files changed
+1227
-489
No files matched your search
@@ -7,9 +7,13 @@
|
||||
|
||||
namespace AKSRT\Widgets;
|
||||
|
||||
use AKSRT\Widgets\Traits\CommonWidgetFields;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class WidgetCoverCards extends \WP_Widget {
|
||||
use CommonWidgetFields;
|
||||
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct(
|
||||
@@ -200,7 +204,8 @@ class WidgetCoverCards extends \WP_Widget {
|
||||
<small><?php esc_html_e('字段: image, video, title, link, target, hide(pc|m), height, mask', 'aksrt'); ?></small>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
$this->render_common_form_section($instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $new_instance
|
||||
@@ -208,7 +213,7 @@ class WidgetCoverCards extends \WP_Widget {
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function update($new_instance, $old_instance): array {
|
||||
return [
|
||||
$business = [
|
||||
'title' => sanitize_text_field((string) ($new_instance['title'] ?? '')),
|
||||
'pc_row' => max(1, min(6, (int) ($new_instance['pc_row'] ?? 2))),
|
||||
'm_row' => max(1, min(3, (int) ($new_instance['m_row'] ?? 1))),
|
||||
@@ -220,6 +225,6 @@ class WidgetCoverCards extends \WP_Widget {
|
||||
'font_bold' => !empty($new_instance['font_bold']) ? 1 : 0,
|
||||
'font_color' => sanitize_hex_color((string) ($new_instance['font_color'] ?? '')) ?: '',
|
||||
'items' => $this->normalize($new_instance['items'] ?? []),
|
||||
];
|
||||
]; return $this->update_common_fields($new_instance, $old_instance, $business);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user