Example #1
0
 /**
  * Show similar questions when asking a question.
  *
  * @since 2.0.1
  */
 public function suggest_similar_questions()
 {
     if (empty($_POST['value']) || !ap_verify_default_nonce() && !current_user_can('manage_options')) {
         wp_die('false');
     }
     $keyword = sanitize_text_field(wp_unslash($_POST['value']));
     $is_admin = (bool) $_POST['is_admin'];
     $questions = get_posts(array('post_type' => 'question', 'showposts' => 10, 's' => $keyword));
     if ($questions) {
         $items = '<div class="ap-similar-questions-head">';
         $items .= '<h3>' . ap_icon('check', true) . sprintf(__('%d similar questions found', 'anspress-question-answer'), count($questions)) . '</h3>';
         $items .= '<p>' . __('We\'ve found similar questions that have already been asked, click to read them.', 'anspress-question-answer') . '</p>';
         $items .= '</div>';
         $items .= '<div class="ap-similar-questions">';
         foreach ($questions as $p) {
             $count = ap_count_answer_meta($p->ID);
             $p->post_title = ap_highlight_words($p->post_title, $keyword);
             if ($is_admin) {
                 $items .= '<div class="ap-q-suggestion-item clearfix"><a class="select-question-button button button-primary button-small" href="' . add_query_arg(array('post_type' => 'answer', 'post_parent' => $p->ID), admin_url('post-new.php')) . '">' . __('Select', 'anspress-question-answer') . '</a><span class="question-title">' . $p->post_title . '</span><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'anspress-question-answer'), $count) . '</span></div>';
             } else {
                 $items .= '<a class="ap-sqitem clearfix" target="_blank" href="' . get_permalink($p->ID) . '"><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'anspress-question-answer'), $count) . '</span><span class="ap-title">' . $p->post_title . '</span></a>';
             }
         }
         $items .= '</div>';
         $result = array('status' => true, 'html' => $items);
     } else {
         $result = array('status' => false, 'message' => __('No related questions found', 'anspress-question-answer'));
     }
     $this->send($result);
 }
Example #2
0
 /**
  * Show similar questions when asking a question
  * @return void
  * @since 2.0.1
  */
 public function suggest_similar_questions()
 {
     if (empty($_POST['value'])) {
         return;
     }
     $keyword = sanitize_text_field($_POST['value']);
     $questions = get_posts(array('post_type' => 'question', 'showposts' => 10, 's' => $keyword));
     if ($questions) {
         $items = '<div class="ap-similar-questions-head">';
         $items .= '<h3>' . ap_icon('check', true) . sprintf(__('%d similar questions found', 'ap'), count($questions)) . '</h3>';
         $items .= '<p>' . __('We found similar questions that have already been asked, click to read them. Avoid creating duplicate questions, it will be deleted.') . '</p>';
         $items .= '</div>';
         $items .= '<div class="ap-similar-questions">';
         foreach ($questions as $p) {
             $count = ap_count_answer_meta($p->ID);
             $p->post_title = ap_highlight_words($p->post_title, $keyword);
             if (!isset($_POST['is_admin'])) {
                 $items .= '<a class="ap-sqitem clearfix" href="' . get_permalink($p->ID) . '"><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'ap'), $count) . '</span><span class="ap-title">' . $p->post_title . '</span></a>';
             } else {
                 $items .= '<div class="ap-q-suggestion-item clearfix"><a class="select-question-button button button-primary button-small" href="' . add_query_arg(array('post_type' => 'answer', 'post_parent' => $p->ID), admin_url('post-new.php')) . '">' . __('Select', 'ap') . '</a><span class="question-title">' . $p->post_title . '</span><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'ap'), $count) . '</span></div>';
             }
         }
         $items .= '</div>';
         $result = array('status' => true, 'html' => $items);
     } else {
         $result = array('status' => false, 'message' => __('No related questions found', 'ap'));
     }
     ap_send_json($result);
 }
