WordPress.org

Make WordPress Core

Ticket #21734: remove-global-terms-for-plugin.diff

File remove-global-terms-for-plugin.diff, 16.1 KB (added by wonderboymusic, 19 months ago)
  • wp-includes/ms-default-filters.php

     
    3333add_filter( 'allowed_redirect_hosts', 'redirect_this_site' ); 
    3434 
    3535// Administration 
    36 add_filter( 'term_id_filter', 'global_terms', 10, 2 ); 
    3736add_action( 'publish_post', 'update_posts_count' ); 
    3837add_action( 'delete_post', '_update_blog_date_on_post_delete' ); 
    3938add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 ); 
  • wp-includes/functions.php

     
    30723072} 
    30733073 
    30743074/** 
    3075  * Whether global terms are enabled. 
    3076  * 
    3077  * 
    3078  * @since 3.0.0 
    3079  * @package WordPress 
    3080  * 
    3081  * @return bool True if multisite and global terms enabled 
    3082  */ 
    3083 function global_terms_enabled() { 
    3084         if ( ! is_multisite() ) 
    3085                 return false; 
    3086  
    3087         static $global_terms = null; 
    3088         if ( is_null( $global_terms ) ) { 
    3089                 $filter = apply_filters( 'global_terms_enabled', null ); 
    3090                 if ( ! is_null( $filter ) ) 
    3091                         $global_terms = (bool) $filter; 
    3092                 else 
    3093                         $global_terms = (bool) get_site_option( 'global_terms_enabled', false ); 
    3094         } 
    3095         return $global_terms; 
    3096 } 
    3097  
    3098 /** 
    30993075 * gmt_offset modification for smart timezone handling. 
    31003076 * 
    31013077 * Overrides the gmt_offset option if we have a timezone_string available. 
  • wp-includes/option.php

     
    174174        if ( empty($site_id) ) 
    175175                $site_id = $wpdb->siteid; 
    176176 
    177         $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' ); 
     177        $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'ms_files_rewriting' ); 
    178178 
    179179        $core_options_in = "'" . implode("', '", $core_options) . "'"; 
    180180        $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) ); 
  • wp-includes/wp-db.php

     
    239239         * @var array 
    240240         */ 
    241241        var $ms_global_tables = array( 'blogs', 'signups', 'site', 'sitemeta', 
    242                 'sitecategories', 'registration_log', 'blog_versions' ); 
     242                'registration_log', 'blog_versions' ); 
    243243 
    244244        /** 
    245245         * WordPress Comments table 
     
    390390        var $site; 
    391391 
    392392        /** 
    393          * Multisite Sitewide Terms table 
    394          * 
    395          * @since 3.0.0 
    396          * @access public 
    397          * @var string 
    398          */ 
    399         var $sitecategories; 
    400  
    401         /** 
    402393         * Multisite Site Metadata table 
    403394         * 
    404395         * @since 3.0.0 
  • wp-includes/ms-load.php

     
    246246        $msg .= __( 'Read the <a target="_blank" href="http://codex.wordpress.org/Debugging_a_WordPress_Network">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' ); 
    247247        $msg .= ' ' . __( 'If you&#8217;re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>'; 
    248248        foreach ( $wpdb->tables('global') as $t => $table ) { 
    249                 if ( 'sitecategories' == $t ) 
    250                         continue; 
    251249                $msg .= '<li>' . $table . '</li>'; 
    252250        } 
    253251        $msg .= '</ul>'; 
  • wp-includes/ms-functions.php

     
    314314 */ 
    315315function get_blog_permalink( $blog_id, $post_id ) { 
    316316        switch_to_blog( $blog_id ); 
    317         $link = get_permalink( $post_id ); 
     317        $link = set_url_scheme( get_permalink( $post_id ) , 'http' ); 
    318318        restore_current_blog(); 
    319319 
    320320        return $link; 
     
    15021502} 
    15031503 
    15041504/** 
    1505  * Maintains a canonical list of terms by syncing terms created for each blog with the global terms table. 
    1506  * 
    1507  * @since 3.0.0 
    1508  * 
    1509  * @see term_id_filter 
    1510  * 
    1511  * @param int $term_id An ID for a term on the current blog. 
    1512  * @return int An ID from the global terms table mapped from $term_id. 
    1513  */ 
    1514 function global_terms( $term_id, $deprecated = '' ) { 
    1515         global $wpdb; 
    1516         static $global_terms_recurse = null; 
    1517  
    1518         if ( !global_terms_enabled() ) 
    1519                 return $term_id; 
    1520  
    1521         // prevent a race condition 
    1522         $recurse_start = false; 
    1523         if ( $global_terms_recurse === null ) { 
    1524                 $recurse_start = true; 
    1525                 $global_terms_recurse = 1; 
    1526         } elseif ( 10 < $global_terms_recurse++ ) { 
    1527                 return $term_id; 
    1528         } 
    1529  
    1530         $term_id = intval( $term_id ); 
    1531         $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) ); 
    1532  
    1533         $global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) ); 
    1534         if ( $global_id == null ) { 
    1535                 $used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) ); 
    1536                 if ( null == $used_global_id ) { 
    1537                         $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); 
    1538                         $global_id = $wpdb->insert_id; 
    1539                         if ( empty( $global_id ) ) 
    1540                                 return $term_id; 
    1541                 } else { 
    1542                         $max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" ); 
    1543                         $max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" ); 
    1544                         $new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 ); 
    1545                         $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) ); 
    1546                         $global_id = $wpdb->insert_id; 
    1547                 } 
    1548         } elseif ( $global_id != $term_id ) { 
    1549                 $local_id = $wpdb->get_row( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE term_id = %d", $global_id ) ); 
    1550                 if ( null != $local_id ) 
    1551                         $local_id = global_terms( $local_id ); 
    1552                         if ( 10 < $global_terms_recurse ) 
    1553                                 $global_id = $term_id; 
    1554         } 
    1555  
    1556         if ( $global_id != $term_id ) { 
    1557                 if ( get_option( 'default_category' ) == $term_id ) 
    1558                         update_option( 'default_category', $global_id ); 
    1559  
    1560                 $wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) ); 
    1561                 $wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) ); 
    1562                 $wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) ); 
    1563  
    1564                 clean_term_cache($term_id); 
    1565         } 
    1566         if( $recurse_start ) 
    1567                 $global_terms_recurse = null; 
    1568  
    1569         return $global_id; 
    1570 } 
    1571  
    1572 /** 
    15731505 * Ensure that the current site's domain is listed in the allowed redirect host list. 
    15741506 * 
    15751507 * @see wp_validate_redirect() 
  • wp-admin/includes/class-wp-terms-list-table.php

     
    341341                                        <span class="title"><?php _ex( 'Name', 'term name' ); ?></span> 
    342342                                        <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> 
    343343                                </label> 
    344         <?php if ( !global_terms_enabled() ) { ?> 
    345344                                <label> 
    346345                                        <span class="title"><?php _e( 'Slug' ); ?></span> 
    347346                                        <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> 
    348347                                </label> 
    349         <?php } ?> 
    350348                        </div></fieldset> 
    351349        <?php 
    352350 
  • wp-admin/includes/upgrade.php

     
    108108        /* translators: Default category slug */ 
    109109        $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug')); 
    110110 
    111         if ( global_terms_enabled() ) { 
    112                 $cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) ); 
    113                 if ( $cat_id == null ) { 
    114                         $wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) ); 
    115                         $cat_id = $wpdb->insert_id; 
    116                 } 
    117                 update_option('default_category', $cat_id); 
    118         } else { 
    119                 $cat_id = 1; 
    120         } 
     111        $cat_id = 1; 
    121112 
    122113        $wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) ); 
    123114        $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1)); 
     
    12421233                } 
    12431234        } 
    12441235 
    1245         // 3.0 
    1246         if ( $wp_current_db_version < 13576 ) 
    1247                 update_site_option( 'global_terms_enabled', '1' ); 
    1248  
    12491236        // 3.3 
    12501237        if ( $wp_current_db_version < 19390 ) 
    12511238                update_site_option( 'initial_db_version', $wp_current_db_version ); 
     
    19361923                        break; 
    19371924                } 
    19381925        } 
     1926 
     1927        // 3.5 
     1928        if ( $wp_current_db_version < 20149 && get_site_option( 'global_terms_enabled' ) ) { 
     1929                // TODO: install plugin 
     1930        } 
    19391931} 
    19401932 
    19411933/** 
     
    19721964 
    19731965} 
    19741966 
    1975 /** 
    1976  * Install global terms. 
    1977  * 
    1978  * @since 3.0.0 
    1979  * 
    1980  */ 
    1981 if ( !function_exists( 'install_global_terms' ) ) : 
    1982 function install_global_terms() { 
    1983         global $wpdb, $charset_collate; 
    1984         $ms_queries = " 
    1985 CREATE TABLE $wpdb->sitecategories ( 
    1986   cat_ID bigint(20) NOT NULL auto_increment, 
    1987   cat_name varchar(55) NOT NULL default '', 
    1988   category_nicename varchar(200) NOT NULL default '', 
    1989   last_updated timestamp NOT NULL, 
    1990   PRIMARY KEY  (cat_ID), 
    1991   KEY category_nicename (category_nicename), 
    1992   KEY last_updated (last_updated) 
    1993 ) $charset_collate; 
    1994 "; 
    1995 // now create tables 
    1996         dbDelta( $ms_queries ); 
    1997 } 
    1998 endif; 
  • wp-admin/includes/schema.php

     
    911911                'add_new_users' => '0', 
    912912                'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', 
    913913                'subdomain_install' => intval( $subdomain_install ), 
    914                 'global_terms_enabled' => global_terms_enabled() ? '1' : '0', 
    915914                'ms_files_rewriting' => is_multisite() ? get_site_option( 'ms_files_rewriting' ) : '0', 
    916915                'initial_db_version' => get_option( 'initial_db_version' ), 
    917916                'active_sitewide_plugins' => array(), 
  • wp-admin/includes/ms.php

     
    497497        return strtr( $code, $lang_codes ); 
    498498} 
    499499 
    500 function sync_category_tag_slugs( $term, $taxonomy ) { 
    501         if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) { 
    502                 if ( is_object( $term ) ) { 
    503                         $term->slug = sanitize_title( $term->name ); 
    504                 } else { 
    505                         $term['slug'] = sanitize_title( $term['name'] ); 
    506                 } 
    507         } 
    508         return $term; 
    509 } 
    510 add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 ); 
    511  
    512500function _access_denied_splash() { 
    513501        if ( ! is_user_logged_in() || is_network_admin() ) 
    514502                return; 
  • wp-admin/edit-tags.php

     
    214214                $help .= '<ul>' . 
    215215                '<li>' . __( '<strong>Name</strong> - The name is how it appears on your site.' ) . '</li>'; 
    216216 
    217                 if ( ! global_terms_enabled() ) 
    218                         $help .= '<li>' . __( '<strong>Slug</strong> - The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>'; 
     217                $help .= '<li>' . __( '<strong>Slug</strong> - The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>'; 
    219218 
    220219                if ( 'category' == $taxonomy ) 
    221220                        $help .= '<li>' . __( '<strong>Parent</strong> - Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>'; 
     
    361360        <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" /> 
    362361        <p><?php _e('The name is how it appears on your site.'); ?></p> 
    363362</div> 
    364 <?php if ( ! global_terms_enabled() ) : ?> 
    365363<div class="form-field"> 
    366364        <label for="tag-slug"><?php _ex('Slug', 'Taxonomy Slug'); ?></label> 
    367365        <input name="slug" id="tag-slug" type="text" value="" size="40" /> 
    368366        <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> 
    369367</div> 
    370 <?php endif; // global_terms_enabled() ?> 
    371368<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?> 
    372369<div class="form-field"> 
    373370        <label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label> 
  • wp-admin/edit-tag-form.php

     
    4141                        <td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" /> 
    4242                        <p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td> 
    4343                </tr> 
    44 <?php if ( !global_terms_enabled() ) { ?> 
    4544                <tr class="form-field"> 
    4645                        <th scope="row" valign="top"><label for="slug"><?php _ex('Slug', 'Taxonomy Slug'); ?></label></th> 
    4746                        <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" /> 
    4847                        <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> 
    4948                </tr> 
    50 <?php } ?> 
    5149<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?> 
    5250                <tr class="form-field"> 
    5351                        <th scope="row" valign="top"><label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label></th> 
  • wp-admin/network/settings.php

     
    8585                update_site_option( 'banned_email_domains', '' ); 
    8686        } 
    8787 
    88         $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', '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', 'global_terms_enabled' ); 
     88        $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', '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' ); 
    8989        $checked_options = array( 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 ); 
    9090        foreach ( $checked_options as $option_name => $option_unchecked_value ) { 
    9191                if ( ! isset( $_POST[$option_name] ) ) 
  • wp-admin/maint/repair.php

     
    3232 
    3333        $tables = $wpdb->tables(); 
    3434 
    35         // Sitecategories may not exist if global terms are disabled. 
    36         if ( is_multisite() && ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->sitecategories'" ) ) 
    37                 unset( $tables['sitecategories'] ); 
    38  
    3935        $tables = array_merge( $tables, (array) apply_filters( 'tables_to_repair', array() ) ); // Return tables with table prefixes. 
    4036 
    4137        // Loop over the tables, checking and repairing as needed.