a query. * @return array[] State style rules. */ function wp_get_block_state_style_rules( $state_styles, $block_type, $rules_group = null ) { $css_rules = array(); $block_selectors = isset( $block_type->selectors ) && is_array( $block_type->selectors ) ? $block_type->selectors : array(); foreach ( $state_styles as $state => $state_style ) { if ( empty( $state_style ) || ! is_array( $state_style ) ) { continue; } foreach ( wp_get_state_style_groups( $state_style, $block_selectors ) as $group ) { wp_add_block_state_style_rule( $css_rules, $state, $group['selector'], $group['style'], $rules_group ); } } return $css_rules; } /** * Returns a unique class for a set of state style rules. * * @since 7.1.0 * * @param string $block_name Block name. * @param array $css_rules State style rules. * @return string Unique class name. */ function wp_get_block_state_unique_class( $block_name, $css_rules ) { return 'wp-states-' . substr( md5( wp_json_encode( array( 'blockName' => $block_name, 'rules' => $css_rules, ) ) ), 0, 8 ); } /** * Splits a selector list by top-level commas. * * @since 7.1.0 * * @param string $selector CSS selector list. * @return string[] Selectors. */ function wp_split_selector_list( $selector ) { if ( ! str_contains( $selector, ',' ) ) { return array( $selector ); } $selectors = array(); $current_selector = ''; $parentheses_depth = 0; $selector_length = strlen( $selector ); for ( $i = 0; $i < $selector_length; $i++ ) { $char = $selector[ $i ]; if ( '(' === $char ) { ++$parentheses_depth; } elseif ( ')' === $char && $parentheses_depth > 0 ) { --$parentheses_depth; } elseif ( ',' === $char && 0 === $parentheses_depth ) { $selectors[] = $current_selector; $current_selector = ''; continue; } $current_selector .= $char; } $selectors[] = $current_selector; return $selectors; } /** * Builds a scoped selector from a block selector and optional pseudo-state. * * @since 7.1.0 * * @param string $base_selector Block-instance scoping selector. * @param string|null $block_selector Block or feature selector from metadata. * @param string $state Pseudo-state selector. * @return string Scoped selector. */ function wp_build_state_selector( $base_selector, $block_selector, $state ) { if ( ! is_string( $block_selector ) || '' === trim( $block_selector ) ) { return $base_selector . $state; } $selectors = wp_split_selector_list( $block_selector ); $scoped_selectors = array(); foreach ( $selectors as $selector ) { $selector = trim( $selector ); if ( '' === $selector ) { continue; } /* * Replace only the leading block selector part (e.g. class name, * attribute selector, ID, or tag name) with the block instance selector. * Preserve anything after that prefix, including modifier classes on the * same element and combinators without spaces. */ if ( preg_match( '/^([.#]?[-_a-zA-Z0-9]+|\[[^\]]+\])/', $selector, $matches ) ) { $scoped_selectors[] = $base_selector . substr( $selector, strlen( $matches[0] ) ) . $state; continue; } $scoped_selectors[] = $base_selector . $state; } return empty( $scoped_selectors ) ? $base_selector . $state : implode( ', ', $scoped_selectors ); } /** * Renders per-instance state styles on the frontend. * * @since 7.1.0 * * @param string $block_content The block's rendered HTML. * @param array $block The block data including blockName and attrs. * @return string Modified block content with injected state styles. */ function wp_render_block_states_support( $block_content, $block ) { if ( empty( $block['blockName'] ) || empty( $block_content ) ) { return $block_content; } /* * Every CSS rule this function can produce is keyed off the block's `style` * attribute. Without it there is nothing to generate, so bail before doing * any of the lookups below — this runs for every block on every request. */ $style = $block['attrs']['style'] ?? array(); if ( empty( $style ) || ! is_array( $style ) ) { return $block_content; } $block_name = $block['blockName']; $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_name ); if ( ! $block_type ) { return $block_content; } $supported_pseudo_states = WP_Theme_JSON::VALID_BLOCK_PSEUDO_SELECTORS[ $block_name ] ?? array(); $css_rules = array(); $viewport_settings = wp_get_global_settings( array( 'viewport' ) ); $responsive_media_queries = WP_Theme_JSON::get_viewport_media_queries( $viewport_settings ); foreach ( $supported_pseudo_states as $pseudo_state ) { if ( empty( $style[ $pseudo_state ] ) || ! is_array( $style[ $pseudo_state ] ) ) { continue; } $css_rules = array_merge( $css_rules, wp_get_block_state_style_rules( array( $pseudo_state => $style[ $pseudo_state ] ), $block_type ) ); } foreach ( $responsive_media_queries as $breakpoint => $media_query ) { if ( empty( $style[ $breakpoint ] ) || ! is_array( $style[ $breakpoint ] ) ) { continue; } $root_state_style = wp_get_root_state_style( $style[ $breakpoint ], array_merge( array( 'elements' ), $supported_pseudo_states ) ); if ( ! empty( $root_state_style ) ) { $css_rules = array_merge( $css_rules, wp_get_block_state_style_rules( array( '' => $root_state_style ), $block_type, $media_query ) ); } if ( ! empty( $style[ $breakpoint ]['elements'] ) && is_array( $style[ $breakpoint ]['elements'] ) ) { $element_selectors = wp_get_block_state_element_selectors( wp_get_block_css_selector( $block_type ) ); foreach ( $style[ $breakpoint ]['elements'] as $element_name => $element_style ) { if ( empty( $element_style ) || ! is_array( $element_style ) || empty( $element_selectors[ $element_name ] ) ) { continue; } $element_pseudo_states = WP_Theme_JSON::VALID_ELEMENT_PSEUDO_SELECTORS[ $element_name ] ?? array(); $root_element_style = wp_get_root_state_style( $element_style, $element_pseudo_states ); wp_add_block_state_style_rule( $css_rules, '', $element_selectors[ $element_name ], $root_element_style, $media_query ); foreach ( $element_pseudo_states as $pseudo_state ) { if ( empty( $element_style[ $pseudo_state ] ) || ! is_array( $element_style[ $pseudo_state ] ) ) { continue; } wp_add_block_state_style_rule( $css_rules, $pseudo_state, $element_selectors[ $element_name ], $element_style[ $pseudo_state ], $media_query ); } } } foreach ( $supported_pseudo_states as $pseudo_state ) { if ( empty( $style[ $breakpoint ][ $pseudo_state ] ) || ! is_array( $style[ $breakpoint ][ $pseudo_state ] ) ) { continue; } $css_rules = array_merge( $css_rules, wp_get_block_state_style_rules( array( $pseudo_state => $style[ $breakpoint ][ $pseudo_state ] ), $block_type, $media_query ) ); } } if ( empty( $css_rules ) ) { return $block_content; } $unique_class = wp_get_block_state_unique_class( $block_name, $css_rules ); /* * Register each state's CSS rules with the block-supports style engine store. * The store deduplicates rules by selector — two block instances with identical * state styles share the same hash class and therefore the same selector, * so only one CSS rule is emitted. The store is flushed to the page by * wp_enqueue_stored_styles() rather than injected inline here. * * State declarations need !important to apply reliably over inline styles and * preset utility classes such as .has-accent-3-background-color. * * Layout-driven state styles (responsive layout, blockGap, child layout) are * handled by wp_render_layout_support_flag() so they share a selector with * the base layout and target the correct (inner) wrapper element. */ $style_rules = array(); foreach ( $css_rules as $rule ) { $declarations = $rule['declarations']; $important_declaration_values = wp_get_state_declarations_with_background_resets( $declarations ); $important_declarations = new WP_Style_Engine_CSS_Declarations(); foreach ( $important_declaration_values as $property => $value ) { $important_declarations->add_declaration( $property, $value, array( 'important' => true, ) ); } $selector = wp_build_state_selector( ".$unique_class", $rule['selector'], $rule['state'] ); $important_style_rule = array( 'selector' => $selector, 'declarations' => $important_declarations, ); if ( ! empty( $rule['rules_group'] ) ) { $important_style_rule['rules_group'] = $rule['rules_group']; } $style_rules[] = $important_style_rule; $fallback_declarations = wp_get_state_declarations_with_fallback_border_styles( $declarations ); foreach ( array_keys( $declarations ) as $property ) { unset( $fallback_declarations[ $property ] ); } if ( empty( $fallback_declarations ) ) { continue; } $fallback_style_rule = array( 'selector' => $selector, 'declarations' => $fallback_declarations, ); if ( ! empty( $rule['rules_group'] ) ) { $fallback_style_rule['rules_group'] = $rule['rules_group']; } $style_rules[] = $fallback_style_rule; } wp_style_engine_get_stylesheet_from_css_rules( $style_rules, array( 'context' => 'block-supports', 'prettify' => false, ) ); $processor = new WP_HTML_Tag_Processor( $block_content ); if ( $processor->next_tag() ) { $processor->add_class( $unique_class ); } return $processor->get_updated_html(); } add_filter( 'render_block', 'wp_render_block_states_support', 10, 2 ); ublic_post_types = $this->get_public_post_types(); $excluded_post_types = $this->get_excluded_post_types_for_indexables(); $included_post_types = \array_diff( $public_post_types, $excluded_post_types ); return $this->filter_included_post_types( $included_post_types ); } /** * Returns all indexable post types with archive pages. * * @return array All post types which are indexable and have archive pages. */ public function get_indexable_post_archives() { return \array_filter( $this->get_indexable_post_type_objects(), [ $this, 'has_archive' ] ); } /** * Filters the post types that are included to be indexed. * * @param array $included_post_types The post types that are included to be indexed. * * @return array The filtered post types that are included to be indexed. */ protected function filter_included_post_types( $included_post_types ) { /** * Filter: 'wpseo_indexable_forced_included_post_types' - Allows force including posts of a certain post * type to be saved to the indexable table. * * @param array $included_post_types The currently included post types that indexables will be created for. */ $filtered_included_post_types = \apply_filters( 'wpseo_indexable_forced_included_post_types', $included_post_types ); if ( ! \is_array( $filtered_included_post_types ) ) { // If the filter got misused, let's return the unfiltered array. return \array_values( $included_post_types ); } // Add sanity check to make sure everything is an actual post type. foreach ( $filtered_included_post_types as $key => $post_type ) { if ( ! \post_type_exists( $post_type ) ) { unset( $filtered_included_post_types[ $key ] ); } } // `array_values`, to make sure that the keys are reset. return \array_values( $filtered_included_post_types ); } /** * Checks if the given post type should be indexed. * * @param string $post_type The post type that is checked. * * @return bool */ public function is_of_indexable_post_type( $post_type ) { $public_types = $this->get_indexable_post_types(); if ( ! \in_array( $post_type, $public_types, true ) ) { return false; } return true; } /** * Checks if the archive of a post type is indexable. * * @param string $post_type The post type to check. * * @return bool if the archive is indexable. */ public function is_post_type_archive_indexable( $post_type ) { $public_type_objects = $this->get_indexable_post_archives(); $public_types = \array_map( static function ( $post_type_object ) { return $post_type_object->name; }, $public_type_objects ); return \in_array( $post_type, $public_types, true ); } /** * Returns an array of complete post type objects for all indexable post types. * * @return array List of indexable post type objects. */ public function get_indexable_post_type_objects() { $post_type_objects = []; $indexable_post_types = $this->get_indexable_post_types(); foreach ( $indexable_post_types as $post_type ) { $post_type_object = \get_post_type_object( $post_type ); if ( ! empty( $post_type_object ) ) { $post_type_objects[ $post_type ] = $post_type_object; } } return $post_type_objects; } } Comments on: That is the way i ranked the top ten ideal casinos on the internet getting Britons https://iconsultindia.com/that-is-the-way-i-ranked-the-top-ten-ideal-casinos-on-the-internet-getting-britons/ Tue, 29 Sep 2026 08:43:04 +0000 hourly 1 https://wordpress.org/?v=7.1.3