本文整理汇总了PHP中ap_get_link_to函数的典型用法代码示例。如果您正苦于以下问题:PHP ap_get_link_to函数的具体用法?PHP ap_get_link_to怎么用?PHP ap_get_link_to使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ap_get_link_to函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
public function widget($args, $instance)
{
$title = apply_filters('widget_title', $instance['title']);
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . $title . $args['after_title'];
}
?>
<form id="ap-search-form" class="ap-search-form" action="<?php
echo ap_get_link_to('search');
?>
" method="GET">
<div class="ap-qaf-inner">
<input class="form-control" type="text" name="ap_s" id="ap-quick-ask-input" placeholder="<?php
_e('Search questions & answers', 'ap');
?>
" value="<?php
echo sanitize_text_field(get_query_var('ap_s'));
?>
" autocomplete="off" />
<button type="submit" ><?php
_e('Search', 'ap');
?>
</button>
</div>
</form>
<?php
echo $args['after_widget'];
}
示例2: ap_linkyfy_mentions
/**
* Surround mentions with anchor tag.
* @param string $content Post content.
* @return string
*/
function ap_linkyfy_mentions($content)
{
if (!ap_opt('base_before_user_perma')) {
$base = home_url('/' . ap_get_user_page_slug() . '/');
} else {
$base = ap_get_link_to(ap_get_user_page_slug());
}
// Find mentions and wrap with anchor.
return preg_replace('/(?:[\\s.]|^)@(\\w+)/', '<a class="ap-mention-link" href="' . $base . '$1">@$1</a> ', $content);
}
示例3: custom_category_link
public function custom_category_link($url, $term, $taxonomy)
{
if (ap_opt('enable_categories')) {
/* change category link if permalink not enabled */
if ('question_category' == $term->taxonomy && !get_option('permalink_structure')) {
return add_query_arg(array('question_category' => false, 'page_id' => ap_opt('base_page'), 'qcat_id' => $term->term_id), $url);
} elseif ('question_category' == $term->taxonomy && get_option('permalink_structure')) {
return ap_get_link_to('category/' . $term->slug);
}
}
return $url;
}
示例4: ap_user_link
function ap_user_link($user_id = false, $sub = false)
{
if (!$user_id) {
$user_id = get_the_author_meta('ID');
}
if ($user_id == 0) {
return false;
}
$user = get_userdata($user_id);
$base = rtrim(ap_get_link_to(array('ap_page' => 'user', 'user' => $user->user_login)), '/');
$args = '';
if (get_option('permalink_structure') != '') {
if (!is_array($sub)) {
$args = $sub ? '/' . $sub : '';
} elseif (is_array($sub)) {
if (!empty($sub)) {
foreach ($sub as $s) {
$args .= $s . '/';
}
}
}
} else {
if (!is_array($sub)) {
$args = $sub ? '&user_page=' . $sub : '';
} elseif (is_array($sub)) {
if (!empty($sub)) {
foreach ($sub as $k => $s) {
$args .= '&' . $k . '=' . $s;
}
}
}
}
return $base . $args;
}
示例5: while
* This file is responsible for displaying question page
* This file can be overridden by creating a anspress directory in active theme folder.
*
* @package AnsPress
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @author Rahul Aryan <rah12@live.com>
*/
while ($question->have_posts()) {
$question->the_post();
if (ap_user_can_view_question()) {
?>
<div id="ap-single" class="clearfix" itemtype="http://schema.org/Question" itemscope="">
<header class="ap-qhead clearfix">
<div class="ap-qtitle-meta">
<a class="ap-btn ap-ask-btn-head pull-right" href="<?php
echo ap_get_link_to('ask');
?>
"><?php
_e('Ask Question');
?>
</a>
<?php
if (!ap_opt("double_titles")) {
?>
<h1 class="entry-title" itemprop="name">
<?php
the_title();
?>
</h1>
<?php
} else {
示例6: ap_link_to
/**
* Echo anspress links.
*
* @since 2.1
*/
function ap_link_to($sub)
{
echo ap_get_link_to($sub);
}
示例7: ap_base_page_sc
//.........这里部分代码省略.........
$question = new WP_Query($question_args);
$category = $question->get_queried_object();
} elseif (is_question_tags()) {
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$per_page = ap_opt('tags_per_page');
$total_terms = wp_count_terms('question_tags');
$offset = $per_page * ($paged - 1);
$args = array('number' => $per_page, 'offset' => $offset, 'hide_empty' => false, 'orderby' => 'count', 'order' => 'DESC');
$tags = get_terms('question_tags', $args);
} elseif (is_question_categories()) {
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$per_page = ap_opt('categories_per_page');
$total_terms = wp_count_terms('question_category');
$offset = $per_page * ($paged - 1);
$cat_args = array('parent' => 0, 'number' => $per_page, 'offset' => $offset, 'hide_empty' => false, 'orderby' => 'count', 'order' => 'DESC');
$categories = get_terms('question_category', $cat_args);
} elseif (is_ap_users()) {
global $current_user_meta;
$count_args = array('fields' => 'all_with_meta', 'number' => 999999);
$user_count_query = new WP_User_Query($count_args);
$user_count = $user_count_query->get_results();
// count the number of users found in the query
$total_users = $user_count ? count($user_count) : 1;
// how many users to show per page
$per_page = ap_opt('users_per_page');
// grab the current page number and set to 1 if no page number is set
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
// calculate the total number of pages.
$total_pages = 1;
$offset = $per_page * ($paged - 1);
$total_pages = ceil($total_users / $per_page);
$order = get_query_var('sort');
if (empty($order)) {
$order = 'points';
}
$args = array('number' => $per_page, 'offset' => $offset);
if ($order == 'points') {
$args['ap_query'] = 'sort_points';
$args['meta_key'] = 'ap_points';
$args['orderby'] = 'meta_value';
$args['order'] = 'DESC';
} elseif ($order == 'newest') {
$args['orderby'] = 'date';
$args['order'] = 'DESC';
}
// The Query
$users = new WP_User_Query($args);
} elseif (is_ap_user()) {
global $current_user_meta;
global $user;
$user = get_userdata(ap_get_user_page_user());
if ($user === FALSE) {
echo '<div class="user-not-found">' . __('User not found', 'ap') . '</div>';
return;
}
$userid = $user->data->ID;
$display_name = $user->data->display_name;
$username = $user->data->user_login;
$current_user_meta = array_map('ap_meta_array_map', get_user_meta($userid));
} elseif (is_ap_search()) {
$question_args['s'] = sanitize_text_field(get_query_var('ap_s'));
$question = new WP_Query($question_args);
} else {
$question = new WP_Query($question_args);
}
echo '<div class="ap-container">';
do_action('ap_page_top');
echo '<div class="ap-dtable">';
echo '<div class="ap-cl">';
include ap_get_theme_location(ap_get_current_page_template());
if (is_ap_users()) {
$base = ap_get_link_to('users') . '/%_%';
ap_pagi($base, ceil($total_users / $per_page), $paged);
}
if (is_question_tags()) {
ap_pagi(ap_get_link_to('tags') . '/%_%', ceil($total_terms / $per_page), $paged);
}
if (is_question_categories()) {
ap_pagi(ap_get_link_to('categories') . '/%_%', ceil($total_terms / $per_page), $paged);
}
echo '</div>';
if (!is_question() && is_active_sidebar('ap-sidebar')) {
echo '<div class="ap-sidebar">';
dynamic_sidebar('ap-sidebar');
echo '</div>';
}
echo '</div>';
if (!ap_opt('author_credits')) {
?>
<div class="ap-footer">
<p class="ap-author-credit">AnsPress Version <?php
echo AP_VERSION;
?>
</p>
</div>
<?php
}
wp_reset_postdata();
echo '</div>';
}
示例8: ap_user_link
function ap_user_link($userid = false, $sub = false)
{
if (!$userid) {
$userid = get_the_author_meta('ID');
}
$user = get_userdata($userid);
$user_link = rtrim(ap_get_link_to('user/' . $user->user_login), '/');
if ($user) {
return $user_link . ($sub ? '/' . $sub : '');
}
return false;
}
示例9: ap_breadcrumbs
public function ap_breadcrumbs($navs)
{
if (is_question_category()) {
$category_id = sanitize_text_field(get_query_var('q_cat'));
$category = get_term_by(is_numeric($category_id) ? 'id' : 'slug', $category_id, 'question_category');
$navs['page'] = array('title' => __('Categories', 'ap'), 'link' => ap_get_link_to('categories'), 'order' => 8);
$navs['category'] = array('title' => $category->name, 'link' => get_term_link($category, 'question_category'), 'order' => 8);
} elseif (is_question_categories()) {
$navs['page'] = array('title' => __('Categories', 'ap'), 'link' => ap_get_link_to('categories'), 'order' => 8);
}
return $navs;
}
示例10: ap_breadcrumbs
public function ap_breadcrumbs($navs)
{
if (is_question_tag()) {
$tag_id = sanitize_title(get_query_var('q_tag'));
$tag = get_term_by(is_numeric($tag_id) ? 'id' : 'slug', $tag_id, 'question_tag');
$navs['page'] = array();
$navs['tag'] = array('title' => $tag->name, 'link' => get_term_link($tag, 'question_tag'), 'order' => 8);
} elseif (is_question_tags()) {
$navs['page'] = array('title' => __('Categories', 'tags-for-anspress'), 'link' => ap_get_link_to('categories'), 'order' => 8);
}
return $navs;
}
示例11: update_menu_url
function update_menu_url($items)
{
// Iterate over the items
foreach ($items as $key => $item) {
if ('http://ANSPRESS_BASE_PAGE_URL' == $item->url) {
$item->url = get_permalink(ap_opt('base_page'));
}
if ('http://ANSPRESS_ASK_PAGE_URL' == $item->url) {
$item->url = ap_get_link_to('ask');
}
if ('http://ANSPRESS_CATEGORIES_PAGE_URL' == $item->url) {
$item->url = ap_get_link_to('categories');
}
if ('http://ANSPRESS_TAGS_PAGE_URL' == $item->url) {
$item->url = ap_get_link_to('tags');
}
if ('http://ANSPRESS_USERS_PAGE_URL' == $item->url) {
$item->url = ap_get_link_to('users');
}
}
return $items;
}
示例12: the_pagination
public function the_pagination($base = false)
{
if (false === $base) {
$base = ap_get_link_to('activity') . '/%_%';
}
ap_pagination($this->paged, $this->total_pages, $base);
}
示例13: ap_get_link_to
*
* [Long Description.]
*
* @link http://wp3.in
* @since 1.0
*
* @package AnsPress
* @subpackage Tags for AnsPress
*/
global $question_tags;
?>
<div id="ap-tags" class="clearfix">
<div class="ap-list-head clearfix">
<form id="ap-search-form" class="ap-search-form pull-left" action="<?php
echo ap_get_link_to('tags');
?>
?type=tags">
<input name="ap_s" type="text" class="ap-form-control" placeholder="<?php
_e('Search tags...', 'ap');
?>
" value="<?php
echo sanitize_text_field(get_query_var('ap_s'));
?>
" />
<input name="type" type="hidden" value="tags" />
</form>
<?php
ap_tags_tab();
?>
</div>
示例14: ap_tags_tab
function ap_tags_tab()
{
$active = isset($_GET['ap_sort']) ? $_GET['ap_sort'] : 'popular';
$link = ap_get_link_to('tags') . '?ap_sort=';
?>
<ul class="ap-questions-tab ap-ul-inline clearfix" role="tablist">
<li class="<?php
echo $active == 'popular' ? ' active' : '';
?>
"><a href="<?php
echo $link . 'popular';
?>
"><?php
_e('Popular', 'tags-for-anspress');
?>
</a></li>
<li class="<?php
echo $active == 'new' ? ' active' : '';
?>
"><a href="<?php
echo $link . 'new';
?>
"><?php
_e('New', 'tags-for-anspress');
?>
</a></li>
<li class="<?php
echo $active == 'name' ? ' active' : '';
?>
"><a href="<?php
echo $link . 'name';
?>
"><?php
_e('Name', 'tags-for-anspress');
?>
</a></li>
<?php
/**
* ACTION: ap_tags_tab
* Used to hook into tags page tab
*/
do_action('ap_tags_tab', $active);
?>
</ul>
<?php
}
示例15: ap_get_link_to
<?php
/**
* Display question list header
*
* Shows sorting, search, tags, category filter form. Also shows a ask button.
*
* @package AnsPress
* @author Rahul Aryan <support@anspress.io>
*/
?>
<div class="ap-list-head clearfix">
<form id="ap-search-form" class="ap-search-form" action="<?php
echo ap_get_link_to('search');
?>
">
<input name="ap_s" type="text" class="ap-form-control" placeholder="<?php
_e('Search questions...', 'anspress-question-answer');
?>
" value="<?php
echo sanitize_text_field(get_query_var('ap_s'));
?>
" />
</form>
<?php
// Hide ask button if user page
if (!is_ap_user()) {
ap_ask_btn();
}
?>
<form id="ap-question-sorting" class="ap-questions-sorting clearfix">