ideasonpurpose / docker-wordpress-dev

Docker-based local development environment for WordPress projects
8 stars 7 forks source link

Clear 'wp_core_block_css_files' transient on theme activation and refresh #72

Open joemaller opened 1 year ago

joemaller commented 1 year ago

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)

joemaller commented 1 year ago

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
joemaller commented 1 year ago

Delete the transient on theme-activation:

add_action('after_switch_theme', function () {
    delete_transient('wp_core_block_css_files');
});
joemaller commented 1 year ago

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\"" &&