示例#1
0
 function be_portfolio($atts)
 {
     global $be_themes_data;
     extract(shortcode_atts(array('col' => 'three', 'gutter_style' => 'style1', 'gutter_width' => 40, 'show_filters' => 'yes', 'tax_name' => 'portfolio_categories', 'filter' => 'categories', 'category' => '', 'items_per_page' => '-1', 'masonry' => '0', 'gallery' => '0', 'pagination' => 'none', 'initial_load_style' => 'none', 'item_parallax' => 0, 'hover_style' => 'style1-hover', 'title_alignment_static' => '', 'overlay_color' => $be_themes_data['color_scheme'], 'gradient_color' => $be_themes_data['color_scheme'], 'gradient' => '0', 'gradient_direction' => 'bottom', 'overlay_opacity' => '85', 'show_overlay' => '', 'title_style' => 'style1', 'title_color' => '', 'cat_color' => '', 'cat_hide' => 0, 'default_image_style' => 'color', 'hover_image_style' => 'color', 'title_animation_type' => 'none', 'cat_animation_type' => 'none', 'image_effect' => 'none', 'like_button' => 0), $atts));
     $output = $global_thumb_overlay_color = $thumb_overlay_color = $global_gradient_style_color = $gradient_style_color = '';
     $col = !isset($col) || empty($col) ? 'three' : $col;
     $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);
     $masonry_enable = !isset($masonry) || empty($masonry) ? 'masonry_disable' : 'masonry_enable';
     $show_filters = !isset($show_filters) || empty($show_filters) ? 'yes' : $show_filters;
     $tax_name = !isset($tax_name) || empty($tax_name) ? 'portfolio_categories' : $tax_name;
     $filter_to_use = !isset($filter) || empty($filter) ? 'categories' : $filter;
     $items_per_page = !isset($items_per_page) || empty($items_per_page) ? '-1' : $items_per_page;
     $pagination = !isset($pagination) || empty($pagination) ? 'none' : $pagination;
     $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;
     $title_animation_type = !isset($title_animation_type) || empty($title_animation_type) ? 'none' : $title_animation_type;
     $cat_animation_type = !isset($cat_animation_type) || empty($cat_animation_type) ? 'none' : $cat_animation_type;
     $image_effect = !isset($image_effect) || empty($image_effect) ? 'none' : $image_effect;
     $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;
     $hover_style = $title_style == 'style5' || $title_style == 'style6' || $title_style == 'style7' ? '' : $hover_style;
     $gradient_direction = !isset($gradient_direction) || empty($gradient_direction) ? 'bottom' : $gradient_direction;
     $global_title_color = $title_color = isset($title_color) && !empty($title_color) ? $title_color : '';
     $global_cat_color = $cat_color = isset($cat_color) && !empty($cat_color) ? $cat_color : '';
     $cat_hide = isset($cat_hide) && !empty($cat_hide) && intval($cat_hide) != 0 ? $cat_hide : 0;
     $item_parallax = isset($item_parallax) && !empty($item_parallax) && intval($item_parallax) != 0 ? 'portfolio-item-parallax' : '';
     $show_overlay = isset($show_overlay) && !empty($show_overlay) && intval($show_overlay) != 0 ? 'force-show-thumb-overlay' : '';
     if ($show_overlay != '') {
         $title_animation_type = 'none';
         $cat_animation_type = 'none';
         $initial_load_style = 'none';
     }
     if (isset($title_alignment_static) && !empty($title_alignment_static) && ($title_style == 'style5' || $title_style == 'style6')) {
         $title_alignment_static = 'text-align: ' . $title_alignment_static . ';';
     } else {
         $title_alignment_static = '';
     }
     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';
         }
     }
     if ($gutter_style == 'style2') {
         $portfolio_wrap_style = 'style="margin-left: -' . $gutter_width . 'px;"';
     } else {
         $portfolio_wrap_style = 'style="margin-right: ' . $gutter_width . 'px;"';
     }
     if (isset($overlay_opacity) && !empty($overlay_opacity)) {
         $global_overlay_opacity = $overlay_opacity = $overlay_opacity;
     } else {
         $global_overlay_opacity = $overlay_opacity = 85;
     }
     if (isset($overlay_color) && !empty($overlay_color)) {
         $overlay_color = be_themes_hexa_to_rgb($overlay_color);
         $global_thumb_overlay_color = $thumb_overlay_color = 'rgba(' . $overlay_color[0] . ',' . $overlay_color[1] . ',' . $overlay_color[2] . ',' . intval($global_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);
             }
             $global_thumb_gradient_overlay_color = $thumb_gradient_overlay_color = 'rgba(' . $gradient_color[0] . ',' . $gradient_color[1] . ',' . $gradient_color[2] . ',' . intval($global_overlay_opacity) / 100 . ')';
             $global_gradient_style_color = $gradient_style_color = 'background-image: -o-linear-gradient(' . $gradient_direction . ', ' . $global_thumb_overlay_color . ' 0%, ' . $global_thumb_gradient_overlay_color . ' 100%);background-image: -moz-linear-gradient(' . $gradient_direction . ', ' . $global_thumb_overlay_color . ' 0%, ' . $global_thumb_gradient_overlay_color . ' 100%);background-image: -webkit-linear-gradient(' . $gradient_direction . ', ' . $global_thumb_overlay_color . ' 0%, ' . $global_thumb_gradient_overlay_color . ' 100%);background-image: -ms-linear-gradient(' . $gradient_direction . ', ' . $global_thumb_overlay_color . ' 0%, ' . $global_thumb_gradient_overlay_color . ' 100%);background-image: linear-gradient(to ' . $gradient_direction . ', ' . $global_thumb_overlay_color . ' 0%, ' . $global_thumb_gradient_overlay_color . ' 100%);';
         }
     }
     $output .= '<div class="portfolio-all-wrap"><div class="portfolio full-screen full-screen-gutter ' . $masonry_enable . ' ' . $gutter_style . '-gutter ' . $col . '-col" data-action="get_ajax_full_screen_gutter_portfolio" data-category="' . $category . '" data-masonry="' . $masonry . '" data-showposts="' . $items_per_page . '" data-paged="2" data-col="' . $col . '" data-gallery="' . $gallery . '" data-filter="' . $filter_to_use . '" data-show_filters="' . $show_filters . '" data-thumbnail-bg-color="' . $global_thumb_overlay_color . '" data-thumbnail-bg-gradient="' . $gradient_style_color . '" data-title-style="' . $title_style . '" data-cat-color="' . $cat_color . '" data-title-color="' . $title_color . '" data-title-animation-type="' . $title_animation_type . '" data-cat-animation-type="' . $cat_animation_type . '" data-hover-style="' . $hover_style . '" data-gutter-width="' . $gutter_width . '" data-img-grayscale="' . $img_grayscale . '" data-image-effect="' . $image_effect . '" data-gradient-style-color="' . $global_gradient_style_color . '" data-cat-hide="' . $cat_hide . '" ' . $portfolio_wrap_style . '>';
     $category = explode(',', $category);
     if ($filter_to_use == 'portfolio_tags' || empty($category)) {
         // $terms = get_terms( $filter_to_use , array( 'orderby' => 'count' , 'order' => 'DESC') );
         $terms = get_terms($filter_to_use);
     } else {
         $args_cat = array('taxonomy' => 'portfolio_categories');
         $stack = array();
         foreach (get_categories($args_cat) as $single_category) {
             if (in_array($single_category->slug, $category)) {
                 array_push($stack, $single_category->cat_ID);
             }
         }
         // $terms = get_terms($filter_to_use, array( 'orderby' => 'count' , 'order' => 'DESC', 'include' => $stack) );
         $terms = get_terms($filter_to_use, array('include' => $stack));
     }
     // var_dump($terms);
     if (!empty($terms) && $show_filters == 'yes') {
         if ($gutter_style == 'style2') {
             $portfolio_filter_style = 'style="margin-left: ' . $gutter_width . 'px;"';
         } else {
             $portfolio_filter_style = '';
         }
         $output .= '<div class="filters clearfix" ' . $portfolio_filter_style . '>';
         $output .= '<h6><span class="sort current_choice" data-id="element">' . __('All', 'be-themes') . '</span></h6>';
         foreach ($terms as $term) {
             $output .= '<h6>';
             $output .= '<span class="sort" data-id="' . $term->slug . '">' . $term->name . '</span>';
             $output .= '</h6>';
         }
         $output .= '</div>';
     }
     $output .= '<div class="portfolio-container clickable clearfix portfolio-shortcode ' . $show_overlay . ' ' . $initial_load_style . ' ' . $item_parallax . '">';
     if (empty($category[0])) {
         $args = array('post_type' => 'portfolio', 'posts_per_page' => $items_per_page, 'orderby' => apply_filters('be_portfolio_order_by', 'date'), 'order' => apply_filters('be_portfolio_order', 'DESC'), 'post_status' => 'publish');
     } else {
         $args = array('post_type' => 'portfolio', 'posts_per_page' => $items_per_page, 'orderby' => apply_filters('be_portfolio_order_by', 'date'), 'order' => apply_filters('be_portfolio_order', 'DESC'), 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => $tax_name, 'field' => 'slug', 'terms' => $category, 'operator' => 'IN')));
     }
     $the_query = new WP_Query($args);
     if ($the_query->have_posts()) {
         while ($the_query->have_posts()) {
             $the_query->the_post();
             if (has_post_thumbnail(get_the_ID())) {
                 $filter_classes = $permalink = '';
                 $mfp_class = 'mfp-image';
                 $post_terms = get_the_terms(get_the_ID(), $filter_to_use);
                 if ($show_filters == 'yes' && is_array($post_terms)) {
                     foreach ($post_terms as $term) {
                         $filter_classes .= $term->slug . " ";
                     }
                 } else {
                     $filter_classes = '';
                 }
                 $attachment_id = get_post_thumbnail_id(get_the_ID());
                 $image_atts = get_portfolio_image(get_the_ID(), $col, $masonry);
                 $attachment_thumb = wp_get_attachment_image_src($attachment_id, $image_atts['size']);
                 $attachment_full = wp_get_attachment_image_src($attachment_id, 'full');
                 $attachment_thumb_url = $attachment_thumb[0];
                 $attachment_full_url = $attachment_full[0];
                 $video_url = get_post_meta($attachment_id, 'be_themes_featured_video_url', true);
                 $visit_site_url = get_post_meta(get_the_ID(), 'be_themes_portfolio_external_url', true);
                 $link_to = get_post_meta(get_the_ID(), 'be_themes_portfolio_link_to', true);
                 $open_with = get_post_meta(get_the_ID(), 'be_themes_portfolio_single_page_style', true);
                 $single_overlay_color = get_post_meta(get_the_ID(), 'be_themes_single_overlay_color', true);
                 $single_overlay_opacity = get_post_meta(get_the_ID(), 'be_themes_single_overlay_color_opacity', true);
                 $single_title_color = get_post_meta(get_the_ID(), 'be_themes_single_overlay_title_color', true);
                 $single_cat_color = get_post_meta(get_the_ID(), 'be_themes_single_overlay_cat_color', true);
                 $attachment_info = be_wp_get_attachment($attachment_id);
                 if (!isset($visit_site_url) || empty($visit_site_url)) {
                     $visit_site_url = '#';
                 }
                 $permalink = $link_to == 'external_url' ? $visit_site_url : get_permalink();
                 //$target = ( $link_to == 'external_url' ) ? 'target="_blank"' : '';
                 $target = "1" == get_post_meta(get_the_ID(), 'be_themes_portfolio_open_new_tab', true) ? 'target="_blank"' : '';
                 if (isset($single_overlay_opacity) && !empty($single_overlay_opacity)) {
                     $overlay_opacity = $single_overlay_opacity;
                 } else {
                     $overlay_opacity = 85;
                 }
                 if (isset($single_overlay_color) && !empty($single_overlay_color)) {
                     $single_overlay_color = be_themes_hexa_to_rgb($single_overlay_color);
                     $thumb_overlay_color = 'rgba(' . $single_overlay_color[0] . ',' . $single_overlay_color[1] . ',' . $single_overlay_color[2] . ',' . intval($overlay_opacity) / 100 . ')';
                     $gradient_style_color = '';
                 } else {
                     $thumb_overlay_color = $global_thumb_overlay_color;
                     $gradient_style_color = $global_gradient_style_color;
                 }
                 if (isset($single_title_color) && !empty($single_title_color)) {
                     $title_color = $single_title_color;
                 } else {
                     $title_color = $global_title_color;
                 }
                 if (isset($single_cat_color) && !empty($single_cat_color)) {
                     $cat_color = $single_cat_color;
                 } else {
                     $cat_color = $global_cat_color;
                 }
                 if (!empty($video_url)) {
                     $attachment_full_url = $video_url;
                     $mfp_class = 'mfp-iframe';
                 }
                 if ($link_to != 'external_url' && isset($open_with) && $open_with == 'lightbox-gallery') {
                     $thumb_class = 'be-lightbox-gallery';
                 } else {
                     if ($link_to != 'external_url' && isset($open_with) && $open_with == 'lightbox') {
                         $thumb_class = 'image-popup-vertical-fit single-image';
                     } else {
                         if ($link_to != 'external_url' && isset($open_with) && $open_with == 'none') {
                             $thumb_class = 'no-link';
                             $attachment_full_url = '#';
                         } else {
                             $thumb_class = '';
                             $mfp_class = '';
                             $attachment_full_url = $permalink;
                         }
                     }
                 }
                 if ($title_style == 'style5' || $title_style == 'style6') {
                     $trigger_animation = '';
                 } else {
                     $trigger_animation = 'animation-trigger';
                 }
                 $output .= '<div class="element be-hoverlay ' . $filter_classes . ' ' . $image_atts['class'] . ' ' . $image_atts['alt_class'] . ' ' . $hover_style . ' ' . $img_grayscale . ' ' . $title_style . '-title" style="margin-bottom: ' . $gutter_width . 'px !important;">';
                 $output .= '<div class="element-inner" style="margin-left: ' . $gutter_width . 'px;">';
                 $output .= '<a href="' . $attachment_full_url . '" class="thumb-wrap ' . $thumb_class . ' ' . $mfp_class . '" title="' . $attachment_info['title'] . '" ' . $target . '>';
                 $output .= '<div class="flip-wrap"><div class="flip-img-wrap ' . $image_effect . '-effect"><img src="' . $attachment_thumb_url . '" alt="' . $attachment_info['alt'] . '" /></div></div>';
                 $output .= '<div class="thumb-overlay "><div class="thumb-bg " style="background-color:' . $thumb_overlay_color . '; ' . $gradient_style_color . '">';
                 $output .= '<div class="thumb-title-wrap ">';
                 $output .= '<div class="thumb-title be-animate animated ' . $trigger_animation . '" data-animation-type="' . $title_animation_type . '" style="color: ' . $title_color . '; ' . $title_alignment_static . '">' . get_the_title() . '</div>';
                 $terms = be_themes_get_taxonomies_by_id(get_the_ID(), 'portfolio_categories');
                 if (!empty($terms) && (isset($cat_hide) && !$cat_hide)) {
                     $output .= '<div class="portfolio-item-cats be-animate animated ' . $trigger_animation . '" data-animation-type="' . $cat_animation_type . '" style="color: ' . $cat_color . '; ' . $title_alignment_static . '">';
                     $length = 1;
                     foreach ($terms as $term) {
                         $output .= '<span>' . $term->name . '</span>';
                         if (count($terms) != $length) {
                             $output .= '<span> &middot; </span>';
                         }
                         $length++;
                     }
                     $output .= '</div>';
                 }
                 $output .= '</div>';
                 $output .= '</div></div>';
                 //End Thumb Bg & Thumb Overlay
                 $output .= '</a>';
                 //End Thumb Wrap
                 if (isset($open_with) && $open_with == 'lightbox-gallery') {
                     $output .= '<div class="popup-gallery">';
                     $attachments = get_post_meta(get_the_ID(), 'be_themes_single_portfolio_slider_images');
                     if (!empty($attachments)) {
                         foreach ($attachments as $attachment_id) {
                             $attach_img = wp_get_attachment_image_src($attachment_id, 'full');
                             $video_url = get_post_meta($attachment_id, 'be_themes_featured_video_url', true);
                             $attachment_info = be_wp_get_attachment($attachment_id);
                             if ($video_url) {
                                 $url = $video_url;
                                 $mfp_class = 'mfp-iframe';
                             } else {
                                 $url = $attach_img[0];
                                 $mfp_class = 'mfp-image';
                             }
                             $output .= '<a href="' . $url . '" class="' . $mfp_class . '" title="' . $attachment_info['title'] . '"></a>';
                         }
                     }
                     $output .= '</div>';
                     //End Gallery
                 }
                 $output .= $like_button != 1 ? be_get_like_button(get_the_ID()) : '';
                 $output .= '</div>';
                 //End Element Inner
                 $output .= '</div>';
                 //End Element
             }
         }
     }
     wp_reset_postdata();
     $output .= '</div>';
     //end portfolio-container
     if ('-1' != $items_per_page && $the_query->found_posts - $items_per_page > 0) {
         $items_initial_load = $items_per_page;
         if ($pagination == 'infinite') {
             $output .= '<div class="trigger_infinite_scroll portfolio_infinite_scroll"></div>';
         } elseif ($pagination == 'loadmore') {
             $output .= '<div class="trigger_load_more portfolio_load_more" data-total-items="' . ($the_query->found_posts - $items_initial_load) . '"><a class="be-shortcode mediumbtn be-button rounded" href="#">' . __('Load More', 'be-themes') . '</a></div>';
         }
     }
     $output .= '</div></div>';
     //end portfolio
     return $output;
 }
