コード例 #1
1
 /**
  * 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 );
 }
コード例 #2
0
ファイル: tag.php プロジェクト: Anawaz/Simple-Related-Posts
 public function get_data_original($num = '', $post_id = null)
 {
     global $wpdb, $post;
     if (!isset($post_id)) {
         $post_id = $post->ID;
     }
     if (empty($post_id)) {
         return false;
     }
     $current_tags = get_the_tags($post_id);
     if (!$current_tags) {
         return false;
     }
     $tags = array();
     foreach ((array) $current_tags as $tag) {
         $tags[] = absint($tag->term_id);
     }
     $tag_list = implode(',', $tags);
     if ($num == '') {
         $option = get_option('sirp_options');
         $num = $option['display_num'];
     }
     $q = "SELECT ID FROM {$wpdb->posts} AS p\n\t\t\tINNER JOIN {$wpdb->term_relationships} AS tr ON (p.ID = tr.object_id)\n\t\t\tINNER JOIN {$wpdb->term_taxonomy} AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)\n\t\t\tWHERE (tt.taxonomy = 'post_tag' AND tt.term_id IN ({$tag_list}))\n\t\t\tAND p.post_status = 'publish'\n\t\t\tAND p.post_type = 'post'\n\t\t\tAND p.ID != {$post_id}\n\t\t\tGROUP BY tr.object_id\n\t\t\tORDER BY post_date DESC" . $wpdb->prepare(" LIMIT %d", $num);
     return $wpdb->get_results($q, ARRAY_A);
 }
コード例 #3
0
ファイル: functions.php プロジェクト: emperorgod/longsays
function dtheme_keywords()
{
    global $s, $post;
    $keywords = '';
    if (is_single()) {
        if (get_the_tags($post->ID)) {
            foreach (get_the_tags($post->ID) as $tag) {
                $keywords .= $tag->name . ', ';
            }
        }
        foreach (get_the_category($post->ID) as $category) {
            $keywords .= $category->cat_name . ', ';
        }
        $keywords = substr_replace($keywords, '', -2);
    } elseif (is_home()) {
        $keywords = dopt('d_keywords');
    } elseif (is_tag()) {
        $keywords = single_tag_title('', false);
    } elseif (is_category()) {
        $keywords = single_cat_title('', false);
    } elseif (is_search()) {
        $keywords = esc_html($s, 1);
    } else {
        $keywords = trim(wp_title('', false));
    }
    if ($keywords) {
        echo "<meta name=\"keywords\" content=\"{$keywords}\" />\n";
    }
}
コード例 #4
0
ファイル: wp-autotags.php プロジェクト: yszar/linuxwp
function wp_aatags_run($post_ID)
{
    $tags = get_option('wp_aatags_opts');
    $number = get_option('wp_aatags_aadnumber');
    global $wpdb;
    if (get_post($post_ID)->post_type == 'post' && !wp_is_post_revision($post_ID) && !get_the_tags($post_ID)) {
        $post_title = get_post($post_ID)->post_title;
        $post_content = get_post($post_ID)->post_content;
        switch ($tags) {
            case 3:
                $requix = strtolower($post_title . ' ' . wp_trim_words($post_content, 333, ''));
                break;
            case 2:
                $requix = strtolower($post_title . ' ' . wp_trim_words($post_content, 999, ''));
                break;
            default:
                $requix = strtolower($post_title);
                break;
        }
        $body = wp_aatags_keycontents(wp_aatags_html2text($requix), $number);
        if ($body != 'rEr') {
            $keywords = wp_aatags_kwsiconv($body);
            wp_add_post_tags($post_ID, $keywords);
        } else {
            wp_aatags_alts($post_ID, $post_title, $post_content);
        }
    }
}
 function render_related_string()
 {
     $settings = C_NextGen_Settings::get_instance();
     $type = $settings->appendType;
     $maxImages = $settings->maxImages;
     $sluglist = array();
     switch ($type) {
         case 'tags':
             if (function_exists('get_the_tags')) {
                 $taglist = get_the_tags();
                 if (is_array($taglist)) {
                     foreach ($taglist as $tag) {
                         $sluglist[] = $tag->slug;
                     }
                 }
             }
             break;
         case 'category':
             $catlist = get_the_category();
             if (is_array($catlist)) {
                 foreach ($catlist as $cat) {
                     $sluglist[] = $cat->category_nicename;
                 }
             }
             break;
     }
     $taglist = implode(',', $sluglist);
     if ($taglist === 'uncategorized' || empty($taglist)) {
         return;
     }
     $renderer = C_Component_Registry::get_instance()->get_utility('I_Displayed_Gallery_Renderer');
     $view = C_Component_Registry::get_instance()->get_utility('I_Component_Factory')->create('mvc_view', '');
     $retval = $renderer->display_images(array('source' => 'tags', 'container_ids' => $taglist, 'display_type' => NEXTGEN_GALLERY_BASIC_THUMBNAILS, 'images_per_page' => $maxImages, 'maximum_entity_count' => $maxImages, 'template' => $view->get_template_abspath('photocrati-nextgen_gallery_display#related'), 'show_all_in_lightbox' => FALSE, 'show_slideshow_link' => FALSE, 'disable_pagination' => TRUE));
     return apply_filters('ngg_show_related_gallery_content', $retval, $taglist);
 }
コード例 #6
0
ファイル: functions.php プロジェクト: boltogriz/blog-cook
function wpthemes_post_class($class = '', $post_id = null)
{
    $post = get_post($post_id);
    $classes = array();
    $classes[] = $post->post_type;
    if (is_sticky($post->ID) && is_home()) {
        $classes[] = 'sticky';
    }
    $classes[] = 'hentry';
    foreach ((array) get_the_category($post->ID) as $cat) {
        if (empty($cat->slug)) {
            continue;
        }
        $classes[] = 'category-' . $cat->slug;
    }
    foreach ((array) get_the_tags($post->ID) as $tag) {
        if (empty($tag->slug)) {
            continue;
        }
        $classes[] = 'tag-' . $tag->slug;
    }
    if (!empty($class)) {
        if (!is_array($class)) {
            $class = preg_split('#\\s+#', $class);
        }
        $classes = array_merge($classes, $class);
    }
    return apply_filters('post_class', $classes, $class, $post_id);
}
コード例 #7
0
function get_related_posts()
{
    // an array of tags from the current post
    $related_tags = get_the_tags();
    /*
    	$tag will be used in this example, this is just the first tag
    	from the array.  To optimize the plugin we would want to loop through
    	all of the tags in the $related_tags array and do something more
    	interesting with them.
    */
    $tag = $related_tags[0];
    // The ID of the current post
    $current_post = get_the_id();
    // The arguments for the nested loop
    $args = array('posts_per_page' => 3, 'post__not_in' => array($current_post), 'tag' => $tag->name);
    $related_query = new WP_Query($args);
    if ($related_query->have_posts()) {
        $html = '<h2>Some Related Posts</h2>';
        $html .= '<ul>';
        while ($related_query->have_posts()) {
            $related_query->the_post();
            $html .= '<li>';
            $html .= get_the_title();
            $html .= '</li>';
        }
        $html .= '</ul>';
    }
    return $html;
}
コード例 #8
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>');
 }
