wp_get_theme_directory_pattern_slugs example


function _register_remote_theme_patterns() {
    /** This filter is documented in wp-includes/block-patterns.php */
    if ( ! apply_filters( 'should_load_remote_block_patterns', true ) ) {
        return;
    }

    if ( ! wp_theme_has_theme_json() ) {
        return;
    }

    $pattern_settings = wp_get_theme_directory_pattern_slugs();
    if ( empty( $pattern_settings ) ) {
        return;
    }

    $request         = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
    $request['slug'] = $pattern_settings;
    $response        = rest_do_request( $request );
    if ( $response->is_error() ) {
        return;
    }
    $patterns          = $response->get_data();
    
Home | Imprint | This part of the site doesn't use cookies.