diff --git a/wp-admin/edit-tag-form.php b/wp-admin/edit-tag-form.php
index dc8461700a..366bb2f6b4 100644
--- a/wp-admin/edit-tag-form.php
+++ b/wp-admin/edit-tag-form.php
@@ -37,7 +37,7 @@ do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?>
|
diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php
index a5e24f9663..950a7a231e 100644
--- a/wp-admin/includes/ms.php
+++ b/wp-admin/includes/ms.php
@@ -520,7 +520,7 @@ function format_code_lang( $code = '' ) {
}
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 ) ) {
$term->slug = sanitize_title( $term->name );
} else {
diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php
index 766d259f2b..f698b052f8 100644
--- a/wp-admin/includes/schema.php
+++ b/wp-admin/includes/schema.php
@@ -659,9 +659,6 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
}
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 );
$users = get_users_of_blog();
if ( $users ) {
@@ -708,11 +705,8 @@ Thanks!
'add_new_users' => '0',
'upload_space_check_disabled' => '0',
'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 = '';
foreach ( $sitemeta as $meta_key => $meta_value ) {
diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php
index 1bdcd48eb8..27baee9e79 100644
--- a/wp-admin/includes/upgrade.php
+++ b/wp-admin/includes/upgrade.php
@@ -110,7 +110,7 @@ function wp_install_defaults($user_id) {
/* translators: 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 ) );
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)) );
@@ -130,7 +130,7 @@ function wp_install_defaults($user_id) {
/* translators: 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 ) );
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)) );
@@ -1917,15 +1917,6 @@ CREATE TABLE $wpdb->sitemeta (
KEY meta_key (meta_key),
KEY site_id (site_id)
) $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 (
domain varchar(200) NOT NULL default '',
path varchar(100) NOT NULL default '',
@@ -1945,4 +1936,29 @@ CREATE TABLE $wpdb->signups (
dbDelta( $ms_queries );
}
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;
?>
diff --git a/wp-admin/ms-edit.php b/wp-admin/ms-edit.php
index c04fe84405..d3c42354c8 100644
--- a/wp-admin/ms-edit.php
+++ b/wp-admin/ms-edit.php
@@ -107,6 +107,12 @@ switch ( $_GET['action'] ) {
}
}
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' );
$checked_options = array('mu_media_buttons', 'menu_items');
foreach ( $checked_options as $option_name ) {
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 5b652fcec7..9503cea7c9 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -447,7 +447,7 @@ function wp_load_core_site_options( $site_id = null ) {
if ( empty($site_id) )
$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) . "'";
$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;
}
+/**
+ * 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
*
diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php
index aa98901136..031155dff6 100644
--- a/wp-includes/ms-functions.php
+++ b/wp-includes/ms-functions.php
@@ -1210,6 +1210,9 @@ function fix_import_form_size( $size ) {
function global_terms( $term_id, $deprecated = '' ) {
global $wpdb;
+ if ( !global_terms_enabled() )
+ return $term_id;
+
$term_id = intval( $term_id );
$c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
|