Posted By

mrgurner on 04/12/11


Tagged

php wordpress array plugins


Versions (?)

Change Order that Wordpress Plugins are Loaded (Load First)


 / Published in: PHP
 

URL: http://wordpress.org/support/topic/how-to-change-plugins-load-order

  1. function this_plugin_first() {
  2. // ensure path to this file is via main wp plugin path
  3. $wp_path_to_this_file = preg_replace('/(.*)plugins\/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__);
  4. $this_plugin = plugin_basename(trim($wp_path_to_this_file));
  5. $active_plugins = get_option('active_plugins');
  6. $this_plugin_key = array_search($this_plugin, $active_plugins);
  7. if ($this_plugin_key) { // if it's 0 it's the first plugin already, no need to continue
  8. array_splice($active_plugins, $this_plugin_key, 1);
  9. array_unshift($active_plugins, $this_plugin);
  10. update_option('active_plugins', $active_plugins);
  11. }
  12. }
  13. add_action("activated_plugin", "this_plugin_first");

Report this snippet  

You need to login to post a comment.