From 11846ab698a201d8544de5df550b2d8c28bf272f Mon Sep 17 00:00:00 2001 From: Luis Felipe Zaguini <26530524+zaguiini@users.noreply.github.com> Date: Thu, 5 Sep 2024 00:10:33 -0300 Subject: [PATCH] Use template instead of the default_content hook to modify the CM placeholder (#122) --- .../manager/class-content-model-loader.php | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/includes/manager/class-content-model-loader.php b/includes/manager/class-content-model-loader.php index ef3f2cf..7698e82 100644 --- a/includes/manager/class-content-model-loader.php +++ b/includes/manager/class-content-model-loader.php @@ -63,10 +63,9 @@ private function __construct() { add_action( 'the_post', array( $this, 'map_template_to_content_model_editor_signature' ) ); /** - * Update placeholder prompts to be more suitable for creating a new model. + * Update title placeholder to be more suitable for creating a new model. */ add_filter( 'enter_title_here', array( $this, 'set_title_placeholder' ), 10, 2 ); - add_filter( 'default_content', array( $this, 'set_content_placeholder' ), 10, 2 ); } /** @@ -111,6 +110,12 @@ private function register_post_type() { 'show_in_menu' => true, 'show_in_rest' => true, 'supports' => array( 'title', 'editor', 'custom-fields' ), + 'template' => array( + array( + 'core/paragraph', + array( 'placeholder' => __( 'Start building your model' ) ), + ), + ), ) ); @@ -329,22 +334,4 @@ public function set_title_placeholder( $title, $post ) { } return $title; } - - /** - * Sets the content placeholder for the Content Model post type. - * - * @param string $content The default content. - * @param WP_Post $post The current post object. - * @return string The modified default content. - */ - public function set_content_placeholder( $content, $post ) { - if ( Content_Model_Manager::POST_TYPE_NAME === $post->post_type ) { - $placeholder = __( 'Start building your model' ); - return sprintf( - '

', - esc_attr( $placeholder ) - ); - } - return $content; - } }