$cb_qry = new WP_Query($cb_featured_qry); } else { global $wp_query; $cb_qry = $wp_query; } if (!isset($cb_category_color_style)) { $cb_category_color_style = NULL; } if ($cb_qry->have_posts()) { while ($cb_qry->have_posts()) { $cb_qry->the_post(); $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on'); $cb_cat_id = get_the_category($post->ID); $cb_post_id = $post->ID; $cb_post_format_icon = cb_post_format_check($cb_post_id); $cb_category_color = cb_get_cat_color($cb_post_id); if ($i % 2 == 0) { $cb_side = NULL; $cb_closer = true; echo '<div class="cb-double clearfix">'; } else { $cb_side = ' cb-last'; $cb_closer = false; } ?> <article id="post-<?php the_ID(); ?> " class="cb-blog-style-b clearfix<?php if (is_sticky()) {
function start_el(&$output, $object, $depth = 0, $args = array(), $id = 0) { $indent = $depth ? str_repeat("\t", $depth) : ''; $classes = empty($object->classes) ? array() : (array) $object->classes; $classes[] = 'menu-item-' . $object->ID; /** * Filter the CSS class(es) applied to a menu item's <li>. * * @since 3.0.0 * * @see wp_nav_menu() * * @param array $classes The CSS classes that are applied to the menu item's <li>. * @param object $item The current menu item. * @param array $args An array of wp_nav_menu() arguments. */ $class_names = join(' ', (array) apply_filters('nav_menu_css_class', array_filter($classes), $object, $args)); $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; /** * Filter the ID applied to a menu item's <li>. * * @since 3.0.1 * * @see wp_nav_menu() * * @param string $menu_id The ID that is applied to the menu item's <li>. * @param object $object The current menu item. * @param array $args An array of wp_nav_menu() arguments. */ $id = apply_filters('nav_menu_item_id', 'menu-item-' . $object->ID, $object, $args); $id = $id ? ' id="' . esc_attr($id) . '"' : ''; $output .= $indent . '<li' . $id . $class_names . '>'; $atts = array(); $atts['title'] = !empty($object->attr_title) ? $object->attr_title : ''; $atts['target'] = !empty($object->target) ? $object->target : ''; $atts['rel'] = !empty($object->xfn) ? $object->xfn : ''; $atts['href'] = !empty($object->url) ? $object->url : ''; /** * Filter the HTML attributes applied to a menu item's <a>. * * @since 3.6.0 * * @see wp_nav_menu() * * @param array $atts { * The HTML attributes applied to the menu item's <a>, empty strings are ignored. * * @type string $title Title attribute. * @type string $target Target attribute. * @type string $rel The rel attribute. * @type string $href The href attribute. * } * @param object $item The current menu item. * @param array $args An array of wp_nav_menu() arguments. */ $atts = apply_filters('nav_menu_link_attributes', $atts, $object, $args); $attributes = ''; foreach ($atts as $attr => $value) { if (!empty($value)) { $value = 'href' === $attr ? esc_url($value) : esc_attr($value); $attributes .= ' ' . $attr . '="' . $value . '"'; } } $cb_cat_menu = $object->cbmegamenu; if ($depth > 0) { $cb_ajax_onoff = ot_get_option('cb_ajax_mm', 'on'); if ($cb_ajax_onoff == 'on') { $attributes .= ' data-cb-c="' . $object->object_id . '" class="cb-c-l"'; } } if ($cb_cat_menu == NULL) { $cb_cat_menu = '2'; } $item_output = $args->before; $item_output .= '<a' . $attributes . '>'; $item_output .= $args->link_before . apply_filters('the_title', $object->title, $object->ID) . $args->link_after; $item_output .= '</a>'; $item_output .= $args->after; $output .= apply_filters('walker_nav_menu_start_el', $item_output, $object, $depth, $args); $cb_base_color = ot_get_option('cb_base_color', '#eb9812'); if (function_exists('get_tax_meta')) { $cb_color = get_tax_meta($object->object_id, 'cb_color_field_id'); } else { $cb_color = $cb_base_color; } $cb_output = $cb_posts = $cb_menu_featured = $cb_has_children = $cb_slider_output = NULL; $cb_current_type = $object->object; $cb_current_classes = $object->classes; if (in_array('cb-has-children', $cb_current_classes)) { $cb_has_children = ' cb-with-sub cb-pre-load'; } if (($cb_cat_menu == 1 || $cb_cat_menu == 4) && $object->menu_item_parent == '0') { $output .= '<div class="cb-big-menu">'; } if ($cb_cat_menu == 2 && $depth == 0 && $object->menu_item_parent == '0' && in_array('cb-has-children', $cb_current_classes)) { $output .= '<div class="cb-links-menu">'; } if ($cb_cat_menu == 3 && $object->menu_item_parent == '0') { $output .= '<div class="cb-mega-menu">'; } if ($cb_cat_menu == 1 && $object->menu_item_parent == '0') { $cb_cat_id = $object->object_id; if (function_exists('get_tax_meta')) { $cb_category_color = get_tax_meta($cb_cat_id, 'cb_color_field_id'); } else { $cb_category_color = NULL; } if ($cb_category_color == NULL || $cb_category_color == '#') { $cb_category_color = $cb_base_color; } $cb_cpt_output = cb_get_custom_post_types(); $cb_args_featured = array('cat' => $cb_cat_id, 'post_type' => $cb_cpt_output, 'post_status' => 'publish', 'posts_per_page' => 1, 'ignore_sticky_posts' => 1, 'meta_key' => 'cb_featured_post_menu', 'meta_value' => 'featured', 'meta_compare' => '=='); $cb_qry_featured = $cb_img = NULL; $cb_qry_featured = new WP_Query($cb_args_featured); $cb_featured_random_title = __('Featured', 'cubell'); if ($cb_qry_featured->post_count == 0) { $cb_qry_featured = NULL; $cb_args_featured = array('cat' => $cb_cat_id, 'post_type' => $cb_cpt_output, 'post_status' => 'publish', 'posts_per_page' => 1, 'ignore_sticky_posts' => 1, 'orderby' => 'rand'); $cb_qry_featured = new WP_Query($cb_args_featured); $cb_featured_random_title = __('Random', 'cubell'); } foreach ($cb_qry_featured->posts as $cb_post) { setup_postdata($cb_post); $cb_post_id = $cb_post->ID; $cb_img = cb_get_thumbnail('480', '240', $cb_post_id); $cb_permalink = get_permalink($cb_post_id); $cb_menu_featured .= ' <li class="cb-article clearfix"> <div class="cb-mask" style="background-color:' . $cb_category_color . ';">' . $cb_img . cb_review_ext_box($cb_post_id, $cb_category_color) . '</div> <div class="cb-meta"> <h2 class="h4"><a href="' . esc_url($cb_permalink) . '">' . $cb_post->post_title . '</a></h2> ' . cb_byline(true, $cb_post_id) . ' </div></li>'; } wp_reset_postdata(); if ($cb_has_children == NULL) { $cb_qry_amount = 6; $cb_big_recent = ' cb-recent-fw'; $cb_closer = '</div>'; } else { $cb_qry_amount = 3; $cb_big_recent = $cb_closer = NULL; } $cb_cpt_output = cb_get_custom_post_types(); $cb_args = array('cat' => $cb_cat_id, 'post_type' => $cb_cpt_output, 'post_status' => 'publish', 'posts_per_page' => $cb_qry_amount, 'ignore_sticky_posts' => 1, 'post__not_in' => array($cb_post_id)); $cb_qry_latest = $cb_img = NULL; $cb_qry_latest = new WP_Query($cb_args); $i = 1; while ($cb_qry_latest->have_posts()) { $cb_qry_latest->the_post(); $cb_post_id = get_the_ID(); $cb_post_title = get_the_title(); $cb_img = cb_get_thumbnail('80', '60', $cb_post_id); $cb_permalink = get_permalink($cb_post_id); $cb_posts .= ' <li class="cb-article-' . $i . ' clearfix"> <div class="cb-mask" style="background-color:' . $cb_category_color . ';">' . $cb_img . cb_review_ext_box($cb_post_id, $cb_category_color, true) . '</div> <div class="cb-meta"> <h2 class="h4"><a href="' . esc_url($cb_permalink) . '">' . $cb_post_title . '</a></h2> ' . cb_byline(false, $cb_post_id, true) . ' </div></li>'; $i++; } wp_reset_postdata(); } if ($cb_cat_menu == 4 && $object->menu_item_parent == '0') { $cb_cpt_output = cb_get_custom_post_types(); $cb_cat_id = $object->object_id; if (function_exists('get_tax_meta')) { $cb_category_color = get_tax_meta($cb_cat_id, 'cb_color_field_id'); } else { $cb_category_color = NULL; } if ($cb_has_children != NULL) { $cb_slider_type = 'flexslider-1-menu'; $cb_args_featured = array('cat' => $cb_cat_id, 'post_type' => $cb_cpt_output, 'post_status' => 'publish', 'posts_per_page' => 9, 'ignore_sticky_posts' => 1); } else { $cb_args_featured = array('cat' => $cb_cat_id, 'post_type' => $cb_cpt_output, 'post_status' => 'publish', 'posts_per_page' => 12, 'ignore_sticky_posts' => 1); $cb_slider_type = 'flexslider-1-fw-menu'; } $cb_qry_featured = $cb_img = NULL; $cb_qry_featured = new WP_Query($cb_args_featured); $cb_featured_random_title = __('Recent', 'cubell'); foreach ($cb_qry_featured->posts as $cb_post) { setup_postdata($cb_post); $cb_post_id = $cb_post->ID; $cb_category_color = cb_get_cat_color($cb_post_id); if (has_post_thumbnail($cb_post_id)) { $cb_img = get_the_post_thumbnail($cb_post_id, 'cb-750-400'); } $cb_permalink = get_permalink($cb_post_id); $cb_slider_output .= ' <li> <div class="cb-mask" style="border-top-color:' . $cb_category_color . ';"><a href="' . esc_url($cb_permalink) . '">' . $cb_img . '</a>' . cb_review_ext_box($cb_post_id, $cb_category_color) . '</div> <div class="cb-meta"> <h2><a href="' . esc_url($cb_permalink) . '">' . $cb_post->post_title . '</a></h2> ' . cb_byline(true, $cb_post_id) . ' </div>' . cb_review_ext_box($cb_post_id, $cb_category_color) . '</li>'; } wp_reset_postdata(); } if ($cb_current_type == 'category') { if ($cb_color == '#' || $cb_color == NULL) { $cb_color = $cb_base_color; } $this->cb_menu_css[] .= '#cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ':hover, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ':focus, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-sub-menu li .cb-grandchild-menu, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-sub-menu { background:' . $cb_color . '!important; } #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-mega-menu .cb-sub-menu li a { border-bottom-color:' . $cb_color . '!important; }'; $cb_border_color = $cb_color; } else { $cb_page_color = get_post_meta($object->object_id, 'cb_overall_color_post'); if ($cb_page_color != NULL && $cb_page_color[0] != '#') { $cb_base_color = $cb_page_color[0]; } $this->cb_menu_css[] .= '#cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ':hover, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ':focus, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-sub-menu li .cb-grandchild-menu, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-sub-menu { background:' . $cb_base_color . '!important; } #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-mega-menu .cb-sub-menu li a { border-bottom-color:' . $cb_base_color . '!important; }'; $cb_border_color = $cb_base_color; } if ($cb_posts != NULL) { $output .= '<div class="cb-articles' . $cb_has_children . '"> <div class="cb-featured"> <div class="cb-mega-title h2"><span style="border-bottom-color:' . $cb_border_color . ';">' . $cb_featured_random_title . '</span></div> <ul>' . $cb_menu_featured . '</ul> </div> <div class="cb-recent' . $cb_big_recent . '"> <div class="cb-mega-title h2"><span style="border-bottom-color:' . $cb_border_color . ';">' . __('Recent', 'cubell') . '</span></div> <ul>' . $cb_posts . '</ul> </div> </div>'; $output .= $cb_closer; } if ($cb_slider_output != NULL) { $output .= '<div class="cb-articles' . $cb_has_children . '"> <h2 class="cb-mega-title cb-slider-title"><span style="border-bottom-color:' . $cb_border_color . ';">' . $cb_featured_random_title . '</span></h2> <div class="cb-slider-a"> <div class="' . $cb_slider_type . ' clearfix"> <ul class="slides">' . $cb_slider_output . '</ul> </div> </div> </div>'; } add_action('wp_head', array($this, 'cb_menu_css')); }
function start_el(&$output, $object, $depth = 0, $args = array(), $id = 0) { parent::start_el($output, $object, $depth, $args); $cb_base_color = ot_get_option('cb_base_color', '#eb9812'); $cb_cat_menu = $object->cbmegamenu; if ($cb_cat_menu == NULL) { $cb_cat_menu = '2'; } if (function_exists('get_tax_meta')) { $cb_color = get_tax_meta($object->object_id, 'cb_color_field_id'); } else { $cb_color = $cb_base_color; } $cb_output = $cb_posts = $cb_menu_featured = $cb_has_children = $cb_slider_output = NULL; $cb_current_type = $object->object; $cb_current_classes = $object->classes; if (in_array('cb-has-children', $cb_current_classes)) { $cb_has_children = ' cb-with-sub'; } if (($cb_cat_menu == 1 || $cb_cat_menu == 4) && $object->menu_item_parent == '0') { $output .= '<div class="cb-big-menu">'; } if ($cb_cat_menu == 2 && $depth == 0 && $object->menu_item_parent == '0') { $output .= '<div class="cb-links-menu">'; } if ($cb_cat_menu == 3 && $object->menu_item_parent == '0') { $output .= '<div class="cb-mega-menu">'; } if ($cb_cat_menu == 1 && $object->menu_item_parent == '0') { $cb_cat_id = $object->object_id; if (function_exists('get_tax_meta')) { $cb_category_color = get_tax_meta($cb_cat_id, 'cb_color_field_id'); } else { $cb_category_color = NULL; } if ($cb_category_color == NULL || $cb_category_color == '#') { $cb_category_color = $cb_base_color; } $cb_args_featured = array('cat' => $cb_cat_id, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'ignore_sticky_posts' => 1, 'meta_key' => 'cb_featured_post_menu', 'meta_value' => 'featured', 'meta_compare' => '=='); $cb_qry_featured = $cb_img = NULL; $cb_qry_featured = new WP_Query($cb_args_featured); $cb_featured_random_title = __('Featured', 'cubell'); if ($cb_qry_featured->post_count == 0) { $cb_qry_featured = NULL; $cb_args_featured = array('cat' => $cb_cat_id, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'ignore_sticky_posts' => 1, 'orderby' => 'rand'); $cb_qry_featured = new WP_Query($cb_args_featured); $cb_featured_random_title = __('Random', 'cubell'); } foreach ($cb_qry_featured->posts as $cb_post) { setup_postdata($cb_post); $cb_post_id = $cb_post->ID; $cb_img = cb_get_thumbnail('480', '240', $cb_post_id); $cb_permalink = get_permalink($cb_post_id); $cb_menu_featured .= ' <li class="cb-article clearfix"> <div class="cb-mask" style="background-color:' . $cb_category_color . ';">' . $cb_img . cb_review_ext_box($cb_post_id, $cb_category_color) . '</div> <div class="cb-meta"> <h2 class="h4"><a href="' . $cb_permalink . '">' . $cb_post->post_title . '</a></h2> ' . cb_byline(true, $cb_post_id) . ' </div></li>'; } wp_reset_postdata(); if ($cb_has_children == NULL) { $cb_qry_amount = 6; $cb_big_recent = ' cb-recent-fw'; $cb_closer = '</div>'; } else { $cb_qry_amount = 3; $cb_big_recent = $cb_closer = NULL; } $cb_args = array('cat' => $cb_cat_id, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $cb_qry_amount, 'ignore_sticky_posts' => 1); $cb_qry_latest = $cb_img = NULL; $cb_qry_latest = new WP_Query($cb_args); $i = 1; foreach ($cb_qry_latest->posts as $cb_post) { setup_postdata($cb_post); $cb_post_id = $cb_post->ID; $cb_img = cb_get_thumbnail('80', '60', $cb_post_id); $cb_permalink = get_permalink($cb_post_id); $cb_posts .= ' <li class="cb-article-' . $i . ' clearfix"> <div class="cb-mask" style="background-color:' . $cb_category_color . ';">' . $cb_img . cb_review_ext_box($cb_post_id, $cb_category_color, true) . '</div> <div class="cb-meta"> <h2 class="h4"><a href="' . $cb_permalink . '">' . $cb_post->post_title . '</a></h2> ' . cb_byline(false, $cb_post_id, true) . ' </div></li>'; $i++; } wp_reset_postdata(); } if ($cb_cat_menu == 4 && $object->menu_item_parent == '0') { $cb_cat_id = $object->object_id; if (function_exists('get_tax_meta')) { $cb_category_color = get_tax_meta($cb_cat_id, 'cb_color_field_id'); } else { $cb_category_color = NULL; } if ($cb_has_children != NULL) { $cb_slider_type = 'flexslider-1-menu'; $cb_args_featured = array('cat' => $cb_cat_id, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 9, 'ignore_sticky_posts' => 1); } else { $cb_args_featured = array('cat' => $cb_cat_id, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 12, 'ignore_sticky_posts' => 1); $cb_slider_type = 'flexslider-1-fw-menu'; } $cb_qry_featured = $cb_img = NULL; $cb_qry_featured = new WP_Query($cb_args_featured); $cb_featured_random_title = __('Recent', 'cubell'); foreach ($cb_qry_featured->posts as $cb_post) { setup_postdata($cb_post); $cb_post_id = $cb_post->ID; $cb_category_color = cb_get_cat_color($cb_post_id); if (has_post_thumbnail($cb_post_id)) { $cb_img = get_the_post_thumbnail($cb_post_id, 'cb-750-400'); } $cb_permalink = get_permalink($cb_post_id); $cb_slider_output .= ' <li> <div class="cb-mask" style="border-top-color:' . $cb_category_color . ';"><a href="' . $cb_permalink . '">' . $cb_img . '</a>' . cb_review_ext_box($cb_post_id, $cb_category_color) . '</div> <div class="cb-meta"> <h2><a href="' . $cb_permalink . '">' . $cb_post->post_title . '</a></h2> ' . cb_byline(true, $cb_post_id) . ' </div>' . cb_review_ext_box($cb_post_id, $cb_category_color) . '</li>'; } wp_reset_postdata(); } if ($cb_current_type == 'category') { if ($cb_color == '#' || $cb_color == NULL) { $cb_color = $cb_base_color; } $this->cb_menu_css[] .= '#cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ':hover, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ':focus, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-sub-menu li .cb-grandchild-menu, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-sub-menu { background:' . $cb_color . '!important; } #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-mega-menu .cb-sub-menu li a { border-bottom-color:' . $cb_color . '!important; }'; $cb_border_color = $cb_color; } else { $cb_page_color = get_post_meta($object->object_id, 'cb_overall_color_post'); if ($cb_page_color != NULL && $cb_page_color[0] != '#') { $cb_base_color = $cb_page_color[0]; } $this->cb_menu_css[] .= '#cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ':hover, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ':focus, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-sub-menu li .cb-grandchild-menu, #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-sub-menu { background:' . $cb_base_color . '!important; } #cb-nav-bar #cb-main-menu .main-nav .menu-item-' . $object->ID . ' .cb-mega-menu .cb-sub-menu li a { border-bottom-color:' . $cb_base_color . '!important; }'; $cb_border_color = $cb_base_color; } if ($cb_posts != NULL) { $output .= '<div class="cb-articles' . $cb_has_children . '"> <div class="cb-featured"> <h2 class="cb-mega-title"><span style="border-bottom-color:' . $cb_border_color . ';">' . $cb_featured_random_title . '</span></h2> <ul>' . $cb_menu_featured . '</ul> </div> <div class="cb-recent' . $cb_big_recent . '"> <h2 class="cb-mega-title"><span style="border-bottom-color:' . $cb_border_color . ';">' . __('Recent', 'cubell') . '</span></h2> <ul>' . $cb_posts . '</ul> </div> </div>'; $output .= $cb_closer; } if ($cb_slider_output != NULL) { $output .= '<div class="cb-articles' . $cb_has_children . '"> <h2 class="cb-mega-title cb-slider-title"><span style="border-bottom-color:' . $cb_border_color . ';">' . $cb_featured_random_title . '</span></h2> <div class="cb-slider-a"> <div class="' . $cb_slider_type . ' clearfix"> <ul class="slides">' . $cb_slider_output . '</ul> </div> </div> </div>'; } add_action('wp_head', array($this, 'cb_menu_css')); }
function cb_get_review_ext_box($cb_post_id = NULL, $cb_small_box = false) { $cb_output = $cb_small_box_output = NULL; $cb_category_color = cb_get_cat_color($cb_post_id); $cb_review_checkbox = get_post_meta($cb_post_id, 'cb_review_checkbox', true); if ($cb_review_checkbox == 'on' || $cb_review_checkbox == '1') { $cb_review_type = get_post_meta($cb_post_id, 'cb_user_score', 'cb-both'); $cb_score_display_type = get_post_meta($cb_post_id, 'cb_score_display_type', true); $cb_user_score = get_post_meta($cb_post_id, 'cb_user_score_output', true); $cb_final_score = get_post_meta($cb_post_id, 'cb_final_score', true); $cb_final_score_override = get_post_meta($cb_post_id, 'cb_final_score_override', true); if ($cb_final_score_override != NULL) { $cb_final_score = $cb_final_score_override; } if ($cb_review_type == 'cb-readers') { $cb_final_score = $cb_user_score; } $cb_review_final_score = intval($cb_final_score); if ($cb_score_display_type == 'percentage') { $cb_score_output = $cb_review_final_score . '<span class="cb-percent-sign">%</span>'; } if ($cb_score_display_type == 'points') { $cb_score_output = $cb_review_final_score / 10; } if ($cb_score_display_type == 'stars') { $cb_review_final_score = $cb_review_final_score / 20; $cb_score_output = number_format($cb_review_final_score, 1); } if ($cb_small_box == true) { $cb_small_box_output = ' cb-small-box'; } $cb_output = '<div class="cb-review-ext-box cb-font-header' . $cb_small_box_output . '"><span class="cb-bg" style="background:' . $cb_category_color . ';"></span><span class="cb-score">' . $cb_score_output . '</span></div>'; } return $cb_output; }