diff --git a/bp-compliments-core.php b/bp-compliments-core.php index 5cf1e2b..f46696f 100644 --- a/bp-compliments-core.php +++ b/bp-compliments-core.php @@ -180,6 +180,12 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) { $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; + } 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; } @@ -214,16 +220,6 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) { * @package BuddyPress_Compliments */ public function enqueue_scripts() { - // Do not enqueue if no user is logged in - if ( ! is_user_logged_in() ) { - return; - } - - // Do not enqueue on multisite if not on multiblog and not on root blog - if( ! bp_is_multiblog_mode() && ! bp_is_root_blog() ) { - return; - } - wp_enqueue_script( 'bp-compliments-js', constant( 'BP_COMPLIMENTS_URL' ) . 'js/bp-compliments.js', array( 'jquery' ) ); wp_register_style( 'bp-compliments-css', constant( 'BP_COMPLIMENTS_URL' ) . 'css/bp-compliments.css' ); wp_enqueue_style( 'bp-compliments-css' ); diff --git a/change_log.txt b/change_log.txt index ee09bb8..9ccc6df 100644 --- a/change_log.txt +++ b/change_log.txt @@ -2,6 +2,7 @@ v0.0.9 Changed textdomain from defined constant to a string - CHANGED Added filters and actions for whoop theme compatibility - ADDED Notification not showing properly - FIXED +Added support for member only compliment display - ADDED v0.0.8 Option added to enable/disable activity component - ADDED diff --git a/includes/bp-compliments-actions.php b/includes/bp-compliments-actions.php index ca3e1bf..358ff08 100644 --- a/includes/bp-compliments-actions.php +++ b/includes/bp-compliments-actions.php @@ -57,9 +57,15 @@ function handle_compliments_form_data() { $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; - } + } 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; + } if (current_user_can( 'manage_options' )) { $show_for_displayed_user = true; diff --git a/includes/bp-compliments-activity.php b/includes/bp-compliments-activity.php index a1e6543..47f2b83 100644 --- a/includes/bp-compliments-activity.php +++ b/includes/bp-compliments-activity.php @@ -156,6 +156,12 @@ function compliments_format_activity_action_compliment_received( $action, $activ if ($bp_compliment_can_see_others_comp == 'yes') { $action = sprintf( __( '%1$s has received a %2$s from %3$s', 'bp-compliments' ), $receiver_link, $compliment_link, $sender_link ); + } elseif ($bp_compliment_can_see_others_comp == 'members_only') { + if (is_user_logged_in()) { + $action = sprintf( __( '%1$s has received a %2$s from %3$s', 'bp-compliments' ), $receiver_link, $compliment_link, $sender_link ); + } else { + $action = sprintf( __( '%1$s has received a %2$s from %3$s', 'bp-compliments' ), $receiver_link, strtolower(BP_COMP_SINGULAR_NAME), $sender_link ); + } } else { $action = sprintf( __( '%1$s has received a %2$s from %3$s', 'bp-compliments' ), $receiver_link, strtolower(BP_COMP_SINGULAR_NAME), $sender_link ); } @@ -200,6 +206,12 @@ function compliments_format_activity_action_compliment_sent( $action, $activity if ($bp_compliment_can_see_others_comp == 'yes') { $action = sprintf( __( '%1$s has sent a %2$s to %3$s', 'bp-compliments' ), $sender_link, $compliment_link, $receiver_link ); + } elseif ($bp_compliment_can_see_others_comp == 'members_only') { + if (is_user_logged_in()) { + $action = sprintf( __( '%1$s has sent a %2$s to %3$s', 'bp-compliments' ), $sender_link, $compliment_link, $receiver_link ); + } else { + $action = sprintf( __( '%1$s has sent a %2$s to %3$s', 'bp-compliments' ), $sender_link, strtolower(BP_COMP_SINGULAR_NAME), $receiver_link ); + } } else { $action = sprintf( __( '%1$s has sent a %2$s to %3$s', 'bp-compliments' ), $sender_link, strtolower(BP_COMP_SINGULAR_NAME), $receiver_link ); } diff --git a/includes/bp-compliments-settings.php b/includes/bp-compliments-settings.php index 326e756..cfebbf1 100644 --- a/includes/bp-compliments-settings.php +++ b/includes/bp-compliments-settings.php @@ -72,11 +72,12 @@ function bp_compliments_settings_page() { - + diff --git a/includes/templates/buddypress/members/single/compliments.php b/includes/templates/buddypress/members/single/compliments.php index 8c19ea1..4c8c532 100644 --- a/includes/templates/buddypress/members/single/compliments.php +++ b/includes/templates/buddypress/members/single/compliments.php @@ -56,7 +56,7 @@ } } - if ($compliments && ($bp_compliment_can_see_others_comp == 'yes')) { + if ( ($compliments && $bp_compliment_can_see_others_comp == 'yes') || ( $compliments && is_user_logged_in() && $bp_compliment_can_see_others_comp == 'members_only' )) { ?>