merge multisite admin - edit links,tags,cats,options, See #11644

git-svn-id: http://svn.automattic.com/wordpress/trunk@12712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
wpmuguru 2010-01-12 21:11:52 +00:00
parent 0495192229
commit 346f859e12
14 changed files with 115 additions and 15 deletions

View File

@ -27,8 +27,23 @@ if ( get_option('db_upgraded') ) {
*/
do_action('after_db_upgrade');
} elseif ( get_option('db_version') != $wp_db_version ) {
wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI']))));
exit;
if ( !is_multisite() ) {
wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI']))));
exit;
} elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
/**
* On really small MU installs run the upgrader every time,
* else run it less often to reduce load.
*
* @since 2.8.4b
*/
$c = get_blog_count();
if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) {
require_once( ABSPATH . WPINC . '/http.php' );
$response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) );
do_action( 'after_mu_upgrade', $response );
}
}
}
require_once(ABSPATH . 'wp-admin/includes/admin.php');
@ -45,6 +60,7 @@ if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') )
set_screen_options();
$posts_per_page = get_option('posts_per_page');
$date_format = get_option('date_format');
$time_format = get_option('time_format');
@ -94,7 +110,7 @@ if (isset($plugin_page)) {
wp_die(__('Invalid plugin page'));
}
if (! ( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) )
if ( !( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) && !( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") && is_file(WPMU_PLUGIN_DIR . "/$plugin_page") ) )
wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
do_action('load-' . $plugin_page);
@ -102,7 +118,10 @@ if (isset($plugin_page)) {
if (! isset($_GET['noheader']))
require_once(ABSPATH . 'wp-admin/admin-header.php');
include(WP_PLUGIN_DIR . "/$plugin_page");
if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") )
include(WPMU_PLUGIN_DIR . "/$plugin_page");
else
include(ABSPATH . PLUGINDIR . "/$plugin_page");
}
include(ABSPATH . 'wp-admin/admin-footer.php');
@ -139,6 +158,9 @@ if (isset($plugin_page)) {
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
define('WP_IMPORTING', true);
if ( is_multisite() ) {
kses_init_filters(); // Always filter imported data with kses.
}
call_user_func($wp_importers[$importer][2]);

View File

@ -297,13 +297,13 @@ if ( $page_links )
<input name="cat_name" id="cat_name" type="text" value="" size="40" aria-required="true" />
<p><?php _e('The name is used to identify the category almost everywhere, for example under the post or in the category widget.'); ?></p>
</div>
<?php if ( is_multisite() ) { ?>
<div class="form-field">
<label for="category_nicename"><?php _e('Category Slug') ?></label>
<input name="category_nicename" id="category_nicename" type="text" value="" size="40" />
<p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
</div>
<?php } ?>
<div class="form-field">
<label for="category_parent"><?php _e('Category Parent') ?></label>
<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>

View File

@ -58,11 +58,13 @@ _fill_empty_category($category);
<th scope="row" valign="top"><label for="cat_name"><?php _e('Category Name') ?></label></th>
<td><input name="cat_name" id="cat_name" type="text" value="<?php echo esc_attr($category->name); ?>" size="40" aria-required="true" /></td>
</tr>
<?php if ( is_multisite() ) { ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="category_nicename"><?php _e('Category Slug') ?></label></th>
<td><input name="category_nicename" id="category_nicename" type="text" value="<?php echo esc_attr(apply_filters('editable_slug', $category->slug)); ?>" size="40" /><br />
<span class="description"><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></span></td>
</tr>
<?php } ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="category_parent"><?php _e('Category Parent') ?></label></th>
<td>

View File

@ -200,13 +200,13 @@ if ( $page_links )
<label for="name"><?php _e('Link Category name') ?></label>
<input name="name" id="name" type="text" value="" size="40" aria-required="true" />
</div>
<?php if ( is_multisite() ) { ?>
<div class="form-field">
<label for="slug"><?php _e('Link Category slug') ?></label>
<input name="slug" id="slug" type="text" value="" size="40" />
<p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
</div>
<?php } ?>
<div class="form-field">
<label for="description"><?php _e('Description (optional)') ?></label>
<textarea name="description" id="description" rows="5" cols="40"></textarea>

View File

@ -72,11 +72,13 @@ _fill_empty_link_category($category);
<th scope="row" valign="top"><label for="name"><?php _e('Link Category name') ?></label></th>
<td><input name="name" id="name" type="text" value="<?php echo esc_attr($category->name); ?>" size="40" aria-required="true" /></td>
</tr>
<?php if ( !is_multisite() ) { ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="slug"><?php _e('Link Category slug') ?></label></th>
<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr(apply_filters('editable_slug', $category->slug)); ?>" size="40" /><br />
<?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></td>
</tr>
<?php } ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="description"><?php _e('Description (optional)') ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo $category->description; ?></textarea><br />

View File

@ -35,11 +35,13 @@ do_action('edit_tag_form_pre', $tag); ?>
<th scope="row" valign="top"><label for="name"><?php _e('Tag name') ?></label></th>
<td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" /></td>
</tr>
<?php if ( !is_multisite() ) { ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="slug"><?php _e('Tag slug') ?></label></th>
<td><input name="slug" id="slug" type="text" value="<?php if ( isset( $tag->slug ) ) echo esc_attr(apply_filters('editable_slug', $tag->slug)); ?>" size="40" />
<p class="description"><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td>
</tr>
<?php } ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="description"><?php _e('Description') ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="50" style="width: 97%;"><?php echo esc_html($tag->description); ?></textarea><br />

View File

@ -300,13 +300,13 @@ else
<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
<p><?php _e('The name is how the tag appears on your site.'); ?></p>
</div>
<?php if ( !is_multisite() ) { ?>
<div class="form-field">
<label for="slug"><?php _e('Tag slug') ?></label>
<input name="slug" id="slug" type="text" value="" size="40" />
<p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
</div>
<?php } ?>
<div class="form-field">
<label for="description"><?php _e('Description') ?></label>
<textarea name="description" id="description" rows="5" cols="40"></textarea>

View File

@ -15,8 +15,10 @@
*/
$self = preg_replace('|^.*/wp-admin/|i', '', $_SERVER['PHP_SELF']);
$self = preg_replace('|^.*/plugins/|i', '', $self);
$self = preg_replace('|^.*/mu-plugins/|i', '', $self);
global $menu, $submenu, $parent_file; //For when admin-header is included from within a function.
$parent_file = apply_filters("parent_file", $parent_file); // For plugins to move submenu tabs around.
get_admin_page_parent();

View File

@ -52,6 +52,7 @@ include('admin-header.php');
<label for="comment_registration">
<input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
<?php _e('Users must be registered and logged in to comment') ?>
<?php if ( !get_option( 'users_can_register' ) && is_multisite() ) _e( ' (Signup has been disabled. Only members of this site can comment)' ); ?>
</label>
<br />

View File

@ -70,6 +70,7 @@ include('./admin-header.php');
<td><input name="blogdescription" type="text" id="blogdescription" value="<?php form_option('blogdescription'); ?>" class="regular-text" />
<span class="description"><?php _e('In a few words, explain what this blog is about.') ?></span></td>
</tr>
<?php if ( !is_multisite() ) { ?>
<tr valign="top">
<th scope="row"><label for="siteurl"><?php _e('WordPress address (URL)') ?></label></th>
<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /></td>
@ -97,6 +98,13 @@ include('./admin-header.php');
<select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option('default_role') ); ?></select>
</td>
</tr>
<?php } else { ?>
<tr valign="top">
<th scope="row"><label for="new_admin_email"><?php _e('E-mail address') ?> </label></th>
<td><input name="new_admin_email" type="text" id="new_admin_email" value="<?php form_option('admin_email'); ?>" class="regular-text code" />
<span class="setting-description"><?php _e('This address is used for admin purposes.') ?> <?php _e('If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>') ?></span></td>
</tr>
<?php } ?>
<tr>
<?php
if ( !wp_timezone_supported() ) : // no magic timezone support here
@ -281,6 +289,26 @@ endfor;
</select></td>
</tr>
<?php do_settings_fields('general', 'default'); ?>
<?php
if ( is_multisite() && is_dir( ABSPATH . LANGDIR ) && $dh = opendir( ABSPATH . LANGDIR ) )
while( ( $lang_file = readdir( $dh ) ) !== false )
if( substr( $lang_file, -3 ) == '.mo' )
$lang_files[] = $lang_file;
$lang = get_option('WPLANG');
if( is_array($lang_files) && !empty($lang_files) ) {
?>
<tr valign="top">
<th width="33%" scope="row"><?php _e('Blog language:') ?></th>
<td>
<select name="WPLANG" id="WPLANG">
<?php mu_dropdown_languages( $lang_files, get_option('WPLANG') ); ?>
</select>
</td>
</tr>
<?php
} // languages
?>
</table>
<?php do_settings_sections('general'); ?>

View File

@ -25,7 +25,7 @@ include('admin-header.php');
<form method="post" action="options.php">
<?php settings_fields('misc'); ?>
<?php if ( !is_multisite() ) { ?>
<h3><?php _e('Uploading Files'); ?></h3>
<table class="form-table">
<tr valign="top">
@ -65,7 +65,7 @@ include('admin-header.php');
</tr>
</table>
<?php } ?>
<?php do_settings_sections('misc'); ?>
<p class="submit">

View File

@ -82,6 +82,9 @@ if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
$permalink_structure = $_POST['permalink_structure'];
if (! empty($permalink_structure) )
$permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
if ( is_multisite() && !is_subdomain_install() && $permalink_structure != '' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) {
$permalink_structure = '/blog' . $permalink_structure;
}
$wp_rewrite->set_permalink_structure($permalink_structure);
}
@ -89,6 +92,9 @@ if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
$category_base = $_POST['category_base'];
if (! empty($category_base) )
$category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
if ( is_miltisite() && !is_subdomain_install() && $category_base != '' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) {
$category_base = '/blog' . $category_base;
}
$wp_rewrite->set_category_base($category_base);
}
@ -96,6 +102,9 @@ if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
$tag_base = $_POST['tag_base'];
if (! empty($tag_base) )
$tag_base = preg_replace('#/+#', '/', '/' . $_POST['tag_base']);
if ( is_multisite() && !is_subdomain_install() && $tag_base != '' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) {
$tag_base = '/blog' . $tag_base;
}
$wp_rewrite->set_tag_base($tag_base);
}
}
@ -194,6 +203,7 @@ $structures = array(
</label>
</th>
<td>
<?php if ( is_multisite() && !is_subdomain_install() && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $permalink_structure = str_replace( "/blog", "", $permalink_structure ); }?>
<input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" />
</td>
</tr>
@ -209,11 +219,11 @@ $structures = array(
<table class="form-table">
<tr>
<th><label for="category_base"><?php _e('Category base'); ?></label></th>
<td><input name="category_base" id="category_base" type="text" value="<?php echo esc_attr($category_base); ?>" class="regular-text code" /></td>
<td><?php if ( is_multisite() && !is_subdomain_install() && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $category_base = str_replace( "/blog", "", $category_base ); }?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td>
</tr>
<tr>
<th><label for="tag_base"><?php _e('Tag base'); ?></label></th>
<td><input name="tag_base" id="tag_base" type="text" value="<?php echo esc_attr($tag_base); ?>" class="regular-text code" /></td>
<td><?php if ( is_multisite() && !is_subdomain_install() && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path ) { echo "/blog"; $tag_base = str_replace( "/blog", "", $tag_base ); }?> <input name="tag_base" id="tag_base" type="text" value="<?php echo esc_attr($tag_base); ?>" class="regular-text code" /></td>
</tr>
<?php do_settings_fields('permalink', 'optional'); ?>
</table>
@ -224,6 +234,7 @@ $structures = array(
<input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" />
</p>
</form>
<?php if ( !is_multisite || is_super_admin() ) { ?>
<?php if ($iis7_permalinks) :
if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) :
if ( file_exists($home_path . 'web.config') ) : ?>
@ -251,6 +262,7 @@ $structures = array(
</form>
<?php endif; ?>
<?php endif; ?>
<?php } // multisite ?>
</div>

View File

@ -81,6 +81,7 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_link_category
<?php do_settings_fields('writing', 'remote_publishing'); ?>
</table>
<?php if ( !is_multisite() || defined( 'POST_BY_EMAIL' ) ) { ?>
<h3><?php _e('Post via e-mail') ?></h3>
<p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it&#8217;s a good idea to keep this address very secret. Here are three random strings you could use: <kbd>%s</kbd>, <kbd>%s</kbd>, <kbd>%s</kbd>.'), wp_generate_password(8, false), wp_generate_password(8, false), wp_generate_password(8, false)) ?></p>
@ -112,7 +113,8 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_categor
</tr>
<?php do_settings_fields('writing', 'post_via_email'); ?>
</table>
<?php } ?>
<?php if ( !is_multisite() ) { ?>
<h3><?php _e('Update Services') ?></h3>
<?php if ( get_option('blog_public') ) : ?>
@ -126,6 +128,7 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_email_categor
<p><?php printf(__('WordPress is not notifying any <a href="http://codex.wordpress.org/Update_Services">Update Services</a> because of your blog&#8217;s <a href="%s">privacy settings</a>.'), 'options-privacy.php'); ?></p>
<?php endif; ?>
<?php } // multisite ?>
<?php do_settings_sections('writing'); ?>

View File

@ -38,6 +38,20 @@ $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
if ( !current_user_can('manage_options') )
wp_die(__('Cheatin&#8217; uh?'));
if ( is_multisite() && is_super_admin() && $_GET[ 'adminhash' ] ) {
$new_admin_details = get_option( 'adminhash' );
if( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && $new_admin_details[ 'newemail' ] != '' ) {
update_option( "admin_email", $new_admin_details[ 'newemail' ] );
delete_option( "adminhash" );
delete_option( "new_admin_email" );
wp_redirect( get_option( "siteurl" ) . "/wp-admin/options-general.php?updated=true" );
exit;
} else {
wp_redirect( get_option( "siteurl" ) . "/wp-admin/options-general.php?updated=false" );
exit;
}
}
switch($action) {
case 'update':
@ -55,6 +69,8 @@ case 'update':
if ( 'options' == $option_page ) {
$options = explode(',', stripslashes( $_POST[ 'page_options' ] ));
if ( !is_super_admin() )
wp_die( __( 'Not allowed here' ) );
} else {
$options = $whitelist_options[ $option_page ];
}
@ -90,6 +106,9 @@ case 'update':
break;
default:
if ( !is_super_admin() )
wp_die( __( 'Not admin' ) );
include('admin-header.php'); ?>
<div class="wrap">
@ -99,6 +118,11 @@ default:
<?php wp_nonce_field('options-options') ?>
<input type="hidden" name="action" value="update" />
<input type='hidden' name='option_page' value='options' />
<?php if ( is_multisite() ) { ?>
<p class="submit submit-top">
<input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" class="button-primary" />
</p>
<?php } ?>
<table class="form-table">
<?php
$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
@ -106,6 +130,8 @@ $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name
foreach ( (array) $options as $option) :
$disabled = '';
$option->option_name = esc_attr($option->option_name);
if( $option->option_name == '' )
continue;
if ( is_serialized($option->option_value) ) {
if ( is_serialized_string($option->option_value) ) {
// this is a serialized string, so we should display it