From 4a98bb2fa12fa420e79c003c913237d58cbb7705 Mon Sep 17 00:00:00 2001 From: ronchambers Date: Mon, 13 Oct 2025 22:45:37 -0700 Subject: [PATCH 1/6] Fix FG Helper for NNO migration --- src/Util/FgHelper.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Util/FgHelper.php b/src/Util/FgHelper.php index 2e3d687f..28ea608d 100644 --- a/src/Util/FgHelper.php +++ b/src/Util/FgHelper.php @@ -69,11 +69,10 @@ public function __construct( string $type ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } - if ( ! is_plugin_active( "fg-{$this->type}-to-wp-premium/fg-{$this->type}-to-wp-premium.php" ) ) { + if ( ! is_plugin_active( "fg-{$this->type}-to-wp-premium/fg-{$this->type}-to-wp-premium.php" ) + && ! is_plugin_active( "fg-{$this->type}-to-wordpress-premium/fg-{$this->type}-to-wordpress-premium.php" ) ) { NMT::exit_with_message( "FG {$this->type} to WP Premium plugin not found. Install and activate it before using this class." ); } - - $this->type = $type; } /** From d8d43fdd491c7c4c6e0f20ac1230fa20204cabe3 Mon Sep 17 00:00:00 2001 From: ronchambers Date: Wed, 19 Nov 2025 18:16:32 -0800 Subject: [PATCH 2/6] Fix FG Helper for NNO migration: publish press --- src/Logic/PublishPressHelper.php | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/Logic/PublishPressHelper.php diff --git a/src/Logic/PublishPressHelper.php b/src/Logic/PublishPressHelper.php new file mode 100644 index 00000000..cbbf8d93 --- /dev/null +++ b/src/Logic/PublishPressHelper.php @@ -0,0 +1,59 @@ + $post_id, + ]; + + // status: draft, trash, delete + if( 'delete' === $status ) { + $options['expireType'] = 'delete'; + // newStatus not needed since post will be deleted. + } + else { + $options['expireType'] = 'change-status'; + $options['newStatus'] = $status; + } + + do_action( + \PublishPress\Future\Modules\Expirator\HooksAbstract::ACTION_SCHEDULE_POST_EXPIRATION, + $post_id, + $epoch_gmt, + $options + ); + + return true; + } + +} From 8d6e97a0e07bf8fdfcda88357b826e78507a0ed1 Mon Sep 17 00:00:00 2001 From: ronchambers Date: Wed, 19 Nov 2025 18:37:44 -0800 Subject: [PATCH 3/6] Fix FG Helper for NNO migration: publish press phpcs --- src/Logic/PublishPressHelper.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Logic/PublishPressHelper.php b/src/Logic/PublishPressHelper.php index cbbf8d93..924ec90c 100644 --- a/src/Logic/PublishPressHelper.php +++ b/src/Logic/PublishPressHelper.php @@ -21,27 +21,26 @@ class PublishPressHelper { * @link https://publishpress.com/knowledge-base/programmatically-schedule-actions/ * @param int $post_id Post ID. - * @param string $status Options: draft, trash, or delete + * @param string $status Options: draft, trash, or delete. * @param int $epoch_gmt Expiration date in GMT epoch time. PHP: date( 'U' ) format. * * @return bool Success or failure. */ public static function set_post_expiration( int $post_id, string $status, int $epoch_gmt ): bool { - if ( ! defined('PUBLISHPRESS_FUTURE_LOADED') || ! defined( '\PublishPress\Future\Modules\Expirator\HooksAbstract::ACTION_SCHEDULE_POST_EXPIRATION' ) ) { + if ( ! defined( 'PUBLISHPRESS_FUTURE_LOADED' ) || ! defined( '\PublishPress\Future\Modules\Expirator\HooksAbstract::ACTION_SCHEDULE_POST_EXPIRATION' ) ) { return false; } - $options = [ + $options = [ 'id' => $post_id, ]; // status: draft, trash, delete - if( 'delete' === $status ) { + if ( 'delete' === $status ) { $options['expireType'] = 'delete'; // newStatus not needed since post will be deleted. - } - else { + } else { $options['expireType'] = 'change-status'; $options['newStatus'] = $status; } @@ -55,5 +54,4 @@ public static function set_post_expiration( int $post_id, string $status, int $e return true; } - } From 7cb72b0d9034b4673ee8d141a190129adc34d690 Mon Sep 17 00:00:00 2001 From: ronchambers Date: Wed, 19 Nov 2025 18:56:57 -0800 Subject: [PATCH 4/6] Fix FG Helper for NNO migration: publish press wp error --- src/Logic/PublishPressHelper.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Logic/PublishPressHelper.php b/src/Logic/PublishPressHelper.php index 924ec90c..04d010e6 100644 --- a/src/Logic/PublishPressHelper.php +++ b/src/Logic/PublishPressHelper.php @@ -5,6 +5,8 @@ namespace Newspack\MigrationTools\Logic; +use WP_Error; + /** * PublishPressHelper migration logic. */ @@ -24,12 +26,12 @@ class PublishPressHelper { * @param string $status Options: draft, trash, or delete. * @param int $epoch_gmt Expiration date in GMT epoch time. PHP: date( 'U' ) format. * - * @return bool Success or failure. + * @return bool|WP_Error True or WP_Error. */ - public static function set_post_expiration( int $post_id, string $status, int $epoch_gmt ): bool { + public static function set_post_expiration( int $post_id, string $status, int $epoch_gmt ): bool|WP_Error { if ( ! defined( 'PUBLISHPRESS_FUTURE_LOADED' ) || ! defined( '\PublishPress\Future\Modules\Expirator\HooksAbstract::ACTION_SCHEDULE_POST_EXPIRATION' ) ) { - return false; + return new WP_Error( 'ERROR_PUBLISHPRESS', 'PublishPress Future ( post-expirator ) not loaded.' ); } $options = [ From a999ead99f554156b0da5919a06ba9ae34384700 Mon Sep 17 00:00:00 2001 From: ronchambers Date: Thu, 20 Nov 2025 01:26:37 -0800 Subject: [PATCH 5/6] Fix FG Helper for NNO migration: proper epoch gmt note. --- src/Logic/PublishPressHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Logic/PublishPressHelper.php b/src/Logic/PublishPressHelper.php index 04d010e6..7e16601f 100644 --- a/src/Logic/PublishPressHelper.php +++ b/src/Logic/PublishPressHelper.php @@ -24,7 +24,7 @@ class PublishPressHelper { * @param int $post_id Post ID. * @param string $status Options: draft, trash, or delete. - * @param int $epoch_gmt Expiration date in GMT epoch time. PHP: date( 'U' ) format. + * @param int $epoch_gmt Expiration date in GMT epoch time. * * @return bool|WP_Error True or WP_Error. */ From aa8adb34a57fb1c1cd0c1fd32a00305d288c77e6 Mon Sep 17 00:00:00 2001 From: ronchambers Date: Sun, 23 Nov 2025 21:20:52 -0800 Subject: [PATCH 6/6] Fix FG Helper for NNO migration: pending WIP --- src/Logic/PublishPressHelper.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Logic/PublishPressHelper.php b/src/Logic/PublishPressHelper.php index 7e16601f..60a6204c 100644 --- a/src/Logic/PublishPressHelper.php +++ b/src/Logic/PublishPressHelper.php @@ -30,6 +30,8 @@ class PublishPressHelper { */ public static function set_post_expiration( int $post_id, string $status, int $epoch_gmt ): bool|WP_Error { + return new WP_Error( 'ERROR_PUBLISHPRESS_WIP', 'work in progress...do not use yet...' ); + if ( ! defined( 'PUBLISHPRESS_FUTURE_LOADED' ) || ! defined( '\PublishPress\Future\Modules\Expirator\HooksAbstract::ACTION_SCHEDULE_POST_EXPIRATION' ) ) { return new WP_Error( 'ERROR_PUBLISHPRESS', 'PublishPress Future ( post-expirator ) not loaded.' ); }