Skip to content

Instantly share code, notes, and snippets.

@Coopeh
Created April 22, 2012 21:48
Show Gist options
  • Save Coopeh/2467122 to your computer and use it in GitHub Desktop.
Save Coopeh/2467122 to your computer and use it in GitHub Desktop.
Set options for all WordPress Multisite blogs
<?php
function set_options($blog_id = null)
{
if ($blog_id) {
switch_to_blog($blog_id);
}
add_option('bla', 'bla');
update_option('bla', 'bla');
if ($blog_id) {
restore_current_blog();
}
}
function update_options()
{
global $wpdb;
$blogs = $wpdb->get_results("
SELECT blog_id
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND archived = '0'
AND spam = '0'
AND deleted = '0'
");
foreach ($blogs as $blog) {
set_options($blog->blog_id);
}
$message = __('All blogs updated.');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment