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 Apps: completely remove the edit post link when in app #14514

Merged
merged 1 commit into from
Feb 12, 2020

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Jan 29, 2020

Fixes wordpress-mobile/WordPress-iOS#13314

Changes proposed in this Pull Request:

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

Matching WordPress.com reference: D38302-code

Testing instructions:

  • Start from a Jetpack site using the Twenty Nineteen theme.
  • Connect your site to WordPress.com.
  • Open your site's frontend in your browser.
  • In your browser tools, change your user agent to wordpress/3.1:
    image
  • Reload the page.
  • You should see a little pencil icon at the bottom of your posts, but no "Edit" text or link.
  • Now apply this branch.
  • The pencil icon should be completely gone.

Proposed changelog entry for your changes:

  • Mobile Apps: completely remove the edit post link when in app

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
@jeherve jeherve added [Type] Bug When a feature is broken and / or not performing as intended General [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Jan 29, 2020
@jeherve jeherve added this to the 8.3 milestone Jan 29, 2020
@jeherve jeherve requested a review from a team as a code owner January 29, 2020 17:49
@jeherve jeherve self-assigned this Jan 29, 2020
@jetpackbot
Copy link

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: February 11, 2020.
Scheduled code freeze: February 4, 2020

Generated by 🚫 dangerJS against 36fe271

Copy link

@designsimply designsimply left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

I tested using the Twenty Twenty theme with the code change applied and I was able to see that the edit link and the edit icon were both removed from Webviews in WPiOS 14.1.0.0 TestFlight beta on iPhone 6S iOS 13.3.

Before After
IMG_3289 IMG_3290

I also verified that I can still see the edit link when viewing the post from Safari directly while logged in as an admin on the site.

IMG_3291

@dereksmart dereksmart merged commit 843056a into master Feb 12, 2020
@dereksmart dereksmart deleted the fix/edit-links-app branch February 12, 2020 20:32
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Feb 12, 2020
jeherve added a commit that referenced this pull request Feb 25, 2020
jeherve added a commit that referenced this pull request Feb 25, 2020
* 8.3 release: changelog

* Changelog: add #14516

* Changelog: add #14574

* Bring in changes from 8.2.1 and 8.2.2

* Update stable version

* Bring in 8.2.3 changes

* Changelog: add #14714

* Changelog: add #14639

* Changelog: add #14678

* Changelog: add #14673

* Changelog: add #14687

* Changelog: add #14704

* Changelog: add #14702

* Changelog: add #14541

* Changelog: add #14657

* Changelog: add #14622

* Changelog: add #14582

* Changelog: add #14638

* Changelog: add #14633

* Changelog: add #14571

* Changelog: add #14592

* Changelog: add #14539

* Changelog: add #14514

* Changelog: add #14643

* Changelog: add #14494

* Changelog: add #13739

* Changelog: add #14707

* Changelog: add #14736

* Changelog: add #14706

* Changelog: add #14730

* Changelog: add #14685

* Changelog: add #14727

* Changelog: add #14711

* Changelog: add #14742

* Changelog: add #14746

* Changelog: add #14725

* Changelog: add #13999

* Changelog: add #14740

* Changelog: add #14759

* Changelog: add #14703

* Changelog: add #14753

* Changelog: add #14754

* Changelog: add #14645

* Cahngelog: add #14599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GlobalStep] Non-functional edit button present when viewing own site.
5 participants