-
Notifications
You must be signed in to change notification settings - Fork 846
Make devicepx library an optional theme feature #10189
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
Conversation
|
That's a great PR description, thank you so much for your effort! Generated by 🚫 dangerJS |
jeherve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. If we make devicepx a tool that can be activated in your theme, it may be useful to move it with the other theme tools in Jetpack, in its own file here:
https://github.com/Automattic/jetpack/tree/master/modules/theme-tools
Here is where those tools are loaded:
https://github.com/Automattic/jetpack/blob/master/modules/module-extras.php#L8
You could then check for Jetpack::is_active() at the top of that new file, and also check for current_theme_supports( 'jetpack-devicepx' ) there. You could even check for AMP there, as we do here for example:
| ! Jetpack_AMP_Support::is_amp_request(); |
@jeherve Makes sense. Do you suggest we add a checkbox to the settings or implement it as code-only option similar to content-options? |
|
I don't think there should be any UI for it. All those theme tools are activated via code. |
jeherve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of this small change?
|
@josephscott With your history with devicepx, wanted to get a check from you for disabling it by default. Any reason we shouldn't? IIRC, when adding srcset support to Photon, our long-term goal was to remove the need for devicepx. |
kasparsd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @kraftbj -- comment added.
|
As a general item, I'd be happy to see devicepx go away entirely. My only concern is for places that assume it will be around and could potentially end up with unexpected results. Devicepx came about because there were not great ways for managing alternate image needs, like DPI ( retina ). Now, we have much better options that don't require JavaScript to be checking things all the time. We certainly have the browser feature support that makes it possible for devicepx to go away. |
# Conflicts: # 3rd-party/class.jetpack-amp-support.php # class.jetpack.php # modules/module-extras.php # tests/php.multisite.xml
|
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: January 14, 2020. |
Check for the theme support flag only
Not sure why it ignored the .editoconfig during conflict resolution
Check if the enqueue callback has been registered instead
|
@brbrr The unit tests have been fixed. Previously it was expecting the @jeherve This is now ready at its simplest form. Let me know if anything else is needed to get this past the finish line. Thank you! |
brbrr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, I was not able to load devicepx after adding it into TwentyTwenty functions.php. Also tested with other themes and AMP active/deactive.
Any ideas what I might be doing wrong?
|
Caution: This PR has changes that must be merged to WordPress.com |
zinigor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well in my tests, I have been able to add the enqueued script by using this snippet:
add_action( 'init', 'zinigor_declare_theme_support' );
function zinigor_declare_theme_support() {
add_theme_support( 'jetpack-devicepx' );
}
Thanks!
Travis is now fine, thanks for the review!
* Changelog: 8.1 additions * Changelog: add #13858 * Changelog: add #13963 * Changelog: add #14174 * Changelog: add #14178 * Changelog: add #14175 * Changelog: add #14192 * Changelog: add #14196 * Changelog: add #14182 * Changelog: add #14218 * Changelog: add #14214 * Changelog: add #13757 * Changelog: add #14190 * Changelog: add #14131 * Changelog: add #14101 * Changelog: add #14203 * Changelog: add #14211 * Changelog: add #14224 * Changelog: add #14230 * Changelog: add #14241 * Changelog: add #14249 * Changelog: add #14264 * Changelog: add #14263 * Changelog: add #14256 * Changelog: add #10189 * Changelog: add #14240 * Changelog: add #14239 Also added some new entries to the testing file. Co-authored-by: Igor Zinovyev <[email protected]>
* Changelog: 8.1 additions * Changelog: add #13858 * Changelog: add #13963 * Changelog: add #14174 * Changelog: add #14178 * Changelog: add #14175 * Changelog: add #14192 * Changelog: add #14196 * Changelog: add #14182 * Changelog: add #14218 * Changelog: add #14214 * Changelog: add #13757 * Changelog: add #14190 * Changelog: add #14131 * Changelog: add #14101 * Changelog: add #14203 * Changelog: add #14211 * Changelog: add #14224 * Changelog: add #14230 * Changelog: add #14241 * Changelog: add #14249 * Changelog: add #14264 * Changelog: add #14263 * Changelog: add #14256 * Changelog: add #10189 * Changelog: add #14240 * Changelog: add #14239 Also added some new entries to the testing file. Co-authored-by: Igor Zinovyev <[email protected]>
Fixes #1850 #820
Changes proposed in this Pull Request:
Enqueue
https://s0.wp.com/wp-content/js/devicepx-jetpack.jsonly if the theme defines support for it viaadd_theme_support( 'jetpack-devicepx' ).Set
jetpack-devicepxas not supported during AMP requests.Testing instructions:
Enable the Jetpack plugin. It no longer enqueues the
https://s0.wp.com/wp-content/js/devicepx-jetpack.jsscript on all pages automatically.Add
add_theme_support( 'jetpack-devicepx' );to theme'sfunctions.phpand notice that now all front-end page loads include thehttps://s0.wp.com/wp-content/js/devicepx-jetpack.jsscript.Load an AMP page and notice that the
devicepxlibrary is not loaded as expected.Proposed changelog entry for your changes:
Disable the
devicepxlibrary by default and allow themes to enable it via theadd_theme_support( 'jetpack-devicepx' );toggle.