Write This Code On theme Function.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( 'plugin-folder-name/plugin-main-file.php' );
It’s working
Related Posts:
- How to check if a theme is active?
- Plugin Deactivate Self on Activation Errors
- Install theme as part of a plugin
- Tips for using WordPress as a CMS? [closed]
- Uninstall, Activate, Deactivate a plugin: typical features & how-to
- Custom Post Type Templates from Plugin Folder?
- to perform the requested action wordpress needs to access your web server. please enter your ftp
- How To Activate Plugins via Code?
- Disable plugin / plugin action via theme
- Activate a plugin through PHPMyAdmin or FTP?
- What Are Security Best Practices for WordPress Plugins and Themes? [closed]
- Hide prices and checkout functionality in woocommerce
- How do I exclude plugins from getting automatically updated?
- Where can I sell WordPress themes and plugins? [closed]
- how to get path to images in the uploads folder to be used in a plugin
- How to maintain W3C standards compliance of a theme
- Difference between a theme and a plugin?
- What are the package and subpackage comment for?
- How can I create a bash install script for my WordPress sites setup (WP+plugins+theme)?
- Shared functionality in plugins and themes
- Experiences with adding Nonces to the comment form
- How to add favicon to my site – in both front end and admin panel
- How to get the active theme’s slug?
- Create theme files for plugin
- How to add plugins to wordpress theme?
- Pluggable function and activation check?
- How can I have two different urls for the same page that load two different templates?
- Plugin (or Theme) containing its own Plugins?
- Reordering themes in admin panel
- All shortcodes not working on custom theme
- How to enable edit button in the theme’s customize UI?
- Disable plugins on cron and ajax page
- Automatically install wordpress plugin at theme activation
- Show a confirm message before plug-in activation
- Need to create a Theme demo site that features multiple themes
- Is it good practice to remove redundant plugins and themes?
- Ship plugin with a custom theme
- Get URL of a specific file
- Disable author pages for specific users
- Set active theme via URL
- Declare a function before plugin does on the theme functions.php file
- How get list of updates of wp site?
- Function to activate WordPress theme inside a plugin
- How to solve a conflict between a plugin and a theme?
- WP Config for FTP credentials
- How do I make my wordpress page more friendly for mobile viewers?
- WordPress error – PHP Fatal error: Uncaught Error: Call to undefined function register_block_type_from_metadata()
- How can I list only sites that use a particular theme or plugin?
- Which hook callback has priority if both plugin and theme use the same hook?
- Activate Plugin which is in subfolder?
- disable active plugins for specific theme
- Check javascript file Proper way in functions.php
- Should I use RIPS tool to test my themes and plugins?
- Make the css of the widget overwrite theme css
- explanation for activate_plugin function in wordpress core
- Themes VS Plugins [duplicate]
- Remote plugin activation hook
- Force wordpress to request for FTP Info on theme/plugin install/update
- Migrating a File from Plugin to Theme and changing its path → instead create a REST endpoint
- A way to sort WordPress themes? [closed]
- Why users disable the WordPress update?
- Can a WordPress plugin or theme contain a virus?
- dequeue not work
- Force plugin to fail activation
- Whats the difference between Page Builder Plugins and Theme Builder Softwares? [closed]
- How to use load_plugin_textdomain from within a theme
- adding a text message beside the comment submit button
- WordPress register_activation_hook table creation not working
- Multisite: Activate plugin for subsites only?
- I can’t upload a new wordpress theme from a zipped file
- The plugin generated x characters of unexpected output, $wpdb not defined
- Theme and Plugins sharing common libraries
- Workflow and best practice for documentation [closed]
- Is there a quick way to inject i18n domain into theme/plugin files?
- Correct way to use register_activation_hook
- How to avoid redefining requirejs in plugin when another plugin also uses requirejs
- Get list of sites that uses specific plugin or theme
- Override the core function locate_template
- WordPress site migration addvice
- Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory
- Recommendations for books/resource to get started with wordpress 3 development (plugins/themes) [closed]
- Uncaught Error: Call to undefined function get_user_by() after moving function from theme to plugin
- Can I share predefined fonts from theme_support with a gutenberg component?
- Is there a reliable way to keep track of how long a WordPress theme has been active?
- Cannot run the code after I activate the plugin
- How can I measure the performance of any WordPress Plugin or Theme?
- Translating plugin inside the theme [closed]
- Why are some of my thumbnails not being generated?
- wordpress in nginx docker container connected to php:8-fpm container and mariadb container isn’t creating any tables on plugin activation
- How to Implement “Notice: This theme recommands the following plugin:xyz” in wordpress? [closed]
- Unable to activate wordpress importer after installing it
- Making menu link open in new tab?
- Woocommerce sidebar not loading in theme
- Include Max mega menu Plugin into theme
- Change settings of get_post_type_object
- How to include plugin without activation?
- add_action in functions.php, do_action in plugin?
- Auto add content such as pages upon plugin activation?
- add_meta_box (Will display only in specific page admin WordPress)
- Sage WordPress – Plugin Namespace: Not Found