function webdados_fb_open_graph() { global $webdados_fb_open_graph_plugin_settings, $webdados_fb_open_graph_plugin_name, $webdados_fb_open_graph_plugin_version, $webdados_fb_open_graph_settings; //Upgrade webdados_fb_open_graph_upgrade(); //Get options - OLD (until 0.5.4) /*foreach($webdados_fb_open_graph_plugin_settings as $key) { $$key=get_option('wonderm00n_open_graph_'.$key); }*/ //Get options - NEW (after 0.5.4) extract($webdados_fb_open_graph_settings); //Also set Title Tag? $fb_set_title_tag = 0; //Additional images $fb_image_additional = array(); $fb_type = 'article'; if (is_singular()) { //It's a Post or a Page or an attachment page - It can also be the homepage if it's set as a page global $post; $fb_title = esc_attr(strip_tags(stripslashes($post->post_title))); //SubHeading if ($fb_show_subheading == 1) { if (webdados_fb_open_graph_subheadingactive()) { $fb_title .= ' - ' . get_the_subheading(); } } $fb_url = get_permalink(); if (is_front_page()) { /* Fix homepage type when it's a static page */ $fb_url = get_option('home') . (intval($fb_url_add_trailing) == 1 ? '/' : ''); $fb_type = trim($fb_type_homepage == '' ? 'website' : $fb_type_homepage); } if (trim($post->post_excerpt) != '') { //If there's an excerpt that's what we'll use $fb_desc = trim($post->post_excerpt); } else { //If not we grab it from the content $fb_desc = trim($post->post_content); } $fb_desc = intval($fb_desc_chars) > 0 ? mb_substr(esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))), 0, $fb_desc_chars) : esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))); if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) { $fb_image = webdados_fb_open_graph_post_image($fb_image_use_specific, $fb_image_use_featured, $fb_image_use_content, $fb_image_use_media, $fb_image_use_default, $fb_image); } //Author $author_id = $post->post_author; if ($author_id > 0) { $fb_author = get_the_author_meta('facebook', $author_id); $fb_author_meta = get_the_author_meta('display_name', $author_id); $fb_author_linkrelgp = get_the_author_meta('googleplus', $author_id); $fb_author_twitter = get_the_author_meta('twitter', $author_id); } else { $fb_author = ''; $fb_author_meta = ''; $fb_author_linkrelgp = ''; $fb_author_twitter = ''; } //Author - Hide on pages? if (is_page() && $fb_author_hide_on_pages == 1) { $fb_author = ''; $fb_author_meta = ''; $fb_author_linkrelgp = ''; $fb_author_twitter = ''; } //Published and Modified time if (is_singular('post')) { $fb_article_pub_date = get_the_date('c'); $fb_article_mod_date = get_the_modified_date('c'); } else { $fb_article_dates_show = 0; $fb_article_pub_date = ''; $fb_article_mod_date = ''; } //Categories if (is_singular('post')) { $cats = get_the_category(); if (!is_wp_error($cats) && (is_array($cats) && count($cats) > 0)) { $fb_sections = array(); foreach ($cats as $cat) { $fb_sections[] = $cat->name; } } } else { $fb_article_sections_show = 0; } //Business Directory Plugin if ($fb_show_businessdirectoryplugin == 1) { @(include_once ABSPATH . 'wp-admin/includes/plugin.php'); if (is_plugin_active('business-directory-plugin/wpbusdirman.php')) { global $wpbdp; //$bdpaction = _wpbdp_current_action(); $bdpaction = $wpbdp->controller->get_current_action(); switch ($bdpaction) { case 'showlisting': //Listing $listing_id = get_query_var('listing') ? wpbdp_get_post_by_slug(get_query_var('listing'))->ID : wpbdp_getv($_GET, 'id', get_query_var('id')); $bdppost = get_post($listing_id); $fb_title = esc_attr(strip_tags(stripslashes($bdppost->post_title))) . ' - ' . $fb_title; $fb_set_title_tag = 1; $fb_url = get_permalink($listing_id); if (trim($bdppost->post_excerpt) != '') { //If there's an excerpt that's what we'll use $fb_desc = trim($bdppost->post_excerpt); } else { //If not we grab it from the content $fb_desc = trim($bdppost->post_content); } $fb_desc = intval($fb_desc_chars) > 0 ? mb_substr(esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))), 0, $fb_desc_chars) : esc_attr(strip_tags(strip_shortcodes(stripslashes($fb_desc)))); if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) { $thumbdone = false; if (intval($fb_image_use_featured) == 1) { //Featured if ($id_attachment = get_post_thumbnail_id($bdppost->ID)) { //There's a featured/thumbnail image for this listing $fb_image = wp_get_attachment_url($id_attachment, false); $thumbdone = true; } } if (!$thumbdone) { //Main image loaded if ($thumbnail_id = wpbdp_listings_api()->get_thumbnail_id($bdppost->ID)) { $fb_image = wp_get_attachment_url($thumbnail_id, false); } } } break; case 'browsecategory': //Categories $term = get_term_by('slug', get_query_var('category'), wpbdp_categories_taxonomy()); $fb_title = esc_attr(strip_tags(stripslashes($term->name))) . ' - ' . $fb_title; $fb_set_title_tag = 1; $fb_url = get_term_link($term); if (trim($term->description) != '') { $fb_desc = trim($term->description); } break; case 'main': //Main page //No changes break; default: //No changes break; } } } } else { global $wp_query; //Other pages - Defaults $fb_title = esc_attr(strip_tags(stripslashes(get_bloginfo('name')))); //$fb_url=get_option('home').(intval($fb_url_add_trailing)==1 ? '/' : ''); //2013-11-4 changed from 'siteurl' to 'home' $fb_url = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //Not really canonical but will work for now //These are only used in posts/pages $fb_article_sections_show = 0; $fb_article_dates_show = 0; $fb_author_show = 0; $fb_author_show_meta = 0; $fb_author_show_linkrelgp = 0; $fb_author_show_twitter = 0; switch (trim($fb_desc_homepage)) { case 'custom': $fb_desc = esc_attr(strip_tags(stripslashes($fb_desc_homepage_customtext))); //WPML? if (function_exists('icl_object_id') && function_exists('icl_register_string')) { global $sitepress; if (ICL_LANGUAGE_CODE != $sitepress->get_default_language()) { $fb_desc = icl_t('wd-fb-og', 'wd_fb_og_desc_homepage_customtext', $fb_desc); } else { //We got it already } } break; default: $fb_desc = esc_attr(strip_tags(stripslashes(get_bloginfo('description')))); break; } if (is_category()) { $fb_title = esc_attr(strip_tags(stripslashes(single_cat_title('', false)))); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); $cat_desc = trim(esc_attr(strip_tags(stripslashes(category_description())))); if (trim($cat_desc) != '') { $fb_desc = $cat_desc; } } else { if (is_tag()) { $fb_title = esc_attr(strip_tags(stripslashes(single_tag_title('', false)))); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); $tag_desc = trim(esc_attr(strip_tags(stripslashes(tag_description())))); if (trim($tag_desc) != '') { $fb_desc = $tag_desc; } } else { if (is_tax()) { $fb_title = esc_attr(strip_tags(stripslashes(single_term_title('', false)))); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); //WooCommerce if (intval($fb_image_show) == 1 || intval($fb_image_show_schema) == 1 || intval($fb_image_show_twitter) == 1) { if (class_exists('woocommerce') && $fb_wc_usecategthumb == 1 && is_product_category()) { if ($thumbnail_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true)) { if ($image = wp_get_attachment_url($thumbnail_id)) { $fb_image = $image; } } } } } else { if (is_search()) { $fb_title = esc_attr(strip_tags(stripslashes(__('Search for') . ' "' . get_search_query() . '"'))); $fb_url = get_search_link(); } else { if (is_author()) { $fb_title = esc_attr(strip_tags(stripslashes(get_the_author_meta('display_name', get_query_var('author'))))); $fb_url = get_author_posts_url(get_query_var('author'), get_query_var('author_name')); } else { if (is_archive()) { if (is_day()) { $fb_title = esc_attr(strip_tags(stripslashes(get_query_var('day') . ' ' . single_month_title(' ', false) . ' ' . __('Archives')))); $fb_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')); } else { if (is_month()) { $fb_title = esc_attr(strip_tags(stripslashes(single_month_title(' ', false) . ' ' . __('Archives')))); $fb_url = get_month_link(get_query_var('year'), get_query_var('monthnum')); } else { if (is_year()) { $fb_title = esc_attr(strip_tags(stripslashes(get_query_var('year') . ' ' . __('Archives')))); $fb_url = get_year_link(get_query_var('year')); } } } } else { if (is_front_page()) { $fb_url = get_option('home') . (intval($fb_url_add_trailing) == 1 ? '/' : ''); $fb_type = trim($fb_type_homepage == '' ? 'website' : $fb_type_homepage); } else { //Others... Defaults already set up there } } } } } } } } //If no description let's just add the title if (trim($fb_desc) == '') { $fb_desc = $fb_title; } //YOAST? if ($fb_show_wpseoyoast == 1) { if (defined('WPSEO_VERSION')) { $wpseo = WPSEO_Frontend::get_instance(); //App ID - From our plugin //Admin ID - From our plugin //Locale - From our plugin //Sitename - From our plugin //Title - From WPSEO $fb_title = strip_tags($wpseo->title(false)); //Title - SubHeading plugin if ($fb_show_subheading == 1) { if (webdados_fb_open_graph_subheadingactive()) { $fb_title .= ' - ' . get_the_subheading(); } } //URL - From WPSEO $fb_url = $wpseo->canonical(false); //Description - From WPSEO or our plugin $fb_desc_temp = $wpseo->metadesc(false); $fb_desc = strip_tags(trim($fb_desc_temp) != '' ? trim($fb_desc_temp) : $fb_desc); //Image - From our plugin } } //WooCommerce - Additional product images? if (intval($fb_image_show) == 1 && class_exists('woocommerce') && $fb_wc_useproductgallery == 1 && is_product()) { global $post; $product = new WC_Product($post->ID); if ($attachment_ids = $product->get_gallery_attachment_ids()) { foreach ($attachment_ids as $attachment_id) { if ($image_link = wp_get_attachment_url($attachment_id)) { if (trim($image_link) != '') { $fb_image_additional[] = trim($image_link); } } } } } //Apply Filters $fb_title = apply_filters('fb_og_title', $fb_title); $fb_desc = apply_filters('fb_og_desc', $fb_desc); $fb_image = apply_filters('fb_og_image', $fb_image); $fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional); $fb_locale = apply_filters('fb_og_locale', $fb_locale); $fb_image_size = false; if (intval($fb_image_show) == 1 && trim($fb_image) != '') { if (intval($fb_image_size_show) == 1) { if (isset($GLOBALS['webdados_fb_img_size'])) { //Already fetched $fb_image_size = $GLOBALS['webdados_fb_img_size']; } else { $fb_image_size = webdados_fb_open_graph_getimagesize($fb_image); } } } else { $fb_image_size_show = 0; } //No spaces on URLs if (isset($fb_url) && trim($fb_url) != '') { $fb_url = str_replace(' ', '%20', trim($fb_url)); } if (isset($fb_publisher) && trim($fb_publisher) != '') { $fb_publisher = str_replace(' ', '%20', trim($fb_publisher)); } if (isset($fb_publisher_schema) && trim($fb_publisher_schema) != '') { $fb_publisher_schema = str_replace(' ', '%20', trim($fb_publisher_schema)); } if (isset($fb_author) && trim($fb_author) != '') { $fb_author = str_replace(' ', '%20', trim($fb_author)); } if (isset($fb_author_linkrelgp) && trim($fb_author_linkrelgp) != '') { $fb_author_linkrelgp = str_replace(' ', '%20', trim($fb_author_linkrelgp)); } if (isset($fb_image) && trim($fb_image) != '') { $fb_image = str_replace(' ', '%20', trim($fb_image)); } if (isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)) { foreach ($fb_image_additional as $key => $value) { $fb_image_additional[$key] = str_replace(' ', '%20', trim($value)); } } $html = ' <!-- START - ' . $webdados_fb_open_graph_plugin_name . ' ' . $webdados_fb_open_graph_plugin_version . ' --> '; if (intval($fb_app_id_show) == 1 && trim($fb_app_id) != '') { $html .= '<meta property="fb:app_id" content="' . trim(esc_attr($fb_app_id)) . '"/> '; } if (intval($fb_admin_id_show) == 1 && trim($fb_admin_id) != '') { $html .= '<meta property="fb:admins" content="' . trim(esc_attr($fb_admin_id)) . '"/> '; } if (intval($fb_locale_show) == 1) { $html .= '<meta property="og:locale" content="' . trim(esc_attr(trim($fb_locale) != '' ? trim($fb_locale) : trim(get_locale()))) . '"/> '; } if (intval($fb_sitename_show) == 1) { $html .= '<meta property="og:site_name" content="' . trim(esc_attr(get_bloginfo('name'))) . '"/> '; } if (intval($fb_title_show) == 1) { $html .= '<meta property="og:title" content="' . trim(esc_attr($fb_title)) . '"/> '; } if (intval($fb_set_title_tag) == 1) { //Does nothing so far. We try to create the <title> tag but it's too late now } if (intval($fb_title_show_schema) == 1) { $html .= '<meta itemprop="name" content="' . trim(esc_attr($fb_title)) . '"/> '; } if (intval($fb_title_show_twitter) == 1) { $html .= '<meta name="twitter:title" content="' . trim(esc_attr($fb_title)) . '"/> '; } if (intval($fb_url_show) == 1) { $html .= '<meta property="og:url" content="' . trim(esc_attr($fb_url)) . '"/> '; } if (intval($fb_url_show_twitter) == 1) { $html .= '<meta name="twitter:url" content="' . trim(esc_attr($fb_url)) . '"/> '; } if (intval($fb_url_canonical) == 1) { $html .= '<link rel="canonical" href="' . trim(esc_attr($fb_url)) . '"/> '; } if (intval($fb_type_show) == 1) { $html .= '<meta property="og:type" content="' . trim(esc_attr($fb_type)) . '"/> '; } if (intval($fb_article_dates_show) == 1 && trim($fb_article_pub_date) != '') { $html .= '<meta property="article:published_time" content="' . trim(esc_attr($fb_article_pub_date)) . '"/> '; } if (intval($fb_article_dates_show) == 1 && trim($fb_article_mod_date) != '') { $html .= '<meta property="article:modified_time" content="' . trim(esc_attr($fb_article_mod_date)) . '" /> <meta property="og:updated_time" content="' . trim(esc_attr($fb_article_mod_date)) . '" /> '; } if (intval($fb_article_sections_show) == 1 && isset($fb_sections) && is_array($fb_sections) && count($fb_sections) > 0) { foreach ($fb_sections as $fb_section) { $html .= '<meta property="article:section" content="' . trim(esc_attr($fb_section)) . '"/> '; } } if (intval($fb_publisher_show) == 1 && trim($fb_publisher) != '') { $html .= '<meta property="article:publisher" content="' . trim(esc_attr($fb_publisher)) . '"/> '; } if (intval($fb_publisher_show_schema) == 1 && trim($fb_publisher_schema) != '') { $html .= '<link rel="publisher" href="' . trim(esc_attr($fb_publisher_schema)) . '"/> '; } if (intval($fb_publisher_show_twitter) == 1 && trim($fb_publisher_twitteruser) != '') { $html .= '<meta name="twitter:site" content="@' . trim(esc_attr($fb_publisher_twitteruser)) . '"/> '; } if (intval($fb_author_show) == 1 && $fb_author != '') { $html .= '<meta property="article:author" content="' . trim(esc_attr($fb_author)) . '"/> '; } if (intval($fb_author_show_meta) == 1 && $fb_author_meta != '') { $html .= '<meta name="author" content="' . trim(esc_attr($fb_author_meta)) . '"/> '; } if (intval($fb_author_show_linkrelgp) == 1 && trim($fb_author_linkrelgp) != '') { $html .= '<link rel="author" href="' . trim(esc_attr($fb_author_linkrelgp)) . '"/> '; } if (intval($fb_author_show_twitter) == 1 && (trim($fb_author_twitter) != '' || trim($fb_publisher_twitteruser) != '')) { $html .= '<meta name="twitter:creator" content="@' . trim(esc_attr(trim($fb_author_twitter) != '' ? trim($fb_author_twitter) : trim($fb_publisher_twitteruser))) . '"/> '; } if (intval($fb_desc_show) == 1) { $html .= '<meta property="og:description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } if (intval($fb_desc_show_meta) == 1) { $html .= '<meta name="description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } if (intval($fb_desc_show_schema) == 1) { $html .= '<meta itemprop="description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } if (intval($fb_desc_show_twitter) == 1) { $html .= '<meta name="twitter:description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } if (intval($fb_image_show) == 1 && trim($fb_image) != '') { $html .= '<meta property="og:image" content="' . trim(esc_attr($fb_image)) . '"/> '; } if (intval($fb_image_show) == 1 && isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) > 0) { foreach ($fb_image_additional as $fb_image_additional_temp) { $html .= '<meta property="og:image" content="' . trim(esc_attr($fb_image_additional_temp)) . '"/> '; } } else { //We only show the image size if we only have one image if (intval($fb_image_size_show) == 1 && isset($fb_image_size) && is_array($fb_image_size) != '') { $html .= '<meta property="og:image:width" content="' . intval(esc_attr($fb_image_size[0])) . '"/> <meta property="og:image:height" content="' . intval(esc_attr($fb_image_size[1])) . '"/> '; } } if (intval($fb_image_show_schema) == 1 && trim($fb_image) != '') { $html .= '<meta itemprop="image" content="' . trim(esc_attr($fb_image)) . '"/> '; } if (intval($fb_image_show_twitter) == 1 && trim($fb_image) != '') { $html .= '<meta name="twitter:image:src" content="' . trim(esc_attr($fb_image)) . '"/> '; } if (intval($fb_title_show_twitter) == 1 || intval($fb_url_show_twitter) == 1 || $fb_author_show_twitter == 1 || $fb_publisher_show_twitter == 1 || $fb_image_show_twitter == 1) { $html .= '<meta name="twitter:card" content="' . trim(esc_attr($fb_twitter_card_type)) . '"/> '; } $html .= '<!-- END - ' . $webdados_fb_open_graph_plugin_name . ' --> '; echo $html; }
function mg_lightbox($post_id, $prev_item = false, $next_item = false) { include_once MG_DIR . '/functions.php'; $post_data = get_post($post_id); $GLOBALS['post'] = $post_data; // post type and layout if ($post_data->post_type == 'product') { // simulate standard type and add flag $wc_prod = new WC_Product($post_id); $wc_gallery = $wc_prod->get_gallery_attachment_ids(); $type = is_array($wc_gallery) && count($wc_gallery) > 0 ? 'img_gallery' : 'single_img'; } else { $type = get_post_meta($post_id, 'mg_main_type', true); $wc_prod = false; } // layout $layout = get_post_meta($post_id, 'mg_layout', true); $touchswipe = get_option('mg_lb_touchswipe') ? 'mg_touchswipe' : ''; $img_max_h = (int) get_post_meta($post_id, 'mg_img_maxheight', true); $item_title = $post_data->post_title; // canvas color for TT $tt_canvas = substr(get_option('mg_item_bg_color', '#ffffff'), 1); // maxwidth control $lb_max_w = (int) get_option('mg_item_maxwidth', 960); if ($lb_max_w == 0) { $lb_max_w = 960; } // Thumb center $tt_center = get_post_meta($post_id, 'mg_thumb_center', true) ? get_post_meta($post_id, 'mg_thumb_center', true) : 'c'; // lightbox max width for the item $fc_max_w = (int) get_post_meta($post_id, 'mg_lb_max_w', true); if (!$fc_max_w || $fc_max_w < 280) { $fc_max_w = false; } // item featured image for socials $fi_img_id = get_post_thumbnail_id($post_id); $fi_src = wp_get_attachment_image_src($fi_img_id, 'medium'); $fi_src_pt = wp_get_attachment_image_src($fi_img_id, 'full'); // pinterest - use full one /////////////////////////// // TYPES if ($type == 'single_img') { $img_id = get_post_thumbnail_id($post_id); $featured = mg_preloader() . '<img src="' . mg_lb_image_optimizer($img_id, $layout, $img_max_h, $tt_center, $resize = 3) . '" alt="' . mg_sanitize_input(strip_tags($item_title)) . '" />'; } elseif ($type == 'img_gallery') { $slider_img = isset($wc_gallery) ? $wc_gallery : get_post_meta($post_id, 'mg_slider_img', true); $style = get_option('mg_slider_style', 'light'); $unique_id = uniqid(); $autoplay = get_post_meta($post_id, 'mg_slider_autoplay', true) ? 'true' : 'false'; // slider height $def_h_val = get_option('mg_slider_main_w_val', 55); $def_h_type = get_option('mg_slider_main_w_type', '%'); $h_val = get_post_meta($post_id, 'mg_slider_w_val', true); $h_type = get_post_meta($post_id, 'mg_slider_w_type', true); if (!$h_val) { $h_val = $def_h_val; } if (!$h_type) { $h_type = $def_h_type; } $height = $h_val . $h_type; // slider proportions parameter if (strpos($height, '%') !== false) { $val = (int) str_replace("%", "", $height) / 100; $proportions_param = 'asp-ratio="' . $val . '"'; $proportions_class = "mg_galleria_responsive"; $slider_h = ''; $stage_max_h = $val; } else { $proportions_param = ''; $proportions_class = ""; $slider_h = 'height: ' . $height . ';'; $stage_max_h = $h_val; } // images management $crop = get_post_meta($post_id, 'mg_slider_crop', true); if (!$crop) { $crop = 'true'; } // slider thumbs visibility $thumbs_visibility = get_post_meta($post_id, 'mg_slider_thumbs', true); $thumbs_class = $thumbs_visibility == 'yes' || $thumbs_visibility == 'always' ? 'mg_galleria_slider_show_thumbs' : ''; // thumbs CSS code if ($thumbs_visibility == 'always' || $thumbs_visibility == 'never') { $css_code = '.mg_galleria_slider_wrap .galleria-mg-toggle-thumb {display: none !important;}'; } else { $css_code = ''; } if (!$thumbs_visibility || $thumbs_visibility == 'no' || $thumbs_visibility == 'never') { $css_code .= '.mg_galleria_slider_wrap .galleria-thumbnails-container {opacity: 0; filter: alpha(opacity=0);}'; } $featured = ' <style type="text/css"> ' . $css_code . ' .mg_item_featured {max-height: 0px; overflow: hidden;} </style> <script type="text/javascript"> mg_galleria_img_crop = "' . $crop . '"; mg_slider_autoplay["#' . $unique_id . '"] = ' . $autoplay . '; </script> <div id="' . $unique_id . '" class="mg_galleria_slider_wrap mg_show_loader mg_galleria_slider_' . $style . ' ' . $thumbs_class . ' ' . $proportions_class . ' mgs_' . $post_id . ' noSwipe" style="width: 100%; ' . $slider_h . '" ' . $proportions_param . ' >'; if (is_array($slider_img)) { if (get_post_meta($post_id, 'mg_slider_random', true)) { shuffle($slider_img); } // woocommerce - if prepend first image if (isset($wc_gallery) && get_post_meta($post_id, 'mg_slider_add_featured', true)) { array_unshift($slider_img, $fi_img_id); } // compose slider structure foreach ($slider_img as $img_id) { // WPML integration - get translated ID if (function_exists('icl_object_id')) { $img_id = icl_object_id($img_id, 'attachment', true); } if (get_post_meta($post_id, 'mg_slider_captions', true) == 1) { $img_data = get_post($img_id); $caption = trim(strip_tags(apply_filters('the_content', $img_data->post_content), 'br')); $caption == '' ? $caption_code = '' : ($caption_code = $caption); } else { $caption_code = ''; } $img_url = mg_lb_image_optimizer($img_id, $layout, false, 'c', $resize = 3); $thumb = mg_thumb_src($img_id, 100, 69, $thumb_q = 85, 'c'); $featured .= ' <a href="' . $img_url . '"> <img src="' . mg_sanitize_input($thumb) . '" data-big="' . $img_url . '" data-description="' . mg_sanitize_input($caption_code) . '" /> </a>'; } } $featured .= '<div style="clear: both;"></div> </div>'; // slider wrap closing // slider init $featured .= '<script type="text/javascript"> jQuery(document).ready(function($) { if(typeof(mg_galleria_init) == "function") { mg_galleria_show("#' . $unique_id . '"); setTimeout(function() { mg_galleria_init("#' . $unique_id . '"); }, 150); } }); </script>'; } elseif ($type == 'video') { $src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full'); $video_url = get_post_meta($post_id, 'mg_video_url', true); $video_w = $layout == 'full' ? 960 : 960 * 0.675; $video_h = $video_w * 0.5600000000000001; // poster if (get_post_meta($post_id, 'mg_video_use_poster', true) == 1) { $img_id = get_post_thumbnail_id($post_id); $poster = true; $poster_h = $lb_max_w * 0.5600000000000001; $poster_img = mg_lb_image_optimizer($img_id, $layout, $poster_h, $tt_center, $resize = 1); } else { $poster = false; $poster_img = ''; } if (lcwp_video_embed_url($video_url) == 'wrong_url') { $autoplay = get_option('mg_video_autoplay') && !$poster ? 'autoplay="on"' : ''; // get video sources $ok_src = array(); $allowed = array('mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv'); $sources = explode(',', $video_url); foreach ($sources as $v_src) { $ext = substr(trim(lcwp_stringToExt($v_src)), 1); if (in_array($ext, $allowed)) { $ok_src[$ext] = trim($v_src); } } $man_src = array(); foreach ($ok_src as $v_type => $url) { $man_src[] = $v_type . '="' . $url . '"'; } if (count($ok_src) == 0) { $featured = '<p><em>Video extension not supported ..</em></p>'; } else { $poster_attr = !empty($poster_img) ? 'poster="' . $poster_img . '"' : ''; $featured = '<div id="mg_wp_video_wrap" class="mg_self-hosted-video">' . do_shortcode('[video ' . implode(' ', $man_src) . ' ' . $poster_attr . ' ' . $autoplay . ' preload="auto"][/video]') . '</div>'; $featured .= "\n\t\t\t\t</div>\n\t\t\t\t\n\t\t\t\t<link rel='stylesheet' id='mediaelement-css' href='" . includes_url() . "js/mediaelement/mediaelementplayer.min.css?ver=2.13.0' type='text/css' media='all' />\n\t\t\t\t<link rel='stylesheet' id='wp-mediaelement-css' href='" . includes_url() . "js/mediaelement/wp-mediaelement.css?ver=3.6' type='text/css' media='all' />\n\t\t\t\t\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t/* <![CDATA[ */\n\t\t\t\tvar mejsL10n = {'language':'en-US','strings':{\n\t\t\t\t\t'Close':'Close',\n\t\t\t\t\t'Fullscreen': '" . __('Fullscreen', 'mg_ml') . "',\n\t\t\t\t\t'Download File': '" . __('Download File', 'mg_ml') . "',\n\t\t\t\t\t'Download Video': '" . __('Download Video', 'mg_ml') . "',\n\t\t\t\t\t'Play\\/Pause': '" . __('Play\\/Pause', 'mg_ml') . "',\n\t\t\t\t\t'Mute Toggle': '" . __('Mute Toggle', 'mg_ml') . "',\n\t\t\t\t\t'None': '" . __('None', 'mg_ml') . "',\n\t\t\t\t\t'Turn off Fullscreen': '" . __('Turn off Fullscreen', 'mg_ml') . "',\n\t\t\t\t\t'Go Fullscreen': '" . __('Go Fullscreen', 'mg_ml') . "',\n\t\t\t\t\t'Unmute': '" . __('Unmute', 'mg_ml') . "',\n\t\t\t\t\t'Mute': '" . __('Mute', 'mg_ml') . "',\n\t\t\t\t\t'Captions\\/Subtitles': '" . __('Captions\\/Subtitles', 'mg_ml') . "'\n\t\t\t\t}};\n\t\t\t\t/* ]]> */\n\t\t\t\t</script>\n\t\t\t\t<script type='text/javascript' src='" . includes_url() . "js/mediaelement/mediaelement-and-player.min.js'></script>\n\t\t\t\t<script type='text/javascript'>\n\t\t\t\t/* <![CDATA[ */\n\t\t\t\tvar _wpmejsSettings = {'pluginPath':'" . str_replace('/', '\\/', includes_url()) . "js\\/mediaelement\\/'};\n\t\t\t\t/* ]]> */\n\t\t\t\t</script>\n\t\t\t\t\n\t\t\t\t<script type='text/javascript' src='" . includes_url() . "js/mediaelement/wp-mediaelement.js'></script>"; } } else { if ($poster) { $autop_url = lcwp_video_embed_url($video_url, true); $v_url = lcwp_video_embed_url($video_url, false); $ifp = mg_preloader() . '<div id="mg_ifp_ol" class="fa fa-play" style="display: none;"></div> <img src="' . $poster_img . '" alt="' . mg_sanitize_input(strip_tags($item_title)) . '" autoplay-url="' . $autop_url . '" style="display: none;" class="mg_lb_video_poster" />'; $poster_bg = 'style="background-image: url(' . $poster_img . ')"'; $vis = 'style="display: none;"'; } else { $ifp = ''; $autoplay = ''; $vis = ''; $poster_bg = ''; $v_url = lcwp_video_embed_url($video_url); } $featured = ' <div id="mg_lb_video_wrap" ' . $poster_bg . '> ' . $ifp . ' <iframe class="mg_video_iframe" width="' . $video_w . '" height="' . $video_h . '" src="' . $v_url . '" frameborder="0" allowfullscreen ' . $vis . '></iframe> </div> '; } } elseif ($type == 'audio') { // check for soundcloud embedding $soundcloud = get_post_meta($post_id, 'mg_soundcloud_url', true); if (!empty($soundcloud)) { $featured = mg_get_soundcloud_embed($soundcloud); } else { $img_id = get_post_thumbnail_id($post_id); $tracklist = get_post_meta($post_id, 'mg_audio_tracks', true); $tot = is_array($tracklist) ? count($tracklist) : 0; $tot == 1 || !get_option('mg_audio_tracklist') ? $tl_class = 'jp_hide_tracklist' : ($tl_class = 'jp_full_tracklist'); // inlude jplayer script $script_name = 'mg_pack.js'; //(get_option('mg_old_js_mode')) ? 'mg_pack.js' : 'mg_pack_old_js.js'; $featured = '<script type="text/javascript" src="' . MG_URL . '/js/jPlayer/' . $script_name . '"></script>'; $featured .= mg_preloader() . '<img src="' . mg_lb_image_optimizer($img_id, $layout, $img_max_h, $tt_center, $resize = 3) . '" alt="' . mg_sanitize_input(strip_tags($item_title)) . '" />'; $featured .= ' <div id="mg_audio_player_' . $post_id . '" class="jp-jplayer"></div> <div id="mg_audio_wrap_' . $post_id . '" class="jp-audio noSwipe" style="display: none;"> <div class="jp-type-playlist"> <div class="jp-gui jp-interface"> <div class="jp-cmd-wrap">'; if ($tot > 1) { $featured .= '<a href="javascript:;" class="jp-previous">previous</a>'; } $featured .= ' <a href="javascript:;" class="jp-play">play</a> <a href="javascript:;" class="jp-pause">pause</a>'; if ($tot > 1) { $featured .= '<a href="javascript:;" class="jp-next">next</a>'; } $featured .= ' <div class="jp-time-holder"> <div class="jp-current-time"></div> <span>/</span> <div class="jp-duration"></div> </div> <div class="jp-progress"> <div class="jp-seek-bar"> <div class="jp-play-bar"></div> </div> </div>'; $featured .= ' <div class="jp-volume-group"> <a href="javascript:;" class="jp-mute" title="mute">mute</a> <a href="javascript:;" class="jp-unmute" title="unmute">unmute</a> <div class="jp-volume-bar"> <div class="jp-volume-bar-value"></div> </div> </div> </div>'; $featured .= ' <div class="jp-track-title"> <div class="jp-playlist ' . $tl_class . '"> <ul> <li></li> </ul> </div> </div> </div> </div> </div>'; if (is_array($tracklist) && count($tracklist) > 0) { // js code $featured .= ' <script type="text/javascript"> jQuery(function(){ mg_lb_jplayer = function() { new jPlayerPlaylist({ jPlayer: "#mg_audio_player_' . $post_id . '", cssSelectorAncestor: "#mg_audio_wrap_' . $post_id . '", }, ['; $a = 1; foreach ($tracklist as $track) { $track_data = get_post($track); $tot > 1 ? $counter = '<em>' . $a . '/' . $tot . '</em>) ' : ($counter = ''); $track_json[] = ' { title:"' . $counter . addslashes($track_data->post_title) . '", mp3:"' . $track_data->guid . '" } '; $a++; } $featured .= implode(',', $track_json) . ' ], {'; // autoplay $autoplay = get_option('mg_audio_autoplay') ? 'autoPlay: true,' : ''; $featured .= ' playlistOptions: { ' . $autoplay . ' displayTime: 0, }, swfPath: "' . MG_URL . '/js/jPlayer/", supplied: "mp3" }); } }); </script> '; } } } // force the layout for the lightbox custom contents if ($type == 'lb_text') { $layout = 'full'; } /////////////////////////// // custom CSS to manage image's height if (($type == 'single_img' || $type == 'audio') && isset($img_max_h) && $img_max_h > 0) { ?> <style type="text/css"> .mg_item_featured { text-align: center; } .mg_item_featured .jp-audio { text-align: left; } .mg_item_featured > img { display: inline-block; margin: auto; width: auto !important; max-height: <?php echo $img_max_h; ?> px; } </style> <?php } /////////////////////////// // builder /*** lightbox command codes ***/ $cmd_mode = get_option('mg_lb_cmd_pos', 'inside'); ?> <div id="mg_inside_close" class="mg_close_lb" <?php if ($cmd_mode != 'inside' && $cmd_mode != 'ins_hidden') { echo 'style="display: none;"'; } ?> ></div> <div id="mg_lb_inside_nav" class="noSwipe" <?php if ($cmd_mode != 'inside') { echo 'style="display: none;"'; } ?> > <?php echo mg_lb_nav_code(array('prev' => $prev_item, 'next' => $next_item), 'inside'); ?> </div> <?php if ($cmd_mode != 'inside' && $cmd_mode != 'ins_hidden') { if ($cmd_mode == 'top') { $code = ' <div id="mg_top_close" class="mg_close_lb" style="display: none;"></div> <div id="mg_lb_top_nav" style="display: none;">' . mg_lb_nav_code(array('prev' => $prev_item, 'next' => $next_item), $cmd_mode) . '</div>'; } else { $code = ' <div id="mg_top_close" class="mg_close_lb" style="display: none;"></div>' . mg_lb_nav_code(array('prev' => $prev_item, 'next' => $next_item), $cmd_mode); } echo ' <script type="text/javascript"> jQuery("#mg_overlay_content").before("' . str_replace(array("\r", "\n", "\t", "\v"), '', str_replace('"', '\\"', $code)) . '"); jQuery("#mg_lb_top_nav, .mg_side_nav, #mg_top_close").fadeIn(350); if(navigator.appVersion.indexOf("MSIE 8.") != -1) { jQuery(".mg_side_nav > div").css("top", 0); } </script>'; } ?> <?php /*** internal contents ***/ ?> <div class="mg_layout_<?php echo $layout; ?> mg_lb_<?php echo $type; ?> "> <div> <?php if ($type != 'lb_text') { ?> <div class="mg_item_featured" <?php if ($fc_max_w) { echo 'rel="' . $fc_max_w . 'px"'; } ?> > <?php echo $featured; ?> </div> <?php } ?> <div class="mg_item_content"> <?php /* custom options - woocommerce attributes */ $opts = mg_lb_cust_opts_code($post_id, $type, $wc_prod); /* title and options wrap */ if ($layout == 'full' && !empty($opts)) { echo '<div class="mg_content_left">'; } echo '<h1 class="mg_item_title">' . apply_filters('the_title', $item_title) . '</h1>'; echo $opts; if ($layout == 'full' && !empty($opts)) { echo '</div>'; } ?> <div class="mg_item_text <?php if ($layout == 'full' && empty($cust_opt)) { echo 'mg_widetext'; } ?> "> <?php echo do_shortcode(wpautop(apply_filters('the_content', $post_data->post_content))); ?> <?php if ($wc_prod && !get_option('mg_wc_hide_add_to_cart')) { echo do_shortcode('[add_to_cart id="' . $post_id . '" style=""]'); } ?> </div> <?php // SOCIALS if (get_option('mg_facebook') || get_option('mg_twitter') || get_option('mg_pinterest')) { $dl_part = get_option('mg_disable_dl') ? '' : '#!mg_ld_' . $post_id; ?> <div id="mg_socials" class="mgls_<?php echo get_option('mg_lb_socials_style', 'squared'); ?> "> <ul> <?php if (get_option('mg_facebook')) { ?> <li id="mg_fb_share"> <a onClick="window.open('https://www.facebook.com/dialog/feed?app_id=425190344259188&display=popup&name=<?php echo urlencode(get_the_title($post_id)); ?> &description=<?php echo urlencode(substr(strip_tags(strip_shortcodes(get_post_field('post_content', $post_id))), 0, 1000)); ?> &picture=<?php echo urlencode($fi_src[0]); ?> &link=<?php echo urlencode(lcwp_curr_url() . $dl_part); ?> &redirect_uri=http://www.lcweb.it/lcis_redirect.php','sharer','toolbar=0,status=0,width=548,height=325');" href="javascript: void(0)"><span title="<?php _e('Share it!', 'mg_ml'); ?> "></span></a> </li> <?php } ?> <?php if (get_option('mg_twitter')) { ?> <li id="mg_tw_share"> <a onClick="window.open('https://twitter.com/share?text=<?php echo urlencode('Check out "' . get_the_title($post_id) . '" on ' . get_bloginfo('name')); ?> &url=<?php echo urlencode(lcwp_curr_url() . $dl_part); ?> ','sharer','toolbar=0,status=0,width=548,height=325');" href="javascript: void(0)"><span title="<?php _e('Tweet it!', 'mg_ml'); ?> "></span></a> </li> <?php } ?> <?php if (get_option('mg_pinterest')) { ?> <?php // $pt_resized_img = mg_thumb_src($fi_src_pt[0], 736, false); ?> <li id="mg_pn_share"> <a onClick="window.open('http://pinterest.com/pin/create/button/?url=<?php echo urlencode(lcwp_curr_url() . $dl_part); ?> &media=<?php echo urlencode($fi_src_pt[0]); ?> &description=<?php echo urlencode(get_the_title($post_id)); ?> ','sharer','toolbar=0,status=0,width=575,height=330');" href="javascript: void(0)"><span title="<?php _e('Pin it!', 'mg_ml'); ?> "></span></a> </li> <?php } ?> <?php if (get_option('mg_googleplus') && !get_option('mg_disable_dl')) { ?> <li id="mg_gp_share"> <a onClick="window.open('https://plus.google.com/share?url=<?php echo urlencode(lcwp_curr_url() . $dl_part); ?> ','sharer','toolbar=0,status=0,width=490,height=360');" href="javascript: void(0)"><span title="<?php _e('Share it!', 'mg_ml'); ?> "></span></a> </li> <?php } ?> </ul> </div> <?php } ?> <br style="clear: both;" /> </div> </div> </div> <?php }
/** * Get the images for a product or product variation. * * @param WC_Product|WC_Product_Variation $product * @return array */ protected function get_images($product) { $images = array(); $attachment_ids = array(); if ($product->is_type('variation')) { if (has_post_thumbnail($product->get_variation_id())) { // Add variation image if set. $attachment_ids[] = get_post_thumbnail_id($product->get_variation_id()); } elseif (has_post_thumbnail($product->id)) { // Otherwise use the parent product featured image if set. $attachment_ids[] = get_post_thumbnail_id($product->id); } } else { // Add featured image. if (has_post_thumbnail($product->id)) { $attachment_ids[] = get_post_thumbnail_id($product->id); } // Add gallery images. $attachment_ids = array_merge($attachment_ids, $product->get_gallery_attachment_ids()); } // Build image data. foreach ($attachment_ids as $position => $attachment_id) { $attachment_post = get_post($attachment_id); if (is_null($attachment_post)) { continue; } $attachment = wp_get_attachment_image_src($attachment_id, 'full'); if (!is_array($attachment)) { continue; } $imageData = array('id' => (int) $attachment_id, 'date_created' => wc_rest_prepare_date_response($attachment_post->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($attachment_post->post_modified_gmt), 'src' => current($attachment), 'name' => get_the_title($attachment_id), 'alt' => get_post_meta($attachment_id, '_wp_attachment_image_alt', true), 'position' => (int) $position); if ($_GET['include'] == 'image-sizes') { $imageData['sizes'] = $this->get_image_sizes($attachment_id); } $images[] = $imageData; } // Set a placeholder image if the product has no images set. if (empty($images)) { $images[] = array('id' => 0, 'date_created' => wc_rest_prepare_date_response(current_time('mysql')), 'date_modified' => wc_rest_prepare_date_response(current_time('mysql')), 'src' => wc_placeholder_img_src(), 'name' => __('Placeholder', 'woocommerce'), 'alt' => __('Placeholder', 'woocommerce'), 'position' => 0); } return $images; }
function anaglyph_woo_template_loop_second_product_thumbnail() { global $post, $woocommerce, $product, $anaglyph_config; $columns_in = (int) $anaglyph_config['shop-product-perrow']; $attachment_ids = ''; $size = 'full'; $productObj = new WC_Product($product); $attachment_ids = $productObj->get_gallery_attachment_ids(); if (!empty($attachment_ids)) { $secondary_image_id = $attachment_ids['0']; if ($columns_in == 2) { $size = array(560, 560); } else { if ($columns_in == 3) { $size = array(420, 420); } else { if ($columns_in == 1) { $size = 'full'; } else { $size = array(258, 258); } } } echo wp_get_attachment_image($secondary_image_id, $size, '', $attr = array('class' => 'anaglyph-second-image attachment-shop-catalog')); } }
/** * Get the images for a product or product variation * * @since 2.1 * @param WC_Product|WC_Product_Variation $product * @return array */ private function get_images($product) { $images = $attachment_ids = array(); if ($product->is_type('variation')) { if (has_post_thumbnail($product->get_variation_id())) { // Add variation image if set $attachment_ids[] = get_post_thumbnail_id($product->get_variation_id()); } elseif (has_post_thumbnail($product->id)) { // Otherwise use the parent product featured image if set $attachment_ids[] = get_post_thumbnail_id($product->id); } } else { // Add featured image if (has_post_thumbnail($product->id)) { $attachment_ids[] = get_post_thumbnail_id($product->id); } // Add gallery images $attachment_ids = array_merge($attachment_ids, $product->get_gallery_attachment_ids()); } // Build image data foreach ($attachment_ids as $position => $attachment_id) { $attachment_post = get_post($attachment_id); if (is_null($attachment_post)) { continue; } $attachment = wp_get_attachment_image_src($attachment_id, 'full'); if (!is_array($attachment)) { continue; } $images[] = array('id' => (int) $attachment_id, 'created_at' => $this->server->format_datetime($attachment_post->post_date_gmt), 'updated_at' => $this->server->format_datetime($attachment_post->post_modified_gmt), 'src' => current($attachment), 'title' => get_the_title($attachment_id), 'alt' => get_post_meta($attachment_id, '_wp_attachment_image_alt', true), 'position' => (int) $position); } // Set a placeholder image if the product has no images set if (empty($images)) { $images[] = array('id' => 0, 'created_at' => $this->server->format_datetime(time()), 'updated_at' => $this->server->format_datetime(time()), 'src' => wc_placeholder_img_src(), 'title' => __('Placeholder', 'woocommerce'), 'alt' => __('Placeholder', 'woocommerce'), 'position' => 0); } return $images; }
function woocomposer_list_shortcode($atts) { global $woocommerce; $img_position = $img_size = $img_border = $border_size = $border_radius = $border_color = $title_font = $price_font = $price_color = $rating_color = $rating_font = $shortcode = ''; extract(shortcode_atts(array("img_position" => "", "shortcode" => "", "img_size" => "", "img_border" => "", "border_size" => "", "border_radius" => "", "border_color" => "", "title_color" => "", "title_font" => "", "price_font" => "", "price_color" => "", "rating_color" => "", "rating_font" => ""), $atts)); $output = $on_sale = $style = $title_style = $pricing_style = $rating_style = ''; if ($img_size !== "") { $style .= 'width:' . $img_size . 'px; height:' . $img_size . 'px;'; } if ($title_color !== "") { $title_style .= 'color:' . $title_color . ';'; } if ($title_font !== "") { $title_style .= 'font-size:' . $title_font . 'px;'; } if ($img_border !== '') { $style .= 'border-style:' . $img_border . ';'; if ($border_size !== '') { $style .= 'border-width:' . $border_size . 'px;'; } if ($border_color !== '') { $style .= 'border-color:' . $border_color . ';'; } if ($border_radius !== '') { $style .= 'border-radius:' . $border_radius . 'px;'; } } if ($price_font !== "") { $pricing_style .= 'font-size:' . $price_font . 'px;'; } if ($price_color !== "") { $pricing_style .= 'color:' . $price_color . ';'; } if ($rating_color !== "") { $rating_style .= 'color:' . $rating_color . ';'; } if ($rating_font !== "") { $rating_style .= 'font-size:' . $rating_font . 'px;'; } $post_count = '12'; $output .= '<div class="woocomposer_list woocommerce">'; /* $output .= do_shortcode($content); */ $pattern = get_shortcode_regex(); if ($shortcode !== '') { $new_shortcode = rawurldecode(base64_decode(strip_tags($shortcode))); } preg_match_all("/" . $pattern . "/", $new_shortcode, $matches); $shortcode_str = str_replace('"', '', str_replace(" ", "&", trim($matches[3][0]))); $short_atts = parse_str($shortcode_str); //explode("&",$shortcode_str); if (isset($matches[2][0])) { $display_type = $matches[2][0]; } else { $display_type = ''; } if (!isset($columns)) { $columns = '4'; } if (isset($per_page)) { $post_count = $per_page; } if (isset($number)) { $post_count = $number; } if (!isset($order)) { $order = 'ASC'; } if (!isset($orderby)) { $orderby = 'date'; } if (!isset($category)) { $category = ''; } if (!isset($ids)) { $ids = ''; } if ($ids) { $ids = explode(',', $ids); $ids = array_map('trim', $ids); } if ($columns == "2") { $columns = 6; } elseif ($columns == "3") { $columns = 4; } elseif ($columns == "4") { $columns = 3; } $meta_query = ''; if ($display_type == "recent_products") { $meta_query = WC()->query->get_meta_query(); } if ($display_type == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } if ($display_type == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'meta_query' => $meta_query); if ($display_type == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } if ($display_type == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } if ($display_type == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } if ($display_type == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN')); } $query = new WP_Query($args); $output .= '<ul class="wcmp-product-list wcmp-img-' . $img_position . ' ' . $order . '">'; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $product_id = get_the_ID(); $post = get_post($product_id); $product_title = get_the_title(); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $product_var = new WC_Product_Variable($product_id); $available_variations = $product_var->get_available_variations(); $output .= '<li>'; $output .= '<a href="' . get_permalink($product_id) . '">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), 'full'); $output .= '<img style="' . $style . '" src="' . $product_img[0] . '"/>'; $output .= '<span style="' . $title_style . '">' . $product_title . '</span>'; $output .= '</a>'; if ($display_type == "top_rated_products") { $output .= '<div style="' . $rating_style . '">' . $rating . '</div>'; } $output .= '<span class="amount" style="' . $pricing_style . '">' . $price . '</span>'; $output .= '</li>'; } } $output .= "\n" . '</ul>'; $output .= "\n" . '</div>'; if ($display_type == "top_rated_products") { remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); } wp_reset_postdata(); return $output; }
function TS_VCSC_WooCommerce_Grid_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-visual-composer-extend-front'); } } else { wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); wp_enqueue_style('ts-extend-dropdown'); wp_enqueue_script('ts-extend-dropdown'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('dashicons'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-buttons'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-extend-isotope'); wp_enqueue_script('ts-visual-composer-extend-front'); } add_action('wp_footer', array($this, 'TS_VCSC_WooCommerce_Grid_Function_Isotope'), 9999); } extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'show_link' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_dynamic' => '', 'rating_quarter' => 'true', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'product_cat', 'layout' => 'masonry', 'column_width' => 285, 'layout_break' => 600, 'show_periods' => 'false', 'sort_by' => 'postName', 'sort_order' => 'asc', 'posts_limit' => 25, 'posts_lazy' => 'false', 'posts_ajax' => 10, 'posts_load' => 'Show More', 'posts_trigger' => 'click', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $postsgrid_random = mt_rand(999999, 9999999); $opening = $closing = $controls = $products = ''; $posts_limit = $products_total; if (!empty($el_id)) { $posts_container_id = $el_id; } else { $posts_container_id = 'ts-vcsc-woocommerce-grid-' . $postsgrid_random; } // Backlight Color if ($lightbox_backlight_choice == "predefined") { $lightbox_backlight_selection = $lightbox_backlight_color; } else { $lightbox_backlight_selection = $lightbox_backlight_custom; } // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $product_style = ''; $frontend_edit = 'true'; $description_style = 'display: none; padding: 15px;'; } else { $product_style = ''; $frontend_edit = 'false'; $description_style = 'display: none; padding: 15px;'; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } $menu_tax = 'product_cat'; $limit_tax = 'product_cat'; // Start WordPress Query $loop = new WP_Query($args); // Language Settings: Isotope Posts $TS_VCSC_Isotope_Posts_Language = get_option('ts_vcsc_extend_settings_translationsIsotopePosts', ''); if ($TS_VCSC_Isotope_Posts_Language == false || empty($TS_VCSC_Isotope_Posts_Language)) { $TS_VCSC_Isotope_Posts_Language = $VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_Isotope_Posts_Language_Defaults; } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Grid_Basic', $atts); } else { $css_class = ''; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'false') { $isotope_posts_list_class = 'ts-posts-timeline-view'; } else { $isotope_posts_list_class = 'ts-posts-timeline-edit'; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'true') { echo '<div id="ts-isotope-posts-grid-frontend-' . $postsgrid_random . '" class="ts-isotope-posts-grid-frontend" style="border: 1px solid #ededed; padding: 10px;">'; echo '<div style="font-weight: bold;">"Basic Products Isotope Grid"</div>'; echo '<div style="margin-bottom: 20px;">The element has been disabled in order to ensure compatiblity with the Visual Composer Front-End Editor.</div>'; echo '<div>' . __("Number of Products", "ts_visual_composer_extend") . ': ' . $posts_limit . '</div>'; $front_edit_reverse = array("excerpt" => __('Excerpt', "ts_visual_composer_extend"), "cutcharacters" => __('Character Limited Content', "ts_visual_composer_extend"), "complete" => __('Full Content', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $show_content) { echo '<div>' . __("Content Length", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("masonry" => __('Centered Masonry', "ts_visual_composer_extend"), "fitRows" => __('Fit Rows', "ts_visual_composer_extend"), "straightDown" => __('Straight Down', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $layout) { echo '<div>' . __("Content", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("postName" => __('Product Name', "ts_visual_composer_extend"), "postPrice" => __('Product Price', "ts_visual_composer_extend"), "postRating" => __('Product Rating', "ts_visual_composer_extend"), "postDate" => __('Product Date', "ts_visual_composer_extend"), "postModified" => __('Product Modified', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_by) { echo '<div>' . __("Sort Criterion", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("asc" => __('Bottom to Top', "ts_visual_composer_extend"), "desc" => __('Top to Bottom', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_order) { echo '<div>' . __("Initial Order", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } echo '<div>' . __("Show Filter Button", "ts_visual_composer_extend") . ': ' . $filter_menu . '</div>'; echo '<div>' . __("Show Layout Button", "ts_visual_composer_extend") . ': ' . $layout_menu . '</div>'; echo '<div>' . __("Show Sort Criterion Button", "ts_visual_composer_extend") . ': ' . $sort_menu . '</div>'; echo '<div>' . __("Show Directions Buttons", "ts_visual_composer_extend") . ': ' . $directions_menu . '</div>'; echo '</div>'; } else { $opening .= '<div id="' . $posts_container_id . '" class="ts-isotope-posts-grid-parent ' . ($layout == 'spineTimeline' ? 'ts-timeline ' : 'ts-postsgrid ') . 'ts-timeline-' . $sort_order . ' ts-posts-timeline ' . $isotope_posts_list_class . ' ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';" data-lazy="' . $posts_lazy . '" data-count="' . $posts_limit . '" data-ajax="' . $posts_ajax . '" data-trigger="' . $posts_trigger . '" data-column="' . $column_width . '" data-layout="' . $layout . '" data-sort="' . $sort_by . '" data-order="' . $sort_order . '" data-break="' . $layout_break . '" data-type="' . $post_type . '">'; // Create Individual Post Output $postCounter = 0; $postCategories = array(); $categoriesCount = 0; if (post_type_exists($post_type) && $loop->have_posts()) { $products .= '<div class="ts-timeline-content">'; $products .= '<ul id="ts-isotope-posts-grid-' . $postsgrid_random . '" class="ts-isotope-posts-grid ts-timeline-list" data-layout="' . $layout . '" data-key="' . $postsgrid_random . '">'; while ($loop->have_posts()) { $loop->the_post(); $postCounter++; $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } if (has_post_thumbnail($loop->post->ID)) { $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $featured = $featured[0]; $thumbnail = $thumbnail[0]; } else { $featured = woocommerce_placeholder_img_src(); $thumbnail = $featured; } $title = get_the_title(); // Create Output if ($postCounter < $posts_limit + 1) { $postAttributes = 'data-visible="false" data-price="' . TS_VCSC_CleanNumberData($product->price) . '" data-rating="' . TS_VCSC_CleanNumberData($rating) . '" data-full="' . get_post_time($date_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"'; if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") { $product_categories = ''; if ($filter_menu == 'true' && taxonomy_exists($menu_tax)) { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { $product_categories .= $term->slug . ' '; $category_check = 0; foreach ($postCategories as $index => $array) { if ($postCategories[$index]['slug'] == $term->slug) { $category_check++; } } if ($category_check == 0) { $categoriesCount++; $categories_array = array('slug' => $term->slug, 'name' => $term->name); $postCategories[] = $categories_array; } } } $product_categories .= 'rating-' . TS_VCSC_CleanNumberData($rating) . ' '; $products .= '<li class="ts-timeline-list-item ts-timeline-date-true ts-isotope-posts-list-item ' . $product_categories . '" ' . $postAttributes . ' style="margin: 10px;">'; $products .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">'; // Product Thumbnail $products .= '<div class="ts-woocommerce-product-preview">'; $products .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '</div>'; // Sale Ribbon if ($onsale == "true") { $products .= '<div class="ts-woocommerce-product-ribbon"></div>'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } $products .= '<div class="ts-woocommerce-product-main">'; $products .= '<div class="mask" style="width: 100%; display: block;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">'; // Product Thubmnail if ($show_image == "true") { if ($link_page == "false") { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } else { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } } // Product Page Link if ($show_link == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="_blank"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>'; } // Product Rating if ($show_rating == "true") { $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; } // Product Price if ($show_price == "true") { $products .= '<div class="ts-woocommerce-product-price">'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; } $products .= '<div class="ts-woocommerce-product-line"></div>'; // Add to Cart Button (Icon) if ($show_cart == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>'; } // View Description Button if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">'; $products .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">'; $products .= '<span class="">'; $products .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>'; $products .= '</span>'; $products .= '</a>'; $products .= '</div>'; } // Product In-Stock or Unavailable if ($show_stock == "true") { $products .= '<div class="ts-woocommerce-product-status">'; if ($stock == 'false') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>'; } else { if ($stock == 'true') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>'; } } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; // Product Title $products .= '<h2 class="ts-woocommerce-product-title">'; $products .= $title; $products .= '</h2>'; // Product Description if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">'; $products .= '<div class="ts-modal-white-header"></div>'; $products .= '<div class="ts-modal-white-frame">'; $products .= '<div class="ts-modal-white-inner">'; $products .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>'; $products .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">'; $products .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $products .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">'; $products .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>'; $products .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>'; $products .= '<div style="margin-top: 20px; text-align: justify;">'; if ($show_content == "excerpt") { $products .= get_the_excerpt(); } else { if ($show_content == "cutcharacters") { $content = apply_filters('the_content', get_the_content()); $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true); $products .= $excerpt; } else { if ($show_content == "complete") { $products .= get_the_content(); } } } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; } $products .= '</div>'; $products .= '</li>'; } } } $products .= '</ul>'; $products .= '</div>'; if ($posts_lazy == "true") { $products .= '<div class="ts-load-more-wrap">'; $products .= '<span class="ts-timeline-load-more">' . $posts_load . '</span>'; $products .= '</div>'; } wp_reset_postdata(); } else { $products .= '<p>Nothing found. Please check back soon!</p>'; } // Create Post Controls (Filter, Sort) $controls .= '<div id="ts-isotope-posts-grid-controls-' . $postsgrid_random . '" class="ts-isotope-posts-grid-controls">'; if ($directions_menu == 'true' && $posts_lazy == 'false') { $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-desc ts-isotope-posts-controls-desc ' . ($sort_order == "desc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-desc-image"></span></div>'; $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-asc ts-isotope-posts-controls-asc ' . ($sort_order == "asc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-asc-image"></span></div>'; } $controls .= '<div class="ts-isotope-posts-grid-controls-menus">'; if ($filter_menu == 'true') { if ($categoriesCount > 1) { $controls .= '<div id="ts-isotope-posts-filter-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-filter-trigger" data-dropdown="#ts-isotope-posts-filter-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['WooFilterProducts'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-filter-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label style="font-weight: bold;"><input class="ts-isotope-posts-filter ts-isotope-posts-filter-all" type="checkbox" style="margin-right: 10px;" checked="checked" data-type="all" data-key="' . $postsgrid_random . '" data-filter="*">' . $TS_VCSC_Isotope_Posts_Language['SeeAll'] . '</label></li>'; $controls .= '<li class="ts-dropdown-divider"></li>'; foreach ($postCategories as $index => $array) { $controls .= '<li><label><input class="ts-isotope-posts-filter ts-isotope-posts-filter-single" type="checkbox" style="margin-right: 10px;" data-type="single" data-key="' . $postsgrid_random . '" data-filter=".' . $postCategories[$index]['slug'] . '">' . $postCategories[$index]['name'] . '</label></li>'; } $controls .= '</ul>'; $controls .= '</div>'; } } if ($layout_menu == 'true') { $controls .= '<div id="ts-isotope-posts-layout-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-layout-trigger" data-dropdown="#ts-isotope-posts-layout-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonLayout'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-layout-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="masonry" style="margin-right: 10px;" ' . ($layout == 'masonry' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['Masonry'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="fitRows" style="margin-right: 10px;" ' . ($layout == 'fitRows' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['FitRows'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="straightDown" style="margin-right: 10px;" ' . ($layout == 'straightDown' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['StraightDown'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } if ($sort_menu == 'true') { $controls .= '<div id="ts-isotope-posts-sort-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-sort-trigger" data-dropdown="#ts-isotope-posts-sort-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonSort'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-sort-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postName" style="margin-right: 10px;" ' . ($sort_by == 'postName' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooTitle'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postPrice" style="margin-right: 10px;" ' . ($sort_by == 'postPrice' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooPrice'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postRatings" style="margin-right: 10px;" ' . ($sort_by == 'postRatings' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooRating'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postDate" style="margin-right: 10px;" ' . ($sort_by == 'postDate' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooDate'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postModified" style="margin-right: 10px;" ' . ($sort_by == 'postModified' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooModified'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } $controls .= '</div>'; $controls .= '<div class="clearFixMe" style="clear:both;"></div>'; $controls .= '</div>'; $closing .= '</div>'; echo $opening; echo $controls; echo $products; echo $closing; } $myvariable = ob_get_clean(); return $myvariable; }
function WooComposer_Loop_style04($atts, $element) { global $woocommerce; $product_style = $display_elements = $quick_view_style = $img_animate = $text_align = $color_heading = $color_categories = $color_price = ''; $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = $advanced_opts = ''; $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $product_animation = ''; $disp_type = $category = $output = $product_style = $border_style = $border_color = $border_size = $border_radius = $lazy_images = $pagination = ''; $sale_price = $shortcode = $on_sale_alignment = $on_sale_style = $product_img_disp = ''; extract(shortcode_atts(array("disp_type" => "", "category" => "", "shortcode" => "", "product_style" => "style01", "display_elements" => "", "quick_view_style" => "expandable", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "pagination" => "", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "product_animation" => "", "lazy_images" => "", "advanced_opts" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts)); $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = ''; $desc_style = $label_style = $on_sale = $class = $style = $border = $desc_style = $sale_price_size = ''; $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single'); $img_animate = 'wcmp-img-' . $img_animate; if ($sale_price !== '') { $sale_price_size = 'font-size:' . $sale_price . 'px;'; } if ($border_style !== '') { $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';'; $border .= 'border-radius:' . $border_radius . 'px;'; } if ($color_product_desc_bg !== '') { $desc_style .= 'background:' . $color_product_desc_bg . ';'; } if ($color_product_desc !== '') { $desc_style .= 'color:' . $color_product_desc . ';'; } $columns = 3; $display_type = $disp_type; if ($color_heading !== "") { $heading_style = 'color:' . $color_heading . ';'; } if ($size_title !== "") { $heading_style .= 'font-size:' . $size_title . 'px;'; } if ($color_categories !== "") { $cat_style = 'color:' . $color_categories . ';'; } if ($size_cat !== "") { $cat_style .= 'font-size:' . $size_cat . 'px;'; } if ($color_price !== "") { $price_style = 'color:' . $color_price . ';'; } if ($size_price !== "") { $price_style .= 'font-size:' . $size_price . 'px;'; } if ($color_rating !== "") { $rating_style .= 'color:' . $color_rating . ';'; } if ($color_rating_bg !== "") { $rating_style .= 'background:' . $color_rating_bg . ';'; } if ($color_quick_bg !== "") { $view_bg_style = 'background:' . $color_quick_bg . ';'; } if ($color_quick !== "") { $view_style = 'color:' . $color_quick . ';'; } if ($color_cart_bg !== "") { $cart_bg_style = 'background:' . $color_cart_bg . ';'; } if ($color_cart !== "") { $cart_style = 'color:' . $color_cart . ';'; } if ($color_on_sale_bg !== "") { $label_style = 'background:' . $color_on_sale_bg . ';'; } if ($color_on_sale !== "") { $label_style .= 'color:' . $color_on_sale . ';'; } $elemets = explode(",", $display_elements); if ($element == "grid") { $paged = get_query_var('paged') ? get_query_var('paged') : 1; } else { $paged = 1; } $post_count = '12'; /* $output .= do_shortcode($content); */ if ($shortcode !== '') { $new_shortcode = rawurldecode(base64_decode(strip_tags($shortcode))); } $pattern = get_shortcode_regex(); $shortcode_str = $short_atts = ''; preg_match_all("/" . $pattern . "/", $new_shortcode, $matches); $shortcode_str = str_replace('"', '', str_replace(" ", "&", trim($matches[3][0]))); $short_atts = parse_str($shortcode_str); //explode("&",$shortcode_str); if (isset($matches[2][0])) { $display_type = $matches[2][0]; } else { $display_type = ''; } if (!isset($columns)) { $columns = '4'; } if (isset($per_page)) { $post_count = $per_page; } if (isset($number)) { $post_count = $number; } if (!isset($order)) { $order = 'asc'; } if (!isset($orderby)) { $orderby = 'date'; } if (!isset($category)) { $category = ''; } if (!isset($ids)) { $ids = ''; } if ($ids) { $ids = explode(',', $ids); $ids = array_map('trim', $ids); } $col = $columns; if ($columns == "2") { $columns = 6; } elseif ($columns == "3") { $columns = 4; } elseif ($columns == "4") { $columns = 3; } $meta_query = ''; if ($display_type == "recent_products") { $meta_query = WC()->query->get_meta_query(); } if ($display_type == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } if ($display_type == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $post_count, 'orderby' => $orderby, 'order' => $order, 'paged' => $paged, 'meta_query' => $meta_query); if ($display_type == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } if ($display_type == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } if ($display_type == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } if ($display_type == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => $ids, 'field' => 'term_id', 'operator' => 'IN')); } $test = ''; if (vc_is_inline()) { $test = "wcmp_vc_inline"; } if ($product_animation == '') { $product_animation = 'no-animation'; } else { $style .= 'opacity:1;'; } if ($element == "grid") { $class = 'vc_span' . $columns . ' '; } $output .= '<div class="woocomposer ' . $test . '" data-columns="' . $col . '">'; $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $product_id = get_the_ID(); $uid = uniqid(); $output .= '<div id="product-' . $uid . '" style="' . $style . '" class="' . $class . ' wpb_column column_container wooproduct" data-animation="animated ' . $product_animation . '">'; if ($element == 'carousel') { $output .= '<div class="wcmp-carousel-item">'; } $product_title = get_the_title($product_id); $post = get_post($product_id); $product_desc = get_post($product_id)->post_excerpt; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock'; if ($product->is_on_sale()) { $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product); } else { $on_sale = ''; } if ($quick_view_style == "expandable") { $quick_view_class = 'quick-view-loop'; } else { $quick_view_class = 'quick-view-loop-popup'; } $cat_count = sizeof(get_the_terms($product_id, 'product_cat')); $tag_count = sizeof(get_the_terms($product_id, 'product_tag')); $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>'); $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>'); $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">'; $output .= "\n\t" . '<div class="wcmp-product-image">'; if (empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") { $uniqid = uniqid(); $output .= '<div class="wcmp-single-image-carousel carousel-in-loop">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>'; } if ($stock == 'OutOfStock') { $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>'; } if ($on_sale !== '') { $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>'; } $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="add_to_cart_button product_type_simple"><i class="wooicon-cart4"></i></a></div>'; if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view ' . $quick_view_class . '" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>'; } if (in_array("reviews", $elemets)) { $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>'; } $output .= '</div>'; $output .= "\n\t" . '<div class="wcmp-product-desc">'; $output .= '<a href="' . get_permalink($product_id) . '">'; $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>'; $output .= '</a>'; if (in_array("category", $elemets)) { $output .= '<h5 style="' . $cat_style . '">'; if ($categories !== '') { $output .= $categories; $output .= $tags; } $output .= '</h5>'; } $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>'; if (in_array("description", $elemets)) { $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>'; } $output .= "\n\t" . '</div>'; $output .= "\n\t" . '</div>'; if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view-wrapper woocommerce" data-columns="' . $col . '">'; if ($quick_view_style !== "expandable") { $output .= '<div class="wcmp-quick-view-wrapper woocommerce product">'; $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>'; } $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); if ($lazy_images == "enable") { $src = plugins_url('../assets/img/loader.gif', __FILE__); } else { $src = $product_img[0]; } $output .= '<div class="wcmp-single-image wcmp-quickview-img images"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div>'; if ($quick_view_style !== "expandable") { $output .= '<div class="wcmp-product-content-single">'; } else { $output .= '<div class="wcmp-product-content">'; } ob_start(); do_action('woocommerce_single_product_summary'); $output .= ob_get_clean(); $output .= '</div>'; $output .= '<div class="clear"></div>'; if ($quick_view_style !== "expandable") { $output .= '</div>'; } $output .= '</div>'; } $output .= "\n" . '</div>'; if ($element == 'carousel') { $output .= "\n\t" . '</div>'; } } } if ($pagination == "enable") { $output .= '<div class="wcmp-paginate">'; $output .= woocomposer_pagination($query->max_num_pages); $output .= '</div>'; } $output .= '</div>'; if ($display_type == "top_rated_products") { remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); } wp_reset_postdata(); return $output; }
function WooComposer_Single_style03($atts) { $product_id = $product_style = $display_elements = $img_animate = $text_align = $color_heading = $color_categories = $color_price = ''; $color_rating = $color_rating_bg = $color_quick_bg = $color_quick = $color_cart_bg = $color_cart = $color_product_desc = ''; $color_product_desc_bg = $size_title = $size_cat = $size_price = $color_on_sale = $color_on_sale_bg = $label_on_sale = $border_style = ''; $border_color = $border_size = $border_radius = $sale_price = $on_sale_alignment = $on_sale_style = $product_img_disp = ''; extract(shortcode_atts(array("product_id" => "", "product_style" => "style01", "display_elements" => "", "label_on_sale" => "Sale!", "text_align" => "left", "img_animate" => "rotate-clock", "color_heading" => "", "color_categories" => "", "color_price" => "", "color_rating" => "", "color_rating_bg" => "", "color_quick_bg" => "", "color_quick" => "", "color_cart_bg" => "", "color_on_sale_bg" => "", "color_on_sale" => "", "color_cart" => "", "color_product_desc" => "", "color_product_desc_bg" => "", "size_title" => "", "size_cat" => "", "size_price" => "", "border_style" => "", "border_color" => "", "border_size" => "", "border_radius" => "", "sale_price" => "", "on_sale_style" => "wcmp-sale-circle", "on_sale_alignment" => "wcmp-sale-right", "product_img_disp" => "single"), $atts)); $output = $heading_style = $cat_style = $price_style = $cart_style = $cart_bg_style = $view_style = $view_bg_style = $rating_style = ''; $desc_style = $label_style = $border = $desc_style = $sale_price_size = ''; $image_size = apply_filters('single_product_large_thumbnail_size', 'shop_single'); if ($sale_price !== '') { $sale_price_size = 'font-size:' . $sale_price . 'px;'; } $img_animate = 'wcmp-img-' . $img_animate; if ($border_style !== '') { $border .= 'border:' . $border_size . 'px ' . $border_style . ' ' . $border_color . ';'; $border .= 'border-radius:' . $border_radius . 'px;'; } if ($color_product_desc_bg !== '') { $desc_style .= 'background:' . $color_product_desc_bg . ';'; } if ($color_product_desc !== '') { $desc_style .= 'color:' . $color_product_desc . ';'; } if ($color_heading !== "") { $heading_style = 'color:' . $color_heading . ';'; } if ($size_title !== "") { $heading_style .= 'font-size:' . $size_title . 'px;'; } if ($color_categories !== "") { $cat_style = 'color:' . $color_categories . ';'; } if ($size_cat !== "") { $cat_style .= 'font-size:' . $size_cat . 'px;'; } if ($color_price !== "") { $price_style = 'color:' . $color_price . ';'; } if ($size_price !== "") { $price_style .= 'font-size:' . $size_price . 'px;'; } if ($color_rating !== "") { $rating_style .= 'color:' . $color_rating . ';'; } if ($color_rating_bg !== "") { $rating_style .= 'background:' . $color_rating_bg . ';'; } if ($color_quick_bg !== "") { $view_bg_style = 'background:' . $color_quick_bg . ';'; } if ($color_quick !== "") { $view_style = 'color:' . $color_quick . ';'; } if ($color_cart_bg !== "") { $cart_bg_style = 'background:' . $color_cart_bg . ';'; } if ($color_cart !== "") { $cart_style = 'color:' . $color_cart . ';'; } if ($color_on_sale_bg !== "") { $label_style = 'background:' . $color_on_sale_bg . ';'; } if ($color_on_sale !== "") { $label_style .= 'color:' . $color_on_sale . ';'; } $elemets = explode(",", $display_elements); $product_title = get_the_title($product_id); $post = get_post($product_id); $product_desc = get_post($product_id)->post_excerpt; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $rating = $product->get_rating_html(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'InStock' : 'OutOfStock'; if ($product->is_on_sale()) { $on_sale = apply_filters('woocommerce_sale_flash', $label_on_sale, $post, $product); } else { $on_sale = ''; } $cat_count = sizeof(get_the_terms($product_id, 'product_cat')); $tag_count = sizeof(get_the_terms($product_id, 'product_tag')); $categories = $product->get_categories(', ', '<span class="posted_in">' . _n('', '', $cat_count, 'woocommerce') . ' ', '.</span>'); $tags = $product->get_tags(', ', '<span class="tagged_as">' . _n('', '', $tag_count, 'woocommerce') . ' ', '.</span>'); $output .= "\n" . '<div class="wcmp-product woocommerce wcmp-' . $product_style . ' ' . $img_animate . '" style="' . $border . ' ' . $desc_style . '">'; $output .= "\n\t" . '<div class="wcmp-product-image">'; if (!empty($attachment_ids) && count($attachment_ids) > 1 && $product_img_disp == "carousel") { $uniqid = uniqid(); $output .= '<div class="wcmp-single-image-carousel">'; $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $src = $product_img[0]; $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); $output .= '<div><div class="wcmp-image"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $src = $product_img[0]; $output .= '<a href="' . get_permalink($product_id) . '"><img class="wcmp-img" src="' . $src . '" data-src="' . $product_img[0] . '"/></a>'; } if ($on_sale !== '') { $output .= "\n" . '<div class="wcmp-onsale ' . $on_sale_alignment . ' ' . $on_sale_style . '"><span class="onsale" style="' . $label_style . ' ' . $sale_price_size . '">' . $on_sale . '</span></div>'; } if ($stock == 'OutOfStock') { $output .= "\n" . '<span class="wcmp-out-stock">' . __('Out Of Stock!', 'woocomposer') . '</span>'; } $output .= '</div>'; $output .= "\n\t" . '<div class="wcmp-product-desc">'; $output .= '<a href="' . get_permalink($product_id) . '">'; $output .= "\n\t\t" . '<h2 style="' . $heading_style . '">' . $product_title . '</h2>'; $output .= '</a>'; if (in_array("category", $elemets)) { $output .= '<h5 style="' . $cat_style . '">'; if ($categories !== '') { $output .= $categories; $output .= $tags; } $output .= '</h5>'; } $output .= "\n\t\t" . '<div class="wcmp-price"><span class="price" style="' . $price_style . '">' . $price . '</span></div>'; $output .= '<div class="wcmp-style3-cart-block">'; /*Class Start wcmp-style3-cart-block*/ $output .= '<div class="wcmp-add-to-cart" style="' . $cart_bg_style . '"><a style="' . $cart_style . '" title="Add to Cart" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-product_id="' . $product_id . '" data-product_sku="" class="button add_to_cart_button product_type_simple">Add to Cart</a></div>'; if (in_array("reviews", $elemets)) { $output .= "\n" . '<div class="wcmp-star-ratings" style="' . $rating_style . '">' . $rating . '</div>'; } if (in_array("quick", $elemets)) { $output .= '<div class="wcmp-quick-view quick-view-single" style="' . $view_bg_style . '"><a style="' . $view_style . '" title="Quick View" href="' . get_permalink($product_id) . '"><i class="wooicon-plus32"></i></a></div>'; } $output .= '</div>'; /*Class End wcmp-style3-cart-block*/ if (in_array("description", $elemets)) { $output .= "\n\t\t" . '<div class="wcmp-product-content" style="' . $desc_style . '">' . $product_desc . '</div>'; } if (in_array("quick", $elemets)) { $query = new WP_Query(array('post_type' => 'product', 'post__in' => array($product_id))); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $output .= '<div class="wcmp-quick-view-wrapper">'; $output .= '<div class="wcmp-quick-view-wrapper woocommerce">'; $output .= '<div class="wcmp-close-single"><i class="wooicon-cross2"></i></div>'; if (!empty($attachment_ids) && count($attachment_ids) > 1) { $uniqid = uniqid(); $output .= '<div class="wcmp-image-carousel wcmp-carousel-' . $uniqid . '" data-class="wcmp-carousel-' . $uniqid . '">'; foreach ($attachment_ids as $attachment_id) { $product_img = wp_get_attachment_image_src($attachment_id, $image_size); $output .= '<div><div class="wcmp-image"><img src="' . $product_img[0] . '"/></div></div>'; } $output .= '</div>'; } else { $product_img = wp_get_attachment_image_src(get_post_thumbnail_id($product_id), $image_size); $output .= '<div class="wcmp-single-image"><img src="' . $product_img[0] . '"/></div>'; } $output .= '<div class="wcmp-product-content-single">'; ob_start(); do_action('woocommerce_single_product_summary'); $output .= ob_get_clean(); $output .= '</div>'; $output .= '<div class="clear"></div>'; $output .= '</div>'; $output .= '</div>'; } } } $output .= "\n\t" . '</div>'; $output .= "\n\t" . '</div>'; return $output; }
function TS_VCSC_WooCommerce_ImageGrid_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-simptip'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'post_type' => 'product', 'limit_posts' => 'true', 'limit_by' => 'category', 'limit_term' => '', 'filter_by' => 'category', 'posts_limit' => 25, 'content_images_size' => 'medium', 'filters_show' => 'true', 'filters_available' => 'Available Groups', 'filters_selected' => 'Filtered Groups', 'filters_nogroups' => 'No Groups', 'filters_toggle' => 'Toggle Filter', 'filters_toggle_style' => '', 'filters_showall' => 'Show All', 'filters_showall_style' => '', 'data_grid_machine' => 'internal', 'data_grid_invalid' => 'false', 'data_grid_target' => '_blank', 'data_grid_breaks' => '240,480,720,960', 'data_grid_width' => 250, 'data_grid_space' => 2, 'data_grid_order' => 'false', 'data_grid_always' => 'true', 'data_grid_price' => 'true', 'fullwidth' => 'false', 'breakouts' => 6, 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $grid_class = 'ts-image-link-grid-edit'; $grid_message = '<div class="ts-composer-frontedit-message">' . __('The grid is currently viewed in front-end edit mode; grid and filter features are disabled for performance and compatibility reasons.', "ts_visual_composer_extend") . '</div>'; $image_style = 'width: 20%; height: 100%; display: inline-block; margin: 0; padding: 0;'; $grid_style = 'height: 100%;'; $frontend_edit = 'true'; } else { if ($data_grid_machine == 'internal') { $grid_class = 'ts-image-link-grid'; } else { if ($data_grid_machine == 'freewall') { $grid_class = 'ts-freewall-link-grid'; } } $image_style = ''; $grid_style = ''; $grid_message = ''; $frontend_edit = 'false'; } $randomizer = mt_rand(999999, 9999999); if (!empty($el_id)) { $modal_id = $el_id; } else { $modal_id = 'ts-vcsc-product-link-grid-' . $randomizer; } $valid_images = 0; if (!empty($data_grid_breaks)) { $data_grid_breaks = str_replace(' ', '', $data_grid_breaks); $count_columns = substr_count($data_grid_breaks, ",") + 1; } else { $count_columns = 0; } $i = -1; $b = 0; $output = ''; if ($filters_toggle_style != '') { wp_enqueue_style('ts-extend-buttonsflat'); } wp_enqueue_style('ts-extend-multiselect'); wp_enqueue_script('ts-extend-multiselect'); $meta_query = ''; $menu_tax = 'product_cat'; $limit_tax = 'product_cat'; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } // Start WordPress Query $loop = new WP_Query($args); if ($data_grid_machine == 'internal') { $class_name = 'ts-image-link-grid-frame'; } else { if ($data_grid_machine == 'freewall') { wp_enqueue_script('ts-extend-freewall'); $class_name = 'ts-image-freewall-grid-frame'; } } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . $class_name . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_ImageGrid_Basic', $atts); } else { $css_class = $class_name . ' ' . $el_class; } $fullwidth_allow = "true"; $postCounter = 0; $modal_gallery = ''; // Front-Edit Message if ($frontend_edit == "true") { $modal_gallery .= $grid_message; if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $matched_terms = 0; $post_thumbnail = get_the_post_thumbnail(); if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) { $postCounter++; if ($postCounter < $posts_limit + 1) { $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; if ('' != $post_thumbnail) { $grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size); $modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $grid_image = $grid_image[0]; $modal_image = $modal_image[0]; } else { $grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png'); $modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png'); } $categories = array(); if (taxonomy_exists($menu_tax)) { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { array_push($categories, $term->name); } $categories = implode($categories, ','); } $valid_images++; $modal_gallery .= '<a style="' . $image_style . '" href="' . get_permalink() . '" target="_blank" title="' . get_the_title() . '">'; $modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">'; $modal_gallery .= '</a>'; $categories = array(); } } } } else { echo __("No products could be found.", "ts_visual_composer_extend"); } wp_reset_postdata(); wp_reset_query(); } else { if ($loop->have_posts()) { if ($data_grid_machine == 'freewall') { $filter_settings = 'data-gridfilter="' . $filters_show . '" data-gridavailable="' . $filters_available . '" data-gridselected="' . $filters_selected . '" data-gridnogroups="' . $filters_nogroups . '" data-gridtoggle="' . $filters_toggle . '" data-gridtogglestyle="' . $filters_toggle_style . '" data-gridshowall="' . $filters_showall . '" data-gridshowallstyle="' . $filters_showall_style . '"'; $modal_gallery .= '<div id="ts-lightbox-freewall-grid-' . $randomizer . '-container" class="ts-lightbox-freewall-grid-container" data-random="' . $randomizer . '" data-width="' . $data_grid_width . '" data-gutter="' . $data_grid_space . '" ' . $filter_settings . ' style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;">'; } while ($loop->have_posts()) { $loop->the_post(); $matched_terms = 0; $post_thumbnail = get_the_post_thumbnail(); if ($matched_terms == 0 && ($post_thumbnail != '' || $data_grid_invalid == "false")) { $postCounter++; if ($postCounter < $posts_limit + 1) { $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; if ('' != $post_thumbnail) { $grid_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $content_images_size); $modal_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $grid_image = $grid_image[0]; $modal_image = $modal_image[0]; } else { $grid_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png'); $modal_image = TS_VCSC_GetResourceURL('images/defaults/no_featured.png'); } $categories = array(); if (taxonomy_exists($menu_tax)) { if ($filters_show == "true") { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { array_push($categories, $term->name); } } $categories = implode($categories, ','); } $valid_images++; $costs = $product->price; $costs = is_numeric($costs) ? wc_price($costs) : $costs; $costs = strip_tags($costs); if ($data_grid_price == "true") { $price = $costs . ' / '; } else { $price = ''; } if ($data_grid_machine == 'internal') { $modal_gallery .= '<img id="ts-image-link-picture-' . $randomizer . '-' . $i . '" class="ts-image-link-picture" src="' . $grid_image . '" rel="link-group-' . $randomizer . '" data-no-lazy="1" data-price="' . $costs . '" data-include="true" data-image="' . $modal_image . '" width="100%" height="auto" title="' . $price . get_the_title() . '" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '">'; } else { if ($data_grid_machine == 'freewall') { $modal_gallery .= '<div id="ts-lightbox-freewall-item-' . $randomizer . '-' . $i . '-parent" class="ts-lightbox-freewall-item ts-lightbox-freewall-active ' . $el_class . ' nchgrid-item nchgrid-tile" data-fixSize="false" data-groups="' . $categories . '" data-target="' . $data_grid_target . '" data-link="' . get_permalink() . '" data-showing="true" data-groups="' . (!empty($categories) ? str_replace('/', ',', $categories) : "") . '" style="width: ' . $data_grid_width . 'px; margin: 0; padding: 0;">'; $modal_gallery .= '<a id="ts-lightbox-freewall-item-' . $randomizer . '-' . $i . '" href="' . get_permalink() . '" target="' . $data_grid_target . '" title="' . get_the_title() . '">'; $modal_gallery .= '<img id="ts-lightbox-freewall-picture-' . $randomizer . '-' . $i . '" class="ts-lightbox-freewall-picture" src="' . $grid_image . '" width="100%" height="auto" title="' . $price . get_the_title() . '">'; $modal_gallery .= '<div class="nchgrid-caption"></div>'; $modal_gallery .= '<div class="nchgrid-caption-text ' . ($data_grid_always == 'true' ? 'nchgrid-caption-text-always' : '') . '">' . $price . get_the_title() . '</div>'; $modal_gallery .= '</a>'; $modal_gallery .= '</div>'; } } $categories = array(); } } } if ($data_grid_machine == 'freewall') { $modal_gallery .= '</div>'; } } else { echo __("No products could be found.", "ts_visual_composer_extend"); } wp_reset_postdata(); wp_reset_query(); } if ($valid_images < $count_columns) { $data_grid_string = explode(',', $data_grid_breaks); $data_grid_breaks = array(); foreach ($data_grid_string as $single_break) { $b++; if ($b <= $valid_images) { array_push($data_grid_breaks, $single_break); } else { break; } } $data_grid_breaks = implode(",", $data_grid_breaks); } else { $data_grid_breaks = $data_grid_breaks; } $output .= '<div id="' . $modal_id . '-frame" class="' . $grid_class . ' ' . $css_class . ' ' . ($fullwidth == "true" && $fullwidth_allow == "true" ? "ts-lightbox-nacho-full-frame" : "") . '" data-random="' . $randomizer . '" data-grid="' . $data_grid_breaks . '" data-margin="' . $data_grid_space . '" data-always="' . $data_grid_always . '" data-order="' . $data_grid_order . '" data-break-parents="' . $breakouts . '" data-inline="' . $frontend_edit . '" data-gridfilter="' . $filters_show . '" data-gridavailable="' . $filters_available . '" data-gridselected="' . $filters_selected . '" data-gridnogroups="' . $filters_nogroups . '" data-gridtoggle="' . $filters_toggle . '" data-gridtogglestyle="' . $filters_toggle_style . '" data-gridshowall="' . $filters_showall . '" data-gridshowallstyle="' . $filters_showall_style . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px; position: relative;">'; if ($data_grid_machine == 'internal') { $output .= '<div id="nch-lb-grid-' . $randomizer . '" class="nch-lb-grid" data-filter="nch-lb-filter-' . $randomizer . '" style="' . $grid_style . '" data-toggle="nch-lb-toggle-' . $randomizer . '" data-random="' . $randomizer . '">'; } $output .= $modal_gallery; if ($data_grid_machine == 'internal') { $output .= '</div>'; } $output .= '</div>'; echo $output; $myvariable = ob_get_clean(); return $myvariable; }
function TS_VCSC_WooCommerce_Slider_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndWaypoints == "true") { if (wp_script_is('waypoints', $list = 'registered')) { wp_enqueue_script('waypoints'); } else { wp_enqueue_script('ts-extend-waypoints'); } } wp_enqueue_style('ts-extend-owlcarousel2'); wp_enqueue_script('ts-extend-owlcarousel2'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_link' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'products_slide' => 4, 'breakpoints_custom' => 'false', 'breakpoints_items' => '1,2,3,4,5,6,7,8', 'auto_height' => 'false', 'page_rtl' => 'false', 'auto_play' => 'false', 'show_bar' => 'false', 'bar_color' => '#dd3333', 'show_speed' => 5000, 'stop_hover' => 'true', 'show_navigation' => 'true', 'show_dots' => 'true', 'items_loop' => 'false', 'animation_in' => 'ts-viewport-css-flipInX', 'animation_out' => 'ts-viewport-css-slideOutDown', 'animation_mobile' => 'false', 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_quarter' => 'true', 'rating_dynamic' => '', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $woo_random = mt_rand(999999, 9999999); if (!empty($el_id)) { $woo_slider_id = $el_id; } else { $woo_slider_id = 'ts-vcsc-woocommerce-slider-' . $woo_random; } $output = ''; // Backlight Color if ($lightbox_backlight_choice == "predefined") { $lightbox_backlight_selection = $lightbox_backlight_color; } else { $lightbox_backlight_selection = $lightbox_backlight_custom; } // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $slider_class = 'owl-carousel2-edit'; $slider_message = '<div class="ts-composer-frontedit-message">' . __('The slider is currently viewed in front-end edit mode; slider features are disabled for performance and compatibility reasons.', "ts_visual_composer_extend") . '</div>'; $product_style = 'width: ' . 100 / $products_slide . '%; height: 100%; float: left; margin: 0; padding: 0;'; $frontend_edit = 'true'; $description_style = 'display: none; padding: 15px;'; } else { $slider_class = 'ts-owlslider-parent owl-carousel2'; $slider_message = ''; $product_style = ''; $frontend_edit = 'false'; $description_style = 'display: none; padding: 15px;'; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $frontend_edit == "true" ? $products_slide : $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } // Start WordPress Query $loop = new WP_Query($args); if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $slider_class . ' ' . $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Slider_Basic', $atts); } else { $css_class = $slider_class . ' ' . $el_class; } $output .= '<div id="' . $woo_slider_id . '-container" class="ts-woocommerce-slider-container">'; // Add Progressbar if ($auto_play == "true" && $show_bar == "true" && $frontend_edit == "false") { $output .= '<div id="ts-owlslider-progressbar-' . $woo_random . '" class="ts-owlslider-progressbar-holder" style=""><div class="ts-owlslider-progressbar" style="background: ' . $bar_color . '; height: 100%; width: 0%;"></div></div>'; } // Add Navigation Controls if ($frontend_edit == "false") { $output .= '<div id="ts-owlslider-controls-' . $woo_random . '" class="ts-owlslider-controls" style="' . ($auto_play == "true" || $show_navigation == "true" ? "display: block;" : "display: none;") . '">'; $output .= '<div id="ts-owlslider-controls-next-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>'; $output .= '<div id="ts-owlslider-controls-prev-' . $woo_random . '" style="' . ($show_navigation == "true" ? "display: block;" : "display: none;") . '" class="ts-owlslider-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>'; if ($auto_play == "true") { $output .= '<div id="ts-owlslider-controls-play-' . $woo_random . '" class="ts-owlslider-controls-play active"><span class="ts-ecommerce-pause"></span></div>'; } $output .= '</div>'; } // Front-Edit Message if ($frontend_edit == "true") { $output .= $slider_message; } // Add Slider $output .= '<div id="' . $woo_slider_id . '" class="' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;" data-id="' . $woo_random . '" data-items="' . $products_slide . '" data-breakpointscustom="' . $breakpoints_custom . '" data-breakpointitems="' . $breakpoints_items . '" data-rtl="' . $page_rtl . '" data-loop="' . $items_loop . '" data-navigation="' . $show_navigation . '" data-dots="' . $show_dots . '" data-mobile="' . $animation_mobile . '" data-animationin="' . $animation_in . '" data-animationout="' . $animation_out . '" data-height="' . $auto_height . '" data-play="' . $auto_play . '" data-bar="' . $show_bar . '" data-color="' . $bar_color . '" data-speed="' . $show_speed . '" data-hover="' . $stop_hover . '">'; if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } if (has_post_thumbnail($loop->post->ID)) { $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $featured = $featured[0]; $thumbnail = $thumbnail[0]; } else { $featured = woocommerce_placeholder_img_src(); $thumbnail = $featured; } $title = get_the_title(); if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") { $output .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">'; // Product Thumbnail $output .= '<div class="ts-woocommerce-product-preview">'; $output .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $output .= '</div>'; // Sale Ribbon if ($onsale == "true") { $output .= '<div class="ts-woocommerce-product-ribbon"></div>'; $output .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } $output .= '<div class="ts-woocommerce-product-main">'; $output .= '<div class="mask" style="width: 100%; display: block;">'; $output .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">'; // Product Thubmnail if ($show_image == "true") { if ($link_page == "false") { $output .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media no-ajaxy" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">'; $output .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $output .= '</a></div>'; } else { $output .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">'; $output .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $output .= '</a></div>'; } } // Product Page Link if ($show_link == "true") { $output .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="' . $link_target . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>'; } // Product Rating if ($show_rating == "true") { $output .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">'; $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $output .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; } // Product Price if ($show_price == "true") { $output .= '<div class="ts-woocommerce-product-price">'; $output .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $output .= '</div>'; } $output .= '<div class="ts-woocommerce-product-line"></div>'; // Add to Cart Button (Icon) if ($show_cart == "true") { $output .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>'; } // View Description Button if ($show_info == "true") { $output .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">'; $output .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">'; $output .= '<span class="">'; $output .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>'; $output .= '</span>'; $output .= '</a>'; $output .= '</div>'; } // Product In-Stock or Unavailable if ($show_stock == "true") { $output .= '<div class="ts-woocommerce-product-status">'; if ($stock == 'false') { $output .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>'; } else { if ($stock == 'true') { $output .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>'; } } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; // Product Title $output .= '<h2 class="ts-woocommerce-product-title">'; $output .= $title; $output .= '</h2>'; // Product Description if ($show_info == "true") { $output .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">'; $output .= '<div class="ts-modal-white-header"></div>'; $output .= '<div class="ts-modal-white-frame">'; $output .= '<div class="ts-modal-white-inner">'; $output .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>'; $output .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">'; $output .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $output .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; $output .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">'; $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $output .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">'; $output .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $output .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $output .= '</div>'; $output .= '</div>'; $output .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>'; $output .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $output .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>'; $output .= '<div style="margin-top: 20px; text-align: justify;">'; if ($show_content == "excerpt") { $output .= get_the_excerpt(); } else { if ($show_content == "cutcharacters") { $content = apply_filters('the_content', get_the_content()); $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true); $output .= $excerpt; } else { if ($show_content == "complete") { $output .= get_the_content(); } } } $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; } $output .= '</div>'; } } } else { echo __("No products could be found.", "ts_visual_composer_extend"); } $output .= '</div>'; $output .= '</div>'; wp_reset_postdata(); wp_reset_query(); echo $output; $myvariable = ob_get_clean(); return $myvariable; }
function TS_VCSC_WooCommerce_Ticker_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); wp_enqueue_script('ts-extend-newsticker'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-font-teammatess'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); } extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'limit_posts' => 'true', 'limit_by' => 'category', 'limit_term' => '', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'category', 'ticker_direction' => 'up', 'ticker_speed' => 3000, 'ticker_break' => 480, 'ticker_border_type' => '', 'ticker_border_thick' => 1, 'ticker_border_color' => '#ededed', 'ticker_border_radius' => '', 'ticker_auto' => 'false', 'ticker_hover' => 'true', 'ticker_controls' => 'true', 'ticker_symbol' => 'false', 'ticker_icon' => '', 'ticker_paint' => '#ffffff', 'ticker_title' => 'true', 'ticker_header' => 'Latest Products', 'ticker_background' => '#D10000', 'ticker_color' => '#ffffff', 'ticker_type' => 'true', 'ticker_image' => 'true', 'ticker_price' => 'true', 'ticker_cart' => 'true', 'ticker_add_item' => 'Add This Item', 'ticker_remove_item' => 'Remove This Item', 'ticker_rating' => 'true', 'ticker_stock' => 'false', 'ticker_side' => 'left', 'ticker_fixed' => 'false', 'ticker_position' => 'top', 'ticker_adjustment' => 0, 'ticker_target' => '_parent', 'posts_limit' => 25, 'rating_maximum' => 5, 'rating_size' => 20, 'rating_quarter' => 'true', 'rating_name' => 'true', 'rating_auto' => 'true', 'rating_position' => 'top', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'true', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $woo_random = mt_rand(999999, 9999999); if (!empty($el_id)) { $woo_ticker_id = $el_id; } else { $woo_ticker_id = 'ts-vcsc-woocommerce-ticker-' . $woo_random; } $output = ''; // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $frontend_edit = 'true'; $ticker_fixed = 'false'; $ticker_auto = 'false'; } else { $frontend_edit = 'false'; $ticker_fixed = $ticker_fixed; $ticker_auto = $ticker_auto; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } // Start WordPress Query $loop = new WP_Query($args); if ($ticker_fixed == "true") { $newsticker_class = 'ts-newsticker-fixed'; $newsticker_position = 'ts-newsticker-' . $ticker_position; if ($ticker_position == "top") { $newsticker_style = 'top: ' . $ticker_adjustment . 'px;'; } else { $newsticker_style = 'bottom: ' . $ticker_adjustment . 'px;'; } $margin_top = 0; $margin_bottom = 0; } else { $newsticker_class = 'ts-newsticker-standard'; $newsticker_position = ''; $newsticker_style = ''; } if ($ticker_border_type != '') { $newsticker_border = 'border: ' . $ticker_border_thick . 'px ' . $ticker_border_type . ' ' . $ticker_border_color . ';'; } else { $newsticker_border = ''; } if ($ticker_side == "left") { $newsticker_elements = 'ts-newsticker-elements-left'; } else { $newsticker_elements = 'ts-newsticker-elements-right'; } if ($ticker_title == "false") { $newsticker_header = 'left: 0;'; $newsticker_controls = 'right: 10px;'; } else { $newsticker_header = ''; $newsticker_controls = ''; } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $el_class . ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Ticker_Basic', $atts); } else { $css_class = $slider_class . ' ' . $el_class; } $output .= '<div id="' . $woo_ticker_id . '" class="ts-newsticker-parent ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';">'; // Create Individual Post Output $postCounter = 0; $postMonths = array(); if ($loop->have_posts()) { $output .= '<div id="ts-newsticker-oneliner-' . $woo_random . '" class="ts-newsticker-oneliner ' . $newsticker_class . ' ' . $newsticker_position . ' ' . $ticker_border_radius . '" style="' . $newsticker_style . ' ' . $newsticker_border . '" data-ticker="ts-newsticker-ticker-' . $woo_random . '" data-controls="ts-newsticker-controls-' . $woo_random . '" data-navigation="' . $ticker_controls . '" data-break="' . $ticker_break . '" data-auto="' . $ticker_auto . '" data-speed="' . $ticker_speed . '" data-hover="' . $ticker_hover . '" data-direction="' . $ticker_direction . '" data-parent="' . $woo_ticker_id . '" data-side="' . $ticker_side . '" data-header="ts-newsticker-header-' . $woo_random . '" data-next="ts-newsticker-controls-next-' . $woo_random . '" data-prev="ts-newsticker-controls-prev-' . $woo_random . '" data-play="ts-newsticker-controls-play-' . $woo_random . '" data-stop="ts-newsticker-controls-stop-' . $woo_random . '">'; $output .= '<div class="ts-newsticker-elements-frame ' . $newsticker_elements . ' ' . $ticker_border_radius . '" style="">'; // Add Navigation Controls $output .= '<div id="ts-newsticker-controls-' . $woo_random . '" class="ts-newsticker-controls" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . ' ' . $newsticker_controls . '">'; $output .= '<div id="ts-newsticker-controls-next-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-next"><span class="ts-ecommerce-arrowright5"></span></div>'; $output .= '<div id="ts-newsticker-controls-prev-' . $woo_random . '" style="' . ($ticker_controls == "true" ? "display: block;" : "display: none;") . '" class="ts-newsticker-controls-prev"><span class="ts-ecommerce-arrowleft5"></span></div>'; $output .= '<div id="ts-newsticker-controls-stop-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: block;" : "display: none;") . '"><span class="ts-ecommerce-pause"></span></div>'; $output .= '<div id="ts-newsticker-controls-play-' . $woo_random . '" class="ts-newsticker-controls-play" style="' . ($ticker_auto == "true" ? "display: none;" : "display: block;") . '"><span class="ts-ecommerce-play"></span></div>'; $output .= '</div>'; if ($ticker_side == "left" && $ticker_title == "true") { $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; left: 0;">'; if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") { $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>'; } $output .= '<span>' . $ticker_header . '</span>'; $output .= '</div>'; } $output .= '<ul id="ts-newsticker-ticker-' . $woo_random . '" class="newsticker ' . $ticker_border_radius . '" style="' . $newsticker_header . '">'; while ($loop->have_posts()) { $loop->the_post(); $postCounter++; if ($postCounter < $posts_limit + 1) { $postAttributes = 'data-full="' . get_post_time($date_format) . '" data-time="' . get_post_time($time_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"'; $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } // Check if Product already in Cart $cart_page_id = wc_get_page_id('cart'); $already_added = "false"; foreach ($woocommerce->cart->get_cart() as $cart_item_key => $cart_item) { if ($product_id == $cart_item['product_id']) { $already_added = "true"; $cart_link = apply_filters('woocommerce_cart_item_remove_link', sprintf('<a class="ts-newsticker-product-remove" href="%s" title="%s" rel="" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cross2"></i></a>', esc_url($woocommerce->cart->get_remove_url($cart_item_key)), $ticker_remove_item), $cart_item_key); } } if ($already_added == "false") { $cart_link = '<span class="ts-woocommerce-link-wrapper"><a class="ts-newsticker-product-purchase" href="?add-to-cart=' . $product_id . '" title="' . $ticker_add_item . '" rel="" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></span>'; } $output .= '<li ' . $postAttributes . '>'; if ($ticker_image == 'true') { if ('' != get_the_post_thumbnail()) { $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $output .= '<img class="ts-newsticker-image" src="' . $thumbnail[0] . '" style="">'; } } $output .= '<span class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" target="' . $ticker_target . '">'; $output .= get_the_title(); $output .= '</a></span>'; // Product Price if ($ticker_price == "true") { $output .= '<span class="ts-newsticker-pricetag" style="">'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $output .= '<span class="ts-newsticker-product-regular" style="float: none;"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </span><span class="ts-newsticker-product-special" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } else { $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } } else { $to = $product->price; $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } } else { $to = $product->price; $output .= '<span class="ts-newsticker-product-current" style="float: none;">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</span>'; } $output .= '</span>'; } // Sale Ribbon if ($onsale == "true") { $output .= '<i style="position: inherit" class="ts-newsticker-product-sale ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } // Product Rating if ($ticker_rating == "true") { $output .= '<span class="ts-rating-stars-frame" data-auto="false" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: none;">'; $output .= '<span class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<span class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</span>'; } $output .= '<span class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<span class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></span>'; $output .= '</span>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<span class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</span>'; } $output .= '</span>'; $output .= '</span>'; } // Add to Cart Icon if ($ticker_cart == "true") { //$output .= '<a class="ts-newsticker-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-newsticker-product-cart ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $output .= $cart_link; } // Product In-Stock or Unavailable if ($ticker_stock == "true") { $output .= '<span class="ts-woocommerce-product-status" style="margin-left: 10px;">'; if ($stock == 'false') { $output .= '<span class="ts-woocommerce-product-stock" style="position: inherit;"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></span>'; } else { if ($stock == 'true') { $output .= '<span class="ts-woocommerce-product-stock" style="position: inherit;"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></span>'; } } $output .= '</span>'; } $output .= '</li>'; } } $output .= '</ul>'; if ($ticker_side == "right" && $ticker_title == "true") { $output .= '<div id="ts-newsticker-header-' . $woo_random . '" class="header ' . $ticker_border_radius . '" style="background: ' . $ticker_background . '; color: ' . $ticker_color . '; right: 0;">'; if ($ticker_icon != '' && $ticker_icon != 'transparent' && $ticker_symbol == "true") { $output .= '<i class="ts-font-icon ' . $ticker_icon . '" style="color: ' . $ticker_paint . '"></i>'; } $output .= '<span>' . $ticker_header . '</span>'; $output .= '</div>'; } $output .= '</div>'; $output .= '</div>'; } else { echo __("No products could be found.", "ts_visual_composer_extend"); } $output .= '</div>'; wp_reset_postdata(); wp_reset_query(); echo $output; $myvariable = ob_get_clean(); return $myvariable; }
function TS_VCSC_WooCommerce_Rating_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-simptip'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-visual-composer-extend-front'); } extract(shortcode_atts(array('best_rated' => 'false', 'id' => '', 'rating_maximum' => 5, 'rating_size' => 24, 'rating_quarter' => 'true', 'rating_title' => 'true', 'rating_auto' => 'true', 'rating_position' => 'top', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => '', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'true', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'title_size' => 24, 'title_truncate' => 'true', 'use_name' => 'true', 'custom_title' => '', 'show_cart' => 'true', 'cart_color' => '#cccccc', 'show_link' => 'true', 'link_color' => '#cccccc', 'tooltip_css' => 'false', 'tooltip_content' => '', 'tooltip_position' => 'ts-simptip-position-top', 'tooltip_style' => '', 'margin_top' => 20, 'margin_bottom' => 20, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); // Final Query Arguments add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'desc', 'paged' => 1, 'meta_query' => $meta_query); $loop = new WP_Query($args); if ($loop->have_posts()) { $best_rating = 0; while ($loop->have_posts()) { $loop->the_post(); $product_id = get_the_ID(); $product = new WC_Product($product_id); if ($product_id == $id) { $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; $link = get_permalink(); // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); break; } } } wp_reset_postdata(); wp_reset_query(); if ($rating_title == "true") { if ($use_name == "true") { $rating_title = $product_title; } else { $rating_title = $custom_title; } } else { $rating_title = ''; } if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } // Line Height Adjustment if ($show_cart == "true" || $show_link == "true") { if ($title_size > 24) { $line_height = $title_size; } else { $line_height = 24; } } else { $line_height = $title_size; } // Tooltip if ($tooltip_css == "true") { if (strlen($tooltip_content) != 0) { $rating_tooltipclasses = " ts-simptip-multiline " . $tooltip_style . " " . $tooltip_position; $rating_tooltipcontent = ' data-tstooltip="' . $tooltip_content . '"'; } else { $rating_tooltipclasses = ""; $rating_tooltipcontent = ""; } } else { $rating_tooltipclasses = ""; if (strlen($tooltip_content) != 0) { $rating_tooltipcontent = ' title="' . $tooltip_content . '"'; } else { $rating_tooltipcontent = ""; } } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Rating_Basic', $atts); } else { $css_class = ''; } $output = ''; $output .= '<div class="ts-rating-stars-frame ' . $el_class . ' ' . $css_class . '" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . 'px;">'; if ($rating_position == 'top' && $rating_title != '') { $output .= '<div class="ts-rating-title ts-rating-title-top ' . ($title_truncate == "true" ? " ts-truncated" : "") . '" style="font-size: ' . $title_size . 'px; line-height: ' . $line_height . 'px; vertical-align: middle;">'; if ($show_cart == "true") { $output .= '<a style="position: inherit; margin-right: 10px;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: ' . $cart_color . '" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; } if ($show_link == "true") { $output .= '<a style="position: inherit; margin-right: 10px;" href="' . $link . '" class="ts-woocommerce-product-link"><i style="color: ' . $link_color . '" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; } $output .= $rating_title; $output .= '</div>'; } if ($rating_tooltipcontent != '') { $output .= '<div class="ts-rating-tooltip ' . $rating_tooltipclasses . '" ' . $rating_tooltipcontent . '>'; } $output .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $output .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $output .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $output .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $output .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $output .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $output .= '</div>'; } $output .= '</div>'; if ($rating_tooltipcontent != '') { $output .= '</div>'; } if ($rating_position == 'bottom' && $rating_title != '') { $output .= '<div class="ts-rating-title ts-rating-title-bottom ' . ($title_truncate == "true" ? " ts-truncated" : "") . '" style="font-size: ' . $title_size . 'px; line-height: ' . $line_height . 'px; vertical-align: middle;">'; if ($show_cart == "true") { $output .= '<a style="position: inherit; margin-left: 10px;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: ' . $cart_color . '" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; } if ($show_link == "true") { $output .= '<a style="position: inherit; margin-left: 10px;" href="' . $link . '" class="ts-woocommerce-product-link"><i style="color: ' . $link_color . '" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; } $output .= $rating_title; $output .= '</div>'; } $output .= '</div>'; echo $output; $myvariable = ob_get_clean(); return $myvariable; }
public function insert_meta_tags() { global $webdados_fb, $wp_query; //Also set Title Tag? - Needed?? $fb_set_title_tag = 0; //Init values $fb_locale = ''; $fb_title = ''; $fb_url = ''; $fb_desc = ''; $fb_image = ''; $fb_type = 'article'; $fb_author = ''; $fb_author_meta = ''; $fb_author_linkrelgp = ''; $fb_author_twitter = ''; $fb_article_pub_date = ''; $fb_article_mod_date = ''; $fb_image_additional = array(); $fb_additional_tags = array('name' => array(), 'property' => array()); $fb_publisher = trim($this->options['fb_publisher']); $fb_publisher_schema = trim($this->options['fb_publisher_schema']); $fb_publisher_twitteruser = trim($this->options['fb_publisher_twitteruser']); //Homepage Description switch ($this->options['fb_desc_homepage']) { case 'custom': $fb_desc_homepage = $this->options['fb_desc_homepage_customtext']; //WPML? if ($webdados_fb->is_wpml_active()) { global $sitepress; if (ICL_LANGUAGE_CODE != $sitepress->get_default_language()) { $fb_desc_homepage = icl_t('wd-fb-og', 'wd_fb_og_desc_homepage_customtext', $fb_desc_homepage); } } break; default: $fb_desc_homepage = get_bloginfo('description'); break; } //Open tag $html = ' <!-- START - ' . WEBDADOS_FB_PLUGIN_NAME . ' ' . WEBDADOS_FB_VERSION . ' --> '; if (is_singular()) { global $post; // Title //It's a Post or a Page or an attachment page - It can also be the homepage if it's set as a page $fb_title = esc_attr(wp_strip_all_tags(stripslashes($post->post_title), true)); //SubHeading if (isset($this->options['fb_show_subheading']) && intval($this->options['fb_show_subheading']) == 1 && $webdados_fb->is_subheading_plugin_active()) { if (isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position'] == 'before') { $fb_title = trim(trim(get_the_subheading()) . ' - ' . trim($fb_title), ' -'); } else { $fb_title = trim(trim($fb_title) . ' - ' . trim(get_the_subheading()), ' -'); } } // URL $fb_url = get_permalink(); // Type if it's a homepage page if (is_front_page()) { /* Fix homepage type when it's a static page */ $fb_url = get_option('home') . (intval($this->options['fb_url_add_trailing']) == 1 ? '/' : ''); $fb_type = trim($this->options['fb_type_homepage'] == '' ? 'website' : $this->options['fb_type_homepage']); } // Description if (trim($post->post_excerpt) != '') { //If there's an excerpt that's what we'll use $fb_desc = trim($post->post_excerpt); } else { //If not we grab it from the content $fb_desc = trim($post->post_content); } // Image if (intval($this->options['fb_image_show']) == 1 || intval($this->options['fb_image_show_schema']) == 1 || intval($this->options['fb_image_show_twitter']) == 1) { $fb_image = $this->get_post_image(); } // Author $author_id = $post->post_author; if ($author_id > 0 && !(is_page() && intval($this->options['fb_author_hide_on_pages']) == 1)) { $fb_author = get_the_author_meta('facebook', $author_id); $fb_author_meta = get_the_author_meta('display_name', $author_id); $fb_author_linkrelgp = get_the_author_meta('googleplus', $author_id); $fb_author_twitter = get_the_author_meta('twitter', $author_id); } //Published and Modified time - We should check this out and maybe have it for any kind of post... if (is_singular('post')) { $fb_article_pub_date = get_the_date('c'); $fb_article_mod_date = get_the_modified_date('c'); } else { //Reset dates show because we're not on posts $this->options['fb_article_dates_show'] = 0; } //Sections if (is_singular('post')) { $cats = get_the_category(); if (!is_wp_error($cats) && (is_array($cats) && count($cats) > 0)) { $fb_sections = array(); foreach ($cats as $cat) { $fb_sections[] = $cat->name; } } } else { $this->options['fb_article_sections_show'] = 0; } // Business Directory Plugin if (isset($this->options['fb_show_businessdirectoryplugin']) && $webdados_fb->is_business_directory_active()) { global $wpbdp; $bdp_action = wpbdp_current_action(); $bdp_disable_cpt = wpbdp_get_option('disable-cpt'); $current_view_object = $wpbdp->dispatcher->current_view_object(); switch ($bdp_action) { case 'show_listing': $fb_title = trim(esc_attr(wp_strip_all_tags(stripslashes($this->post->post_title), true)) . ' - ' . $fb_title, ' -'); $fb_set_title_tag = 1; $fb_url = get_permalink($this->post->ID); if (trim($this->post->post_excerpt) != '') { //If there's an excerpt that's what we'll use $fb_desc = trim($this->post->post_excerpt); } else { //If not we grab it from the content $fb_desc = trim($this->post->post_content); } if (intval($this->options['fb_image_show']) == 1 || intval($this->options['fb_image_show_schema']) == 1 || intval($this->options['fb_image_show_twitter']) == 1) { $thumbdone = false; if (intval($this->options['fb_image_use_featured']) == 1) { //Featured if ($id_attachment = get_post_thumbnail_id($this->post->ID)) { //There's a featured/thumbnail image for this listing $fb_image = wp_get_attachment_url($id_attachment, false); $thumbdone = true; } else { } } if (!$thumbdone) { //Main image loaded if ($thumbnail_id = wpbdp_listings_api()->get_thumbnail_id($this->post->ID)) { $fb_image = wp_get_attachment_url($thumbnail_id, false); $thumbdone = true; } } } } } // WooCommerce if ($webdados_fb->is_woocommerce_active() && is_product()) { $fb_type = 'product'; $product = new WC_Product($post->ID); //Price $fb_additional_tags['property']['og_price_amount'] = array($product->get_price_including_tax()); if (function_exists('get_woocommerce_currency')) { $fb_additional_tags['property']['og_price_currency'] = array(get_woocommerce_currency()); } $fb_additional_tags['name']['twitter_label1'] = array(__('Price', 'wd-fb-og')); if (function_exists('get_woocommerce_currency')) { $fb_additional_tags['name']['twitter_data1'] = array($product->get_price_including_tax() . ' ' . get_woocommerce_currency()); } //Additional product images? if (intval($this->options['fb_image_show']) == 1 && $this->options['fb_wc_useproductgallery'] == 1) { if ($attachment_ids = $product->get_gallery_attachment_ids()) { foreach ($attachment_ids as $attachment_id) { if ($image_link = wp_get_attachment_url($attachment_id)) { if (trim($image_link) != '') { $fb_image_additional[] = array('fb_image' => trim($image_link), 'png_overlay' => intval($this->options['fb_wc_usepg_png_overlay']) ? true : false); } } } } } } } else { //Other pages - Defaults $fb_title = esc_attr(wp_strip_all_tags(stripslashes(get_bloginfo('name')), true)); $fb_url = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //Not really canonical but will work for now $fb_image = trim($this->options['fb_image']); $this->options['fb_article_sections_show'] = 0; $this->options['fb_article_dates_show'] = 0; $this->options['fb_author_show'] = 0; $this->options['fb_author_show_meta'] = 0; $this->options['fb_author_show_linkrelgp'] = 0; $this->options['fb_author_show_twitter'] = 0; $this->options['fb_author_show_twitter'] = 0; //Category if (is_category()) { $fb_title = esc_attr(wp_strip_all_tags(stripslashes(single_cat_title('', false)), true)); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); $cat_desc = trim(esc_attr(wp_strip_all_tags(stripslashes(category_description()), true))); if (trim($cat_desc) != '') { $fb_desc = $cat_desc; } } else { if (is_tag()) { $fb_title = esc_attr(wp_strip_all_tags(stripslashes(single_tag_title('', false)), true)); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); $tag_desc = trim(esc_attr(wp_strip_all_tags(stripslashes(tag_description()), true))); if (trim($tag_desc) != '') { $fb_desc = $tag_desc; } } else { if (is_tax()) { $fb_title = esc_attr(wp_strip_all_tags(stripslashes(single_term_title('', false)), true)); $term = $wp_query->get_queried_object(); $fb_url = get_term_link($term, $term->taxonomy); $tax_desc = trim(esc_attr(wp_strip_all_tags(stripslashes(term_description()), true))); if (trim($tax_desc) != '') { $fb_desc = $tag_desc; } //WooCommerce if ($webdados_fb->is_woocommerce_active() && intval($this->options['fb_wc_usecategthumb']) == 1 && is_product_category()) { if (intval($this->options['fb_image_show']) == 1 || intval($this->options['fb_image_show_schema']) == 1 || intval($this->options['fb_image_show_twitter']) == 1) { if ($thumbnail_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true)) { if ($image = wp_get_attachment_url($thumbnail_id)) { $fb_image = $image; } } } } } else { if (is_search()) { $fb_title = esc_attr(wp_strip_all_tags(stripslashes(__('Search for', 'wd-fb-og') . ' "' . get_search_query() . '"'), true)); $fb_url = get_search_link(); } else { if (is_author()) { $fb_title = esc_attr(wp_strip_all_tags(stripslashes(get_the_author_meta('display_name', get_query_var('author'))), true)); $fb_url = get_author_posts_url(get_query_var('author'), get_query_var('author_name')); } else { if (is_archive()) { if (is_day()) { $fb_title = esc_attr(wp_strip_all_tags(stripslashes(get_query_var('day') . ' ' . single_month_title(' ', false) . ' ' . __('Archives', 'wd-fb-og')), true)); $fb_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day')); } else { if (is_month()) { $fb_title = esc_attr(wp_strip_all_tags(stripslashes(single_month_title(' ', false) . ' ' . __('Archives', 'wd-fb-og')), true)); $fb_url = get_month_link(get_query_var('year'), get_query_var('monthnum')); } else { if (is_year()) { $fb_title = esc_attr(wp_strip_all_tags(stripslashes(get_query_var('year') . ' ' . __('Archives', 'wd-fb-og')), true)); $fb_url = get_year_link(get_query_var('year')); } } } } else { if (is_front_page()) { $fb_url = get_option('home') . (intval($this->options['fb_url_add_trailing']) == 1 ? '/' : ''); $fb_type = trim($this->options['fb_type_homepage'] == '' ? 'website' : $this->options['fb_type_homepage']); $fb_desc = $fb_desc_homepage; } else { //Others... Defaults already set up there } } } } } } } } //og:type for WPML root page? if ($webdados_fb->is_wpml_active()) { if (class_exists('WPML_Root_Page')) { if (WPML_Root_Page::is_current_request_root()) { $fb_type = trim($this->options['fb_type_homepage'] == '' ? 'website' : $this->options['fb_type_homepage']); } } } //Default description, if empty until now if (trim($fb_desc) == '') { switch ($this->options['fb_desc_default_option']) { case 'custom': $fb_desc = $this->options['fb_desc_default']; //WPML? if ($webdados_fb->is_wpml_active()) { global $sitepress; if (ICL_LANGUAGE_CODE != $sitepress->get_default_language()) { $fb_desc = icl_t('wd-fb-og', 'wd_fb_og_fb_desc_default', $fb_desc); } } break; default: $fb_desc = $fb_desc_homepage; break; } } //Trim description $fb_desc = trim(str_replace(' ', ' ', $fb_desc)); //Non-breaking spaces are usefull on a meta description. We'll just convert them to normal spaces to really trim it $fb_desc = trim(intval($this->options['fb_desc_chars']) > 0 ? mb_substr(wp_strip_all_tags(strip_shortcodes(stripslashes($fb_desc), true)), 0, intval($this->options['fb_desc_chars'])) : wp_strip_all_tags(strip_shortcodes(stripslashes($fb_desc), true))); //YOAST SEO? if ($this->options['fb_show_wpseoyoast'] == 1) { if ($webdados_fb->is_yoast_seo_active()) { $wpseo = WPSEO_Frontend::get_instance(); //Title $fb_title_temp = $wpseo->title(false); $fb_title = wp_strip_all_tags(trim($fb_title_temp) != '' ? trim($fb_title_temp) : $fb_title, true); //Title - SubHeading plugin if ($fb_title_temp != '' && $this->options['fb_show_subheading'] == 1) { if ($webdados_fb->is_subheading_plugin_active()) { if (isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position'] == 'before') { $fb_title = trim(trim(get_the_subheading()) . ' - ' . trim($fb_title), ' -'); } else { $fb_title = trim(trim($fb_title) . ' - ' . trim(get_the_subheading()), ' -'); } } } //URL $fb_url_temp = $wpseo->canonical(false); $fb_url = wp_strip_all_tags(trim($fb_url_temp) != '' ? trim($fb_url_temp) : $fb_url, true); //Description $fb_desc_temp = $wpseo->metadesc(false); $fb_desc = wp_strip_all_tags(trim($fb_desc_temp) != '' ? trim($fb_desc_temp) : $fb_desc, true); } } //All in One SEO Pack? if ($this->options['fb_show_aioseop'] == 1) { if ($webdados_fb->is_aioseop_active()) { global $aiosp; //Title - Why are we getting the first post title on archives and homepage...?!? $fb_title_temp = $aiosp->orig_title; $fb_title = wp_strip_all_tags(trim($fb_title_temp) != '' ? trim($fb_title_temp) : $fb_title, true); //Title - SubHeading plugin if ($fb_title_temp != '' && $this->options['fb_show_subheading'] == 1) { if ($webdados_fb->is_subheading_plugin_active()) { if (isset($this->options['fb_subheading_position']) && $this->options['fb_subheading_position'] == 'before') { $fb_title = trim(trim(get_the_subheading()) . ' - ' . trim($fb_title), ' -'); } else { $fb_title = trim(trim($fb_title) . ' - ' . trim(get_the_subheading()), ' -'); } } } //URL - See aioseop_class.php 3898 - We have a problem because wp_query is not the same right now /*$fb_url_temp = ''; $aioseop_options = get_option( 'aioseop_options' ); $opts = $aiosp->meta_opts; var_dump($wp_query); $show_page = true; if ( ! empty( $aioseop_options['aiosp_no_paged_canonical_links'] ) ) { $show_page = false; } if ( $aioseop_options['aiosp_can'] ) { if ( ! empty( $aioseop_options['aiosp_customize_canonical_links'] ) && ! empty( $opts['aiosp_custom_link'] ) ) { $fb_url_temp = $opts['aiosp_custom_link']; } if ( empty( $url ) ) { $fb_url_temp = $aiosp->aiosp_mrt_get_url( $wp_query, $show_page ); } $fb_url_temp = $aiosp->validate_url_scheme( $fb_url_temp ); $fb_url_temp = apply_filters( 'aioseop_canonical_url', $fb_url_temp ); } var_dump($fb_url_temp); $fb_url = wp_strip_all_tags( trim($fb_url_temp)!='' ? trim($fb_url_temp) : $fb_url, true);*/ //Description - Why are we getting the first post description on archives and homepage...?!? if (is_home() && !is_front_page()) { $post = aiosp_common::get_blog_page(); } else { $post = $aiosp->get_queried_object(); } $fb_desc_temp = apply_filters('aioseop_description', $aiosp->get_main_description($post)); $fb_desc = wp_strip_all_tags(trim($fb_desc_temp) != '' ? trim($fb_desc_temp) : $fb_desc, true); } } //Apply Filters $fb_locale = apply_filters('fb_og_locale', $fb_locale); $fb_title = apply_filters('fb_og_title', $fb_title); $fb_url = apply_filters('fb_og_url', $fb_url); $fb_type = apply_filters('fb_og_type', $fb_type); $fb_desc = apply_filters('fb_og_desc', $fb_desc); $fb_image = apply_filters('fb_og_image', $fb_image); $fb_image_additional = apply_filters('fb_og_image_additional', $fb_image_additional); //Image size $fb_image_size = false; if (intval($this->options['fb_image_show']) == 1 && trim($fb_image) != '') { if (intval($this->options['fb_image_size_show']) == 1) { if (isset($this->image_size) && is_array($this->image_size)) { //Already fetched $fb_image_size = $this->image_size; } else { $fb_image_size = $this->get_open_graph_image_size($fb_image); } } } else { $this->options['fb_image_show'] = 0; } //Image overlay - Single? if (intval($this->options['fb_image_show']) == 1 && intval($this->options['fb_image_overlay']) == 1 && apply_filters('fb_og_image_overlay', true, $fb_image)) { //Single $temp_fb_image_overlay = $this->get_image_with_overlay($fb_image); if ($temp_fb_image_overlay['overlay']) { $fb_image = $temp_fb_image_overlay['fb_image']; //We know the exact size now. We better just show it, right? $this->options['fb_image_size_show'] = 1; $fb_image_size = array(WEBDADOS_FB_W, WEBDADOS_FB_H); } //Additional if (isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) > 0) { foreach ($fb_image_additional as $key => $value) { if ($value['png_overlay']) { $temp_fb_image_overlay = $this->get_image_with_overlay($value['fb_image']); if ($temp_fb_image_overlay['overlay']) { $fb_image_additional[$key]['fb_image'] = $temp_fb_image_overlay['fb_image']; } } } } } //No spaces on URLs if (isset($fb_url) && trim($fb_url) != '') { $fb_url = str_replace(' ', '%20', trim($fb_url)); } if (isset($fb_publisher) && trim($fb_publisher) != '') { $fb_publisher = str_replace(' ', '%20', trim($fb_publisher)); } if (isset($fb_publisher_schema) && trim($fb_publisher_schema) != '') { $fb_publisher_schema = str_replace(' ', '%20', trim($fb_publisher_schema)); } if (isset($fb_author) && trim($fb_author) != '') { $fb_author = str_replace(' ', '%20', trim($fb_author)); } if (isset($fb_author_linkrelgp) && trim($fb_author_linkrelgp) != '') { $fb_author_linkrelgp = str_replace(' ', '%20', trim($fb_author_linkrelgp)); } if (isset($fb_image) && trim($fb_image) != '') { $fb_image = str_replace(' ', '%20', trim($fb_image)); } if (isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional)) { foreach ($fb_image_additional as $key => $value) { $fb_image_additional[$key]['fb_image'] = str_replace(' ', '%20', trim($value['fb_image'])); } } //If there's still no description let's just add the title as a last resort if (trim($fb_desc) == '') { $fb_desc = $fb_title; } //Print tags // Facebook $html .= ' <!-- Facebook Open Graph --> '; //Locale if (intval($this->options['fb_locale_show']) == 1) { $html .= ' <meta property="og:locale" content="' . trim(esc_attr(trim($this->options['fb_locale']) != '' ? trim($this->options['fb_locale']) : trim(get_locale()))) . '"/> '; } //Site name if (intval($this->options['fb_sitename_show']) == 1) { $html .= ' <meta property="og:site_name" content="' . trim(esc_attr(get_bloginfo('name'))) . '"/> '; } //Title if (intval($this->options['fb_title_show']) == 1 && trim($fb_title) != '') { $html .= ' <meta property="og:title" content="' . trim(esc_attr($fb_title)) . '"/> '; } //URL if (intval($this->options['fb_url_show']) == 1 && trim($fb_url) != '') { $html .= ' <meta property="og:url" content="' . trim(esc_attr($fb_url)) . '"/> '; } //Type if (intval($this->options['fb_type_show']) == 1 && trim($fb_type) != '') { $html .= ' <meta property="og:type" content="' . trim(esc_attr($fb_type)) . '"/> '; } //Description if (intval($this->options['fb_desc_show']) == 1 && trim($fb_desc) != '') { $html .= ' <meta property="og:description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } //Image if (intval($this->options['fb_image_show']) == 1 && trim($fb_image) != '') { $html .= ' <meta property="og:image" content="' . trim(esc_attr($fb_image)) . '"/> '; } //Additional Images if (intval($this->options['fb_image_show']) == 1 && isset($fb_image_additional) && is_array($fb_image_additional) && count($fb_image_additional) > 0) { foreach ($fb_image_additional as $fb_image_additional_temp) { $html .= ' <meta property="og:image" content="' . trim(esc_attr($fb_image_additional_temp['fb_image'])) . '"/> '; } } else { //Image Size - We only show the image size if we only have one image if (intval($this->options['fb_image_size_show']) == 1 && isset($fb_image_size) && is_array($fb_image_size)) { $html .= ' <meta property="og:image:width" content="' . intval(esc_attr($fb_image_size[0])) . '"/> <meta property="og:image:height" content="' . intval(esc_attr($fb_image_size[1])) . '"/> '; } } //Dates if (intval($this->options['fb_article_dates_show']) == 1 && trim($fb_article_pub_date) != '') { $html .= ' <meta property="article:published_time" content="' . trim(esc_attr($fb_article_pub_date)) . '"/> '; } if (intval($this->options['fb_article_dates_show']) == 1 && trim($fb_article_mod_date) != '') { $html .= ' <meta property="article:modified_time" content="' . trim(esc_attr($fb_article_mod_date)) . '" /> <meta property="og:updated_time" content="' . trim(esc_attr($fb_article_mod_date)) . '" /> '; } //Sections if (intval($this->options['fb_article_sections_show']) == 1 && isset($fb_sections) && is_array($fb_sections) && count($fb_sections) > 0) { foreach ($fb_sections as $fb_section) { $html .= ' <meta property="article:section" content="' . trim(esc_attr($fb_section)) . '"/> '; } } //Author if (intval($this->options['fb_author_show']) == 1 && $fb_author != '') { $html .= ' <meta property="article:author" content="' . trim(esc_attr($fb_author)) . '"/> '; } //Publisher if (intval($this->options['fb_publisher_show']) == 1 && trim($fb_publisher) != '') { $html .= ' <meta property="article:publisher" content="' . trim(esc_attr($fb_publisher)) . '"/> '; } //App ID if (intval($this->options['fb_app_id_show']) == 1 && trim($this->options['fb_app_id']) != '') { $html .= ' <meta property="fb:app_id" content="' . trim(esc_attr($this->options['fb_app_id'])) . '"/> '; } //Admins if (intval($this->options['fb_admin_id_show']) == 1 && trim($this->options['fb_admin_id']) != '') { $html .= ' <meta property="fb:admins" content="' . trim(esc_attr($this->options['fb_admin_id'])) . '"/> '; } // Schema $html .= ' <!-- Google+ / Schema.org --> '; //Title if (intval($this->options['fb_title_show_schema']) == 1 && trim($fb_title) != '') { $html .= ' <meta itemprop="name" content="' . trim(esc_attr($fb_title)) . '"/> '; } //Description if (intval($this->options['fb_desc_show_schema']) == 1 && trim($fb_desc) != '') { $html .= ' <meta itemprop="description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } //Image if (intval($this->options['fb_image_show_schema']) == 1 && trim($fb_image) != '') { $html .= ' <meta itemprop="image" content="' . trim(esc_attr($fb_image)) . '"/> '; } //Author if (intval($this->options['fb_author_show_linkrelgp']) == 1 && trim($fb_author_linkrelgp) != '') { $html .= ' <link rel="author" href="' . trim(esc_attr($fb_author_linkrelgp)) . '"/> '; } //Publisher if (intval($this->options['fb_publisher_show_schema']) == 1 && trim($fb_publisher_schema) != '') { $html .= ' <link rel="publisher" href="' . trim(esc_attr($fb_publisher_schema)) . '"/> '; } // Twitter $html .= ' <!-- Twitter Cards --> '; //Title if (intval($this->options['fb_title_show_twitter']) == 1 && trim($fb_title) != '') { $html .= ' <meta name="twitter:title" content="' . trim(esc_attr($fb_title)) . '"/> '; } //URL if (intval($this->options['fb_url_show_twitter']) == 1 && trim($fb_url) != '') { $html .= ' <meta name="twitter:url" content="' . trim(esc_attr($fb_url)) . '"/> '; } //Description if (intval($this->options['fb_desc_show_twitter']) == 1 && trim($fb_desc) != '') { $html .= ' <meta name="twitter:description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } //Image if (intval($this->options['fb_image_show_twitter']) == 1 && trim($fb_image) != '') { $html .= ' <meta name="twitter:image" content="' . trim(esc_attr($fb_image)) . '"/> '; } //Twitter Card if (intval($this->options['fb_title_show_twitter']) == 1 || intval($this->options['fb_url_show_twitter']) == 1 || intval($this->options['fb_desc_show_twitter']) == 1 || intval($this->options['fb_publisher_show_twitter']) == 1 || intval($this->options['fb_image_show_twitter']) == 1) { $html .= ' <meta name="twitter:card" content="' . trim(esc_attr($this->options['fb_twitter_card_type'])) . '"/> '; } //Author if (intval($this->options['fb_author_show_twitter']) == 1 && trim($fb_author_twitter) != '') { $html .= ' <meta name="twitter:creator" content="@' . trim(esc_attr($fb_author_twitter)) . '"/> '; } //Publisher if (intval($this->options['fb_publisher_show_twitter']) == 1 && trim($fb_publisher_twitteruser) != '') { $html .= ' <meta name="twitter:site" content="@' . trim(esc_attr($fb_publisher_twitteruser)) . '"/> '; } // SEO $html .= ' <!-- SEO --> '; //Title if (intval($fb_set_title_tag) == 1 && trim($fb_title) != '') { //Does nothing so far. We try to create the <title> tag but it's too late now //We should use wp_title(), but do we want to? This is only because Business Directory Plugin and they seem to have it covered by now... } //URL if (intval($this->options['fb_url_canonical']) == 1) { $html .= ' <link rel="canonical" href="' . trim(esc_attr($fb_url)) . '"/> '; } //Description if (intval($this->options['fb_desc_show_meta']) == 1 && trim($fb_desc) != '') { $html .= ' <meta name="description" content="' . trim(esc_attr($fb_desc)) . '"/> '; } //Author if (intval($this->options['fb_author_show_meta']) == 1 && $fb_author_meta != '') { $html .= ' <meta name="author" content="' . trim(esc_attr($fb_author_meta)) . '"/> '; } //Publisher if (intval($this->options['fb_publisher_show_meta']) == 1) { $html .= ' <meta name="publisher" content="' . trim(esc_attr(get_bloginfo('name'))) . '"/> '; } // SEO $html .= ' <!-- Misc. tags --> '; foreach ($fb_additional_tags as $type => $tags) { foreach ($tags as $tag => $values) { foreach ($values as $value) { $html .= ' <meta ' . $type . '="' . str_replace('_', ':', trim($tag)) . '" content="' . trim(esc_attr($value)) . '"/> '; } } } //Close tag $html .= '<!-- END - ' . WEBDADOS_FB_PLUGIN_NAME . ' ' . WEBDADOS_FB_VERSION . ' --> '; echo $html; }
protected function content($atts, $content = null) { $atts = function_exists('vc_map_get_attributes') ? vc_map_get_attributes('kt_featured_products', $atts) : $atts; $atts = shortcode_atts(array('title' => __('Hot Categories', 'kutetheme'), 'size' => 'kt_shop_catalog_270', 'display_type' => '1', 'box_type' => 'featured', 'ids' => '', 'number' => 4, 'css_animation' => '', 'el_class' => '', 'css' => '', 'autoplay' => 'false', 'navigation' => 'false', 'margin' => 30, 'slidespeed' => 200, 'css' => '', 'el_class' => '', 'loop' => 'false', 'use_responsive' => 1, 'items_destop' => 3, 'items_tablet' => 2, 'items_mobile' => 1), $atts); extract($atts); $elementClass = array('base' => apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' trending ', $this->settings['base'], $atts), 'extra' => $this->getExtraClass($el_class), 'css_animation' => $this->getCSSAnimation($css_animation), 'shortcode_custom' => vc_shortcode_custom_css_class($css, ' ')); $elementClass = preg_replace(array('/\\s+/', '/^\\s|\\s$/'), array(' ', ''), implode(' ', $elementClass)); $data_carousel = array("autoplay" => $autoplay, "nav" => $navigation, "margin" => $margin, "smartSpeed" => $slidespeed, "theme" => 'style-navigation-bottom', "autoheight" => 'false', 'dots' => 'false', 'loop' => $loop, 'autoplayTimeout' => 1000, 'autoplayHoverPause' => 'true'); ob_start(); $args = array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $number); if ($ids) { $ids = explode(',', $ids); } else { $ids = array(); } if ($box_type == 'by_id') { $args = array('post_type' => 'product', 'post__in' => $ids); } $products = get_posts($args); $count = count($products); $per_page = 2; $loop = false; if ($count > 2) { $loop = true; } ?> <!-- Style 1 --> <?php if ($display_type == 1) { ?> <div class=" <?php echo esc_attr($elementClass); ?> "> <?php if ($title) { ?> <h2 class="trending-title"><?php echo esc_html($title); ?> </h2> <?php } ?> <div class="trending-product owl-carousel nav-center" data-items="1" data-dots="false" data-nav="true" data-autoplay="true" <?php if ($loop) { ?> data-loop="true" <?php } ?> > <?php $page = 1; if ($count % $per_page == 0) { $page = $count / $per_page; } else { $page = $count / $per_page + 1; } ?> <?php for ($i = 1; $i <= $page; $i++) { ?> <ul> <?php $from = ($i - 1) * $per_page; $to = $i * $per_page; for ($from; $from < $to; $from++) { if (isset($products[$from]) && $products[$from]) { $p = $products[$from]; $product = new WC_Product($p->ID); ?> <li> <div class="product-container"> <div class="product-image"> <a href="<?php echo get_permalink($p->ID); ?> "> <?php echo get_the_post_thumbnail($p->ID, $size); ?> </a> </div> <div class="product-info"> <h5 class="product-name"> <a href="<?php echo get_permalink($p->ID); ?> "><?php echo esc_html($p->post_title); ?> </a> </h5> <div class="product-price"> <?php echo $product->get_price_html(); ?> </div> </div> </div> </li> <?php } } ?> </ul> <?php } ?> </div> </div> <?php } ?> <!-- Style 2 --> <?php if ($display_type == 2) { ?> <?php $products = new WP_Query($args); ?> <?php if ($use_responsive) { $arr = array('0' => array("items" => $items_mobile), '768' => array("items" => $items_tablet), '992' => array("items" => $items_destop)); $data_responsive = json_encode($arr); $data_carousel["responsive"] = $data_responsive; if ($products->post_count < $items_mobile || $products->post_count < $items_tablet || $products->post_count < $items_destop) { $data_carousel['loop'] = 'false'; } else { $data_carousel['loop'] = $loop; } } else { $data_carousel['items'] = 3; if ($products->post_count < 3) { $data_carousel['loop'] = 'false'; } else { $data_carousel['loop'] = $loop; } } ?> <div class="section8 block-trending <?php echo esc_attr($elementClass); ?> "> <h3 class="section-title"><?php echo esc_html($title); ?> </h3> <?php if ($products->have_posts()) { ?> <ul class="products-style8 owl-carousel" <?php echo _data_carousel($data_carousel); ?> > <?php while ($products->have_posts()) { $products->the_post(); ?> <li class="product autoHeight-item"> <div class="product-container"> <div class="product-thumb"> <?php $product = new WC_Product(get_the_ID()); $attachment_ids = $product->get_gallery_attachment_ids(); $secondary_image = ''; if ($attachment_ids) { $secondary_image = wp_get_attachment_image($attachment_ids[0], $size); } if (has_post_thumbnail()) { ?> <a class="primary_image" href="<?php the_permalink(); ?> "><?php the_post_thumbnail($size); ?> </a> <?php } else { ?> <a class="primary_image" href="<?php the_permalink(); ?> "><?php echo wc_placeholder_img($size); ?> </a> <?php } if ($secondary_image != "") { ?> <a class="secondary_image" href="<?php the_permalink(); ?> "><?php echo $secondary_image; ?> </a> <?php } else { ?> <a class="secondary_image" href="<?php the_permalink(); ?> "><?php echo wc_placeholder_img($size); ?> </a> <?php } ?> <?php kt_get_tool_quickview(); ?> <div class="product-label"><?php do_action('kt_loop_product_label'); ?> </div> </div> <div class="product-info"> <div class="product-name"> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <div class="box-price"> <?php do_action('kt_after_shop_loop_item_title'); ?> </div> <div class="button-control"> <?php kt_get_tool_compare(); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php kt_get_tool_wishlish(); ?> </div> </div> </div> </li> <?php } ?> </ul> <?php } ?> . </div> <?php } ?> <?php wp_reset_postdata(); $result = ob_get_contents(); ob_end_clean(); return $result; }