__CLASS__, 'attributes' => $attributes, 'block_ids' => self::$block_ids, ] ); // Add default ARIA labels if not present using WP HTML Tag Processor // Only available in WordPress 6.2+, skip for older versions. if ( class_exists( 'WP_HTML_Tag_Processor' ) ) { $control_type = $attributes['controlType'] ?? 'next'; $has_aria_label = isset( $attributes['htmlAttributes']['aria-label'] ) && ! empty( $attributes['htmlAttributes']['aria-label'] ); $processor = new \WP_HTML_Tag_Processor( $block_content ); // Find the first tag (the button/control element). if ( $processor->next_tag() ) { // Add default ARIA label if not present. if ( ! $has_aria_label && ! $processor->get_attribute( 'aria-label' ) ) { // Map control types to default ARIA labels. $default_labels = [ 'next' => __( 'Next slide', 'generateblocks-pro' ), 'previous' => __( 'Previous slide', 'generateblocks-pro' ), 'play' => __( 'Play carousel', 'generateblocks-pro' ), 'pause' => __( 'Pause carousel', 'generateblocks-pro' ), 'play-pause' => __( 'Toggle carousel playback', 'generateblocks-pro' ), 'first' => __( 'Go to first slide', 'generateblocks-pro' ), 'last' => __( 'Go to last slide', 'generateblocks-pro' ), ]; $aria_label = $default_labels[ $control_type ] ?? __( 'Carousel control', 'generateblocks-pro' ); $processor->set_attribute( 'aria-label', $aria_label ); } // For play-pause controls, ensure aria-pressed attribute exists. if ( 'play-pause' === $control_type && ! $processor->get_attribute( 'aria-pressed' ) ) { $processor->set_attribute( 'aria-pressed', 'false' ); } $block_content = $processor->get_updated_html(); } } return $block_content; } }