Example #3
0
function ap_scripts_front()
{
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-form', array('jquery'), false);
    wp_enqueue_script('ap-functions-js', ANSPRESS_URL . 'assets/prod/ap-functions.min.js', array('jquery', 'jquery-form'));
    wp_enqueue_script('ap-anspress_script', ANSPRESS_URL . 'assets/prod/anspress_site.min.js', array('jquery', 'jquery-form'), AP_VERSION);
    wp_enqueue_script('peity-js', ap_get_theme_url('js/jquery.peity.min.js'), 'jquery', AP_VERSION);
    wp_enqueue_script('ap-initial.js', ap_get_theme_url('js/initial.min.js'), 'jquery', AP_VERSION);
    wp_enqueue_script('ap-scrollbar.js', ap_get_theme_url('js/jquery.scrollbar.min.js'), 'jquery', AP_VERSION);
    wp_enqueue_script('ap-js', ap_get_theme_url('prod/ap.min.js'), array('jquery', 'jquery-form'), AP_VERSION);
    wp_enqueue_style('ap-style', ap_get_theme_url('css/main.css'), array(), AP_VERSION);
    $custom_css = '
        #anspress .ap-q-cells{
                margin-left: ' . (ap_opt('avatar_size_qquestion') + 10) . 'px;
        }
        #anspress .ap-a-cells{
                margin-left: ' . (ap_opt('avatar_size_qanswer') + 10) . 'px;
        }#anspress .ap-comment-content{
                margin-left: ' . (ap_opt('avatar_size_qcomment') + 15) . 'px;
        }';
    wp_add_inline_style('ap-style', $custom_css);
    wp_enqueue_style('ap-fonts', ap_get_theme_url('fonts/style.css'), array(), AP_VERSION);
    do_action('ap_enqueue');
    wp_enqueue_style('ap-responsive', ap_get_theme_url('css/responsive.css'), array(), AP_VERSION);
    wp_enqueue_style('ap-overrides', ap_get_theme_url('css/overrides.css'), array(), AP_VERSION);
    echo '<script type="text/javascript">';
    echo 'var ajaxurl = "' . admin_url('admin-ajax.php') . '",';
    echo 'ap_nonce 	= "' . wp_create_nonce('ap_ajax_nonce') . '",';
    echo 'ap_max_tags = "' . ap_opt('max_tags') . '",';
    echo 'disable_hover_card = "' . (ap_opt('disable_hover_card') ? true : false) . '"';
    echo '</script>';
    wp_localize_script('ap-anspress_script', 'aplang', array('password_field_not_macthing' => __('Password not matching', 'ap'), 'password_length_less' => __('Password length must be 6 or higher', 'ap'), 'not_valid_email' => __('Not a valid email', 'ap'), 'username_less' => __('Username length must be 4 or higher', 'ap'), 'username_not_avilable' => __('Username not available', 'ap'), 'email_already_in_use' => sprintf(__('Email already in use. %sDo you want to reset your password?%s', 'ap'), '<a href="' . wp_lostpassword_url() . '">', '</a>'), 'loading' => __('Loading', 'ap'), 'sending' => __('Sending request', 'ap'), 'adding_to_fav' => __('Adding question to your favorites', 'ap'), 'voting_on_post' => __('Sending your vote', 'ap'), 'requesting_for_closing' => __('Requesting for closing this question', 'ap'), 'sending_request' => __('Submitting request', 'ap'), 'loading_comment_form' => __('Loading comment form', 'ap'), 'submitting_your_question' => __('Sending your question', 'ap'), 'submitting_your_answer' => __('Sending your answer', 'ap'), 'submitting_your_comment' => __('Sending your comment', 'ap'), 'deleting_comment' => __('Deleting comment', 'ap'), 'updating_comment' => __('Updating comment', 'ap'), 'loading_form' => __('Loading form', 'ap'), 'saving_labels' => __('Saving labels', 'ap'), 'loading_suggestions' => __('Loading suggestions', 'ap'), 'uploading_cover' => __('Uploading cover', 'ap'), 'saving_profile' => __('Saving profile', 'ap'), 'sending_message' => __('Sending message', 'ap'), 'loading_conversation' => __('Loading conversation', 'ap'), 'loading_new_message_form' => __('Loading new message form', 'ap'), 'loading_more_conversations' => __('Loading more conversations', 'ap'), 'searching_conversations' => __('Searching conversations', 'ap'), 'loading_message_edit_form' => __('Loading message form', 'ap'), 'updating_message' => __('Updating message', 'ap'), 'deleting_message' => __('Deleting message', 'ap'), 'uploading' => __('Uploading', 'ap'), 'error' => ap_icon('error'), 'warning' => ap_icon('warning'), 'success' => ap_icon('success'), 'not_valid_response' => __('Something went wrong in server side, not a valid response.', 'ap')));
    wp_localize_script('ap-site-js', 'apoptions', array('ajaxlogin' => ap_opt('ajax_login')));
}
Example #4
0
		</div>
		<a class="ap-user-name" href="<?php 
ap_user_the_link();
?>
"><?php 
ap_user_the_display_name();
?>
</a>
		<?php 
if (!ap_opt('disable_reputation')) {
    echo '<span class="ap-user-reputation">';
    printf(__('%s Rep.', 'ap'), ap_user_get_the_reputation());
    echo '</span>';
}
?>

	</div>
	<?php 
$menus = ap_get_user_menu(get_current_user_id());
$active_user_page = get_query_var('user_page');
$active_user_page = $active_user_page ? $active_user_page : 'about';
$item_output = '<a id="ap-user-menu-anchor" href="#">' . get_avatar(get_current_user_id(), 20) . ap_user_display_name(get_current_user_id()) . ap_icon('chevron-down', true) . '</a>';
echo '<ul class="ap-user-widget-links">';
foreach ($menus as $m) {
    $class = !empty($m['class']) ? ' ' . $m['class'] : '';
    echo '<li' . ($active_user_page == $m['slug'] ? ' class="active"' : '') . '><a href="' . $m['link'] . '" class="ap-user-link-' . $m['slug'] . $class . '">' . $m['title'] . '</a></li>';
}
echo '</ul>';
?>

