<?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); ?> </div> </article> <?php } } echo '</div>'; } // endif wp_reset_postdata();
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); $cb_title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $cb_category = apply_filters('widget_category', empty($instance['category']) ? '' : $instance['category'], $instance, $this->id_base); if (empty($instance['number']) || !($cb_number = absint($instance['number']))) { $cb_number = 6; } 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-slider cb-slider-1 cb-recent-slider cb-relative cb-arrows-tr clearfix"> <ul class="slides"> <?php while ($cb_qry->have_posts()) { $cb_qry->the_post(); global $post; $cb_post_id = $post->ID; ?> <li <?php post_class('cb-article cb-style-1 clearfix'); ?> > <div class="cb-mask"><?php cb_thumbnail('360', '240', $cb_post_id); ?> </div> <div class="cb-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> </li> <?php } ?> </ul> </div> <?php echo $after_widget; wp_reset_postdata(); } $cache[$args['widget_id']] = ob_get_flush(); wp_cache_set('widget_recent_posts_slider', $cache, 'widget'); }
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) { if (ot_get_option('cb_ajax_mm', 'on') == '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', '#f2c231'); if (function_exists('get_tax_meta')) { $cb_use_color = get_tax_meta($object->object_id, 'cb_color_field_id'); } else { $cb_use_color = $cb_base_color; } $cb_output = $cb_featured_plus_four = $cb_posts = $cb_menu_featured = $cb_slider_output = $cb_has_children = 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 == 3 || $cb_cat_menu == 4) && $object->menu_item_parent == '0') { $output .= '<div class="cb-menu-drop cb-bg cb-mega-menu cb-big-menu clearfix">'; } if ($cb_cat_menu == 1 && $depth == 0 && $object->menu_item_parent == '0' && in_array('cb-has-children', $cb_current_classes)) { $output .= '<div class="cb-links-menu cb-menu-drop">'; } if ($cb_cat_menu == 2 && $object->menu_item_parent == '0') { $output .= '<div class="cb-menu-drop cb-bg cb-mega-menu cb-mega-menu-columns">'; } if ($cb_cat_menu == 3 && $object->menu_item_parent == '0') { $cb_cat_id = $object->object_id; $cb_category_color = NULL; $cb_posts .= '<div class="cb-upper-title"><h2>' . $object->title . '</h2><a href="' . $object->url . '" class="cb-see-all">' . __('See all', 'cubell') . '</a></div><ul class="cb-sub-posts">'; if (function_exists('get_tax_meta')) { $cb_category_color = get_tax_meta($cb_cat_id, 'cb_color_field_id'); } if ($cb_category_color == NULL || $cb_category_color == '#') { $cb_category_color = $cb_base_color; } $cb_cpt_output = cb_get_custom_post_types(); if ($cb_has_children == NULL) { $cb_mega_classes = 'cb-mega-three cb-mega-posts '; $cb_width = '360'; $cb_height = '240'; $cb_closer = '</div>'; $cb_ppp = apply_filters('cb-mm-number-posts', '3'); } else { $cb_mega_classes = 'cb-sub-mega-three cb-pre-load cb-mega-posts '; $cb_width = '260'; $cb_height = '170'; $cb_closer = NULL; $cb_ppp = apply_filters('cb-mm-with-menu-number-posts', '3'); } $cb_args = array('cat' => $cb_cat_id, 'post_status' => 'publish', 'posts_per_page' => $cb_ppp, 'ignore_sticky_posts' => 1); $cb_qry_latest = new WP_Query($cb_args); $i = 1; $cb_post_output = NULL; while ($cb_qry_latest->have_posts()) { $cb_qry_latest->the_post(); $cb_post_id = get_the_ID(); $cb_posts .= ' <li class="' . implode(" ", get_post_class("cb-looper cb-article-" . $i . " cb-mm-posts-count-" . $cb_ppp . " cb-style-1 clearfix", $cb_post_id)) . '"><div class="cb-mask cb-img-fw" ' . cb_get_img_bg_color($cb_post_id) . '>' . cb_get_thumbnail($cb_width, $cb_height, $cb_post_id) . '</div><div class="cb-meta"><h2 class="cb-post-title"><a href="' . esc_url(get_permalink($cb_post_id)) . '">' . get_the_title() . '</a></h2>' . cb_get_byline_date($cb_post_id) . '</div></li>'; $i++; } wp_reset_postdata(); $cb_posts .= '</ul>'; } if ($object->menu_item_parent == '0') { if ($cb_current_type == 'category') { if ($cb_use_color != NULL) { $this->cb_menu_css[] .= '.cb-mm-on #cb-nav-bar .cb-main-nav .menu-item-' . $object->ID . ':hover, .cb-mm-on #cb-nav-bar .cb-main-nav .menu-item-' . $object->ID . ':focus { background:' . $cb_use_color . ' !important ; }'; $this->cb_menu_css[] .= '.cb-mm-on #cb-nav-bar .cb-main-nav .menu-item-' . $object->ID . ' .cb-big-menu { border-top-color: ' . $cb_use_color . '; }'; } } else { $cb_page_color = get_post_meta($object->object_id, 'cb_overall_color_post'); if ($cb_page_color != NULL && $cb_page_color[0] != '#') { $this->cb_menu_css[] .= '.cb-mm-on #cb-nav-bar .cb-main-nav .menu-item-' . $object->ID . ':hover, .cb-mm-on #cb-nav-bar .cb-main-nav .menu-item-' . $object->ID . ':focus { background:' . $cb_page_color[0] . ' !important ; }'; } } } if ($cb_posts != NULL) { $output .= '<div class="' . $cb_mega_classes . ' clearfix">' . $cb_posts . '</div>' . $cb_closer; } add_action('wp_head', array($this, 'cb_menu_css')); }