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

Mobile: Hide edit post link in content #12867

Merged
merged 4 commits into from
Jul 4, 2019
Merged

Conversation

donpark
Copy link
Contributor

@donpark donpark commented Jun 26, 2019

Changes proposed in this Pull Request:

Adds an edit_post_link filter to return empty string if request is from an WordPress mobile app.

Hides edit post link in post content if client is a WordPress mobile app.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

No. This is a manual sync PR for D29686-code.

See trac link in the patch for more detail on the issue this PR and the mentioned patch addresses.

Testing instructions:

  1. Use a browser that lets you change User-Agent easily. Chrome, for example, has User agent settings under Three Dot menu > More tools > Network conditions.
  2. View a post you have edit permission to using Chrome browser with default User-Agent.
  3. Verify that Edit link is displayed.

screenshot_726

  1. Add wp-iphone/1.0 or wp-android to User-Agent string and refresh the page.

screenshot_725

  1. Verify that Edit link is no longer displayed.

Proposed changelog entry for your changes:

Hide edit post link in post content if client is a WordPress mobile app.

@donpark donpark requested a review from a team June 26, 2019 15:42
@donpark donpark self-assigned this Jun 26, 2019
@donpark donpark added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Package] Sync labels Jun 26, 2019
@jetpackbot
Copy link

jetpackbot commented Jun 26, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: July 2, 2019.
Scheduled code freeze: June 25, 2019

Generated by 🚫 dangerJS against f9a90bc

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Do you think it would make sense to shorten this into something like:

if ( Jetpack_User_Agent_Info::is_mobile_app() ) {
	add_filter( 'edit_post_link', '__return_empty_string' );
}

Should we also consider moving this out of the Minileven module, so it can be applied regardless of the theme you are using, and even if the mobile theme feature / module is not enabled on your site?

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Feature] Mobile Theme aka minileven [Status] Tested on WP.com and removed [Package] Sync [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jun 26, 2019
@donpark
Copy link
Contributor Author

donpark commented Jun 27, 2019

Do you think it would make sense to shorten this into something like:

if ( Jetpack_User_Agent_Info::is_mobile_app() ) {
	add_filter( 'edit_post_link', '__return_empty_string' );
}

Ha. Yes, init-per-request mindset is still a stranger to me.

Should we also consider moving this out of the Minileven module, so it can be applied regardless of the theme you are using, and even if the mobile theme feature / module is not enabled on your site?

Can you suggest the ideal place for this code? I just followed where wp-mobile.php function names pointed to.

@jeherve
Copy link
Member

jeherve commented Jun 27, 2019

Can you suggest the ideal place for this code? I just followed where wp-mobile.php function names pointed to.

It may be best to place it in class.jetpack.php. That file is already way too big, but it's really the only place where it fits well right now. You'll actually find other edit post link changes in there (look for point_edit_post_links_to_calypso) :)

@donpark donpark added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jun 27, 2019
@donpark donpark requested a review from jeherve June 27, 2019 22:52
@donpark
Copy link
Contributor Author

donpark commented Jun 27, 2019

Result of my test against my wpsandbox.me site using the latest:

Without this patch:

screenshot_736

With this patch:

screenshot_735

@jeherve jeherve added this to the 7.6 milestone Jul 3, 2019
@jeherve jeherve added General [Status] Ready to Merge Go ahead, you can push that green button! and removed [Feature] Mobile Theme aka minileven [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jul 3, 2019
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This works well for me. 👍

@jeherve jeherve merged commit 706cdfd into master Jul 4, 2019
@jeherve jeherve deleted the mobile/hide-edit-post-link branch July 4, 2019 17:36
@matticbot matticbot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jul 4, 2019
jeherve added a commit that referenced this pull request Jul 19, 2019
jeherve added a commit that referenced this pull request Jul 30, 2019
* Add initial changelog / testing list changes for 7.6

* Update stable tag to 7.5.3

* changelog: add #12957

* Changelog: add #12932

* Changelog: add #12867

* Changelog: add #12823

* changelog: add #12969

* changelog: add #13012

* changelog: add #12974

* Changelog: add #13059

* Changelog: add #13079

* Changelog: add #12924

* changelog: add #12954

* Changelog: add #12959

* Changelog: add #12977

* Changelog: add #12830

* Changelog: add #12926

* Changelog: add #12958

* Changelog: add #12999

* Changelog: add #13077

* Changelog: add #13083

* Changelog: add #13087

* Changelog: add #13110

* Changelog: add #13116

* Changelog: add #13117

* Changelog: add #12821

* Changelog: add #13120

* changelog: add #13139

* Changelog: add #13143

* Changelog: add #13147

* Testing list: add section about sync
jeherve added a commit that referenced this pull request Jul 30, 2019
* Add initial changelog / testing list changes for 7.6

* Update stable tag to 7.5.3

* changelog: add #12957

* Changelog: add #12932

* Changelog: add #12867

* Changelog: add #12823

* changelog: add #12969

* changelog: add #13012

* changelog: add #12974

* Changelog: add #13059

* Changelog: add #13079

* Changelog: add #12924

* changelog: add #12954

* Changelog: add #12959

* Changelog: add #12977

* Changelog: add #12830

* Changelog: add #12926

* Changelog: add #12958

* Changelog: add #12999

* Changelog: add #13077

* Changelog: add #13083

* Changelog: add #13087

* Changelog: add #13110

* Changelog: add #13116

* Changelog: add #13117

* Changelog: add #12821

* Changelog: add #13120

* changelog: add #13139

* Changelog: add #13143

* Changelog: add #13147

* Testing list: add section about sync
jeherve added a commit that referenced this pull request Jan 29, 2020
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
dereksmart pushed a commit that referenced this pull request Feb 12, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants