Make WordPress Core


Ignore:
Timestamp:
02/18/2016 12:23:04 AM (8 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.