/**
     * How to display the widget on the screen.
     */
    function widget($args, $instance)
    {
        extract($args);
        global $wp_query, $post;
        /* Our variables from the widget settings. */
        $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
        $title_tabs = array(apply_filters('widget_title', isset($instance['title_popular']) ? $instance['title_popular'] : ''), apply_filters('widget_title', isset($instance['title_commented']) ? $instance['title_commented'] : ''));
        $number = isset($instance['number']) ? (int) $instance['number'] : '';
        $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0;
        $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0;
        $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0;
        $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0;
        $category = isset($instance['category']) ? (int) $instance['category'] : 0;
        $output = $tabs = '';
        for ($i = 0; $i < 2; $i++) {
            $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC');
            if ($i == 0) {
                // Most popular
                $args['meta_key'] = 'post_views_count';
                $args['orderby'] = 'meta_value_num';
            } else {
                // Most commented
                $args['orderby'] = 'comment_count';
            }
            if ($category > 0) {
                $args['cat'] = $category;
            }
            $ex = get_theme_option('exclude_cats');
            if (!empty($ex)) {
                $args['category__not_in'] = explode(',', $ex);
            }
            query_posts($args);
            /* Loop posts */
            if (have_posts()) {
                $tabs .= '<li><a href="#widget_popular_' . $i . '" class="theme_button"><span>' . $title_tabs[$i] . '</span></a></li>';
                $output .= '
					<div class="tab_content" id="widget_popular_' . $i . '">
				';
                $post_number = 0;
                while (have_posts()) {
                    the_post();
                    $post_number++;
                    $post_id = get_the_ID();
                    $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s'));
                    $post_title = $post->post_title;
                    $post_link = get_permalink();
                    $output .= '
						<div class="post_item' . ($post_number == 1 ? ' first' : '') . '">
					';
                    if ($show_image) {
                        $post_thumb = getResizedImageTag($post_id, 60, 60);
                        if ($post_thumb) {
                            $output .= '
									<div class="post_thumb image_wrapper">' . $post_thumb . '</div>
							';
                        }
                    }
                    $output .= '
									<div class="post_wrapper">
										<h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5>
					';
                    if ($show_date || $show_counters || $show_author) {
                        $output .= '
										<div class="post_info theme_info">
						';
                        if ($show_date) {
                            $output .= '
												<span class="post_date theme_text">' . $post_date . '</span>
							';
                        }
                        if ($show_author) {
                            $post_author_id = $post->post_author;
                            $post_author_name = get_the_author_meta('display_name', $post_author_id);
                            $post_author_url = get_author_posts_url($post_author_id, '');
                            $output .= '
											<span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span>
							';
                        }
                        if ($show_counters) {
                            if ($i == 0) {
                                $post_counters = getPostViews($post_id);
                                $post_comments_link = $post_link;
                            } else {
                                $post_counters = get_comments_number();
                                $post_comments_link = get_comments_link($post_id);
                            }
                            if ($show_counters == 2 && ($show_date || $show_author)) {
                                $output .= '<br />';
                            }
                            $output .= '
											<span class="post_comments' . ($show_counters == 2 ? '_text' : '') . '"><a href="' . $post_comments_link . '">' . ($show_counters == 2 ? '' : '<span class="comments_icon icon-' . ($i == 0 ? 'eye' : 'chat-1') . '"></span>') . '<span class="post_comments_number">' . $post_counters . '</span>' . ($show_counters == 2 ? ' ' . ($i == 0 ? __('views', 'themerex') : __('comments', 'themerex')) : '') . '</a></span>
								';
                        }
                        $output .= '
										</div>
						';
                    }
                    $output .= '
							</div>
						</div>
					';
                    if ($post_number >= $number) {
                        break;
                    }
                }
                $output .= '
					</div>
				';
            }
        }
        /* Restore main wp_query and current post data in the global var $post */
        wp_reset_query();
        wp_reset_postdata();
        if (!empty($output)) {
            wp_enqueue_script('jquery-ui-tabs', false, array('jquery', 'jquery-ui-core'), null, true);
            /* Before widget (defined by themes). */
            echo $before_widget;
            /* Display the widget title if one was input (before and after defined by themes). */
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            echo '
				<div class="popular_and_commented_tabs' . ($show_image ? '' : ' ordered_list') . ($show_image || $show_date || $show_counters > 1 || $show_author ? '' : ' flat_list') . '">
					<ul class="tabs">
						' . $tabs . '
					</ul>
					' . $output . '
					<script type="text/javascript">
						jQuery(document).ready(function() {
							jQuery(\'.popular_and_commented_tabs\').tabs();
						});
					</script>
				</div>
			';
            /* After widget (defined by themes). */
            echo $after_widget;
        }
    }
    /**
     * How to display the widget on the screen.
     */
    function widget($args, $instance)
    {
        extract($args);
        global $wp_query, $post;
        /* Our variables from the widget settings. */
        $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
        $number = isset($instance['number']) ? (int) $instance['number'] : '';
        $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0;
        $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0;
        $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0;
        $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0;
        $category = isset($instance['category']) ? (int) $instance['category'] : 0;
        $counters = 'stars';
        //get_theme_option("blog_counters");
        $output = '';
        $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC', 'orderby' => 'date', 'meta_query' => array(array('key' => 'reviews_avg' . (get_theme_option('reviews_first') == 'author' ? '' : '2'), 'value' => 0, 'compare' => '>', 'type' => 'NUMERIC')));
        if ($category > 0) {
            $args['cat'] = $category;
        }
        $ex = get_theme_option('exclude_cats');
        if (!empty($ex)) {
            $args['category__not_in'] = explode(',', $ex);
        }
        query_posts($args);
        /* Loop posts */
        if (have_posts()) {
            $post_number = 0;
            while (have_posts()) {
                the_post();
                $post_number++;
                $post_id = get_the_ID();
                $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s'));
                $post_title = $post->post_title;
                $post_link = get_permalink();
                $output .= '
					<div class="post_item' . ($post_number == 1 ? ' first' : '') . '">
				';
                if ($show_image) {
                    $post_thumb = getResizedImageTag($post_id, 60, 60);
                    if ($post_thumb) {
                        $output .= '
								<div class="post_thumb image_wrapper">' . $post_thumb . '</div>
						';
                    }
                }
                $output .= '
								<div class="post_wrapper">
									<h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5>
				';
                if ($show_counters) {
                    $post_counters = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . (get_theme_option('reviews_first') == 'author' ? '' : '2'), true));
                    if ($post_counters > 0) {
                        if (themerex_strpos($post_counters, '.') === false) {
                            $post_counters .= '.0';
                        }
                        if ($show_counters == 2 && get_custom_option('show_reviews') == 'yes') {
                            $output .= '
								<div class="reviews_summary blog_reviews">
									<div class="criteria_summary criteria_row">
										' . getReviewsSummaryStars($post_counters) . '
									</div>
								</div>
							';
                        }
                    }
                }
                if ($show_date || $show_counters || $show_author) {
                    $output .= '
									<div class="post_info theme_info">
					';
                    if ($show_date) {
                        $output .= '
											<span class="post_date theme_text">' . $post_date . '</span>
						';
                    }
                    if ($show_author) {
                        $post_author_id = $post->post_author;
                        $post_author_name = get_the_author_meta('display_name', $post_author_id);
                        $post_author_url = get_author_posts_url($post_author_id, '');
                        $output .= '
											<span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span>
						';
                    }
                    if ($show_counters == 1 && $post_counters) {
                        $output .= '
									<a class="link_review" href="' . $post_link . '">
										<span class="post_review">
											<span class="post_review_number">' . $post_counters . '</span>
											<span class="review_icon icon-star"></span>
										</span>
									</a>';
                    }
                    $output .= '
							</div>
					';
                }
                $output .= '
						</div>
					</div>
				';
                if ($post_number >= $number) {
                    break;
                }
            }
        }
        /* Restore main wp_query and current post data in the global var $post */
        wp_reset_query();
        wp_reset_postdata();
        if (!empty($output)) {
            /* Before widget (defined by themes). */
            echo balanceTags($before_widget);
            /* Display the widget title if one was input (before and after defined by themes). */
            if ($title) {
                echo balanceTags($before_title . $title . $after_title);
            }
            echo '
				<div class="recent_reviews' . ($show_image ? '' : ' ordered_list') . ($show_image || $show_date || $show_counters > 1 || $show_author ? '' : ' flat_list') . '">
					' . $output . '
				</div>
			';
            /* After widget (defined by themes). */
            echo balanceTags($after_widget);
        }
    }
Esempio n. 3
0
             if ($recent['post_audio'] == '') {
                 $src = getPostAudio($recent['post_content_prepared'], true);
                 if ($src) {
                     $recent['post_audio'] = substituteAudio('<audio src="' . $src . '">');
                 }
             }
             if ($recent['post_audio'] != '' && get_custom_option('substitute_audio') == 'yes') {
                 $src = getPostAudio($recent['post_audio']);
                 if ($src) {
                     $recent['post_audio'] = substituteAudio('<audio src="' . $src . '">');
                 }
             }
         } else {
             if ($recent['post_format'] == 'image' && !$recent['$post_thumb']) {
                 if (($src = getPostImage($recent['post_content_prepared'])) != '') {
                     $recent['post_thumb'] = getResizedImageTag($src, 310, 310);
                 }
             } else {
                 if ($recent['post_format'] == 'link') {
                     $post_url_data = getPostLink($recent['post_content_prepared'], false);
                     $recent['post_url'] = $post_url_data['url'];
                     $recent['post_url_target'] = $post_url_data['target'];
                 }
             }
         }
     }
 }
 $recent['categories'] = getCategoriesByPostId($recent['ID']);
 $recent['post_hover_bg'] = get_custom_option('puzzles_post_bg', null, $recent['ID']);
 $recent['post_hover_pos'] = get_custom_option('puzzles_post_position', null, $recent['ID']);
 $recent['post_accent_color'] = get_custom_option('theme_accent_color', null, $recent['ID']);
