Editor: Add the `replace_editor` filter.

This filter allows the Core editor to be replaced by an entirely different editor (coughcoughGUTENBERGcough).

Props azaozz, who is supposed to be on sabbatical right now.
Fixes #42119.


Built from https://develop.svn.wordpress.org/trunk@41829


git-svn-id: http://core.svn.wordpress.org/trunk@41663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2017-10-11 12:06:48 +00:00
parent 8b4a8b6c15
commit a72be13ec0
4 changed files with 32 additions and 27 deletions

View File

@ -17,6 +17,17 @@ if ( !defined('ABSPATH') )
*/
global $post_type, $post_type_object, $post;
if ( is_multisite() ) {
add_action( 'admin_footer', '_admin_notice_post_locked' );
} else {
$check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
if ( count( $check_users ) > 1 )
add_action( 'admin_footer', '_admin_notice_post_locked' );
unset( $check_users );
}
wp_enqueue_script('post');
$_wp_editor_expand = $_content_editor_dfw = false;

View File

@ -63,24 +63,17 @@ if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_
}
// Schedule auto-draft cleanup
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) )
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
wp_enqueue_script( 'autosave' );
if ( is_multisite() ) {
add_action( 'admin_footer', '_admin_notice_post_locked' );
} else {
$check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
if ( count( $check_users ) > 1 )
add_action( 'admin_footer', '_admin_notice_post_locked' );
unset( $check_users );
}
// Show post form.
$post = get_default_post_to_edit( $post_type, true );
$post_ID = $post->ID;
include( ABSPATH . 'wp-admin/edit-form-advanced.php' );
/** This filter is documented in wp-admin/post.php */
if ( apply_filters( 'replace_editor', false, $post ) !== true ) {
wp_enqueue_script( 'autosave' );
include( ABSPATH . 'wp-admin/edit-form-advanced.php' );
}
include( ABSPATH . 'wp-admin/admin-footer.php' );

View File

@ -144,6 +144,18 @@ case 'edit':
$post_new_file = "post-new.php?post_type=$post_type";
}
/**
* Allows replacement of the editor.
*
* @since 4.9.0
*
* @param boolean Whether to replace the editor. Default false.
* @param object $post Post object.
*/
if ( apply_filters( 'replace_editor', false, $post ) === true ) {
break;
}
if ( ! wp_check_post_lock( $post->ID ) ) {
$active_post_lock = wp_set_post_lock( $post->ID );
@ -151,17 +163,6 @@ case 'edit':
wp_enqueue_script('autosave');
}
if ( is_multisite() ) {
add_action( 'admin_footer', '_admin_notice_post_locked' );
} else {
$check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
if ( count( $check_users ) > 1 )
add_action( 'admin_footer', '_admin_notice_post_locked' );
unset( $check_users );
}
$title = $post_type_object->labels->edit_item;
$post = get_post($post_id, OBJECT, 'edit');

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta1-41828';
$wp_version = '4.9-beta1-41829';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.