Пример #1
0
 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;
 }
Пример #2
0
							<div class="post_reviews theme_<?php 
        echo get_custom_option('sidebar_main_theme');
        ?>
">
								<?php 
        $output = $marks = $users = '';
        if ($use_tabs) {
            $author_tab = '<li><a href="#reviews_author" class="theme_button">' . __('Author', 'themerex') . '</a></li>';
            $users_tab = '<li><a href="#reviews_users" class="theme_button">' . __('Users', 'themerex') . '</a></li>';
            $output .= '<ul class="tabs theme_field">' . ($reviews_first_author ? $author_tab . $users_tab : $users_tab . $author_tab) . '</ul>';
        }
        $field = array("options" => get_theme_option('reviews_criterias'));
        if (count($post_categories) > 0) {
            foreach ($post_categories as $cat) {
                $id = (int) $cat['term_id'];
                $prop = getCategoryInheritedProperty($id, 'reviews_criterias');
                if (!empty($prop) && $prop != 'default' && themerex_substr(trim($prop), 0, 1) != '|') {
                    $field['options'] = $prop;
                    break;
                }
            }
        }
        if ($reviews_first_author || !$reviews_second_hide) {
            $output .= '<div id="reviews_author" class="reviews_tab reviews_author">';
            $field["id"] = "reviews_marks_author";
            $field["descr"] = $post_descr;
            $marks = marksToDisplay(get_custom_option('reviews_marks'));
            $output .= getReviewsMarkup($field, $marks, false, $reviews_first_author);
            $output .= '</div>';
        }
        if (!$reviews_first_author || !$reviews_second_hide) {
Пример #3
0
                $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> ';
}
if ($post_accent_category == '' && count($post_categories) > 0) {
    $post_accent_category = $post_categories[0]['name'];
    if ($post_accent_color == '' && $parent_cat_id == 0) {
        $post_accent_color = getCategoryInheritedProperty($post_categories[0]['term_id'], 'theme_accent_color');
    }
}
// Get all post's tags
$post_tags_str = '';
if (($post_tags = get_the_tags()) != 0) {
    $tag_number = 0;
    foreach ($post_tags as $tag) {
        $tag_number++;
        $post_tags_str .= '<a class="tag_link" href="' . get_tag_link($tag->term_id) . '">' . $tag->name . ($tag_number == count($post_tags) ? '' : ',') . '</a> ';
    }
}
// Load teplate for current Blog Style
require get_template_directory() . '/template-blog-' . $blog_style . '.php';
Пример #4
0
function prepareThemeCustomStyles()
{
    // Custom font
    $fonts = getThemeFontsList(false);
    $font = get_custom_option('theme_font');
    if (isset($fonts[$font])) {
        addThemeCustomStyle("\n\t\t\tbody, button, input, select, textarea {\n\t\t\t\tfont-family: '" . $font . "', " . $fonts[$font]['family'] . ";\n\t\t\t}\n\t\t");
    }
    $font = get_custom_option('logo_font');
    if (isset($fonts[$font])) {
        addThemeCustomStyle("\n\t\t\t.logo_text .logo_title {\n\t\t\t\tfont-family: '" . $font . "', " . $fonts[$font]['family'] . ";\n\t\t\t}\n\t\t");
    }
    // Custom menu
    if (get_theme_option('menu_colored') == 'yes') {
        $menu_name = 'mainmenu';
        if (($locations = get_nav_menu_locations()) && isset($locations[$menu_name])) {
            $menu = wp_get_nav_menu_object($locations[$menu_name]);
            if (is_object($menu) && $menu) {
                $menu_items = wp_get_nav_menu_items($menu->term_id);
                $menu_styles = '';
                $menu_slider = get_theme_option('menu_slider') == 'yes';
                if (count($menu_items) > 0) {
                    foreach ($menu_items as $k => $item) {
                        //				if ($item->menu_item_parent==0) {
                        $cur_accent_color = '';
                        if ($item->type == 'taxonomy' && $item->object == 'category') {
                            $cur_accent_color = getCategoryInheritedProperty($item->object_id, 'theme_accent_color');
                        }
                        if ((empty($cur_accent_color) || $cur_accent_color == 'default') && isset($item->classes[0]) && !empty($item->classes[0])) {
                            $cur_accent_color = (themerex_substr($item->classes[0], 0, 1) != '#' ? '#' : '') . $item->classes[0];
                        }
                        if (!empty($cur_accent_color) && $cur_accent_color != 'default') {
                            $menu_styles .= ($item->menu_item_parent == 0 ? "#header_middle_inner #mainmenu li.menu-item-{$item->ID}.current-menu-item > a," : '') . "\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID} > a:hover,\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID}.sfHover > a {\n\t\t\t\t\t\t\t\t\t\tbackground-color: {$cur_accent_color} !important;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID} ul {\n\t\t\t\t\t\t\t\t\t\tbackground-color: {$cur_accent_color} !important;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t";
                        }
                        if ($menu_slider && $item->menu_item_parent == 0) {
                            $menu_styles .= "\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID}.blob_over:not(.current-menu-item) > a:hover,\n\t\t\t\t\t\t\t\t\t#header_middle_inner #mainmenu li.menu-item-{$item->ID}.blob_over.sfHover > a {\n\t\t\t\t\t\t\t\t\t\tbackground-color: transparent !important;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t";
                        }
                        //				}
                    }
                }
                if (!empty($menu_styles)) {
                    addThemeCustomStyle($menu_styles);
                }
            }
        }
    }
    // Main menu height
    $menu_height = (int) get_theme_option('menu_height');
    if ($menu_height > 20) {
        addThemeCustomStyle("\n\t\t\t#mainmenu > li > a {\n\t\t\t\theight: {$menu_height}px !important;\n\t\t\t\tline-height: {$menu_height}px !important;\n\t\t\t}\n\t\t\t#mainmenu > li ul {\n\t\t\t\ttop: {$menu_height}px !important;\n\t\t\t}\n\t\t\t#header_middle {\n\t\t\t\tmin-height: {$menu_height}px !important;\n\t\t\t}\n\t\t");
    }
    // Submenu width
    $menu_width = (int) get_theme_option('menu_width');
    if ($menu_width > 50) {
        addThemeCustomStyle("\n\t\t\t#mainmenu > li ul {\n\t\t\t\twidth: {$menu_width}px;\n\t\t\t}\n\t\t\t#mainmenu > li ul li ul {\n\t\t\t\tleft: " . ($menu_width + 1) . "px;\n\t\t\t}\n\t\t\t#mainmenu > li:nth-child(n+6) ul li ul {\n\t\t\t\tleft: -" . ($menu_width + 1) . "px;\n\t\t\t}\n\t\t");
    }
    // Custom css from theme options
    $css = get_custom_option('custom_css');
    if (!empty($css)) {
        addThemeCustomStyle($css);
    }
    return getThemeCustomStyles();
}
Пример #5
0
function sc_slider($atts, $content = null)
{
    extract(shortcode_atts(array("id" => "", "engine" => "flex", "links" => "0", "controls" => "0", "titles" => "0", "alias" => "", "ids" => "", "cat" => "", "count" => "0", "offset" => "", "orderby" => "date", "order" => 'desc', "width" => "", "height" => "", "align" => "", "border" => "0", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    $s = ($top !== '' ? 'margin-top:' . $top . 'px;' : '') . ($bottom !== '' ? 'margin-bottom:' . $bottom . 'px;' : '') . ($left !== '' ? 'margin-left:' . $left . 'px;' : '') . ($right !== '' ? 'margin-right:' . $right . 'px;' : '') . (!empty($width) ? 'width:' . $width . (themerex_strpos($width, '%') !== false ? '' : 'px') . ';' : '') . (!empty($height) ? 'height:' . $height . (themerex_strpos($height, '%') !== false ? '' : 'px') . ';' : '');
    $output = '<div' . ($id ? ' id="' . $id . '"' : '') . ' class="sc_slider' . ' sc_slider_' . $engine . ($controls > 0 ? ' sc_slider_controls' : '') . ($align != '' ? ' align' . $align : '') . ($border > 0 ? ' sc_slider_border' : '') . '"' . ($s != '' ? ' style="' . $s . '"' : '') . '>';
    if ($engine == 'revo') {
        if (is_plugin_active('revslider/revslider.php') && !empty($alias)) {
            $output .= do_shortcode('[rev_slider ' . $alias . ']');
        } else {
            $output = '';
        }
    } else {
        if ($engine == 'flex') {
            $output .= '<ul class="slides">';
            global $post;
            if (!empty($ids)) {
                $posts = explode(',', $ids);
                $count = count($posts);
            }
            $args = array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc');
            if ($offset > 0 && empty($ids)) {
                $args['offset'] = $offset;
            }
            $args = addSortOrderInQuery($args, $orderby, $order, true);
            $args = addPostsAndCatsInQuery($args, $ids, $cat);
            $query = new WP_Query($args);
            while ($query->have_posts()) {
                $query->the_post();
                $post_id = get_the_ID();
                $post_link = get_permalink();
                $post_attachment = wp_get_attachment_url(get_post_thumbnail_id($post_id));
                $post_accent_color = '';
                $post_accent_category = '';
                $post_title = getPostTitle($post_id);
                $output .= '<li style="background-image:url(' . $post_attachment . ')">' . ($links > 0 ? '<a href="' . $post_attachment . '" title="' . htmlspecialchars($post_title) . '">' : '');
                if ($titles) {
                    $post_hover_bg = get_custom_option('puzzles_post_bg', null, $post_id);
                    $post_bg = '';
                    if ($post_hover_bg != '' && $post_hover_bg != 'default') {
                        $rgb = Hex2RGB($post_hover_bg);
                        $post_hover_ie = str_replace('#', '', $post_hover_bg);
                        $post_bg = "background-color: rgba({$rgb['r']},{$rgb['g']},{$rgb['b']},0.8);";
                    }
                    $output .= '<div class="sc_slider_info' . ($titles > 1 ? ' sc_slider_info_fixed' : '') . ' theme_accent_bg"' . ($post_bg != '' ? ' style="' . $post_bg . '"' : '') . '>';
                    $post_descr = getPostDescription();
                    if (get_custom_option("slider_info_category") == 'yes') {
                        // || empty($cat)) {
                        // Get all post's categories
                        $post_categories = getCategoriesByPostId($post_id);
                        $post_categories_str = '';
                        for ($i = 0; $i < count($post_categories); $i++) {
                            if ($post_accent_category == '') {
                                if (get_theme_option('close_category') == 'parental') {
                                    $parent_cat_id = 0;
                                    //(int) get_custom_option('category_id');
                                    $parent_cat = getParentCategory($post_categories[$i]['term_id'], $parent_cat_id);
                                    if ($parent_cat) {
                                        $post_accent_category = $parent_cat['name'];
                                        if ($post_accent_color == '') {
                                            $post_accent_color = getCategoryInheritedProperty($parent_cat['term_id'], 'theme_accent_color');
                                        }
                                    }
                                } else {
                                    $post_accent_category = $post_categories[$i]['name'];
                                    if ($post_accent_color == '') {
                                        $post_accent_color = getCategoryInheritedProperty($post_categories[$i]['term_id'], 'theme_accent_color');
                                    }
                                }
                            }
                            if ($post_accent_category != '' && $post_accent_color != '') {
                                break;
                            }
                        }
                        if ($post_accent_category == '' && count($post_categories) > 0) {
                            $post_accent_category = $post_categories[0]['name'];
                            if ($post_accent_color == '') {
                                $post_accent_color = getCategoryInheritedProperty($post_categories[0]['term_id'], 'theme_accent_color');
                            }
                        }
                        if ($post_accent_category != '') {
                            $output .= '<div class="sc_slider_category theme_accent_bg"' . (themerex_substr($post_accent_color, 0, 1) == '#' ? ' style="background-color: ' . $post_accent_color . '"' : '') . '>' . $post_accent_category . '</div>';
                        }
                    }
                    $output_reviews = '';
                    if (get_custom_option('show_reviews') == 'yes' && get_custom_option('slider_reviews') == 'yes') {
                        $avg_author = marksToDisplay(get_post_meta($post_id, 'reviews_avg' . (get_theme_option('reviews_first') == 'author' && $orderby != 'users_rating' || $orderby == 'author_rating' ? '' : '2'), true));
                        if ($avg_author > 0) {
                            $output_reviews .= '<div class="sc_slider_reviews reviews_summary blog_reviews' . (get_custom_option("slider_info_category") == 'yes' ? ' after_category' : '') . '">' . '<div class="criteria_summary criteria_row">' . getReviewsSummaryStars($avg_author) . '</div>' . '</div>';
                        }
                    }
                    if (get_custom_option("slider_info_category") == 'yes') {
                        $output .= $output_reviews;
                    }
                    $output .= '<h2 class="sc_slider_subtitle"><a href="' . $post_link . '">' . $post_title . '</a></h2>';
                    if (get_custom_option("slider_info_category") != 'yes') {
                        $output .= $output_reviews;
                    }
                    if (get_custom_option('slider_descriptions') == 'yes') {
                        $output .= '<div class="sc_slider_descr">' . $post_descr . '</div>';
                    }
                    $output .= '</div>';
                } else {
                    //$output .= '<a href="'. $post_link . '">'.$titles.'</a>';
                }
                $output .= ($links > 0 ? '</a>' : '') . '</li>';
            }
            wp_reset_postdata();
            $output .= '</ul>';
        } else {
            $output = '';
        }
    }
    $output .= !empty($output) ? '</div>' : '';
    return $output;
}