wp-media / wp-rocket-cli

WP CLI interface for the WP Rocket plugin
74 stars 37 forks source link

Add a possibility to generate CPCSS for the given post #28

Open hlorofos opened 4 years ago

hlorofos commented 4 years ago

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.

hlorofos commented 2 years ago

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

codepuncher commented 2 years ago

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

alanablett commented 1 year ago

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.