Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: pre_get_block_template

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

Line Code
1022       * Return a non-null value to bypass the WordPress queries.
1023       *
1024       * @since 5.9.0
1025       *
1026       * @param WP_Block_Template|null $block_template Return block template object to short-circuit the default query,
1027       *                                               or null to allow WP to run its normal queries.
1028       * @param string                 $id             Template unique identifier (example: theme_slug//template_slug).
1029       * @param string                 $template_type  Template type: `'wp_template'` or '`wp_template_part'`.
1030       */
1031      $block_template = apply_filters( 'pre_get_block_template', null, $id, $template_type );
1032      if ( ! is_null( $block_template ) ) {
1033           return $block_template;
1034      }
1035
1036      $parts = explode( '//', $id, 2 );
1037      if ( count( $parts ) < 2 ) {
1038           return null;
1039      }
1040      list( $theme, $slug ) = $parts;