Beispiel #1
0
 function be_gallery($atts)
 {
     global $be_themes_data;
     extract(shortcode_atts(array('col' => 'three', 'lightbox_type' => '', 'gutter_style' => 'style1', 'items_per_load' => '', 'gallery_paginate' => 'none', 'gutter_width' => 40, 'masonry' => '0', 'initial_load_style' => 'none', 'item_parallax' => 0, 'disable_hover_icon' => '0', 'hover_style' => 'style1-hover', 'default_image_style' => 'color', 'hover_image_style' => 'color', 'image_effect' => 'none', 'overlay_color' => $be_themes_data['color_scheme'], 'gradient_color' => $be_themes_data['color_scheme'], 'gradient' => '0', 'gradient_direction' => 'bottom', 'overlay_opacity' => '85', 'like_button' => 0, 'image_source' => 'selected', 'images' => '', 'account_name' => 'themeforest', 'count' => 10, 'ids' => '', 'columns' => 0, 'link' => 'none'), $atts));
     $output = $thumb_overlay_color = $gradient_style_color = '';
     $col = !isset($col) || empty($col) ? 'three' : $col;
     $columns = !isset($columns) || empty($columns) ? 0 : $columns;
     $link = !isset($link) || empty($link) ? '' : $link;
     $items_per_load = !isset($items_per_load) || empty($items_per_load) ? '' : $items_per_load;
     $gallery_paginate = !isset($gallery_paginate) || empty($gallery_paginate) ? 'none' : $gallery_paginate;
     $gutter_style = !isset($gutter_style) || empty($gutter_style) ? 'style1' : $gutter_style;
     $gutter_width = isset($gutter_width) || $gutter_width == 0 || !empty($gutter_width) ? intval($gutter_width) : intval(40);
     $images = !isset($images) || empty($images) ? '' : $images;
     //Conditions if default WP gallery is used
     if ($columns != 0 || !empty($ids) && $images == '') {
         // $masonry = 1;
         $lightbox_type = 'photoswipe';
         $gutter_width = 10;
         if ($columns < 2 || $columns > 5) {
             $columns = 'three';
         } elseif ($columns == 2) {
             $columns = 'two';
         } elseif ($columns == 3) {
             $columns = 'three';
         } elseif ($columns == 4) {
             $columns = 'four';
         } elseif ($columns == 5) {
             $columns = 'five';
         }
         $col = $columns;
     }
     //Condition if default WP gallery is used
     $images = isset($ids) && $images == '' ? $ids : $images;
     $masonry = !isset($masonry) || empty($masonry) ? 0 : $masonry;
     $initial_load_style = !isset($initial_load_style) || empty($initial_load_style) ? 'none' : $initial_load_style;
     $hover_style = !isset($hover_style) || empty($hover_style) ? 'style1-hover' : $hover_style;
     $disable_hover_icon = !isset($disable_hover_icon) || empty($disable_hover_icon) ? '' : 'hover-icon-no-show';
     $default_image_style = !isset($default_image_style) || empty($default_image_style) ? 'color' : $default_image_style;
     $hover_image_style = !isset($hover_image_style) || empty($hover_image_style) ? 'color' : $hover_image_style;
     $image_effect = !isset($image_effect) || empty($image_effect) ? 'none' : $image_effect;
     $gradient_direction = !isset($gradient_direction) || empty($gradient_direction) ? 'bottom' : $gradient_direction;
     $image_source = !isset($image_source) || empty($image_source) ? 'selected' : $image_source;
     $account_name = !isset($account_name) || empty($account_name) ? 'themeforest' : $account_name;
     $item_parallax = isset($item_parallax) && !empty($item_parallax) && intval($item_parallax) != 0 ? 'portfolio-item-parallax' : '';
     $count = !isset($count) || empty($count) ? 10 : $count;
     // Changes for PhotoSwipe Gallery
     $element_class = 'photoswipe' == $lightbox_type ? 'be-photoswipe-gallery' : '';
     //End
     if ($default_image_style == 'black_white') {
         if ($hover_image_style == 'black_white') {
             $img_grayscale = 'bw_to_bw';
         } else {
             $img_grayscale = 'bw_to_c';
         }
     } else {
         if ($hover_image_style == 'black_white') {
             $img_grayscale = 'c_to_bw';
         } else {
             $img_grayscale = 'c_to_c';
         }
     }
     $overlay_opacity = !isset($overlay_opacity) || empty($overlay_opacity) ? 85 : $overlay_opacity;
     if (isset($overlay_color) && !empty($overlay_color)) {
         $overlay_color = be_themes_hexa_to_rgb($overlay_color);
         $thumb_overlay_color = 'rgba(' . $overlay_color[0] . ',' . $overlay_color[1] . ',' . $overlay_color[2] . ',' . intval($overlay_opacity) / 100 . ')';
         if ($gradient) {
             if (!isset($gradient_color) && empty($gradient_color)) {
                 $gradient_color = $overlay_color;
             } else {
                 $gradient_color = be_themes_hexa_to_rgb($gradient_color);
             }
             $thumb_gradient_overlay_color = 'rgba(' . $gradient_color[0] . ',' . $gradient_color[1] . ',' . $gradient_color[2] . ',' . intval($overlay_opacity) / 100 . ')';
             $gradient_style_color = 'background-image: -o-linear-gradient(' . $gradient_direction . ', ' . $thumb_overlay_color . ' 0%, ' . $thumb_gradient_overlay_color . ' 100%);background-image: -moz-linear-gradient(' . $gradient_direction . ', ' . $thumb_overlay_color . ' 0%, ' . $thumb_gradient_overlay_color . ' 100%);background-image: -webkit-linear-gradient(' . $gradient_direction . ', ' . $thumb_overlay_color . ' 0%, ' . $thumb_gradient_overlay_color . ' 100%);background-image: -ms-linear-gradient(' . $gradient_direction . ', ' . $thumb_overlay_color . ' 0%, ' . $thumb_gradient_overlay_color . ' 100%);background-image: linear-gradient(to ' . $gradient_direction . ', ' . $thumb_overlay_color . ' 0%, ' . $thumb_gradient_overlay_color . ' 100%);';
         }
     }
     if ($gutter_style == 'style2') {
         $portfolio_wrap_style = 'style="margin-left: -' . $gutter_width . 'px;"';
     } else {
         $portfolio_wrap_style = 'style="margin-right: ' . $gutter_width . 'px;"';
     }
     $source = array('source' => $image_source, 'account_name' => $account_name, 'count' => $count, 'col' => $col, 'masonry' => $masonry);
     $paged = '0';
     $images_offset = '0';
     $images_arr = $images;
     $data_total_items = count(explode(',', $images_arr)) - $items_per_load;
     if ('none' != $gallery_paginate && '' != $items_per_load) {
         $images_subset = array_slice(explode(',', $images), $images_offset, $items_per_load);
     } else {
         $images_subset = explode(',', $images);
     }
     $images = get_gallery_image_from_source($source, implode(",", $images_subset), $lightbox_type);
     if ($images && is_array($images) && !isset($images['error']) && empty($images['error'])) {
         $output .= '<div class="portfolio-all-wrap ' . $disable_hover_icon . '">';
         $output .= '<div class="portfolio full-screen full-screen-gutter ' . $gutter_style . '-gutter ' . $col . '-col" ' . $portfolio_wrap_style . ' data-action="get_be_gallery_with_pagination" data-paged="1" data-masonry="' . $masonry . '" data-source=\'' . json_encode($source) . '\' data-gutter-width="' . $gutter_width . '" data-images-array="' . $images_arr . '" data-col="' . $col . '" data-items-per-load="' . $items_per_load . '" data-hover-style="' . $hover_style . '" data-image-grayscale="' . $img_grayscale . '" data-lightbox-type="' . $lightbox_type . '" data-image-source="' . $image_source . '" data-image-effect="' . $image_effect . '" data-thumb-overlay-color="' . $thumb_overlay_color . '" data-grad-style-color="' . $gradient_style_color . '" data-like-button="' . $like_button . '" >';
         $output .= '<div class="portfolio-container clickable clearfix portfolio-shortcode ' . $element_class . ' ' . $initial_load_style . ' ' . $item_parallax . '">';
         $output .= get_be_gallery_shortcode($images, $col, $masonry, $hover_style, $img_grayscale, $gutter_width, $lightbox_type, $image_source, $image_effect, $thumb_overlay_color, $gradient_style_color, $like_button);
         //1.9
         $output .= '</div>';
         //end portfolio-container
         if ('' != $items_per_load && isset($gallery_paginate) && 'selected' == $image_source) {
             if ($gallery_paginate == 'infinite') {
                 $output .= '<div class="trigger_infinite_scroll gallery_infinite_scroll"></div>';
             } elseif ($gallery_paginate == 'loadmore') {
                 $output .= '<div class="trigger_load_more gallery_load_more " data-total-items="' . $data_total_items . '"><a class="be-shortcode mediumbtn be-button rounded" href="#">' . __('Load More', 'be-themes') . '</a></div>';
             }
         }
         $output .= '</div>';
         //end portfolio
         $output .= '</div>';
         //end portfolio-all-wrap
     } else {
         if (is_array($images) && !empty($images['error'])) {
             $output .= '<p class="element-empty-message">' . $images['error'] . '</p>';
         } else {
             $output .= '<p class="element-empty-message"><b>' . __('Gallery Error : ', 'be-themes') . '</b>' . __('Unknown Error Please try again later', 'be-themes') . '</p>';
         }
     }
     return $output;
 }
 function be_themes_get_be_gallery_with_pagination()
 {
     extract($_POST);
     if ($paged != 0) {
         $images_offset = $paged * $items_per_load;
     } else {
         $images_offset = $paged;
     }
     $images_arr = explode(',', $images_arr);
     if ($images_offset >= count($images_arr)) {
         return 0;
         die;
     }
     $images_subset = array_slice($images_arr, $images_offset, $items_per_load);
     $images = get_gallery_image_from_source(json_decode(stripslashes($source), true), implode(",", $images_subset), $lightbox_type);
     echo get_be_gallery_shortcode($images, $col, $masonry, $hover_style, $img_grayscale, $gutter_width, $lightbox_type, $image_source, $image_effect, $thumb_overlay_color, $gradient_style_color, $like_button);
 }