Skip to content

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

Description

@DamChtlv

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',
);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions