Skip to content

Commit

Permalink
FIX: Saving in Classic Editor shouldn't redirect to Gutenberg
Browse files Browse the repository at this point in the history
`get_edit_post_link` is used in `post.php` to redirect when saving. See https://core.trac.wordpress.org/browser/trunk/src/wp-admin/post.php#L190

By checking to see if the referer is the classic editor, modification to the edit post link is preserved.

Introduced in #1797
Fixes #2707
  • Loading branch information
aaronjorbin authored and aduth committed Sep 27, 2017
1 parent feccae8 commit 0c79d75
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/register.php
Expand Up @@ -221,6 +221,13 @@ function gutenberg_get_edit_post_url( $post_id ) {
* @return string Edit post link.
*/
function gutenberg_filter_edit_post_link( $url, $post_id, $context ) {
$sendback = wp_get_referer();
if ( $sendback && (
strpos( $sendback, 'post.php' ) !== false ||
strpos( $sendback, 'post-new.php' ) !== false ) ) {
return $url;
}

$post = get_post( $post_id );
if ( gutenberg_can_edit_post( $post_id ) && gutenberg_post_has_blocks( $post_id ) && post_type_supports( get_post_type( $post_id ), 'editor' ) ) {
$gutenberg_url = gutenberg_get_edit_post_url( $post->ID );
Expand Down

0 comments on commit 0c79d75

Please sign in to comment.