$sql = "SELECT catid FROM #__content WHERE id = " . $temp[0]; $database->setQuery($sql); return $database->loadResult(); } } $catId = getCategory(JRequest::getInt('id')); #------------------------- Ancestor Category IDs --------------------------# if ($catId && ($inheritStyle || $inheritLayout)) { function getParentCategory($id) { $database = JFactory::getDBO(); $sql = "SELECT parent_id\n FROM #__categories\n WHERE id = {$id}"; $database->setQuery($sql); return $database->loadResult(); } $parentCategory = getParentCategory($catId); function getAncestorCategories($id) { $database = JFactory::getDBO(); $sql = "SELECT b.id, b.title\n FROM #__categories a,\n #__categories b\n WHERE a.id = {$id}\n AND a.lft > b.lft\n AND a.rgt < b.rgt\n AND a.id <> b.id\n AND b.lft > 0"; $database->setQuery($sql); return $database->loadObjectList(); } } #--------------------------------- Alias ----------------------------------# if ($itemId) { $currentAlias = $app->getMenu()->getActive()->alias; } #------------------Extended Template Style Overrides------------------------# $styleOverride = new ConstructTemplateHelper(); $styleOverride->includeFile = array();
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 themerex_get_post_data_for_theme($post_data, $opt, $post_obj) { $post_data['post_accent_color'] = $opt['parent_cat_id'] > 0 ? empty($opt['accent_color']) ? get_category_inherited_property($opt['parent_cat_id'], 'theme_accent_color') : $opt['accent_color'] : ''; if ($post_data['post_accent_color'] == '') { $ex_cats = explode(',', get_theme_option('exclude_cats')); for ($i = 0; $i < count($post_data['post_categories_list']); $i++) { if (in_array($post_data['post_categories_list'][$i]['term_id'], $ex_cats)) { continue; } if (get_theme_option('close_category') == 'parental') { $parent_cat = getParentCategory($post_data['post_categories_list'][$i]['term_id'], $opt['parent_cat_id']); if ($parent_cat) { $post_data['post_accent_color'] = get_category_inherited_property($parent_cat['term_id'], 'theme_accent_color'); } } else { $post_data['post_accent_color'] = get_category_inherited_property($post_categories_list[$i]['term_id'], 'theme_accent_color'); } if ($post_data['post_accent_color'] != '') { break; } } } return $post_data; }
$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'); } } } else { $post_accent_category = $post_categories[$i]['name']; if ($post_accent_color == '' && $parent_cat_id == 0) { $post_accent_color = getCategoryInheritedProperty($post_categories[$i]['term_id'], 'theme_accent_color'); } } } $post_categories_str .= '<a class="cat_link" href="' . $post_categories[$i]['link'] . '">' . $post_categories[$i]['name'] . ($i < count($post_categories) - 1 ? ',' : '') . '</a> '; }
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; }
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 getProductCategory($product_id) { if (empty($product_id) or $product_id == 0 or $product_id == "") { return ""; } $sql = "SELECT tn.tid as id_category, v.name as base_category, td.name as category "; $sql .= "FROM term_node tn "; $sql .= "LEFT OUTER JOIN term_data td ON tn.tid = td.tid "; $sql .= "LEFT OUTER JOIN vocabulary v ON v.vid = td.vid "; $sql .= "WHERE nid={$product_id} "; $req = mysql_query($sql); $count = mysql_num_rows($req); $result = array(); if ($count > 0) { while ($res = mysql_fetch_array($req)) { $category_list = array(); $id_category = $res["id_category"]; $base_category = $res["base_category"]; $category = $res["category"]; $category_list[] = $category; while ($id_category != 0) { $parent_info = getParentCategory($id_category); $id_category = $parent_info["id_category"]; $category = $parent_info["title"]; if ($id_category != 0) { $category_list[] = $category; } } if (isset($base_category)) { $category_list[] = $base_category; $full_category = implode("/", array_reverse($category_list)); $result[] = $full_category; } } } return $result; }
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); }
<?php require_once "ApiLibrary.php"; //Checks if this is running from a request if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'GET') { //This checks to see if anything was passed into the parameter userName if (!isset($_GET['catId'])) { //handle error } else { $_catId = $_GET['catId']; echo getParentCategory($_catId); } }
/** * Генерирует путь для раздела в виде html */ function generateHtmlPath($node, $enableLast = false) { if ($enableLast) { $enableLastNode = true; } else { $enableLastNode = false; //$chNodes = $node->get_elements_by_tagname("UL"); //$enableLastNode = (sizeof($chNodes) > 0); } $category = getCategory($node); $parentCategory = getParentCategory($node); $path = iconv("UTF-8", "windows-1251", $parentCategory . $category); $tmp = explode("/", $path); $html = generateRootLink() . CATEGS_SEP; $path = INDEX_LINK; for ($i = 0; $i < sizeof($tmp) - 1; $i++) { $path .= validFileName(translitText($tmp[$i]), true) . "/"; $html .= "<a href=\"{$path}\">" . $tmp[$i] . "</a>" . CATEGS_SEP; } $i = sizeof($tmp) - 1; if ($enableLastNode) { $path .= validFileName(translitText($tmp[$i], true)); $html .= "<a href=\"{$path}\">" . $tmp[$i] . "</a>"; } else { $html .= $tmp[$i]; } return $html; }