Esempio n. 4
0
    function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0)
    {
        global $wp_query;
        if ($depth == 0) {
            $this->item_data = $item;
        }
        // WP date format
        $df = get_option('date_format');
        // Menu item description
        $description = $description_title = '';
        if (!empty($item->description)) {
            if (!function_exists('get_custom_option') || get_custom_option('menu_description') == 'below') {
                $description = '<span class="menu_item_description' . '">' . str_replace('#', '<br>', esc_attr($item->description)) . '</span>';
            } else {
                $description_title = ' title="' . str_replace('#', "\n", esc_attr($item->description)) . '"';
            }
        }
        //if ($depth != 0) $description = "";
        $top_level_type = isset($item->top_level_type) ? $item->top_level_type : '';
        if ($top_level_type == 'auto') {
            // If auto method set
            $item_output = '';
            $class_names = $value = '';
            $classes = empty($item->classes) ? array() : (array) $item->classes;
            $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
            if ($depth == 0 && $item->top_menu_view != 'default') {
                $class_names .= ' ' . $item->top_menu_view . ' custom_view_item';
            }
            $class_names = ' class="menu-item-has-children ' . esc_attr($class_names) . '"';
            $item_output .= '<li' . $class_names . '>';
            // Setting Defaults
            $view_type = isset($item->top_menu_view) ? $item->top_menu_view : '';
            $item_icon = isset($item->item_icon_class) ? $item->item_icon_class : '';
            $item_thumb = isset($item->item_thumb) ? $item->item_thumb : '';
            $item_view = isset($item->top_menu_view) ? $item->top_menu_view : '';
            $item_count = isset($item->auto_items_count) ? $item->auto_items_count : '';
            $item_sorting = isset($item->item_sorting_by) ? $item->item_sorting_by : '';
            $post_types = isset($item->post_types_list) ? $item->post_types_list : '';
            if (!empty($post_types)) {
                $post_types = explode(',', $post_types);
            }
            $query_order = 'DESC';
            if ($item_sorting == 'title') {
                $query_order = 'ASC';
            }
            $post_cat_list = isset($item->categories) ? $item->categories : '';
            $categories = $inner_output = $query_args = array();
            $attributes = '';
            $item_output .= $args->before;
            $attributes .= !empty($item_thumb) ? 'data-thumb="' . esc_attr($item_thumb) . '"' : '';
            $attributes .= !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : $description_title;
            $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
            $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
            $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
            $item_output .= '<a ' . $attributes . '>' . (!empty($item->item_icon_class) ? '<span class="menu_icon ' . $item->item_icon_class . '"></span>' : '') . $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $description . $args->link_after . '</a>';
            /* Auto menu query */
            if (!empty($post_cat_list)) {
                $tax_names = array();
                if (count($post_types) > 0) {
                    foreach ($post_types as $type) {
                        $types_tax = get_object_taxonomies($type);
                        foreach ($types_tax as $tax_type) {
                            $tax_names[] = $tax_type;
                        }
                    }
                }
                $categories = explode(',', $post_cat_list);
                $term_obj = array();
                foreach ($categories as $category) {
                    $category = trim(chop($category));
                    foreach ($tax_names as $name) {
                        $term_temp = get_term_by('slug', $category, $name, ARRAY_A);
                        if ($term_temp) {
                            $term_obj[$category] = $term_temp;
                            $term_obj[$category]['term_link'] = get_term_link($category, $name);
                            break;
                        }
                    }
                }
                foreach ($term_obj as $term) {
                    $query_args['post_type'] = $post_types;
                    $query_args['tax_query'] = array();
                    $query_args['tax_query'][] = array('taxonomy' => $name, 'field' => 'slug', 'terms' => array($term['slug']));
                    if (!empty($item_count)) {
                        $query_args['posts_per_page'] = $item_count;
                    }
                    $query_args['order'] = $query_order;
                    $the_query = new WP_Query($query_args);
                    while ($the_query->have_posts()) {
                        $the_query->the_post();
                        //Get the item data
                        $item_title = get_the_title();
                        $item_id = get_the_ID();
                        $item_link = get_permalink($item_id);
                        $comment_count = wp_count_comments($item_id);
                        $post_date = get_the_date();
                        $inner_output[$term['slug']][$item_id] = array('item_title' => $item_title, 'item_link' => $item_link);
                    }
                    $inner_output[$term['slug']]['term_link'] = $term['term_link'];
                    $inner_output[$term['slug']]['term_name'] = $term['name'];
                }
                wp_reset_postdata();
            }
            if (!empty($inner_output)) {
                if ($view_type == 'columns') {
                    $item_output .= '<ul class="menu-panel columns"><li><ul class="custom-menu-style columns sub-menu">';
                    $list_num = 0;
                    foreach ($inner_output as $cat => $cat_val) {
                        $item_output .= '<li class="' . ($list_num > 0 ? 'divided ' : '') . 'column_item">';
                        $list_num++;
                        $item_output .= '<a href="' . $cat_val['term_link'] . '">' . $cat_val['term_name'] . '</a><ul>';
                        foreach ($cat_val as $item_id => $item_data) {
                            if ($item_id == 'term_link' || $item_id == 'term_name') {
                                continue;
                            }
                            $item_output .= '<li><a href="' . $item_data['item_link'] . '">' . $item_data['item_title'] . '</a></li>';
                        }
                        $item_output .= '</ul></li>';
                    }
                    $item_output .= '</ul></li></ul>';
                } else {
                    if ($view_type == 'thumb') {
                        $thumb_size = getThumbSizes(array('thumb_size' => 'widgets'));
                        $thumb_full_size = getThumbSizes(array('thumb_size' => 'image_large', 'thumb_crop' => false));
                        $curr_item = '';
                        $item_output .= '<ul class="menu-panel thumb"><li><ul class="custom-menu-style thumb sub-menu">';
                        foreach ($inner_output as $cat => $cat_val) {
                            foreach ($cat_val as $item_id => $item_data) {
                                if ($item_id == 'term_link' || $item_id == 'term_name') {
                                    continue;
                                }
                                $item_thumb = getResizedImageTag($item_id, $thumb_size['w'], $thumb_size['h']);
                                $item_thumb_full = getResizedImageUrl($item_id, $thumb_full_size['w'], $thumb_full_size['h']);
                                $author_id = get_post($item_id)->post_author;
                                $author_data = get_userdata($author_id);
                                $item_author = $author_data->display_name;
                                $item_title = get_the_title($item_id);
                                $item_date = get_the_time($df, $item_id);
                                //$author_url =	get_author_posts_url($author_id);
                                if (empty($curr_item)) {
                                    $curr_item = $item_id;
                                    $placeholder_thumb = getResizedImageTag($curr_item, $thumb_full_size['w'], $thumb_full_size['h']);
                                    $placeholder_title = $item_title;
                                    $placeholder_link = $item_link;
                                    $placeholder_date = $item_date;
                                    $placeholder_author = $item_author;
                                    //$placeholder_author_url = $author_url;
                                }
                                $item_output .= '<li><a href="' . $item_data['item_link'] . '"
								data-author="' . $item_author . '"
								data-pubdate="' . $item_date . '"
								data-thumb="' . $item_thumb_full . '"
								data-title="' . $item_title . '"
								data-link="' . $item_link . '"
								>' . ($item_thumb != '' ? $item_thumb : '<span class="img_placeholder"></span>') . '</a></li>';
                            }
                        }
                        $item_output .= '</ul>';
                        $item_output .= '<div class="item_placeholder">';
                        // Placeholder section
                        if ($curr_item != '') {
                            $item_output .= '
							<div class="thumb_wrap">' . $placeholder_thumb . '</div>
							<h4 class="item_title"><a href="' . $placeholder_link . '">' . $placeholder_title . '</a></h4>
							<div class="item_info">
							<div class="item_pubdate"><span>' . __('Posted', 'themerex') . '</span>&nbsp;<em>' . $placeholder_date . '</em></div>
							<div class="item_author"><span>' . __('by', 'themerex') . '</span>&nbsp;<em>' . $placeholder_author . '</em></div>
							</div>
						';
                        }
                        $item_output .= '</div></li></ul>';
                    } else {
                        if ($view_type == 'thumb_title') {
                            $thumb_size = getThumbSizes(array('thumb_size' => 'portfolio4'));
                            $item_output .= '<ul class="menu-panel thumb_title"><li><ul class="custom-menu-style thumb_title sub-menu">';
                            foreach ($inner_output as $cat => $cat_val) {
                                $curr_item = '';
                                $item_output .= '<li class="items_column"><a href="' . $cat_val['term_link'] . '">' . $cat_val['term_name'] . '</a><ul>';
                                foreach ($cat_val as $item_id => $item_data) {
                                    if ($item_id == 'term_link' || $item_id == 'term_name') {
                                        continue;
                                    }
                                    $item_date = get_the_time($df, $item_id);
                                    $item_comments = wp_count_comments($item_id);
                                    $item_thumb = getResizedImageUrl($item_id, $thumb_size['w'], $thumb_size['h']);
                                    //$author_url =	get_author_posts_url($author_id);
                                    if (empty($curr_item)) {
                                        $curr_item = $item_id;
                                        $placeholder_thumb = getResizedImageTag($curr_item, $thumb_size['w'], $thumb_size['h']);
                                        $placeholder_date = $item_date;
                                        $placeholder_comments = $item_comments->approved;
                                    }
                                    $item_output .= '<li>' . '<a href="' . $item_data['item_link'] . '"
									data-pubdate="' . $item_date . '"
									data-comments="' . $item_comments->approved . '"
									data-thumb="' . $item_thumb . '"
									>' . $item_data['item_title'] . '</a>' . '</li>';
                                }
                                $item_output .= '</ul>';
                                // Placeholder output
                                $item_output .= '<div class="item_placeholder">';
                                if ($curr_item != '') {
                                    $item_output .= '
								<div class="thumb_wrap">' . $placeholder_thumb . '</div>
								<div class="item_info">
								<div class="item_pubdate"><span>' . __('Posted', 'themerex') . '</span>&nbsp;<em>' . $placeholder_date . '</em></div>
								<div class="item_comments"><span class="icon icon-comment-1"></span>&nbsp;<em>' . $placeholder_comments . '</em></div>
								</div>';
                                }
                                $item_output .= '</div></li>';
                            }
                            $item_output .= '</ul></li></ul>';
                        }
                    }
                }
            }
            $item_output .= $args->after;
        } else {
            // Manual or default method
            if ($depth == 0) {
                $this->top_menu_view = $item->top_menu_view;
            }
            $indent = $depth ? str_repeat("\t", $depth) : '';
            $class_names = $value = '';
            $classes = empty($item->classes) ? array() : (array) $item->classes;
            $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item));
            if ($depth == 0 && $item->top_menu_view != 'default') {
                $class_names .= ' ' . $item->top_menu_view . ' custom_view_item';
            }
            $class_names = ' class="' . esc_attr($class_names) . '"';
            $output .= $indent . ($this->top_menu_view == 'thumb' && $depth > 1 || $this->top_menu_view == 'thumb_title' && $depth > 2 ? '</li>' : '') . '<li id="menu-item-' . $item->ID . '"' . $value . $class_names . '>';
            $item_thumb = '';
            $thumb_size = getThumbSizes(array('thumb_size' => 'widgets'));
            $width = $thumb_size['w'];
            $height = $thumb_size['h'];
            $item_thumb = getResizedImageUrl($item->item_thumb, $width, $height);
            if (empty($item_thumb)) {
                if ($item->type != 'custom') {
                    $item_id = $item->object_id;
                    $item_thumb = getResizedImageUrl($item_id, $width, $height);
                }
            }
            $attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : $description_title;
            $attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
            $attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
            $attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
            if ($this->top_menu_view == 'thumb' || $this->top_menu_view == 'thumb_title') {
                if ($depth > 0) {
                    if ($item->object != 'custom') {
                        $post_id = $item->object_id;
                        $post_title = get_the_title($post_id);
                        if (empty($post_title)) {
                            $post_title = $item->title;
                        }
                        $thumb_size = getThumbSizes(array('thumb_size' => $this->top_menu_view == 'thumb_title' ? 'portfolio4' : 'image_large'));
                        $thumb_width = $thumb_size['w'];
                        $thumb_height = $thumb_size['h'];
                        $post_pubdate = get_the_time($df, $post_id);
                        $author_id = get_post($post_id)->post_author;
                        $author_data = get_userdata($author_id);
                        $post_author = $author_data->display_name;
                        $author_url = get_author_posts_url($author_id);
                        $placeholder_thumb = getResizedImageUrl($post_id, $thumb_width, $thumb_height);
                        if (empty($placeholder_thumb)) {
                            $placeholder_thumb = getResizedImageUrl($item->item_thumb, $thumb_width, $thumb_height);
                        }
                        $post_comments = wp_count_comments($post_id);
                        $comment_count = $post_comments->approved;
                    } else {
                        $placeholder_thumb = $item->item_thumb;
                        $post_title = $item->title;
                    }
                    $attributes .= !empty($post_title) ? ' data-title="' . $post_title . '"' : $description_title;
                    $attributes .= !empty($post_author) ? ' data-author="' . $post_author . '"' : '';
                    $attributes .= !empty($placeholder_thumb) ? ' data-thumb="' . $placeholder_thumb . '"' : '';
                    $attributes .= !empty($post_pubdate) ? ' data-pubdate="' . $post_pubdate . '"' : '';
                    $attributes .= !empty($comment_count) ? ' data-comments="' . $comment_count . '"' : '';
                }
            }
            $icon_padding = '';
            $item_output = $args->before;
            $item_output .= '<a' . $attributes . '>';
            //if ($this->top_menu_view == 'columns' && $depth > 1) {
            if (!empty($item->item_icon_class)) {
                $item_output .= '<span class="menu_icon ' . $item->item_icon_class . '"></span>';
            }
            //}
            if ($this->top_menu_view == 'thumb' && $depth > 0) {
                if ($item_thumb != '') {
                    $item_output .= '<img src="' . $item_thumb . '" width="' . $width . '" height="' . $height . '" alt="">';
                }
            } else {
                $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID);
            }
            $item_output .= $description . $args->link_after . '</a>';
            if ($this->top_menu_view == 'thumb_title') {
                if ($depth == 1) {
                    $this->level_holder = array();
                }
            }
            $item_output .= $args->after;
            $type_depth = 2;
            if ($this->top_menu_view == 'thumb') {
                $type_depth = 1;
            }
            if (empty($this->level_holder)) {
                if ($depth == $type_depth) {
                    $this->level_holder = $item;
                }
            } else {
                if ($item->current == '1') {
                    if ($depth >= $type_depth) {
                        $this->level_holder = $item;
                    }
                }
            }
        }
        $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
    }
