Complete the code to activate a caching plugin in WordPress.
<?php // Activate the caching plugin activate_plugin('[1]'); ?>
The wp-super-cache/wp-cache.php is the main file to activate the WP Super Cache plugin, which improves performance by caching pages.
Complete the code to enqueue a minified CSS file for performance optimization in WordPress.
<?php
function theme_enqueue_styles() {
wp_enqueue_style('theme-style', get_template_directory_uri() . '/style[1].css');
}
add_action('wp_enqueue_scripts', 'theme_enqueue_styles');The suffix -min is commonly used for minified CSS files to improve loading speed.
Fix the error in the code to properly clear cache using a performance plugin's function.
<?php
// Clear cache after post update
function clear_cache_after_update() {
if (function_exists('[1]')) {
[1]();
}
}
add_action('save_post', 'clear_cache_after_update');The w3tc_flush_all function is used by the W3 Total Cache plugin to clear all caches properly.
Fill both blanks to create a filter that disables emoji scripts for better performance.
<?php add_filter('[1]', '[2]'); function disable_emojis() { return false; }
The filter print_emoji_detection_script controls emoji scripts, and hooking it to disable_emojis function disables them to improve performance.
Fill all three blanks to create a function that lazy loads images using a performance plugin filter.
<?php add_filter('[1]', function($content) { return preg_replace('/<img(.*?)src=/', '<img$1loading="[2]" src=', $content); }); // Enable lazy loading for images add_filter('[3]', '__return_true');
The filter the_content allows modifying post content to add loading="lazy" to images. The filter wp_lazy_loading_enabled enables lazy loading globally.