Exemplo n.º 1
11
 function inti_get_categories_meta($args = '')
 {
     $count = 0;
     $categories_list = '';
     $categories = get_the_category();
     foreach ($categories as $category) {
         $count++;
         if ($args['show_uncategorized']) {
             $categories_list .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__('View all posts in %s', 'inti'), $category->name) . '"><span class="label category">' . $category->name . '</span></a>';
             if ($count != count($categories)) {
                 $categories_list .= ' ';
                 //separator
             }
         } else {
             if ($category->slug != 'uncategorized' || $category->name != 'Uncategorized') {
                 $categories_list .= '<a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__('View all posts in %s', 'inti'), $category->name) . '"><span class="label category">' . $category->name . '</span></a>';
                 if ($count != count($categories)) {
                     $categories_list .= ' ';
                     //separator
                 }
             }
         }
     }
     return $categories_list;
 }
Exemplo n.º 2
6
function the_breadcrumb()
{
    global $post;
    if (!is_home()) {
        echo '<div class="main_breadcrum"><p><a href="'. get_option('home') .'"> Home </a> > ';
        if ( is_category() || is_single() ) {
            foreach( ( get_the_category() ) as $category ) {
                if ( $category->cat_name != 'Slider' ) {
                    echo '<a href="'. get_category_link( $category->term_id ) .'" title="'. $category->name .'" ' . '>'. $category->name .'</a> ';
                }
            }
            echo '</p></div>'; 
        } elseif ( is_page() ) {
            if( $post->post_parent ){
                $result = get_post_ancestors( $post->ID );
                $title = get_the_title();
                $output = '';
                $anc = array_reverse( $result );
                foreach ( $anc as $ancestor ) {
                    $output .= '<a href="'. get_permalink( $ancestor ) .'" title="'. get_the_title( $ancestor ) .'">'.get_the_title( $ancestor ) .'</a> > ';
                }
                echo $output;
                echo '<strong title="'. $title .'"> '. $title .'</strong></p></div>';
            } else {
                echo '<strong> '. get_the_title() .'</strong></p></div>';
            }
        }
    }
}
function CTF_snippet($atts)
{
    extract(shortcode_atts(array('category' => '', 'link' => '', 'date' => '', 'dofollow' => FALSE), $atts));
    global $post;
    $snippet = "{$postid}<div class=\"ctf-snippet\">";
    $snippet .= "<span class=\"ctf-title\">CTF:</span> <span class=\"ctf-value\">";
    if (empty($category)) {
        //Default category (1st category)
        $snippet .= "<a href=\"" . get_category_link(get_the_category($post->ID)[0]->cat_ID) . "\" rel=\"category tag\">" . get_the_category($post->ID)[0]->name . "</a>";
    } else {
        $snippet .= $category;
    }
    $snippet .= "</span>";
    $snippet .= "<br />";
    $snippet .= "<span class=\"ctf-title\">Link to challenge:</span> <span class=\"ctf-value\">";
    //Generate link
    if (!empty($link)) {
        $snippet .= "<a href=\"{$link}\" rel=\"external";
        if (!$dofollow) {
            $snippet .= " nofollow";
        }
        $pu = parse_url($link);
        $link_base = $pu["scheme"] . "://" . $pu["host"];
        $snippet .= "\">{$link_base}</a>";
        $snippet .= "<img class=\"external_url\" src=\"" . get_stylesheet_directory_uri() . "/images/external-link.png\" />";
    } else {
        $snippet .= "N/A";
    }
    $snippet .= "</span><br />";
    //Date of completion
    $snippet .= "<span class=\"ctf-title\">Date Completed:</span> <span class=\"ctf-value\">{$date}</span>";
    $snippet .= "</div>";
    return $snippet;
}
Exemplo n.º 4
0
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  * @since 1.0.0
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 function widget($args, $instance)
 {
     // Extract args
     extract($args, EXTR_SKIP);
     $category_id = empty($instance['category_id']) ? 1 : $instance['category_id'];
     $use_cat_title = empty($instance['use_cat_title']) ? 0 : $instance['use_cat_title'];
     $hide_empty_cats = empty($instance['hide_empty_cats']) ? 0 : $instance['hide_empty_cats'];
     $show_post_count = empty($instance['show_post_count']) ? 0 : $instance['show_post_count'];
     $title_link = empty($instance['title_link']) ? 0 : $instance['title_link'];
     if ($use_cat_title) {
         $title = apply_filters('widget_title', get_cat_name($category_id), $instance, $this->id_base);
     } else {
         $title = apply_filters('widget_title', empty($instance['title']) ? __('Sub Categories', 'wpsp') : $instance['title'], $instance, $this->id_base);
     }
     $no_sub_text = '<p>' . __('No sub-categories', 'wpsp') . '</p>';
     $subs = wp_list_categories(array('child_of' => $category_id, 'hide_empty' => $hide_empty_cats, 'show_count' => $show_post_count, 'title_li' => null, 'show_option_none' => '', 'echo' => 0));
     echo $before_widget;
     if ($title_link) {
         echo $before_title . '<a href="' . get_category_link($category_id) . '">' . $title . '</a>' . $after_title;
     } else {
         echo $before_title . $title . $after_title;
     }
     if (!empty($subs)) {
         echo '<ul>' . $subs . '</ul>';
     } else {
         echo $no_sub_text;
     }
     echo $after_widget;
     return $instance;
 }
