| @@ 551-610 (lines=60) @@ | ||
| 548 | ||
| 549 | ||
| 550 | ||
| 551 | function win8_gallery_shortcode( $attr ) { |
|
| 552 | global $post; |
|
| 553 | ||
| 554 | static $instance = 0; |
|
| 555 | $instance++; |
|
| 556 | ||
| 557 | $output = ''; |
|
| 558 | ||
| 559 | // We're trusting author input, so let's at least make sure it looks like a valid orderby statement |
|
| 560 | if ( isset( $attr['orderby'] ) ) { |
|
| 561 | $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); |
|
| 562 | if ( !$attr['orderby'] ) |
|
| 563 | unset( $attr['orderby'] ); |
|
| 564 | } |
|
| 565 | ||
| 566 | extract( shortcode_atts( array( |
|
| 567 | 'order' => 'ASC', |
|
| 568 | 'orderby' => 'menu_order ID', |
|
| 569 | 'id' => $post->ID, |
|
| 570 | 'include' => '', |
|
| 571 | 'exclude' => '', |
|
| 572 | 'slideshow' => false |
|
| 573 | ), $attr, 'gallery' ) ); |
|
| 574 | ||
| 575 | // Custom image size and always use it |
|
| 576 | add_image_size( 'win8app-column', 480 ); |
|
| 577 | $size = 'win8app-column'; |
|
| 578 | ||
| 579 | $id = intval( $id ); |
|
| 580 | if ( 'RAND' === $order ) |
|
| 581 | $orderby = 'none'; |
|
| 582 | ||
| 583 | if ( !empty( $include ) ) { |
|
| 584 | $include = preg_replace( '/[^0-9,]+/', '', $include ); |
|
| 585 | $_attachments = get_posts( array( 'include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); |
|
| 586 | $attachments = array(); |
|
| 587 | foreach ( $_attachments as $key => $val ) { |
|
| 588 | $attachments[$val->ID] = $_attachments[$key]; |
|
| 589 | } |
|
| 590 | } elseif ( !empty( $exclude ) ) { |
|
| 591 | $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); |
|
| 592 | $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); |
|
| 593 | } else { |
|
| 594 | $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); |
|
| 595 | } |
|
| 596 | ||
| 597 | if ( ! empty( $attachments ) ) { |
|
| 598 | foreach ( $attachments as $id => $attachment ) { |
|
| 599 | $link = isset( $attr['link'] ) && 'file' === $attr['link'] ? wp_get_attachment_link( $id, $size, false, false ) : wp_get_attachment_link( $id, $size, true, false ); |
|
| 600 | ||
| 601 | if ( $captiontag && trim($attachment->post_excerpt) ) { |
|
| 602 | $output .= "<div class='wp-caption aligncenter'>$link |
|
| 603 | <p class='wp-caption-text'>" . wptexturize($attachment->post_excerpt) . "</p> |
|
| 604 | </div>"; |
|
| 605 | } else { |
|
| 606 | $output .= $link . ' '; |
|
| 607 | } |
|
| 608 | } |
|
| 609 | } |
|
| 610 | } |
|
| 611 | ||
| 612 | /** |
|
| 613 | * Returns attachment object. |
|
| @@ 282-341 (lines=60) @@ | ||
| 279 | return $post; |
|
| 280 | } |
|
| 281 | ||
| 282 | function win8_gallery_shortcode( $attr ) { |
|
| 283 | global $post; |
|
| 284 | ||
| 285 | static $instance = 0; |
|
| 286 | $instance++; |
|
| 287 | ||
| 288 | $output = ''; |
|
| 289 | ||
| 290 | // We're trusting author input, so let's at least make sure it looks like a valid orderby statement |
|
| 291 | if ( isset( $attr['orderby'] ) ) { |
|
| 292 | $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); |
|
| 293 | if ( !$attr['orderby'] ) |
|
| 294 | unset( $attr['orderby'] ); |
|
| 295 | } |
|
| 296 | ||
| 297 | extract( shortcode_atts( array( |
|
| 298 | 'order' => 'ASC', |
|
| 299 | 'orderby' => 'menu_order ID', |
|
| 300 | 'id' => $post->ID, |
|
| 301 | 'include' => '', |
|
| 302 | 'exclude' => '', |
|
| 303 | 'slideshow' => false |
|
| 304 | ), $attr, 'gallery' ) ); |
|
| 305 | ||
| 306 | // Custom image size and always use it |
|
| 307 | add_image_size( 'win8app-column', 480 ); |
|
| 308 | $size = 'win8app-column'; |
|
| 309 | ||
| 310 | $id = intval( $id ); |
|
| 311 | if ( 'RAND' === $order ) |
|
| 312 | $orderby = 'none'; |
|
| 313 | ||
| 314 | if ( !empty( $include ) ) { |
|
| 315 | $include = preg_replace( '/[^0-9,]+/', '', $include ); |
|
| 316 | $_attachments = get_posts( array( 'include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); |
|
| 317 | $attachments = array(); |
|
| 318 | foreach ( $_attachments as $key => $val ) { |
|
| 319 | $attachments[$val->ID] = $_attachments[$key]; |
|
| 320 | } |
|
| 321 | } elseif ( !empty( $exclude ) ) { |
|
| 322 | $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); |
|
| 323 | $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); |
|
| 324 | } else { |
|
| 325 | $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) ); |
|
| 326 | } |
|
| 327 | ||
| 328 | if ( ! empty( $attachments ) ) { |
|
| 329 | foreach ( $attachments as $id => $attachment ) { |
|
| 330 | $link = isset( $attr['link'] ) && 'file' === $attr['link'] ? wp_get_attachment_link( $id, $size, false, false ) : wp_get_attachment_link( $id, $size, true, false ); |
|
| 331 | ||
| 332 | if ( $captiontag && trim($attachment->post_excerpt) ) { |
|
| 333 | $output .= "<div class='wp-caption aligncenter'>$link |
|
| 334 | <p class='wp-caption-text'>" . wptexturize($attachment->post_excerpt) . "</p> |
|
| 335 | </div>"; |
|
| 336 | } else { |
|
| 337 | $output .= $link . ' '; |
|
| 338 | } |
|
| 339 | } |
|
| 340 | } |
|
| 341 | } |
|
| 342 | } |
|
| 343 | ||