Make WordPress Core


Ignore:
Timestamp:
08/22/2015 04:38:09 PM (9 years ago)
Author:
wonderboymusic
Message:

Ensure that attachment_url_to_postid() matches cross-scheme when front-end and back-end schemes are different.

Adds unit test.

Props welcher.
Fixes #33109.

File:
1 edited

Legend:

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

    r33643 r33705  
    34323432    $path = $url;
    34333433
     3434    $site_url = parse_url( $dir['url'] );
     3435    $image_path = parse_url( $path );
     3436
     3437    //force the protocols to match if needed
     3438    if ( isset( $image_path['scheme'] ) && ( $image_path['scheme'] !== $site_url['scheme'] ) ) {
     3439        $path = str_replace( $image_path['scheme'], $site_url['scheme'], $path );
     3440    }
     3441
    34343442    if ( 0 === strpos( $path, $dir['baseurl'] . '/' ) ) {
    34353443        $path = substr( $path, strlen( $dir['baseurl'] . '/' ) );
     
    34503458     * @param string   $url     The URL being looked up.
    34513459     */
    3452     $post_id = apply_filters( 'attachment_url_to_postid', $post_id, $url );
    3453 
    3454     return (int) $post_id;
     3460    return (int) apply_filters( 'attachment_url_to_postid', $post_id, $url );
    34553461}
    34563462
Note: See TracChangeset for help on using the changeset viewer.