get_theme_data example



/** * Returns the current theme's wanted patterns (slugs) to be * registered from Pattern Directory. * * @since 6.3.0 * * @return string[] */
function wp_get_theme_directory_pattern_slugs() {
    return WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_patterns();
}

/** * Determines the CSS selector for the block type and property provided, * returning it if available. * * @since 6.3.0 * * @param WP_Block_Type $block_type The block's type. * @param string|array $target The desired selector's target, `root` or array path. * @param boolean $fallback Whether to fall back to broader selector. * * @return string|null CSS selector or `null` if no selector available. */
$result->merge( static::get_core_data() );
        if ( 'default' === $origin ) {
            $result->set_spacing_sizes();
            return $result;
        }

        $result->merge( static::get_block_data() );
        if ( 'blocks' === $origin ) {
            return $result;
        }

        $result->merge( static::get_theme_data() );
        if ( 'theme' === $origin ) {
            $result->set_spacing_sizes();
            return $result;
        }

        $result->merge( static::get_user_data() );
        $result->set_spacing_sizes();

        return $result;
    }

    

function _add_block_template_info( $template_item ) {
    if ( ! wp_theme_has_theme_json() ) {
        return $template_item;
    }

    $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates();
    if ( isset( $theme_data[ $template_item['slug'] ] ) ) {
        $template_item['title']     = $theme_data[ $template_item['slug'] ]['title'];
        $template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes'];
    }

    return $template_item;
}

/** * Attempts to add the template part's area information to the input template. * * @since 5.9.0 * @access private * * @param array $template_info Template to add information to (requires 'type' and 'slug' fields). * @return array Template info. */
Home | Imprint | This part of the site doesn't use cookies.