Is there a way to determine if only the WordPress plugin is installed?

I like to know if there is a way to find out if the Just plugin is installed. I don’t care if it is still activated, but only if this plugin is installed!

Do you know a good way to do this?

I have to be more specific. I know where to find the plugins, and I know how I can see if they are installed. The question is is there any software way to check if the plugin is installed.

i.e.: WordPress provides us with register_activation_hook () to do any operation that we like when activating the plugin, but there is no corresponding hook for installing the plugin. Is there any way to determine the installation of the plugin?

+5
source share
2 answers

Here is the best way I've found so far: (it was written in WP 3.5)

Information:

The main thing to keep in mind register_activation_hook is that it is called an intermediary page between clicking on the activation link from wp-admin / plugins.php and viewing the plugin activation notification after it has been connected. I found this after I tried to use a variable $_GETthat is sent from the Activate link. If you look well at the link you click and the link you are in is a little different. That is why you cannot use add_action(), do_action() or add_filter()... inside triggers register_activation_hook(). It is instantly redirected after activating the plugin.

Decision:

add_option hook

/* Main Plugin File */
...
register_activation_hook( __FILE__, function() {
  add_option('Activated_Plugin','Plugin-Slug');
  /* activation code here */
});

add_action('admin_init','load_plugin');
function load_plugin() {
    if(is_admin()&&get_option('Activated_Plugin')=='Plugin-Slug') {
     delete_option('Activated_Plugin');
     /* do some stuff once right after activation */
    }
}

...

+8

, :

  • ,
  • , .
  • , define() - , plugins_loaded hook
  • ,
  • ,
+2

All Articles