コード例 #9
0
ファイル: template-tags.php プロジェクト: de190909/WPTest
 function flatbook_post_metas()
 {
     $user = get_the_author();
     $date = get_the_date('F j');
     $cats = get_the_category();
     $tags = get_the_tags();
     $comm = get_comments_number();
     $type = get_post_format();
     if (false === $type) {
         $type = __('standard', 'flatbook');
     }
     echo '<div class="entry-metas">';
     if ($type) {
         echo '<span class="format"><i class="fa fa-inbox"></i>' . $type . '</span>';
     }
     if ($date) {
         echo '<span class="posted-on"><i class="fa fa-dashboard"></i>' . $date . '</span>';
     }
     if ($user) {
         echo '<span class="byline"><i class="fa fa-user"></i>' . $user . '</span>';
     }
     if ($cats) {
         echo '<span class="cats"><i class="fa fa-folder-open"></i>' . $cats[0]->cat_name . '</span>';
     }
     if ($tags) {
         echo '<span class="tags"><i class="fa fa-tags"></i>' . $tags[0]->name . '</span>';
     }
     if ($comm) {
         echo '<span class="comments"><i class="fa fa-comments"></i>' . $comm . __(' Comment', 'flatbook') . '</span>';
     }
     echo '</div>';
 }
コード例 #10
0
/**
	*获取相关文章
	*http://www.bgbk.org
*/
function Bing_related_posts_ID($post = null)
{
    $post = get_post($post);
    $number = 3;
    $posts = array();
    $tags = get_the_tags($post);
    $exclude_ID = array($post->ID);
    if (!empty($tags)) {
        $tags_ID = array();
        foreach ($tags as $tag) {
            $tags_ID[] = $tag->term_id;
        }
        $posts = get_posts(array('tag__in' => $tags_ID, 'exclude' => $exclude_ID, 'orderby' => 'rand', 'fields' => 'ids', 'numberposts' => $number));
    }
    $cats = get_the_category($post);
    if (count($posts) < $number && !empty($cats)) {
        $cats_ID = array();
        foreach ($cats as $cat) {
            $cats_ID[] = $cat->term_id;
        }
        $_posts = get_posts(array('category__in' => $cats_ID, 'exclude' => array_merge($exclude_ID, $posts), 'orderby' => 'rand', 'fields' => 'ids', 'numberposts' => $number - count($posts)));
        $posts = array_merge($posts, $_posts);
    }
    if (count($posts) < $number) {
        $_posts = get_posts(array('exclude' => array_merge($exclude_ID, $posts), 'orderby' => 'rand', 'fields' => 'ids', 'numberposts' => $number - count($posts)));
        $posts = array_merge($posts, $_posts);
    }
    return $posts;
}
コード例 #11
0
 public function auto_add_tag($title, $post_id)
 {
     global $post;
     $result = '';
     $add_tags = '';
     $i = 0;
     if (in_the_loop()) {
         $p = get_post($post_id);
         $cur_title = $p->post_title;
         $post_tags = get_the_tags($post_id);
         if ($post_tags) {
             foreach ($post_tags as $tag) {
                 //get the first post tag
                 if ($i == 0) {
                     $add_tags .= '&lsqb;' . $tag->name . '&rsqb;&nbsp;';
                 }
                 $i++;
             }
         }
         $result = $add_tags . $cur_title;
     } else {
         $result = $title;
     }
     return $result;
 }
