diff --git a/modules/custom-status/custom-status.php b/modules/custom-status/custom-status.php index c76af258..d91f1026 100644 --- a/modules/custom-status/custom-status.php +++ b/modules/custom-status/custom-status.php @@ -288,18 +288,24 @@ function action_admin_enqueue_scripts() { return; } - // Load block editor assets and return early. - if ( $this->is_block_editor() ) { - global $post; + // Assets for block editor UI. + add_action( 'enqueue_block_editor_assets', array( $this, 'load_scripts_for_block_editor') ); - 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 ); + // Assets for iframed block editor and editor UI. + add_action( 'enqueue_block_editor_assets', array( $this, 'load_styles_for_block_editor') ); - $custom_statuses = apply_filters( 'ef_custom_status_list', $this->get_custom_statuses(), $post ); + // // Load block editor assets and return early. + // if ( $this->is_block_editor() ) { + // global $post; - wp_localize_script( 'edit-flow-block-custom-status-script', 'EditFlowCustomStatuses', array_values( $custom_statuses ) ); - return; - } + // 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; + // } // Load Javascript we need to use on the configuration views (jQuery Sortable and Quick Edit) if ( $this->is_whitelisted_settings_view( $this->module->name ) ) { @@ -321,7 +327,20 @@ function action_admin_enqueue_scripts() { )); } + } + + function load_scripts_for_block_editor(){ + global $post; + + 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 ) ); + } + function load_styles_for_block_editor(){ + wp_enqueue_style( 'edit-flow-block-custom-status-styles', EDIT_FLOW_URL . 'blocks/dist/custom-status.editor.build.css', false, EDIT_FLOW_VERSION ); } /** diff --git a/modules/custom-status/lib/custom-status-blockified.js b/modules/custom-status/lib/custom-status-blockified.js new file mode 100644 index 00000000..2526a970 --- /dev/null +++ b/modules/custom-status/lib/custom-status-blockified.js @@ -0,0 +1,12 @@ +function setup() { + if ( EditFlowCustomStatuses ) { + const statuses = EditFlowCustomStatuses.map( status => ( { + label: status.name, + value: status.slug, + } ) ); + + console.log( statuses ); + } +} + +setup();