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
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
1 change: 0 additions & 1 deletion includes/class-solrpower-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

add_action( 'save_post', array( $this, 'handle_modified' ) );
add_action( 'delete_post', array( $this, 'handle_delete' ) );
Expand Down