WordPress set up the loading sequence of plug-ins example

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.