From ec75c8cdc5de1e88be10b7319056d429d5e23496 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Mon, 27 Jan 2020 13:52:57 -0800 Subject: [PATCH 1/3] Fix ef_custom_status_list filter on get_custom_statuses() --- modules/custom-status/custom-status.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/custom-status/custom-status.php b/modules/custom-status/custom-status.php index 79a34ef3b..5a06d6e7b 100644 --- a/modules/custom-status/custom-status.php +++ b/modules/custom-status/custom-status.php @@ -585,7 +585,7 @@ function delete_custom_status( $status_id, $args = array(), $reassign = '' ) { * @return array $statuses All of the statuses */ function get_custom_statuses( $args = array() ) { - global $wp_post_statuses; + global $post, $wp_post_statuses; if ( $this->disable_custom_statuses_for_post_type() ) { return $this->get_core_post_statuses(); @@ -633,6 +633,8 @@ function get_custom_statuses( $args = array() ) { foreach( $hold_to_end as $unpositioned_status ) $ordered_statuses[] = $unpositioned_status; + $ordered_statuses = apply_filters( 'ef_custom_status_list', $ordered_statuses, $post ); + $this->custom_statuses_cache[ $arg_hash ] = $ordered_statuses; return $ordered_statuses; From 03452051f967fee80015561c872829273b0e757d Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Mon, 27 Jan 2020 14:44:36 -0800 Subject: [PATCH 2/3] Localize filter to block editor --- modules/custom-status/custom-status.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/custom-status/custom-status.php b/modules/custom-status/custom-status.php index 5a06d6e7b..e5bdced62 100644 --- a/modules/custom-status/custom-status.php +++ b/modules/custom-status/custom-status.php @@ -289,9 +289,11 @@ function action_admin_enqueue_scripts() { // Load block editor assets and return early. if ( $this->is_block_editor() ) { + global $post; wp_enqueue_style( 'edit-flow-block-custom-status-styles', EDIT_FLOW_URL . 'blocks/dist/custom-status.editor.build.css', false, EDIT_FLOW_VERSION ); wp_enqueue_script( 'edit-flow-block-custom-status-script', EDIT_FLOW_URL . 'blocks/dist/custom-status.build.js', array( 'wp-blocks', 'wp-element', 'wp-edit-post', 'wp-plugins', 'wp-components' ), EDIT_FLOW_VERSION ); - wp_localize_script( 'edit-flow-block-custom-status-script', 'EditFlowCustomStatuses', array_values( $this->get_custom_statuses() ) ); + $custom_statuses = apply_filters( 'ef_custom_status_list', $this->get_custom_statuses(), $post ); + wp_localize_script( 'edit-flow-block-custom-status-script', 'EditFlowCustomStatuses', array_values( $custom_statuses ) ); return; } @@ -585,7 +587,7 @@ function delete_custom_status( $status_id, $args = array(), $reassign = '' ) { * @return array $statuses All of the statuses */ function get_custom_statuses( $args = array() ) { - global $post, $wp_post_statuses; + global $wp_post_statuses; if ( $this->disable_custom_statuses_for_post_type() ) { return $this->get_core_post_statuses(); @@ -633,8 +635,6 @@ function get_custom_statuses( $args = array() ) { foreach( $hold_to_end as $unpositioned_status ) $ordered_statuses[] = $unpositioned_status; - $ordered_statuses = apply_filters( 'ef_custom_status_list', $ordered_statuses, $post ); - $this->custom_statuses_cache[ $arg_hash ] = $ordered_statuses; return $ordered_statuses; From 3298fad1f8ae9d18abfb7bb1df4195b7c08aaa78 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Mon, 27 Jan 2020 15:03:50 -0800 Subject: [PATCH 3/3] Add some whitespace for clarity --- modules/custom-status/custom-status.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/custom-status/custom-status.php b/modules/custom-status/custom-status.php index e5bdced62..0086c70a1 100644 --- a/modules/custom-status/custom-status.php +++ b/modules/custom-status/custom-status.php @@ -290,9 +290,12 @@ function action_admin_enqueue_scripts() { // Load block editor assets and return early. if ( $this->is_block_editor() ) { global $post; + wp_enqueue_style( 'edit-flow-block-custom-status-styles', EDIT_FLOW_URL . 'blocks/dist/custom-status.editor.build.css', false, EDIT_FLOW_VERSION ); wp_enqueue_script( 'edit-flow-block-custom-status-script', EDIT_FLOW_URL . 'blocks/dist/custom-status.build.js', array( 'wp-blocks', 'wp-element', 'wp-edit-post', 'wp-plugins', 'wp-components' ), EDIT_FLOW_VERSION ); + $custom_statuses = apply_filters( 'ef_custom_status_list', $this->get_custom_statuses(), $post ); + wp_localize_script( 'edit-flow-block-custom-status-script', 'EditFlowCustomStatuses', array_values( $custom_statuses ) ); return; }