-
Notifications
You must be signed in to change notification settings - Fork 62
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
base: main
Are you sure you want to change the base?
Conversation
@@ -41,7 +41,6 @@ public static function get_instance() { | |||
* Instantiate the object. | |||
*/ | |||
function __construct() { | |||
add_action( 'publish_post', array( $this, 'handle_modified' ) ); |
There was a problem hiding this comment.
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' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_action( 'publish_page', array( $this, 'handle_modified' ) ); |
Similar to publish_post, we don't need publish_page either, right?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
No description provided.