Skip to content

Instantly share code, notes, and snippets.

@igmoweb
Last active December 14, 2015 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igmoweb/9db3bc38a632b717d01c to your computer and use it in GitHub Desktop.
Save igmoweb/9db3bc38a632b717d01c to your computer and use it in GitHub Desktop.
Extend Site New Use case
<?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