From e9c360743877af7d92060414457f6f5bd69eb7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 9 Nov 2021 16:10:48 +0100 Subject: [PATCH] Fix Gutenberg 11.8.2 in WordPress trunk (#36347) Co-authored-by: Riad Benguella --- lib/class-wp-theme-json-schema-v0.php | 6 +- lib/interface-wp-theme-json-schema.php | 2 +- packages/block-library/src/calendar/index.php | 74 ++++++++++--------- 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/lib/class-wp-theme-json-schema-v0.php b/lib/class-wp-theme-json-schema-v0.php index 30a0578178c7f..19d0fb1359388 100644 --- a/lib/class-wp-theme-json-schema-v0.php +++ b/lib/class-wp-theme-json-schema-v0.php @@ -1,16 +1,16 @@ post_status || 'post' !== $post->post_type ) { - return; - } +/** + * Handler for updating the has published posts flag when a post is deleted. + * + * @param int $post_id Deleted post ID. + */ +function block_core_calendar_update_has_published_post_on_delete( $post_id ) { + if ( is_multisite() ) { + return; + } + + $post = get_post( $post_id ); - block_core_calendar_update_has_published_posts(); + if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) { + return; } - /** - * Handler for updating the has published posts flag when a post status changes. - * - * @param string $new_status The status the post is changing to. - * @param string $old_status The status the post is changing from. - * @param WP_Post $post Post object. - */ - function block_core_calendar_update_has_published_post_on_transition_post_status( $new_status, $old_status, $post ) { - if ( $new_status === $old_status ) { - return; - } + block_core_calendar_update_has_published_posts(); +} - if ( 'post' !== get_post_type( $post ) ) { - return; - } +/** + * Handler for updating the has published posts flag when a post status changes. + * + * @param string $new_status The status the post is changing to. + * @param string $old_status The status the post is changing from. + * @param WP_Post $post Post object. + */ +function block_core_calendar_update_has_published_post_on_transition_post_status( $new_status, $old_status, $post ) { + if ( is_multisite() ) { + return; + } - if ( 'publish' !== $new_status && 'publish' !== $old_status ) { - return; - } + if ( $new_status === $old_status ) { + return; + } - block_core_calendar_update_has_published_posts(); + if ( 'post' !== get_post_type( $post ) ) { + return; } - add_action( 'delete_post', 'block_core_calendar_update_has_published_post_on_delete' ); - add_action( 'transition_post_status', 'block_core_calendar_update_has_published_post_on_transition_post_status', 10, 3 ); + if ( 'publish' !== $new_status && 'publish' !== $old_status ) { + return; + } + + block_core_calendar_update_has_published_posts(); } + +add_action( 'delete_post', 'block_core_calendar_update_has_published_post_on_delete' ); +add_action( 'transition_post_status', 'block_core_calendar_update_has_published_post_on_transition_post_status', 10, 3 );