diff --git a/bp-compliments-core.php b/bp-compliments-core.php index a211e8a..f458d95 100644 --- a/bp-compliments-core.php +++ b/bp-compliments-core.php @@ -166,12 +166,21 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) { // 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 == 'yes') { + $show_for_displayed_user = true; + } else { + $show_for_displayed_user = false; + } + bp_core_new_nav_item( array( 'name' => sprintf( __( 'Compliments %d', BP_COMP_TEXTDOMAIN ), $counts['received'] ), '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' ) ); diff --git a/change_log.txt b/change_log.txt index 6ceece1..80da952 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +v0.0.4 +Members can see other members compliment page? setting - ADDED + v0.0.3 Validation added when adding compliment, icon required - FIXED Some strings are not translatable - FIXED diff --git a/includes/bp-compliments-activity.php b/includes/bp-compliments-activity.php index 0c88133..9b57ed6 100644 --- a/includes/bp-compliments-activity.php +++ b/includes/bp-compliments-activity.php @@ -140,13 +140,25 @@ function compliments_register_activity_actions() { */ function compliments_format_activity_action_compliment_received( $action, $activity ) { global $bp; + $receiver_link = bp_core_get_userlink( $activity->user_id ); $sender_link = bp_core_get_userlink( $activity->secondary_item_id ); $receiver_url = bp_core_get_userlink( $activity->user_id, false, true ); $compliment_url = $receiver_url . $bp->compliments->id . '/?c_id='.$activity->item_id; $compliment_link = ''.__("compliment", BP_COMP_TEXTDOMAIN).''; - $action = sprintf( __( '%1$s has received a %2$s from %3$s', BP_COMP_TEXTDOMAIN ), $receiver_link, $compliment_link, $sender_link ); + $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->loggedin_user->id == $bp->displayed_user->id) { + $bp_compliment_can_see_others_comp = 'yes'; + } + + if ($bp_compliment_can_see_others_comp == 'yes') { + $action = sprintf( __( '%1$s has received a %2$s from %3$s', BP_COMP_TEXTDOMAIN ), $receiver_link, $compliment_link, $sender_link ); + } else { + $action = sprintf( __( '%1$s has received a compliment from %2$s', BP_COMP_TEXTDOMAIN ), $receiver_link, $sender_link ); + } /** @@ -179,7 +191,18 @@ function compliments_format_activity_action_compliment_sent( $action, $activity $compliment_url = $receiver_url . $bp->compliments->id . '/?c_id='.$activity->item_id; $compliment_link = ''.__("compliment", BP_COMP_TEXTDOMAIN).''; - $action = sprintf( __( '%1$s has sent a %2$s to %3$s', BP_COMP_TEXTDOMAIN ), $sender_link, $compliment_link, $receiver_link ); + $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->loggedin_user->id == $bp->displayed_user->id) { + $bp_compliment_can_see_others_comp = 'yes'; + } + + if ($bp_compliment_can_see_others_comp == 'yes') { + $action = sprintf( __( '%1$s has sent a %2$s to %3$s', BP_COMP_TEXTDOMAIN ), $sender_link, $compliment_link, $receiver_link ); + } else { + $action = sprintf( __( '%1$s has sent a compliment to %2$s', BP_COMP_TEXTDOMAIN ), $sender_link, $receiver_link ); + } /** * Filters the 'compliment_sent' activity action format. diff --git a/includes/bp-compliments-taxonomies.php b/includes/bp-compliments-taxonomies.php index c025950..2e86b07 100644 --- a/includes/bp-compliments-taxonomies.php +++ b/includes/bp-compliments-taxonomies.php @@ -236,6 +236,7 @@ function compliment_remove_parent_dropdown() add_action( 'admin_init', 'bp_compliments_register_settings' ); function bp_compliments_register_settings() { + register_setting( 'bp-compliment-settings', 'bp_compliment_can_see_others_comp' ); register_setting( 'bp-compliment-settings', 'bp_compliment_can_delete' ); register_setting( 'bp-compliment-settings', 'bp_comp_per_page' ); register_setting( 'bp-compliment-settings', 'bp_comp_custom_css' ); @@ -249,6 +250,10 @@ function bp_compliments_settings_page() {