Ejemplo n.º 1
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;
        }
    }
Ejemplo n.º 2
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'] : '');
        $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);
        }
    }
Ejemplo n.º 3
0
                                $show_content_block = false;
                            }
                        }
                    }
                    ?>
									<span class="post_format theme_accent_bg <?php 
                    echo $recent['post_icon'];
                    ?>
"<?php 
                    echo themerex_substr($recent['post_accent_color'], 0, 1) == '#' ? ' style="background-color: ' . $recent['post_accent_color'] . '"' : '';
                    ?>
></span>
									<?php 
                    $reviewsBlock = '';
                    if (get_custom_option('show_reviews', null, $recent['ID']) == 'yes') {
                        $avg_author = marksToDisplay(get_post_meta($recent['ID'], 'reviews_avg' . (get_theme_option('reviews_first') == 'author' ? '' : '2'), true));
                        if ($avg_author > 0) {
                            $reviewsBlock = '
												<div class="reviews_summary blog_reviews theme_puzzles"' . ($recent['post_hover_bg'] != '' && $recent['post_hover_bg'] != 'default' ? ' style="background-color:' . $recent['post_hover_bg'] . ';"' : '') . '>
													<div class="criteria_summary criteria_row">
														' . getReviewsSummaryStars($avg_author) . '
													</div>
												</div>
											';
                        }
                    }
                    if ($puzzles_style == 'heavy') {
                        if ($recent['post_accent_category'] != '') {
                            ?>
										<span class="post_category theme_accent_bg"<?php 
                            echo themerex_substr($recent['post_accent_color'], 0, 1) == '#' ? ' style="background-color: ' . $recent['post_accent_color'] . '"' : '';
Ejemplo n.º 4
0
function sc_slider($atts, $content = null)
{
    if (in_shortcode_blogger()) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "class" => "", "engine" => get_custom_option('substitute_slider_engine'), "chop_effect" => "", "alias" => "", "ids" => "", "cat" => "", "count" => "0", "offset" => "", "orderby" => "date", "order" => 'desc', "border" => "none", "controls" => "no", "pagination" => "no", "titles" => "no", "descriptions" => get_custom_option('slider_descriptions'), "links" => "no", "align" => "", "interval" => "", "date_format" => "", "crop" => "on", "width" => "", "height" => "", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    global $THEMEREX_sc_slider_engine, $THEMEREX_sc_slider_width, $THEMEREX_sc_slider_height, $THEMEREX_sc_slider_links;
    if (empty($width)) {
        $width = "100%";
    }
    if (empty($interval)) {
        $interval = mt_rand(5000, 10000);
    }
    if ($engine == 'chop' && !file_exists(themerex_get_file_dir('/js/chopslider/jquery.id.chopslider-2.0.0.free.min.js'))) {
        $engine = 'swiper';
    }
    if ($engine == 'chop' && empty($chop_effect)) {
        $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))];
    }
    $THEMEREX_sc_slider_engine = $engine;
    $THEMEREX_sc_slider_width = getStyleValue($width);
    $THEMEREX_sc_slider_height = getStyleValue($height);
    $THEMEREX_sc_slider_links = sc_param_is_on($links);
    if (empty($id)) {
        $id = "sc_slider_" . str_replace('.', '', mt_rand());
    }
    $ms = getStyleString($top, $right, $bottom, $left);
    $ws = getStyleString('', '', '', '', $width);
    $hs = getStyleString('', '', '', '', '', $height);
    $s = ($border == 'none' && !in_array($pagination, array('full', 'over')) ? $ms : '') . $hs . $ws;
    if ($border != 'none' && in_array($pagination, array('full', 'over'))) {
        $pagination = 'yes';
    }
    if ($engine != 'flex' && $engine != 'chop' && $engine != 'swiper' && in_array($pagination, array('full', 'over'))) {
        $pagination = 'yes';
    }
    $output = ($border != 'none' ? '<div class="sc_border sc_border_' . $border . ($align != '' && $align != 'none' ? ' sc_align' . $align : '') . '"' . ($ms . $hs ? ' style="' . $ms . $hs . '"' : '') . '>' : '') . (in_array($pagination, array('full', 'over')) ? '<div class="sc_slider_pagination_area sc_slider_pagination_' . $pagination . '"' . ($ms . $hs ? ' style="' . $ms . $hs . '"' : '') . '>' : '') . '<div' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_slider' . (!empty($class) ? ' ' . $class : '') . ' sc_slider_' . $engine . (sc_param_is_on($controls) ? ' sc_slider_controls' : ' sc_slider_nocontrols') . (sc_param_is_on($pagination) ? ' sc_slider_pagination' : ' sc_slider_nopagination') . ($border == 'none' && $align != '' && $align != 'none' ? ' sc_align' . $align : '') . ($engine == 'swiper' ? ' swiper-slider-container' : '') . '"' . ((int) $interval > 0 ? ' data-interval="' . $interval . '"' : '') . ($engine == 'chop' ? ' data-effect="' . $chop_effect . '"' : '') . ($s != '' ? ' style="' . $s . '"' : '') . '>';
    $pagination_items = '';
    if ($engine == 'revo') {
        if (revslider_exists() && !empty($alias)) {
            $output .= do_shortcode('[rev_slider ' . $alias . ']');
        } else {
            $output = '';
        }
    } else {
        if ($engine == 'royal') {
            if (royalslider_exists() && !empty($alias)) {
                $output .= do_shortcode('[[new_royalslider id="' . $alias . '"]');
            } else {
                $output = '';
            }
        } else {
            if ($engine == 'flex' || $engine == 'chop' || $engine == 'swiper') {
                $imageAsBackground = $engine != 'chop';
                $caption = '';
                $output .= '<ul class="slides' . ($engine == 'swiper' ? ' swiper-wrapper' : '') . '">';
                $content = do_shortcode($content);
                if ($content) {
                    $output .= $content;
                } else {
                    global $post;
                    if (!empty($ids)) {
                        $posts = explode(',', $ids);
                        $count = count($posts);
                    }
                    $args = array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc');
                    if ($offset > 0 && empty($ids)) {
                        $args['offset'] = $offset;
                    }
                    $args = addSortOrderInQuery($args, $orderby, $order);
                    $args = addFiltersInQuery($args, array('thumbs'));
                    $args = addPostsAndCatsInQuery($args, $ids, $cat);
                    $query = new WP_Query($args);
                    $numSlide = 0;
                    while ($query->have_posts()) {
                        $query->the_post();
                        $numSlide++;
                        $post_id = get_the_ID();
                        $post_title = get_the_title();
                        $post_link = get_permalink();
                        $post_date = get_the_date(!empty($date_format) ? $date_format : 'd.m.y');
                        $post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id));
                        if (sc_param_is_on($crop)) {
                            $post_attachment = $imageAsBackground ? getResizedImageURL($post_attachment, !empty($width) && themerex_strpos($width, '%') === false ? $width : null, !empty($height) && themerex_strpos($height, '%') === false ? $height : null) : getResizedImageTag($post_attachment, !empty($width) && themerex_strpos($width, '%') === false ? $width : null, !empty($height) && themerex_strpos($height, '%') === false ? $height : null);
                        } else {
                            if (!$imageAsBackground) {
                                $post_attachment = '<img src="' . $post_attachment . '" alt="">';
                            }
                        }
                        $post_accent_color = '';
                        $post_category = '';
                        $post_category_link = '';
                        if (in_array($pagination, array('full', 'over'))) {
                            // Get all post's tags
                            $post_tags_links = '';
                            if (($post_tags_list = get_the_tags()) != 0) {
                                $tag_number = 0;
                                foreach ($post_tags_list as $tag) {
                                    $tag_number++;
                                    $post_tags_links .= '<span class="slide_tag">' . $tag->name . ($tag_number == count($post_tags_list) ? '' : ',') . '</span> ';
                                }
                            }
                            $pagination_items .= '<li' . (empty($pagination_items) ? ' class="' . ($engine == 'chop' ? 'cs-active-pagination' : 'active') . '"' : '') . '>' . '<div class="slide_pager">' . '<div class="slide_date">' . $post_date . '</div>' . '<div class="slide_info">' . '<h4 class="slide_title">' . $post_title . '</h4>' . '<div class="slide_tags">' . $post_tags_links . '</div>' . '</div>' . '</div>' . '</li>';
                        }
                        $output .= '<li' . ' class="' . $engine . '-slide' . ($engine == 'chop' && $numSlide == 1 ? ' cs-activeSlide' : '') . '"' . ' style="' . ($engine == 'chop' && $numSlide == 1 ? 'display:block;' : '') . ($imageAsBackground ? 'background-image:url(' . $post_attachment . ');' : '') . $ws . $hs . '"' . '>' . (sc_param_is_on($links) ? '<a href="' . $post_link . '" title="' . htmlspecialchars($post_title) . '">' : '') . (!$imageAsBackground ? $post_attachment : '');
                        $caption = $engine == 'swiper' || $engine == 'flex' ? '' : $caption;
                        if (!sc_param_is_off($titles)) {
                            $post_hover_bg = get_custom_option('theme_color', null, $post_id);
                            $post_bg = '';
                            if ($post_hover_bg != '' && !is_inherit_option($post_hover_bg)) {
                                $rgb = Hex2RGB($post_hover_bg);
                                $post_hover_ie = str_replace('#', '', $post_hover_bg);
                                $post_bg = "background-color: rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.8);";
                            }
                            $caption .= ($engine == 'chop' ? '<div class="sc_slider_info_item">' : '') . '<div class="sc_slider_info' . ($titles == 'fixed' ? ' sc_slider_info_fixed' : '') . ($engine == 'swiper' ? ' content-slide' : '') . '"' . ($post_bg != '' ? ' style="' . $post_bg . '"' : '') . '>';
                            $post_descr = getPostDescription();
                            if (get_custom_option("slider_info_category") == 'yes') {
                                // || empty($cat)) {
                                // Get all post's categories
                                $post_categories = getCategoriesByPostId($post_id);
                                $post_categories_str = '';
                                for ($i = 0; $i < count($post_categories); $i++) {
                                    if ($post_category == '') {
                                        if (get_theme_option('close_category') == 'parental') {
                                            $parent_cat_id = 0;
                                            //(int) get_custom_option('category_id');
                                            $parent_cat = getParentCategory($post_categories[$i]['term_id'], $parent_cat_id);
                                            if ($parent_cat) {
                                                $post_category = $parent_cat['name'];
                                                $post_category_link = $parent_cat['link'];
                                                if ($post_accent_color == '') {
                                                    $post_accent_color = get_category_inherited_property($parent_cat['term_id'], 'theme_color');
                                                }
                                            }
                                        } else {
                                            $post_category = $post_categories[$i]['name'];
                                            $post_category_link = $post_categories[$i]['link'];
                                            if ($post_accent_color == '') {
                                                $post_accent_color = get_category_inherited_property($post_categories[$i]['term_id'], 'theme_color');
                                            }
                                        }
                                    }
                                    if ($post_category != '' && $post_accent_color != '') {
                                        break;
                                    }
                                }
                                if ($post_category == '' && count($post_categories) > 0) {
                                    $post_category = $post_categories[0]['name'];
                                    $post_category_link = $post_categories[0]['link'];
                                    if ($post_accent_color == '') {
                                        $post_accent_color = get_category_inherited_property($post_categories[0]['term_id'], 'theme_color');
                                    }
                                }
                                if ($post_category != '') {
                                    $caption .= '<div class="sc_slider_category"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '><a href="' . $post_category_link . '">' . $post_category . '</a></div>';
                                }
                            }
                            $output_reviews = '';
                            if (get_custom_option('show_reviews') == 'yes' && get_custom_option('slider_reviews') == 'yes') {
                                $avg_author = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . (get_theme_option('reviews_first') == 'author' && $orderby != 'users_rating' || $orderby == 'author_rating' ? '' : '2'), true));
                                if ($avg_author > 0) {
                                    $output_reviews .= '<div class="sc_slider_reviews reviews_summary blog_reviews' . (get_custom_option("slider_info_category") == 'yes' ? ' after_category' : '') . '">' . '<div class="criteria_summary criteria_row">' . getReviewsSummaryStars($avg_author) . '</div>' . '</div>';
                                }
                            }
                            if (get_custom_option("slider_info_category") == 'yes') {
                                $caption .= $output_reviews;
                            }
                            $caption .= '<h2 class="sc_slider_subtitle"><a href="' . $post_link . '">' . $post_title . '</a></h2>';
                            if (get_custom_option("slider_info_category") != 'yes') {
                                $caption .= $output_reviews;
                            }
                            if ($descriptions > 0) {
                                $caption .= '<div class="sc_slider_descr">' . getShortString($post_descr, $descriptions) . '</div>';
                            }
                            $caption .= '</div>' . ($engine == 'chop' ? '</div>' : '');
                        }
                        $output .= ($engine == 'swiper' || $engine == 'flex' ? $caption : '') . (sc_param_is_on($links) ? '</a>' : '') . '</li>';
                    }
                    wp_reset_postdata();
                }
                $output .= '</ul>';
                if ($engine == 'swiper' || $engine == 'chop') {
                    if (sc_param_is_on($controls)) {
                        $output .= '
					<ul class="flex-direction-nav">
					<li><a class="flex-prev" href="#"></a></li>
					<li><a class="flex-next" href="#"></a></li>
					</ul>';
                    }
                    if (sc_param_is_on($pagination)) {
                        $output .= '<div class="flex-control-nav"></div>';
                    }
                }
                if ($engine == 'chop') {
                    $output .= '
				<div class="sc_slider_info_slides">' . $caption . '</div>
				<div class="sc_slider_info_holder"></div>
				';
                }
            } else {
                $output = '';
            }
        }
    }
    if (!empty($output)) {
        $output .= '</div>' . ($border != 'none' ? '</div>' : '');
        if ($pagination_items) {
            $output .= '
				<div class="flex-control-nav manual"' . ($hs ? ' style="' . $hs . '"' : '') . '>
					<div id="' . $id . '_scroll" class="sc_scroll sc_scroll_vertical swiper-slider-container scroll-container"' . ($hs ? ' style="' . $hs . '"' : '') . '>
						<div class="sc_scroll_wrapper swiper-wrapper">
							<div class="sc_scroll_slide swiper-slide">
								<ul>' . $pagination_items . '</ul>
							</div>
						</div>
						<div id="' . $id . '_scroll_bar" class="sc_scroll_bar sc_scroll_bar_vertical"></div>
					</div>
				</div>';
            $output .= '</div>';
        }
    }
    return $output;
}
Ejemplo n.º 5
0
function show_meta_box_post()
{
    global $THEMEREX_meta_box_post, $post, $THEMEREX_options;
    // Use nonce for verification
    echo '<input type="hidden" name="meta_box_post_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
    // Nonce for ajax queries
    $THEMEREX_ajax_nonce = wp_create_nonce('ajax_nonce');
    $THEMEREX_ajax_url = admin_url('admin-ajax.php');
    $maxLevel = max(5, (int) get_theme_option('reviews_max_level'));
    $custom_options = get_post_meta($post->ID, 'post_custom_options', true);
    if (isset($custom_options['reviews_marks'])) {
        $custom_options['reviews_marks'] = marksToDisplay($custom_options['reviews_marks']);
    }
    $post_options = array_merge($THEMEREX_options, $THEMEREX_meta_box_post['fields']);
    themerex_options_load_scripts();
    themerex_options_prepare_js('post');
    ?>
    
    <script type="text/javascript">
		// AJAX fields
		var THEMEREX_ajax_url = "<?php 
    echo $THEMEREX_ajax_url;
    ?>
";
		var THEMEREX_ajax_nonce = "<?php 
    echo $THEMEREX_ajax_nonce;
    ?>
";
		//var reviews_criterias = "";
		var reviews_levels = "<?php 
    echo get_theme_option('reviews_criterias_levels');
    ?>
";
		var reviews_max_level = <?php 
    echo $maxLevel;
    ?>
;
		var allowUserReviews = true;
		jQuery(document).ready(function() {
			// Init post specific meta fields
			//initPostReviews();
		});
	</script>
    
	<div class="reviews_<?php 
    echo $maxLevel;
    ?>
">

    <?php 
    themerex_options_page_start(array('data' => $post_options, 'add_inherit' => true, 'show_page_layout' => false, 'override' => 'post'));
    foreach ($post_options as $option) {
        if (!isset($option['override']) || !in_array('post', explode(',', $option['override']))) {
            continue;
        }
        $id = isset($option['id']) ? $option['id'] : '';
        $meta = isset($custom_options[$id]) ? $custom_options[$id] : '';
        if ($id == 'reviews_marks') {
            $cat_list = getCategoriesByPostId($post->ID);
            if (count($cat_list) > 0) {
                foreach ($cat_list as $cat) {
                    $id = (int) $cat['term_id'];
                    $prop = get_category_inherited_property($id, 'reviews_criterias');
                    if (!empty($prop) && !is_inherit_option($prop)) {
                        $option['options'] = $prop;
                        break;
                    }
                }
            }
        }
        themerex_options_show_field($option, $meta);
    }
    themerex_options_page_stop();
    ?>
	</div>
	<?php 
}
Ejemplo n.º 6
0
function sc_slider($atts, $content = null)
{
    if (in_shortcode_blogger()) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "engine" => "flex", "alias" => "", "ids" => "", "theme" => "dark", "cat" => "", "count" => "0", "offset" => "", "orderby" => "date", "order" => 'desc', "controls" => "no", "pagination" => "no", "titles" => "no", "links" => "no", "rev_style" => "rev_full", "align" => "", "width" => "100%", "height" => "400", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    /*scripts & styles*/
    themerex_enqueue_style('swiperslider-style', get_template_directory_uri() . '/js/swiper/idangerous.swiper.css', array(), null);
    themerex_enqueue_script('swiperslider', get_template_directory_uri() . '/js/swiper/idangerous.swiper-2.1.js', array('jquery'), null, true);
    themerex_enqueue_style('swiperslider-scrollbar-style', get_template_directory_uri() . '/js/swiper/idangerous.swiper.scrollbar.css', array(), null);
    themerex_enqueue_script('swiperslider-scrollbar', get_template_directory_uri() . '/js/swiper/idangerous.swiper.scrollbar-2.1.js', array('jquery'), null, true);
    themerex_enqueue_script('hover-dir', get_template_directory_uri() . '/js/hover/jquery.hoverdir.js', array(), null, true);
    themerex_enqueue_style('hover-intent', get_template_directory_uri() . '/js/hover/hoverIntent.js', array(), null);
    global $THEMEREX_sc_slider_engine, $THEMEREX_sc_slider_width, $THEMEREX_sc_slider_height, $THEMEREX_sc_slider_links;
    $THEMEREX_sc_slider_engine = $engine;
    $THEMEREX_sc_slider_width = $width;
    $THEMEREX_sc_slider_height = $height;
    $THEMEREX_sc_slider_links = sc_param_is_on($links);
    $s = ($top !== '' ? 'margin-top:' . $top . 'px;' : '') . ($bottom !== '' ? 'margin-bottom:' . $bottom . 'px;' : '') . ($left !== '' ? 'margin-left:' . $left . ((int) $left > 0 || (int) $left < 0 ? 'px' : '') . ';' : '') . ($right !== '' ? 'margin-right:' . $right . ((int) $right > 0 || (int) $right < 0 ? 'px' : '') . ';' : '') . (!empty($width) ? 'width:' . $width . (themerex_strpos($width, '%') !== false ? '' : 'px') . ';' : '') . (!empty($height) ? 'height:' . $height . (themerex_strpos($height, '%') !== false ? '' : 'px') . ';' : '');
    $c = ' sc_slider_' . $engine . (sc_param_is_on($controls) ? ' sc_slider_controls' : '') . (sc_param_is_on($pagination) ? ' sc_slider_pagination' : '') . ($align != '' && $align != 'none' ? ' sc_float_' . $align : '') . ($engine == 'swiper' ? ' swiper-container' : '');
    $output = '<div' . ($id ? ' id="sc_slider_' . $id . '"' : '') . ' class="sc_slider ' . $c . '" ' . ($s != '' ? ' style="' . $s . '"' : '') . ' data-settings="horizontal">';
    if ($engine == 'revo') {
        if (revslider_exists() && !empty($alias)) {
            $output .= do_shortcode('[rev_slider ' . $alias . ']');
        } else {
            $output = '';
        }
    } else {
        if ($engine == 'royal') {
            if (royalslider_exists() && !empty($alias)) {
                $output .= do_shortcode('[[new_royalslider id="' . $alias . '"]');
            } else {
                $output = '';
            }
        } else {
            if ($engine == 'flex' || $engine == 'swiper') {
                $output .= '<ul class="slides' . ($engine == 'swiper' ? ' swiper-wrapper' : '') . '">';
                $content = do_shortcode($content);
                if ($content) {
                    $output .= $content;
                } else {
                    global $post;
                    if (!empty($ids)) {
                        $posts = explode(',', $ids);
                        $count = count($posts);
                    }
                    $args = array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc');
                    if ($offset > 0 && empty($ids)) {
                        $args['offset'] = $offset;
                    }
                    $args = addSortOrderInQuery($args, $orderby, $order, true);
                    $args = addPostsAndCatsInQuery($args, $ids, $cat);
                    $query = new WP_Query($args);
                    while ($query->have_posts()) {
                        $query->the_post();
                        $post_id = get_the_ID();
                        $post_link = get_permalink();
                        $post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id));
                        $post_accent_color = '';
                        $post_category = '';
                        $post_category_link = '';
                        $post_title = getPostTitle($post_id);
                        $avg_author = 0;
                        $ed = themerex_substr($width, -1) == '%' ? '%' : 'px';
                        //image crop
                        $no_crop = getThumbSizes(array('thumb_size' => 'image_large', 'thumb_crop' => true, 'sidebar' => false));
                        $crop = array("w" => $width != '' && $ed != '%' ? $width : $no_crop['w'], "h" => $height != '' && $ed != '%' ? $height : null);
                        $post_attachment = getResizedImageURL($post_attachment, $crop['w'], $crop['h']);
                        $output .= '<li' . ($engine == 'swiper' ? ' class="swiper-slide"' : '') . ' data-theme="' . ($theme != '' ? $theme : 'dark') . '" style="background-image:url(' . $post_attachment . ');' . (!empty($width) ? ' width:' . $width . (themerex_strpos($width, '%') !== false ? '' : 'px') . ';' : '') . (!empty($height) ? ' height:' . $height . (themerex_strpos($height, '%') !== false ? '' : 'px') . ';' : '') . '">' . (sc_param_is_on($links) ? '<a href="' . $post_attachment . '" title="' . htmlspecialchars($post_title) . '">' : '');
                        if (!sc_param_is_off($titles)) {
                            $post_hover_bg = get_custom_option('theme_color', null, $post_id);
                            $post_bg = '';
                            if ($post_hover_bg != '' && !is_inherit_option($post_hover_bg)) {
                                $rgb = Hex2RGB_1($post_hover_bg);
                                $post_hover_ie = str_replace('#', '', $post_hover_bg);
                                $post_bg = "background-color: rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.8);";
                            }
                            $output .= '<div class="sc_slider_info' . ($titles == 'fixed' ? ' sc_slider_info_fixed' : ' sc_slider_info_slide') . ($engine == 'swiper' ? ' content-slide' : '') . '"><div class="main">';
                            $post_descr = getPostDescription();
                            //reviews
                            if (get_custom_option('show_reviews') == 'yes' && get_custom_option('slider_reviews') == 'yes') {
                                $output_reviews = '';
                                $rating_max = get_custom_option('reviews_max_level');
                                $review_title = sprintf($rating_max < 100 ? __('Rating: %s from %s', 'themerex') : __('Rating: %s', 'themerex'), number_format($avg_author, 1) . ($rating_max < 100 ? '' : '%'), $rating_max . ($rating_max < 100 ? '' : '%'));
                                $avg_author = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . (get_theme_option('reviews_first') == 'author' && $orderby != 'users_rating' || $orderby == 'author_rating' ? '' : '2'), true));
                                if ($avg_author > 0 && get_custom_option('slider_reviews_style') == 'rev_short') {
                                    $output .= '<div class="sc_slider_reviews_short" title="' . $review_title . '"><span class="rInfo">' . $avg_author . '</span><span class="rDelta">' . ($rating_max < 100 ? '<span class="icon-star"></span>' : '%') . '</span></div>';
                                } else {
                                    if ($avg_author > 0 && get_custom_option('slider_reviews_style') == 'rev_full') {
                                        $output_reviews .= '<div class="sc_slider_reviews reviews_summary blog_reviews" title="' . $review_title . '">' . '<div class="criteria_summary criteria_row">' . getReviewsSummaryStars($avg_author) . '</div>' . '</div>';
                                    }
                                }
                                $output .= $output_reviews;
                            }
                            //category
                            if (get_custom_option("slider_info_category") == 'yes') {
                                // || empty($cat)) {
                                // Get all post's categories
                                $post_categories = getCategoriesByPostId($post_id);
                                $post_categories_str = '';
                                for ($i = 0; $i < count($post_categories); $i++) {
                                    if ($post_category == '') {
                                        if (get_theme_option('close_category') == 'parental') {
                                            $parent_cat_id = 0;
                                            //(int) get_custom_option('category_id');
                                            $parent_cat = getParentCategory($post_categories[$i]['term_id'], $parent_cat_id);
                                            if ($parent_cat) {
                                                $post_category = $parent_cat['name'];
                                                $post_category_link = $parent_cat['link'];
                                                if ($post_accent_color == '') {
                                                    $post_accent_color = get_category_inherited_property($parent_cat['term_id'], 'theme_color');
                                                }
                                            }
                                        } else {
                                            $post_category = $post_categories[$i]['name'];
                                            $post_category_link = $post_categories[$i]['link'];
                                            if ($post_accent_color == '') {
                                                $post_accent_color = get_category_inherited_property($post_categories[$i]['term_id'], 'theme_color');
                                            }
                                        }
                                    }
                                    if ($post_category != '' && $post_accent_color != '') {
                                        break;
                                    }
                                }
                                if ($post_category == '' && count($post_categories) > 0) {
                                    $post_category = $post_categories[0]['name'];
                                    $post_category_link = $post_categories[0]['link'];
                                    if ($post_accent_color == '') {
                                        $post_accent_color = get_category_inherited_property($post_categories[0]['term_id'], 'theme_color');
                                    }
                                }
                                if ($post_category != '') {
                                    $output .= '<div class="sc_slider_category"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '><a href="' . $post_category_link . '">' . $post_category . '</a></div>';
                                }
                            }
                            //title
                            if (strlen($post_title) > 25) {
                                $post_title = substr($post_title, 0, 25) . '...';
                            }
                            $output .= '<h2 class="sc_slider_subtitle"><a href="' . $post_link . '">' . $post_title . '</a></h2>';
                            //descriptions
                            if (get_custom_option('slider_descriptions') == 'yes') {
                                $output .= '<div class="sc_slider_descr">' . $post_descr . '</div>';
                            }
                            $output .= '</div></div>';
                        }
                        $output .= (sc_param_is_on($links) ? '</a>' : '') . '</li>';
                    }
                    wp_reset_postdata();
                }
                $output .= '</ul>';
                if ($engine == 'swiper') {
                    if (sc_param_is_on($controls)) {
                        $output .= '
					<ul class="slider-control-nav">
						<li class="slide-prev"><a class="icon-left-open-big" href="#"></a></li>
						<li class="slide-next"><a class="icon-right-open-big" href="#"></a></li>
					</ul>';
                    }
                    if (sc_param_is_on($pagination)) {
                        $output .= '
					<div class="slider-pagination-nav"></div>
				';
                    }
                }
            } else {
                $output = '';
            }
        }
    }
    $output .= !empty($output) ? '</div>' : '';
    return $output;
}
Ejemplo n.º 7
0
function show_meta_box_post()
{
    global $THEMEREX_meta_box_post, $post, $THEMEREX_options;
    // Use nonce for verification
    echo '<input type="hidden" name="meta_box_post_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
    // Nonce for ajax queries
    $THEMEREX_ajax_nonce = wp_create_nonce('ajax_nonce');
    $THEMEREX_ajax_url = admin_url('admin-ajax.php');
    $maxLevel = max(5, (int) get_theme_option('reviews_max_level'));
    $custom_options = get_post_meta($post->ID, 'post_custom_options', true);
    if (isset($custom_options['reviews_marks'])) {
        $custom_options['reviews_marks'] = marksToDisplay($custom_options['reviews_marks']);
    }
    $post_options = array_merge($THEMEREX_options, $THEMEREX_meta_box_post['fields']);
    themerex_options_load_scripts();
    themerex_options_prepare_js();
    themerex_enqueue_script('_admin', get_template_directory_uri() . '/js/_admin.js', array('jquery'), null, true);
    ?>
    
    <script type="text/javascript">
		// AJAX fields
		var THEMEREX_ajax_url = "<?php 
    echo $THEMEREX_ajax_url;
    ?>
";
		var THEMEREX_ajax_nonce = "<?php 
    echo $THEMEREX_ajax_nonce;
    ?>
";
		var reviews_criterias = "<?php 
    $rc = get_theme_option('reviews_criterias');
    echo is_array($rc) ? implode(',', $rc) : '';
    ?>
";
		var reviews_levels = "<?php 
    echo get_theme_option('reviews_criterias_levels');
    ?>
";
		var reviews_max_level = <?php 
    echo $maxLevel;
    ?>
;
		var allowUserReviews = true;
		jQuery(document).ready(function() {
			// Init post specific meta fields
			//initPostReviews();
		});
	</script>
    
	<div class="reviews_<?php 
    echo esc_attr($maxLevel);
    ?>
">

    <?php 
    themerex_options_page_start(array('data' => $post_options, 'add_inherit' => true, 'show_page_layout' => false, 'override' => 'post'));
    foreach ($post_options as $option) {
        if (!isset($option['override']) || !in_array('post', explode(',', $option['override']))) {
            continue;
        }
        $id = isset($option['id']) ? $option['id'] : '';
        $meta = isset($custom_options[$id]) ? $custom_options[$id] : '';
        themerex_options_show_field($option, $meta);
    }
    themerex_options_page_stop();
    ?>
	</div>
	<?php 
}
    }
}
$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_counters = marksToDisplay(get_post_meta($post_id, $post_rating, true));
                $post_counters_icon = 'star-1';
            } else {
                $post_counters = get_comments_number($post_id);
                $post_counters_icon = 'comment-1';
            }
        }
    }
    if ($show_counters == 'stars' && $post_counters > 0) {
        if (themerex_strpos($post_counters, '.') === false) {
            $post_counters .= '.0';
        }
        if (get_custom_option('show_reviews') == 'yes') {
            $output .= '<div class="summaryRating">' . getReviewsSummaryStars($post_counters, false, false) . '</div>';
        }
    }
