Advertisement
Guest User

MrBrian

a guest
Aug 23rd, 2008
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.60 KB | None | 0 0
  1. <?php
  2. /*
  3. * Plugin Name: WPMU Blog Defaults
  4. * Plugin URI: http://paidtoblog.com
  5. * Description: Change the default options for WPMU and new blogs automagically
  6. * Version: 1.0.2
  7. * Author URI: MrBrian
  8. */
  9.  
  10. //------------------------------------------------------------------------//
  11. //---Remove permalinks from menu------------------------------------------//
  12. //------------------------------------------------------------------------//
  13. function remove_permalinks_menu_item()
  14. {
  15.     global $submenu;
  16.     if(!is_site_admin()) $submenu['options-general.php'][35] = '';
  17. }
  18. add_action( 'admin_menu', 'remove_permalinks_menu_item' );
  19.  
  20. //------------------------------------------------------------------------//
  21. //---Change the permalink structure and default blogroll------------------//
  22. //------------------------------------------------------------------------//
  23.  
  24. function change_newblog_defaults( $blog_id, $user_id )
  25. {
  26.     global $wpdb, $current_site, $wp_rewrite;
  27.     //--change permalink structure
  28.     switch_to_blog($blog_id);
  29.     $permalink_structure = '/%category%/%postname%/';
  30.     $wp_rewrite->set_permalink_structure($permalink_structure);
  31.     $wp_rewrite->flush_rules();
  32.     $wpdb->query( "UPDATE {$wpdb->terms} SET name = 'Articles', slug = 'articles' WHERE term_id = 1" );
  33.     //--end
  34.    
  35.     //--change default blogroll
  36.     $wpdb->query( "DELETE FROM {$wpdb->links} WHERE link_id = 1" );
  37.     $wpdb->query( "DELETE FROM {$wpdb->links}WHERE link_id = 2" );
  38.     $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/')" );
  39.     //--end
  40.     restore_current_blog();
  41. }
  42. add_action( 'wpmu_new_blog', 'change_newblog_defaults', 10, 2 );
  43.  
  44. //------------------------------------------------------------------------//
  45. //---Modify the From and email used when sending emails from WPMU---------//
  46. //------------------------------------------------------------------------//
  47.  
  48. function change_wp_mail_from($from_email)
  49. {
  50.     return $from_email; //return whatever you want as email, i just like it as default.
  51. }
  52. add_filter( 'wp_mail_from', 'change_wp_mail_from' );
  53.  
  54. function change_wp_mail_from_name($from_name)
  55. {
  56.     global $current_site;
  57.     return $current_site->domain;
  58. }
  59. add_filter( 'wp_mail_from_name', 'change_wp_mail_from_name' );
  60.  
  61. //------------------------------------------------------------------------//
  62. //---Change The Help and Forum links at very top of WPMU backend---------//
  63. //------------------------------------------------------------------------//
  64.  
  65. function change_header_navigation($header_nav)
  66. {
  67.     global $current_site;
  68.     $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>';
  69.     return $header_nav;
  70. }
  71. add_filter('admin_header_navigation', 'change_header_navigation');
  72.  
  73. //------------------------------------------------------------------------//
  74. //---Change default widgets------------------------------------------//
  75. //------------------------------------------------------------------------//
  76. This activates the given widgets in sidebar-1 and -2. You need to know the internal names of the widgets.
  77. function change_blog_widgets() {
  78.  
  79.     add_option("sidebars_widgets",
  80.         array("sidebar-1" => array("tag_cloud"),
  81.              "sidebar-2" => array("archives", "links")));
  82.  
  83. }
  84. add_action("populate_options", "change_blog_widgets");
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement