Activate wordpress plugin php code
Posted by navaneeth on Dec 5, 2013 in General, Php, Wordpress | No comments yet
Being a developer some times when developing wordpress plugin what if we don’t have the admin access to activate the plugin. So in this post we are discussing about how we can activate wordpress plugin php code
we need to run an function named do_activate_plugin
so place the custom function inside the themes functions.php
and run the website
Here is the code for the function
function do_activate_plugin( $plugin ) { $current = get_option( 'active_plugins' ); $plugin = plugin_basename( trim( $plugin ) ); if ( !in_array( $plugin, $current ) ) { $current[] = $plugin; sort( $current ); do_action( 'activate_plugin', trim( $plugin ) ); update_option( 'active_plugins', $current ); do_action( 'activate_' . trim( $plugin ) ); do_action( 'activated_plugin', trim( $plugin) ); } return null; } do_activate_plugin( 'categorize/categorize.php' );
The parameter passed in the function is the pluginfolder/pluginfile
Hope this will help you you activate wordpress plugin php code
Leave a Reply