~canonical-sysadmins/wordpress/4.7.1

« back to all changes in this revision

Viewing changes to wp-includes/embed.php

  • Committer: Barry Price
  • Date: 2016-06-22 02:23:41 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: barry.price@canonical.com-20160622022341-9qrp2nesacwfx017
Merge WP4.5.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1079
1079
         */
1080
1080
        echo apply_filters( 'embed_site_title_html', $site_title );
1081
1081
}
 
1082
 
 
1083
/**
 
1084
 * Filters the oEmbed result before any HTTP requests are made.
 
1085
 *
 
1086
 * If the URL belongs to the current site, the result is fetched directly instead of
 
1087
 * going through the oEmbed discovery process.
 
1088
 *
 
1089
 * @since 4.5.3
 
1090
 *
 
1091
 * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null.
 
1092
 * @param string      $url    The URL that should be inspected for discovery `<link>` tags.
 
1093
 * @param array       $args   oEmbed remote get arguments.
 
1094
 * @return null|string The UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
 
1095
 *                     Null if the URL does not belong to the current site.
 
1096
 */
 
1097
function wp_filter_pre_oembed_result( $result, $url, $args ) {
 
1098
        $post_id = url_to_postid( $url );
 
1099
 
 
1100
        /** This filter is documented in wp-includes/class-wp-oembed-controller.php */
 
1101
        $post_id = apply_filters( 'oembed_request_post_id', $post_id, $url );
 
1102
 
 
1103
        if ( ! $post_id ) {
 
1104
                return $result;
 
1105
        }
 
1106
 
 
1107
        $width = isset( $args['width'] ) ? $args['width'] : 0;
 
1108
 
 
1109
        $data = get_oembed_response_data( $post_id, $width );
 
1110
        $data = _wp_oembed_get_object()->data2html( (object) $data, $url );
 
1111
 
 
1112
        if ( ! $data ) {
 
1113
                return $result;
 
1114
        }
 
1115
 
 
1116
        return $data;
 
1117
}