providers
5 years ago
class-fast-image.php
8 years ago
class-folders-walker.php
7 years ago
class-folders.php
5 years ago
class-frontend.php
5 years ago
class-galleries.php
5 years ago
class-multilang.php
5 years ago
class-remote-library-api.php
5 years ago
class-remote-library.php
5 years ago
class-settings.php
5 years ago
class-tour.php
5 years ago
class-welcome.php
5 years ago
class-widgets.php
5 years ago
functions.php
5 years ago
functions.php
129 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Responsive Lightbox public functions |
| 4 | * |
| 5 | * Functions available for users and developers. May not be replaced. |
| 6 | * |
| 7 | * @since 2.0 |
| 8 | */ |
| 9 | if ( ! defined( 'ABSPATH' ) ) |
| 10 | exit; |
| 11 | |
| 12 | /** |
| 13 | * Display gallery using shortcode. |
| 14 | * |
| 15 | * @param array $args Shortcode arguments |
| 16 | * @return void |
| 17 | */ |
| 18 | function rl_gallery( $args = array() ) { |
| 19 | $defaults = array( |
| 20 | 'id' => 0 |
| 21 | ); |
| 22 | |
| 23 | // merge defaults with arguments |
| 24 | $args = array_merge( $defaults, $args ); |
| 25 | |
| 26 | // parse ID |
| 27 | $args['id'] = (int) $args['id']; |
| 28 | |
| 29 | // is it gallery? |
| 30 | if ( get_post_type( $args['id'] ) === 'rl_gallery' ) |
| 31 | echo do_shortcode( '[rl_gallery id="' . $args['id'] . '"]' ); |
| 32 | else |
| 33 | echo '[rl_gallery id="' . $args['id'] . '"]'; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get gallery shortcode images - wrapper. |
| 38 | * |
| 39 | * @param array $args Gallery arguments |
| 40 | * @return array Gallery images |
| 41 | */ |
| 42 | function rl_get_gallery_shortcode_images( $args ) { |
| 43 | return Responsive_Lightbox()->frontend->get_gallery_shortcode_images( $args ); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Get gallery fields - wrapper. |
| 48 | * |
| 49 | * @param string $type Gallery type |
| 50 | * @return array Gallery fields |
| 51 | */ |
| 52 | function rl_get_gallery_fields( $type ) { |
| 53 | return Responsive_Lightbox()->frontend->get_gallery_fields( $type ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Get gallery fields combined with shortcode attributes - wrapper. |
| 58 | * |
| 59 | * @param array $fields Gallery fields |
| 60 | * @param array $shortcode_atts Gallery shortcode attributes |
| 61 | * @param bool $gallery Whether is it rl_gallery shortcode |
| 62 | * @return array All combined field attributes |
| 63 | */ |
| 64 | function rl_get_gallery_fields_atts( $fields, $shortcode_atts, $gallery = true ) { |
| 65 | return Responsive_Lightbox()->frontend->get_gallery_fields_atts( $fields, $shortcode_atts, $gallery ); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get gallery images - wrapper. |
| 70 | * |
| 71 | * @param int $gallery_id Gallery ID |
| 72 | * @param array $args Gellery args |
| 73 | * @return array Gallery images |
| 74 | */ |
| 75 | function rl_get_gallery_images( $gallery_id, $args ) { |
| 76 | if ( did_action( 'init' ) ) |
| 77 | return Responsive_Lightbox()->galleries->get_gallery_images( $gallery_id, $args ); |
| 78 | else |
| 79 | return array(); |
| 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 | * Get attachment id by url. |
| 94 | * |
| 95 | * @param string $url |
| 96 | * @return int |
| 97 | */ |
| 98 | function rl_get_attachment_id_by_url( $url ) { |
| 99 | return Responsive_Lightbox()->frontend->get_attachment_id_by_url( $url ); |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Get image size by url. |
| 104 | * |
| 105 | * @param string $url Image url |
| 106 | * @return string |
| 107 | */ |
| 108 | function rl_get_image_size_by_url( $url ) { |
| 109 | return Responsive_Lightbox()->frontend->get_image_size_by_url( $url ); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Check whether lightbox supports specified type. |
| 114 | * |
| 115 | * @param string $type Lightbox support type |
| 116 | * @return bool|array |
| 117 | */ |
| 118 | function rl_current_lightbox_supports( $type = '' ) { |
| 119 | $script = Responsive_Lightbox()->options['settings']['script']; |
| 120 | $scripts = Responsive_Lightbox()->settings->scripts; |
| 121 | |
| 122 | if ( $type !== '' ) { |
| 123 | if ( array_key_exists( $script, $scripts ) && array_key_exists( 'supports', $scripts[$script] ) ) |
| 124 | return in_array( $type, $scripts[$script]['supports'], true ); |
| 125 | } else |
| 126 | return $scripts[$script]['supports']; |
| 127 | |
| 128 | return false; |
| 129 | } |