示例#2
0
 function 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)
 {
     $output = '';
     if (!empty($images)) {
         foreach ($images as $image) {
             $image_atts = get_portfolio_image($image['id'], $col, $masonry);
             $attachment_info = be_wp_get_attachment($image['id']);
             $output .= '<div class="element be-hoverlay ' . $image_atts['class'] . ' ' . $image_atts['alt_class'] . ' ' . $hover_style . ' ' . $img_grayscale . '" style="margin-bottom: ' . $gutter_width . 'px !important;">';
             $output .= '<div class="element-inner" style="margin-left: ' . $gutter_width . 'px;">';
             // Changes for PhotoSwipe Gallery
             if ('photoswipe' == $lightbox_type && 'pintrest' != $image_source) {
                 $output .= '<a href="' . $image['full_image_url'] . '" data-size="' . $image['width'] . 'x' . $image['height'] . '" data-href="' . $image['full_image_url'] . '" class="thumb-wrap" title="' . $image['description'] . '">';
             } else {
                 $output .= '<a href="' . $image['full_image_url'] . '" data-href="' . $image['full_image_url'] . '" class="thumb-wrap image-popup-vertical-fit ' . $image['mfp_class'] . '" title="' . $image['caption'] . '">';
             }
             //End
             $output .= '<div class="flip-wrap"><div class="flip-img-wrap ' . $image_effect . '-effect"><img src="' . $image['thumbnail'] . '" alt="' . $attachment_info['alt'] . '" /></div></div>';
             $output .= '<div class="thumb-overlay"><div class="thumb-bg" style="background-color:' . $thumb_overlay_color . '; ' . $gradient_style_color . '">';
             $output .= '<div class="thumb-title-wrap display-table-cell vertical-align-middle align-center fadeIn animated">';
             $output .= '<div class="thumb-title"><i class="portfolio-overlay-icon"></i></div>';
             $output .= '</div>';
             $output .= '</div></div>';
             //End Thumb Bg & Thumb Overlay
             $output .= '</a>';
             //End Thumb Wrap
             $output .= $like_button != 1 && !empty($image['id']) ? be_get_like_button($image['id']) : '';
             $output .= '</div>';
             //End Element Inner
             $output .= '</div>';
             //End Element
         }
     }
     return $output;
 }
