From 1481c1c504c9cb6cd0131ad0bd94ff547fbd8ca0 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Wed, 6 Feb 2019 15:25:51 -0500 Subject: [PATCH] Plugin: Remove lingering references to integrated classic editor (#13544) * Docs: Update meta box document to reflect core behavior * Plugin: Remove lingering references to integrated Classic Editor --- .../backward-compatibility/deprecations.md | 6 +++ .../backward-compatibility/meta-box.md | 14 +++---- gutenberg.php | 24 +++--------- lib/client-assets.php | 2 +- lib/register.php | 32 +++++----------- phpunit/class-admin-test.php | 37 ------------------- 6 files changed, 27 insertions(+), 88 deletions(-) diff --git a/docs/designers-developers/developers/backward-compatibility/deprecations.md b/docs/designers-developers/developers/backward-compatibility/deprecations.md index 62752b2c54d6f0..a5db81f7514f56 100644 --- a/docs/designers-developers/developers/backward-compatibility/deprecations.md +++ b/docs/designers-developers/developers/backward-compatibility/deprecations.md @@ -2,6 +2,12 @@ The Gutenberg project's deprecation policy is intended to support backward compatibility for releases, when possible. The current deprecations are listed below and are grouped by _the version at which they will be removed completely_. If your plugin depends on these behaviors, you must update to the recommended alternative before the noted version. +## 5.3.0 + +- The PHP function `gutenberg_redirect_to_classic_editor_when_saving_posts` has been removed. +- The PHP function `gutenberg_revisions_link_to_editor` has been removed. +- The PHP function `gutenberg_remember_classic_editor_when_saving_posts` has been removed. + ## 5.2.0 - The PHP function `gutenberg_parse_blocks` has been removed. Use [`parse_blocks`](https://developer.wordpress.org/reference/functions/parse_blocks/) instead. diff --git a/docs/designers-developers/developers/backward-compatibility/meta-box.md b/docs/designers-developers/developers/backward-compatibility/meta-box.md index e6268e6924ea90..18feca91ceed2a 100644 --- a/docs/designers-developers/developers/backward-compatibility/meta-box.md +++ b/docs/designers-developers/developers/backward-compatibility/meta-box.md @@ -38,11 +38,11 @@ When Gutenberg is used, this meta box will no longer be displayed in the meta bo On each Gutenberg page load, we register an action that collects the meta box data to determine if an area is empty. The original global state is reset upon collection of meta box data. -See `lib/register.php gutenberg_trick_plugins_into_registering_meta_boxes()` +See [`register_and_do_post_meta_boxes`](https://developer.wordpress.org/reference/functions/register_and_do_post_meta_boxes/). -`gutenberg_collect_meta_box_data()` is hooked in later on `admin_head`. It will run through the functions and hooks that `post.php` runs to register meta boxes; namely `add_meta_boxes`, `add_meta_boxes_{$post->post_type}`, and `do_meta_boxes`. +It will run through the functions and hooks that `post.php` runs to register meta boxes; namely `add_meta_boxes`, `add_meta_boxes_{$post->post_type}`, and `do_meta_boxes`. -A copy of the global `$wp_meta_boxes` is made then filtered through `apply_filters( 'filter_gutenberg_meta_boxes', $_meta_boxes_copy );`, which will strip out any core meta boxes, standard custom taxonomy meta boxes, and any meta boxes that have declared themselves as only existing for backward compatibility purposes. +Meta boxes are filtered to strip out any core meta boxes, standard custom taxonomy meta boxes, and any meta boxes that have declared themselves as only existing for backward compatibility purposes. Then each location for this particular type of meta box is checked for whether it is active. If it is not empty a value of true is stored, if it is empty a value of false is stored. This meta box location data is then dispatched by the editor Redux store in `INITIALIZE_META_BOX_STATE`. @@ -63,13 +63,9 @@ When the post is updated, only meta box areas that are active will be submitted. When the meta box area is saving, we display an updating overlay, to prevent users from changing the form values while a save is in progress. -After the new block editor is made into the default editor, it will be necessary to provide the classic-editor flag to access the meta box partial page. +An example save url would look like: -`gutenberg_meta_box_save()` saves meta box changes. A `meta_box` request parameter should be present and should match one of `'advanced'`, `'normal'`, or `'side'`. This value will determine which meta box area is served. - -So an example url would look like: - -`mysite.com/wp-admin/post.php?post=1&action=edit&meta_box=$location&classic-editor` +`mysite.com/wp-admin/post.php?post=1&action=edit&meta-box-loader=1` This url is automatically passed into React via a `_wpMetaBoxUrl` global variable. diff --git a/gutenberg.php b/gutenberg.php index ed2ad711cd42ff..11e173a033767f 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -31,21 +31,11 @@ function the_gutenberg_project() { @@ -128,10 +118,6 @@ function is_gutenberg_page() { return false; } - if ( isset( $_GET['classic-editor'] ) ) { - return false; - } - if ( ! gutenberg_can_edit_post( $post ) ) { return false; } diff --git a/lib/client-assets.php b/lib/client-assets.php index 1178d245ed875a..97afc6084a41c4 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -1110,7 +1110,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) { $post_autosave = gutenberg_get_autosave_newer_than_post_save( $post ); if ( $post_autosave ) { $editor_settings['autosave'] = array( - 'editLink' => add_query_arg( 'gutenberg', true, get_edit_post_link( $post_autosave->ID ) ), + 'editLink' => get_edit_post_link( $post_autosave->ID ), ); } diff --git a/lib/register.php b/lib/register.php index ebdc43c7f2e5c1..f8f7410d312534 100644 --- a/lib/register.php +++ b/lib/register.php @@ -203,67 +203,55 @@ function gutenberg_bulk_post_updated_messages( $messages ) { * Injects a hidden input in the edit form to propagate the information that classic editor is selected. * * @since 1.5.2 + * @deprecated 5.0.0 */ function gutenberg_remember_classic_editor_when_saving_posts() { - ?> - - assertTrue( gutenberg_content_has_blocks( $content_with_blocks ) ); $this->assertFalse( gutenberg_content_has_blocks( $content_without_blocks ) ); } - - /** - * Test that the revisions 'return to editor' links are set correctly for Classic & Gutenberg editors. - * - * @covers ::gutenberg_revisions_link_to_editor - */ - function test_gutenberg_revisions_link_to_editor() { - global $pagenow; - - // Set up $pagenow so the filter will work. - $pagenow = 'revision.php'; - - // Test the filter when Gutenberg is the active editor. - $_REQUEST['gutenberg'] = '1'; - $link = apply_filters( 'get_edit_post_link', 'http://test.com' ); - $this->assertEquals( 'http://test.com', $link ); - - // Test the filter when Gutenberg is not the active editor. - unset( $_REQUEST['gutenberg'] ); - $link = apply_filters( 'get_edit_post_link', 'http://test.com' ); - $this->assertEquals( 'http://test.com?classic-editor', $link ); - } - - /** - * Test that the revisions 'restore this revision' button links correctly for Classic & Gutenberg editors. - */ - function test_gutenberg_revisions_restore() { - // Test the filter when Gutenberg is the active editor. - $_REQUEST['gutenberg'] = '1'; - $link = apply_filters( 'wp_prepare_revision_for_js', array( 'restoreUrl' => 'http://test.com' ) ); - $this->assertEquals( array( 'restoreUrl' => 'http://test.com?gutenberg=1' ), $link ); - - // Test the filter when Gutenberg is not the active editor. - unset( $_REQUEST['gutenberg'] ); - $link = apply_filters( 'wp_prepare_revision_for_js', array( 'restoreUrl' => 'http://test.com' ) ); - $this->assertEquals( array( 'restoreUrl' => 'http://test.com' ), $link ); - } }