Skip to content
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

Enhance TailwindCSS classes scan with generated cache files (WP Rocket...) #231

Open
DamChtlv opened this issue Jan 9, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@DamChtlv
Copy link
Collaborator

DamChtlv commented Jan 9, 2023

Some TailwindCSS classes are not found when they are only existing in back-office (example: text styles, width/height/padding classes...)
To enhance the scan detection, it's possible to scan WP Rocket generated html cache files to find some classes which were only available in there.

Proof of concept using the Pilo'Press filter: pip/tailwind_api/content_to_scan :
(tested on Sunna)

// Tell Pilo'Press to scan WP Rocket cache files to find missing TailwindCSS classes
add_filter( 'pip/tailwind_api/content_to_scan', 'scan_cache_files_for_tailwind_classes' );
function scan_cache_files_for_tailwind_classes( $contents_to_scan ) {

    // Home page
    $contents_to_scan[] = trailingslashit( WP_CONTENT_DIR ) . 'cache/wp-rocket/**/*.html';

    // First level (posts / pages)
    $contents_to_scan[] = trailingslashit( WP_CONTENT_DIR ) . 'cache/wp-rocket/**/**/*.html';

    // Second level (post-types / terms)
    $contents_to_scan[] = trailingslashit( WP_CONTENT_DIR ) . 'cache/wp-rocket/**/**/**/*.html';

    return $contents_to_scan;
}

Those 3 new paths should be added here:

$purge_content = array(
$theme_path . '*.php',
$theme_path . '**/*.php',
$theme_path . 'acf-json/*.json',
PIP_THEME_LAYOUTS_PATH . '**/*.php',
PIP_THEME_LAYOUTS_PATH . '**/*.css',
PIP_THEME_LAYOUTS_PATH . '**/*.js',
PIP_THEME_LAYOUTS_PATH . '**/*.json',
$theme_path . 'safelist.txt',
$theme_path . 'style.css',
$theme_path . 'pilopress/assets/styles.css',
);

@DamChtlv DamChtlv added the enhancement New feature or request label Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant