/** * 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 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); } } } } }
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; }
public static function getCurrentTagObj() { static $cache = null; if ($cache !== null) { return $cache; } $cache = \get_tag(static::getCurrentTagID()); return $cache; }
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; }
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; }
/** * 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')); }
/** * 产品选项 */ 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')); }
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(); } }
/** * @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); }
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; }
/** * 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; } } } break; case 'category': if (!$rule['minor'] && is_category()) { $condition_result = true; } else { $rule['minor'] = self::maybe_get_split_term($rule['minor'], $rule['major']); if (is_category($rule['minor'])) { $condition_result = true; } else { if (is_singular() && $rule['minor'] && in_array('category', get_post_taxonomies()) && has_category($rule['minor'])) { $condition_result = true; } } } break; case 'loggedin': $condition_result = is_user_logged_in(); if ('loggedin' !== $rule['minor']) { $condition_result = !$condition_result; } break; case 'author': $post = get_post(); if (!$rule['minor'] && is_author()) { $condition_result = true; } else { if ($rule['minor'] && is_author($rule['minor'])) { $condition_result = true; } else { if (is_singular() && $rule['minor'] && $rule['minor'] == $post->post_author) { $condition_result = true; } } } break; case 'role': if (is_user_logged_in()) { $current_user = wp_get_current_user(); $user_roles = $current_user->roles; if (in_array($rule['minor'], $user_roles)) { $condition_result = true; } else { $condition_result = false; } } else { $condition_result = false; } break; case 'taxonomy': $term = explode('_tax_', $rule['minor']); // $term[0] = taxonomy name; $term[1] = term id if (isset($term[0]) && isset($term[1])) { $term[1] = self::maybe_get_split_term($term[1], $term[0]); } if (isset($term[1]) && is_tax($term[0], $term[1])) { $condition_result = true; } else { if (isset($term[1]) && is_singular() && $term[1] && has_term($term[1], $term[0])) { $condition_result = true; } else { if (is_singular() && ($post_id = get_the_ID())) { $terms = get_the_terms($post_id, $rule['minor']); // Does post have terms in taxonomy? if ($terms && !is_wp_error($terms)) { $condition_result = true; } } } } break; } if ($condition_result || self::$passed_template_redirect) { // Some of the conditions will return false when checked before the template_redirect // action has been called, like is_page(). Only store positive lookup results, which // won't be false positives, before template_redirect, and everything after. $condition_result_cache[$condition_key] = $condition_result; } } if ($condition_result) { break; } } if ('show' == $instance['conditions']['action'] && !$condition_result || 'hide' == $instance['conditions']['action'] && $condition_result) { return false; } return $instance; }
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; } // if this is a userpost/payperpost then return if user has access to it $is_userpost = in_array($wp_query->post->ID, $this->GetMembershipContent($wp_query->post->post_type, 'U-' . $wpm_current_user->ID)); if ($is_userpost) { return $template; } // page / post is excluded (special page) so give all if (in_array($wp_query->post->ID, $this->ExcludePages(array()))) { return $template; } } // process categories if (is_category() || is_tax()) { if (is_category()) { $cat_ID = get_query_var('cat'); } else { $cat_ID = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); $cat_ID = $cat_ID->term_id; } // go ahead for non-protected categories if (!$this->CatProtected($cat_ID)) { return $template; } } // retrieve page to display for non-members $nonmemberredirect = $this->NonMembersURL(); if (!$wpm_current_user->ID) { $redirect = $nonmemberredirect; // redirect non-members if ($redirect != $wpm_request_url) { header('Location:' . $redirect); exit; } } else { // user is a member // check if any of the current user's membership levels have expired $activeLevels = $thelevels = (array) $this->GetMembershipLevels($wpm_current_user->ID, null, null, null, true); $timestamps = $this->UserLevelTimestamps($wpm_current_user->ID); $time = time(); $expiredLevels = $unconfirmedLevels = $forAprovalLevels = $cancelledLevels = array(); foreach ((array) $activeLevels as $key => $thelevelid) { if ($this->LevelExpired($thelevelid, $wpm_current_user->ID)) { unset($activeLevels[$key]); $expiredLevels[] = $thelevelid; } } // no more levels left for this member? if so, redirect if (!count($activeLevels)) { $redirect = $this->ExpiredURL($nonmemberredirect); if ($redirect != $wpm_request_url) { header('Location:' . $redirect); exit; } } // check if any of the levels are for confirmation foreach ((array) $activeLevels as $key => $thelevelid) { if ($this->LevelUnConfirmed($thelevelid, $wpm_current_user->ID)) { unset($activeLevels[$key]); $unconfirmedLevels[] = $thelevelid; } } // no more levels left for this member? if so, redirect to for confirmation page if (!count($activeLevels)) { $redirect = $this->ForConfirmationURL(); if ($redirect != $wpm_request_url) { header('Location:' . $redirect); exit; } } // check if any of the levels are for approval foreach ((array) $activeLevels as $key => $thelevelid) { if ($this->LevelForApproval($thelevelid, $wpm_current_user->ID)) { unset($activeLevels[$key]); $forAprovalLevels[] = $thelevelid; } } // no more levels left for this member? if so, redirect to for approval page if (!count($activeLevels)) { $redirect = $this->ForApprovalURL(); if ($redirect != $wpm_request_url) { header('Location:' . $redirect); exit; } } // check if any of the levels are cancelled foreach ((array) $activeLevels as $key => $thelevelid) { if ($this->LevelCancelled($thelevelid, $wpm_current_user->ID)) { unset($activeLevels[$key]); $cancelledLevels[] = $thelevelid; } } // no more levels left for this member? if so, redirect to cancelled page if (!count($activeLevels)) { $redirect = $this->CancelledURL(); if ($redirect != $wpm_request_url) { header('Location:' . $redirect); exit; } } // check viewing status for each level (if all is selected for any) $canviewpage = $canviewcategory = $canviewpost = $canviewcomment = false; foreach ((array) $thelevels as $thelevelid) { if (in_array($thelevelid, $activeLevels)) { $thelevel = $wpm_levels[$thelevelid]; $canviewpage = $canviewpage | isset($thelevel['allpages']); $canviewcategory = $canviewcategory | isset($thelevel['allcategories']); $canviewpost = $canviewpost | isset($thelevel['allposts']); $canviewcomment = $canviewcomment | isset($thelevel['allcomments']); } } // check individual viewing status for each content type (post, page, category, comment) $wronglevel = $cancelled = $unconfirmed = $expired = $forapproval = false; if (!$canviewcomment && is_single()) { $access = array_intersect((array) $this->GetContentLevels('comments', $wp_query->post->ID), $activeLevels); if (empty($access)) { //check if it's a custom post type $protected_types = $this->GetOption('protected_custom_post_types'); $post_type = get_post_type($wp_query->post); if (in_array($post_type, (array) $protected_types)) { $access = array_intersect((array) $this->GetContentLevels($post_type, $wp_query->post->ID), $activeLevels); } else { add_filter('comments_template', array(&$this, 'NoComments')); } } } if (!$canviewpage && is_page()) { $access = array_intersect((array) $this->GetContentLevels('pages', $wp_query->post->ID), $activeLevels); if (!empty($access)) { return $template; } $wronglevel = true; } elseif (!$canviewcategory && is_category() or is_tax()) { $access = array_intersect((array) $this->GetContentLevels('categories', $cat_ID), $activeLevels); if (!empty($access)) { return $template; } $wronglevel = true; } elseif (!$canviewpost && is_single()) { $access = array_intersect((array) $this->GetContentLevels('posts', $wp_query->post->ID), $activeLevels); if (!empty($access)) { return $template; } $wronglevel = true; } if ($wronglevel) { if (!empty($expiredLevels)) { $redirect = $this->ExpiredURL(); } elseif (!empty($unconfirmedLevels)) { $redirect = $this->ForConfirmationURL(); } elseif (!empty($forAprovalLevels)) { $redirect = $this->ForApprovalURL(); } elseif (!empty($cancelledLevels)) { $redirect = $this->CancelledURL(); } else { $redirect = $this->WrongLevelURL(); } if ($redirect != $wpm_request_url) { header('Location:' . $redirect); exit; } } } return $template; }
/** * 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"; } }
?> </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);
public function buildWhereClause() { $settings = $this->getSettings(); if ($settings['adCycle'] == 0) { $cycle = 1000; } else { $cycle = $settings['adCycle']; } global $current_user, $wpdb; $sTable = $wpdb->prefix . 'sam_stats'; $viewPages = 0; $wcc = ''; $wci = ''; $wca = ''; $wcx = ''; $wct = ''; $wcxc = ''; $wcxa = ''; $wcxt = ''; $wcct = ''; $wcxct = ''; if (is_user_logged_in()) { get_currentuserinfo(); $uSlug = $current_user->user_nicename; $wcul = "IF(sa.ad_users_reg = 1, IF(sa.x_ad_users = 1, NOT FIND_IN_SET(\"{$uSlug}\", sa.x_view_users), TRUE) AND IF(sa.ad_users_adv = 1, (sa.adv_nick <> \"{$uSlug}\"), TRUE), FALSE)"; } else { $wcul = "(sa.ad_users_unreg = 1)"; } $wcu = "(IF(sa.ad_users = 0, TRUE, {$wcul})) AND"; if (is_home() || is_front_page()) { $viewPages += SAM_IS_HOME; } if (is_singular()) { $viewPages |= SAM_IS_SINGULAR; if ($this->isCustomPostType()) { $viewPages |= SAM_IS_SINGLE; $viewPages |= SAM_IS_POST_TYPE; $postType = get_post_type(); $wct .= " AND IF(sa.view_type < 2 AND sa.ad_custom AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), FIND_IN_SET(\"{$postType}\", sa.view_custom), TRUE)"; $wcxt .= " AND IF(sa.view_type < 2 AND sa.x_custom AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), NOT FIND_IN_SET(\"{$postType}\", sa.x_view_custom), TRUE)"; } if (is_single()) { global $post; $viewPages |= SAM_IS_SINGLE; $categories = get_the_category($post->ID); $tags = get_the_tags(); $postID = !empty($post->ID) ? $post->ID : 0; $customTerms = self::customTaxonomiesTerms($postID); if (!empty($categories)) { $wcc_0 = ''; $wcxc_0 = ''; $wcc = " AND IF(sa.view_type < 2 AND sa.ad_cats AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE),"; $wcxc = " AND IF(sa.view_type < 2 AND sa.x_cats AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE),"; foreach ($categories as $category) { if (empty($wcc_0)) { $wcc_0 = " FIND_IN_SET(\"{$category->category_nicename}\", sa.view_cats)"; } else { $wcc_0 .= " OR FIND_IN_SET(\"{$category->category_nicename}\", sa.view_cats)"; } if (empty($wcxc_0)) { $wcxc_0 = " (NOT FIND_IN_SET(\"{$category->category_nicename}\", sa.x_view_cats))"; } else { $wcxc_0 .= " AND (NOT FIND_IN_SET(\"{$category->category_nicename}\", sa.x_view_cats))"; } } $wcc .= $wcc_0 . ", TRUE)"; $wcxc .= $wcxc_0 . ", TRUE)"; } if (!empty($tags)) { $wct_0 = ''; $wcxt_0 = ''; $wct .= " AND IF(sa.view_type < 2 AND sa.ad_tags AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE),"; $wcxt .= " AND IF(sa.view_type < 2 AND sa.x_tags AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE),"; foreach ($tags as $tag) { if (empty($wct_0)) { $wct_0 = " FIND_IN_SET(\"{$tag->slug}\", sa.view_tags)"; } else { $wct_0 .= " OR FIND_IN_SET(\"{$tag->slug}\", sa.view_tags)"; } if (empty($wcxt_0)) { $wcxt_0 = " (NOT FIND_IN_SET(\"{$tag->slug}\", sa.x_view_tags))"; } else { $wcxt_0 .= " AND (NOT FIND_IN_SET(\"{$tag->slug}\", sa.x_view_tags))"; } } $wct .= $wct_0 . ", TRUE)"; $wcxt .= $wcxt_0 . ", TRUE)"; } if (!empty($customTerms)) { $wcct_0 = ''; $wcxct_0 = ''; $wcct .= " AND IF(sa.view_type < 2 AND sa.ad_custom_tax_terms AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE),"; $wcxct .= " AND IF(sa.view_type < 2 AND sa.x_ad_custom_tax_terms AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE),"; foreach ($customTerms as $cTerm) { if (empty($wcct_0)) { $wcct_0 = " FIND_IN_SET(\"{$cTerm}\", sa.view_custom_tax_terms)"; } else { $wcct_0 .= " OR FIND_IN_SET(\"{$cTerm}\", sa.view_custom_tax_terms)"; } if (empty($wcxct_0)) { $wcxct_0 = " (NOT FIND_IN_SET(\"{$cTerm}\", sa.x_view_custom_tax_terms))"; } else { $wcxct_0 .= " AND (NOT FIND_IN_SET(\"{$cTerm}\", sa.x_view_custom_tax_terms))"; } } $wcct .= $wcct_0 . ", TRUE)"; $wcxct .= $wcxct_0 . ", TRUE)"; } $wci = " OR (sa.view_type = 2 AND FIND_IN_SET({$postID}, sa.view_id))"; $wcx = " AND IF(sa.x_id, NOT FIND_IN_SET({$postID}, sa.x_view_id), TRUE)"; $author = get_userdata($post->post_author); $wca = " AND IF(sa.view_type < 2 AND sa.ad_authors AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), FIND_IN_SET(\"{$author->user_nicename}\", sa.view_authors), TRUE)"; $wcxa = " AND IF(sa.view_type < 2 AND sa.x_authors AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), NOT FIND_IN_SET(\"{$author->user_nicename}\", sa.x_view_authors), TRUE)"; } if (is_page()) { global $post; $postID = !empty($post->ID) ? $post->ID : 0; $viewPages |= SAM_IS_PAGE; $wci = " OR (sa.view_type = 2 AND FIND_IN_SET({$postID}, sa.view_id))"; $wcx = " AND IF(sa.x_id, NOT FIND_IN_SET({$postID}, sa.x_view_id), TRUE)"; } if (is_attachment()) { $viewPages |= SAM_IS_ATTACHMENT; } } if (is_search()) { $viewPages |= SAM_IS_SEARCH; } if (is_404()) { $viewPages |= SAM_IS_404; } if (is_archive()) { $viewPages |= SAM_IS_ARCHIVE; if (is_tax()) { $viewPages |= SAM_IS_TAX; $term = get_query_var('term'); $wcct = " AND IF(sa.view_type < 2 AND sa.ad_custom_tax_terms AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), FIND_IN_SET('{$term}', sa.view_custom_tax_terms), TRUE)"; $wcxct = " AND IF(sa.view_type < 2 AND sa.x_ad_custom_tax_terms AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), NOT FIND_IN_SET('{$term}', sa.x_view_custom_tax_terms), TRUE)"; } if (is_category()) { $viewPages |= SAM_IS_CATEGORY; $cat = get_category(get_query_var('cat'), false); $wcc = " AND IF(sa.view_type < 2 AND sa.ad_cats AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), FIND_IN_SET(\"{$cat->category_nicename}\", sa.view_cats), TRUE)"; $wcxc = " AND IF(sa.view_type < 2 AND sa.x_cats AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), NOT FIND_IN_SET(\"{$cat->category_nicename}\", sa.x_view_cats), TRUE)"; } if (is_tag()) { $viewPages |= SAM_IS_TAG; $tag = get_tag(get_query_var('tag_id')); $wct = " AND IF(sa.view_type < 2 AND sa.ad_tags AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), FIND_IN_SET('{$tag->slug}', sa.view_tags), TRUE)"; $wcxt = " AND IF(sa.view_type < 2 AND sa.x_tags AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), NOT FIND_IN_SET('{$tag->slug}', sa.x_view_tags), TRUE)"; } if (is_author()) { global $wp_query; $viewPages |= SAM_IS_AUTHOR; $author = $wp_query->get_queried_object(); $wca = " AND IF(sa.view_type < 2 AND sa.ad_authors = 1 AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), FIND_IN_SET('{$author->user_nicename}', sa.view_authors), TRUE)"; $wcxa = " AND IF(sa.view_type < 2 AND sa.x_authors AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), NOT FIND_IN_SET('{$author->user_nicename}', sa.x_view_authors), TRUE)"; } if (is_post_type_archive()) { $viewPages |= SAM_IS_POST_TYPE_ARCHIVE; //$postType = post_type_archive_title( '', false ); $postType = get_post_type(); $wct = " AND IF(sa.view_type < 2 AND sa.ad_custom AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), FIND_IN_SET('{$postType}', sa.view_custom), TRUE)"; $wcxt = " AND IF(sa.view_type < 2 AND sa.x_custom AND IF(sa.view_type = 0, sa.view_pages+0 & {$viewPages}, TRUE), NOT FIND_IN_SET('{$postType}', sa.x_view_custom), TRUE)"; } if (is_date()) { $viewPages |= SAM_IS_DATE; } } if (empty($wcc)) { $wcc = " AND (sa.ad_cats = 0)"; } if (empty($wca)) { $wca = " AND (sa.ad_authors = 0)"; } $whereClause = "{$wcu} ((sa.view_type = 1)"; $whereClause .= " OR (sa.view_type = 0 AND (sa.view_pages+0 & {$viewPages}))"; $whereClause .= "{$wci})"; $whereClause .= "{$wcc} {$wca} {$wct} {$wcct} {$wcx} {$wcxc} {$wcxa} {$wcxt} {$wcxct}"; $hits = "SELECT IFNULL(COUNT(*), 0) FROM {$sTable} ss WHERE ss.id = sa.id AND ss.event_type = 0"; $clicks = "SELECT IFNULL(COUNT(*), 0) FROM {$sTable} ss WHERE ss.id = sa.id AND ss.event_type = 1"; $whereClauseT = " AND IF(sa.ad_schedule, CURDATE() BETWEEN sa.ad_start_date AND sa.ad_end_date, TRUE)"; $whereClauseT .= " AND IF(sa.limit_hits, sa.hits_limit > ({$hits}), TRUE)"; $whereClauseT .= " AND IF(sa.limit_clicks, sa.clicks_limit > ({$clicks}), TRUE)"; $whereClauseW = " AND IF(sa.ad_weight > 0, (sa.ad_weight_hits*10/(sa.ad_weight*{$cycle})) < 1, FALSE)"; $whereClause2W = "AND (sa.ad_weight > 0)"; return array('WC' => $whereClause, 'WCT' => $whereClauseT, 'WCW' => $whereClauseW, 'WC2W' => $whereClause2W); }
private function get_bread_crumb_array($args) { global $post; $bread_crumb_arr = array(); $bread_crumb_arr[] = array('title' => $args['home_label'], 'link' => get_bloginfo('url') . '/'); $bread_crumb_arr = $this->add_posts_page_array($bread_crumb_arr); if (is_404()) { $bread_crumb_arr[] = array('title' => $args['404_label'], 'link' => false); } elseif (is_search()) { $bread_crumb_arr[] = array('title' => sprintf($args['search_label'], get_search_query()), 'link' => false); } elseif (is_tax()) { $taxonomy = get_query_var('taxonomy'); if ($this->site_structure['post']['page'] != 0) { // TODO 投稿タイプの判別 $parent_page = get_post($this->site_structure['post']['page']); $singular_bread_crumb_arr = $this->get_singular_bread_crumb_array($parent_page, $args); $bread_crumb_arr = array_merge($bread_crumb_arr, $singular_bread_crumb_arr); } $term = get_term_by('slug', get_query_var('term'), $taxonomy); if (is_taxonomy_hierarchical($taxonomy) && $term->parent != 0) { $ancestors = array_reverse(get_ancestors($term->term_id, $taxonomy)); foreach ($ancestors as $ancestor_id) { $ancestor = get_term($ancestor_id, $taxonomy); $bread_crumb_arr[] = array('title' => $ancestor->name, 'link' => get_term_link($ancestor, $term->slug)); } } $bread_crumb_arr[] = array('title' => sprintf($args['taxonomy_label'], $term->name), 'link' => get_term_link($term->term_id, $term->slug)); } elseif (is_attachment()) { if ($post->post_parent) { if ($parent_post = get_post($post->post_parent)) { $singular_bread_crumb_arr = $this->get_singular_bread_crumb_array($parent_post, $args); $bread_crumb_arr = array_merge($bread_crumb_arr, $singular_bread_crumb_arr); } } $bread_crumb_arr[] = array('title' => sprintf($args['attachment_label'], $post->post_title), 'link' => get_permalink($post->ID)); } elseif (is_singular() && !is_front_page()) { $singular_bread_crumb_arr = $this->get_singular_bread_crumb_array($post, $args); $bread_crumb_arr = array_merge($bread_crumb_arr, $singular_bread_crumb_arr); $bread_crumb_arr[] = array('title' => $post->post_title, 'link' => get_permalink($post->ID)); } elseif (is_category()) { global $cat; if ($this->site_structure['post']['page'] != 0) { $singular_bread_crumb_arr = $this->get_parent_page_array('post', $args); $bread_crumb_arr = array_merge($bread_crumb_arr, $singular_bread_crumb_arr); } $category = get_category($cat); if ($category->parent != 0) { $ancestors = array_reverse(get_ancestors($category->term_id, 'category')); foreach ($ancestors as $ancestor_id) { $ancestor = get_category($ancestor_id); $bread_crumb_arr[] = array('title' => $ancestor->name, 'link' => get_category_link($ancestor->term_id)); } } $bread_crumb_arr[] = array('title' => sprintf($args['category_label'], $category->name), 'link' => get_category_link($cat)); } elseif (is_tag()) { global $tag_id; if ($this->site_structure['post']['page'] != 0) { $singular_bread_crumb_arr = $this->get_parent_page_array('post', $args); $bread_crumb_arr = array_merge($bread_crumb_arr, $singular_bread_crumb_arr); } $tag = get_tag($tag_id); $bread_crumb_arr[] = array('title' => sprintf($args['tag_label'], $tag->name), 'link' => get_tag_link($tag_id)); } elseif (is_author()) { $author = get_query_var('author'); $bread_crumb_arr[] = array('title' => sprintf($args['author_label'], get_the_author_meta('display_name', get_query_var('author'))), 'link' => get_author_posts_url($author)); } elseif (is_day()) { $post_type = get_query_var('post_type') ? get_query_var('post_type') : 'post'; if (isset($this->site_structure[$post_type]['page']) && $this->site_structure[$post_type]['page'] != 0) { $singular_bread_crumb_arr = $this->get_parent_page_array($post_type, $args); $bread_crumb_arr = array_merge($bread_crumb_arr, $singular_bread_crumb_arr); } if ($m = get_query_var('m')) { $year = substr($m, 0, 4); $month = substr($m, 4, 2); $day = substr($m, 6, 2); } else { $year = get_query_var('year'); $month = get_query_var('monthnum'); $day = get_query_var('day'); } $month_title = $this->get_month_title($month); $bread_crumb_arr[] = array('title' => sprintf($args['year_label'], $year), 'link' => get_year_link($year)); $bread_crumb_arr[] = array('title' => sprintf($args['month_label'], $month_title), 'link' => get_month_link($year, $month)); $bread_crumb_arr[] = array('title' => sprintf($args['day_label'], $day), 'link' => get_day_link($year, $month, $day)); } elseif (is_month()) { $post_type = get_query_var('post_type') ? get_query_var('post_type') : 'post'; if (isset($this->site_structure[$post_type]['page']) && $this->site_structure[$post_type]['page'] != 0) { $singular_bread_crumb_arr = $this->get_parent_page_array($post_type, $args); $bread_crumb_arr = array_merge($bread_crumb_arr, $singular_bread_crumb_arr); } if ($m = get_query_var('m')) { $year = substr($m, 0, 4); $month = substr($m, 4, 2); } else { $year = get_query_var('year'); $month = get_query_var('monthnum'); } $month_title = $this->get_month_title($month); $bread_crumb_arr[] = array('title' => sprintf($args['year_label'], $year), 'link' => get_year_link($year)); $bread_crumb_arr[] = array('title' => sprintf($args['month_label'], $month_title), 'link' => get_month_link($year, $month)); } elseif (is_year()) { $post_type = get_query_var('post_type') ? get_query_var('post_type') : 'post'; if (isset($this->site_structure[$post_type]['page']) && $this->site_structure[$post_type]['page'] != 0) { $singular_bread_crumb_arr = $this->get_parent_page_array($post_type, $args); $bread_crumb_arr = array_merge($bread_crumb_arr, $singular_bread_crumb_arr); } if ($m = get_query_var('m')) { $year = substr($m, 0, 4); } else { $year = get_query_var('year'); } $bread_crumb_arr[] = array('title' => sprintf($args['year_label'], $year), 'link' => get_year_link($year)); } elseif (is_post_type_archive()) { $post_type = get_post_type_object(get_query_var('post_type')); $bread_crumb_arr[] = array('title' => sprintf($args['post_type_label'], $post_type->label), 'link' => get_post_type_archive_link($post_type->name)); } $bread_crumb_arr = apply_filters('bread_crumb_arr', $bread_crumb_arr); return $bread_crumb_arr; }
/** * Queries the selected tags to show pre-selected values by the user. * * @since 1.0.0 */ public function query_selected_taxonomies() { // Run a security check first. check_ajax_referer('omapi-query-nonce', 'nonce'); // Prepare variables. $ids = explode(',', stripslashes($_POST['ids'])); $ret = array(); $ret['items'] = array(); // Make the query. foreach ($ids as $id) { $tag = get_tag(absint($id)); if ($tag) { $ret['items'][] = array('id' => $tag->term_id, 'title' => $tag->name); } } // Send back the response. die(json_encode($ret)); }
if (!empty($f['tags_id'])) { foreach ($f['tags_id'] as $tag) { $tagname = get_tag($tag); $tagarray[] = $tagname->name; } $tag = join(',', $tagarray); } else { $tag = array(); } } else { if (empty($f['tags_id'])) { $f['tags_id'] = array(); $tag = ''; } else { $f['tags_id'] = array($f['tags_id']); $tagname = get_tag(intval($f['tags_id'])); $tag = $tagname->name; } } if (is_array($f['category_id'])) { foreach ($f['category_id'] as $cat) { $catarray[] = get_cat_name($cat); } $category = join(',', $catarray); } else { if (empty($f['category_id'])) { $f['category_id'] = array(1); $category = get_the_category_by_ID(1); } else { $f['category_id'] = array($f['category_id']); $category = get_the_category_by_ID(intval($f['category_id']));
/** * 构造方法 */ public function __construct() { $this->base_uri = 'http://chinagdg.org/feed/'; $this->tag = get_tag($this->base_uri); }
public function pre_get_posts($query) { global $wpdb; $qv =& $query->query_vars; if ($query->is_main_query() || !empty($qv['lang']) || !empty($qv['post_type']) && !$this->model->is_translated_post_type($qv['post_type'])) { return; } $sign = create_function('$n', 'return $n > 0 ? 1 : ($n < 0 ? -1 : 0);'); // /!\ always keep untranslated as is // term ids separated by a comma $arr = array(); if (!empty($qv['cat'])) { foreach (explode(',', $qv['cat']) as $cat) { $arr[] = ($tr = $sign($cat) * pll_get_term(abs($cat))) ? $tr : $cat; } $qv['cat'] = implode(',', $arr); } // category_name $arr = array(); if (!empty($qv['category_name'])) { foreach (explode(',', $qv['category_name']) as $slug) { $arr[] = ($cat = get_category_by_slug($slug)) && ($tr_id = pll_get_term($cat->term_id)) && !is_wp_error($tr = get_category($tr_id)) ? $tr->slug : $slug; } $qv['category_name'] = implode(',', $arr); } // array of term ids foreach (array('category__and', 'category__in', 'category__not_in', 'tag__and', 'tag__in', 'tag__not_in') as $key) { $arr = array(); if (!empty($qv[$key])) { foreach ($qv[$key] as $cat) { $arr[] = ($tr = pll_get_term($cat)) ? $tr : $cat; } $qv[$key] = $arr; } } // tag $arr = array(); if (!empty($qv['tag'])) { $sep = strpos($qv['tag'], ',') !== false ? ',' : '+'; // two possible separators for tag slugs foreach (explode($sep, $qv['tag']) as $slug) { $arr[] = ($tag = get_term_by('slug', $slug, 'post_tag')) && ($tr_id = pll_get_term($tag->term_id)) && !is_wp_error($tr = get_tag($tr_id)) ? $tr->slug : $slug; } $qv['tag'] = implode($sep, $arr); } // tag_id can only take one id if (!empty($qv['tag_id']) && ($tr_id = pll_get_term($qv['tag_id']))) { $qv['tag_id'] = $tr_id; } // array of tag slugs foreach (array('tag_slug__and', 'tag_slug__in') as $key) { $arr = array(); if (!empty($qv[$key])) { foreach ($qv[$key] as $slug) { $arr[] = ($tag = get_term_by('slug', $slug, 'post_tag')) && ($tr_id = pll_get_term($tag->term_id)) && !is_wp_error($tr = get_tag($tr_id)) ? $tr->slug : $slug; } $qv[$key] = $arr; } } // custom taxonomies // according to codex, this type of query is deprecated as of WP 3.1 but it does not appear in WP 3.5 source code foreach (array_intersect($this->model->get_translated_taxonomies(), get_taxonomies(array('_builtin' => false))) as $taxonomy) { $tax = get_taxonomy($taxonomy); $arr = array(); if (!empty($qv[$tax->query_var])) { $sep = strpos($qv[$tax->query_var], ',') !== false ? ',' : '+'; // two possible separators foreach (explode($sep, $qv[$tax->query_var]) as $slug) { $arr[] = ($tag = get_term_by('slug', $slug, $taxonomy)) && ($tr_id = pll_get_term($tag->term_id)) && !is_wp_error($tr = get_term($tr_id, $taxonomy)) ? $tr->slug : $slug; } $qv[$tax->query_var] = implode($sep, $arr); } } // tax_query since WP 3.1 if (!empty($qv['tax_query']) && is_array($qv['tax_query'])) { $qv['tax_query'] = $this->translate_tax_query_recursive($qv['tax_query']); } // p, page_id, post_parent can only take one id foreach (array('p', 'page_id', 'post_parent') as $key) { if (!empty($qv[$key]) && ($tr_id = pll_get_post($qv[$key]))) { $qv[$key] = $tr_id; } } // name, pagename can only take one slug foreach (array('name', 'pagename') as $key) { if (!empty($qv[$key])) { // no function to get post by name except get_posts itself $post_type = empty($qv['post_type']) ? 'post' : $qv['post_type']; $id = $wpdb->get_var($wpdb->prepare("SELECT ID from {$wpdb->posts} WHERE post_type=%s AND post_name=%s", $post_type, $qv[$key])); $qv[$key] = $id && ($tr_id = pll_get_post($id)) && ($tr = get_post($tr_id)) ? $tr->post_name : $qv[$key]; } } // array of post ids // post_parent__in & post_parent__not_in since WP 3.6 foreach (array('post__in', 'post__not_in', 'post_parent__in', 'post_parent__not_in') as $key) { $arr = array(); if (!empty($qv[$key])) { // post__in used by the 2 functions below // useless to filter them as output is already in the right language and would result in performance loss foreach (debug_backtrace() as $trace) { if (in_array($trace['function'], array('wp_nav_menu', 'gallery_shortcode'))) { return; } } foreach ($qv[$key] as $p) { $arr[] = ($tr = pll_get_post($p)) ? $tr : $p; } $qv[$key] = $arr; } } }
</div> <div class="col-lg-4 col-lg-offset-1 col-md-4 col-sm-12"> <div class="widget-box list"> <h3 class="widget-title"> <?php if (!$posttype) { echo "Filter"; } else { echo "More"; } ?> </h3> <ul> <?php $t = get_tag($thistagid); $t = $thistagslug; if ($posttype == 'task') { $landingpage = get_option('options_module_tasks_page'); if (!$landingpage) { $landingpage_link_text = 'tasks and guides'; $landingpage = site_url() . '/how-do-i/'; } else { $landingpage_link_text = get_the_title($landingpage[0]); $landingpage = get_permalink($landingpage[0]); } echo "<li><a href='" . $landingpage . "'>Go to " . $landingpage_link_text . "</a></li>"; } if ($posttype == 'project') { $landingpage = get_option('options_module_projects_page'); if (!$landingpage) {
function get_tag_feed_link($tag_id, $feed = '') { $tag_id = (int) $tag_id; $tag = get_tag($tag_id); if (empty($tag) || is_wp_error($tag)) { return false; } $permalink_structure = get_option('permalink_structure'); if (empty($feed)) { $feed = get_default_feed(); } if ('' == $permalink_structure) { $link = get_option('home') . "?feed={$feed}&tag=" . $tag->slug; } else { $link = get_tag_link($tag->term_id); if ($feed == get_default_feed()) { $feed_link = 'feed'; } else { $feed_link = "feed/{$feed}"; } $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); } $link = apply_filters('tag_feed_link', $link, $feed); return $link; }
function wiziapp_buildTagPage($tag_id) { $screen_conf = $GLOBALS['WiziappScreens']->getScreenLayout('posts'); $pageNumber = isset($_GET['wizipage']) ? $_GET['wizipage'] : 0; $numberOfPosts = WiziappConfig::getInstance()->posts_list_limit; $offset = $numberOfPosts * $pageNumber; $tag = get_tag($tag_id); $title = wiziapp_apply_request_title("{$tag->name}"); $query = "tag__in={$tag_id}&orderby=post_date&posts_per_page=" . $numberOfPosts . "&offset=" . $offset; // Find the total number of posts in the blog $totalPostsInTag = $tag->count; if ($totalPostsInTag < $offset) { echo json_encode(wiziapp_prepareSectionScreen(array(), $title, "List")); exit; } if ($numberOfPosts < $totalPostsInTag) { $showMore = $totalPostsInTag - $numberOfPosts; } else { $showMore = FALSE; } $posts = wiziapp_buildPostListPage($query, '', $screen_conf['items'], TRUE, $showMore, FALSE); $postsCount = count($posts); $totalShownPosts = $totalPostsInTag - ($offset + $postsCount); if ($totalShownPosts < $numberOfPosts) { $showMore = $totalShownPosts; } else { $showMore = $numberOfPosts; } if ($showMore) { $obj = new WiziappMoreCellItem('L1', array(sprintf(__("Load %d more items", 'wiziapp'), $showMore), $pageNumber + 1)); $moreComponent = $obj->getComponent(); $posts[] = $moreComponent; } $section = array(); $section[] = array('section' => array('title' => '', 'id' => 'recent', 'items' => $posts)); echo json_encode(wiziapp_prepareSectionScreen($section, $title, "List")); // echo json_encode(wiziapp_prepareSectionScreen(array($posts), $title, "List")); // echo json_encode(wiziapp_prepareScreen($cPage, $title, 'list', false, true)); }
<?php $tags = get_the_tags(get_the_ID()); if (!empty($tags)) { ?> <div class="tag-could tag-title"><i class="fa fa-tags"></i> <?php foreach ($tags as $tag) { $tag = get_tag($tag); $link = get_tag_link($tag); echo ' <a href="' . esc_url($link) . '" title="' . esc_attr($tag->name) . '" class="tag-1"><span>' . $tag->name . '</span><s>' . $tag->count . '</s></a>'; } ?> </div><?php }
function dimox_breadcrumbs() { /* === OPTIONS === */ $text['home'] = 'Home'; // text for the 'Home' link $text['category'] = 'Archive by Category "%s"'; // text for a category page $text['search'] = 'Search Results for "%s"'; // text for a search results page $text['tag'] = 'Posts Tagged "%s"'; // text for a tag page $text['author'] = 'Articles Posted by %s'; // text for an author page $text['404'] = 'Error 404'; // text for the 404 page $text['page'] = 'Page %s'; // text 'Page N' $text['cpage'] = 'Comment Page %s'; // text 'Comment Page N' $wrap_before = '<div class="breadcrumbs">'; // the opening wrapper tag $wrap_after = '</div><!-- .breadcrumbs -->'; // the closing wrapper tag $sep = '<i class="fa fa-angle-double-right"></i>'; // separator between crumbs $sep_before = '<span class="sep">'; // tag before separator $sep_after = '</span>'; // tag after separator $show_home_link = 1; // 1 - show the 'Home' link, 0 - don't show $show_on_home = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $show_current = 1; // 1 - show current page title, 0 - don't show $before = '<span class="current">'; // tag before the current crumb $after = '</span>'; // tag after the current crumb /* === END OF OPTIONS === */ global $post; $home_link = home_url('/'); $link_before = '<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">'; $link_after = '</span>'; $link_attr = ' itemprop="url"'; $link_in_before = '<span itemprop="title">'; $link_in_after = '</span>'; $link = $link_before . '<a href="%1$s"' . $link_attr . '>' . $link_in_before . '%2$s' . $link_in_after . '</a>' . $link_after; $frontpage_id = get_option('page_on_front'); $parent_id = $post->post_parent; $sep = ' ' . $sep_before . $sep . $sep_after . ' '; if (is_front_page()) { if ($show_on_home) { echo $wrap_before . '<a href="' . $home_link . '">' . $text['home'] . '</a>' . $wrap_after; } } else { echo $wrap_before; if ($show_home_link) { echo sprintf($link, $home_link, $text['home']); } if (is_category()) { $cat = get_category(get_query_var('cat'), false); if ($cat->parent != 0) { $cats = get_category_parents($cat->parent, TRUE, $sep); $cats = preg_replace("#^(.+){$sep}\$#", "\$1", $cats); $cats = preg_replace('#<a([^>]+)>([^<]+)<\\/a>#', $link_before . '<a$1' . $link_attr . '>' . $link_in_before . '$2' . $link_in_after . '</a>' . $link_after, $cats); if ($show_home_link) { echo $sep; } echo $cats; } if (get_query_var('paged')) { $cat = $cat->cat_ID; echo $sep . sprintf($link, get_category_link($cat), get_cat_name($cat)) . $sep . $before . sprintf($text['page'], get_query_var('paged')) . $after; } else { if ($show_current) { echo $sep . $before . sprintf($text['category'], single_cat_title('', false)) . $after; } } } elseif (is_search()) { if (have_posts()) { if ($show_home_link && $show_current) { echo $sep; } if ($show_current) { echo $before . sprintf($text['search'], get_search_query()) . $after; } } else { if ($show_home_link) { echo $sep; } echo $before . sprintf($text['search'], get_search_query()) . $after; } } elseif (is_day()) { if ($show_home_link) { echo $sep; } echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $sep; echo sprintf($link, get_month_link(get_the_time('Y'), get_the_time('m')), get_the_time('F')); if ($show_current) { echo $sep . $before . get_the_time('d') . $after; } } elseif (is_month()) { if ($show_home_link) { echo $sep; } echo sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')); if ($show_current) { echo $sep . $before . get_the_time('F') . $after; } } elseif (is_year()) { if ($show_home_link && $show_current) { echo $sep; } if ($show_current) { echo $before . get_the_time('Y') . $after; } } elseif (is_single() && !is_attachment()) { if ($show_home_link) { echo $sep; } if (get_post_type() != 'post') { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; if ($slug['slug'] == 'marketplace-listing') { $link = $link_before . '<a href="%1$s"' . $link_attr . '>' . $link_in_before . 'Made in West Virginia' . $link_in_after . '</a>' . $link_after; $s = 'made-in-west-virginia'; } elseif ($slug['slug'] == 'directory-listing') { $link = $link_before . '<a href="%1$s"' . $link_attr . '>' . $link_in_before . 'Creative Network' . $link_in_after . '</a>' . $link_after; $s = 'creative-network'; } elseif ($slug['slug'] == 'trail') { $link = $link_before . '<a href="%1$s"' . $link_attr . '>' . $link_in_before . 'Visit Art Spaces' . $link_in_after . '</a>' . $link_after; $s = 'visit-art-spaces'; } else { } printf($link, $home_link . $s, $post_type->labels->singular_name); if ($show_current) { echo $sep . $before . get_the_title() . $after; } } else { $cat = get_the_category(); $cat = $cat[0]; $cats = get_category_parents($cat, TRUE, $sep); if (!$show_current || get_query_var('cpage')) { $cats = preg_replace("#^(.+){$sep}\$#", "\$1", $cats); } $cats = preg_replace('#<a([^>]+)>([^<]+)<\\/a>#', $link_before . '<a$1' . $link_attr . '>' . $link_in_before . '$2' . $link_in_after . '</a>' . $link_after, $cats); echo $cats; if (get_query_var('cpage')) { echo $sep . sprintf($link, get_permalink(), get_the_title()) . $sep . $before . sprintf($text['cpage'], get_query_var('cpage')) . $after; } else { if ($show_current) { echo $before . get_the_title() . $after; } } } // custom post type } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) { $post_type = get_post_type_object(get_post_type()); if (get_query_var('paged')) { echo $sep . sprintf($link, get_post_type_archive_link($post_type->name), $post_type->label) . $sep . $before . sprintf($text['page'], get_query_var('paged')) . $after; } else { if ($show_current) { echo $sep . $before . $post_type->label . $after; } } } elseif (is_attachment()) { if ($show_home_link) { echo $sep; } $parent = get_post($parent_id); $cat = get_the_category($parent->ID); $cat = $cat[0]; if ($cat) { $cats = get_category_parents($cat, TRUE, $sep); $cats = preg_replace('#<a([^>]+)>([^<]+)<\\/a>#', $link_before . '<a$1' . $link_attr . '>' . $link_in_before . '$2' . $link_in_after . '</a>' . $link_after, $cats); echo $cats; } printf($link, get_permalink($parent), $parent->post_title); if ($show_current) { echo $sep . $before . get_the_title() . $after; } } elseif (is_page() && !$parent_id) { if ($show_current) { echo $sep . $before . get_the_title() . $after; } } elseif (is_page() && $parent_id) { if ($show_home_link) { echo $sep; } if ($parent_id != $frontpage_id) { $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); if ($parent_id != $frontpage_id) { $breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID)); } $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { echo $breadcrumbs[$i]; if ($i != count($breadcrumbs) - 1) { echo $sep; } } } if ($show_current) { echo $sep . $before . get_the_title() . $after; } } elseif (is_tag()) { if (get_query_var('paged')) { $tag_id = get_queried_object_id(); $tag = get_tag($tag_id); echo $sep . sprintf($link, get_tag_link($tag_id), $tag->name) . $sep . $before . sprintf($text['page'], get_query_var('paged')) . $after; } else { if ($show_current) { echo $sep . $before . sprintf($text['tag'], single_tag_title('', false)) . $after; } } } elseif (is_author()) { global $author; $author = get_userdata($author); if (get_query_var('paged')) { if ($show_home_link) { echo $sep; } echo sprintf($link, get_author_posts_url($author->ID), $author->display_name) . $sep . $before . sprintf($text['page'], get_query_var('paged')) . $after; } else { if ($show_home_link && $show_current) { echo $sep; } if ($show_current) { echo $before . sprintf($text['author'], $author->display_name) . $after; } } } elseif (is_404()) { if ($show_home_link && $show_current) { echo $sep; } if ($show_current) { echo $before . $text['404'] . $after; } } elseif (has_post_format() && !is_singular()) { if ($show_home_link) { echo $sep; } echo get_post_format_string(get_post_format()); } elseif (is_home()) { if ($show_home_link) { echo $sep . "News & Updates"; } } echo $wrap_after; } }
/** * Get the URL of the featured image for a tag. * * The featured image URL is pulled from the theme's images directory. The file * name should match "tag-[category_slug].jpg". If the file does not exist, * this returns an empty string. * * @param $cat_ID (Int) The tag ID for which to get the featured image. * * @return (String) The URL of the featured_image for the given tag, or the * empty string on failure. */ function tag_featured_image_URL($tag_ID) { $image = '/images/tag-' . get_tag($tag_ID)->slug . '.jpg'; $path = get_stylesheet_directory() . $image; $URL = get_stylesheet_directory_uri() . $image; // If the file is not actually real, return the empty string. if (file_exists($path)) { return $URL; } else { return ''; } }
<div class="addthis_toolbox addthis_default_style" style="float:right;"> <a class="addthis_button_facebook"></a> <a class="addthis_button_google"></a> <a class="addthis_button_twitter"></a> <span class="addthis_separator">•</span> <a href="http://www.addthis.com/bookmark.php?v=250&username=xa-4c40b32a7baba973" class="addthis_button_compact">More</a> </div> <script type="text/javascript" src="//s7.addthis.com/js/250/addthis_widget.js#username=xa-4c40b32a7baba973"></script> <!-- AddThis Button END --> <?php } echo '<div class="scalar_logo_wrapper">' . "\n"; // Publisher icon if (!empty($book->publisher_thumbnail)) { $href = ''; $link_tags = get_tag('a', $book->publisher); if (!empty($link_tags)) { $href = getAttribute('href', $link_tags[0]); } if (!empty($href)) { echo '<a href="' . $href . '">'; } echo '<img class="publisher-thumb" src="' . confirm_slash(base_url()) . confirm_slash($book->slug) . $book->publisher_thumbnail . '" />' . "\n"; if (!empty($href)) { echo '</a>'; } } // Page version number if (isset($page->version_index) && isset($page->versions[$page->version_index]) && !empty($page->versions[$page->version_index])) { $title = $page->versions[$page->version_index]->title; $created = $page->versions[$page->version_index]->created;
function get_related($tag, $custom = null, $count = null) { if (empty($count)) { $count = config('related.count'); if (empty($count)) { $count = 3; } } $posts = get_tag($tag, 1, $count + 1, true); $tmp = array(); $req = urldecode($_SERVER['REQUEST_URI']); foreach ($posts as $post) { $url = $post->url; if (stripos($url, $req) === false) { $tmp[] = $post; } } if (empty($custom)) { $total = count($tmp); if ($total >= 1) { $i = 1; echo '<ul>'; foreach ($tmp as $post) { echo '<li><a href="' . $post->url . '">' . $post->title . '</a></li>'; if ($i++ >= $count) { break; } } echo '</ul>'; } else { echo '<ul><li>No related post found</li></ul>'; } } else { return $tmp; } }
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); if ($proper && login()) { $file = from($_REQUEST, 'file'); $destination = from($_GET, 'destination'); delete_page($file, $destination); } }); // Show the tag page get('/tag/:tag', function ($tag) { if (!login()) { file_cache($_SERVER['REQUEST_URI']); } $page = from($_GET, 'page'); $page = $page ? (int) $page : 1; $perpage = config('tag.perpage'); $posts = get_tag($tag, $page, $perpage, false); $total = get_tagcount($tag, 'basename'); $ttag = new stdClass(); $ttag->title = tag_i18n($tag); if (empty($posts) || $page < 1) { // a non-existing page not_found(); } render('main', array('title' => 'Posts tagged: ' . tag_i18n($tag) . ' - ' . blog_title(), 'description' => 'All posts tagged: ' . tag_i18n($tag) . ' on ' . blog_title() . '.', 'canonical' => site_url() . 'tag/' . strtolower($tag), 'page' => $page, 'posts' => $posts, 'tag' => $ttag, 'bodyclass' => 'intag', 'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Posts tagged: ' . tag_i18n($tag), 'pagination' => has_pagination($total, $perpage, $page), 'is_tag' => true)); }); // Show the archive page get('/archive/:req', function ($req) { if (!login()) { file_cache($_SERVER['REQUEST_URI']); } $page = from($_GET, 'page');