From 36fe2713ddc8a2387ab6e90628b14de137b050b7 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Wed, 29 Jan 2020 18:39:08 +0100 Subject: [PATCH] Mobile Apps: completely remove the edit post link when in app Fixes https://github.com/wordpress-mobile/WordPress-iOS/issues/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 --- class.jetpack.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class.jetpack.php b/class.jetpack.php index ff8aa0738a109..f5b98e9d101a9 100644 --- a/class.jetpack.php +++ b/class.jetpack.php @@ -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