WordPress.org

Make WordPress Core

Changeset 12948


Ignore:
Timestamp:
02/04/10 18:57:32 (4 years ago)
Author:
ryan
Message:

ms-functions pruning and cleanup. Props nacin. see #11644

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r12794 r12948  
    326326    $url = $uploads['url'] . "/$filename"; 
    327327 
     328    if ( is_multisite() ) 
     329        delete_transient( 'dirsize_cache' ); 
     330 
    328331    return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ) ); 
    329332} 
  • trunk/wp-includes/ms-default-filters.php

    r12900 r12948  
    55add_action ( 'wpmu_new_user', 'newuser_notify_siteadmin' ); 
    66add_action ( 'wpmu_activate_user', 'add_new_user_to_blog', 10, 3 ); 
    7 add_action ( 'sanitize_user', 'strtolower_usernames', 10, 3 ); 
     7add_action ( 'sanitize_user', 'strtolower' ); 
    88 
    99// Blogs 
  • trunk/wp-includes/ms-functions.php

    r12933 r12948  
    1818function get_blogaddress_by_id( $blog_id ) { 
    1919    $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details! 
    20     return clean_url("http://" . $bloginfo->domain . $bloginfo->path); 
     20    return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path ); 
    2121} 
    2222 
     
    2727        if ( $blogname == 'main' ) 
    2828            $blogname = 'www'; 
    29         return clean_url( "http://" . $blogname . "." . $current_site->domain . $current_site->path ); 
     29        return esc_url( 'http://' . $blogname . '.' . $current_site->domain . $current_site->path ); 
    3030    } else { 
    31         return clean_url( "http://" . $current_site->domain . $current_site->path . $blogname . '/' ); 
     31        return esc_url( 'http://' . $current_site->domain . $current_site->path . $blogname . '/' ); 
    3232    } 
    3333} 
     
    3939        if ( $domain != $_SERVER['HTTP_HOST'] ) { 
    4040            $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); 
    41             if ( $blogname != 'www.' ) { 
    42                 $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path . $blogname . '/'; 
    43             } else { // we're installing the main blog 
    44                 $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path; 
    45             } 
     41            $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path; 
     42            // we're not installing the main blog 
     43            if ( $blogname != 'www.' ) 
     44                $url .= $blogname . '/'; 
    4645        } else { // main blog 
    4746            $url = 'http://' . $domain . $path; 
    4847        } 
    4948    } 
    50     return clean_url($url); 
     49    return esc_url( $url ); 
    5150} 
    5251 
     
    5655    $stats['blogs'] = get_blog_count(); 
    5756 
    58     $count_ts = get_site_option( "get_user_count_ts" ); 
     57    $count_ts = get_site_option( 'user_count_ts' ); 
    5958    if ( time() - $count_ts > 3600 ) { 
    60         $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users}" ); 
    61         update_site_option( "user_count", $count ); 
    62         update_site_option( "user_count_ts", time() ); 
     59        $count = $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->users" ); 
     60        update_site_option( 'user_count', $count ); 
     61        update_site_option( 'user_count_ts', time() ); 
    6362    } else { 
    64         $count = get_site_option( "user_count" ); 
     63        $count = get_site_option( 'user_count' ); 
    6564    } 
    6665    $stats['users'] = $count; 
     
    7170    global $wpdb; 
    7271 
    73     if ( $sitedomain == '' ) 
     72    if ( ! $sitedomain ) 
    7473        $site_id = $wpdb->siteid; 
    7574    else 
    76         $site_id = $wpdb->get_var( $wpdb->prepare("SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) ); 
    77  
    78     if ( $site_id != false ) 
    79         return $wpdb->get_results( $wpdb->prepare("SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $site_id), ARRAY_A ); 
     75        $site_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path ) ); 
     76 
     77    if ( $site_id ) 
     78        return $wpdb->get_results( $wpdb->prepare( "SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $site_id ), ARRAY_A ); 
    8079 
    8180    return false; 
     
    120119 
    121120    if ( $details ) { 
    122         if ( !is_object($details) && $details == -1 ) 
    123             return false; 
    124         elseif ( !is_object($details) ) // Clear old pre-serialized objects. Cache clients do better with that. 
    125             wp_cache_delete( $blog_id . $all, 'blog-details' ); 
    126         else 
    127             return $details; 
    128     } 
    129  
    130     $details = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE blog_id = %d /* get_blog_details */", $blog_id) ); 
    131     if ( !$details ) { 
     121        if ( ! is_object( $details ) ) { 
     122            if ( $details == -1 ) 
     123                return false; 
     124            else 
     125                // Clear old pre-serialized objects. Cache clients do better with that. 
     126                wp_cache_delete( $blog_id . $all, 'blog-details' ); 
     127        } 
     128        return $details; 
     129    } 
     130 
     131    $details = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE blog_id = %d", $blog_id ) ); 
     132    if ( ! $details ) { 
    132133        wp_cache_set( $blog_id . $all, -1, 'blog-details' ); 
    133134        return false; 
    134135    } 
    135136 
    136     if ( !$get_all ) { 
     137    if ( ! $get_all ) { 
    137138        wp_cache_set( $blog_id . $all, $details, 'blog-details' ); 
    138139        return $details; 
    139140    } 
    140141 
    141     $wpdb->suppress_errors(); 
    142     switch_to_blog( $blog_id ); 
    143     $details->blogname      = get_option( 'blogname' ); 
    144     $details->siteurl       = get_option( 'siteurl' ); 
    145     $details->post_count    = get_option( 'post_count' ); 
    146     restore_current_blog(); 
    147     $wpdb->suppress_errors( false ); 
    148  
    149     $details = apply_filters('blog_details', $details); 
     142    $details->blogname      = get_blog_option( $blog_id, 'blogname' ); 
     143    $details->siteurl       = get_blog_option( $blog_id, 'siteurl' ); 
     144    $details->post_count    = get_blog_option( $blog_id, 'post_count' ); 
     145 
     146    $details = apply_filters( 'blog_details', $details ); 
    150147 
    151148    wp_cache_set( $blog_id . $all, $details, 'blog-details' ); 
     
    630627            reset( $most_active ); 
    631628            foreach ( (array) $most_active as $key => $details ) { 
    632                 $url = clean_url("http://" . $details['domain'] . $details['path']); 
     629                $url = esc_url("http://" . $details['domain'] . $details['path']); 
    633630                echo "<li>" . $details['postcount'] . " <a href='$url'>$url</a></li>"; 
    634631            } 
     
    11521149        $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; 
    11531150 
    1154     $activate_url = clean_url($activate_url); 
     1151    $activate_url = esc_url($activate_url); 
    11551152    $admin_email = get_site_option( "admin_email" ); 
    11561153    if ( $admin_email == '' ) 
     
    11581155    $from_name = get_site_option( "site_name" ) == '' ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 
    11591156    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 
    1160     $message = sprintf( apply_filters( 'wpmu_signup_blog_notification_email', __( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your blog here:\n\n%s" ) ), $activate_url, clean_url( "http://{$domain}{$path}" ), $key ); 
     1157    $message = sprintf( apply_filters( 'wpmu_signup_blog_notification_email', __( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your blog here:\n\n%s" ) ), $activate_url, esc_url( "http://{$domain}{$path}" ), $key ); 
    11611158    // TODO: Don't hard code activation link. 
    1162     $subject = sprintf( apply_filters( 'wpmu_signup_blog_notification_subject', __( '[%1s] Activate %2s' ) ), $from_name, clean_url( 'http://' . $domain . $path ) ); 
     1159    $subject = sprintf( apply_filters( 'wpmu_signup_blog_notification_subject', __( '[%1s] Activate %2s' ) ), $from_name, esc_url( 'http://' . $domain . $path ) ); 
    11631160    wp_mail($user_email, $subject, $message, $message_headers); 
    11641161    return true; 
     
    13271324        return false; 
    13281325 
    1329     $options_site_url = clean_url("http://{$current_site->domain}{$current_site->path}wp-admin/ms-options.php"); 
     1326    $options_site_url = esc_url("http://{$current_site->domain}{$current_site->path}wp-admin/ms-options.php"); 
    13301327 
    13311328    switch_to_blog( $blog_id ); 
     
    13581355    $user = new WP_User($user_id); 
    13591356 
    1360     $options_site_url = clean_url("http://{$current_site->domain}{$current_site->path}wp-admin/ms-options.php"); 
     1357    $options_site_url = esc_url("http://{$current_site->domain}{$current_site->path}wp-admin/ms-options.php"); 
    13611358    $msg = sprintf(__("New User: %1s 
    13621359Remote IP: %2s 
     
    15941591    return $dirsize[ $directory ][ 'size' ]; 
    15951592} 
    1596  
    1597 function clear_dirsize_cache( $file = true ) { 
    1598     delete_transient( 'dirsize_cache' ); 
    1599     return $file; 
    1600 } 
    1601 add_filter( 'wp_handle_upload', 'clear_dirsize_cache' ); 
    1602 add_action( 'delete_attachment', 'clear_dirsize_cache' ); 
    16031593 
    16041594function recurse_dirsize( $directory ) { 
     
    18361826} 
    18371827add_action('update_option_blog_public', 'update_blog_public', 10, 2); 
    1838  
    1839 function strtolower_usernames( $username, $raw, $strict ) { 
    1840     return strtolower( $username ); 
    1841 } 
    1842  
     1828     
    18431829/* Redirect all hits to "dashboard" blog to wp-admin/ Dashboard. */ 
    18441830function redirect_mu_dashboard() { 
     
    18551841 
    18561842function get_dashboard_blog() { 
    1857     global $current_site; 
    1858  
    1859     if ( get_site_option( 'dashboard_blog' ) == false ) 
    1860         return get_blog_details( $current_site->blog_id ); 
    1861     else 
    1862         return get_blog_details( get_site_option( 'dashboard_blog' ) ); 
     1843    if ( $blog = get_site_option( 'dashboard_blog' ) ) 
     1844        return get_blog_details( $blog ); 
     1845 
     1846    return get_blog_details( $GLOBALS['current_site']->blog_id ); 
    18631847} 
    18641848 
     
    18791863} 
    18801864 
    1881 function retrieve_password_sitename( $title ) { 
    1882     global $current_site; 
    1883     return sprintf( __( '[%s] Password Reset' ), $current_site->site_name ); 
    1884 } 
    1885 add_filter( 'retrieve_password_title', 'retrieve_password_sitename' ); 
    1886  
    1887 function reset_password_sitename( $title ) { 
    1888     global $current_site; 
    1889     return sprintf( __( '[%s] Your new password' ), $current_site->site_name ); 
    1890 } 
    1891 add_filter( 'password_reset_title', 'reset_password_sitename' ); 
    1892  
    1893 function lowercase_username( $username, $raw_username, $strict ) { 
    1894     return strtolower( $username ); 
    1895 } 
    1896 add_filter( 'sanitize_user', 'lowercase_username', 10, 3 ); 
    1897  
    18981865function users_can_register_signup_filter() { 
    18991866    $registration = get_site_option('registration'); 
    19001867    if ( $registration == 'all' || $registration == 'user' ) 
    19011868        return true; 
    1902     else 
    1903         return false; 
     1869 
     1870    return false; 
    19041871} 
    19051872add_filter('option_users_can_register', 'users_can_register_signup_filter'); 
     
    19501917 * @since 2.8.5 
    19511918 **/ 
    1952 function filter_SSL( $url) { 
     1919function filter_SSL( $url ) { 
    19531920    if ( !is_string( $url ) ) 
    19541921        return get_bloginfo( 'url' ); //return home blog url with proper scheme 
  • trunk/wp-includes/post.php

    r12938 r12948  
    31863186    $backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true ); 
    31873187    $file = get_attached_file( $post_id ); 
     3188 
     3189    if ( is_multisite() ) 
     3190        delete_transient( 'dirsize_cache' ); 
    31883191 
    31893192    do_action('delete_attachment', $post_id); 
  • trunk/wp-login.php

    r12859 r12948  
    196196            $message .= 'http://' . trailingslashit( $current_site->domain . $current_site->path ) . "wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login) . "\r\n"; 
    197197 
    198     // The blogname option is escaped with esc_html on the way into the database in sanitize_option 
    199     // we want to reverse this for the plain text arena of emails. 
    200     $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 
    201  
    202     $title = sprintf(__('[%s] Password Reset'), $blogname); 
     198    if ( is_multisite() ) 
     199        $blogname = $GLOBALS['current_site']->site_name; 
     200    else 
     201        // The blogname option is escaped with esc_html on the way into the database in sanitize_option 
     202        // we want to reverse this for the plain text arena of emails. 
     203        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 
     204 
     205    $title = sprintf( __('[%s] Password Reset'), $blogname ); 
    203206 
    204207    $title = apply_filters('retrieve_password_title', $title); 
     
    245248    $message .= site_url('wp-login.php', 'login') . "\r\n"; 
    246249 
    247     // The blogname option is escaped with esc_html on the way into the database in sanitize_option 
    248     // we want to reverse this for the plain text arena of emails. 
    249     $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 
    250  
    251     $title = sprintf(__('[%s] Your new password'), $blogname); 
     250    if ( is_multisite() ) 
     251        $blogname = $GLOBALS['current_site']->site_name; 
     252    else 
     253        // The blogname option is escaped with esc_html on the way into the database in sanitize_option 
     254        // we want to reverse this for the plain text arena of emails. 
     255        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 
     256 
     257    $title = sprintf( __('[%s] Your new password'), $blogname ); 
    252258 
    253259    $title = apply_filters('password_reset_title', $title); 
Note: See TracChangeset for help on using the changeset viewer.