Make WordPress Core

Ticket #24126: 24126.2.diff

File 24126.2.diff, 4.8 KB (added by wonderboymusic, 13 years ago)
  • wp-content/themes/twentythirteen/content-gallery.php

    diff --git wp-content/themes/twentythirteen/content-gallery.php wp-content/themes/twentythirteen/content-gallery.php
    index 6ee2b3d..e357980 100644
     
    2424                        <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?>
    2525                        <?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
    2626                <?php else : ?>
    27                         <?php the_content(); ?>
     27                        <?php the_post_format_gallery(); ?>
    2828                <?php endif; // is_single() ?>
    2929        </div><!-- .entry-content -->
    3030
  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index bd52867..8e7a94d 100644
    function get_content_image( &$content, $html = true, $remove = false ) { 
    22782278 * @since 3.6.0
    22792279 *
    22802280 * @param string $content A string which might contain image data.
     2281 * @param boolean $html Whether to return HTML or data
    22812282 * @param boolean $remove Optional. Whether to remove the found data from the passed content.
    22822283 * @param int $limit Optional. The number of galleries to return
    22832284 * @return array A list of galleries, which in turn are a list of their srcs in order
    22842285 */
    2285 function get_content_galleries( &$content, $remove = false, $limit = 0 ) {
     2286function get_content_galleries( &$content, $html = true, $remove = false, $limit = 0 ) {
    22862287        $src = '';
    22872288        $galleries = array();
    22882289        $matches = array();
    function get_content_galleries( &$content, $remove = false, $limit = 0 ) { 
    22972298
    22982299                                $data = shortcode_parse_atts( $shortcode[3] );
    22992300                                $gallery = do_shortcode_tag( $shortcode );
    2300                                 preg_match_all( '#src=[\'"](.+?)[\'"]#is', $gallery, $src, PREG_SET_ORDER );
    2301                                 if ( ! empty( $src ) ) {
    2302                                         foreach ( $src as $s )
    2303                                                 $srcs[] = $s[1];
     2301                                if ( $html ) {
     2302                                        $galleries[] = $gallery;
     2303                                } else {
     2304                                        preg_match_all( '#src=[\'"](.+?)[\'"]#is', $gallery, $src, PREG_SET_ORDER );
     2305                                        if ( ! empty( $src ) ) {
     2306                                                foreach ( $src as $s )
     2307                                                        $srcs[] = $s[1];
     2308                                        }
     2309
     2310                                        $data['src'] = array_values( array_unique( $srcs ) );
     2311                                        $galleries[] = $data;
    23042312                                }
    23052313
    2306                                 $data['src'] = array_values( array_unique( $srcs ) );
    2307                                 $galleries[] = $data;
    23082314                                if ( $limit > 0 && count( $galleries ) >= $limit )
    23092315                                        break;
    23102316                        }
    function get_content_galleries( &$content, $remove = false, $limit = 0 ) { 
    23202326 * @since 3.6.0
    23212327 *
    23222328 * @param int $post_id Optional. Post ID.
     2329 * @param boolean $html Whether to return HTML or data
    23232330 * @return array A list of arrays, each containing gallery data and srcs parsed
    23242331 *              from the expanded shortcode
    23252332 */
    2326 function get_post_galleries( $post_id = 0 ) {
     2333function get_post_galleries( $post_id = 0, $html = true ) {
    23272334        $post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
    23282335        if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' )  )
    23292336                return array();
    23302337
    2331         return get_content_galleries( $post->post_content );
     2338        return get_content_galleries( $post->post_content, $html );
    23322339}
    23332340
    23342341/**
    function get_post_galleries_images( $post_id = 0 ) { 
    23452352        if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' )  )
    23462353                return array();
    23472354
    2348         $data = get_content_galleries( $post->post_content );
     2355        $data = get_content_galleries( $post->post_content, false );
    23492356        return wp_list_pluck( $data, 'src' );
    23502357}
    23512358
    function get_post_galleries_images( $post_id = 0 ) { 
    23552362 * @since 3.6.0
    23562363 *
    23572364 * @param int $post_id Optional. Post ID.
     2365 * @param boolean $html Whether to return HTML or data
    23582366 * @return array Gallery data and srcs parsed from the expanded shortcode
    23592367 */
    2360 function get_post_gallery( $post_id = 0 ) {
     2368function get_post_gallery( $post_id = 0, $html = true ) {
    23612369        $post = empty( $post_id ) ? clone get_post() : get_post( $post_id );
    23622370        if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) )
    23632371                return array();
    23642372
    2365         $data = get_content_galleries( $post->post_content, false, 1 );
     2373        $data = get_content_galleries( $post->post_content, $html, false, 1 );
    23662374        return reset( $data );
    23672375}
    23682376
    23692377/**
     2378 * Output the first gallery in the current (@global) $post
     2379 *
     2380 * @since 3.6.0
     2381 */
     2382function the_post_format_gallery() {
     2383        echo get_post_gallery();
     2384}
     2385
     2386/**
    23702387 * Check a post's content for galleries and return the image srcs for the first found gallery
    23712388 *
    23722389 * @since 3.6.0
    function get_post_gallery( $post_id = 0 ) { 
    23752392 * @return array A list of a gallery's image srcs in order
    23762393 */
    23772394function get_post_gallery_images( $post_id = 0 ) {
    2378         $gallery = get_post_gallery( $post_id );
     2395        $gallery = get_post_gallery( $post_id, false );
    23792396        if ( empty( $gallery['src'] ) )
    23802397                return array();
    23812398