Skip to content

Commit

Permalink
Plugin: Remove lingering references to integrated Classic Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jan 29, 2019
1 parent 92a1073 commit f7235c6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ The Gutenberg project's deprecation policy is intended to support backward compa
- The PHP function `gutenberg_collect_meta_box_data` has been removed. Use [`register_and_do_post_meta_boxes`](https://developer.wordpress.org/reference/functions/register_and_do_post_meta_boxes/) instead.
- `window._wpLoadGutenbergEditor` has been removed. Use `window._wpLoadBlockEditor` instead. Note: This is a private API, not intended for public use. It may be removed in the future.
- The PHP function `gutenberg_get_script_polyfill` has been removed. Use [`wp_get_script_polyfill`](https://developer.wordpress.org/reference/functions/wp_get_script_polyfill/) instead.
- 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.

## 4.5.0
- `Dropdown.refresh()` has been deprecated as the contained `Popover` is now automatically refreshed.
Expand Down
24 changes: 5 additions & 19 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,11 @@ function the_gutenberg_project() {
<noscript>
<div class="error" style="position:absolute;top:32px;z-index:40"><p>
<?php
// Using Gutenberg as Plugin.
if ( is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
$current_url = esc_url( add_query_arg( 'classic-editor', true, $_SERVER['REQUEST_URI'] ) );
printf(
// Translators: link is to current page specify classic editor.
__( 'The Block Editor requires JavaScript. You can use the <a href="%s">Classic Editor</a>.', 'gutenberg' ),
$current_url
);
} else { // Using Gutenberg in Core.
printf(
/* translators: %s: https://wordpress.org/plugins/classic-editor/ */
__( 'The Block Editor requires JavaScript. Please try the <a href="%s">Classic Editor plugin</a>.', 'gutenberg' ),
__( 'https://wordpress.org/plugins/classic-editor/', 'gutenberg' )
);
}
printf(
/* translators: %s: https://wordpress.org/plugins/classic-editor/ */
__( 'The Block Editor requires JavaScript. Please try the <a href="%s">Classic Editor plugin</a>.', 'gutenberg' ),
__( 'https://wordpress.org/plugins/classic-editor/', 'gutenberg' )
);
?>
</p></div>
</noscript>
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,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 ),
);
}

Expand Down
32 changes: 10 additions & 22 deletions lib/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
?>
<input type="hidden" name="classic-editor" />
<?php
_deprecated_function( __FUNCTION__, '5.0.0' );
}
add_action( 'edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts' );

/**
* Appends a query argument to the redirect url to make sure it gets redirected to the classic editor.
*
* @since 1.5.2
* @deprecated 5.0.0
*
* @param string $url Redirect url.
* @return string Redirect url.
*/
function gutenberg_redirect_to_classic_editor_when_saving_posts( $url ) {
if ( isset( $_REQUEST['classic-editor'] ) ) {
$url = add_query_arg( 'classic-editor', '', $url );
}
_deprecated_function( __FUNCTION__, '5.0.0' );

return $url;
}
add_filter( 'redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts', 10, 1 );

/**
* Appends a query argument to the edit url to make sure it is redirected to
* the editor from which the user navigated.
*
* @since 1.5.2
* @deprecated 5.0.0
*
* @param string $url Edit url.
* @return string Edit url.
*/
function gutenberg_revisions_link_to_editor( $url ) {
global $pagenow;
if ( 'revision.php' !== $pagenow || isset( $_REQUEST['gutenberg'] ) ) {
return $url;
}
_deprecated_function( __FUNCTION__, '5.0.0' );

return add_query_arg( 'classic-editor', '', $url );
return $url;
}
add_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );

/**
* Modifies revisions data to preserve Gutenberg argument used in determining
* where to redirect user returning to editor.
*
* @since 1.9.0
* @deprecated 5.0.0
*
* @param array $revisions_data The bootstrapped data for the revisions screen.
* @return array Modified bootstrapped data for the revisions screen.
*/
function gutenberg_revisions_restore( $revisions_data ) {
if ( isset( $_REQUEST['gutenberg'] ) ) {
$revisions_data['restoreUrl'] = add_query_arg(
'gutenberg',
$_REQUEST['gutenberg'],
$revisions_data['restoreUrl']
);
}
_deprecated_function( __FUNCTION__, '5.0.0' );

return $revisions_data;
}
add_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
37 changes: 0 additions & 37 deletions phpunit/class-admin-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,41 +140,4 @@ function test_gutenberg_content_has_blocks() {
$this->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 );
}
}

0 comments on commit f7235c6

Please sign in to comment.