/** * Output widget * @param array $args Widget arguments. * @param array $instance Widget instance. */ public function widget($args, $instance) { global $ap_activities; $ap_activities = ap_get_activities(array('per_page' => 20, 'notification' => true, 'user_id' => ap_get_displayed_user_id())); echo $args['before_widget']; ap_get_template_part('widgets/notifications'); echo $args['after_widget']; }
function ap_user_fields($args = '', $group = false) { if (ap_get_displayed_user_id() != get_current_user_id()) { return; } if (!$group) { $group = !isset($_GET['group']) ? 'basic' : sanitize_text_field($_GET['group']); } echo ap_user_get_fields($args, $group); }
public function insert_views($template) { //Log current time as user meta, so later we can check when user was active. if (is_user_logged_in()) { update_user_meta(get_current_user_id(), '__last_active', current_time('mysql')); } if (is_question()) { ap_insert_views(get_question_id(), 'question'); } if (is_ap_user() && ap_get_displayed_user_id() != get_current_user_id() && ap_get_displayed_user_id()) { ap_insert_views(ap_get_displayed_user_id(), 'profile'); } }
public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); $number = $instance['number']; $avatar_size = $instance['avatar_size']; echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } if (is_ap_user()) { $followers = ap_has_users(array('user_id' => ap_get_displayed_user_id(), 'sortby' => 'followers')); if ($followers->has_users()) { include ap_get_theme_location('widgets/followers.php'); } else { _e('No followers yet', 'ap'); } } else { _e('This widget can only be used in user page.', 'ap'); } echo $args['after_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']; } global $ap_user_query; if (is_user_logged_in()) { $ap_user_query = ap_has_users(array('ID' => ap_get_displayed_user_id())); if ($ap_user_query->has_users()) { while (ap_users()) { ap_the_user(); ap_get_template_part('widgets/user'); } } } else { _e('Login to see your profile links', 'ap'); } echo $args['after_widget']; }
/** * Get users registartion date * @return string Date */ function ap_user_get_registered_date() { global $ap_user_query; if (!isset($ap_user_query->user)) { return ap_get_displayed_user_id(); } $user = $ap_user_query->user; return $user->data->user_registered; }
/** * Register followers page in AnsPress */ public function following_page() { $following = ap_has_users(array('user_id' => ap_get_displayed_user_id(), 'sortby' => 'following')); if ($following->has_users()) { include ap_get_theme_location('user/following.php'); } else { esc_attr_e('You are not following anyone.', 'anspress-question-answer'); } }
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); }
public function __construct($args = '') { // grab the current page number and set to 1 if no page number is set $this->paged = get_query_var('paged') ? get_query_var('paged') : 1; $this->offset = $this->per_page * ($this->paged - 1); $this->args = wp_parse_args($args, array('user_id' => ap_get_displayed_user_id(), 'number' => $this->per_page, 'offset' => $this->offset)); $this->per_page = $this->args['number']; $this->query(); }
?> </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 } ?> <!-- Start ap-profile-lr --> <div class="ap-user-lr"> <?php ap_user_page(); ?> </div>
/** * 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; $ap_activities = ap_get_activities(array('per_page' => 20, 'notification' => true, 'user_id' => ap_get_displayed_user_id())); ob_start(); ap_get_template_part('user/notification-dropdown'); $o .= ob_get_clean(); } return $o; }
while (ap_questions()) { ap_the_question(); ?> <?php ap_get_template_part('user/list-question'); ?> <?php } ?> <div class="ap-user-posts-footer"> <?php printf(__('More questions by %s', 'ap'), ap_user_get_the_display_name()); ?> <a href="<?php echo ap_user_link(ap_get_displayed_user_id(), 'questions'); ?> "><?php _e('view', 'ap'); ?> →</a> </div> <?php } else { ?> <?php _e('No question asked yet!', 'ap'); ?> <?php
<ul class="ap-ul-inline clearfix"> <?php while ($followers->users()) { $followers->the_user(); ?> <li> <a class="ap-users-avatar" href="<?php ap_user_the_link(); ?> " title="<?php ap_user_the_display_name(); ?> "> <?php ap_user_the_avatar($avatar_size); ?> </a> </li> <?php } ?> </ul> <a class="ap-widget-all-link" href="<?php echo ap_user_link(ap_get_displayed_user_id(), 'followers'); ?> "><?php _e('View all followers →', 'ap'); ?> </a> </div>
function ap_hover_card_ajax_query($user_id = false) { if ($user_id === false) { $user_id = ap_get_displayed_user_id(); } return 'action=ap_ajax&ap_ajax_action=user_cover&user_id=' . $user_id; }
?> <div id="ap-users" class="ap-users ap-user-activity"> <h3 class="ap-user-page-title clearfix"> <?php echo ap_page_title(); ?> </h3> <?php if (ap_has_activities()) { ?> <div class="ap-activities"> <?php /* Start the Loop */ while (ap_activities()) { ap_the_activity(); ap_get_template_part('activity/item'); } ?> </div> <?php ap_activity_pagination(ap_user_link(ap_get_displayed_user_id(), 'activity-feed')); ?> <?php } else { ap_get_template_part('content-none'); } ?> </div>
<div id="ap-lists"> <h3 class="ap-user-page-title clearfix"> <?php echo ap_page_title(); ?> <?php ap_question_sorting(ap_user_link(ap_get_displayed_user_id(), 'questions')); ?> </h3> <?php if (ap_have_questions()) { ?> <div class="ap-questions"> <?php /* Start the Loop */ while (ap_questions()) { ap_the_question(); ap_get_template_part('user/list-question'); } ?> </div> <?php ap_questions_the_pagination(); ?> <?php } else { include ap_get_theme_location('content-none.php'); } ?> </div>