%PDF- %PDF-
Direktori : /var/www/html/shaban/laviva/wp-content/themes/levelup/inc/ |
Current File : /var/www/html/shaban/laviva/wp-content/themes/levelup/inc/helpers.php |
<?php // File Security Check if ( ! defined( 'ABSPATH' ) ) { exit; } require_once LEVELUP_TEMPLATE_PATH . '/inc/helpers/html.php'; require_once LEVELUP_TEMPLATE_PATH . '/inc/helpers/sanitize.php'; require_once LEVELUP_TEMPLATE_PATH . '/inc/helpers/page.php'; require_once LEVELUP_TEMPLATE_PATH . '/inc/helpers/stylesheet.php'; if ( ! function_exists( 'levelup_get_blank_image' ) ) { function levelup_get_blank_image() { return LEVELUP_TEMPLATE_URL . '/images/1px.gif'; } } if ( ! function_exists( "levelup_get_options" ) ) { function levelup_get_options($param, $default = '', $type = ''){ global $levelup_options; $return = ''; $return_default = ''; if ($default && empty($levelup_options[$param])){ $return = $default; } if( !empty($levelup_options) && array_key_exists ( $param , $levelup_options )){ if ($type == 'bg-color' && array_key_exists('background-color', $levelup_options[$param])) { $return = $levelup_options[$param]['background-color']; } else if($type == 'rgba'){ if( ! isset($levelup_options[$param]['rgba']) || !$levelup_options[$param]['rgba']){ $return_default = $default; } else { $return_default = $levelup_options[$param]['rgba']; } } else if($type == 'gradient'){ if( !$levelup_options[$param]['from'] || !$levelup_options[$param]['to']){ $return = $default; } } else if($type == 'background'){ if(!$levelup_options[$param]['background-color']){ $levelup_options[$param]['background-color'] = $default['background-color']; } if(!$levelup_options[$param]['background-repeat']){ $levelup_options[$param]['background-repeat'] = $default['background-repeat']; } if(!$levelup_options[$param]['background-size']){ $levelup_options[$param]['background-size'] = $default['background-size']; } if(!$levelup_options[$param]['background-attachment']){ $levelup_options[$param]['background-attachment'] = $default['background-attachment']; } if(!$levelup_options[$param]['background-position']){ $levelup_options[$param]['background-position'] = $default['background-position']; } } $return = $return_default ? $return_default : $levelup_options[$param]; } return apply_filters( 'levelup_get_options_filter', $return, $param ); } } function levelup_comments_will_be_displayed() { return !( post_password_required() || ( !comments_open() && '0' == get_comments_number() ) ); } function levelup_is_edit_page($new_edit = null){ global $pagenow; if (!is_admin()) { return false; } if ($new_edit == "edit") { return in_array($pagenow, array('post.php',)); } elseif ($new_edit == "new") { return in_array($pagenow, array('post-new.php')); } else { return in_array($pagenow, array('post.php', 'post-new.php')); } } if ( ! function_exists( 'levelup_post_navigation' ) ) { function levelup_post_navigation( $args = array() ) { global $wpdb, $post, $levelup_options; if ( !in_the_loop()) { return false; } $taxonomy = 'category'; $options['same_category'] = false; $options['excluded_terms'] = apply_filters('levelup_portfolio_category_filter', ''); if ( 'rdy_portfolio' == get_post_type() && !empty( $levelup_options['portfolio-post_nav-same_category'] ) ) { $taxonomy = 'rdy_portfolio_category'; $options['same_category'] = true; } elseif ( 'rdy_project' == get_post_type() && !empty( $levelup_options['project-post_nav-same_category'] ) ) { $taxonomy = 'rdy_project_category'; $options['same_category'] = true; } elseif ( 'post' == get_post_type() && !empty( $levelup_options['blog-post_nav-same_category'] ) ) { $taxonomy = 'category'; $options['same_category'] = true; } $options['type'] = get_post_type(); $options['taxonomy'] = $taxonomy; $entries = array(); if ( ( 'rdy_portfolio' == get_post_type() && isset( $levelup_options['portfolio-post_nav-reverse'] ) && $levelup_options['portfolio-post_nav-reverse'] ) || ( 'rdy_project' == get_post_type() && isset( $levelup_options['project-post_nav-reverse'] ) && $levelup_options['project-post_nav-reverse'] ) || ( 'post' == get_post_type() && isset( $levelup_options['blog-post_nav-reverse'] ) && $levelup_options['blog-post_nav-reverse'] ) ) { $entries['prev'] = get_next_post( $options['same_category'], $options['excluded_terms'], $options['taxonomy'] ); $entries['next'] = get_previous_post( $options['same_category'], $options['excluded_terms'], $options['taxonomy'] ); } else { $entries['prev'] = get_previous_post( $options['same_category'], $options['excluded_terms'], $options['taxonomy'] ); $entries['next'] = get_next_post( $options['same_category'], $options['excluded_terms'], $options['taxonomy'] ); } $output = ''; if (!empty($entries['prev'])) { $entry = $entries['prev']; $post_type = get_post_type($entry->ID); $link = get_permalink($entry->ID); $post_title = esc_html( get_the_title($entry->ID) ); $image = '<i class="gi-arrow-left gi"></i>'; $title = esc_html__('Previous', 'LEVELUP'); $class = 'rdy-post-prev col-xs-6 col-sm-5'; $output .= '<a href="' . esc_url( $link ) . '" class="' . esc_attr( $class ) . '">'; $output .= '<div class="col-table">'; $output .= '<div class="col-td arrow"></div>'; $output .= '<div class="col-td">'; $output .= '<i class="gi-arrow-left gi gi-xs visible-xs-block"></i>'; $output .= '<p class="rdy-nav-direction hidden-xs">' . $title . '</p>'; $output .= '<p class="rdy-nav-title">' . $image . $post_title . '</p>'; $output .= '</div>'; $output .= '</div>'; $output .= '</a>'; } if (!empty($entries['next'])) { $entry = $entries['next']; $post_type = get_post_type($entry->ID); $link = get_permalink($entry->ID); $post_title = esc_html( get_the_title($entry->ID) ); $image = ' <i class="gi-arrow-right gi"></i>'; $title = esc_html__('Next', 'LEVELUP'); $class = 'rdy-post-next col-xs-6 col-sm-5 pull-right'; $output .= '<a href="' . esc_url( $link ) . '" class="' . esc_attr( $class ) . '">'; $output .= '<div class="col-table">'; $output .= '<div class="col-td">'; $output .= '<i class="gi-arrow-right gi gi-xs visible-xs-block"></i>'; $output .= '<p class="rdy-nav-direction hidden-xs">' . $title . '</p>'; $output .= '<p class="rdy-nav-title">' . $image . $post_title . '</p>'; $output .= '</div>'; $output .= '<div class="col-td arrow"></div>'; $output .= '</div>'; $output .= '</a>'; } if('post' == get_post_type() || 'rdy_project' == get_post_type() || ('rdy_portfolio' == get_post_type() && $levelup_options['portfolio-post_nav-url'])){ $class_right = ' pull-right'; if(!empty($entries['prev'])){ $class_right = ''; } if(empty($entries['prev']) && empty($entries['prev'])){ $class_right = ' col-xs-offset-5'; } if('post' == get_post_type()){ $back_link = levelup_all_posts_link(); } if('rdy_project' == get_post_type()){ $back_link = get_post_type_archive_link( 'rdy_project' ); } if('rdy_portfolio' == get_post_type() && $levelup_options['portfolio-post_nav-url']){ $back_link = get_permalink($levelup_options['portfolio-post_nav-url']); } $output .= '<div class="col-xs-2 grid' . esc_attr( $class_right ) . ' dots hidden-xs"><span class="col-table"><span class="col-td"><a href="' . esc_url( $back_link ) . '"><i></i><i></i><i></i><b></b></a></span></span></div>'; } echo $output; return ''; } } if ( ! function_exists( 'levelup_all_posts_link' ) ) { function levelup_all_posts_link() { if ( 'page' == get_option( 'show_on_front' ) ) { if ( get_option( 'page_for_posts' ) ) { return esc_url( get_permalink( get_option( 'page_for_posts' ) ) ); } else { return esc_url( home_url( '/?post_type=post' ) ); } } else { return esc_url( home_url( '/' ) ); } } } if ( ! function_exists( 'levelup_post_navigation_bar' ) ) { function levelup_post_navigation_bar($args = array()) { global $wpdb, $post, $levelup_options; if ((is_single() && get_post_type() == 'rdy_project' && $levelup_options['single-navigation_bar']) || (is_single() && get_post_type() == 'rdy_portfolio' && $levelup_options['single-portfolio-navigation_bar']) ) { if (get_post_type() == 'rdy_project' && $levelup_options['single-navigation_bar']) { $navigation_bar = $levelup_options['single-navigation_bar']; $navigation_bar_v2 = $levelup_options['single-navigation_bar_v2']; } elseif (get_post_type() == 'rdy_portfolio' && $levelup_options['single-portfolio-navigation_bar']) { $navigation_bar = $levelup_options['single-portfolio-navigation_bar']; $navigation_bar_v2 = $levelup_options['single-portfolio-navigation_bar_v2']; } while (have_posts()) : the_post(); if (!in_the_loop()) { return false; } $taxonomy = 'category'; $options['same_category'] = false; $options['excluded_terms'] = apply_filters('levelup_portfolio_category_filter', ''); $options['type'] = get_post_type(); $options['taxonomy'] = $taxonomy; $entries = array(); $entries['prev'] = get_previous_post($options['same_category'], $options['excluded_terms'], $options['taxonomy']); $entries['next'] = get_next_post($options['same_category'], $options['excluded_terms'], $options['taxonomy']); $v2_style = ($navigation_bar == 2) ? ' with-' . ($navigation_bar_v2 ? $navigation_bar_v2 : 'icons') : ''; $output = '<div class="navigation-bar hidden' . ($navigation_bar ? ' type' . $navigation_bar : '') . $v2_style . '"' . ($navigation_bar == 2 ? ' style="display:none"' : '') . '><div class="container">'; if (!empty($entries['prev'])) { $entry = $entries['prev']; $link = get_permalink($entry->ID); $post_title = esc_html( get_the_title($entry->ID) ); $image = '<i class="gi-arrow-left gi"></i>'; $title = esc_html__('Previous', 'LEVELUP'); $class = 'rdy-post-prev col-xs-5'; if ($navigation_bar == 1) { $output .= '<a href="' . esc_url( $link ) . '" class="' . esc_attr( $class ) . '">'; $output .= '<span class="col-table">'; $output .= '<span class="col-td">'; $output .= '<p class="rdy-nav-title">' . $image . '<span class="hidden-xs">' . $post_title . '</span></p>'; $output .= '</span>'; $output .= '</span>'; $output .= '</a>'; } else if ($navigation_bar == 2) { $output .= '<div class="project_nav leftSide"><a href="' . esc_url( $link ) . '" class="previous" rel="prev_project"><span>' . (($navigation_bar == 2 && $navigation_bar_v2 == 'text') ? esc_html__('Prev', 'LEVELUP') : '') . '</span></a></div>'; } } if (!empty($entries['next'])) { $entry = $entries['next']; $link = get_permalink($entry->ID); $post_title = esc_html( get_the_title($entry->ID) ); $image = ' <i class="gi-arrow-right gi"></i>'; $title = esc_html__('Next', 'LEVELUP'); $class = 'rdy-post-next col-xs-5 pull-right'; if ($navigation_bar == 1) { $output .= '<a href="' . esc_url( $link ) . '" class="' . esc_attr( $class ) . '">'; $output .= '<span class="col-table">'; $output .= '<span class="col-td">'; $output .= '<p class="rdy-nav-title">' . $image . '<span class="hidden-xs">' . $post_title . '</span></p>'; $output .= '</span>'; $output .= '</span>'; $output .= '</a>'; } else if ($navigation_bar == 2) { $output .= '<div class="project_nav rightSide"><a href="' . esc_url( $link ) . '" class="next" rel="next_project"><span>' . (($navigation_bar == 2 && $navigation_bar_v2 == 'text') ? esc_html__('Next', 'LEVELUP') : '') . '</span></a></div>'; } } $back_url = ''; $class_right = ' pull-right'; if (!empty($entries['prev'])) { $class_right = ''; } if ('rdy_project' == get_post_type()) { $back_url = get_post_type_archive_link('rdy_project'); } if ('rdy_portfolio' == get_post_type() && $levelup_options['portfolio-post_nav-url']) { $back_url = get_permalink($levelup_options['portfolio-post_nav-url']); } $class_right = ' pull-right'; if (!empty($entries['prev'])) { $class_right = ''; } if ($back_url) { $output .= '<div class="col-xs-2 dots' . esc_attr( $class_right ) . '"><a href="' . esc_url( $back_url ) . '"><i></i><i></i><i></i><b></b></a></div>'; } $output .= '</div></div>'; echo $output; endwhile; } return ''; } } if ( ! function_exists( 'levelup_get_pagetitle_catalogs' ) ) { function levelup_get_pagetitle_catalogs($print = true) { global $levelup_options; $config = Levelup_Config::get_instance(); $categories = $out = ''; $term = get_queried_object(); $parent_id = empty($term->term_id) ? 0 : $term->term_id; if ((is_home() || is_author() || is_category() || is_tag()) && !levelup_get_options('page-title-blog-category-enable')) { return ''; } $shop = false; if (is_home()) { $categories = get_categories(array('hide_empty' => 0, 'parent' => $parent_id)); } elseif ( function_exists( "is_woocommerce" ) ) { $shop = true; $show_categories = false; if (is_shop() && (get_option('woocommerce_shop_page_display') == '')) $show_categories = false; if (is_shop() && (get_option('woocommerce_shop_page_display') == 'products')) $show_categories = false; if (is_shop() && (get_option('woocommerce_shop_page_display') == 'subcategories')) $show_categories = false; if (is_shop() && (get_option('woocommerce_shop_page_display') == 'both')) $show_categories = true; if (is_product_category() && (get_option('woocommerce_category_archive_display') == '')) $show_categories = false; if (is_product_category() && (get_option('woocommerce_category_archive_display') == 'products')) $show_categories = false; if (is_product_category() && (get_option('woocommerce_category_archive_display') == 'subcategories')) $show_categories = false; if (is_product_category() && (get_option('woocommerce_category_archive_display') == 'both')) $show_categories = true; if (is_product_category() && (get_woocommerce_term_meta($parent_id, 'display_type', true) == 'products')) $show_categories = false; if (is_product_category() && (get_woocommerce_term_meta($parent_id, 'display_type', true) == 'subcategories')) $show_categories = false; if (is_product_category() && (get_woocommerce_term_meta($parent_id, 'display_type', true) == 'both')) $show_categories = true; if (isset($_GET["s"]) && $_GET["s"] != '') { $show_categories = false; } if ($show_categories == true) { $categories = get_terms('product_cat', array('hide_empty' => 0, 'parent' => $parent_id)); } } if ($categories): $out = '<ul class="list_categories' . ($levelup_options['page-title-list-style'] ? ' ' . esc_attr( $levelup_options['page-title-list-style'] ) : ' no-anim') . ( $config->get('fancy_header.list.style') == 'light' ? ' light' : ' dark') . '">';// list-centered $cat_counter = 0; foreach ($categories as $category) : if ($shop) { $link = get_term_link($category->slug, 'product_cat'); } else { $link = get_category_link($category->term_id); } $out .= '<li class="category_item">'; $out .= '<a href="' . esc_url( $link ) . '" class="category_item_link">'; $out .= '<span class="category_name">' . esc_html($category->name) . '</span>'; $out .= '</a>'; $out .= '</li>'; endforeach; $out .= '</ul>'; endif; return $out; } } if ( ! function_exists( 'levelup_get_pagetitle_meta' ) ) { function levelup_get_pagetitle_meta() { $out = ''; while ( have_posts() ) : the_post(); $config = Levelup_Config::get_instance(); $title_style = ''; if('fancy' == $config->get('header_title')){ $title_style = 'color: ' . esc_attr( $config->get('fancy_header.title.color') ) . ';'; } $out = '<div class="meta-info" style="' . esc_attr( $title_style ) . '">'; $out .= levelup_posted_on_full(false); $out .= '</div>'; endwhile; return $out; } } function levelup_get_embed( $src, $width = null, $height = null ) { global $wp_embed; if ( empty( $wp_embed ) ) { return false; } $video_shotcode = sprintf( '[embed%s%s]%s[/embed]', ! empty( $width ) ? ' width="' . intval( $width ) . '"' : '', ! empty( $height ) ? ' height="' . intval( $height ) . '"' : '', $src ); $video_shotcode = $wp_embed->run_shortcode( $video_shotcode ); return $video_shotcode; } if ( ! function_exists( 'levelup_get_posts_small_list' ) ) { function levelup_get_posts_small_list( $attachments_data, $options = array() ) { if ( empty( $attachments_data ) ) { return array(); } global $post; $default_options = array( 'links_rel' => '', 'show_images' => true ); $options = wp_parse_args( $options, $default_options ); $image_args = array( 'img_class' => '', 'class' => 'post-rollover', 'custom' => $options['links_rel'], 'options' => array( 'w' => 600, 'h' => 500, 'z' => true ), 'echo' => false, ); $articles = array(); $class = ''; $post_was_changed = false; $post_backup = $post; foreach ( $attachments_data as $data ) { $new_post = null; if ( isset( $data['parent_id'] ) ) { $post_was_changed = true; $new_post = get_post( $data['parent_id'] ); if ( $new_post ) { $post = $new_post; setup_postdata( $post ); } } $permalink = esc_url($data['permalink']); $attachment_args = array( 'href' => $permalink, 'img_meta' => array( $data['full'], $data['width'], $data['height'] ), 'img_id' => empty($data['ID']) ? 0 : $data['ID'], 'echo' => false, 'wrap' => '<a %CLASS% %HREF% %CUSTOM%><img %IMG_CLASS% %SRC% %SIZE% %ALT% /></a>', ); if ( empty($data['title']) ) { $data['title'] = _x('No title', 'blog small list', 'LEVELUP'); } if ( !empty( $data['parent_id'] ) ) { $class = 'post-' . levelup_get_post_format_class( get_post_format( $data['parent_id'] ) ); if ( empty($data['ID']) ) { $attachment_args['wrap'] = '<a %HREF% %CLASS% %TITLE%></a>'; $attachment_args['class'] = $image_args['class'] . ' no-avatar'; $attachment_args['img_meta'] = array('', 0, 0); $attachment_args['options'] = false; } } $article = sprintf( '<article class="%s"><div class="col-td">%s</div><div class="post-content">%s%s</div></article>', $class, $options['show_images'] ? levelup_get_thumb_img( array_merge($image_args, $attachment_args) ) : '', '<a href="' . $permalink . '">' . esc_html($data['title']) . '</a><br />', '<time class="text-secondary" datetime="' . get_the_date('c') . '">' . get_the_date(get_option('date_format')) . '</time>' ); $articles[] = $article; } if ( $post_was_changed ) { $post = $post_backup; setup_postdata( $post ); } return $articles; } } if ( ! function_exists( 'levelup_display_related_posts' ) ) { function levelup_display_related_posts() { if ( !levelup_get_options( 'blog-related_posts', false ) ) { return ''; } global $post; $html = ''; $terms = array(); $terms = wp_get_object_terms( $post->ID, 'category', array('fields' => 'ids') ); if ( $terms && !is_wp_error($terms) ) { $attachments_data = levelup_get_related_posts( array( 'cats' => $terms, 'post_type' => 'post', 'taxonomy' => 'category', 'args' => array( 'posts_per_page' => intval(levelup_get_options('general-rel_posts_max', 12)) ) ) ); $head_title = esc_html__( 'Related posts', 'LEVELUP' ); $posts_list = levelup_get_posts_small_list( $attachments_data ); if ( $posts_list ) { $config = Levelup_Config::get_instance(); if ( 'disabled' != $config->get('sidebar_position') ) { $column_class = 'col-md-4'; } else { $column_class = 'col-md-3'; } foreach ( $posts_list as $p ) { $html .= sprintf( '<div class="col-cell %s"><div class="borders">%s</div></div>', $column_class, $p ); } $html = '<section class="related-posts row">' . $html . '</section>'; if ( $head_title ) { $html = '<div class="rdy-fancy-separator title-left fancy-posts-title"><h3 class="rdy-fancy-title">' . $head_title . '</h3></div>' . $html; } } } echo (string) apply_filters( 'levelup_display_related_posts', $html ); return ''; } } if ( ! function_exists( 'levelup_get_attachments' ) ) { function levelup_get_attachments( $args = array() ) { $default_args = array( 'posts_per_page' => -1, 'orderby' => 'post__in', 'order' => 'DESC' ); $args = wp_parse_args( $args, $default_args ); if ( !array_key_exists('post__in', $args) || empty($args['post__in']) ) { return new WP_Error( 'no_attachments', esc_html__( 'Please set "post__in" argument', 'LEVELUP' ) ); } return new WP_Query( array( 'no_found_rows' => true, 'posts_per_page' => $args['posts_per_page'], 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'inherit', 'post__in' => $args['post__in'], 'orderby' => $args['orderby'], 'order' => $args['order'] ) ); } } if ( ! function_exists( 'levelup_get_posts_in_categories' ) ) { function levelup_get_posts_in_categories( $options = array() ) { $default_options = array( 'post_type' => 'post', 'taxonomy' => 'category', 'field' => 'term_id', 'cats' => array( 0 ), 'select' => 'all', 'args' => array(), ); $options = wp_parse_args( $options, $default_options ); $args = array( 'posts_per_page' => -1, 'post_type' => $options['post_type'], 'no_found_rows' => 1, 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => $options['taxonomy'], 'field' => $options['field'], 'terms' => $options['cats'], ) ), ); $args = array_merge( $args, $options['args'] ); switch( $options['select'] ) { case 'only': $args['tax_query'][0]['operator'] = 'IN'; break; case 'except': $args['tax_query'][0]['operator'] = 'NOT IN'; break; default: unset( $args['tax_query'] ); } $query = new WP_Query( $args ); return $query; } } if ( ! function_exists( 'levelup_get_short_post_myme_type' ) ) { function levelup_get_short_post_myme_type( $post_id = '' ) { $mime_type = get_post_mime_type( $post_id ); if ( $mime_type ) { $mime_type = current(explode('/', $mime_type)); } return $mime_type; } } if ( ! function_exists( 'levelup_get_related_posts' ) ) { function levelup_get_related_posts( $options = array() ) { $default_options = array( 'select' => 'only', 'exclude_current' => true, 'args' => array(), ); $options = wp_parse_args( $options, $default_options ); if ( in_the_loop() && $options['exclude_current'] ) { $options['args'] = array_merge( $options['args'], array( 'post__not_in' => array( get_the_ID() ) ) ); } $posts = levelup_get_posts_in_categories( $options ); $attachments_ids = array(); $attachments_data_override = array(); $posts_data = array(); if ( $posts->have_posts() ) { while ( $posts->have_posts() ) { $posts->the_post(); if ( has_post_thumbnail() ) { $attachment_id = get_post_thumbnail_id(); } else if ( $attachment = levelup_get_first_image() ) { $attachment_id = $attachment->ID; } else { $attachment_id = 0; } switch ( get_post_type() ) { case 'post': $post_meta = levelup_new_posted_on( 'post' ); break; case 'rdy_portfolio': $post_meta = levelup_new_posted_on( 'rdy_portfolio' ); break; default: $post_meta = levelup_new_posted_on(); } $post_data = array(); $post_data['full'] = $post_data['width'] = $post_data['height'] = ''; $meta = wp_get_attachment_image_src( $attachment_id, 'full' ); if ( !empty($meta) ) { $post_data['full'] = esc_url($meta[0]); $post_data['width'] = absint($meta[1]); $post_data['height'] = absint($meta[2]); } $post_data['thumbnail'] = wp_get_attachment_image_src( $attachment_id, 'thumbnail' ); $post_data['caption'] = ''; $post_data['video_url'] = esc_url( get_post_meta( $attachment_id, 'rdy-video-url', true ) ); $post_data['mime_type_full'] = get_post_mime_type( $attachment_id ); $post_data['mime_type'] = levelup_get_short_post_myme_type( $attachment_id ); $post_data['ID'] = $attachment_id; $post_data['image_attachment_data'] = array( 'caption' => $post_data['caption'], 'description' => wp_kses_post( get_post_field( 'post_content', $attachment_id ) ), 'title' => get_the_title( $attachment_id ), 'permalink' => get_permalink( $attachment_id ), 'video_url' => $post_data['video_url'], 'ID' => $attachment_id ); $post_data['title'] = get_the_title(); $post_data['permalink'] = get_permalink(); $post_data['link'] = levelup_get_project_link('project-link'); $post_data['description'] = get_the_excerpt(); $post_data['alt'] = get_the_title(); $post_data['parent_id'] = get_the_ID(); $post_data['meta'] = $post_meta; $posts_data[] = $post_data; } wp_reset_postdata(); } return $posts_data; } } if ( ! function_exists( 'levelup_get_first_image' ) ) { function levelup_get_first_image( $post_id = null ) { if ( in_the_loop() && !$post_id ) { $post_id = get_the_ID(); } if ( !$post_id ) { return false; } $args = array( 'posts_per_page' => 1, 'order' => 'ASC', 'post_mime_type' => 'image', 'post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', ); $attachments = get_children( $args ); if ( $attachments ) { return current($attachments); } return false; } } if ( ! function_exists( 'levelup_has_tags' ) ) { function levelup_has_tags() { global $levelup_options; if (has_tag() && !empty($levelup_options['display_tags']) && $levelup_options['display_tags'] == 1) { return true; } return false; } } if ( ! function_exists( 'levelup_get_post_format_class' ) ) { function levelup_get_post_format_class( $post_format = null ) { if ( 'post' == get_post_type() && null === $post_format ) { $post_format = get_post_format(); } $format_class_adapter = array( '' => 'format-standard', 'image' => 'format-photo', 'gallery' => 'format-gallery', 'quote' => 'format-quote', 'video' => 'format-video', 'link' => 'format-link', 'audio' => 'format-audio', 'chat' => 'format-chat', 'status' => 'format-status', 'aside' => 'format-aside' ); $format_class = isset( $format_class_adapter[ $post_format ] ) ? $format_class_adapter[ $post_format ] : $format_class_adapter['']; return $format_class; } } if ( ! function_exists( 'levelup_is_post_title_enabled' ) ) { function levelup_is_post_title_enabled() { if((class_exists( 'Woocommerce' ) && ( is_product() || is_wc_endpoint_url( 'lost-password' ) )) || is_404() ) return false; return in_array( levelup_config()->get( 'header_title' ), array( 'enabled', '' ) ); } } function levelup_count_words( $text, $num_words = 55 ) { $text = wp_strip_all_tags( $text ); if ( 'characters' == _x( 'words', 'word count: words or characters?', 'LEVELUP' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); preg_match_all( '/./u', $text, $words_array ); $words_array = array_slice( $words_array[0], 0, null ); } else { $words_array = preg_split( "/[\n\r\t ]+/", $text, -1, PREG_SPLIT_NO_EMPTY ); } return count( $words_array ); } if ( ! function_exists( 'levelup_get_the_excerpt' ) ) { function levelup_get_the_excerpt() { global $post; $text = ''; if ( !has_excerpt( $post->ID ) ) { if ( empty( $output ) && ! empty( $post->post_content ) ) { $text = wp_strip_all_tags( do_shortcode( $post->post_content ) ); $excerpt_length = apply_filters( 'excerpt_length', 55 ); $excerpt_more = apply_filters( 'excerpt_more', ' ' . '...' ); $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); } } if ( empty($text) && get_the_excerpt() ) { remove_filter('the_excerpt', 'wpautop'); $text = apply_filters( 'the_excerpt', get_the_excerpt() ); } return $text; } } if ( ! function_exists( 'levelup_the_excerpt' ) ) { function levelup_the_excerpt() { echo levelup_get_the_excerpt(); } } if ( ! function_exists( 'levelup_get_attachments_data_count' ) ) { function levelup_get_attachments_data_count( $attachments_data = array() ) { $images_count = 0; $videos_count = 0; if ( !empty( $attachments_data ) ) { foreach ( $attachments_data as $att_data ) { if ( empty( $att_data['video_url'] ) ) { $images_count++; } else { $videos_count++; } } unset( $att_data ); } return array( $images_count, $videos_count ); } } if ( ! function_exists( 'levelup_get_the_clear_content' ) ) { function levelup_get_the_clear_content() { $content = get_the_content( '' ); $content = strip_shortcodes( $content ); $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); return $content; } } if ( ! function_exists( 'levelup_get_social_icon' ) ) { function levelup_get_social_icon( $icon = '', $url = '#', $title = '', $classes = array(), $target = '_blank' ) { $clean_target = esc_attr( $target ); $icon_classes = 'fa-' . $icon . ' fa'; if ( 'skype' == $icon ) { $clean_url = esc_attr( $url ); } else if ( 'mail' == $icon && is_email( $url ) ) { $clean_url = 'mailto:' . esc_attr( $url ); $clean_target = '_top'; $icon_classes = 'fa fa-envelope'; } else if ( 'website' == $icon ) { $clean_url = esc_url( $url ); $icon_classes = 'fa fa-globe'; } else if ( 'forrst' == $icon ) { $clean_url = esc_url( $url ); $icon_classes = 'gi gi-forrst'; } else if ( 'px-500' == $icon ) { $clean_url = esc_url( $url ); $icon_classes = 'fa fa-500px'; } else { $clean_url = esc_url( $url ); } $output = sprintf( '<a title="%2$s" target="%4$s" href="%1$s" class="icon %3$s"></a>', $clean_url, esc_attr( $title ), esc_attr( $icon_classes ), $clean_target ); return $output; } } if ( ! function_exists( 'levelup_is_load_more_pagination' ) ) { function levelup_is_load_more_pagination() { $config = Levelup_Config::get_instance(); return in_array( $config->get( 'load_style' ), array( 'ajax_more', 'lazy_loading' ) ); } } if ( ! function_exists( 'levelup_get_default_avatar' ) ) { function levelup_get_default_avatar() { return LEVELUP_TEMPLATE_URL . '/assets/images/no-avatar.gif'; } } if ( ! function_exists( 'levelup_display_post_author' ) ) { function levelup_display_post_author() { global $levelup_options; $user_url = get_the_author_meta('user_url'); $avatar = get_avatar( get_the_author_meta('ID'), 105, levelup_get_default_avatar() ); ?> <div class="row"> <div class="col-md-12"> <div class="entry-author clearfix"> <?php if ( $user_url ) { printf( '<a href="%s" class="avatar-img">%s</a>', esc_url($user_url), $avatar ); } else { echo str_replace( "class='", "class='avatar-img ", $avatar ); } ?> <p class="post-author"><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) );?>"><?php the_author_meta( 'display_name' );?></a></p> <?php if( get_the_author_meta( 'description' ) ): ?><p class="post-author-desc"><?php the_author_meta( 'description' ); ?></p><?php endif;?> <p class="post-author-link"><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) );?>"><?php esc_html_e( 'All Posts by ', 'LEVELUP' ); the_author_meta( 'display_name' ); ?></a></p> </div> </div> </div> <?php } } if ( ! function_exists( 'levelup_blog_social_sharing' ) ) { function levelup_blog_social_sharing() { levelup_display_share_buttons('post', array( 'echo' => true )); return ''; } } if ( ! function_exists( 'levelup_social_sharing' ) ) { function levelup_social_sharing() { global $levelup_options; ob_start(); if( !empty($levelup_options['blog_social']) && $levelup_options['blog_social'] == 1) { echo '<div class="post-share clearfix"> <div class="post-share-buttons">'; if ( !empty($levelup_options['blog-facebook-sharing']) && $levelup_options['blog-facebook-sharing'] == 1) { echo '<a class="fa fa-facebook" href="#" title="' . esc_html__('Share this', 'LEVELUP') . '"></a>'; } if ( !empty($levelup_options['blog-twitter-sharing']) && $levelup_options['blog-twitter-sharing'] == 1) { echo '<a class="fa fa-twitter" href="#" title="' . esc_html__('Tweet this', 'LEVELUP') . '"></a>'; } if ( !empty($levelup_options['blog-google-plus-sharing']) && $levelup_options['blog-google-plus-sharing'] == 1) { echo '<a class="fa fa-google-plus" href="#" title="' . esc_html__('Share this', 'LEVELUP') . '"></a>'; } if ( !empty($levelup_options['blog-linkedin-sharing']) && $levelup_options['blog-linkedin-sharing'] == 1) { echo '<a class="fa fa-linkedin" href="#" title="' . esc_html__('Share this', 'LEVELUP') . '"></a>'; } if ( !empty($levelup_options['blog-pinterest-sharing']) && $levelup_options['blog-pinterest-sharing'] == 1) { echo '<a class="fa fa-pinterest" href="#" title="' . esc_html__('Pin this', 'LEVELUP') . '"></a>'; } echo '</div></div>'; } $sharing_output = ob_get_contents(); ob_end_clean(); echo $sharing_output; } } if ( ! function_exists( 'levelup_stylesheet_color_hex2rgb' ) ) { function levelup_stylesheet_color_hex2rgb( $_color, $raw = false ) { if( is_array($_color) ) { $rgb_array = array_map('intval', $_color); }else { $color = str_replace( '#', '', trim($_color) ); if ( count($color) < 6 ) { $color .= $color; } $rgb_array = sscanf($color, '%2x%2x%2x'); if( is_array($rgb_array) && count($rgb_array) == 3 ) { $rgb_array = array_map('absint', $rgb_array); }else { return ''; } } if ( !$raw ) { return sprintf( 'rgb(%d,%d,%d)', $rgb_array[0], $rgb_array[1], $rgb_array[2] ); } return $rgb_array; } } if (!function_exists( 'levelup_hex2rgb' )) { function levelup_hex2rgb($hex) { $hex = str_replace("#", "", $hex); if (strlen($hex) == 3) { $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1)); $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1)); $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1)); } else { $r = hexdec(substr($hex, 0, 2)); $g = hexdec(substr($hex, 2, 2)); $b = hexdec(substr($hex, 4, 2)); } $rgb = array($r, $g, $b); return $rgb; } } if (!function_exists( 'levelup_rgba_color' )) { function levelup_rgba_color($color, $transparency) { if ($color !== '' && $transparency !== '') { $rgba_color = ''; $rgb_color_array = levelup_hex2rgb($color); $rgba_color .= 'rgba(' . implode(', ', $rgb_color_array) . ', ' . $transparency . ')'; return $rgba_color; } return ''; } } if (!function_exists( 'levelup_stylesheet_color_hex2rgba' )) { function levelup_stylesheet_color_hex2rgba($color, $opacity = 0) { if (!$color){ return ''; } $rgb_array = levelup_stylesheet_color_hex2rgb($color, true); return sprintf('rgba(%d,%d,%d,%s)', $rgb_array[0], $rgb_array[1], $rgb_array[2], levelup_stylesheet_get_opacity($opacity)); } } if (!function_exists( 'levelup_stylesheet_color_rgba2rgb' )) { function levelup_stylesheet_color_rgba2rgb($rgba) { $raw_rgba = str_replace(array('rgba(', ')'), '', $rgba); $raw_rgba = explode(',', $raw_rgba); $raw_rgba = array_map('trim', $raw_rgba); list($R, $G, $B, $O) = $raw_rgba; return sprintf('rgb(%s,%s,%s)', $R, $G, $B); } } if (!function_exists( 'levelup_stylesheet_make_ie_compat_rgba' )) { function levelup_stylesheet_make_ie_compat_rgba($color, $ie_color, $opacity) { $return = array( 'rgba' => levelup_stylesheet_color_hex2rgba($color, $opacity), 'ie_color' => $ie_color ); if ($opacity == 100) { $return['ie_color'] = $color; } return $return; } } if (!function_exists( 'levelup_rgba2hex' )) { function levelup_rgba2hex($string) { $rgba = array(); $regex = '#\((([^()]+|(?R))*)\)#'; if (preg_match_all($regex, $string, $matches)) { $rgba = explode(',', implode(' ', $matches[1])); } else { $rgba = explode(',', $string); } $r = dechex($rgba['0']); $g = dechex($rgba['1']); $b = dechex($rgba['2']); $r = (strlen("" . $r) === 1) ? "0" . $r : $r; $g = (strlen("" . $g) === 1) ? "0" . $g : $g; $b = (strlen("" . $b) === 1) ? "0" . $b : $b; return '#' . $r . $g . $b; } } if (!function_exists( 'levelup_get_default_image' )) { function levelup_get_default_image() { return array( LEVELUP_TEMPLATE_URL . '/assets/images/noimage.png', 1000, 1000); } } function levelup_fjarrett_get_attachment_id_from_url( $url ) { // Split the $url into two parts with the wp-content directory as the separator. $parse_url = explode( parse_url( WP_CONTENT_URL, PHP_URL_PATH ), $url ); // Get the host of the current site and the host of the $url, ignoring www. $this_host = str_ireplace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) ); $file_host = str_ireplace( 'www.', '', parse_url( $url, PHP_URL_HOST ) ); // Return nothing if there aren't any $url parts or if the current host and $url host do not match. if ( ! isset( $parse_url[1] ) || empty( $parse_url[1] ) || ( $this_host != $file_host ) ) { return; } // Now we're going to quickly search the DB for any attachment GUID with a partial path match. // Example: /uploads/2013/05/test-image.jpg global $wpdb; $prefix = $wpdb->prefix; $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM " . $prefix . "posts WHERE guid RLIKE %s;", $parse_url[1] ) ); return (!empty($attachment)) ? $attachment[0] : null; } function levelup_options_img($image_url){ $image_id = levelup_fjarrett_get_attachment_id_from_url( $image_url ); if(!is_null($image_id) && !empty($image_id)) { $image = wp_get_attachment_image_src($image_id, 'full'); return $image[0]; } else { return $image_url; } } if ( ! function_exists( 'levelup_add_preload_me_class_to_images' ) ) : function levelup_add_preload_me_class_to_images( $args = array() ) { $img_class = $args['img_class']; $img_class = str_replace('preload-i', '', $img_class); $img_class .= ' preload-i'; $args['img_class'] = trim( $img_class ); return $args; } endif; add_filter( 'levelup_get_thumb_img-args', 'levelup_add_preload_me_class_to_images', 15 ); if ( !function_exists( 'levelup_get_thumb_img' ) ) { function levelup_get_thumb_img( $opts = array() ) { global $post; $default_image = levelup_get_default_image(); $defaults = array( 'wrap' => '<a %HREF% %CLASS% %TITLE% %CUSTOM%><img %SRC% %IMG_CLASS% %SIZE% %ALT% %IMG_TITLE% /></a>', 'class' => '', 'alt' => '', 'title' => '', 'custom' => '', 'img_class' => '', 'img_title' => '', 'img_description' => '', 'img_caption' => '', 'href' => '', 'img_meta' => array(), 'img_id' => 0, 'options' => array(), 'default_img' => $default_image, 'prop' => false, 'echo' => true ); $opts = wp_parse_args( $opts, $defaults ); $opts = apply_filters('levelup_get_thumb_img-args', $opts); $original_image = null; if ( $opts['img_meta'] ) { $original_image = $opts['img_meta']; } else{ $original_image = wp_get_attachment_image_src( $opts['img_id'], 'full' ); } if ( !$original_image ) { $original_image = $opts['default_img']; } // proportion if ( $original_image && !empty($opts['prop']) && ( empty($opts['options']['h']) || empty($opts['options']['w']) ) ) { $_prop = $opts['prop']; $_img_meta = $original_image; if ( $_prop > 1 ) { $h = intval(floor($_img_meta[1] / $_prop)); $w = intval(floor($_prop * $h)); } else if ( $_prop < 1 ) { $w = intval(floor($_prop * $_img_meta[2])); $h = intval(floor($w / $_prop)); } else { $w = $h = min($_img_meta[1], $_img_meta[2]); } if ( !empty($opts['options']['w']) ) { $__prop = $h / $w; $w = intval($opts['options']['w']); $h = intval(floor($__prop * $w)); } else if ( !empty($opts['options']['h']) ) { $__prop = $w / $h; $h = intval($opts['options']['h']); $w = intval(floor($__prop * $h)); } $opts['options']['w'] = $w; $opts['options']['h'] = $h; } if ( $opts['options'] ) { $resized_image = levelup_get_resized_img( $original_image, $opts['options'] ); } else { $resized_image = $original_image; } if ( $img_id = absint( $opts['img_id'] ) ) { if ( '' === $opts['alt'] ) { $opts['alt'] = get_post_meta( $img_id, '_wp_attachment_image_alt', true ); } if ( '' === $opts['img_title'] ) { $opts['img_title'] = get_the_title( $img_id ); } } $class = empty( $opts['class'] ) ? '' : 'class="' . esc_attr( trim($opts['class']) ) . '"'; $title = empty( $opts['title'] ) ? '' : 'title="' . esc_attr( trim($opts['title']) ) . '"'; $img_title = empty( $opts['img_title'] ) ? '' : 'title="' . esc_attr( trim($opts['img_title']) ) . '"'; $img_class = empty( $opts['img_class'] ) ? '' : 'class="' . esc_attr( trim($opts['img_class']) ) . '"'; $href = $opts['href']; if ( !$href ) { $href = $original_image[0]; } $src = $resized_image[0]; if ( empty($resized_image[3]) || !is_string($resized_image[3]) ) { $size = image_hwstring($resized_image[1], $resized_image[2]); } else { $size = $resized_image[3]; } $src = str_replace( array(' '), array('%20'), $src ); $output = str_replace( array( '%HREF%', '%CLASS%', '%TITLE%', '%CUSTOM%', '%SRC%', '%IMG_CLASS%', '%SIZE%', '%ALT%', '%IMG_TITLE%', '%RAW_TITLE%', '%RAW_ALT%', '%RAW_IMG_TITLE%', '%RAW_IMG_DESCRIPTION%', '%RAW_IMG_CAPTION' ), array( 'href="' . esc_url( $href ) . '"', $class, $title, strip_tags( $opts['custom'] ), 'src="' . esc_url( $src ) . '"', $img_class, $size, 'alt="' . esc_attr( $opts['alt'] ) . '"', $img_title, esc_attr( $opts['title'] ), esc_attr( $opts['alt'] ), esc_attr( $opts['img_title'] ), esc_attr( $opts['img_description'] ), esc_attr( $opts['img_caption'] ) ), $opts['wrap'] ); if ( $opts['echo'] ) { echo $output; return ''; } return $output; } } if ( ! function_exists( 'levelup_vc_is_inline' ) ) { function levelup_vc_is_inline() { return function_exists( 'vc_is_inline' ) && vc_is_inline(); } } if (!function_exists( 'levelup_stylesheet_get_opacity' )) { function levelup_stylesheet_get_opacity($opacity = 0) { $opacity = absint($opacity); $opacity = ($opacity > 0) ? $opacity / 100 : 0; return $opacity; } } if (!function_exists( 'levelup_stylesheet_make_web_font_object' )) { function levelup_stylesheet_make_web_font_object($font_1, $defaults = array()) { // defaults $weight = $style = 'normal'; $family = 'Open Sans'; $font = new stdClass(); $font->family = is_array( $font_1 ) && array_key_exists( 'font-family', $font_1 ) && $font_1['font-family'] ? $font_1['font-family'] : $family; $font->style = is_array( $font_1 ) && array_key_exists( 'font-style', $font_1 ) && $font_1['font-style'] ? $font_1['font-style'] : $style; $font->weight = is_array( $font_1 ) && array_key_exists( 'font-weight', $font_1 ) && $font_1['font-weight'] ? $font_1['font-weight'] : $weight; $font->size = is_array( $font_1 ) && array_key_exists( 'font-size', $font_1 ) && $font_1['font-size'] ? $font_1['font-size'] : 13; $font->line = is_array( $font_1 ) && array_key_exists( 'line-height', $font_1 ) && $font_1['line-height'] ? $font_1['line-height'] : '100%'; $font->transform = is_array( $font_1 ) && array_key_exists( 'text-transform', $font_1 ) && $font_1['text-transform'] ? $font_1['text-transform'] : 'None'; $font->spacing = is_array( $font_1 ) && array_key_exists( 'letter-spacing', $font_1 ) && $font_1['letter-spacing'] ? $font_1['letter-spacing'] : 0; $font->color = is_array( $font_1 ) && array_key_exists( 'color', $font_1 ) && $font_1['color'] ? $font_1['color'] : '#000000'; return $font; } } if (!function_exists( 'levelup_get_accent_color' )) { function levelup_get_accent_color($type, $color = '') { global $levelup_options; switch ($type) { case 'accent': return $levelup_options['accent-color']; break; default: return $color; break; } } } if (!function_exists( 'levelup_get_paged_var' )) { function levelup_get_paged_var() { if (!($pg = get_query_var('page'))) { $pg = get_query_var('paged'); $pg = $pg ? $pg : 1; } return absint($pg); } } if (!function_exists( 'levelup_check_valid_colorhex' )) { function levelup_check_valid_colorhex($colorCode) { $colorCode = ltrim($colorCode, '#'); if ( ctype_xdigit($colorCode) && (strlen($colorCode) == 6 || strlen($colorCode) == 3) ) { return true; } else { return false; } } } if (!function_exists( 'levelup_check_valid_color' )) { function levelup_check_valid_color($colorCode) { if ( preg_match( "/(#([0-9a-f]{3}){1,2}|(rgba|hsla)\(\d{1,3}%?(,\s?\d{1,3}%?){2},\s?(1|0?\.\d+)\)|(rgb|hsl)\(\d{1,3}%?(,\s?\d{1,3}%?\)){2})/i", $colorCode ) ) { return true; } else { return false; } } } if (!function_exists( 'levelup_convert_opacity' )) { function levelup_convert_opacity($val, $inverse = false) { $default_val = .25; if (!$val && $val != 0) return $default_val; $val = floatval($val); if ($val >= 0 && $val <= 100) { if ($inverse) { $val = (100 - $val) / 100; } else { $val = $val / 100; } return $val; } return $default_val; } } if (!function_exists( 'levelup_httpify' )) { function levelup_httpify($link, $append = 'http://', $allowed = array('http://', 'https://')) { $found = false; foreach ($allowed as $protocol) if (strpos($link, $protocol) !== false) $found = true; if ($found) return $link; return $append . $link; } } if (!function_exists( 'levelup_calc_columns_class' )) { function levelup_calc_columns_class($num, $fixed = false) { $res_class = ''; $classes = array(); if ($num == 4) { if ($fixed) { $classes[] = 'col-sm-3'; $classes[] = 'col-xs-12'; } else { $classes[] = 'col-lg-3'; $classes[] = 'col-md-4'; $classes[] = 'col-sm-6'; $classes[] = 'col-xs-12'; } } elseif ($num == 3) { if ($fixed) { $classes[] = 'col-sm-4'; $classes[] = 'col-xs-12'; } else { $classes[] = 'col-lg-4'; $classes[] = 'col-md-6'; $classes[] = 'col-sm-6'; $classes[] = 'col-xs-12'; } } elseif ($num == 2) { if ($fixed) { $classes[] = 'col-sm-6'; $classes[] = 'col-xs-12'; } else { $classes[] = 'col-lg-6'; $classes[] = 'col-md-6'; $classes[] = 'col-sm-6'; $classes[] = 'col-xs-12'; } } elseif ($num == 1) { $classes[] = 'col-xs-12'; } elseif ($num == 6) { if ($fixed) { $classes[] = 'col-sm-2'; $classes[] = 'col-xs-12'; } else { $classes[] = 'col-lg-2'; $classes[] = 'col-md-3'; $classes[] = 'col-sm-4'; $classes[] = 'col-xs-12'; } } $res_class = join(" ", $classes); return $res_class; } } if (!function_exists( 'levelup_calculate_responsive_font_class' )) { function levelup_calculate_responsive_font_class($size, $id=false){ $limits = array( '5' => array(30, 50), '4' => array(50, 75), '3' => array(75, 100), '2' => array(100, 125), '1' => array(125, 15000), ); foreach($limits as $key => $value){ if($size > $value[0] && $size <= $value[1]){ if($id) return $key ; else return 'responsive-h' . $key ; } } return False; } } if (!function_exists( 'levelup_retina_on' )) { function levelup_retina_on() { return false; } } if (!function_exists( 'levelup_is_hd_device' )) { function levelup_is_hd_device() { return (isset($_COOKIE['devicePixelRatio']) && $_COOKIE['devicePixelRatio'] > 1.3); } } if (!function_exists( 'levelup_constrain_dim' )) { function levelup_constrain_dim( $w0, $h0, &$w1, &$h1, $change = false ) { $prop_sizes = wp_constrain_dimensions( $w0, $h0, $w1, $h1 ); if ( $change ) { $w1 = $prop_sizes[0]; $h1 = $prop_sizes[1]; } return array( $w1, $h1 ); } } if (!function_exists( 'levelup_get_resized_img' )) { function levelup_get_resized_img( $img, $opts ) { $opts = apply_filters( 'levelup_get_resized_img-options', $opts, $img ); if ( !is_array( $img ) || !$img || (!$img[1] && !$img[2]) ) { return false; } if ( !is_array( $opts ) || !$opts ) { if ( !isset( $img[3] ) ) { $img[3] = image_hwstring( $img[1], $img[2] ); } return $img; } if ( !isset($opts['hd_convert']) ) { $opts['hd_convert'] = true; } $defaults = array( 'w' => 0, 'h' => 0 , 'zc' => 1, 'z' => 1 ); $opts = wp_parse_args( $opts, $defaults ); $w = absint( $opts['w'] ); $h = absint( $opts['h'] ); if ( 0 == $opts['zc'] && ( $img[1] <= $w && $img[2] <= $h ) ) { return array( $img[0], $img[1], $img[2], image_hwstring( $img[1], $img[2] ) ); } elseif ( 3 == $opts['zc'] || empty ( $w ) || empty ( $h ) ) { if ( 0 == $opts['z'] ) { levelup_constrain_dim( $img[1], $img[2], $w, $h, true ); } else { $p = absint( $img[1] ) / absint( $img[2] ); $hx = absint( floor( $w / $p ) ); $wx = absint( floor( $h * $p ) ); if ( empty( $w ) ) { $w = $wx; } else if ( empty( $h ) ) { $h = $hx; } else { if ( $hx < $h && $wx >= $w ) { $h = $hx; } elseif ( $wx < $w && $hx >= $h ) { $w = $wx; } } } if ( $img[1] == $w && $img[2] == $h ) { return array( $img[0], $img[1], $img[2], image_hwstring( $img[1], $img[2] ) ); } } $img_h = $h; $img_w = $w; if ( $opts['hd_convert'] && levelup_retina_on() && levelup_is_hd_device() ) { $img_h *= 2; $img_w *= 2; } if ( 1 == $opts['zc'] ) { if ( $img[1] >= $img_w && $img[2] >= $img_h ) { } else if ( $img[1] <= $img[2] && $img_w >= $img_h ) { $cw_new = $img[1]; $k = $cw_new/$img_w; $ch_new = $k * $img_h; } else if ( $img[1] >= $img[2] && $img_w <= $img_h ) { $ch_new = $img[2]; $k = $ch_new/$img_h; $cw_new = $k * $img_w; } else { $kh = $img_h/$img[2]; $kw = $img_w/$img[1]; $kres = max( $kh, $kw ); $ch_new = $img_h/$kres; $cw_new = $img_w/$kres; } if ( isset($ch_new, $cw_new) ) { $img_h = absint(floor($ch_new)); $img_w = absint(floor($cw_new)); } } $file_url = levelup_aq_resize( $img[0], $img_w, $img_h, true, true, false ); if ( !$file_url ) { $file_url = $img[0]; } return array( $file_url, $w, $h, image_hwstring( $w, $h ) ); } } if (!function_exists( 'levelup_get_uniqid' )) { function levelup_get_uniqid() { return str_replace(".", "", uniqid('', true)); } } if (!function_exists( 'levelup_is_blog' )) { function levelup_is_blog() { global $post; $posttype = get_post_type($post); return ( ( ( is_archive() ) || ( is_author() ) || ( is_category() ) || ( is_home() ) || ( is_single() ) || ( is_tag() ) ) && ( $posttype == 'post' ) ) ? true : false; } } if (!function_exists( 'levelup_get_typography_fontsize' )) { function levelup_get_typography_fontsize($opt) { global $levelup_options; if (array_key_exists('font-size', $levelup_options[$opt])) { if (!is_numeric($levelup_options[$opt]['font-size'])) { $val = preg_replace('/[^0-9]/', '', $levelup_options[$opt]['font-size']); } return $val ? $val : $levelup_options[$opt]['font-size']; } return false; } } if (!function_exists( 'levelup_get_blog_video' )) { function levelup_get_blog_video() { global $post; $video_embed = get_post_meta($post->ID, '_rdy_page_video_embed', true); $video_m4v = get_post_meta($post->ID, '_rdy_page_video_m4v', true); $video_ogv = get_post_meta($post->ID, '_rdy_page_video_ogv', true); $video_poster = get_post_meta($post->ID, '_rdy_page_video_image', true); $video_container_class = 'video'; if (!empty($video_embed) || !empty($video_m4v)) { $wp_version = floatval(get_bloginfo('version')); //video embed if (!empty($video_embed)) { echo '<div class="' . esc_attr( $video_container_class ) . '">' . do_shortcode($video_embed) . '</div>'; } else { if (!empty($video_m4v) || !empty($video_ogv)) { $video_output = '[video '; if (!empty($video_m4v)) { $video_output .= 'mp4="' . esc_url( $video_m4v ) . '" '; } if (!empty($video_ogv)) { $video_output .= 'ogv="' . esc_url( $video_ogv ) . '"'; } $video_poster_src = wp_get_attachment_image_src($video_poster, 'full'); $video_output .= ' poster="' . esc_url( $video_poster_src[0] ) . '"]'; echo '<div class="' . esc_attr( $video_container_class ) . '">' . do_shortcode($video_output) . '</div>'; } } } } } if ( ! function_exists( 'levelup_make_image_src_ssl_friendly' ) ) { function levelup_make_image_src_ssl_friendly( $src ) { $ssl_friendly_src = (string) $src; if ( is_ssl() ) { $ssl_friendly_src = str_replace('http:', 'https:', $ssl_friendly_src); } return $ssl_friendly_src; } } if ( ! function_exists( 'levelup_is_param' ) ) { function levelup_is_param( $param, $class, $class2 = '' ) { global $levelup_options; if ( array_key_exists( $param, $levelup_options ) && ! empty( $levelup_options[ $param ] ) && $levelup_options[ $param ] ) { echo esc_attr( $class ); } elseif ( $class2 ) { echo esc_attr( $class2 ); } } } if ( ! function_exists( 'levelup_vc_build_link' ) ) { function levelup_vc_build_link( $value ) { $value = vc_parse_multi_attribute( $value, array( 'url' => '', 'title' => '', 'target' => '' ) ); if ( array_key_exists( 'target', $value ) && strpos( $value['target'], '_blank' ) !== false ) { $value['target'] = '_blank'; } return $value; } } if ( ! function_exists( 'levelup_get_topbar_block' ) ) { function levelup_get_topbar_block( $side ) { global $levelup_options; if ( !array_key_exists( $side, $levelup_options['header-topbar-blocks'] ) ) { return false; } $output = ''; foreach ( $levelup_options['header-topbar-blocks'][$side] as $key => $value ) { $icon = ''; switch ( $key ) { case 'text': $output .= levelup_get_topbar_elem( wp_kses( $levelup_options['header-topbar-elem-text'], array( 'a' => array( 'href' => array(), 'target' => array(), 'class' => array() ) ) ) ); break; case 'email': if ( $levelup_options['header-topbar-elem-email_icon'] ) { $icon = '<span class="icon fa fa-envelope"></span>'; } $output .= levelup_get_topbar_elem( $icon . '<a href="mailto:' . sanitize_email( $levelup_options['header-topbar-elem-email'] ) . '">' . sanitize_email( $levelup_options['header-topbar-elem-email'] ) . '</a>' ); break; case 'phone': if ( $levelup_options['header-topbar-elem-phone_icon'] ) { $icon = '<span class="icon fa fa-phone"></span>'; } $elem = $icon . esc_html( $levelup_options['header-topbar-elem-phone'] ); if ( levelup_get_options( 'header-topbar-elem-phone_link' ) ) { $elem = '<a href="tel:' . esc_html( $levelup_options['header-topbar-elem-phone'] ) . '">' . $elem . '</a>'; } $output .= levelup_get_topbar_elem( $elem ); break; case 'skype': if ( $levelup_options['header-topbar-elem-skype_icon'] ) { $icon = '<span class="icon fa fa-skype"></span>'; } $output .= levelup_get_topbar_elem( $icon . esc_html( $levelup_options['header-topbar-elem-skype'] ) ); break; case 'login': if ( class_exists( 'Woocommerce' ) ) { $woo_account_page_link = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ); if ( $woo_account_page_link ) { if( ! is_user_logged_in() ) { $title = esc_html__( 'Login', 'LEVELUP' ); } else { $title = esc_html__( 'My Account', 'LEVELUP' ); } $output .= levelup_get_topbar_elem( '<a href="' . esc_url( $woo_account_page_link ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $title ) . '</a>'); } } break; case 'search': $output .= levelup_get_topbar_elem( '<form class="searchform" role="search" method="get" action="' . esc_url( home_url( '/' ) ) . '"><input type="text" class="field searchform-s" name="s" value="' . esc_attr( get_search_query() ) . '" placeholder="' . esc_html__( 'Type and hit enter …', 'LEVELUP' ) . '" /></form>' ); break; case 'cart': $output .= levelup_get_topbar_elem( '<a href="' . wc_get_cart_url() . '" class="cart"><span class="gi gi-cart-01"></span></a>' ); break; case 'social': $output .= levelup_get_topbar_elem( levelup_header_topbar_socials(true) ); break; case 'menu': $output .= levelup_get_topbar_elem( wp_nav_menu( array( 'theme_location' => 'topbar', 'container' => false, 'echo' => false, 'depth' => 1, ) ) ); break; } } return $output; } } if ( ! function_exists( 'levelup_get_footerbar_block' ) ) { function levelup_get_footerbar_block( $side ) { global $levelup_options; if ( !array_key_exists( $side, $levelup_options['footer-sub-blocks'] ) ) { return false; } $output = ''; foreach ( $levelup_options['footer-sub-blocks'][$side] as $key => $value ) { $icon = ''; switch ( $key ) { case 'text': $output .= levelup_get_topbar_elem( sprintf('<p>%s</p>', $levelup_options['footer-sub-column1-text']) ); break; case 'social': // $output .= levelup_get_topbar_elem( levelup_header_topbar_socials(true) ); $output .= levelup_get_topbar_elem( levelup_footer_socials(true, true) ); break; case 'logo': if ( $levelup_options['footer-sub-logo'] && array_key_exists('url', $levelup_options['footer-sub-logo']) && $levelup_options['footer-sub-logo']['url'] ) { $html = '<img class="footer-logo" src="' . esc_url( $levelup_options['footer-sub-logo']['url'] ) . '">'; if ( levelup_get_options( 'footer-sub-logo_link' ) ) { $html = '<a class="footer-logo-a" href="' . ( ! empty ( $levelup_options['logo-custom-url'] ) ? $levelup_options['logo-custom-url'] : esc_url( home_url( '/' ) ) ) . '">' . $html . '</a>'; } $output .= levelup_get_topbar_elem( $html ); } break; case 'menu': $output .= levelup_get_topbar_elem( wp_nav_menu( array( 'theme_location' => 'footerbar', 'container' => false, 'echo' => false, 'depth' => 1, ) ) ); break; } } return $output; } } if ( ! function_exists( 'levelup_get_topbar_elem' ) ) { function levelup_get_topbar_elem( $elem, $type = '' ) { $output = sprintf( '<div class="elem">%s</div>', $elem ); return $output; } } if ( ! function_exists( 'levelup_get_logo' ) ) { function levelup_get_logo($header_menu = false) { global $levelup_options; if ( ! empty( $levelup_options['use-logo'] ) && $levelup_options['use-logo'] != '' ) { if ( $header_menu ) { echo '<div class="col-td logo-container">'; } ?> <a href="<?php if(!empty($levelup_options['logo-custom-url'])) echo esc_url( $levelup_options['logo-custom-url'] ); else echo esc_url( home_url( '/' ) ); ?>"<?php if ( ! $header_menu ):?> id="logo"<?php endif;?> class="zlogo main-logo<?php if ( isset( $levelup_options['logo-mobile'] ) && isset( $levelup_options['logo-mobile']['url'] ) && ! empty( $levelup_options['logo-mobile']['url'] ) ) { echo ' with-mobile-logo';}?>"> <div class="logo-holder<?php echo esc_attr( $levelup_options['logo-top-stick'] ? ' logo-stick' : '' ); ?>"> <?php if ( ! empty( $levelup_options['use-logo'] ) && $levelup_options['use-logo'] == 'image' && ( $levelup_options['logo']['id'] || $levelup_options['retina-logo']['id'] || ( $levelup_options['logo-light']['id'] || $levelup_options['retina-logo-light']['id'] ) ) ) { $logo_1 = null; $logo_1r = null; $logo_2 = null; $logo_2r = null; if ( isset( $levelup_options['logo']['url'] ) && $levelup_options['logo']['url'] && isset( $levelup_options['logo-light']['url'] ) && $levelup_options['logo-light']['url'] ) { $logo_1 = $levelup_options['logo']['url']; $logo_1r = isset($levelup_options['retina-logo']['url']) ? $levelup_options['retina-logo']['url'] : ''; $logo_2 = $levelup_options['logo-light']['url']; $logo_2r = isset($levelup_options['retina-logo-light']['url']) ? $levelup_options['retina-logo-light']['url'] : ''; } elseif ( isset( $levelup_options['logo']['url'] ) && $levelup_options['logo']['url'] ) { $logo_1 = $levelup_options['logo']['url']; $logo_1r = $levelup_options['retina-logo']['url']; } elseif ( isset( $levelup_options['logo-light']['url'] ) && $levelup_options['logo-light']['url'] ) { $logo_1 = $levelup_options['logo-light']['url']; $logo_1r = $levelup_options['retina-logo-light']['url']; } if( $logo_1 ) echo levelup_get_image_with_srcset( esc_url( $logo_1 ), esc_url( $logo_1r ), '', '', 'starting-logo dark-version' ); if( $logo_2 ) echo levelup_get_image_with_srcset( esc_url( $logo_2 ), esc_url( $logo_2r ), '', '', 'starting-logo light-version' ); if ( isset( $levelup_options['logo-mobile'] ) && isset( $levelup_options['logo-mobile']['url'] ) && ! empty( $levelup_options['logo-mobile']['url'] ) ) { echo levelup_get_image_with_srcset( esc_url( $levelup_options['logo-mobile']['url'] ), '', '', '', 'mobile-logo' ); } } elseif ( ! empty( $levelup_options['use-logo'] ) && $levelup_options['use-logo'] == 'title' ) { echo $levelup_options['logo-title'] ? esc_html( $levelup_options['logo-title'] ) : esc_html( get_bloginfo( 'name' ) ); } ?> </div> </a> <?php if ( $header_menu ) { echo '</div>'; } } } } if ( ! function_exists( "levelup_is_css_has_background" ) ) { function levelup_is_css_has_background( $css ) { if ( preg_match( '/background:|background-color:/', $css ) ) { return true; } return false; } } if ( ! function_exists( "levelup_get_posts_count" ) ) { function levelup_get_posts_count() { global $wp_query; return $wp_query->post_count; } } function levelup_init_options () { $opt_name = 'levelup_options'; if (!empty($opt_name) && !empty($key)) { $levelupredux = get_option($opt_name); if (isset($levelupredux[$key])) { return $levelupredux[$key]; } else { return; } } else { return; } } if ( ! function_exists( 'levelup_get_breadcrumbs' ) ) { function levelup_get_breadcrumbs( $args = array() ) { $default_args = array( 'text' => array( 'home' => __( 'Home', 'LEVELUP'), 'category' => __( 'Category "%s"', 'LEVELUP'), 'search' => __( 'Results for "%s"', 'LEVELUP'), 'tag' => __( 'Entries tagged with "%s"', 'LEVELUP'), 'author' => __( 'Article author %s', 'LEVELUP'), '404' => __( 'Error 404', 'LEVELUP'), ), 'showCurrent' => 1, 'showOnHome' => 1, 'delimiter' => '', 'before' => '<li class="current">', 'after' => '</li>', 'linkBefore' => '<li typeof="v:Breadcrumb">', 'linkAfter' => '</li>', 'linkAttr' => ' rel="v:url" property="v:title"', 'beforeBreadcrumbs' => '', 'afterBreadcrumbs' => '', 'listAttr' => ' class="breadcrumbs text-small"' ); $args = wp_parse_args( $args, $default_args ); $get_the_title = get_the_title(); $breadcrumbs_html = apply_filters( 'levelup_get_breadcrumbs-html', '', $args ); if ( $breadcrumbs_html ) { return $breadcrumbs_html; } extract( array_intersect_key( $args, $default_args ) ); $link = $linkBefore . '<a' . $linkAttr . ' href="%1$s" title="">%2$s</a>' . $linkAfter; // $breadcrumbs_html .= '<div class="assistive-text">' . __( 'You are here:', 'LEVELUP' ) . '</div>'; $homeLink = home_url() . '/'; global $post; if (is_home() || is_front_page()) { if ($showOnHome == 1) { $breadcrumbs_html .= '<ol' . $listAttr . '><a href="' . $homeLink . '">' . $text['home'] . '</a></ol>'; } } else { $breadcrumbs_html .= '<ol' . $listAttr . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . sprintf($link, $homeLink, $text['home']) . $delimiter; if ( is_category() ) { $thisCat = get_category(get_query_var('cat'), false); if ($thisCat->parent != 0) { $cats = get_category_parents($thisCat->parent, TRUE, $delimiter); $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats); $cats = str_replace('</a>', '</a>' . $linkAfter, $cats); if(preg_match( '/title="/', $cats ) ===0) { $cats = preg_replace('/title=""/', 'title=""', $cats); } $breadcrumbs_html .= $cats; } $breadcrumbs_html .= $before . sprintf($text['category'], single_cat_title('', false)) . $after; } elseif ( is_search() ) { $breadcrumbs_html .= $before . sprintf($text['search'], get_search_query()) . $after; } elseif ( is_day() ) { $breadcrumbs_html .= sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter; $breadcrumbs_html .= sprintf($link, get_month_link(get_the_time('Y'),get_the_time('m')), get_the_time('F')) . $delimiter; $breadcrumbs_html .= $before . get_the_time('d') . $after; } elseif ( is_month() ) { $breadcrumbs_html .= sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter; $breadcrumbs_html .= $before . get_the_time('F') . $after; } elseif ( is_year() ) { $breadcrumbs_html .= $before . get_the_time('Y') . $after; } elseif ( is_single() && !is_attachment() ) { $post_type = get_post_type(); if ( $post_type === 'rdy_portfolio' ) { $post_type_obj = get_post_type_object( $post_type ); $post_type_link = get_permalink( levelup_get_options( 'portfolio-post_nav-url' ) ); $breadcrumbs_html .= sprintf($link, $post_type_link ? $post_type_link : get_post_type_archive_link( $post_type ), $post_type_obj->labels->singular_name); $cat = get_the_terms(get_the_ID(), 'rdy_portfolio_category'); if ( $cat ) { $cat = $cat[0]; $breadcrumbs_html .= $delimiter . sprintf($link, get_term_link($cat), esc_html($cat->name)) . $after; } if ($showCurrent == 1 && !empty($get_the_title)) { $breadcrumbs_html .= $delimiter . $before . get_the_title() . $after; } } elseif ( $post_type !== 'post' ) { $post_type_obj = get_post_type_object( $post_type ); $breadcrumbs_html .= sprintf($link, get_post_type_archive_link( $post_type ), $post_type_obj->labels->singular_name); if ($showCurrent == 1 && !empty($get_the_title)) { $breadcrumbs_html .= $delimiter . $before . get_the_title() . $after; } } else { $cat = get_the_category(); if ( $cat ) { $cat = $cat[0]; $cats = get_category_parents($cat, TRUE, $delimiter); if ( ! is_wp_error( $cats ) ) { if ($showCurrent == 0) { $cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats); } $cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats); $cats = str_replace('</a>', '</a>' . $linkAfter, $cats); $breadcrumbs_html .= $cats; } } if ($showCurrent == 1 && !empty($get_the_title)) { $breadcrumbs_html .= $before . get_the_title() . $after; } } } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) { $post_type_obj = get_post_type_object(get_post_type()); if ( $post_type_obj ) { $breadcrumbs_html .= $before . $post_type_obj->labels->singular_name . $after; } } elseif ( is_attachment() ) { if ($showCurrent == 1 && !empty($get_the_title)) { $breadcrumbs_html .= $delimiter . $before . get_the_title() . $after; } } elseif ( is_page() && !$post->post_parent ) { if ($showCurrent == 1 && !empty($get_the_title)) { $breadcrumbs_html .= $before . get_the_title() . $after; } } elseif ( is_page() && $post->post_parent ) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_post($parent_id); $breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID)); $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { $breadcrumbs_html .= $breadcrumbs[$i]; if ($i != count($breadcrumbs)-1) { $breadcrumbs_html .= $delimiter; } } if ($showCurrent == 1 && !empty($get_the_title)) { $breadcrumbs_html .= $delimiter . $before . get_the_title() . $after; } } elseif ( is_tag() ) { $breadcrumbs_html .= $before . sprintf($text['tag'], single_tag_title('', false)) . $after; } elseif ( is_author() ) { global $author; $userdata = get_userdata($author); $breadcrumbs_html .= $before . sprintf($text['author'], $userdata->display_name) . $after; } elseif ( is_404() ) { $breadcrumbs_html .= $before . $text['404'] . $after; } if ( get_query_var('paged') ) { $breadcrumbs_html .= $before; if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) { $breadcrumbs_html .= ' ('; } $breadcrumbs_html .= __( 'Page', 'LEVELUP' ) . ' ' . get_query_var('paged'); if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) { $breadcrumbs_html .= ')'; } $breadcrumbs_html .= $after; } $breadcrumbs_html .= '</ol>'; } return apply_filters( 'levelup_get_breadcrumbs', $beforeBreadcrumbs . $breadcrumbs_html . $afterBreadcrumbs, $args ); } } if ( ! function_exists( "levelup_is_header_enable" ) ) { function levelup_is_header_enable() { global $levelup_options; $config = Levelup_Config::get_instance(); $levelup_header_disable = $config->get( 'header.status' ) != '' ? $config->get( 'header.status' ) == 'disable' ? true : false : $levelup_options['menu-disable']; return $levelup_header_disable; } } if ( ! function_exists( "levelup_get_header_cta" ) ) { function levelup_get_header_cta() { $return = ''; if ( levelup_get_options( 'header-cta-position' ) ) { $return .= '<a' . ( levelup_get_options( 'header-cta-1-appear' ) ? ' data-cta-appear="' . levelup_get_options( 'header-cta-1-appear' ) . '"' : '' ) . ' href="' . esc_url( levelup_get_options( 'header-cta-1-url' ) ) . '" class="cta-button cta-button-1' . ( levelup_get_options( 'header-cta-1-type' ) == 'flat' ? ' flat' : ' outline' ) . '' . ( levelup_get_options( 'header-cta-1-size' ) ? ' ' . esc_attr( levelup_get_options( 'header-cta-1-size' ) ) : ' medium' ) . ' ' . apply_filters( 'levelup_header_cta1_class', '' ) . '"' . (levelup_get_options( 'header-cta-1-target_blank' ) ? ' target="_blank"' : '') . '>' . esc_html( levelup_get_options( 'header-cta-1-text' ) ) . '</a>'; if ( levelup_get_options( 'header-cta-2-enable' ) ) { $return .= '<a' . ( levelup_get_options( 'header-cta-2-appear' ) ? ' data-cta-appear="' . levelup_get_options( 'header-cta-2-appear' ) . '"' : '' ) . ' href="' . esc_url( levelup_get_options( 'header-cta-2-url' ) ) . '" class="cta-button cta-button-2' . ( levelup_get_options( 'header-cta-2-type' ) == 'flat' ? ' flat' : ' outline' ) . '' . ( levelup_get_options( 'header-cta-2-size' ) ? ' ' . esc_attr( levelup_get_options( 'header-cta-5-size' ) ) : ' medium' ) . ' ' . apply_filters( 'levelup_header_cta2_class', '' ) . '"' . (levelup_get_options( 'header-cta-2-target_blank' ) ? ' target="_blank"' : '') . '>' . esc_html( levelup_get_options( 'header-cta-2-text' ) ) . '</a>'; } if ( levelup_get_options( 'header-cta-3-enable' ) ) { $return .= '<a' . ( levelup_get_options( 'header-cta-3-appear' ) ? ' data-cta-appear="' . levelup_get_options( 'header-cta-3-appear' ) . '"' : '' ) . ' href="' . esc_url( levelup_get_options( 'header-cta-3-url' ) ) . '" class="cta-button cta-button-3' . ( levelup_get_options( 'header-cta-3-type' ) == 'flat' ? ' flat' : ' outline' ) . '' . ( levelup_get_options( 'header-cta-3-size' ) ? ' ' . esc_attr( levelup_get_options( 'header-cta-3-size' ) ) : ' medium' ) . ' ' . apply_filters( 'levelup_header_cta3_class', '' ) . '"' . (levelup_get_options( 'header-cta-3-target_blank' ) ? ' target="_blank"' : '') . '>' . esc_html( levelup_get_options( 'header-cta-3-text' ) ) . '</a>'; } } // $return = '<li class="menu-cta-button"><a' . ( levelup_get_options( 'header-cta-appear' ) ? ' data-cta-appear="' . levelup_get_options( 'header-cta-appear' ) . '"' : '' ) . ' href="' . esc_url( levelup_get_options( 'header-cta-url' ) ) . '" class="cta-button' . ( levelup_get_options( 'header-cta-type' ) == 'flat' ? ' flat' : ' outline' ) . '' . ( levelup_get_options( 'header-cta-size' ) ? ' ' . esc_attr( levelup_get_options( 'header-cta-size' ) ) : ' medium' ) . '">' . esc_html( levelup_get_options( 'header-cta-text' ) ) . '</a></li>'; return $return; } } if ( ! function_exists( "levelup_get_header_mobile_cta" ) ) { function levelup_get_header_mobile_cta() { $return = ''; if ( levelup_get_options( 'header-cta-position' ) && levelup_get_options( 'header-cta-1-mobile' ) ) { $return .= '<a href="' . esc_url( levelup_get_options( 'header-cta-1-url' ) ) . '" class="cta-button cta-button-1"' . (levelup_get_options( 'header-cta-1-target_blank' ) ? ' target="_blank"' : '') . '>' . esc_html( levelup_get_options( 'header-cta-1-text' ) ) . '</a>'; if ( levelup_get_options( 'header-cta-2-enable' ) && levelup_get_options( 'header-cta-2-mobile' ) ) { $return .= '<a href="' . esc_url( levelup_get_options( 'header-cta-2-url' ) ) . '" class="cta-button cta-button-2"' . (levelup_get_options( 'header-cta-2-target_blank' ) ? ' target="_blank"' : '') . '>' . esc_html( levelup_get_options( 'header-cta-2-text' ) ) . '</a>'; } if ( levelup_get_options( 'header-cta-3-enable' ) && levelup_get_options( 'header-cta-3-mobile' ) ) { $return .= '<a href="' . esc_url( levelup_get_options( 'header-cta-3-url' ) ) . '" class="cta-button cta-button-3"' . (levelup_get_options( 'header-cta-3-target_blank' ) ? ' target="_blank"' : '') . '>' . esc_html( levelup_get_options( 'header-cta-3-text' ) ) . '</a>'; } } return $return; } } if ( ! function_exists( "levelup_get_the_category_list" ) ) { function levelup_get_the_category( $id = false, $taxonomy ) { $categories = get_the_terms( $id, $taxonomy ); if ( ! $categories || is_wp_error( $categories ) ) $categories = array(); $categories = array_values( $categories ); foreach ( array_keys( $categories ) as $key ) { _make_cat_compat( $categories[$key] ); } /** * Filters the array of categories to return for a post. * * @since 3.1.0 * @since 4.4.0 Added `$id` parameter. * * @param array $categories An array of categories to return for the post. * @param int $id ID of the post. */ return apply_filters( 'get_the_categories', $categories, $id ); } } if ( ! function_exists( "levelup_get_the_category_list" ) ) { function levelup_get_the_category_list( $separator = '', $taxonomy, $parents = '', $post_id = false ) { global $wp_rewrite; if ( ! is_object_in_taxonomy( get_post_type( $post_id ), $taxonomy ) ) { /** This filter is documented in wp-includes/category-template.php */ return apply_filters( 'the_category', '', $separator, $parents ); } /** * Filters the categories before building the category list. * * @since 4.4.0 * * @param array $categories An array of the post's categories. * @param int|bool $post_id ID of the post we're retrieving categories for. When `false`, we assume the * current post in the loop. */ $categories = apply_filters( 'the_category_list', levelup_get_the_category( $post_id, $taxonomy ), $post_id ); if ( empty( $categories ) ) { /** This filter is documented in wp-includes/category-template.php */ return apply_filters( 'the_category', __( 'Uncategorized' ), $separator, $parents ); } $rel = ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) ? 'rel="category tag"' : 'rel="category"'; $thelist = ''; if ( '' == $separator ) { $thelist .= '<ul class="post-categories">'; foreach ( $categories as $category ) { $thelist .= "\n\t<li>"; switch ( strtolower( $parents ) ) { case 'multiple': if ( $category->parent ) $thelist .= get_category_parents( $category->parent, true, $separator ); $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>'; break; case 'single': $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>'; if ( $category->parent ) $thelist .= get_category_parents( $category->parent, false, $separator ); $thelist .= $category->name.'</a></li>'; break; case '': default: $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a></li>'; } } $thelist .= '</ul>'; } else { $i = 0; foreach ( $categories as $category ) { if ( 0 < $i ) $thelist .= $separator; switch ( strtolower( $parents ) ) { case 'multiple': if ( $category->parent ) $thelist .= get_category_parents( $category->parent, true, $separator ); $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>'; break; case 'single': $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>'; if ( $category->parent ) $thelist .= get_category_parents( $category->parent, false, $separator ); $thelist .= "$category->name</a>"; break; case '': default: $thelist .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" ' . $rel . '>' . $category->name.'</a>'; } ++$i; } } /** * Filters the category or list of categories. * * @since 1.2.0 * * @param string $thelist List of categories for the current post. * @param string $separator Separator used between the categories. * @param string $parents How to display the category parents. Accepts 'multiple', * 'single', or empty. */ return apply_filters( 'the_category', $thelist, $separator, $parents ); } }