diff --git a/change_log.txt b/change_log.txt index 02c7329..133f5ee 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,7 @@ v1.0.1 Use singular name instead of slug name - FIXED +Admin can delete compliments - ADDED +404 page when deleting compliments - FIXED v1.0.0 Compliment message uses slug name instead of singular name - FIXED diff --git a/includes/bp-compliments-actions.php b/includes/bp-compliments-actions.php index 2634815..2ad1d4b 100644 --- a/includes/bp-compliments-actions.php +++ b/includes/bp-compliments-actions.php @@ -93,8 +93,10 @@ function delete_single_complement() { return; } - if ( bp_displayed_user_id() != bp_loggedin_user_id() ) { - return; + if (!current_user_can( 'manage_options' )) { + if ( bp_displayed_user_id() != bp_loggedin_user_id() ) { + return; + } } if (!isset($_GET['c_id']) OR !isset($_GET['action']) ) { @@ -104,6 +106,10 @@ function delete_single_complement() { $bp_compliment_can_delete_value = esc_attr( get_option('bp_compliment_can_delete')); $bp_compliment_can_delete = $bp_compliment_can_delete_value ? $bp_compliment_can_delete_value : 'yes'; + if (current_user_can( 'manage_options' )) { + $bp_compliment_can_delete = 'yes'; + } + if ($bp_compliment_can_delete == 'no') { return; } diff --git a/includes/templates/buddypress/members/single/compliments.php b/includes/templates/buddypress/members/single/compliments.php index af2a03f..33383be 100644 --- a/includes/templates/buddypress/members/single/compliments.php +++ b/includes/templates/buddypress/members/single/compliments.php @@ -81,9 +81,14 @@ class='preview-upload'/> global $bp; $bp_compliment_can_delete_value = esc_attr( get_option('bp_compliment_can_delete')); $bp_compliment_can_delete = $bp_compliment_can_delete_value ? $bp_compliment_can_delete_value : 'yes'; - if (is_user_logged_in() && ($bp->loggedin_user->id == $bp->displayed_user->id) && ($bp_compliment_can_delete != 'no')) { + + if (current_user_can( 'manage_options' )) { + $bp_compliment_can_delete = 'yes'; + } + + if (is_user_logged_in() && (($bp->loggedin_user->id == $bp->displayed_user->id) || current_user_can( 'manage_options' )) && ($bp_compliment_can_delete == 'yes')) { $receiver_url = bp_core_get_userlink( $comp->receiver_id, false, true ); - $compliment_url = $receiver_url . $bp->compliments->id . '/?c_id='.$comp->id.'&action=delete'; + $compliment_url = $receiver_url . BP_COMPLIMENTS_SLUG . '/?c_id='.$comp->id.'&action=delete'; ?> diff --git a/languages/bp-compliments-en_US.mo b/languages/bp-compliments-en_US.mo index cceaae8..550dd80 100644 Binary files a/languages/bp-compliments-en_US.mo and b/languages/bp-compliments-en_US.mo differ diff --git a/languages/bp-compliments-en_US.po b/languages/bp-compliments-en_US.po index 9f9430c..262cc3c 100644 --- a/languages/bp-compliments-en_US.po +++ b/languages/bp-compliments-en_US.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: BuddyPress Compliments 1.0.1\n" -"POT-Creation-Date: 2015-11-09 20:08-0000\n" -"PO-Revision-Date: 2015-11-09 20:08-0000\n" +"POT-Creation-Date: 2015-11-10 15:37-0000\n" +"PO-Revision-Date: 2015-11-10 15:37-0000\n" "Last-Translator: \n" "Language-Team: GeoDirectory \n" "Language: en_US\n" @@ -277,31 +277,31 @@ msgstr "" msgid "Send %s" msgstr "" -#: includes/templates/buddypress/members/single/compliments.php:88 +#: includes/templates/buddypress/members/single/compliments.php:93 msgid "Delete" msgstr "" -#: includes/templates/buddypress/members/single/compliments.php:122 +#: includes/templates/buddypress/members/single/compliments.php:127 #, 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:125 +#: includes/templates/buddypress/members/single/compliments.php:130 msgid "Go to Page" msgstr "" -#: includes/templates/buddypress/members/single/compliments.php:141 +#: includes/templates/buddypress/members/single/compliments.php:146 msgid "You don't have permission to access this page." msgstr "" -#: includes/templates/buddypress/members/single/compliments.php:148 +#: includes/templates/buddypress/members/single/compliments.php:153 #, 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:154 +#: includes/templates/buddypress/members/single/compliments.php:159 #, php-format msgid "Sorry, no %1$s just yet." msgstr ""