0
0
Wordpressframework~10 mins

Plugin header and activation 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 add the plugin name in the header comment.

Wordpress
<?php
/*
Plugin Name: [1]
*/
Drag options to blanks, or click blank then click option'
AMy Simple Plugin
Bfunction activate_plugin() {}
C<?php
Dadd_action
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put the plugin name inside the comment block.
Using PHP code instead of a comment for the header.
2fill in blank
medium

Complete the code to register an activation hook for the plugin.

Wordpress
register_activation_hook(__FILE__, [1]);
Drag options to blanks, or click blank then click option'
A'deactivate_plugin'
B'activate_plugin'
C'init_plugin'
D'load_plugin'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong function name string.
Not passing the function name as a string.
3fill in blank
hard

Fix the error in the activation function declaration.

Wordpress
function [1]() {
    // Activation code here
}
Drag options to blanks, or click blank then click option'
Aactivate plugin
Bactivate-plugin
Cactivate_plugin
DActivatePlugin
Attempts:
3 left
💡 Hint
Common Mistakes
Using hyphens or spaces in function names.
Capitalizing function names inconsistently.
4fill in blank
hard

Fill both blanks to correctly register and define the activation function.

Wordpress
register_activation_hook(__FILE__, [1]);

function [2]() {
    // Activation tasks
}
Drag options to blanks, or click blank then click option'
A'activate_plugin'
B'deactivate_plugin'
Cactivate_plugin
Ddeactivate_plugin
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between the hook string and function name.
Using quotes around the function name in the function declaration.
5fill in blank
hard

Fill all three blanks to create a plugin header, activation function, and register the activation hook.

Wordpress
<?php
/*
Plugin Name: [1]
*/

function [2]() {
    // Activation code
}

register_activation_hook(__FILE__, [3]);
Drag options to blanks, or click blank then click option'
AMy Plugin
Bactivate_my_plugin
C'activate_my_plugin'
Ddeactivate_my_plugin
Attempts:
3 left
💡 Hint
Common Mistakes
Not matching the function name in the hook and function.
Forgetting the plugin header comment format.