Skip to content

Commit

Permalink
Mobile Apps: completely remove the edit post link when in app
Browse files Browse the repository at this point in the history
Fixes wordpress-mobile/WordPress-iOS#13314

This issue was introduced in #12867.

The original goal of this change was to to hide the Edit Post link
whenever you would access your site via the mobile app's in-app browser.

To hide the Edit Post link, we originally opted to hook into the edit_post_link filter.
While this works, it only changes the string returned for the Edit Post link itself.
It does not account for any "before" or "after" parameters that may be passed
when calling the edit_post_link function; those are not part of the filter:
https://github.com/WordPress/WordPress/blob/001ffe81fbec4438a9f594f330e18103d21fbcd7/wp-includes/link-template.php#L1439

Instead, let's shortcircuit that link earlier, by hooking into the get_edit_post_link filter.
If that filter is set to return an empty string, the edit_post_link function will return early:
https://github.com/WordPress/WordPress/blob/001ffe81fbec4438a9f594f330e18103d21fbcd7/wp-includes/link-template.php#L1420
  • Loading branch information
jeherve committed Jan 29, 2020
1 parent e9ce145 commit 36fe271
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion class.jetpack.php
Expand Up @@ -641,7 +641,7 @@ function( $callable ) {

// Hide edit post link if mobile app.
if ( Jetpack_User_Agent_Info::is_mobile_app() ) {
add_filter( 'edit_post_link', '__return_empty_string' );
add_filter( 'get_edit_post_link', '__return_empty_string' );
}

// Update the Jetpack plan from API on heartbeats
Expand Down

0 comments on commit 36fe271

Please sign in to comment.