knoffs
Member
Posted 15 years ago #
hello,
i have deleted many themes that i used to provide to my bloggers. now almost all blogs are not showing up.
what i need, is the code to let all users have a new default template / stylesheet
i think that it should be possible with WPMU Power Tools,
but i dont know the PHP Code command to Execute it on all blogs.
if anybody knows how to do that, would be great if you could help me here.
If you deleted a theme that was in use, then yes, the blog using that theme will show up blank.
Go to Site Admin -> Blogs, find the blog in question, click edit. Find the fields that say Template and Stylesheet and set them both to default.
You'd want to loop through all the blogs and run something like so. Warning - untested. And you'll obviously need to look up the templatename and and stylesheetname that you want them to be switched to.
$blogs = (1,2,3); //your list of foobared blogs here
foreach ($blogs as $blog) {
switch_to_blog($blog->blog_id);
switch_theme('templatename', 'stylesheetname');
restore_current_blog();
}
Something like this might work as an mu-plugin, I've tried it on my "sandbox". Can anyone see any flaw in the logic?
<?php
function ds_reset_busted_theme() {
if ( file_exists(TEMPLATEPATH . '/home.php') ) {
return;
}
if ( !file_exists(TEMPLATEPATH . '/index.php') ) {
update_option( 'template', 'default');
update_option( 'stylesheet', 'default');
header("Status: 200");
header("Location: /index.php");
exit;
}
}
add_action('template_redirect','ds_reset_busted_theme');
?>
knoffs
Member
Posted 15 years ago #
thanks all for the help!!
i was doing the update_option loop that i have found in the functions and used the "power tools" on all blogs.
as dsader also mentioned,
i used the code ...
update_option( 'template', default);
update_option( 'stylesheet', default);