diff --git a/modules/custom-status/custom-status.php b/modules/custom-status/custom-status.php index c76af258..e6be914c 100644 --- a/modules/custom-status/custom-status.php +++ b/modules/custom-status/custom-status.php @@ -162,6 +162,14 @@ function install() { 'position' => 5, ), ), + array( + 'term' => __( 'Expired', 'edit-flow' ), + 'args' => array( + 'slug' => 'expired', + 'description' => __( 'Post has expired, and it has to bew updated an editor.', 'edit-flow' ), + 'position' => 6, + ), + ), ); // Okay, now add the default statuses to the db if they don't already exist @@ -202,6 +210,20 @@ function upgrade( $previous_version ) { // Custom status descriptions become base64_encoded, instead of maybe json_encoded. $this->upgrade_074_term_descriptions( self::taxonomy_key ); } + // Upgrade path to v0.9.9 + if ( version_compare( $previous_version, '0.9.9', '<' ) ) { + $expiry_custom_status = array( + 'term' => __( 'Expired', 'edit-flow' ), + 'args' => array( + 'slug' => 'expired', + 'description' => __( 'Post has expired, and it has to bew updated an editor.', 'edit-flow' ), + 'position' => 6, + ), + ); + + if( !term_exists( $expiry_custom_status['term'], self::taxonomy_key ) ) + $this->add_custom_status( $expiry_custom_status['term'], $expiry_custom_status['args'] ); + } } diff --git a/modules/editorial-metadata/editorial-metadata.php b/modules/editorial-metadata/editorial-metadata.php index df86e8d7..9822e44b 100644 --- a/modules/editorial-metadata/editorial-metadata.php +++ b/modules/editorial-metadata/editorial-metadata.php @@ -560,14 +560,20 @@ function save_meta_box( $id, $post ) { } function unpublish_post_task( $post_id ) { + $post_status_to_set = 'pending'; + + if ( $this->module_enabled( 'custom-status' ) ) { + $post_status_to_set = 'expired'; + } + // Bistro ToDo: Cancel the scheduled task to change the status of the post to pending_review. $success_value = wp_update_post( array( 'ID' => $post_id, - 'post_status' => 'pending' + 'post_status' => $post_status_to_set ), true ); if ( is_wp_error( $success_value ) ) { - error_log( 'Error updating post status to pending: ' . $success_value->get_error_message() ); + error_log( 'Error updating post status to ' . $post_status_to_set . ': ' . $success_value->get_error_message() ); } }