$aieo_pnd_id( $name ), 'label' => $label, 'control' => $control );
if ( '' !== $help ) {
$row['help'] = $help;
}
return \Rooster\Admin\Ui::field_row( $row );
};
$aieo_pnd_choice = static function ( $name, $label, $options, $value, $help = '' ) use ( $aieo_pnd_row, $aieo_pnd_id ) {
return $aieo_pnd_row( $name, $label, \Rooster\Admin\Fields::segmented( $name, $options, (string) $value, array( 'id' => $aieo_pnd_id( $name ), 'labelledby' => $aieo_pnd_id( $name ) . '-label' ) ), $help, array( 'group' => true ) );
};
$aieo_pnd_switch = static function ( $name, $on, $text ) use ( $aieo_pnd_id ) {
return \Rooster\Admin\Ui::toggle( $name, (bool) $on, array( 'id' => $aieo_pnd_id( $name ), 'hidden' => false, 'label' => $text ) );
};
$aieo_pnd_px = static function ( $name, $value, $min, $max ) use ( $aieo_pnd_id ) {
return \Rooster\Admin\Ui::input( $name, (string) (int) $value, array( 'id' => $aieo_pnd_id( $name ), 'type' => 'number', 'xs' => true, 'unit' => 'px', 'min' => $min, 'max' => $max ) );
};
$aieo_pnd_colour = static function ( $name, $value, $fallback ) use ( $aieo_pnd_id ) {
return \Rooster\Admin\Fields::color( $name, (string) $value, array( 'id' => $aieo_pnd_id( $name ), 'default' => $fallback ) );
};
$aieo_pnd_card = static function ( $card, $before, $rows, $after = '' ) {
$form_id = 'aieo-card-' . $card['anchor'] . '-form';
list( $open, $close ) = AIEO_DMM_UI::card( $card + array( 'footer' => \Rooster\Admin\States::save_button( $form_id ) ) );
echo $open;
echo AIEO_DMM_UI::card_form( 'aieo_dmm_needs_save_display', 'product_needs_display', $form_id, $before . '
' . $rows . '
' . $after );
echo $close;
};
if ( function_exists( 'rooster_admin_band_open' ) ) {
rooster_admin_band_open( array( 'cols' => 2 ) );
}
$aieo_pnd_rows = $aieo_pnd_row( 'enabled', __( 'Render front-end list', 'ai-eshop-optimizer' ), $aieo_pnd_switch( 'enabled', ! empty( $display['enabled'] ), __( 'Render the Rooster One product-needs list on single product pages. This is the SAME switch as the “Product Needs” toggle in the Frontend dashboard.', 'ai-eshop-optimizer' ) ) );
$aieo_pnd_rows .= $aieo_pnd_choice(
'display_location',
__( 'Location', 'ai-eshop-optimizer' ),
array(
'summary' => __( 'Product summary (after Add to Cart)', 'ai-eshop-optimizer' ),
'tab' => __( 'As a product tab', 'ai-eshop-optimizer' ),
),
$display['display_location']
);
$aieo_pnd_card(
array(
'anchor' => 'product-needs-display-front-end-gate',
'icon' => 'door-open',
'title' => __( 'Enable and place product needs', 'ai-eshop-optimizer' ),
'description' => __( 'Turns the Rooster One needs list on for single product pages (the same switch as the Product Needs toggle in Frontend) and places it after Add to Cart or in its own tab.', 'ai-eshop-optimizer' ),
'col' => 1,
),
\Rooster\Admin\Guidance::text( __( 'When the front-end gate is OFF, PPE\'s Product Needs module renders. When it\'s ON, Rooster One renders the list using the styling below — disable PPE\'s Product Needs module then to avoid duplicate output.', 'ai-eshop-optimizer' ) ),
$aieo_pnd_rows
);
$aieo_pnd_rows = $aieo_pnd_row( 'title', __( 'List title (summary mode)', 'ai-eshop-optimizer' ), \Rooster\Admin\Ui::input( 'title', (string) $display['title'], array( 'id' => $aieo_pnd_id( 'title' ), 'medium' => true ) ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'show_title', __( 'Show title', 'ai-eshop-optimizer' ), $aieo_pnd_switch( 'show_title', ! empty( $display['show_title'] ), __( 'Display the list title above the needs (summary mode).', 'ai-eshop-optimizer' ) ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'tab_title', __( 'Tab title', 'ai-eshop-optimizer' ), \Rooster\Admin\Ui::input( 'tab_title', (string) $display['tab_title'], array( 'id' => $aieo_pnd_id( 'tab_title' ), 'medium' => true ) ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'tab_priority', __( 'Tab priority', 'ai-eshop-optimizer' ), \Rooster\Admin\Ui::input( 'tab_priority', (string) (int) $display['tab_priority'], array( 'id' => $aieo_pnd_id( 'tab_priority' ), 'type' => 'number', 'xs' => true, 'min' => 1, 'max' => 999 ) ), __( 'Lower numbers appear earlier. WC defaults: Description=10, Additional Info=20, Reviews=30.', 'ai-eshop-optimizer' ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'show_links', __( 'Make needs clickable', 'ai-eshop-optimizer' ), $aieo_pnd_switch( 'show_links', 'yes' === $display['show_links'], __( 'Link each need to its taxonomy archive.', 'ai-eshop-optimizer' ) ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'show_descriptions', __( 'Show descriptions on hover', 'ai-eshop-optimizer' ), $aieo_pnd_switch( 'show_descriptions', 'yes' === $display['show_descriptions'], __( 'Use the term\'s description as a native browser tooltip.', 'ai-eshop-optimizer' ) ) );
$aieo_pnd_card(
array(
'anchor' => 'product-needs-display-text',
'icon' => 'text-cursor-input',
'title' => __( 'Needs list titles and links', 'ai-eshop-optimizer' ),
'description' => __( 'Sets the summary heading, the tab title and its priority (lower = earlier, WC uses 10/20/30), and whether needs link to their archive or show a hover tooltip.', 'ai-eshop-optimizer' ),
'col' => 1,
),
'',
$aieo_pnd_rows
);
$icon_kind = isset( $display['icon_kind'] ) ? (string) $display['icon_kind'] : 'check';
$icon_url = isset( $display['icon_url'] ) ? (string) $display['icon_url'] : '';
$icon_aid = isset( $display['icon_attachment_id'] ) ? (int) $display['icon_attachment_id'] : 0;
$aieo_pnd_icon = '';
$aieo_pnd_rows = $aieo_pnd_row(
'display_style',
__( 'List style', 'ai-eshop-optimizer' ),
\Rooster\Admin\Ui::select(
'display_style',
array(
'list' => __( 'List (stacked, one per line)', 'ai-eshop-optimizer' ),
'pills' => __( 'Pills (tag-style, side by side)', 'ai-eshop-optimizer' ),
),
(string) ( $display['display_style'] ?? 'list' ),
array( 'id' => 'aieo-pn-display-style' )
),
__( '“Pills” shows each need as a tag chip. Style the chips in the “Pill style” card below.', 'ai-eshop-optimizer' ),
array( 'id' => 'aieo-pn-display-style' )
);
$aieo_pnd_rows .= $aieo_pnd_choice(
'align',
__( 'Alignment', 'ai-eshop-optimizer' ),
array(
'flex-start' => __( 'Left', 'ai-eshop-optimizer' ),
'center' => __( 'Center', 'ai-eshop-optimizer' ),
'flex-end' => __( 'Right', 'ai-eshop-optimizer' ),
),
$display['align']
);
$aieo_pnd_rows .= $aieo_pnd_row(
'icon_kind',
__( 'Icon', 'ai-eshop-optimizer' ),
\Rooster\Admin\Fields::segmented(
'icon_kind',
array(
'check' => __( 'Default checkmark', 'ai-eshop-optimizer' ),
'custom' => __( 'Custom image', 'ai-eshop-optimizer' ),
'none' => __( 'No icon', 'ai-eshop-optimizer' ),
),
$icon_kind,
array( 'id' => $aieo_pnd_id( 'icon_kind' ), 'labelledby' => $aieo_pnd_id( 'icon_kind' ) . '-label' )
) . $aieo_pnd_icon,
'',
array( 'group' => true )
);
$aieo_pnd_rows .= $aieo_pnd_row( 'icon_color', __( 'Icon color (default checkmark)', 'ai-eshop-optimizer' ), $aieo_pnd_colour( 'icon_color', $display['icon_color'], '#27ae60' ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'text_color', __( 'Text color', 'ai-eshop-optimizer' ), $aieo_pnd_colour( 'text_color', $display['text_color'], '#333333' ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'link_color', __( 'Link color', 'ai-eshop-optimizer' ), $aieo_pnd_colour( 'link_color', $display['link_color'], '#0073aa' ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'bg_color', __( 'Background color', 'ai-eshop-optimizer' ), $aieo_pnd_colour( 'bg_color', $display['bg_color'], '#f8f9fa' ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'border_color', __( 'Border color', 'ai-eshop-optimizer' ), $aieo_pnd_colour( 'border_color', $display['border_color'], '#e9ecef' ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'border_width', __( 'Border width', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'border_width', $display['border_width'] ?? 1, 0, 20 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'border_radius', __( 'Border radius', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'border_radius', $display['border_radius'] ?? 0, 0, 100 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'margin_top', __( 'Margin top', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'margin_top', $display['margin_top'], 0, 200 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'margin_bottom', __( 'Margin bottom', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'margin_bottom', $display['margin_bottom'], 0, 200 ) );
$aieo_pnd_card(
array(
'anchor' => 'product-needs-display-appearance',
'icon' => 'palette',
'title' => __( 'Needs list style and colours', 'ai-eshop-optimizer' ),
'description' => __('Set how the needs list looks on product pages: its layout, colours and size.', 'ai-eshop-optimizer'),
'col' => 2,
),
'',
$aieo_pnd_rows
);
$aieo_pnd_rows = $aieo_pnd_row( 'pill_text_size', __( 'Text size', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'pill_text_size', $display['pill_text_size'] ?? 13, 8, 40 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'pill_radius', __( 'Corner radius', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'pill_radius', $display['pill_radius'] ?? 16, 0, 100 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'pill_pad_v', __( 'Vertical padding', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'pill_pad_v', $display['pill_pad_v'] ?? 6, 0, 60 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'pill_pad_h', __( 'Horizontal padding', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'pill_pad_h', $display['pill_pad_h'] ?? 12, 0, 80 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'pill_gap', __( 'Space between pills', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'pill_gap', $display['pill_gap'] ?? 8, 0, 60 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'pill_bg', __( 'Background color', 'ai-eshop-optimizer' ), $aieo_pnd_colour( 'pill_bg', $display['pill_bg'] ?? '#eef1f4', '#eef1f4' ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'pill_border_width', __( 'Border width', 'ai-eshop-optimizer' ), $aieo_pnd_px( 'pill_border_width', $display['pill_border_width'] ?? 1, 0, 20 ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'pill_border_color', __( 'Border color', 'ai-eshop-optimizer' ), $aieo_pnd_colour( 'pill_border_color', $display['pill_border_color'] ?? '#d6dbe1', '#d6dbe1' ) );
$aieo_pnd_rows .= $aieo_pnd_row( 'pill_text_color', __( 'Text color', 'ai-eshop-optimizer' ), $aieo_pnd_colour( 'pill_text_color', $display['pill_text_color'] ?? '#333333', '#333333' ) );
$aieo_pnd_card(
array(
'anchor' => 'product-needs-display-pill-style',
'icon' => 'stamp',
'title' => __( 'Pill style', 'ai-eshop-optimizer' ),
'description' => __( 'Applies when “List style” above is set to Pills.', 'ai-eshop-optimizer' ),
'col' => 1,
),
'',
$aieo_pnd_rows
);
if ( function_exists( 'rooster_admin_band_close' ) ) {
rooster_admin_band_close();
}
?>