By default, WordPress Plug-ins are loaded according to the letter of the plug-in, such as a/a.php is loaded than b/b.php, then we need to change the plug-in load sequence how to operate it, because the activation of the plug-in is the existence of active_plugins option inside , we only need to activate or deactivate the plugin when the system updates active_plugins this option value before the hook it can.
For example, the following code, we can set the micro-robot plug-in to the last load:
Add_filter (' Pre_update_option_active_plugins ', ' weixin_robot_set_plugin_load_late ');
function weixin_robot_set_plugin_load_late ($active _plugins) {
$weixin _plugin = Plugin_basename (weixin_robot_plugin_file);
if (False!== ($plugin _key = Array_search ($weixin _plugin, $active _plugins)) {
unset ($active _plugins[$plugin _key]);
$active _plugins[] = $weixin _plugin;
}
return $active _plugins;
}
More:
In general, if the plug-in inside are all functions, and not immediately execute the code, the plug-in load sequence is not a relationship, if you need to have the plug-in inside the immediate execution of the code, it is best to put the plugins_loaded action inside the execution, such action The action that is executed after all plug-ins have been loaded.