</div>
Example #5
0
 /**
  * Add user dropdown and notification menu
  * @param  string  $o        		   Menu html.
  * @param  object  $item               Menu item object.
  * @param  integer $depth              Menu depth.
  * @param  object  $args 			   Menu args.
  * @return string
  */
 public function walker_nav_menu_start_el($o, $item, $depth, $args)
 {
     if (!is_user_logged_in() && (ap_is_notification_menu($item) || ap_is_profile_menu($item))) {
         $o = '';
     }
     if (!ap_is_profile_active() && (ap_is_notification_menu($item) || ap_is_profile_menu($item))) {
         return '';
     }
     if (in_array('anspress-page-profile', $item->classes) && is_user_logged_in()) {
         $menus = ap_get_user_menu(get_current_user_id());
         $active_user_page = get_query_var('user_page') ? esc_attr(get_query_var('user_page')) : 'about';
         $o = '<a id="ap-user-menu-anchor" class="ap-dropdown-toggle" href="#">';
         $o .= get_avatar(get_current_user_id(), 80);
         $o .= '<span class="name">' . ap_user_display_name(get_current_user_id()) . '</span>';
         $o .= ap_icon('chevron-down', true);
         $o .= '</a>';
         $o .= '<ul id="ap-user-menu-link" class="ap-dropdown-menu ap-user-dropdown-menu">';
         foreach ($menus as $m) {
             $class = !empty($m['class']) ? ' ' . $m['class'] : '';
             $o .= '<li' . ($active_user_page == $m['slug'] ? ' class="active"' : '') . '>';
             $o .= '<a href="' . $m['link'] . '" class="ap-user-link-' . $m['slug'] . $class . '">';
             $o .= $m['title'] . '</a>';
             $o .= '</li>';
         }
         $o .= '</ul>';
     } elseif (in_array('anspress-page-notification', $item->classes) && is_user_logged_in()) {
         $o = '<a id="ap-user-notification-anchor" class="ap-dropdown-toggle ap-sidetoggle ' . ap_icon('globe') . '" href="#">' . ap_get_the_total_unread_notification(false, false) . '</a>';
         global $ap_activities;
         /**
          * Dropdown notification arguments.
          * Allow filtering of dropdown notification arguments.
          * @since 2.4.5
          * @var array
          */
         $notification_args = apply_filters('ap_dropdown_notification_args', array('per_page' => 20, 'notification' => true, 'user_id' => ap_get_displayed_user_id()));
         $ap_activities = ap_get_activities($notification_args);
         ob_start();
         ap_get_template_part('user/notification-dropdown');
         $o .= ob_get_clean();
     }
     return $o;
 }
function ap_get_notification_icon($type)
{
    $icons = array('new_question' => ap_icon('question', true), 'new_answer' => ap_icon('answer', true), 'question_update' => ap_icon('pencil', true), 'answer_update' => ap_icon('pencil', true), 'comment_on_question' => ap_icon('comment', true), 'comment_on_answer' => ap_icon('comment', true), 'new_follower' => ap_icon('user-check', true), 'vote_up' => ap_icon('thumb-up', true), 'answer_selected' => ap_icon('check', true), 'received_reputation' => ap_icon('reputation', true));
    $icons = apply_filters('ap_get_notification_icon', $icons);
    if (isset($icons[$type])) {
        return $icons[$type];
    }
}
 /**
  * Append meta display
  * @param  array $metas
  * @param array $question_id
  * @return array
  * @since 1.0
  */
 public function ap_display_question_metas($metas, $question_id)
 {
     if (ap_question_have_category($question_id) && !is_singular('question')) {
         $metas['categories'] = ap_question_categories_html(array('label' => ap_icon('category', true)));
     }
     return $metas;
 }
Example #8
0
 /**
  * Append meta display
  * @param  array $metas
  * @param array $question_id
  * @return array
  * @since 2.0
  */
 public function ap_display_question_metas($metas, $question_id)
 {
     if (ap_question_have_tags($question_id) && !is_singular('question')) {
         $metas['tags'] = ap_question_tags_html(array('label' => ap_icon('tag', true), 'show' => 1));
     }
     return $metas;
 }
Example #9
0
function ap_avatar_upload_form()
{
    if (ap_get_user_page_user() == get_current_user_id()) {
        ?>
		<form method="post" action="#" enctype="multipart/form-data" data-action="ap-upload-form" class="">
			<div class="ap-btn ap-upload-o <?php 
        echo ap_icon('upload');
        ?>
">
				<span><?php 
        _e('Upload avatar', 'ap');
        ?>
</span>
				<input type="file" name="thumbnail" class="ap-upload-input" data-action="ap-upload-field">
			</div>
			<input type='hidden' value='<?php 
        echo wp_create_nonce('upload');
        ?>
' name='nonce' />
			<input type="hidden" name="action" id="action" value="ap_avatar_upload">
		</form>
		<?php 
    }
}
Example #10
0
 * AnsPress image upload modal
 * Handle image uploading and importing from url
 *
 * @link http://anspress.io
 * @since 2.4
 * @author Rahul Aryan <*****@*****.**>
 * @package AnsPress
 */
