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

Remove not necessary publish_post action. #587

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

kporras07
Copy link
Contributor

No description provided.

@@ -41,7 +41,6 @@ public static function get_instance() {
* Instantiate the object.
*/
function __construct() {
add_action( 'publish_post', array( $this, 'handle_modified' ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per https://github.com/WordPress/WordPress/blob/f08039702ecdfeaba850c91bc0e3008272104509/wp-includes/post.php#L4892 both actions will run one after the other one in case of a save_post.

@@ -41,7 +41,6 @@ public static function get_instance() {
* Instantiate the object.
*/
function __construct() {
add_action( 'publish_post', array( $this, 'handle_modified' ) );
add_action( 'publish_page', array( $this, 'handle_modified' ) );

Choose a reason for hiding this comment

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

Suggested change
add_action( 'publish_page', array( $this, 'handle_modified' ) );

Similar to publish_post, we don't need publish_page either, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no save_page here. Maybe we should swap it with save_page? Not sure but IIUC save_post won't cover publish_page

Choose a reason for hiding this comment

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

do_action( 'publish_page' ) gets called by wp_transition_post_status dynamically, which is called by wp_publish_post.

do_action( 'save_post' ) gets called further down in wp_publish_post. It also gets called by wp_insert_post

The only reason we'd need both publish_page and save_post is if somebody was manually calling wp_transition_post_status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants