Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create plugin support for CDN'ing of static assets. (#10102)
* Add in support for `integrity` data for SRI. * esc_attr ftw * Add populating for integrity parameters based on .org api plugin files only for now * Correct the conditionals for the right error condition. * Only swap out Jetpack asset urls if it's not a development version. If it is a development version, we want to use local up to date assets. * Tidy up the actions that it runs on * Abstract some stuff like versions out * Styles need love too * Skip for already done items * Add ability to pass in plugin and versino for getting checksums * Add ability to get known plugin versions. * Whitespace * Move line * Retool get core checksums to take args * First pass at swapping out core files * Oops. Forgot to specify the proper item in the object. * Add a better fallback and remove an instance that shouldn't happen. * Some additional docs and tidying. * Switch url pattern for cdn as per @bazza * Ditch version numbers We shouldn't need versino numbers as the core version is in the path. * Abstract out the plugin resource swapping. Make it easier to do WooCommerce and others as well. * Purge SRI validation for the moment. Wins from it are incremental, and we'll probably re-add it later -- but with better sourcing for the hashes. * Somewhat big overhaul. * Stop caring about hashes, just care about files. * Add in caching of the file manifest based on plugin / core versions * Strip down how much data we're stashing * Use array_filter for more intelligible code than a foreach * ??? * PROFIT! * Fixed a fatal and a warning. * Moved the CDN class to its own module to be able to turn it off and on. * Simplify how we get the core checksums. * Extract out the cdn domain to a class constant. * Short circuit fn if no data returned. * Don't loop through core files if there isn't a cdn'd version. * Undo whitespace tweaks for less churn * tabs > spaces * Revert whitespace change for cleaner pr * If querying for the current version of Jetpack, return the built manifest. * Added override filters for plugin and core version strings. * Added a line to generate the manifest as the latest stage before deploying to SVN. * Add new method for testing if a version number is public and can be on t he cdn. * Deactivate requiring a connection for now. Helps with local testing, but we may need it on for shipping, just for TOS purposes. * Fixed filter name, props @georgestephanis. * Added the core asset version filter where it needed to be. * Removed an unneeded excludes definition and fixed whitespace. * Whitespace, comments and lint pass. * Also swap to cdn versions on the admin side. Props @jeherve for the catch. * Only query the api if the version string looks like a public release. * Let other plugins return their assets via a filter, rather than an external api or stored option. * Cache for up to 24h the lack of data about a specific plugin version. * Add support for CDN'ing WooCommerce assets as well. * Make sure wp-admin isn't concatenating scripts. This will break the CDN'ing of scripts, and as they're being served over HTTP/2 concatenation provides less benefit over the ability of the browser to cache individual assets. * Simplify the rewriting of Core assets. Instead of hitting the API and related overhead, let's just assume that if Core is a publicly released version (no `-dev` or `-rc2` versions or the like) that the tag will be in the CDN, and then rewrite any css/js files in the `wp-includes` and `wp-admin` directories. * Make sure we're not rewriting odd stuff like using admin-ajax to serve scripts
- Loading branch information