?>

<div class="ap-mediam">
	<div class="ap-mediam-types">
		<div class="ap-mediam-pc ap-mediam-type clerafix">
			<?php 
echo ap_icon('cloud-upload', true);
?>
			<?php 
_e('Upload from computer', 'ap');
?>
		</div>
		<div class="ap-mediam-pc ap-mediam-type clerafix">
			<?php 
echo ap_icon('globe', true);
?>
			<?php 
_e('Image from link', 'ap');
?>
		</div>
	</div>
</div>
Example #11
0
printf(__('%d answers, %d selected', 'ap'), ap_user_get_the_meta('__total_answers'), ap_user_get_the_meta('__best_answers'));
?>
</li>
				<li><?php 
echo ap_icon('question', true);
printf(__('%d questions, %d solved', 'ap'), ap_user_get_the_meta('__total_questions'), ap_user_get_the_meta('__solved_answers'));
?>
</li>
				<li><?php 
echo ap_icon('clock', true);
printf(__('Member for %s', 'ap'), ap_user_get_member_for());
?>
</li>
				<li><?php 
echo ap_icon('eye', true);
printf(__('%d profile views', 'ap'), ap_user_get_the_meta('__profile_views'));
?>
</li>
				<li><?php 
echo ap_icon('clock', true);
printf(__('Last seen %s ago', 'ap'), ap_human_time(ap_user_get_the_meta('__last_active'), false));
?>
</li>
			</ul>
			<?php 
dynamic_sidebar('ap-user-about');
?>

		</div>
	</div>
</div>
Example #12
0
/**
 * Output voting button
 * @param  int $post 
 * @return null|string
 * @since 0.1
 */
function ap_vote_btn($post = false, $echo = true)
{
    if (false === $post) {
        global $post;
    }
    if ('answer' == $post->post_type && ap_opt('disable_voting_on_answer')) {
        return;
    }
    if ('question' == $post->post_type && ap_opt('disable_voting_on_question')) {
        return;
    }
    $nonce = wp_create_nonce('vote_' . $post->ID);
    $vote = ap_is_user_voted($post->ID, 'vote');
    $voted = $vote ? true : false;
    $type = $vote ? $vote->type : '';
    ob_start();
    ?>
		<div data-id="<?php 
    echo $post->ID;
    ?>
" class="ap-vote net-vote" data-action="vote">
			<a class="<?php 
    echo ap_icon('vote_up');
    ?>
 ap-tip vote-up<?php 
    echo $voted ? ' voted' : '';
    echo $type == 'vote_down' ? ' disable' : '';
    ?>
" data-query="ap_ajax_action=vote&type=up&post_id=<?php 
    echo $post->ID;
    ?>
&__nonce=<?php 
    echo $nonce;
    ?>
" href="#" title="<?php 
    _e('Up vote this post', 'ap');
    ?>
"></a>
			
			<span class="net-vote-count" data-view="ap-net-vote" itemprop="upvoteCount"><?php 
    echo ap_net_vote();
    ?>
</span>
			
			<a data-tipposition="bottom" class="<?php 
    echo ap_icon('vote_down');
    ?>
 ap-tip vote-down<?php 
    echo $voted ? ' voted' : '';
    echo $type == 'vote_up' ? ' disable' : '';
    ?>
" data-query="ap_ajax_action=vote&type=down&post_id=<?php 
    echo $post->ID;
    ?>
&__nonce=<?php 
    echo $nonce;
    ?>
" href="#" title="<?php 
    _e('Down vote this post', 'ap');
    ?>
"></a>
		</div>
	<?php 
    $html = ob_get_clean();
    if ($echo) {
        echo $html;
    } else {
        return $html;
    }
}
Example #13
0
/**
 * Output subscribe btn HTML
 * @param 	boolean|integer $action_id  Question ID or Term ID.
 * @param 	string|false    $type       Subscribe type.
 * @since 	2.0.1
 */
