WordPress.org

Make WordPress Core

Changeset 36569


Ignore:
Timestamp:
02/18/2016 12:23:04 AM (4 years ago)
Author:
azaozz
Message:

Replace wp_upload_dir() with the new wp_get_upload_dir() in all cases where a file is not being uploaded. Deprecate _wp_upload_dir_baseurl(), and replace it with wp_get_upload_dir().

See #34359.

Location:
trunk/src
Files:
6 edited

Legend:

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

    r36505 r36569  
    109109
    110110    if ( $drop ) {
    111         $uploads = wp_upload_dir();
     111        $uploads = wp_get_upload_dir();
    112112
    113113        $tables = $wpdb->tables( 'blog' );
  • trunk/src/wp-includes/comment.php

    r36566 r36569  
    22062206
    22072207    //Do not search for a pingback server on our own uploads
    2208     $uploads_dir = wp_upload_dir();
     2208    $uploads_dir = wp_get_upload_dir();
    22092209    if ( 0 === strpos($url, $uploads_dir['baseurl']) )
    22102210        return false;
  • trunk/src/wp-includes/deprecated.php

    r36416 r36569  
    37173717    return $text;
    37183718}
     3719
     3720/**
     3721 * Returns the base URL of the uploads directory.
     3722 *
     3723 * @since 4.4.0
     3724 * @access private
     3725 * @deprecated 4.5.0
     3726 *
     3727 * @return string The base URL.
     3728 */
     3729function _wp_upload_dir_baseurl() {
     3730    $upload_dir = wp_get_upload_dir();
     3731    return $upload_dir['baseurl'];
     3732}
  • trunk/src/wp-includes/functions.php

    r36565 r36569  
    18861886                }
    18871887
    1888                 $uploads['error'] = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path );
     1888                $uploads['error'] = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), esc_html( $error_path ) );
    18891889            }
    18901890
  • trunk/src/wp-includes/media.php

    r36517 r36569  
    904904
    905905/**
    906  * Caches and returns the base URL of the uploads directory.
    907  *
    908  * @since 4.4.0
    909  * @access private
    910  *
    911  * @return string The base URL, cached.
    912  */
    913 function _wp_upload_dir_baseurl() {
    914     static $baseurl = array();
    915 
    916     $blog_id = get_current_blog_id();
    917 
    918     if ( empty( $baseurl[$blog_id] ) ) {
    919         $uploads_dir = wp_upload_dir();
    920         $baseurl[$blog_id] = $uploads_dir['baseurl'];
    921     }
    922 
    923     return $baseurl[$blog_id];
    924 }
    925 
    926 /**
    927906 * Get the image size as array from its meta data.
    928907 *
     
    10461025    }
    10471026
    1048     $image_baseurl = _wp_upload_dir_baseurl();
    1049     $image_baseurl = trailingslashit( $image_baseurl ) . $dirname;
     1027    $upload_dir = wp_get_upload_dir();
     1028    $image_baseurl = trailingslashit( $upload_dir['baseurl'] ) . $dirname;
    10501029
    10511030    /*
     
    37403719    global $wpdb;
    37413720
    3742     $dir = wp_upload_dir();
     3721    $dir = wp_get_upload_dir();
    37433722    $path = $url;
    37443723
  • trunk/src/wp-includes/post.php

    r36566 r36569  
    187187function get_attached_file( $attachment_id, $unfiltered = false ) {
    188188    $file = get_post_meta( $attachment_id, '_wp_attached_file', true );
     189
    189190    // If the file is relative, prepend upload dir.
    190     if ( $file && 0 !== strpos($file, '/') && !preg_match('|^.:\\\|', $file) && ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) )
     191    if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) && ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) ) {
    191192        $file = $uploads['basedir'] . "/$file";
    192     if ( $unfiltered )
     193    }
     194
     195    if ( $unfiltered ) {
    193196        return $file;
     197    }
    194198
    195199    /**
     
    249253    $new_path = $path;
    250254
    251     $uploads = wp_upload_dir();
     255    $uploads = wp_get_upload_dir();
    252256    if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) {
    253257            $new_path = str_replace( $uploads['basedir'], '', $new_path );
     
    48484852    do_action( 'deleted_post', $post_id );
    48494853
    4850     $uploadpath = wp_upload_dir();
     4854    $uploadpath = wp_get_upload_dir();
    48514855
    48524856    if ( ! empty($meta['thumb']) ) {
     
    49654969    $url = '';
    49664970    // Get attached file.
    4967     if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) {
     4971    if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true ) ) {
    49684972        // Get upload directory.
    4969         if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) {
     4973        if ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) {
    49704974            // Check that the upload base exists in the file location.
    49714975            if ( 0 === strpos( $file, $uploads['basedir'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.