Exemplo n.º 5
0
function loop_category($category)
{
    $idObj = get_category_by_slug($category);
    $cat_name = $idObj->name;
    if ($category === 'news') {
        $number = 4;
    } else {
        $number = 1;
    }
    $args = array('posts_per_page' => $number, 'category_name' => $category);
    $posts_array = get_posts($args);
    $length = count($posts_array);
    if ($length > 0) {
        echo '<a href="' . get_category_link($idObj->cat_ID) . ' " ><h3 class="big-article-title">' . $cat_name . '</h3></a>';
        global $post;
        foreach ($posts_array as $key => $post) {
            setup_postdata($post);
            if ($key === 0) {
                get_template_part('templates/content', get_post_type() != 'post' ? get_post_type() : get_post_format());
            } else {
                if ($key === 1) {
                    echo '<ul class="other-post-list length' . ($length - 1) . '">';
                }
                get_template_part('templates/content', 'post-intro');
                if ($key === $length) {
                    echo '</ul>';
                }
            }
        }
        wp_reset_postdata();
    }
}
    function widget($args, $instance)
    {
        extract($args);
        $title = empty($instance['title']) ? '' : $instance['title'];
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		<ul class="media-list">
			<?php 
        $args = array('hierarchical' => false, 'pad_counts' => true, 'parent' => 0, 'orderby' => 'count', 'order' => 'DESC');
        $topCat = get_categories($args);
        foreach ($topCat as $category) {
            $attrImg = array('class' => 'pull-left', 'alt' => 'Logo ' . $category->name, 'height' => 40, 'width' => 40, 'title' => $category->name);
            echo '<li class="media"><div class="media-left"><a title="' . $category->name . '" class="media-heading" href="' . get_category_link($category->term_id) . '">';
            z_taxonomy_image($category->term_id, array(40, 40, true), $attrImg);
            echo '</a></div><div class="media-body media-middle">';
            echo '<a title="' . $category->name . '" class="media-heading" href="' . get_category_link($category->term_id) . '">' . $category->name . ' <span class="badge">' . $category->count . '</span></a>';
            echo '</div></li>';
        }
        ?>
		</ul>

	<?php 
        echo $after_widget;
    }
Exemplo n.º 7
0
 function get_category()
 {
     $buffy = '';
     //read the post meta to get the custom primary category
     $td_post_theme_settings = get_post_meta($this->post->ID, 'td_post_theme_settings', true);
     if (!empty($td_post_theme_settings['td_primary_cat'])) {
         //we have a custom category selected
         $selected_category_obj = get_category($td_post_theme_settings['td_primary_cat']);
     } else {
         //get one auto
         $categories = get_the_category($this->post->ID);
         if (!empty($categories[0])) {
             if ($categories[0]->name === TD_FEATURED_CAT and !empty($categories[1])) {
                 $selected_category_obj = $categories[1];
             } else {
                 $selected_category_obj = $categories[0];
             }
         }
     }
     if (!empty($selected_category_obj)) {
         //@todo catch error here
         $buffy .= '<a href="' . get_category_link($selected_category_obj->cat_ID) . '">' . $selected_category_obj->name . '</a>';
     }
     //return print_r($post, true);
     return $buffy;
 }
Exemplo n.º 8
0
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $category_id = empty($instance['category_id']) ? 1 : $instance['category_id'];
        $use_cat_title = empty($instance['use_cat_title']) ? 0 : $instance['use_cat_title'];
        $hide_empty_cats = empty($instance['hide_empty_cats']) ? 0 : $instance['hide_empty_cats'];
        $show_post_count = empty($instance['show_post_count']) ? 0 : $instance['show_post_count'];
        $title_link = empty($instance['title_link']) ? 0 : $instance['title_link'];
        $excluded = empty($instance['excluded']) ? '' : $instance['excluded'];
        $sub_subs = empty($instance['sub_subs']) ? 0 : $instance['sub_subs'];
        $dropdown = empty($instance['dropdown']) ? 0 : $instance['dropdown'];
        $post_is_parent = empty($instance['post_is_parent']) ? 0 : $instance['post_is_parent'];
        $dropdown_text = empty($instance['dropdown_text']) ? __('Select Sub-category', 'sub-categories-widget') : $instance['dropdown_text'];
        $list_order = empty($instance['list_order']) ? 0 : $instance['list_order'];
        if ($post_is_parent) {
            $category = get_the_category();
            $category_id = $category ? $category[0]->cat_ID : 1;
        }
        if ($use_cat_title) {
            $title = apply_filters('widget_title', get_cat_name($category_id), $instance, $this->id_base);
        } else {
            $title = apply_filters('widget_title', empty($instance['title']) ? __('Sub Categories', 'sub-categories-widget') : $instance['title'], $instance, $this->id_base);
        }
        $parent = $sub_subs == 1 ? 'child_of' : 'parent';
        $order = $list_order == 1 ? 'DESC' : 'ASC';
        $no_sub_text = '<p>' . __('No sub-categories', 'sub-categories-widget') . '</p>';
        $subs = wp_list_categories(array($parent => $category_id, 'hide_empty' => $hide_empty_cats, 'show_count' => $show_post_count, 'exclude' => $excluded, 'title_li' => null, 'show_option_none' => '', 'echo' => 0, 'orderby' => 'ID', 'order' => $order));
        if ($post_is_parent == 0 || $post_is_parent == 1 && !empty($subs)) {
            echo $before_widget;
            if ($title_link) {
                echo $before_title . '<a href="' . get_category_link($category_id) . '">' . $title . '</a>' . $after_title;
            } else {
                echo $before_title . $title . $after_title;
            }
            if ($dropdown == 0) {
                if (!empty($subs)) {
                    echo '<ul>' . $subs . '</ul>';
                } else {
                    echo $no_sub_text;
                }
            } else {
                $subs = wp_dropdown_categories(array('id' => 'sub-cat-' . $this->number, 'show_option_none' => $dropdown_text, $parent => $category_id, 'hide_empty' => $hide_empty_cats, 'show_count' => $show_post_count, 'exclude' => $excluded, 'hide_if_empty' => true, 'echo' => false, 'orderby' => 'ID', 'order' => $order));
                if (!empty($subs)) {
                    echo $subs;
                    echo '<script type="text/javascript">
						/* <![CDATA[ */
						var dropdown' . $this->number . ' = document.getElementById("sub-cat-' . $this->number . '");
						function onSubCatChange() {
						if (dropdown' . $this->number . '.options[dropdown' . $this->number . '.selectedIndex].value > 0) { location.href = "' . get_option('home') . '?cat="+dropdown' . $this->number . '.options[dropdown' . $this->number . '.selectedIndex].value; }
						}
						dropdown' . $this->number . '.onchange = onSubCatChange;
						/* ]]> */
						</script>';
                } else {
                    echo $no_sub_text;
                }
            }
            echo $after_widget;
        }
    }
Exemplo n.º 9
0
 function widget($args, $instance)
 {
     extract($args);
     $c = $instance['count'] ? '1' : '0';
     $archive_type = $instance['archive_type'] ? '1' : '0';
     $title = apply_filters('widget_title', __('Archives', 'unspoken'));
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     if ($archive_type == 0) {
         $categories = get_categories();
         $output = '<ul>';
         foreach ($categories as $category) {
             $output .= sprintf('<li><a href="%1$s" title="%2$s">%3$s</a><span>%4$s</span></li>', get_category_link($category->term_id), sprintf(__('View all posts in %s', 'unspoken'), $category->name), $category->name, $c ? $category->count : '');
         }
         $output .= '</ul>';
     } else {
         global $wpdb, $wp_locale;
         // set limit for list
         $archive_limit = 0;
         // query
         $q = "SELECT YEAR(post_date) AS 'year', MONTH(post_date) AS 'month', COUNT(ID) as post_count " . "FROM {$wpdb->posts} " . "WHERE post_type = 'post' AND post_status = 'publish' " . "GROUP BY month, year " . "ORDER BY post_date DESC" . ($archive_limit == 0 ? '' : ' LIMIT ' . $archive_limit);
         // make query for result
         $months = $wpdb->get_results($q);
         $output = '<ul>';
         // looping through result
         foreach ($months as $month) {
             $output .= sprintf('<li><a href="%1$s">%2$s<span>%3$s</span></a></li>', get_month_link($month->year, $month->month), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month->month), $month->year), $c ? $month->post_count : '');
         }
         $output .= '</ul>';
     }
     echo $output;
     echo $after_widget;
 }
 private function _meta_data($view, $params)
 {
     $defaults = array('class' => '');
     $params = wp_parse_args($params, $defaults);
     $content = '';
     // Date
     $content .= '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" class="blog_date"><i class="icon-calendar"></i>' . get_the_date('F j, Y') . '</a>';
     // Categories
     $post_categories = wp_get_post_categories(get_the_ID());
     $categories = array();
     foreach ($post_categories as $c) {
         $cat = get_category($c);
         $categories[] = '<a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a>';
     }
     if (count($categories) > 0) {
         $content .= '<div class="blog_category"><i class="icon-tag"></i>' . implode(', ', $categories) . '</div>';
     }
     // Author
     $content .= '<span class="blog_author"><i class="icon-user"></i>' . get_the_author() . '</span>';
     $post_tags = wp_get_post_tags(get_the_ID());
     $tags = array();
     foreach ($post_tags as $tag) {
         $tags[] = '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a>';
     }
     if (count($tags) > 0) {
         $content .= '<div class="blog_category"><i class="icon-tag"></i>' . implode(', ', $tags) . '</div>';
     }
     return '<div class="' . $params['class'] . '">' . $content . '</div>';
 }
 function widget($args, $instance)
 {
     /* Get title */
     $args['title'] = $instance['title'];
     /* If empty, default */
     if (!$args['title']) {
         $args['title'] = 'Popular Categorys';
     }
     /* Get nnpopularcats */
     $args['npopularcats'] = $instance['npopularcats'];
     /* If empty, default 10 */
     if (!$args['npopularcats']) {
         $args['npopularcats'] = 10;
     }
     /* Get popular cats */
     global $wpdb;
     $query = "SELECT a.name, a.slug, b.term_id, b.count FROM {$wpdb->term_taxonomy} b\n    \t\t\tLEFT JOIN {$wpdb->terms} a\n    \t\t\tON b.term_id = a.term_id\n    \t\t\tWHERE b.taxonomy = 'category'\n    \t\t\tORDER BY b.count DESC\n    \t\t\tLIMIT " . $args['npopularcats'];
     $get_categories = $wpdb->get_results($query);
     // Prepare cats list
     $list = '<ul class="popular-category-list">';
     foreach ($get_categories as $cat) {
         $list .= '<li><a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a></li>';
     }
     $list .= '</ul>';
     // Print everything
     echo $args['before_widget'] . $args['before_title'] . $args['title'] . $args['after_title'];
     echo $list;
     echo $args['after_widget'];
 }
