0
0
Wordpressframework~20 mins

Plugin installation and activation in Wordpress - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Plugin Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens after activating a WordPress plugin?

After you activate a plugin in WordPress, what is the immediate effect on the website?

AThe website automatically updates to the latest WordPress version.
BThe plugin files are deleted from the server to save space.
CThe WordPress core files are replaced with the plugin's files.
DThe plugin's code starts running and can add features or change site behavior immediately.
Attempts:
2 left
💡 Hint

Think about what activating a plugin means for the website's functionality.

📝 Syntax
intermediate
2:00remaining
Which code snippet correctly activates a plugin programmatically?

In WordPress, which PHP code correctly activates a plugin named 'my-plugin/my-plugin.php'?

Awp_activate_plugin('my-plugin/my-plugin.php');
Bactivate('my-plugin/my-plugin.php');
Cactivate_plugin('my-plugin/my-plugin.php');
Dplugin_activate('my-plugin/my-plugin.php');
Attempts:
2 left
💡 Hint

Look for the official WordPress function to activate plugins.

🔧 Debug
advanced
2:00remaining
Why does this plugin activation fail with a fatal error?

Given this plugin main file code, why does activating it cause a fatal error?

<?php
function my_plugin_init() {
  echo $undefined_variable;
}
add_action('init', 'my_plugin_init');
ABecause $undefined_variable is not defined, causing a PHP notice but not a fatal error.
BBecause echo cannot be used inside functions hooked to 'init'.
CBecause using an undefined variable in echo causes a fatal error during activation.
DBecause add_action is called before WordPress is fully loaded.
Attempts:
2 left
💡 Hint

Think about what happens when PHP tries to echo a variable that does not exist.

state_output
advanced
2:00remaining
What is the value of 'active_plugins' option after activating two plugins?

Assuming the 'active_plugins' option initially is an empty array, what will it contain after activating these two plugins?

activate_plugin('plugin-one/plugin-one.php');
activate_plugin('plugin-two/plugin-two.php');
$active = get_option('active_plugins');
A['plugin-two/plugin-two.php']
B['plugin-one/plugin-one.php', 'plugin-two/plugin-two.php']
C[]
D['plugin-one/plugin-one.php']
Attempts:
2 left
💡 Hint

Activating plugins adds them to the active plugins list.

🧠 Conceptual
expert
2:00remaining
Which hook runs only once immediately after plugin activation?

Which WordPress hook is designed to run only once right after a plugin is activated?

Aregister_activation_hook
Bwp_loaded
Cplugins_loaded
Dinit
Attempts:
2 left
💡 Hint

Think about the special hook used to run setup code when a plugin is activated.