From 9d2f1200f8b9030581e89904dfcf084dfe251d29 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Wed, 27 Sep 2023 17:14:37 -0600 Subject: [PATCH] Remove remaining hooks from footnotes that are causing issues --- lib/compat/plugin/footnotes.php | 6 ++++++ packages/block-library/src/footnotes/index.php | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/compat/plugin/footnotes.php b/lib/compat/plugin/footnotes.php index 7699f3112560c..915e554cea7ae 100644 --- a/lib/compat/plugin/footnotes.php +++ b/lib/compat/plugin/footnotes.php @@ -34,4 +34,10 @@ if ( has_filter( 'rest_pre_insert_post', '_wp_rest_api_force_autosave_difference' ) ) { remove_filter( 'rest_pre_insert_post', '_wp_rest_api_force_autosave_difference' ); } + if ( has_filter( '_wp_post_revision_field_footnotes', 'wp_get_footnotes_from_revision' ) ) { + remove_filter( '_wp_post_revision_field_footnotes', 'wp_get_footnotes_from_revision' ); + } + if ( has_filter( '_wp_post_revision_fields', 'wp_add_footnotes_to_revision' ) ) { + remove_filter( '_wp_post_revision_fields', 'wp_add_footnotes_to_revision' ); + } } diff --git a/packages/block-library/src/footnotes/index.php b/packages/block-library/src/footnotes/index.php index dfe6336b0929d..f8b5f6248a4d4 100644 --- a/packages/block-library/src/footnotes/index.php +++ b/packages/block-library/src/footnotes/index.php @@ -200,6 +200,7 @@ function wp_restore_footnotes_from_revision( $post_id, $revision_id ) { * Adds the footnotes field to the revisions display. * * @since 6.3.0 + * @since 6.4.0 Core added post meta revisions, so this is no longer needed. * * @param array $fields The revision fields. * @return array The revision fields. @@ -208,12 +209,15 @@ function wp_add_footnotes_to_revision( $fields ) { $fields['footnotes'] = __( 'Footnotes' ); return $fields; } -add_filter( '_wp_post_revision_fields', 'wp_add_footnotes_to_revision' ); +if ( ! function_exists( 'wp_post_revision_meta_keys' ) ) { + add_filter( '_wp_post_revision_fields', 'wp_add_footnotes_to_revision' ); +} /** * Gets the footnotes field from the revision for the revisions screen. * * @since 6.3.0 + * @since 6.4.0 Core added post meta revisions, so this is no longer needed. * * @param string $revision_field The field value, but $revision->$field * (footnotes) does not exist. @@ -224,7 +228,9 @@ function wp_add_footnotes_to_revision( $fields ) { function wp_get_footnotes_from_revision( $revision_field, $field, $revision ) { return get_metadata( 'post', $revision->ID, $field, true ); } -add_filter( '_wp_post_revision_field_footnotes', 'wp_get_footnotes_from_revision', 10, 3 ); +if ( ! function_exists( 'wp_post_revision_meta_keys' ) ) { + add_filter( '_wp_post_revision_field_footnotes', 'wp_get_footnotes_from_revision', 10, 3 ); +} /** * The REST API autosave endpoint doesn't save meta, so we can use the