Ticket #39304: 39304.diff
File 39304.diff, 1.9 KB (added by , 8 years ago) |
---|
-
src/wp-includes/media.php
function get_media_embedded_in_content( 3667 3667 * from the expanded shortcode. 3668 3668 */ 3669 3669 function get_post_galleries( $post, $html = true ) { 3670 3670 if ( ! $post = get_post( $post ) ) 3671 3671 return array(); 3672 3672 3673 3673 if ( ! has_shortcode( $post->post_content, 'gallery' ) ) 3674 3674 return array(); 3675 3675 3676 3676 $galleries = array(); 3677 3677 if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ) ) { 3678 3678 foreach ( $matches as $shortcode ) { 3679 3679 if ( 'gallery' === $shortcode[2] ) { 3680 3680 $srcs = array(); 3681 3681 3682 $shortcode_attrs = shortcode_parse_atts( $shortcode[3] ); 3683 if ( ! is_array( $shortcode_attrs ) ) { 3684 $shortcode_attrs = array(); 3685 } 3686 3687 // force-specify the post id of the gallery we want to view. 3688 if ( empty( $shortcode_atts['id'] ) ) { 3689 $shortcode[3] .= ' id="' . $post->ID . '"'; 3690 } 3691 3682 3692 $gallery = do_shortcode_tag( $shortcode ); 3683 3693 if ( $html ) { 3684 3694 $galleries[] = $gallery; 3685 3695 } else { 3686 3696 preg_match_all( '#src=([\'"])(.+?)\1#is', $gallery, $src, PREG_SET_ORDER ); 3687 3697 if ( ! empty( $src ) ) { 3688 3698 foreach ( $src as $s ) 3689 3699 $srcs[] = $s[2]; 3690 3700 } 3691 3701 3692 $data = shortcode_parse_atts( $shortcode[3] ); 3693 $data['src'] = array_values( array_unique( $srcs ) ); 3694 $galleries[] = $data; 3702 $shortcode_attrs['src'] = array_values( array_unique( $srcs ) ); 3703 $galleries[] = $shortcode_attrs; 3695 3704 } 3696 3705 } 3697 3706 } 3698 3707 } 3699 3708 3700 3709 /** 3701 3710 * Filters the list of all found galleries in the given post. 3702 3711 * 3703 3712 * @since 3.6.0 3704 3713 * 3705 3714 * @param array $galleries Associative array of all found post galleries. 3706 3715 * @param WP_Post $post Post object. 3707 3716 */ 3708 3717 return apply_filters( 'get_post_galleries', $galleries, $post ); 3709 3718 }