Esempio n. 5
0
function sc_testimonials_item($atts, $content = null)
{
    if (in_shortcode_blogger()) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "class" => "", "name" => "", "position" => "", "photo" => "", "email" => ""), $atts));
    global $THEMEREX_sc_testimonials_count, $THEMEREX_sc_testimonials_width, $THEMEREX_sc_testimonials_height;
    $THEMEREX_sc_testimonials_count++;
    if (empty($photo)) {
        if (!empty($email)) {
            $photo = get_avatar($email, 50);
        }
    } else {
        if ($photo > 0) {
            $attach = wp_get_attachment_image_src($photo, 'full');
            if (isset($attach[0]) && $attach[0] != '') {
                $photo = $attach[0];
            }
        }
        $photo = getResizedImageTag($photo, 50, 50);
    }
    if (empty($photo)) {
        $photo = '<img src="' . themerex_get_file_url('/images/no-ava.png') . '" alt="">';
    }
    return '<li' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_testimonials_item swiper-slide' . (!empty($class) ? ' ' . $class : '') . '" style="' . (!empty($THEMEREX_sc_testimonials_width) ? 'width:' . $THEMEREX_sc_testimonials_width . ';' : '') . (!empty($THEMEREX_sc_testimonials_height) ? 'height:' . $THEMEREX_sc_testimonials_height . ';' : '') . '">' . '<div class="sc_testimonials_item_content">' . '<div class="sc_testimonials_item_quote"><div class="sc_testimonials_item_text">' . do_shortcode($content) . '</div></div>' . '<div class="sc_testimonials_item_author">' . '<div class="sc_testimonials_item_avatar">' . $photo . '</div>' . '<div class="sc_testimonials_item_name">' . $name . '</div>' . '<div class="sc_testimonials_item_position">' . $position . '</div>' . '</div>' . '</div>' . '</li>';
}
Esempio n. 6
0
    function themerex_wrapper_start()
    {
        $thumb_size = array('fullpost' => array('w' => get_custom_option('show_sidebar_main') == 'fullwidth' ? 1243 : 932, 'h' => null));
        $post_id = get_option('woocommerce_shop_page_id');
        $blog_style = 'fullpost';
        //get_custom_option('blog_style');
        $post_thumb = getResizedImageTag($post_id, $thumb_size[$blog_style]['w'], $thumb_size[$blog_style]['h'], null, true, false, true);
        ?>
		<div id="main_inner" class="clearboth blog_style_<?php 
        echo $blog_style;
        ?>
">
			<div id="content" class="content_blog post_single" role="main">
				<article <?php 
        post_class('theme_article post_format_standard');
        ?>
>
					<?php 
        // If post have thumbnail - show it
        if ($post_thumb && get_custom_option('show_featured_image') == 'yes') {
            ?>
						<div class="post_thumb image_wrapper no_thumb">
							<?php 
            echo $post_thumb;
            ?>
						</div>
					<?php 
        }
        ?>
					<div class="post_content<?php 
        echo get_custom_option('without_paddings') == 'yes' ? ' without_paddings' : '';
        ?>
">
	<?php 
    }
<?php

$show_title = true;
$columns = max(1, min(4, (int) themerex_substr($opt['style'], -1)));
$style_image = get_custom_option('portfolio_image_style', null, $post_data['post_id']);
$thumb_sizes = getPortfolioThumbSizes(array('thumb_crop' => true, 'thumb_size' => $style_image));
$post_data['post_thumb'] = getResizedImageTag($post_data['post_id'], $thumb_sizes['w'], $thumb_sizes['h']);
//for new image
$isotopeWidth = 1;
$isotopeHeight = 1;
switch ($style_image) {
    case 'image-square-2':
        $isotopeWidth = 2;
        $isotopeHeight = 2;
        break;
    case 'image-rectangle':
        $isotopeWidth = 2;
        $isotopeHeight = 1;
        break;
}
?>

<article data-width="<?php 
echo esc_attr($isotopeWidth);
?>
" data-height="<?php 
echo esc_attr($isotopeHeight);
?>
" class="ellNOspacing isotopeElement <?php 
echo 'post_format_' . $post_data['post_format'] . ($opt['number'] % 2 == 0 ? ' even' : ' odd') . ($opt['number'] == 0 ? ' first' : '') . ($opt['number'] == $opt['posts_on_page'] ? ' last' : '') . ($opt['add_view_more'] ? ' viewmore' : '') . ($opt['filters'] != '' ? ' flt_' . join(' flt_', $opt['filters'] == 'categories' ? $post_data['post_categories_ids'] : $post_data['post_tags_ids']) : '');
?>
<?php

$show_title = true;
//get_custom_option('show_post_title', null, $post_data['post_id'])=='yes';
$mult = min(2, max(1, get_theme_option("retina_ready")));
?>
<div class="columns1_2 related_post">
	<div class="thumb_wrap">		
		<?php 
$mult = min(2, max(1, get_theme_option("retina_ready")));
$post_thumb = getResizedImageTag($post_data['post_id'], 86 * $mult, 86 * $mult, true);
echo !empty($post_thumb) ? '<div class="post_thumb">' . $post_thumb . '</div>' : '<div class="post_thumb"><i class="icon-picture-1"></i></div>';
?>
	</div>
	<div class="extra_wrap">
		<?php 
if ($show_title) {
    ?>
		<h3><a href="<?php 
    echo $post_data['post_link'];
    ?>
"><?php 
    echo $post_data['post_title'];
    ?>
</a></h3>
		<?php 
}
?>
		
		<header class="post_info infoPost">
			<?php 
<?php

global $post;
$post_id = $post->ID;
$post_date = getDateOrDifference($post->post_date);
$post_title = $post->post_title;
$post_link = get_permalink($post_id);
$output .= '
	<article class="post_item' . ($show_image == 0 ? ' no_thumb' : ' with_thumb') . ($post_number == 1 ? ' first' : '') . '">
';
if ($show_image) {
    $post_thumb = getResizedImageTag($post_id, 75, 75);
    if ($post_thumb) {
        $output .= '
			<div class="post_thumb">' . $post_thumb . '</div>
		';
    }
}
$output .= '
			<h5 class="post_title"><a href="' . $post_link . '">' . $post_title . '</a></h5>
