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 '
$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; ?>