the_ID(); ?> " <?php post_class("cb-blog-style-b cb-module-a cb-article cb-article-row-2 cb-article-row cb-img-above-meta clearfix cb-separated cb-no-{$cb_count}"); ?> role="article"> <div class="cb-mask cb-img-fw" <?php cb_img_bg_color($cb_post_id); ?> > <?php cb_thumbnail('360', '240'); ?> <?php cb_review_ext_box($cb_post_id); ?> </div> <div class="cb-meta clearfix"> <h2 class="cb-post-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php cb_byline($cb_post_id);
echo ' sticky'; } echo $cb_side; if ($cb_category_color_style != NULL) { echo ' ' . $cb_category_color_style; } ?> " role="article"> <div class="cb-mask" style="background-color:<?php echo $cb_category_color; ?> ;"> <?php cb_thumbnail('360', '240'); echo cb_review_ext_box($cb_post_id, $cb_category_color); echo $cb_post_format_icon; ?> </div> <div class="cb-meta"> <h2 class="h4"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php echo cb_byline();
function widget($args, $instance) { $cache = wp_cache_get('widget_recent_posts', 'widget'); if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'cubell') : $instance['title'], $instance, $this->id_base); $category = apply_filters('widget_category', empty($instance['category']) ? '' : $instance['category'], $instance, $this->id_base); $type = apply_filters('widget_type', empty($instance['type']) ? 'cb-small' : $instance['type'], $instance, $this->id_base); if (empty($instance['number']) || !($number = absint($instance['number']))) { $number = 5; } if ($category != 'cb-all') { $cb_cat_qry = $category; } else { $cb_cat_qry = NULL; } $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'category_name' => $cb_cat_qry, 'post_status' => 'publish', 'ignore_sticky_posts' => true))); if ($r->have_posts()) { echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="cb-light <?php echo $type; ?> "> <?php while ($r->have_posts()) { $r->the_post(); global $post; $cb_custom_fields = get_post_custom(); $cb_global_color = ot_get_option('cb_base_color', '#eb9812'); $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on'); $cb_review_checkbox = get_post_meta(get_the_id(), "cb_review_checkbox"); if ($type == 'cb-small') { $width = '80'; $height = '60'; $cb_small_box = true; $cb_class = NULL; } if ($type == 'cb-big') { $width = '360'; $height = '240'; $cb_small_box = false; $cb_class = ' class="h2"'; } $cb_all_categories = get_the_category(); $cb_current_cat_id = $cb_all_categories[0]->term_id; $cb_category_color = get_tax_meta($cb_current_cat_id, 'cb_color_field_id'); if ($cb_category_color == "#" || $cb_category_color == NULL) { $cb_parent_cat_id = $cb_all_categories[0]->parent; if ($cb_parent_cat_id != '0') { $cb_category_color = get_tax_meta($cb_parent_cat_id, 'cb_color_field_id'); } if ($cb_category_color == "#" || $cb_category_color == NULL) { $cb_category_color = $cb_global_color; } } $cb_post_id = $post->ID; $cb_post_format_icon = cb_post_format_check($cb_post_id); ?> <li class="cb-article clearfix"> <div class="cb-mask" style="background-color:<?php echo $cb_category_color; ?> ;"> <?php cb_thumbnail($width, $height); echo cb_review_ext_box($cb_post_id, $cb_category_color, $cb_small_box); echo $cb_post_format_icon; ?> </div> <div class="cb-meta"> <h4<?php echo $cb_class; ?> ><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <?php echo cb_byline(false, $cb_post_id, true); ?> <?php if ($type == 'cb-big') { echo '<div class="cb-excerpt">' . cb_clean_excerpt(120) . '</div>'; } ?> </div> </li> <?php } ?> </ul> <?php echo $after_widget; ?> <?php // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_recent_posts', $cache, 'widget'); }
function my_posts_screen_content() { get_template_part('directory-to-content-file'); $theuser = bp_displayed_user_id(); $paged = get_query_var('paged') ? get_query_var('paged') : 1; query_posts(array('posts_per_page' => 5, 'author' => $theuser, 'cb_offset_loop' => $cb_offset_loop, 'paged' => $paged)); if (have_posts()) { while (have_posts()) { the_post(); ?> <article id="post-<?php the_ID(); ?> " class="cb-blog-style-a clearfix<?php if (is_sticky()) { echo ' sticky'; } if ($cb_category_color_style != NULL) { echo ' ' . $cb_category_color_style; } ?> " role="article"> <div class="cb-mask" style="background-color:<?php echo $cb_category_color; ?> ;"> <?php cb_thumbnail('300', '200'); echo cb_review_ext_box($cb_post_id, $cb_category_color); echo $cb_post_format_icon; ?> </div> <div class="cb-meta"> <h2 class="h4"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php echo cb_byline(); ?> <div class="cb-excerpt"><?php echo cb_clean_excerpt(210, false); ?> </div> </div> </article> <?php } wp_reset_query(); // resets main query } else { ?> <h1>Sorry...</h1> <p><?php _e('You have not posted any article.'); ?> </p> <h4> <a style="color: grey" href="<?php echo home_url(); ?> //add-new/"><?php esc_html_e("Add an article now", 'cubell'); ?> </a></h4> <?php } }
<?php } else { ?> <article class="cb-article-small cb-separated clearfix" role="article"> <div class="cb-mask cb-img-fw" <?php cb_img_bg_color($cb_post_id); ?> > <?php cb_thumbnail('100', '65'); ?> <?php cb_review_ext_box($cb_post_id, true); ?> </div> <div class="cb-meta"> <h2 class="cb-post-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h2> <?php echo cb_get_byline_date($cb_post_id); ?>
function widget($args, $instance) { $cache = wp_cache_get('widget_top_reviews', 'widget'); if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Top Reviews', 'cubell') : $instance['title'], $instance, $this->id_base); $cb_category = apply_filters('widget_category', empty($instance['category']) ? '' : $instance['category'], $instance, $this->id_base); $cb_filter = apply_filters('widget_filter', empty($instance['filter']) ? '' : $instance['filter'], $instance, $this->id_base); $cb_type = apply_filters('widget_type', empty($instance['type']) ? '' : $instance['type'], $instance, $this->id_base); if ($cb_filter == NULL) { $cb_filter = 'alltime'; } if (empty($instance['number']) || !($number = absint($instance['number']))) { $number = 5; } if ($cb_category != 'cb-all') { $cb_cat_qry = $cb_category; } else { $cb_cat_qry = NULL; } if ($cb_type == 'cb-reader-score') { $cb_type_filter = 'cb_user_score_output'; } else { $cb_type_filter = 'cb_final_score'; } if ($cb_filter == 'week') { $cb_week = date('W'); $cb_year = date('Y'); $cb_qry = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'category_name' => $cb_cat_qry, 'year' => $cb_year, 'w' => $cb_week, 'no_found_rows' => true, 'post_status' => 'publish', 'meta_key' => $cb_type_filter, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => true))); } elseif ($cb_filter == 'alltime') { $cb_qry = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'category_name' => $cb_cat_qry, 'no_found_rows' => true, 'post_status' => 'publish', 'meta_key' => $cb_type_filter, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => true))); } elseif ($cb_filter == 'month') { $cb_month = date('m', strtotime('-30 days')); $cb_year = date('Y', strtotime('-30 days')); $cb_qry = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'category_name' => $cb_cat_qry, 'year' => $cb_year, 'monthnum' => $cb_month, 'no_found_rows' => true, 'post_status' => 'publish', 'meta_key' => $cb_type_filter, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => true))); } elseif ($cb_filter == '2011' || $cb_filter == '2012' || $cb_filter == '2013' || $cb_filter == '2014') { $cb_qry = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'category_name' => $cb_cat_qry, 'year' => $cb_filter, 'no_found_rows' => true, 'post_status' => 'publish', 'meta_key' => $cb_type_filter, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => true))); } if ($cb_qry->have_posts()) { echo $before_widget; if ($title != NULL) { echo $before_title . $title . $after_title; } echo '<ul>'; $i = 1; while ($cb_qry->have_posts()) { $cb_qry->the_post(); global $post; $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on'); $cb_global_color = ot_get_option('cb_base_color', '#eb9812'); $cb_cat_id = get_the_category(); $cb_current_cat_id = $cb_cat_id[0]->term_id; $cb_category_color = get_tax_meta($cb_current_cat_id, 'cb_color_field_id'); if ($cb_category_color == "#" || $cb_category_color == NULL) { $cb_parent_cat_id = $cb_cat_id[0]->parent; if ($cb_parent_cat_id != '0') { $cb_category_color = get_tax_meta($cb_parent_cat_id, 'cb_color_field_id'); } if ($cb_category_color == "#" || $cb_category_color == NULL) { $cb_category_color = $cb_global_color; } } $cb_post_id = $post->ID; ?> <li class="cb-article clearfix" style="border-top-color:<?php echo $cb_category_color; ?> ;"> <div class="cb-mask"><?php cb_thumbnail('430', '270'); ?> </div> <div class="cb-meta"> <h4><a href="<?php the_permalink(); ?> "><?php echo get_the_title(); ?> </a></h4> <?php echo cb_byline(false); ?> </div> <div class="cb-countdown header-font"><?php echo $i; ?> </div> <?php if ($cb_type != 'cb-reader-score') { echo cb_review_ext_box($cb_post_id, $cb_category_color); } ?> </li> <?php $i++; } echo '</ul>'; echo $after_widget; // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_top_reviews', $cache, 'widget'); }
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 widget($args, $instance) { $cache = wp_cache_get('widget_recent_posts', 'widget'); if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $cb_title = empty($instance['title']) ? '' : $instance['title']; $cb_category = empty($instance['category']) ? '' : $instance['category']; $cb_type = empty($instance['type']) ? 'cb-small' : $instance['type']; if (empty($instance['number']) || !($cb_number = absint($instance['number']))) { $cb_number = 5; } if ($cb_category != 'cb-all') { $cb_cat_qry = $cb_category; } else { $cb_cat_qry = NULL; } $cb_cpt_output = cb_get_custom_post_types(); $cb_qry = new WP_Query(array('post_type' => $cb_cpt_output, 'posts_per_page' => $cb_number, 'no_found_rows' => true, 'category_name' => $cb_cat_qry, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); if ($cb_qry->have_posts()) { echo $before_widget; if ($cb_title) { echo $before_title . esc_html($cb_title) . $after_title; } ?> <div class="cb-module-block cb-small-margin"> <?php while ($cb_qry->have_posts()) { $cb_qry->the_post(); global $post; $cb_post_id = $post->ID; $cb_width = '100'; $cb_height = '65'; $cb_style = ' cb-separated'; $cb_bg_color = cb_get_img_bg_color($cb_post_id); if ($cb_type == 'cb-article-big') { $cb_width = '360'; $cb_height = '240'; $cb_style = ' cb-meta-style-2'; $cb_bg_color = NULL; } ?> <article <?php post_class('cb-looper cb-article ' . esc_attr($cb_type) . ' ' . esc_attr($cb_style) . ' clearfix', $cb_post_id); ?> > <div class="cb-mask cb-img-fw" <?php $cb_bg_color; ?> > <?php cb_thumbnail($cb_width, $cb_height); ?> <?php cb_review_ext_box($cb_post_id, true); ?> </div> <div class="cb-meta cb-article-meta"> <h4 class="cb-post-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <?php echo cb_get_byline_date($cb_post_id); ?> </div> <?php if ($cb_type == 'cb-article-big') { echo '<a href="' . get_the_permalink() . '" class="cb-link"></a>'; } ?> </article> <?php } ?> </div> <?php echo $after_widget; ?> <?php wp_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_recent_posts', $cache, 'widget'); }
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 widget($args, $instance) { $cache = wp_cache_get('widget_popular_posts', 'widget'); if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $cb_title = empty($instance['cb_title']) ? '' : $instance['cb_title']; $cb_category = empty($instance['category']) ? '' : $instance['category']; $cb_type = empty($instance['cb_type']) ? 'cb-article-small' : $instance['cb_type']; $cb_filter_date = empty($instance['cb_filter_date']) ? 'alltime' : $instance['cb_filter_date']; $cb_filter_by = empty($instance['cb_filter_by']) ? 'cb-comments' : $instance['cb_filter_by']; if (empty($instance['cb_number']) || !($cb_number = absint($instance['cb_number']))) { $cb_number = 5; } if ($cb_category != 'cb-all') { $cb_cat_qry = $cb_category; } else { $cb_cat_qry = NULL; } $cb_qry = NULL; $cb_c = 300; $i = 1; if ($cb_filter_by == 'cb-visits') { if (function_exists('stats_get_csv')) { if ($cb_filter_date == 'week') { $cb_weekly_qry = 'cb-week-pop'; if (($cb_qry = get_transient($cb_weekly_qry)) === false) { $cb_qry = stats_get_csv('postviews', 'days=8&limit=' . (6 + $cb_number)); set_transient($cb_weekly_qry, $cb_qry, $cb_c); } } elseif ($cb_filter_date == 'month') { $cb_monthly_qry = 'cb-month-pop'; if (($cb_qry = get_transient($cb_monthly_qry)) === false) { $cb_qry = stats_get_csv('postviews', 'days=31&limit=' . (6 + $cb_number)); set_transient($cb_monthly_qry, $cb_qry, $cb_c); } } elseif ($cb_filter_date == 'alltime') { $cb_alltime_qry = 'cb-alltime-pop'; if (($cb_qry = get_transient($cb_alltime_qry)) === false) { $cb_qry = stats_get_csv('postviews', 'days=-1&limit=' . (6 + $cb_number)); set_transient($cb_alltime_qry, $cb_qry, $cb_c); } } } else { echo '<div class="cb-sidebar-widget">15Zine Popular Posts Widget: To use the "View Count" option You need to install Jetpack plugin and enable the "Stats" module.</div>'; } } else { $cb_cpt_output = cb_get_custom_post_types(); $cb_qry = new WP_Query(array('post_type' => $cb_cpt_output, 'posts_per_page' => $cb_number, 'category_name' => $cb_cat_qry, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'orderby' => 'comment_count')); } echo $before_widget; $cb_width = '100'; $cb_height = '65'; $cb_style = ' cb-separated'; if ($cb_type == 'cb-article-big') { $cb_width = '360'; $cb_height = '240'; $cb_style = ' cb-meta-style-2'; } if ($cb_title) { echo $before_title . esc_html($cb_title) . $after_title; } echo '<div class="cb-module-block cb-small-margin">'; if ($cb_filter_by == 'cb-comments' && $cb_qry->have_posts()) { while ($cb_qry->have_posts()) { $cb_qry->the_post(); global $post; $cb_post_id = $post->ID; ?> <article <?php post_class('cb-article ' . esc_attr($cb_type) . ' ' . esc_attr($cb_style) . ' clearfix'); ?> > <div class="cb-mask cb-img-fw" <?php cb_img_bg_color($cb_post_id); ?> > <?php cb_thumbnail($cb_width, $cb_height); ?> <?php cb_review_ext_box($cb_post_id, true); ?> </div> <div class="cb-meta cb-article-meta"> <h4 class="cb-post-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <div class="cb-byline cb-byline-short cb-comment-count"> <a href="<?php echo get_comments_link($cb_post_id); ?> "> <?php echo number_format_i18n(get_comments_number($cb_post_id)) . ' ' . __('Comments', 'cubell'); ?> </a> </div> </div> <?php if ($cb_type == 'cb-article-big') { echo '<a href="' . get_the_permalink() . '" class="cb-link"></a>'; } ?> </article> <?php } wp_reset_postdata(); } if ($cb_filter_by == 'cb-visits' && !empty($cb_qry)) { $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on'); $cb_post_meta_views = ot_get_option('cb_byline_postviews', 'on'); foreach ($cb_qry as $cb_post) { $cb_post_id = $cb_post['post_id']; $cb_cats = wp_get_post_categories($cb_post_id); if (empty($cb_cats)) { continue; } ?> <article class="cb-article <?php echo esc_attr($cb_type) . ' ' . esc_attr($cb_style); ?> clearfix"> <div class="cb-mask cb-img-fw"> <?php cb_thumbnail($cb_width, $cb_height, $cb_post_id); ?> </div> <div class="cb-meta cb-article-meta"> <h4 class="cb-post-title"><a href="<?php echo esc_url($cb_post['post_permalink']); ?> "><?php echo esc_html($cb_post['post_title']); ?> </a></h4> <?php if ($cb_meta_onoff == 'on' && $cb_post_meta_views == 'on') { ?> <div class="cb-byline cb-byline-short cb-comment-count"><?php echo intval($cb_post['views']); ?> <?php _e('Views', 'cubell'); ?> </div> <?php } ?> </div> <?php if ($cb_type == 'cb-article-big') { echo '<a href="' . get_the_permalink() . '" class="cb-link"></a>'; } ?> </article> <?php if ($i == $cb_number) { break; } $i++; } } echo '</div>'; echo $after_widget; $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_popular_posts', $cache, 'widget'); }
function widget($args, $instance) { $cache = wp_cache_get('widget_recent_posts_slider', 'widget'); if (!is_array($cache)) { $cache = array(); } if (!isset($args['widget_id'])) { $args['widget_id'] = $this->id; } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Latest', 'cubell') : $instance['title'], $instance, $this->id_base); $category = apply_filters('widget_category', empty($instance['category']) ? '' : $instance['category'], $instance, $this->id_base); if (empty($instance['number']) || !($number = absint($instance['number']))) { $number = 6; } if ($category != 'cb-all') { $cb_cat_qry = $category; } else { $cb_cat_qry = NULL; } $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'category_name' => $cb_cat_qry, 'post_status' => 'publish', 'ignore_sticky_posts' => true))); if ($r->have_posts()) { echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="flexslider-widget"> <ul class="slides"> <?php while ($r->have_posts()) { $r->the_post(); global $post; $format = get_post_format(); $cb_custom_fields = get_post_custom(); $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on'); $cb_global_color = ot_get_option('cb_base_color', '#eb9812'); $cb_review_checkbox = get_post_meta(get_the_id(), "cb_review_checkbox"); $cb_cat_id = get_the_category(); $cb_current_cat_id = $cb_cat_id[0]->term_id; $cb_category_color = get_tax_meta($cb_current_cat_id, 'cb_color_field_id'); if ($cb_category_color == "#" || $cb_category_color == NULL) { $cb_parent_cat_id = $cb_cat_id[0]->parent; if ($cb_parent_cat_id != '0') { $cb_category_color = get_tax_meta($cb_parent_cat_id, 'cb_color_field_id'); } if ($cb_category_color == "#" || $cb_category_color == NULL) { $cb_category_color = $cb_global_color; } } $cb_post_id = $post->ID; if ($cb_review_checkbox) { $format = 'false'; } ?> <li class="cb-article clearfix" style="border-top-color:<?php echo $cb_category_color; ?> ;"> <div class="cb-mask"><?php cb_thumbnail('430', '270'); ?> </div> <div class="cb-meta"> <h4><a href="<?php the_permalink(); ?> "><?php echo get_the_title(); ?> </a></h4> <?php echo cb_byline(false); ?> </div> <?php echo cb_review_ext_box($cb_post_id, $cb_category_color); ?> </li> <?php } ?> </ul> </div> <?php echo $after_widget; ?> <?php // Reset the global $the_post as this query will have stomped on it wp_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_recent_posts_slider', $cache, 'widget'); }