コード例 #12
0
ファイル: paths.php プロジェクト: moscarar/cityhow
function get_bodyid()
{
    if (is_home()) {
        $bodyid = 'home';
    } elseif (is_archive() and !is_author() and !is_tax() and !is_tag()) {
        $categories = get_the_category();
        foreach ($categories as $category) {
            $cat_id = $category->term_id;
            $cat_parent_id = $category->category_parent;
        }
        if ($cat_parent_id) {
            $cat_name = strtolower(get_the_category_by_id($cat_parent_id));
        } else {
            $cat_name = strtolower(get_the_category_by_id($cat_id));
        }
        $bodyid = $cat_name;
    } elseif (is_archive() and is_author()) {
        $bodyid = 'profile';
    } elseif (is_archive() and is_tax('nh_cities')) {
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        $term_name = $term->name;
        $bodyid = 'cities-' . $term_name;
    } elseif (is_archive() and is_tag()) {
        $tags = get_the_tags();
        foreach ($tags as $tag) {
            $tag_name = $tag->name;
        }
        $bodyid = $tag_name;
    } elseif (is_page()) {
        if (is_page('topics')) {
            $bodyid = 'topics';
        } elseif (is_page('cities')) {
            $bodyid = 'cities';
        } elseif (is_page('login')) {
            $bodyid = 'settings';
        } else {
            $bodyid = 'general';
        }
    } elseif (is_single()) {
        $categories = get_the_category();
        foreach ($categories as $category) {
            $cat_id = $category->term_id;
            $cat_parent_id = $category->category_parent;
        }
        if ($cat_parent_id) {
            $cat_name = strtolower(get_the_category_by_id($cat_parent_id));
            $bodyid = $cat_name;
        } else {
            $cat_name = strtolower(get_the_category_by_id($cat_id));
            $bodyid = $cat_name;
        }
        //		if (isset($cat_name)) {
        //			$bodyid = $cat_name;
        //		}
    } elseif (is_search()) {
        $bodyid = 'search';
    }
    return $bodyid;
}
コード例 #13
0
	function widget($args, $instance) {

		global $post;
				
		// don't show widget if we are not on a post page
		if ($post == null || $post->post_type != 'post') {
			echo '<!-- ' . __('Tweet Blender: Not shown as this is not a post', 'tweetblender') . ' -->';
			return;
		}

		// check custom tb_tags field
		$sources = array();
		$custom_fields = get_post_custom($post->ID);
 		$post_tags = get_the_tags($post->ID);
		if (isset($custom_fields['tb_tags'])) {
			foreach($custom_fields['tb_tags'] as $key => $tags) {
				$sources = array_merge($sources,explode(',',$tags));
			}			
		}
		// check general post tags
		elseif (isset($post_tags) && is_array($post_tags) && sizeof($post_tags) > 0) {
			foreach($post_tags as $tag) {
				$sources[] = trim($tag->name);			
			}
		}
		// don't show widget if there are no tags
		else {
			echo '<!-- ' . __('Tweet Blender: Not shown as there are no tags for this post', 'tweetblender') . ' -->';
			return;
		}

		if (sizeof($args) > 0) {
			extract($args, EXTR_SKIP);			
		}
		$tb_o = get_option('tweet-blender');
		
		echo $before_widget;
		$title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
		if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };

		$instance['widget_sources'] = join('\n\r',$sources);
			
		// add configuraiton options
		echo '<form id="' . $this->id . '-f" class="tb-widget-configuration">';
		echo '<input type="hidden" name="sources" value="' . addslashes(join(',',$sources)) . '">';
		echo '<input type="hidden" name="refreshRate" value="' . $instance['widget_refresh_rate'] . '">';
		echo '<input type="hidden" name="tweetsNum" value="' . $instance['widget_tweets_num'] . '">';
		echo '</form>';
			
		// print out header and list of tweets
		echo '<div id="'. $this->id . '-mc">';
		echo tb_create_markup($mode = 'widget',$instance,$this->id,$tb_o);

		// print out footer
		echo '<div class="tb_footer"></div>';

		echo '</div>';
		echo $after_widget;
	}
