예제 #1
0
    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
0
/**
 * 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
0
 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
0
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
0
 * 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 <*****@*****.**>
 */
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
0
파일: functions.php 프로젝트: Krl4/anspress
/**
 * Echo anspress links.
 *
 * @since 2.1
 */
function ap_link_to($sub)
{
    echo ap_get_link_to($sub);
}
예제 #7
0
    public function ap_base_page_sc($atts, $content = "")
    {
        if (!is_question()) {
            $order = get_query_var('sort');
            $label = sanitize_text_field(get_query_var('label'));
            if (empty($order)) {
                $order = 'active';
            }
            //ap_opt('answers_sort');
            if (empty($label)) {
                $label = '';
            }
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $question_args = array('ap_query' => 'main_questions', 'post_type' => 'question', 'post_status' => 'publish', 'showposts' => ap_opt('question_per_page'), 'paged' => $paged);
            if ($order == 'active') {
                $question_args['ap_query'] = 'main_questions_active';
                $question_args['orderby'] = 'meta_value';
                $question_args['meta_key'] = ANSPRESS_UPDATED_META;
                $question_args['meta_query'] = array('relation' => 'OR', array('key' => ANSPRESS_UPDATED_META, 'compare' => 'NOT EXISTS'));
            } elseif ($order == 'voted') {
                $question_args['orderby'] = 'meta_value_num';
                $question_args['meta_key'] = ANSPRESS_VOTE_META;
            } elseif ($order == 'answers') {
                $question_args['orderby'] = 'meta_value_num';
                $question_args['meta_key'] = ANSPRESS_ANS_META;
            } elseif ($order == 'unanswered') {
                $question_args['orderby'] = 'meta_value';
                $question_args['meta_key'] = ANSPRESS_ANS_META;
                $question_args['meta_value'] = '0';
            } elseif ($order == 'oldest') {
                $question_args['orderby'] = 'date';
                $question_args['order'] = 'ASC';
            }
            if ($label != '') {
                $question_args['tax_query'] = array(array('taxonomy' => 'question_label', 'field' => 'slug', 'terms' => $label));
            }
            $question_args = apply_filters('ap_main_query_args', $question_args);
        }
        if (is_question()) {
            $args = array('p' => get_question_id(), 'post_type' => 'question', 'post_status' => array('moderate', 'publish'));
            $question = new WP_Query($args);
        } elseif (is_question_tag()) {
            $question_args['tax_query'] = array(array('taxonomy' => 'question_tags', 'field' => 'id', 'terms' => array(get_question_tag_id())));
            $question = new WP_Query($question_args);
            $tag = $question->get_queried_object();
        } elseif (is_question_cat()) {
            $question_args['tax_query'] = array(array('taxonomy' => 'question_category', 'field' => 'id', 'terms' => array(get_question_cat_id())));
            $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
0
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;
}
 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;
 }
 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
0
 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
0
 public function the_pagination($base = false)
 {
     if (false === $base) {
         $base = ap_get_link_to('activity') . '/%_%';
     }
     ap_pagination($this->paged, $this->total_pages, $base);
 }
예제 #13
0
파일: tags.php 프로젝트: venturepact/blog
 *
 * [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
0
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
0
<?php

/**
 * Display question list header
 *
 * Shows sorting, search, tags, category filter form. Also shows a ask button.
 *
 * @package AnsPress
 * @author  Rahul Aryan <*****@*****.**>
 */
?>
<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">
예제 #16
0
 /**
  * Add current-menu-item class in AnsPress pages
  * @param  array  $class Menu class.
  * @param  object $item Current menu item.
  * @return array menu item.
  * @since  2.1
  */
 public function fix_nav_current_class($class, $item)
 {
     $pages = anspress()->pages;
     if (!empty($item) && is_object($item)) {
         foreach ($pages as $slug => $args) {
             if (in_array('anspress-page-link', $class)) {
                 if (ap_get_link_to(get_query_var('ap_page')) != $item->url) {
                     $pos = array_search('current-menu-item', $class);
                     unset($class[$pos]);
                 }
                 if (!in_array('ap-dropdown', $class) && (in_array('anspress-page-notification', $class) || in_array('anspress-page-profile', $class))) {
                     $class[] = 'ap-dropdown';
                 }
             }
         }
     }
     return $class;
 }
예제 #17
0
/**
 * Display users page tab
 * @return void
 */
function ap_users_tab()
{
    $active = isset($_GET['ap_sort']) ? $_GET['ap_sort'] : 'reputation';
    $link = ap_get_link_to('users') . '?ap_sort=';
    ?>

    <ul class="ap-questions-tab ap-ul-inline clearfix" role="tablist">
        <?php 
    if (!ap_opt('disable_reputation')) {
        ?>

            <li class="<?php 
        echo $active == 'reputation' ? ' active' : '';
        ?>
"><a href="<?php 
        echo $link . 'reputation';
        ?>
"><?php 
        _e('Reputation', 'ap');
        ?>
</a></li>
        <?php 
    }
    ?>

        <li class="<?php 
    echo $active == 'active' ? ' active' : '';
    ?>
"><a href="<?php 
    echo $link . 'active';
    ?>
"><?php 
    _e('Active', 'ap');
    ?>
</a></li>
        <li class="<?php 
    echo $active == 'best_answer' ? ' active' : '';
    ?>
"><a href="<?php 
    echo $link . 'best_answer';
    ?>
"><?php 
    _e('Best answer', 'ap');
    ?>
</a></li>
        <li class="<?php 
    echo $active == 'answer' ? ' active' : '';
    ?>
"><a href="<?php 
    echo $link . 'answer';
    ?>
"><?php 
    _e('Answer', 'ap');
    ?>
</a></li>
        <li class="<?php 
    echo $active == 'newest' ? ' active' : '';
    ?>
"><a href="<?php 
    echo $link . 'newest';
    ?>
"><?php 
    _e('Newest', 'ap');
    ?>
</a></li>
        <?php 
    /**
     * ACTION: ap_users_tab
     * Used to hook into users page tab
     * @since 2.1.0
     */
    do_action('ap_users_tab', $active);
    ?>

    </ul>
    <?php 
}
예제 #18
0
파일: theme.php 프로젝트: haythameyd/powrly
function ap_get_breadcrumbs()
{
    $current_page = get_query_var('ap_page');
    $title = ap_page_title();
    $a = array();
    $a['base'] = array('title' => ap_opt('base_page_title'), 'link' => ap_base_page_link(), 'order' => 0);
    if (is_question_tag()) {
        $a['tag'] = array('title' => __('Tags', 'ap'), 'link' => '', 'order' => 10);
    } elseif (is_question()) {
        $a['page'] = array('title' => substr($title, 0, 30) . (strlen($title) > 30 ? __('..', 'ap') : ''), 'link' => get_permalink(get_question_id()), 'order' => 10);
    } elseif ($current_page != 'base' && $current_page != '') {
        if ($current_page == 'user') {
            $a['page'] = array('title' => __('User', 'ap'), 'link' => ap_user_link(ap_get_displayed_user_id()), 'order' => 10);
            $a['user_page'] = array('title' => substr($title, 0, 30) . (strlen($title) > 30 ? __('..', 'ap') : ''), 'link' => ap_user_link(ap_get_displayed_user_id(), get_query_var('user_page')), 'order' => 10);
        } else {
            $a['page'] = array('title' => substr($title, 0, 30) . (strlen($title) > 30 ? __('..', 'ap') : ''), 'link' => ap_get_link_to($current_page), 'order' => 10);
        }
    }
    $a = apply_filters('ap_breadcrumbs', $a);
    return ap_sort_array_by_order($a);
}
예제 #19
0
 public function custom_question_link($url, $post)
 {
     if ('question' == get_post_type($post)) {
         if (get_option('permalink_structure')) {
             $question_slug = ap_opt('question_prefix');
             $question_slug = strlen($question_slug) > 0 ? $question_slug . '/' : '';
             return ap_get_link_to($question_slug . $post->ID . '/' . $post->post_name);
         } else {
             return add_query_arg(array('apq' => false, 'page_id' => ap_opt('base_page'), 'question_id' => $post->ID), $url);
         }
     }
     return $url;
 }
예제 #20
0
 public function the_pagination()
 {
     $base = ap_get_link_to('users') . '/%_%';
     ap_pagination($this->paged, $this->total_pages, $base);
 }
예제 #21
0
function ap_ask_btn($parent_id = false)
{
    $args = array('ap_page' => 'ask');
    if ($parent_id !== false) {
        $args['parent'] = $parent_id;
    }
    if (get_query_var('parent') != '') {
        $args['parent'] = get_query_var('parent');
    }
    echo '<a class="ap-btn ap-ask-btn-head pull-right" href="' . ap_get_link_to($args) . '">' . __('Ask Question') . '</a>';
}