Changeset 54240
- Timestamp:
- 09/20/2022 02:49:25 AM (23 months ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/edit-tag-form.php
r53913 r54240 149 149 <p class="description" id="name-description"><?php echo $tax->labels->name_field_description; ?></p></td> 150 150 </tr> 151 <?php if ( ! global_terms_enabled() ) { ?>152 151 <tr class="form-field term-slug-wrap"> 153 152 <th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th> … … 171 170 <p class="description" id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p></td> 172 171 </tr> 173 <?php } ?>174 172 <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?> 175 173 <tr class="form-field term-parent-wrap"> -
trunk/src/wp-admin/edit-tags.php
r53913 r54240 281 281 '<li>' . __( '<strong>Name</strong> — The name is how it appears on your site.' ) . '</li>'; 282 282 283 if ( ! global_terms_enabled() ) { 284 $help .= '<li>' . __( '<strong>Slug</strong> — The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>'; 285 } 283 $help .= '<li>' . __( '<strong>Slug</strong> — The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>'; 286 284 287 285 if ( 'category' === $taxonomy ) { … … 457 455 <p id="name-description"><?php echo $tax->labels->name_field_description; ?></p> 458 456 </div> 459 <?php if ( ! global_terms_enabled() ) : ?>460 457 <div class="form-field term-slug-wrap"> 461 458 <label for="tag-slug"><?php _e( 'Slug' ); ?></label> … … 463 460 <p id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p> 464 461 </div> 465 <?php endif; // global_terms_enabled() ?>466 462 <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?> 467 463 <div class="form-field term-parent-wrap"> -
trunk/src/wp-admin/includes/class-wp-terms-list-table.php
r54071 r54240 666 666 </label> 667 667 668 <?php if ( ! global_terms_enabled() ) : ?> 669 <label> 670 <span class="title"><?php _e( 'Slug' ); ?></span> 671 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> 672 </label> 673 <?php endif; ?> 668 <label> 669 <span class="title"><?php _e( 'Slug' ); ?></span> 670 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> 671 </label> 674 672 </div> 675 673 </fieldset> -
trunk/src/wp-admin/includes/ms-admin-filters.php
r47119 r54240 23 23 add_action( 'update_site_option_admin_email', 'wp_network_admin_email_change_notification', 10, 4 ); 24 24 25 // Taxonomy hooks.26 add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );27 28 25 // Post hooks. 29 26 add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 ); -
trunk/src/wp-admin/includes/ms-deprecated.php
r45932 r54240 109 109 */ 110 110 function ms_deprecated_blogs_file() {} 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 -
trunk/src/wp-admin/includes/ms.php
r53203 r54240 545 545 546 546 /** 547 * Synchronizes category and post tag slugs when global terms are enabled.548 *549 * @since 3.0.0550 *551 * @param WP_Term|array $term The term.552 * @param string $taxonomy The taxonomy for `$term`. Should be 'category' or 'post_tag', as these are553 * the only taxonomies which are processed by this function; anything else554 * will be returned untouched.555 * @return WP_Term|array Returns `$term`, after filtering the 'slug' field with `sanitize_title()`556 * if `$taxonomy` is 'category' or 'post_tag'.557 */558 function sync_category_tag_slugs( $term, $taxonomy ) {559 if ( global_terms_enabled() && ( 'category' === $taxonomy || 'post_tag' === $taxonomy ) ) {560 if ( is_object( $term ) ) {561 $term->slug = sanitize_title( $term->name );562 } else {563 $term['slug'] = sanitize_title( $term['name'] );564 }565 }566 return $term;567 }568 569 /**570 547 * Displays an access denied message when a user tries to view a site's dashboard they 571 548 * do not have access to. -
trunk/src/wp-admin/includes/schema.php
r54232 r54240 1271 1271 'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', 1272 1272 'subdomain_install' => $subdomain_install, 1273 'global_terms_enabled' => global_terms_enabled() ? '1' : '0',1274 1273 'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0', 1275 1274 'user_count' => get_site_option( 'user_count' ), -
trunk/src/wp-admin/includes/upgrade.php
r53897 r54240 160 160 $cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) ); 161 161 162 if ( global_terms_enabled() ) { 163 $cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) ); 164 if ( null == $cat_id ) { 165 $wpdb->insert( 166 $wpdb->sitecategories, 167 array( 168 'cat_ID' => 0, 169 'cat_name' => $cat_name, 170 'category_nicename' => $cat_slug, 171 'last_updated' => current_time( 'mysql', true ), 172 ) 173 ); 174 $cat_id = $wpdb->insert_id; 175 } 176 update_option( 'default_category', $cat_id ); 177 } else { 178 $cat_id = 1; 179 } 162 $cat_id = 1; 180 163 181 164 $wpdb->insert( … … 3538 3521 } 3539 3522 3540 if ( ! function_exists( 'install_global_terms' ) ) :3541 /**3542 * Install global terms.3543 *3544 * @since 3.0.03545 *3546 * @global wpdb $wpdb WordPress database abstraction object.3547 * @global string $charset_collate3548 */3549 function install_global_terms() {3550 global $wpdb, $charset_collate;3551 $ms_queries = "3552 CREATE TABLE $wpdb->sitecategories (3553 cat_ID bigint(20) NOT NULL auto_increment,3554 cat_name varchar(55) NOT NULL default '',3555 category_nicename varchar(200) NOT NULL default '',3556 last_updated timestamp NOT NULL,3557 PRIMARY KEY (cat_ID),3558 KEY category_nicename (category_nicename),3559 KEY last_updated (last_updated)3560 ) $charset_collate;3561 ";3562 // Now create tables.3563 dbDelta( $ms_queries );3564 }3565 endif;3566 3567 3523 /** 3568 3524 * Determine if global tables should be upgraded. -
trunk/src/wp-admin/network/settings.php
r53131 r54240 101 101 'welcome_user_email', 102 102 'fileupload_maxk', 103 'global_terms_enabled',104 103 'illegal_names', 105 104 'limited_email_domains', -
trunk/src/wp-includes/class-wpdb.php
r54133 r54240 341 341 'site', 342 342 'sitemeta', 343 'sitecategories',344 343 'registration_log', 345 344 ); 345 346 347 348 349 350 351 352 353 354 346 355 347 356 /** … … 1124 1133 * 1125 1134 * @since 3.0.0 1135 1126 1136 * 1127 1137 * @uses wpdb::$tables … … 1129 1139 * @uses wpdb::$global_tables 1130 1140 * @uses wpdb::$ms_global_tables 1141 1131 1142 * 1132 1143 * @param string $scope Optional. Possible values include 'all', 'global', 'ms_global', 'blog', … … 1160 1171 case 'old': 1161 1172 $tables = $this->old_tables; 1173 1174 1175 1162 1176 break; 1163 1177 default: -
trunk/src/wp-includes/functions.php
r54233 r54240 6221 6221 6222 6222 /** 6223 * Determines whether global terms are enabled.6224 *6225 * @since 3.0.06226 *6227 * @return bool True if multisite and global terms enabled.6228 */6229 function global_terms_enabled() {6230 if ( ! is_multisite() ) {6231 return false;6232 }6233 6234 static $global_terms = null;6235 if ( is_null( $global_terms ) ) {6236 6237 /**6238 * Filters whether global terms are enabled.6239 *6240 * Returning a non-null value from the filter will effectively short-circuit the function6241 * and return the value of the 'global_terms_enabled' site option instead.6242 *6243 * @since 3.0.06244 *6245 * @param null $enabled Whether global terms are enabled.6246 */6247 $filter = apply_filters( 'global_terms_enabled', null );6248 if ( ! is_null( $filter ) ) {6249 $global_terms = (bool) $filter;6250 } else {6251 $global_terms = (bool) get_site_option( 'global_terms_enabled', false );6252 }6253 }6254 return $global_terms;6255 }6256 6257 /**6258 6223 * Determines whether site meta is enabled. 6259 6224 * -
trunk/src/wp-includes/ms-default-filters.php
r53011 r54240 76 76 77 77 // Administration. 78 add_filter( 'term_id_filter', 'global_terms', 10, 2 );79 78 add_action( 'after_delete_post', '_update_posts_count_on_delete' ); 80 79 add_action( 'delete_post', '_update_blog_date_on_post_delete' ); -
trunk/src/wp-includes/ms-deprecated.php
r53458 r54240 731 731 return $value; 732 732 } 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 -
trunk/src/wp-includes/ms-functions.php
r54080 r54240 2051 2051 2052 2052 /** 2053 * Maintains a canonical list of terms by syncing terms created for each blog with the global terms table.2054 *2055 * @since 3.0.02056 *2057 * @see term_id_filter2058 *2059 * @global wpdb $wpdb WordPress database abstraction object.2060 *2061 * @param int $term_id An ID for a term on the current blog.2062 * @param string $deprecated Not used.2063 * @return int An ID from the global terms table mapped from $term_id.2064 */2065 function global_terms( $term_id, $deprecated = '' ) {2066 global $wpdb;2067 static $global_terms_recurse = null;2068 2069 if ( ! global_terms_enabled() ) {2070 return $term_id;2071 }2072 2073 // Prevent a race condition.2074 $recurse_start = false;2075 if ( null === $global_terms_recurse ) {2076 $recurse_start = true;2077 $global_terms_recurse = 1;2078 } elseif ( 10 < $global_terms_recurse++ ) {2079 return $term_id;2080 }2081 2082 $term_id = (int) $term_id;2083 $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );2084 2085 $global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) );2086 if ( null == $global_id ) {2087 $used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) );2088 if ( null == $used_global_id ) {2089 $wpdb->insert(2090 $wpdb->sitecategories,2091 array(2092 'cat_ID' => $term_id,2093 'cat_name' => $c->name,2094 'category_nicename' => $c->slug,2095 )2096 );2097 $global_id = $wpdb->insert_id;2098 if ( empty( $global_id ) ) {2099 return $term_id;2100 }2101 } else {2102 $max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" );2103 $max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );2104 $new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 );2105 $wpdb->insert(2106 $wpdb->sitecategories,2107 array(2108 'cat_ID' => $new_global_id,2109 'cat_name' => $c->name,2110 'category_nicename' => $c->slug,2111 )2112 );2113 $global_id = $wpdb->insert_id;2114 }2115 } elseif ( $global_id != $term_id ) {2116 $local_id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) );2117 if ( null != $local_id ) {2118 global_terms( $local_id );2119 if ( 10 < $global_terms_recurse ) {2120 $global_id = $term_id;2121 }2122 }2123 }2124 2125 if ( $global_id != $term_id ) {2126 if ( get_option( 'default_category' ) == $term_id ) {2127 update_option( 'default_category', $global_id );2128 }2129 2130 $wpdb->update( $wpdb->terms, array( 'term_id' => $global_id ), array( 'term_id' => $term_id ) );2131 $wpdb->update( $wpdb->term_taxonomy, array( 'term_id' => $global_id ), array( 'term_id' => $term_id ) );2132 $wpdb->update( $wpdb->term_taxonomy, array( 'parent' => $global_id ), array( 'parent' => $term_id ) );2133 2134 clean_term_cache( $term_id );2135 }2136 if ( $recurse_start ) {2137 $global_terms_recurse = null;2138 }2139 2140 return $global_id;2141 }2142 2143 /**2144 2053 * Ensures that the current site's domain is listed in the allowed redirect host list. 2145 2054 * -
trunk/tests/phpunit/tests/pluggable.php
r54218 r54240 83 83 'wp_new_blog_notification', 84 84 'wp_upgrade', 85 'install_global_terms',86 85 ); 87 86 $test_files = array( … … 258 257 'wp_new_blog_notification' => array( 'blog_title', 'blog_url', 'user_id', 'password' ), 259 258 'wp_upgrade' => array(), 260 'install_global_terms' => array(),261 259 ); 262 260
Note: See TracChangeset
for help on using the changeset viewer.