wp-media / wp-rocket-cli

WP CLI interface for the WP Rocket plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add a possibility to generate CPCSS for the given post

hlorofos opened this issue · comments

I've a plenty of posts on a site and want to create CPCSS for all my posts. Critical path generator created only css for the main page. Now I have to click through all my posts and generate CPCSS manually.

Any update with the possibility to initiate the process without visiting the admin page?

Would love to see this! Big part missing from my workflow keeping all posts from having good Pagespeed scores

I had to return to this issue recently and found that switching the theme caused CPCSS to be generated. This lead me to create a simple plugin that fired off the switch_theme action, passing it the current theme as arguments to avoid actually having to switch to a different theme.

$theme = wp_get_theme();
$theme_name = $theme->get( 'Name' );
do_action('switch_theme', $theme_name, $theme, $theme);

This seems to work in my case. Obviously this could cause side effects if you have other code hooking into the switch_theme action.