Example #1
4
/**
 * News child tags
 */
function ungarh_tag_list()
{
    //get all the options that we want to show
    global $wpdb;
    $tagsToShow = $wpdb->get_results("\n    SELECT SUBSTR(option_name,11) as id\n    FROM wp_options\n    WHERE option_name LIKE 'filter_tag%' and option_value = 'on' and length(option_name) > 10");
    $tagLinks = array();
    foreach ($tagsToShow as $tag) {
        $name = get_tag($tag->id);
        $tagLinks['Alla nyheter'] = home_url('/nyheter');
        $tagLinks[$name->name] = get_tag_link($tag->id);
    }
    if (!is_home() || is_tag()) {
        ?>
    <nav class="sub-pages-nav" role="navigation">
      <ul class="nav sub-pages">
        <?php 
        foreach ($tagLinks as $key => $value) {
            echo '<li><a href="' . $value . '">' . $key . '</a></li>';
        }
        ?>
      </ul>
    </nav>
  <?php 
    }
}
 function widget($args, $instance)
 {
     /* PRINT THE WIDGET */
     extract($args, EXTR_SKIP);
     $title = !empty($instance['title']) ? $instance['title'] : '';
     if (is_singular('post') && has_tag()) {
         global $post;
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title;
             echo $title;
             echo $after_title;
         }
         echo '<div class="tagcloud">';
         $tags = wp_get_post_tags($post->ID);
         foreach ($tags as $t => $tag) {
             echo '<a href="' . get_tag_link($tag->term_id) . '" title="' . $tag->count . ' topic">';
             echo $tag->name;
             echo '</a>';
         }
         echo '<div class="clear"></div>';
         echo '</div>';
         echo $after_widget;
     }
 }
 /**
  * Triggers on a change event and adds the relevant URL's to the ban list
  *
  * Function inspired by Varnish HTTP Purge
  * https://github.com/Ipstenu/varnish-http-purge/blob/master/plugin/varnish-http-purge.php#L277
  *
  * @param  [type] $postId [description]
  * @return [type]         [description]
  */
 protected function handleChange($postId)
 {
     // If this is a valid post we want to purge the post, the home page and any associated tags & cats
     // If not, purge everything on the site.
     $validPostStatus = array("publish", "trash");
     $thisPostStatus = get_post_status($postId);
     // If this is a revision, stop.
     if (get_permalink($postId) !== true && !in_array($thisPostStatus, $validPostStatus)) {
         return;
     } else {
         // array to collect all our URLs
         $listofurls = array();
         // Category purge based on Donnacha's work in WP Super Cache
         $categories = get_the_category($postId);
         if ($categories) {
             foreach ($categories as $cat) {
                 $this->invalidateUrl(get_category_link($cat->term_id));
             }
         }
         // Tag purge based on Donnacha's work in WP Super Cache
         $tags = get_the_tags($postId);
         if ($tags) {
             foreach ($tags as $tag) {
                 $this->invalidateUrl(get_tag_link($tag->term_id));
             }
         }
         // Author URL
         $this->invalidateUrl(get_author_posts_url(get_post_field('post_author', $postId)));
         $this->invalidateUrl(get_author_feed_link(get_post_field('post_author', $postId)));
         // Archives and their feeds
         $archiveurls = array();
         if (get_post_type_archive_link(get_post_type($postId)) == true) {
             $this->invalidateUrl(get_post_type_archive_link(get_post_type($postId)));
             $this->invalidateUrl(get_post_type_archive_feed_link(get_post_type($postId)));
         }
         // Post URL
         $this->invalidateUrl(get_permalink($postId));
         // Feeds
         $this->invalidateUrl(get_bloginfo_rss('rdf_url'));
         $this->invalidateUrl(get_bloginfo_rss('rss_url'));
         $this->invalidateUrl(get_bloginfo_rss('rss2_url'));
         $this->invalidateUrl(get_bloginfo_rss('atom_url'));
         $this->invalidateUrl(get_bloginfo_rss('comments_rss2_url'));
         $this->invalidateUrl(get_post_comments_feed_link($postId));
         // Home Page and (if used) posts page
         $this->invalidateUrl(home_url('/'));
         if (get_option('show_on_front') == 'page') {
             $this->invalidateUrl(get_permalink(get_option('page_for_posts')));
         }
     }
     // Filter to add or remove urls to the array of purged urls
     // @param array $purgeUrls the urls (paths) to be purged
     // @param int $postId the id of the new/edited post
     // $this->invalidateUrls = apply_filters( 'vhp_purge_urls', $this->invalidateUrls, $postId );
 }
