Editor: More strict checks for globals in render_block
Props kraftbj. Fixes #49927. git-svn-id: https://develop.svn.wordpress.org/trunk@48243 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b2cc1dfd70
commit
ac7c4e270b
@ -685,7 +685,7 @@ function render_block( $parsed_block ) {
|
|||||||
|
|
||||||
$context = array();
|
$context = array();
|
||||||
|
|
||||||
if ( ! empty( $post ) ) {
|
if ( $post instanceof WP_Post ) {
|
||||||
$context['postId'] = $post->ID;
|
$context['postId'] = $post->ID;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -697,7 +697,7 @@ function render_block( $parsed_block ) {
|
|||||||
$context['postType'] = $post->post_type;
|
$context['postType'] = $post->post_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $wp_query->tax_query->queried_terms['category'] ) ) {
|
if ( $wp_query instanceof WP_Query && isset( $wp_query->tax_query->queried_terms['category'] ) ) {
|
||||||
$context['query'] = array( 'categoryIds' => array() );
|
$context['query'] = array( 'categoryIds' => array() );
|
||||||
foreach ( $wp_query->tax_query->queried_terms['category']['terms'] as $category_slug_or_id ) {
|
foreach ( $wp_query->tax_query->queried_terms['category']['terms'] as $category_slug_or_id ) {
|
||||||
$context['query']['categoryIds'][] = 'slug' === $wp_query->tax_query->queried_terms['category']['field'] ? get_cat_ID( $category_slug_or_id ) : $category_slug_or_id;
|
$context['query']['categoryIds'][] = 'slug' === $wp_query->tax_query->queried_terms['category']['field'] ? get_cat_ID( $category_slug_or_id ) : $category_slug_or_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user