示例#3
0
 function get_gallery_image_from_source($source, $images = false, $lightbox_type)
 {
     $media = $return = array();
     global $be_themes_data;
     switch ($source['source']) {
         case 'instagram':
             $transient_var = 'transient_instagram_user_data_' . $source['account_name'] . '_' . $source['count'];
             $instagram_access_token = isset($be_themes_data['instagram_access_token']) && !empty($be_themes_data['instagram_access_token']) ? $be_themes_data['instagram_access_token'] : '336050189.5b9e1e6.b7004d62939049478de2390091d61b9e';
             $transient_media = get_transient($transient_var);
             if ($transient_media && isset($transient_media) && !empty($transient_media)) {
                 $media = unserialize($transient_media);
             } else {
                 $user_data = wp_remote_get('https://api.instagram.com/v1/users/search?q=' . $source['account_name'] . '&access_token=' . $instagram_access_token);
                 if (is_wp_error($user_data)) {
                     delete_transient($transient_var);
                     $return['error'] = '<b>' . __('Instagram Error : ', 'be-themes') . '</b>' . $user_data->error_message;
                     return $return;
                 } else {
                     $user_data = json_decode($user_data['body']);
                     $user_data_arr = $user_data->data;
                     foreach ($user_data_arr as $users) {
                         if ($users->username == $source['account_name']) {
                             $user_id = $users->id;
                             break;
                         }
                     }
                     if (isset($user_data->error_message) || !empty($user_data->error_message)) {
                         delete_transient($transient_var);
                         $return['error'] = '<b>' . __('Instagram Error : ', 'be-themes') . '</b>' . $user_data->error_message;
                         return $return;
                     }
                     if (isset($user_id) && !empty($user_id) && $user_id) {
                         $instagram_media = wp_remote_get('https://api.instagram.com/v1/users/' . $user_id . '/media/recent/?access_token=' . $instagram_access_token . '&count=' . $source['count']);
                         if (isset($instagram_media->error_message) || !empty($instagram_media->error_message)) {
                             delete_transient($transient_var);
                             $return['error'] = '<b>' . __('Instagram Error : ', 'be-themes') . '</b>' . $instagram_media->error_message;
                             return $return;
                         }
                         if ($instagram_media && isset($instagram_media) && !empty($instagram_media)) {
                             set_transient($transient_var, serialize($instagram_media), 60 * 60 * 24 * 2);
                             $media = $instagram_media;
                         }
                     }
                 }
             }
             if ($media && isset($media) && !empty($media)) {
                 $images = json_decode($media["body"]);
                 $images = $images->data;
                 foreach ($images as $key => $value) {
                     $temp_image_array = array();
                     $temp_image_array = array('thumbnail' => $value->images->standard_resolution->url, 'full_image_url' => $value->images->standard_resolution->url, 'mfp_class' => $lightbox_type == 'photoswipe' ? '' : 'mfp-image', 'caption' => !empty($value->caption->text) ? $value->caption->text : '', 'description' => !empty($value->caption->text) ? $value->caption->text : '', 'width' => $value->images->standard_resolution->width, 'height' => $value->images->standard_resolution->height, 'id' => '');
                     array_push($return, $temp_image_array);
                 }
             }
             return $return;
             break;
         case 'flickr':
             delete_transient('transient_flickr_user_data_' . $source['account_name'] . '_' . $source['count']);
             $transient_media = get_transient('transient_flickr_user_data_' . $source['account_name'] . '_' . $source['count']);
             if ($transient_media && isset($transient_media) && !empty($transient_media)) {
                 $media = unserialize($transient_media);
             } else {
                 $user_data = wp_remote_get('https://api.flickr.com/services/rest/?method=flickr.people.findByUsername&username='******'account_name'] . '&format=php_serial&api_key=85145f20ba1864d8ff559a3971a0a033');
                 $user_data = unserialize($user_data["body"]);
                 if (isset($user_data['stat']) && $user_data['stat'] == 'ok') {
                     if (isset($user_data["user"]["nsid"]) && !empty($user_data["user"]["nsid"]) && $user_data["user"]["nsid"]) {
                         $flickr_media = wp_remote_get('https://api.flickr.com/services/rest/?method=flickr.photos.search&user_id=' . $user_data["user"]["nsid"] . '&format=php_serial&api_key=85145f20ba1864d8ff559a3971a0a033&per_page=' . $source['count'] . '&page=1&extras=url_z,url_o');
                         $flickr_media = unserialize($flickr_media["body"]);
                         if (isset($flickr_media['stat']) && $flickr_media['stat'] == 'ok') {
                             set_transient('transient_flickr_user_data_' . $source['account_name'] . '_' . $source['count'], serialize($flickr_media), 60 * 60 * 1);
                             $media = $flickr_media;
                         } else {
                             $return['error'] = '<b>' . __('Flickr Error : ', 'be-themes') . '</b>' . __("Unknown Error", "be-themes");
                             return $return;
                         }
                     }
                 } else {
                     $return['error'] = '<b>' . __('Flickr Error : ', 'be-themes') . '</b>' . $user_data["message"];
                     return $return;
                 }
             }
             if ($media && isset($media) && !empty($media)) {
                 $images = $media['photos']['photo'];
                 foreach ($images as $key => $value) {
                     $temp_image_array = array();
                     $temp_image_array = array('thumbnail' => isset($value["url_z"]) && !empty($value["url_z"]) ? $value["url_z"] : $value["url_o"], 'full_image_url' => isset($value["url_z"]) && !empty($value["url_z"]) ? $value["url_z"] : $value["url_o"], 'mfp_class' => $lightbox_type == 'photoswipe' ? '' : 'mfp-image', 'caption' => !empty($value["title"]) ? $value["title"] : '', 'description' => !empty($value["title"]) ? $value["title"] : '', 'width' => isset($value["width_z"]) && !empty($value["width_z"]) ? $value["width_z"] : $value["width_o"], 'height' => isset($value["height_z"]) && !empty($value["height_z"]) ? $value["height_z"] : $value["height_o"], 'id' => '');
                     array_push($return, $temp_image_array);
                 }
             }
             return $return;
         case 'dribble':
             $transient_media = get_transient('transient_dribble_user_data_' . $source['account_name'] . '_' . $source['count']);
             if ($transient_media && isset($transient_media) && !empty($transient_media)) {
                 $media = unserialize($transient_media);
             } else {
                 $dribble_media = wp_remote_get('https://dribbble.com/' . $source['account_name'] . '/shots.json');
                 if (isset($dribble_media["response"]["message"]) && !empty($dribble_media["response"]["message"]) && $dribble_media["response"]["message"] == 'OK') {
                     $dribble_media = json_decode($dribble_media["body"]);
                     if ($dribble_media && isset($dribble_media) && !empty($dribble_media)) {
                         set_transient('transient_dribble_user_data_' . $source['account_name'] . '_' . $source['count'], serialize($dribble_media), 60 * 60 * 1);
                         $media = $dribble_media;
                     }
                 } else {
                     $return['error'] = '<b>' . __('Dribble Error : ', 'be-themes') . '</b>' . $dribble_media["response"]["message"];
                     return $return;
                 }
             }
             if ($media && isset($media) && !empty($media)) {
                 $images = $media->shots;
                 $i = 0;
                 foreach ($images as $key => $value) {
                     if ($i < $source['count']) {
                         $temp_image_array = array();
                         $temp_image_array = array('thumbnail' => $value->image_400_url, 'full_image_url' => $value->image_url, 'mfp_class' => $lightbox_type == 'photoswipe' ? '' : 'mfp-image', 'caption' => !empty($value->title) ? $value->title : '', 'description' => !empty($value->title) ? $value->title : '', 'width' => $value->width, 'height' => $value->height, 'id' => '');
                         array_push($return, $temp_image_array);
                         $i++;
                     }
                 }
             }
             return $return;
             break;
         case 'pintrest':
             require_once get_template_directory() . '/functions/Pintrest/Pinterest.class.php';
             $pinterest = new Pinterest($source['account_name']);
             $pinterest->itemsperpage = $source['count'];
             $pinsresult = $pinterest->getPins();
             foreach ($pinsresult["data"] as $pin) {
                 $bigimage = str_replace("237x", "736x", $pin->images->{'237x'}->url);
                 $temp_image_array = array();
                 $temp_image_array = array('thumbnail' => $bigimage, 'full_image_url' => $bigimage, 'mfp_class' => 'mfp-image', 'caption' => '', 'id' => '');
                 array_push($return, $temp_image_array);
             }
             return $return;
             break;
         default:
             if ($images) {
                 $images = explode(",", $images);
                 foreach ($images as $image) {
                     $temp_image_array = array();
                     $image_atts = get_portfolio_image($image, $source['col'], $source['masonry']);
                     $attachment_thumb = wp_get_attachment_image_src($image, $image_atts['size']);
                     $attachment_full = wp_get_attachment_image_src($image, 'full');
                     $attachment_thumb_url = $attachment_thumb[0];
                     $attachment_full_url = $attachment_full[0];
                     $video_url = get_post_meta($image, 'be_themes_featured_video_url', true);
                     $attachment_info = be_wp_get_attachment($image);
                     $mfp_class = $lightbox_type == 'photoswipe' ? '' : 'mfp-image';
                     if (!empty($video_url) && $lightbox_type != 'photoswipe') {
                         $attachment_full_url = $video_url;
                         $mfp_class = 'mfp-iframe';
                     }
                     $temp_image_array = array('thumbnail' => $attachment_thumb_url, 'full_image_url' => $attachment_full_url, 'mfp_class' => $mfp_class, 'caption' => $attachment_info['title'], 'description' => $attachment_info['description'], 'width' => $attachment_info['width'], 'height' => $attachment_info['height'], 'id' => $image);
                     array_push($return, $temp_image_array);
                 }
                 return $return;
             }
             break;
     }
 }
