After you activate a plugin in WordPress, what is the immediate effect on the website?
Think about what activating a plugin means for the website's functionality.
Activating a plugin loads its code so it can add features or modify the site. It does not delete files or update WordPress itself.
In WordPress, which PHP code correctly activates a plugin named 'my-plugin/my-plugin.php'?
Look for the official WordPress function to activate plugins.
The correct function is activate_plugin(). Other options are not valid WordPress functions.
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');
Think about what happens when PHP tries to echo a variable that does not exist.
Using an undefined variable in echo causes a PHP notice, but not a fatal error, so the plugin activation should not fail fatally for this reason.
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');Activating plugins adds them to the active plugins list.
Each activated plugin is added to the 'active_plugins' option array, so both plugins appear in the list.
Which WordPress hook is designed to run only once right after a plugin is activated?
Think about the special hook used to run setup code when a plugin is activated.
register_activation_hook runs only once immediately after plugin activation to perform setup tasks.