• Hi !

    Sometimes, maybe, we need to load this plugin first (idea from :https://www.ads-software.com/support/topic/how-to-change-plugins-load-order?replies=11) or last.

    To load the plugin as the FIRST :

    function this_plugin_first() {
    	// ensure path to this file is via main wp plugin path
    	$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);
    	if ($this_plugin_key) { // if it's 0 it's the first plugin already, no need to continue
    		array_splice($active_plugins, $this_plugin_key, 1);
    		array_unshift($active_plugins, $this_plugin);
    		update_option('active_plugins', $active_plugins);
    	}
    }
    add_action("activated_plugin", "this_plugin_first");

    Now, mine ;), to load it as the LAST :

    function this_plugin_last() {
    	// ensure path to this file is via main wp plugin path
    	$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);
    	if ($this_plugin_key) { // if it's 0 it's the first plugin already, no need to continue
    		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");

    You need to alter the “init.php” and put the needed solution at the end.

    https://www.ads-software.com/plugins/easy-logo-slider/

  • The topic ‘[Enhancement] Loading the plugin’ is closed to new replies.