=== WP Critical CSS === Contributors: pcfreak30 Donate link: https://www.paypal.me/pcfreak30 Tags: optimize, above the fold, critical css Requires at least: 4.5 Tested up to: 5.2 Stable tag: trunk License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html WordPress plugin that will use CriticalCSS.com to automatically generate above-the-fold CSS for your pages. == Description == This plugin will automatically have the CriticalCSS.com web service get the needed above the fold CSS for every page on your site to help improve your user experience and site speed. This is commonly required by google pagespeed as one of the last steps to do. **This plugin alone will not improve site performance**. You need a minify and/or caching plugin as well. This plugin **does not** handle any minification or re-ordering of assets. I recommend using [WP Rocket](https://wp-rocket.me/) with my [WP Rocket Footer JS](https://wordpress.org/plugins/rocket-footer-js/), [WP Rocket ASYNC CSS](https://wordpress.org/plugins/rocket-async-css/), and the plugin [Preloader](https://wordpress.org/plugins/the-preloader/) If you are looking for a professional team to get your WordPress site to run faster, check us out for our speed optimization services at [Rank Grow Digital](https://rankgrowdigital.com/) == Installation == This section describes how to install the plugin and get it working. 1. Upload the plugin files to the `/wp-content/plugins/criticalcss` directory, or install the plugin through the WordPress plugins screen directly. 2. Activate the plugin through the 'Plugins' screen in WordPress 4. Go to Settings -> Critical CSS, and add your API key from [CriticalCSS.com](https://www.criticalcss.com/account/api-keys). == Frequently Asked Questions == * Where do I get an API key from? Please sign up at [CriticalCSS.com](https://www.criticalcss.com/?aff=3) then go to [CriticalCSS.com API Keys](https://www.criticalcss.com/account/api-keys). Be sure to read the additional pricing information! At the time of writing (1 Jan 2017) the price for using [CriticalCSS.com](https://www.criticalcss.com/?aff=3) is: £2/month for membership + £5/domain/month. This means the total cost will be £7/month if you use this plugin for one site. * How do I report an issue? You may go to https://www.github.com/pcfreak30/wp-criticalcss/issues and make a new issue. For any support, see the support forums. * Will this work for inside paywalls or membershp sites? Currently no. Since CriticalCSS.com can not access protected pages currently, the page must be publicaly visible to work. Means to allow this to work may come in the future. * What will happen if I update content on the site or change my theme? The plugins css cache will automatically purge for that post or term and get queued for processing again on the next user request of it. * What will happen if I upgrade a plugin or theme? The whole cache will be purged regardless of the purge setting * Does this support any caching plugins? Yes currently WP-Rocket is supported. Others can be added as integrations on request. * What host is supported? Generally any host. Some hosts like WPEngine has special support to purge the server cache. * What is the `/nocache/` in the URL's in the queue? This is used as a special version of the web page that forcibly disables supported caching and minify plugins to ensure that critical css is created without complications. SEO wise these URL's are safe as they have no references anywhere and google will not be aware to crawl them. == Changelog == ### 0.7.7 ### * Bug: Fix edge case with custom post types rewrite rules by putting them before the generic rules ### 0.7.6 ### * Bug: Don't check for manual css to see if we need to add to queue since we can just disable the api by removing the key * Bug: Fix forceInclude CSS selectors functionality. It was not sending the right field name to the API. * Bug: Dont try and remove duplicate rewrite rules due to possible edge cases * Compatibility: WP Rocket 3.4 got rid of get_rocket_purge_cron_interval, add compatibility ### 0.7.5 ### * Bug: Misc fixes to remove warnings with $_POST vars * Bug: Fix what is purged in web fetch mode for the page check flag * Bug: Remove use of compat function * Bug: Fix slashing in saving critical css data * Feature: Add WebP compatibility to force webp detection off no nocache requests * Enhancement: Refactor queue logic to only process 1 item per run and don't die after * Enhancement: Refactor kinsta integration to use their mu-plugin for purging * Enhancement: Refactor rewrite url logic for nocache urls based on WP Core rewrite class * Enhancement: Enable the queue processes to run until the queue is empty with filterable delays if running in PHP CLI mode (shell) * Enhancement: Remove the paging in the queue UI tables for simplicity * Enhancement: Add compatibility with Kinsta caching to bust it with a query string for nocache urls * Compatibility: Add compatibility with SEO/redirect plugins ### 0.7.4 ### * Compatibility: Add compatibility support for Elementor to prevent critical css from showing up on editor preview ### 0.7.3 ### * Bug: Prevent override of DONOTCACHEPAGE with WP Rocket * Enhancement: Ensure that nocache pages are purged on wpengine to prevent caching * Compatibility: Add compatibility support for Kinsta hosting ### 0.7.2 ### * Enhancement: Update framework ### 0.7.1 ### * Bug: Fix small random bugs * Bug: Don't check queue in content mode if we have manual or fallback CSS * Bug: If global fallback cache is empty, ensure $fallback is false * Bug: Ensure item data is stored correctly for meta in multisite * Bug: Handle JOB_ONGOING status in processing * Bug: If prioritize_manual_css is not on then set manual to false to ensure its queued * Bug: Don't hook wp_criticalcss_purge_cache during cron * Bug: If remote CSS file could not be fetched, skip it instead of silently failing * Enhancement: Add upgrade logic to clean up tables * Enhancement: Only set CSS content hashes if no template is set in background processing * Enhancement: Don't show force_web_check option in template mode * Enhancement: Only show post type, archive and taxonomy css options if manual css is on * Enhancement: Don't show template cache if manual css is on * Enhancement: Don't purge cache if manual css is on and there is no API key * Enhancement: Only show queue and log tabs if an api key is entered * Enhancement: Don't purge cache if API key is empty * Enhancement: Allow API key to be emptyued * Enhancement: Support query vars in get_current_page_type * Feature: Allow manual css for post types, post type archives, and taxonomies * Feature: Add template log to track what pages have been enqueued for a template to improve purging * Feature: Add checking for post type, post type archive, and taxonomy CSS * Compatibility: Force wp-rocket's critical css off * Compatibility: Add integration with a3 lazy load to disable lazy load on nocache pages ### 0.7.0.1 ### * Bug: Fix usage of restore_current_blog being undefined ### 0.7.0 ### ### Big Warning ### This is a ***MAJOR*** release and over 50% of the code is rewritten. While it has been extensively tested, there may still be bugs! Please test in a development site before deploying! Due to the amount of work, only a summary of this version will be detailed below. * ***Major*** rewrite using new composer based framework. * Feature: Added queue table for web check queue. * Feature: Added log table which gets purged via custom cron event if there is no cache integration. * Feature: Added ability to force styles to be included in critical css with simple names or regex. * Feature: Added ability to give a manual CSS input for any term or post * Feature: Added ability to have a parent hierarchical term or hierarchical custom post type override its children and force them to use its CSS. The very top parent with the override will be used. This is exposed with the manual input on editing a term or post. * Feature: Added ability to force manual css to always be used in-place of generated css. * Feature: Added a setting for a global CSS fallback. This is manual input only. * Bugs: Too many to review that are fixed ### 0.6.4 ### * Bug: SECOND_IN_SECONDS is defined in wp-rockets compatibility code only, so must be removed ### 0.6.3 ### * Bug: Ensure object_id is an integer in get_permalink * Bug: Disable rocket_clean_wpengine and rocket_clean_supercacher functions in after_rocket_clean_domain action when disabling integrations * Enhancement: Don't use web check transient in template mode ### 0.6.2 ### * Bug: Don't clear web check flags for posts or terms on edit in template mode ### 0.6.1 ### * Bug: Fix the queue item exists method to only query template if it exists * Bug: Correct data unset's in save and update queue methods * Bug: Don't try adding to API queue if no template exists * Bug: Purge all cache in template mode * Bug: Fix missing variable assignment for get_transient call in get_item_data * Bug: Restore set_cache call accidentally removed in 0.6.0 ### 0.6.0 ### * Bug: Fix multisite settings menu * Feature: Add new cache mode to process pages by the wordpress template * Feature: Add full multisite compatibilty using site transients and network wide queue tables * Security: Prevent direct access class files ### 0.5.1 ### * Bug: Use get_expire_period not get_rocket_purge_cron_interval ### 0.5.0 ### * Bug: Replace purge lock with disable_external_integration method due to the order that the actions run * Bug: Disable external integration when purging cache from web check queue * Enhancement: Improve redirect_canonical logic * Enhancement: Rebuild cache system without using SQL * Cleanup: Clean up code and fix typo with cache ### 0.4.5 ### * Change: Generalize fix_woocommerce_rewrite to fix_rewrites * Bug: Add nocache URL rewrite fix for page archives * Tweak: Don't append $query_string as it is generally unnecessary ### 0.4.4 ### * Bug: Ensure all custom taxonomies that have rewrite enabled have the nocache url enabled * Bug: Fix woocommerce taxonomies by forcing all nocache rewrite rules for woocommerce taxonomies to the top of the rewrite rule list ### 0.4.3 ### * Enhancement: Added hack for WPEngine websites to prevent duplicate item entries ### 0.4.2 ### * Enhancement: Convert relative URL's to absolute when doing a web check ### 0.4.1 ### * Bug: Add a purge_lock property with getter/setter to flag when cache is being purged due to a item completing the API queue to prevent a process infinate cycle ### 0.4.0 ### * Bug: Fix version comparison logic for upgrade routines and allow previous upgrade code to run on 0.4.0 upgrade due to the bug * Enhancement: Major refactor to use dedicated mysql storage tables for queue instead of wp_options to simplify data management and ensure no duplicates can exist * Enhancement: If $url in WP_CriticalCSS::get_permalink is a WP_Error, return false * Enhancement: Skip item in web check queue if item exists in API queue or the permalink is false * Cleanup: Purge all queue items from options table and web check transients on 0.4.0 upgrade ### 0.3.6 ### * Bug: Only set DONOTCACHEPAGE if not set ### 0.3.5 ### * Enhancement: If nocache is on, add robots meta for SEO to prevent duplicate content ### 0.3.4 ### * Bug: Add slashes with wp_slash to protect post meta with slashes ### 0.3.3 ### * Bug: Ensure the version setting actually updates on upgrade ### 0.3.2 ### * Enhancement: Prevent duplicate web request queue items by querying the serialized data from the options table ### 0.3.1 ### * Bug: Fix purge bulk action * Cleanup: Merge settings classes together ### 0.3.0 ### * Bug: Store status information when a generate API request is made * Enhancement: Rework elements of settings UI * Enhancement: Add bulk purge option in queue table * Enhancement: Queue system and core system refactor that checks for changes by hashing html and css output via web request ### 0.2.5 ### * Bug: after_rocket_clean_domain hook needs to be in disable_autopurge check ### 0.2.4.1 ### * Bug: Messed up 0.2.4 version number ### 0.2.4 ### * Change: Do not automatically auto-purge by default * Bug: Use parse_url and http_build_url to safely append nocache in the permalink * Bug: Allow purge through wp-rocket to work if its not through cron * Bug: Fix timestamp logic * Enhancement: Do not process critical css on 404 pages ### 0.2.3 ### * Bug: Rename more places to wp_criticalcss ### 0.2.2 ### * Change: Renamed options page * Bug: Switch to using OPTIONNAME constant ### 0.2.1 ### * Bug: Missed places to use new class name ### 0.2.0 ### * Change: Rename everything to WP CriticalCSS due to legalities. This means that it will not be fully compatible with 0.1.x as all classes and options are renamed. ### 0.1.3 ### * Bug/Enhancement: Use a simpler means to enable nocache on the homepage thats less error prone * Cleanup: reorder_rewrite_rules method not needed ### 0.1.2 ### * Bug: Revert bug fix for purging in 0.1.1 and just purge before setting cache ### 0.1.1 ### * Bug: Always delete pending transient if there is no fatal error * Bug: Toggle purge plugin integration to prevent generated css from getting purged * Enhancement: If WP_Error just return item so it will get re-attempted * Enhancement: Add method to disable purge plugin integration ### 0.1.0 ### * Initial version
pcfreak30/wp-criticalcss
WordPress Plugin that utilizes CriticalCSS.com web service to automatically create the required CSS for above the fold
PHP