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

Sharing: revert changes to echo inline sharing js #6641

Closed
wants to merge 2 commits into from

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Mar 13, 2017

Fixes #6640
Reverts changes introduced in #6339

$service->display_footer() includes calls to js_dialog when not using Jetpack's Official sharing buttons.
js_dialog often uses wp_add_inline_script(), thus recreating the issues described in #6640.

Testing instructions:

  1. Enable Sharing
  2. Add a few non-official sharing buttons to your posts, like Facebook, Google+, and Twitter.
  3. Open one of your posts.
  4. When clicking on a sharing button, sharing windows should open in a small pop-up. Before this PR, and since Remove unused JS logic in email sharing #6339, they opened in a separate window since inline scripts for each button weren't outputted on the page.

Proposed changelog entry for your changes:

  • Sharing: make sure that sharing buttons open in a small pop-up instead of a separate window.

cc @kasparsd who worked on the original PR.

Fixes #6640
Reverts changes introduced in #6339

`$service->display_footer()` includes calls to `js_dialog` when not using Jetpack's Official sharing buttons.
`js_dialog` often uses `wp_add_inline_script()`, thus recreating the issues described in #6640.
@jeherve jeherve added [Feature] Sharing Post sharing, sharing buttons [Pri] BLOCKER [Status] Needs Review This PR is ready for review. [Type] Bug When a feature is broken and / or not performing as intended labels Mar 13, 2017
@jeherve jeherve added this to the 4.7.1 milestone Mar 13, 2017
@jeherve jeherve self-assigned this Mar 13, 2017
@jeherve jeherve requested review from zinigor and dereksmart March 13, 2017 18:16
Copy link
Member

@zinigor zinigor left a comment

Choose a reason for hiding this comment

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

Fixes the problem, plus does not cause regressions WRT #6339. Thanks!

@kasparsd
Copy link
Contributor

Before this PR, and since #6339, they opened in a separate window since inline scripts for each button weren't outputted on the page.

I'm not sure I follow this. #6339 only moved the inline scripts to a later wp_footer hook which is after all the JS has been printed. Moving it back before the jQuery is loaded will cause the same issue as before.

Copy link
Member

@zinigor zinigor left a comment

Choose a reason for hiding this comment

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

OK, I forgot to test against the error that was caused by loading scripts in the footer, disregard my earlier review.

@zinigor zinigor self-assigned this Mar 14, 2017
@jeherve
Copy link
Member Author

jeherve commented Mar 14, 2017

Moving it back before the jQuery is loaded will cause the same issue as before.

That's correct. This PR is only reverting the changes introduced in #6339, since they stopped Jetpack from outputting inline sharing scripts in the footer.

@kasparsd
Copy link
Contributor

@jeherve Looks like we're good, if we don't add back that unused jQuery call:

jQuery( document ).ready( function(){ document.getElementById('jetpack-source_f_name').value = '' });

@kasparsd
Copy link
Contributor

And a permanent fix is to ensure that all display_footer() methods use wp_add_inline_script() instead of a direct JS output if they depend on jQuery being loaded.

@zinigor
Copy link
Member

zinigor commented Mar 14, 2017

I have added wrapping of display_footer script output with wp_add_inline_script. Everything seems to be working fine with footer output of jQuery, but this turned into a quite heavy PR.

@kasparsd how do you find jQuery loading in the footer working for you? I'm having problems running my testing site like that because some themes try to use it in the header, notably TwentySeventeen.

@jeherve how would you feel about that change going into the point release?

cc @dereksmart @eliorivero for a second glance. You can find testing instructions in the description and comments to #6339

@kasparsd
Copy link
Contributor

kasparsd commented Mar 14, 2017

@zinigor Loading jQuery in the footer works fine now.

@zinigor How about refactoring the popup opener to properly escape the $name and $opts variables kasparsd@fb7847d

Copy link
Contributor

@eliorivero eliorivero left a comment

Choose a reason for hiding this comment

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

Works fine, 🐑

@eliorivero eliorivero added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Mar 14, 2017
@zinigor zinigor removed this from the 4.7.1 milestone Mar 14, 2017
@zinigor
Copy link
Member

zinigor commented Mar 14, 2017

This PR needs more work and more testing, we can't include all this in 4.7.1 sadly. We will work on this one in the following release cycle, plus test all these changes in WordPress.com. We'll also see that all the scripts are properly escaping variables, remove all unneeded ones and clean up existing.

Thanks for contributing to this @kasparsd , your input has been very helpful! I've taken a look at your work in your fork of Jetpack, feel free to create a PR against this repository, we'll take a look.

jeherve added a commit that referenced this pull request Mar 14, 2017
@zinigor zinigor removed the [Status] Ready to Merge Go ahead, you can push that green button! label Mar 14, 2017
@kasparsd
Copy link
Contributor

@zinigor Yeah, this does feel like a major undertaking considering the amount of changes required to get rid of the inline jQuery calls.

@jeherve
Copy link
Member Author

jeherve commented Mar 14, 2017

Closing this PR for now.

@kasparsd It looks like you're making some good progress with kasparsd#1

Feel free to open a PR against automattic/jetpack when ready, we can continue from there!

Thanks!

@jeherve jeherve closed this Mar 14, 2017
dereksmart pushed a commit that referenced this pull request Mar 14, 2017
* Changelog: add #6641

* Changelog: add #6647

* Changelog: add #6631

* Changelog: add #6630

* Changelog: update release date.
dereksmart pushed a commit that referenced this pull request Mar 14, 2017
* Changelog: add #6641

* Changelog: add #6647

* Changelog: add #6631

* Changelog: add #6630

* Changelog: update release date.
@kraftbj kraftbj deleted the fix/sharing-6339 branch May 24, 2019 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Sharing Post sharing, sharing buttons Touches WP.com Files [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.

5 participants