/** * Thumbnail HTML creation, base for index and other components * @param [type] $block_data * @param [type] $el_id * @param [type] $style_preset * @param [type] $layout * @param [type] $lightbox_classes * @param [type] $carousel_textual * @param boolean $with_html * @return [type] */ function uncode_create_single_block($block_data, $el_id, $style_preset, $layout, $lightbox_classes, $carousel_textual, $with_html = true) { $image_orig_w = $image_orig_h = $crop = $item_media = $media_code = $media_mime = $create_link = $title_link = $text_content = $media_attributes = $big_image = $lightbox_data = $single_height = $single_title = $nested = $media_poster = $dummy_oembed = $images_size = $single_family = $object_class = $single_back_color = $single_animation = $is_product = $single_icon = $single_text = $single_style = $single_elements_click = $overlay_color = $overlay_opacity = $tmb_data = ''; $media_type = 'image'; $multiple_items = false; if (isset($block_data['classes'])) { $block_classes = $block_data['classes']; } if (isset($block_data['tmb_data'])) { $tmb_data = $block_data['tmb_data']; } if (isset($block_data['media_id'])) { $item_thumb_id = $block_data['media_id']; } if (isset($block_data['images_size'])) { $images_size = $block_data['images_size']; } if (isset($block_data['single_style'])) { $single_style = $block_data['single_style']; } if (isset($block_data['single_text'])) { $single_text = $block_data['single_text']; } if (isset($block_data['single_elements_click'])) { $single_elements_click = $block_data['single_elements_click']; } if (isset($block_data['overlay_color'])) { $overlay_color = $block_data['overlay_color']; } if (isset($block_data['overlay_opacity'])) { $overlay_opacity = (int) $block_data['overlay_opacity'] / 100; } if (isset($block_data['single_width'])) { $single_width = $block_data['single_width']; } if (isset($block_data['single_height'])) { $single_height = $block_data['single_height']; } if (isset($block_data['single_back_color'])) { $single_back_color = $block_data['single_back_color']; } if (isset($block_data['single_title'])) { $single_title = $block_data['single_title']; } if (isset($block_data['single_icon'])) { $single_icon = $block_data['single_icon']; } if (isset($block_data['poster'])) { $media_poster = $block_data['poster']; } if (isset($block_data['title_classes'])) { $title_classes = !$block_data['title_classes'] ? array('h3') : $block_data['title_classes']; } if (isset($block_data['animation'])) { $single_animation = $block_data['animation']; } if (isset($block_data['product']) && $block_data['product'] === true) { $is_product = true; } else { $is_product = false; } if (!isset($block_classes)) { $block_classes = array(); } if (isset($block_data['link'])) { $create_link = is_array($block_data['link']) ? $block_data['link']['url'] : $block_data['link']; $title_link = $create_link; } $a_classes = array(); if (isset($block_data['link_class'])) { $a_classes[] = $block_data['link_class']; } /*** MEDIA SECTION ***/ if (isset($images_size) && $images_size !== '' && $style_preset !== 'metro') { switch ($images_size) { case 'one-one': $single_height = $single_width; break; case 'four-three': $single_height = $single_width / (4 / 3); break; case 'three-two': $single_height = $single_width / (3 / 2); break; case 'sixteen-nine': $single_height = $single_width / (16 / 9); break; case 'twentyone-nine': $single_height = $single_width / (21 / 9); break; case 'three-four': $single_height = $single_width / (3 / 4); break; case 'two-three': $single_height = $single_width / (2 / 3); break; case 'nine-sixteen': $single_height = $single_width / (9 / 16); break; } $block_classes[] = 'tmb-img-ratio'; } if (empty($item_thumb_id) || FALSE === get_post_status($item_thumb_id)) { $item_media = 'https://placeholdit.imgix.net/~text?txtsize=33&txt=media+not+available&w=500&h=500'; $media_attributes = ''; $image_orig_w = 500; $image_orig_h = 500; } else { /** get media info **/ $items_thumb_id = explode(',', $item_thumb_id); if (count($items_thumb_id) > 1) { if ($media_poster) { $media_attributes = uncode_get_media_info($items_thumb_id[0]); $media_metavalues = unserialize($media_attributes->metadata); $media_mime = $media_attributes->post_mime_type; } else { $multiple_items = true; } } else { $media_attributes = uncode_get_media_info($item_thumb_id); if (!isset($media_attributes)) { $media_attributes = new stdClass(); } $media_metavalues = unserialize($media_attributes->metadata); $media_mime = $media_attributes->post_mime_type; } /** check if open to lightbox **/ if ($lightbox_classes) { if (isset($lightbox_classes['data-title']) && $lightbox_classes['data-title'] === true) { $lightbox_classes['data-title'] = $media_attributes->post_title; } if (isset($lightbox_classes['data-caption']) && $lightbox_classes['data-caption'] === true) { $lightbox_classes['data-caption'] = $media_attributes->post_excerpt; } } /** shortcode carousel **/ if ($multiple_items) { $shortcode = '[vc_gallery nested="yes" el_id="gallery-' . rand() . '" medias="' . $item_thumb_id . '" type="carousel" style_preset="' . $style_preset . '" single_padding="0" thumb_size="' . $images_size . '" carousel_lg="1" carousel_md="1" carousel_sm="1" gutter_size="0" media_items="media" carousel_interval="0" carousel_dots="yes" carousel_dots_mobile="yes" carousel_autoh="yes" carousel_type="fade" carousel_nav="no" carousel_nav_mobile="no" carousel_dots_inside="yes" single_text="overlay" single_border="yes" single_width="' . $single_width . '" single_height="' . $single_height . '" single_text_visible="no" single_text_anim="no" single_overlay_visible="no" single_overlay_anim="no" single_image_anim="no"]'; $media_oembed = uncode_get_oembed($item_thumb_id, $shortcode, 'shortcode', false); $media_code = $media_oembed['code']; $media_type = $media_oembed['type']; if (($key = array_search('tmb-overlay-anim', $block_classes)) !== false) { unset($block_classes[$key]); } if (($key = array_search('tmb-overlay-text-anim', $block_classes)) !== false) { unset($block_classes[$key]); } if (($key = array_search('tmb-image-anim', $block_classes)) !== false) { unset($block_classes[$key]); } $image_orig_w = $single_width; $image_orig_h = $single_height; $object_class = 'nested-carousel object-size'; } else { /** This is a self-hosted image **/ if (strpos($media_mime, 'image/') !== false && $media_mime !== 'image/url' && isset($media_metavalues['width']) && isset($media_metavalues['height'])) { $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; /** check if open to lightbox **/ if ($lightbox_classes) { $big_image = uncode_resize_image($media_attributes->guid, $media_attributes->path, $image_orig_w, $image_orig_h, 12, null, false); $create_link = $big_image['url']; } /** calculate height ratio if masonry and thumb size **/ if ($style_preset === 'masonry') { if ($images_size !== '') { $crop = true; } else { $crop = false; } } else { $crop = true; } $resized_image = uncode_resize_image($media_attributes->guid, $media_attributes->path, $image_orig_w, $image_orig_h, $single_width, $single_height, $crop); $item_media = esc_attr($resized_image['url']); $image_orig_w = $resized_image['width']; $image_orig_h = $resized_image['height']; } else { if ($media_mime === 'oembed/svg') { $media_type = 'html'; $media_code = $media_attributes->post_content; $media_code = preg_replace('#\\s(id)="([^"]+)"#', ' $1="$2-' . rand() . '"', $media_code); if ($media_mime === 'oembed/svg') { $media_code = preg_replace('#\\s(xmlns)="([^"]+)"#', '', $media_code); $media_code = preg_replace('#\\s(xmlns:svg)="([^"]+)"#', '', $media_code); $media_code = preg_replace('#\\s(xmlns:xlink)="([^"]+)"#', '', $media_code); } /** This is an iframe **/ } else { if ($media_mime === 'oembed/iframe') { $media_type = 'other'; $media_code = $media_attributes->post_content; $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; } else { $object_class = 'object-size'; /** external image **/ if ($media_mime === 'image/url') { $item_media = $media_attributes->guid; $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; if ($lightbox_classes) { $create_link = $item_media; } } else { $media_oembed = uncode_get_oembed($item_thumb_id, $media_attributes->guid, $media_attributes->post_mime_type, $media_poster, $media_attributes->post_excerpt, $media_attributes->post_content); /** check if is an image oembed **/ if ($media_oembed['type'] === 'image') { $item_media = esc_attr($media_oembed['code']); $image_orig_w = $media_oembed['width']; $image_orig_h = $media_oembed['height']; $media_type = 'image'; if ($lightbox_classes) { $create_link = $media_oembed['code']; } } else { /** check if there is a poster **/ if (isset($media_oembed['poster']) && $media_oembed['poster'] !== '' && $media_poster) { /** calculate height ratio if masonry and thumb size **/ if ($style_preset === 'masonry') { if ($images_size !== '') { $crop = true; } else { $crop = false; } } else { $crop = true; } if (!empty($media_oembed['poster']) && $media_oembed['poster'] !== '') { $poster_attributes = uncode_get_media_info($media_oembed['poster']); $media_metavalues = unserialize($poster_attributes->metadata); $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; $resized_image = uncode_resize_image($poster_attributes->guid, $poster_attributes->path, $image_orig_w, $image_orig_h, $single_width, $single_height, $crop); $item_media = esc_attr($resized_image['url']); $image_orig_w = $resized_image['width']; $image_orig_h = $resized_image['height']; $media_type = 'image'; if ($lightbox_classes) { switch ($media_attributes->post_mime_type) { case 'oembed/twitter': case 'oembed/html': $big_image = uncode_resize_image($poster_attributes->guid, $poster_attributes->path, $image_orig_w, $image_orig_h, 12, null, false); $create_link = $big_image['url']; break; default: $create_link = $media_oembed['code']; break; } } } } else { $media_code = $media_oembed['code']; $media_type = $media_oembed['type']; $object_class = $media_oembed['class']; if ($style_preset === 'metro' || $images_size != '') { $image_orig_w = $single_width; $image_orig_h = $single_height; } else { $image_orig_w = $media_oembed['width']; $image_orig_h = $media_oembed['height']; } if (strpos($media_mime, 'audio/') !== false && isset($media_oembed['poster']) && $media_oembed['poster'] !== '') { $poster_attributes = uncode_get_media_info($media_oembed['poster']); $media_metavalues = unserialize($poster_attributes->metadata); $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; $resized_image = uncode_resize_image($poster_attributes->guid, $poster_attributes->path, $image_orig_w, $image_orig_h, $single_width, $single_height, $crop); $media_oembed['dummy'] = $image_orig_h / $image_orig_w * 100; } if ($image_orig_h === 0) { $image_orig_h = 1; } if ($media_oembed['dummy'] !== 0 && $style_preset !== 'metro') { $dummy_oembed = ' style="padding-top: ' . $media_oembed['dummy'] . '%"'; } if ($lightbox_classes && $media_type === 'image') { $create_link = $media_oembed['code']; } } } } } } } } } if ($item_media === '' && !isset($media_attributes->guid) && !$multiple_items) { $media_type = 'image'; $item_media = 'http://placehold.it/500&text=media+not+available'; $image_orig_w = 500; $image_orig_h = 500; } if (!$with_html) { return array('code' => $media_type === 'image' ? esc_url($item_media) : $media_code, 'type' => $media_type, 'width' => $image_orig_w, 'height' => $image_orig_h); } $entry = $inner_entry = ''; foreach ($layout as $key => $value) { switch ($key) { case 'icon': if ($single_icon !== '' && $single_text === 'overlay') { $inner_entry .= '<i class="' . $single_icon . ' t-overlay-icon"></i>'; } break; case 'title': $get_title = isset($media_attributes->post_title) ? $media_attributes->post_title : ''; if ($single_text === 'overlay' && $single_elements_click !== 'yes' || isset($media_attributes->team) && $media_attributes->team || $title_link === '#') { $print_title = $single_title ? $single_title : $media_attributes->post_title; if ($print_title !== '') { $inner_entry .= '<h3 class="t-entry-title ' . trim(implode(' ', $title_classes)) . '">' . $print_title . '</h3>'; } } else { $print_title = $single_title ? $single_title : $get_title; if ($print_title !== '') { $inner_entry .= '<h3 class="t-entry-title ' . trim(implode(' ', $title_classes)) . '"><a href="' . $title_link . '">' . $print_title . '</a></h3>'; } } break; case 'type': $inner_entry .= '<p class="t-entry-type"><span>' . ucfirst(get_post_type($block_data['id'])) . '</span></p>'; break; case 'category': case 'meta': if (isset($value[0]) && $value[0] === 'yesbg') { $with_bg = true; } else { $with_bg = false; } $inner_entry .= '<p class="t-entry-meta">'; if (is_sticky()) { $inner_entry .= '<span class="t-entry-category"><i class="fa fa-ribbon fa-push-right"></i>' . esc_html__('Sticky', 'uncode') . '</span>'; } if ($key === 'meta') { $year = get_the_time('Y'); $month = get_the_time('m'); $day = get_the_time('d'); $date = get_the_date('', $block_data['id']); $inner_entry .= '<span class="t-entry-category"><i class="fa fa-clock fa-push-right"></i><a href="' . get_day_link($year, $month, $day) . '">' . $date . '</a></span>'; } $categories_array = isset($block_data['single_categories_id']) ? $block_data['single_categories_id'] : array(); $cat_icon = false; $tag_icon = false; $cat_count = count($categories_array); $cat_counter = 0; foreach ($categories_array as $t_key => $tax) { $category = ''; $add_comma = true; $term_color = get_option('_uncode_taxonomy_' . $tax); $cat_classes = 't-entry-category'; if (isset($term_color['term_color']) && $term_color['term_color'] !== '' && $with_bg) { $term_color = 'text-' . $term_color['term_color'] . '-color'; } else { $term_color = ''; } if (isset($block_data['single_categories'][$t_key])) { $single_cat = $block_data['single_categories'][$t_key]; if (gettype($single_cat) !== 'string' && isset($single_cat['link'])) { $cat_link = $block_data['single_categories'][$t_key]['link']; if ($block_data['single_categories'][$t_key]['tax'] === 'category' && !$cat_icon) { $category .= '<i class="fa fa-archive2 fa-push-right"></i>'; $cat_icon = true; $add_comma = false; } if ($block_data['single_categories'][$t_key]['tax'] === 'post_tag' && !$tag_icon) { $category .= '<i class="fa fa-tag2 fa-push-right"></i>'; $tag_icon = true; $add_comma = false; } } else { $cat_link = $block_data['single_categories'][$t_key]; } $cat_link = str_replace('<a ', '<a class="' . $term_color . '" ', $cat_link); $category .= ($cat_counter !== 0 && $add_comma ? '<span class="cat-comma">,</span>' : '') . $cat_link; $add_comma = true; } else { $category = ''; } $inner_entry .= '<span class="' . $cat_classes . '">' . $category . '</span>'; $cat_counter++; $category = ''; } $inner_entry .= '</p>'; break; case 'date': $date = get_the_date('', $block_data['id']); $inner_entry .= '<p class="t-entry-meta">'; $inner_entry .= '<span class="t-entry-date">' . $date . '</span>'; $inner_entry .= '</p>'; break; case 'text': $post_format = get_post_format(); if (isset($value[0]) && $value[0] === 'full') { $block_text = apply_filters('the_content', ($post_format === 'link' ? '<i class="fa fa-link fa-push-right"></i>' : '') . get_the_content()); $block_text .= wp_link_pages(array('before' => '<div class="page-links">' . esc_html__('Pages:', 'uncode'), 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'echo' => 0)); } else { $block_text = get_post_field('post_excerpt', $block_data['id']); } if (isset($block_data['text_length']) && $block_data['text_length'] !== '') { $block_text = '<p>' . uncode_truncate($block_text, $block_data['text_length']) . '</p>'; } else { if (isset($value[1]) && !empty($value[1])) { $block_text = '<p>' . uncode_truncate($block_text, $value[1]) . '</p>'; } } if ($single_text === 'overlay' && $single_elements_click !== 'yes') { $inner_entry .= '<p class="t-entry-excerpt">' . preg_replace('/<\\/?a(.|\\s)*?>/', '', $block_text) . '</p>'; } else { if (isset($value[0]) && $value[0] === 'full') { $inner_entry .= $block_text; } else { $inner_entry .= '<p class="t-entry-excerpt">' . $block_text . '</p>'; } } break; case 'link': $btn_shape = ' btn-default'; if (isset($value[0]) && $value[0] !== 'default') { if ($value[0] === 'link') { $btn_shape = ' btn-link'; } else { $btn_shape = ' btn-default btn-' . $value[0]; } } if ($single_text === 'overlay' && $single_elements_click !== 'yes') { $inner_entry .= '<p class="t-entry-readmore"><span class="btn' . $btn_shape . '">Read More</span></p>'; } else { $inner_entry .= '<p class="t-entry-readmore"><a href="' . $create_link . '" class="btn' . $btn_shape . '">Read More</a></p>'; } break; case 'author': $author = get_post_field('post_author', $block_data['id']); $author_name = get_the_author_meta('display_name', $author); $author_link = get_author_posts_url($author); $inner_entry .= '<p class="t-entry-author">'; if ($single_text === 'overlay' && $single_elements_click !== 'yes') { $inner_entry .= get_avatar($author, 80) . '<span>' . esc_html__('by ', 'uncode') . $author_name . '</span>'; } else { $inner_entry .= '<a href="' . $author_link . '">' . get_avatar($author, 80) . '<span>' . esc_html__('by ', 'uncode') . $author_name . '</span></a>'; } $inner_entry .= '</p>'; break; case 'extra': $inner_entry .= '<p class="t-entry-comments entry-small"><span class="extras">'; if (function_exists('dot_irecommendthis')) { global $uncode_irecommendthis; if ($single_text === 'under') { $inner_entry .= $uncode_irecommendthis->dot_recommend($block_data['id'], true); } else { if ($single_elements_click === 'yes') { $inner_entry .= $uncode_irecommendthis->dot_recommend($block_data['id'], true); } else { $inner_entry .= $uncode_irecommendthis->dot_recommend($block_data['id'], false); } } } $num_comments = get_comments_number($block_data['id']); $entry_comments = '<i class="fa fa-speech-bubble"></i><span>' . $num_comments . ' ' . _nx('Comment', 'Comments', $num_comments, 'comments', 'uncode') . '</span>'; if ($single_text === 'overlay' && $single_elements_click !== 'yes') { $inner_entry .= '<span class="extras-wrap">' . $entry_comments . '</span>'; } else { $inner_entry .= '<a class="extras-wrap" href="' . get_comments_link($block_data['id']) . '" title="title">' . $entry_comments . '</a>'; } $inner_entry .= '<span class="extras-wrap"><i class="fa fa-watch"></i><span>' . uncode_estimated_reading_time($block_data['id']) . '</span></span></span></p>'; break; case 'price': global $woocommerce; if (class_exists('WooCommerce')) { $product = new WC_Product($block_data['id']); $inner_entry .= '<span class="price ' . trim(implode(' ', $title_classes)) . '">' . $product->get_price_html() . '</span>'; } break; case 'caption': if (isset($media_attributes->post_excerpt) && $media_attributes->post_excerpt !== '') { $inner_entry .= '<p class="t-entry-meta"><span>' . $media_attributes->post_excerpt . '</span></p>'; } break; case 'description': if (isset($media_attributes->post_content) && $media_attributes->post_content !== '') { $inner_entry .= '<p class="t-entry-excerpt">' . $media_attributes->post_content . '</p>'; } break; case 'team-social': if ($media_attributes->team) { $team_socials = explode("\n", $media_attributes->team_social); $inner_entry .= '<p class="t-entry-comments t-entry-member-social"><span class="extras">'; foreach ($team_socials as $key => $value) { if ($value !== '') { $get_host = parse_url($value); $host = str_replace("www.", "", $get_host['host']); $host = explode('.', $host); if ($host[0] === 'plus') { $host[0] = 'google-' . $host[0]; } $inner_entry .= '<a href="' . esc_url($value) . '" target="_blank"><i class="fa fa-' . esc_attr($host[0]) . '"></i></a>'; } } $inner_entry .= '</span></p>'; } break; case 'sep-one': case 'sep-two': $sep_class = isset($value[0]) && $value[0] === 'reduced' ? ' class="separator-reduced"' : ''; $inner_entry .= '<hr' . $sep_class . ' />'; break; } } if (isset($media_attributes->team) && $media_attributes->team) { $single_elements_click = 'yes'; } if (!empty($layout) && !(count($layout) === 1 && array_key_exists('media', $layout)) && $inner_entry !== '') { if ($single_text === 'under') { $entry .= '<div class="t-entry-text"> <div class="t-entry-text-tc ' . $block_data['text_padding'] . '">'; } $entry .= '<div class="t-entry">'; $entry .= $inner_entry; $entry .= '</div>'; if ($single_text === 'under') { $entry .= '</div> </div>'; } } if ($lightbox_classes) { $lightbox_data = ' ' . implode(' ', array_map(function ($v, $k) { return $k . '="' . $v . '"'; }, $lightbox_classes, array_keys($lightbox_classes))); $lightbox_data .= ' data-lbox="ilightbox_' . $el_id . '"'; $video_src = ''; if (isset($media_attributes->post_mime_type) && strpos($media_attributes->post_mime_type, 'video/') !== false) { $video_src .= 'html5video:{preload:\'true\','; $alt_videos = get_post_meta($item_thumb_id, "_uncode_video_alternative", true); if (!empty($alt_videos)) { foreach ($alt_videos as $key => $value) { $exloded_url = explode(".", strtolower($value)); $ext = end($exloded_url); if ($ext !== '') { $video_src .= $ext . ":'" . $value . "',"; } } } $video_src .= '},'; } $lightbox_data .= ' data-options="' . $video_src . 'thumbnail: \'' . $item_media . '\'"'; } $layoutArray = array_keys($layout); foreach ($layoutArray as $key => $value) { if ($value === 'icon') { unset($layoutArray[$key]); } } if (!array_key_exists('media', $layout)) { $block_classes[] = 'tmb-only-text'; $with_media = false; } else { $with_media = true; } if ($single_text === 'overlay') { $block_classes[] = 'tmb-media-first'; $block_classes[] = 'tmb-media-last'; $block_classes[] = 'tmb-content-overlay'; } else { $block_classes[] = 'tmb-content-under'; $layoutLast = (string) array_pop($layoutArray); if (($layoutLast === 'media' || $layoutLast === '') && $with_media) { $block_classes[] = 'tmb-media-last'; } else { $block_classes[] = 'tmb-media-first'; } } $media_alt = isset($media_attributes->alt) ? $media_attributes->alt : ''; if ($single_back_color === '') { $block_classes[] = 'tmb-no-bg'; } else { $single_back_color = ' style-' . $single_back_color . '-bg'; } $output = '<div class="' . implode(' ', $block_classes) . '"> <div class="' . ($nested !== 'yes' ? 't-inside' : '') . $single_back_color . $single_animation . '" ' . implode(' ', array_map(function ($v, $k) { return $k . '="' . $v . '"'; }, $tmb_data, array_keys($tmb_data))) . '>'; if ($single_text === 'under' && $layoutLast === 'media') { $output .= $entry; } if (array_key_exists('media', $layout) || $single_text === 'overlay') { $output .= '<div class="t-entry-visual"> <div class="t-entry-visual-tc"> <div class="t-entry-visual-cont">'; if ($style_preset === 'masonry' && ($images_size !== '' || ($single_text === 'under' || $single_elements_click !== 'yes')) && array_key_exists('media', $layout)) { if ($media_type === 'image' && $image_orig_w != 0 && $image_orig_h != 0) { $dummy_padding = round($image_orig_h / $image_orig_w * 100, 2); $output .= '<div class="dummy" style="padding-top: ' . $dummy_padding . '%;"></div>'; } } if (($single_text === 'under' || $single_elements_click !== 'yes') && $media_type === 'image') { if ($style_preset === 'masonry') { $a_classes[] = 'pushed'; } $data_values = isset($block_data['link']['target']) && !empty($block_data['link']['target']) && is_array($block_data['link']) ? ' target="' . trim($block_data['link']['target']) . '"' : ''; $output .= '<a href="' . ($media_type === 'image' ? $create_link : '') . '"' . (count($a_classes) > 0 ? ' class="' . trim(implode(' ', $a_classes)) . '"' : '') . $lightbox_data . $data_values . '>'; } $output .= '<div class="t-entry-visual-overlay"><div class="t-entry-visual-overlay-in ' . $overlay_color . '" style="opacity: ' . $overlay_opacity . ';"></div></div> <div class="t-overlay-wrap"> <div class="t-overlay-inner"> <div class="t-overlay-content"> <div class="t-overlay-text ' . $block_data['text_padding'] . '">'; if ($single_text === 'overlay') { $output .= $entry; } else { $output .= '<div class="t-entry t-single-line">'; if (array_key_exists('icon', $layout)) { if ($single_icon !== '') { $output .= '<i class="' . $single_icon . ' t-overlay-icon"></i>'; } } $output .= '</div>'; } $output .= '</div> </div> </div> </div>'; if (array_key_exists('media', $layout)) { if ($style_preset === 'metro') { if ($single_elements_click === 'yes' && $media_type === 'image') { $a_classes[] = 't-background-click'; $data_values = !empty($block_data['link']['target']) ? ' target="' . trim($block_data['link']['target']) . '"' : ''; $output .= '<a href="' . ($media_type === 'image' ? $create_link : '') . '"' . (count($a_classes) > 0 ? ' class="' . trim(implode(' ', $a_classes)) . '"' : '') . $lightbox_data . $data_values . '> <div class="t-background-cover" style="background-image:url(\'' . $item_media . '\')"></div> </a>'; } else { if ($media_type === 'image') { $output .= '<div class="t-background-cover" style="background-image:url(\'' . $item_media . '\')"></div>'; } else { $output .= '<div class="fluid-object ' . trim(implode(' ', $title_classes)) . ' ' . $object_class . '"' . $dummy_oembed . '>' . $media_code . '</div>'; } } } else { if ($media_type === 'image') { $output .= '<img src="' . $item_media . '" width="' . $image_orig_w . '" height="' . $image_orig_h . '" alt="' . $media_alt . '" />'; } else { $output .= '<div class="fluid-object ' . trim(implode(' ', $title_classes)) . ' ' . $object_class . '"' . $dummy_oembed . '>' . $media_code . '</div>'; } } } if (($single_text === 'under' || $single_elements_click !== 'yes') && $media_type === 'image') { $output .= '</a>'; } if ($is_product) { $product = wc_get_product($block_data['id']); $product_add_to_cart = sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="%s product_type_%s">%s</a>', esc_url($product->add_to_cart_url()), esc_attr($product->id), esc_attr($product->get_sku()), $product->is_purchasable() ? 'add_to_cart_button' : '', esc_attr($product->product_type), esc_html($product->add_to_cart_text())); $output .= '<div class="add-to-cart-overlay">' . $product_add_to_cart . '</div>'; } $output .= '</div> </div> </div>'; } if ($single_text === 'under' && $layoutLast !== 'media') { $output .= $entry; } $output .= '</div> </div>'; return $output; }
extract(shortcode_atts(array('url' => '', 'link' => '', 'target' => 'self', 'button_color' => 'default', 'size' => '', 'width' => '', 'outline' => '', 'wide' => 'no', 'icon' => '', 'icon_position' => 'left', 'icon_animation' => '', 'border_animation' => '', 'radius' => '', 'shadow' => '', 'italic' => '', 'display' => '', 'top_margin' => '', 'onclick' => '', 'rel' => '', 'media_lightbox' => '', 'css_animation' => '', 'animation_delay' => '', 'animation_speed' => '', 'el_class' => ''), $atts)); //parse link $link = $link == '||' ? '' : $link; $link = vc_build_link($link); $a_href = $link['url']; $a_title = $link['title']; $a_target = $link['target']; if ($media_lightbox !== '') { $media_attributes = uncode_get_media_info($media_lightbox); if (isset($media_attributes)) { $media_metavalues = unserialize($media_attributes->metadata); $media_mime = $media_attributes->post_mime_type; if (strpos($media_mime, 'image/') !== false && $media_mime !== 'image/url' && isset($media_metavalues['width']) && isset($media_metavalues['height'])) { $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; $big_image = uncode_resize_image($media_attributes->guid, $media_attributes->path, $image_orig_w, $image_orig_h, 12, null, false); $a_href = $big_image['url']; } else { if ($media_mime === 'image/url') { $a_href = $media_attributes->guid; } else { $media_oembed = uncode_get_oembed($media_lightbox, $media_attributes->guid, $media_attributes->post_mime_type, false, $media_attributes->post_excerpt, $media_attributes->post_content, true); if ($media_mime === 'oembed/html' || $media_mime === 'oembed/iframe') { $frame_id = 'frame-' . big_rand(); $a_href = '#' . $frame_id; echo '<div id="' . $frame_id . '" style="display: none;">' . $media_attributes->post_content . '</div>'; } else { $a_href = $media_oembed['code']; } } }
function __construct($type, $param) { global $LOGO, $metabox_data, $post, $menutype; $type = $type == '' ? 'hmenu-right' : $type; $vertical = strpos($type, 'vmenu') !== false || $type === 'menu-overlay' ? true : false; $social_html = $secondary_menu_html = $social_icon = $search = $main_absolute = $sub_absolute = $main_transparent = $sub_transparent = $stylemainback = $stylesecback = $mainborders = $main_width = $menu_bloginfo = ''; $logoDiv = '<a href="' . esc_url(home_url('/')) . '" class="navbar-brand" data-minheight="' . ($LOGO->logo_min == "" ? "20" : esc_attr($LOGO->logo_min)) . '">'; $logo_height = isset($LOGO->logo_height) ? $LOGO->logo_height : '20'; $logo_height = preg_replace('/[^0-9.]+/', '', $logo_height); if (isset($LOGO->logo_id)) { $logo_info = uncode_get_media_info($LOGO->logo_id); if (!empty($logo_info)) { if ($logo_info->post_mime_type === 'oembed/svg') { $media_code = $logo_info->post_content; $media_metavalues = unserialize($logo_info->metadata); $logo_ratio = $media_metavalues['width'] / $media_metavalues['height']; $media_code = preg_replace('#\\s(id)="([^"]+)"#', ' $1="$2-' . rand() . '"', $media_code); if ($logo_info->post_mime_type === 'oembed/svg') { $media_code = preg_replace('#\\s(xmlns)="([^"]+)"#', '', $media_code); $media_code = preg_replace('#\\s(xmlns:svg)="([^"]+)"#', '', $media_code); $media_code = preg_replace('#\\s(xmlns:xlink)="([^"]+)"#', '', $media_code); if ($menutype === 'menu-overlay') { $vmenu_position = ot_get_option('_uncode_vmenu_position'); if ($vmenu_position === 'left') { $media_code = str_replace('<svg ', '<svg preserveAspectRatio="xMaxYMin" ', $media_code); } else { $media_code = str_replace('<svg ', '<svg preserveAspectRatio="xMinYMin" ', $media_code); } } else { if ($vertical) { $vmenu_position = ot_get_option('_uncode_vmenu_position'); if ($vmenu_position === 'right') { $media_code = str_replace('<svg ', '<svg preserveAspectRatio="xMaxYMin" ', $media_code); } else { $media_code = str_replace('<svg ', '<svg preserveAspectRatio="xMinYMin" ', $media_code); } } else { $media_code = str_replace('<svg ', '<svg preserveAspectRatio="xMinYMin" ', $media_code); } } } $logoDiv .= '<div class="html-code" style="height: ' . $logo_height . 'px">'; $logoDiv .= '<canvas class="logo-canvas" height="' . round($logo_height) . '" width="' . round($logo_ratio * $logo_height) . '"></canvas>'; $logoDiv .= $media_code . '</div></a>'; } else { if ($logo_info->post_mime_type === 'oembed/html') { $logoDiv .= '<h1 class="text-logo h3" style="font-size:' . $logo_height . 'px;">' . esc_html($logo_info->post_content) . '</h1></a>'; } else { $logo_metavalues = unserialize($logo_info->metadata); $logo_resized = uncode_resize_image($logo_info->guid, $logo_info->path, $logo_metavalues['width'], $logo_metavalues['height'], round($logo_metavalues['width'] * $logo_height / $logo_metavalues['height']), $logo_height, false, true); if (!$vertical) { $logoDiv .= '<canvas class="logo-canvas" height="' . round($logo_resized['height']) . '" width="' . round($logo_resized['width']) . '" style="max-height: ' . $logo_height . 'px;"></canvas>'; } $logoDiv .= '<img src="' . $logo_resized['url'] . '" alt="logo" width="' . round($logo_resized['width']) . '" height="' . round($logo_resized['height']) . '" class="img-responsive" /></a>'; } } } else { $logoDiv .= '<h1 class="text-logo h3" style="font-size:' . $logo_height . 'px;">' . esc_html(get_bloginfo('name', 'display')) . '</h1></a>'; } } else { $logoDiv .= '<h1 class="text-logo h3" style="font-size:' . $logo_height . 'px;">' . esc_html(get_bloginfo('name', 'display')) . '</h1></a>'; } $socials = ot_get_option('_uncode_social_list', '', false, true); $boxed = ot_get_option('_uncode_boxed'); $menu_bloginfo = ot_get_option('_uncode_menu_bloginfo'); $post_type = isset($post->post_type) ? $post->post_type : 'post'; if (is_archive()) { $post_type .= '_index'; } $theme_locations = get_nav_menu_locations(); if (isset($metabox_data['_uncode_specific_menu'][0]) && $metabox_data['_uncode_specific_menu'][0] !== '') { $primary_menu = $metabox_data['_uncode_specific_menu'][0]; } else { $menu_generic = ot_get_option('_uncode_' . $post_type . '_menu'); if ($menu_generic !== '') { $primary_menu = $menu_generic; } else { $primary_menu = ''; if (isset($theme_locations['primary'])) { $menu_obj = get_term($theme_locations['primary'], 'nav_menu'); if (isset($menu_obj->name)) { $primary_menu = $menu_obj->name; } } } } if (isset($metabox_data['_uncode_specific_menu_width'][0]) && $metabox_data['_uncode_specific_menu_width'][0] !== '') { if ($metabox_data['_uncode_specific_menu_width'][0] === 'full') { $menu_full_width = true; } } else { $menu_generic_width = ot_get_option('_uncode_' . $post_type . '_menu_width'); if ($menu_generic_width === 'full') { $menu_full_width = true; } else { $menu_full = ot_get_option('_uncode_menu_full'); $menu_full_width = $menu_full !== 'on' ? false : true; } } if (!isset($menu_full_width)) { $menu_full_width = false; } $menu_sticky = ot_get_option('_uncode_menu_sticky') === 'on' ? ' menu-sticky' : ''; $menu_hide = ot_get_option('_uncode_menu_hide') === 'on' ? ' menu-hide' : ''; $menu_no_arrow = ot_get_option('_uncode_menu_no_arrows') === 'on' ? ' menu-no-arrows' : ''; $effects = ''; $menu_shrink = ot_get_option('_uncode_menu_shrink') === 'on' && $type !== 'hmenu-center' ? ' menu-shrink' : ''; $effects .= $menu_hide !== '' ? $menu_hide : ''; if ($boxed === 'on') { $effects .= ' limit-width'; } else { if (!$menu_full_width) { $main_width = ' limit-width'; } } $has_shadows = ot_get_option('_uncode_menu_shadows') == 'on' ? true : false; $has_borders = ot_get_option('_uncode_menu_borders') == 'on' ? true : false; $remove_shadow = isset($metabox_data['_uncode_specific_menu_no_shadow'][0]) && $metabox_data['_uncode_specific_menu_no_shadow'][0] === 'on' ? true : false; $menushadows = $has_shadows ? ' menu-shadows' : ''; $menushadows .= $remove_shadow ? ' force-no-shadows' : ''; $menuborders = $has_borders ? $vertical ? ' vmenu-borders' : ' menu-borders' : ' menu-no-borders'; $general_style = ot_get_option('_uncode_general_style'); $stylemain = ot_get_option('_uncode_primary_menu_style'); if ($stylemain === '') { $stylemain = $general_style; } $stylemainsubmenu = ot_get_option('_uncode_primary_submenu_style'); if ($stylemainsubmenu === '') { $stylemainsubmenu = $stylemain; } $stylesecmenu = ot_get_option('_uncode_secondary_menu_style'); if ($stylesecmenu === '') { $stylesecmenu = $general_style; } $transpmainheader = ot_get_option('_uncode_menu_bg_alpha_' . $stylemain); $stylemainback = ot_get_option('_uncode_menu_bg_color_' . $stylemain); $stylemainback = $stylemainback === '' ? ' style-' . $stylemain . '-bg' : ' style-' . $stylemainback . '-bg'; if ($type === 'menu-overlay') { $styleoverlay = ot_get_option('_uncode_overlay_menu_style'); $stylemainmenu = ' menu-' . $styleoverlay . ' submenu-' . $styleoverlay; $buttonstyle_primary = 'mobile-menu-button-' . $styleoverlay; } else { $stylemainmenu = ' menu-' . $stylemain . ' submenu-' . ($vertical ? $stylemain : $stylemainsubmenu); $buttonstyle_primary = 'mobile-menu-button-' . $stylemain; } $stylemainbackfull = $stylemainback . $menuborders . $menushadows; $stylemainback = ''; $menushadows = ''; $stylemaincombo = ' menu-primary' . $stylemainmenu; $stylesecback = ot_get_option('_uncode_secmenu_bg_color_' . $stylesecmenu); $stylesecback = $stylesecback === '' ? ' style-' . $stylesecmenu . '-bg' : ' style-' . $stylesecback . '-bg'; $stylesubstylemenu = ' menu-' . $stylesecmenu . ' submenu-' . $stylesecmenu; $stylesecbackfull = ''; $stylesecback = $stylesecback; $stylesubcombo = ' menu-secondary' . $stylesubstylemenu; if ($transpmainheader !== '100') { $remove_transparency = false; if (isset($metabox_data['_uncode_specific_menu_opaque'][0]) && $metabox_data['_uncode_specific_menu_opaque'][0] === 'on') { $remove_transparency = true; } else { $get_remove_transparency = ot_get_option('_uncode_' . $post_type . '_menu_opaque'); if ($get_remove_transparency === 'on') { $remove_transparency = true; } } if (!$remove_transparency) { $stylemaincombo .= ' menu-transparent'; if (!$vertical && $type !== 'offcanvas_head') { $stylemaincombo .= ' menu-add-padding'; } $main_absolute = ' menu-absolute'; } } $stylemaincombo .= ' style-' . $stylemain . '-original'; $woo_icon = ''; if (class_exists('WooCommerce')) { $woo_cart = ot_get_option('_uncode_woocommerce_cart'); $woo_icon = ot_get_option('_uncode_woocommerce_cart_icon'); if ($woo_cart === 'on' && $woo_icon !== '') { $woo_icon = uncode_add_cart_in_menu($woo_icon); } else { $woo_icon = ''; } } $search_active = ot_get_option('_uncode_menu_search'); if ($search_active === 'on' || $woo_icon !== '') { if ($vertical) { $search .= '<div class="menu-accordion">'; } $search .= '<ul class="menu-smart' . (is_rtl() ? ' sm-rtl' : '') . ' sm' . ($vertical ? ' sm-vertical' : ' menu-icons') . '">'; if ($search_active === 'on') { $search .= '<li class="search-icon style-' . $stylemain . ' dropdown">'; $search .= '<a href="#"' . (!$vertical ? ' class="trigger-overlay" data-area="search" data-container="box-container"' : '') . '> <i class="fa fa-search3"></i>'; if (!$vertical) { $search .= '<span class="desktop-hidden">'; } $search .= '<span>' . esc_html__('Search', 'uncode') . '</span>'; if (!$vertical) { $search .= '</span>'; } $search .= '<i class="fa fa-angle-down fa-dropdown' . (!$vertical ? ' desktop-hidden' : '') . '"></i> </a> <ul role="menu" class="drop-menu' . (!$vertical ? ' desktop-hidden' : '') . '"> <li> <form class="search" method="get" action="' . get_site_url() . '"> <input type="search" class="search-field" placeholder="' . esc_html__('Search…', 'uncode') . '" value="" name="s" title="Search for:" /> </form> </li> </ul>'; $search .= '</li>'; } $search .= $woo_icon; $search .= '</ul>'; if ($vertical) { $search .= '</div>'; } } if (!empty($socials) && strpos($type, 'vmenu') !== false) { $social_html .= '<div class="nav navbar-nav navbar-social"><ul class="menu-smart' . (is_rtl() ? ' sm-rtl' : '') . ' sm menu-social mobile-hidden tablet-hidden">'; foreach ($socials as $social) { $social_html .= '<li><a href="' . $social['_uncode_link'] . '"><i class="' . $social['_uncode_social'] . '"></i></a></li>'; } $social_html .= '</ul></div>'; } $no_secondary = ot_get_option('_uncode_menu_no_secondary'); $secondary_menu = ''; if ($no_secondary !== 'on' && isset($theme_locations['secondary'])) { $menu_obj = get_term($theme_locations['secondary'], 'nav_menu'); if (isset($menu_obj->name)) { $secondary_menu = $menu_obj->name; } $secondary_menu_html = wp_nav_menu(array("menu" => $secondary_menu, "theme_location" => "secondary", "container" => "div", "walker" => new wp_bootstrap_navwalker(), 'fallback_cb' => false, "container_class" => "navbar-topmenu navbar-nav-last", "menu_class" => "menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " menu-mini sm", "echo" => 0)); if ($menu_bloginfo !== '' || $secondary_menu_html !== '' && !empty($secondary_menu_html)) { $secondary_menu_html = '<div class="top-menu navbar' . $stylesubcombo . $stylesecbackfull . $stylesecback . '"> <div class="row-menu' . $main_width . '"> <div class="row-menu-inner"> <div class="col-lg-0 middle mobile-hidden tablet-hidden"> <div class="menu-bloginfo"> <div class="menu-bloginfo-inner style-' . $stylesecmenu . '"> ' . $menu_bloginfo . ' </div> </div> </div> <div class="col-lg-12 mobile-hidden tablet-hidden menu-horizontal"> ' . $secondary_menu_html . ' </div> </div> </div> </div>'; } } switch ($type) { /** * Horizontal menus * */ case 'hmenu-right': case 'hmenu-left': case 'hmenu-justify': $this->html = '<div class="menu-wrapper' . $menu_shrink . $menu_sticky . $menu_no_arrow . '"> ' . ($no_secondary !== 'on' ? $secondary_menu_html : '') . ' <header id="masthead" class="navbar' . $stylemaincombo . $main_absolute . ' menu-with-logo"> <div class="menu-container' . $effects . $stylemainbackfull . '"> <div class="row-menu' . $main_width . '"> <div class="row-menu-inner' . $stylemainback . '"> <div class="col-lg-0 logo-container megamenu-diff middle"> <div id="main-logo" class="navbar-header style-' . $stylemain . '"> ' . $logoDiv . ' </div> <div class="mmb-container"><div class="mobile-menu-button ' . $buttonstyle_primary . ' lines-button x2"><span class="lines"></span></div></div> </div> <div class="col-lg-12 main-menu-container middle"> <div class="menu-horizontal"> <div class="menu-horizontal-inner"> ' . wp_nav_menu(array("menu" => $primary_menu, "theme_location" => "primary", "container" => "div", "container_class" => "nav navbar-nav navbar-main " . ($search !== '' || $type === 'hmenu-justify' ? 'navbar-nav-first' : 'navbar-nav-last'), "menu_class" => "menu-primary-inner menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " sm", "fallback_cb" => "wp_bootstrap_navwalker::fallback", "walker" => new wp_bootstrap_navwalker(), "echo" => 0)) . ($search !== '' || $type === 'hmenu-justify' ? '<div class="nav navbar-nav navbar-nav-last">' . $search . '</div>' : ''); if ($no_secondary !== 'on') { $this->html .= '<div class="desktop-hidden"> ' . wp_nav_menu(array("menu" => $secondary_menu, "theme_location" => "secondary", "container" => "div", "container_class" => "menu-accordion", "menu_class" => "menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " sm sm-vertical", 'fallback_cb' => false, "walker" => new wp_bootstrap_navwalker(), "echo" => 0)) . '</div>'; } $this->html .= '</div> </div> </div> </div> </div> </div> </header> </div>'; break; /** * Center menu * */ /** * Center menu * */ case 'hmenu-center': $this->html = '<div class="menu-wrapper' . $menu_sticky . $menu_no_arrow . ' style-' . $stylemain . '-original">' . ($no_secondary !== 'on' ? $secondary_menu_html : '') . '<div class="navbar menu-secondary"> <div class="row-menu style-' . $stylemain . '-bg"> <div class="row-menu-inner"> <div class="col-lg-0 logo-container"> <div id="main-logo" class="navbar-header style-' . $stylemain . '"> ' . $logoDiv . ' </div> </div> </div> <div class="mmb-container"><div class="mobile-menu-button ' . $buttonstyle_primary . ' lines-button x2"><span class="lines"></span></div></div> </div> </div> <header id="masthead" class="navbar' . $stylemaincombo . '"> <div class="menu-container' . $effects . $stylemainbackfull . '"> <div class="row-menu' . $main_width . '"> <div class="row-menu-inner' . $stylemainback . '"> <div class="col-lg-12 main-menu-container middle"> <div class="menu-horizontal"> <div class="menu-horizontal-inner"> ' . wp_nav_menu(array("menu" => $primary_menu, "theme_location" => "primary", "container" => "div", "container_class" => "nav navbar-nav navbar-main " . ($search !== '' ? 'navbar-nav-first' : 'navbar-nav-last'), "menu_class" => "menu-primary-inner menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " sm", "fallback_cb" => "wp_bootstrap_navwalker::fallback", "walker" => new wp_bootstrap_navwalker(), "echo" => 0)) . ($search !== '' ? '<div class="nav navbar-nav navbar-nav-last">' . $search . '</div>' : ''); if ($no_secondary !== 'on') { $this->html .= '<div class="desktop-hidden"> ' . wp_nav_menu(array("menu" => $secondary_menu, "theme_location" => "secondary", "container" => "div", "container_class" => "menu-accordion", "menu_class" => "menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " sm sm-vertical", 'fallback_cb' => false, "walker" => new wp_bootstrap_navwalker(), "echo" => 0)) . '</div>'; } $this->html .= '</div> </div> </div> </div> </div> </div> </header> </div>'; break; case 'offcanvas_head': $this->html = '<div class="menu-wrapper' . $menu_shrink . $menu_sticky . '"> <div id="masthead" class="navbar' . $stylemaincombo . $main_absolute . ' menu-with-logo"> <div class="menu-container' . $effects . $stylemainbackfull . '"> <div class="row-menu row-offcanvas' . $main_width . '"> <div class="row-menu-inner row-brand' . $stylemainback . '"> <div class="col-lg-0 logo-container megamenu-diff middle"> <div id="main-logo" class="navbar-header style-' . $stylemain . '"> ' . $logoDiv . ' </div> <div class="mmb-container"><div class="' . ($param == 'menu-overlay' ? 'mobile-menu-button menu-button-overlay no-toggle' : 'mobile-menu-button menu-button-offcanvas') . ' ' . $buttonstyle_primary . ' lines-button x2 trigger-overlay" ' . ($param == 'menu-overlay' ? 'data-area="menu" data-container="main-container"' : '') . '><span class="lines"></span></div></div> </div> </div> </div> </div> </div> </div>'; break; /** * Overlay menu * */ /** * Overlay menu * */ case 'menu-overlay': $this->html = '<div class="overlay overlay-contentscale style-' . $styleoverlay . '-bg overlay-menu" data-area="menu" data-container="main-container"> <div class="main-header"> <div class="mmb-container mobile-hidden tablet-hidden"><div class="mobile-menu-button' . ($param === 'menu-overlay' ? ' menu-button-overlay' : ' menu-button-offcanvas') . ' ' . $buttonstyle_primary . ' lines-button x2 overlay-close close no-toggle" data-area="menu" data-container="main-container"' . ($param === 'menu-overlay' ? ' style="top: ' . $logo_height / 2 . 'px;"' : '') . '><span class="lines"></span></div></div> <div class="vmenu-container menu-container style-' . $styleoverlay . $menu_no_arrow . $stylemaincombo . '"> <div class="row row-parent"> <div class="row-inner"> <div class="menu-sidebar main-menu-container"> <div class="navbar-main"> <div class="menu-sidebar-inner"> ' . wp_nav_menu(array("menu" => $primary_menu, "theme_location" => "primary", "container" => "div", "container_class" => "menu-accordion", "menu_class" => "menu-primary-inner menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " sm sm-vertical", "fallback_cb" => "wp_bootstrap_navwalker::fallback", "walker" => new wp_bootstrap_navwalker(), "echo" => 0)); if ($search !== '') { $this->html .= $search; } if ($no_secondary !== 'on') { $this->html .= wp_nav_menu(array("menu" => $secondary_menu, "theme_location" => "secondary", "container" => "div", "items_wrap" => '<ul id="%1$s" class="%2$s">%3$s</ul>', "container_class" => "menu-accordion", "menu_class" => "menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " sm sm-vertical", 'fallback_cb' => false, "walker" => new wp_bootstrap_navwalker(), "echo" => 0)); } $this->html .= '</div> </div> </div> </div> </div> </div> </div> </div>'; break; /** * Vertical menus * */ /** * Vertical menus * */ default: $footer_copyright = ot_get_option('_uncode_footer_copyright'); $footer_text_content = ''; if ($footer_copyright !== 'off') { $footer_text_content .= '<p>© ' . date("Y") . ' ' . get_bloginfo('name') . ' <span style="white-space:nowrap;">' . esc_html__('All rights reserved', 'uncode') . '</span></p>'; } $footer_text = ot_get_option('_uncode_footer_text'); if ($footer_text !== '') { $footer_text_content .= do_shortcode(apply_filters('the_content', $footer_text)); } $this->html = '<div class="main-header"> <div class="vmenu-container menu-container ' . str_replace(' menu-transparent', '', $stylemaincombo) . $stylemainbackfull . $menu_no_arrow . '"> <div class="row row-parent' . $stylemainback . '">'; if ($menutype !== 'vmenu-offcanvas') { $this->html .= '<div class="row-inner restrict row-brand"> <div class="col-lg-12 logo-container"> <div class="style-' . $stylemain . '"> ' . $logoDiv . ' </div> <div class="mmb-container"><div class="mobile-menu-button ' . $buttonstyle_primary . ' lines-button x2"><span class="lines"></span></div></div> </div> </div>'; } $this->html .= '<div class="row-inner expand"> <div class="main-menu-container"> <div class="row-inner expand"> <div class="menu-sidebar navbar-main"> <div class="menu-sidebar-inner"> ' . wp_nav_menu(array("menu" => $primary_menu, "theme_location" => "primary", "container" => "div", "container_class" => "menu-accordion", "menu_class" => "menu-primary-inner menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " sm sm-vertical", "fallback_cb" => "wp_bootstrap_navwalker::fallback", "walker" => new wp_bootstrap_navwalker(), "echo" => 0)) . ' </div> </div> </div>'; if ($no_secondary !== 'on' || $social_html !== '' || $search !== '' || $footer_text_content !== '') { $this->html .= '<div class="row-inner restrict"> <div class="menu-sidebar"> <div class="menu-sidebar-inner"> ' . $search; if ($no_secondary !== 'on') { $this->html .= wp_nav_menu(array("menu" => $secondary_menu, "theme_location" => "secondary", "container" => "div", "items_wrap" => '<ul id="%1$s" class="%2$s">%3$s</ul>', "container_class" => "menu-accordion", "menu_class" => "menu-smart" . (is_rtl() ? ' sm-rtl' : '') . " sm sm-vertical", 'fallback_cb' => false, "walker" => new wp_bootstrap_navwalker(), "echo" => 0)); } if ($social_html !== '') { $this->html .= $social_html; } if ($footer_text_content !== '') { $this->html .= '<div class="mobile-hidden tablet-hidden vmenu-footer style-' . $stylemain . '">' . $footer_text_content . '</div>'; } $this->html .= '</div> </div> </div>'; } $this->html .= '</div> </div> </div> </div> </div>'; break; } }
* @version 2.0.14 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly global $post, $woocommerce, $product; ?> <div class="images"> <?php if (has_post_thumbnail()) { $image_title = esc_attr(get_the_title(get_post_thumbnail_id())); $image_attributes = uncode_get_media_info(get_post_thumbnail_id()); $image_metavalues = unserialize($image_attributes->metadata); $image_resized = uncode_resize_image($image_attributes->guid, $image_attributes->path, $image_metavalues['width'], $image_metavalues['height'], 5, null, false); $image_link = $image_attributes->guid; $image = '<img src="' . $image_resized['url'] . '" width="' . $image_resized['width'] . '" height="' . $image_resized['height'] . '" />'; $attachment_count = count($product->get_gallery_attachment_ids()); if ($attachment_count > 0) { global $gallery_id; $gallery_id = big_rand(); } echo apply_filters('woocommerce_single_product_image_html', sprintf('<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s" data-options="thumbnail: \'' . $image_resized['url'] . '\'" data-lbox="ilightbox_gallery-' . $gallery_id . '">%s</a>', $image_link, $image_title, $image), $post->ID); } else { echo apply_filters('woocommerce_single_product_image_html', sprintf('<img src="%s" alt="%s" />', wc_placeholder_img_src(), esc_html__('Placeholder', 'woocommerce')), $post->ID); } ?> <?php do_action('woocommerce_product_thumbnails');
/** * oEmbed helper * @param [int] $id * @param [string] $url * @return [array] */ function uncode_get_oembed($id, $url, $mime, $with_poster = false, $excerpt = null, $html = null, $lighbox_code = false) { global $front_background_colors; $object_class = $poster = $poster_id = ''; $oembed_size = uncode_get_dummy_size($id); $media_type = 'other'; if ($with_poster) { $poster = get_post_meta($id, "_uncode_poster_image", true); $poster_id = $poster; } switch ($mime) { case 'oembed/flickr': case 'oembed/Imgur': case 'oembed/photobucket': $media_type = 'image'; $media_oembed = wp_oembed_get($url); preg_match_all('/src="([^"]*)"/i', $media_oembed, $img_src); $media_oembed = isset($img_src[1][0]) ? str_replace('"', '', $img_src[1][0]) : ''; if ($mime === 'oembed/flickr') { $media_oembed = str_replace('_n.', '_b.', $media_oembed); } break; case 'oembed/instagram': $media_type = 'image'; $url = 'http://api.instagram.com/oembed?url=' . $url; $json = wp_remote_fopen($url); $json_data = json_decode($json, true); $media_oembed = $json_data['thumbnail_url']; $oembed_size['width'] = $oembed_size['height'] = 640; break; case 'oembed/youtube': if (isset($poster) && $poster !== '' && $with_poster || $lighbox_code) { $get_url = parse_url($url); if (isset($get_url['query'])) { $get_id = explode('=', $get_url['query']); $src_id = $get_id[1]; } else { $src_id = basename($url); } $media_oembed = 'https://www.youtube.com/embed/' . $src_id; } else { $media_oembed = wp_oembed_get($url); } break; case 'oembed/vimeo': if (isset($poster) && $poster !== '' && $with_poster || $lighbox_code) { $media_oembed = 'https://player.vimeo.com/video/' . basename($url); } else { $media_oembed = wp_oembed_get($url); $media_oembed = str_replace(basename($url), basename($url) . '?title=0&byline=0&portrait=0', $media_oembed); } break; case 'oembed/soundcloud': if (isset($poster) && $poster !== '' && $with_poster || $lighbox_code) { //Get the JSON data of song details with embed code from SoundCloud oEmbed $getValues = wp_remote_fopen('http://soundcloud.com/oembed?format=js&url=' . $url . '&iframe=true'); //Clean the Json to decode $decodeiFrame = substr($getValues, 1, -2); //json decode to convert it as an array $decodeiFrame = json_decode($decodeiFrame); preg_match('/src="([^"]+)"/', $decodeiFrame->html, $iframe_src); $media_oembed = $iframe_src[1]; } else { $accent_color = $front_background_colors['accent']; $accent_color = str_replace('#', '', $accent_color); $getValues = wp_remote_fopen('http://soundcloud.com/oembed?format=js&url=' . $url . '&iframe=true'); $decodeiFrame = substr($getValues, 1, -2); $decodeiFrame = json_decode($decodeiFrame); if (isset($decodeiFrame->html)) { preg_match('/src="([^"]+)"/', $decodeiFrame->html, $iframe_src); $iframe_url = str_replace('visual=true', 'visual=false', $iframe_src[1]); $media_oembed = '<iframe width="100%" scrolling="no" frameborder="no" src="' . $iframe_url . '&color=' . $accent_color . '&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false"></iframe>'; if (strpos($iframe_url, 'playlist') !== false) { $object_class = 'soundcloud-playlist'; } else { $object_class = 'soundcloud-single'; } } else { $media_oembed = '<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=media+not+available&w=500&h=500" />'; } } break; case 'oembed/spotify': if (isset($poster) && $poster !== '' && $with_poster || $lighbox_code) { $get_url = parse_url($url); $break_spotify = explode('/', $get_url['path']); $media_oembed = 'https://embed.spotify.com/?uri=spotify' . implode(':', $break_spotify); } else { $media_oembed = wp_oembed_get($url); $media_oembed = preg_replace('#\\s(width)="([^"]+)"#', '', $media_oembed); $media_oembed = preg_replace('#\\s(height)="([^"]+)"#', '', $media_oembed); $object_class = 'object-size spotify'; } break; case 'oembed/twitter': $url = 'https://api.twitter.com/1/statuses/oembed.json?id=' . basename($url); $json = wp_remote_fopen($url); $json_data = json_decode($json, true); $id = basename($json_data['url']); $html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $json_data['html']); $html = str_replace("— ", '', $html); $dom = new domDocument(); $dom->loadHTML($html); $dom->preserveWhiteSpace = false; $twitter_content = $dom->getElementsByTagname('blockquote'); $twitter_blockquote = ''; $twitter_footer = ''; foreach ($twitter_content as $item) { $twitter_content_inner = $item->getElementsByTagname('p'); foreach ($twitter_content_inner as $item_inner) { foreach ($item_inner->childNodes as $child) { $twitter_blockquote .= $child->ownerDocument->saveXML($child); } $item_inner->parentNode->removeChild($item_inner); } foreach ($item->childNodes as $child) { $twitter_footer .= $child->ownerDocument->saveXML($child); } $item->parentNode->removeChild($item); } $media_oembed = '<div class="twitter-item"> <div class="twitter-item-data"> <blockquote class="tweet-text pullquote"> <p>' . $twitter_blockquote . '</p>'; $media_oembed .= '<p class="twitter-footer"><i class="fa fa-twitter"></i><small>' . $twitter_footer . '</small></p>'; $media_oembed .= '</blockquote> </div> </div>'; $width = 1; $height = 0; $object_class = 'tweet object-size regular-text'; break; case 'oembed/html': $author = $author_img = ''; $width = 1; $height = 0; $poster = get_post_meta($id, "_uncode_poster_image", true); $poster_id = $poster; if ($poster !== '' && $with_poster || $lighbox_code) { $attr = array('class' => "avatar"); $author_img = wp_get_attachment_image($poster, 'thumbnail', false, $attr); $author_img = '<figure class="gravatar">' . $author_img . '</figure>'; } if ($excerpt) { $author = '<p><small>' . $excerpt . '</small></p>'; } $media_oembed = '<blockquote class="pullquote">' . $author_img . '<p>' . esc_html($html) . '</p>' . $author . '</blockquote>'; $object_class = 'regular-text object-size'; $poster = ''; break; case 'shortcode': $media_oembed = do_shortcode($url); $object_class = 'object-size shortcode'; break; default: if (strpos($mime, 'audio/') !== false) { if (isset($poster) && $poster !== '' && $with_poster || $lighbox_code) { $media_oembed = $url; } else { $object_class = 'object-size self-audio'; $media_oembed = apply_filters('the_content', '[audio src="' . $url . '"]'); $poster = get_post_meta($id, "_uncode_poster_image", true); $poster_id = $poster; } } else { if (strpos($mime, 'video/') !== false) { if (isset($poster) && $poster !== '' && $with_poster || $lighbox_code) { $media_oembed = $url; } else { $videos = array(); $exloded_url = explode(".", strtolower($url)); $ext = end($exloded_url); $videos[(string) $ext] = $url; $alt_videos = get_post_meta($id, "_uncode_video_alternative", true); if (!empty($alt_videos)) { foreach ($alt_videos as $key => $value) { $exloded_url = explode(".", strtolower($value)); $ext = end($exloded_url); $videos[(string) $ext] = $value; } } else { $videos = array('src' => '"' . $url . '"'); } $video_src = ''; foreach ($videos as $key => $value) { $video_src .= ' ' . $key . '=' . $value; } $object_class = 'object-size self-video'; $poster = get_post_meta($id, "_uncode_poster_image", true); $poster_url = ''; if (isset($poster) && $poster !== '') { $poster_attributes = uncode_get_media_info($poster); if (isset($poster_attributes->metadata)) { $media_metavalues = unserialize($poster_attributes->metadata); $image_orig_w = $media_metavalues['width']; $image_orig_h = $media_metavalues['height']; $resized_image = uncode_resize_image($poster_attributes->guid, $poster_attributes->path, $image_orig_w, $image_orig_h, 12, '', false); $poster_url = $resized_image['url']; } } if ($poster_url !== '') { $poster_url = ' poster="' . $poster_url . '"'; } $media_oembed = apply_filters('the_content', '[video' . $video_src . $poster_url . ']'); } } else { $media_oembed = wp_oembed_get($url); } } break; } if ($oembed_size['dummy'] == 0) { preg_match_all('/width="([^"]*)"/i', $media_oembed, $iWidth); $width = isset($iWidth[1][0]) ? $iWidth[1][0] : 1; preg_match_all('/height="([^"]*)"/i', $media_oembed, $iHeight); $height = isset($iHeight[1][0]) ? $iHeight[1][0] : 1; $oembed_size['dummy'] = round($height / $width * 100, 2); } return array('code' => $media_oembed, 'width' => $oembed_size['width'], 'height' => $oembed_size['height'], 'dummy' => $oembed_size['dummy'], 'type' => $media_type, 'class' => $object_class, 'poster' => $poster, 'poster_id' => $poster_id); }
$media_string = '<div class="uncode-single-media-wrapper single-advanced' . $shape . '">' . $media_html . '</div>'; } else { $style_preset = 'masonry'; if ($media_ratio !== '') { $block_data['images_size'] = $media_ratio; } $layout = array('media'); if (empty($media) || FALSE === get_post_status($media)) { $media_html = '<img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=media+not+available&w=500&h=500" />'; } else { $media_attributes = uncode_get_media_info($media); $media_metavalues = unserialize($media_attributes->metadata); $media_mime = $media_attributes->post_mime_type; /** check if open to lightbox **/ if ($lightbox_classes) { $big_image = uncode_resize_image($media_attributes->guid, $media_attributes->path, $media_metavalues['width'], $media_metavalues['height'], 12, null, false); $a_href = $big_image['url']; } $media_code = uncode_create_single_block($block_data, rand(), $style_preset, $layout, $lightbox_classes, $carousel_textual, false); if ($media_code['type'] === 'image') { $media_html = '<img src="' . $media_code['code'] . '" width="' . $media_code['width'] . '" height="' . $media_code['height'] . '" alt="" />'; } else { $media_html = $media_code['code']; } if ($media_code['type'] === 'other' && !$multiple) { $shape .= ' single-other'; } } if ($media_lightbox === 'yes') { $lightbox_data = ' ' . implode(' ', array_map(function ($v, $k) { return $k . '="' . $v . '"';