<?php
/*
* Plugin Name: WPMU Blog Defaults
* Plugin URI: http://paidtoblog.com
* Description: Change the default options for WPMU and new blogs automagically
* Version: 1.0.2
* Author URI: MrBrian
*/
//------------------------------------------------------------------------//
//---Remove permalinks from menu------------------------------------------//
//------------------------------------------------------------------------//
function remove_permalinks_menu_item()
{
global $submenu;
if(!is_site_admin()) $submenu['options-general.php'][35] = '';
}
add_action( 'admin_menu', 'remove_permalinks_menu_item' );
//------------------------------------------------------------------------//
//---Change the permalink structure and default blogroll------------------//
//------------------------------------------------------------------------//
function change_newblog_defaults( $blog_id, $user_id )
{
global $wpdb, $current_site, $wp_rewrite;
//--change permalink structure
switch_to_blog($blog_id);
$permalink_structure = '/%category%/%postname%/';
$wp_rewrite->set_permalink_structure($permalink_structure);
$wp_rewrite->flush_rules();
$wpdb->query( "UPDATE {$wpdb->terms} SET name = 'Articles', slug = 'articles' WHERE term_id = 1" );
//--end
//--change default blogroll
$wpdb->query( "DELETE FROM {$wpdb->links} WHERE link_id = 1" );
$wpdb->query( "DELETE FROM {$wpdb->links}WHERE link_id = 2" );
$wpdb->query( "INSERT INTO {$wpdb->links} (link_url, link_name, link_category, link_owner, link_rss) VALUES ('http://" . $current_site->domain . $current_site->path . "', '" . $current_site->domain . "', 1356, '$user_id', 'http://" . $current_site->domain . $current_site->path . "feed/')" );
//--end
restore_current_blog();
}
add_action( 'wpmu_new_blog', 'change_newblog_defaults', 10, 2 );
//------------------------------------------------------------------------//
//---Modify the From and email used when sending emails from WPMU---------//
//------------------------------------------------------------------------//
function change_wp_mail_from($from_email)
{
return $from_email; //return whatever you want as email, i just like it as default.
}
add_filter( 'wp_mail_from', 'change_wp_mail_from' );
function change_wp_mail_from_name($from_name)
{
global $current_site;
return $current_site->domain;
}
add_filter( 'wp_mail_from_name', 'change_wp_mail_from_name' );
//------------------------------------------------------------------------//
//---Change The Help and Forum links at very top of WPMU backend---------//
//------------------------------------------------------------------------//
function change_header_navigation($header_nav)
{
global $current_site;
$header_nav = ' | <a href="http://' . $current_site->domain . $current_site->path . 'faq/">Help</a>' . ' | ' . '<a href="http://' . $current_site->domain . $current_site->path . 'forum/">Forums</a>';
return $header_nav;
}
add_filter('admin_header_navigation', 'change_header_navigation');
//------------------------------------------------------------------------//
//---Change default widgets------------------------------------------//
//------------------------------------------------------------------------//
This activates the given widgets in sidebar-1 and -2. You need to know the internal names of the widgets.
function change_blog_widgets() {
add_option("sidebars_widgets",
"sidebar-2" => array("archives", "links")));
}
add_action("populate_options", "change_blog_widgets");
?>