$variant, 'attrs' => array( 'id' => $id ) + ( '' !== $ask ? $aieo_sw_ask[ $ask ] : array() ) ) );
};
$aieo_sw_color = static function ( $name, $default, $row ) use ( $settings ) {
$archive = '_shop_archive' === substr( $name, -13 );
$base = $archive ? substr( $name, 0, -13 ) : $name;
if ( 0 === strpos( $base, 'button_' ) ) {
$what = false !== strpos( $base, '_hover' ) ? _x( 'hover', 'a swatch state', 'ai-eshop-optimizer' )
: ( false !== strpos( $base, '_selected' ) ? _x( 'selected', 'a swatch state', 'ai-eshop-optimizer' ) : _x( 'default', 'a swatch state', 'ai-eshop-optimizer' ) );
} else {
$what = __( 'Colour', 'ai-eshop-optimizer' );
}
$label = $row . ', ' . ( $archive ? __( 'Archive / shop', 'ai-eshop-optimizer' ) : __( 'Product page', 'ai-eshop-optimizer' ) ) . ', ' . $what;
return \Rooster\Admin\Fields::color( $name, (string) ( $settings[ $name ] ?? $default ), array( 'id' => 'aieo-sw-' . str_replace( '_', '-', $name ), 'default' => $default, 'alpha' => true, 'aria-label' => $label ) );
};
$aieo_sw_id = static function ( $name ) {
return 'aieo-sw-' . str_replace( '_', '-', $name );
};
$aieo_sw_num = static function ( $name, $default, array $opts = array() ) use ( $settings, $aieo_sw_id ) {
return \Rooster\Admin\Ui::input( $name, (string) ( $settings[ $name ] ?? $default ), $opts + array( 'type' => 'number', 'xs' => true, 'min' => '0', 'unit' => 'px', 'id' => $aieo_sw_id( $name ) ) );
};
$aieo_sw_pp = __( 'Product page', 'ai-eshop-optimizer' );
$aieo_sw_ar = __( 'Archive / shop', 'ai-eshop-optimizer' );
$aieo_sw_pair = static function ( $key, $label, $pp, $ar ) use ( $aieo_sw_num, $aieo_sw_id, $aieo_sw_pp, $aieo_sw_ar ) {
$parts = array();
foreach ( array( array( $key, $pp, $aieo_sw_pp ), array( $key . '_shop_archive', $ar, $aieo_sw_ar ) ) as $aieo_sw_p ) {
$parts[] = array( 'label' => $aieo_sw_p[2], 'id' => $aieo_sw_id( $aieo_sw_p[0] ), 'control' => $aieo_sw_num( $aieo_sw_p[0], $aieo_sw_p[1] ) );
}
return \Rooster\Admin\Ui::field_row( array( 'id' => $aieo_sw_id( $key ) . '-row', 'label' => $label, 'parts' => $parts ) );
};
$aieo_sw_cols = static function ( $id, $label, array $pp, array $ar, $help = '' ) use ( $aieo_sw_pp, $aieo_sw_ar ) {
$column = static function ( $name, array $boxes ) use ( $label ) {
$parts = array();
foreach ( $boxes as $box ) {
$parts[] = array( 'label' => $box[0], 'control' => $box[1] );
}
return \Rooster\Admin\Fields::compound( $parts, array( 'label' => $label . ', ' . $name ) );
};
return \Rooster\Admin\Ui::field_row( array(
'id' => $id,
'label' => $label,
'help' => $help,
'parts' => array(
array( 'label' => $aieo_sw_pp, 'control' => $column( $aieo_sw_pp, $pp ) ),
array( 'label' => $aieo_sw_ar, 'control' => $column( $aieo_sw_ar, $ar ) ),
),
) );
};
$aieo_sw_row = static function ( $id, $label, $control, $help = '' ) {
return \Rooster\Admin\Ui::field_row( array( 'id' => $id, 'label' => $label, 'control' => $control, 'help' => $help ) );
};
$aieo_sw_sides = array(
'top' => _x( 'Top', 'a side of a box', 'ai-eshop-optimizer' ),
'right' => _x( 'Right', 'a side of a box', 'ai-eshop-optimizer' ),
'bottom' => _x( 'Bottom', 'a side of a box', 'ai-eshop-optimizer' ),
'left' => _x( 'Left', 'a side of a box', 'ai-eshop-optimizer' ),
);
$aieo_sw_variable = isset( $stats['variable_products'] ) ? (int) $stats['variable_products'] : 0;
$aieo_sw_queued = '
' . esc_html( sprintf(
_n( '%s variable product will be queued.', '%s variable products will be queued.', $aieo_sw_variable, 'ai-eshop-optimizer' ),
number_format_i18n( $aieo_sw_variable )
) ) . '
';
$aieo_sw_images = 0;
if ( function_exists( 'wc_get_attribute_taxonomies' ) ) {
foreach ( (array) wc_get_attribute_taxonomies() as $aieo_sw_tax ) {
if ( 'image' === $aieo_sw_tax->attribute_type ) {
++$aieo_sw_images;
}
}
}
$aieo_sw_flagging = '' . esc_html( sprintf(
_n( '%s image swatch attribute will be marked as a colour.', '%s image swatch attributes will be marked as colours.', $aieo_sw_images, 'ai-eshop-optimizer' ),
number_format_i18n( $aieo_sw_images )
) ) . '
';
$aieo_sw_dialogs_cache = \Rooster\Admin\States::confirm(
'aieo-sw-dialog-rebuild',
'apply',
__( 'Queue a full rebuild of every variable product’s swatch cache?', 'ai-eshop-optimizer' ),
$aieo_sw_queued,
array( 'confirm' => __( 'Rebuild all', 'ai-eshop-optimizer' ) )
)
. \Rooster\Admin\States::confirm( 'aieo-sw-dialog-clear', 'reset', __( 'Empty the swatch cache tables? Swatches switch off, and the shop shows WooCommerce’s own variation pickers, until the cache is built again.', 'ai-eshop-optimizer' ), '', array( 'confirm' => __( 'Clear cache', 'ai-eshop-optimizer' ) ) )
. \Rooster\Admin\States::confirm( 'aieo-sw-dialog-migrate', 'replace', __( 'Bring the settings across from the old om-product-swatches plugin and rebuild every variable product?', 'ai-eshop-optimizer' ), $aieo_sw_queued, array( 'confirm' => __( 'Migrate from legacy', 'ai-eshop-optimizer' ) ) );
$aieo_sw_dialogs_colour = \Rooster\Admin\States::confirm( 'aieo-sw-dialog-flag', 'apply', __( 'Mark ALL image swatch attributes as colours? The colours fill in again on the next rebuild.', 'ai-eshop-optimizer' ), $aieo_sw_flagging, array( 'confirm' => __( 'Flag all image swatches as colour', 'ai-eshop-optimizer' ) ) )
. \Rooster\Admin\States::confirm( 'aieo-sw-dialog-unflag', 'reset', __( 'Clear the colour marking from ALL swatch attributes?', 'ai-eshop-optimizer' ), '', array( 'confirm' => __( 'Clear all colour flags', 'ai-eshop-optimizer' ) ) );
list( $aieo_sw_open, $aieo_sw_close ) = AIEO_DMM_UI::card(
array(
'anchor' => 'swatches-cache-monitoring',
'icon' => 'gauge',
'class' => 'aieo-dmm-swatches-monitoring',
'title' => __( 'Cache monitoring', 'ai-eshop-optimizer' ),
'description' => __( 'High-performance variation swatches for variable products. The cache stores a denormalized snapshot of each variable product’s variations (one row per product × context) so the shop archive can render swatches without instantiating WooCommerce variation objects on every page view.', 'ai-eshop-optimizer' ),
'footer' => $aieo_sw_button( __( 'Rebuild all', 'ai-eshop-optimizer' ), 'aieo-dmm-swatches-rebuild', 'rebuild', 'primary' ) . ' '
. $aieo_sw_button( __( 'Clear cache', 'ai-eshop-optimizer' ), 'aieo-dmm-swatches-clear', 'clear' ) . ' '
. $aieo_sw_button( __( 'Migrate from legacy', 'ai-eshop-optimizer' ), 'aieo-dmm-swatches-migrate', 'migrate' ) . ' '
. $aieo_sw_button( __( 'Refresh stats', 'ai-eshop-optimizer' ), 'aieo-dmm-swatches-refresh-stats' ),
)
);
echo $aieo_sw_open;
?>
'cache_rows',
'label' => __('Cache rows', 'ai-eshop-optimizer'),
'html' => '' . (int) $stats['cache_rows'] . ''
. ' ' . sprintf(
esc_html__('(%d variable products × 2 contexts = target).', 'ai-eshop-optimizer'),
(int) $stats['variable_products']
) . '',
),
array(
'id' => 'map_rows',
'label' => __('Variation map rows', 'ai-eshop-optimizer'),
'html' => '' . (int) $stats['map_rows'] . '',
),
array(
'id' => 'coverage_pct',
'label' => __('Coverage', 'ai-eshop-optimizer'),
'html' => '' . esc_html((string) $stats['coverage_pct']) . '%',
),
array(
'id' => 'stale_rows',
'label' => __('Stale rows', 'ai-eshop-optimizer'),
'html' => '' . (int) $stats['stale_rows'] . ''
. ' '
. esc_html__('Rows whose settings hash no longer matches — they’ll rebuild lazily on first frontend hit.', 'ai-eshop-optimizer')
. '',
),
array(
'id' => 'last_built_at',
'label' => __('Last rebuild', 'ai-eshop-optimizer'),
'html' => ''
. esc_html((string) ($stats['last_built_at'] ?: '—')) . '',
),
array(
'id' => 'object_cache',
'label' => __('External object cache', 'ai-eshop-optimizer'),
'html' => !empty($stats['object_cache'])
? \Rooster\Admin\Ui::badge(__('Active', 'ai-eshop-optimizer'), 'success', array('dot' => true))
: \Rooster\Admin\Ui::badge(__('Not detected', 'ai-eshop-optimizer'), 'mono', array('dot' => true)),
),
array(
'id' => 'legacy_plugin_active',
'label' => __('Legacy plugin active', 'ai-eshop-optimizer'),
'html' => !empty($stats['legacy_plugin_active'])
? \Rooster\Admin\Ui::badge(__('om-product-swatches is loaded (shadow-write target)', 'ai-eshop-optimizer'), 'success', array('dot' => true))
: \Rooster\Admin\Ui::badge(__('om-product-swatches not loaded', 'ai-eshop-optimizer'), 'mono', array('dot' => true)),
),
);
AIEO_Table::render(
array(
'id' => 'aieo-dmm-swatches-stats',
'head' => false,
'row_header' => true,
'columns' => array(
array('key' => 'label', 'type' => 'text', 'width' => '260px'),
array(
'key' => 'html',
'type' => 'control',
'format' => array(
'render' => static function ($row) {
return (string) $row['html'];
},
),
),
),
'rows' => $aieo_sw_stat_rows,
'row_key' => 'id',
'page_id' => 'swatches',
)
);
echo $aieo_sw_dialogs_cache;
echo $aieo_sw_close;
?>
'swatches-colour-context-seo-feeds',
'icon' => 'palette',
'class' => 'aieo-dmm-colour-context',
'title' => __( 'Colour context (SEO and feeds)', 'ai-eshop-optimizer' ),
'description' => __( 'Mark which swatch attributes represent a product COLOUR. For each flagged attribute, the variation’s term name (e.g. “French Caramel”) is written into the product colour used by the SEO product schema and the marketplace feeds. You can also tick “Rooster One colour context” on a single attribute under Products → Attributes.', 'ai-eshop-optimizer' ),
'footer' => $aieo_sw_button( __( 'Flag all image swatches as colour', 'ai-eshop-optimizer' ), 'aieo-dmm-colour-flag-image', 'flag', 'primary' ) . ' '
. $aieo_sw_button( __( 'Clear all colour flags', 'ai-eshop-optimizer' ), 'aieo-dmm-colour-clear', 'unflag' ),
'footnote' => __( 'After changing flags, run the data-prep pipeline (Catalog Sync → Data prep schedule → Run now), or wait for the hourly build, so colours repopulate into the product vitals.', 'ai-eshop-optimizer' ),
)
);
echo $aieo_sw_open;
?>
get_colour_flag_count() : 0; ?>
$anchor,
'icon' => $icon,
'title' => $title,
'description' => $description,
'footer' => class_exists( '\Rooster\Admin\States' ) ? \Rooster\Admin\States::save_button( $form_id ) : '',
) ) );
echo $open;
ob_start();
return array( $form_id, $close );
};
$aieo_sw_group_close = static function ( $ctx ) {
echo \Rooster\Admin\States::form( $ctx[0], (string) ob_get_clean(), array( 'url' => '', 'attrs' => array( 'data-aieo-swatches-form' => '' ) ) );
echo $ctx[1];
};
$aieo_sw_ctx = $aieo_sw_group_open( 'swatches-core-settings', 'settings', __( 'Core settings', 'ai-eshop-optimizer' ), __( 'Switch the swatches on, choose where they show, and set how many fit on an archive card.', 'ai-eshop-optimizer' ) );
?>
'yes', 'id' => 'aieo-sw-enabled', 'label' => __('Show the swatches on the shop\'s product pages and product cards', 'ai-eshop-optimizer'))))
. $aieo_sw_row('aieo-sw-on-shop-catalog', __('Show on shop / archive', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('on_shop_catalog', (bool) (!empty($settings['on_shop_catalog'])), array('value' => '1', 'id' => 'aieo-sw-on-shop-catalog', 'label' => __('Render swatches on product archive / category pages', 'ai-eshop-optimizer'))))
. $aieo_sw_row('aieo-sw-display-variation-name-on-product-title', __('Variation name under product title', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('display_variation_name_on_product_title', (bool) (!empty($settings['display_variation_name_on_product_title'])), array('value' => '1', 'id' => 'aieo-sw-display-variation-name-on-product-title', 'label' => __('On the product page, show the selected variation’s description + attribute under the title (e.g. “No100 Fair - Light”). Read instantly from the preloaded swatch cache.', 'ai-eshop-optimizer'))))
. $aieo_sw_row('aieo-sw-shade-name', __('Shade name', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::select('shade_name', array(
'desc_term' => __('The variation’s description, then the term', 'ai-eshop-optimizer'),
'term_desc' => __('The term, then the variation’s description', 'ai-eshop-optimizer'),
'term' => __('The term alone', 'ai-eshop-optimizer'),
), class_exists('AIEO_DMM_Swatches_Runtime') ? AIEO_DMM_Swatches_Runtime::instance()->shade_mode() : (string) ($settings['shade_name'] ?? 'desc_term'), array('id' => 'aieo-sw-shade-name')), __('How a shade is called wherever a shopper reads it: its caption, the line under the title, the chosen shades, the multi-select, the waiting list, the quote, the deal card and the e-mails. The description first: “No100 Fair - Light”. The term first: “5.5 - Ocean blue”. The term alone: “5.5”. A shade whose variation has no description is called by its term. The cart’s, checkout’s and order’s “Variant” line stays as WooCommerce stores it.', 'ai-eshop-optimizer'))
. $aieo_sw_row('aieo-sw-core-limit-desktop', __('Archive swatch limit (desktop)', 'ai-eshop-optimizer'), $aieo_sw_num('image_swatch_limit_desktop', 5, array('id' => 'aieo-sw-core-limit-desktop', 'min' => '1', 'max' => '20', 'unit' => '')))
. $aieo_sw_row('aieo-sw-core-limit-mobile', __('Archive swatch limit (mobile)', 'ai-eshop-optimizer'), $aieo_sw_num('image_swatch_limit_mobile', 3, array('id' => 'aieo-sw-core-limit-mobile', 'min' => '1', 'max' => '20', 'unit' => '')));
?>
__('Tick boxes in the page: a tap ticks at once', 'ai-eshop-optimizer'),
'links' => __('Drawn by the script: the first tap waits for it', 'ai-eshop-optimizer'),
), 'links' === (string) ($settings['product_swatch_controls'] ?? 'inputs') ? 'links' : 'inputs', array('id' => 'aieo-sw-product-swatch-controls')), __('Tick boxes: each shade is a real tick box (or a choice, when one shade is chosen) printed with the page, and a multi-select\'s button and “Clear selections” come with it, so a shopper\'s first tap counts even on a slow phone. Drawn by the script: the shades are links the swatch script answers, and a multi-select\'s button is built at the first touch. The drop-down list and the product cards keep their own.', 'ai-eshop-optimizer'));
echo $aieo_sw_row('aieo-sw-product-swatch-look', __('Look of the shades', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::select('product_swatch_look', array(
'designer' => __('The designer’s: two rows of chips, “See all” and the chosen list', 'ai-eshop-optimizer'),
'classic' => __('Classic: every chip, the summary above the button', 'ai-eshop-optimizer'),
), 'classic' === (string) ($settings['product_swatch_look'] ?? 'designer') ? 'classic' : 'designer', array('id' => 'aieo-sw-product-swatch-look')), __('The designer’s: the chosen shade and how many are chosen above the chips, two rows of chips, “See all N shades” opening every shade in a window (a sheet on a phone), and the chosen shades listed with their quantities, the total on the button. Classic: the look before it. For colour and picture swatches shown as tick boxes; buttons, the drop-down list and the product cards keep their own.', 'ai-eshop-optimizer'));
echo $aieo_sw_row('aieo-sw-multi-select-enabled', __('Enable multi-select', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('multi_select_enabled', (bool) (!empty($settings['multi_select_enabled'])), array('value' => '1', 'id' => 'aieo-sw-multi-select-enabled', 'label' => __('Allow ticking multiple variations and adding them in one request', 'ai-eshop-optimizer'))))
. $aieo_sw_row('aieo-sw-multi-select-display-style', __('Default display style', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::select('multi_select_display_style', array(
'grid' => __('Grid of image swatches', 'ai-eshop-optimizer'),
'dropdown' => __('Dropdown list', 'ai-eshop-optimizer'),
), (string) ($settings['multi_select_display_style'] ?? 'grid'), array('id' => 'aieo-sw-multi-select-display-style')), __('Can be overridden per-category below.', 'ai-eshop-optimizer'))
. $aieo_sw_row('aieo-sw-multi-select-show-quantity', __('Show quantity input in dropdown mode', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('multi_select_show_quantity', (bool) (!empty($settings['multi_select_show_quantity'])), array('value' => '1', 'id' => 'aieo-sw-multi-select-show-quantity', 'label' => __('Add a qty field next to each row in the dropdown list', 'ai-eshop-optimizer'))))
. $aieo_sw_row('aieo-sw-multi-select-button-text', __('“Add selected” button', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::input('multi_select_button_text', (string) ($settings['multi_select_button_text'] ?? 'Add Selected to Cart'), array('id' => 'aieo-sw-multi-select-button-text', 'medium' => true)))
. $aieo_sw_row('aieo-sw-multi-select-button-position', __('Button position', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::select('multi_select_button_position', array(
'above' => __('Button above the swatches / list', 'ai-eshop-optimizer'),
'below' => __('Button below the swatches / list', 'ai-eshop-optimizer'),
), (string) ($settings['multi_select_button_position'] ?? 'above'), array('id' => 'aieo-sw-multi-select-button-position')))
. $aieo_sw_row('aieo-sw-cart-sync-enabled', __('Cart sync', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('cart_sync_enabled', (bool) (!empty($settings['cart_sync_enabled'])), array('value' => '1', 'id' => 'aieo-sw-cart-sync-enabled', 'label' => __('Highlight variations that are already in the shopper’s cart', 'ai-eshop-optimizer'))))
. $aieo_sw_row('aieo-sw-cart-summary-visible', __('“In cart” summary badge', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('cart_summary_visible', (bool) (!empty($settings['cart_summary_visible'])), array('value' => '1', 'id' => 'aieo-sw-cart-summary-visible', 'label' => __('Show the “X items in cart — View details” summary above each product card and on product pages', 'ai-eshop-optimizer'))), __('Independent of the swatch highlight above. Turn this off if the badge clutters product cards but you still want the in-cart green border on swatches.', 'ai-eshop-optimizer'))
. $aieo_sw_row('aieo-sw-cart-variation-image', __('Cart / mini-cart image source', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::select('cart_variation_image', array(
'swatch' => __('Variation swatch image', 'ai-eshop-optimizer'),
'variation' => __('Variation gallery image', 'ai-eshop-optimizer'),
'gallery' => __('Parent gallery image', 'ai-eshop-optimizer'),
'product' => __('Parent product image', 'ai-eshop-optimizer'),
), (string) ($settings['cart_variation_image'] ?? 'swatch'), array('id' => 'aieo-sw-cart-variation-image')))
. $aieo_sw_row('aieo-sw-track-per-variation-atc', __('Per-variation Add-to-cart text', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('track_per_variation_atc', (bool) (!empty($settings['track_per_variation_atc'])), array('value' => '1', 'id' => 'aieo-sw-track-per-variation-atc', 'label' => __('Update the variable PDP “Add to cart” button + +N badge per variation chip pick', 'ai-eshop-optimizer'))), __('Off (default): any variation in cart → button shows the “in cart” label and the +N badge counts every variation aggregated under the parent. On: the button text + badge re-render every time the shopper picks a different chip and reflect that specific variation’s cart qty (zero if that variation is not in cart). Pairs with the Add-to-Cart Text labels under DMM → Add-to-Cart Text.', 'ai-eshop-optimizer'));
?>
array(__('Tick box', 'ai-eshop-optimizer'), __('Always shown. A tap anywhere on the row ticks it, apart from the quantity.', 'ai-eshop-optimizer'), '', ''),
'image' => array(__('Image', 'ai-eshop-optimizer'), __('The variation’s swatch: its colour or its picture.', 'ai-eshop-optimizer'), 'multi_select_row_image', __('Show the image', 'ai-eshop-optimizer')),
'name' => array(__('Name', 'ai-eshop-optimizer'), __('Always shown: it names the tick box.', 'ai-eshop-optimizer'), '', ''),
'price' => array(__('Price', 'ai-eshop-optimizer'), __('Placed next to the name, it is shown under it.', 'ai-eshop-optimizer'), 'multi_select_row_price', __('Show the price', 'ai-eshop-optimizer')),
'qty' => array(__('Quantity', 'ai-eshop-optimizer'), __('A stepper on a ticked row. On the product page, only where the quantity setting above allows it.', 'ai-eshop-optimizer'), 'multi_select_row_qty', __('Show the quantity', 'ai-eshop-optimizer')),
);
$aieo_sw_order = array_values(array_intersect(array_map('strval', (array) ($settings['multi_select_row_order'] ?? array())), array_keys($aieo_sw_parts)));
$aieo_sw_rows = array();
foreach (array_unique(array_merge($aieo_sw_order, array_keys($aieo_sw_parts))) as $aieo_sw_key) {
list($aieo_sw_label, $aieo_sw_note, $aieo_sw_field, $aieo_sw_show) = $aieo_sw_parts[$aieo_sw_key];
$aieo_sw_rows[] = array(
'_id' => $aieo_sw_key,
'part' => $aieo_sw_label,
'shown' => array(
'html' => '' === $aieo_sw_field
? esc_html__('Always', 'ai-eshop-optimizer')
: \Rooster\Admin\Ui::toggle($aieo_sw_field, !isset($settings[$aieo_sw_field]) || !empty($settings[$aieo_sw_field]), array('value' => '1', 'id' => 'aieo-sw-row-' . $aieo_sw_key, 'label' => $aieo_sw_show, 'label_hidden' => true, 'hidden' => false)),
),
'note' => $aieo_sw_note,
);
}
?>
'part', 'label' => __('Part', 'ai-eshop-optimizer')),
array('key' => 'shown', 'label' => _x('Shown', 'a part of a row: shown or hidden', 'ai-eshop-optimizer'), 'type' => 'html', 'width' => 'min'),
array('key' => 'note', 'label' => __('In the row', 'ai-eshop-optimizer')),
),
$aieo_sw_rows,
array(
'id' => 'aieo-sw-row-layout',
'caption' => __('The parts of a variation’s row, in their order', 'ai-eshop-optimizer'),
'move' => array(
'name' => 'multi_select_row_order',
'default' => array_keys($aieo_sw_parts),
'label' => __('Row layout', 'ai-eshop-optimizer'),
),
'local' => array('form' => true, 'prefix' => 'aieo_rl_'),
)
);
?>
array(__('Only multi-select these categories', 'ai-eshop-optimizer'), __('Leave empty to apply to every category.', 'ai-eshop-optimizer')),
'grid_style_categories' => array(__('Grid-style categories', 'ai-eshop-optimizer'), ''),
'dropdown_style_categories' => array(__('Dropdown-style categories', 'ai-eshop-optimizer'), ''),
'quantity_selector_categories' => array(__('Dropdown + qty categories', 'ai-eshop-optimizer'), __('Subset of dropdown-style categories where the row includes a quantity input.', 'ai-eshop-optimizer')),
);
foreach ($aieo_sw_cats as $aieo_sw_name => $aieo_sw_cat) {
echo $aieo_sw_row($aieo_sw_id($aieo_sw_name), $aieo_sw_cat[0], \Rooster\Admin\Ui::select($aieo_sw_name . '[]', array(), '', array('id' => $aieo_sw_id($aieo_sw_name), 'medium' => true, 'attrs' => array('multiple' => true, 'data-aieo-sw-cats' => '', 'data-selected' => (string) wp_json_encode($settings[$aieo_sw_name] ?? array())))), $aieo_sw_cat[1]);
}
?>
array(__('Border (default)', 'ai-eshop-optimizer'), 1, '#dedede'), '_hover' => array(__('Border (hover)', 'ai-eshop-optimizer'), 2, '#212121'), '_selected' => array(__('Border (selected)', 'ai-eshop-optimizer'), 2, '#212121')) as $aieo_sw_state => $aieo_sw_b) {
echo $aieo_sw_cols(
$aieo_sw_id('color_border' . $aieo_sw_state) . '-row',
$aieo_sw_b[0],
array(array(__('Size', 'ai-eshop-optimizer'), $aieo_sw_num('color_border_size' . $aieo_sw_state, $aieo_sw_b[1])), array(__('Colour', 'ai-eshop-optimizer'), $aieo_sw_color('color_border_color' . $aieo_sw_state, $aieo_sw_b[2], $aieo_sw_b[0]))),
array(array(__('Size', 'ai-eshop-optimizer'), $aieo_sw_num('color_border_size' . $aieo_sw_state . '_shop_archive', $aieo_sw_b[1])), array(__('Colour', 'ai-eshop-optimizer'), $aieo_sw_color('color_border_color' . $aieo_sw_state . '_shop_archive', $aieo_sw_b[2], $aieo_sw_b[0])))
);
}
echo \Rooster\Admin\Ui::field_row(array(
'id' => 'aieo-sw-color-swatch-limit',
'label' => __('Swatch limit (desktop / mobile)', 'ai-eshop-optimizer'),
'help' => __('Archive-only cap. 0 = unlimited.', 'ai-eshop-optimizer'),
'parts' => array(
array('label' => __('Desktop', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('color_swatch_limit_desktop'), 'control' => $aieo_sw_num('color_swatch_limit_desktop', 5, array('min' => '1', 'max' => '20', 'unit' => ''))),
array('label' => __('Mobile', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('color_swatch_limit_mobile'), 'control' => $aieo_sw_num('color_swatch_limit_mobile', 3, array('min' => '1', 'max' => '20', 'unit' => ''))),
),
));
?>
_x('default', 'a swatch state', 'ai-eshop-optimizer'), '_hover' => _x('hover', 'a swatch state', 'ai-eshop-optimizer'), '_selected' => _x('selected', 'a swatch state', 'ai-eshop-optimizer')) as $aieo_sw_state => $aieo_sw_state_label) {
$out[] = array($aieo_sw_state_label, $aieo_sw_color($base . $aieo_sw_state . $suffix, $defaults[count($out)], $row));
}
return $out;
};
foreach (array(
'button_text_color' => array(__('Text colour (default / hover / selected)', 'ai-eshop-optimizer'), array('#212121', '#ffffff', '#ffffff')),
'button_bg_color' => array(__('Background (default / hover / selected)', 'ai-eshop-optimizer'), array('#ffffff', '#212121', '#212121')),
'button_border_color' => array(__('Border colour (default / hover / selected)', 'ai-eshop-optimizer'), array('#212121', '#212121', '#212121')),
) as $aieo_sw_base => $aieo_sw_c) {
echo $aieo_sw_cols($aieo_sw_id($aieo_sw_base) . '-row', $aieo_sw_c[0], $aieo_sw_three($aieo_sw_base, $aieo_sw_c[1], '', $aieo_sw_c[0]), $aieo_sw_three($aieo_sw_base, $aieo_sw_c[1], '_shop_archive', $aieo_sw_c[0]));
}
$aieo_sw_l = __('Border size / radius', 'ai-eshop-optimizer');
echo $aieo_sw_cols(
'aieo-sw-button-border-row',
$aieo_sw_l,
array(array(__('Size', 'ai-eshop-optimizer'), $aieo_sw_num('button_border_size', 1)), array(__('Radius', 'ai-eshop-optimizer'), $aieo_sw_num('button_border_radius', 5))),
array(array(__('Size', 'ai-eshop-optimizer'), $aieo_sw_num('button_border_size_shop_archive', 1)), array(__('Radius', 'ai-eshop-optimizer'), $aieo_sw_num('button_border_radius_shop_archive', 5)))
);
$aieo_sw_l = __('Padding (top / right / bottom / left)', 'ai-eshop-optimizer');
$aieo_sw_pads = static function ($suffix, array $defaults) use ($aieo_sw_num, $aieo_sw_sides) {
$out = array();
foreach ($aieo_sw_sides as $aieo_sw_side => $aieo_sw_side_label) {
$out[] = array($aieo_sw_side_label, $aieo_sw_num('button_padding_' . $aieo_sw_side . $suffix, $defaults[$aieo_sw_side], array('unit' => '')));
}
return $out;
};
echo $aieo_sw_cols(
'aieo-sw-button-padding-row',
$aieo_sw_l,
$aieo_sw_pads('', array('top' => 8, 'right' => 12, 'bottom' => 8, 'left' => 12)),
$aieo_sw_pads('_shop_archive', array('top' => 6, 'right' => 10, 'bottom' => 6, 'left' => 10))
)
. $aieo_sw_pair('button_gap', __('Gap between swatches', 'ai-eshop-optimizer'), 8, 6);
$aieo_sw_parts = array();
foreach (array('top' => 4, 'right' => 8, 'bottom' => 4, 'left' => 8) as $aieo_sw_side => $aieo_sw_default) {
$aieo_sw_parts[] = array('label' => $aieo_sw_sides[$aieo_sw_side], 'id' => $aieo_sw_id('button_padding_' . $aieo_sw_side . '_mobile'), 'control' => $aieo_sw_num('button_padding_' . $aieo_sw_side . '_mobile', $aieo_sw_default));
}
$aieo_sw_parts[] = array('label' => __('Font size', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('button_font_size_mobile'), 'control' => $aieo_sw_num('button_font_size_mobile', 11, array('min' => '6', 'max' => '20')));
echo \Rooster\Admin\Ui::field_row(array(
'id' => 'aieo-sw-button-mobile-padding',
'label' => __('Mobile padding override (top / right / bottom / left)', 'ai-eshop-optimizer'),
'help' => __('Padding + font-size applied via @media (max-width: 600px) — keeps button labels like "200ml" readable on small thumbnails.', 'ai-eshop-optimizer'),
'parts' => $aieo_sw_parts,
))
. $aieo_sw_row('aieo-sw-button-stack-vertical-archive', __('Stack vertically on archive cards', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('button_stack_vertical_archive', (bool) (!empty($settings['button_stack_vertical_archive'])), array('value' => '1', 'id' => 'aieo-sw-button-stack-vertical-archive', 'label' => __('Render button swatches as a vertical column on the left side of the archive card (matches the image-swatch layout).', 'ai-eshop-optimizer'))))
. $aieo_sw_row('aieo-sw-button-circle-archive', __('Circular buttons on archive', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::toggle('button_circle_archive', (bool) (!empty($settings['button_circle_archive'])), array('value' => '1', 'id' => 'aieo-sw-button-circle-archive', 'label' => __('Render archive button swatches as fixed-size circles (e.g. "100ml" inside a 36px disc, matching the wishlist heart visual).', 'ai-eshop-optimizer'))))
. \Rooster\Admin\Ui::field_row(array(
'id' => 'aieo-sw-button-circle-size',
'label' => __('Circle size on archive', 'ai-eshop-optimizer'),
'help' => __('Diameter applies to width AND height. Font-size scales the label. Long labels (e.g. "1000ml") may need a larger diameter or a smaller font.', 'ai-eshop-optimizer'),
'parts' => array(
array('label' => __('Diameter', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('button_circle_diameter_archive'), 'control' => $aieo_sw_num('button_circle_diameter_archive', 36, array('min' => '20', 'max' => '80'))),
array('label' => __('Font size', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('button_font_size_shop_archive'), 'control' => $aieo_sw_num('button_font_size_shop_archive', 11, array('min' => '6', 'max' => '20'))),
),
))
. \Rooster\Admin\Ui::field_row(array(
'id' => 'aieo-sw-button-swatch-limit',
'label' => __('Swatch limit (desktop / mobile)', 'ai-eshop-optimizer'),
'help' => __('Archive-only cap.', 'ai-eshop-optimizer'),
'parts' => array(
array('label' => __('Desktop', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('button_swatch_limit_desktop'), 'control' => $aieo_sw_num('button_swatch_limit_desktop', 5, array('min' => '1', 'max' => '20', 'unit' => ''))),
array('label' => __('Mobile', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('button_swatch_limit_mobile'), 'control' => $aieo_sw_num('button_swatch_limit_mobile', 3, array('min' => '1', 'max' => '20', 'unit' => ''))),
),
));
?>
array(__('Width (desktop / mobile)', 'ai-eshop-optimizer'), 40, 32, 26, 22), 'image_height' => array(__('Height (desktop / mobile)', 'ai-eshop-optimizer'), 40, 32, 26, 22)) as $aieo_sw_key => $aieo_sw_w) {
echo $aieo_sw_cols($aieo_sw_id($aieo_sw_key) . '-row', $aieo_sw_w[0], $aieo_sw_dm($aieo_sw_key, $aieo_sw_w[1], $aieo_sw_w[2]), $aieo_sw_dm($aieo_sw_key . '_shop_archive', $aieo_sw_w[3], $aieo_sw_w[4]));
}
echo $aieo_sw_pair('image_gap', __('Gap', 'ai-eshop-optimizer'), 8, 6)
. $aieo_sw_pair('image_border_radius', __('Border radius', 'ai-eshop-optimizer'), 0, 0);
foreach (array('' => array(__('Border (default)', 'ai-eshop-optimizer'), 1, '#dedede'), '_hover' => array(__('Border (hover)', 'ai-eshop-optimizer'), 2, '#212121'), '_selected' => array(__('Border (selected)', 'ai-eshop-optimizer'), 2, '#212121')) as $aieo_sw_state => $aieo_sw_b) {
echo $aieo_sw_cols(
$aieo_sw_id('image_border' . $aieo_sw_state) . '-row',
$aieo_sw_b[0],
array(array(__('Size', 'ai-eshop-optimizer'), $aieo_sw_num('image_border_size' . $aieo_sw_state, $aieo_sw_b[1])), array(__('Colour', 'ai-eshop-optimizer'), $aieo_sw_color('image_border_color' . $aieo_sw_state, $aieo_sw_b[2], $aieo_sw_b[0]))),
array(array(__('Size', 'ai-eshop-optimizer'), $aieo_sw_num('image_border_size' . $aieo_sw_state . '_shop_archive', $aieo_sw_b[1])), array(__('Colour', 'ai-eshop-optimizer'), $aieo_sw_color('image_border_color' . $aieo_sw_state . '_shop_archive', $aieo_sw_b[2], $aieo_sw_b[0])))
);
}
echo $aieo_sw_row('aieo-sw-image-loading-strategy', __('Loading strategy', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::select('image_loading_strategy', array(
'lazy' => __('Lazy (default)', 'ai-eshop-optimizer'),
'eager' => __('Eager', 'ai-eshop-optimizer'),
'auto' => __('Auto', 'ai-eshop-optimizer'),
), (string) ($settings['image_loading_strategy'] ?? 'lazy'), array('id' => 'aieo-sw-image-loading-strategy')))
. \Rooster\Admin\Ui::field_row(array(
'id' => 'aieo-sw-image-swatch-limit',
'label' => __('Swatch limit (desktop / mobile)', 'ai-eshop-optimizer'),
'help' => __('Archive-only cap. Also controls the archive cache row size.', 'ai-eshop-optimizer'),
'parts' => array(
array('label' => __('Desktop', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('image_swatch_limit_desktop'), 'control' => $aieo_sw_num('image_swatch_limit_desktop', 5, array('min' => '1', 'max' => '20', 'unit' => ''))),
array('label' => __('Mobile', 'ai-eshop-optimizer'), 'id' => $aieo_sw_id('image_swatch_limit_mobile'), 'control' => $aieo_sw_num('image_swatch_limit_mobile', 3, array('min' => '1', 'max' => '20', 'unit' => ''))),
),
));
?>
'refresh-cw', 'attrs' => array('id' => 'aieo-sw-regen-sizes'))); ?>
__('Extra swatch with “+N more” badge', 'ai-eshop-optimizer'),
'text_only' => __('Plain text link', 'ai-eshop-optimizer'),
'both' => __('Both swatch + text link', 'ai-eshop-optimizer'),
), (string) ($settings['see_all_display_mode'] ?? 'swatches_only'), array('id' => 'aieo-sw-see-all-display-mode')))
. $aieo_sw_row('aieo-sw-see-all-text', __('Trigger text', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::input('see_all_text', (string) ($settings['see_all_text'] ?? 'See all {count} variations'), array('id' => 'aieo-sw-see-all-text', 'medium' => true)), __('Use {count} as a placeholder for the total variation count.', 'ai-eshop-optimizer'))
. $aieo_sw_row('aieo-sw-see-all-modal-title', __('Modal title', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::input('see_all_modal_title', (string) ($settings['see_all_modal_title'] ?? 'All Variations'), array('id' => 'aieo-sw-see-all-modal-title', 'medium' => true)))
. $aieo_sw_row('aieo-sw-see-all-view-product-text', __('“View product page” link text', 'ai-eshop-optimizer'), \Rooster\Admin\Ui::input('see_all_view_product_text', (string) ($settings['see_all_view_product_text'] ?? 'View product page'), array('id' => 'aieo-sw-see-all-view-product-text', 'medium' => true)));
?>