Skip to content

Commit

Permalink
Merge pull request #13 from mistergiri/master
Browse files Browse the repository at this point in the history
Compliments can be renamed to anything Ex: Gifts
  • Loading branch information
NomadDevs authored and NomadDevs committed Aug 13, 2015
2 parents ba53327 + 5b74a3f commit ff3b7d8
Show file tree
Hide file tree
Showing 13 changed files with 266 additions and 221 deletions.
11 changes: 5 additions & 6 deletions bp-compliments-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public function includes( $includes = array() ) {
require( $this->path . '/bp-compliments-classes.php' );
// Functions related to compliment component.
require( $this->path . '/bp-compliments-functions.php' );
// Functions related to compliment types and icons.
require( $this->path . '/bp-compliments-taxonomies.php' );
// Functions related to frontend content display.
require( $this->path . '/bp-compliments-screens.php' );
// Functions related to compliment buttons and template tags.
Expand All @@ -81,6 +79,10 @@ public function includes( $includes = array() ) {
require( $this->path . '/bp-compliments-activity.php' );
// Functions related to compliment forms.
require( $this->path . '/bp-compliments-forms.php' );
// Functions related to compliment settings.
require( $this->path . '/bp-compliments-settings.php' );
// Functions related to compliment types and icons.
require( $this->path . '/bp-compliments-taxonomies.php' );
}

/**
Expand All @@ -95,9 +97,6 @@ public function includes( $includes = array() ) {
public function setup_globals( $args = array() ) {
global $bp;

if ( ! defined( 'BP_COMPLIMENTS_SLUG' ) )
define( 'BP_COMPLIMENTS_SLUG', 'compliments' );

// Set up the $globals array
$globals = array(
'notification_callback' => 'bp_compliments_format_notifications',
Expand Down Expand Up @@ -176,7 +175,7 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
}

bp_core_new_nav_item( array(
'name' => sprintf( __( 'Compliments <span>%d</span>', BP_COMP_TEXTDOMAIN ), $counts['received'] ),
'name' => BP_COMP_PLURAL_NAME." "."<span>".$counts['received']."</span>",
'slug' => $bp->compliments->compliments->slug,
'position' => $this->params['adminbar_myaccount_order'],
'screen_function' => 'bp_compliments_screen_compliments',
Expand Down
7 changes: 7 additions & 0 deletions bp-compliments.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
* BuddyPress compliments text domain.
*/
define( 'BP_COMP_TEXTDOMAIN', 'bp-compliments' );
/**
* BuddyPress compliments names.
*/
define( 'BP_COMP_SINGULAR_NAME', trim(esc_attr( get_option('bp_compliment_singular_name', __( 'Compliment', BP_COMP_TEXTDOMAIN )))) );
define( 'BP_COMP_PLURAL_NAME', trim(esc_attr( get_option('bp_compliment_plural_name', __( 'Compliments', BP_COMP_TEXTDOMAIN )))) );
define( 'BP_COMPLIMENTS_SLUG', strtolower(trim(esc_attr( get_option('bp_compliment_slug', __( 'compliments', BP_COMP_TEXTDOMAIN ))))) );


/**
* Only load the plugin code if BuddyPress is activated.
Expand Down
3 changes: 3 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v0.0.6
Compliments can be renamed to anything Ex: "Gifts" - ADDED

v0.0.5
404 error while sending compliments - FIXED

Expand Down
8 changes: 4 additions & 4 deletions includes/bp-compliments-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ function handle_compliments_form_data() {
$redirect_url = bp_core_get_user_domain($receiver_id);

if ( ! bp_compliments_start_compliment($args)) {
bp_core_add_message( sprintf( __( 'There was a problem when trying to send compliment to %s, please contact administrator.', BP_COMP_TEXTDOMAIN ), $receiver_name ), 'error' );
bp_core_add_message( sprintf( __( 'There was a problem when trying to send %s to %s, please contact administrator.', BP_COMP_TEXTDOMAIN ), strtolower(BP_COMP_SINGULAR_NAME), $receiver_name ), 'error' );
} else {
bp_core_add_message( sprintf( __( 'Your compliment sent to %s.', BP_COMP_TEXTDOMAIN ), $receiver_name ) );
bp_core_add_message( sprintf( __( 'Your %s sent to %s.', BP_COMP_TEXTDOMAIN ), strtolower(BP_COMP_SINGULAR_NAME), $receiver_name ) );
}

$bp_compliment_can_see_others_comp_value = esc_attr( get_option('bp_compliment_can_see_others_comp'));
Expand All @@ -66,7 +66,7 @@ function handle_compliments_form_data() {
}

if ($show_for_displayed_user) {
$redirect = $redirect_url.'compliments/';
$redirect = $redirect_url.BP_COMPLIMENTS_SLUG.'/';
} else {
$redirect = $redirect_url;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ function delete_single_complement() {
*/
do_action( 'bp_compliments_after_remove_compliment', $c_id );

$redirect = bp_displayed_user_domain().'compliments/';
$redirect = bp_displayed_user_domain().BP_COMPLIMENTS_SLUG.'/';
bp_core_redirect( $redirect );
}
add_action( 'bp_actions', 'delete_single_complement');
Expand Down
20 changes: 10 additions & 10 deletions includes/bp-compliments-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ function compliments_register_activity_actions() {
bp_activity_set_action(
$bp->compliments->id,
'compliment_received',
__( 'Compliment Received', BP_COMP_TEXTDOMAIN ),
sprintf( __( '%s Received', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ),
'compliments_format_activity_action_compliment_received',
__( 'Compliments', BP_COMP_TEXTDOMAIN ),
BP_COMP_PLURAL_NAME,
array( 'activity' )
);

bp_activity_set_action(
$bp->compliments->id,
'compliment_sent',
__( 'Compliment Sent', BP_COMP_TEXTDOMAIN ),
sprintf( __( '%s Sent', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ),
'compliments_format_activity_action_compliment_sent',
__( 'Compliments', BP_COMP_TEXTDOMAIN ),
BP_COMP_PLURAL_NAME,
array( 'activity' )
);

Expand Down Expand Up @@ -144,8 +144,8 @@ function compliments_format_activity_action_compliment_received( $action, $activ
$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 = '<a href="'.$compliment_url.'">'.__("compliment", BP_COMP_TEXTDOMAIN).'</a>';
$compliment_url = $receiver_url . BP_COMPLIMENTS_SLUG . '/?c_id='.$activity->item_id;
$compliment_link = '<a href="'.$compliment_url.'">'.strtolower(BP_COMP_SINGULAR_NAME).'</a>';

$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';
Expand All @@ -157,7 +157,7 @@ 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_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 );
$action = sprintf( __( '%1$s has received a %2$s from %3$s', BP_COMP_TEXTDOMAIN ), $receiver_link, strtolower(BP_COMP_SINGULAR_NAME), $sender_link );
}


Expand Down Expand Up @@ -188,8 +188,8 @@ function compliments_format_activity_action_compliment_sent( $action, $activity
$sender_link = bp_core_get_userlink( $activity->user_id );
$receiver_link = bp_core_get_userlink( $activity->secondary_item_id );
$receiver_url = bp_core_get_userlink( $activity->secondary_item_id, false, true );
$compliment_url = $receiver_url . $bp->compliments->id . '/?c_id='.$activity->item_id;
$compliment_link = '<a href="'.$compliment_url.'">'.__("compliment", BP_COMP_TEXTDOMAIN).'</a>';
$compliment_url = $receiver_url . BP_COMPLIMENTS_SLUG . '/?c_id='.$activity->item_id;
$compliment_link = '<a href="'.$compliment_url.'">'.strtolower(BP_COMP_SINGULAR_NAME).'</a>';

$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';
Expand All @@ -201,7 +201,7 @@ 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_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 );
$action = sprintf( __( '%1$s has sent a %2$s to %3$s', BP_COMP_TEXTDOMAIN ), $sender_link, strtolower(BP_COMP_SINGULAR_NAME), $receiver_link );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/bp-compliments-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0) {
<div class="comp-modal">
<div class="comp-modal-content-wrap">
<div class="comp-modal-title">
<h2><?php echo __( 'Choose Your Compliment Type:', BP_COMP_TEXTDOMAIN ); ?></h2>
<h2><?php echo sprintf( __( 'Choose Your %s Type:', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ); ?></h2>
</div>
<div class="comp-modal-content">
<form action="" method="post">
Expand Down
12 changes: 6 additions & 6 deletions includes/bp-compliments-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function bp_compliments_format_notifications( $action, $item_id, $secondary_item
$text = false;

if ( 1 == $total_items ) {
$text = sprintf( __( '%s has sent you a compliment', BP_COMP_TEXTDOMAIN ), bp_core_get_user_displayname( $item_id ) );
$text = sprintf( __( '%s has sent you a %s', BP_COMP_TEXTDOMAIN ), bp_core_get_user_displayname( $item_id ), strtolower(BP_COMP_SINGULAR_NAME) );
$link = bp_core_get_user_domain( $bp->loggedin_user->id ) .BP_COMPLIMENTS_SLUG. '/?bpc_read=true&bpc_sender_id='.$item_id;
}
break;
Expand Down Expand Up @@ -182,12 +182,12 @@ function bp_compliments_new_compliment_email_notification() {
// Set up and send the message
$to = $receiver_ud->user_email;

$subject = '[' . wp_specialchars_decode( bp_get_option( 'blogname' ), ENT_QUOTES ) . '] ' . sprintf( __( '%s has sent you a compliment', BP_COMP_TEXTDOMAIN ), $sender_name );
$subject = '[' . wp_specialchars_decode( bp_get_option( 'blogname' ), ENT_QUOTES ) . '] ' . sprintf( __( '%s has sent you a %s', BP_COMP_TEXTDOMAIN ), $sender_name, strtolower(BP_COMP_SINGULAR_NAME) );

$message = sprintf( __(
'%s has sent you a compliment.
'%s has sent you a %s.
To view %s\'s compliment: %s', BP_COMP_TEXTDOMAIN ), $sender_name, $sender_name, $compliment_link );
To view %s\'s %s: %s', BP_COMP_TEXTDOMAIN ), $sender_name, strtolower(BP_COMP_SINGULAR_NAME), $sender_name, strtolower(BP_COMP_SINGULAR_NAME), $compliment_link );

// Add notifications link if settings component is enabled
if ( bp_is_active( 'settings' ) ) {
Expand Down Expand Up @@ -274,7 +274,7 @@ function bp_compliments_screen_notification_settings() {
<thead>
<tr>
<th class="icon"></th>
<th class="title"><?php _e( 'Compliments', BP_COMP_TEXTDOMAIN ) ?></th>
<th class="title"><?php echo BP_COMP_PLURAL_NAME; ?></th>
<th class="yes"><?php _e( 'Yes', BP_COMP_TEXTDOMAIN ) ?></th>
<th class="no"><?php _e( 'No', BP_COMP_TEXTDOMAIN )?></th>
</tr>
Expand All @@ -283,7 +283,7 @@ function bp_compliments_screen_notification_settings() {
<tbody>
<tr>
<td></td>
<td><?php _e( 'A member sends you a compliment', BP_COMP_TEXTDOMAIN ) ?></td>
<td><?php echo sprintf( __( 'A member sends you a %s', BP_COMP_TEXTDOMAIN ), strtolower(BP_COMP_SINGULAR_NAME)); ?></td>
<td class="yes"><input type="radio" name="notifications[notification_on_compliments]" value="yes" <?php checked( $notify, 'yes', true ) ?>/></td>
<td class="no"><input type="radio" name="notifications[notification_on_compliments]" value="no" <?php checked( $notify, 'no', true ) ?>/></td>
</tr>
Expand Down
100 changes: 100 additions & 0 deletions includes/bp-compliments-settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php
add_action('admin_menu', 'register_compliments_menu_page');

/**
* Register Compliments menu below Settings menu.
*
* @since 0.0.1
* @package BuddyPress_Compliments
*/
function register_compliments_menu_page() {
add_menu_page(
BP_COMP_PLURAL_NAME,
BP_COMP_PLURAL_NAME,
'manage_options',
'bp-compliment-settings',
'bp_compliments_settings_page',
plugins_url( 'buddypress-compliments/images/smiley-icon.png' ),
85
);
}

add_action( 'admin_init', 'bp_compliments_register_settings' );
function bp_compliments_register_settings() {
register_setting( 'bp-compliment-settings', 'bp_compliment_singular_name' );
register_setting( 'bp-compliment-settings', 'bp_compliment_plural_name' );
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_comp_per_page' );
register_setting( 'bp-compliment-settings', 'bp_comp_custom_css' );
}

function bp_compliments_settings_page() {
?>
<div class="wrap">
<h2><?php echo sprintf( __( 'BuddyPress %s - Settings', BP_COMP_TEXTDOMAIN ), BP_COMP_PLURAL_NAME ); ?></h2>
<form method="post" action="options.php">
<?php settings_fields( 'bp-compliment-settings' ); ?>
<?php do_settings_sections( 'bp-compliment-settings' );

$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';

$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';

$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;

$comp_custom_css_value = esc_attr( get_option('bp_comp_custom_css'));
$comp_custom_css = $comp_custom_css_value ? $comp_custom_css_value : '';
?>
<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>
<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>
<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>
<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_COMP_TEXTDOMAIN ), 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_COMP_TEXTDOMAIN ); ?></option>
<option value="no" <?php selected( $bp_compliment_can_see_others_comp, 'no' ); ?>><?php echo __( 'No', BP_COMP_TEXTDOMAIN ); ?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo sprintf( __( 'Members can delete %s received?', BP_COMP_TEXTDOMAIN ), strtolower(BP_COMP_PLURAL_NAME) ); ?></th>
<td>
<select id="bp_compliment_can_delete" name="bp_compliment_can_delete">
<option value="yes" <?php selected( $bp_compliment_can_delete, 'yes' ); ?>><?php echo __( 'Yes', BP_COMP_TEXTDOMAIN ); ?></option>
<option value="no" <?php selected( $bp_compliment_can_delete, '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>
</tr>
<tr valign="top">
<th scope="row"><?php echo __( 'Custom CSS styles', BP_COMP_TEXTDOMAIN ); ?></th>
<td><textarea class="widefat" rows="5" name="bp_comp_custom_css"><?php echo $comp_custom_css; ?></textarea></td>
</tr>
<tr valign="top">
<th></th>
<td><?php submit_button(null, 'primary','submit',false); ?></td>
</tr>
</table>

</form>
</div>
<?php }
Loading

0 comments on commit ff3b7d8

Please sign in to comment.