コード例 #14
0
ファイル: functions.php プロジェクト: haxrat/haxrat
/**
 * Tags as meta keywords
 **/
function meta_keywords()
{
    $posttags = get_the_tags();
    foreach ((array) $posttags as $tag) {
        $meta_keywords .= $tag->name . ',';
    }
    return substr($meta_keywords, 0, -1);
}
コード例 #15
0
 function get_tags_list()
 {
     $tags = get_the_tags();
     if (empty($tags)) {
         return;
     }
     get_view('post-tags', '', compact('tags'));
 }
コード例 #16
0
ファイル: Api.php プロジェクト: kmvan/poil10n
 public static function getTheTags($postID)
 {
     static $cache = [];
     if (!isset($cache[$postID])) {
         $cache[$postID] = \get_the_tags($postID);
     }
     return $cache[$postID];
 }
コード例 #17
0
function meta_post_keywords()
{
    $posttags = get_the_tags();
    foreach ((array) $posttags as $tag) {
        $meta_post_keywords .= $tag->name . ',';
    }
    echo '<meta name="keywords" content="' . $meta_post_keywords . '" />';
}
コード例 #18
0
function csv_tags_m()
{
    $posttags = get_the_tags();
    foreach ((array) $posttags as $tag) {
        @($csv_tags .= $tag->name . ',');
    }
    echo $csv_tags;
}
コード例 #19
0
ファイル: index.php プロジェクト: polhec/related_posts_mon
function related_posts()
{
    echo "<h3 class=\"dividing-title\">Oglejte si še</h3>";
    $rp_prikazani[0] = get_the_ID();
    //ID glavnega posta, da se ne ponovi v predlogih
    global $post;
    $rp_x = 0;
    //Štetje, koliko postov je bilo izpisanih
    $rp_relacije = get_field('relacije');
    //Funkcija od Advanced custom fields plugina, no plugin no FUN
    //Izpiši ročno izbrane poste
    if ($rp_relacije) {
        $rp_args = array('post__in' => $rp_relacije);
        $rp_post_array = get_posts($rp_args);
        foreach ($rp_post_array as $post) {
            setup_postdata($post);
            rp_izpis();
            $rp_prikazani[$rp_x + 1] = get_the_ID();
            $rp_x++;
        }
        wp_reset_postdata();
    }
    //Če niso izbrani 4 posti, poišči dodatne, glede na kategorijo ali tag
    if ($rp_x < 4) {
        $rp_categories = get_the_category();
        foreach ($rp_categories as $rp_category) {
            if ($rp_category->term_id != get_cat_ID("prva_stran1") and $rp_category->term_id != get_cat_ID("prva_stran2") and $rp_category->term_id != get_cat_ID("prva_stran3") and $rp_category->term_id != get_cat_ID("slider")) {
                $rp_cat_list[] = $rp_category->term_id;
            }
        }
        $rp_oznake = get_the_tags();
        $rp_tag_list = array();
        if (is_array($rp_oznake)) {
            foreach ($rp_oznake as $rp_oznaka) {
                $rp_tag_list[] = $rp_oznaka->term_id;
            }
        }
        $rp_args = array('posts_per_page' => 6 - $rp_x, 'offset' => 0, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'suppress_filters' => true, 'tax_query' => array('relation' => 'OR', array('taxonomy' => 'post_tag', 'field' => 'term_id', 'terms' => $rp_tag_list), array('taxonomy' => 'category', 'field' => 'term_id', 'terms' => $rp_cat_list)));
        $rp_post_array = get_posts($rp_args);
        foreach ($rp_post_array as $post) {
            setup_postdata($post);
            $rp_cid = get_the_ID();
            //Preveri, če je post že prikazan in v tem primeru postavi $rp_y = 0
            $rp_y = 1;
            foreach ($rp_prikazani as $rp_i) {
                if ($rp_i == $rp_cid) {
                    $rp_y = 0;
                }
            }
            //Preveri, če bo post izpisan
            if ($rp_x < 4 && $rp_y) {
                rp_izpis();
                $rp_x++;
            }
        }
        wp_reset_postdata();
    }
}
コード例 #20
0
ファイル: textfield.php プロジェクト: Knorcedger/main
function wk_submit_textfield($level, $name, $translation, $default, $size, $object_id = '', $object_type = 'post')
{
    if ($object_id != '') {
        if ($object_type == 'post') {
            //check if it is the post_title, the tags, or a post meta
            if ($name == 'post_title') {
                //fetch the post we are trying to edit
                $post = query_posts('p=' . $object_id);
                $value = $post[0]->post_title;
            } elseif ($name == 'tags_input') {
                $value = '';
                foreach (get_the_tags($object_id) as $tag) {
                    $value .= $tag->name . ', ';
                }
                //remove trailing ,
                $value = substr($value, 0, strlen($value) - 2);
            } else {
                $value = get_post_meta($object_id, $name, true);
            }
        } elseif ($object_type == 'user') {
            //then the $current_user was already checked and has the value we want
            //global $current_user;
            if ($object_id != '') {
                wp_set_current_user($object_id);
            }
            $value = $current_user->{$name};
        }
    } else {
        $value = $default;
    }
    ?>
<p class="<?php 
    echo $name;
    ?>
">
	<label for="<?php 
    echo $name;
    ?>
"><?php 
    echo $translation;
    ?>
: </label>
	<input type="text" name="<?php 
    echo $name;
    ?>
" id="<?php 
    echo $name;
    ?>
" value="<?php 
    echo $value;
    ?>
" size="<?php 
    echo $size;
    ?>
" />
</p>
<?php 
}
コード例 #21
0
function parse_tm_related_post_func($atts, $content)
{
    $postformat = isset($atts['postformat']) ? $atts['postformat'] : '';
    $posttypes = isset($atts['posttypes']) ? $atts['posttypes'] : 'post';
    $count = isset($atts['count']) ? $atts['count'] : -1;
    $tags = isset($atts['tag']) ? $atts['tag'] : '';
    $orderby = isset($atts['orderby']) ? $atts['orderby'] : '';
    global $post;
    if (is_single()) {
        if ($tags == '') {
            $tags = '';
            $posttags = get_the_tags();
            if ($posttags) {
                foreach ($posttags as $tag) {
                    $tags .= ',' . $tag->slug;
                }
                $tags = substr($tags, 1);
            }
        }
    }
    $args = array('taxonomy' => 'post_format', 'post_type' => $posttypes, 'posts_per_page' => $count, 'post_status' => 'publish', 'posts_not_in' => array(get_the_ID($post)), 'terms' => array($postformat), 'tag' => $tags);
    $the_query = new WP_Query($args);
    if ($the_query->have_posts()) {
        $html = '<div class="popular_video ">';
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $html .= '
				<div class="row-fluid">
				  <div class="rt-article span12">
					  <div class="popular_video_item">
						  <div class="video_thumb">
							<a href="#">' . get_the_post_thumbnail(get_the_ID(), array(150, 150)) . '
							<span class="link-overlay fa fa-play"></span></a>
							' . tm_post_rating(get_the_ID()) . '
						  </div> 	
						  <div class="pp_info">
							<h4 class="rt-article-title"> <a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h4>
							<div class="pp_video_view"><span><i class="icon-eye-open"></i>  ' . tm_get_post_views() . '' . __('  Views') . '</span></div>
							<div class="pp_video_comment"><span><i class="icon-comment"></i>  ' . get_comments_number() . '' . __(' Comments') . '</span></div>
							<div class="pp_video_like"><span><i class="icon-heart"></i>   ' . tm_get_post_likes(get_the_ID()) . ' ' . __(' Likes') . '</span></div>
						  </div>
						<!-- end post wrap -->
						<div class="clear"><!-- --></div>
					</div>
				  </div>
				  <!-- end span -->                              
				</div>
			';
        }
    }
    $html .= '
		</div>
		<div class="clear"></div>
	';
    wp_reset_query();
    return $html;
}
コード例 #22
0
ファイル: post_to_red.php プロジェクト: Mauru/red
function post_to_red_post($post_id)
{
    $post = get_post($post_id);
    if (isset($_POST['post_to_red'])) {
        update_post_meta($post_id, 'post_to_red', '1');
    }
    // if meta has been set
    if (get_post_meta($post_id, "post_to_red", true) === '1') {
        $user_name = post_to_red_get_acct_name();
        $password = post_to_red_get_password();
        $seed_location = post_to_red_get_seed_location();
        $channel = post_to_red_get_channel_name();
        $backlink = get_option('post_to_red_backlink');
        if (isset($user_name) && isset($password) && isset($seed_location)) {
            // remove potential comments
            $message = preg_replace('/<!--(.*)-->/Uis', '', $post->post_content);
            // get any tags and make them hashtags
            $post_tags = get_the_tags($post_id);
            if ($post_tags) {
                foreach ($post_tags as $tag) {
                    $tag_string .= "#" . $tag->name . " ";
                }
            }
            $message_id = site_url() . '/' . $post_id;
            if (isset($tag_string)) {
                $message .= "<br />{$tag_string}";
            }
            $cats = '';
            $terms = get_the_terms($post_id, 'category');
            if ($terms) {
                foreach ($terms as $term) {
                    if (strlen($cats)) {
                        $cats .= ',';
                    }
                    $cats .= htmlspecialchars_decode($term->name, ENT_COMPAT);
                }
            }
            $bbcode = xpost_to_html2bbcode($message);
            if ($backlink) {
                $bbcode .= "\n\n" . _('Source:') . ' ' . '[url]' . get_permalink($post_id) . '[/url]';
            }
            $url = $seed_location . '/api/statuses/update';
            $headers = array('Authorization' => 'Basic ' . base64_encode("{$user_name}:{$password}"));
            $body = array('title' => xpost_to_html2bbcode($post->post_title), 'status' => $bbcode, 'source' => 'WordPress', 'namespace' => 'wordpress', 'remote_id' => $message_id, 'permalink' => $post->guid);
            if ($channel) {
                $body['channel'] = $channel;
            }
            if ($cats) {
                $body['category'] = $cats;
            }
            // post:
            $request = new WP_Http();
            $result = $request->request($url, array('method' => 'POST', 'body' => $body, 'headers' => $headers));
        }
    }
}
コード例 #23
0
/**
 * 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-->";
    }
}
コード例 #24
0
 function gather($data)
 {
     $newtags = array();
     $tags = get_the_tags($data->ID);
     if ($tags) {
         foreach ((array) $tags as $tag) {
             $newtags[] = $tag->name;
         }
     }
     return implode(' ', $newtags);
 }
コード例 #25
0
ファイル: Post.php プロジェクト: laraish/laraish
 /**
  * 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 [];
     }
 }
コード例 #26
0
/**
 * Portions of the template that require more logic in order to theme.
 *
 * @package wp-devangelist
 */
