controls['style'] = array( 'tab' => 'content', 'label' => esc_html__( 'Display Style', 'ai-discoverability-kit' ), 'type' => 'select', 'options' => array( 'badge' => esc_html__( 'Badge (Circle)', 'ai-discoverability-kit' ), 'bar' => esc_html__( 'Progress Bar', 'ai-discoverability-kit' ), 'minimal' => esc_html__( 'Minimal (Number)', 'ai-discoverability-kit' ), ), 'default' => 'badge', ); $this->controls['show_label'] = array( 'tab' => 'content', 'label' => esc_html__( 'Show Label', 'ai-discoverability-kit' ), 'type' => 'checkbox', 'default' => true, ); $this->controls['primary_color'] = array( 'tab' => 'content', 'label' => esc_html__( 'Primary Color', 'ai-discoverability-kit' ), 'type' => 'color', 'default' => array( 'hex' => '#00e58a' ), ); } /** * Render the element output. * * @return void */ public function render(): void { $product_id = get_the_ID(); if ( ! function_exists( 'wc_get_product' ) ) { return; } $product = wc_get_product( $product_id ); if ( ! $product || ! $product->is_type( array( 'simple', 'variable', 'grouped', 'external' ) ) ) { return; } $readiness = new \AICommerce\Analytics\ReadinessScore( new \AICommerce\Schema\ProductSchema(), new \AICommerce\Schema\Validator() ); $result = $readiness->calculate_and_cache( $product ); $score = (int) ( $result['overall'] ?? 0 ); $style = $this->settings['style'] ?? 'badge'; $show_label = $this->settings['show_label'] ?? true; $color = $this->settings['primary_color']['hex'] ?? '#00e58a'; if ( function_exists( 'aicommerce_render_score_badge' ) ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper already escapes. echo aicommerce_render_score_badge( $score, $style, (bool) $show_label, $color ); } } }