Skip to content

Commit

Permalink
Compat: Test classic referrer using admin_url
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Sep 27, 2017
1 parent 0c79d75 commit 4abf259
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ function gutenberg_get_edit_post_url( $post_id ) {
* @return string Edit post link.
*/
function gutenberg_filter_edit_post_link( $url, $post_id, $context ) {
// Avoid redirect to Gutenberg after saving a block post in Classic editor.
$sendback = wp_get_referer();
if ( $sendback && (
strpos( $sendback, 'post.php' ) !== false ||
strpos( $sendback, 'post-new.php' ) !== false ) ) {
0 === strpos( $sendback, parse_url( admin_url( 'post.php' ), PHP_URL_PATH ) ) ||
0 === strpos( $sendback, parse_url( admin_url( 'post-new.php' ), PHP_URL_PATH ) ) ) ) {
return $url;
}

Expand Down

0 comments on commit 4abf259

Please sign in to comment.