@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <tr class="<?php echo $class; ?>" id="trPid_<?php echo $product['post_datas']->ID; ?>"> |
4 | 6 | <td class="wps-mass-interface-line-selector"><div class="wps-form-group"><div class="wps-form"><center><input type="checkbox" class="wps-save-product-checkbox" name="wps_product_quick_save[]" value="<?php echo $product['post_datas']->ID; ?>" /></center></div></div></td> |
@@ -1,21 +1,21 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <tr class="<?php echo $class; ?>" id="trPid_<?php echo $product['post_datas']->ID; ?>"> |
4 | 4 | <td class="wps-mass-interface-line-selector"><div class="wps-form-group"><div class="wps-form"><center><input type="checkbox" class="wps-save-product-checkbox" name="wps_product_quick_save[]" value="<?php echo $product['post_datas']->ID; ?>" /></center></div></div></td> |
5 | 5 | |
6 | 6 | <td class="wps_mass_interface_line"> |
7 | - <span class="wps_mass_interface_picture_container" id="wps_mass_interface_picture_container_<?php echo $product['post_datas']->ID; ?>"><?php echo get_the_post_thumbnail( $product['post_datas']->ID, 'thumbnail'); ?></span> |
|
7 | + <span class="wps_mass_interface_picture_container" id="wps_mass_interface_picture_container_<?php echo $product['post_datas']->ID; ?>"><?php echo get_the_post_thumbnail($product['post_datas']->ID, 'thumbnail'); ?></span> |
|
8 | 8 | <input type="hidden" value="" name="wps_mass_interface[<?php echo $product['post_datas']->ID; ?>][picture]" /> |
9 | 9 | <?php |
10 | - if( has_post_thumbnail($product['post_datas']->ID) ) { |
|
10 | + if (has_post_thumbnail($product['post_datas']->ID)) { |
|
11 | 11 | $has_thumb = true; |
12 | 12 | } else { |
13 | 13 | $has_thumb = false; |
14 | 14 | } |
15 | 15 | ?> |
16 | - <a href="#" style="display: <?php echo ( $has_thumb ) ? 'none' : 'inline-block'; ?>;" class="wps-bton-second-mini-rounded wps_add_picture_to_product_in_mass_interface" id="wps_add_picture_to_product_in_mass_interface_<?php echo $product['post_datas']->ID; ?>"><?php _e( 'Add a picture', 'wpshop'); ?></a> |
|
16 | + <a href="#" style="display: <?php echo ($has_thumb) ? 'none' : 'inline-block'; ?>;" class="wps-bton-second-mini-rounded wps_add_picture_to_product_in_mass_interface" id="wps_add_picture_to_product_in_mass_interface_<?php echo $product['post_datas']->ID; ?>"><?php _e('Add a picture', 'wpshop'); ?></a> |
|
17 | 17 | <div class="row-actions"> |
18 | - <center><a href="#" class="wps_del_picture_to_product_in_mass_interface" style="display: <?php echo ( !$has_thumb ) ? 'none' : 'inline-block'; ?>;" id="wps_del_picture_to_product_in_mass_interface_<?php echo $product['post_datas']->ID; ?>"><?php _e( 'Delete picture', 'wpshop'); ?></a></center> |
|
18 | + <center><a href="#" class="wps_del_picture_to_product_in_mass_interface" style="display: <?php echo (!$has_thumb) ? 'none' : 'inline-block'; ?>;" id="wps_del_picture_to_product_in_mass_interface_<?php echo $product['post_datas']->ID; ?>"><?php _e('Delete picture', 'wpshop'); ?></a></center> |
|
19 | 19 | </div> |
20 | 20 | </td> |
21 | 21 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | <input type="text" name="wps_mass_interface[<?php echo $product['post_datas']->ID; ?>][post_title]" value="<?php echo $product['post_datas']->post_title; ?>" /> |
27 | 27 | </div> |
28 | 28 | <div class="row-actions"> |
29 | - <a href="<?php echo get_edit_post_link( $product['post_datas']->ID ); ?>" target="_blank"><?php _e('Edit This')?></a> | |
|
29 | + <a href="<?php echo get_edit_post_link($product['post_datas']->ID); ?>" target="_blank"><?php _e('Edit This')?></a> | |
|
30 | 30 | <span class="trash"><a id="wps_mass_interface_post_delete_<?php echo $product['post_datas']->ID; ?>" class="submitdelete" href="#"><?php _e('Trash')?></a><input id="wps_mass_interface_post_delete_input_<?php echo $product['post_datas']->ID; ?>" type="hidden" name="wps_mass_interface[<?php echo $product['post_datas']->ID; ?>][post_delete]" value="false" /></span> | |
31 | 31 | <a href="<?php echo get_permalink($product['post_datas']->ID); ?>" target="_blank"><?php _e('View product', 'wpshop')?></a> |
32 | 32 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | <div class="wps-form-group"> |
39 | 39 | <?php /*<label><?php _e( 'Product description', 'wpshop'); ?> :</label>*/ ?> |
40 | 40 | <div class="wps-form"> |
41 | - <textarea id="wps_product_description_<?php echo $product['post_datas']->ID; ?>" name="wps_mass_interface[<?php echo $product['post_datas']->ID; ?>][post_content]"><?php echo nl2br( $product['post_datas']->post_content );?></textarea> |
|
41 | + <textarea id="wps_product_description_<?php echo $product['post_datas']->ID; ?>" name="wps_mass_interface[<?php echo $product['post_datas']->ID; ?>][post_content]"><?php echo nl2br($product['post_datas']->post_content); ?></textarea> |
|
42 | 42 | </div> |
43 | 43 | </div> |
44 | 44 | </td> |
@@ -49,43 +49,43 @@ discard block |
||
49 | 49 | <center><a class="wps-bton-first-mini-rounded wps_add_files_to_product_in_mass_interface" id="wps_add_files_to_product_in_mass_interface_<?php echo $product['post_datas']->ID; ?>"><?php _e( 'Add files', 'wpshop'); ?></a></center> |
50 | 50 | </td>*/ ?> |
51 | 51 | |
52 | - <?php if( !empty($quick_add_form_attributes) ) : |
|
52 | + <?php if (!empty($quick_add_form_attributes)) : |
|
53 | 53 | $i = 0; ?> |
54 | - <?php foreach( $quick_add_form_attributes as $attribute_id => $att_def ) : |
|
54 | + <?php foreach ($quick_add_form_attributes as $attribute_id => $att_def) : |
|
55 | 55 | |
56 | 56 | $att = null; |
57 | - $query = $wpdb->prepare( 'SELECT * FROM '. WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE attribute_set_id = %d AND attribute_id = %d AND status = %s', $default, $attribute_id, 'valid' ); |
|
58 | - $checking_display_att = $wpdb->get_results( $query ); |
|
57 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_set_id = %d AND attribute_id = %d AND status = %s', $default, $attribute_id, 'valid'); |
|
58 | + $checking_display_att = $wpdb->get_results($query); |
|
59 | 59 | |
60 | - if( !empty($checking_display_att) ) : |
|
61 | - $current_value = wpshop_attributes::getAttributeValueForEntityInSet( $att_def['data_type'], $attribute_id, $product_entity_id, $product['post_datas']->ID ); |
|
62 | - $output_specs = array( |
|
60 | + if (!empty($checking_display_att)) : |
|
61 | + $current_value = wpshop_attributes::getAttributeValueForEntityInSet($att_def['data_type'], $attribute_id, $product_entity_id, $product['post_datas']->ID); |
|
62 | + $output_specs = array( |
|
63 | 63 | 'page_code' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, |
64 | 64 | 'element_identifier' => $product['post_datas']->ID, |
65 | - 'field_id' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT.'_'.$product['post_datas']->ID. '_', |
|
66 | - 'current_value' => ( !empty($current_value->value) ? $current_value->value : '' ) |
|
65 | + 'field_id' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_' . $product['post_datas']->ID . '_', |
|
66 | + 'current_value' => (!empty($current_value->value) ? $current_value->value : '') |
|
67 | 67 | ); |
68 | - $att = wpshop_attributes::display_attribute( $att_def['code'], 'admin', $output_specs ); |
|
68 | + $att = wpshop_attributes::display_attribute($att_def['code'], 'admin', $output_specs); |
|
69 | 69 | endif; |
70 | 70 | ?> |
71 | 71 | <td class="wps_mass_interface_line"> |
72 | 72 | <div class="wps-form-group"> |
73 | 73 | <?php /*<label><?php _e( $att['field_definition']['label'], 'wpshop' ); ?></label>*/ ?> |
74 | - <div class="wps-form"><?php echo str_replace( 'name="wpshop_product_attribute', 'name="wpshop_product_attribute[' .$product['post_datas']->ID. ']', $att['field_definition']['output'] ); ?></div> |
|
74 | + <div class="wps-form"><?php echo str_replace('name="wpshop_product_attribute', 'name="wpshop_product_attribute[' . $product['post_datas']->ID . ']', $att['field_definition']['output']); ?></div> |
|
75 | 75 | </div> |
76 | 76 | </td> |
77 | 77 | <?php $i++; |
78 | 78 | endforeach; ?> |
79 | 79 | <?php endif; ?> |
80 | 80 | |
81 | - <td class="wps_mass_interface_line_deleted" colspan="<?php echo 3 + $i;?>" style="display: none;"> |
|
82 | - <?php printf( __( '%s will be deleted.', 'wpshop' ), $product['post_datas']->post_title); ?> <a class="wps_mass_interface_post_deleted_cancel" id="wps_mass_interface_post_delete_cancel_<?php echo $product['post_datas']->ID; ?>" href="#">Annuler</a> |
|
81 | + <td class="wps_mass_interface_line_deleted" colspan="<?php echo 3 + $i; ?>" style="display: none;"> |
|
82 | + <?php printf(__('%s will be deleted.', 'wpshop'), $product['post_datas']->post_title); ?> <a class="wps_mass_interface_post_deleted_cancel" id="wps_mass_interface_post_delete_cancel_<?php echo $product['post_datas']->ID; ?>" href="#">Annuler</a> |
|
83 | 83 | </td> |
84 | 84 | </tr> |
85 | 85 | <?php // ------------------------------------------------------------------------------------------------------ ?> |
86 | 86 | <?php |
87 | - $concurs = get_post_meta( $product['post_datas']->ID, '_concur', true ); |
|
88 | - if ( empty( $concurs ) ) { |
|
87 | + $concurs = get_post_meta($product['post_datas']->ID, '_concur', true); |
|
88 | + if (empty($concurs)) { |
|
89 | 89 | $concurs = array(); |
90 | 90 | } |
91 | 91 | foreach ($concurs as $key => $concur) { |
@@ -102,22 +102,22 @@ discard block |
||
102 | 102 | </td> |
103 | 103 | <td><input type="text" placeholder="Prix" name="concur[<?php echo $product['post_datas']->ID; ?>][price][]" value="<?php echo $concur['price']; ?>"></td> |
104 | 104 | <td class="del_concur" style="color: red; cursor: pointer;">Supprimer</td> |
105 | - <?php for ($j=0; $j < $i-2; $j++) { |
|
105 | + <?php for ($j = 0; $j < $i - 2; $j++) { |
|
106 | 106 | echo '<td></td>'; |
107 | 107 | } ?> |
108 | 108 | </tr> |
109 | 109 | <?php |
110 | 110 | } |
111 | - $output_specs = array( 'page_code' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'element_identifier' => $product['post_datas']->ID, 'field_id' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT.'_'.$product['post_datas']->ID. '_%ID%' ); |
|
111 | + $output_specs = array('page_code' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'element_identifier' => $product['post_datas']->ID, 'field_id' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_' . $product['post_datas']->ID . '_%ID%'); |
|
112 | 112 | ?> |
113 | 113 | <tr class="<?php echo $class; ?> concurs cloner" style="display:none" data-id="<?php echo $product['post_datas']->ID; ?>"> |
114 | 114 | <td><input type="hidden" class="is_row" name="concur[<?php echo $product['post_datas']->ID; ?>][is_row][]" value="0"></td> |
115 | 115 | <td><input type="text" placeholder="Date" class="datepicker_concur" value="<?php echo current_time('Y-m-d'); ?>" name="concur[<?php echo $product['post_datas']->ID; ?>][date][]"></td> |
116 | 116 | <td><input type="text" placeholder="Lien" name="concur[<?php echo $product['post_datas']->ID; ?>][link][]"></td> |
117 | - <td><?php $att = wpshop_attributes::display_attribute( 'concurents_', 'backend', $output_specs ); echo preg_replace( '/name=".*?"/i', 'name="concur[' .$product['post_datas']->ID. '][name][]"', preg_replace( '/class=".*?"/i', 'class="wpshop_product_attribute_concurents_ chosen_select_concur"', $att['field_definition']['output'] ) ); ?></td> |
|
117 | + <td><?php $att = wpshop_attributes::display_attribute('concurents_', 'backend', $output_specs); echo preg_replace('/name=".*?"/i', 'name="concur[' . $product['post_datas']->ID . '][name][]"', preg_replace('/class=".*?"/i', 'class="wpshop_product_attribute_concurents_ chosen_select_concur"', $att['field_definition']['output'])); ?></td> |
|
118 | 118 | <td><input type="text" placeholder="Prix" name="concur[<?php echo $product['post_datas']->ID; ?>][price][]"></td> |
119 | 119 | <td class="del_concur" style="color: red; cursor: pointer;">Supprimer</td> |
120 | - <?php for ($j=0; $j < $i-2; $j++) { |
|
120 | + <?php for ($j = 0; $j < $i - 2; $j++) { |
|
121 | 121 | echo '<td></td>'; |
122 | 122 | } ?> |
123 | 123 | </tr> |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | <td></td> |
128 | 128 | <td></td> |
129 | 129 | <td class="add_concur" style="color: #0073aa; cursor: pointer;">Ajouter un concurrent</td> |
130 | - <?php for ($j=0; $j < $i-1; $j++) { |
|
130 | + <?php for ($j = 0; $j < $i - 1; $j++) { |
|
131 | 131 | echo '<td></td>'; |
132 | 132 | } ?> |
133 | 133 | </tr> |
@@ -1,11 +1,11 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | - if ( !empty( $paginate ) ) : ?> |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | + if (!empty($paginate)) : ?> |
|
3 | 3 | <ul class="wps-mass-product-pagination"> |
4 | 4 | <?php $i = 1; ?> |
5 | - <?php foreach ( $paginate as $page ) : ?> |
|
5 | + <?php foreach ($paginate as $page) : ?> |
|
6 | 6 | <li> |
7 | - <?php if ( 1 == $i ) : ?> |
|
8 | - <?php echo str_replace( "href=''", 'href="' . admin_url( 'admin-ajax.php?action=wps_add_quick_interface' ) . '"', $page ); ?> |
|
7 | + <?php if (1 == $i) : ?> |
|
8 | + <?php echo str_replace("href=''", 'href="' . admin_url('admin-ajax.php?action=wps_add_quick_interface') . '"', $page); ?> |
|
9 | 9 | <?php else: ?> |
10 | 10 | <?php echo $page; ?> |
11 | 11 | <?php endif; ?> |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | if ( !empty( $paginate ) ) : ?> |
3 | 5 | <ul class="wps-mass-product-pagination"> |
4 | 6 | <?php $i = 1; ?> |
@@ -6,8 +8,11 @@ discard block |
||
6 | 8 | <li> |
7 | 9 | <?php if ( 1 == $i ) : ?> |
8 | 10 | <?php echo str_replace( "href=''", 'href="' . admin_url( 'admin-ajax.php?action=wps_add_quick_interface' ) . '"', $page ); ?> |
9 | - <?php else: ?> |
|
10 | - <?php echo $page; ?> |
|
11 | + <?php else { |
|
12 | + : ?> |
|
13 | + <?php echo $page; |
|
14 | +} |
|
15 | +?> |
|
11 | 16 | <?php endif; ?> |
12 | 17 | </li> |
13 | 18 | <?php $i++; ?> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Model file for product mass modification module |
4 | 6 | * |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * Model file for product mass modification module |
4 | 4 | * |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param integer $count_products |
21 | 21 | * @return array |
22 | 22 | */ |
23 | - function get_quick_interface_products( $attribute_set_id, $start_limit = 0, $nb_product_per_page = 20, $order = 'ID', $order_by = 'ASC' ) { |
|
23 | + function get_quick_interface_products($attribute_set_id, $start_limit = 0, $nb_product_per_page = 20, $order = 'ID', $order_by = 'ASC') { |
|
24 | 24 | global $wpdb; |
25 | 25 | |
26 | 26 | /*switch( $order ) { |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | AND meta_key = %s |
39 | 39 | AND meta_value = %s |
40 | 40 | ORDER BY {$order} DESC |
41 | - LIMIT " . $start_limit * $nb_product_per_page . ", " .$nb_product_per_page ."" |
|
41 | + LIMIT " . $start_limit * $nb_product_per_page . ", " . $nb_product_per_page . "" |
|
42 | 42 | , WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, '_wpshop_product_attribute_set_id', $attribute_set_id ); |
43 | - $products = $wpdb->get_results( $query ); |
|
43 | + $products = $wpdb->get_results($query); |
|
44 | 44 | |
45 | - if( !empty($products) ) { |
|
46 | - foreach( $products as $product ) { |
|
45 | + if (!empty($products)) { |
|
46 | + foreach ($products as $product) { |
|
47 | 47 | // For each product stock Post Datas and attributes definition |
48 | 48 | $tmp = array(); |
49 | 49 | $tmp['post_datas'] = $product; |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | |
60 | 60 | function get_product_attributes_sets() { |
61 | 61 | global $wpdb; |
62 | - $product_entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
63 | - $query = $wpdb->prepare( 'SELECT * FROM '. WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s', $product_entity_id, 'valid' ); |
|
64 | - $attributes_groups = $wpdb->get_results( $query ); |
|
62 | + $product_entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
63 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s', $product_entity_id, 'valid'); |
|
64 | + $attributes_groups = $wpdb->get_results($query); |
|
65 | 65 | |
66 | 66 | return $attributes_groups; |
67 | 67 | } |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | |
70 | 70 | function get_attributes_quick_add_form() { |
71 | 71 | global $wpdb; |
72 | - $product_entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
73 | - $query = $wpdb->prepare( 'SELECT * FROM '. WPSHOP_DBT_ATTRIBUTE . ' WHERE entity_id = %d AND is_used_in_quick_add_form = %s AND status = %s', $product_entity_id, 'yes', 'valid' ); |
|
74 | - $attributes = $wpdb->get_results( $query, ARRAY_A ); |
|
72 | + $product_entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
73 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE entity_id = %d AND is_used_in_quick_add_form = %s AND status = %s', $product_entity_id, 'yes', 'valid'); |
|
74 | + $attributes = $wpdb->get_results($query, ARRAY_A); |
|
75 | 75 | |
76 | 76 | return $attributes; |
77 | 77 | } |
@@ -1,2 +1,2 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | -DEFINE( 'WPS_OPINION_ID', 'wps_opinion'); |
|
3 | 1 | \ No newline at end of file |
2 | +<?php if (!defined('ABSPATH')) exit; |
|
3 | +DEFINE('WPS_OPINION_ID', 'wps_opinion'); |
|
4 | 4 | \ No newline at end of file |
@@ -1,2 +1,4 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | DEFINE( 'WPS_OPINION_ID', 'wps_opinion'); |
3 | 5 | \ No newline at end of file |
@@ -158,13 +158,13 @@ |
||
158 | 158 | $rate = get_comment_meta( $send_opinion->comment_ID, '_wps_customer_rate', true ); |
159 | 159 | $data = array( 'id' => $send_opinion->comment_ID, |
160 | 160 | 'opinion_post_ID' => $send_opinion->comment_post_ID, |
161 | - 'author_IP' => $send_opinion->comment_author_IP, |
|
162 | - 'author' => $send_opinion->comment_author, |
|
163 | - 'author_email' => $send_opinion->comment_author_email, |
|
164 | - 'opinion_content' => $send_opinion->comment_content, |
|
165 | - 'opinion_date' => $send_opinion->comment_date, |
|
166 | - 'author_id' => $send_opinion->user_id, |
|
167 | - 'opinion_approved' => $send_opinion->comment_approved, |
|
161 | + 'author_IP' => $send_opinion->comment_author_IP, |
|
162 | + 'author' => $send_opinion->comment_author, |
|
163 | + 'author_email' => $send_opinion->comment_author_email, |
|
164 | + 'opinion_content' => $send_opinion->comment_content, |
|
165 | + 'opinion_date' => $send_opinion->comment_date, |
|
166 | + 'author_id' => $send_opinion->user_id, |
|
167 | + 'opinion_approved' => $send_opinion->comment_approved, |
|
168 | 168 | 'opinion_rate' => $rate |
169 | 169 | ); |
170 | 170 | $posted_opinions[] = new wps_opinion_model( $data ); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_opinion_ctr { |
3 | 3 | |
4 | 4 | /** Define the main directory containing the template for the current plugin |
@@ -13,36 +13,36 @@ discard block |
||
13 | 13 | |
14 | 14 | function __construct() { |
15 | 15 | $this->template_dir = WPS_OPINION_PATH . WPS_OPINION_DIR . "/templates/"; |
16 | - add_action( 'admin_init', array( $this, 'declare_options' ) ); |
|
17 | - add_shortcode( 'wps_opinion', array( $this, 'display_opinion_customer_interface') ); |
|
18 | - add_shortcode( 'wps_star_rate_product', array( $this, 'display_star_rate_in_product') ); |
|
19 | - add_shortcode( 'wps_opinion_product', array( $this, 'display_opinion_in_product') ); |
|
20 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts' ) ); |
|
16 | + add_action('admin_init', array($this, 'declare_options')); |
|
17 | + add_shortcode('wps_opinion', array($this, 'display_opinion_customer_interface')); |
|
18 | + add_shortcode('wps_star_rate_product', array($this, 'display_star_rate_in_product')); |
|
19 | + add_shortcode('wps_opinion_product', array($this, 'display_opinion_in_product')); |
|
20 | + add_action('wp_enqueue_scripts', array($this, 'add_scripts')); |
|
21 | 21 | |
22 | 22 | /** Ajax actions **/ |
23 | - add_action( 'wp_ajax_wps-opinion-save-form', array( $this, 'wps_opinion_save_form') ); |
|
24 | - add_action( 'wp_ajax_nopriv_wps-opinion-save-form', array( $this, 'wps_opinion_save_form') ); |
|
25 | - add_action( 'wp_ajax_wps-update-opinion-star-rate', array( $this, 'wps_update_opinion_star_rate') ); |
|
26 | - add_action( 'wp_ajax_wps-refresh-add-opinion-list', array( $this, 'wps_refresh_add_opinion_list') ); |
|
27 | - add_action( 'wp_ajax_wps_fill_opinion_modal', array( $this, 'wps_fill_opinion_modal') ); |
|
23 | + add_action('wp_ajax_wps-opinion-save-form', array($this, 'wps_opinion_save_form')); |
|
24 | + add_action('wp_ajax_nopriv_wps-opinion-save-form', array($this, 'wps_opinion_save_form')); |
|
25 | + add_action('wp_ajax_wps-update-opinion-star-rate', array($this, 'wps_update_opinion_star_rate')); |
|
26 | + add_action('wp_ajax_wps-refresh-add-opinion-list', array($this, 'wps_refresh_add_opinion_list')); |
|
27 | + add_action('wp_ajax_wps_fill_opinion_modal', array($this, 'wps_fill_opinion_modal')); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Add JS Files |
32 | 32 | */ |
33 | 33 | function add_scripts() { |
34 | - wp_enqueue_script( 'jquery' ); |
|
35 | - wp_enqueue_script( 'jquery-form' ); |
|
36 | - wp_enqueue_script( 'wps-opinion-js', WPS_OPINION_URL . WPS_OPINION_DIR .'/assets/js/wps_opinion.js', false ); |
|
34 | + wp_enqueue_script('jquery'); |
|
35 | + wp_enqueue_script('jquery-form'); |
|
36 | + wp_enqueue_script('wps-opinion-js', WPS_OPINION_URL . WPS_OPINION_DIR . '/assets/js/wps_opinion.js', false); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * OPTIONS - Declare add-on configuration panel |
41 | 41 | */ |
42 | - function declare_options(){ |
|
43 | - add_settings_section('wpshop_addons_opinions_options', '<span class="dashicons dashicons-format-chat"></span>'.__('Customer opinions', 'wpshop'), '', 'wpshop_addons_options'); |
|
44 | - register_setting('wpshop_options', 'wps_opinion', array( $this, 'validate_options')); |
|
45 | - add_settings_field('wpshop_opinions_field', __( 'Activate possibility to add opinions on products', 'wpshop'), array( $this, 'addons_definition_fields'), 'wpshop_addons_options', 'wpshop_addons_opinions_options'); |
|
42 | + function declare_options() { |
|
43 | + add_settings_section('wpshop_addons_opinions_options', '<span class="dashicons dashicons-format-chat"></span>' . __('Customer opinions', 'wpshop'), '', 'wpshop_addons_options'); |
|
44 | + register_setting('wpshop_options', 'wps_opinion', array($this, 'validate_options')); |
|
45 | + add_settings_field('wpshop_opinions_field', __('Activate possibility to add opinions on products', 'wpshop'), array($this, 'addons_definition_fields'), 'wpshop_addons_options', 'wpshop_addons_opinions_options'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | * @param array $input |
51 | 51 | * @return unknown |
52 | 52 | */ |
53 | - function validate_options( $input ) { |
|
53 | + function validate_options($input) { |
|
54 | 54 | return $input; |
55 | 55 | } |
56 | 56 | |
57 | 57 | function addons_definition_fields() { |
58 | - $opinion_option = get_option( 'wps_opinion' ); |
|
59 | - echo '<input type="checkbox" name="wps_opinion[active]" ' . ( ( !empty($opinion_option) && !empty($opinion_option['active']) ) ? 'checked="ckecked"' : '' ) . '/>'; |
|
58 | + $opinion_option = get_option('wps_opinion'); |
|
59 | + echo '<input type="checkbox" name="wps_opinion[active]" ' . ((!empty($opinion_option) && !empty($opinion_option['active'])) ? 'checked="ckecked"' : '') . '/>'; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Display opinions for an element |
64 | 64 | * @param integer $element_id |
65 | 65 | */ |
66 | - function display_opinions( $element_id ) { |
|
67 | - if( !empty($element_id) ) { |
|
66 | + function display_opinions($element_id) { |
|
67 | + if (!empty($element_id)) { |
|
68 | 68 | $wps_opinion_mdl = new wps_opinion_model(); |
69 | - $opinions = $wps_opinion_mdl->get_opinions( $element_id ); |
|
70 | - if( !empty($opinions) ) { |
|
69 | + $opinions = $wps_opinion_mdl->get_opinions($element_id); |
|
70 | + if (!empty($opinions)) { |
|
71 | 71 | ob_start(); |
72 | - require( wpshop_tools::get_template_part( WPS_OPINION_DIR, $this->template_dir, "frontend", "opinions") ); |
|
72 | + require(wpshop_tools::get_template_part(WPS_OPINION_DIR, $this->template_dir, "frontend", "opinions")); |
|
73 | 73 | $output = ob_get_contents(); |
74 | 74 | ob_end_clean(); |
75 | 75 | } |
@@ -81,18 +81,18 @@ discard block |
||
81 | 81 | * @param decimal $rate |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - function display_stars( $rate ) { |
|
84 | + function display_stars($rate) { |
|
85 | 85 | $output = ''; |
86 | - $opinion_option = get_option( 'wps_opinion' ); |
|
87 | - if( !empty($opinion_option) && !empty($opinion_option['active']) ) { |
|
88 | - if( isset($rate) ) { |
|
89 | - $exploded_rate = explode( '.', $rate ); |
|
90 | - for( $i = 1; $i <= 5; $i++ ) { |
|
91 | - if ( $i <= $exploded_rate[0] ) { |
|
86 | + $opinion_option = get_option('wps_opinion'); |
|
87 | + if (!empty($opinion_option) && !empty($opinion_option['active'])) { |
|
88 | + if (isset($rate)) { |
|
89 | + $exploded_rate = explode('.', $rate); |
|
90 | + for ($i = 1; $i <= 5; $i++) { |
|
91 | + if ($i <= $exploded_rate[0]) { |
|
92 | 92 | $output .= '<div class="dashicons dashicons-star-filled"></div>'; |
93 | 93 | } |
94 | 94 | else { |
95 | - if( ($i == intval( $exploded_rate[0] ) + 1) && !empty($exploded_rate[1]) && intval($exploded_rate[1]) > 0) { |
|
95 | + if (($i == intval($exploded_rate[0]) + 1) && !empty($exploded_rate[1]) && intval($exploded_rate[1]) > 0) { |
|
96 | 96 | $output .= '<div class="dashicons dashicons-star-half"></div>'; |
97 | 97 | } |
98 | 98 | else { |
@@ -115,24 +115,24 @@ discard block |
||
115 | 115 | function display_opinion_customer_interface() { |
116 | 116 | $output = ''; |
117 | 117 | $customer_id = get_current_user_id(); |
118 | - $opinion_option = get_option( 'wps_opinion' ); |
|
119 | - if( !empty($opinion_option) && !empty($opinion_option['active']) ) { |
|
120 | - if( !empty($customer_id) ) { |
|
118 | + $opinion_option = get_option('wps_opinion'); |
|
119 | + if (!empty($opinion_option) && !empty($opinion_option['active'])) { |
|
120 | + if (!empty($customer_id)) { |
|
121 | 121 | /** Products which wait opinion **/ |
122 | 122 | //Get all ordered products with no opinion of this customer |
123 | 123 | $wps_opinion_mdl = new wps_opinion_model(); |
124 | - $ordered_products = $wps_opinion_mdl->get_ordered_products( $customer_id, false); |
|
125 | - if( !empty($ordered_products) ) { |
|
124 | + $ordered_products = $wps_opinion_mdl->get_ordered_products($customer_id, false); |
|
125 | + if (!empty($ordered_products)) { |
|
126 | 126 | ob_start(); |
127 | - require( wpshop_tools::get_template_part( WPS_OPINION_DIR, $this->template_dir, "frontend", "waited_opinions") ); |
|
127 | + require(wpshop_tools::get_template_part(WPS_OPINION_DIR, $this->template_dir, "frontend", "waited_opinions")); |
|
128 | 128 | $output .= ob_get_contents(); |
129 | 129 | ob_end_clean(); |
130 | 130 | } |
131 | 131 | |
132 | 132 | /** Posted opinions **/ |
133 | - $posted_opinions = $this->wps_customer_posted_opinions( $customer_id ); |
|
133 | + $posted_opinions = $this->wps_customer_posted_opinions($customer_id); |
|
134 | 134 | ob_start(); |
135 | - require( wpshop_tools::get_template_part( WPS_OPINION_DIR, $this->template_dir, "frontend", "posted_opinions") ); |
|
135 | + require(wpshop_tools::get_template_part(WPS_OPINION_DIR, $this->template_dir, "frontend", "posted_opinions")); |
|
136 | 136 | $output .= ob_get_contents(); |
137 | 137 | ob_end_clean(); |
138 | 138 | } |
@@ -145,18 +145,18 @@ discard block |
||
145 | 145 | * @param int $customer_id |
146 | 146 | * @return array wps_opinion_model |
147 | 147 | */ |
148 | - function wps_customer_posted_opinions( $customer_id ) { |
|
148 | + function wps_customer_posted_opinions($customer_id) { |
|
149 | 149 | $posted_opinions = array(); |
150 | - $opinion_option = get_option( 'wps_opinion' ); |
|
151 | - if( !empty($opinion_option) && !empty($opinion_option['active']) ) { |
|
152 | - if( !empty($customer_id) ) { |
|
150 | + $opinion_option = get_option('wps_opinion'); |
|
151 | + if (!empty($opinion_option) && !empty($opinion_option['active'])) { |
|
152 | + if (!empty($customer_id)) { |
|
153 | 153 | $wps_opinion_mdl = new wps_opinion_model(); |
154 | 154 | /** Customer opinions **/ |
155 | - $send_opinions = $wps_opinion_mdl->get_customer_opinions( $customer_id ); |
|
155 | + $send_opinions = $wps_opinion_mdl->get_customer_opinions($customer_id); |
|
156 | 156 | |
157 | - foreach( $send_opinions as $send_opinion ) { |
|
158 | - $rate = get_comment_meta( $send_opinion->comment_ID, '_wps_customer_rate', true ); |
|
159 | - $data = array( 'id' => $send_opinion->comment_ID, |
|
157 | + foreach ($send_opinions as $send_opinion) { |
|
158 | + $rate = get_comment_meta($send_opinion->comment_ID, '_wps_customer_rate', true); |
|
159 | + $data = array('id' => $send_opinion->comment_ID, |
|
160 | 160 | 'opinion_post_ID' => $send_opinion->comment_post_ID, |
161 | 161 | 'author_IP' => $send_opinion->comment_author_IP, |
162 | 162 | 'author' => $send_opinion->comment_author, |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | 'opinion_approved' => $send_opinion->comment_approved, |
168 | 168 | 'opinion_rate' => $rate |
169 | 169 | ); |
170 | - $posted_opinions[] = new wps_opinion_model( $data ); |
|
170 | + $posted_opinions[] = new wps_opinion_model($data); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | * @param array $args |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - function display_star_rate_in_product( $args ) { |
|
182 | + function display_star_rate_in_product($args) { |
|
183 | 183 | $output = ''; |
184 | - $opinion_option = get_option( 'wps_opinion' ); |
|
185 | - if( !empty($opinion_option) && !empty($opinion_option['active']) ) { |
|
186 | - if( !empty($args) && !empty($args['pid']) ) { |
|
184 | + $opinion_option = get_option('wps_opinion'); |
|
185 | + if (!empty($opinion_option) && !empty($opinion_option['active'])) { |
|
186 | + if (!empty($args) && !empty($args['pid'])) { |
|
187 | 187 | $wps_opinion_mdl = new wps_opinion_model(); |
188 | - $comments_for_products = $wps_opinion_mdl->get_opinions_for_product( $args['pid'], 'approve' ); |
|
189 | - if( !empty($comments_for_products) ) { |
|
190 | - $rate = $this->calcul_rate_average( $comments_for_products ); |
|
191 | - $output = $this->display_stars( $rate ); |
|
188 | + $comments_for_products = $wps_opinion_mdl->get_opinions_for_product($args['pid'], 'approve'); |
|
189 | + if (!empty($comments_for_products)) { |
|
190 | + $rate = $this->calcul_rate_average($comments_for_products); |
|
191 | + $output = $this->display_stars($rate); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -200,37 +200,37 @@ discard block |
||
200 | 200 | * @param array $comments_for_product |
201 | 201 | * @return decimal |
202 | 202 | */ |
203 | - function calcul_rate_average( $comments_for_product ) { |
|
203 | + function calcul_rate_average($comments_for_product) { |
|
204 | 204 | $rate_average = $r = $i = 0; |
205 | - if( !empty($comments_for_product) ) { |
|
206 | - foreach( $comments_for_product as $comment_for_product ) { |
|
207 | - if( $comment_for_product->opinion_approved == 1 ) { |
|
205 | + if (!empty($comments_for_product)) { |
|
206 | + foreach ($comments_for_product as $comment_for_product) { |
|
207 | + if ($comment_for_product->opinion_approved == 1) { |
|
208 | 208 | $r += $comment_for_product->opinion_rate; |
209 | 209 | $i++; |
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - $rate_average = ( !empty($i) ) ? number_format( ( $r / $i ), 1, '.', '' ) : 0; |
|
213 | + $rate_average = (!empty($i)) ? number_format(($r / $i), 1, '.', '') : 0; |
|
214 | 214 | } |
215 | 215 | return $rate_average; |
216 | 216 | } |
217 | 217 | |
218 | - function display_opinion_in_product( $args ) { |
|
218 | + function display_opinion_in_product($args) { |
|
219 | 219 | $output = ''; |
220 | - $opinion_option = get_option( 'wps_opinion' ); |
|
221 | - if( !empty($opinion_option) && !empty($opinion_option['active']) ) { |
|
222 | - if( !empty($args) && !empty($args['pid']) ) { |
|
220 | + $opinion_option = get_option('wps_opinion'); |
|
221 | + if (!empty($opinion_option) && !empty($opinion_option['active'])) { |
|
222 | + if (!empty($args) && !empty($args['pid'])) { |
|
223 | 223 | $wps_opinion_mdl = new wps_opinion_model(); |
224 | - $comments_for_product = $wps_opinion_mdl->get_opinions_for_product( $args['pid'], 'approve' ); |
|
224 | + $comments_for_product = $wps_opinion_mdl->get_opinions_for_product($args['pid'], 'approve'); |
|
225 | 225 | |
226 | - if( !empty($comments_for_product) ) { |
|
226 | + if (!empty($comments_for_product)) { |
|
227 | 227 | ob_start(); |
228 | - require( wpshop_tools::get_template_part( WPS_OPINION_DIR, $this->template_dir, "frontend", "opinion_in_product") ); |
|
228 | + require(wpshop_tools::get_template_part(WPS_OPINION_DIR, $this->template_dir, "frontend", "opinion_in_product")); |
|
229 | 229 | $output .= ob_get_contents(); |
230 | 230 | ob_end_clean(); |
231 | 231 | } |
232 | 232 | else { |
233 | - $output = '<div class="wps-alert-info">' .__( 'No opinion has been posted on this product', 'wps_opinion'). '</div>'; |
|
233 | + $output = '<div class="wps-alert-info">' . __('No opinion has been posted on this product', 'wps_opinion') . '</div>'; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
@@ -238,20 +238,20 @@ discard block |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | function wps_update_opinion_star_rate() { |
241 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
241 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
242 | 242 | |
243 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_update_opinion_star_rate' ) ) |
|
243 | + if (!wp_verify_nonce($_wpnonce, 'wps_update_opinion_star_rate')) |
|
244 | 244 | wp_die(); |
245 | 245 | |
246 | 246 | $status = false; |
247 | 247 | $output = ''; |
248 | - $rate = !empty( $_POST['rate'] ) ? (int) $_POST['rate'] : 0; |
|
248 | + $rate = !empty($_POST['rate']) ? (int)$_POST['rate'] : 0; |
|
249 | 249 | |
250 | - if( isset( $rate ) ) { |
|
251 | - $output = $this->display_stars( $rate ); |
|
250 | + if (isset($rate)) { |
|
251 | + $output = $this->display_stars($rate); |
|
252 | 252 | $status = true; |
253 | 253 | } |
254 | - echo json_encode( array( 'status' => $status, 'response' => $output) ); |
|
254 | + echo json_encode(array('status' => $status, 'response' => $output)); |
|
255 | 255 | wp_die(); |
256 | 256 | } |
257 | 257 | |
@@ -259,45 +259,45 @@ discard block |
||
259 | 259 | * AJAX - Save opinions |
260 | 260 | */ |
261 | 261 | function wps_opinion_save_form() { |
262 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
262 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
263 | 263 | |
264 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_opinion_save_form' ) ) |
|
264 | + if (!wp_verify_nonce($_wpnonce, 'wps_opinion_save_form')) |
|
265 | 265 | wp_die(); |
266 | 266 | |
267 | 267 | $status = false; $response = ''; |
268 | 268 | $wps_opinion_mdl = new wps_opinion_model(); |
269 | 269 | $user_id = get_current_user_id(); |
270 | 270 | // Check if opinion for this product has been posted |
271 | - $checking_opinions = $wps_opinion_mdl->get_opinions_for_product( intval($_POST['wps-opinion-product-id']) ); |
|
271 | + $checking_opinions = $wps_opinion_mdl->get_opinions_for_product(intval($_POST['wps-opinion-product-id'])); |
|
272 | 272 | $comment_exist = false; |
273 | - if( !empty($checking_opinions) ) { |
|
274 | - foreach( $checking_opinions as $o ) { |
|
275 | - if( $o->user_id == $user_id ) { |
|
273 | + if (!empty($checking_opinions)) { |
|
274 | + foreach ($checking_opinions as $o) { |
|
275 | + if ($o->user_id == $user_id) { |
|
276 | 276 | $comment_exist = true; |
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
280 | - if( !empty($user_id) && !$comment_exist ) { |
|
281 | - $user_data = get_userdata( $user_id ); |
|
282 | - $data = array( 'opinion_post_ID' => intval($_POST['wps-opinion-product-id']), |
|
280 | + if (!empty($user_id) && !$comment_exist) { |
|
281 | + $user_data = get_userdata($user_id); |
|
282 | + $data = array('opinion_post_ID' => intval($_POST['wps-opinion-product-id']), |
|
283 | 283 | 'author_IP' => $_SERVER['REMOTE_ADDR'], |
284 | - 'author' => get_user_meta( $user_id, 'first_name', true ).' '.get_user_meta( $user_id, 'last_name', true), |
|
285 | - 'author_email' => ( !empty( $user_data->user_email) ) ? $user_data->user_email : '', |
|
286 | - 'opinion_content' => strip_tags( sanitize_text_field ( $_POST['wps-opinion-comment'] ) ), |
|
287 | - 'opinion_date' => current_time( 'mysql', 0 ), |
|
284 | + 'author' => get_user_meta($user_id, 'first_name', true) . ' ' . get_user_meta($user_id, 'last_name', true), |
|
285 | + 'author_email' => (!empty($user_data->user_email)) ? $user_data->user_email : '', |
|
286 | + 'opinion_content' => strip_tags(sanitize_text_field($_POST['wps-opinion-comment'])), |
|
287 | + 'opinion_date' => current_time('mysql', 0), |
|
288 | 288 | 'author_id' => $user_id, |
289 | - 'opinion_rate' => intval( $_POST['wps-opinion-rate'] ) |
|
289 | + 'opinion_rate' => intval($_POST['wps-opinion-rate']) |
|
290 | 290 | ); |
291 | 291 | |
292 | - $wps_opinion_mdl->Create( $data ); |
|
292 | + $wps_opinion_mdl->Create($data); |
|
293 | 293 | $wps_opinion_mdl->Save(); |
294 | 294 | $status = true; |
295 | - $response = __( 'Comment has been send and must be approved by an administrator before publishing', 'wpshop' ); |
|
295 | + $response = __('Comment has been send and must be approved by an administrator before publishing', 'wpshop'); |
|
296 | 296 | } |
297 | 297 | else { |
298 | - $response = __( 'You have already post a comment for this product', 'wpshop' ); |
|
298 | + $response = __('You have already post a comment for this product', 'wpshop'); |
|
299 | 299 | } |
300 | - echo json_encode( array( 'status' => $status, 'response' => $response) ); |
|
300 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
301 | 301 | wp_die(); |
302 | 302 | } |
303 | 303 | |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | * AJAX - Refresh Opinion list |
306 | 306 | */ |
307 | 307 | function wps_refresh_add_opinion_list() { |
308 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
308 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
309 | 309 | |
310 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_refresh_add_opinion_list' ) ) |
|
310 | + if (!wp_verify_nonce($_wpnonce, 'wps_refresh_add_opinion_list')) |
|
311 | 311 | wp_die(); |
312 | 312 | |
313 | 313 | $status = true; $response = ''; |
314 | 314 | $response = $this->display_opinion_customer_interface(); |
315 | - echo json_encode( array('status' => $status, 'response' => $response ) ); |
|
315 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
316 | 316 | wp_die(); |
317 | 317 | } |
318 | 318 | |
@@ -320,19 +320,19 @@ discard block |
||
320 | 320 | * AJAX - Fill the opinion modal |
321 | 321 | */ |
322 | 322 | function wps_fill_opinion_modal() { |
323 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
323 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
324 | 324 | |
325 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_fill_opinion_modal' ) ) |
|
325 | + if (!wp_verify_nonce($_wpnonce, 'wps_fill_opinion_modal')) |
|
326 | 326 | wp_die(); |
327 | 327 | |
328 | 328 | $status = true; $title = ''; $content = ''; |
329 | - $title = __( 'Add your opinion', 'wps_opinion'); |
|
329 | + $title = __('Add your opinion', 'wps_opinion'); |
|
330 | 330 | ob_start(); |
331 | - $pid = ( !empty($_POST['pid']) ) ? intval( $_POST['pid'] ) : null; |
|
332 | - require( wpshop_tools::get_template_part( WPS_OPINION_DIR, $this->template_dir, "frontend", "wps-modal-opinion") ); |
|
331 | + $pid = (!empty($_POST['pid'])) ? intval($_POST['pid']) : null; |
|
332 | + require(wpshop_tools::get_template_part(WPS_OPINION_DIR, $this->template_dir, "frontend", "wps-modal-opinion")); |
|
333 | 333 | $content = ob_get_contents(); |
334 | 334 | ob_end_clean(); |
335 | - echo json_encode( array( 'status' => $status, 'title' => $title, 'content' => $content ) ); |
|
335 | + echo json_encode(array('status' => $status, 'title' => $title, 'content' => $content)); |
|
336 | 336 | wp_die(); |
337 | 337 | } |
338 | 338 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_opinion_ctr { |
3 | 5 | |
4 | 6 | /** Define the main directory containing the template for the current plugin |
@@ -90,18 +92,15 @@ discard block |
||
90 | 92 | for( $i = 1; $i <= 5; $i++ ) { |
91 | 93 | if ( $i <= $exploded_rate[0] ) { |
92 | 94 | $output .= '<div class="dashicons dashicons-star-filled"></div>'; |
93 | - } |
|
94 | - else { |
|
95 | + } else { |
|
95 | 96 | if( ($i == intval( $exploded_rate[0] ) + 1) && !empty($exploded_rate[1]) && intval($exploded_rate[1]) > 0) { |
96 | 97 | $output .= '<div class="dashicons dashicons-star-half"></div>'; |
97 | - } |
|
98 | - else { |
|
98 | + } else { |
|
99 | 99 | $output .= '<div class="dashicons dashicons-star-empty"></div>'; |
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
103 | - } |
|
104 | - else { |
|
103 | + } else { |
|
105 | 104 | $output = '-'; |
106 | 105 | } |
107 | 106 | } |
@@ -228,8 +227,7 @@ discard block |
||
228 | 227 | require( wpshop_tools::get_template_part( WPS_OPINION_DIR, $this->template_dir, "frontend", "opinion_in_product") ); |
229 | 228 | $output .= ob_get_contents(); |
230 | 229 | ob_end_clean(); |
231 | - } |
|
232 | - else { |
|
230 | + } else { |
|
233 | 231 | $output = '<div class="wps-alert-info">' .__( 'No opinion has been posted on this product', 'wps_opinion'). '</div>'; |
234 | 232 | } |
235 | 233 | } |
@@ -240,8 +238,9 @@ discard block |
||
240 | 238 | function wps_update_opinion_star_rate() { |
241 | 239 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
242 | 240 | |
243 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_update_opinion_star_rate' ) ) |
|
244 | - wp_die(); |
|
241 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_update_opinion_star_rate' ) ) { |
|
242 | + wp_die(); |
|
243 | + } |
|
245 | 244 | |
246 | 245 | $status = false; |
247 | 246 | $output = ''; |
@@ -261,8 +260,9 @@ discard block |
||
261 | 260 | function wps_opinion_save_form() { |
262 | 261 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
263 | 262 | |
264 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_opinion_save_form' ) ) |
|
265 | - wp_die(); |
|
263 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_opinion_save_form' ) ) { |
|
264 | + wp_die(); |
|
265 | + } |
|
266 | 266 | |
267 | 267 | $status = false; $response = ''; |
268 | 268 | $wps_opinion_mdl = new wps_opinion_model(); |
@@ -293,8 +293,7 @@ discard block |
||
293 | 293 | $wps_opinion_mdl->Save(); |
294 | 294 | $status = true; |
295 | 295 | $response = __( 'Comment has been send and must be approved by an administrator before publishing', 'wpshop' ); |
296 | - } |
|
297 | - else { |
|
296 | + } else { |
|
298 | 297 | $response = __( 'You have already post a comment for this product', 'wpshop' ); |
299 | 298 | } |
300 | 299 | echo json_encode( array( 'status' => $status, 'response' => $response) ); |
@@ -307,8 +306,9 @@ discard block |
||
307 | 306 | function wps_refresh_add_opinion_list() { |
308 | 307 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
309 | 308 | |
310 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_refresh_add_opinion_list' ) ) |
|
311 | - wp_die(); |
|
309 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_refresh_add_opinion_list' ) ) { |
|
310 | + wp_die(); |
|
311 | + } |
|
312 | 312 | |
313 | 313 | $status = true; $response = ''; |
314 | 314 | $response = $this->display_opinion_customer_interface(); |
@@ -322,8 +322,9 @@ discard block |
||
322 | 322 | function wps_fill_opinion_modal() { |
323 | 323 | $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
324 | 324 | |
325 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_fill_opinion_modal' ) ) |
|
326 | - wp_die(); |
|
325 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_fill_opinion_modal' ) ) { |
|
326 | + wp_die(); |
|
327 | + } |
|
327 | 328 | |
328 | 329 | $status = true; $title = ''; $content = ''; |
329 | 330 | $title = __( 'Add your opinion', 'wps_opinion'); |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <div class="wps-table-content wps-table-row"> |
4 | 6 | <div class="wps-table-cell"><?php echo mysql2date( get_option('date_format'), $posted_opinion->opinion_date, true ); ?></div> |
@@ -1,15 +1,15 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <div class="wps-table-content wps-table-row"> |
4 | - <div class="wps-table-cell"><?php echo mysql2date( get_option('date_format'), $posted_opinion->opinion_date, true ); ?></div> |
|
5 | - <div class="wps-table-cell"><a href="<?php echo get_permalink($posted_opinion->opinion_post_ID); ?>" target="_blank"><?php echo get_the_post_thumbnail( $posted_opinion->opinion_post_ID, 'thumbnail', array( 'class' => 'wps-circlerounded') ); ?></a></div> |
|
4 | + <div class="wps-table-cell"><?php echo mysql2date(get_option('date_format'), $posted_opinion->opinion_date, true); ?></div> |
|
5 | + <div class="wps-table-cell"><a href="<?php echo get_permalink($posted_opinion->opinion_post_ID); ?>" target="_blank"><?php echo get_the_post_thumbnail($posted_opinion->opinion_post_ID, 'thumbnail', array('class' => 'wps-circlerounded')); ?></a></div> |
|
6 | 6 | <div class="wps-table-cell"> |
7 | 7 | <a href="<?php echo get_permalink($posted_opinion->opinion_post_ID); ?>" target="_blank"> |
8 | 8 | <?php |
9 | - $product = get_post( $posted_opinion->opinion_post_ID ); |
|
10 | - if( !empty($product) && !empty($product->post_type) ) : |
|
11 | - if( $product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) : |
|
12 | - $product = get_post( $product->post_parent ); |
|
9 | + $product = get_post($posted_opinion->opinion_post_ID); |
|
10 | + if (!empty($product) && !empty($product->post_type)) : |
|
11 | + if ($product->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) : |
|
12 | + $product = get_post($product->post_parent); |
|
13 | 13 | endif; |
14 | 14 | endif; |
15 | 15 | echo $product->post_title; |
@@ -17,5 +17,5 @@ discard block |
||
17 | 17 | </a> |
18 | 18 | </div> |
19 | 19 | <div class="wps-table-cell"><?php echo $posted_opinion->opinion_content; ?></div> |
20 | - <div class="wps-table-cell"><?php echo wps_opinion_ctr::display_stars( $posted_opinion->opinion_rate ); ?></div> |
|
20 | + <div class="wps-table-cell"><?php echo wps_opinion_ctr::display_stars($posted_opinion->opinion_rate); ?></div> |
|
21 | 21 | </div> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <div class="wps-table-content wps-table-row"> |
4 | 6 | <div class="wps-table-cell wps-cart-item-img"><a href="<?php echo get_permalink($ordered_product); ?>"><?php echo get_the_post_thumbnail( $ordered_product, 'thumbnail', array( 'class' => 'wps-circlerounded') ); ?></a></div> |
@@ -1,7 +1,7 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <div class="wps-table-content wps-table-row"> |
4 | - <div class="wps-table-cell wps-cart-item-img"><a href="<?php echo get_permalink($ordered_product); ?>"><?php echo get_the_post_thumbnail( $ordered_product, 'thumbnail', array( 'class' => 'wps-circlerounded') ); ?></a></div> |
|
5 | - <div class="wps-table-cell"><a href="<?php echo get_permalink($ordered_product); ?>" target="_blank"><?php echo get_the_title( $ordered_product ); ?></a></div> |
|
6 | - <div class="wps-table-cell"><button class="wps-bton-first-mini-rounded wps-add-opinion-opener" data-nonce="<?php echo wp_create_nonce( 'wps_fill_opinion_modal' ); ?>" id="wps-add-opinion-<?php echo $ordered_product; ?>"><?php _e( 'Add your opinion', 'wps_opinion'); ?></button></div> |
|
4 | + <div class="wps-table-cell wps-cart-item-img"><a href="<?php echo get_permalink($ordered_product); ?>"><?php echo get_the_post_thumbnail($ordered_product, 'thumbnail', array('class' => 'wps-circlerounded')); ?></a></div> |
|
5 | + <div class="wps-table-cell"><a href="<?php echo get_permalink($ordered_product); ?>" target="_blank"><?php echo get_the_title($ordered_product); ?></a></div> |
|
6 | + <div class="wps-table-cell"><button class="wps-bton-first-mini-rounded wps-add-opinion-opener" data-nonce="<?php echo wp_create_nonce('wps_fill_opinion_modal'); ?>" id="wps-add-opinion-<?php echo $ordered_product; ?>"><?php _e('Add your opinion', 'wps_opinion'); ?></button></div> |
|
7 | 7 | </div> |
@@ -1,15 +1,15 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <div class="wps-table"> |
4 | 4 | <?php |
5 | -foreach( $comments_for_product as $comment_for_product ) : |
|
6 | - if( $comment_for_product->opinion_approved == 1 ) : |
|
5 | +foreach ($comments_for_product as $comment_for_product) : |
|
6 | + if ($comment_for_product->opinion_approved == 1) : |
|
7 | 7 | ?> |
8 | 8 | <div class="wps-table-content wps-table-row"> |
9 | 9 | <div class="wps-table-cell"><?php echo $comment_for_product->author; ?></div> |
10 | - <div class="wps-table-cell"><?php echo mysql2date( get_option('date_format'), $comment_for_product->opinion_date, true ); ?></div> |
|
10 | + <div class="wps-table-cell"><?php echo mysql2date(get_option('date_format'), $comment_for_product->opinion_date, true); ?></div> |
|
11 | 11 | <div class="wps-table-cell"><?php echo $comment_for_product->opinion_content; ?></div> |
12 | - <div class="wps-table-cell"><?php echo wps_opinion_ctr::display_stars( $comment_for_product->opinion_rate ); ?></div> |
|
12 | + <div class="wps-table-cell"><?php echo wps_opinion_ctr::display_stars($comment_for_product->opinion_rate); ?></div> |
|
13 | 13 | </div> |
14 | 14 | <?php |
15 | 15 | endif; |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <div class="wps-table"> |
4 | 6 | <?php |
@@ -1,17 +1,17 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | -<div><span class="wps-h3"><?php _e( 'This products wait your opinion', 'wps_opinion'); ?></span></div> |
|
3 | +<div><span class="wps-h3"><?php _e('This products wait your opinion', 'wps_opinion'); ?></span></div> |
|
4 | 4 | <div class="wps-table"> |
5 | 5 | <div class="wps-table-header wps-table-row"> |
6 | - <div class="wps-table-cell"><?php _e( 'Picture', 'wps_opinion'); ?></div> |
|
7 | - <div class="wps-table-cell"><?php _e( 'Product', 'wps_opinion'); ?></div> |
|
6 | + <div class="wps-table-cell"><?php _e('Picture', 'wps_opinion'); ?></div> |
|
7 | + <div class="wps-table-cell"><?php _e('Product', 'wps_opinion'); ?></div> |
|
8 | 8 | <div class="wps-table-cell"></div> |
9 | 9 | </div> |
10 | - <?php if( !empty($ordered_products) ) : ?> |
|
11 | - <?php foreach( $ordered_products as $ordered_product ) : ?> |
|
12 | - <?php require( wpshop_tools::get_template_part( WPS_OPINION_DIR, $this->template_dir, "frontend", "waited_opinion") ); ?> |
|
10 | + <?php if (!empty($ordered_products)) : ?> |
|
11 | + <?php foreach ($ordered_products as $ordered_product) : ?> |
|
12 | + <?php require(wpshop_tools::get_template_part(WPS_OPINION_DIR, $this->template_dir, "frontend", "waited_opinion")); ?> |
|
13 | 13 | <?php endforeach; ?> |
14 | 14 | <?php else : ?> |
15 | - <?php _e( 'No products wait your opinion !', 'wps_opinion'); ?> |
|
15 | + <?php _e('No products wait your opinion !', 'wps_opinion'); ?> |
|
16 | 16 | <?php endif; ?> |
17 | 17 | </div> |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <div><span class="wps-h3"><?php _e( 'This products wait your opinion', 'wps_opinion'); ?></span></div> |
4 | 6 | <div class="wps-table"> |
@@ -11,7 +13,10 @@ discard block |
||
11 | 13 | <?php foreach( $ordered_products as $ordered_product ) : ?> |
12 | 14 | <?php require( wpshop_tools::get_template_part( WPS_OPINION_DIR, $this->template_dir, "frontend", "waited_opinion") ); ?> |
13 | 15 | <?php endforeach; ?> |
14 | - <?php else : ?> |
|
15 | - <?php _e( 'No products wait your opinion !', 'wps_opinion'); ?> |
|
16 | + <?php else { |
|
17 | + : ?> |
|
18 | + <?php _e( 'No products wait your opinion !', 'wps_opinion'); |
|
19 | +} |
|
20 | +?> |
|
16 | 21 | <?php endif; ?> |
17 | 22 | </div> |