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