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