Example #4
0
function My_TagCloud($params = array())
{
    extract(shortcode_atts(array('orderby' => 'name', 'order' => 'ASC', 'number' => '', 'wrapper' => '', 'sizeclass' => 'tagSize-', 'sizemin' => 1, 'sizemax' => 5), $params));
    // initialize
    $ret = '';
    $min = 9999999;
    $max = 0;
    // fetch all WordPress tags
    $tags = get_tags(array('orderby' => $orderby, 'order' => $order, 'number' => $number));
    // get minimum and maximum number tag counts
    foreach ($tags as $tag) {
        $min = min($min, $tag->count);
        $max = max($max, $tag->count);
    }
    // generate tag list
    foreach ($tags as $tag) {
        $url = get_tag_link($tag->term_id);
        if ($max > $min) {
            $class = $sizeclass . floor(($tag->count - $min) / ($max - $min) * ($sizemax - $sizemin) + $sizemin);
        } else {
            $class = $sizeclass;
        }
        $ret .= ($wrapper ? '<' . $wrapper . ' class="tagWrapper">' : '') . '<a href="' . $url . '" class="' . $class . ' link">' . $tag->name . '</a>' . ($wrapper ? '</' . $wrapper . '>' : '');
    }
    return str_replace(get_bloginfo('url'), '', $ret);
}
Example #5
0
 function widget($args, $instance)
 {
     global $wp_query;
     $facets = elasticsearch\Faceting::all();
     $url = null;
     if (is_category() || is_tax()) {
         $url = get_term_link($wp_query->queried_object);
     } elseif (is_tag()) {
         $url = get_tag_link($wp_query->queried_object->term_id);
     } elseif (is_archive()) {
         $url = get_post_type_archive_link($wp_query->queried_object->query_var);
     } elseif (is_search()) {
         $url = home_url('/');
     }
     foreach ($facets as $type => $facet) {
         if (count($facet['selected']) > 0) {
             $name = $type;
             if (taxonomy_exists($type)) {
                 $name = get_taxonomy($type)->label;
             }
             echo '<aside id="facet-' . $type . '-selected" class="widget facets facets-selected">';
             echo '<h3 class="widget-title">' . $name . '</h3>';
             echo '<ul>';
             foreach ($facet['selected'] as $option) {
                 $url = elasticsearch\Faceting::urlRemove($url, $type, $option['slug']);
                 echo '<li id="facet-' . $type . '-' . $option['slug'] . '" class="facet-item">';
                 echo '<a href="' . $url . '">' . $option['name'] . '</a>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</aside>';
         }
     }
 }
/**
 * List the tags of posts as links. 
 * 
 * Creates links to tag posts in a comma separated list. 
 * 
 * @param  [array] $posttags  The array of tags
 * @return [string]           String of tags.
 */
function list_tags($posttags)
{
    if (isset($posttags) && is_array($posttags)) {
        foreach ($posttags as $tag) {
            if ($tag === end($posttags)) {
                ?>
				<a href="<?php 
                echo esc_attr(get_tag_link($tag->term_id));
                ?>
"> <?php 
                echo esc_html($tag->name);
                ?>
</a>
				<?php 
            } else {
                ?>
				<a href="<?php 
                echo esc_attr(get_tag_link($tag->term_id));
                ?>
"> <?php 
                echo esc_html($tag->name);
                ?>
</a>
				<?php 
            }
        }
    }
}
function wpml_link_to_element($element_id, $element_type = 'post', $link_text = '', $optional_parameters = array(), $anchor = '', $echoit = true)
{
    if (!function_exists('icl_link_to_element')) {
        switch ($element_type) {
            case 'post':
            case 'page':
                $ret = '<a href="' . get_permalink($element_id) . '">';
                if ($anchor) {
                    $ret .= $anchor;
                } else {
                    $ret .= get_the_title($element_id);
                }
                $ret .= '<a>';
                break;
            case 'tag':
            case 'post_tag':
                $tag = get_term_by('id', $element_id, 'tag', ARRAY_A);
                $ret = '<a href="' . get_tag_link($element_id) . '">' . $tag->name . '</a>';
            case 'category':
                $ret = '<a href="' . get_tag_link($element_id) . '">' . get_the_category_by_ID($element_id) . '</a>';
            default:
                $ret = '';
        }
        if ($echoit) {
            echo $ret;
        } else {
            return $ret;
        }
    } else {
        return icl_link_to_element($element_id, $element_type, $link_text, $optional_parameters, $anchor, $echoit);
    }
}
Example #8
0
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_name', $instance['title']);
     $count = $instance['count'];
     $offset = $instance['offset'];
     echo $before_widget;
     echo $before_title . $title . $after_title;
     /**
     * <div class="side-hot">
     		<h2>热门话题</h2>
     		<div class="hot-qui">
     		<?php wp_tag_cloud('smallest=12&largest=18&unit=px&number=20&orderby=count&order=DESC');?>
     		</div>
     		</div>
     */
     echo '<div class="side-hot"><h2>热门话题</h2><div class="hot-qui">';
     $tags_list = get_tags('smallest=12&largest=18&unit=px&orderby=count&order=DESC&number=' . $count . '&offset=' . $offset);
     if ($tags_list) {
         foreach ($tags_list as $tag) {
             echo '<a href="' . get_tag_link($tag) . '">' . $tag->name . ' (' . $tag->count . ')</a>';
         }
     } else {
         echo '暂无标签!';
     }
     echo '</div></div>';
     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>';
 }
    /**
     * Outputs the HTML for this widget.
     *
     * @param array  An array of standard parameters for widgets in this theme
     * @param array  An array of settings for this widget instance
     * @return void Echoes it's output
     **/
    function widget($args, $instance)
    {
        extract($args, EXTR_SKIP);
        $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
        $text = empty($instance['text']) ? ' ' : apply_filters('widget_title', $instance['text']);
        echo $before_widget;
        echo $before_title;
        echo $title;
        // Can set this with a widget option, or omit altogether
        echo $after_title;
        //
        // Widget display logic goes here
        //
        /*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo*/
        /* Here We Go, BUild the Gate to prevent headache to find out which the Output*/
        /*oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo*/
        ?>
	<?php 
        $tags = get_tags();
        $html = '<div class="tags">';
        foreach ($tags as $tag) {
            $tag_link = get_tag_link($tag->term_id);
            $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>#";
            $html .= "{$tag->name}</a>";
        }
        $html .= '</div>';
        echo $html;
        ?>

    <?php 
        echo $after_widget;
    }