function wp_devangelist_tag_list()
{
    $tags = get_the_tags();
    if ($tags) {
        echo '<span class="tag-list">';
        foreach ($tags as $tag) {
            echo '<span class="fa fa-tag">' . $tag->name . '</span>';
        }
        echo '</span>';
    }
}
コード例 #27
0
function getSinglePost($posttype = null)
{
    $postId = get_the_id();
    $attachedimage = new TimberImage(get_post_thumbnail_id());
    $categories = get_the_category();
    // setup an array to change the post data returned
    $singlePostArray = array('date' => strtotime(get_the_date()), 'id' => get_the_id(), 'title' => get_the_title(), 'categories' => $categories, 'tags' => get_the_tags(), 'post_type' => $posttype, 'image' => $attachedimage, 'link' => get_permalink());
    // Restores original Post Data
    wp_reset_postdata();
    return $singlePostArray;
}
コード例 #28
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;
}
コード例 #29
0
ファイル: functions.php プロジェクト: rkunev/Clean
/**
 * @todo Add Function documentation
 */
function zclean_get_article_tag_names()
{
    global $post;
    $output = array();
    $tags = get_the_tags($post->ID);
    if (is_array($tags)) {
        $output = array_map(function ($tag) {
            return $tag->name;
        }, $tags);
    }
    return $output;
}
コード例 #30
0
ファイル: wordpress-export.php プロジェクト: neo1218/gude
function getTag()
{
    $tags = get_the_tags();
    if ($tags === false) {
        return '';
    }
    $tags_a = array();
    foreach ($tags as $tag) {
        $tags_a[] = "'" . $tag->name . "'";
    }
    return implode(',', $tags_a);
}