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
205      $supports_core_patterns = get_theme_support( 'core-block-patterns' );
206
207      /**
208       * Filter to disable remote block patterns.
209       *
210       * @since 5.8.0
211       *
212       * @param bool $should_load_remote
213       */
214      $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
215
216      if ( $supports_core_patterns && $should_load_remote ) {
217           $request         = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
218           $core_keyword_id = 11; // 11 is the ID for "core".
219           $request->set_param( 'keyword', $core_keyword_id );
220           $response = rest_do_request( $request );
221           if ( $response->is_error() ) {
222                return;
223           }
 
Line Code
236  *
237  * @since 5.9.0
238  * @since 6.2.0 Normalized the pattern from the API (snake_case) to the
239  *              format expected by `register_block_pattern()` (camelCase).
240  */
241 function _load_remote_featured_patterns() {
242      $supports_core_patterns = get_theme_support( 'core-block-patterns' );
243
244      /** This filter is documented in wp-includes/block-patterns.php */
245      $should_load_remote = apply_filters( 'should_load_remote_block_patterns', true );
246
247      if ( ! $should_load_remote || ! $supports_core_patterns ) {
248           return;
249      }
250
251      $request         = new WP_REST_Request( 'GET', '/wp/v2/pattern-directory/patterns' );
252      $featured_cat_id = 26; // This is the `Featured` category id from pattern directory.
253      $request->set_param( 'category', $featured_cat_id );
254      $response = rest_do_request( $request );
 
Line Code
273  * `theme.json` file.
274  *
275  * @since 6.0.0
276  * @since 6.2.0 Normalized the pattern from the API (snake_case) to the
277  *              format expected by `register_block_pattern()` (camelCase).
278  * @access private
279  */
280 function _register_remote_theme_patterns() {
281      /** This filter is documented in wp-includes/block-patterns.php */
282      if ( ! apply_filters( 'should_load_remote_block_patterns', true ) ) {
283           return;
284      }
285
286      if ( ! wp_theme_has_theme_json() ) {
287           return;
288      }
289
290      $pattern_settings = WP_Theme_JSON_Resolver::get_theme_data()->get_patterns();
291      if ( empty( $pattern_settings ) ) {