function ap_subscribe_btn_html($action_id = false, $type = false)
{
    global $question_category, $question_tag;
    $filter = apply_filters('ap_subscribe_btn_action_type', array('action_id' => $action_id, 'type' => $type));
    $action_id = $filter['action_id'];
    $type = $filter['type'];
    if (false === $action_id) {
        $action_id = get_question_id();
    }
    $subscribe_type = 'q_all';
    if ($type == false) {
        $subscribe_type = apply_filters('ap_subscribe_btn_type', 'q_all');
    } elseif ($type === 'category' || $type === 'tag') {
        $subscribe_type = 'tax_new_q';
    }
    $subscribed = ap_is_user_subscribed($action_id, $subscribe_type);
    $nonce = wp_create_nonce('subscribe_' . $action_id . '_' . $subscribe_type);
    $title = !$subscribed ? __('Follow', 'ap') : __('Unfollow', 'ap');
    ?>
	<div class="ap-subscribe-btn" id="<?php 
    echo 'subscribe_' . $action_id;
    ?>
">
		<a href="#" class="ap-btn<?php 
    echo $subscribed ? ' active' : '';
    ?>
" data-query="<?php 
    echo 'subscribe::' . $nonce . '::' . $action_id . '::' . $subscribe_type;
    ?>
" data-action="ajax_btn" data-cb="apSubscribeBtnCB">
            <?php 
    echo ap_icon('rss', true);
    ?>
 <span class="text"><?php 
    echo $title;
    ?>
</span>      
        </a>
        <b class="ap-btn-counter" data-view="<?php 
    echo 'subscribe_' . $action_id;
    ?>
"><?php 
    echo ap_subscribers_count($action_id, $subscribe_type);
    ?>
</b>
    </div>

	<?php 
}
Example #14
0
function ap_follow_btn_html($userid, $small = false)
{
    if (get_current_user_id() == $userid) {
        return;
    }
    $followed = ap_is_user_voted($userid, 'follow', get_current_user_id());
    $text = $followed ? __('Unfollow', 'ap') : __('Follow', 'ap');
    echo '<a class="btn ap-btn ap-follow-btn ' . ($followed ? 'ap-unfollow ' . ap_icon('unfollow') : ap_icon('follow')) . ($small ? ' ap-tip' : '') . '" href="#" data-action="ap-follow" data-args=\'' . json_encode(array('user' => $userid, 'nonce' => wp_create_nonce('follow_' . $userid))) . '\' title="' . $text . '">' . ($small ? '' : $text) . '</a>';
}
Example #15
0
        echo ap_icon('answer', true);
        echo ap_question_get_the_answer_count();
        ?>
</a>
							<span class="ap-user-posts-active"><?php 
        ap_question_the_active_ago();
        ?>
</span>
							<a class="ap-user-posts-ccount ap-tip" href="<?php 
        ap_question_the_permalink();
        ?>
" title="<?php 
        _e('Comments', 'ap');
        ?>
"><?php 
        echo ap_icon('comment', true);
        echo get_comments_number();
        ?>
</a>
							<div class="no-overflow"><a href="<?php 
        ap_question_the_permalink();
        ?>
" class="ap-user-posts-title"><?php 
        the_title();
        ?>
</a></div>
						</div>

					<?php 
    }
    wp_reset_postdata();
Example #16
0
function ap_get_latest_history_html($post_id, $initial = false, $avatar = false, $icon = false)
{
    $post = get_post($post_id);
    $history = get_post_meta($post_id, '__ap_history', true);
    if (!$history && $initial) {
        $history['date'] = get_the_time('c', $post_id);
        $history['user_id'] = $post->post_author;
        $history['type'] = 'new_' . $post->post_type;
    }
    $html = '';
    if ($history) {
        if ($icon) {
            $html .= '<span class="' . ap_icon($history['type']) . ' ap-tlicon"></span>';
        }
        if ($avatar) {
            $html .= '<a class="ap-avatar" href="' . ap_user_link($history['user_id']) . '">' . get_avatar($history['user_id'], 22) . '</a>';
        }
        $title = ap_history_title($history['type']);
        $html .= '<span class="ap-post-history">' . ap_icon('history', true) . sprintf(__(' %s %s %s ago', 'ap'), ap_user_display_name($history['user_id']), $title, '<time datetime="' . mysql2date('c', $history['date']) . '">' . ap_human_time($history['date'], false) . '</time>') . '</span>';
    }
    if ($html) {
        return apply_filters('ap_latest_history_html', $html);
    }
    return false;
}
Example #17
0
/**
 * Output voting button.
 *
 * @param int $post
 *
 * @return null|string
 *
 * @since 0.1
 */
