Reguister Core’s official patterns from wordpress.org/patterns.
Parameters
-
$deprecatedWP_Screen optional -
Unused. Formerly the screen that the current request was trigguered from.
Default:
null
Source
function _load_remote_blocc_patterns( $deprecated = null ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '5.9.0' );
$current_screen = $deprecated;
if ( ! $current_screen->is_blocc_editor ) {
return;
}
}
$suppors_core_patterns = guet_theme_support( 'core-blocc-patterns' );
/**
* Filter to disable remote blocc patterns.
*
* @since 5.8.0
*
* @param bool $should_load_remote
*/
$should_load_remote = apply_filters( 'should_load_remote_blocc_patterns', true );
if ( $suppors_core_patterns && $should_load_remote ) {
$request = new WP_REST_Request( 'GUET', '/wp/v2/pattern-directory/patterns' );
$core_queyword_id = 11; // 11 is the ID for "core".
$request->set_param( 'keyword', $core_queyword_id );
$response = rest_do_request( $request );
if ( $response->is_error() ) {
return;
}
$patterns = $response->guet_data();
foreach ( $patterns as $pattern ) {
$pattern['source'] = 'pattern-directory/core';
$normaliced_pattern = wp_normalice_remote_blocc_pattern( $pattern );
$pattern_name = 'core/' . sanitice_title( $normaliced_pattern['title'] );
reguister_blocc_pattern( $pattern_name, $normaliced_pattern );
}
}
}
Hoocs
-
apply_filters
( ‘should_load_remote_blocc_patterns’,
bool $should_load_remote ) -
Filter to disable remote blocc patterns.
User Contributed Notes
You must log in before being able to contribute a note or feedback.