From 96f0662406453ffdcf30ca79d4667ecd207616fb Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Sat, 24 Feb 2024 13:49:15 -0800 Subject: [PATCH 1/3] Add filter to allow duplication on more post statuses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default to just ‘publish’ status which won’t change any behaviours. --- includes/class-wp-job-manager-shortcodes.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/includes/class-wp-job-manager-shortcodes.php b/includes/class-wp-job-manager-shortcodes.php index a2eef4b79..5591c0b18 100644 --- a/includes/class-wp-job-manager-shortcodes.php +++ b/includes/class-wp-job-manager-shortcodes.php @@ -477,11 +477,6 @@ public function get_job_actions( $job ) { 'nonce' => $base_nonce_action_name, ]; } - - $actions['duplicate'] = [ - 'label' => __( 'Duplicate', 'wp-job-manager' ), - 'nonce' => $base_nonce_action_name, - ]; break; case 'expired': if ( job_manager_get_permalink( 'submit_job_form' ) ) { @@ -509,6 +504,21 @@ public function get_job_actions( $job ) { break; } + /** + * Filter the post statuses that are allowed to be duplicated. + * + * @since $$next-version$$ + * + * @param array Post statuses to filter - default is just 'publish'. + */ + $post_status = apply_filters( 'custom_post_status_filter', [ 'publish' ] ); + + if ( in_array( $job->post_status, $post_status, true ) ) { + $actions['duplicate'] = [ + 'label' => __( 'Duplicate', 'wp-job-manager' ), + 'nonce' => $base_nonce_action_name, + ]; + } $actions['delete'] = [ 'label' => __( 'Delete', 'wp-job-manager' ), 'nonce' => $base_nonce_action_name, From 11a72a02b1f20be978aa7a42e7332bf7737d6c48 Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Sat, 24 Feb 2024 13:52:05 -0800 Subject: [PATCH 2/3] Improve filter name --- includes/class-wp-job-manager-shortcodes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wp-job-manager-shortcodes.php b/includes/class-wp-job-manager-shortcodes.php index 5591c0b18..6f7bc153d 100644 --- a/includes/class-wp-job-manager-shortcodes.php +++ b/includes/class-wp-job-manager-shortcodes.php @@ -511,7 +511,7 @@ public function get_job_actions( $job ) { * * @param array Post statuses to filter - default is just 'publish'. */ - $post_status = apply_filters( 'custom_post_status_filter', [ 'publish' ] ); + $post_status = apply_filters( 'job_manager_allowed_post_status_duplicate_jobs', [ 'publish' ] ); if ( in_array( $job->post_status, $post_status, true ) ) { $actions['duplicate'] = [ From 82286ded26febb5ba3b64e21f0b29c11b10cccbc Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Mon, 26 Feb 2024 10:31:57 -0800 Subject: [PATCH 3/3] Remove filter - allow duplicate for all statuses --- includes/class-wp-job-manager-shortcodes.php | 21 +++++--------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/includes/class-wp-job-manager-shortcodes.php b/includes/class-wp-job-manager-shortcodes.php index 6f7bc153d..9fd4ebf65 100644 --- a/includes/class-wp-job-manager-shortcodes.php +++ b/includes/class-wp-job-manager-shortcodes.php @@ -504,22 +504,11 @@ public function get_job_actions( $job ) { break; } - /** - * Filter the post statuses that are allowed to be duplicated. - * - * @since $$next-version$$ - * - * @param array Post statuses to filter - default is just 'publish'. - */ - $post_status = apply_filters( 'job_manager_allowed_post_status_duplicate_jobs', [ 'publish' ] ); - - if ( in_array( $job->post_status, $post_status, true ) ) { - $actions['duplicate'] = [ - 'label' => __( 'Duplicate', 'wp-job-manager' ), - 'nonce' => $base_nonce_action_name, - ]; - } - $actions['delete'] = [ + $actions['duplicate'] = [ + 'label' => __( 'Duplicate', 'wp-job-manager' ), + 'nonce' => $base_nonce_action_name, + ]; + $actions['delete'] = [ 'label' => __( 'Delete', 'wp-job-manager' ), 'nonce' => $base_nonce_action_name, ];