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

Footnotes: fix accidental override #53663

Merged
merged 2 commits into from Aug 16, 2023

Conversation

ellatrix
Copy link
Member

What?

We're accidentally overriding the $post_type global 🤦‍♀️

Fixes https://core.trac.wordpress.org/ticket/59105.

Why?

How?

Avoid the foreach loop setting the $post_type global

Alternatively, we could move this to register_block_core_footnotes, but I opted for moving as little code as possible.

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

@ellatrix ellatrix added the [Type] Bug An existing feature does not function as intended label Aug 15, 2023
add_action( "rest_after_insert_{$post_type}", 'wp_add_footnotes_revisions_to_post_meta' );
}
add_action( 'rest_after_insert_post', 'wp_add_footnotes_revisions_to_post_meta' );
add_action( 'rest_after_insert_page', 'wp_add_footnotes_revisions_to_post_meta' );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting that we could move this to the register_block_core_footnotes function, which runs on init, but I'm scared to move code around at this point. It's an option though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We anyway went for hardcoding these for this release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now; it'll have to change anyway once we add support for other post types so we can leave bigger changes till then 😄

Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

add_action( "rest_after_insert_{$post_type}", 'wp_add_footnotes_revisions_to_post_meta' );
}
add_action( 'rest_after_insert_post', 'wp_add_footnotes_revisions_to_post_meta' );
add_action( 'rest_after_insert_page', 'wp_add_footnotes_revisions_to_post_meta' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now; it'll have to change anyway once we add support for other post types so we can leave bigger changes till then 😄

@tellthemachines tellthemachines added the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Aug 15, 2023
@ellatrix ellatrix marked this pull request as ready for review August 15, 2023 09:12
@Mamaduka Mamaduka added the [Package] Block library /packages/block-library label Aug 15, 2023
@tellthemachines tellthemachines merged commit 574cc41 into trunk Aug 16, 2023
52 checks passed
@tellthemachines tellthemachines deleted the fix/fn-overriding-post-type-global branch August 16, 2023 00:43
@github-actions github-actions bot added this to the Gutenberg 16.5 milestone Aug 16, 2023
tellthemachines pushed a commit that referenced this pull request Aug 16, 2023
* Footnotes: fix accidental  override

* Remove double quotes
@tellthemachines tellthemachines removed the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Aug 16, 2023
tellthemachines added a commit that referenced this pull request Aug 16, 2023
* Footnotes: Fix recursion into updating attributes when attributes is not an object (#53257)

* Fix crash by moving editor style logic into a hook with useMemo (#53596)

* Move editor style logic into a hook whith useMemo

* Remove unnecessary useMemo

* Move the  whole logic inside the 'useMemo'

* Add missing useSelect dep

---------

Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>

* Adding an is_array check before using count in case $footnotes is not countable (#53660)

* Footnotes: fix accidental  override (#53663)

* Footnotes: fix accidental  override

* Remove double quotes

* Footnotes: autosave is not slashing JSON (#53664)

* Footnotes: autosave saves decoded JSON

* wp_slash

* Curly quote

* Slash on save and restore

* Ensure the preview dropdown popover closes (<16.3) for e2e tests

---------

Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Co-authored-by: Noah Allen <noahtallen@gmail.com>
Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com>
Co-authored-by: ramon <ramonjd@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants