feat(widgets): render icon fields with the universal icon picker
The widget FormRenderer icon case and the nav-menu item icon field now emit the shared picker (preview + choose/clear + editable text input, delegated events so lazy forms and repeater rows work). Icon values are sanitized through aksrt_sanitize_icon_value on both save paths so inline customsvg- markup survives; the widget admin screen enqueues the picker.
This commit is contained in:
@@ -28,6 +28,7 @@ final class AdminFormController {
|
||||
wp_enqueue_script('jquery-ui-sortable');
|
||||
wp_enqueue_style('aksrt-widget-admin', AKSRT_URI . '/assets/widgets/admin.css', ['wp-color-picker'], AKSRT_VERSION);
|
||||
wp_enqueue_style('aksrt-widget-preview', AKSRT_URI . '/assets/widgets/frontend.css', [], AKSRT_VERSION);
|
||||
aksrt_icon_picker_assets(['wp-color-picker']);
|
||||
wp_enqueue_script('aksrt-widget-admin-core', AKSRT_URI . '/assets/widgets/admin-core.js', [], AKSRT_VERSION, true);
|
||||
wp_enqueue_script('aksrt-widget-admin', AKSRT_URI . '/assets/widgets/admin.js', ['jquery', 'jquery-ui-sortable', 'wp-color-picker', 'aksrt-widget-admin-core'], AKSRT_VERSION, true);
|
||||
wp_localize_script('aksrt-widget-admin', 'aksrtWidgetAdmin', [
|
||||
|
||||
@@ -81,7 +81,9 @@ final class FieldSchema {
|
||||
case 'color':
|
||||
return self::color((string) $value);
|
||||
case 'icon':
|
||||
return sanitize_text_field((string) $value);
|
||||
return function_exists('aksrt_sanitize_icon_value')
|
||||
? aksrt_sanitize_icon_value((string) $value)
|
||||
: sanitize_text_field((string) $value);
|
||||
case 'textarea':
|
||||
return !empty($field['allow_html']) ? wp_kses_post((string) $value) : sanitize_textarea_field((string) $value);
|
||||
case 'text':
|
||||
|
||||
@@ -79,7 +79,7 @@ final class FormRenderer {
|
||||
echo '<input class="widefat aksrt-widget-color" type="text" id="' . esc_attr($field_id) . '" name="' . esc_attr($field_name) . '" value="' . esc_attr((string) $value) . '">';
|
||||
break;
|
||||
case 'icon':
|
||||
echo '<div class="aksrt-widget-icon"><i class="' . esc_attr((string) $value) . '" aria-hidden="true"></i><input class="widefat" type="text" id="' . esc_attr($field_id) . '" name="' . esc_attr($field_name) . '" value="' . esc_attr((string) $value) . '" placeholder="fa fas fa-star"></div>';
|
||||
echo aksrt_icon_picker_field($field_name, $field_id, (string) $value);
|
||||
break;
|
||||
case 'link':
|
||||
self::link($widget, $key, is_array($value) ? $value : []);
|
||||
|
||||
Reference in New Issue
Block a user