wp_get_layout_definitions example

if ( isset( $block_metadata['name'] ) ) {
            $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] );
            if ( ! block_has_support( $block_type, array( 'layout' ), false ) && ! block_has_support( $block_type, array( '__experimentalLayout' ), false ) ) {
                return $block_rules;
            }
        }

        $selector                 = isset( $block_metadata['selector'] ) ? $block_metadata['selector'] : '';
        $has_block_gap_support    = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null;
        $has_fallback_gap_support = ! $has_block_gap_support; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback gap styles support.         $node                     = _wp_array_get( $this->theme_json, $block_metadata['path'], array() );
        $layout_definitions       = wp_get_layout_definitions();
        $layout_selector_pattern  = '/^[a-zA-Z0-9\-\.\ *+>:\(\)]*$/'; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors.
        /* * Gap styles will only be output if the theme has block gap support, or supports a fallback gap. * Default layout gap styles will be skipped for themes that do not explicitly opt-in to blockGap with a `true` or `false` value. */
        if ( $has_block_gap_support || $has_fallback_gap_support ) {
            $block_gap_value = null;
            // Use a fallback gap value if block gap support is not available.             if ( ! $has_block_gap_support ) {
                $block_gap_value = static::ROOT_BLOCK_SELECTOR === $selector ? '0.5em' : null;
                
$content = new WP_HTML_Tag_Processor( $block_content );
        $content->next_tag();
        $content->add_class( implode( ' ', $outer_class_names ) );
        return (string) $content;
    }

    $global_settings = wp_get_global_settings();
    $fallback_layout = ! empty( _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) ) ? _wp_array_get( $block_type->supports, array( 'layout', 'default' ), array() ) : _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() );
    $used_layout     = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $fallback_layout;

    $class_names        = array();
    $layout_definitions = wp_get_layout_definitions();
    $container_class    = wp_unique_id( 'wp-container-' );
    $layout_classname   = '';

    // Set the correct layout type for blocks using legacy content width.     if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] || isset( $used_layout['contentSize'] ) && $used_layout['contentSize'] ) {
        $used_layout['type'] = 'constrained';
    }

    $root_padding_aware_alignments = _wp_array_get( $global_settings, array( 'useRootPaddingAwareAlignments' ), false );

    if (
        
Home | Imprint | This part of the site doesn't use cookies.