Commit e53dcb66 authored by lechuck's avatar lechuck Committed by lechuck
Browse files

New Blogs Default upgrade to 2.2.2

parent 51f32fcc
<?php <?php
/****************************************************************************************************************** /******************************************************************************************************************
Plugin Name: cets_blog_defaults Plugin Name: New Blog Defaults (CETS)
Plugin URI: Plugin URI:
Description: WordPress Multisite plugin for network admin to set defaults for new blogs. Description: WordPress Multisite plugin for network admin to set defaults for new blogs.
Version: 2.2.2
Version: 2.2 Author: Deanna Schneider, Jason Lemahieu (MadtownLems)
Author: Deanna Schneider, Jason Lemahieu
Copyright: Copyright:
Copyright 2008 CETS Copyright 2008 - 2012 CETS
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -106,6 +102,7 @@ class cets_blog_defaults ...@@ -106,6 +102,7 @@ class cets_blog_defaults
'default_cat_name' => 'Uncategorized', 'default_cat_name' => 'Uncategorized',
'default_link_cat' => 'Links', 'default_link_cat' => 'Links',
'delete_first_post' => 0, 'delete_first_post' => 0,
'delete_initial_widgets' => 0,
'delete_first_comment' => 0, 'delete_first_comment' => 0,
'default_links' => '', 'default_links' => '',
'default_categories' => '', 'default_categories' => '',
...@@ -251,6 +248,13 @@ class cets_blog_defaults ...@@ -251,6 +248,13 @@ class cets_blog_defaults
} }
unset($options['delete_first_post']); unset($options['delete_first_post']);
// Delete Initial Widgets
if (isset($options['delete_initial_widgets']) && $options['delete_initial_widgets'] == 1){
delete_option('sidebars_widgets');
}
unset($options['delete_initial_widgets']);
// Add Default Links // Add Default Links
if (isset($options['default_links']) && strlen($options['default_links'])){ if (isset($options['default_links']) && strlen($options['default_links'])){
...@@ -483,20 +487,30 @@ class cets_blog_defaults ...@@ -483,20 +487,30 @@ class cets_blog_defaults
else {$newoptions['delete_blogroll_links'] = 0;} else {$newoptions['delete_blogroll_links'] = 0;}
$newoptions['default_cat_name'] = $_POST['default_cat_name']; $newoptions['default_cat_name'] = $_POST['default_cat_name'];
$newoptions['default_link_cat'] = $_POST['default_link_cat']; $newoptions['default_link_cat'] = $_POST['default_link_cat'];
if ($_POST['delete_first_post'] == 1) {
if ($_POST['delete_first_post'] == 1) {
$newoptions['delete_first_post'] = 1; } $newoptions['delete_first_post'] = 1; }
else {$newoptions['delete_first_post'] = 0;} else {$newoptions['delete_first_post'] = 0;}
if ($_POST['delete_initial_widgets'] == 1) {
$newoptions['delete_initial_widgets'] = 1; }
else {$newoptions['delete_initial_widgets'] = 0;}
if ($_POST['delete_first_comment'] == 1) { if ($_POST['delete_first_comment'] == 1) {
$newoptions['delete_first_comment'] = 1; } $newoptions['delete_first_comment'] = 1; }
else {$newoptions['delete_first_comment'] = 0;} else {$newoptions['delete_first_comment'] = 0;}
if ($_POST['add_user_to_blog'] == 1) { if ($_POST['add_user_to_blog'] == 1) {
$newoptions['add_user_to_blog'] = 1; } $newoptions['add_user_to_blog'] = 1; }
else {$newoptions['add_user_to_blog'] = 0;} else {$newoptions['add_user_to_blog'] = 0;}
$newoptions['add_user_to_blog_role'] = $_POST['add_user_to_blog_role']; $newoptions['add_user_to_blog_role'] = $_POST['add_user_to_blog_role'];
$newoptions['add_user_to_blog_id'] = $_POST['add_user_to_blog_id']; $newoptions['add_user_to_blog_id'] = $_POST['add_user_to_blog_id'];
if ($_POST['close_comments_on_hello_world'] == 1) { if ($_POST['close_comments_on_hello_world'] == 1) {
$newoptions['close_comments_on_hello_world'] = 1; } $newoptions['close_comments_on_hello_world'] = 1; }
else {$newoptions['close_comments_on_hello_world'] = 0;} else {$newoptions['close_comments_on_hello_world'] = 0;}
if ($_POST['close_comments_on_about_page'] == 1) { if ($_POST['close_comments_on_about_page'] == 1) {
$newoptions['close_comments_on_about_page'] = 1; } $newoptions['close_comments_on_about_page'] = 1; }
else {$newoptions['close_comments_on_about_page'] = 0;} else {$newoptions['close_comments_on_about_page'] = 0;}
...@@ -547,7 +561,7 @@ class cets_blog_defaults ...@@ -547,7 +561,7 @@ class cets_blog_defaults
global $wpdb; global $wpdb;
// only allow site admins to come here. // only allow site admins to come here.
if( is_site_admin() == false ) { if( is_super_admin() == false ) {
wp_die( __('You do not have permission to access this page.') ); wp_die( __('You do not have permission to access this page.') );
} }
...@@ -556,7 +570,7 @@ class cets_blog_defaults ...@@ -556,7 +570,7 @@ class cets_blog_defaults
// process form submission // process form submission
if ($_POST['action'] == 'update') { if (isset($_POST['action']) && $_POST['action'] == 'update') {
$this->update_defaults($_POST); $this->update_defaults($_POST);
$updated = true; $updated = true;
} }
...@@ -564,7 +578,7 @@ class cets_blog_defaults ...@@ -564,7 +578,7 @@ class cets_blog_defaults
// make sure we're using latest data // make sure we're using latest data
$opt = get_site_option('cets_blog_defaults_options'); $opt = get_site_option('cets_blog_defaults_options');
if ($updated) { ?> if (isset($updated) && $updated) { ?>
<div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div> <div id="message" class="updated fade"><p><?php _e('Options saved.') ?></p></div>
<?php } ?> <?php } ?>
...@@ -589,44 +603,6 @@ class cets_blog_defaults ...@@ -589,44 +603,6 @@ class cets_blog_defaults
<!-- Begin Time Zone --> <!-- Begin Time Zone -->
<tr> <tr>
<?php <?php
if ( !wp_timezone_supported() ) : // no magic timezone support here
?>
<th scope="row"><label for="gmt_offset"><?php _e('Timezone') ?> </label></th>
<td>
<select name="gmt_offset" id="gmt_offset">
<?php
$current_offset = $opt['gmt_offset'];
$offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5,
0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
foreach ( $offset_range as $offset ) {
if ( 0 < $offset )
$offset_name = '+' . $offset;
elseif ( 0 == $offset )
$offset_name = '';
else
$offset_name = (string) $offset;
$offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
$selected = '';
if ( $current_offset == $offset ) {
$selected = " selected='selected'";
$current_offset_name = $offset_name;
}
echo "<option value=\"" . esc_attr($offset) . "\"$selected>" . sprintf(__('UTC %s'), $offset_name) . '</option>';
}
?>
</select>
<?php _e('hours'); ?>
<span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n( $time_format, false, 'gmt')); ?></span>
<?php if ($current_offset) : ?>
<span id="local-time"><?php printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, date_i18n($time_format)); ?></span>
<?php endif; ?>
<br />
<span class="description"><?php _e('Unfortunately, you have to manually update this for Daylight Savings Time. Lame, we know, but will be fixed in the future.'); ?></span>
</td>
<?php
else: // looks like we can do nice timezone selection!
$current_offset = $opt['gmt_offset']; $current_offset = $opt['gmt_offset'];
$tzstring = $opt['timezone_string']; $tzstring = $opt['timezone_string'];
...@@ -696,11 +672,13 @@ class cets_blog_defaults ...@@ -696,11 +672,13 @@ class cets_blog_defaults
<?php endif; ?> <?php endif; ?>
</td> </td>
<?php endif; ?>
</tr> </tr>
<!-- End Time Zone --> <!-- End Time Zone -->
<tr> <tr>
<th scope="row"><?php _e('Date Format') ?></th> <th scope="row"><?php _e('Date Format') ?></th>
...@@ -904,7 +882,7 @@ class cets_blog_defaults ...@@ -904,7 +882,7 @@ class cets_blog_defaults
<label for="close_comments_for_old_posts"> <label for="close_comments_for_old_posts">
<input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', $opt['close_comments_for_old_posts']); ?> /> <input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', $opt['close_comments_for_old_posts']); ?> />
<?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . attribute_escape($opt['close_comments_days_old']) . '" class="small-text" />') ?> <?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . esc_attr($opt['close_comments_days_old']) . '" class="small-text" />') ?>
<br /> <br />
<label for="thread_comments"> <label for="thread_comments">
<input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', $opt['thread_comments']); ?> /> <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', $opt['thread_comments']); ?> />
...@@ -917,7 +895,7 @@ class cets_blog_defaults ...@@ -917,7 +895,7 @@ class cets_blog_defaults
$thread_comments_depth = '</label><select name="thread_comments_depth" id="thread_comments_depth">'; $thread_comments_depth = '</label><select name="thread_comments_depth" id="thread_comments_depth">';
for ( $i = 1; $i <= $maxdeep; $i++ ) { for ( $i = 1; $i <= $maxdeep; $i++ ) {
$thread_comments_depth .= "<option value='$i'"; $thread_comments_depth .= "<option value='$i'";
if ( $opt['thread_comments_depth'] == $i ) $thread_comments_depth .= " selected='selected'"; if (isset($opt['thread_comments_depth']) && $opt['thread_comments_depth'] == $i ) $thread_comments_depth .= " selected='selected'";
$thread_comments_depth .= ">$i</option>"; $thread_comments_depth .= ">$i</option>";
} }
$thread_comments_depth .= '</select>'; $thread_comments_depth .= '</select>';
...@@ -931,12 +909,12 @@ class cets_blog_defaults ...@@ -931,12 +909,12 @@ class cets_blog_defaults
$default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"'; $default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
if ( 'newest' == $opt['default_comments_page'] ) $default_comments_page .= ' selected="selected"'; if ( isset($opt['default_comments_page']) && 'newest' == $opt['default_comments_page'] ) $default_comments_page .= ' selected="selected"';
$default_comments_page .= '>' . __('last') . '</option><option value="oldest"'; $default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
if ( 'oldest' == $opt['default_comments_page'] ) $default_comments_page .= ' selected="selected"'; if ( 'oldest' == $opt['default_comments_page'] ) $default_comments_page .= ' selected="selected"';
$default_comments_page .= '>' . __('first') . '</option></select>'; $default_comments_page .= '>' . __('first') . '</option></select>';
printf( __('Break comments into pages with %1$s comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . attribute_escape($opt['comments_per_page']) . '" class="small-text" />', $default_comments_page ); printf( __('Break comments into pages with %1$s comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . esc_attr($opt['comments_per_page']) . '" class="small-text" />', $default_comments_page );
?></label> ?></label>
<br /> <br />
...@@ -1156,7 +1134,7 @@ class cets_blog_defaults ...@@ -1156,7 +1134,7 @@ class cets_blog_defaults
</th> </th>
<td> <td>
<?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $permalink_structure = str_replace( "/blog", "", $opt['permalink_structure'] ); }?> <?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $permalink_structure = str_replace( "/blog", "", $opt['permalink_structure'] ); }?>
<input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo attribute_escape($opt['permalink_structure']); ?>" size="50" /> <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo esc_attr($opt['permalink_structure']); ?>" size="50" />
</td> </td>
</tr> </tr>
</table> </table>
...@@ -1171,11 +1149,11 @@ class cets_blog_defaults ...@@ -1171,11 +1149,11 @@ class cets_blog_defaults
<table class="form-table"> <table class="form-table">
<tr> <tr>
<th><?php _e('Category base'); ?></th> <th><?php _e('Category base'); ?></th>
<td><?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $opt['category_base'] = str_replace( "/blog", "", $opt['category_base'] ); }?> <input name="category_base" type="text" class="code" value="<?php echo attribute_escape( $opt['category_base'] ); ?>" size="30" /></td> <td><?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $opt['category_base'] = str_replace( "/blog", "", $opt['category_base'] ); }?> <input name="category_base" type="text" class="code" value="<?php echo esc_attr( $opt['category_base'] ); ?>" size="30" /></td>
</tr> </tr>
<tr> <tr>
<th><?php _e('Tag base'); ?></th> <th><?php _e('Tag base'); ?></th>
<td><?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $opt['tag_base'] = str_replace( "/blog", "", $opt['tag_base'] ); }?> <input name="tag_base" id="tag_base" type="text" class="code" value="<?php echo attribute_escape($opt['tag_base']); ?>" size="30" /></td> <td><?php if( constant( 'VHOST' ) == 'no' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $opt['tag_base'] = str_replace( "/blog", "", $opt['tag_base'] ); }?> <input name="tag_base" id="tag_base" type="text" class="code" value="<?php echo esc_attr($opt['tag_base']); ?>" size="30" /></td>
</tr> </tr>
</table> </table>
...@@ -1258,15 +1236,17 @@ class cets_blog_defaults ...@@ -1258,15 +1236,17 @@ class cets_blog_defaults
$blog_allowed_themes = wpmu_get_blog_allowedthemes(); $blog_allowed_themes = wpmu_get_blog_allowedthemes();
if( is_array( $blog_allowed_themes ) ) if( is_array( $blog_allowed_themes ) )
$allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes ); $allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes );
if( $blog_id != 1 )
if( $blog_id != 1 ) {
unset( $allowed_themes[ "h3" ] ); unset( $allowed_themes[ "h3" ] );
}
if( isset( $allowed_themes[ wp_specialchars( $ct->stylesheet ) ] ) == false ) if( isset( $allowed_themes[ esc_html( $ct->stylesheet ) ] ) == false )
$allowed_themes[ wp_specialchars( $ct->stylesheet ) ] = true; $allowed_themes[ esc_html( $ct->stylesheet ) ] = true;
reset( $themes ); reset( $themes );
foreach( $themes as $key => $theme ) { foreach( $themes as $key => $theme ) {
if( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false ) { if( isset( $allowed_themes[ esc_html( $theme[ 'Stylesheet' ] ) ] ) == false ) {
unset( $themes[ $key ] ); unset( $themes[ $key ] );
} }
} }
...@@ -1377,6 +1357,14 @@ class cets_blog_defaults ...@@ -1377,6 +1357,14 @@ class cets_blog_defaults
<input name="delete_first_post" type="checkbox" id="delete_first_post" value="1" <?php if ($opt['delete_first_post'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?></label> <input name="delete_first_post" type="checkbox" id="delete_first_post" value="1" <?php if ($opt['delete_first_post'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?></label>
</td> </td>
</tr> </tr>
<tr>
<th>Delete Initial Widgets</th>
<td>
<input name="delete_initial_widgets" type="checkbox" id="delete_initial_widgets" value="1" <?php if ($opt['delete_initial_widgets'] == 1) echo('checked="checked"'); ?> /> <?php _e('Yes') ?>
</td>
</tr>
<tr> <tr>
<th colspan="2"> <th colspan="2">
Sites that use a combination of BBPress and BuddyPress need all users to be subscribed to the blog on which BBPress is installed. The following section lets you do that. Note that you may add people to a comma-delimited list of blogs, but they will have the same role on each blog. Sites that use a combination of BBPress and BuddyPress need all users to be subscribed to the blog on which BBPress is installed. The following section lets you do that. Note that you may add people to a comma-delimited list of blogs, but they will have the same role on each blog.
...@@ -1422,7 +1410,7 @@ $cets_wpmubd = new cets_blog_defaults(); ...@@ -1422,7 +1410,7 @@ $cets_wpmubd = new cets_blog_defaults();
// call set up if there's not option set yet // call set up if there's not option set yet
if( get_site_option( 'cets_blog_defaults_setup' ) == null OR ($_GET['reset'] == 1 && $_GET['page'] == 'cets_blog_defaults_management_page')) { if( get_site_option( 'cets_blog_defaults_setup' ) == null OR (isset($_GET['reset']) && $_GET['reset'] == 1 && $_GET['page'] == 'cets_blog_defaults_management_page')) {
// only allow site admins to run setup. // only allow site admins to run setup.
//if( is_site_admin() == true ) { //if( is_site_admin() == true ) {
...@@ -1481,17 +1469,3 @@ function cets_nbd_from_name($from_name) ...@@ -1481,17 +1469,3 @@ function cets_nbd_from_name($from_name)
} }
?>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Contributors: DeannaS, kgraeme, MadtownLems Contributors: DeannaS, kgraeme, MadtownLems
Tags: WPMU, Wordpress Mu, Wordpress Multiuser, Blog Defaults, Set Defaults Tags: WPMU, Wordpress Mu, Wordpress Multiuser, Blog Defaults, Set Defaults
Requires at least: 3.0 Requires at least: 3.0
Tested up to: 3.1 Tested up to: 3.4.2
Stable tag: trunk Stable tag: trunk
...@@ -48,6 +48,9 @@ No, it's not designed to affect current blogs. Settings will only affect new blo ...@@ -48,6 +48,9 @@ No, it's not designed to affect current blogs. Settings will only affect new blo
You will have to pull a tagged version from the repository. Version 2.1 of this plugin works on older versions of WordPress. You will have to pull a tagged version from the repository. Version 2.1 of this plugin works on older versions of WordPress.
== Changelog == == Changelog ==
2.2.2 - Minor cleanup and removed some notices
2.2 - Moved admin page to Network->Settings for 3.1. Increased required WP Version to 3.0. (stopped support for lower version) 2.2 - Moved admin page to Network->Settings for 3.1. Increased required WP Version to 3.0. (stopped support for lower version)
2.1 - Fixed deprecated parameter on add_sub_menu page 2.1 - Fixed deprecated parameter on add_sub_menu page
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment