Skip to content
Snippets Groups Projects
Commit 53b2267f authored by Erick Hitter's avatar Erick Hitter
Browse files

Register meta

parent 79c5bec1
No related branches found
No related tags found
1 merge request!14Add native block-editor support
......@@ -41,9 +41,59 @@ class External_Permalinks_Redux_Block_Editor {
* @return void
*/
protected function _setup() {
add_action( 'rest_api_init', array( $this, 'register_meta' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue' ) );
}
/**
* Register meta for access in block editor.
*
* @return void
*/
public function register_meta() {
global $wp_version;
if (
! function_exists( 'register_meta' )
|| version_compare( $wp_version, '4.6.0', '<' )
) {
return;
}
register_meta(
'post',
external_permalinks_redux::get_instance()->meta_key_target,
array(
'default' => '',
'description' => __(
'Redirect destination',
'external-permalinks-redux'
),
'type' => 'string',
'sanitize_callback' => 'esc_url_raw',
'show_in_rest' => true,
'single' => true,
)
);
register_meta(
'post',
external_permalinks_redux::get_instance()->meta_key_type,
array(
// Matches fallback in `external_permalinks_redux::get_redirect_data()`
'default' => 302,
'description' => __(
'Redirect status code',
'external-permalinks-redux'
),
'type' => 'integer',
'sanitize_callback' => 'absint',
'show_in_rest' => true,
'single' => true,
)
);
}
/**
* Enqueue block-editor script.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment