function widget($args, $instance)
 {
     extract($args);
     $selected_category = $instance["selected_category"];
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
     $icon_type = $instance["icon_type"];
     $cat_icon_url = $instance["cat_icon_url"];
     $post_style = $instance["post_style"];
     $post_thumbnail_size = $instance['post_thumbnail_size'];
     $this->post_excerpt_length = $instance['post_excerpt_length'];
     $number_of_posts = $instance["number_of_posts"];
     $icon_height = $instance['icon_height'];
     $icon_width = $instance['icon_width'];
     $all_posts_text = $instance['all_posts_text'];
     $order = isset($instance['order']) ? $instance['order'] : 'DESC';
     $order_by = isset($instance['order_by']) ? $instance['order_by'] : 'date';
     $ignore_sticky = isset($instance['ignore_sticky']) ? $instance['ignore_sticky'] : 'ignore';
     $post_ids = isset($instance['post_ids']) ? $instance['post_ids'] : '';
     $tags = isset($instance['tags']) ? $instance['tags'] : '';
     $post_formats = isset($instance['post_formats']) ? $instance['post_formats'] : '';
     $any_post_type = isset($instance['any_post_type']) ? $instance['any_post_type'] : false;
     $separate_widgets = isset($instance['separate_widgets']) ? $instance['separate_widgets'] : false;
     $ret = "";
     if ($icon_type == 'plugin') {
         if (function_exists('get_cat_icon')) {
             $cat_icon = get_cat_icon('echo=false&cat=' . $selected_category);
             if (trim($cat_icon) != '') {
                 $ret .= "\t\t<div class='suf-cat-posts-widget-image' style='height: {$icon_height};'>";
                 $ret .= $cat_icon;
                 $ret .= "</div>\n";
             }
         }
     } else {
         if ($icon_type == 'custom') {
             if (trim($cat_icon_url) != '') {
                 $ret .= "\t\t<div class='suf-cat-posts-widget-image' style='height: {$icon_height};'>";
                 $ret .= "<a href='" . get_category_link($selected_category) . "'>";
                 $ret .= "<img src='{$cat_icon_url}' alt='" . esc_attr($title) . "' title='" . esc_attr($title) . "' style='width: {$icon_width}; height: {$icon_height};'/>";
                 $ret .= "</a>\n";
                 $ret .= "</div>\n";
             }
         }
     }
     $query_args = array('posts_per_page' => $number_of_posts, 'order' => $order, 'orderby' => $order_by);
     $tax_query = array('relation' => 'AND');
     if ($selected_category != '0' && $selected_category != 0) {
         $query_args['cat'] = $selected_category;
         $cat_tax = array('taxonomy' => 'category', 'field' => 'id', 'terms' => array($selected_category), 'operator' => 'IN');
     }
     $post_in = array();
     if (trim($post_ids) != '') {
         $solo_posts = preg_replace('/\\s\\s+/', ' ', $post_ids);
         $solo_posts = explode(',', $solo_posts);
         if (count($solo_posts) > 0) {
             $post_in = $solo_posts;
         }
     }
     if ($ignore_sticky == 'ignore') {
         $query_args['ignore_sticky_posts'] = true;
     } else {
         if ($ignore_sticky == 'only-sticky') {
             $post_in = get_option('sticky_posts');
         } else {
             $query_args['ignore_sticky_posts'] = false;
         }
     }
     if (is_array($post_in) && count($post_in) > 0) {
         $query_args['post__in'] = $post_in;
     }
     if (trim($tags) != '') {
         $solo_tags = preg_replace('/\\s\\s+/', ' ', $tags);
         if (count($solo_tags) > 0) {
             $query_args['tag'] = $solo_tags;
         }
     }
     if ($post_formats != '') {
         $format_tax = array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array("post-format-{$post_formats}"), 'operator' => 'IN');
     }
     if (isset($cat_tax) && isset($format_tax)) {
         $tax_query[] = $cat_tax;
         $tax_query[] = $format_tax;
         unset($query_args['cat']);
         $query_args['tax_query'] = $tax_query;
     } else {
         if (isset($cat_tax) || isset($format_tax)) {
             unset($query_args['cat']);
             $tax_query = array(isset($cat_tax) ? $cat_tax : $format_tax);
             $query_args['tax_query'] = $tax_query;
         }
     }
     if ($any_post_type) {
         $query_args['post_type'] = 'any';
     }
     $query = new WP_query($query_args);
     if (isset($query->posts) && is_array($query->posts) && count($query->posts) > 0 && !($separate_widgets && ($post_style == 'thumbnail-full' || $post_style == 'thumbnail-excerpt'))) {
         if ($post_style == 'magazine') {
             $ret .= "<ul class='suf-cat-posts-list'>\n";
         } else {
             if ($post_style == 'thumbnail' || $post_style == 'thumbnail-excerpt' || $post_style == 'thumbnail-full') {
                 $ret .= "<ul class='suf-posts-thumbnail'>\n";
             } else {
                 $ret .= "<ul>\n";
             }
         }
         while ($query->have_posts()) {
             $query->the_post();
             if ($post_style == 'magazine') {
                 $ret .= "<li class='suf-cat-post'><a href='" . get_permalink() . "' class='suf-cat-post'>" . get_the_title() . "</a></li>\n";
             } else {
                 if ($post_style == 'thumbnail') {
                     $image = suffusion_get_image(array('widget-thumb' => 'widget-' . $post_thumbnail_size));
                     $ret .= "<li class='fix'><div class='suf-widget-thumb'>" . $image . "</div><a href='" . get_permalink() . "' class='suf-widget-thumb-title'>" . get_the_title() . "</a></li>\n";
                 } else {
                     if ($post_style == 'thumbnail-excerpt') {
                         add_filter('excerpt_length', array(&$this, 'excerpt_length'));
                         $image = suffusion_get_image(array('widget-thumb' => 'widget-' . $post_thumbnail_size));
                         $ret .= "<li class='fix'><div class='suf-widget-thumb'>" . $image . "</div><a href='" . get_permalink() . "' class='suf-widget-thumb-title'>" . get_the_title() . "</a>" . suffusion_excerpt(false, false, false) . "</li>\n";
                     } else {
                         if ($post_style == 'thumbnail-full') {
                             $image = suffusion_get_image(array('widget-thumb' => 'widget-' . $post_thumbnail_size));
                             $continue = __('Continue reading &raquo;', 'suffusion');
                             $content = get_the_content($continue);
                             $content = apply_filters('the_content', $content);
                             $content = str_replace(']]>', ']]&gt;', $content);
                             $ret .= "<li class='fix'><div class='suf-widget-thumb'>" . $image . "</div><a href='" . get_permalink() . "' class='suf-widget-thumb-title'>" . get_the_title() . "</a>" . $content . "</li>\n";
                         } else {
                             if ($post_style == 'thumbnail-only') {
                                 $image = suffusion_get_image(array('widget-thumb' => 'widget-' . $post_thumbnail_size, 'no-link' => true));
                                 $ret .= "<li class='suf-widget-mosaic'><div class='suf-widget-thumb'><a href='" . get_permalink() . "' title=\"" . esc_attr(get_the_title()) . "\">" . $image . "</a></div></li>\n";
                             } else {
                                 $ret .= "<li><a href='" . get_permalink() . "'>" . get_the_title() . "</a></li>\n";
                             }
                         }
                     }
                 }
             }
         }
         wp_reset_query();
         $ret .= "</ul>";
     } else {
         if ($separate_widgets && ($post_style == 'thumbnail-full' || $post_style == 'thumbnail-excerpt')) {
             $original_before_widget = $before_widget;
             while ($query->have_posts()) {
                 $query->the_post();
                 $before_widget = preg_replace('/(?<=id=")[^"]+/', '$0-' . get_the_ID(), $original_before_widget);
                 echo $before_widget . "\n";
                 echo $before_title . get_the_title() . $after_title;
                 if ($post_style == 'thumbnail-full') {
                     $image = suffusion_get_image(array('widget-thumb' => 'widget-' . $post_thumbnail_size));
                     $continue = __('Continue reading &raquo;', 'suffusion');
                     $content = get_the_content($continue);
                     $content = apply_filters('the_content', $content);
                     $content = str_replace(']]>', ']]&gt;', $content);
                     echo "<div class='suf-widget-thumb'>" . $image . "</div>" . $content . "\n";
                 } else {
                     add_filter('excerpt_length', array(&$this, 'excerpt_length'));
                     $image = suffusion_get_image(array('widget-thumb' => 'widget-' . $post_thumbnail_size));
                     echo "<div class='suf-widget-thumb'>" . $image . "</div>" . suffusion_excerpt(false, false, false) . "\n";
                 }
                 echo $after_widget . "\n";
             }
             wp_reset_query();
             return;
         }
     }
     if (trim($all_posts_text)) {
         $ret .= "\t<div class='suf-mag-category-footer'>\n";
         $ret .= "\t\t<a href='" . get_category_link($selected_category) . "' class='suf-mag-category-all-posts'>{$all_posts_text}</a>";
         $ret .= "\t</div>\n";
     }
     echo $before_widget;
     if ($title != '') {
         $title = do_shortcode($title);
         echo $before_title . $title . $after_title;
     }
     echo $ret;
     echo $after_widget;
 }