';
if ($show_counters) {
    if ($show_counters == 'views') {
        $post_counters = getPostViews($post_id);
        $post_counters_icon = 'eye';
    } else {
        if ($show_counters == 'likes') {
            $post_counters = getPostLikes($post_id);
            $post_counters_icon = 'heart-1';
        } else {
            if ($show_counters == 'stars' || $show_counters == 'rating') {
                        $post_audio = substituteAudio('<audio src="' . $src . '">');
                    }
                }
                if ($post_audio != '' && get_custom_option('substitute_audio') == 'yes') {
                    $src = getPostAudio($post_audio);
                    if ($src) {
                        $post_audio = substituteAudio('<audio src="' . $src . '">');
                    }
                }
            }
        }
    }
}
if ($post_format == 'image' && !$post_thumb) {
    if (($src = getPostImage($post_content_prepared)) != '') {
        $post_thumb = getResizedImageTag($src, $thumb_size[$blog_style]['w'], $thumb_size[$blog_style]['h']);
    }
} else {
    if ($post_format == 'link') {
        $post_url_data = getPostLink($post_content_prepared, false);
        $post_link = $post_url = $post_url_data['url'];
        $post_url_target = $post_url_data['target'];
    }
}
// Get all post's categories
$post_categories = getCategoriesByPostId($post_id);
$post_categories_str = '';
$post_accent_color = $parent_cat_id > 0 ? !isset($post_accent_color) || $post_accent_color == '' ? getCategoryInheritedProperty($parent_cat_id, 'theme_accent_color') : $post_accent_color : '';
$post_accent_category = '';
$ex_cats = explode(',', get_theme_option('exclude_cats'));
for ($i = 0; $i < count($post_categories); $i++) {
<?php

global $post;
$post_id = $post->ID;
$post_date = getDateOrDifference($post->post_date);
$post_title = $post->post_title;
$post_link = get_permalink($post_id);
$output .= '
	<article class="post_item' . ($show_image == 0 ? ' no_thumb' : ' with_thumb') . ($post_number == 1 ? ' first' : '') . '">
';
if ($show_image) {
    $post_thumb = getResizedImageTag($post_id, 90, 70);
    if ($post_thumb) {
        $output .= '
			<div class="post_thumb">' . balanceTags($post_thumb) . '</div>
		';
    }
}
$output .= '
			<h5 class="post_title"><a href="' . esc_url($post_link) . '">' . esc_html($post_title) . '</a></h5>
';
if ($show_counters) {
    if ($show_counters == 'views') {
        $post_counters = getPostViews($post_id);
        $post_counters_icon = 'eye';
    } else {
        if ($show_counters == 'likes') {
            $post_counters = getPostLikes($post_id);
            $post_counters_icon = 'heart';
        } else {
            $post_counters = get_comments_number($post_id);
Esempio n. 12
0
$show_search = get_custom_option('show_searchform');
$show_mobilemenu = get_custom_option('show_mobilemenu');
$show_tagline = get_custom_option('show_tagline');
$menu_style = get_custom_option('mainmenu_style');
$show_banner = get_custom_option('show_banner');
$fix_menu = get_custom_option('fix_menu');
$main_sidebar = get_custom_option('show_sidebar_main');
if (!empty($_GET['show_shop_sidebar']) && $_GET['show_shop_sidebar'] == true) {
    $main_sidebar = 'left';
}
$custom_header = get_custom_option('custom_header_show') == 'yes' ? get_custom_option('custom_header') : '';
$fullwidth_slider = get_custom_option('fullwidth_slider');
$blog_style = get_custom_option('blog_style');
$header_banner_code = get_custom_option('header_banner_code');
$header_banner_img = get_custom_option('header_banner');
$header_banner_img = !empty($header_banner_img) ? getResizedImageTag($header_banner_img, 728 * $mult, 90 * $mult) : '';
$header_banner_url = get_custom_option('header_banner_url');
if ($header_banner_code) {
    $header_banner = !empty($header_banner_code) ? $header_banner_code : '';
} else {
    $header_banner = !empty($header_banner_img) ? $header_banner_img : '';
    $header_banner = !empty($header_banner_url) ? '<a href="' . $header_banner_url . '">' . $header_banner . '</a>' : $header_banner;
}
$crumbs = showBreadcrumbs(array('home' => __('Home', 'themerex'), 'echo' => false, 'truncate_title' => 50));
$section_align = get_custom_option('section_align');
$show_user_panel = get_custom_option('section_1');
if (function_exists('icl_get_languages')) {
    $lang_pane = icl_get_languages();
}
?>
<!DOCTYPE html>
Esempio n. 13
0
function sc_testimonials($atts, $content = null)
{
    extract(shortcode_atts(array("id" => "", "user" => "", "name" => "", "position" => "", "photo" => "", "nophoto" => "0", "email" => "", "style" => "flat", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    $s = ($top !== '' ? 'margin-top:' . $top . 'px;' : '') . ($bottom !== '' ? 'margin-bottom:' . $bottom . 'px;' : '') . ($left !== '' ? 'margin-left:' . $left . 'px;' : '') . ($right !== '' ? 'margin-right:' . $right . 'px;' : '');
    if (!empty($user) && ($author = get_user_by('login', $user)) != false) {
        $meta = get_user_meta($author->ID);
        $name = $author->data->display_name;
        $position = $meta['user_position'][0];
        $photo = get_avatar($author->data->user_email, 45);
    } else {
        $photo = getResizedImageTag($photo, 45, 45);
    }
    return '<div' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_testimonials sc_testimonials_style_' . $style . '"' . ($s != '' ? ' style="' . $s . '"' : '') . '>' . '<div class="sc_testimonials_content">' . ($style == 'callout' ? '<span class="icon-quote"></span>' : '') . do_shortcode($content) . '</div>' . '<div class="sc_testimonials_extra"><div class="sc_testimonials_extra_inner"></div></div>' . '<div class="sc_testimonials_user">' . ($nophoto == 0 ? '<div class="sc_testimonials_avatar image_wrapper">' . $photo . '</div>' : '') . '<h4 class="sc_testimonials_title">' . $name . '</h4>' . '<div class="sc_testimonials_position">' . $position . '</div>' . '</div>' . '</div>';
}
Esempio n. 14
0
    function buildGalleryTag($photos, $w, $h, $zoom = false, $link = '')
    {
        $engine = get_custom_option('substitute_slider_engine');
        $gallery_text = '';
        $gallery_items_in_bg = $engine != 'chop';
        // todo: magnific & pretty
        // magnific & pretty
        themerex_enqueue_style('magnific-style', themerex_get_file_url('/js/magnific-popup/magnific-popup.css'), array(), null);
        themerex_enqueue_script('magnific', themerex_get_file_url('/js/magnific-popup/jquery.magnific-popup.min.js'), array('jquery'), null, true);
        // Load PrettyPhoto if it selected in Theme Options
        if (get_theme_option('popup_engine') == 'pretty') {
            themerex_enqueue_style('prettyphoto-style', themerex_get_file_url('/js/prettyphoto/css/prettyPhoto.css'), array(), null);
            themerex_enqueue_script('prettyphoto', themerex_get_file_url('/js/prettyphoto/jquery.prettyPhoto.min.js'), array('jquery'), 'no-compose', true);
        }
        // todo: sliders
        themerex_enqueue_style('swiperslider-style', themerex_get_file_url('/js/swiper/idangerous.swiper.css'), array(), null);
        themerex_enqueue_style('swiperslider-scrollbar-style', themerex_get_file_url('/js/swiper/idangerous.swiper.scrollbar.css'), array(), null);
        themerex_enqueue_script('swiperslider', themerex_get_file_url('/js/swiper/idangerous.swiper-2.7.js'), array('jquery'), null, true);
        themerex_enqueue_script('swiperslider-scrollbar', themerex_get_file_url('/js/swiper/idangerous.swiper.scrollbar-2.4.js'), array('jquery'), null, true);
        themerex_enqueue_script('flexslider', themerex_get_file_url('/js/jquery.flexslider.min.js'), array('jquery'), null, true);
        if (count($photos) > 0) {
            if ($engine == 'chop') {
                $effects2D = array("vertical", "horizontal", "half", "multi");
                $effects3D = array("3DBlocks", "3DFlips");
                $chop_effect = $effects2D[min(3, mt_rand(0, 3))] . '|' . $effects3D[min(1, mt_rand(0, 1))];
            }
            $id = "sc_slider_" . str_replace('.', '', mt_rand());
            $interval = mt_rand(5000, 10000);
            $gallery_text = '
				<div id="' . $id . '" class="sc_slider sc_slider_' . $engine . ($engine == 'swiper' ? ' swiper-slider-container' : '') . ' sc_slider_controls"' . (!empty($w) && themerex_strpos($w, '%') === false ? ' data-old-width="' . $w . '"' : '') . (!empty($h) && themerex_strpos($h, '%') === false ? ' data-old-height="' . $h . '"' : '') . ($engine == 'chop' ? ' data-effect="' . $chop_effect . '"' : '') . ' data-interval="' . $interval . '"' . '>
					<ul class="slides' . ($engine == 'swiper' ? ' swiper-wrapper' : '') . '"' . ($engine == 'swiper' ? ' style="height:' . $h . 'px;"' : '') . '>
					';
            $numSlide = 0;
            foreach ($photos as $photo) {
                $numSlide++;
                if ($gallery_items_in_bg) {
                    $photo_min = getResizedImageURL($photo, $w, $h);
                    $gallery_text .= '<li' . ' class="' . $engine . '-slide"' . ' style="background-image:url(' . $photo_min . ');' . (!empty($w) ? 'width:' . $w . (themerex_strpos($w, '%') !== false ? '' : 'px') . ';' : '') . (!empty($h) ? 'height:' . $h . (themerex_strpos($h, '%') !== false ? '' : 'px') . ';' : '') . '">' . ($zoom ? '<a href="' . $photo . '"></a>' : ($link ? '<a href="' . $link . '"></a>' : '')) . '</li>';
                } else {
                    $photo_min = getResizedImageTag($photo, $w, $h);
                    $gallery_text .= '<li' . ' class="' . $engine . '-slide' . ($engine == 'chop' && $numSlide == 1 ? ' cs-activeSlide' : '') . '"' . ' style="' . ($engine == 'chop' && $numSlide == 1 ? 'display:block;' : '') . (!empty($w) ? 'width:' . $w . (themerex_strpos($w, '%') !== false ? '' : 'px') . ';' : '') . (!empty($h) ? 'height:' . $h . (themerex_strpos($h, '%') !== false ? '' : 'px') . ';' : '') . '">' . ($zoom ? '<a href="' . $photo . '">' . $photo_min . '</a>' : (!empty($link) ? '<a href="' . $link . '">' . $photo_min . '</a>' : $photo_min)) . '</li>';
                }
            }
            $gallery_text .= '</ul>';
            if ($engine == 'swiper' || $engine == 'chop') {
                $gallery_text .= '
					<ul class="flex-direction-nav">
					<li><a class="flex-prev" href="#"></a></li>
					<li><a class="flex-next" href="#"></a></li>
					</ul>
				';
            }
            $gallery_text .= '</div>';
        }
        return $gallery_text;
    }
Esempio n. 15
0
function buildGalleryTag($photos, $w, $h, $zoom = false)
{
    $gallery_text = '';
    if (count($photos) > 0) {
        $gallery_text = '
			<div class="sc_slider sc_slider_flex">
				<ul class="slides">
				';
        foreach ($photos as $photo) {
            $photo_min = getResizedImageTag($photo, $w, $h);
            $gallery_text .= $zoom ? '<li><a href="' . $photo . '" rel="prettyPhoto[slideshow]">' . $photo_min . '</a></li>' : '<li>' . $photo_min . '</li>';
        }
        $gallery_text .= '
				</ul>
			</div>
		';
    }
    return $gallery_text;
}
    /**
     * How to display the widget on the screen.
     */
    function widget($args, $instance)
    {
        extract($args);
        global $wp_query, $post;
        /* Our variables from the widget settings. */
        $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
        $title_tabs = array(apply_filters('widget_title', isset($instance['title_latest']) ? $instance['title_latest'] : ''), apply_filters('widget_title', isset($instance['title_popular']) ? $instance['title_popular'] : ''), apply_filters('widget_title', isset($instance['title_commented']) ? $instance['title_commented'] : ''));
        $title_tabs = array_filter($title_tabs);
        $title_length = isset($instance['title_length']) ? (int) $instance['title_length'] : 0;
        $number = isset($instance['number']) ? (int) $instance['number'] : '';
        $show_info = isset($instance['show_info']) ? $instance['show_info'] : 0;
        $show_rating = isset($instance['show_rating']) ? (int) $instance['show_rating'] : 0;
        $show_cats = isset($instance['show_cats']) ? (int) $instance['show_cats'] : 0;
        $category = isset($instance['category']) ? (int) $instance['category'] : 0;
        $post_thumb = isset($instance['post_thumb']) ? $instance['post_thumb'] : 'hide';
        $output = $tabs = '';
        $titles_str = implode('', $title_tabs);
        for ($i = 0; $i < 3; $i++) {
            if (!empty($title_tabs[$i]) || $i == 0 && strlen($titles_str) == 0) {
                $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC');
                if ($i == 0) {
                    // Latest
                    $args['orderby'] = 'date';
                    $args['order'] = 'DESC';
                } else {
                    if ($i == 1) {
                        // Most popular
                        $args['meta_key'] = 'post_views_count';
                        $args['orderby'] = 'meta_value_num';
                    } else {
                        // Most commented
                        $args['orderby'] = 'comment_count';
                    }
                }
                if ($category > 0) {
                    $args['cat'] = $category;
                }
                $ex = get_theme_option('exclude_cats');
                if (!empty($ex)) {
                    $args['category__not_in'] = explode(',', $ex);
                }
                query_posts($args);
                /* Loop posts */
                if (have_posts()) {
                    $abc_range = range('a', 'z');
                    $abc_shuffle = str_shuffle(implode('', $abc_range));
                    $unikey = substr($abc_shuffle, 10);
                    if (count($title_tabs) > 1) {
                        $tabs .= '<li><a href="#widget_popular_' . $i . '_' . $unikey . '" class="theme_button"><span>' . $title_tabs[$i] . '</span></a></li>';
                    }
                    $output .= '
						<div class="tab_content style_' . $post_thumb . '" id="widget_popular_' . $i . '_' . $unikey . '">
					';
                    $post_number = 0;
                    while (have_posts()) {
                        the_post();
                        $post_number++;
                        $post_id = get_the_ID();
                        $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s'));
                        $post_title = $post->post_title;
                        $post_title = !empty($title_length) ? getShortString($post_title, $title_length, '...') : $post_title;
                        $post_link = get_permalink();
                        $post_custom = get_post_custom($post_id);
                        $post_comments = wp_count_comments($post_id);
                        $post_comments_link = '<a href="' . $post_link . '#comments"><i class="icon-comment-1"></i>' . $post_comments->approved . '</a>';
                        $post_votes = !empty($post_custom['post_votes_data']) ? $post_custom['post_votes_data'] : '';
                        $votes_data = !empty($post_votes[0]) ? unserialize($post_votes[0]) : '';
                        $crit_points = !empty($votes_data['criterias_points']) ? $votes_data['criterias_points'] : '';
                        $total_votes = !empty($votes_data['total_votes']) ? $votes_data['total_votes'] : '';
                        $votes_sum = !empty($crit_points) ? array_sum($crit_points) : '';
                        $votes_avg = !empty($votes_sum) && !empty($total_votes) ? $votes_sum / $total_votes : '';
                        $votes_avg = !empty($votes_avg) ? number_format($votes_avg, 0) : '';
                        $cust_opt = !empty($post_custom['post_custom_options'][0]) ? unserialize($post_custom['post_custom_options'][0]) : '';
                        $author_review = !empty($cust_opt['reviews_marks']) ? explode(',', $cust_opt['reviews_marks']) : '';
                        $author_avg = count($author_review) > 0 ? number_format(array_sum($author_review) / count($author_review), 0) : 0;
                        $post_format = get_post_format($post_id);
                        $post_format = $post_format == false ? 'standard' : $post_format;
                        $format_icon = getPostFormatIcon($post_format);
                        $avg_arr = array();
                        $avg_arr[] = !empty($author_avg) ? $author_avg : '';
                        $avg_arr[] = !empty($votes_avg) ? $votes_avg : '';
                        $avg_arr = array_filter($avg_arr);
                        $total_avg = count($avg_arr) > 0 ? array_sum($avg_arr) / count($avg_arr) : '';
                        $post_categories_links = '';
                        if ($show_cats) {
                            $post_categories_list = getCategoriesByPostId($post_id);
                            $ex_cats = explode(',', get_theme_option('exclude_cats'));
                            $cat_count = count($post_categories_list);
                            for ($c = 0; $c < $cat_count; $c++) {
                                if (in_array($post_categories_list[$c]['term_id'], $ex_cats)) {
                                    continue;
                                }
                                $post_categories_ids[] = $post_categories_list[$c]['term_id'];
                                $category_color = get_category_inherited_property($post_categories_list[$c]['term_id'], 'category_color');
                                if (empty($category_color)) {
                                    $category_color = get_theme_option('category_color');
                                }
                                $post_categories_links .= '<a class="cat_link" href="' . $post_categories_list[$c]['link'] . '"' . (!empty($category_color) ? ' style="background:' . $category_color . '"' : '') . '	>' . $post_categories_list[$c]['name'] . '</a>';
                                $post_categories_links .= count($post_categories_list) > 1 && $c + 1 == $cat_count ? '<br>' : '';
                            }
                        }
                        $review = '';
                        if (!empty($total_avg) && $show_rating) {
                            $review = get_review_rating('5stars', min($total_avg, 100), 100, '#f2c574');
                        }
                        $post_info = '';
                        $post_info .= !empty($show_info) ? '<div class="widget_popular_post_info">' . $post_categories_links . (!empty($review) ? $review : '') . '<span class="post_date"><i class="icon-clock-1"></i>' . $post_date . '</span>' . '<span class="divider">|</span>' . $post_comments_link . '</div>' : '';
                        $output .= '
							<div class="post_item' . ($post_number == 1 ? ' first' : '') . (!empty($post_thumb) ? ' thumb_style_' . $post_thumb : '') . '">
						';
                        $thumb_size = $post_thumb == 'large_thumb' ? 100 : 64;
                        if (in_array($post_thumb, array('large_thumb', 'default_thumb'))) {
                            $post_thumbnail = getResizedImageTag($post_id, $thumb_size, $thumb_size);
                            if ($post_thumbnail) {
                                $output .= '
										<div class="post_thumb image_wrapper">' . $post_thumbnail . '</div>
								';
                            }
                        } else {
                            if ($post_thumb == 'post_format') {
                                $output .= '<i class="' . $format_icon . ' format-icon"></i>';
                            }
                        }
                        $output .= '
										<div class="post_wrapper">
											<h5 class="post_title theme_title"><a href="' . $post_link . '">' . $post_title . '</a></h5>
						';
                        $output .= $post_info . '
								</div>
							</div>
						';
                        if ($post_number >= $number) {
                            break;
                        }
                    }
                    $output .= '
						</div>';
                }
            }
        }
        /* Restore main wp_query and current post data in the global var $post */
        wp_reset_query();
        wp_reset_postdata();
        if (!empty($output)) {
            wp_enqueue_script('jquery-ui-tabs', false, array('jquery', 'jquery-ui-core'), null, true);
            /* Before widget (defined by themes). */
            echo $before_widget;
            /* Display the widget title if one was input (before and after defined by themes). */
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            echo '
				<div class="popular_and_commented_tabs' . ($show_info || $show_rating ? '' : ' flat_list') . '">
					' . (strlen($titles_str) != 0 && count($title_tabs) > 1 ? '<ul class="tabs">' . $tabs . '</ul>' : '') . '
					' . $output . '
					<script type="text/javascript">
						jQuery(document).ready(function() {
							jQuery(\'.popular_and_commented_tabs\').tabs();
						});
					</script>
				</div>
			';
            /* After widget (defined by themes). */
            echo $after_widget;
        }
    }
    /**
     * How to display the widget on the screen.
     */
    function widget($args, $instance)
    {
        extract($args);
        global $wp_query, $post;
        /* Our variables from the widget settings. */
        $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
        $number = isset($instance['number']) ? (int) $instance['number'] : '';
        $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0;
        $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0;
        $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0;
        $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0;
        $category = isset($instance['category']) ? (int) $instance['category'] : 0;
        $counters = get_theme_option("blog_counters");
        $output = '';
        $args = array('numberposts' => $number, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'ignore_sticky_posts' => 1, 'suppress_filters' => true);
        if ($category > 0) {
            $args['category'] = $category;
        }
        $ex = get_theme_option('exclude_cats');
        if (!empty($ex)) {
            $args['category__not_in'] = explode(',', $ex);
        }
        $recent_posts = wp_get_recent_posts($args);
        $post_number = 0;
        foreach ($recent_posts as $post) {
            $post_number++;
            $post_id = $post['ID'];
            $post_date = getDateOrDifference($post['post_date']);
            $post_title = $post['post_title'];
            $post_link = get_permalink($post_id);
            $output .= '
				<div class="post_item' . ($post_number == 1 ? ' first' : '') . '">
			';
            if ($show_image) {
                $post_thumb = getResizedImageTag($post_id, 60, 60);
                if ($post_thumb) {
                    $output .= '
							<div class="post_thumb image_wrapper">' . $post_thumb . '</div>
					';
                }
            }
            $output .= '
							<div class="post_wrapper">
								<h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5>
			';
            if ($show_date || $show_counters == 2 || $show_author) {
                $output .= '
								<div class="post_info theme_info">
				';
                if ($show_date) {
                    $output .= '
										<span class="post_date theme_text">' . $post_date . '</span>
					';
                }
                if ($show_author) {
                    $post_author_id = $post['post_author'];
                    $post_author_name = get_the_author_meta('display_name', $post_author_id);
                    $post_author_url = get_author_posts_url($post_author_id, '');
                    $output .= '
									<span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span>
					';
                }
                if ($show_counters) {
                    $post_counters = $counters == 'comments' ? get_comments_number($post_id) : getPostViews($post_id);
                    $post_counters_link = $counters == 'comments' ? get_comments_link($post_id) : $post_link;
                    if ($show_counters == 2 && ($show_date || $show_author)) {
                        $output .= '<br />';
                    }
                    $output .= '
									<span class="post_comments' . ($show_counters == 2 ? '_text' : '') . '"><a href="' . $post_counters_link . '">' . ($show_counters == 2 ? '' : '<span class="comments_icon icon-' . ($counters == 'views' ? 'eye' : 'chat-1') . '"></span>') . '<span class="post_comments_number">' . $post_counters . '</span>' . ($show_counters == 2 ? ' ' . ($counters == 'views' ? __('views', 'themerex') : __('comments', 'themerex')) : '') . '</a></span>
						';
                }
                $output .= '
								</div>
				';
            }
            $output .= '
					</div>
				</div>
			';
            if ($post_number >= $number) {
                break;
            }
        }
        if (!empty($output)) {
            /* Before widget (defined by themes). */
            echo $before_widget;
            /* Display the widget title if one was input (before and after defined by themes). */
            echo $before_title . $title . $after_title;
            echo $output;
            /* After widget (defined by themes). */
            echo $after_widget;
        }
    }
Esempio n. 18
0
function sc_testimonials_item($atts, $content = null)
{
    if (in_shortcode_blogger()) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "name" => "", "position" => "", "photo" => "", "email" => ""), $atts));
    global $THEMEREX_sc_testimonials_count, $THEMEREX_sc_testimonials_width, $THEMEREX_sc_testimonials_height;
    $THEMEREX_sc_testimonials_count++;
    $photo = getAttachmentID($photo);
    if (empty($photo)) {
        if (!empty($email)) {
            $photo = get_avatar($email, 50);
        }
    } else {
        $photo = getResizedImageTag($photo, 50, 50);
    }
    $author_show = $position . $photo . $email != '';
    $s = (!empty($THEMEREX_sc_testimonials_width) ? 'width:' . $THEMEREX_sc_testimonials_width . (themerex_strpos($THEMEREX_sc_testimonials_width, '%') !== false ? '' : 'px') . ';' : '') . (!empty($THEMEREX_sc_testimonials_height) ? 'height:' . $THEMEREX_sc_testimonials_height . (themerex_strpos($THEMEREX_sc_testimonials_height, '%') !== false ? '' : 'px') . ';' : '');
    $c = $author_show ? ' sc_testimonials_item_author_show' : '';
    //if (empty($photo)) $photo = '<img src="'.get_template_directory_uri().'/images/no-ava.png" alt="">';
    return '<li' . ($id ? ' id="sc_testimonials_item_' . $id . '"' : '') . ' class="sc_testimonials_item swiper-slide' . $c . '" ' . ($s != '' ? 'style="' . $s . '"' : '') . '>' . '<div class="sc_testimonials_item_content">' . '<div class="sc_testimonials_item_quote"><span class="sc_testimonials_item_text"><span class="sc_testimonials_item_text_before">' . do_shortcode(strip_tags($content)) . '</span></span></div>' . ($author_show ? '<div class="sc_testimonials_item_author">' . ($photo != '' ? '<div class="sc_testimonials_item_avatar">' . $photo . '</div>' : '') . '<div class="sc_testimonials_item_user">' . ($name != '' ? '<span class="sc_testimonials_item_name">' . $name . '</span>' : '') . ($position != '' ? '<span class="sc_testimonials_item_position">' . $position . '</span>' : '') . '</div>' . '</div>' : '') . '</div>' . '</li>';
}
Esempio n. 19
0
    /**
     * How to display the widget on the screen.
     */
    function widget($args, $instance)
    {
        extract($args);
        global $wp_query, $post;
        /* Our variables from the widget settings. */
        $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
        $title_tabs = array(apply_filters('widget_title', isset($instance['title_author']) ? $instance['title_author'] : ''), apply_filters('widget_title', isset($instance['title_users']) ? $instance['title_users'] : ''));
        $number = isset($instance['number']) ? (int) $instance['number'] : '';
        $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0;
        $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0;
        $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0;
        $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0;
        $category = isset($instance['category']) ? (int) $instance['category'] : 0;
        $counters = 'stars';
        $output = '';
        $tabs = array();
        $reviews_first_author = get_theme_option('reviews_first') == 'author';
        $reviews_second_hide = get_theme_option('reviews_second') == 'hide';
        for ($i = 0; $i < 2; $i++) {
            if ($i == 0 && !$reviews_first_author && $reviews_second_hide) {
                continue;
            }
            if ($i == 1 && $reviews_first_author && $reviews_second_hide) {
                continue;
            }
            $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'order' => 'DESC', 'orderby' => 'meta_value_num', 'meta_key' => 'reviews_avg' . ($i == 0 ? '' : '2'));
            if ($category > 0) {
                $args['cat'] = $category;
            }
            $ex = get_theme_option('exclude_cats');
            if (!empty($ex)) {
                $args['category__not_in'] = explode(',', $ex);
            }
            query_posts($args);
            /* Loop posts */
            if (have_posts()) {
                $tabs[$i] = '<li><a href="#widget_top10_' . $i . '" class="theme_button"><span>' . $title_tabs[$i] . '</span></a></li>';
                $output .= '
					<div class="tab_content" id="widget_top10_' . $i . '"' . ($i == 1 && !$output ? ' style="display: block;"' : '') . '>
				';
                $post_number = 0;
                while (have_posts()) {
                    the_post();
                    $post_number++;
                    $post_id = get_the_ID();
                    $post_date = getDateOrDifference(get_the_date('Y-m-d H:i:s'));
                    $post_title = $post->post_title;
                    $post_link = get_permalink();
                    $output .= '
						<div class="post_item' . ($post_number == 1 ? ' first' : '') . '">
					';
                    if ($show_image) {
                        $post_thumb = getResizedImageTag($post_id, 60, 60);
                        if ($post_thumb) {
                            $output .= '
									<div class="post_thumb image_wrapper">' . $post_thumb . '</div>
							';
                        }
                    }
                    $output .= '
									<div class="post_wrapper">
										<h5 class="post_title theme_title' . ($show_counters == 2 ? '' : ' title_padding') . '"><a href="' . $post_link . '">' . $post_title . '</a></h5>
					';
                    if ($show_counters) {
                        $post_counters = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . ($i == 0 ? '' : '2'), true));
                        if ($post_counters > 0) {
                            if (themerex_strlen($post_counters) == 1) {
                                $post_counters .= '.0';
                            }
                            if ($show_counters == 2 && get_custom_option('show_reviews') == 'yes') {
                                $output .= '
									<div class="reviews_summary blog_reviews">
										<div class="criteria_summary criteria_row">
											' . getReviewsSummaryStars($post_counters) . '
										</div>
									</div>
								';
                            }
                        }
                    }
                    if ($show_date || $show_counters || $show_author) {
                        $output .= '
										<div class="post_info theme_info">
						';
                        if ($show_date) {
                            $output .= '
												<span class="post_date theme_text">' . $post_date . '</span>
							';
                        }
                        if ($show_author) {
                            $post_author_id = $post->post_author;
                            $post_author_name = get_the_author_meta('display_name', $post_author_id);
                            $post_author_url = get_author_posts_url($post_author_id, '');
                            $output .= '
											<span class="post_author">' . __('by', 'themerex') . ' <a href="' . $post_author_url . '">' . $post_author_name . '</a></span>
							';
                        }
                        if ($show_counters == 1 && $post_counters) {
                            $output .= '
										<span class="post_comments"><a href="' . $post_link . '">
											<span class="comments_icon icon-star"></span><span class="post_comments_number">' . $post_counters . '</span>
										</a></span>';
                        }
                        $output .= '
										</div>
						';
                    }
                    $output .= '
							</div>
						</div>
					';
                    if ($post_number >= $number) {
                        break;
                    }
                }
                $output .= '
					</div>
				';
            }
        }
        /* Restore main wp_query and current post data in the global var $post */
        wp_reset_query();
        wp_reset_postdata();
        if (!empty($output)) {
            if (!$reviews_second_hide) {
                wp_enqueue_script('jquery-ui-tabs', false, array('jquery', 'jquery-ui-core'), null, true);
            }
            /* Before widget (defined by themes). */
            echo $before_widget;
            /* Display the widget title if one was input (before and after defined by themes). */
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            echo '
				<div class="top10_tabs' . ($show_image ? '' : ' ordered_list') . ($show_image || $show_date || $show_author ? '' : ' flat_list') . '">' . (!$reviews_second_hide ? '<ul class="tabs">' . ($reviews_first_author ? $tabs[0] . $tabs[1] : $tabs[1] . $tabs[0]) . '</ul>' : '') . $output . (!$reviews_second_hide ? '
							<script type="text/javascript">
								jQuery(document).ready(function() {
									jQuery(\'.top10_tabs\').tabs();
								});
							</script>' : '') . '
				</div>
			';
            /* After widget (defined by themes). */
            echo $after_widget;
        }
    }
$top_news_title = get_custom_option('top_news_title');
$term_output = '';
if (!empty($cats)) {
    $term_output .= '<div class="top_news_section">';
    $term_output .= '<h3 class="top_news_title">' . $top_news_title . '</h3>';
    foreach ($cats as $cat) {
        $category_color = get_category_inherited_property($cat, 'category_color');
        $category_color = empty($category_color) ? get_theme_option('category_color') : $category_color;
        $cat_term = get_term($cat, 'category');
        $term_name = $cat_term->name;
        $term_output .= '<div class="top_news_term">';
        $term_output .= '<span class="term_name"' . (!empty($category_color) ? ' style="color:' . $category_color . '"' : '') . '>' . $term_name . '</span>';
        $args = array('post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'post_password' => '', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => 'DESC', 'cat' => $cat);
        query_posts($args);
        /* Loop posts */
        while (have_posts()) {
            the_post();
            $post_id = get_the_ID();
            $post_link = get_permalink($post_id);
            $post_thumb = getResizedImageTag($post_id, 152 * $mult, 152 * $mult);
            $post_title = get_the_title($post_id);
            $term_output .= '<div class="post_' . $post_id . ' top_news_post"><a href="' . $post_link . '">' . $post_thumb . '<span class="top_news_post_title">' . $post_title . '</span></a></div>';
        }
        $term_output .= '</div>';
    }
    /* Restore main wp_query and current post data in the global var $post */
    wp_reset_query();
    wp_reset_postdata();
    $term_output .= '</div>';
    echo $term_output;
}