0
0
Wordpressframework~10 mins

CDN integration 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 specify the CDN URL in the WordPress configuration.

Wordpress
define('CDN_URL', '[1]');
Drag options to blanks, or click blank then click option'
A'ftp://cdn.example.com'
B'http://localhost/'
C'https://cdn.example.com'
D'/local-assets/'
Attempts:
3 left
💡 Hint
Common Mistakes
Using local paths instead of full URLs
Using non-HTTP protocols like FTP
2fill in blank
medium

Complete the code to enqueue a CSS file from the CDN in WordPress.

Wordpress
wp_enqueue_style('theme-style', [1] . 'style.css');
Drag options to blanks, or click blank then click option'
Asite_url() . '/'
BCDN_URL . '/'
Cplugins_url() . '/'
Dget_template_directory_uri() . '/'
Attempts:
3 left
💡 Hint
Common Mistakes
Using local theme or plugin URLs instead of CDN URL
3fill in blank
hard

Fix the error in the code to rewrite asset URLs to use the CDN in WordPress.

Wordpress
function rewrite_asset_url($url) {
    return preg_replace('/^[1]/', CDN_URL, $url);
}
Drag options to blanks, or click blank then click option'
A'https?://example.com/wp-content/uploads'
B'/wp-content/uploads/'
C'http://cdn.example.com/'
D'/uploads/'
Attempts:
3 left
💡 Hint
Common Mistakes
Using relative paths instead of full URL in regex
Missing protocol in regex pattern
4fill in blank
hard

Fill both blanks to correctly filter WordPress content URLs to use the CDN.

Wordpress
add_filter('the_content', function($content) {
    return str_replace([1], [2], $content);
});
Drag options to blanks, or click blank then click option'
Asite_url() . '/wp-content/uploads/'
BCDN_URL . '/uploads/'
Cget_template_directory_uri() . '/css/'
Dplugins_url() . '/js/'
Attempts:
3 left
💡 Hint
Common Mistakes
Replacing wrong paths like theme or plugin URLs
5fill in blank
hard

Fill all three blanks to configure WordPress to serve static assets from the CDN.

Wordpress
$cdn_assets = [
    '[1]',
    '[2]',
    '[3]'
];
Drag options to blanks, or click blank then click option'
Awp-content/uploads
Bwp-includes/js
Cwp-content/themes
Dwp-admin/css
Attempts:
3 left
💡 Hint
Common Mistakes
Including admin CSS directory
Missing common asset directories