From b69f76567d5eefb6168dab2cd36776e2ec16a29a Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Mon, 5 Feb 2018 09:10:29 -0500 Subject: [PATCH] Change method for adding Gutenberg metabox --- .../class-displayfeaturedimagegenesis-postmeta.php | 13 +++++++++---- includes/class-displayfeaturedimagegenesis.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/includes/class-displayfeaturedimagegenesis-postmeta.php b/includes/class-displayfeaturedimagegenesis-postmeta.php index c0f4e42..aa3d200 100644 --- a/includes/class-displayfeaturedimagegenesis-postmeta.php +++ b/includes/class-displayfeaturedimagegenesis-postmeta.php @@ -28,6 +28,15 @@ class Display_Featured_Image_Genesis_Post_Meta { */ protected $move = '_displayfeaturedimagegenesis_move'; + /** + * Add a new metabox only on Gutenberg screens. + * + * @since 2.7.0 + */ + public function maybe_add_metabox() { + add_action( 'add_meta_boxes', array( $this, 'add_metabox' ), 10, 2 ); + } + /** * For Gutenberg, add a new metabox, since the thumbnail hooks are no longer present. * Should eventually be replaced with a block. @@ -40,10 +49,6 @@ class Display_Featured_Image_Genesis_Post_Meta { if ( ! post_type_supports( $post_type, 'thumbnail' ) ) { return; } - $classic_editor = filter_input( INPUT_GET, 'classic-editor', FILTER_VALIDATE_BOOLEAN ); - if ( null !== $classic_editor ) { - return; - } add_meta_box( $this->metabox, __( 'Display Featured Image', 'display-featured-image-genesis' ), diff --git a/includes/class-displayfeaturedimagegenesis.php b/includes/class-displayfeaturedimagegenesis.php index 3611511..368ce54 100644 --- a/includes/class-displayfeaturedimagegenesis.php +++ b/includes/class-displayfeaturedimagegenesis.php @@ -148,7 +148,7 @@ class Display_Featured_Image_Genesis { add_action( 'admin_init', array( $this->author, 'set_author_meta' ) ); // Post Meta - add_action( 'add_meta_boxes', array( $this->post_meta, 'add_metabox' ), 10, 2 ); + add_action( 'enqueue_block_assets', array( $this->post_meta, 'maybe_add_metabox' ) ); add_filter( 'admin_post_thumbnail_html', array( $this->post_meta, 'meta_box' ), 10, 2 ); add_action( 'save_post', array( $this->post_meta, 'save_meta' ) );