From d85fa1a73e6f577f21dfabf89a470eb77253b984 Mon Sep 17 00:00:00 2001 From: Giri Dhar Date: Fri, 19 Feb 2016 14:28:36 +0530 Subject: [PATCH 1/2] category support removed --- change_log.txt | 1 - css/bp-compliments.css | 50 +----- includes/bp-compliments-forms.php | 73 +------- includes/bp-compliments-settings.php | 13 -- includes/bp-compliments-taxonomies.php | 228 ------------------------- 5 files changed, 3 insertions(+), 362 deletions(-) diff --git a/change_log.txt b/change_log.txt index 339161f..58119ba 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,4 @@ v1.0.2 -Category support added for compliments - ADDED Compliment user settings page - ADDED v1.0.1 diff --git a/css/bp-compliments.css b/css/bp-compliments.css index 2a71d42..200bad3 100644 --- a/css/bp-compliments.css +++ b/css/bp-compliments.css @@ -176,52 +176,4 @@ width: 32px; height: 32px; margin: 0 auto; -} - -.comp-modal-category { - border-bottom: 1px solid #ddd; - list-style-type: none; - font-size: 14px; -} - -.comp-modal-category > li { - float: left; - margin-bottom: -1px; -} - -.comp-modal-category > li > a { - position: relative; - display: block; - padding: 10px 15px; - margin-right: 2px; - line-height: 1.42857143; - border: 1px solid transparent; - border-radius: 4px 4px 0 0; -} - -.comp-modal-category > li > a:hover { - border-color: #eee #eee #ddd; -} - -.comp-modal-category > li.selected > a, -.comp-modal-category > li.selected > a:hover, -.comp-modal-category > li.selected > a:focus { - color: #555; - cursor: default; - background-color: #fff; - border: 1px solid #ddd; - border-bottom-color: transparent; - opacity: 1; - font-weight: normal; -} - -.comp-modal-category:before, -.comp-modal-category:after { - display: table; - content: ""; - line-height: 0; -} - -.comp-modal-category:after { - clear: both; -} +} \ No newline at end of file diff --git a/includes/bp-compliments-forms.php b/includes/bp-compliments-forms.php index f747008..a6328c1 100644 --- a/includes/bp-compliments-forms.php +++ b/includes/bp-compliments-forms.php @@ -14,9 +14,8 @@ * * @param int $pid The post ID. * @param int $receiver_id Compliment receiver ID. - * @param int $category_id Compliment category ID. */ -function bp_compliments_modal_form($pid = 0, $receiver_id = 0, $category_id = 0) { +function bp_compliments_modal_form($pid = 0, $receiver_id = 0 ) { if (!$receiver_id && bp_displayed_user_id()) { $receiver_id = bp_displayed_user_id(); } @@ -27,56 +26,12 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0, $category_id = 0)

- 'name', - 'hide_empty' => 0, - ); - $cat_terms = get_terms('compliment_category', $cat_args); - $output = ""; - echo $output; - } - ?>
false, 'orderby' => 'id' ); - if ($category_id) { - $cat_meta = get_option("taxonomy_$category_id"); - if ($cat_meta) { - $cat_ids = array(); - foreach ($cat_meta as $id) { - $cat_ids[] = (int) $id; - } - $args['include'] = $cat_ids; - } - } $terms = get_terms( 'compliment', $args ); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ echo '
    '; @@ -98,7 +53,6 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0, $category_id = 0) '; - $ajax_nonce = wp_create_nonce("bp-compliments-nonce"); ?> @@ -118,23 +72,6 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0, $category_id = 0) container.replaceWith(""); mod_shadow.hide(); }); - jQuery('a.comp-modal-category-cat').click(function (e) { - e.preventDefault(); - var mod_shadow = jQuery('#bp_compliments_modal_shadow'); - var container = jQuery('.comp-modal'); - container.html("
    "); - var category_id = jQuery(this).data('catid'); - mod_shadow.show(); - var data = { - 'action': 'bp_compliments_modal_ajax', - 'bp_compliments_nonce': '', - 'category_id': category_id - }; - - jQuery.post('', data, function (response) { - container.replaceWith(response); - }); - }); }); - - - - - - diff --git a/includes/bp-compliments-taxonomies.php b/includes/bp-compliments-taxonomies.php index 0d1d771..4e07df7 100644 --- a/includes/bp-compliments-taxonomies.php +++ b/includes/bp-compliments-taxonomies.php @@ -23,19 +23,6 @@ function register_compliments_submenu_page() { 'edit-tags.php?taxonomy=compliment' ); - $bp_compliment_enable_categories_value = esc_attr( get_option('bp_compliment_enable_categories')); - $bp_compliment_enable_categories = $bp_compliment_enable_categories_value ? $bp_compliment_enable_categories_value : 'no'; - - if ($bp_compliment_enable_categories == 'yes') { - add_submenu_page( - 'bp-compliment-settings', - __( 'Categories', 'bp-compliments' ), - __( 'Categories', 'bp-compliments' ), - 'manage_options', - 'edit-tags.php?taxonomy=compliment_category' - ); - } - } // hook into the init action and call create_book_taxonomies when it fires add_action( 'init', 'create_compliment_taxonomies', 0 ); @@ -73,36 +60,6 @@ function create_compliment_taxonomies() { register_taxonomy( 'compliment', array(), $args ); - // Add new taxonomy, make it hierarchical (like categories) - $cat_labels = array( - 'name' => 'Categories', - 'singular_name' => 'Category', - 'search_items' => __( 'Search Categories', 'bp-compliments' ), - 'all_items' => __( 'All Categories', 'bp-compliments' ), - 'parent_item' => __( 'Parent Category', 'bp-compliments' ), - 'parent_item_colon' => __( 'Parent Category:', 'bp-compliments' ), - 'edit_item' => __( 'Edit Category', 'bp-compliments' ), - 'update_item' => __( 'Update Category', 'bp-compliments' ), - 'add_new_item' => __( 'Add New Category', 'bp-compliments' ), - 'new_item_name' => __( 'New Category Name', 'bp-compliments' ), - 'menu_name' => 'Category', - ); - - $cat_args = array( - 'hierarchical' => true, - 'labels' => $cat_labels, - 'show_ui' => true, - 'show_admin_column' => true, - 'query_var' => true, - 'rewrite' => array( 'slug' => 'compliment_category' ), - ); - - $bp_compliment_enable_categories_value = esc_attr( get_option('bp_compliment_enable_categories')); - $bp_compliment_enable_categories = $bp_compliment_enable_categories_value ? $bp_compliment_enable_categories_value : 'no'; - - if ($bp_compliment_enable_categories == 'yes') { - register_taxonomy( 'compliment_category', array(), $cat_args ); - } } //compliment icons @@ -128,34 +85,6 @@ function compliments_enqueue_admin_js( $hook_suffix ) { */ function compliments_taxonomy_add_new_meta_field() { ?> - -
    - 'name', - 'hide_empty' => 0, - ); - $terms = get_terms( 'compliment_category', $cat_args ); - ?> - - "; - $output .= ""; - foreach($terms as $term){ - $term_id = $term->term_id; - $term_name =$term->name; - $output .= ""; - } - $output .= ""; - echo $output; - ?> -
    -

    @@ -181,41 +110,6 @@ function compliments_taxonomy_edit_meta_field($term) { $t_id = $term->term_id; $term_meta = get_option( "taxonomy_$t_id" ); ?> - - - 'name', - 'hide_empty' => 0, - ); - $terms = get_terms( 'compliment_category', $cat_args ); - ?> - - - "; - $output .= ""; - foreach($terms as $term){ - $term_id = $term->term_id; - $term_name =$term->name; - $output .= ""; - } - $output .= ""; - echo $output; - ?> - - - @@ -252,23 +146,6 @@ function save_taxonomy_custom_meta( $term_id ) { } } - $bp_compliment_enable_categories_value = esc_attr( get_option('bp_compliment_enable_categories')); - $bp_compliment_enable_categories = $bp_compliment_enable_categories_value ? $bp_compliment_enable_categories_value : 'no'; - - if ($bp_compliment_enable_categories == 'yes') { - $cat_id = $_POST['term_meta']['compliments_category']; - //save the cat id - if ($cat_id) { - $t_id = (int)$t_id; - $cat_meta = get_option("taxonomy_$cat_id"); - if (!$cat_meta) { - $cat_meta = array(); - } - $cat_meta[$t_id] = $t_id; - update_option("taxonomy_$cat_id", $cat_meta); - } - } - // Save the option array. update_option( "taxonomy_$t_id", $term_meta ); } @@ -293,13 +170,6 @@ function modify_compliment_columns($columns) { 'icon' => __('Icon', 'bp-compliments'), ); - $bp_compliment_enable_categories_value = esc_attr( get_option('bp_compliment_enable_categories')); - $bp_compliment_enable_categories = $bp_compliment_enable_categories_value ? $bp_compliment_enable_categories_value : 'no'; - - if ($bp_compliment_enable_categories == 'yes') { - $new_columns['category'] = __('Category', 'bp-compliments'); - } - return $new_columns; } @@ -318,17 +188,11 @@ function modify_compliment_columns($columns) { function manage_bp_compliment_columns($out, $column_name, $t_id) { $term_meta = get_option( "taxonomy_$t_id" ); $term_icon = esc_attr( $term_meta['compliments_icon'] ) ? esc_attr( $term_meta['compliments_icon'] ) : ""; - $term_category = esc_attr( $term_meta['compliments_category'] ) ? esc_attr( $term_meta['compliments_category'] ) : ""; switch ($column_name) { case 'icon': $out .= ''; break; - case 'category': - $term = get_term_by('id', $term_category, 'compliment_category'); - $out .= $term->name; - break; - default: break; } @@ -399,95 +263,3 @@ function bp_comp_custom_css() { $value) { - $icon_meta = get_option("taxonomy_$icon_id"); - if ($icon_meta && is_array($icon_meta)) { - $icon_meta['compliments_category'] = ''; - update_option("taxonomy_$icon_id", $icon_meta); - } - } - } - } - - if ($taxonomy == 'compliment') { - $t_id = $term; - $term_meta = get_option("taxonomy_$t_id"); - if ($term_meta) { - $cat_id = $term_meta['compliments_category']; - if ($cat_id) { - $cat_id = (int) $cat_id; - $cat_meta = get_option("taxonomy_$cat_id"); - if ($cat_meta) { - unset($cat_meta[$t_id]); - update_option("taxonomy_$cat_id", $cat_meta); - } - } - } - } -} -add_action('pre_delete_term', 'bp_comp_delete_category', 10, 2); - -add_filter("manage_edit-compliment_category_columns", 'modify_compliment_category_columns'); -/** - * Modify compliment category page admin columns. - * - * @since 0.0.1 - * @package BuddyPress_Compliments - * - * @param array $columns The column array. - * @return array Modified column array. - */ -function modify_compliment_category_columns($columns) { - - unset($columns['posts']); - $columns['item_count'] = __('Count', 'bp-compliments'); - - return $columns; -} - -add_filter("manage_compliment_category_custom_column", 'manage_bp_compliment_category_columns', 10, 3); -/** - * Modify compliment category page admin column content. - * - * @since 0.0.1 - * @package BuddyPress_Compliments - * - * @param string $out The html output. - * @param string $column_name The column name. - * @param int $t_id The term ID. - * @return string The modified html output. - */ -function manage_bp_compliment_category_columns($out, $column_name, $t_id) { - $term_meta = get_option( "taxonomy_$t_id" ); - switch ($column_name) { - case 'item_count': - if ($term_meta && is_array($term_meta)) { - $out .= count($term_meta); - } else { - $out .= "0"; - } - break; - - default: - break; - } - return $out; -} - -add_action('admin_head', 'hide_bp_comp_category_parent_field'); -function hide_bp_comp_category_parent_field() { - ?> - - Date: Fri, 19 Feb 2016 15:39:32 +0530 Subject: [PATCH 2/2] Compliments message links are clickable --- change_log.txt | 2 ++ includes/bp-compliments-notifications.php | 4 ++-- includes/templates/buddypress/members/single/compliments.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/change_log.txt b/change_log.txt index 58119ba..d3cb323 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,7 @@ v1.0.2 Compliment user settings page - ADDED +Linebreaks are removed on compliment messages - FIXED +Compliments message links are clickable - ADDED v1.0.1 Use singular name instead of slug name - FIXED diff --git a/includes/bp-compliments-notifications.php b/includes/bp-compliments-notifications.php index 42340e0..c0493a1 100644 --- a/includes/bp-compliments-notifications.php +++ b/includes/bp-compliments-notifications.php @@ -185,12 +185,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 %s', 'bp-compliments' ), $sender_name, strtolower(BP_COMP_SINGULAR_NAME) ); + $subject = '[' . wp_specialchars_decode( bp_get_option( 'blogname' ), ENT_QUOTES ) . '] ' . sprintf( __( '%s has sent you a %s', 'bp-compliments' ), $sender_name, BP_COMP_SINGULAR_NAME ); $message = sprintf( __( '%s has sent you a %s. -To view %s\'s %s: %s', 'bp-compliments' ), $sender_name, strtolower(BP_COMP_SINGULAR_NAME), $sender_name, strtolower(BP_COMP_SINGULAR_NAME), $compliment_link ); +To view %s\'s %s: %s', 'bp-compliments' ), $sender_name, BP_COMP_SINGULAR_NAME, $sender_name, BP_COMP_SINGULAR_NAME, $compliment_link ); // Add notifications link if settings component is enabled if ( bp_is_active( 'settings' ) ) { diff --git a/includes/templates/buddypress/members/single/compliments.php b/includes/templates/buddypress/members/single/compliments.php index bb01f3a..7501664 100644 --- a/includes/templates/buddypress/members/single/compliments.php +++ b/includes/templates/buddypress/members/single/compliments.php @@ -118,7 +118,7 @@ class='preview-upload'/>
message); ?> + echo make_clickable(apply_filters('the_content', $comp->message)); ?>