Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Saving in Classic Editor shouldn't redirect to Gutenberg #2709

Merged
merged 2 commits into from
Sep 27, 2017

Conversation

aaronjorbin
Copy link
Member

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

lib/register.php Outdated
@@ -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 ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be more specific about these referrers, in case post.php occurs as a suffix for a file, or query parameter, or otherwise? Maybe:

0 === strpos( parse_url( admin_url( 'post.php' ), PHP_URL_PATH ), $sendback )

lib/register.php Outdated
$sendback = wp_get_referer();
if ( $sendback && (
strpos( $sendback, 'post.php' ) !== false ||
strpos( $sendback, 'post-new.php' ) !== false ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the space indenting here be a tab? It's not clear by the PHP standards, but the JavaScript standards are more specific about this case:

When a conditional is too long to fit on one line, successive lines must be indented one extra level to distinguish them from the body.

https://make.wordpress.org/core/handbook/best-practices/coding-standards/javascript/#multi-line-statements

i.e.

if ( $sendback && (
		strpos( $sendback, 'post.php' ) !== false ||
		strpos( $sendback, 'post-new.php' ) !== false ) ) {
	return $url;
}

aaronjorbin and others added 2 commits September 27, 2017 08:54
`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
@aduth aduth merged commit 8c06c40 into master Sep 27, 2017
@aduth aduth deleted the update/edit-post-links branch September 27, 2017 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants