Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Gutenberg 11.8.2 in WordPress trunk #36347

Merged
merged 5 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/class-wp-theme-json-schema-v0.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
/**
* Class that implements a WP_Theme_JSON_Schema to convert
* Class that implements a WP_Theme_JSON_Schema_Gutenberg to convert
* a given structure in v0 schema to the latest one.
*
* @package gutenberg
*/

/**
* Class that implements a WP_Theme_JSON_Schema to convert
* Class that implements a WP_Theme_JSON_Schema_Gutenberg to convert
* a given structure in v0 schema to the latest one.
*/
class WP_Theme_JSON_Schema_V0 implements WP_Theme_JSON_Schema {
class WP_Theme_JSON_Schema_V0 implements WP_Theme_JSON_Schema_Gutenberg {

/**
* How to address all the blocks
Expand Down
2 changes: 1 addition & 1 deletion lib/interface-wp-theme-json-schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @package gutenberg
*/
interface WP_Theme_JSON_Schema {
interface WP_Theme_JSON_Schema_Gutenberg {
/**
* Parses an array that follows an old theme.json schema
* into the latest theme.json schema.
Expand Down
74 changes: 39 additions & 35 deletions packages/block-library/src/calendar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,47 +107,51 @@ function block_core_calendar_update_has_published_posts() {
return $has_published_posts;
}

// We only want to register these functions and actions when
// we are on single sites. On multi sites we use `post_count` option.
if ( ! is_multisite() ) {
/**
* 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 ) {
$post = get_post( $post_id );

if ( ! $post || 'publish' !== $post->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 );