Changeset 42343 for trunk/src/wp-includes/embed.php
- Timestamp:
- 11/30/2017 11:09:33 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/embed.php
r41634 r42343 62 62 */ 63 63 function wp_embed_defaults( $url = '' ) { 64 if ( ! empty( $GLOBALS['content_width'] ) ) 64 if ( ! empty( $GLOBALS['content_width'] ) ) { 65 65 $width = (int) $GLOBALS['content_width']; 66 67 if ( empty( $width ) ) 66 } 67 68 if ( empty( $width ) ) { 68 69 $width = 500; 70 } 69 71 70 72 $height = min( ceil( $width * 1.5 ), 1000 ); … … 132 134 function wp_oembed_add_provider( $format, $provider, $regex = false ) { 133 135 if ( did_action( 'plugins_loaded' ) ) { 134 $oembed = _wp_oembed_get_object();135 $oembed->providers[ $format] = array( $provider, $regex );136 $oembed = _wp_oembed_get_object(); 137 $oembed->providers[ $format ] = array( $provider, $regex ); 136 138 } else { 137 139 WP_oEmbed::_add_provider_early( $format, $provider, $regex ); … … 227 229 function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { 228 230 global $wp_embed; 229 $embed = $wp_embed->autoembed( sprintf( "https://youtube.com/watch?v=%s", urlencode( $matches[2] ) ) );231 $embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) ); 230 232 231 233 /** … … 396 398 397 399 if ( '' !== $permalink ) { 398 $url = add_query_arg( array( 399 'url' => urlencode( $permalink ), 400 'format' => ( 'json' !== $format ) ? $format : false, 401 ), $url ); 400 $url = add_query_arg( 401 array( 402 'url' => urlencode( $permalink ), 403 'format' => ( 'json' !== $format ) ? $format : false, 404 ), $url 405 ); 402 406 } 403 407 … … 450 454 * and edit wp-embed.js directly. 451 455 */ 452 $output .= <<<JS456 $output .= <<<JS 453 457 include "js/wp-embed.min.js" 454 458 JS; … … 518 522 * } 519 523 */ 520 $min_max_width = apply_filters( 'oembed_min_max_width', array( 521 'min' => 200, 522 'max' => 600 523 ) ); 524 $min_max_width = apply_filters( 525 'oembed_min_max_width', array( 526 'min' => 200, 527 'max' => 600, 528 ) 529 ); 524 530 525 531 $width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] ); … … 583 589 if ( wp_attachment_is_image( $post ) ) { 584 590 $thumbnail_id = $post->ID; 585 } else 591 } elseif ( wp_attachment_is( 'video', $post ) ) { 586 592 $thumbnail_id = get_post_thumbnail_id( $post ); 587 593 $data['type'] = 'video'; … … 591 597 if ( $thumbnail_id ) { 592 598 list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) ); 593 $data['thumbnail_url'] = $thumbnail_url;594 $data['thumbnail_width'] = $thumbnail_width;595 $data['thumbnail_height'] = $thumbnail_height;599 $data['thumbnail_url'] = $thumbnail_url; 600 $data['thumbnail_width'] = $thumbnail_width; 601 $data['thumbnail_height'] = $thumbnail_height; 596 602 } 597 603 … … 730 736 $allowed_html = array( 731 737 'a' => array( 732 'href' 738 'href' => true, 733 739 ), 734 740 'blockquote' => array(), … … 760 766 761 767 $url = esc_url( "{$results[2]}#?secret=$secret" ); 762 $q = $results[1];768 $q = $results[1]; 763 769 764 770 $html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html ); … … 767 773 768 774 $allowed_html['blockquote']['data-secret'] = true; 769 $allowed_html['iframe']['data-secret'] = true;775 $allowed_html['iframe']['data-secret'] = true; 770 776 771 777 $html = wp_kses( $html, $allowed_html ); … … 798 804 } 799 805 800 $link = sprintf( '<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>', 806 $link = sprintf( 807 '<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>', 801 808 esc_url( get_permalink() ), 802 809 /* translators: %s: Name of current post */ … … 874 881 <style type="text/css"> 875 882 <?php 876 877 readfile( ABSPATH . WPINC . "/css/wp-embed-template.css");878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 883 if ( SCRIPT_DEBUG ) { 884 readfile( ABSPATH . WPINC . '/css/wp-embed-template.css' ); 885 } else { 886 /* 887 * If you're looking at a src version of this file, you'll see an "include" 888 * statement below. This is used by the `grunt build` process to directly 889 * include a minified version of wp-oembed-embed.css, instead of using the 890 * readfile() method from above. 891 * 892 * If you're looking at a build version of this file, you'll see a string of 893 * minified CSS. If you need to debug it, please turn on SCRIPT_DEBUG 894 * and edit wp-embed-template.css directly. 895 */ 896 ?> 897 include "css/wp-embed-template.min.css" 898 <?php 899 } 893 900 ?> 894 901 </style> … … 905 912 <script type="text/javascript"> 906 913 <?php 907 908 readfile( ABSPATH . WPINC . "/js/wp-embed-template.js");909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 914 if ( SCRIPT_DEBUG ) { 915 readfile( ABSPATH . WPINC . '/js/wp-embed-template.js' ); 916 } else { 917 /* 918 * If you're looking at a src version of this file, you'll see an "include" 919 * statement below. This is used by the `grunt build` process to directly 920 * include a minified version of wp-embed-template.js, instead of using the 921 * readfile() method from above. 922 * 923 * If you're looking at a build version of this file, you'll see a string of 924 * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG 925 * and edit wp-embed-template.js directly. 926 */ 927 ?> 928 include "js/wp-embed-template.min.js" 929 <?php 930 } 924 931 ?> 925 932 </script> … … 1075 1082 1076 1083 if ( is_multisite() ) { 1077 $url_parts = wp_parse_args( wp_parse_url( $url ), array( 1078 'host' => '', 1084 $url_parts = wp_parse_args( 1085 wp_parse_url( $url ), array( 1086 'host' => '', 1087 'path' => '/', 1088 ) 1089 ); 1090 1091 $qv = array( 1092 'domain' => $url_parts['host'], 1079 1093 'path' => '/', 1080 ) ); 1081 1082 $qv = array( 'domain' => $url_parts['host'], 'path' => '/' ); 1094 ); 1083 1095 1084 1096 // In case of subdirectory configs, set the path.
Note: See TracChangeset
for help on using the changeset viewer.