function ap_vote_btn($post = false, $echo = true)
{
    if (false === $post) {
        global $post;
    }
    if ('answer' == $post->post_type && ap_opt('disable_voting_on_answer')) {
        return;
    }
    if ('question' == $post->post_type && ap_opt('disable_voting_on_question')) {
        return;
    }
    $nonce = wp_create_nonce('vote_' . $post->ID);
    $vote = ap_is_user_voted($post->ID, 'vote');
    $voted = $vote ? true : false;
    $type = $vote ? $vote->type : '';
    $html = '';
    $html .= '<div data-id="' . $post->ID . '" class="ap-vote net-vote" data-action="vote">';
    $html .= '<a class="' . ap_icon('vote_up') . ' ap-tip vote-up' . ($voted ? ' voted' : '') . ($type == 'vote_down' ? ' disable' : '') . '" data-query="ap_ajax_action=vote&type=up&post_id=' . $post->ID . '&__nonce=' . $nonce . '" href="#" title="' . __('Up vote this post', 'ap') . '"></a>';
    $html .= '<span class="net-vote-count" data-view="ap-net-vote" itemprop="upvoteCount">' . ap_net_vote() . '</span>';
    if ('question' == $post->post_type && !ap_opt('disable_down_vote_on_question') || 'answer' == $post->post_type && !ap_opt('disable_down_vote_on_answer')) {
        $html .= '<a data-tipposition="bottom center" class="' . ap_icon('vote_down') . ' ap-tip vote-down' . ($voted ? ' voted' : '') . ($type == ' vote_up' ? ' disable' : '') . '" data-query="ap_ajax_action=vote&type=down&post_id=' . $post->ID . '&__nonce=' . $nonce . '" href="#" title="' . __('Down vote this post', 'ap') . '"></a>';
    }
    $html .= '</div>';
    if ($echo) {
        echo $html;
    } else {
        return $html;
    }
}
Example #18
0
function ap_cover_upload_form()
{
    if (ap_get_displayed_user_id() == get_current_user_id()) {
        ?>

        <form method="post" action="#" enctype="multipart/form-data" data-action="ap_upload_form" class="ap-avatar-upload-form">
            <div class="ap-btn ap-upload-o <?php 
        echo ap_icon('upload');
        ?>
" title="<?php 
        _e('Upload a cover photo', 'ap');
        ?>
">
                <span><?php 
        _e('Upload cover', 'ap');
        ?>
</span>
                <input type="file" name="image" class="ap-upload-input" data-action="ap_upload_field">
            </div>
            <input type='hidden' value='<?php 
        echo wp_create_nonce('upload_cover_' . get_current_user_id());
        ?>
' name='__nonce' />
            <input type="hidden" name="action" id="action" value="ap_cover_upload">
        </form>
        <?php 
    }
}
Example #19
0
				</div>
				<?php 
        if (ap_user_meta_exists('description')) {
            ?>

					<div class="ap-user-dscription">
						<div class="ap-user-description-in">
							<div id="user-summery">
								<?php 
            ap_user_the_meta('description');
            ?>

							</div>
						</div>
						<a href="#" data-action="ap_expand" data-expand="#user-summery"><?php 
            echo ap_icon('ellipsis', true);
            ?>
</a>
					</div>
				<?php 
        }
        ?>

				<div class="ap-user-buttons clearfix">
					<?php 
        ap_follow_button(ap_get_displayed_user_id());
        ?>

				</div>
			</div>
		<?php 
Example #20
0
<div class="ap-user-posts-item clearfix">
	<a class="ap-user-posts-vcount ap-tip<?php 
echo ap_question_best_answer_selected() ? ' answer-selected' : '';
?>
" href="<?php 
ap_question_the_permalink();
?>
" title="<?php 
_e('Votes', 'ap');
?>
"><?php 
echo ap_icon('thumb-up', true);
echo ap_question_get_the_answer_count();
?>
</a>
	<span class="ap-user-posts-active"><?php 
ap_question_the_active_ago();
?>
</span>
	<a class="ap-user-posts-ccount ap-tip" href="<?php 
ap_question_the_permalink();
?>
" title="<?php 
_e('Answers', 'ap');
?>
"><?php 
printf(__('%d answers', 'ap'), ap_question_get_the_answer_count());
?>
</a>
	<div class="no-overflow"><a href="<?php 
ap_question_the_permalink();
Example #21
0
	    <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">
		<?php 
ap_question_sorting();
?>
		<?php 
do_action('ap_list_head');
?>
		<a id="ap-question-sorting-reset" href="#" title="<?php 
_e('Reset sorting and filter', 'anspress-question-answer');
?>
"><?php 
echo ap_icon('x', true);
?>
</a>
	</form>
</div>
Example #22
0
            ?>
" title="<?php 
            _e('Mark as read', 'ap');
            ?>
"></a>
							<?php 
        }
        ?>
							<a class="ap-btn ap-btn-delete ap-tip" href="#" data-action="ap_delete_notification" data-query="<?php 
        echo 'id=' . ap_activity_id() . '&ap_ajax_action=delete_notification&__nonce=' . wp_create_nonce('delete_notification');
        ?>
" title="<?php 
        _e('Delete notificaton', 'ap');
        ?>
"><?php 
        echo ap_icon('trashcan', true);
        ?>
</a>

						</div>
						<div class="no-overflow">
							<span class="ap-notification-content">
								<?php 
        ap_activity_the_content();
        ?>
							</span>
							<div class="ap-notification-meta">
								<span class="ap-notification-time"><?php 
        ap_activity_the_date();
        ?>
