Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: should_load_remote_block_patterns

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
225      $supports_core_patterns = get_theme_support( 'core-block-patterns' );
226
227      /**
228       * Filter to disable remote block patterns.
229       *
230       * @since 5.8.0
231       *
232       * @param bool $should_load_remote
233       */
234      $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
235
236      if ( $supports_core_patterns && $should_load_remote ) {
237           $request         = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
238           $core_keyword_id = 11; // 11 is the ID for "core".
239           $request->set_param( 'keyword', $core_keyword_id );
240           $response = rest_do_request( $request );
241           if ( $response->is_error() ) {
242                return;
243           }
 
Line Code
258  * @since 5.9.0
259  * @since 6.2.0 Normalized the pattern from the API (snake_case) to the
260  *              format expected by `register_block_pattern()` (camelCase).
261  * @since 6.3.0 Add 'pattern-directory/featured' to the pattern's 'source'.
262  */
263 function _load_remote_featured_patterns() {
264      $supports_core_patterns = get_theme_support( 'core-block-patterns' );
265
266      /** This filter is documented in wp-includes/block-patterns.php */
267      $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
268
269      if ( ! $should_load_remote || ! $supports_core_patterns ) {
270           return;
271      }
272
273      $request         = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
274      $featured_cat_id = 26; // This is the `Featured` category id from pattern directory.
275      $request->set_param( 'category', $featured_cat_id );
276      $response = rest_do_request( $request );
 
Line Code
297  *
298  * @since 6.0.0
299  * @since 6.2.0 Normalized the pattern from the API (snake_case) to the
300  *              format expected by `register_block_pattern()` (camelCase).
301  * @since 6.3.0 Add 'pattern-directory/theme' to the pattern's 'source'.
302  * @access private
303  */
304 function _register_remote_theme_patterns() {
305      /** This filter is documented in wp-includes/block-patterns.php */
306      if ( ! apply_filters( 'should_load_remote_block_patterns', true ) ) {
307           return;
308      }
309
310      if ( ! wp_theme_has_theme_json() ) {
311           return;
312      }
313
314      $pattern_settings = wp_get_theme_directory_pattern_slugs();
315      if ( empty( $pattern_settings ) ) {