@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | if( !$is_from_admin ) : ?> |
3 | 5 | <span class="wps-h5"><?php _e( 'My coupons', 'wpshop'); ?></span> |
4 | 6 | <?php endif; ?> |
@@ -1,14 +1,14 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | - if( !$is_from_admin ) : ?> |
|
3 | -<span class="wps-h5"><?php _e( 'My coupons', 'wpshop'); ?></span> |
|
4 | -<?php endif; ?> |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | + if (!$is_from_admin) : ?> |
|
3 | +<span class="wps-h5"><?php _e('My coupons', 'wpshop'); ?></span> |
|
4 | +<?php endif; ?> |
|
5 | 5 | |
6 | 6 | <div class="wps-table"> |
7 | 7 | <div class="wps-table-header wps-table-row"> |
8 | - <div class="wps-table-cell"><?php _e( 'Coupon value', 'wpshop'); ?></div> |
|
8 | + <div class="wps-table-cell"><?php _e('Coupon value', 'wpshop'); ?></div> |
|
9 | 9 | <!-- TODO Display elements only when is !empty --> |
10 | - <!--<div class="wps-table-cell"><?php _e( 'Validity date', 'wpshop'); ?></div>--> |
|
11 | - <div class="wps-table-cell"><?php _e( 'Coupon code', 'wpshop'); ?></div> |
|
10 | + <!--<div class="wps-table-cell"><?php _e('Validity date', 'wpshop'); ?></div>--> |
|
11 | + <div class="wps-table-cell"><?php _e('Coupon code', 'wpshop'); ?></div> |
|
12 | 12 | </div> |
13 | 13 | <?php echo $coupons_rows; ?> |
14 | 14 | </div> |
@@ -1,4 +1,4 @@ |
||
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 | 4 | <div class="wps-table-cell"><?php echo $coupon_value; ?></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"><?php echo $coupon_value; ?></div> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <table class="wpshop_coupon_definition_table" > |
4 | 6 | <tr class="wpshop_coupon_definition_table_code_coupon_line" > |
@@ -1,16 +1,16 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <table class="wpshop_coupon_definition_table" > |
4 | 4 | <tr class="wpshop_coupon_definition_table_code_coupon_line" > |
5 | - <td class="wpshop_coupon_definition_table_label wpshop_coupon_definition_code_coupon_input_label" ><label for="coupon_code" ><?php _e('Coupon code','wpshop'); ?></label></td> |
|
5 | + <td class="wpshop_coupon_definition_table_label wpshop_coupon_definition_code_coupon_input_label" ><label for="coupon_code" ><?php _e('Coupon code', 'wpshop'); ?></label></td> |
|
6 | 6 | <td class="wpshop_coupon_definition_table_input wpshop_coupon_definition_code_coupon_input" ><input type="text" name="coupon_code" id="coupon_code" value="<?php echo $coupon_code; ?>" /></td> |
7 | 7 | </tr> |
8 | 8 | <tr class="wpshop_coupon_definition_table_code_type_line" > |
9 | - <td class="wpshop_coupon_definition_table_label wpshop_coupon_definition_coupon_type_amount_label" ><input type="radio" name="coupon_type" class="wpshop_coupon_type" id="coupon_type_amount" value="amount" <?php echo ( ($wpshop_coupon_discount_type=='amount') || empty($wpshop_coupon_discount_type) ? 'checked="checked"' : null ); ?> /><label for="coupon_type_amount" ><?php _e('Coupon discount amount','wpshop'); ?></label></td> |
|
10 | - <td class="wpshop_coupon_definition_table_input wpshop_coupon_definition_coupon_type_input" rowspan="2" ><input type="text" name="coupon_discount_amount" value="<?php echo $coupon_discount_amount; ?>" /><span class="wpshop_coupon_type_unit wpshop_coupon_type_unit_amount" > <?php echo ( ( (!empty($wpshop_coupon_discount_type) && $wpshop_coupon_discount_type == 'percent' ) ) ? '%' : wpshop_tools::wpshop_get_currency().' '.__('ATI', 'wpshop')); ?></span><span class="wpshopHide wpshop_coupon_type_unit wpshop_coupon_type_unit_percent" > % </span></td> |
|
9 | + <td class="wpshop_coupon_definition_table_label wpshop_coupon_definition_coupon_type_amount_label" ><input type="radio" name="coupon_type" class="wpshop_coupon_type" id="coupon_type_amount" value="amount" <?php echo (($wpshop_coupon_discount_type == 'amount') || empty($wpshop_coupon_discount_type) ? 'checked="checked"' : null); ?> /><label for="coupon_type_amount" ><?php _e('Coupon discount amount', 'wpshop'); ?></label></td> |
|
10 | + <td class="wpshop_coupon_definition_table_input wpshop_coupon_definition_coupon_type_input" rowspan="2" ><input type="text" name="coupon_discount_amount" value="<?php echo $coupon_discount_amount; ?>" /><span class="wpshop_coupon_type_unit wpshop_coupon_type_unit_amount" > <?php echo (((!empty($wpshop_coupon_discount_type) && $wpshop_coupon_discount_type == 'percent')) ? '%' : wpshop_tools::wpshop_get_currency() . ' ' . __('ATI', 'wpshop')); ?></span><span class="wpshopHide wpshop_coupon_type_unit wpshop_coupon_type_unit_percent" > % </span></td> |
|
11 | 11 | </tr> |
12 | 12 | <tr class="wpshop_coupon_definition_table_code_type_line" > |
13 | - <td class="wpshop_coupon_definition_table_label wpshop_coupon_definition_coupon_type_percent_label" ><input type="radio" name="coupon_type" id="coupon_type_percent" class="wpshop_coupon_type" value="percent" <?php echo ($wpshop_coupon_discount_type=='percent'?'checked="checked"':null); ?> /><label for="coupon_type_percent" ><?php _e('Coupon discount percent','wpshop'); ?></label></td> |
|
13 | + <td class="wpshop_coupon_definition_table_label wpshop_coupon_definition_coupon_type_percent_label" ><input type="radio" name="coupon_type" id="coupon_type_percent" class="wpshop_coupon_type" value="percent" <?php echo ($wpshop_coupon_discount_type == 'percent' ? 'checked="checked"' : null); ?> /><label for="coupon_type_percent" ><?php _e('Coupon discount percent', 'wpshop'); ?></label></td> |
|
14 | 14 | </tr> |
15 | 15 | <tr> |
16 | 16 | <td> |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, |
25 | 25 | 'post_status' => 'draft', |
26 | 26 | ); |
27 | - $customers = get_posts( $args ); |
|
28 | - if ( !empty($customers) ) : |
|
29 | - foreach( $customers as $customer ) : |
|
30 | - $name = strtoupper( get_user_meta( $customer->post_author, 'last_name', true ) ).' '.get_user_meta( $customer->post_author, 'first_name', true ); |
|
27 | + $customers = get_posts($args); |
|
28 | + if (!empty($customers)) : |
|
29 | + foreach ($customers as $customer) : |
|
30 | + $name = strtoupper(get_user_meta($customer->post_author, 'last_name', true)) . ' ' . get_user_meta($customer->post_author, 'first_name', true); |
|
31 | 31 | $user = get_userdata($customer->post_author); |
32 | - if ( !empty( $user ) ) : |
|
32 | + if (!empty($user)) : |
|
33 | 33 | ?> |
34 | - <option value="<?php echo $customer->post_author; ?>" <?php echo ( (!empty( $coupon_receiver) && is_array($coupon_receiver) && in_array($customer->post_author, $coupon_receiver)) ? 'selected="selected"' : '' ); ?>><?php echo $name; ?> ( <?php echo $user->user_email; ?> )</option> |
|
34 | + <option value="<?php echo $customer->post_author; ?>" <?php echo ((!empty($coupon_receiver) && is_array($coupon_receiver) && in_array($customer->post_author, $coupon_receiver)) ? 'selected="selected"' : ''); ?>><?php echo $name; ?> ( <?php echo $user->user_email; ?> )</option> |
|
35 | 35 | <?php |
36 | 36 | endif; |
37 | 37 | endforeach; |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | <label for="wpshop_coupon_mini_amount"><?php _e('Minimum order amount to use this coupon', 'wpshop'); ?></label> : |
57 | 57 | </td> |
58 | 58 | <td> |
59 | - <input type="text" name="wpshop_coupon_mini_amount" value="<?php echo ( (!empty($wpshop_coupon_minimum_amount) && !empty($wpshop_coupon_minimum_amount['amount']) ) ? $wpshop_coupon_minimum_amount['amount'] : ''); ?>" id="wpshop_coupon_mini_amount" /> <?php echo $default_currency; ?> |
|
59 | + <input type="text" name="wpshop_coupon_mini_amount" value="<?php echo ((!empty($wpshop_coupon_minimum_amount) && !empty($wpshop_coupon_minimum_amount['amount'])) ? $wpshop_coupon_minimum_amount['amount'] : ''); ?>" id="wpshop_coupon_mini_amount" /> <?php echo $default_currency; ?> |
|
60 | 60 | <select name="wpshop_coupon_min_mount_shipping_rule"> |
61 | - <option value="no_shipping_cost" <?php echo ( (!empty($wpshop_coupon_minimum_amount) && !empty($wpshop_coupon_minimum_amount['shipping_rule']) && $wpshop_coupon_minimum_amount['shipping_rule'] == 'no_shipping_cost') ? 'selected="selected"' : ''); ?>><?php _e('Without shipping cost', 'wpshop'); ?></option> |
|
62 | - <option value="shipping_cost" <?php echo ( (!empty($wpshop_coupon_minimum_amount) && !empty($wpshop_coupon_minimum_amount['shipping_rule']) && $wpshop_coupon_minimum_amount['shipping_rule'] == 'shipping_cost') ? 'selected="selected"' : ''); ?>><?php _e('With shipping cost', 'wpshop'); ?></option> |
|
61 | + <option value="no_shipping_cost" <?php echo ((!empty($wpshop_coupon_minimum_amount) && !empty($wpshop_coupon_minimum_amount['shipping_rule']) && $wpshop_coupon_minimum_amount['shipping_rule'] == 'no_shipping_cost') ? 'selected="selected"' : ''); ?>><?php _e('Without shipping cost', 'wpshop'); ?></option> |
|
62 | + <option value="shipping_cost" <?php echo ((!empty($wpshop_coupon_minimum_amount) && !empty($wpshop_coupon_minimum_amount['shipping_rule']) && $wpshop_coupon_minimum_amount['shipping_rule'] == 'shipping_cost') ? 'selected="selected"' : ''); ?>><?php _e('With shipping cost', 'wpshop'); ?></option> |
|
63 | 63 | </select> |
64 | 64 | <br/><?php _e('Leave empty if you want no limitation', 'wpshop'); ?> |
65 | 65 | </td> |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_coupon_model { |
3 | 5 | function __construct() { |
4 | 6 | |
@@ -65,8 +67,7 @@ discard block |
||
65 | 67 | |
66 | 68 | if ( !empty($coupon_use[$user_id]) ) { |
67 | 69 | $coupon_use[$user_id] = $coupon_use[$user_id] + 1; |
68 | - } |
|
69 | - else { |
|
70 | + } else { |
|
70 | 71 | $coupon_use[$user_id] = 1; |
71 | 72 | } |
72 | 73 | update_post_meta( $coupon_id, '_wpshop_coupon_usage', $coupon_use); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_coupon_model { |
3 | 3 | function __construct() { |
4 | 4 | |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @return array |
10 | 10 | */ |
11 | 11 | function get_coupons() { |
12 | - $coupons = get_posts( array( 'post_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_COUPON, 'post_status' => 'publish' ) ); |
|
12 | + $coupons = get_posts(array('post_per_page' => -1, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_COUPON, 'post_status' => 'publish')); |
|
13 | 13 | return $coupons; |
14 | 14 | } |
15 | 15 | |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | * Save coupon custom datas on asave post action |
18 | 18 | * @param array $data |
19 | 19 | */ |
20 | - function save_coupons_informations( $data ) { |
|
21 | - if( !empty($data) ) { |
|
22 | - $amount_min_limit = array( 'amount' => ( ( !empty($data['wpshop_coupon_mini_amount']) ) ? $data['wpshop_coupon_mini_amount'] : null ), 'shipping_rule' => ( ( !empty($data['wpshop_coupon_min_mount_shipping_rule']) ) ? $data['wpshop_coupon_min_mount_shipping_rule'] : null ) ); |
|
20 | + function save_coupons_informations($data) { |
|
21 | + if (!empty($data)) { |
|
22 | + $amount_min_limit = array('amount' => ((!empty($data['wpshop_coupon_mini_amount'])) ? $data['wpshop_coupon_mini_amount'] : null), 'shipping_rule' => ((!empty($data['wpshop_coupon_min_mount_shipping_rule'])) ? $data['wpshop_coupon_min_mount_shipping_rule'] : null)); |
|
23 | 23 | update_post_meta($data['post_ID'], 'wpshop_coupon_code', $data['coupon_code']); |
24 | - update_post_meta($data['post_ID'], 'wpshop_coupon_discount_value', floatval( str_replace(',', '.',$data['coupon_discount_amount']) ) ); |
|
24 | + update_post_meta($data['post_ID'], 'wpshop_coupon_discount_value', floatval(str_replace(',', '.', $data['coupon_discount_amount']))); |
|
25 | 25 | update_post_meta($data['post_ID'], 'wpshop_coupon_discount_type', $data['wpshop_coupon_discount_type']); |
26 | - update_post_meta($data['post_ID'], 'wpshop_coupon_individual_use', $data['coupon_receiver'] ); |
|
26 | + update_post_meta($data['post_ID'], 'wpshop_coupon_individual_use', $data['coupon_receiver']); |
|
27 | 27 | update_post_meta($data['post_ID'], 'wpshop_coupon_product_ids', ''); |
28 | 28 | update_post_meta($data['post_ID'], 'wpshop_coupon_exclude_product_ids', ''); |
29 | - update_post_meta($data['post_ID'], 'wpshop_coupon_usage_limit', $data['coupon_usage_limit'] ); |
|
29 | + update_post_meta($data['post_ID'], 'wpshop_coupon_usage_limit', $data['coupon_usage_limit']); |
|
30 | 30 | update_post_meta($data['post_ID'], 'wpshop_coupon_start_date', ''); |
31 | 31 | update_post_meta($data['post_ID'], 'wpshop_coupon_expiry_date', ''); |
32 | 32 | update_post_meta($data['post_ID'], 'wpshop_coupon_apply_before_tax', ''); |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @param integer $coupon_id |
43 | 43 | * @return array |
44 | 44 | */ |
45 | - function get_coupon_data( $coupon_id ) { |
|
45 | + function get_coupon_data($coupon_id) { |
|
46 | 46 | global $wpdb; |
47 | - $coupon_id = ( !empty($coupon_id) ) ? $coupon_id : ( !empty($_SESSION['cart']['coupon_id']) ) ? $_SESSION['cart']['coupon_id'] : null ; |
|
48 | - if( !empty($coupon_id) ) { |
|
49 | - $query = $wpdb->prepare('SELECT meta_key, meta_value FROM ' . $wpdb->postmeta . ' WHERE post_id = %d', $coupon_id ); |
|
47 | + $coupon_id = (!empty($coupon_id)) ? $coupon_id : (!empty($_SESSION['cart']['coupon_id'])) ? $_SESSION['cart']['coupon_id'] : null; |
|
48 | + if (!empty($coupon_id)) { |
|
49 | + $query = $wpdb->prepare('SELECT meta_key, meta_value FROM ' . $wpdb->postmeta . ' WHERE post_id = %d', $coupon_id); |
|
50 | 50 | $coupons = $wpdb->get_results($query, ARRAY_A); |
51 | 51 | $coupon = array(); |
52 | 52 | $coupon['coupon_id'] = $coupon_id; |
53 | - foreach($coupons as $coupon_info){ |
|
53 | + foreach ($coupons as $coupon_info) { |
|
54 | 54 | $coupon[$coupon_info['meta_key']] = $coupon_info['meta_value']; |
55 | 55 | } |
56 | 56 | return $coupon; |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | /** Save an historic of coupon usage */ |
62 | - function save_coupon_use( $coupon_id ) { |
|
63 | - $coupon_use = get_post_meta( $coupon_id, '_wpshop_coupon_usage', true); |
|
62 | + function save_coupon_use($coupon_id) { |
|
63 | + $coupon_use = get_post_meta($coupon_id, '_wpshop_coupon_usage', true); |
|
64 | 64 | $user_id = get_current_user_id(); |
65 | 65 | |
66 | - if ( !empty($coupon_use[$user_id]) ) { |
|
66 | + if (!empty($coupon_use[$user_id])) { |
|
67 | 67 | $coupon_use[$user_id] = $coupon_use[$user_id] + 1; |
68 | 68 | } |
69 | 69 | else { |
70 | 70 | $coupon_use[$user_id] = 1; |
71 | 71 | } |
72 | - update_post_meta( $coupon_id, '_wpshop_coupon_usage', $coupon_use); |
|
72 | + update_post_meta($coupon_id, '_wpshop_coupon_usage', $coupon_use); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wpshop_customer_search { |
3 | 5 | |
4 | 6 | function __construct() { |
@@ -1,24 +1,24 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wpshop_customer_search { |
3 | 3 | |
4 | 4 | function __construct() { |
5 | - if ( is_admin() ) { |
|
6 | - add_filter( 'posts_where', array(&$this, 'wpshop_search_where_in_customer') ); |
|
5 | + if (is_admin()) { |
|
6 | + add_filter('posts_where', array(&$this, 'wpshop_search_where_in_customer')); |
|
7 | 7 | } |
8 | 8 | } |
9 | 9 | |
10 | - public function wpshop_search_where_in_customer( $where ) { |
|
11 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
12 | - $s = !empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
13 | - $entity_filter = !empty( $_GET['filter'] ) ? sanitize_text_field( $_GET['filter'] ) : ''; |
|
10 | + public function wpshop_search_where_in_customer($where) { |
|
11 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
12 | + $s = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
13 | + $entity_filter = !empty($_GET['filter']) ? sanitize_text_field($_GET['filter']) : ''; |
|
14 | 14 | |
15 | - if( is_admin() && ( !empty($post_type) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) ) && ( !empty( $s ) || !empty( $entity_filter ) ) ) { |
|
15 | + if (is_admin() && (!empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS)) && (!empty($s) || !empty($entity_filter))) { |
|
16 | 16 | global $wpdb; |
17 | 17 | |
18 | 18 | $where = " AND {$wpdb->posts}.post_type = '" . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS . "'"; |
19 | 19 | |
20 | - if( !empty( $entity_filter ) ) { |
|
21 | - switch ( $entity_filter ) { |
|
20 | + if (!empty($entity_filter)) { |
|
21 | + switch ($entity_filter) { |
|
22 | 22 | case 'orders': |
23 | 23 | $operator = 'IN'; |
24 | 24 | break; |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | )"; |
36 | 36 | } |
37 | 37 | |
38 | - if( !empty( $s ) ) { |
|
39 | - $s_soundex = soundex( $s ); |
|
40 | - $s = strtoupper( $s ); |
|
38 | + if (!empty($s)) { |
|
39 | + $s_soundex = soundex($s); |
|
40 | + $s = strtoupper($s); |
|
41 | 41 | $where .= " AND ( {$wpdb->posts}.ID = '{$s}' |
42 | 42 | OR UPPER( {$wpdb->posts}.post_title ) LIKE '%{$s}%' |
43 | 43 | OR SOUNDEX( {$wpdb->posts}.post_title ) = '{$s_soundex}' |
@@ -93,6 +93,6 @@ discard block |
||
93 | 93 | |
94 | 94 | } |
95 | 95 | |
96 | -if ( class_exists("wpshop_customer_search") ) { |
|
96 | +if (class_exists("wpshop_customer_search")) { |
|
97 | 97 | $wpshop_customer_search = new wpshop_customer_search(); |
98 | 98 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** Check if the plugin version is defined. If not defined script will be stopped here */ |
4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -1,11 +1,11 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /** Check if the plugin version is defined. If not defined script will be stopped here */ |
4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
5 | - die( __("You are not allowed to use this service.", 'wpshop') ); |
|
4 | +if (!defined('WPSHOP_VERSION')) { |
|
5 | + die(__("You are not allowed to use this service.", 'wpshop')); |
|
6 | 6 | } |
7 | 7 | |
8 | -if ( !class_exists("wpshop_entity_filter") ) { |
|
8 | +if (!class_exists("wpshop_entity_filter")) { |
|
9 | 9 | class wpshop_entity_filter { |
10 | 10 | function __construct() { |
11 | 11 | add_action('restrict_manage_posts', array(&$this, 'wpshop_entity_filter')); |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | function wpshop_entity_filter() { |
16 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
17 | - $entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
16 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
17 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
18 | 18 | |
19 | 19 | if (isset($post_type)) { |
20 | 20 | if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT)) { |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | function wpshop_entity_filter_parse_query($query) { |
34 | 34 | global $pagenow, $wpdb; |
35 | 35 | |
36 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
37 | - $entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
36 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
37 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
38 | 38 | |
39 | - if ( is_admin() && ($pagenow == 'edit.php') && !empty( $post_type ) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) && !empty( $entity_filter ) ) { |
|
39 | + if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) && !empty($entity_filter)) { |
|
40 | 40 | |
41 | 41 | $check = null; |
42 | - switch ( $entity_filter ) { |
|
42 | + switch ($entity_filter) { |
|
43 | 43 | case 'no_picture': |
44 | 44 | $sql_query = $wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} pm WHERE meta_key = %s ", '_thumbnail_id'); |
45 | 45 | $check = 'post__not_in'; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | // $price_attribute = wpshop_attributes::getElement( WPSHOP_PRODUCT_PRICE_TTC, "'valid'", 'code'); |
50 | 50 | // $sql_query = $wpdb->prepare("SELECT DISTINCT ID as post_id FROM {$wpdb->posts} WHERE post_type = %s AND ID NOT IN (SELECT entity_id FROM {$table_attribute_decimal} WHERE value > 0 AND attribute_id = %d)", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, $price_attribute->id); |
51 | 51 | // $check = 'post__in'; |
52 | - $query->set( 'meta_query' , array( |
|
52 | + $query->set('meta_query', array( |
|
53 | 53 | array( |
54 | 54 | 'key' => '_displayed_price', |
55 | 55 | 'value' => '', |
@@ -89,20 +89,20 @@ discard block |
||
89 | 89 | WHERE meta_key = %s |
90 | 90 | ) AND post_type = %s" |
91 | 91 | , "_barcode", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "_barcode", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, "_barcode", WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ); |
92 | - $options_product_without_barcode = $wpdb->get_results( $the_query ); |
|
93 | - if ( !empty( $options_product_without_barcode ) ) { |
|
94 | - foreach ( $options_product_without_barcode as $post ) { |
|
92 | + $options_product_without_barcode = $wpdb->get_results($the_query); |
|
93 | + if (!empty($options_product_without_barcode)) { |
|
94 | + foreach ($options_product_without_barcode as $post) { |
|
95 | 95 | $post_to_get[] = $post->post_parent; |
96 | 96 | } |
97 | 97 | } |
98 | 98 | /** If there are post that have variations without barcode => add them to the post list to get */ |
99 | - if ( !empty( $post_to_get ) ) { |
|
100 | - $query->query_vars[ 'post__in' ] = $post_to_get; |
|
99 | + if (!empty($post_to_get)) { |
|
100 | + $query->query_vars['post__in'] = $post_to_get; |
|
101 | 101 | } |
102 | 102 | break; |
103 | 103 | case 'no_barcode_products': |
104 | 104 | /** Check all product that don't have a barcode or having a barcode containing PDCT */ |
105 | - $query->set( 'meta_query' , array( |
|
105 | + $query->set('meta_query', array( |
|
106 | 106 | 'relation' => 'OR', |
107 | 107 | array( |
108 | 108 | 'key' => '_barcode', |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | break; |
119 | 119 | } |
120 | 120 | |
121 | - if ( !empty( $check ) ) { |
|
121 | + if (!empty($check)) { |
|
122 | 122 | $results = $wpdb->get_results($sql_query); |
123 | 123 | $post_id_list = array(); |
124 | - foreach($results as $item){ |
|
124 | + foreach ($results as $item) { |
|
125 | 125 | $post_id_list[] = $item->post_id; |
126 | 126 | } |
127 | 127 | $query->query_vars[$check] = $post_id_list; |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wpshop_order_search { |
3 | 5 | |
4 | 6 | function __construct() { |
@@ -1,10 +1,10 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wpshop_order_search { |
3 | 3 | |
4 | 4 | function __construct() { |
5 | - if ( is_admin() ) { |
|
5 | + if (is_admin()) { |
|
6 | 6 | //add_action('posts_where_request', array(&$this, 'wpshop_search_where_in_order')); |
7 | - add_filter( 'posts_where', array(&$this, 'wpshop_search_where_in_order'), 10, 2 ); |
|
7 | + add_filter('posts_where', array(&$this, 'wpshop_search_where_in_order'), 10, 2); |
|
8 | 8 | } |
9 | 9 | } |
10 | 10 | |
@@ -13,31 +13,31 @@ discard block |
||
13 | 13 | * @param string $join The current |
14 | 14 | * @return string The new search query table list |
15 | 15 | */ |
16 | - public function wpshop_search_join( $join ) { |
|
16 | + public function wpshop_search_join($join) { |
|
17 | 17 | global $wpdb; |
18 | 18 | |
19 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
19 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
20 | 20 | |
21 | - if( is_search() || (is_admin() && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) ) { |
|
21 | + if (is_search() || (is_admin() && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) { |
|
22 | 22 | $join .= " LEFT JOIN $wpdb->postmeta ON " . $wpdb->posts . ".ID = $wpdb->postmeta.post_id "; |
23 | 23 | } |
24 | 24 | |
25 | 25 | return $join; |
26 | 26 | } |
27 | 27 | |
28 | - public function wpshop_search_where_in_order( $where ) { |
|
28 | + public function wpshop_search_where_in_order($where) { |
|
29 | 29 | global $wpdb; |
30 | 30 | |
31 | - $s = !empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
32 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
31 | + $s = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
32 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
33 | 33 | |
34 | - if ( !empty( $s ) && !empty( $post_type ) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) { |
|
34 | + if (!empty($s) && !empty($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
35 | 35 | |
36 | 36 | $where = " AND {$wpdb->posts}.post_type = '" . WPSHOP_NEWTYPE_IDENTIFIER_ORDER . "'"; |
37 | 37 | |
38 | - if( !empty( $s ) ) { |
|
39 | - $s_soundex = soundex( sanitize_text_field( $_GET['s'] ) ); |
|
40 | - $s = strtoupper( sanitize_text_field( $_GET['s'] ) ); |
|
38 | + if (!empty($s)) { |
|
39 | + $s_soundex = soundex(sanitize_text_field($_GET['s'])); |
|
40 | + $s = strtoupper(sanitize_text_field($_GET['s'])); |
|
41 | 41 | $where .= "AND ( |
42 | 42 | ( |
43 | 43 | {$wpdb->posts}.ID IN ( |
@@ -95,6 +95,6 @@ discard block |
||
95 | 95 | |
96 | 96 | } |
97 | 97 | |
98 | -if ( class_exists("wpshop_order_search") ) { |
|
98 | +if (class_exists("wpshop_order_search")) { |
|
99 | 99 | $wpshop_order_search = new wpshop_order_search(); |
100 | 100 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * WpShop Search bootstrap file |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | |
12 | 12 | /** Template Global vars **/ |
13 | 13 | DEFINE('WPS_SEARCH_DIR', basename(dirname(__FILE__))); |
14 | -DEFINE('WPS_SEARCH_PATH', str_replace( "\\", "/", str_replace( WPS_SEARCH_DIR, "", dirname( __FILE__ ) ) ) ); |
|
15 | -DEFINE('WPS_SEARCH_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', WPS_SEARCH_PATH ) ); |
|
14 | +DEFINE('WPS_SEARCH_PATH', str_replace("\\", "/", str_replace(WPS_SEARCH_DIR, "", dirname(__FILE__)))); |
|
15 | +DEFINE('WPS_SEARCH_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', WPS_SEARCH_PATH)); |
|
16 | 16 | |
17 | -include( plugin_dir_path( __FILE__ ).'/controller/wps_filter_search.php' ); |
|
18 | -include( plugin_dir_path( __FILE__ ).'/controller/wpshop_entity_filter.php' ); |
|
19 | -include( plugin_dir_path( __FILE__ ).'/controller/wps_order_search.php' ); |
|
20 | -include( plugin_dir_path( __FILE__ ).'/controller/wps_customer_search.php' ); |
|
17 | +include(plugin_dir_path(__FILE__) . '/controller/wps_filter_search.php'); |
|
18 | +include(plugin_dir_path(__FILE__) . '/controller/wpshop_entity_filter.php'); |
|
19 | +include(plugin_dir_path(__FILE__) . '/controller/wps_order_search.php'); |
|
20 | +include(plugin_dir_path(__FILE__) . '/controller/wps_customer_search.php'); |
|
21 | 21 | |
22 | 22 | $wps_filter_search = new wps_filter_search(); |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** |
4 | 6 | * WpShop Search bootstrap file |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <div class="wps-form-group"> |
4 | 4 | <label><?php _e($attribute_def->frontend_label, 'wpshop'); ?></label> |
@@ -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-form-group"> |
4 | 6 | <label><?php _e($attribute_def->frontend_label, 'wpshop'); ?></label> |