Changeset 44155 for trunk/src/wp-includes/embed.php
- Timestamp:
- 12/14/2018 03:24:35 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/embed.php
r44154 r44155 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 ), 405 $url 406 ); 402 407 } 403 408 … … 450 455 * and edit wp-embed.js directly. 451 456 */ 452 $output .= <<<JS457 $output .= <<<JS 453 458 include "js/wp-embed.min.js" 454 459 JS; … … 518 523 * } 519 524 */ 520 $min_max_width = apply_filters( 'oembed_min_max_width', array( 521 'min' => 200, 522 'max' => 600 523 ) ); 525 $min_max_width = apply_filters( 526 'oembed_min_max_width', 527 array( 528 'min' => 200, 529 'max' => 600, 530 ) 531 ); 524 532 525 533 $width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] ); … … 570 578 571 579 if ( is_multisite() ) { 572 $url_parts = wp_parse_args( wp_parse_url( $url ), array( 573 'host' => '', 580 $url_parts = wp_parse_args( 581 wp_parse_url( $url ), 582 array( 583 'host' => '', 584 'path' => '/', 585 ) 586 ); 587 588 $qv = array( 589 'domain' => $url_parts['host'], 574 590 'path' => '/', 575 ) ); 576 577 $qv = array( 'domain' => $url_parts['host'], 'path' => '/' ); 591 ); 578 592 579 593 // In case of subdirectory configs, set the path. … … 648 662 if ( wp_attachment_is_image( $post ) ) { 649 663 $thumbnail_id = $post->ID; 650 } else 664 } elseif ( wp_attachment_is( 'video', $post ) ) { 651 665 $thumbnail_id = get_post_thumbnail_id( $post ); 652 666 $data['type'] = 'video'; … … 656 670 if ( $thumbnail_id ) { 657 671 list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) ); 658 $data['thumbnail_url'] = $thumbnail_url;659 $data['thumbnail_width'] = $thumbnail_width;660 $data['thumbnail_height'] = $thumbnail_height;672 $data['thumbnail_url'] = $thumbnail_url; 673 $data['thumbnail_width'] = $thumbnail_width; 674 $data['thumbnail_height'] = $thumbnail_height; 661 675 } 662 676 … … 795 809 $allowed_html = array( 796 810 'a' => array( 797 'href' 811 'href' => true, 798 812 ), 799 813 'blockquote' => array(), … … 825 839 826 840 $url = esc_url( "{$results[2]}#?secret=$secret" ); 827 $q = $results[1];841 $q = $results[1]; 828 842 829 843 $html = str_replace( $results[0], ' src=' . $q . $url . $q . ' data-secret=' . $q . $secret . $q, $html ); … … 832 846 833 847 $allowed_html['blockquote']['data-secret'] = true; 834 $allowed_html['iframe']['data-secret'] = true;848 $allowed_html['iframe']['data-secret'] = true; 835 849 836 850 $html = wp_kses( $html, $allowed_html ); … … 863 877 } 864 878 865 $link = sprintf( '<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>', 879 $link = sprintf( 880 '<a href="%1$s" class="wp-embed-more" target="_top">%2$s</a>', 866 881 esc_url( get_permalink() ), 867 882 /* translators: %s: Name of current post */ … … 939 954 <style type="text/css"> 940 955 <?php 941 942 readfile( ABSPATH . WPINC . "/css/wp-embed-template.css");943 944 945 946 947 948 949 950 951 952 953 954 956 if ( SCRIPT_DEBUG ) { 957 readfile( ABSPATH . WPINC . '/css/wp-embed-template.css' ); 958 } else { 959 /* 960 * If you're looking at a src version of this file, you'll see an "include" 961 * statement below. This is used by the `grunt build` process to directly 962 * include a minified version of wp-oembed-embed.css, instead of using the 963 * readfile() method from above. 964 * 965 * If you're looking at a build version of this file, you'll see a string of 966 * minified CSS. If you need to debug it, please turn on SCRIPT_DEBUG 967 * and edit wp-embed-template.css directly. 968 */ 969 ?> 955 970 include "css/wp-embed-template.min.css" 956 957 971 <?php 972 } 958 973 ?> 959 974 </style> … … 970 985 <script type="text/javascript"> 971 986 <?php 972 973 readfile( ABSPATH . WPINC . "/js/wp-embed-template.js");974 975 976 977 978 979 980 981 982 983 984 985 987 if ( SCRIPT_DEBUG ) { 988 readfile( ABSPATH . WPINC . '/js/wp-embed-template.js' ); 989 } else { 990 /* 991 * If you're looking at a src version of this file, you'll see an "include" 992 * statement below. This is used by the `grunt build` process to directly 993 * include a minified version of wp-embed-template.js, instead of using the 994 * readfile() method from above. 995 * 996 * If you're looking at a build version of this file, you'll see a string of 997 * minified JavaScript. If you need to debug it, please turn on SCRIPT_DEBUG 998 * and edit wp-embed-template.js directly. 999 */ 1000 ?> 986 1001 include "js/wp-embed-template.min.js" 987 988 1002 <?php 1003 } 989 1004 ?> 990 1005 </script>
Note: See TracChangeset
for help on using the changeset viewer.