示例#4
0
function be_themes_get_ajax_full_screen_gutter_portfolio()
{
    extract($_POST);
    $output = '';
    $global_thumb_overlay_color = $thumb_overlay_color;
    $global_gradient_style_color = $gradient_style_color;
    if (isset($title_color) && !empty($title_color)) {
        $global_title_color = $title_color = $title_color;
    } else {
        $global_title_color = $title_color = '';
    }
    if (isset($cat_color) && !empty($cat_color)) {
        $global_cat_color = $cat_color = $cat_color;
    } else {
        $global_cat_color = $cat_color = '';
    }
    $filter_to_use = 'portfolio_' . $filter;
    $offset = $showposts * $paged - $showposts;
    if ($paged == 0) {
        $offset = 0;
    } else {
        $offset = $showposts * $paged - $showposts;
    }
    $selected_categorey = explode(',', $category);
    if ($category) {
        $args = array('post_type' => 'portfolio', 'posts_per_page' => intval($showposts), 'offset' => intval($offset), 'tax_query' => array(array('taxonomy' => 'portfolio_categories', 'field' => 'slug', 'terms' => $selected_categorey, 'operator' => 'IN')), 'orderby' => 'date', 'order' => 'DESC', 'status' => 'publish');
    } else {
        $args = array('post_type' => 'portfolio', 'posts_per_page' => intval($showposts), 'offset' => intval($offset), 'orderby' => 'date', 'order' => 'DESC', 'status' => 'publish');
    }
    $the_query = new WP_Query($args);
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $filter_classes = $permalink = '';
            $mfp_class = 'mfp-image';
            $post_terms = get_the_terms(get_the_ID(), $filter_to_use);
            if ($show_filters == 'yes' && is_array($post_terms)) {
                foreach ($post_terms as $term) {
                    $filter_classes .= $term->slug . " ";
                }
            } else {
                $filter_classes = '';
            }
            $attachment_id = get_post_thumbnail_id(get_the_ID());
            $image_atts = get_portfolio_image(get_the_ID(), $col, $masonry);
            $attachment_thumb = wp_get_attachment_image_src($attachment_id, $image_atts['size']);
            $attachment_full = wp_get_attachment_image_src($attachment_id, 'full');
            $attachment_thumb_url = $attachment_thumb[0];
            $attachment_full_url = $attachment_full[0];
            $video_url = get_post_meta($attachment_id, 'be_themes_featured_video_url', true);
            $visit_site_url = get_post_meta(get_the_ID(), 'be_themes_portfolio_external_url', true);
            $link_to = get_post_meta(get_the_ID(), 'be_themes_portfolio_link_to', true);
            $open_with = get_post_meta(get_the_ID(), 'be_themes_portfolio_single_page_style', true);
            $single_overlay_color = get_post_meta(get_the_ID(), 'be_themes_single_overlay_color', true);
            $single_overlay_opacity = get_post_meta(get_the_ID(), 'be_themes_single_overlay_color_opacity', true);
            $single_title_color = get_post_meta(get_the_ID(), 'be_themes_single_overlay_title_color', true);
            $single_cat_color = get_post_meta(get_the_ID(), 'be_themes_single_overlay_cat_color', true);
            $attachment_info = be_wp_get_attachment($attachment_id);
            if (!isset($visit_site_url) || empty($visit_site_url)) {
                $visit_site_url = '#';
            }
            $permalink = $link_to == 'external_url' ? $visit_site_url : get_permalink();
            if (isset($single_overlay_opacity) && !empty($single_overlay_opacity)) {
                $overlay_opacity = $single_overlay_opacity;
            } else {
                $overlay_opacity = 85;
            }
            if (isset($single_overlay_color) && !empty($single_overlay_color)) {
                $single_overlay_color = be_themes_hexa_to_rgb($single_overlay_color);
                $thumb_overlay_color = 'rgba(' . $single_overlay_color[0] . ',' . $single_overlay_color[1] . ',' . $single_overlay_color[2] . ',' . intval($overlay_opacity) / 100 . ')';
                $gradient_style_color = '';
            } else {
                $thumb_overlay_color = $global_thumb_overlay_color;
                $gradient_style_color = $global_gradient_style_color;
            }
            if (isset($single_title_color) && !empty($single_title_color)) {
                $title_color = $single_title_color;
            } else {
                $title_color = $global_title_color;
            }
            if (isset($single_cat_color) && !empty($single_cat_color)) {
                $cat_color = $single_cat_color;
            } else {
                $cat_color = $global_cat_color;
            }
            if (!empty($video_url)) {
                $attachment_full_url = $video_url;
                $mfp_class = 'mfp-iframe';
            }
            if (isset($open_with) && $open_with == 'lightbox-gallery') {
                $thumb_class = 'be-lightbox-gallery';
            } else {
                if (isset($open_with) && $open_with == 'lightbox') {
                    $thumb_class = 'image-popup-vertical-fit';
                } else {
                    if (isset($open_with) && $open_with == 'none') {
                        $thumb_class = 'no-link';
                        $attachment_full_url = '#';
                    } else {
                        $thumb_class = '';
                        $attachment_full_url = $permalink;
                    }
                }
            }
            if ($hover_style == 'style9-hover') {
                $trigger_animation = '';
            } else {
                $trigger_animation = 'animation-trigger';
            }
            $link_to_thumbnail = $attachment_full_url;
            $terms = be_themes_get_taxonomies_by_id(get_the_ID(), 'portfolio_categories');
            $element_classes = '';
            foreach ($terms as $term) {
                $element_classes .= $term->slug . ' ';
            }
            $output .= '<div class="element be-hoverlay ' . $filter_classes . ' ' . $element_classes . $image_atts['class'] . ' ' . $image_atts['alt_class'] . ' ' . $hover_style . ' ' . $img_grayscale . ' ' . $title_style . '-title" id="' . be_get_the_slug(get_the_ID()) . '" style="margin-bottom: ' . $gutter_width . 'px !important;">';
            $output .= '<div class="element-inner" style="margin-left: ' . $gutter_width . 'px;">';
            $output .= '<a href="' . $link_to_thumbnail . '" data-href="' . $attachment_full_url . '" class="thumb-wrap ' . $thumb_class . ' ' . $mfp_class . '" title="' . $attachment_info['title'] . '">';
            $output .= '<div class="flip-wrap"><div class="flip-img-wrap ' . $image_effect . '-effect"><img src="' . $attachment_thumb_url . '" alt /></div></div>';
            $output .= '<div class="thumb-overlay"><div class="thumb-bg" style="background-color:' . $thumb_overlay_color . '; ' . $gradient_style_color . '">';
            $output .= '<div class="thumb-title-wrap ">';
            $output .= '<div class="thumb-title be-animate animated ' . $trigger_animation . '" data-animation-type="' . $title_animation_type . '" style="color: ' . $title_color . ';">' . get_the_title() . '</div>';
            if (!empty($terms) && (isset($cat_hide) && !$cat_hide)) {
                $output .= '<div class="portfolio-item-cats be-animate animated ' . $trigger_animation . '" data-animation-type="' . $cat_animation_type . '" style="color: ' . $cat_color . ';">';
                $length = 1;
                foreach ($terms as $term) {
                    $output .= '<span>' . $term->name . '</span>';
                    if (count($terms) != $length) {
                        $output .= '<span>, </span>';
                    }
                    $length++;
                }
                $output .= '</div>';
            }
            $output .= '</div>';
            $output .= '</div></div>';
            //End Thumb Bg & Thumb Overlay
            $output .= '</a>';
            //End Thumb Wrap
            if (isset($open_with) && $open_with == 'lightbox-gallery') {
                $output .= '<div class="popup-gallery">';
                $attachments = get_post_meta(get_the_ID(), 'be_themes_single_portfolio_slider_images');
                if (!empty($attachments)) {
                    foreach ($attachments as $attachment_id) {
                        $attach_img = wp_get_attachment_image_src($attachment_id, 'full');
                        $video_url = get_post_meta($attachment_id, 'be_themes_featured_video_url', true);
                        $attachment_info = be_wp_get_attachment($attachment_id);
                        if ($video_url) {
                            $url = $video_url;
                            $mfp_class = 'mfp-iframe';
                        } else {
                            $url = $attach_img[0];
                            $mfp_class = 'mfp-image';
                        }
                        $output .= '<a href="' . $url . '" class="' . $mfp_class . '" title="' . $attachment_info['title'] . '"></a>';
                    }
                }
                $output .= '</div>';
                //End Gallery
            }
            $output .= be_get_like_button(get_the_ID());
            $output .= '</div>';
            //End Element Inner
            $output .= '</div>';
            //End Element
        }
        wp_reset_postdata();
        echo $output;
    } else {
        return 0;
    }
    die;
}