Skip to content

Commit

Permalink
Merge pull request #16 from mistergiri/master
Browse files Browse the repository at this point in the history
Added support for member only compliment display
  • Loading branch information
NomadDevs authored and NomadDevs committed Sep 21, 2015
2 parents 0c38628 + d50eb40 commit 55387c8
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 48 deletions.
16 changes: 6 additions & 10 deletions bp-compliments-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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' );
Expand Down
1 change: 1 addition & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions includes/bp-compliments-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions includes/bp-compliments-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
}
Expand Down
7 changes: 4 additions & 3 deletions includes/bp-compliments-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ function bp_compliments_settings_page() {
<td><input type="text" class="widefat" name="bp_compliment_slug" value="<?php echo BP_COMPLIMENTS_SLUG; ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php echo sprintf( __( 'Members can see other members %s page?', 'bp-compliments' ), strtolower(BP_COMP_SINGULAR_NAME) ); ?></th>
<th scope="row"><?php echo sprintf( __( 'Who can see other members %s page?', 'bp-compliments' ), strtolower(BP_COMP_SINGULAR_NAME) ); ?></th>
<td>
<select id="bp_compliment_can_see_others_comp" name="bp_compliment_can_see_others_comp">
<option value="yes" <?php selected( $bp_compliment_can_see_others_comp, 'yes' ); ?>><?php echo __( 'Yes', 'bp-compliments' ); ?></option>
<option value="no" <?php selected( $bp_compliment_can_see_others_comp, 'no' ); ?>><?php echo __( 'No', 'bp-compliments' ); ?></option>
<option value="yes" <?php selected( $bp_compliment_can_see_others_comp, 'yes' ); ?>><?php echo __( 'Anybody', 'bp-compliments' ); ?></option>
<option value="no" <?php selected( $bp_compliment_can_see_others_comp, 'no' ); ?>><?php echo __( 'Nobody', 'bp-compliments' ); ?></option>
<option value="members_only" <?php selected( $bp_compliment_can_see_others_comp, 'members_only' ); ?>><?php echo __( 'Members Only', 'bp-compliments' ); ?></option>
</select>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' )) {
?>
<div class="comp-user-content">
<ul class="comp-user-ul">
Expand Down
Binary file modified languages/bp-compliments-en_US.mo
Binary file not shown.
76 changes: 45 additions & 31 deletions languages/bp-compliments-en_US.po
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
msgid ""
msgstr ""
"Project-Id-Version: BuddyPress Compliments 0.0.8\n"
"POT-Creation-Date: 2015-09-03 20:38-0000\n"
"PO-Revision-Date: 2015-09-03 20:38-0000\n"
"POT-Creation-Date: 2015-09-21 13:02+0530\n"
"PO-Revision-Date: 2015-09-21 13:02+0530\n"
"Last-Translator: \n"
"Language-Team: GeoDirectory <[email protected]>\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.7.5\n"
"X-Generator: Poedit 1.8.1\n"
"X-Poedit-Basepath: ../\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x\n"
Expand Down Expand Up @@ -54,13 +54,17 @@ msgid "%s Sent"
msgstr ""

#: includes/bp-compliments-activity.php:158
#: includes/bp-compliments-activity.php:160
#: includes/bp-compliments-activity.php:161
#: includes/bp-compliments-activity.php:163
#: includes/bp-compliments-activity.php:166
#, php-format
msgid "%1$s has received a %2$s from %3$s"
msgstr ""

#: includes/bp-compliments-activity.php:202
#: includes/bp-compliments-activity.php:204
#: includes/bp-compliments-activity.php:208
#: includes/bp-compliments-activity.php:211
#: includes/bp-compliments-activity.php:213
#: includes/bp-compliments-activity.php:216
#, php-format
msgid "%1$s has sent a %2$s to %3$s"
msgstr ""
Expand All @@ -83,20 +87,20 @@ msgid "Cancel"
msgstr ""

#: includes/bp-compliments-notifications.php:49
#: includes/bp-compliments-notifications.php:185
#: includes/bp-compliments-notifications.php:188
#, php-format
msgid "%s has sent you a %s"
msgstr ""

#: includes/bp-compliments-notifications.php:188
#: includes/bp-compliments-notifications.php:191
#, php-format
msgid ""
"%s has sent you a %s.\n"
"\n"
"To view %s's %s: %s"
msgstr ""

#: includes/bp-compliments-notifications.php:195
#: includes/bp-compliments-notifications.php:198
#, php-format
msgid ""
"\n"
Expand All @@ -106,23 +110,21 @@ msgid ""
"%s"
msgstr ""

#: includes/bp-compliments-notifications.php:278
#: includes/bp-compliments-settings.php:78
#: includes/bp-compliments-settings.php:87
#: includes/bp-compliments-settings.php:96
#: includes/bp-compliments-settings.php:105
msgid "Yes"
msgstr ""

#: includes/bp-compliments-notifications.php:279
#: includes/bp-compliments-settings.php:79
#: includes/bp-compliments-notifications.php:281
#: includes/bp-compliments-settings.php:88
#: includes/bp-compliments-settings.php:97
#: includes/bp-compliments-settings.php:106
msgid "Yes"
msgstr ""

#: includes/bp-compliments-notifications.php:282
#: includes/bp-compliments-settings.php:89
#: includes/bp-compliments-settings.php:98
#: includes/bp-compliments-settings.php:107
msgid "No"
msgstr ""

#: includes/bp-compliments-notifications.php:286
#: includes/bp-compliments-notifications.php:289
#, php-format
msgid "A member sends you a %s"
msgstr ""
Expand All @@ -146,30 +148,42 @@ msgstr ""

#: includes/bp-compliments-settings.php:75
#, php-format
msgid "Members can see other members %s page?"
msgid "Who can see other members %s page?"
msgstr ""

#: includes/bp-compliments-settings.php:78
msgid "Anybody"
msgstr ""

#: includes/bp-compliments-settings.php:79
msgid "Nobody"
msgstr ""

#: includes/bp-compliments-settings.php:80
msgid "Members Only"
msgstr ""

#: includes/bp-compliments-settings.php:84
#: includes/bp-compliments-settings.php:85
#, php-format
msgid "Members can delete %s received?"
msgstr ""

#: includes/bp-compliments-settings.php:93
#: includes/bp-compliments-settings.php:94
#, php-format
msgid "Enable activity component for %s ?"
msgstr ""

#: includes/bp-compliments-settings.php:102
#: includes/bp-compliments-settings.php:103
#, php-format
msgid "Enable notification component for %s ?"
msgstr ""

#: includes/bp-compliments-settings.php:111
#: includes/bp-compliments-settings.php:112
#, php-format
msgid "Number of %s to display per page?"
msgstr ""

#: includes/bp-compliments-settings.php:115
#: includes/bp-compliments-settings.php:116
msgid "Custom CSS styles"
msgstr ""

Expand Down Expand Up @@ -267,27 +281,27 @@ msgstr ""
msgid "Delete"
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:120
#: includes/templates/buddypress/members/single/compliments.php:122
#, php-format
msgid "1 of 1"
msgid_plural "%1$s to %2$s of %3$s"
msgstr[0] ""
msgstr[1] ""

#: includes/templates/buddypress/members/single/compliments.php:123
#: includes/templates/buddypress/members/single/compliments.php:125
msgid "Go to Page"
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:139
#: includes/templates/buddypress/members/single/compliments.php:141
msgid "You don't have permission to access this page."
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:146
#: includes/templates/buddypress/members/single/compliments.php:148
#, php-format
msgid "Aw, you have no %1$s yet. To get some try sending %1$s to others."
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:152
#: includes/templates/buddypress/members/single/compliments.php:154
#, php-format
msgid "Sorry, no %1$s just yet."
msgstr ""

0 comments on commit 55387c8

Please sign in to comment.