first pass on optional global terms, see #12589
git-svn-id: http://svn.automattic.com/wordpress/trunk@13715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
10656cb1eb
commit
47302e0188
|
@ -200,7 +200,7 @@ if ( $page_links )
|
||||||
<label for="name"><?php _e('Link Category name') ?></label>
|
<label for="name"><?php _e('Link Category name') ?></label>
|
||||||
<input name="name" id="name" type="text" value="" size="40" aria-required="true" />
|
<input name="name" id="name" type="text" value="" size="40" aria-required="true" />
|
||||||
</div>
|
</div>
|
||||||
<?php if ( !is_multisite() ) { ?>
|
<?php if ( !global_terms_enabled() ) { ?>
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label for="slug"><?php _e('Link Category slug') ?></label>
|
<label for="slug"><?php _e('Link Category slug') ?></label>
|
||||||
<input name="slug" id="slug" type="text" value="" size="40" />
|
<input name="slug" id="slug" type="text" value="" size="40" />
|
||||||
|
|
|
@ -37,7 +37,7 @@ do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?>
|
||||||
<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><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" />
|
||||||
<p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
|
<p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ( !is_multisite() ) { ?>
|
<?php if ( !global_terms_enabled() ) { ?>
|
||||||
<tr class="form-field">
|
<tr class="form-field">
|
||||||
<th scope="row" valign="top"><label for="slug"><?php echo _x('Slug', 'Taxonomy Slug'); ?></label></th>
|
<th scope="row" valign="top"><label for="slug"><?php echo _x('Slug', 'Taxonomy 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" />
|
<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" />
|
||||||
|
|
|
@ -520,7 +520,7 @@ function format_code_lang( $code = '' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sync_category_tag_slugs( $term, $taxonomy ) {
|
function sync_category_tag_slugs( $term, $taxonomy ) {
|
||||||
if ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) {
|
if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
|
||||||
if ( is_object( $term ) ) {
|
if ( is_object( $term ) ) {
|
||||||
$term->slug = sanitize_title( $term->name );
|
$term->slug = sanitize_title( $term->name );
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -659,9 +659,6 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !is_multisite() ) {
|
if ( !is_multisite() ) {
|
||||||
|
|
||||||
$wpdb->query( "INSERT INTO $wpdb->sitecategories (cat_id, cat_name, category_nicename, last_updated) SELECT term_id, `name`, slug, NOW() FROM $wpdb->terms" );
|
|
||||||
|
|
||||||
$site_admins = array( $site_user->user_login );
|
$site_admins = array( $site_user->user_login );
|
||||||
$users = get_users_of_blog();
|
$users = get_users_of_blog();
|
||||||
if ( $users ) {
|
if ( $users ) {
|
||||||
|
@ -708,11 +705,8 @@ Thanks!
|
||||||
'add_new_users' => '0',
|
'add_new_users' => '0',
|
||||||
'upload_space_check_disabled' => '0',
|
'upload_space_check_disabled' => '0',
|
||||||
'subdomain_install' => intval( $subdomain_install ),
|
'subdomain_install' => intval( $subdomain_install ),
|
||||||
|
'global_terms_enabled' => global_terms_enabled() ? '1' : '0'
|
||||||
);
|
);
|
||||||
if ( is_multisite() )
|
|
||||||
$sitemeta[ 'global_terms_enabled' ] = get_site_option( 'global_terms_enabled', '0' );
|
|
||||||
else
|
|
||||||
$sitemeta[ 'global_terms_enabled' ] = '0';
|
|
||||||
|
|
||||||
$insert = '';
|
$insert = '';
|
||||||
foreach ( $sitemeta as $meta_key => $meta_value ) {
|
foreach ( $sitemeta as $meta_key => $meta_value ) {
|
||||||
|
|
|
@ -110,7 +110,7 @@ function wp_install_defaults($user_id) {
|
||||||
/* translators: Default category slug */
|
/* translators: Default category slug */
|
||||||
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
|
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
|
||||||
|
|
||||||
if ( is_multisite() ) {
|
if ( global_terms_enabled() ) {
|
||||||
$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
|
$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
|
||||||
if ( $cat_id == null ) {
|
if ( $cat_id == null ) {
|
||||||
$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
|
$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
|
||||||
|
@ -130,7 +130,7 @@ function wp_install_defaults($user_id) {
|
||||||
/* translators: Default link category slug */
|
/* translators: Default link category slug */
|
||||||
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
|
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
|
||||||
|
|
||||||
if ( is_multisite() ) {
|
if ( global_terms_enabled() ) {
|
||||||
$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
|
$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
|
||||||
if ( $blogroll_id == null ) {
|
if ( $blogroll_id == null ) {
|
||||||
$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
|
$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
|
||||||
|
@ -1917,15 +1917,6 @@ CREATE TABLE $wpdb->sitemeta (
|
||||||
KEY meta_key (meta_key),
|
KEY meta_key (meta_key),
|
||||||
KEY site_id (site_id)
|
KEY site_id (site_id)
|
||||||
) $charset_collate;
|
) $charset_collate;
|
||||||
CREATE TABLE $wpdb->sitecategories (
|
|
||||||
cat_ID bigint(20) NOT NULL auto_increment,
|
|
||||||
cat_name varchar(55) NOT NULL default '',
|
|
||||||
category_nicename varchar(200) NOT NULL default '',
|
|
||||||
last_updated timestamp NOT NULL,
|
|
||||||
PRIMARY KEY (cat_ID),
|
|
||||||
KEY category_nicename (category_nicename),
|
|
||||||
KEY last_updated (last_updated)
|
|
||||||
) $charset_collate;
|
|
||||||
CREATE TABLE $wpdb->signups (
|
CREATE TABLE $wpdb->signups (
|
||||||
domain varchar(200) NOT NULL default '',
|
domain varchar(200) NOT NULL default '',
|
||||||
path varchar(100) NOT NULL default '',
|
path varchar(100) NOT NULL default '',
|
||||||
|
@ -1945,4 +1936,29 @@ CREATE TABLE $wpdb->signups (
|
||||||
dbDelta( $ms_queries );
|
dbDelta( $ms_queries );
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install global terms.
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if ( !function_exists( 'install_global_terms' ) ) :
|
||||||
|
function install_global_terms() {
|
||||||
|
global $wpdb, $charset_collate;
|
||||||
|
$ms_queries = "
|
||||||
|
CREATE TABLE $wpdb->sitecategories (
|
||||||
|
cat_ID bigint(20) NOT NULL auto_increment,
|
||||||
|
cat_name varchar(55) NOT NULL default '',
|
||||||
|
category_nicename varchar(200) NOT NULL default '',
|
||||||
|
last_updated timestamp NOT NULL,
|
||||||
|
PRIMARY KEY (cat_ID),
|
||||||
|
KEY category_nicename (category_nicename),
|
||||||
|
KEY last_updated (last_updated)
|
||||||
|
) $charset_collate;
|
||||||
|
";
|
||||||
|
// now create tables
|
||||||
|
dbDelta( $ms_queries );
|
||||||
|
}
|
||||||
|
endif;
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -107,6 +107,12 @@ switch ( $_GET['action'] ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_site_option( "dashboard_blog", $dashboard_blog_id );
|
update_site_option( "dashboard_blog", $dashboard_blog_id );
|
||||||
|
// global terms
|
||||||
|
if ( !global_terms_enabled() && '1' == $_POST[ 'global_terms_enabled' ] ) {
|
||||||
|
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
||||||
|
// create global terms table
|
||||||
|
install_global_terms();
|
||||||
|
}
|
||||||
$options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'admin_notice_feed', 'global_terms_enabled' );
|
$options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'admin_notice_feed', 'global_terms_enabled' );
|
||||||
$checked_options = array('mu_media_buttons', 'menu_items');
|
$checked_options = array('mu_media_buttons', 'menu_items');
|
||||||
foreach ( $checked_options as $option_name ) {
|
foreach ( $checked_options as $option_name ) {
|
||||||
|
|
|
@ -447,7 +447,7 @@ function wp_load_core_site_options( $site_id = null ) {
|
||||||
if ( empty($site_id) )
|
if ( empty($site_id) )
|
||||||
$site_id = $wpdb->siteid;
|
$site_id = $wpdb->siteid;
|
||||||
|
|
||||||
$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'dashboard_blog', 'can_compress_scripts');
|
$core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'dashboard_blog', 'can_compress_scripts', 'global_terms_enabled' );
|
||||||
|
|
||||||
$core_options_in = "'" . implode("', '", $core_options) . "'";
|
$core_options_in = "'" . implode("', '", $core_options) . "'";
|
||||||
$options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
|
$options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) );
|
||||||
|
@ -3690,6 +3690,22 @@ function is_main_site( $blog_id = '' ) {
|
||||||
return $blog_id == $current_site->blog_id;
|
return $blog_id == $current_site->blog_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* are global terms enabled
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @since 3.0.0
|
||||||
|
* @package WordPress
|
||||||
|
*
|
||||||
|
* @return bool True if multisite and global terms enabled
|
||||||
|
*/
|
||||||
|
function global_terms_enabled() {
|
||||||
|
if ( is_multisite() && '1' == get_site_option( 'global_terms_enabled' ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gmt_offset modification for smart timezone handling
|
* gmt_offset modification for smart timezone handling
|
||||||
*
|
*
|
||||||
|
|
|
@ -1210,6 +1210,9 @@ function fix_import_form_size( $size ) {
|
||||||
function global_terms( $term_id, $deprecated = '' ) {
|
function global_terms( $term_id, $deprecated = '' ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
|
if ( !global_terms_enabled() )
|
||||||
|
return $term_id;
|
||||||
|
|
||||||
$term_id = intval( $term_id );
|
$term_id = intval( $term_id );
|
||||||
$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
|
$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue