Skip to content

Commit

Permalink
Merge pull request #14 from mistergiri/master
Browse files Browse the repository at this point in the history
Settings added to enable/disable components
  • Loading branch information
NomadDevs authored and NomadDevs committed Aug 25, 2015
2 parents 3cf90bd + f3289c2 commit bddbc6e
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 27 deletions.
14 changes: 12 additions & 2 deletions bp-compliments-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public function __construct() {
* @package BuddyPress_Compliments
*/
public function includes( $includes = array() ) {
$bp_compliment_enable_activity_value = esc_attr( get_option('bp_compliment_enable_activity'));
$bp_compliment_enable_activity = $bp_compliment_enable_activity_value ? $bp_compliment_enable_activity_value : 'yes';

$bp_compliment_enable_notifications_value = esc_attr( get_option('bp_compliment_enable_notifications'));
$bp_compliment_enable_notifications = $bp_compliment_enable_notifications_value ? $bp_compliment_enable_notifications_value : 'yes';

// Include the Class that interact with the custom db table.
require( $this->path . '/bp-compliments-classes.php' );
// Functions related to compliment component.
Expand All @@ -74,9 +80,13 @@ public function includes( $includes = array() ) {
// Functions related to handling user submitted data and actions.
require( $this->path . '/bp-compliments-actions.php' );
// Functions related to notification component.
require( $this->path . '/bp-compliments-notifications.php' );
if ($bp_compliment_enable_notifications == 'yes') {
require( $this->path . '/bp-compliments-notifications.php' );
}
// Functions related to activity component.
require( $this->path . '/bp-compliments-activity.php' );
if ($bp_compliment_enable_activity == 'yes') {
require( $this->path . '/bp-compliments-activity.php' );
}
// Functions related to compliment forms.
require( $this->path . '/bp-compliments-forms.php' );
// Functions related to compliment settings.
Expand Down
7 changes: 7 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.0.8
Option added to enable/disable activity component - ADDED
Option added to enable/disable notifications component - ADDED
Added placeholder text to message textarea - ADDED
Compliments in activity dropdown filter is ambiguous - FIXED
Undefined property ID notice - FIXED

v0.0.7
Compliments can be renamed to anything Ex: "Gifts" - ADDED

Expand Down
28 changes: 25 additions & 3 deletions includes/bp-compliments-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function compliments_format_activity_action_compliment_received( $action, $activ
$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) {
if (bp_is_user() && ($bp->loggedin_user->id == $bp->displayed_user->id)) {
$bp_compliment_can_see_others_comp = 'yes';
}

Expand Down Expand Up @@ -194,7 +194,7 @@ function compliments_format_activity_action_compliment_sent( $action, $activity
$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) {
if (bp_is_user() && ($bp->loggedin_user->id == $bp->displayed_user->id)) {
$bp_compliment_can_see_others_comp = 'yes';
}

Expand Down Expand Up @@ -259,4 +259,26 @@ function compliments_delete_activity_for_user( $user_id ) {
'secondary_item_id' => $user_id
) );
}
add_action('bp_compliments_after_remove_data', 'compliments_delete_activity_for_user');
add_action('bp_compliments_after_remove_data', 'compliments_delete_activity_for_user');

/**
* Compliment activity collapses two filters into one
*
* @since 0.0.8
* @package BuddyPress_Compliments
*
* @param array $filters Array of filter options for the given context, in the following format: $option_value => $option_name.
* @param string $context Context for the filter. 'activity', 'member', 'member_groups', 'group'.
*
* @return array
*/
function compliments_merge_filter( $filters, $context ){
if (array_key_exists('compliment_sent', $filters) && array_key_exists('compliment_received', $filters)) {
$label = $filters['compliment_sent'];
unset($filters['compliment_sent']);
unset($filters['compliment_received']);
$filters['compliment_sent,compliment_received'] = $label;
}
return $filters;
}
add_filter('bp_get_activity_show_filters_options', 'compliments_merge_filter', 10, 2);
2 changes: 1 addition & 1 deletion includes/bp-compliments-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0) {
echo '</ul>';

?>
<textarea name="message" maxchar="1000"></textarea>
<textarea placeholder="<?php echo __( 'Type your message here', BP_COMP_TEXTDOMAIN ); ?>" name="message" maxchar="1000"></textarea>
<input type="hidden" name="post_id" value="<?php echo $pid; ?>"/>
<input type="hidden" name="receiver_id" value="<?php echo $receiver_id; ?>"/>
<?php wp_nonce_field( 'handle_compliments_form_data','handle_compliments_nonce' ); ?>
Expand Down
32 changes: 29 additions & 3 deletions includes/bp-compliments-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function bp_compliments_register_settings() {
register_setting( 'bp-compliment-settings', 'bp_compliment_slug' );
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_compliment_enable_activity' );
register_setting( 'bp-compliment-settings', 'bp_compliment_enable_notifications' );
register_setting( 'bp-compliment-settings', 'bp_comp_per_page' );
register_setting( 'bp-compliment-settings', 'bp_comp_custom_css' );
}
Expand All @@ -44,6 +46,12 @@ function bp_compliments_settings_page() {
$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';

$bp_compliment_enable_activity_value = esc_attr( get_option('bp_compliment_enable_activity'));
$bp_compliment_enable_activity = $bp_compliment_enable_activity_value ? $bp_compliment_enable_activity_value : 'yes';

$bp_compliment_enable_notifications_value = esc_attr( get_option('bp_compliment_enable_notifications'));
$bp_compliment_enable_notifications = $bp_compliment_enable_notifications_value ? $bp_compliment_enable_notifications_value : 'yes';

$comp_per_page_value = esc_attr( get_option('bp_comp_per_page'));
$comp_per_page = $comp_per_page_value ? (int) $comp_per_page_value : 5;

Expand All @@ -52,15 +60,15 @@ function bp_compliments_settings_page() {
?>
<table class="widefat fixed" style="padding:10px;margin-top: 10px;">
<tr valign="top">
<th scope="row"><?php echo __( 'Singlular name ( Ex: Gift. Default: Compliment )', BP_COMP_TEXTDOMAIN ); ?></th>
<th scope="row"><?php echo __( 'Singlular name ( e.g. Gift. Default: Compliment )', BP_COMP_TEXTDOMAIN ); ?></th>
<td><input type="text" class="widefat" name="bp_compliment_singular_name" value="<?php echo BP_COMP_SINGULAR_NAME; ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php echo __( 'Plural name ( Ex: Gifts. Default: Compliments )', BP_COMP_TEXTDOMAIN ); ?></th>
<th scope="row"><?php echo __( 'Plural name ( e.g. Gifts. Default: Compliments )', BP_COMP_TEXTDOMAIN ); ?></th>
<td><input type="text" class="widefat" name="bp_compliment_plural_name" value="<?php echo BP_COMP_PLURAL_NAME; ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php echo __( 'Slug ( Ex: gifts. Default: compliments. must be lowercase )', BP_COMP_TEXTDOMAIN ); ?></th>
<th scope="row"><?php echo __( 'Slug ( e.g. gifts. Default: compliments. must be lowercase )', BP_COMP_TEXTDOMAIN ); ?></th>
<td><input type="text" class="widefat" name="bp_compliment_slug" value="<?php echo BP_COMPLIMENTS_SLUG; ?>" /></td>
</tr>
<tr valign="top">
Expand All @@ -81,6 +89,24 @@ function bp_compliments_settings_page() {
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo sprintf( __( 'Enable activity component for %s ?', BP_COMP_TEXTDOMAIN ), strtolower(BP_COMP_PLURAL_NAME) ); ?></th>
<td>
<select id="bp_compliment_enable_activity" name="bp_compliment_enable_activity">
<option value="yes" <?php selected( $bp_compliment_enable_activity, 'yes' ); ?>><?php echo __( 'Yes', BP_COMP_TEXTDOMAIN ); ?></option>
<option value="no" <?php selected( $bp_compliment_enable_activity, 'no' ); ?>><?php echo __( 'No', BP_COMP_TEXTDOMAIN ); ?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo sprintf( __( 'Enable notification component for %s ?', BP_COMP_TEXTDOMAIN ), strtolower(BP_COMP_PLURAL_NAME) ); ?></th>
<td>
<select id="bp_compliment_enable_notifications" name="bp_compliment_enable_notifications">
<option value="yes" <?php selected( $bp_compliment_enable_notifications, 'yes' ); ?>><?php echo __( 'Yes', BP_COMP_TEXTDOMAIN ); ?></option>
<option value="no" <?php selected( $bp_compliment_enable_notifications, 'no' ); ?>><?php echo __( 'No', BP_COMP_TEXTDOMAIN ); ?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo sprintf( __( 'Number of %s to display per page?', BP_COMP_TEXTDOMAIN ), BP_COMP_PLURAL_NAME ); ?></th>
<td><input type="number" class="widefat" name="bp_comp_per_page" value="<?php echo $comp_per_page; ?>" /></td>
Expand Down
Binary file modified languages/bp-compliments-en_US.mo
Binary file not shown.
54 changes: 36 additions & 18 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.6\n"
"POT-Creation-Date: 2015-08-19 18:11-0000\n"
"PO-Revision-Date: 2015-08-19 18:11-0000\n"
"POT-Creation-Date: 2015-08-22 22:07+0530\n"
"PO-Revision-Date: 2015-08-22 22:07+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 @@ -70,6 +70,10 @@ msgstr ""
msgid "Choose Your %s Type:"
msgstr ""

#: includes/bp-compliments-forms.php:58
msgid "Type your message here"
msgstr ""

#: includes/bp-compliments-forms.php:63
msgid "Send"
msgstr ""
Expand Down Expand Up @@ -103,14 +107,18 @@ msgid ""
msgstr ""

#: includes/bp-compliments-notifications.php:278
#: includes/bp-compliments-settings.php:70
#: includes/bp-compliments-settings.php:79
#: 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:71
#: includes/bp-compliments-settings.php:80
#: includes/bp-compliments-settings.php:79
#: includes/bp-compliments-settings.php:88
#: includes/bp-compliments-settings.php:97
#: includes/bp-compliments-settings.php:106
msgid "No"
msgstr ""

Expand All @@ -119,39 +127,49 @@ msgstr ""
msgid "A member sends you a %s"
msgstr ""

#: includes/bp-compliments-settings.php:36
#: includes/bp-compliments-settings.php:38
#, php-format
msgid "BuddyPress %s - Settings"
msgstr ""

#: includes/bp-compliments-settings.php:55
msgid "Singlular name ( Ex: Gift. Default: Compliment )"
#: includes/bp-compliments-settings.php:63
msgid "Singlular name ( e.g. Gift. Default: Compliment )"
msgstr ""

#: includes/bp-compliments-settings.php:59
msgid "Plural name ( Ex: Gifts. Default: Compliments )"
#: includes/bp-compliments-settings.php:67
msgid "Plural name ( e.g. Gifts. Default: Compliments )"
msgstr ""

#: includes/bp-compliments-settings.php:63
msgid "Slug ( Ex: gifts. Default: compliments. must be lowercase )"
#: includes/bp-compliments-settings.php:71
msgid "Slug ( e.g. gifts. Default: compliments. must be lowercase )"
msgstr ""

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

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

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

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

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

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

Expand Down

0 comments on commit bddbc6e

Please sign in to comment.