0
0
Wordpressframework~10 mins

Performance plugins in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to activate a caching plugin in WordPress.

Wordpress
<?php
// Activate the caching plugin
activate_plugin('[1]');
?>
Drag options to blanks, or click blank then click option'
Aakismet/akismet.php
Bcontact-form-7/wp-contact-form-7.php
Chello-dolly/hello.php
Dwp-super-cache/wp-cache.php
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing plugins unrelated to performance like Akismet or Hello Dolly.
Using plugin file names that do not exist.
2fill in blank
medium

Complete the code to enqueue a minified CSS file for performance optimization in WordPress.

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');
Drag options to blanks, or click blank then click option'
A-min
B-dev
C-debug
D-full
Attempts:
3 left
💡 Hint
Common Mistakes
Using development or debug suffixes which are not optimized.
Forgetting to enqueue the style properly.
3fill in blank
hard

Fix the error in the code to properly clear cache using a performance plugin's function.

Wordpress
<?php
// Clear cache after post update
function clear_cache_after_update() {
    if (function_exists('[1]')) {
        [1]();
    }
}
add_action('save_post', 'clear_cache_after_update');
Drag options to blanks, or click blank then click option'
Aclear_cache
Bwp_cache_clear_cache
Cw3tc_flush_all
Dcache_clear
Attempts:
3 left
💡 Hint
Common Mistakes
Using a function that does not exist or is not defined by the plugin.
Calling cache clear functions without checking if they exist.
4fill in blank
hard

Fill both blanks to create a filter that disables emoji scripts for better performance.

Wordpress
<?php
add_filter('[1]', '[2]');

function disable_emojis() {
    return false;
}
Drag options to blanks, or click blank then click option'
Aprint_emoji_detection_script
Bdisable_emojis
Cwp_head
Dwp_footer
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated filters like 'wp_head' or 'wp_footer'.
Not returning false in the disabling function.
5fill in blank
hard

Fill all three blanks to create a function that lazy loads images using a performance plugin filter.

Wordpress
<?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');
Drag options to blanks, or click blank then click option'
Athe_content
Blazy
Cwp_lazy_loading_enabled
Dwp_head
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong filters that do not affect image loading.
Forgetting to set loading attribute to 'lazy'.