get_results( "SELECT attribute_name, attribute_type FROM {$wpdb->prefix}woocommerce_attribute_taxonomies", ARRAY_A ); foreach ( (array) $aieo_tc_rows as $aieo_tc_row ) { $aieo_tc_raw_types[ 'pa_' . (string) $aieo_tc_row['attribute_name'] ] = (string) $aieo_tc_row['attribute_type']; } foreach ( $aieo_tc_map as $aieo_tc_k => $aieo_tc_v ) { if ( isset( $aieo_tc_raw_types[ $aieo_tc_k ] ) && $aieo_tc_raw_types[ $aieo_tc_k ] !== $aieo_tc_v ) { $aieo_tc_diff_count++; } } } ?> 'theme-compat-detected', 'icon' => 'search', 'title' => __( 'Detected theme', 'ai-eshop-optimizer' ), 'description' => __( 'Many themes render their own variation swatches, product cards and carousels. Where they do, both they and Rooster One hook the same WooCommerce places, and only one can win. This screen is where you decide which.', 'ai-eshop-optimizer' ), ) ); echo $aieo_tc_c1_open; ?> 'theme', 'label' => __( 'Active theme', 'ai-eshop-optimizer' ), 'value' => $aieo_tc_status['theme'], 'note' => $aieo_tc_status['theme_version'], ), ); if ( ! empty( $aieo_tc_status['generic'] ) ) { $aieo_tc_detected[] = array( 'id' => 'adapter', 'label' => __( 'Adapter', 'ai-eshop-optimizer' ), 'value' => __( 'No bundled adapter for this theme.', 'ai-eshop-optimizer' ), 'note' => __( 'That is not a problem on its own. An adapter only adds knowledge of where this particular theme hooks, so we can stand it down cleanly. Without one you can still switch a surface to Rooster One, and if the theme keeps drawing its own version as well you will see both, which is the sign an adapter is needed.', 'ai-eshop-optimizer' ), ); } else { $aieo_tc_detected[] = array( 'id' => 'adapter', 'label' => __( 'Adapter', 'ai-eshop-optimizer' ), 'value' => $aieo_tc_status['adapter_label'], 'note' => ( '' !== $aieo_tc_status['verified_against'] ) ? sprintf( __( 'verified against %s', 'ai-eshop-optimizer' ), $aieo_tc_status['verified_against'] ) : '', ); } $aieo_tc_facts = array(); foreach ( $aieo_tc_detected as $aieo_tc_row ) { $aieo_tc_facts[] = array( 'label' => $aieo_tc_row['label'], 'html' => esc_html( (string) $aieo_tc_row['value'] ) . ( '' !== (string) $aieo_tc_row['note'] ? '
' . esc_html( (string) $aieo_tc_row['note'] ) . '' : '' ), ); } echo \Rooster\Admin\Ui::facts( $aieo_tc_facts ); echo $aieo_tc_c1_close; ?> 'theme-compat-surfaces', 'flush' => true, 'icon' => 'layout-template', 'title' => __( 'What Rooster One takes over', 'ai-eshop-optimizer' ), 'description' => __( 'Each surface is independent. Leaving one with the theme does not affect the others.', 'ai-eshop-optimizer' ), ) ); echo $aieo_tc_c2_open; ?> $aieo_tc_surface ) { $aieo_tc_mode = AIEO_Theme_Adapters::mode( $aieo_tc_id ); $aieo_tc_known = (bool) AIEO_Theme_Adapters::adapter_surface( $aieo_tc_id ); if ( AIEO_Theme_Adapters::overrides_theme( $aieo_tc_id ) ) { $aieo_tc_state = $aieo_tc_known ? __( 'Rooster One renders this, and the theme has been stood down.', 'ai-eshop-optimizer' ) : __( 'Rooster One renders this. No adapter for this theme, so if the theme also draws its own you may see both.', 'ai-eshop-optimizer' ); } elseif ( '' === $aieo_tc_mode ) { $aieo_tc_state = __( 'Not decided. The theme keeps control, exactly as it behaves today.', 'ai-eshop-optimizer' ); } else { $aieo_tc_state = __( 'Left to the theme, by choice.', 'ai-eshop-optimizer' ); } $aieo_tc_surface_rows[] = array( 'id' => $aieo_tc_id, 'label' => $aieo_tc_surface['label'], 'summary' => isset( $aieo_tc_surface['summary'] ) ? $aieo_tc_surface['summary'] : '', 'modes' => isset( $aieo_tc_surface['modes'] ) ? (array) $aieo_tc_surface['modes'] : array(), 'mode' => $aieo_tc_mode, 'state' => $aieo_tc_state, ); } AIEO_Table::render( array( 'caption' => __( 'What Rooster One takes over', 'ai-eshop-optimizer' ), 'id' => 'aieo-theme-compat-surfaces', 'columns' => array( array( 'key' => 'label', 'label' => __( 'Surface', 'ai-eshop-optimizer' ), 'type' => 'text', 'subline' => 'summary', 'width' => '30%', ), array( 'key' => 'mode', 'label' => __( 'Who renders it', 'ai-eshop-optimizer' ), 'type' => 'control', 'width' => '34%', 'format' => array( 'render' => function ( $row ) { return \Rooster\Admin\Ui::select( '', array_map( 'strval', (array) $row['modes'] ), (string) $row['mode'], array( 'id' => 'aieo-theme-compat-mode-' . $row['id'], 'aria-label' => sprintf( __( 'Who renders %s', 'ai-eshop-optimizer' ), $row['label'] ), 'attrs' => array( 'data-surface' => $row['id'] ), ) ) . ''; }, ), ), array( 'key' => 'state', 'label' => __( 'Status', 'ai-eshop-optimizer' ), 'type' => 'text', ), ), 'rows' => $aieo_tc_surface_rows, 'row_key' => 'id', 'row_data' => array( 'surface' => 'id' ), 'page_id' => 'theme_compat', ) ); echo $aieo_tc_c2_close; ?> 'theme-compat-blocks-own', 'icon' => 'pencil-line', 'title' => __( 'Block settings in the editor', 'ai-eshop-optimizer' ), 'description' => __( 'Rooster One keeps its product cards and other blocks the same everywhere. Turn this on to let the settings you give a block in the editor, its spacing, sizes and picture fit, win over Rooster One\'s.', 'ai-eshop-optimizer' ), ) ); echo $aieo_tc_c5_open; echo '
'; if ( $aieo_tc_ours ) { echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-blocks-own-theme', 'group' => true, 'label' => __( 'Your block settings win', 'ai-eshop-optimizer' ), 'control' => '' . esc_html( $aieo_tc_own ? _x( 'On', 'block settings in the editor: the state', 'ai-eshop-optimizer' ) : _x( 'Off', 'block settings in the editor: the state', 'ai-eshop-optimizer' ) ) . '', 'help' => __( 'On Rooster Zero this is the theme\'s own Design setting, «Block settings in the editor»: change it there, and Rooster One follows.', 'ai-eshop-optimizer' ), ) ); } else { echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-blocks-own-toggle', 'label' => __( 'Your block settings win', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::toggle( '', $aieo_tc_own, array( 'id' => 'aieo-blocks-own-toggle', 'label' => __( 'Let the settings I give a block win', 'ai-eshop-optimizer' ), ) ) . '', 'help' => __( 'Off: Rooster One\'s cards look the same on every page, whatever a block was given. On: a block\'s own spacing, sizes and picture fit show as you set them.', 'ai-eshop-optimizer' ), ) ); } echo '
'; echo $aieo_tc_c5_close; ?> 'theme-compat-plugins', 'icon' => 'puzzle', 'title' => __( 'Recognised plugins', 'ai-eshop-optimizer' ), 'description' => __( 'Plugins Rooster One knows and works with. Where one is active, Rooster One uses it without anything to set; turn it off here to keep the theme\'s own.', 'ai-eshop-optimizer' ), ) ); echo $aieo_tc_c4_open; $aieo_tc_active = array_filter( $aieo_tc_plugins, static function ( $p ) { return ! empty( $p['active'] ); } ); if ( array() === $aieo_tc_active ) { echo \Rooster\Admin\Ui::empty_state( __( 'No recognised plugin is active', 'ai-eshop-optimizer' ), sprintf( __( 'Rooster One recognises %s. None of them is active on this site.', 'ai-eshop-optimizer' ), implode( ', ', array_map( 'strval', wp_list_pluck( $aieo_tc_plugins, 'name' ) ) ) ), array( 'icon' => 'puzzle', 'compact' => true ) ); } else { echo '
'; foreach ( $aieo_tc_active as $aieo_tc_pid => $aieo_tc_plugin ) { $aieo_tc_field = 'aieo-recognised-' . sanitize_key( (string) $aieo_tc_pid ); echo \Rooster\Admin\Ui::field_row( array( 'id' => $aieo_tc_field, 'label' => trim( $aieo_tc_plugin['name'] . ' ' . $aieo_tc_plugin['edition'] . ' ' . $aieo_tc_plugin['version'] ), 'control' => \Rooster\Admin\Ui::toggle( '', ! empty( $aieo_tc_plugin['on'] ), array( 'id' => $aieo_tc_field, 'label' => (string) $aieo_tc_plugin['switch'], 'attrs' => array( 'data-plugin' => (string) $aieo_tc_pid ), ) ) . '', 'help' => (string) $aieo_tc_plugin['help'], ) ); foreach ( (array) ( $aieo_tc_plugin['choices'] ?? array() ) as $aieo_tc_cid => $aieo_tc_choice ) { $aieo_tc_cfield = $aieo_tc_field . '-' . sanitize_key( (string) $aieo_tc_cid ); echo \Rooster\Admin\Ui::field_row( array( 'id' => $aieo_tc_cfield, 'label' => (string) $aieo_tc_choice['label'], 'control' => \Rooster\Admin\Ui::select( '', (array) $aieo_tc_choice['options'], (string) ( $aieo_tc_choice['value'] ?? '' ), array( 'id' => $aieo_tc_cfield, 'attrs' => array( 'data-plugin' => (string) $aieo_tc_pid, 'data-choice' => (string) $aieo_tc_cid, ), ) ) . '', 'help' => (string) ( $aieo_tc_choice['help'] ?? '' ), ) ); } } echo '
'; } echo $aieo_tc_c4_close; if ( class_exists( 'AIEO_Site_Address' ) ) { list( $aieo_tc_c5_open, $aieo_tc_c5_close ) = AIEO_DMM_UI::card( array( 'anchor' => 'theme-compat-address', 'icon' => 'refresh-cw', 'title' => __( "The site's address", 'ai-eshop-optimizer' ), 'description' => __( "Rooster One builds some files from the site's address: the mega menu, the sitemaps, the admin search and the theme's page styles. When the site moves to another address, a copy restored on the live domain for instance, they are rebuilt and the caches emptied the first time an administrator opens the dashboard. Rebuild them here at any time.", 'ai-eshop-optimizer' ), 'footer' => \Rooster\Admin\Ui::button( __( 'Rebuild them now', 'ai-eshop-optimizer' ), array( 'type' => 'submit', 'variant' => 'primary', 'icon' => 'refresh-cw', 'attrs' => array( 'form' => 'aieo-site-address-form' ) ) ), ) ); echo $aieo_tc_c5_open; $aieo_tc_built = AIEO_Site_Address::built_for(); echo '
'; echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-site-address-built', 'label' => __( 'Built for', 'ai-eshop-optimizer' ), 'control' => '' . esc_html( '' !== $aieo_tc_built ? $aieo_tc_built : AIEO_Site_Address::home() ) . '', ) ); echo ''; wp_nonce_field( AIEO_Site_Address::ACTION ); echo '
'; echo $aieo_tc_c5_close; } ?> 'theme-compat-attribute-types', 'icon' => 'shapes', 'title' => __( 'Attribute types', 'ai-eshop-optimizer' ), 'description' => __( 'Every swatch plugin invents its own name for what an attribute is, so a theme may call a colour picker something we do not recognise. This runs once, works out what each attribute actually is from your own data, and saves the answer. It is not repeated when a page loads.', 'ai-eshop-optimizer' ), ) ); echo $aieo_tc_c3_open; ?> 'aieo-theme-compat-job', 'state' => $aieo_tc_map ? 'idle' : 'not-run', 'run' => __( 'Detect attribute types', 'ai-eshop-optimizer' ), 'run_attrs' => array( 'id' => 'aieo-theme-compat-detect', 'data-surface' => 'swatches', ), 'primary' => false, 'result' => $aieo_tc_map ? sprintf( __( '%d attributes mapped.', 'ai-eshop-optimizer' ), count( $aieo_tc_map ) ) : '', ) ); echo $aieo_tc_job; ?>

