Last active
December 14, 2015 18:58
-
-
Save igmoweb/9db3bc38a632b717d01c to your computer and use it in GitHub Desktop.
Extend Site New Use case
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 | |
add_action( 'network_after_site_new_form', function() { | |
$themes = wp_get_themes(); | |
?> | |
<table class="form-table"> | |
<tr class="form-field"> | |
<th scope="row"><label for="my-plugin-theme">Select your theme</label></th> | |
<td> | |
<select name="my-plugin-theme" id="my-plugin-theme"> | |
<?php foreach ( $themes as $theme ): ?> | |
<option value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>"><?php echo $theme->title; ?></option> | |
<?php endforeach; ?> | |
</select> | |
</td> | |
</tr> | |
</table> | |
<?php | |
}); | |
add_action( 'wpmu_new_blog', function( $blog_id ) { | |
if ( ! isset( $_POST['my-plugin-theme'] ) ) | |
return; | |
switch_to_blog($blog_id); | |
switch_theme( $_POST['my-plugin-theme'] ); | |
restore_current_blog(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment