Skip to content

Commit

Permalink
Remove remaining hooks from footnotes that are causing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsilverstein committed Sep 27, 2023
1 parent 82ad972 commit 9d2f120
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/compat/plugin/footnotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
}
10 changes: 8 additions & 2 deletions packages/block-library/src/footnotes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 9d2f120

Please sign in to comment.