本文整理汇总了PHP中get_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP get_tag函数的具体用法?PHP get_tag怎么用?PHP get_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ungarh_tag_list
/**
* 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
}
}
示例2: upgrade_terms
function upgrade_terms()
{
global $wpdb;
$table = $wpdb->prefix . $this->terms_table;
if ($wpdb->get_var("SHOW TABLES LIKE '{$table}'") == $table) {
if (is_array($this->categories)) {
foreach ($this->categories as $id => $category) {
$object =& get_category($id);
if ($object && is_array($category['head'])) {
$robots = is_array($category['head']['meta']['robots']) ? serialize($category['head']['meta']['robots']) : '';
$query = "INSERT INTO {$table} (term_id, name, taxonomy, title, description, keywords, robots, headline, content) VALUES ('{$id}', '{$object->name}', '{$object->taxonomy}', '" . urldecode($category['head']['title']) . "', '" . urldecode($category['head']['meta']['description']) . "', '" . urldecode($category['head']['meta']['keywords']) . "', '{$robots}', '', '')";
$wpdb->query($query);
}
}
}
if (is_array($this->tags)) {
foreach ($this->tags as $id => $tag) {
$object =& get_tag($id);
if ($object && is_array($tag['head'])) {
$robots = is_array($tag['head']['meta']['robots']) ? serialize($tag['head']['meta']['robots']) : '';
$query = "INSERT INTO {$table} (term_id, name, taxonomy, title, description, keywords, robots, headline, content) VALUES ('{$id}', '{$object->name}', '{$object->taxonomy}', '" . urldecode($tag['head']['title']) . "', '" . urldecode($tag['head']['meta']['description']) . "', '" . urldecode($tag['head']['meta']['keywords']) . "', '{$robots}', '', '')";
$wpdb->query($query);
}
}
}
}
}
示例3: my_rest_prepare_post
function my_rest_prepare_post($data, $post, $request)
{
$_data = $data->data;
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail = wp_get_attachment_image_src($thumbnail_id);
$_data['featured_image_thumbnail_url'] = $thumbnail[0];
$categories = get_categories();
$_data['all_categories'] = $categories;
unset($_data['author']);
unset($_data['comment_status']);
unset($_data['ping_status']);
unset($_data['modified']);
unset($_data['modified_gmt']);
unset($_data['date_gmt']);
unset($_data['guid']);
unset($_data['slug']);
unset($_data['sticky']);
$tags_arr = array();
foreach ($_data['tags'] as $tagID) {
$tag = get_tag($tagID);
// add name field to the array
$tags_arr[] = array('ID' => $tagID, 'name' => $tag->name);
}
$_data['tags'] = $tags_arr;
// assign the new tags array to the JSON field
$categories_arr = array();
foreach ($_data['categories'] as $catID) {
// add name field to the array
$categories_arr[] = array('ID' => $catID, 'name' => get_cat_name($catID));
}
$_data['categories'] = $categories_arr;
// assign the new tags array to the JSON field
$data->data = $_data;
return $data;
}
示例4: getCurrentTagObj
public static function getCurrentTagObj()
{
static $cache = null;
if ($cache !== null) {
return $cache;
}
$cache = \get_tag(static::getCurrentTagID());
return $cache;
}
示例5: ls
function ls($arg = 'all')
{
global $src_dir;
global $src_url;
if ($arg != 'all') {
if (eregi("[1-9]+[0-9]*", $arg)) {
$number_of_releases = $arg;
} elseif (substr($arg, 0, 1) == '.') {
$allowed_extention = $arg;
}
}
$src_array = read_dir($src_dir);
for ($i = 0; $i < sizeof($src_array); $i++) {
$_ = explode('.', $src_array[$i]);
$src_unique[$_[0]] .= $src_array[$i] . "\n";
}
$release = array_keys($src_unique);
if (!isset($number_of_releases)) {
$number_of_releases = sizeof($release);
}
for ($i = 0; $i < $number_of_releases; $i++) {
$_ = trim($src_unique[$release[$i]]);
$file = explode("\n", $_);
for ($j = 0; $j < sizeof($file); $j++) {
$offset = strlen($release[$i]) - strlen($file[$j]);
$ext = substr($file[$j], $offset);
if ($ext == '.xml') {
// release changes >>
$changes = trim(get_tag(read_file($src_dir . $file[$j]), 'changes'));
} else {
// downloadable files >>
if (isset($allowed_extention)) {
if ($ext == $allowed_extention) {
$link[] = '<a href="/get/' . $file[$j] . '">' . $file[$j] . '</a>';
}
} else {
$link[] = '<a href="/get/' . $file[$j] . '">' . $file[$j] . '</a>';
}
}
}
if (sizeof($link) > 0) {
sort($link);
reset($link);
if ($changes != '') {
$changes = "<p>Changes:</p>\n" . $changes . "\n";
}
$ls[] = "<p><strong>" . $release[$i] . "</strong></p>\n" . $changes . "<p>Download:</p>\n<ul>\n<li>" . implode("<br></li>\n<li>", $link) . "<br></li>\n</ul>\n";
}
unset($changes);
unset($link);
}
if (sizeof($ls) > 0) {
$out = "<!-- downloadable files >> -->\n" . implode('', $ls) . "<!-- downloadable files << -->\n";
}
return $out;
}
示例6: parse_xml
function parse_xml($file)
{
global $xml_tags;
$in = read_file($file);
$in = trim($in);
for ($i = 0; $i < sizeof($xml_tags); $i++) {
$out[$xml_tags[$i]] = get_tag($in, $xml_tags[$i]);
}
return $out;
}
示例7: index
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$packages = $this->object->getList(array('type' => 'package', 'with' => array('tag', 'meta')));
$price_levels = array();
foreach ($packages['data'] as $package) {
$price_levels[get_tag($package, '价格档次')] = get_meta($package, '价格');
}
$products = $this->object->getList(array('type' => 'product', 'meta' => array('首页推荐' => true), 'with_meta' => true));
$this->load->view('home', compact('price_levels', 'products'));
}
示例8: index
/**
* 产品选项
*/
function index()
{
if (!is_null($this->input->post('next'))) {
// TODO 应当对次数做验证,这个表单需要验证
$package = $this->object->fetch($this->input->post('package'));
//生成订单
$order_id = $this->object->add(array('type' => 'order', 'name' => $package['name'] . ' (' . get_tag($package, '内容分类') . ' ' . get_tag($package, '价格档次') . ') ' . $this->input->post('次数') . '周', 'meta' => array('套餐' => $package['name'] . ' (' . get_tag($package, '内容分类') . ' ' . get_tag($package, '价格档次') . ')', '内容分类' => get_tag($package, '内容分类'), '价格档次' => get_tag($package, '价格档次'), '次数' => $this->input->post('次数'), '金额' => $this->input->post('次数') * get_meta($package, '价格'), '是否卡片' => $this->input->post('是否卡片'), '首次送货日期' => $this->input->post('首次送货日期')), 'relative' => array('package' => $this->input->post('package'), 'purchaser' => $this->user->session_id)));
redirect('buy/logistic/' . $order_id);
}
$packages = $this->object->getList(array_merge(array('type' => 'package', 'with' => array('tag', 'meta')), $this->input->get('package') ? array('tag' => array('价格档次' => $this->input->get('package'))) : array()));
$this->load->view('buy/product_option', compact('packages'));
}
示例9: get_by_user
function get_by_user($user, $db)
{
$exercises = array();
$exercises["data"] = '';
$exercises["status"] = 'failed';
$exercises["error_message"] = '';
if ($db->connect_errno) {
$exercises["status"] = 'failed';
$exercises["error_message"] = $db->connect_error;
} else {
if ($sql_cmd = $db->prepare("SELECT DISTINCT(e.`id`), e.`title`, e.`content`,\n\t\t\t\t\t\t\t\t\t\t\te.`user_create`, e.`created_time`,\n\t\t\t\t\t\t\t\t\t\t\ted.`rating`, ed.`difficulty`, ed.`view_count`,\n\t\t\t\t\t\t\t\t\t\t\tc.`name`\n\t\t\t\t\t\t\t\t\t FROM `exercise` e\n\t\t\t\t\t\t\t\t\t INNER JOIN `exercise_detail` ed ON ed.`id` = e.`id`\n\t\t\t\t\t\t\t\t\t INNER JOIN `category` c ON c.`id` = e.`cat_id`\n\t\t\t\t\t\t\t\t\t WHERE e.`user_create` = ?\n\t\t\t\t\t\t\t\t\t ORDER BY ed.`view_count`\n\t\t\t\t\t\t\t\t\t LIMIT 10")) {
$sql_cmd->bind_param("s", $user);
if ($sql_cmd->execute()) {
$sql_cmd->bind_result($id, $title, $content, $user_create, $created_time, $rating, $difficulty, $view_count, $cat_name);
while ($sql_cmd->fetch()) {
$exercise = array();
$exercise["id"] = $id;
$exercise["title"] = $title;
$exercise["content"] = $content;
$exercise["user_create"] = $user_create;
$exercise["created_time"] = $created_time;
$exercise["rating"] = $rating;
$exercise["difficulty"] = $difficulty;
$exercise["view_count"] = $view_count;
$exercise["cat_name"] = $cat_name;
$exercises["data"][] = $exercise;
}
} else {
$exercises["status"] = 'failed';
$exercises["error_message"] = $sql_cmd->error;
}
$sql_cmd->close();
} else {
$exercises["status"] = 'failed';
$exercises["error_message"] = $db->error;
}
get_tag($exercises, $db);
$exercises["status"] = $exercises["error_message"] == '' ? 'success' : 'failed';
echo json_encode(utf8ize($exercises['data']), JSON_PRETTY_PRINT);
// printf("<pre>%s</pre>", $json);
$db->close();
}
}
示例10: test_empty_category__in
/**
* @ticket 28099
* @group taxonomy
*/
function test_empty_category__in()
{
$cat_id = $this->factory->category->create();
$post_id = $this->factory->post->create();
wp_set_post_categories($post_id, $cat_id);
$q1 = get_posts(array('category__in' => array($cat_id)));
$this->assertNotEmpty($q1);
$q2 = get_posts(array('category__in' => array()));
$this->assertNotEmpty($q2);
$tag = wp_insert_term('woo', 'post_tag');
$tag_id = $tag['term_id'];
$slug = get_tag($tag_id)->slug;
wp_set_post_tags($post_id, $slug);
$q3 = get_posts(array('tag__in' => array($tag_id)));
$this->assertNotEmpty($q3);
$q4 = get_posts(array('tag__in' => array()));
$this->assertNotEmpty($q4);
$q5 = get_posts(array('tag_slug__in' => array($slug)));
$this->assertNotEmpty($q5);
$q6 = get_posts(array('tag_slug__in' => array()));
$this->assertNotEmpty($q6);
}
示例11: postTagline
public function postTagline()
{
$post = get_post();
if (get_class($post) !== 'WP_Post') {
return "";
}
$date = apply_filters('the_date', $post->post_date);
$dateString = date('M j, Y', strtotime($date));
$author = get_the_author();
$tags = wp_get_post_tags($post->ID);
$taglist = "";
if (count($tags) > 0) {
$taglist = "| ";
foreach ($tags as $tag) {
$tag = get_tag($tag->term_id);
$l = get_tag_link($tag->term_id);
$taglink = '<a href=" ' . $l . '">' . $tag->name . '</a>';
$taglist .= $taglink . " ";
}
}
$val = "<h6>by {$author} | {$dateString} {$taglist}</h6>";
return $val;
}
示例12: filter_widget
/**
* Determine whether the widget should be displayed based on conditions set by the user.
*
* @param array $instance The widget settings.
* @return array Settings to display or bool false to hide.
*/
public static function filter_widget($instance)
{
global $wp_query;
if (empty($instance['conditions']) || empty($instance['conditions']['rules'])) {
return $instance;
}
// Store the results of all in-page condition lookups so that multiple widgets with
// the same visibility conditions don't result in duplicate DB queries.
static $condition_result_cache = array();
$condition_result = false;
foreach ($instance['conditions']['rules'] as $rule) {
$condition_key = self::generate_condition_key($rule);
if (isset($condition_result_cache[$condition_key])) {
$condition_result = $condition_result_cache[$condition_key];
} else {
switch ($rule['major']) {
case 'date':
switch ($rule['minor']) {
case '':
$condition_result = is_date();
break;
case 'month':
$condition_result = is_month();
break;
case 'day':
$condition_result = is_day();
break;
case 'year':
$condition_result = is_year();
break;
}
break;
case 'page':
// Previously hardcoded post type options.
if ('post' == $rule['minor']) {
$rule['minor'] = 'post_type-post';
} else {
if (!$rule['minor']) {
$rule['minor'] = 'post_type-page';
}
}
switch ($rule['minor']) {
case '404':
$condition_result = is_404();
break;
case 'search':
$condition_result = is_search();
break;
case 'archive':
$condition_result = is_archive();
break;
case 'posts':
$condition_result = $wp_query->is_posts_page;
break;
case 'home':
$condition_result = is_home();
break;
case 'front':
if (current_theme_supports('infinite-scroll')) {
$condition_result = is_front_page();
} else {
$condition_result = is_front_page() && !is_paged();
}
break;
default:
if (substr($rule['minor'], 0, 10) == 'post_type-') {
$condition_result = is_singular(substr($rule['minor'], 10));
} elseif ($rule['minor'] == get_option('page_for_posts')) {
// If $rule['minor'] is a page ID which is also the posts page
$condition_result = $wp_query->is_posts_page;
} else {
// $rule['minor'] is a page ID
$condition_result = is_page($rule['minor']);
// Check if $rule['minor'] is parent of page ID
if (!$condition_result && isset($rule['has_children']) && $rule['has_children']) {
$condition_result = wp_get_post_parent_id(get_the_ID()) == $rule['minor'];
}
}
break;
}
break;
case 'tag':
if (!$rule['minor'] && is_tag()) {
$condition_result = true;
} else {
$rule['minor'] = self::maybe_get_split_term($rule['minor'], $rule['major']);
if (is_singular() && $rule['minor'] && has_tag($rule['minor'])) {
$condition_result = true;
} else {
$tag = get_tag($rule['minor']);
if ($tag && !is_wp_error($tag) && is_tag($tag->slug)) {
$condition_result = true;
}
}
//.........这里部分代码省略.........
示例13: Process
function Process($template)
{
global $wp_query;
if (!$wp_query->post->ID) {
if (is_tag()) {
// get the tag if there appears to be no post and it's a tag page
$xxx = get_tag($wp_query->query_vars['tag_id']);
} else {
//Check if the the category is really empty or not then redirect the user to error pages
// if it's a category, check if the category has posts in it...
if (is_category()) {
$cat = $GLOBALS['wp_query']->query_vars['cat'];
if ($cat) {
$args = array('category' => $cat);
$cat_posts = get_posts($args);
//get the posts for the category
if (empty($cat_posts)) {
//if its empty, lets check if the category is really empty or WishList Member hides it
$cat = get_category($cat);
if ($cat->count > 0) {
//if theres a post in this cat, redirect to non member page
$redirect = is_user_logged_in() ? $this->WrongLevelURL() : $this->NonMembersURL();
header("Location:" . $redirect);
exit;
}
}
}
}
// return $template if there's no post
return $template;
}
if ($xxx->count) {
// we really have at least a post in this tag but it's being hidden
// so we redirect to the correct error page
$redirect = is_user_logged_in() ? $this->WrongLevelURL() : $this->NonMembersURL();
// and redirect
header("Location:" . $redirect);
exit;
}
// return $template if there's no post and it's not a tag page
return $template;
}
// just return the template if it's a tag page
if (is_tag()) {
return $template;
}
// get current user
$wpm_current_user = wp_get_current_user();
// give everything is user is admin
if ($wpm_current_user->caps['administrator']) {
return $template;
}
// Construct Full Request URL
$wpm_request_url = $this->RequestURL();
// get all levels
$wpm_levels = (array) $this->GetOption('wpm_levels');
// check if the requested URL is a special URL
$specialurl = false;
$regurl = get_bloginfo('url') . '/register/';
foreach ((array) $wpm_levels as $wpml) {
$specialurl = $specialurl | (bool) ($regurl . $wpml['url'] == $wpm_request_url);
}
if ($specialurl) {
return $template;
}
// process attachments
if (is_attachment()) {
$aid = $wp_query->query_vars['attachment_id'];
if (!$aid && $wp_query->post->post_type == 'attachment') {
$aid = $wp_query->post->ID;
}
$attachment = get_post($aid);
// no parent post? return template as-is
if (!$attachment->post_parent) {
return $template;
}
// we clone the protection information from the parent
$type = get_post_type($attachment->post_parent) == 'page' ? 'pages' : 'posts';
$this->CloneProtection($attachment->post_parent, $aid, $type, 'posts');
}
// process pages and posts
if (is_page() or is_single()) {
/* page/post becomes protected if a more tag is located and wpm_protect_after_more==1 */
if ($this->GetOption('protect_after_more') && strpos($wp_query->post->post_content, '<!--more-->') !== false) {
$protectmore = true;
} else {
$protectmore = false;
}
// is page or post protected?
$protect = $protectmore || $this->Protect($wp_query->post->ID);
/*
// post is protected if category is protected
$cats=wp_get_post_categories($wp_query->post->ID);
$protectcat=false;
foreach((array)$cats AS $cat) $protectcat=$protectcat|$this->CatProtected($cat);
*/
// page / post not protected so give them all
if (!$protect) {
return $template;
}
//.........这里部分代码省略.........
示例14: feed_links_extra
/**
* Display the links to the extra feeds such as category feeds.
*
* @since 2.8.0
*
* @param array $args Optional arguments.
*/
function feed_links_extra($args)
{
$defaults = array('separator' => _x('»', 'feed link'), 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), 'cattitle' => __('%1$s %2$s %3$s Category Feed'), 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'));
$args = wp_parse_args($args, $defaults);
if (is_single() || is_page()) {
$post =& get_post($id = 0);
if (comments_open() || pings_open() || $post->comment_count > 0) {
$title = esc_attr(sprintf($args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html(get_the_title())));
$href = get_post_comments_feed_link($post->ID);
}
} elseif (is_category()) {
$cat_id = intval(get_query_var('cat'));
$title = esc_attr(sprintf($args['cattitle'], get_bloginfo('name'), $args['separator'], get_cat_name($cat_id)));
$href = get_category_feed_link($cat_id);
} elseif (is_tag()) {
$tag_id = intval(get_query_var('tag_id'));
$tag = get_tag($tag_id);
$title = esc_attr(sprintf($args['tagtitle'], get_bloginfo('name'), $args['separator'], $tag->name));
$href = get_tag_feed_link($tag_id);
} elseif (is_author()) {
$author_id = intval(get_query_var('author'));
$title = esc_attr(sprintf($args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta('display_name', $author_id)));
$href = get_author_feed_link($author_id);
} elseif (is_search()) {
$title = esc_attr(sprintf($args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query()));
$href = get_search_feed_link();
}
if (isset($title) && isset($href)) {
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n";
}
}
示例15: unserialize
?>
</td>
<td><?php
echo $v->theme_name;
?>
</td>
<td><?php
echo $v->subtheme_name;
?>
</td>
<td><?php
$tags = unserialize($v->tag);
$array = array();
if (!empty($tags)) {
foreach ($tags as $t) {
$array[] = get_tag($t);
}
echo implode(', ', $array);
} else {
echo "";
}
?>
</td>
<td><?php
$tags_items = unserialize($v->tag_item);
$array = array();
if (!empty($tags_items)) {
foreach ($tags_items as $t) {
$array[] = get_tag_item($t);
}
echo implode(', ', $array);