示例#2
0
function suffusion_get_category_information()
{
    $ret = "<div class=\"category-description\">\n";
    if (function_exists('get_cat_icon')) {
        $ret .= get_cat_icon('echo=false');
    }
    $ret .= category_description() . "\n";
    $ret .= "</div><!-- .category-description -->\n";
    $ret = apply_filters('suffusion_category_information', $ret);
    return $ret;
}
示例#3
0
 $cols_per_row = $suf_mag_catblocks_per_row;
 foreach ($categories as $category) {
     if ($ctr % $suf_mag_catblocks_per_row == 0) {
         if ($total - 1 - $ctr < $suf_mag_catblocks_per_row) {
             $cols_per_row = $total - $ctr;
         }
     }
     global $suf_mag_catblocks_images_enabled, $suf_mag_catblocks_desc_enabled, $suf_mag_catblocks_posts_enabled, $suf_mag_catblocks_num_posts;
     global $suf_mag_catblocks_see_all_text, $suf_mag_catblocks_post_style, $suf_mag_catblocks_thumbnail_size, $suf_mag_catblocks_title_alignment;
     echo "";
     echo "\n\t<div class='suf-mag-category suf-tile-{$cols_per_row}c {$suf_mag_excerpt_full_story_position}'>\n";
     echo "\t<h2 class='suf-mag-category-title {$suf_mag_catblocks_title_alignment}'>" . $category->cat_name;
     echo "</h2>";
     if ($suf_mag_catblocks_images_enabled != 'hide') {
         if (function_exists('get_cat_icon')) {
             $cat_icon = get_cat_icon('echo=false&cat=' . $category->cat_ID);
             if ($suf_mag_catblocks_images_enabled == 'hide-empty' && trim($cat_icon) != '' || $suf_mag_catblocks_images_enabled == 'show') {
                 echo "\t\t<div class='suf-mag-category-image'>";
                 echo $cat_icon;
                 echo "</div>\n";
             }
         }
     }
     if ($suf_mag_catblocks_desc_enabled == 'show') {
         echo '<div class="suf-mag-category-description">' . $category->category_description . '</div>';
     }
     if ($suf_mag_catblocks_posts_enabled == 'show') {
         $cat_args = array('cat' => $category->cat_ID, 'posts_per_page' => $suf_mag_catblocks_num_posts);
         if (function_exists('mycategoryorder')) {
             $cat_args['orderby'] = 'order';
         }
    ?>
 
								</div>
                            </li>
						<?php 
}
?>
                    </ul>
                </div>
			</div>
                
                <div class="midlsldercnt">
					<div class="leftcatbox" style="height:auto;">
						<div class="leftcatimgcntmn">
							<?php 
echo get_cat_icon("echo=false&cat=13");
///////////// Training ////////////
?>
						</div>
						<div class="leftcatnmcnt">
							<h2 style="font-size:20px;text-decoration:underline"><a href="http://gogorunning.com/category/<?php 
echo get_cat_slug(13);
?>
/"><?php 
echo get_cat_name(13);
?>
</a></h2>
						</div>
					</div>
                <div class="rightcatslider">
                	<ul id="mycarousel3" class="jcarousel-skin-tango">
/**
 * Adds compatibility with Recent posts and recent comments, similar posts from Rob Marsh (http://rmarsh.com/)
 * Just use the tag {caticons} to display the category icon
 * @author Brahim Machkouri
 */
function otf_caticons($option_key, $result, $ext)
{
    $categories = get_the_category($result->ID);
    return get_cat_icon('cat=' . $categories[0]->term_id . '&echo=0');
}