Make WordPress Core

Ticket #15170: 15170.diff

File 15170.diff, 3.9 KB (added by ryan, 15 years ago)
  • wp-includes/ms-default-filters.php

     
    3939add_action( 'private_to_published', 'wpmu_update_blogs_date' );
    4040add_action( 'publish_phone', 'wpmu_update_blogs_date' );
    4141add_action( 'publish_post', 'wpmu_update_blogs_date' );
     42add_action( 'admin_init', 'wp_schedule_update_checks');
     43add_action( 'update_network_counts', 'wp_update_network_counts');
    4244
    4345// Files
    4446add_filter( 'wp_upload_bits', 'upload_is_file_too_big' );
     
    5759        add_filter( 'enable_edit_any_user_configuration', '__return_false' );
    5860add_filter( 'force_filtered_html_on_import', '__return_true' );
    5961
    60 
    6162// WP_HOME and WP_SITEURL should not have any effect in MS
    6263remove_filter( 'option_siteurl', '_config_wp_siteurl' );
    6364remove_filter( 'option_home',    '_config_wp_home'    );
  • wp-includes/ms-functions.php

     
    157157 * @return int
    158158 */
    159159function get_user_count() {
    160         global $wpdb;
    161 
    162         $count_ts = get_site_option( 'user_count_ts' );
    163         if ( time() - $count_ts > 3600 ) {
    164                 $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") );
    165                 update_site_option( 'user_count', $count );
    166                 update_site_option( 'user_count_ts', time() );
    167         }
    168 
    169         $count = get_site_option( 'user_count' );
    170 
    171         return $count;
     160        return get_site_option( 'user_count' );
    172161}
    173162
    174163/**
     
    184173 * @return int
    185174 */
    186175function get_blog_count( $id = 0 ) {
    187         global $wpdb;
    188 
    189         if ( $id == 0 )
    190                 $id = $wpdb->siteid;
    191 
    192         $count_ts = get_site_option( 'blog_count_ts' );
    193         if ( time() - $count_ts > 3600 ) {
    194                 $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' and archived = '0'", $id) );
    195                 update_site_option( 'blog_count', $count );
    196                 update_site_option( 'blog_count_ts', time() );
    197         }
    198 
    199         $count = get_site_option( 'blog_count' );
    200 
    201         return $count;
     176        return get_site_option( 'blog_count' );
    202177}
    203178
    204179/**
     
    15331508        return $url;
    15341509}
    15351510
     1511/**
     1512 * Schedule update of the network-wide counts for the current network.
     1513 *
     1514 * @since 3.1.0
     1515 */
     1516function wp_schedule_update_network_counts() {
     1517        if ( !is_main_site() )
     1518                return;
     1519
     1520        if ( !wp_next_scheduled('update_network_counts') && !defined('WP_INSTALLING') )
     1521                wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
     1522}
     1523
     1524/**
     1525 *  Update the network-wide counts for the current network.
     1526 *
     1527 *  @since 3.1.0
     1528 */
     1529function wp_update_network_counts() {
     1530        global $wpdb;
     1531
     1532        $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' and archived = '0'", $wpdb->siteid) );
     1533        update_site_option( 'blog_count', $count );
     1534
     1535        $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") );
     1536        update_site_option( 'user_count', $count );
     1537}
     1538
    15361539?>
  • wp-admin/includes/default-list-tables.php

     
    27392739                $pagenum = $this->get_pagenum();
    27402740
    27412741                $s = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST[ 's' ] ) ) : '';
     2742
     2743                // Limit is set to 2 for testing.
     2744                if ( ! $s && ( get_blog_count() > 2 ) ) {
     2745                        $total = 0;
     2746                        $this->items = array();
     2747                        $this->set_pagination_args( array(
     2748                                'total_items' => $total,
     2749                                'per_page' => $per_page,
     2750                        ) );
     2751                        return;
     2752                }
     2753
    27422754                $like_s = esc_sql( like_escape( $s ) );
    27432755
    27442756                $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";