Example #11
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;
}
Example #12
0
function core_header_tag_cloud($tags, $args = '')
{
    global $wp_rewrite;
    $defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC');
    $args = wp_parse_args($args, $defaults);
    extract($args);
    if (!$tags) {
        return;
    }
    $counts = $tag_links = array();
    foreach ((array) $tags as $tag) {
        $counts[$tag->name] = $tag->count;
        $tag_links[$tag->name] = get_tag_link($tag->term_id);
        if (is_wp_error($tag_links[$tag->name])) {
            return $tag_links[$tag->name];
        }
        $tag_ids[$tag->name] = $tag->term_id;
    }
    $min_count = min($counts);
    $spread = max($counts) - $min_count;
    if ($spread <= 0) {
        $spread = 1;
    }
    $font_spread = $largest - $smallest;
    if ($font_spread <= 0) {
        $font_spread = 1;
    }
    $font_step = $font_spread / $spread;
    // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
    if ('name' == $orderby) {
        uksort($counts, 'strnatcasecmp');
    } else {
        asort($counts);
    }
    if ('DESC' == $order) {
        $counts = array_reverse($counts, true);
    }
    $a = array();
    $rel = is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? ' rel="tag"' : '';
    foreach ($counts as $tag => $count) {
        $tag_id = $tag_ids[$tag];
        $tag_link = clean_url($tag_links[$tag]);
        $tag = str_replace(' ', '&nbsp;', wp_specialchars($tag));
        $a[] = "\t<option value='{$tag_link}'>{$tag} ({$count})</option>";
    }
    switch ($format) {
        case 'array':
            $return =& $a;
            break;
        case 'list':
            $return = "<ul class='wp-tag-cloud'>\n\t<li>";
            $return .= join("</li>\n\t<li>", $a);
            $return .= "</li>\n</ul>\n";
            break;
        default:
            $return = join("\n", $a);
            break;
    }
    return apply_filters('core_header_tag_cloud', $return, $tags, $args);
}
 function widget($args, $instance)
 {
     /* PRINT THE WIDGET */
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args((array) $instance, array('title' => null));
     $title = esc_attr($instance['title']);
     if (is_singular('post') && has_tag()) {
         global $post;
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title;
             echo apply_filters('widget_title', $title, $instance, $this->id_base);
             echo $after_title;
         }
         echo '<div class="tagcloud">';
         $tags = wp_get_post_tags($post->ID);
         foreach ($tags as $t => $tag) {
             echo '<a href="' . get_tag_link($tag->term_id) . '" title="' . $tag->count . ' topic">';
             echo $tag->name;
             echo '</a>';
         }
         echo '<div class="clear"></div>';
         echo '</div>';
         echo $after_widget;
     }
 }
 function widget($args, $instance)
 {
     global $post;
     /* PRINT THE WIDGET */
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args((array) $instance, array('title' => ''));
     $title = $instance['title'];
     if (is_singular('post') && has_tag()) {
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title;
             echo apply_filters('widget_title', esc_attr($title), $instance, $this->id_base);
             echo $after_title;
         }
         echo '<div class="tagcloud">';
         $tags = wp_get_post_tags($post->ID);
         foreach ($tags as $t => $tag) {
             $tag_url = get_tag_link($tag->term_id);
             if (is_wp_error($tag_url)) {
                 continue;
             }
             echo '<a href="' . esc_url($tag_url) . '" title="' . absint($tag->count) . '">';
             echo esc_html($tag->name);
             echo '</a>';
         }
         echo '<div class="clearfix"></div>';
         echo '</div>';
         echo $after_widget;
     }
 }
 function widget($args, $instance)
 {
     global $post;
     extract($args);
     $tagstitle = isset($instance['tagstitle']) ? esc_attr($instance['tagstitle']) : '';
     if ($tagstitle == "") {
         $tagstitle = __("Tags", "indonez");
     }
     echo $before_widget;
     echo $before_title . $tagstitle . $after_title;
     $tags = array();
     $posts = get_posts('numberposts=-1');
     foreach ($posts as $p) {
         foreach (wp_get_post_tags($p->ID) as $tag) {
             if (array_key_exists($tag->name, $tags)) {
                 $tags[$tag->name]['count']++;
             } else {
                 $tags[$tag->name]['count'] = 1;
                 $tags[$tag->name]['link'] = get_tag_link($tag->term_id);
             }
         }
     }
     // Show tag cloud
     echo '<div class="tag-cloud">';
     foreach ($tags as $tag_name => $tag) {
         echo '<a href="' . esc_url($tag['link']) . '">' . $tag_name . '</a>';
     }
     echo '</div>';
     echo $after_widget;
 }