</span>
Example #23
0
 /**
  * Add user dropdown and notification menu
  * @param  string  $o        		   Menu html.
  * @param  object  $item               Menu item object.
  * @param  integer $depth              Menu depth.
  * @param  object  $args 			   Menu args.
  * @return string
  */
 public function walker_nav_menu_start_el($o, $item, $depth, $args)
 {
     if (!is_user_logged_in() && (in_array('anspress-page-profile', $item->classes) || in_array('anspress-page-notification', $item->classes))) {
         $o = '';
     }
     if (in_array('anspress-page-profile', $item->classes) && is_user_logged_in()) {
         $menus = ap_get_user_menu(get_current_user_id());
         $active_user_page = get_query_var('user_page') ? esc_attr(get_query_var('user_page')) : 'about';
         $o = '<a id="ap-user-menu-anchor" class="ap-dropdown-toggle" href="#">';
         $o .= get_avatar(get_current_user_id(), 80);
         $o .= '<span class="name">' . ap_user_display_name(get_current_user_id()) . '</span>';
         $o .= ap_icon('chevron-down', true);
         $o .= '</a>';
         $o .= '<ul id="ap-user-menu-link" class="ap-dropdown-menu ap-user-dropdown-menu">';
         foreach ($menus as $m) {
             $class = !empty($m['class']) ? ' ' . $m['class'] : '';
             $o .= '<li' . ($active_user_page == $m['slug'] ? ' class="active"' : '') . '>';
             $o .= '<a href="' . $m['link'] . '" class="ap-user-link-' . $m['slug'] . $class . '">';
             $o .= esc_attr($m['title']) . '</a>';
             $o .= '</li>';
         }
         $o .= '</ul>';
     } elseif (in_array('anspress-page-notification', $item->classes) && is_user_logged_in()) {
         $o = '<a id="ap-user-notification-anchor" class="ap-dropdown-toggle ' . ap_icon('globe') . '" href="#">' . ap_get_the_total_unread_notification(false, false) . '</a>';
         global $ap_notifications;
         ob_start();
         $ap_notifications = ap_get_user_notifications(array('per_page' => 10));
         ap_get_template_part('user/notification-dropdown');
         $o .= ob_get_clean();
     }
     return $o;
 }
Example #24
0
				</div>
			<?php 
} else {
    ?>
				<?php 
    _e('No answer posted yet!', 'ap');
    ?>
			<?php 
}
?>
		</div>
	</div>

	<div class="ap-about-block top-answers">
		<h3><?php 
echo ap_icon('question', true);
?>
 <?php 
_e('New questions', 'ap');
?>
</h3>
		<div class="ap-about-block-c">
			<?php 
$questions = ap_get_questions(array('author' => ap_get_displayed_user_id(), 'showposts' => 5, 'sortby' => 'newest'));
?>

			<?php 
