Example #1
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 #2
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 #3
0
/**
 * Output user menu
 * Extract menu from registered user pages
 * @return void
 * @since 2.0.1
 */
function ap_user_menu($collapse = true, $user_id = false)
{
    if (false === $user_id) {
        $user_id = ap_get_displayed_user_id();
    }
    $menus = ap_get_user_menu($user_id);
    foreach ($menus as $k => $m) {
        if (false === $m['public'] && !ap_is_my_profile()) {
            unset($menus[$k]);
        }
    }
    $active_user_page = get_query_var('user_page');
    $active_user_page = ap_active_user_page();
    if (!empty($menus) && is_array($menus)) {
        $o = '<ul id="ap-user-menu" class="ap-user-menu ' . ($collapse ? 'ap_collapse_menu' : '') . ' clearfix">';
        foreach ($menus as $m) {
            $class = !empty($m['class']) ? ' ' . $m['class'] : '';
            $o .= '<li' . ($active_user_page == $m['slug'] ? ' class="active"' : '') . '><a href="' . $m['link'] . '" class="ap-user-menu-' . $m['slug'] . $class . '">' . $m['title'] . '</a></li>';
        }
        /*if ( $collapse ) {
        			$o .= '<li class="ap-user-menu-more ap-dropdown"><a href="#" class="ap-dropdown-toggle">'.__( 'More', 'ap' ).ap_icon( 'chevron-down', true ).'</a><ul class="ap-dropdown-menu"></ul></li>'; }
        
        		$o .= '</ul>';*/
        echo $o;
    }
}
Example #4
0
/**
 * Output user menu
 * Extract menu from registered user pages
 * @return void
 * @since 2.0.1
 */
function ap_user_menu()
{
    $menus = ap_get_user_menu();
    $active_user_page = get_query_var('user_page');
    $active_user_page = $active_user_page ? $active_user_page : 'about';
    if (!empty($menus) && is_array($menus)) {
        $o = '<ul id="ap-user-menu" class="ap-user-menu ap_collapse_menu clearfix">';
        foreach ($menus as $m) {
            $class = !empty($m['class']) ? ' ' . $m['class'] : '';
            $o .= '<li' . ($active_user_page == $m['slug'] ? ' class="active"' : '') . '><a href="' . $m['link'] . '" class="ap-user-menu-' . $m['slug'] . $class . '">' . $m['title'] . '</a></li>';
        }
        $o .= '<li class="ap-user-menu-more ap-dropdown"><a href="#" class="ap-dropdown-toggle">' . __('More', 'ap') . ap_icon('chevron-down', true) . '</a><ul class="ap-dropdown-menu"></ul></li>';
        $o .= '</ul>';
        echo $o;
    }
}
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;
 }