From af671313c859c8bfb25f4b67a09478d8a178e2f4 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Thu, 19 Jun 2025 12:24:48 +1000 Subject: [PATCH] XPosts: When a post is cloned, don't bring the XPost metadata with it. Bringing the XPost metadata over causes any xposts on the cloned post to be sent to the previous post, if it was xposted. This is plugin compatibility for: https://wordpress.org/plugins/duplicate-post/ --- inc/xposts.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/inc/xposts.php b/inc/xposts.php index e17aa84..e576511 100644 --- a/inc/xposts.php +++ b/inc/xposts.php @@ -39,6 +39,9 @@ function __construct() { // Don't let xposts participate in resolved/unresolved add_filter( 'o2_resolved_posts_maybe_mark_new_as_unresolved', array( $this, 'o2rpx_dont_mark_xposts' ), 10, 2 ); + // Duplicate Posts: don't copy xpost metadata with the post. + add_filter( 'duplicate_post_excludelist_filter', array( $this, 'duplicate_post_excludelist_filter' ) ); + parent::__construct( 'xposts' ); } @@ -606,6 +609,15 @@ function o2rpx_dont_mark_xposts( $true, $post ) { return $true; } + + /* Don't copy xpost-related metadata when cloning posts. */ + function duplicate_post_excludelist_filter( $metadata ) { + // Don't copy xpost metadata with the post. + $metadata[] = 'xpost-*'; + $metadata[] = 'xcomment-*'; + + return $metadata; + } } endif; // class_exists