class-frontend.php
8 years ago
class-galleries.php
8 years ago
class-settings.php
8 years ago
class-tour.php
8 years ago
class-welcome.php
8 years ago
class-widgets.php
8 years ago
functions.php
8 years ago
functions.php
109 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Responsive Lightbox public functions |
| 5 | * |
| 6 | * Functions available for users and developers. May not be replaced. |
| 7 | * |
| 8 | * @author Digital Factory |
| 9 | * @package Responsive Lightbox/Functions |
| 10 | * @version |
| 11 | */ |
| 12 | if ( ! defined( 'ABSPATH' ) ) |
| 13 | exit; |
| 14 | |
| 15 | /** |
| 16 | * Display gallery using shortcode. |
| 17 | * |
| 18 | * @param array $args Shortcode arguments |
| 19 | * @return void |
| 20 | */ |
| 21 | function rl_gallery( $args = array() ) { |
| 22 | $defaults = array( |
| 23 | 'id' => 0 |
| 24 | ); |
| 25 | |
| 26 | // merge defaults with arguments |
| 27 | $args = array_merge( $defaults, $args ); |
| 28 | |
| 29 | // parse ID |
| 30 | $args['id'] = (int) $args['id']; |
| 31 | |
| 32 | // is it gallery? |
| 33 | if ( get_post_type( $args['id'] ) === 'rl_gallery' ) |
| 34 | echo do_shortcode( '[rl_gallery id="' . $args['id'] . '"]' ); |
| 35 | else |
| 36 | echo '[rl_gallery id="' . $args['id'] . '"]'; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Get gallery shortcode images - wrapper. |
| 41 | * |
| 42 | * @param array $args Gallery arguments |
| 43 | * @return array Gallery images |
| 44 | */ |
| 45 | function rl_get_gallery_shortcode_images( $args ) { |
| 46 | return Responsive_Lightbox()->frontend->get_gallery_shortcode_images( $args ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Get gallery fields - wrapper. |
| 51 | * |
| 52 | * @param string $type Gallery type |
| 53 | * @return array Gallery fields |
| 54 | */ |
| 55 | function rl_get_gallery_fields( $type ) { |
| 56 | return Responsive_Lightbox()->frontend->get_gallery_fields( $type ); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get gallery fields combined with shortcode attributes - wrapper. |
| 61 | * |
| 62 | * @param array $fields Gallery fields |
| 63 | * @param array $shortcode_atts Gallery shortcode attributes |
| 64 | * @param bool $gallery Whether is it rl_gallery shortcode |
| 65 | * @return array All combined field attributes |
| 66 | */ |
| 67 | function rl_get_gallery_fields_atts( $fields, $shortcode_atts, $gallery = true ) { |
| 68 | return Responsive_Lightbox()->frontend->get_gallery_fields_atts( $fields, $shortcode_atts, $gallery ); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Get gallery images - wrapper. |
| 73 | * |
| 74 | * @param int $gallery_id Gallery ID |
| 75 | * @param array $args Gellery args |
| 76 | * @return array Gallery images |
| 77 | */ |
| 78 | function rl_get_gallery_images( $gallery_id, $args ) { |
| 79 | return Responsive_Lightbox()->galleries->get_gallery_images( $gallery_id, $args ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Add lightbox to images, galleries and videos. |
| 84 | * |
| 85 | * @param string $content HTML content |
| 86 | * @return string |
| 87 | */ |
| 88 | function rl_add_lightbox( $content ) { |
| 89 | return Responsive_Lightbox()->frontend->add_lightbox( $content ); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * Check whether lightbox supports specified type. |
| 94 | * |
| 95 | * @param string $type Lightbox support type |
| 96 | * @return bool|array |
| 97 | */ |
| 98 | function rl_current_lightbox_supports( $type = '' ) { |
| 99 | $script = Responsive_Lightbox()->options['settings']['script']; |
| 100 | $scripts = Responsive_Lightbox()->settings->scripts; |
| 101 | |
| 102 | if ( $type !== '' ) { |
| 103 | if ( array_key_exists( $script, $scripts ) && array_key_exists( 'supports', $scripts[$script] ) ) |
| 104 | return in_array( $type, $scripts[$script]['supports'], true ); |
| 105 | } else |
| 106 | return $scripts[$script]['supports']; |
| 107 | |
| 108 | return false; |
| 109 | } |