" . do_shortcode( $o ) . "
";
';
// Check element
if ( $elm === 'logo' || $elm === 'logo_2' ) {
$logo = self::option( $elm );
if ( $logo ) {
echo '
';
} else {
echo '
' . esc_html( get_bloginfo( 'name' ) ) . '
';
}
$logo_tooltip = self::option( 'logo_hover_tooltip' );
if ( $logo_tooltip && $m['id'] !== 'header_4' && $m['id'] !== 'header_5' ) {
echo '
' . self::get_page_as_element( esc_html( $logo_tooltip ) ) . '
';
}
echo '
';
} else if ( $elm === 'menu' ) {
$type = empty( $i['menu_type'] ) ? 'cz_menu_default' : $i['menu_type'];
if ( $type === 'offcanvas_menu_left' ) {
$type = 'offcanvas_menu inview_left';
} else if ( $type === 'offcanvas_menu_right' ) {
$type = 'offcanvas_menu inview_right';
}
$menu_title = isset( $i['menu_title'] ) ? $i['menu_title'] : '';
$menu_icon = empty( $i['menu_icon'] ) ? 'fa fa-bars' : $i['menu_icon'];
$icon_style = empty( $i['sk_menu_icon'] ) ? '' : $i['sk_menu_icon'];
$menu_icon_class = $menu_title ? ' icon_plus_text' : '';
// Add icon and mobile menu
if ( $type && $type !== 'offcanvas_menu' && $type !== 'cz_menu_default' ) {
echo '';
}
echo '';
// Default
if ( empty( $i['menu_location'] ) ) {
$i['menu_location'] = 'primary';
}
// Check for meta box and set one page instead primary
if ( self::meta( 0, 0, 'one_page' ) ) {
$i['menu_location'] = 'one-page';
}
// Menu
$nav = array(
'theme_location' => esc_attr( $i['menu_location'] ),
'cz_row_id' => esc_attr( $m['id'] ),
'container' => false,
'fallback_cb' => '',
'items_wrap' => ''
);
if ( class_exists( 'Codevz_Walker_nav' ) ) {
$nav['walker'] = new Codevz_Walker_nav();
}
wp_nav_menu( $nav );
} else if ( $elm === 'social' ) {
// Escaped in social()
echo self::social();
} else if ( $elm === 'image' && isset( $i['image'] ) ) {
$link = empty( $i['image_link'] ) ? '' : $i['image_link'];
$width = empty( $i['image_width'] ) ? 'auto' : $i['image_width'];
if ( $link ) {
echo '
';
} else {
echo '
';
}
} else if ( $elm === 'icon' ) {
$link = isset( $i['it_link'] ) ? $i['it_link'] : '';
$text_style = empty( $i['sk_it'] ) ? '' : self::sk_inline_style( $i['sk_it'] );
$icon_style = empty( $i['sk_it_icon'] ) ? '' : $i['sk_it_icon'];
if ( $link ) {
echo '
';
} else {
echo '';
}
if ( ! empty( $i['it_icon'] ) ) {
echo '';
}
if ( ! empty( $i['it_text'] ) ) {
echo '' . do_shortcode( wp_kses_post( str_replace( '%year%', current_time( 'Y' ), $i['it_text'] ) ) ) . '';
} else {
echo '';
}
if ( $link ) {
echo '';
} else {
echo '
';
}
} else if ( $elm === 'search' ) {
$icon_style = empty( $i['sk_search_icon'] ) ? '' : $i['sk_search_icon'];
$icon_in_style = empty( $i['sk_search_icon_in'] ) ? '' : $i['sk_search_icon_in'];
$input_style = empty( $i['sk_search_input'] ) ? '' : $i['sk_search_input'];
$outer_style = empty( $i['sk_search_con'] ) ? '' : $i['sk_search_con'];
$ajax_style = empty( $i['sk_search_ajax'] ) ? '' : $i['sk_search_ajax'];
$icon = empty( $i['search_icon'] ) ? 'fa fa-search' : $i['search_icon'];
$ajax = empty( $i['ajax_search'] ) ? '' : ' cz_ajax_search';
$form_style = empty( $i['search_form_width'] ) ? '' : 'width: ' . esc_attr( $i['search_form_width'] );
$i['search_type'] = empty( $i['search_type'] ) ? 'form' : $i['search_type'];
$i['search_placeholder'] = empty( $i['search_placeholder'] ) ? '' : $i['search_placeholder'];
echo '';
echo self::contains( esc_attr( $i['search_type'] ), 'form' ) ? '' : '
';
echo '
';
} else if ( $elm === 'widgets' ) {
$con_style = empty( $i['sk_offcanvas'] ) ? '' : $i['sk_offcanvas'];
$icon_style = empty( $i['sk_offcanvas_icon'] ) ? '' : $i['sk_offcanvas_icon'];
$icon = empty( $i['offcanvas_icon'] ) ? 'fa fa-bars' : $i['offcanvas_icon'];
echo '';
if ( is_active_sidebar( 'offcanvas_area' ) ) {
dynamic_sidebar( 'offcanvas_area' );
}
echo '
';
} else if ( $elm === 'hf_elm' ) {
$con_style = empty( $i['sk_hf_elm'] ) ? '' : $i['sk_hf_elm'];
$icon_style = empty( $i['sk_hf_elm_icon'] ) ? '' : $i['sk_hf_elm_icon'];
$icon = empty( $i['hf_elm_icon'] ) ? 'fa fa-bars' : $i['hf_elm_icon'];
echo '' . ( empty( $i['hf_elm_page'] ) ? '' : self::get_page_as_element( esc_html( $i['hf_elm_page'] ) ) ) . '
';
} else if ( $elm === 'shop_cart' ) {
if ( function_exists( 'is_woocommerce' ) ) {
$icon_style = empty( $i['sk_shop_icon'] ) ? '' : $i['sk_shop_icon'];
$icon = empty( $i['shopcart_icon'] ) ? 'fa fa-shopping-basket' : $i['shopcart_icon'];
$woo_style = empty( $i['sk_shop_count'] ) ? '' : '.cz_cart_count, .cart_1 .cz_cart_count{' . esc_attr( $i['sk_shop_count'] ) . '}';
$woo_style .= empty( $i['sk_shop_content'] ) ? '' : '.cz_cart_items{' . esc_attr( $i['sk_shop_content'] ) . '}';
echo '';
}
} else if ( $elm === 'line' && isset( $i['line_type'] ) ) {
$line = empty( $i['sk_line'] ) ? '' : $i['sk_line'];
echo '
';
} else if ( $elm === 'button' ) {
$elm_uniqid = 'cz_btn_' . rand( 11111, 99999 );
$btn_css = empty( $i['sk_btn'] ) ? '' : $i['sk_btn'];
$btn_hover = empty( $i['sk_btn_hover'] ) ? '' : '.' . esc_attr( $elm_uniqid ) . ':hover{' . str_replace( ';', ' !important;', $i['sk_btn_hover'] ) . '}';
echo '';
} else if ( $elm === 'custom' && isset( $i['custom'] ) ) {
echo do_shortcode( esc_html( $i['custom'] ) );
} else if ( $elm === 'wpml' ) {
if ( function_exists('icl_get_languages') ) {
$wpml = icl_get_languages( 'skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str' );
if ( is_array( $wpml ) ) {
$bg = empty( $i['wpml_background'] ) ? '' : 'background: ' . esc_attr( $i['wpml_background'] ) . '';
echo '
';
foreach ( $wpml as $lang => $vals ) {
if ( ! empty( $vals ) ) {
$class = $vals['active'] ? 'cz_current_language' : '';
if ( empty( $i['wpml_title'] ) ) {
$title = $vals['translated_name'];
} else if ( $i['wpml_title'] !== 'no_title' ) {
$title = ucwords( $vals[ $i['wpml_title'] ] );
} else {
$title = '';
}
$color = ( empty( $i['wpml_color'] ) || $class ) ? '' : 'color: ' . esc_attr( $i['wpml_color'] );
if ( !empty( $i['wpml_flag'] ) ) {
echo '
' . esc_html( $title ) . '';
} else {
echo '
' . esc_html( $title ) . '';
}
}
}
echo '
';
}
}
} else if ( $elm === 'custom_element' && ! empty( $i['header_elements'] ) ) {
// Custom page as element
echo self::get_page_as_element( esc_html( $i['header_elements'] ) );
} else if ( $elm === 'avatar' ) {
$sk_avatar = empty( $i['sk_avatar'] ) ? '' : $i['sk_avatar'];
$link = empty( $i['avatar_link'] ) ? '' : $i['avatar_link'];
$size = empty( $i['avatar_size'] ) ? '' : $i['avatar_size'];
echo '
';
if ( is_user_logged_in() ) {
global $current_user;
echo get_avatar( esc_html( $current_user->user_email ), esc_attr( $size ) );
} else {
echo get_avatar( 'xxx@xxx.xxx', esc_attr( $size ) );
}
echo '';
}
// Close element
echo '
';
}
/**
*
* Get WooCommerce cart in header
*
* @return string
*
*/
public static function codevz_woo_cart( $fragments ) {
$wc = WC();
$count = $wc->cart->cart_contents_count;
$total = $wc->cart->get_cart_total();
ob_start(); ?>
0 ) { ?>
-
cart->cart_contents_count == 0 ) { ?>
cart->cart_contents as $cart_item_key => $cart_item ) { $id = $cart_item['product_id']; ?>
x cart->get_product_subtotal( $cart_item['data'], 1 ) ); ?>
$fragments['.cz_cart'] = ob_get_clean();
return $fragments;
}
/**
*
* Generate inner row elements positions
*
* @return string
*
*/
public static function codevz_row_inner( $id = 0, $pos = 0, $out = '' ) {
if ( isset( $_POST['id'] ) && isset( $_POST['pos'] ) ) {
$ajax = 1;
$id = $_POST['id'];
$pos = $_POST['pos'];
}
$elms = self::option( $id . $pos );
if ( $elms ) {
$shape = self::get_string_between( self::option( '_css_' . $id . $pos ), '_class_shape:', ';' );
$shape = $shape ? ' ' . $shape : '';
$center = self::contains( $pos, 'center' );
echo '
';
if ( $center ) {
echo '
';
}
$inner_id = 0;
foreach ( (array) $elms as $v ) {
if ( empty( $v['element'] ) ) {
continue;
}
$more = array();
$more['id'] = $id;
$more['depth'] = $pos . '_' . self::$elm_id++;
$more['inner_depth'] = $pos . '_' . $inner_id++;
// Variables are array()
self::get_row_element( $v, $more );
}
if ( $center ) {
echo '
';
}
echo '
';
}
if ( isset( $ajax ) ) {
die();
}
}
/**
*
* Generate header|footer|side row elements
*
* @return string
*
*/
public static function row( $args ) {
ob_start();
foreach ( $args['nums'] as $num ) {
$id = esc_attr( $args['id'] );
// Check if sticky header is not custom
if ( $num === '5' && ! self::option( 'sticky_header' ) ) {
continue;
}
// Columns
$left = self::option( $id . $num . $args['left'] );
$right = self::option( $id . $num . $args['right'] );
$center = self::option( $id . $num . $args['center'] );
// Row Shape
$shape = self::get_string_between( self::option( '_css_row_' . $id . $num ), '_class_shape:', ';' );
$shape = $shape ? ' ' . $shape : '';
// Menu FX
$menufx = self::get_string_between( self::option( '_css_menu_a_hover_before_' . $id . $num ), '_class_menu_fx:', ';' );
$menufx = $menufx ? ' ' . $menufx : '';
// Check sticky header
$sticky = self::option( 'sticky_header' );
$sticky = ( self::contains( $sticky, $num ) && $id !== 'footer_' ) ? ' header_is_sticky' : '';
$sticky .= ( $sticky && self::option( 'smart_sticky' ) ) ? ' smart_sticky' : '';
$sticky .= ( self::option( 'mobile_sticky' ) && $id . $num === 'header_4' ) ? ' ' . self::option( 'mobile_sticky' ) : '';
// Before mobile header
if ( $num === '4' && self::option( 'b_mobile_header' ) ) {
echo '';
}
// Start
if ( $left || $center || $right ) {
echo '';
}
// After mobile header
if ( $num === '4' && self::option( 'a_mobile_header' ) ) {
echo '';
}
}
echo ob_get_clean();
}
/**
*
* Generate page
*
* @return string
*
*/
public static function generate_page( $page = '' ) {
get_header();
// Settings
$cpt = self::get_post_type();
$is_search = is_search();
if ( $is_search ) {
$option_cpt = '_search';
} else {
$option_cpt = ( $cpt === 'post' || $cpt === 'page' || empty( $cpt ) ) ? '' : '_' . $cpt;
}
$title = self::option( 'page_title' . $option_cpt );
$title = ( ! $title || $title === '1' ) ? self::option( 'page_title' ) : $title;
$layout = self::option( 'layout' . $option_cpt );
$layout = ( ! $layout || $layout === '1' ) ? self::option( 'layout' ) : $layout;
$primary = self::option( 'primary' . $option_cpt, 'primary' );
$secondary = self::option( 'secondary' . $option_cpt, 'secondary' );
$blank = ( $layout === 'bpnp' ) ? 1 : 0;
$is_404 = ( is_404() || $page === '404' );
$current_id = $is_404 ? self::option( '404' ) : ( isset( self::$post->ID ) ? self::$post->ID : 0 );
if ( is_singular() || $cpt === 'page' || $is_404 ) {
$meta = self::meta( $current_id );
if ( isset( $meta['layout'] ) && $meta['layout'] !== '1' ) {
$layout = $meta['layout'];
$primary = $meta['primary'];
$secondary = $meta['secondary'];
$blank = ( $meta['layout'] === 'none' || $meta['layout'] === 'bpnp' ) ? 1 : 0;
$title = ( $meta['page_title'] === 'd' ) ? $title : $meta['page_title'];
}
}
$queried_object = get_queried_object();
// Start page content
$bpnp = ( $layout === 'bpnp' ) ? ' cz_bpnp' : '';
$bpnp .= empty( $meta['page_content_margin'] ) ? '' : ' ' . $meta['page_content_margin'];
echo '
';
// Before content
if ( $is_404 ) {
echo '
';
} else if ( $layout === 'both-side' ) {
echo '';
} else if ( $layout === 'both-side2' ) {
echo '';
} else if ( $layout === 'both-right' ) {
echo '';
} else if ( $layout === 'both-right2' ) {
echo '';
} else if ( $layout === 'right' ) {
echo '';
} else if ( $layout === 'right-s' ) {
echo '';
} else if ( $layout === 'both-left' ) {
echo '';
} else if ( $layout === 'both-left2' ) {
echo '';
} else if ( $layout === 'left' ) {
echo '';
} else if ( $layout === 'left-s' ) {
echo '';
} else {
echo '';
}
$single_classes = is_single() ? ' ' . implode( ' ', get_post_class( 'single_con' ) ) : '';
echo '';
if ( $is_404 ) {
if ( $current_id ) {
echo self::get_page_as_element( $current_id );
} else {
echo '
404' . self::option( '404_msg', 'Page not found!' ) . '
';
echo '
';
echo '
' . self::option( '404_btn', 'Back to Homepage' ) . '';
}
} else if ( $page === 'page' || $page === 'single' ) {
if ( have_posts() ) {
$single_meta_cpt = ( $cpt === 'page' || empty( $cpt ) ) ? 'post' : $cpt;
$single_meta = (array) self::option( 'meta_data_' . $single_meta_cpt );
$single_meta = array_flip( $single_meta );
while ( have_posts() ) {
the_post();
if ( ! $blank && ( $title === '1' || $title === '2' || $title === '8' ) ) {
// Escaped inside page_title()
self::page_title( 'h3', '', ( is_single() && empty( $queried_object->taxonomy ) && isset( $single_meta['mbot'] ) ) );
}
if ( $page === 'single' && has_post_thumbnail() && isset( $single_meta['image'] ) ) {
echo '
';
the_post_thumbnail( 'full' );
echo '
';
}
echo '
';
the_content();
echo '
';
echo '
';
wp_link_pages( array(
'before'=>'',
'link_after'=>'',
'link_before'=>'
'
));
}
if ( $page === 'single' && empty( $queried_object->taxonomy ) ) {
if ( isset( $single_meta['date'] ) || isset( $single_meta['author'] ) ) {
$author_url = get_author_posts_url( get_the_author_meta( 'ID' ) );
echo '';
echo isset( $single_meta['author'] ) ? '' . get_avatar( get_the_author_meta( 'ID' ), 40 ) . '' : '';
echo '';
echo isset( $single_meta['author'] ) ? '' . ucwords( get_the_author() ) . '' : '';
echo isset( $single_meta['date'] ) ? '' . esc_html( get_the_time( get_option( 'date_format' ) ) ) . '' : '';
echo '';
}
echo '';
if ( isset( $single_meta['cats'] ) ) {
echo '';
// Escaped inside post_category()
echo self::post_category();
echo '
';
}
if ( isset( $single_meta['tags'] ) ) {
// Escaped inside the_tags()
echo self::the_tags();
}
echo '
';
if ( isset( $single_meta['next_prev'] ) && self::next_prev_item() ) {
echo '
' . self::next_prev_item(); // Escaped inside next_prev_item()
}
if ( isset( $single_meta['author_box'] ) && self::author_box() ) {
echo '
';
echo '
' . esc_html( ucfirst( get_the_author_meta('display_name') ) ) . 'Author posts
';
// Escaped inside author_box()
echo self::author_box();
}
$related_ppp = self::option( 'related_' . $single_meta_cpt . '_ppp' );
if ( $related_ppp && $related_ppp != '0' && $cpt !== 'page' && $cpt !== 'product' && $cpt !== 'dwqa-question' ) {
// Escaped data inside related()
echo self::related(array(
'posts_per_page' => esc_attr( $related_ppp ),
'related_columns' => esc_attr( self::option( 'related_' . $single_meta_cpt . '_col', 's4' ) ),
'section_title' => esc_html( self::option( 'related_posts_' . $single_meta_cpt, 'Related Posts ...' ) )
));
}
}
}
} else if ( $page === 'woocommerce' ) {
woocommerce_content();
} else if ( have_posts() ) {
if ( ! is_home() && ( $title === '2' || $title === '8' ) ) {
// Escaped data inside page_title()
self::page_title();
}
if ( is_author() && self::author_box() ) {
echo '
' . esc_html( ucfirst( get_the_author_meta('display_name') ) ) . 'View all posts
';
// Escaped data inside author_box()
echo self::author_box();
echo '
';
}
$cpt = $cpt ? $cpt : 'post';
$template = self::option( 'template_' . $cpt );
if ( $template && self::option( 'template_style' ) !== 'x' ) {
echo self::get_page_as_element( esc_html( $template ), 1 );
} else {
// Posts
echo '
';
$i = 1;
if ( $cpt === 'post' ) {
$post_class = '';
$post_template = esc_html( self::option( 'template_style' ) );
$image_size = 'codevz_360_320';
$plcw = '360';
if ( $post_template == '2' ) {
$post_class = ' cz_default_loop_right';
} else if ( $post_template == '3' ) {
$post_class = ' cz_default_loop_full';
$image_size = 'codevz_1200_500';
$plcw = '1200';
} else if ( $post_template == '4' ) {
$post_class = ' cz_default_loop_grid col s6';
} else if ( $post_template == '5' ) {
$post_class = ' cz_default_loop_grid col s4';
}
$nt = self::option( 'no_thumbnail' );
while ( have_posts() ) {
the_post();
$link = get_the_permalink();
$author_url = get_author_posts_url( get_the_author_meta( 'ID' ) );
echo '
';
if ( $i % ( ( $post_template === '4' ) ? 2 : ( ( $post_template === '5' ) ? 3 : 99 ) ) === 0 ) {
echo '
';
}
$i++;
}
} else { // Other posts types
$col = self::option( 'cols_' . $cpt, 's4' );
while ( have_posts() ) {
the_post();
$link = get_the_permalink();
echo '
';
if ( $i % ( ( $col === 's4' ) ? 3 : ( ( $col === 's3' ) ? 4 : 2 ) ) === 0 ) {
echo '
';
}
$i++;
}
}
echo '
'; // row
// Pagination
echo '
';
$is_rtl = ( is_rtl() || self::option( 'rtl' ) || isset( $_GET['rtl'] ) );
the_posts_pagination(array(
'prev_text' => $is_rtl ? '' : '',
'next_text' => $is_rtl ? '' : '',
'before_page_number' => ''
));
echo '
';
}
} else {
echo '
' . esc_html( self::option( 'not_found', 'Not found!' ) ) . '
';
}
echo '
'; // content
// Comments
if ( empty( $queried_object->taxonomy ) || isset( $queried_object->post_type ) ) {
if ( ! $is_404 && comments_open() ) {
echo '';
} else if ( isset( $queried_object->post_type ) && $queried_object->post_type == 'post' ) {
echo '';
}
}
echo '';
// After content
if ( $is_404 ) {
echo '';
} else if ( $layout === 'right' ) {
echo '';
} else if ( $layout === 'right-s' ) {
echo '';
} else if ( $layout === 'left' ) {
echo '';
} else if ( $layout === 'left-s' ) {
echo '';
} else if ( $layout === 'both-side' ) {
echo '';
} else if ( $layout === 'both-side2' ) {
echo '';
} else if ( $layout === 'both-right' ) {
echo '';
} else if ( $layout === 'both-right2' ) {
echo '';
} else if ( $layout === 'both-left' ) {
echo '';
} else if ( $layout === 'both-left2' ) {
echo '';
}
echo ''; // row, page_content
get_footer();
}
/**
*
* Get post type's categories
*
* @return string
*
*/
public static function post_category( $l = 1, $s = 0 ) {
$out = array();
$cpt = self::get_post_type();
$tax = ( $cpt === 'post' ) ? 'category' : $cpt . '_cat';
$terms = (array) get_the_terms( self::$post->ID, $tax );
foreach ( $terms as $term ) {
if ( isset( $term->term_id ) ) {
$out[] = $l ? '
' . esc_html( $term->name ) . '' : esc_html( $term->name );
}
}
$out = implode( $s ? ', ' : '', $out );
$pre = $l ? '
' : '
';
return $out ? $pre . $out : '';
}
/**
*
* Get post type's tags
*
* @return string
*
*/
public static function the_tags() {
$out = '';
$tax = get_object_taxonomies( self::$post->post_type, 'objects' );
foreach ( $tax as $tax_slug => $taks ) {
$terms = get_the_terms( self::$post->ID, $tax_slug );
if ( ! empty( $terms ) && self::contains( $taks->label, 'Tags' ) ) {
$out .= '
';
foreach ( $terms as $term ) {
$out .= '' . esc_html( $term->name ) . '';
}
$out .= "
";
}
}
return $out;
}
/**
*
* Get related posts for single post page
*
* @return string
*
*/
public static function related( $args = array() ) {
$id = self::$post->ID;
$cpt = get_post_type( $id );
$meta = self::meta();
$args = wp_parse_args( $args, array(
'extra_class' => '',
'by' => 'cats',
'post_type' => $cpt,
'post__not_in' => array( $id ),
'posts_per_page'=> 3,
'related_columns'=> 's4'
) );
if ( $args['by'] === 'cats' ) {
if ( $cpt === 'post' ) {
$args['category__in'] = wp_get_post_categories( $id, array( 'fields'=>'ids' ) );
} else {
$taxonomy = $cpt . '_cat';
$get_cats = get_the_terms( $id, $taxonomy );
$get_cats = $get_cats ? $get_cats : '';
if ( $get_cats ) {
$tax = array('relation' => 'OR');
foreach ( $get_cats as $key ) {
if ( is_object( $key ) ) {
$tax[] = array(
'taxonomy' => $taxonomy,
'terms' => $key->term_id
);
}
}
$args['tax_query'] = $tax;
}
}
} else if ( $args['by'] === 'tags' ) {
$args['tag__in'] = wp_get_post_tags( $id, array( 'fields'=>'ids' ) );
} else if ( $args['by'] === 'rand' ) {
$args['orderby'] = 'rand';
}
/* Tax query */
$taxes = array( '_cats', '_tags' );
$tax_query = array();
foreach ( $taxes as $tax ) {
if ( isset( $args[ $tax ] ) ) {
$tax_array = explode( ',', $args[ $tax ] );
if ( $tax === '_cats' ) {
$tax = 'category';
} else if ( $tax === '_tags' ) {
$tax = 'post_tags';
}
foreach ( $tax_array as $cat ) {
if ( ! empty( $cat ) ) {
$tax_query[] = array( 'taxonomy' => $tax, 'field' => 'slug', 'terms' => $cat );
}
}
}
}
$args['tax_query'] = empty( $tax_query ) ? null : wp_parse_args( $tax_query, array( 'relation' => 'OR' ) );
$query = new WP_Query( $args );
ob_start();
echo '
';
if ( $query->have_posts() ):
$i = 1;
$col = ( $args['related_columns'] === 's6' ) ? 2 : ( ( $args['related_columns'] === 's4' ) ? 3 : 4 );
while ( $query->have_posts() ) : $query->the_post();
$cats = ( ! $cpt || $cpt === '' || $cpt === 'post' ) ? 'category' : $cpt . '_cat';
?>
if ( $i % $col === 0 ) {
echo '
';
}
$i++;
endwhile;
endif;
echo '
';
wp_reset_postdata();
$related = ob_get_clean();
if ( $related ) {
return '
' . esc_html( $args['section_title'] ) . '
' . $related;
}
}
/**
*
* Get string between two string
*
* @return string
*
*/
public static function get_string_between( $c = '', $s, $e, $m = 0 ) {
if ( $c ) {
if ( $m ) {
preg_match_all( '~' . preg_quote( $s, '~' ) . '(.*?)' . preg_quote( $e, '~' ) . '~s', $c, $matches );
return $matches[0];
}
$r = explode( $s, $c );
if ( isset( $r[1] ) ) {
$r = explode( $e, $r[1] );
return $r[0];
}
}
return;
}
/**
*
* Check if string contains specific value(s)
*
* @return string
*
*/
public static function contains( $v = '', $a = array() ) {
if ( $v ) {
foreach ( (array) $a as $k ) {
if ( $k && strpos( $v, $k ) !== false ) {
return 1;
break;
}
}
}
return null;
}
/**
*
* Get current page title
*
* @return string
*
*/
public static function page_title( $tag = 'h3', $class = '', $meta = 0 ) {
$is_woocommerce = ( function_exists( 'is_woocommerce' ) && ( is_shop() || is_woocommerce() ) );
if ( is_404() ) {
$i = '404';
} else if ( is_search() ) {
$i = self::option( 'search_title_prefix', 'Search result for:' ) . ' ' . get_search_query();
} else if ( is_archive() && ! $is_woocommerce ) {
$i = get_the_archive_title();
} else if ( is_single() ) {
$i = single_post_title( '', false );
$i = $i ? $i : get_the_title();
} else if ( is_home() ) {
$i = get_option( 'page_for_posts' ) ? get_the_title( get_option( 'page_for_posts' ) ) : 'Blog';
} else {
$i = get_the_title();
}
$small = '';
if ( $meta ) {
$author_url = get_author_posts_url( get_the_author_meta( 'ID' ) );
$small .= '
';
$small .= 'Posted by ' . ucwords( get_the_author() ) . '';
$small .= 'on ' . esc_html( get_the_time( get_option( 'date_format' ) ) ) . '';
$small .= '';
}
echo '<' . esc_attr( $tag ) . ' class="section_title ' . esc_attr( $class ) . '">' . wp_kses_post( $i . $small ) . '' . esc_attr( $tag ) . '>';
if ( is_category() && category_description() ) {
echo category_description();
}
if ( is_tag() && tag_description() ) {
echo tag_description();
}
if ( is_tax() && term_description( get_query_var('term_id'), get_query_var( 'taxonomy' ) ) ) {
echo term_description( get_query_var('term_id'), get_query_var( 'taxonomy' ) );
}
}
/**
*
* Get author box
*
* @return string
*
*/
public static function author_box() {
return get_the_author_meta( 'description' ) ? '
' . get_avatar( get_the_author_meta( 'user_email' ), '100' ) . '
' . get_the_author_meta('description') . '
' : '';
}
/**
*
* Ajax search process
*
* @return string
*
*/
public static function codevz_ajax_search() {
if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'ajax_search_nonce' ) ) {
die( '
Try again ...' );
}
$l = empty( $_GET['posts_per_page'] ) ? 4 : (int) $_GET['posts_per_page'];
$s = sanitize_text_field( $_GET['s'] );
$c = empty( $_GET['cpt'] ) ? array( 'any' ) : explode( ',', str_replace( ' ', '', $_GET['cpt'] ) );
$q = new WP_Query( array(
'post_type' => $c,
's' => $s,
'posts_per_page' => $l,
'orderby' => 'type',
'fields' => 'ids'
));
$nt = empty( $_GET['no_thumbnail'] ) ? 0 : 1;
ob_start();
if ( $q->have_posts() ) {
while ( $q->have_posts() ) {
$q->the_post();
$cpt = self::get_post_type();
if ( $cpt === 'page' || $cpt === 'dwqa-answer' ) {
continue;
}
echo '
';
if ( has_post_thumbnail() && ! $nt ) {
echo '
';
}
echo apply_filters( 'cz_ajax_search_instead_img', '' );
echo '
';
echo '
';
echo apply_filters( 'cz_ajax_search_meta', '
' . ucwords( ( $cpt === 'dwqa-question' ) ? 'Questions' : $cpt ) . '' . esc_html( get_the_date() ) . '' );
echo '
';
}
} else {
echo '
' . esc_html( self::option( 'not_found', 'Not found!' ) ) . '';
}
if ( $q->post_count >= $l ) {
unset( $_GET['action'] );
unset( $_GET['nonce'] );
$va = empty( $_GET['view_all_translate'] ) ? 'View all results' : $_GET['view_all_translate'];
echo '
' . $va . ' ';
comments_template();
echo '