From 52c9499f2a8b8578ef3584080a8e0163b89b6c85 Mon Sep 17 00:00:00 2001 From: Giri Date: Wed, 12 Aug 2015 20:46:13 +0530 Subject: [PATCH 1/2] Compliments can be renamed to anything Ex: Gifts --- bp-compliments-core.php | 11 +- bp-compliments.php | 7 + change_log.txt | 3 + includes/bp-compliments-actions.php | 8 +- includes/bp-compliments-activity.php | 20 +- includes/bp-compliments-forms.php | 2 +- includes/bp-compliments-notifications.php | 12 +- includes/bp-compliments-settings.php | 100 ++++++++ includes/bp-compliments-taxonomies.php | 105 ++------ includes/bp-compliments-templatetags.php | 2 +- .../buddypress/members/single/compliments.php | 4 +- languages/bp-compliments-en_US.mo | Bin 522 -> 522 bytes languages/bp-compliments-en_US.po | 229 +++++++++--------- 13 files changed, 274 insertions(+), 229 deletions(-) create mode 100644 includes/bp-compliments-settings.php diff --git a/bp-compliments-core.php b/bp-compliments-core.php index f458d95..ab40e5b 100644 --- a/bp-compliments-core.php +++ b/bp-compliments-core.php @@ -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. @@ -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' ); } /** @@ -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', @@ -176,7 +175,7 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) { } bp_core_new_nav_item( array( - 'name' => sprintf( __( 'Compliments %d', BP_COMP_TEXTDOMAIN ), $counts['received'] ), + 'name' => BP_COMP_PLURAL_NAME." "."".$counts['received']."", 'slug' => $bp->compliments->compliments->slug, 'position' => $this->params['adminbar_myaccount_order'], 'screen_function' => 'bp_compliments_screen_compliments', diff --git a/bp-compliments.php b/bp-compliments.php index c604c71..d4e3efa 100644 --- a/bp-compliments.php +++ b/bp-compliments.php @@ -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. diff --git a/change_log.txt b/change_log.txt index b0b1749..4a4592f 100644 --- a/change_log.txt +++ b/change_log.txt @@ -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 diff --git a/includes/bp-compliments-actions.php b/includes/bp-compliments-actions.php index 6ee5735..04cdfbc 100644 --- a/includes/bp-compliments-actions.php +++ b/includes/bp-compliments-actions.php @@ -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')); @@ -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; } @@ -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'); diff --git a/includes/bp-compliments-activity.php b/includes/bp-compliments-activity.php index 9b57ed6..7687648 100644 --- a/includes/bp-compliments-activity.php +++ b/includes/bp-compliments-activity.php @@ -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' ) ); @@ -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 = ''.__("compliment", BP_COMP_TEXTDOMAIN).''; + $compliment_url = $receiver_url . BP_COMPLIMENTS_SLUG . '/?c_id='.$activity->item_id; + $compliment_link = ''.strtolower(BP_COMP_SINGULAR_NAME).''; $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'; @@ -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 ); } @@ -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 = ''.__("compliment", BP_COMP_TEXTDOMAIN).''; + $compliment_url = $receiver_url . BP_COMPLIMENTS_SLUG . '/?c_id='.$activity->item_id; + $compliment_link = ''.strtolower(BP_COMP_SINGULAR_NAME).''; $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'; @@ -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 ); } /** diff --git a/includes/bp-compliments-forms.php b/includes/bp-compliments-forms.php index 2bcfba0..a979bd1 100644 --- a/includes/bp-compliments-forms.php +++ b/includes/bp-compliments-forms.php @@ -23,7 +23,7 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0) {
-

+

diff --git a/includes/bp-compliments-notifications.php b/includes/bp-compliments-notifications.php index 417822e..7454492 100644 --- a/includes/bp-compliments-notifications.php +++ b/includes/bp-compliments-notifications.php @@ -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; @@ -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' ) ) { @@ -274,7 +274,7 @@ function bp_compliments_screen_notification_settings() { - + @@ -283,7 +283,7 @@ function bp_compliments_screen_notification_settings() { - + /> /> diff --git a/includes/bp-compliments-settings.php b/includes/bp-compliments-settings.php new file mode 100644 index 0000000..170ca08 --- /dev/null +++ b/includes/bp-compliments-settings.php @@ -0,0 +1,100 @@ + +
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + +
+ _x( 'Compliments', 'taxonomy general name', BP_COMP_TEXTDOMAIN ), - 'singular_name' => _x( 'Compliment', 'taxonomy singular name', BP_COMP_TEXTDOMAIN ), - 'search_items' => __( 'Search Compliments', BP_COMP_TEXTDOMAIN ), - 'all_items' => __( 'All Compliments', BP_COMP_TEXTDOMAIN ), - 'parent_item' => __( 'Parent Compliment', BP_COMP_TEXTDOMAIN ), - 'parent_item_colon' => __( 'Parent Compliment:', BP_COMP_TEXTDOMAIN ), - 'edit_item' => __( 'Edit Compliment', BP_COMP_TEXTDOMAIN ), - 'update_item' => __( 'Update Compliment', BP_COMP_TEXTDOMAIN ), - 'add_new_item' => __( 'Add New Compliment', BP_COMP_TEXTDOMAIN ), - 'new_item_name' => __( 'New Compliment Name', BP_COMP_TEXTDOMAIN ), - 'menu_name' => __( 'Compliment', BP_COMP_TEXTDOMAIN ), + 'name' => BP_COMP_PLURAL_NAME, + 'singular_name' => BP_COMP_SINGULAR_NAME, + 'search_items' => sprintf( __( 'Search %s', BP_COMP_TEXTDOMAIN ), BP_COMP_PLURAL_NAME ), + 'all_items' => sprintf( __( 'All %s', BP_COMP_TEXTDOMAIN ), BP_COMP_PLURAL_NAME ), + 'parent_item' => sprintf( __( 'Parent %s', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ), + 'parent_item_colon' => sprintf( __( 'Parent %s:', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ), + 'edit_item' => sprintf( __( 'Edit %s', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ), + 'update_item' => sprintf( __( 'Update %s', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ), + 'add_new_item' => sprintf( __( 'Add New %s', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ), + 'new_item_name' => sprintf( __( 'New %s Name', BP_COMP_TEXTDOMAIN ), BP_COMP_SINGULAR_NAME ), + 'menu_name' => BP_COMP_SINGULAR_NAME, ); $args = array( @@ -93,7 +84,7 @@ function compliments_enqueue_admin_js( $hook_suffix ) { function compliments_taxonomy_add_new_meta_field() { ?>
- +
@@ -117,7 +108,7 @@ function compliments_taxonomy_edit_meta_field($term) { $t_id = $term->term_id; $term_meta = get_option( "taxonomy_$t_id" ); ?> - + @@ -234,72 +225,6 @@ function compliment_remove_parent_dropdown() -
-

- -
- - - - - - - - - - - - - - - - - - - - - - - -
- -
- -
- -
-
-