ideasonpurpose/docker-wordpress-dev

Clear 'wp_core_block_css_files' transient on theme activation and refresh

Opened this issue · 3 comments

For some reason the wp_core_block_css_files is persisting and preventing the loading of some styles. This has resulted in visual discrepancies between development and production deploys, despite identical code.

Initial thinking is to add the following:

See also WordPress#59111

Note that wp-config.php hacks didn't work easily, (see #71) and adding define( 'WP_DEVELOPMENT_MODE', 'core' ); didn't fix this issue anyway (as suggested here)

Delete the transient directly from the DB table:

DELETE FROM `wp_options` WHERE option_name = '_transient_wp_core_block_css_files';

wp-cli command:

wp --allow-root transient delete wp_core_block_css_files

Delete the transient on theme-activation:

add_action('after_switch_theme', function () {
    delete_transient('wp_core_block_css_files');
});

Escaped shell command from docker-compose.yml:

echo -e "🐛  \033[36mClearing buggy \033[90mwp_core_block_css_files \033[36mtransient\033[0m" &&
mariadb -h db $${MYSQL_DATABASE} \
    -e "DELETE FROM wp_options \
        WHERE option_name = \"_transient_wp_core_block_css_files\"" &&