diff --git wp-content/themes/twentythirteen/content-gallery.php wp-content/themes/twentythirteen/content-gallery.php
index 6ee2b3d..e357980 100644
|
|
|
|
| 24 | 24 | <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentythirteen' ) ); ?> |
| 25 | 25 | <?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>' ) ); ?> |
| 26 | 26 | <?php else : ?> |
| 27 | | <?php the_content(); ?> |
| | 27 | <?php the_post_format_gallery(); ?> |
| 28 | 28 | <?php endif; // is_single() ?> |
| 29 | 29 | </div><!-- .entry-content --> |
| 30 | 30 | |
diff --git wp-includes/media.php wp-includes/media.php
index bd52867..8e7a94d 100644
|
|
|
function get_content_image( &$content, $html = true, $remove = false ) { |
| 2278 | 2278 | * @since 3.6.0 |
| 2279 | 2279 | * |
| 2280 | 2280 | * @param string $content A string which might contain image data. |
| | 2281 | * @param boolean $html Whether to return HTML or data |
| 2281 | 2282 | * @param boolean $remove Optional. Whether to remove the found data from the passed content. |
| 2282 | 2283 | * @param int $limit Optional. The number of galleries to return |
| 2283 | 2284 | * @return array A list of galleries, which in turn are a list of their srcs in order |
| 2284 | 2285 | */ |
| 2285 | | function get_content_galleries( &$content, $remove = false, $limit = 0 ) { |
| | 2286 | function get_content_galleries( &$content, $html = true, $remove = false, $limit = 0 ) { |
| 2286 | 2287 | $src = ''; |
| 2287 | 2288 | $galleries = array(); |
| 2288 | 2289 | $matches = array(); |
| … |
… |
function get_content_galleries( &$content, $remove = false, $limit = 0 ) { |
| 2297 | 2298 | |
| 2298 | 2299 | $data = shortcode_parse_atts( $shortcode[3] ); |
| 2299 | 2300 | $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; |
| 2304 | 2312 | } |
| 2305 | 2313 | |
| 2306 | | $data['src'] = array_values( array_unique( $srcs ) ); |
| 2307 | | $galleries[] = $data; |
| 2308 | 2314 | if ( $limit > 0 && count( $galleries ) >= $limit ) |
| 2309 | 2315 | break; |
| 2310 | 2316 | } |
| … |
… |
function get_content_galleries( &$content, $remove = false, $limit = 0 ) { |
| 2320 | 2326 | * @since 3.6.0 |
| 2321 | 2327 | * |
| 2322 | 2328 | * @param int $post_id Optional. Post ID. |
| | 2329 | * @param boolean $html Whether to return HTML or data |
| 2323 | 2330 | * @return array A list of arrays, each containing gallery data and srcs parsed |
| 2324 | 2331 | * from the expanded shortcode |
| 2325 | 2332 | */ |
| 2326 | | function get_post_galleries( $post_id = 0 ) { |
| | 2333 | function get_post_galleries( $post_id = 0, $html = true ) { |
| 2327 | 2334 | $post = empty( $post_id ) ? clone get_post() : get_post( $post_id ); |
| 2328 | 2335 | if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) ) |
| 2329 | 2336 | return array(); |
| 2330 | 2337 | |
| 2331 | | return get_content_galleries( $post->post_content ); |
| | 2338 | return get_content_galleries( $post->post_content, $html ); |
| 2332 | 2339 | } |
| 2333 | 2340 | |
| 2334 | 2341 | /** |
| … |
… |
function get_post_galleries_images( $post_id = 0 ) { |
| 2345 | 2352 | if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) ) |
| 2346 | 2353 | return array(); |
| 2347 | 2354 | |
| 2348 | | $data = get_content_galleries( $post->post_content ); |
| | 2355 | $data = get_content_galleries( $post->post_content, false ); |
| 2349 | 2356 | return wp_list_pluck( $data, 'src' ); |
| 2350 | 2357 | } |
| 2351 | 2358 | |
| … |
… |
function get_post_galleries_images( $post_id = 0 ) { |
| 2355 | 2362 | * @since 3.6.0 |
| 2356 | 2363 | * |
| 2357 | 2364 | * @param int $post_id Optional. Post ID. |
| | 2365 | * @param boolean $html Whether to return HTML or data |
| 2358 | 2366 | * @return array Gallery data and srcs parsed from the expanded shortcode |
| 2359 | 2367 | */ |
| 2360 | | function get_post_gallery( $post_id = 0 ) { |
| | 2368 | function get_post_gallery( $post_id = 0, $html = true ) { |
| 2361 | 2369 | $post = empty( $post_id ) ? clone get_post() : get_post( $post_id ); |
| 2362 | 2370 | if ( empty( $post ) || ! has_shortcode( $post->post_content, 'gallery' ) ) |
| 2363 | 2371 | return array(); |
| 2364 | 2372 | |
| 2365 | | $data = get_content_galleries( $post->post_content, false, 1 ); |
| | 2373 | $data = get_content_galleries( $post->post_content, $html, false, 1 ); |
| 2366 | 2374 | return reset( $data ); |
| 2367 | 2375 | } |
| 2368 | 2376 | |
| 2369 | 2377 | /** |
| | 2378 | * Output the first gallery in the current (@global) $post |
| | 2379 | * |
| | 2380 | * @since 3.6.0 |
| | 2381 | */ |
| | 2382 | function the_post_format_gallery() { |
| | 2383 | echo get_post_gallery(); |
| | 2384 | } |
| | 2385 | |
| | 2386 | /** |
| 2370 | 2387 | * Check a post's content for galleries and return the image srcs for the first found gallery |
| 2371 | 2388 | * |
| 2372 | 2389 | * @since 3.6.0 |
| … |
… |
function get_post_gallery( $post_id = 0 ) { |
| 2375 | 2392 | * @return array A list of a gallery's image srcs in order |
| 2376 | 2393 | */ |
| 2377 | 2394 | function get_post_gallery_images( $post_id = 0 ) { |
| 2378 | | $gallery = get_post_gallery( $post_id ); |
| | 2395 | $gallery = get_post_gallery( $post_id, false ); |
| 2379 | 2396 | if ( empty( $gallery['src'] ) ) |
| 2380 | 2397 | return array(); |
| 2381 | 2398 | |