Created
April 13, 2016 10:54
-
-
Save danielbachhuber/cc8be5468d4a28a477f6d59620aeb405 to your computer and use it in GitHub Desktop.
Example for how you might install a plugin after a theme is activated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Run with wp --require=install-required-plugins.php theme activate p2 | |
| */ | |
| WP_CLI::add_hook( 'after_wp_load', function() { | |
| add_action( 'switch_theme', function( $_, $theme ){ | |
| if ( 'p2' !== $theme->get_stylesheet() ) { | |
| return; | |
| } | |
| $ret = WP_CLI::launch_self( 'plugin install', array( 'jetpack' ), array( 'activate' => true ), false, true ); | |
| WP_CLI::log( $ret->stdout ); | |
| }, 10, 2 ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment