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 2 times in this file.

Line Code
64      $supports_core_patterns = get_theme_support( 'core-block-patterns' );
65
66      /**
67       * Filter to disable remote block patterns.
68       *
69       * @since 5.8.0
70       *
71       * @param bool $should_load_remote
72       */
73      $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
74
75      if ( $supports_core_patterns && $should_load_remote ) {
76           $request         = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
77           $core_keyword_id = 11; // 11 is the ID for "core".
78           $request->set_param( 'keyword', $core_keyword_id );
79           $response = rest_do_request( $request );
80           if ( $response->is_error() ) {
81                return;
82           }
 
Line Code
92 /**
93  * Register `Featured` (category) patterns from wordpress.org/patterns.
94  *
95  * @since 5.9.0
96  */
97 function _load_remote_featured_patterns() {
98      $supports_core_patterns = get_theme_support( 'core-block-patterns' );
99
100      /** This filter is documented in wp-includes/block-patterns.php */
101      $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
102
103      if ( ! $should_load_remote || ! $supports_core_patterns ) {
104           return;
105      }
106
107      if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( 'featured' ) ) {
108           register_block_pattern_category( 'featured', array( 'label' => __( 'Featured' ) ) );
109      }
110