$aieo_tc_type ) { $aieo_tc_raw = isset( $aieo_tc_raw_types[ $aieo_tc_tax ] ) ? $aieo_tc_raw_types[ $aieo_tc_tax ] : ''; $aieo_tc_diff = ( '' !== $aieo_tc_raw && $aieo_tc_raw !== $aieo_tc_type ); $aieo_tc_type_rows[] = array( 'tax' => (string) $aieo_tc_tax, 'raw' => $aieo_tc_raw, 'resolved' => (string) $aieo_tc_type, 'diff' => $aieo_tc_diff, 'reason' => $aieo_tc_diff ? __( 'The theme uses its own name for this, so we translate it.', 'ai-eshop-optimizer' ) : __( 'Already one of our own types.', 'ai-eshop-optimizer' ), ); } AIEO_Table::card( array( 'wrap' => false, 'page_id' => 'theme_compat', 'row_key' => 'tax', 'rows' => $aieo_tc_type_rows, 'id' => 'aieo-theme-compat-types', 'empty' => __( 'Run the detection above to fill this in.', 'ai-eshop-optimizer' ), 'row_class' => static function ( $r ) { return ! empty( $r['diff'] ) ? 'aieo-tc-diff aieo-t-row--warning' : ''; }, 'filters' => $aieo_tc_map ? array( array( 'key' => 'diff', 'label' => __( 'Named differently by the theme', 'ai-eshop-optimizer' ), 'kind' => 'boolean', 'control' => 'segmented' ), ) : array(), 'columns' => array( array( 'key' => 'tax', 'label' => __( 'Attribute', 'ai-eshop-optimizer' ), 'type' => 'code', 'width' => '30%' ), array( 'key' => 'raw', 'label' => __( 'Theme calls it', 'ai-eshop-optimizer' ), 'width' => '15%' ), array( 'key' => 'resolved', 'label' => __( 'We render it as', 'ai-eshop-optimizer' ), 'width' => '15%' ), array( 'key' => 'reason', 'label' => __( 'Why', 'ai-eshop-optimizer' ), 'sortable' => false, 'tone' => 'secondary' ), ), ) ); echo $aieo_tc_c3_close; ?>