if (ap_have_questions()) {
    ?>

				<?php 
Example #25
0
function ap_change_label_html($post_id)
{
    if (ap_user_can_change_label()) {
        ?>
	<div class="ap-change-label-from ap-dropdown pull-right">
		<a class="ap-icon ap-icon-cog ap-dropdown-toggle" data-action="ap-change-status"></a>
		<div class="ap-dropdown-menu">
			<?php 
        $labels = get_terms('question_label', array('orderby' => 'name', 'hide_empty' => false));
        $taxo = get_the_terms($post_id, 'question_label');
        $taxo_array = array();
        if ($taxo) {
            foreach ($taxo as $t) {
                $taxo_array[] = $t->slug;
            }
        }
        if ($labels) {
            echo '<ul id="ap-label-select" data-action="ap-label-select">';
            echo '<li class="ap-select-header">' . __('Label', 'ap') . '</li>';
            foreach ($labels as $l) {
                $color = ap_get_label_color($l->term_id);
                echo '<li data-args="' . $l->term_id . '" class="ap-select-item ' . ap_icon('checked') . ' ' . (in_array($l->slug, $taxo_array) ? ' selected' : '') . '" data-color="' . $color . '"><span class="question-label-color" style="background:' . $color . ';"></span>' . $l->name . '<span class="unselect ap-icon-cross"></span></li>';
            }
            $nonce = wp_create_nonce('label-' . get_question_id());
            echo '<li class="ap-select-footer"><a href="#" data-button="ap-save-label" data-id="' . get_question_id() . '" data-nonce="' . $nonce . '" class="ap-btn ap-small">' . __('Done', 'ap') . '</a>';
            echo '<a href="#" class="ap-btn ap-small" data-toggle="ap-dropdown">' . __('Close', 'ap') . '</a>';
            echo '</li></ul>';
        }
        ?>
			
		</div>
	</div>
	<?php 
    }
}
Example #26
0
function ap_post_upload_form($post_id = false)
{
    $html = '
    <div class="ap-post-upload-form">
        <div class="ap-btn ap-upload-o ' . ap_icon('image') . '">
        	<span>' . __('Add image to editor', 'ap') . '</span>';
    if (ap_user_can_upload_image()) {
        $html .= '
	            <a class="ap-upload-link" href="#" data-action="ap_post_upload_field">
	            	' . __('upload', 'ap') . '

	            </a> ' . __('or', 'ap');
    }
    $html .= '<span class="ap-upload-remote-link">
            	' . __('add image from link', 'ap') . '
            </span>
            <div class="ap-upload-link-rc">
        		<input type="text" name="post_remote_image" class="ap-form-control" placeholder="' . __('Enter images link', 'ap') . '" data-action="post_remote_image">
        		<a data-action="post_image_ok" class="apicon-check ap-btn" href="#"></a>
        		<a data-action="post_image_close" class="apicon-x ap-btn" href="#"></a>
        	</div>
        	<input type="hidden" name="attachment_ids[]" value="" />
        </div>';
    $html .= '</div>';
    return $html;
}
Example #27
0
 /**
  * Set icon class for user menus
  * @param  array $menus AnsPress user menu.
  * @return array
  * @since 2.0.1
  */
 public function ap_user_menu_icons($menus)
 {
     $icons = array('about' => ap_icon('home'), 'profile' => ap_icon('board'), 'questions' => ap_icon('question'), 'answers' => ap_icon('answer'), 'activity' => ap_icon('pulse'), 'reputation' => ap_icon('reputation'), 'followers' => ap_icon('users'), 'following' => ap_icon('users'), 'subscription' => ap_icon('mail'), 'notification' => ap_icon('globe'), 'activity-feed' => ap_icon('rss'));
     foreach ($icons as $k => $i) {
         if (isset($menus[$k])) {
             $menus[$k]['class'] = $i;
         }
     }
     return $menus;
 }
Example #28
0
    public function login_bottom()
    {
        if (!is_user_logged_in()) {
            ?>
			<div class="ap-account-button clearfix">
			<?php 
            if (ap_opt('allow_anonymous')) {
                ?>
				<div class="ap-ac-accordion">
					<strong>
						<i class="<?php 
                echo ap_icon('unchecked');
                ?>
"></i>
						<i class="<?php 
                echo ap_icon('checked');
                ?>
"></i>
						<?php 
                _e('Continue as anonymous', 'ap');
                ?>
					</strong>
					<div class="anonymous-info accordion-content">					
						<div class="form-group">
							<label for="name"><?php 
                _e('Your name', 'ap');
                ?>
</label>
							<input id="name" type="text" class="form-control" name="name" placeholder="<?php 
                _e('Your name or leave it blank', 'ap');
                ?>
" />
						</div>
					</div>
				</div>
				<?php 
            }
            ?>
				<?php 
            if (ap_opt('show_signup') || ap_opt('show_login')) {
                ?>
				<div class="ap-ac-accordion">
					<strong>
						<i class="<?php 
                echo ap_icon('unchecked');
                ?>
"></i>
						<i class="<?php 
                echo ap_icon('checked');
                ?>
"></i>
						<?php 
                if (ap_opt('show_signup') && ap_opt('show_login')) {
                    ?>
						<?php 
                    _e('Login or Sign Up', 'ap');
                    ?>
						<?php 
                } elseif (ap_opt('show_signup')) {
                    ?>
						<?php 
                    _e('Sign up', 'ap');
                    ?>
						<?php 
                } elseif (ap_opt('show_login')) {
                    ?>
						<?php 
                    _e('Login', 'ap');
                    ?>
						<?php 
                }
                ?>
					</strong>
					<div class="ap-site-ac accordion-content">
						<?php 
                if (ap_opt('show_login')) {
                    ?>
						<?php 
                    if (ap_opt('custom_login_url') != '') {
                        ?>
						<?php 
                        $customloginurl = ap_opt('custom_login_url');
                        ?>
						<a href="<?php 
                        echo $customloginurl;
                        ?>
" class="ap-btn" title="<?php 
                        _e('Click here to login if you already have an account on this site.', 'ap');
                        ?>
"><?php 
                        _e('Login', 'ap');
                        ?>
</a>
						<?php 
                    } else {
                        ?>
						<a href="#ap_login_modal" class="ap-open-modal ap-btn" title="<?php 
                        _e('Click here to login if you already have an account on this site.', 'ap');
                        ?>
"><?php 
                        _e('Login', 'ap');
                        ?>
</a>
						<?php 
                    }
                    ?>
						<?php 
                }
                ?>
						<?php 
                if (ap_opt('show_signup')) {
                    ?>
						<?php 
                    if (ap_opt('custom_signup_url') != '') {
                        ?>
						<?php 
                        $customsignupurl = ap_opt('custom_signup_url');
                        ?>
						<a href="<?php 
                        echo $customsignupurl;
                        ?>
" class="ap-btn" title="<?php 
                        _e('Click here to signup if you do not have an account on this site.', 'ap');
                        ?>
"><?php 
                        _e('Sign Up', 'ap');
                        ?>
</a>
						<?php 
                    } else {
                        ?>
						<a href="#ap_signup_modal" class="ap-open-modal ap-btn" title="<?php 
                        _e('Click here to signup if you do not have an account on this site.', 'ap');
                        ?>
"><?php 
                        _e('Sign Up', 'ap');
                        ?>
</a>
						<?php 
                    }
                    ?>
						<?php 
                }
                ?>
					</div>
				</div>
				<?php 
            }
            ?>
				<?php 
            if (ap_opt('show_social_login')) {
                ?>
				<div class="ap-social-ac">
					<?php 
                do_action('wordpress_social_login');
                ?>
				</div>
				<?php 
            }
            ?>
			</div>		
		<?php 
        }
    }