Exemplo n.º 12
0
function run_menu()
{
    $Menu = [];
    $args = array('orderby' => 'name', 'parent' => 0);
    $categories = get_categories($args);
    foreach ($categories as $key => $category) {
        $children = get_terms($category->taxonomy, array('parent' => $category->term_id, 'hide_empty' => false));
        if ($children) {
            $genre = $category->name;
            $list = '<li class="has-children"><a href="#0">' . $genre . '</a><ul class="is-hidden here"><li class="go-back"><a href="#0">' . $genre . '</a></li><li class="see-all"><a href="' . get_category_link($category->term_id) . '">All ' . $genre . '</a></li>';
            $ChildCats = get_categories('child_of=' . $category->cat_ID);
            foreach ($ChildCats as $ChildCat) {
                $option = '<li><a href="' . get_category_link($ChildCat->term_id) . '">';
                $option .= $ChildCat->cat_name;
                $option .= '</a></li>';
                $list .= $option;
            }
            $list .= '</ul></li>';
        } else {
            $list = '<li><a href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
        }
        $Menu[] = $list;
    }
    return $Menu;
    //print_r($Menu);
}
Exemplo n.º 13
0
function woo_tumblog_category_link($post_id = 0, $type = 'articles')
{
    $category_link = '';
    if (get_option('woo_tumblog_content_method') == 'post_format') {
        $post_format = get_post_format();
        if ($post_format == '') {
            $category = get_the_category();
            $category_name = $category[0]->cat_name;
            // Get the ID of a given category
            $category_id = get_cat_ID($category_name);
            // Get the URL of this category
            $category_link = get_category_link($category_id);
        } else {
            $category_link = get_post_format_link($post_format);
        }
    } else {
        $tumblog_list = get_the_term_list($post_id, 'tumblog', '', '|', '');
        $tumblog_array = explode('|', $tumblog_list);
        ?>
		<?php 
        $tumblog_items = array('articles' => get_option('woo_articles_term_id'), 'images' => get_option('woo_images_term_id'), 'audio' => get_option('woo_audio_term_id'), 'video' => get_option('woo_video_term_id'), 'quotes' => get_option('woo_quotes_term_id'), 'links' => get_option('woo_links_term_id'));
        ?>
		<?php 
        // Get the ID of Tumblog Taxonomy
        $category_id = $tumblog_items[$type];
        $term =& get_term($category_id, 'tumblog');
        // Get the URL of Articles Tumblog Taxonomy
        $category_link = get_term_link($term, 'tumblog');
    }
    return $category_link;
}
Exemplo n.º 14
0
 function render($atts, $content = null)
 {
     parent::render($atts);
     $buffy = '';
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     // exclude categories from the demo
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '90, 91, 92, 93 , 94, 95, 96, 97, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 82, 83, 84, 85, 86, 87, 88, 89, 98, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     // has a limit of 6 by default
     $buffy .= '<div class="' . $this->get_block_classes(array('widget', 'widget_categories')) . '">';
     $buffy .= $this->get_block_title();
     if (!empty($categories)) {
         $buffy .= '<ul class="td-pb-padding-side">';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
Exemplo n.º 15
0
 /**
  * Get the categories attached to this post
  * @return array
  */
 public function categories()
 {
     $categories = get_the_category($this->wp_post);
     return array_map(function ($category) {
         return (object) array_merge((array) $category, ['url' => get_category_link($category->term_id)]);
     }, $categories);
 }
Exemplo n.º 16
0
 function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0)
 {
     if (!isset($td_last_category_objects[$depth])) {
         $this->td_category_hierarchy[$depth] = $category;
     }
     if ($depth == 0) {
         //reset the parrents
         $this->td_category_hierarchy = array();
         //put the
         $this->td_category_hierarchy[0] = $category;
         //add first parent
         $this->td_category_buffer['<a href="' . get_category_link($category->term_id) . '" target="_blank" data-is-category-link="yes">' . $category->name . '</a>'] = $category->term_id;
     } else {
         $td_tmp_buffer = '';
         $last_cat_id = 0;
         foreach ($this->td_category_hierarchy as $parent_cat_obj) {
             if ($td_tmp_buffer === '') {
                 $td_tmp_buffer = '<a href="' . get_category_link($parent_cat_obj->term_id) . '" target="_blank" data-is-category-link="yes">' . $parent_cat_obj->name . '</a>';
                 $last_cat_id = $parent_cat_obj->term_id;
             } else {
                 $td_tmp_buffer .= '<img src="' . get_template_directory_uri() . '/wp-admin/images/panel/panel-breadcrumb.png" class="td-panel-breadcrumb">' . '<a href="' . get_category_link($parent_cat_obj->term_id) . '" target="_blank" data-is-category-link="yes">' . $parent_cat_obj->name . '</a>';
                 $last_cat_id = $parent_cat_obj->term_id;
             }
         }
         //add child
         $this->td_category_buffer[$td_tmp_buffer] = $last_cat_id;
     }
 }
Exemplo n.º 17
0
/**
* @desc weighted categories cloud with options for fontsize, color, after html, before html, exludecategories
* @param int $smallest	- fontsize of the smallest category
* @param int $largest	- fontsize of the largest category
* @param string $unit	- unit for the fontsize % / px /
* @param string $cold 	- fontcolor for the coldest cat
* @param string $hot 	- fontcolor for the hottest cat
* @param string $before	- html before each cat link
* @param string $after 	- html after each cat link
* @param string $exclude- categories to exclude as comma seperated list
* @author george leciejewski / Christoph Wimmer
*/
function categories_cloud($smallest = 50, $largest = 200, $unit = "%", $cold = "", $hot = "", $before = '', $after = '', $exclude = '')
{
    global $wpdb;
    $exclusions = '';
    if (!empty($exclude)) {
        # set excluded category ids for sql
        $excats = preg_split('/[\\s,]+/', $exclude);
        if (count($excats)) {
            foreach ($excats as $excat) {
                $exclusions .= ' AND ' . $wpdb->categories . '.cat_ID <> ' . intval($excat) . ' ';
            }
        }
    }
    # returns the categories as objects $result->post, id, name, nicename
    $results = $wpdb->get_results('SELECT ' . $wpdb->categories . '.cat_ID AS `id`,' . $wpdb->categories . '.cat_name AS `name`,' . $wpdb->categories . '.category_nicename AS `nicename`' . ',COUNT(' . $wpdb->post2cat . '.rel_id) AS `posts` FROM ' . $wpdb->categories . ', ' . $wpdb->post2cat . ' WHERE ' . $wpdb->categories . '.cat_ID = ' . $wpdb->post2cat . '.category_id' . $exclusions . ' GROUP BY ' . $wpdb->categories . '.cat_ID ORDER BY cat_name ASC');
    $content = array();
    foreach ($results as $key => $val) {
        # normalize the values to fit into KingCloud Class content var
        $content[$key]['url'] = get_category_link($val->id);
        $content[$key]['text'] = stripslashes($val->name);
        $content[$key]['title'] = $val->posts . ' Artikel';
        $content[$key]['count'] = $val->posts;
    }
    $cloud = new KingCloud($content, $smallest, $largest, $unit, $cold, $hot, $before, $after);
    $cloud->output();
}
Exemplo n.º 18
0
 function get_block_sub_cats($atts)
 {
     extract(shortcode_atts(array('limit' => 5, 'sort' => '', 'category_id' => '', 'category_ids' => '', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'show_child_cat' => '', 'sub_cat_ajax' => ''), $atts));
     $buffy = '';
     if (!empty($show_child_cat) and !empty($category_id)) {
         $td_subcategories = get_categories(array('child_of' => $category_id));
         if (!empty($td_subcategories)) {
             if ($show_child_cat != 'all') {
                 $td_subcategories = array_slice($td_subcategories, 0, $show_child_cat);
             }
             $buffy .= '<div class="block-mega-child-cats">';
             //show all categories only on ajax
             if (empty($sub_cat_ajax)) {
                 $buffy .= '<div><a class="cur-sub-cat ajax-sub-cat-mega sub-cat-' . $this->block_uid . '" id="sub-cat-' . $this->block_uid . '-' . $category_id . '" data-cat_id="' . $category_id . '"
                     data-td_block_id="' . $this->block_uid . '" href="' . get_category_link($category_id) . '">' . __td('All') . '</a></div>';
             }
             foreach ($td_subcategories as $td_category) {
                 if (empty($sub_cat_ajax)) {
                     $buffy .= '<div><a class="ajax-sub-cat-mega sub-cat-' . $this->block_uid . '" id="sub-cat-' . $this->block_uid . '-' . $td_category->cat_ID . '" data-cat_id="' . $td_category->cat_ID . '" data-td_block_id="' . $this->block_uid . '" href="' . get_category_link($td_category->cat_ID) . '">' . $td_category->name . '</a></div>';
                 } else {
                     $buffy .= '<div><a href="' . get_category_link($td_category->cat_ID) . '">' . $td_category->name . '</a></div>';
                 }
             }
             $buffy .= '</div>';
         } else {
             //there are no subcategories, return false - this is used by the mega menu block to alter it's structure
             return false;
         }
     }
     return $buffy;
 }
function list_categories_from_current_blog_post()
{
    $postCats = get_the_category();
    if ($postCats) {
        ?>
    	
      <h5>Catorgories</h5>

      <ul>

      <?php 
        //the_terms($post->ID,"service_type", '', ', ', ' ');
        ?>

      <?php 
        //customPostTypeCatList('post');
        $separator = '';
        $output = '';
        if ($postCats) {
            foreach ($postCats as $category) {
                $output .= '<li><a href="' . get_category_link($category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '">' . $category->cat_name . '</a></li>' . $separator;
            }
            echo trim($output, $separator);
        }
    }
    echo '</ul>';
}
Exemplo n.º 20
0
 function widget($args, $instance)
 {
     extract($args);
     $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
     $limit = is_numeric($instance['limit']) ? $instance['limit'] : 5;
     $orderby = $instance['orderby'] ? $instance['orderby'] : 'date';
     $order = $instance['order'] ? $instance['order'] : 'desc';
     $exclude = $instance['exclude'] != '' ? $instance['exclude'] : 0;
     $excludeposts = $instance['excludeposts'] != '' ? $instance['excludeposts'] : 0;
     $offset = is_numeric($instance['offset']) ? $instance['offset'] : 0;
     $category_id = $instance['categoryid'];
     $dateformat = $instance['dateformat'] ? $instance['dateformat'] : get_option('date_format');
     $showdate = $instance['show_date'] == 'on' ? 'yes' : 'no';
     $showexcerpt = $instance['show_excerpt'] == 'on' ? 'yes' : 'no';
     $excerptsize = empty($instance['excerpt_size']) ? 55 : $instance['excerpt_size'];
     $showauthor = $instance['show_author'] == 'on' ? 'yes' : 'no';
     $showcatlink = $instance['show_catlink'] == 'on' ? 'yes' : 'no';
     $thumbnail = $instance['thumbnail'] == 'on' ? 'yes' : 'no';
     $thumbnail_size = $instance['thumbnail_size'] ? $instance['thumbnail_size'] : 'thumbnail';
     $morelink = empty($instance['morelink']) ? ' ' : $instance['morelink'];
     $atts = array('id' => $category_id, 'orderby' => $orderby, 'order' => $order, 'numberposts' => $limit, 'date' => $showdate, 'author' => $showauthor, 'dateformat' => $dateformat, 'template' => 'default', 'excerpt' => $showexcerpt, 'excerpt_size' => $excerptsize, 'exclude' => $exclude, 'excludeposts' => $excludeposts, 'offset' => $offset, 'catlink' => $showcatlink, 'thumbnail' => $thumbnail, 'thumbnail_size' => $thumbnail_size, 'morelink' => $morelink);
     echo $before_widget;
     if ($title == 'catlink') {
         //if the user has setup 'catlink' as the title, replace it with the category link:
         $lcp_category = get_category($category_id);
         $title = '<a href="' . get_category_link($lcp_category->cat_ID) . '">' . $lcp_category->name . '</a>';
     }
     echo $before_title . $title . $after_title;
     $catlist_displayer = new CatListDisplayer($atts);
     echo $catlist_displayer->display();
     echo $after_widget;
 }
Exemplo n.º 21
0
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $sticky = isset($instance['sticky']) ? $instance['sticky'] : 1;
        if ($category) {
            $cat_url = get_category_link($category);
            $before_title = $before_title . '<a href="' . esc_url($cat_url) . '" class="widget-title-link">';
            $after_title = '</a>' . $after_title;
        }
        echo $before_widget;
        if (!empty($title)) {
            echo $before_title . esc_attr($title) . $after_title;
        }
        $args = array('posts_per_page' => '1', 'offset' => $offset, 'cat' => $category, 'ignore_sticky_posts' => $sticky);
        $widget_loop = new WP_Query($args);
        ?>
		<div class="mh-fp-large-widget clearfix"><?php 
        while ($widget_loop->have_posts()) {
            $widget_loop->the_post();
            get_template_part('content', 'lead');
            echo '<hr class="mh-separator">' . "\n";
        }
        wp_reset_postdata();
        ?>
		</div><?php 
        echo $after_widget;
    }
Exemplo n.º 22
0
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  * @since 1.0.0
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 function widget($args, $instance)
 {
     // Extract args
     extract($args, EXTR_SKIP);
     $category_id = empty($instance['category_id']) ? 1 : $instance['category_id'];
     $post_num = empty($instance['post_num']) ? 5 : $instance['post_num'];
     $use_cat_title = empty($instance['use_cat_title']) ? 0 : $instance['use_cat_title'];
     $title_link = empty($instance['title_link']) ? 0 : $instance['title_link'];
     if ($use_cat_title) {
         $title = apply_filters('widget_title', get_cat_name($category_id), $instance, $this->id_base);
     } else {
         $title = apply_filters('widget_title', empty($instance['title']) ? __('Listen to Broadcast', 'wpsp') : $instance['title'], $instance, $this->id_base);
     }
     echo $before_widget;
     if ($title_link) {
         echo $before_title . '<a href="' . get_category_link($category_id) . '">' . $title . '</a>' . $after_title;
     } else {
         echo $before_title . $title . $after_title;
     }
     global $post;
     $args = array();
     $defaults = array('post_type' => 'post', 'posts_per_page' => (int) $post_num, 'post__not_in' => array($post->ID), 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-audio')), array('taxonomy' => 'category', 'field' => 'term_id', 'terms' => array($category_id))));
     $args = wp_parse_args($args, $defaults);
     extract($args);
     $custom_query = new WP_Query($args);
     if ($custom_query->have_posts()) {
         while ($custom_query->have_posts()) {
             $custom_query->the_post();
             get_template_part('partials/content', 'radio');
         }
         wp_reset_postdata();
     }
     echo $after_widget;
     return $instance;
 }
Exemplo n.º 23
0
 function sourdough_get_categories($sep = ', ', $before = '', $after = '')
 {
     /*
     Echoes the categories with the parent of each as a css class.
     Allows you to style each category link based on it's parent.
     Must be used within the loop.
     
     Example:
         <a href="/category" class="parent-class">cagtegory Name</a>
     */
     $total_cats = count(get_the_category());
     $i = 0;
     foreach (get_the_category() as $cat) {
         ++$i;
         $parent = get_category($cat->parent);
         $link = get_category_link($cat->cat_ID);
         echo $before;
         if (!$parent->errors) {
             echo '<a href="' . $link . '" title="' . $cat->name . '" class="' . $parent->slug . '">' . $cat->name . '</a>';
         } else {
             echo '<a href="' . $link . '" title="' . $cat->name . '">' . $cat->name . '</a>';
         }
         if ($i < $total_cats) {
             echo $sep;
         }
         echo $after;
     }
 }
Exemplo n.º 24
0
 function cats()
 {
     foreach (wp_get_post_categories(get_the_ID()) as $c) {
         $cat = get_category($c);
         return ' - <a href="' . get_category_link($cat) . '" title="' . $cat->name . '" class="category">' . $cat->name . '</a>';
     }
 }
Exemplo n.º 25
0
 private function build_output($tag)
 {
     $this->lcp_output .= $this->get_category_link('strong');
     $this->lcp_output .= '<' . $tag;
     //Give a class to wrapper tag
     if (isset($this->params['class'])) {
         $this->lcp_output .= ' class="' . $this->params['class'] . '"';
     }
     $this->lcp_output .= '>';
     $inner_tag = $tag == 'ul' ? 'li' : 'p';
     //Posts loop
     foreach ($this->catlist->get_categories_posts() as $single) {
         if (!post_password_required($single)) {
             $this->lcp_output .= $this->lcp_build_post($single, $inner_tag);
         }
     }
     //Close wrapper tag
     $this->lcp_output .= '</' . $tag . '>';
     if (!empty($this->params['morelink'])) {
         $href = 'href="' . get_category_link($this->catlist->get_category_id()) . '"';
         $class = "";
         if (!empty($this->params['morelink_class'])) {
             $class = 'class="' . $this->params['morelink_class'] . '" ';
         }
         $readmore = $this->params['morelink'];
         $this->lcp_output .= '<a ' . $href . ' ' . $class . ' >' . $readmore . '</a>';
     }
 }
Exemplo n.º 26
0
    function widget($args, $instance)
    {
        ?>
        <div class="category_widget">
            <div class="title">
                <h4><?php 
        _e('Category', 'sunnypoint');
        ?>
</h4>
            </div>
            <div class="list">
                <?php 
        $all_cats = get_categories();
        foreach ($all_cats as $cat) {
            ?>
                    <div class="category">
                        <div class="number"><span><?php 
            print $cat->count;
            ?>
</span></div>
                        <div class="name"><a href="<?php 
            print get_category_link($cat->cat_ID);
            ?>
 "><p><?php 
            print $cat->name;
            ?>
</p></a></div>
                    </div>
                <?php 
        }
        ?>
            </div>
        </div>
    <?php 
    }
Exemplo n.º 27
0
 function render($atts)
 {
     $this->block_uid = td_global::td_generate_unique_id();
     //update unique id on each render
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '251, 252, 253, 254, 255, 256, 257, 258, 305, 306, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     $buffy = '';
     $buffy .= '<div class="td_block_wrap td_popular_categories widget widget_categories">';
     $buffy .= $this->get_block_title_raw($atts, 'Popular category');
     if (!empty($categories)) {
         $buffy .= '<ul>';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
Exemplo n.º 28
0
function wpm_url($item, $nourl)
{
    switch ($item->type) {
        case 'Home':
            $sof = get_option('show_on_front');
            $pfp = get_option('page_for_posts');
            if ($sof == 'page') {
                $url = $pfp ? get_page_link($pfp) : $nourl;
            } else {
                $url = get_bloginfo('url', 'display');
            }
            return $url;
        case 'FrontPage':
            return get_bloginfo('url', 'display');
        case 'Tag':
            return get_tag_link($item->selection);
        case 'Category':
            return get_category_link($item->selection);
        case 'Page':
            return get_page_link($item->selection);
        case 'Post':
            return get_permalink($item->selection);
        case 'External':
            return $item->selection;
        case 'PHP':
            $out = eval($item->selection);
            return is_array($out) ? $out[1] : $out;
    }
    return $nourl;
}
 function render($atts, $content = null)
 {
     parent::render($atts);
     $buffy = '';
     extract(shortcode_atts(array('limit' => '6', 'custom_title' => '', 'custom_url' => '', 'hide_title' => '', 'header_color' => ''), $atts));
     $cat_args = array('show_count' => true, 'orderby' => 'count', 'hide_empty' => false, 'order' => 'DESC', 'number' => $limit + 1, 'exclude' => get_cat_ID(TD_FEATURED_CAT));
     // exclude categories from the demo
     if (TD_DEPLOY_MODE == 'demo' or TD_DEPLOY_MODE == 'dev') {
         $cat_args['exclude'] = '44,45,46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 110, ' . get_cat_ID(TD_FEATURED_CAT);
     }
     $categories = get_categories($cat_args);
     $buffy .= '<div class="td_block_wrap td_popular_categories widget widget_categories">';
     $buffy .= $this->get_block_title();
     if (!empty($categories)) {
         $buffy .= '<ul class="td-pb-padding-side">';
         foreach ($categories as $category) {
             if (strtolower($category->cat_name) != 'uncategorized') {
                 $buffy .= '<li><a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '<span class="td-cat-no">' . $category->count . '</span></a></li>';
             }
         }
         $buffy .= '</ul>';
     }
     $buffy .= '</div> <!-- ./block -->';
     return $buffy;
 }
Exemplo n.º 30
-2
function ac_output_first_category($class = '', $span_wrap = false)
{
    global $post;
    $output_category = '';
    $gpt = get_post_type(get_the_ID());
    if (has_filter('ac_output_first_category_class_filter')) {
        $applied_class = apply_filters('ac_output_first_category_class_filter', $class);
        if (!empty($applied_class)) {
            $show_class = 'class="' . esc_attr($applied_class) . '" ';
        } else {
            $show_class = '';
        }
    } elseif (!empty($class)) {
        $show_class = 'class="' . esc_attr($class) . '" ';
    } else {
        $show_class = '';
    }
    $category = get_the_category();
    if ($category) {
        $output_category = '<a href="' . get_category_link($category[0]->term_id) . '" ' . $show_class . 'title="' . sprintf(__("View all posts in %s", "justwrite"), $category[0]->name) . '" ' . '>' . $category[0]->name . '</a> ';
    }
    if (!$span_wrap) {
        if ($gpt != 'page' && !empty($category)) {
            echo $output_category;
        }
    } else {
        $output_category = '<span ' . $show_class . '>' . $category[0]->name . '</span> ';
        echo $output_category;
    }
}