Forked from bappi-d-great/How to load a wordpress plugin at very last.php
Created
October 12, 2022 09:28
-
-
Save theperfectwill/a3c704f852556d24fc1b7c5c6933a183 to your computer and use it in GitHub Desktop.
How to load a wordpress plugin at very last - change plugin order to load last
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* Use the code at the beginning of a plugin that you want to be laoded at last | |
* | |
*/ | |
function this_plugin_last() { | |
$wp_path_to_this_file = preg_replace('/(.*)plugins\/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__); | |
$this_plugin = plugin_basename(trim($wp_path_to_this_file)); | |
$active_plugins = get_option('active_plugins'); | |
$this_plugin_key = array_search($this_plugin, $active_plugins); | |
array_splice($active_plugins, $this_plugin_key, 1); | |
array_push($active_plugins, $this_plugin); | |
update_option('active_plugins', $active_plugins); | |
} | |
add_action("activated_plugin", "this_plugin_last"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment