Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.