The loading sequence of WordPress plug-ins is not necessary for many friends, but sometimes there are too many plug-ins to be installed. We need to set the sequence. How can we install them, let's take a look. the loading sequence of WordPress plug-ins is not necessary for many friends, but sometimes there are too many plug-ins to be installed. We need to set the sequence. How can we install them, let's take a look.
Script ec (2); script
By default, WordPress plug-ins are loaded alphabetically by plug-ins, such as a/. php is better than B/B. php loads the plug-in first, so how do we change the loading sequence of the plug-in? Because the activated plug-in exists in the option of active_plugins, we only need to activate or disable the plug-in, the system can hook active_plugins before updating the option value.
For example, the following code sets the robot plug-in as the final 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:
Generally, if the plug-in contains all functions but no code to be executed immediately, the loading sequence of the plug-in is irrelevant. If you need to have the code to be executed immediately in the plug-in, it is best to put it in plugins_loaded action for execution. This action means the actions executed after all the plug-ins are loaded.