function get_custom_option($name, $defa = null, $post_id = 0, $cat_id = 0) { $defaults = array('default', 'inherit'); if ($cat_id > 0) { $rez = getCategoryInheritedProperty($cat_id, $name); if ($rez == '') { $rez = get_theme_option($name, $defa); } } else { if ($post_id > 0) { $rez = get_theme_option($name, $defa); $custom_options = get_post_meta($post_id, 'post_custom_options', true); if (isset($custom_options[$name]) && !in_array(themerex_strtolower($custom_options[$name]), $defaults)) { $rez = $custom_options[$name]; } else { $categories = getCategoriesByPostId($post_id); $tmp = ''; for ($cc = 0; $cc < count($categories) && $tmp == ''; $cc++) { $tmp = getCategoryInheritedProperty($categories[$cc]['term_id'], $name); } if ($tmp != '') { $rez = $tmp; } } } else { global $THEMEREX_post_options, $THEMEREX_cat_options, $THEMEREX_custom_options, $THEMEREX_shop_options; if (isset($THEMEREX_custom_options[$name])) { $rez = $THEMEREX_custom_options[$name]; } else { $rez = get_theme_option($name, $defa); if (is_woocommerce_page() && isset($THEMEREX_shop_options[$name]) && !in_array(themerex_strtolower(is_array($THEMEREX_shop_options[$name]) ? $THEMEREX_shop_options[$name][0] : $THEMEREX_shop_options[$name]), $defaults)) { $rez = is_array($THEMEREX_shop_options[$name]) ? $THEMEREX_shop_options[$name][0] : $THEMEREX_shop_options[$name]; } if (!is_single() && isset($THEMEREX_post_options[$name]) && !in_array(themerex_strtolower(is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name]), $defaults)) { $rez = is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name]; } if (isset($THEMEREX_cat_options[$name]) && !in_array(themerex_strtolower($THEMEREX_cat_options[$name]), $defaults)) { $rez = $THEMEREX_cat_options[$name]; } if (is_single() && isset($THEMEREX_post_options[$name]) && !in_array(themerex_strtolower(is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name]), $defaults)) { $rez = is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name]; } if (get_theme_option('show_theme_customizer') == 'yes') { $tmp = getValueGPC($name, $rez); if (!in_array(themerex_strtolower($tmp), $defaults)) { $rez = $tmp; } } $THEMEREX_custom_options[$name] = $rez; } } } return $rez; }
$THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true); } else { if (is_404() && ($page_id = getTemplatePageId('404')) > 0) { $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true); } else { if (function_exists('is_bbpress') && is_bbpress() && ($page_id = getTemplatePageId('bbpress')) > 0) { $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true); } else { if (function_exists('is_buddypress') && is_buddypress() && ($page_id = getTemplatePageId('buddypress')) > 0) { $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true); } else { if (is_single() || is_page() || is_singular() || $wp_query->is_posts_page == 1) { // Current post custom options $page_id = is_single() || is_page() ? get_the_ID() : (isset($wp_query->queried_object_id) ? $wp_query->queried_object_id : getTemplatePageId('template-blog')); $THEMEREX_post_options = get_post_meta($page_id, 'post_custom_options', true); $THEMEREX_cat_options = getCategoriesInheritedProperties(getCategoriesByPostId($page_id)); } } } } } } } // Reject old browsers support global $THEMEREX_jreject; $THEMEREX_jreject = false; if (!isset($_COOKIE['jreject'])) { wp_enqueue_style('jquery_reject-style', get_template_directory_uri() . '/js/jreject/css/jquery.reject.css', array(), null); wp_enqueue_script('jquery_reject', get_template_directory_uri() . '/js/jreject/jquery.reject.js', array('jquery'), null, true); setcookie('jreject', 1, 0, '/'); $THEMEREX_jreject = true;
} 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']); $recent['post_accent_category'] = count($recent['categories']) > 0 ? $recent['categories'][0]['name'] : ''; $show_content_block = !in_array($recent['post_format'], array('link', 'image')) || !$recent['post_thumb']; $puzzles_style = get_custom_option('puzzles_style'); $no_thumb = in_array($recent['post_format'], array('quote', 'link', 'image')) || !$recent['post_thumb'] && (!$recent['post_gallery'] || $recent['post_protected']); ?> <div class="related_posts_item related_post_item_<?php echo $i; ?> post_format_<?php echo $recent['post_format']; ?> <?php
function showBreadcrumbs($args = array()) { global $wp_query, $post; $args = array_merge(array('home' => '', 'home_url' => '', 'show_all_filters' => true, 'show_all_posts' => true, 'truncate_title' => 0, 'truncate_add' => '...', 'echo' => true), is_array($args) ? $args : array('home' => $args)); $rez = ''; $rez2 = ''; $rez_all = ''; $type = getBlogType(); $title = getShortString(getBlogTitle(), $args['truncate_title'], $args['truncate_add']); $cat = ''; $parentTax = ''; if (!in_array($type, array('home', 'frontpage'))) { $need_reset = true; $parent = 0; $post_id = 0; if ($type == 'page' || $type == 'attachment') { $pageParentID = isset($wp_query->post->post_parent) ? $wp_query->post->post_parent : 0; $post_id = $type == 'page' ? isset($wp_query->post->ID) ? $wp_query->post->ID : 0 : $pageParentID; while ($pageParentID > 0) { $pageParent = get_post($pageParentID); $rez2 = '<li class="cat_post"><a href="' . get_permalink($pageParent->ID) . '">' . getShortString($pageParent->post_title, $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2; if (($pageParentID = $pageParent->post_parent) > 0) { $page_id = $pageParentID; } } } else { if ($type == 'single') { $post_id = isset($wp_query->post->ID) ? $wp_query->post->ID : 0; } } $depth = 0; $ex_cats = explode(',', get_theme_option('exclude_cats')); $taxonomy = themerex_strpos($type, 'woocommerce') !== false ? array('product_cat') : array('category'); do { if ($depth++ == 0) { if (in_array($type, array('single', 'attachment', 'woocommerce_product'))) { if ($type != 'woocommerce_product' && $args['show_all_filters']) { $post_format = get_post_format($post_id); if (($tpl_id = getTemplatePageId('only-' . $post_format)) > 0) { $rez_all .= '<li class="all"><a href="' . get_permalink($tpl_id) . '">' . sprintf(__('All %s', 'themerex'), getPostFormatName($post_format, false)) . '</a></li>'; } } $cats = getCategoriesByPostId($post_id, $taxonomy); $cat = $cats ? $cats[0] : false; if ($cat) { if (!in_array($cat['term_id'], $ex_cats)) { $cat_link = get_term_link($cat['slug'], $cat['taxonomy']); $rez2 = '<li class="cat_post"><a href="' . $cat_link . '">' . getShortString($cat['name'], $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2; } } else { $post_type = get_post_type($post_id); $parentTax = 'category' . ($post_type == 'post' ? '' : '_' . $post_type); } } else { if ($type == 'category') { $cat = get_term_by('id', get_query_var('cat'), 'category', ARRAY_A); } else { if (themerex_strpos($type, 'woocommerce') !== false) { if (is_product_category()) { $cat = get_term_by('slug', get_query_var('product_cat'), 'product_cat', ARRAY_A); } } } } if ($cat) { $parent = $cat['parent']; $parentTax = $cat['taxonomy']; } } if ($parent) { $cat = get_term_by('id', $parent, $parentTax, ARRAY_A); if ($cat) { if (!in_array($cat['term_id'], $ex_cats)) { $cat_link = get_term_link($cat['slug'], $cat['taxonomy']); $rez2 = '<li class="cat_parent"><a href="' . $cat_link . '">' . getShortString($cat['name'], $args['truncate_title'], $args['truncate_add']) . '</a></li>' . $rez2; } $parent = $cat['parent']; } } } while ($parent); if (themerex_strpos($type, 'woocommerce') !== false && !in_array(themerex_strtolower($title), array('shop')) && ($shop_id = get_option('woocommerce_shop_page_id')) > 0) { $rez_all = '<li class="all"><a href="' . get_permalink($shop_id) . '">' . __('Shop', 'themerex') . '</a></li>' . $rez_all; } if ($args['show_all_posts'] && !in_array(themerex_strtolower($title), array('all posts')) && ($blog_id = getTemplatePageId('template-blog')) > 0) { $rez_all = '<li class="all"><a href="' . get_permalink($blog_id) . '">' . __('All Posts', 'themerex') . '</a></li>' . $rez_all; } $rez3 = ''; if (themerex_strpos($type, 'woocommerce') === false && is_archive() && is_object($post)) { $year = get_the_time('Y'); $month = get_the_time('m'); if (is_day() || is_month()) { $rez3 .= '<li class="cat_parent"><a href="' . get_year_link($year) . '">' . $year . '</a></li>'; } if (is_day()) { $rez3 .= '<li class="cat_parent"><a href="' . get_month_link($year, $month) . '">' . prepareDateForTranslation(get_the_date('F')) . '</a></li>'; } } if (!is_front_page()) { // && !is_home() $rez .= '<ul class="breadcrumbs">' . (isset($args['home']) && $args['home'] != '' ? '<li class="home"><a href="' . ($args['home_url'] ? $args['home_url'] : home_url()) . '">' . $args['home'] . '</a></li>' : '') . $rez_all . $rez2 . $rez3 . ($title ? '<li class="current">' . $title . '</li>' : '') . '</ul>'; } } if ($args['echo'] && !empty($rez)) { echo $rez; } return $rez; }
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; }
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 }
function get_custom_option($name, $defa = null, $post_id = 0, $cat_id = 0) { if (isset($_GET[$name])) { $rez = $_GET[$name]; } else { if ($cat_id > 0) { $rez = get_category_inherited_property($cat_id, $name); if ($rez == '') { $rez = get_theme_option($name, $defa); } } else { if ($post_id > 0) { $rez = get_theme_option($name, $defa); $custom_options = get_post_meta($post_id, 'post_custom_options', true); if (isset($custom_options[$name]) && !is_inherit_option($custom_options[$name])) { $rez = $custom_options[$name]; } else { if (is_category()) { $categories = array(); $categories[] = get_queried_object(); } else { $categories = getCategoriesByPostId($post_id); } $tmp = ''; for ($cc = 0; $cc < count($categories) && (empty($tmp) || is_inherit_option($tmp)); $cc++) { $tmp = get_category_inherited_property(is_object($categories[$cc]) ? $categories[$cc]->term_id : $categories[$cc]['term_id'], $name); } if ($tmp != '') { $rez = $tmp; } } } else { global $THEMEREX_post_options, $THEMEREX_cat_options, $THEMEREX_custom_options, $THEMEREX_shop_options; if (isset($THEMEREX_custom_options[$name])) { $rez = $THEMEREX_custom_options[$name]; } else { $rez = get_theme_option($name, $defa); if (is_woocommerce_page() && isset($THEMEREX_shop_options[$name]) && !is_inherit_option($THEMEREX_shop_options[$name])) { $rez = is_array($THEMEREX_shop_options[$name]) ? $THEMEREX_shop_options[$name][0] : $THEMEREX_shop_options[$name]; } if (!is_single() && isset($THEMEREX_post_options[$name]) && !is_inherit_option($THEMEREX_post_options[$name])) { $rez = is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name]; } if (isset($THEMEREX_cat_options[$name]) && !is_inherit_option($THEMEREX_cat_options[$name])) { $rez = $THEMEREX_cat_options[$name]; } if (is_single() && isset($THEMEREX_post_options[$name]) && !is_inherit_option($THEMEREX_post_options[$name])) { $rez = is_array($THEMEREX_post_options[$name]) ? $THEMEREX_post_options[$name][0] : $THEMEREX_post_options[$name]; } if (get_theme_option('show_theme_customizer') == 'yes') { $tmp = getValueGPC($name, $rez); if (!is_inherit_option($tmp)) { $rez = $tmp; } } $THEMEREX_custom_options[$name] = $rez; } } } } return $rez; }
function themerex_callback_view_more_posts() { global $_REQUEST, $post, $wp_query; if (!wp_verify_nonce($_REQUEST['nonce'], 'ajax_nonce')) { die; } $response = array('error' => '', 'data' => '', 'no_more_data' => 0); $page = $_REQUEST['page']; $args = unserialize(stripslashes($_REQUEST['data'])); $vars = unserialize(stripslashes($_REQUEST['vars'])); if ($page > 0 && is_array($args) && is_array($vars)) { extract($vars); $args['page'] = $page; $args['paged'] = $page; $args['ignore_sticky_posts'] = 1; $args['posts_per_page'] = $vars['ppp']; if (!isset($wp_query)) { $wp_query = new WP_Query($args); } else { query_posts($args); } $per_page = count($wp_query->posts); $response['no_more_data'] = $page >= $wp_query->max_num_pages; //$per_page < $ppp; $post_number = 0; $accent_color = ''; $response['data'] = ''; $post_cats = array(); while (have_posts()) { the_post(); $post_number++; $post_data = getPostData(array('thumb_size' => $blog_style, 'parent_cat_id' => $parent_cat_id, 'sidebar' => !in_array($show_sidebar_main, array('none', 'fullwidth')), 'accent_color' => $accent_color, 'thumb_size' => $thumb_size)); $post_id = $post_data['post_id']; $terms = getCategoriesByPostId($post_id); if (count($terms) != 0) { foreach ($terms as $term) { $post_cats[$term['term_id']] = $term['name']; } } $accent_color = $post_data['post_accent_color']; $response['data'] .= showPostLayout(array('layout' => $blog_style, 'show' => false, 'number' => $post_number, 'add_view_more' => true, 'posts_on_page' => $per_page, 'thumb_size' => $thumb_size, 'thumb_size' => $thumb_size, 'excerpt_length' => $excerpt_length, 'sidebar' => !in_array($show_sidebar_main, array('none', 'fullwidth')), 'iso_columns' => $iso_columns), $post_data); } $response['cats'] = $post_cats; } else { $response['error'] = __('Wrong query arguments', 'themerex'); } echo json_encode($response); die; }
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; }
/** * 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; } }
} } } 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++) { if (in_array($post_categories[$i]['term_id'], $ex_cats)) { continue; } if ($post_accent_category == '') { if (get_theme_option('close_category') == 'parental') { $parent_cat = getParentCategory($post_categories[$i]['term_id'], $parent_cat_id); if ($parent_cat) { $post_accent_category = $parent_cat['name']; if ($post_accent_color == '' && $parent_cat_id == 0) { $post_accent_color = getCategoryInheritedProperty($parent_cat['term_id'], 'theme_accent_color');
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; }
function getPostData(&$opt, $post_obj = null) { $opt = getPostDataOptions($opt); if (empty($opt['layout'])) { $opt['layout'] = !empty($opt['thumb_size']) ? $opt['thumb_size'] : 'excerpt'; } global $post, $wp_query; $old_post = null; if (!empty($post) && is_object($post)) { $old_post = clone $post; } if ($post_obj != null) { $post = $post_obj; setup_postdata($post); } $cur_post = clone $post; $post_id = get_the_ID(); $post_protected = post_password_required(); $post_format = get_post_format(); if (empty($post_format)) { $post_format = 'standard'; } $post_icon = getPostFormatIcon($post_format); $post_type = get_post_type(); $post_flags = array('sticky' => is_sticky()); $post_link = get_permalink(); $post_comments_link = get_comments_link(); $post_date_sql = get_the_date('Y-m-d H:i:s'); $post_date_stamp = get_the_date('U'); $post_date = getDateOrDifference($post_date_sql); if (!empty($opt['date_format'])) { $parts = explode('+', $opt['date_format']); $post_date_part1 = empty($parts[0]) ? '' : date($parts[0], $post_date_stamp); $post_date_part2 = empty($parts[1]) ? '' : date($parts[1], $post_date_stamp); if ($post_date_part1 . $post_date_part2 != '') { $post_date = $post_date_part1 . ($post_date_part2 != '' ? ' ' . $post_date_part2 : ''); } $post_date_part1 = get_the_date('j M'); } $post_comments = $post_views = $post_likes = 0; if ($opt['counters'] != 'none') { $post_comments = get_comments_number(); $post_views = getPostViews($post_id); $post_likes = getPostLikes($post_id); } $post_reviews_author = $post_reviews_users = 0; if ($opt['reviews']) { $post_reviews_author = ''; $post_reviews_users = ''; } $post_author = get_the_author(); $post_author_id = get_the_author_meta('ID'); $post_author_url = get_author_posts_url($post_author_id, ''); // Is user can edit and/or delete this post? $allow_editor = get_theme_option("allow_editor") == 'yes'; $post_edit_enable = $allow_editor && ($post_type == 'post' && current_user_can('edit_posts', $post_id) || $post_type == 'page' && current_user_can('edit_pages', $post_id)); $post_delete_enable = $allow_editor && ($post_type == 'post' && current_user_can('delete_posts', $post_id) || $post_type == 'page' && current_user_can('delete_pages', $post_id)); // Post content global $more; $old_more = $more; $more = -1; $post_content_original = trim(chop($post->post_content)); $post_content_plain = trim(chop(get_the_content())); $more = $old_more; $post_content = trim(chop(get_the_content($opt['more_tag'], $opt['strip_teaser']))); // Substitute WP [gallery] shortcode $thumb_sizes = getThumbSizes(array('thumb_size' => $opt['thumb_size'], 'thumb_crop' => $opt['thumb_crop'], 'sidebar' => $opt['sidebar'])); if ($opt['content']) { if ($opt['substitute_gallery']) { $post_content = substituteGallery($post_content, $post_id, $thumb_sizes['w'], $thumb_sizes['h_crop'], 'none', true); } $post_content = apply_filters('the_content', $post_content); if ($post_id != get_the_ID()) { // Fix bug in the WPML $post = $cur_post; setup_postdata($post); } if ($opt['substitute_video']) { $post_content = substituteVideo($post_content, $thumb_sizes['w'], $thumb_sizes['h_crop']); } if ($opt['substitute_audio']) { $post_content = substituteAudio($post_content); } } // Post excerpt $post_excerpt_original = $post->post_excerpt; $post_excerpt = has_excerpt() || $post_protected ? get_the_excerpt() : ''; if (empty($post_excerpt)) { if (($more_pos = themerex_strpos($post_content_plain, '<span id="more-')) !== false) { $post_excerpt = themerex_substr($post_content_plain, 0, $more_pos); } else { $post_excerpt = in_array($post_format, array('quote', 'link')) ? $post_content : strip_shortcodes(strip_tags(get_the_excerpt())); } } if ($opt['substitute_gallery']) { $post_excerpt = substituteGallery($post_excerpt, $post_id, $thumb_sizes['w'], $thumb_sizes['h_crop']); } $post_excerpt = apply_filters('themerex_sc_clear_around', $post_excerpt); $post_excerpt = apply_filters('the_excerpt', $post_excerpt); $post_excerpt = apply_filters('themerex_p_clear_around', $post_excerpt); if ($post_id != get_the_ID()) { // Fix bug in the WPML $post = $cur_post; setup_postdata($post); } if ($opt['substitute_video']) { $post_excerpt = substituteVideo($post_excerpt, $thumb_sizes['w'], $thumb_sizes['h_crop']); } if ($opt['substitute_audio']) { $post_excerpt = substituteAudio($post_excerpt); } $post_excerpt = trim(chop(str_replace(array('[...]', '[…]'), array('', ''), $post_excerpt))); // Post Title $post_title = $post_title_plain = trim(chop(get_the_title())); $post_title = apply_filters('the_title', $post_title); if ($post_id != get_the_ID()) { // Fix bug in the WPML $post = $cur_post; setup_postdata($post); } // Prepare dedicated content $opt['dedicated'] = get_dedicated_content(); //$opt['location'] = !empty($opt['location']) ? $opt['location'] : get_custom_option('dedicated_location'); $opt['location'] = !empty($opt['location']) ? $opt['location'] : 'left'; if (empty($opt['location']) || $opt['location'] == 'default') { $opt['location'] = get_custom_option('dedicated_location', '', $post_id); } if ($opt['location'] == 'alter' && !is_single() && (!is_page() || isset($wp_query->is_posts_page) && $wp_query->is_posts_page == 1)) { $loc = array('center', 'right', 'left'); $opt['location'] = $loc[($opt['number'] - 1) % count($loc)]; } if (!empty($opt['dedicated'])) { $class = getTagAttrib($opt['dedicated'], '<div class="sc_section>', 'class'); if ($opt['location'] == 'default') { if (($pos = themerex_strpos($class, 'sc_align')) !== false) { $pos += 8; $pos2 = themerex_strpos($class, ' ', $pos); $opt['location'] = $pos2 === false ? themerex_substr($class, $pos) : themerex_substr($class, $pos, $pos2 - $pos); } if ($opt['location'] == '' || $opt['location'] == 'default') { $opt['location'] = 'center'; } } if (!is_singular() || in_shortcode_blogger(true) || themerex_strpos($class, 'sc_align') !== false && themerex_strpos($class, 'columns') === false) { $class = str_replace(array('sc_alignright', 'sc_alignleft', 'sc_aligncenter'), array('', '', ''), $class) . ' sc_align' . $opt['location']; if ($opt['location'] == 'center' && themerex_strpos($class, 'columns2_3') === false && $opt['sidebar']) { $class = str_replace('columns', '_columns', $class) . ' columns2_3'; } else { if (($opt['location'] == 'left' || $opt['location'] == 'right') && themerex_strpos($class, 'columns1_2') === false) { // && $opt['sidebar']) $class = str_replace('columns', '_columns', $class) . ' columns1_2'; } } $opt['dedicated'] = setTagAttrib($opt['dedicated'], '<div class="sc_section>', 'class', $class); } } //else if ($opt['location']=='' || $opt['location']=='default') //$opt['location'] = 'center'; //if ($opt['location']=='default') $opt['location']='center'; $opt['post_class'] = themerex_strtoproper($opt['location']); // Substitute <video> tags to <iframe> in dedicated content if ($opt['substitute_video']) { $opt['dedicated'] = substituteVideo($opt['dedicated'], $thumb_sizes['w'], $thumb_sizes['h_crop']); } // Substitute <audio> tags with src from soundcloud to <iframe> if ($opt['substitute_audio']) { $opt['dedicated'] = substituteAudio($opt['dedicated']); } // Extract gallery, video and audio from full post content $post_thumb = $post_attachment = $post_gallery = $post_video = $post_audio = $post_url = $post_url_target = ''; if (themerex_substr($opt['layout'], 0, 6) == 'single') { $post_thumb = getResizedImageTag($post_id, $thumb_sizes['w'], $thumb_sizes['h'], null, false, false, true); } else { $post_thumb = getResizedImageTag($post_id, $thumb_sizes['w'], $post_type == 'product' && get_theme_option('crop_product_thumb') == 'no' ? null : $thumb_sizes['h']); } $post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id)); if ($post_format == 'gallery') { $post_gallery = buildGalleryTag(getPostGallery($post_content_plain, $post_id, max(2, get_custom_option('gallery_max_slides'))), $thumb_sizes['w'], $thumb_sizes['h_crop'], false, get_custom_option('substitute_slider_engine') != 'flex' ? '' : $post_link); } else { if ($post_format == 'video') { $post_video = getPostVideo($post_content_original, false); if ($post_video == '') { $src = getVideoPlayerURL(getPostVideo($post_content_original, true), $post_thumb != ''); if ($src) { $post_video = substituteVideo('<video src="' . $src . '">', $thumb_sizes['w'], round($thumb_sizes['w'] / 16 * 9), false); } //$thumb_sizes['h_crop']); } if ($post_video != '' && $opt['substitute_video']) { $src = getVideoPlayerURL(getPostVideo($post_video), $post_thumb != ''); if ($src) { $post_video = substituteVideo('<video src="' . $src . '">', $thumb_sizes['w'], round($thumb_sizes['w'] / 16 * 9), false); } //$thumb_sizes['h_crop']); } } else { if ($post_format == 'audio') { $post_audio = getPostAudio($post_content_original, false); if ($post_audio == '') { $src = getPostAudio($post_content_original, true); if ($src) { $post_audio = substituteAudio('<audio src="' . $src . '"></audio>'); } } if ($post_audio != '' && $opt['substitute_audio'] == 'yes') { $src = getPostAudio($post_audio); $tag_t = getTagAttrib($post_audio, '[trx_audio]', 'title'); $tag_t = $tag_t == '' ? getTagAttrib($post_audio, '[audio]', 'title') : $tag_t; $tag_at = getTagAttrib($post_audio, '[trx_audio]', 'author'); $tag_at = $tag_at == '' ? getTagAttrib($post_audio, '[audio]', 'author') : $tag_at; if ($src) { $post_audio = substituteAudio('<audio title="' . $tag_t . '" author="' . $tag_at . '" src="' . $src . '"></audio>'); } } } } } if ($post_format == 'image' && !$post_thumb) { if (($src = getPostImage($post_content_original)) != '') { $post_thumb = getResizedImageTag($src, $thumb_sizes['w'], $thumb_sizes['h_crop']); } } if ($post_format == 'link') { $post_url_data = getPostLink($post_content_original, false); $post_link = $post_url = $post_url_data['url']; $post_url_target = $post_url_data['target']; } // Get all post's categories $post_categories_list = array(); $post_categories_ids = array(); $post_categories_slugs = array(); $post_categories_links = ''; $post_root_category = ''; if ($opt['categories_list']) { $post_categories_list = getCategoriesByPostId($post_id); $ex_cats = explode(',', get_theme_option('exclude_cats')); for ($i = 0; $i < count($post_categories_list); $i++) { if (in_array($post_categories_list[$i]['term_id'], $ex_cats)) { continue; } if ($post_root_category == '') { if (get_theme_option('close_category') == 'parental') { $parent_cat = getParentCategory($post_categories_list[$i]['term_id'], $opt['parent_cat_id']); if ($parent_cat) { $post_root_category = $parent_cat['name']; } } else { $post_root_category = $post_categories_list[$i]['name']; } } $post_categories_ids[] = $post_categories_list[$i]['term_id']; $post_categories_slugs[] = $post_categories_list[$i]['slug']; $post_categories_links .= '<a class="cat_link" href="' . $post_categories_list[$i]['link'] . '">' . $post_categories_list[$i]['name'] . ($i < count($post_categories_list) - 1 ? ',' : '') . '</a> '; } if ($post_root_category == '' && count($post_categories_list) > 0) { $post_root_category = $post_categories_list[0]['name']; } } // Get all post's tags $post_tags_list = array(); $post_tags_ids = array(); $post_tags_slugs = array(); $post_tags_links = ''; if ($opt['tags_list']) { if (($post_tags_list = get_the_tags()) != 0) { $tag_number = 0; foreach ($post_tags_list as $tag) { $tag_number++; $post_tags_links .= '<a class="tag_link" href="' . get_tag_link($tag->term_id) . '">' . $tag->name . ($tag_number == count($post_tags_list) ? '' : ',') . '</a> '; $post_tags_ids[] = $tag->term_id; $post_tags_slugs[] = $tag->slug; } } else { if (!is_array($post_tags_list)) { $post_tags_list = array(); } } } if ($old_post != null) { $post = $old_post; setup_postdata($post); } $post_data = compact('post_id', 'post_protected', 'post_type', 'post_format', 'post_flags', 'post_icon', 'post_link', 'post_comments_link', 'post_date_sql', 'post_date_stamp', 'post_date', 'post_date_part1', 'post_date_part2', 'post_comments', 'post_views', 'post_likes', 'post_reviews_author', 'post_reviews_users', 'post_author', 'post_author_id', 'post_author_url', 'post_title', 'post_title_plain', 'post_content_plain', 'post_content_original', 'post_content', 'post_excerpt_original', 'post_excerpt', 'post_thumb', 'post_attachment', 'post_gallery', 'post_video', 'post_audio', 'post_url', 'post_url_target', 'post_categories_list', 'post_categories_slugs', 'post_categories_ids', 'post_categories_links', 'post_root_category', 'post_tags_list', 'post_tags_ids', 'post_tags_slugs', 'post_tags_links', 'post_edit_enable', 'post_delete_enable'); return apply_filters('themerex_get_post_data', $post_data, $opt, $post_obj); }