WordPress.org

Make WordPress Core

Ticket #25650: 25650_approach_1.patch

File 25650_approach_1.patch, 2.3 KB (added by igmoweb, 5 years ago)

First approach for a solution

  • src/wp-content/plugins/hello.php

     
    7979
    8080add_action( 'admin_head', 'dolly_css' );
    8181
     82
     83add_action( 'init', 'test' );
     84function test() {
     85        var_dump(wp_upload_dir());
     86
     87        switch_to_blog( 7 );
     88        var_dump(wp_upload_dir());
     89        restore_current_blog();
     90
     91        wp_die();
     92}
    8293?>
  • src/wp-includes/functions.php

     
    18241824
    18251825        if ( !$url = get_option( 'upload_url_path' ) ) {
    18261826                if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )
    1827                         $url = WP_CONTENT_URL . '/uploads';
     1827                        $url = content_url() . '/uploads';
    18281828                else
    18291829                        $url = trailingslashit( $siteurl ) . $upload_path;
    18301830        }
  • src/wp-includes/link-template.php

     
    31263126 * @return string Content url link with optional path appended.
    31273127 */
    31283128function content_url($path = '') {
    3129         $url = set_url_scheme( WP_CONTENT_URL );
     3129        global $wp_content_url;
    31303130
     3131        if ( empty( $wp_content_url ) ) {
     3132                $wp_content_url = WP_CONTENT_URL;
     3133        }
     3134
     3135        $url = set_url_scheme( $wp_content_url );
     3136
    31313137        if ( $path && is_string( $path ) )
    31323138                $url .= '/' . ltrim($path, '/');
    31333139
  • src/wp-includes/ms-blogs.php

     
    666666                $current_user->for_blog( $new_blog );
    667667        }
    668668
     669        // Change the content URL to the new blog
     670        global $wp_content_url;
     671
     672        if ( empty( $wp_content_url ) ) {
     673                $wp_content_url = WP_CONTENT_URL;
     674        }
     675
     676        $new_blog_details = get_blog_details( $new_blog );
     677        $prev_blog_details = get_blog_details( $prev_blog_id );
     678
     679        $wp_content_url = str_replace( $prev_blog_details->siteurl, $new_blog_details->siteurl, $wp_content_url );
     680
    669681        /** This filter is documented in wp-includes/ms-blogs.php */
    670682        do_action( 'switch_blog', $new_blog, $prev_blog_id );
    671683        $GLOBALS['switched'] = true;