Ejemplo n.º 9
0
                break;
            }
        }
    }
    // Author marks
    $output .= '<div class="sc_tabs_array">';
    if ($reviews_first_author || !$reviews_second_hide) {
        $field["id"] = "reviews_marks_author";
        $field["descr"] = strip_tags($post_data['post_excerpt']);
        $field["accept"] = false;
        $marks = marksToDisplay(marksPrepare(get_custom_option('reviews_marks'), count($field['options'])));
        $output .= '<div class="reviewTab" id="author-tabs">' . getReviewsMarkup($field, $marks, false, false, $reviews_first_author) . '</div>';
    }
    // Users marks
    if (!$reviews_first_author || !$reviews_second_hide) {
        $marks = marksToDisplay(marksPrepare(get_post_meta($post_data['post_id'], 'reviews_marks2', true), count($field['options'])));
        $users = max(0, get_post_meta($post_data['post_id'], 'reviews_users', true));
        $field["id"] = "reviews_marks_users";
        $field["descr"] = sprintf(__("Summary rating from <b>%s</b> user's marks.", 'themerex'), $users) . ' ' . (!isset($_COOKIE['reviews_vote']) || themerex_strpos($_COOKIE['reviews_vote'], ',' . $post_data['post_id'] . ',') === false ? __('You can set own marks for this article - just click on stars above and press "Accept".', 'themerex') : __('Thanks for your vote!', 'themerex'));
        $field["accept"] = $allowUserReviews;
        $output .= '<div class="reviewTab" id="users-tabs"' . (!$output ? ' style="display: block;"' : '') . '>' . getReviewsMarkup($field, $marks, $allowUserReviews, false, !$reviews_first_author) . '</div>';
    }
    $output .= '</div>';
    $THEMEREX_REVIEWS_RATING .= $output . '</div>';
    if ($allowUserReviews) {
        $THEMEREX_REVIEWS_RATING .= '
			<script type="text/javascript">
				var reviews_max_level = ' . $maxLevel . ';
				var reviews_levels = "' . get_theme_option('reviews_criterias_levels') . '";
				var reviews_vote = "' . (isset($_COOKIE['reviews_vote']) ? $_COOKIE['reviews_vote'] : '') . '";
				var marks = "' . $marks . '".split(",");
Ejemplo n.º 10
0
function sc_slider($atts, $content = null)
{
    extract(shortcode_atts(array("id" => "", "engine" => "flex", "links" => "0", "controls" => "0", "titles" => "0", "alias" => "", "ids" => "", "cat" => "", "count" => "0", "offset" => "", "orderby" => "date", "order" => 'desc', "width" => "", "height" => "", "align" => "", "border" => "0", "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;' : '') . (!empty($width) ? 'width:' . $width . (themerex_strpos($width, '%') !== false ? '' : 'px') . ';' : '') . (!empty($height) ? 'height:' . $height . (themerex_strpos($height, '%') !== false ? '' : 'px') . ';' : '');
    $output = '<div' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_slider' . ' sc_slider_' . $engine . ($controls > 0 ? ' sc_slider_controls' : '') . ($align != '' ? ' align' . $align : '') . ($border > 0 ? ' sc_slider_border' : '') . '"' . ($s != '' ? ' style="' . $s . '"' : '') . '>';
    if ($engine == 'revo') {
        if (is_plugin_active('revslider/revslider.php') && !empty($alias)) {
            $output .= do_shortcode('[rev_slider ' . $alias . ']');
        } else {
            $output = '';
        }
    } else {
        if ($engine == 'flex') {
            $output .= '<ul class="slides">';
            global $post;
            if (!empty($ids)) {
                $posts = explode(',', $ids);
                $count = count($posts);
            }
            $args = array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc');
            if ($offset > 0 && empty($ids)) {
                $args['offset'] = $offset;
            }
            $args = addSortOrderInQuery($args, $orderby, $order, true);
            $args = addPostsAndCatsInQuery($args, $ids, $cat);
            $query = new WP_Query($args);
            while ($query->have_posts()) {
                $query->the_post();
                $post_id = get_the_ID();
                $post_link = get_permalink();
                $post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id));
                $post_accent_color = '';
                $post_accent_category = '';
                $post_title = getPostTitle($post_id);
                $output .= '<li style="background-image:url(' . $post_attachment . ')">' . ($links > 0 ? '<a href="' . $post_attachment . '" title="' . htmlspecialchars($post_title) . '">' : '');
                if ($titles) {
                    $post_hover_bg = get_custom_option('puzzles_post_bg', null, $post_id);
                    $post_bg = '';
                    if ($post_hover_bg != '' && $post_hover_bg != 'default') {
                        $rgb = Hex2RGB($post_hover_bg);
                        $post_hover_ie = str_replace('#', '', $post_hover_bg);
                        $post_bg = "background-color: rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.8);";
                    }
                    $output .= '<div class="sc_slider_info' . ($titles > 1 ? ' sc_slider_info_fixed' : '') . ' theme_accent_bg"' . ($post_bg != '' ? ' style="' . $post_bg . '"' : '') . '>';
                    $post_descr = getPostDescription();
                    if (get_custom_option("slider_info_category") == 'yes') {
                        // || empty($cat)) {
                        // Get all post's categories
                        $post_categories = getCategoriesByPostId($post_id);
                        $post_categories_str = '';
                        for ($i = 0; $i < count($post_categories); $i++) {
                            if ($post_accent_category == '') {
                                if (get_theme_option('close_category') == 'parental') {
                                    $parent_cat_id = 0;
                                    //(int) get_custom_option('category_id');
                                    $parent_cat = getParentCategory($post_categories[$i]['term_id'], $parent_cat_id);
                                    if ($parent_cat) {
                                        $post_accent_category = $parent_cat['name'];
                                        if ($post_accent_color == '') {
                                            $post_accent_color = getCategoryInheritedProperty($parent_cat['term_id'], 'theme_accent_color');
                                        }
                                    }
                                } else {
                                    $post_accent_category = $post_categories[$i]['name'];
                                    if ($post_accent_color == '') {
                                        $post_accent_color = getCategoryInheritedProperty($post_categories[$i]['term_id'], 'theme_accent_color');
                                    }
                                }
                            }
                            if ($post_accent_category != '' && $post_accent_color != '') {
                                break;
                            }
                        }
                        if ($post_accent_category == '' && count($post_categories) > 0) {
                            $post_accent_category = $post_categories[0]['name'];
                            if ($post_accent_color == '') {
                                $post_accent_color = getCategoryInheritedProperty($post_categories[0]['term_id'], 'theme_accent_color');
                            }
                        }
                        if ($post_accent_category != '') {
                            $output .= '<div class="sc_slider_category theme_accent_bg"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '>' . $post_accent_category . '</div>';
                        }
                    }
                    $output_reviews = '';
                    if (get_custom_option('show_reviews') == 'yes' && get_custom_option('slider_reviews') == 'yes') {
                        $avg_author = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . (get_theme_option('reviews_first') == 'author' && $orderby != 'users_rating' || $orderby == 'author_rating' ? '' : '2'), true));
                        if ($avg_author > 0) {
                            $output_reviews .= '<div class="sc_slider_reviews reviews_summary blog_reviews' . (get_custom_option("slider_info_category") == 'yes' ? ' after_category' : '') . '">' . '<div class="criteria_summary criteria_row">' . getReviewsSummaryStars($avg_author) . '</div>' . '</div>';
                        }
                    }
                    if (get_custom_option("slider_info_category") == 'yes') {
                        $output .= $output_reviews;
                    }
                    $output .= '<h2 class="sc_slider_subtitle"><a href="' . $post_link . '">' . $post_title . '</a></h2>';
                    if (get_custom_option("slider_info_category") != 'yes') {
                        $output .= $output_reviews;
                    }
                    if (get_custom_option('slider_descriptions') == 'yes') {
                        $output .= '<div class="sc_slider_descr">' . $post_descr . '</div>';
                    }
                    $output .= '</div>';
                } else {
                    //$output .= '<a href="'. $post_link . '">'.$titles.'</a>';
                }
                $output .= ($links > 0 ? '</a>' : '') . '</li>';
            }
            wp_reset_postdata();
            $output .= '</ul>';
        } else {
            $output = '';
        }
    }
    $output .= !empty($output) ? '</div>' : '';
    return $output;
}
Ejemplo n.º 11
0
function show_meta_box_post()
{
    global $THEMEREX_meta_box_post, $post, $THEMEREX_theme_options;
    $THEMEREX_ajax_nonce = wp_create_nonce('ajax_nonce');
    $THEMEREX_ajax_url = admin_url('admin-ajax.php');
    $maxLevel = max(5, (int) get_theme_option('reviews_max_level'));
    $custom_options = get_post_meta($post->ID, 'post_custom_options', true);
    if (isset($custom_options['reviews_marks'])) {
        $custom_options['reviews_marks'] = marksToDisplay($custom_options['reviews_marks']);
    }
    wp_enqueue_script('_admin', get_template_directory_uri() . '/js/_admin.js', array('jquery'), null, true);
    ?>
    
    <script type="text/javascript">
		// AJAX fields
		var THEMEREX_ajax_url = "<?php 
    echo $THEMEREX_ajax_url;
    ?>
";
		var THEMEREX_ajax_nonce = "<?php 
    echo $THEMEREX_ajax_nonce;
    ?>
";
		var reviews_criterias = "<?php 
    echo get_theme_option('reviews_criterias');
    ?>
";
		var reviews_levels = "<?php 
    echo get_theme_option('reviews_criterias_levels');
    ?>
";
		var reviews_max_level = <?php 
    echo $maxLevel;
    ?>
;
		var allowUserReviews = true;
		jQuery(document).ready(function() {
			// Remove General tab - not contain override options
			jQuery('.opt_tabs > ul > li#tab_blog_general').eq(0).remove();
			jQuery('#content_blog_general').eq(0).remove();
			jQuery('.opt_tabs > ul').eq(0).append(jQuery('.opt_tabs > ul > li#tab_general').eq(0));
			jQuery('.opt_tabs > ul > li#tab_general a').eq(0).html('<?php 
    _e('Advertisement', 'themerex');
    ?>
');
			jQuery('.opt_tabs > ul > li > a').eq(0).trigger('click');
			// Init post specific meta fields
			initPostReviews();
		});
	</script>
    
    <?php 
    // Use nonce for verification
    echo '<input type="hidden" name="meta_box_post_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
    ?>

	<div id="truethemes_container" class="reviews_<?php 
    echo $maxLevel;
    ?>
">

    <?php 
    $menu = $output = '';
    $flags = array('group_opened' => false, 'tabs_opened' => false, 'heading_opened' => false, 'heading_as_tabs' => true, 'radio_as_select' => true, 'inherit' => true, 'clear_shortname' => true);
    foreach ($THEMEREX_theme_options as $option) {
        if (!isset($option['override']) || !in_array('post', explode(',', $option['override']))) {
            continue;
        }
        $id = isset($option['id']) ? get_option_name($option['id']) : '';
        $meta = isset($custom_options[$id]) ? $custom_options[$id] : '';
        list($o, $m) = theme_options_show_field($option, $meta, $flags);
        $output .= $o;
        $menu .= $m;
    }
    foreach ($THEMEREX_meta_box_post['fields'] as $option) {
        $meta = isset($option['id']) && isset($custom_options[$option['id']]) ? $custom_options[$option['id']] : '';
        list($o, $m) = theme_options_show_field($option, $meta, $flags);
        $output .= $o;
        $menu .= $m;
    }
    if ($flags['group_opened']) {
        $output .= '</div></div>';
    }
    $output .= '</div>';
    echo '<div class="opt_tabs"><ul>' . $menu . '</ul>' . $output;
}
 if (empty($post_votes_data)) {
     foreach ($criterias_list as $criteria) {
         $post_votes_data['criterias_points'][$criteria] = 0;
     }
     $post_votes_data['total_votes'] = 1;
 }
 $user_total_votes = $post_votes_data['total_votes'];
 $user_criteria_points = $post_votes_data['criterias_points'];
 $user_votes_avg = array();
 foreach ($user_criteria_points as $criteria => $points) {
     $user_votes_avg[$criteria] = $points / $user_total_votes;
 }
 $width = 137;
 $user_reviews_output = trex_vote_results($user_votes_avg, $vote_max, $width);
 $user_reviews_avg = array_sum($user_votes_avg) / count($user_criteria_points);
 $user_reviews_avg_to_view = marksToDisplay($user_reviews_avg, $vote_max);
 $user_reviews_output .= trex_avg_total_score($user_reviews_avg_to_view, $user_reviews_avg);
 /**/
 $criteria_points = array();
 foreach ($criterias_list as $key => $criteria) {
     $criteria_points[$criteria] = $votes_list[$key];
 }
 if ($use_tabs) {
     $users_total_block = trex_avg_total_score($author_avg_to_view, $author_avg);
 }
 $author_short_decs = '<div class="short_descr">' . getShortString(strip_tags($post_data['post_excerpt']), 100) . '</div>';
 $author_full_decs = '<div class="full_descr">' . $post_data['post_excerpt'] . '</div>';
 $user_short_desc = '<div class="short_descr">This section displays an average rating from all users according to specified criteria. Total number of ratings ' . $user_total_votes . '</div>';
 $user_reviews_output .= $user_short_desc;
 /**/
 $output = $marks = $users = '';