Skip to content

Commit

Permalink
category support removed
Browse files Browse the repository at this point in the history
  • Loading branch information
viruthagiri committed Feb 19, 2016
1 parent 82e60f2 commit d85fa1a
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 362 deletions.
1 change: 0 additions & 1 deletion change_log.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
v1.0.2
Category support added for compliments - ADDED
Compliment user settings page - ADDED

v1.0.1
Expand Down
50 changes: 1 addition & 49 deletions css/bp-compliments.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
73 changes: 2 additions & 71 deletions includes/bp-compliments-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -27,56 +26,12 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0, $category_id = 0)
<h2><?php echo sprintf( __( 'Choose Your %s Type:', 'bp-compliments' ), BP_COMP_SINGULAR_NAME ); ?></h2>
</div>
<div class="comp-modal-content">
<?php
$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_args = array(
'orderby' => 'name',
'hide_empty' => 0,
);
$cat_terms = get_terms('compliment_category', $cat_args);
$output = "<ul class='comp-modal-category'>";
$count = 0;
foreach ($cat_terms as $cat_term) {
$count++;
$cat_term_id = $cat_term->term_id;
$cat_term_meta = get_option("taxonomy_$cat_term_id");
if ($cat_term_meta) {
$cat_term_name = $cat_term->name;
if ($count == 1 && !$category_id) {
$output .= "<li class='selected'>";
$category_id = $cat_term_id;
} elseif ($cat_term_id == $category_id) {
$output .= "<li class='selected'>";
} else {
$output .= "<li>";
}
$output .= "<a href='#' class='comp-modal-category-cat' data-catid='" . $cat_term_id . "'>" . $cat_term_name . "</a>";
$output .= "</li>";
}
}
$output .= "</ul>";
echo $output;
}
?>
<form action="" method="post">
<?php
$args = array(
'hide_empty' => 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 '<ul class="comp-form-ul">';
Expand All @@ -98,7 +53,6 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0, $category_id = 0)
<?php
}
echo '</ul>';
$ajax_nonce = wp_create_nonce("bp-compliments-nonce");
?>
<textarea placeholder="<?php echo __( 'Type your message here', 'bp-compliments' ); ?>" name="message" maxchar="1000"></textarea>
<input type="hidden" name="post_id" value="<?php echo $pid; ?>"/>
Expand All @@ -118,23 +72,6 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0, $category_id = 0)
container.replaceWith("<div class='comp-modal' style='display: none;'><div class='comp-modal-content-wrap'><div class='comp-modal-title comp-loading-icon'><div class='bp-loading-icon'></div></div></div></div>");
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("<div class='comp-modal-content-wrap'><div class='comp-modal-title comp-loading-icon'><div class='bp-loading-icon'></div></div></div>");
var category_id = jQuery(this).data('catid');
mod_shadow.show();
var data = {
'action': 'bp_compliments_modal_ajax',
'bp_compliments_nonce': '<?php echo $ajax_nonce; ?>',
'category_id': category_id
};

jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', data, function (response) {
container.replaceWith(response);
});
});
});
</script>
<?php
Expand All @@ -158,13 +95,7 @@ function bp_compliments_modal_form($pid = 0, $receiver_id = 0, $category_id = 0)
function bp_compliments_modal_ajax()
{
check_ajax_referer('bp-compliments-nonce', 'bp_compliments_nonce');

if (isset($_POST['category_id'])) {
$category_id = (int) strip_tags(esc_sql($_POST['category_id']));
bp_compliments_modal_form(0, 0, $category_id);
} else {
bp_compliments_modal_form();
}
bp_compliments_modal_form();

wp_die();
}
Expand Down
13 changes: 0 additions & 13 deletions includes/bp-compliments-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function bp_compliments_register_settings() {
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_compliment_enable_categories' );
register_setting( 'bp-compliment-settings', 'bp_comp_per_page' );
register_setting( 'bp-compliment-settings', 'bp_comp_custom_css' );
}
Expand All @@ -53,9 +52,6 @@ function bp_compliments_settings_page() {
$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';

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

$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 Down Expand Up @@ -113,15 +109,6 @@ function bp_compliments_settings_page() {
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo sprintf( __( 'Enable categories for %s ?', 'bp-compliments' ), strtolower(BP_COMP_PLURAL_NAME) ); ?></th>
<td>
<select id="bp_compliment_enable_categories" name="bp_compliment_enable_categories">
<option value="yes" <?php selected( $bp_compliment_enable_categories, 'yes' ); ?>><?php echo __( 'Yes', 'bp-compliments' ); ?></option>
<option value="no" <?php selected( $bp_compliment_enable_categories, 'no' ); ?>><?php echo __( 'No', 'bp-compliments' ); ?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo sprintf( __( 'Number of %s to display per page?', 'bp-compliments' ), 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
Loading

0 comments on commit d85fa1a

Please sign in to comment.