-
Notifications
You must be signed in to change notification settings - Fork 815
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
Calling sharing_add_footer after (!) wp_print_footer_scripts in wp_footer to ensure jQuery dependancy #1223
Comments
+1 for this. Alternative is to remove the footer calls and use the wp_enqueue_scripts hook and do: global $wp_scripts;
$wp_scripts->add_data( 'jquery', 'data', $jetpack_sharing_scripts ); I can submit a pull request if this would be ideal. A drawback is that the scripts will show up in the header if jQuery is enqueued in the header. |
An elegant baked-in solution would be nice. Too many hacks in this script to get this to work with enqueuing: https://gist.github.com/ronalfy/3d5de0527095ff00907b |
…-priority Change "sharing_add_footer" priority to temporarily fix jQuery undefined console errors when using ShareDaddy with jQuery enqueued in the footer (#1223)
Priority higher or equal to 20 causes the sharing library not to be enqueued at all in some cases See #1223
…ned console errors when using ShareDaddy with jQuery enqueued in the footer
I’m still seeing this issue with Jetpack 3.9.6 and WP 4.5. Changing the action priority of In WP 4.5, there is https://developer.wordpress.org/reference/functions/wp_add_inline_script/ |
Yes, we aim for Jetpack to be compatible with the current version and one major version before that, so we'll need to wait for WordPress 4.6 to be released before to require 4.5+. |
Also reported in 59964-zd-vip |
I updated my original report with a link to the actual script from |
@jeherve 4.7 has been released so we could create a PR for this? |
@jeherve I think the JS |
* Remove unused JS logic Fixes #1223 * Print inline scripts after WP is done with footer scripts Ensures that dependencies are met.
Reopening as we had to revert this in #6649. This was explained in #6641. Next steps to get this fixed once and for all are described here: |
3128393-t |
related: link |
This issue has been marked as stale. This happened because:
No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation. |
Currently
sharing_add_footer
is being attached towp_footer
with priority 10 which is before WordPress has printed the footer scripts aswp_print_footer_scripts
is attached towp_footer
with priority 20.sharing_add_footer
echoes inline Javascript duringdisplay_footer()
(here is an example) which depends on jQuery being already available. This fails in cases when jQuery is enqueued in the footer.The solution is to move
sharing_add_footer
to a later priority:The text was updated successfully, but these errors were encountered: