PATH:
home
/
lab2454c
/
adenbic.com
/
wp-content
/
plugins
/
templatemela-shortcodes
/
shortcodes
<?php /***************** Blog Posts ****************/ function shortcode_blog_posts_container($atts, $content = null, $code) { extract(shortcode_atts(array( 'type' => 'grid', 'items_per_column' => '5', 'number_of_posts' => '10', 'category' => '', 'width' => '386', 'height' => '250', 'linkurl' => '', 'linktext' => '', 'excerpt_length' => '75' ), $atts)); $linktextvariable = ""; if(!empty($linkurl) || !empty($linkurl)): $linktextvariable .= '<div class="blog-more-link"><a href='.$linkurl.'>'.$linktext.'</a></div>'; endif; if(!empty($category)): $term_id = $category; $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $number_of_posts, 'orderby' => 'date', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => $term_id ) ) ); else: $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $number_of_posts, 'orderby' => 'date', ); endif; $i = 1; wp_reset_postdata(); $output = ''; $blog_array = new WP_Query( $args ); $count = $blog_array->post_count; $output = ''; $style=''; if ( $blog_array->have_posts() ): $output .= '<div id="blog-posts-products" class="blog-posts-content posts-content '.$type.'">'; if($type == "slider") { if($count > $items_per_column) $output .= '<div id="'.$items_per_column.'_blog_carousel" class="slider blog-carousel style-'.$style.'">'; else $output .= '<div id="blog_grid" class="blog-grid grid cols-'.$items_per_column.'">'; } else { $output .= '<div id="blog_grid" class="blog-grid grid cols-'.$items_per_column.'">'; } while ( $blog_array->have_posts() ) : $blog_array->the_post(); if($i % $items_per_column == 1 ) $class = " first"; elseif($i % $items_per_column == 0 ) $class = " last"; else $class = ""; $post_date = get_the_date(); $post_author = get_the_author(); if ( has_post_thumbnail() && ! post_password_required() ) : $post_thumbnail_id = get_post_thumbnail_id(); $image = wp_get_attachment_url( $post_thumbnail_id ); else: $image = get_template_directory_uri()."/images/megnor/placeholder.png"; endif; $src = tmpmela_mr_image_resize($image, $width, $height, true, 't', false); if( empty ( $src ) || $src == 'image_not_specified' ): $src = get_template_directory_uri()."/images/megnor/placeholder.png"; $src = tmpmela_mr_image_resize($src, $width, $height, true, 't', false); endif; $output .= '<div class="item container '.$class.'">'; $output .= '<div class="container-inner">'; $output .= '<div class="post-image-outer"><div class="post-image">'; $output .= '<img src="'.$src.'" title="'.get_the_title().'" alt="'.get_the_title().'" />'; $output .= '<div class="block_hover">'; $output .= '<div class="links">'; $output .= '<a href="'.$image.'" class="icon mustang-gallery"><i class="fa fa-eye"></i></a>'; $output .= '<a href="'.get_permalink().'" class="icon"><i class="fa fa-link"></i></a>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div></div>'; $output .= '<div class="post-content-outer">'; $output .= '<div class="entry-meta-blog"><div class="meta-inner-blog">'; $output .= '<span class="entry-date-blog"><span class="day-year-blog"><span class="fa fa-calendar-o"></span>'.$post_date.'</span></span>'; $output .= '</div></div>'; $output .= '<div class="post-title"><h3><a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a></h3></div>'; $output .= '<div class="post-description"><p>'.tmpmela_blog_post_excerpt($excerpt_length).'</p></div>'; $output .= '<div class="read-more"><a class="button" href="'.get_permalink().'" title="'.get_the_title().'">'.esc_html__('Read More', 'kartwow').'</a></div>'; $output .= '</div>'; $output .= '</div></div>'; $i++; endwhile; $output .= $linktextvariable; wp_reset_postdata(); $output .= '</div></div>'; else: $output .= '<div class="no-result">'.esc_html__('No results found...', 'kartwow').'</div>'; endif; return $output; } add_shortcode('blog_posts', 'shortcode_blog_posts_container'); /***** Product Category Tabs List******/ function shortcode_category_tabs($atts, $content = null){ extract(shortcode_atts(array( 'tab1_text' => '', 'tab2_text' => '', 'tab3_text' => '', 'tab4_text' => '', ), $atts)); $output = ''; $output .= '<div id="horizontalTab">'; $output .= '<ul class="resp-tabs-list">'; if(!empty($tab1_text)): $output .= '<li ><div class="tab-title">'.$tab1_text.'</div></li>'; endif; if(!empty($tab2_text)): $output .= '<li ><div class="tab-title">'.$tab2_text.'</div></li>'; endif; if(!empty($tab3_text)): $output .= '<li ><div class="tab-title">'.$tab3_text.'</div></li>'; endif; $output .= '</ul>'; $output .= '<div class="resp-tabs-container">'; $output .= do_shortcode($content); $output .= '</div>'; $output .= '</div>'; return $output; } add_shortcode('woo_categories', 'shortcode_category_tabs'); add_shortcode('woo_categories', 'shortcode_category_tabs'); /*************** Woo Category Slider & Grid **************/ function shortcode_woo_product_categories($atts, $content = null) { extract(shortcode_atts(array( 'type' => 'grid', 'style' => '1', 'items_per_column' => '3', 'height' => '366', 'width' => '366', 'child_category' => '', 'hide_empty' => '1', 'items_per_page' => '10', 'target' => '_self', 'link_text' => '', 'count_display' => 'yes', ), $atts)); $category_ids_array = explode(",",'product_cat'); $output = ''; $name=''; $category_link_text=''; if($link_text !== ""){ $category_link_text= '<span class="cat-all-category"><a class="button cat_name" target="'.$target.'" href="'.$link_text.'">'.esc_html__('View All', 'kartwow').'</a></span>'; } $readmore=''; if($type == "slider"){ $output .= '<div class="woo_categories_slider woo_categories_block">'; $output .= '<div id="'.$items_per_column.'_category_carousel" class="category-carousel">'; } else{ $output .= '<div class="woo_categories_grid woo_categories_block">'; $output .= '<div id="'.$items_per_column.'_category_grid" class="columns-'.$items_per_column.'">'; } $args = array( 'parent' => $child_category, 'hide_empty' => $hide_empty, 'taxonomy' => 'product_cat', 'number' => $items_per_page, ); $categories = get_categories( $args ); foreach($categories as $cat){ $category_ids = get_term( $cat, 'product_cat' ); $thumbnail_id = get_term_meta( $cat->term_id, 'thumbnail_id', true ); if( empty ($thumbnail_id)): $src = get_template_directory_uri()."/images/megnor/placeholder.png"; else: $image = wp_get_attachment_url( $thumbnail_id ); $src = tmpmela_mr_image_resize($image, $width, $height, true, 't', false); endif; $output .= '<div class="cat-outer-block style-'.$style.'">'; $output .= '<div class="cat-inner-block">'; $output .= '<div class="cat_description">'; $output .= '<a class="cat_name" target="'.$target.'" href="'.get_category_link( $category_ids ).'" title="'.$cat->name.'">'.$cat->name.'</a>'; $output .= '<div class="cat_sub_description">'.$cat->description.'</div>'; if($count_display == 'yes' ): $output .= '<div class="cat-desc">('.$cat->count.' '.esc_html__('Items').')</div>'; endif; $output .= '<div class="cat-img-block">'; $output .= '<a class="cat-img" target="'.$target.'" href="'.get_category_link( $category_ids ).'" title="'.$cat->name.'" >'; $output .= '<img src="'.$src.'" title="'.$cat->name.'" alt="'.$cat->name.'" height="'.$height.'" width="'.$width.'"/>'; $output .= '</a>'; $output .= '</div>'; $output .= '<a class="tm_cat_content" target="'.$target.'" href="'.get_category_link( $category_ids ).'" title="'.$cat->name.'"><span class="short_title"><span class="short_title-inner">'.esc_html__('Shop Now ').'</span></span></a>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; } $output .= '</div>'; $output .= $category_link_text; $output .= '</div>'; return $output; } if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) : add_shortcode("woo_product_categories", "shortcode_woo_product_categories"); endif; /***************** Faqs *****************/ function shortcode_faqs($atts, $content = null, $code) { extract(shortcode_atts(array( 'style' => '1', 'category' => '' ), $atts)); $output = ''; $output .= '<div class="faqs-container">'; $output .= '<div class="faqs-content style-'.$style.'">'; if(!empty($category)): $term_id = $category; $args = array( 'post_type' => 'faq', 'post_status' => 'publish', 'posts_per_page' => '50', 'tax_query' => array( array( 'taxonomy' => 'faq_categories', 'field' => 'id', 'terms' => $term_id ) ) ); query_posts($args); $term = get_term( $term_id, 'faq_categories' ); if(!empty($term)): $output .= '<h3 class="small-title">'.$term->name.'</h3>'; endif; $output .= '<div class="faqs-category-container">'; while (have_posts()) : the_post(); if($style == '1'): $output .= '<div class="single-faq toogle_div">'; $output .= '<a class="tog" href="#"><span class="faq_title">'. get_the_title() .' </span></a>'; $output .= '<div class="tab_content">'.get_the_content().'</div>'; $output .= '</div>'; endif; if($style == '2'): $output .= '<div class="single-faq">'; $output .= '<div class="title">'.get_the_title().'</div>'; $output .= '<div class="content">'.get_the_content().'</div>'; $output .= '</div>'; endif; endwhile; $output .= '</div>'; else: $categories = get_categories('hide_empty=0&orderby=name&taxonomy=faq_categories'); foreach ($categories as $category_item ) { $args = array( 'post_type' => 'faq', 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'faq_categories', 'field' => 'id', 'terms' => $category_item->term_id ) ) ); query_posts($args); $output .= '<h3 class="small-title">'.$category_item->name.'</h3>'; $output .= '<div class="faqs-category-container">'; while (have_posts()) : the_post(); if($style == '1'): $output .= '<div class="single-faq toogle_div">'; $output .= '<a class="tog" href="#"><span class="faq_title">'. get_the_title() .' </span></a>'; $output .= '<div class="tab_content">'.get_the_content().'</div>'; $output .= '</div>'; endif; if($style == '2'): $output .= '<div class="single-faq">'; $output .= '<div class="title">'.get_the_title().'</div>'; $output .= '<div class="content">'.get_the_content().'</div>'; $output .= '</div>'; endif; endwhile; $output .= '</div>'; } endif; $output .= '</div>'; $output .= '</div>'; wp_reset_query(); return $output; } add_shortcode('faqs', 'shortcode_faqs'); /***************** Portfolio Filter ****************/ function shortcode_portfolio_filter_container($atts, $content = null, $code) { global $logotype; extract(shortcode_atts(array( 'items_per_column' => 4, 'align' => '', 'width' => '', 'height' => '' ), $atts)); $categories = get_categories('hide_empty=0&orderby=name&taxonomy=portfolio_categories'); $output = ''; $output .= '<div class="clearfix portfolio-filter-container filter-container">'; $output .= '<section id="portfolio_filter_options" class="options category-container">'; $output .= '<ul id="filters" class="option-set" data-option-key="filter">'; $output .= '<li><a href="#show-all" data-option-value="*" class="selected">Show All</a></li>'; foreach ($categories as $category_item ) { $output .= '<li><a href="#'.$category_item->slug.'" data-option-value=".'.$category_item->slug.'">'.$category_item->cat_name.'</a></li>'; } $output .= '</ul></section>'; $output .= '<div class="portfolio-filter-outer portfolios">'; $output .= '<div id="portfolio_filter" class="portfolio-container portfolio-filter clearfix da-thumbs portfolio-cols-'.$items_per_column.'">'; foreach ($categories as $category_item ): $paged = ( isset( $my_query_array['paged'] ) && !empty( $my_query_array['paged'] ) ) ? $my_query_array['paged'] : 1; $args = array( 'post_type' => 'portfolio', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'portfolio_categories', 'field' => 'id', 'terms' => $category_item->term_id, 'paged' => $paged ) ) ); query_posts($args); while (have_posts()) : the_post(); $image = tmpmela_get_first_post_images(get_the_ID()); $src = tmpmela_mr_image_resize($image, $width, $height, true, 't', false); if( empty ( $src ) || $src == 'image_not_specified' ): $src = get_template_directory_uri()."/images/megnor/placeholder.png"; $src = tmpmela_mr_image_resize($src, $width, $height, true, false); endif; $output .= '<div class="'.$category_item->slug.' main item single-portfolio">'; $output .= '<div class="image image-block">'; $output .= '<img src="'.$src.'" title="'.get_the_title().'" alt="'.get_the_title().'" />'; $output .= '<div class="block_hover"><div class="block_hover_inner">'; $output .= '<h3 class="entry-title">'.get_the_title().'</h3>'; $output .= '<div class="links">'; $output .= '<a href="'.$image.'" class="icon mustang-gallery"><i class="fa fa-eye"></i></a>'; $output .= '<a href="'.get_permalink().'" class="icon"><i class="fa fa-link"></i></a>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div></div>'; $output .= '</div>'; endwhile; endforeach; wp_reset_query(); $output .= '</div></div></div>'; return $output; } add_shortcode('tmpmela_portfolio_filter', 'shortcode_portfolio_filter_container'); /***************** Portfolio Slider ****************/ function shortcode_portfolio_slider_container($atts, $content = null, $code) { global $logotype; extract(shortcode_atts(array( 'category' => '', 'items_per_column' => 3, 'number_of_posts' => 10, 'width' => '', 'height' => '', 'excerpt_length' => '100' ), $atts)); if(!empty($category)): $term_id = $category; $args = array( 'post_type' => 'portfolio', 'post_status' => 'publish', 'posts_per_page' => $number_of_posts, 'tax_query' => array( array( 'taxonomy' => 'portfolio_categories', 'field' => 'id', 'terms' => $term_id ) ) ); else: $args = array( 'post_type' => 'portfolio', 'post_status' => 'publish', 'posts_per_page' => "'".$number_of_posts."'" ); endif; $array_posts = query_posts($args); $count = count($array_posts); $output = ''; if($count > 0): $output .= '<div class="portfolio-container">'; $output .= '<div id="'.$items_per_column.'_portfolio_carousel" class="portfolio-carousel cols-'.$items_per_column.'">'; $i = 1; while (have_posts()) : the_post(); if($i % $items_per_column == 1 ) $class = "first"; elseif($i % $items_per_column == 0 ) $class = "last"; else $class = ""; $image = tmpmela_get_first_post_images(get_the_ID()); $image_src = tmpmela_mr_image_resize($image, $width, $height, true, 't', false); if(empty($image_src)) $image_src = get_template_directory_uri()."/images/megnor/placeholder.png"; $output .= '<div class="item portfolio-main">'; $output .= '<div class="product-block single-portfolio '.$class.'">'; $output .= '<div class="portfolio-image">'; $output .= '<img src="'.$image_src.'" title="'.get_the_title().'" alt="'.get_the_title().'" />'; $output .= '<div class="block_hover">'; $output .= '<div class="links">'; $output .= '<a href="'.$image.'" title="Click to view Full Image" class="icon mustang-gallery"><i class="fa fa-eye"></i></a>'; $output .= '<a href="'.get_permalink().'" title="'.esc_html__('Click to view read more', 'kartwow').'" class="icon"><i class="fa fa-link"></i></a>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '<div class="portfolio-title"><a href="'.get_permalink().'">'.get_the_title().'</a></div>'; $output .= '<div class="portfolio-description">'.tmpmela_portfolio_excerpt($excerpt_length ).'</div>'; $output .= '<div class="read-more"><a href="'.get_permalink().'" title="'.get_the_title().'">'.esc_html__('Read more', 'kartwow').'</a></div>'; $output .= '</div>'; $output .= '</div>'; $i++; endwhile; $output .= '</div>'; wp_reset_query(); $output .= '</div>'; else: $output .= '<div class="no-result">'.esc_html__(''.esc_html__('No results found...', 'kartwow').'', 'kartwow').'</div>'; endif; return $output; } add_shortcode('tmpmela_portfolio_slider', 'shortcode_portfolio_slider_container'); /***************** Portfolio Grid ****************/ function shortcode_portfolio($atts, $content = null, $code) { extract(shortcode_atts(array( 'column' => 4, 'cat' => '', 'max' => '12', 'width' => '', 'height' => '', 'excerpt_length' => '100' ), $atts)); $output = ''; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $terms = array(); if ($cat != '') { $cat = preg_replace('/\s*,\s*/', ',', $cat); foreach(explode(',', $cat) as $term_name) { $terms[] = get_term_by('name', $term_name, 'portfolio_categories'); } foreach($terms as $term) { $term_ids[] = $term->term_id; } $args = array( 'posts_per_page' => $max, 'paged' => $paged, 'post_type' => 'portfolio', 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'portfolio_categories', 'field' => 'id', 'terms' => $term_ids ) ) ); } else { $args = array( 'posts_per_page' => $max, 'paged' => $paged, 'post_type' => 'portfolio', 'post_status' => 'publish' ); } query_posts($args); $output = '<div class="portfolios">'; $output .= '<ul class="portfolio_'.$column.'column da-thumbs">'; $num_layout = substr($column, 0, 1); $i = 1; while(have_posts()) { the_post(); $terms = get_the_terms(get_the_ID(), 'portfolio_categories'); if ( strlen( $img = get_the_post_thumbnail( get_the_ID()) ) ): $image = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) ); else: $image = tmpmela_get_first_post_images(get_the_ID()); endif; $src = tmpmela_mr_image_resize($image, $width, $height, true, 't',false); if( empty ( $src ) || $src == 'image_not_specified' ): $src = get_template_directory_uri()."/images/megnor/placeholder.png"; $image = $src; $src = tmpmela_mr_image_resize($image, $width, $height, true, 't',false); endif; ?> <?php $terms_slug = array(); if (is_array($terms)) { foreach($terms as $term) { $terms_slug[] = $term->slug; } } if($i % $num_layout == 0) $li_class = "last"; else if($i % $num_layout == 1) $li_class = "first"; else $li_class = "inner"; $output .= '<li class="'.$li_class.'">'; $more = get_post_meta(get_the_ID(), '_more', true); $output .= '<div class="main"><div class="image-block">'; if(get_option('portfolio','display_image') || $column == 1): $output .= '<a href= "'.$image.'" class="mustang-gallery">'; $output .= '<img class="image1" src="'.$src.'"/ >'; $output .= '</a>'; endif; $output .= '<div class="block_hover">'; $output .= '<div class="links">'; $output .= '<a href="'.$image.'" title="Click to view Full Image" class="icon mustang-gallery"><i class="fa fa-eye"></i></a>'; $output .= '<a href="'.get_permalink().'" title="'.esc_html__('Click to view read more', 'kartwow').'" class="icon"><i class="fa fa-link"></i></a>'; $output .= '</div></div>'; $output .= '</div>'; $output .= '<h4><a class="portfolio-title" href="'.get_permalink().'">'.get_the_title().'</a></h4>'; $output .= tmpmela_excerpt_length_limit($excerpt_length); $output .= '</li>'; $i++; } $output .= '</ul>'; $output .= tmpmela_shortcode_paging_nav(); $output .= '</div>'; wp_reset_query(); return $output; } add_shortcode('tmpmela_portfolio', 'shortcode_portfolio'); /***************** Pricing Table ****************/ function shortcode_pricingtable($atts, $content = null) { extract(shortcode_atts(array( "heading" => '', "button_text" => '', "button_link" => '', "price" => '', "price_per" => '', "selected" => 'no', "target" => '_self', ), $atts)); if($selected == 'yes') { $selected = 'selected'; } $output = ''; $output .='<div class="pricing_wrapper">'; $output .='<div class="pricing_wrapper_inner '.$selected.'">'; if($heading != '' && $price_per != '' && $price != '') { $output .='<div class="pricing_heading">'.$heading.'</div>'; $output .='<div class="pricing_top">'; $output .='<div class="pricing_per">'.$price_per.'</div>'; $output .='<div class="pricing_price">'.$price.'</div></div>'; } else{ $output .='<div class="nopricing_heading"></div>'; $output .='<div class="nopricing_top"><div class="pricing_per"></div><div class="pricing_price"></div></div>'; } $output .='<div class="pricing_bottom">'; $output .='<ul>'; $output .= do_shortcode($content); $output .='</ul>'; $output .='<div class="pricing_button">'; if($button_text != '') { $output .='<a href="'.$button_link.'" target="'.$target.'" class="button" id="pricing-btn">'.$button_text .'</a>'; } $output .='</div></div>'; $output .='</div></div>'; return $output; } add_shortcode("tmpmela_pricingtable", "shortcode_pricingtable"); function shortcode_pricingtable_row($atts, $content = null){ extract(shortcode_atts(array( "symbol" => '', ), $atts)); $output = ''; if(!empty($symbol)) $output .= '<li><i class="fa '.$symbol.'"></i>'.do_shortcode($content).'</li>'; else $output .= '<li>'.do_shortcode($content).'</li>'; return $output; } add_shortcode('price_row', 'shortcode_pricingtable_row'); /***************** Products ****************/ function shortcode_woo_products_container($atts, $content = null, $code) { global $logotype; extract(shortcode_atts(array( 'type' => 'slider', 'items_per_column' => 5, 'product' => 'shop', 'classname' => '', 'no_more' => 'No more Products to display' ), $atts)); $logotype = $type; static $cnt = 1; $output = ''; $output .= '<div class="woo-products woo-content products_block '.$product.' '.$classname.'">'; if($type == "slider") { $output .= '<div id="'.$items_per_column.'_woo_carousel" class="woo-carousel cols-'.$items_per_column.'">'; } else { $output .= '<div class="woo_grid woo-grid cols-'.$items_per_column.'">'; } $output .= do_shortcode($content).'</div>'; if($type == "grid") { $output .= '<div class="tmpmela-message"><i class="fa fa-frown-o"></i>'.$no_more.'</div>'; $output .= '<div class="loadgridlist-wrapper"><button class="woocount loadgridlist">'.esc_html__('View More Products', 'kartwow').'</button></div>'; } $output .='</div>'; $cnt++; return $output; } add_shortcode('woo_products', 'shortcode_woo_products_container'); /************** Products Tabs **************/ function shortcode_product_tabs($atts, $content = null) { extract(shortcode_atts(array( 'tab1_text' => '', 'tab2_text' => '', 'tab3_text' => '', 'tab4_text' => '', ), $atts)); $output = ''; $output .= '<div id="horizontalTab">'; $output .= '<ul class="resp-tabs-list">'; if(!empty($tab1_text)): $output .= '<li ><div class="tab-title">'.$tab1_text.'</div></li>'; endif; if(!empty($tab2_text)): $output .= '<li ><div class="tab-title">'.$tab2_text.'</div></li>'; endif; if(!empty($tab3_text)): $output .= '<li ><div class="tab-title">'.$tab3_text.'</div></li>'; endif; if(!empty($tab4_text)): $output .= '<li ><div class="tab-title">'.$tab4_text.'</div></li>'; endif; $output .= '</ul>'; $output .= '<div class="resp-tabs-container">'; $output .= do_shortcode($content); $output .= '</div>'; $output .= '</div>'; return $output; } add_shortcode('tmpmela_product_tabs', 'shortcode_product_tabs'); function shortcode_product_tab($atts, $content = null){ extract(shortcode_atts(array( ), $atts)); $output = ''; $output .= do_shortcode($content); return $output; } add_shortcode('tmpmela_tab_home', 'shortcode_product_tab'); /***************** Our Team ****************/ function shortcode_ourteam($atts, $content = null) { extract(shortcode_atts(array( 'type' => '', 'items_per_column' => 4, 'image_width' => 285, 'image_height' => 370, 'number_of_posts' => -1 ), $atts)); global $post; $i = 1; $output = ''; wp_reset_postdata(); $args = array( 'posts_per_page' => $number_of_posts, 'post_status' => 'publish', 'post_type' => 'staff', 'orderby' => 'date' ); $output = ''; $team_array = new WP_Query( $args ); if ( $team_array->have_posts() ): $output .= '<div id="team-posts-products" class="team-posts-content staff-page posts-content">'; if($type == "slider") { $output .= '<div id="'.$items_per_column.'_team_carousel" class="team-carousel">'; } else { $output .= '<div id="team_grid" class="team-grid grid cols-'.$items_per_column.'">'; } while ( $team_array->have_posts() ) : $team_array->the_post(); get_post_meta(get_the_ID(), 'staff_position', TRUE) ? $staff_position = get_post_meta(get_the_ID(), 'staff_position', TRUE) : $staff_position = ''; get_post_meta(get_the_ID(), 'staff_link', TRUE) ? $staff_link = get_post_meta(get_the_ID(), 'staff_link', TRUE) : $staff_link = ''; get_post_meta(get_the_ID(), 'staff_phone', TRUE) ? $staff_phone = get_post_meta(get_the_ID(), 'staff_phone', TRUE) : $staff_phone = ''; get_post_meta(get_the_ID(), 'staff_email', TRUE) ? $staff_email = get_post_meta(get_the_ID(), 'staff_email', TRUE) : $staff_email = ''; get_post_meta(get_the_ID(), 'staff_twitter', TRUE) ? $staff_twitter = get_post_meta(get_the_ID(), 'staff_twitter', TRUE) : $staff_twitter = ''; get_post_meta(get_the_ID(), 'staff_facebook', TRUE) ? $staff_facebook = get_post_meta(get_the_ID(), 'staff_facebook', TRUE) : $staff_facebook = ''; get_post_meta(get_the_ID(), 'staff_google_plus', TRUE) ? $staff_google_plus = get_post_meta(get_the_ID(), 'staff_google_plus', TRUE) : $staff_google_plus = ''; get_post_meta(get_the_ID(), 'staff_linkedin', TRUE) ? $staff_linkedin = get_post_meta(get_the_ID(), 'staff_linkedin', TRUE) : $staff_linkedin = ''; get_post_meta(get_the_ID(), 'staff_youtube', TRUE) ? $staff_youtube = get_post_meta(get_the_ID(), 'staff_youtube', TRUE) : $staff_youtube = ''; get_post_meta(get_the_ID(), 'staff_rss', TRUE) ? $staff_rss = get_post_meta(get_the_ID(), 'staff_rss', TRUE) : $staff_rss = ''; get_post_meta(get_the_ID(), 'staff_pinterest', TRUE) ? $staff_pinterest = get_post_meta(get_the_ID(), 'staff_pinterest', TRUE) : $staff_pinterest = ''; get_post_meta(get_the_ID(), 'staff_skype', TRUE) ? $staff_skype = get_post_meta(get_the_ID(), 'staff_skype', TRUE) : $staff_skype = ''; $s = 0; if(!empty($staff_link)) $s++; if(!empty($staff_email)) $s++; if(!empty($staff_twitter)) $s++; if(!empty($staff_facebook)) $s++; if(!empty($staff_google_plus)) $s++; if(!empty($staff_linkedin)) $s++; if(!empty($staff_youtube)) $s++; if(!empty($staff_rss)) $s++; if(!empty($staff_pinterest)) $s++; if(!empty($staff_skype)) $s++; if($i % $items_per_column == 1 ) $class = " first"; elseif($i % $items_per_column == 0 ) $class = " last"; else $class = ""; if ( has_post_thumbnail() && ! post_password_required() ) : $post_thumbnail_id = get_post_thumbnail_id(); $image = wp_get_attachment_url( $post_thumbnail_id ); else: $image = get_template_directory_uri()."/images/megnor/placeholder.png"; endif; $src = tmpmela_mr_image_resize($image, $image_width, $image_height, true, 't', false); if( empty ( $src ) || $src == 'image_not_specified' ): $src = get_template_directory_uri()."/images/megnor/placeholder.png"; $src = tmpmela_mr_image_resize($src, $image_width, $image_height, true, 't', false); endif; $output .= '<article class="item container'.$class.'">'; $output .= '<div class="single-team container-inner">'; $output .= '<div class="staff-image">'; $output .= '<img src="'.$src.'" title="'.get_the_title().'" alt="'.get_the_title().'" />'; $output .= '<div class="staff-image-hover"></div>'; $output .= '</div>'; $output .= '<div class="staff-content">'; $shorttitle = substr(the_title('','',FALSE),0,150); if(!empty($shorttitle) && $shorttitle != '') $output .= '<div class="staff-name"><a title="'.get_the_title().'" href="'.get_permalink().'" >'.$shorttitle.'</a></div>'; if(!empty($staff_position) && $staff_position != '') $output .= '<div class="staff-position"><span>'.$staff_position.'</span></div>'; $content = substr(get_the_content('','',FALSE),0,70); $output .= '<div class="staff_content">'.$content.'</div>'; $output .= '<div class="staff-social icon-'.$s.'">'; if(!empty($staff_link) && $staff_link != '') $output .= '<a href="'.$staff_link.'" title="Website" class="website icon"><i class="fa fa-link"></i></a>'; if(!empty($staff_email) && $staff_email != '') $output .= '<a href="mailto:'.$staff_email.'" title="Email" class="email icon"><i class="fa fa-envelope"></i></a>'; if(!empty($staff_twitter) && $staff_twitter != '') $output .= '<a href="'.$staff_twitter.'" title="Twitter" class="twitter icon"><i class="fa fa-twitter"></i></a>'; if(!empty($staff_facebook) && $staff_facebook != '') $output .= '<a href="'.$staff_facebook.'" title="Facebook" class="facebook icon"><i class="fa fa-facebook"></i></a>'; if(!empty($staff_google_plus) && $staff_google_plus != '') $output .= '<a href="'.$staff_google_plus.'" title="Google Plus" class="google-plus icon"><i class="fa fa-google-plus"></i></a>'; if(!empty($staff_linkedin) && $staff_linkedin != '') $output .= '<a href="'.$staff_linkedin.'" title="Linkedin" class="linkedin icon"><i class="fa fa-linkedin"></i></a>'; if(!empty($staff_youtube) && $staff_youtube != '') $output .= '<a href="'.$staff_youtube.'" title="Youtube" class="youtube icon"><i class="fa fa-youtube"></i></a>'; if(!empty($staff_rss) && $staff_rss != '') $output .= '<a href="'.$staff_rss.'" title="RSS" class="rss icon"><i class="fa fa-rss"></i></a>'; if(!empty($staff_pinterest) && $staff_pinterest != '') $output .= '<a href="'.$staff_pinterest.'" title="Pinterest" class="pinterest icon"><i class="fa fa-pinterest"></i></a>'; if(!empty($staff_skype) && $staff_skype != '') $output .= '<a href="'.$staff_skype.'" title="Skype" class="skype icon"><i class="fa fa-skype"></i></a>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div></article>'; $i++; endwhile; wp_reset_postdata(); $output .= '</div></div>'; else: $output .= '<div class="no-result">'.esc_html__('No results found...', 'kartwow').'</div>'; endif; return $output; } add_shortcode("tmpmela_ourteam", "shortcode_ourteam"); /***************** Custom Testimonial ****************/ function shortcode_custom_testimonials($atts, $content = null, $code) { extract(shortcode_atts(array( 'type' => '', 'items_per_column' => 3, 'number_of_posts' => 5, 'image_width' => 40, 'image_height' => 40, 'excerpt_length' => 160, 'display_image' => 'no', 'align' => 'left', ), $atts)); global $post; $i = 1; $args = array( 'posts_per_page' => $number_of_posts, 'post_status' => 'publish', 'post_type' => 'testimonial', ); $testimonial_array = get_posts($args); $testimonial_count = count($testimonial_array); $output = ''; if($testimonial_count > 0 ): $output .= '<div class="custom-testimonial '.$type.'">'; if($type == "slider") { $output .= '<div id="'.$items_per_column.'_testimonial_carousel" class="testimonial-carousel">'; } elseif($type == "grid") { $output .= '<div id="testimonial_grid" class="testimonial-grid testimonial-cols-'.$items_per_column.'">'; } $i = 1; $temp2 = 0; foreach($testimonial_array as $post) : setup_postdata($post); get_post_meta($post->ID, 'testimonial_position', TRUE) ? $testimonial_position = get_post_meta($post->ID, 'testimonial_position', TRUE) : $testimonial_position = ''; get_post_meta($post->ID, 'testimonial_link', TRUE) ? $testimonial_link = get_post_meta($post->ID, 'testimonial_link', TRUE) : $testimonial_link = ''; $contents = strip_tags(tmpmela_strip_images($post->post_content)); if($i % $items_per_column == 1) $class = " first-item"; elseif($i % $items_per_column == 0) $class = " last-item"; else $class = ""; $output .= '<div class="item'.$class.'">'; $output .= '<div class="product-block">'; $output .= '<div class="custom-testimonial-inner '.$align.'">'; if ( has_post_thumbnail() && ! post_password_required() && $display_image == 'yes') : $post_thumbnail_id = get_post_thumbnail_id(); $post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id ); $output .= '<div class="testmonial-image">'; $output .= '<img src="'.tmpmela_mr_image_resize($post_thumbnail_url, $image_width, $image_height, true, 'left', false).'" title="'.get_the_title().'" alt="'.get_the_title().'" />'; $output .= '</div>'; else: $output .= '<div class="testmonial-icon">'; $output .= '<i style="font-size:'.$image_width.';" class="fa fa-quote-left"></i>'; $output .= '</div>'; endif; $output .= '<div class="testimonial-wrapper">'; $output .= '<div class="testmonial-text">'; $output .= '<div class="testimonial-content"><blockquote><q>'.tmpmela_excerpt_length_limit($excerpt_length).'</q></blockquote></div>'; $output .= '<div class="testimonial-title"><a title="'.get_the_title().'" href="'.get_permalink().'" >'.get_the_title().'</a></div>'; if(!empty($testimonial_position)): $output .= '<div class="testimonial-designation">'.$testimonial_position.'</div>'; endif; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $i++; endforeach; $output .= '</div>'; $output .= '</div>'; else: $output .= '<div class="no-result">'.esc_html__('No results found...', 'kartwow').'</div>'; endif; wp_reset_query(); return $output; } add_shortcode('testimonials', 'shortcode_custom_testimonials'); /***************** Brand ****************/ function shortcode_brand($atts, $content = null, $code) { extract(shortcode_atts(array( 'style' => '1', 'items_per_column' => 5, 'image_width' => 104, 'image_height' => 76 ), $atts)); $output = ''; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $terms = array(); $args = array( 'paged' => $paged, 'post_type' => 'product', 'post_status' => 'publish', 'taxonomy' => 'product_brand', ); $terms = get_terms($args); query_posts($args); if ( in_array( 'woocommerce/woocommerce.php' ,apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && in_array( 'TemplatemelaCustomPost/TemplatemelaCustomPost.php' , apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { $output .= '<div class="brand-container">'; $output .= '<div id="'.$items_per_column.'_brand_carousel" class="brand-carousel tmpmela-logo-content">'; $num_layout = substr($items_per_column, 0, 1); $i = 1; global $term; $terms = get_terms('product_brand'); $terms_slug = array(); if (is_array($terms)) { foreach($terms as $term) { if($i % $items_per_column == 1) $class = " first-item"; elseif($i % $items_per_column == 0) $class = " last-item"; else $class = "inner"; $term_ids = get_term( $term, 'product_brand' ); $output .= '<div class="item brand_main">'; $output .= '<div class="product-block style-'.$style.'">'; $output .= '<div class="single-brand">'; $thumbnail_id = get_term_meta( $term_ids->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); if(!empty($image)) : $output .= '<div class="entry-thumbnail">'; $output .= '<a href="'.get_term_link( $term ).'"><img src="'.$image.'" title="'.esc_attr($term->name).'" alt="'.esc_attr($term->name).'" /></a>'; $output .= '</div>'; else: $output .= '<i style="width:'.$image_width.';height:'.$image_height.';" class="fa fa-user"></i>'; endif; if($style == '2'): $output .= '<div class="brand-content">'; if(!empty($term->name)) : $output .= '<h5 class="entry-title">'.esc_attr($term->name).'</h5>'; endif; $output .= '</div>'; endif; $output .= '</div>'; $output .= '</div>'; $output .= '</div>'; $i++; } } $output .= '</div>'; $output .= '</div>'; } wp_reset_query(); return $output; } add_shortcode('tmpmela_brand', 'shortcode_brand'); /***************** Hot Product With Thumbnail ****************/ function shortcode_tmpmela_counter_products_container($atts, $content = null, $code) { extract(shortcode_atts(array( 'height' => '264', 'width' => '198', 'number_of_items' => 5, 'excerpt_length' => '20' ), $atts)); $output = ''; global $post; $params = array('posts_per_page' => -1,'post_type' => array('product', 'product_variation')); $wc_query = new WP_Query($params); if ( in_array( 'woocommerce/woocommerce.php' ,apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { $output .= '<div class="woo-products woo-content products_block shop">'; if ($wc_query->have_posts()) : $output .= '<div id="home_featured_carousel" class="home-featured-carousel owl-carousel woocommerce">'; while ($wc_query->have_posts()) : $wc_query->the_post(); $today = date('Y-m-d'); $sale_price_dates_from = ( $date = get_post_meta( $post->ID, '_sale_price_dates_from', true ) ) ? date_i18n( 'Y-m-d', $date ) : ''; $sale_price_dates_to = ( $date = get_post_meta( $post->ID, '_sale_price_dates_to', true ) ) ? date_i18n( 'Y-m-d', $date ) : ''; if ($today >= $sale_price_dates_from && $today <= $sale_price_dates_to){ if ($sale_price_dates_to != "") { global $product; $rating = $product->get_average_rating(); $attachment_ids = $product->get_gallery_image_ids(); $output .= '<div class="item container-inner">'; $output .= '<div class="feature-image-wrapper">'; if($product->is_on_sale() ) : $output.='<span class="onsale">'. __( 'Sale', 'woocommerce' ).'</span>'; endif; $output .= '<div class="images image-carousel">'; if ( has_post_thumbnail() ) { $output .= woocommerce_get_product_thumbnail( $width, $height , '', true); } $output .='</div></div>'; $output .='<div class="product-detail">'; $output .='<div class="woocommerce-product-rating">'.wc_get_rating_html($rating).'</div>'; $output .='<h3 class="product-name">'; $output .='<a href="'.get_permalink().'">'.$product->get_title().'</a>'; $output .='</h3>'; $output .='<div class="product-price price">'.$product->get_price_html().'</div>'; $output .='<div class="count-down">'; $output .='<div class="countbox hastime" data-time="'.$sale_price_dates_to.'">'; $output .= '</div></div>'; $output .='<div class="product-description">'.tmpmela_excerpt($excerpt_length).'</div>'; if ( ! $product->is_in_stock() ) : $output .= '<a href="'.apply_filters( 'out_of_stock_add_to_cart_url', get_permalink( $product->get_id() ) ).'" class="button">'.apply_filters( 'out_of_stock_add_to_cart_text', __( 'Read More', 'woocommerce' ) ).'</a>'; else : $link = array( 'url' => '', 'label' => '', 'class' => '' ); switch ( $product->get_type() ) { case "variable" : $link['url'] = apply_filters( 'variable_add_to_cart_url', get_permalink( $product->get_id() ) ); $link['label'] = apply_filters( 'variable_add_to_cart_text', __( 'Select options', 'woocommerce' ) ); break; case "grouped" : $link['url'] = apply_filters( 'grouped_add_to_cart_url', get_permalink( $product->get_id() ) ); $link['label'] = apply_filters( 'grouped_add_to_cart_text', __( 'View options', 'woocommerce' ) ); break; case "external" : $link['url'] = apply_filters( 'external_add_to_cart_url', get_permalink( $product->get_id() ) ); $link['label'] = apply_filters( 'external_add_to_cart_text', __( 'Read More', 'woocommerce' ) ); break; default : if ( $product->is_purchasable() ) { $link['url'] = apply_filters( 'add_to_cart_url', esc_url( $product->add_to_cart_url() ) ); $link['label'] = apply_filters( 'add_to_cart_text', __( 'Add to cart', 'woocommerce' ) ); $link['class'] = apply_filters( 'add_to_cart_class', 'add_to_cart_button' ); } else { $link['url'] = apply_filters( 'not_purchasable_url', get_permalink( $product->get_id() ) ); $link['label'] = apply_filters( 'not_purchasable_text', __( 'Read More', 'woocommerce' ) ); } break; } $output .='<div class="product-button product-block-hover">'; // If there is a simple product. if ( $product->get_type() == 'simple' ) { // Display the submit button. $output .= sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s product_type_simple ">%s</a>', esc_url( $product->add_to_cart_url() ), esc_attr( isset( $quantity ) ? $quantity : 1 ), esc_attr( $product->get_id() ), esc_attr( $product->get_sku() ), esc_attr( isset( $class ) ? $class : 'button add_to_cart_button ajax_add_to_cart' ), esc_html( $product->add_to_cart_text() )); } else { $output .= sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>', esc_url( $product->add_to_cart_url() ), esc_attr( isset( $quantity ) ? $quantity : 1 ), esc_attr( $product->get_id() ), esc_attr( $product->get_sku() ), esc_attr( isset( $class ) ? $class : 'button add_to_cart_button ajax_add_to_cart' ), esc_html( $product->add_to_cart_text() )); } endif; $output .='<div class="product-button-icon">'; if ( in_array( 'yith-woocommerce-compare/init.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ): $output .= do_shortcode( "[yith_compare_button]" ); endif; if ( in_array( 'yith-woocommerce-quick-view/init.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ): $output .= do_shortcode( "[yith_quick_view]" ); endif; if ( in_array( 'yith-woocommerce-wishlist/init.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ): $output .= do_shortcode( "[yith_wcwl_add_to_wishlist]" ); endif; $output .='</div>'; $output .='</div>'; $output .='</div>'; $output .='</div>'; } } endwhile; wp_reset_postdata(); $output .='</div>'; $output .='</div>'; endif; } return $output; } add_shortcode('tmpmela_counter_products', 'shortcode_tmpmela_counter_products_container'); /******************** Single static Category Link ***************/ function shortcode_single_category($atts, $content = null) { extract(shortcode_atts(array( 'text1' => '', 'category_name_id' => '', 'link_text' => '', 'link_url' => '', ), $atts)); $title = ''; $category_ids_array = explode(",",$category_name_id); $category_ids_array[] = $category_ids_array; $output = ''; $output .= '<div class="category_link">'; $output .= '<div class="static-inner">' ; if(!empty($text1)) : $title = '<span class="text1 static-text">'.$text1.'</span>'; endif; $output .='<span class="static-title">'.$title.'</span>'; $output .= '<ul class="category_link_inner">'; $args = array( 'taxonomy' => "product_cat", 'hide_empty' => false, 'hierarchical' => '0', 'orderby' => '', 'include' => $category_ids_array ); $categories = get_terms($args); foreach($categories as $term) { $output .= '<li><a href="'.get_term_link($term).'" target="_blank">'.$term->name.'</a></li>'; } $output .= '</ul>'; if(!empty($link_text)) : $link_text = '<a href="'.$link_url.'" class="link-text button">'.$link_text.'</a>'; endif; $output .='<span class="category-link-text">'.$link_text.'</span>'; $output .= '</div>'; $output .= '</div>'; return $output; } add_shortcode("single_category", "shortcode_single_category"); //deactivate WordPress function remove_shortcode('gallery', 'gallery_shortcode'); //activate own function add_shortcode('gallery', 'msdva_gallery_shortcode'); function msdva_gallery_shortcode($attr) { $post = get_post(); static $instance = 0; $instance++; if ( ! empty( $attr['ids'] ) ) { // 'ids' is explicitly ordered, unless you specify otherwise. if ( empty( $attr['orderby'] ) ) $attr['orderby'] = 'post__in'; $attr['include'] = $attr['ids']; } // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output; // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( !$attr['orderby'] ) unset( $attr['orderby'] ); } extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'divtag' => 'div', 'columns' => 3, 'size' => 'full', 'include' => '', 'exclude' => '', 'link' => 'file' // CHANGE #1 ), $attr, 'gallery')); $id = intval($id); if ( 'RAND' == $order ) $orderby = 'none'; if ( !empty($include) ) { $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( !empty($exclude) ) { $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } else { $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } if ( empty($attachments) ) return ''; if ( is_feed() ) { $output = "\n"; foreach ( $attachments as $att_id => $attachment ) $output .= tmpmela_wp_get_attachment_link($att_id, $size, true) . "\n"; return $output; } $itemtag = tag_escape($itemtag); $captiontag = tag_escape($captiontag); $icontag = tag_escape($icontag); $valid_tags = wp_kses_allowed_html( 'post' ); if ( ! isset( $valid_tags[ $itemtag ] ) ) $itemtag = 'dl'; if ( ! isset( $valid_tags[ $captiontag ] ) ) $captiontag = 'dd'; if ( ! isset( $valid_tags[ $icontag ] ) ) $icontag = 'dt'; $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; $float = is_rtl() ? 'right' : 'left'; $selector = "gallery-{$instance}"; $gallery_style = $gallery_div = ''; if ( apply_filters( 'use_default_gallery_style', true ) ) $gallery_style = " <style type='text/css'> #{$selector} { margin: auto; } #{$selector} .gallery-item { float: {$float}; margin-top: 10px; text-align: center; width: {$itemwidth}%; } #{$selector} img { border: 2px solid #cfcfcf; } #{$selector} .gallery-caption { margin-inline-start: 0; } /* see gallery_shortcode() in wp-includes/media.php */ </style>"; $size_class = sanitize_html_class( $size ); $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div ); $i = 0; foreach ( $attachments as $id => $attachment ) { $image_url = $attachment->guid; $image_output = tmpmela_wp_get_attachment_link( $id, $size, true, false ); $image_meta = wp_get_attachment_metadata( $id ); $orientation = ''; if ( isset( $image_meta['height'], $image_meta['width'] ) ) $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; $output .= "<{$itemtag} class='gallery-item'>"; $output .= " <{$icontag} class='gallery-icon {$orientation}'> $image_output </{$icontag}>"; $output .= " <{$captiontag} class='wp-caption-text gallery-caption'> <{$divtag} class='gallery-caption-inner'>"; $output .= " <{$divtag} class='wp-caption-text gallery-title'> " . wptexturize($attachment->post_title) . " </{$divtag}>"; if ( $captiontag && trim($attachment->post_excerpt) ) { $output .= "<{$divtag} class='wp-caption-text gallery-excerpt'>"; if($columns == 1): $excerpt_length = 100; elseif($columns == 2): $excerpt_length = 300; elseif($columns == 3): $excerpt_length = 200; elseif($columns == 4): $excerpt_length = 50; elseif($columns == 5): $excerpt_length = 10; endif; $output .= substr($attachment->post_excerpt,0,$excerpt_length); $output .= "</{$divtag}>"; $output .= "<{$divtag} class='wp-caption-text gallery-zoom'> <a href=" . $image_url . " title='Click to view Full Image' class='icon mustang-gallery'><i class='fa fa-eye'></i></a> </{$divtag}>"; $output .= "<{$divtag} class='wp-caption-text gallery-redirect'> <a href=" . get_attachment_link( $attachment->ID ) . " title='Click to view read more' class='icon readmore'><i class='fa fa-link'></i></a> </{$divtag}>"; }else{ $output .= "<{$divtag} class='wp-caption-text gallery-zoom no-text'> <a href=" . $image_url . " title='Click to view Full Image' class='icon mustang-gallery'><i class='fa fa-eye'></i></a> </{$divtag}>"; $output .= "<{$divtag} class='wp-caption-text gallery-redirect'> <a href=" . get_attachment_link( $attachment->ID ) . " title='Click to view read more' class='icon readmore'><i class='fa fa-link'></i></a> </{$divtag}>"; } $output .= "</{$divtag}>"; $output .= "</{$captiontag}>"; $output .= "</{$itemtag}>"; } $output .= " </div>\n"; return $output; } function tmpmela_wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = true, $icon = false, $text = false ) { $id = intval( $id ); $_post = get_post( $id ); if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) return __( 'Missing Attachment', 'kartwow' ); if ( $permalink ) // FIX!! ask for large URL $image_attributes = wp_get_attachment_image_src( $_post->ID, 'large' ); $url = $image_attributes[0]; $post_title = esc_attr( $_post->post_title ); if ( $text ) $link_text = $text; elseif ( $size && 'none' != $size ) $link_text = wp_get_attachment_image( $id, $size, $icon ); else $link_text = ''; if ( trim( $link_text ) == '' ) $link_text = $_post->post_title; return apply_filters( 'wp_get_attachment_link', "<a rel='gallery-nr'>$link_text</a>", $id, $size, $permalink, $icon, $text ); } /***************** Banner slider ****************/ function shortcode_single_slide($atts, $content = null, $code) { extract(shortcode_atts(array( 'title' => '', ), $atts)); $output = ''; $output .= '<div class="banner-slider-container">'; $output .= '<div class="slider-container-inner">'; $output .= '<div class="title">'.$title.'</div>'; $output .= '<ul class="slides">'; $output .= do_shortcode($content); $output .= '</ul>'; $output .= '</div></div>'; return $output; } add_shortcode('slider', 'shortcode_single_slide'); function shortcode_single_slider($atts, $content = null) { extract(shortcode_atts(array( 'image' => '', 'link' => '', 'height' => '', 'width' => '', ), $atts)); $output = ''; $output .= '<li><div class="banner-image">'; if(!empty($link)): $output .= '<a target="_Self" href="'.$link.'"><img src="'.$image.'" alt="'.get_the_title().'" height="'.$height.'" width="'.$width.'" class="vv" /></a>'; else: $output .= '<img src="'.$image.'" alt="'.get_the_title().'" class="vv" />'; endif; $output .= '</li></div">'; return $output; } add_shortcode('slide', 'shortcode_single_slider'); ?>
[+]
..
[-] templatemela-shortcodes.php
[edit]