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