Changeset 37798
- Timestamp:
- 06/21/2016 02:41:05 PM (9 years ago)
- Location:
- branches/4.4
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.4/src/wp-includes/class-oembed.php
r36066 r37798 285 285 */ 286 286 public function get_html( $url, $args = '' ) { 287 /** 288 * Filters the oEmbed result before any HTTP requests are made. 289 * 290 * This allows one to short-circuit the default logic, perhaps by 291 * replacing it with a routine that is more optimal for your setup. 292 * 293 * Passing a non-null value to the filter will effectively short-circuit retrieval, 294 * returning the passed value instead. 295 * 296 * @since 4.5.3 297 * 298 * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null. 299 * @param string $url The URL to the content that should be attempted to be embedded. 300 * @param array $args Optional. Arguments, usually passed from a shortcode. Default empty. 301 */ 302 $pre = apply_filters( 'pre_oembed_result', null, $url, $args ); 303 304 if ( null !== $pre ) { 305 return $pre; 306 } 307 287 308 $provider = $this->get_provider( $url, $args ); 288 309 289 if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) ) 290 return false; 310 if ( ! $provider || false === $data = $this->fetch( $provider, $url, $args ) ) { 311 return false; 312 } 291 313 292 314 /** -
branches/4.4/src/wp-includes/default-filters.php
r35742 r37798 474 474 add_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10, 3 ); 475 475 add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 ); 476 add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 ); 476 477 477 478 unset( $filter, $action ); -
branches/4.4/src/wp-includes/embed.php
r37093 r37798 1046 1046 <?php 1047 1047 } 1048 1049 /** 1050 * Filters the oEmbed result before any HTTP requests are made. 1051 * 1052 * If the URL belongs to the current site, the result is fetched directly instead of 1053 * going through the oEmbed discovery process. 1054 * 1055 * @since 4.5.3 1056 * 1057 * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. Default null. 1058 * @param string $url The URL that should be inspected for discovery `<link>` tags. 1059 * @param array $args oEmbed remote get arguments. 1060 * @return null|string The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. 1061 * Null if the URL does not belong to the current site. 1062 */ 1063 function wp_filter_pre_oembed_result( $result, $url, $args ) { 1064 $post_id = url_to_postid( $url ); 1065 1066 /** This filter is documented in wp-includes/class-wp-oembed-controller.php */ 1067 $post_id = apply_filters( 'oembed_request_post_id', $post_id, $url ); 1068 1069 if ( ! $post_id ) { 1070 return $result; 1071 } 1072 1073 $width = isset( $args['width'] ) ? $args['width'] : 0; 1074 1075 $data = get_oembed_response_data( $post_id, $width ); 1076 $data = _wp_oembed_get_object()->data2html( (object) $data, $url ); 1077 1078 if ( ! $data ) { 1079 return $result; 1080 } 1081 1082 return $data; 1083 }
Note: See TracChangeset
for help on using the changeset viewer.