/** * Setup profile navigation. * * @since 0.0.1 * @package BuddyPress_Compliments * * @global object $bp BuddyPress instance. * @param array $main_nav Not being used. * @param array $sub_nav Not being used. */ public function setup_nav($main_nav = array(), $sub_nav = array()) { global $bp; /** * Functions hooked to this action will be processed before compliments navigation setup. * * @since 0.0.1 * @package BuddyPress_Compliments */ do_action('bp_compliments_before_setup_nav'); // Need to change the user ID, so if we're not on a member page, $counts variable is still calculated $user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id(); $counts = bp_compliments_total_counts(array('user_id' => $user_id)); $bp_compliment_can_see_others_comp_value = esc_attr(get_option('bp_compliment_can_see_others_comp')); $bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes'; if ($bp_compliment_can_see_others_comp == 'members_choice') { $bp_compliment_can_see_your_comp_value = esc_attr(get_user_meta(bp_displayed_user_id(), 'bp_compliment_can_see_your_comp', true)); $bp_compliment_can_see_others_comp = $bp_compliment_can_see_your_comp_value ? $bp_compliment_can_see_your_comp_value : 'yes'; } if ($bp_compliment_can_see_others_comp == 'yes') { $show_for_displayed_user = true; } elseif ($bp_compliment_can_see_others_comp == 'members_only') { if (is_user_logged_in()) { $show_for_displayed_user = true; } else { $show_for_displayed_user = false; } } else { $show_for_displayed_user = false; } bp_core_new_nav_item(array('name' => BP_COMP_PLURAL_NAME . " " . "<span>" . $counts['received'] . "</span>", 'slug' => $bp->compliments->compliments->slug, 'position' => $this->params['adminbar_myaccount_order'], 'screen_function' => 'bp_compliments_screen_compliments', 'show_for_displayed_user' => $show_for_displayed_user, 'default_subnav_slug' => 'compliments', 'item_css_id' => 'members-compliments')); /** * Functions hooked to this action will be processed after compliments navigation setup. * * @since 0.0.1 * @package BuddyPress_Compliments */ do_action('bp_compliments_after_setup_nav'); }
/** * Functions hooked to this action will be processed before displaying compliments page content. * * @since 0.0.1 * @package BuddyPress_Compliments * * @global object $bp BuddyPress instance. */ do_action('bp_before_member_' . bp_current_action() . '_content'); ?> <div class="bp-compliments-wrap"> <?php $c_id = false; $count_args = array('user_id' => bp_displayed_user_id()); $count_array = bp_compliments_total_counts($count_args); $total = (int) $count_array['received']; $comp_per_page_value = esc_attr(get_option('bp_comp_per_page')); $items_per_page = $comp_per_page_value ? (int) $comp_per_page_value : 5; $bp_compliment_can_see_others_comp_value = esc_attr(get_option('bp_compliment_can_see_others_comp')); $bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes'; if ($bp_compliment_can_see_others_comp == 'members_choice') { $bp_compliment_can_see_your_comp_value = esc_attr(get_user_meta(bp_displayed_user_id(), 'bp_compliment_can_see_your_comp', true)); $bp_compliment_can_see_others_comp = $bp_compliment_can_see_your_comp_value ? $bp_compliment_can_see_your_comp_value : 'yes'; } if (bp_displayed_user_id() == bp_loggedin_user_id()) { $bp_compliment_can_see_others_comp = 'yes'; } elseif (current_user_can('manage_options')) { $bp_compliment_can_see_others_comp = 'yes'; } $page = isset($_GET['cpage']) ? abs((int) $_GET['cpage']) : 1;