/**
 * Display tag cloud.
 *
 * The text size is set by the 'smallest' and 'largest' arguments, which will
 * use the 'unit' argument value for the CSS text size unit. The 'format'
 * argument can be 'flat' (default), 'list', 'nolink', or 'array'. The flat value for the
 * 'format' argument will separate tags with spaces. The list value for the
 * 'format' argument will format the tags in a UL HTML list. The nolink value for the
 * 'format' argument will display the tags without links. The array value for the
 * 'format' argument will return in PHP array type format.
 *
 * The 'orderby' argument will accept 'name' or 'count' and defaults to 'name'.
 * The 'order' is the direction to sort, defaults to 'ASC' and can be 'DESC'.
 *
 * The 'number' argument is how many tags to return. By default, the limit will
 * be to return the top 20 tags in the tag cloud list.
 *
 * The 'topic_count_text_callback' argument is a function, which, given the count
 * of the posts  with that tag, returns a text for the tooltip of the tag link.
 * @see default_topic_count_text
 *
 * The 'exclude' and 'include' arguments are used for the {@link get_tags()}
 * function. Only one should be used, because only one will be used and the
 * other ignored, if they are both set.
 *
 * @since 2.3.0
 *
 * @param array|string $args Optional. Override default arguments.
 * @return array Generated tag cloud, only if no failures and 'array' is set for the 'format' argument.
 */
