false, ) ); } add_action( 'add_meta_boxes', __NAMESPACE__ . '\replace_metabox' ); /** * Replace the meta box contents. * * @param WP_Post $post The current post object. */ function render_metabox( $post ) { $settings = array( 'media_buttons' => false, 'teeny' => true, ); /** * Filter the settings passed to wp_editor() for the post excerpt. * * @see wp_editor() * * @param array $settings Settings for wp_editor(). */ $settings = apply_filters( 'ape_editor_settings', $settings ); wp_editor( html_entity_decode( $post->post_excerpt ), 'excerpt', $settings ); } /** * Remove the alignment buttons from the post excerpt WYSIWYG. * * @param array $buttons An array of teenyMCE buttons. * @param string $editor_id A unique identifier for the TinyMCE instance. * @return array The $buttons array, minus alignment actions. */ function remove_alignment_buttons( $buttons, $editor_id ) { if ( 'excerpt' === $editor_id ) { $buttons = array_values( array_diff( $buttons, [ 'alignleft', 'alignright', 'aligncenter' ] ) ); } return $buttons; } add_filter( 'teeny_mce_buttons', __NAMESPACE__ . '\remove_alignment_buttons', 10, 2 ); /** * Register the script to remove the "Post Excerpt" panel from the block editor. */ function remove_panel_from_block_editor() { wp_enqueue_script( 'advanced-post-excerpt', plugins_url( 'js/advanced-post-excerpt.js', __FILE__ ), array( 'wp-edit-post' ), PLUGIN_VERSION, true ); } add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\remove_panel_from_block_editor' );