attachments.php
6 years ago
blocks.php
1 month ago
common.php
4 months ago
maxmegamenu.php
1 month ago
meow_gallery.php
3 months ago
metaslider.php
1 month ago
my-calendar.php
1 month ago
woocommerce.php
1 month ago
wpseo.php
3 years ago
meow_gallery.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | add_action('wpmc_scan_post', 'wpmc_scan_html_meow_gallery', 10, 2); |
| 4 | add_filter( 'mgl_is_archive_context', 'wpmc_mgl_truncate'); |
| 5 | |
| 6 | function wpmc_mgl_truncate( $should_truncate ) |
| 7 | { |
| 8 | $should_truncate = false; |
| 9 | return $should_truncate ; |
| 10 | } |
| 11 | |
| 12 | function wpmc_scan_html_meow_gallery($html, $id) |
| 13 | { |
| 14 | global $wpmc; |
| 15 | $html = apply_filters( 'wpmc_affect_html_from_builder', $html, $id ); |
| 16 | |
| 17 | $posts_images_urls = array(); |
| 18 | $posts_images_ids = array(); |
| 19 | |
| 20 | $matches = array(); |
| 21 | |
| 22 | |
| 23 | global $wpmgl; |
| 24 | if ( !isset( $wpmgl ) ) { |
| 25 | return; // Meow Gallery is not active |
| 26 | } |
| 27 | |
| 28 | |
| 29 | // Galleries |
| 30 | $pattern = get_shortcode_regex( ['gallery', 'meow-gallery'] ); |
| 31 | preg_match_all( '/'. $pattern .'/s', $html, $matches ); |
| 32 | |
| 33 | foreach( $matches[3] as $index => $attrs_string ) { |
| 34 | $attrs_string = stripslashes( $attrs_string ); |
| 35 | $attributes = shortcode_parse_atts( $attrs_string ); |
| 36 | $attributes = apply_filters( 'shortcode_atts_gallery', $attributes, null, $attributes, null ); |
| 37 | $inner_html = $wpmgl->gallery( $attributes ); |
| 38 | |
| 39 | $urls = $wpmc->get_urls_from_html( $inner_html ); |
| 40 | |
| 41 | $posts_images_urls = array_merge( $posts_images_urls, $urls ); |
| 42 | } |
| 43 | |
| 44 | $wpmc->add_reference_url( $posts_images_urls, 'Meow Gallery', $id ); |
| 45 | $posts_images_urls = array(); |
| 46 | |
| 47 | // Collections |
| 48 | |
| 49 | global $wpmgl_pro; |
| 50 | if ( !isset( $wpmgl_pro ) ) { |
| 51 | return; // Meow Gallery Pro is not active |
| 52 | } |
| 53 | |
| 54 | $pattern = get_shortcode_regex( ['meow-collection'] ); |
| 55 | preg_match_all( '/'. $pattern .'/s', $html, $matches ); |
| 56 | |
| 57 | $thumbnail_keys = [ |
| 58 | 'gallery_id' => 'id', |
| 59 | 'wplr_collection_id' => 'wplr-collection', |
| 60 | ]; |
| 61 | |
| 62 | foreach( $matches[3] as $index => $attrs_string ) { |
| 63 | $attrs_string = stripslashes( $attrs_string ); |
| 64 | $attributes = shortcode_parse_atts( $attrs_string ); |
| 65 | |
| 66 | // This filters triggers Photo Engine to transform wplr-folder to attributes |
| 67 | $attributes = apply_filters( 'shortcode_atts_collection', $attributes, null, $attributes ); |
| 68 | list( $gallery_ids, $layout ) = $wpmgl_pro->get_galleries_from_collection( $attributes ); |
| 69 | |
| 70 | //We either get the galleries ids or the thumbnails information from wplr |
| 71 | $collection_thumbnails = $wpmgl_pro->get_thumbnails( $gallery_ids, $attributes, $layout ); |
| 72 | |
| 73 | foreach ( $collection_thumbnails as $thumbnail ) { |
| 74 | $key = null; |
| 75 | $value = null; |
| 76 | |
| 77 | if ( array_key_exists( 'wplr_collection_id', $thumbnail ) ) { |
| 78 | $key = $thumbnail_keys['wplr_collection_id']; |
| 79 | $value = $thumbnail['wplr_collection_id']; |
| 80 | } |
| 81 | |
| 82 | if( array_key_exists( 'gallery_id', $thumbnail ) ) { |
| 83 | $key = $thumbnail_keys['gallery_id']; |
| 84 | $value = $thumbnail[ 'gallery_id' ]; |
| 85 | } |
| 86 | |
| 87 | $inner_html = $wpmgl->gallery( [ $key => $value ] ); |
| 88 | $urls = $wpmc->get_urls_from_html( $inner_html ); |
| 89 | |
| 90 | $posts_images_urls = array_merge( $posts_images_urls, $urls ); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | $wpmc->add_reference_url( $posts_images_urls, 'Meow Collection', $id ); |
| 95 | } |