function seo_tag_cloud($args = '')
{
    $defaults = array('largest' => 10, 'number' => 20, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'target' => '');
    $args = wp_parse_args($args, $defaults);
    $tags = get_tags(array_merge($args, array('orderby' => 'count', 'order' => 'DESC')));
    // Always query top tags
    if (empty($tags)) {
        return;
    }
    foreach ($tags as $key => $tag) {
        if ('edit' == $args['link']) {
            $link = get_edit_tag_link($tag->term_id);
        } else {
            $link = get_tag_link($tag->term_id);
        }
        if (is_wp_error($link)) {
            return false;
        }
        $tags[$key]->link = $link;
        $tags[$key]->id = $tag->term_id;
    }
    $return = seo_tag_cloud_generate($tags, $args);
    // Here's where those top tags get sorted according to $args
    $return = apply_filters('wp_tag_cloud', $return, $args);
    if ('array' == $args['format']) {
        return $return;
    }
    echo $return;
}
Example #17
0
function tags_index_start()
{
    global $mybb, $db, $tags, $theme, $templates, $lang, $collapsedimg, $collapsed;
    if ($mybb->settings['tags_enabled'] == 0 || $mybb->settings['tags_index'] == 0) {
        return;
    }
    $lang->load('tags');
    $mybb->settings['tags_limit'] = (int) $mybb->settings['tags_limit'];
    $order_by = 'RAND()';
    if ($db->type == 'pgsql' || $db->type == 'sqlite') {
        $order_by = 'RANDOM()';
    }
    $query = DBTags::get("SUM(threads.views) as sumviews, tags.name", "tags.name != ''", array('orderBy' => $order_by, 'orderType' => '', 'limit' => "0, {$mybb->settings['tags_limit']}"));
    $tags = $comma = '';
    while ($tag = $db->fetch_array($query)) {
        if (!$tag['name']) {
            continue;
        }
        $tag['name'] = htmlspecialchars_uni($tag['name']);
        $tag['tag_link'] = get_tag_link($tag['name']);
        $tag['size'] = tags_getsize($tag['sumviews']);
        eval('$tags .= "' . $templates->get('tags_box_tag_sized') . '";');
        $comma = $lang->comma;
    }
    if ($tags != '') {
        eval('$tags = "' . $templates->get('tags_box') . '";');
    }
}
Example #18
0
function wolf_breadcrumbs_get_category_links($page_id = '')
{
    if (strlen(trim($page_id)) > 0) {
        $cat_name = '';
        $cat_url = '';
        $cats = get_the_category($page_id);
        if (count($cats) > 0) {
            $cat = $cats[0];
            $cat_id = $cat->cat_ID;
            $cat_name = $cat->cat_name;
            $cat_url = get_category_link($cat_id);
        }
    } else {
        if (single_tag_title('', false == '')) {
            $cat_id = get_query_var('cat');
            $cat_name = get_cat_name($cat_id);
            $cat_url = get_category_link($cat_id);
        } else {
            $cat_url = get_tag_link(get_query_var('tag_id'));
            $cat_name = single_tag_title('', false);
        }
    }
    $cat_link = '<li>';
    $cat_link .= '<a href="' . $cat_url . '" itemprop="url"><span itemprop="title">' . $cat_name . '</span></a>';
    if (strlen(trim($page_id)) > 0 && strlen(trim($cat_name)) > 0) {
        $cat_link .= '<span class="divider">/</span>';
    }
    $cat_link .= '</li>';
    return $cat_link;
}
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_name', $instance['title']);
     $count = $instance['count'];
     $offset = $instance['offset'];
     $more = $instance['more'];
     $link = $instance['link'];
     $mo = '';
     if ($more != '' && $link != '') {
         $mo = '<a class="btn" href="' . $link . '">' . $more . '</a>';
     }
     echo $before_widget;
     echo $before_title . $mo . $title . $after_title;
     echo '<div class="d_tags">';
     $tags_list = get_tags('orderby=count&order=DESC&number=' . $count . '&offset=' . $offset);
     if ($tags_list) {
         foreach ($tags_list as $tag) {
             echo '<a title="' . $tag->count . '个话题" href="' . get_tag_link($tag) . '">' . $tag->name . ' (' . $tag->count . ')</a>';
         }
     } else {
         echo '暂无标签!';
     }
     echo '</div>';
     echo $after_widget;
 }
