Skip to content

Instantly share code, notes, and snippets.

@cfoellmann
Created February 9, 2014 22:00
Show Gist options
  • Select an option

  • Save cfoellmann/8906637 to your computer and use it in GitHub Desktop.

Select an option

Save cfoellmann/8906637 to your computer and use it in GitHub Desktop.
<?php
register_settings_on_network( 'option_name', array( 'some' => '1' ) );
function register_settings_on_network( $option_name, $defaults ) {
global $wpdb;
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
if ( $blogs ) {
foreach( $blogs as $blog ) {
switch_to_blog( $blog['blog_id'] );
add_option( $option_name, $defaults );
}
restore_current_blog();
}
} // END register_settings_on_network()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment