@@ -257,6 +257,21 @@ public function is_rest_request() {
257257 * @return void
258258 */
259259 public function republish ( WP_Post $ post , WP_Post $ original_post ) {
260+
261+ /**
262+ * Fires before the Rewrite & Republish copy is republished to the original post.
263+ *
264+ * This action runs before any content, taxonomies, or meta are copied from the
265+ * Rewrite & Republish copy to the original post. Use this hook to perform actions
266+ * or modifications before the republishing process begins.
267+ *
268+ * @since 4.6
269+ *
270+ * @param WP_Post $post The Rewrite & Republish copy.
271+ * @param WP_Post $original_post The original post that will be overwritten.
272+ */
273+ \do_action ( 'duplicate_post_before_republish ' , $ post , $ original_post );
274+
260275 // Remove WordPress default filter so a new revision is not created on republish.
261276 \remove_action ( 'post_updated ' , 'wp_save_post_revision ' , 10 );
262277
@@ -272,6 +287,21 @@ public function republish( WP_Post $post, WP_Post $original_post ) {
272287
273288 // Re-enable the creation of a new revision.
274289 \add_action ( 'post_updated ' , 'wp_save_post_revision ' , 10 , 1 );
290+
291+ /**
292+ * Fires after the Rewrite & Republish copy has been republished to the original post.
293+ *
294+ * This action runs after all content, taxonomies, and meta have been copied from
295+ * the Rewrite & Republish copy to the original post. The copy is marked as republished
296+ * but has not yet been deleted. Use this hook to perform cleanup or additional
297+ * processing after the republishing is complete.
298+ *
299+ * @since 4.6
300+ *
301+ * @param WP_Post $post The Rewrite & Republish copy.
302+ * @param WP_Post $original_post The original post that has been updated.
303+ */
304+ \do_action ( 'duplicate_post_after_republish ' , $ post , $ original_post );
275305 }
276306
277307 /**
0 commit comments