Example #20
0
 /**
  * Prints HTML with meta information for the categories, tags and comments.
  */
 function ushipnetwork_entry_footer()
 {
     // Hide category and tag text for pages.
     if ('post' === get_post_type()) {
         $byline = sprintf(esc_html_x('by %s', 'post author', 'ushipnetwork'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
         echo '<div class="byline">' . '<div class="authorship">' . $byline . '</div>' . '<div class="share">';
         include "share.php";
         echo '</div>' . '</div>';
         $posttags = get_the_tags();
         $count = 0;
         $separator = ', ';
         $output = '';
         if (!empty($posttags)) {
             echo '<span class="tag-list">tags: ';
             foreach ($posttags as $posttag) {
                 $count++;
                 if ($count <= 2) {
                     $output .= '<a href="' . esc_url(get_tag_link($posttag->term_id)) . '" alt="' . esc_attr(sprintf(__('View all posts in %s', 'textdomain'), $posttag->name)) . '">' . esc_html($posttag->name) . '</a>' . $separator;
                 }
             }
             echo trim($output, $separator);
         }
         echo '</span>';
     }
     edit_post_link(sprintf(esc_html__('Edit %s', 'ushipnetwork'), the_title('<span class="screen-reader-text">"', '"</span>', false)), '<span class="edit-link">', '</span>');
 }
 function widget($args, $instance)
 {
     extract($args);
     $current_taxonomy = $this->_get_current_taxonomy($instance);
     if (!empty($instance['title'])) {
         $title = $instance['title'];
     } else {
         if ('post_tag' == $current_taxonomy) {
             $title = __('Tags', 'tfuse');
         } else {
             $tax = get_taxonomy($current_taxonomy);
             $title = $tax->labels->name;
         }
     }
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $b = $instance['b'] = empty($instance['b']) ? '' : $instance['b'];
     $class = $b ? 'widget-boxed' : '';
     $before_widget = '<div class="widget widget_tag_cloud ' . $class . '">';
     $after_widget = '</div>';
     $before_title = '<h3 class="widget-title">';
     $after_title = '</h3>';
     echo $before_widget;
     $title = tfuse_qtranslate($title);
     if ($title) {
     }
     ?>
 <?php 
     echo $before_title . $title . $after_title;
     echo '<div class="tagcloud clearfix">';
     if ($instance['taxonomy'] != 'category') {
         $posttags = get_tags();
         if ($posttags) {
             $count = 0;
             foreach ($posttags as $tag) {
                 $count++;
                 if ($count == count($posttags)) {
                     echo '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a>';
                 } else {
                     echo '<a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . ' </a>';
                 }
             }
         }
     } else {
         $posttags = get_categories();
         if ($posttags) {
             $count = 0;
             foreach ($posttags as $tag) {
                 $count++;
                 if ($count == count($posttags)) {
                     echo '<a href="' . get_category_link($tag->term_id) . '">' . $tag->name . '</a>';
                 } else {
                     echo '<a href="' . get_category_link($tag->term_id) . '">' . $tag->name . ' </a>';
                 }
             }
         }
     }
     echo "</div>\n";
     echo $after_widget;
 }
 function build_jsonldBreadcrumb()
 {
     $jsonLD["@context"] = "http://schema.org/";
     $jsonLD["@type"] = "BreadcrumbList";
     //---------------------------------
     // pre-define some variables
     //---------------------------------
     $home_title = get_bloginfo('name');
     $home_url = esc_url(home_url('/'));
     $blog_url = get_permalink(get_option('page_for_posts'));
     $blog_title = get_the_title(get_option('page_for_posts', true));
     $url = $url ? $url : get_permalink();
     $title = $title ? $title : get_the_title();
     $itemList = array();
     //----------------------------------
     // Output
     //-----------------------------------
     $itemList[] = array("@type" => "ListItem", "position" => 1, "item" => array('@id' => $home_url, 'name' => $home_title));
     //----------------------------------------------
     // figure out the next number
     // <meta property="position" content="{NUM}">
     //----------------------------------------------
     $next = 2;
     if (is_single() or is_home()) {
         //-------------------------------------
         // we have a blog "post"
         // so we added the blog url (not home)
         // so next is 3 not 2!
         //--------------------------------------
         $itemList[] = array("@type" => "ListItem", "position" => 2, "item" => array('@id' => $blog_url, 'name' => $blog_title));
         $next = 3;
     }
     if (is_single() or is_page() or is_tag() or is_category()) {
         //----------------------------------
         // is it a tag?
         //----------------------------------
         if (is_tag()) {
             $title = single_tag_title("", false);
             $tag_id = get_term_by('name', $title, 'post_tag');
             $url = get_tag_link($tag_id->term_id);
         }
         if (is_category()) {
             $title = single_cat_title("", false);
             $category_id = get_cat_ID($title);
             $url = get_category_link($category_id);
         }
         $itemList[] = array("@type" => "ListItem", "position" => $next, "item" => array('@id' => $url, 'name' => $title));
     }
     $jsonLD["itemListElement"] = $itemList;
     /*echo '<pre>';
     	print_r(json_encode($jsonLD));
     	echo '</pre>';*/
     if ((is_page() or is_single() or is_home() or is_tag() or is_category()) and !is_front_page()) {
         echo '<script type="application/ld+json">';
         echo json_encode($jsonLD);
         echo '</script>';
     }
 }
function clear_tag_cache()
{
    global $wpssc;
    $tagobj = get_tags();
    foreach ($tagobj as $tag) {
        $link = get_tag_link($tag->term_id);
        $wpssc->delete_cache($link);
    }
}
Example #24
0
 function wp_get_tag_urls()
 {
     $tags = get_tags();
     $urls = array();
     foreach ($tags as $tag) {
         array_push($urls, get_tag_link($tag->term_id));
     }
     return $urls;
 }
/**
 * Prints HTML with article's footer. 
 * 
 */
function lady_B_post_footer($show_comments_template = false, $show_no_comment_info = true)
{
    //check comments
    $num_comments = get_comments_number();
    // get_comments_number returns only a numeric value
    if (comments_open()) {
        if ($num_comments == 0) {
            $comments = __('No comments', 'lady_B');
        } elseif ($num_comments > 1) {
            $comments = $num_comments . __(' comments', 'lady_B');
        } else {
            $comments = __('1 comment', 'lady_B');
        }
        $comments_txt = '<a href="' . get_comments_link() . '">' . $comments . '</a>';
    } else {
        if ($show_no_comment_info) {
            $comments_txt = __('Comments are off for this post.', 'lady_B');
        } else {
            $comments_txt = '';
        }
    }
    //check tags
    $separator = ', ';
    $posttags = get_the_tags();
    $mtags = "";
    if ($posttags) {
        $mtags = __('Tags: ', 'lady_B');
        foreach ($posttags as $tag) {
            $mtags .= '<a href="' . esc_url(get_tag_link($tag->term_id)) . '" alt="' . esc_attr(sprintf(__('View all posts tagged %s', 'lady_B'), $tag->name)) . '">' . esc_html($tag->name) . '</a>' . $separator;
        }
        $mtags .= "<br/>";
    }
    //check categories
    $mcat = "";
    $postcat = get_the_category();
    if ($postcat) {
        $mcat = __('In: ', 'lady_B');
        foreach ($postcat as $category) {
            $mcat .= '<a href="' . esc_url(get_category_link($category->term_id)) . '" alt="' . esc_attr(sprintf(__('View all posts in %s', 'lady_B'), $category->name)) . '">' . esc_html($category->name) . '</a>' . $separator;
        }
    }
    //we need different layout for single.php
    if ($show_comments_template) {
        $template = "";
        if (comments_open() || get_comments_number()) {
            ob_start();
            comments_template();
            $template = ob_get_contents();
            // Store buffer in variable
            ob_end_clean();
        }
        print "</div><!--end of entry--><footer><p class='more'>" . $mtags . $mcat . "</p><p class='comments'>" . $comments_txt . "</p>" . $template . "</footer></article><!--end of post-->";
    } else {
        print "</div><!--end of entry--><footer><p class='comments'>" . $comments_txt . "</p><p class='more'>" . $mtags . $mcat . "</p></footer></article><!--end of post-->";
    }
}
Example #26
0
/**
 * Display a tag clouds.
 */
function vicuna_tag_cloud($args = '')
{
    global $wp_rewrite;
    $defaults = array('levels' => 6, 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '');
    $args = wp_parse_args($args, $defaults);
    $tags = get_tags(array_merge($args, array('orderby' => 'count', 'order' => 'ASC')));
    // Always query top tags
    if (empty($tags)) {
        return;
    }
    extract($args);
    if (!$tags) {
        return;
    }
    $counts = $tag_links = array();
    foreach ((array) $tags as $tag) {
        $counts[$tag->name] = $tag->count;
        $tag_links[$tag->name] = get_tag_link($tag->term_id);
        if (is_wp_error($tag_links[$tag->name])) {
            return $tag_links[$tag->name];
        }
        $tag_ids[$tag->name] = $tag->term_id;
    }
    $min_count = min($counts);
    $step = (int) ((max($counts) - $min_count) / $levels) + 1;
    if ($step <= 1) {
        $step = 1;
    }
    // SQL cannot save you; this is a second (potentially different) sort on a subset of data.
    if ('name' == $orderby) {
        uksort($counts, 'strnatcasecmp');
    } else {
        asort($counts);
    }
    if ('DESC' == $order) {
        $counts = array_reverse($counts, true);
    }
    $a = array();
    $rel = is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ? ' rel="tag"' : '';
    foreach ($counts as $tag => $count) {
        $tag_id = $tag_ids[$tag];
        $tag_link = clean_url($tag_links[$tag]);
        $level = $levels - (int) (($count - $min_count) / $step);
        $tag = str_replace(' ', '&nbsp;', wp_specialchars($tag));
        $a[] = "<li class=\"level" . $level . "\"><a href=\"{$tag_link}\" title=\"" . attribute_escape(sprintf(__('%d Entries', 'vicuna'), $count)) . "\"{$rel}>{$tag}</a></li>";
    }
    $return = "<ul class=\"tagCloud\">\n\t";
    $return .= join("\n\t", $a);
    $return .= "\n</ul>\n";
    if (is_wp_error($return)) {
        return false;
    } else {
        echo apply_filters('vicuna_tag_cloud', $return, $tags, $args);
    }
}
Example #27
0
function maniapress_get_tags($postId)
{
    $tags = get_the_tags($postId);
    if ($tags) {
        foreach ($tags as $key => $tag) {
            $tags[$key] = sprintf('$h[%s]%s$h', get_tag_link($tag->term_id), $tag->name);
        }
        $tags = 'in ' . implode(', ', $tags);
    }
    return $tags;
}
Example #28
0
function get_category_tags($args)
{
    global $wpdb;
    $tags = $wpdb->get_results("\n\t\tSELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link\n\t\tFROM\n\t\t\twp_posts as p1\n\t\t\tLEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID\n\t\t\tLEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id\n\t\t\tLEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id,\n\n\t\t\twp_posts as p2\n\t\t\tLEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID\n\t\t\tLEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id\n\t\t\tLEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id\n\t\tWHERE\n\t\t\tt1.taxonomy = 'category' AND p1.post_status = 'publish' AND terms1.term_id IN (" . $args['categories'] . ") AND\n\t\t\tt2.taxonomy = 'post_tag' AND p2.post_status = 'publish'\n\t\t\tAND p1.ID = p2.ID\n\t\tORDER by tag_name\n\t");
    $count = 0;
    foreach ($tags as $tag) {
        $tags[$count]->tag_link = get_tag_link($tag->tag_id);
        $count++;
    }
    return $tags;
}
Example #29
0
function hmc_shared_blog_category_tags($args)
{
    global $wpdb;
    $tags = $wpdb->get_results("\n\tSELECT DISTINCT\n\tterms2.term_id as tag_ID,\n\tterms2.name as tag_name,\n\tt2.count as posts_with_tag\n\tFROM\n\t{$wpdb->posts} as p1\n\tLEFT JOIN {$wpdb->term_relationships} as r1 ON p1.ID = r1.object_ID\n\tLEFT JOIN {$wpdb->term_taxonomy} as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id\n\tLEFT JOIN {$wpdb->terms} as terms1 ON t1.term_id = terms1.term_id,\n\t\n\t{$wpdb->posts} as p2\n\tLEFT JOIN {$wpdb->term_relationships} as r2 ON p2.ID = r2.object_ID\n\tLEFT JOIN {$wpdb->term_taxonomy} as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id\n\tLEFT JOIN {$wpdb->terms} as terms2 ON t2.term_id = terms2.term_id\n\tWHERE (\n\tt1.taxonomy = 'category' AND\n\tp1.post_status = 'publish' AND\n\tterms1.term_id = '" . $args['categories'] . "' AND\n\tt2.taxonomy = 'post_tag' AND\n\tp2.post_status = 'publish' AND\n\tp1.ID = p2.ID\n\t)\n\t");
    $count = 0;
    foreach ($tags as $tag) {
        $tags[$count]->tag_link = get_tag_link($tag->tag_ID);
        $count++;
    }
    return $tags;
}
Example #30
0
 /**
  * Get the tags attached to this post
  * @return array
  */
 public function tags()
 {
     $tags = get_the_tags($this->wp_post);
     if (is_array($tags)) {
         return array_map(function ($tag) {
             return (object) array_merge((array) $tag, ['url' => get_tag_link($tag->term_id)]);
         }, $tags);
     } else {
         return [];
     }
 }