diff --git a/external-permalinks-redux.php b/external-permalinks-redux.php index 7af66bf29afe04e8b65f8203b0e9f60b91a4c81f..f0d8d79e1fcb018cce517caf24359d32f291f768 100644 --- a/external-permalinks-redux.php +++ b/external-permalinks-redux.php @@ -180,20 +180,24 @@ class external_permalinks_redux { return; } - foreach ( $this->post_types as $post_type ) { - if ( - function_exists( 'use_block_editor_for_post_type' ) - && use_block_editor_for_post_type( $post_type ) - ) { - return; - } + $this->post_types = array_flip( $this->post_types ); + foreach ( array_keys( $this->post_types ) as $post_type ) { $title = apply_filters( 'epr_metabox_title', '', $post_type ); - if ( ! $title ) { + if ( empty( $title ) ) { $title = __( 'External Permalinks Redux', 'external-permalinks-redux' ); } + $this->post_types[ $post_type ] = $title; + + if ( + function_exists( 'use_block_editor_for_post_type' ) + && use_block_editor_for_post_type( $post_type ) + ) { + continue; + } + add_meta_box( 'external-permalinks-redux', $title, array( $this, 'meta_box' ), $post_type, 'normal' ); unset( $title ); diff --git a/inc/class-external-permalinks-redux-block-editor.php b/inc/class-external-permalinks-redux-block-editor.php index 93a9f2570493926f023e0172bce21a3e0962dfad..2feb7ee97a79c0dec33b6bea39666b6f5e32c1a5 100644 --- a/inc/class-external-permalinks-redux-block-editor.php +++ b/inc/class-external-permalinks-redux-block-editor.php @@ -66,5 +66,18 @@ class External_Permalinks_Redux_Block_Editor { $asset_data['version'], true ); + + wp_localize_script( + $asset_handle, + 'externalPermalinksReduxConfig', + array( + 'metaKeys' => array( + 'target' => external_permalinks_redux::get_instance()->meta_key_target, + 'type' => external_permalinks_redux::get_instance()->meta_key_type, + ), + 'postTypes' => external_permalinks_redux::get_instance()->post_types, + 'statusCodes' => external_permalinks_redux::get_instance()->status_codes, + ) + ); } }