Skip to content

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
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 force-pushed the update/edit-post-links branch from b9511b5 to 4abf259 Compare September 27, 2017 12:54
@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.

3 participants