Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How To Activate WordPress Plugins via Code

How To Activate WordPress Plugins via Code | activate plugin wordpress function | activate plugin wordpress code

How To Activate WordPress Plugins via Code

Use the below code at the end of your functions.php file and save the file. Please change the Plugin name in this line of code run_activate_plugin( 'akismet/akismet.php' );

function run_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;
}
run_activate_plugin( 'akismet/akismet.php' );
  • 10 Ways to Drive Traffic to Your Website
  • How to Add Custom WordPress User Role

The post How To Activate Wordpress Plugins via Code appeared first on FreeWebMentor.



This post first appeared on Programming Blog Focused On Web Technologies, please read the originial post: here

Share the post

How To Activate WordPress Plugins via Code

×

Subscribe to Programming Blog Focused On Web Technologies

Get updates delivered right to your inbox!

Thank you for your subscription

×