@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_export_mdl { |
3 | 3 | |
4 | 4 | /** |
@@ -8,88 +8,88 @@ discard block |
||
8 | 8 | * @param date $dt2 may be null |
9 | 9 | * @return array |
10 | 10 | */ |
11 | - function get_customers($term, $dt1=null, $dt2=null) { |
|
11 | + function get_customers($term, $dt1 = null, $dt2 = null) { |
|
12 | 12 | global $wpdb; |
13 | 13 | $users; |
14 | 14 | switch ($term) { |
15 | 15 | case 'users_all': |
16 | - $query = $wpdb->prepare( "SELECT ID AS USER_ID, '' AS POST_ID FROM {$wpdb->users} WHERE %d", 1); |
|
16 | + $query = $wpdb->prepare("SELECT ID AS USER_ID, '' AS POST_ID FROM {$wpdb->users} WHERE %d", 1); |
|
17 | 17 | $list_users = $wpdb->get_results($query, OBJECT); |
18 | 18 | break; |
19 | 19 | case 'customers_all': |
20 | - $query = $wpdb->prepare( "SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", 'wpshop_shop_order' ); |
|
20 | + $query = $wpdb->prepare("SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", 'wpshop_shop_order'); |
|
21 | 21 | $list_users = $wpdb->get_results($query, OBJECT); |
22 | 22 | break; |
23 | 23 | case 'newsletters_site': |
24 | - $query = $wpdb->prepare( "SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", 'wpshop_shop_order', 'user_preferences', 's:16:"newsletters_site";i:1;', 's:16:"newsletters_site";b:1;' ); |
|
24 | + $query = $wpdb->prepare("SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", 'wpshop_shop_order', 'user_preferences', 's:16:"newsletters_site";i:1;', 's:16:"newsletters_site";b:1;'); |
|
25 | 25 | $list_users = $wpdb->get_results($query, OBJECT); |
26 | 26 | break; |
27 | 27 | case 'newsletters_site_partners': |
28 | - $query = $wpdb->prepare( "SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", 'wpshop_shop_order', 'user_preferences', 's:25:"newsletters_site_partners";i:1;', 's:25:"newsletters_site_partners";b:1;' ); |
|
28 | + $query = $wpdb->prepare("SELECT user_id AS USER_ID, GROUP_CONCAT( ID ) AS POST_ID FROM {$wpdb->usermeta} JOIN {$wpdb->posts} ON post_author = user_id AND post_type = %s WHERE meta_key = %s AND ( meta_value LIKE ('%%%s%%') || meta_value LIKE ('%%%s%%') ) GROUP BY USER_ID", 'wpshop_shop_order', 'user_preferences', 's:25:"newsletters_site_partners";i:1;', 's:25:"newsletters_site_partners";b:1;'); |
|
29 | 29 | $list_users = $wpdb->get_results($query, OBJECT); |
30 | 30 | break; |
31 | 31 | case 'date': |
32 | - $query = $wpdb->prepare( "SELECT us.`ID` AS USER_ID, GROUP_CONCAT( ps.`ID` ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON `post_author` = us.`ID` AND `post_type` = %s WHERE `user_registered` >= %s AND `user_registered` <= %s GROUP BY USER_ID", 'wpshop_shop_order', date("Y-m-j", strtotime($dt1)), date("Y-m-j", strtotime("+1 day", strtotime($dt2))) ); |
|
32 | + $query = $wpdb->prepare("SELECT us.`ID` AS USER_ID, GROUP_CONCAT( ps.`ID` ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON `post_author` = us.`ID` AND `post_type` = %s WHERE `user_registered` >= %s AND `user_registered` <= %s GROUP BY USER_ID", 'wpshop_shop_order', date("Y-m-j", strtotime($dt1)), date("Y-m-j", strtotime("+1 day", strtotime($dt2)))); |
|
33 | 33 | $list_users = $wpdb->get_results($query, OBJECT); |
34 | 34 | break; |
35 | 35 | case 'orders': |
36 | - $query = $wpdb->prepare( "SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", 'wpshop_shop_order' ); |
|
36 | + $query = $wpdb->prepare("SELECT us.ID AS USER_ID, GROUP_CONCAT( ps.ID ) AS POST_ID FROM {$wpdb->users} us JOIN {$wpdb->posts} ps ON us.ID = ps.post_author AND ps.post_type = %s GROUP BY USER_ID", 'wpshop_shop_order'); |
|
37 | 37 | $list_users = $wpdb->get_results($query, OBJECT); |
38 | 38 | break; |
39 | 39 | } |
40 | 40 | $users_array = array(); |
41 | 41 | $users_array[] = array( |
42 | - 'name' => __( 'Name', 'wps_export' ), |
|
43 | - 'first_name' => __( 'First name', 'wps_export' ), |
|
44 | - 'email' => __( 'Mail', 'wps_export' ), |
|
45 | - 'tel' => __( 'Phone', 'wps_export' ), |
|
46 | - 'registered' => __( 'Registered', 'wps_export' ) |
|
42 | + 'name' => __('Name', 'wps_export'), |
|
43 | + 'first_name' => __('First name', 'wps_export'), |
|
44 | + 'email' => __('Mail', 'wps_export'), |
|
45 | + 'tel' => __('Phone', 'wps_export'), |
|
46 | + 'registered' => __('Registered', 'wps_export') |
|
47 | 47 | ); |
48 | - if ( !empty( $list_users ) ) { |
|
48 | + if (!empty($list_users)) { |
|
49 | 49 | $billing_address_indicator = get_option('wpshop_billing_address'); |
50 | 50 | $billing_address_indicator = $billing_address_indicator['choice']; |
51 | - foreach( $list_users as $user_post ) { |
|
52 | - if($term == 'orders') { |
|
51 | + foreach ($list_users as $user_post) { |
|
52 | + if ($term == 'orders') { |
|
53 | 53 | $vuser = false; |
54 | 54 | } |
55 | - $user = get_userdata( $user_post->USER_ID ); |
|
55 | + $user = get_userdata($user_post->USER_ID); |
|
56 | 56 | $tmp_array = array(); |
57 | - $last_name = get_user_meta( $user->ID, 'last_name', true ); |
|
58 | - $first_name = get_user_meta( $user->ID, 'first_name', true ); |
|
59 | - if( empty($last_name) ) |
|
57 | + $last_name = get_user_meta($user->ID, 'last_name', true); |
|
58 | + $first_name = get_user_meta($user->ID, 'first_name', true); |
|
59 | + if (empty($last_name)) |
|
60 | 60 | $last_name = $user->display_name; |
61 | - if( empty($first_name) ) |
|
61 | + if (empty($first_name)) |
|
62 | 62 | $first_name = '-'; |
63 | 63 | $tmp_array['name'] = $last_name; |
64 | 64 | $tmp_array['first_name'] = $first_name; |
65 | 65 | $tmp_array['email'] = $user->user_email; |
66 | 66 | $tmp_array['tel'] = ''; |
67 | 67 | $result = wps_address::get_addresses_list($user->ID); |
68 | - if( !empty($result) && !empty($result[$billing_address_indicator]) ) { |
|
69 | - foreach($result[$billing_address_indicator] as $address_id => $address_data) { |
|
70 | - if( !empty($address_data['phone']) ) { |
|
68 | + if (!empty($result) && !empty($result[$billing_address_indicator])) { |
|
69 | + foreach ($result[$billing_address_indicator] as $address_id => $address_data) { |
|
70 | + if (!empty($address_data['phone'])) { |
|
71 | 71 | $tmp_array['tel'] = $address_data['phone']; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | 75 | $tmp_array['registered'] = date('d M Y H:i', strtotime($user->user_registered)); |
76 | 76 | $posts_id = explode(',', $user_post->POST_ID); |
77 | - $orders = get_posts( array( |
|
77 | + $orders = get_posts(array( |
|
78 | 78 | 'include' => $posts_id, |
79 | 79 | 'post_type' => 'wpshop_shop_order', |
80 | 80 | 'posts_per_page' => -1 |
81 | 81 | )); |
82 | - foreach( $orders as $order ) { |
|
83 | - if($term == 'orders') { |
|
84 | - $command = get_post_meta( $order->ID, '_order_postmeta', true ); |
|
85 | - if( ( !empty($dt1) && !empty($command['order_grand_total']) && $command['order_grand_total'] >= $dt1 ) || ( !empty($dt2) && $dt2===true && $command['order_payment']['customer_choice']['method'] == 'free' ) ) { |
|
82 | + foreach ($orders as $order) { |
|
83 | + if ($term == 'orders') { |
|
84 | + $command = get_post_meta($order->ID, '_order_postmeta', true); |
|
85 | + if ((!empty($dt1) && !empty($command['order_grand_total']) && $command['order_grand_total'] >= $dt1) || (!empty($dt2) && $dt2 === true && $command['order_payment']['customer_choice']['method'] == 'free')) { |
|
86 | 86 | $vuser = true; |
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | - if($term != 'orders') { |
|
90 | + if ($term != 'orders') { |
|
91 | 91 | $users_array[] = $tmp_array; |
92 | - } elseif($vuser) { |
|
92 | + } elseif ($vuser) { |
|
93 | 93 | $users_array[] = $tmp_array; |
94 | 94 | } |
95 | 95 | } |
@@ -104,66 +104,66 @@ discard block |
||
104 | 104 | * @param date $dt2 |
105 | 105 | * @return array |
106 | 106 | */ |
107 | - function get_orders($term, $dt1=null, $dt2=null) { |
|
107 | + function get_orders($term, $dt1 = null, $dt2 = null) { |
|
108 | 108 | $commands_array = array(); |
109 | 109 | $commands_array[] = array( |
110 | - 'order_type' => __( 'Order type', 'wps_export' ), |
|
111 | - 'order_invoice_ref' => __( 'Identifier', 'wps_export' ), |
|
112 | - 'name' => __( 'Name', 'wps_export' ), |
|
113 | - 'first_name' => __( 'First name', 'wps_export' ), |
|
114 | - 'email' => __( 'Mail', 'wps_export' ), |
|
115 | - 'tel' => __( 'Phone', 'wps_export' ), |
|
116 | - 'date_order' => __( 'Order date', 'wps_export' ), |
|
117 | - 'order_total_et' => __( 'Products ET', 'wps_export' ), |
|
118 | - 'order_shipping_cost_et' => __( 'Shipping ET', 'wps_export' ), |
|
119 | - 'order_shipping_cost_ati' => __( 'Shipping ATI', 'wps_export' ), |
|
120 | - 'order_discount_amount' => __( 'Order discount', 'wps_export' ), |
|
121 | - 'order_grand_total' => __( 'Order ATI', 'wps_export' ) |
|
110 | + 'order_type' => __('Order type', 'wps_export'), |
|
111 | + 'order_invoice_ref' => __('Identifier', 'wps_export'), |
|
112 | + 'name' => __('Name', 'wps_export'), |
|
113 | + 'first_name' => __('First name', 'wps_export'), |
|
114 | + 'email' => __('Mail', 'wps_export'), |
|
115 | + 'tel' => __('Phone', 'wps_export'), |
|
116 | + 'date_order' => __('Order date', 'wps_export'), |
|
117 | + 'order_total_et' => __('Products ET', 'wps_export'), |
|
118 | + 'order_shipping_cost_et' => __('Shipping ET', 'wps_export'), |
|
119 | + 'order_shipping_cost_ati' => __('Shipping ATI', 'wps_export'), |
|
120 | + 'order_discount_amount' => __('Order discount', 'wps_export'), |
|
121 | + 'order_grand_total' => __('Order ATI', 'wps_export') |
|
122 | 122 | ); |
123 | - $orders = get_posts( array( |
|
123 | + $orders = get_posts(array( |
|
124 | 124 | 'post_type' => 'wpshop_shop_order', |
125 | 125 | 'posts_per_page' => -1 |
126 | - ) ); |
|
127 | - if ( !empty( $orders ) ) { |
|
128 | - foreach( $orders as $order ) { |
|
129 | - if( !empty($dt1) && strtotime($dt1) <= strtotime($order->post_date) && strtotime($order->post_date) <= strtotime("+1 day", strtotime($dt2)) ) { |
|
126 | + )); |
|
127 | + if (!empty($orders)) { |
|
128 | + foreach ($orders as $order) { |
|
129 | + if (!empty($dt1) && strtotime($dt1) <= strtotime($order->post_date) && strtotime($order->post_date) <= strtotime("+1 day", strtotime($dt2))) { |
|
130 | 130 | $user = get_userdata($order->post_author); |
131 | 131 | $tmp_array = array(); |
132 | - $order_postmeta = get_post_meta( $order->ID, '_order_postmeta', true); |
|
133 | - $tmp_array['order_type'] = ( !empty($order_postmeta['order_invoice_ref']) ) ? __( 'Invoice', 'wps_export' ) : ( ( !empty($order_postmeta['order_key']) ) ? __( 'Order', 'wps_export' ) : __( 'Quotation', 'wps_export' ) ); |
|
134 | - $tmp_array['order_invoice_ref'] = ( !empty($order_postmeta['order_invoice_ref']) ) ? $order_postmeta['order_invoice_ref'] : ( ( !empty($order_postmeta['order_key']) ) ? $order_postmeta['order_key'] : $order_postmeta['order_temporary_key'] ); |
|
135 | - $tmp_array['name'] = ( !empty($user->ID) ) ? get_user_meta( $user->ID, 'last_name', true ) : ''; |
|
136 | - $tmp_array['first_name'] = ( !empty($user->ID) ) ? get_user_meta( $user->ID, 'first_name', true ) : ''; |
|
137 | - $tmp_array['email'] = ( !empty($user->user_email) ) ? $user->user_email : ''; |
|
132 | + $order_postmeta = get_post_meta($order->ID, '_order_postmeta', true); |
|
133 | + $tmp_array['order_type'] = (!empty($order_postmeta['order_invoice_ref'])) ? __('Invoice', 'wps_export') : ((!empty($order_postmeta['order_key'])) ? __('Order', 'wps_export') : __('Quotation', 'wps_export')); |
|
134 | + $tmp_array['order_invoice_ref'] = (!empty($order_postmeta['order_invoice_ref'])) ? $order_postmeta['order_invoice_ref'] : ((!empty($order_postmeta['order_key'])) ? $order_postmeta['order_key'] : $order_postmeta['order_temporary_key']); |
|
135 | + $tmp_array['name'] = (!empty($user->ID)) ? get_user_meta($user->ID, 'last_name', true) : ''; |
|
136 | + $tmp_array['first_name'] = (!empty($user->ID)) ? get_user_meta($user->ID, 'first_name', true) : ''; |
|
137 | + $tmp_array['email'] = (!empty($user->user_email)) ? $user->user_email : ''; |
|
138 | 138 | $tmp_array['tel'] = ''; |
139 | - $order_info = get_post_meta( $order->ID, '_order_info', true); |
|
140 | - if( !empty($order_info) && !empty($order_info['billing']['address']['phone']) ) { |
|
139 | + $order_info = get_post_meta($order->ID, '_order_info', true); |
|
140 | + if (!empty($order_info) && !empty($order_info['billing']['address']['phone'])) { |
|
141 | 141 | $tmp_array['tel'] .= $order_info['billing']['address']['phone']; |
142 | 142 | } |
143 | 143 | $tmp_array['date_order'] = ''; |
144 | - if( !empty($order->post_date) ) { |
|
145 | - $tmp_array['date_order'] = mysql2date( get_option( 'date_format' ), $order->post_date, true ); |
|
144 | + if (!empty($order->post_date)) { |
|
145 | + $tmp_array['date_order'] = mysql2date(get_option('date_format'), $order->post_date, true); |
|
146 | 146 | } |
147 | - $tmp_array['order_total_et'] = number_format( ( !empty($order_postmeta['order_total_ht']) ) ? $order_postmeta['order_total_ht'] : 0, 2, '.', '' ); |
|
147 | + $tmp_array['order_total_et'] = number_format((!empty($order_postmeta['order_total_ht'])) ? $order_postmeta['order_total_ht'] : 0, 2, '.', ''); |
|
148 | 148 | //$tmp_array['order_total_ati'] = number_format( ( !empty($order_postmeta['order_total_ttc']) ) ? $order_postmeta['order_total_ttc'] : 0, 2, '.', '' ); |
149 | - $order_shipping_cost = ( !empty($order_postmeta['order_shipping_cost']) ) ? $order_postmeta['order_shipping_cost'] : 0; |
|
150 | - $price_piloting_option = get_option( 'wpshop_shop_price_piloting' ); |
|
151 | - if( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) { |
|
149 | + $order_shipping_cost = (!empty($order_postmeta['order_shipping_cost'])) ? $order_postmeta['order_shipping_cost'] : 0; |
|
150 | + $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
|
151 | + if (!empty($price_piloting_option) && $price_piloting_option == 'HT') { |
|
152 | 152 | $shipati = $order_shipping_cost * 1.2; |
153 | 153 | $shipet = $order_shipping_cost; |
154 | 154 | } else { |
155 | 155 | $shipet = $order_shipping_cost / 1.2; |
156 | 156 | $shipati = $order_shipping_cost; |
157 | 157 | } |
158 | - $tmp_array['order_shipping_cost_et'] = number_format( $shipet, 2, '.', '' ); |
|
159 | - $tmp_array['order_shipping_cost_ati'] = number_format( $shipati, 2, '.', '' ); |
|
160 | - $tmp_array['order_discount_amount'] = number_format( ( !empty($order_postmeta['order_discount_amount_total_cart']) ) ? $order_postmeta['order_discount_amount_total_cart'] : 0, 2, '.', '' ); |
|
161 | - $tmp_array['order_grand_total'] = number_format( ( !empty($order_postmeta['order_grand_total']) ) ? $order_postmeta['order_grand_total'] : 0, 2, '.', '' ); |
|
158 | + $tmp_array['order_shipping_cost_et'] = number_format($shipet, 2, '.', ''); |
|
159 | + $tmp_array['order_shipping_cost_ati'] = number_format($shipati, 2, '.', ''); |
|
160 | + $tmp_array['order_discount_amount'] = number_format((!empty($order_postmeta['order_discount_amount_total_cart'])) ? $order_postmeta['order_discount_amount_total_cart'] : 0, 2, '.', ''); |
|
161 | + $tmp_array['order_grand_total'] = number_format((!empty($order_postmeta['order_grand_total'])) ? $order_postmeta['order_grand_total'] : 0, 2, '.', ''); |
|
162 | 162 | $commands_array[] = $tmp_array; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | - $commands_array = apply_filters( 'wps_order_export_filter', $commands_array, $orders, $dt1, $dt2 ); |
|
166 | + $commands_array = apply_filters('wps_order_export_filter', $commands_array, $orders, $dt1, $dt2); |
|
167 | 167 | return $commands_array; |
168 | 168 | } |
169 | 169 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_export_mdl { |
3 | 5 | |
4 | 6 | /** |
@@ -56,10 +58,12 @@ discard block |
||
56 | 58 | $tmp_array = array(); |
57 | 59 | $last_name = get_user_meta( $user->ID, 'last_name', true ); |
58 | 60 | $first_name = get_user_meta( $user->ID, 'first_name', true ); |
59 | - if( empty($last_name) ) |
|
60 | - $last_name = $user->display_name; |
|
61 | - if( empty($first_name) ) |
|
62 | - $first_name = '-'; |
|
61 | + if( empty($last_name) ) { |
|
62 | + $last_name = $user->display_name; |
|
63 | + } |
|
64 | + if( empty($first_name) ) { |
|
65 | + $first_name = '-'; |
|
66 | + } |
|
63 | 67 | $tmp_array['name'] = $last_name; |
64 | 68 | $tmp_array['first_name'] = $first_name; |
65 | 69 | $tmp_array['email'] = $user->user_email; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | /** |
5 | 5 | * Get customers with a term: all, newsletters_site, newsletters_site_partners, date(between 2 dates) or if order is higher than. |
6 | 6 | * @param string $term |
7 | - * @param price/date $dt1 may be null |
|
7 | + * @param string|boolean $dt1 may be null |
|
8 | 8 | * @param date $dt2 may be null |
9 | 9 | * @return array |
10 | 10 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * @author ALLEGRE Jérôme - Eoxia dev team <[email protected]> |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | |
10 | 10 | /** Template Global vars **/ |
11 | 11 | DEFINE('WPS_MARKETING_TOOLS_DIR', basename(dirname(__FILE__))); |
12 | -DEFINE('WPS_MARKETING_TOOLS_PATH', str_replace( "\\", "/", str_replace( WPS_MARKETING_TOOLS_DIR, "", dirname( __FILE__ ) ) ) ); |
|
13 | -DEFINE('WPS_MARKETING_TOOLS_URL', str_replace( str_replace( "\\", "/", ABSPATH), site_url() . '/', WPS_MARKETING_TOOLS_PATH ) ); |
|
12 | +DEFINE('WPS_MARKETING_TOOLS_PATH', str_replace("\\", "/", str_replace(WPS_MARKETING_TOOLS_DIR, "", dirname(__FILE__)))); |
|
13 | +DEFINE('WPS_MARKETING_TOOLS_URL', str_replace(str_replace("\\", "/", ABSPATH), site_url() . '/', WPS_MARKETING_TOOLS_PATH)); |
|
14 | 14 | |
15 | 15 | |
16 | 16 | |
17 | -include( plugin_dir_path( __FILE__ ).'/controller/wps_marketing_tools_ctr.php' ); |
|
17 | +include(plugin_dir_path(__FILE__) . '/controller/wps_marketing_tools_ctr.php'); |
|
18 | 18 | // include( plugin_dir_path( __FILE__ ).'/model/wps_message_mdl.php' ); |
19 | 19 | |
20 | 20 | $wps_marketing_tools = new wps_marketing_tools_ctr(); |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_marketing_tools_ctr { |
3 | 3 | /** Define the main directory containing the template for the current plugin |
4 | 4 | * @var string |
@@ -14,25 +14,25 @@ discard block |
||
14 | 14 | // Template loading... |
15 | 15 | $this->template_dir = WPS_MARKETING_TOOLS_PATH . WPS_MARKETING_TOOLS_DIR . "/templates/"; |
16 | 16 | |
17 | - add_action('wsphop_options', array( $this, 'declare_options'), 8); |
|
18 | - add_action('wpshop_free_shipping_cost_alert', array( $this, 'display_free_shipping_cost_alert')); |
|
19 | - add_shortcode('display_save_money_message', array( $this, 'display_save_money_message')); |
|
17 | + add_action('wsphop_options', array($this, 'declare_options'), 8); |
|
18 | + add_action('wpshop_free_shipping_cost_alert', array($this, 'display_free_shipping_cost_alert')); |
|
19 | + add_shortcode('display_save_money_message', array($this, 'display_save_money_message')); |
|
20 | 20 | |
21 | - add_shortcode( 'wps_low_stock_alert', array($this, 'display_alert_stock_message' ) ); |
|
21 | + add_shortcode('wps_low_stock_alert', array($this, 'display_alert_stock_message')); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * OPTIONS - Declare options |
26 | 26 | */ |
27 | - function declare_options () { |
|
28 | - if ( WPSHOP_DEFINED_SHOP_TYPE == 'sale' ) { |
|
29 | - $wpshop_shop_type = !empty( $_POST['wpshop_shop_type'] ) ? sanitize_text_field( $_POST['wpshop_shop_type'] ) : ''; |
|
30 | - $old_wpshop_shop_type = !empty( $_POST['old_wpshop_shop_type'] ) ? sanitize_text_field( $_POST['old_wpshop_shop_type'] ) : ''; |
|
27 | + function declare_options() { |
|
28 | + if (WPSHOP_DEFINED_SHOP_TYPE == 'sale') { |
|
29 | + $wpshop_shop_type = !empty($_POST['wpshop_shop_type']) ? sanitize_text_field($_POST['wpshop_shop_type']) : ''; |
|
30 | + $old_wpshop_shop_type = !empty($_POST['old_wpshop_shop_type']) ? sanitize_text_field($_POST['old_wpshop_shop_type']) : ''; |
|
31 | 31 | |
32 | - if ( ( $wpshop_shop_type == '' || $wpshop_shop_type != 'presentation' ) |
|
33 | - && ( $old_wpshop_shop_type == '' && $old_wpshop_shop_type != 'presentation' ) ) { |
|
32 | + if (($wpshop_shop_type == '' || $wpshop_shop_type != 'presentation') |
|
33 | + && ($old_wpshop_shop_type == '' && $old_wpshop_shop_type != 'presentation')) { |
|
34 | 34 | register_setting('wpshop_options', 'wpshop_cart_option', array($this, 'wpshop_options_validate_free_shipping_cost_alert')); |
35 | - add_settings_field('wpshop_free_shipping_cost_alert', __('Display a free shipping cost alert in the cart', 'wpshop'), array( $this, 'wpshop_free_shipping_cost_alert_field'), 'wpshop_cart_info', 'wpshop_cart_info'); |
|
35 | + add_settings_field('wpshop_free_shipping_cost_alert', __('Display a free shipping cost alert in the cart', 'wpshop'), array($this, 'wpshop_free_shipping_cost_alert_field'), 'wpshop_cart_info', 'wpshop_cart_info'); |
|
36 | 36 | // Low stock alert option |
37 | 37 | register_setting('wpshop_options', 'wpshop_low_stock_alert_options', array($this, 'wpshop_low_stock_alert_validator')); |
38 | 38 | add_settings_field('wpshop_display_low_stock', __('Display Low stock Alert message', 'wpshop'), array($this, 'wpshop_display_low_stock_alert_interface'), 'wpshop_display_option', 'wpshop_display_options_sections'); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * OPTIONS - Display Free Shipping alert option field |
46 | 46 | */ |
47 | - function wpshop_free_shipping_cost_alert_field () { |
|
47 | + function wpshop_free_shipping_cost_alert_field() { |
|
48 | 48 | $cart_option = get_option('wpshop_cart_option'); |
49 | 49 | $input_def = array(); |
50 | 50 | $input_def['name'] = ''; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $input_def['valueToPut'] = 'index'; |
54 | 54 | $input_def['value'] = !empty($cart_option['free_shipping_cost_alert']) ? $cart_option['free_shipping_cost_alert'][0] : ''; |
55 | 55 | $input_def['possible_value'] = 'yes'; |
56 | - $output = wpshop_form::check_input_type($input_def, 'wpshop_cart_option[free_shipping_cost_alert]') . '<a href="#" title="'.__('Check this box if you want to display an free shipping cost in the mini-cart','wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
56 | + $output = wpshop_form::check_input_type($input_def, 'wpshop_cart_option[free_shipping_cost_alert]') . '<a href="#" title="' . __('Check this box if you want to display an free shipping cost in the mini-cart', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
57 | 57 | |
58 | 58 | echo $output; |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param unknown_type $input |
64 | 64 | * @return unknown |
65 | 65 | */ |
66 | - function wpshop_options_validate_free_shipping_cost_alert ($input) { |
|
66 | + function wpshop_options_validate_free_shipping_cost_alert($input) { |
|
67 | 67 | return $input; |
68 | 68 | } |
69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param string $input |
73 | 73 | * @return string |
74 | 74 | */ |
75 | - function wpshop_low_stock_alert_validator ($input) { |
|
75 | + function wpshop_low_stock_alert_validator($input) { |
|
76 | 76 | return $input; |
77 | 77 | } |
78 | 78 | |
@@ -81,48 +81,48 @@ discard block |
||
81 | 81 | */ |
82 | 82 | function wpshop_display_low_stock_alert_interface() { |
83 | 83 | $low_stock_option = get_option('wpshop_low_stock_alert_options'); |
84 | - $activate_low_stock_alert = ( (!empty($low_stock_option) && !empty($low_stock_option['active']) && $low_stock_option['active'] == 'on') ? 'checked="checked"' : null); |
|
85 | - $based_on_stock = ( !empty($low_stock_option) && !empty($low_stock_option['based_on_stock']) && $low_stock_option['based_on_stock'] == 'yes') ? 'checked="checked"' : null; |
|
86 | - $not_based_on_stock = ( !empty($low_stock_option) && !empty($low_stock_option['based_on_stock']) && $low_stock_option['based_on_stock'] == 'no') ? 'checked="checked"' : null; |
|
87 | - $alert_limit = ( !empty($low_stock_option) && !empty($low_stock_option['alert_limit']) ) ? $low_stock_option['alert_limit'] : ''; |
|
84 | + $activate_low_stock_alert = ((!empty($low_stock_option) && !empty($low_stock_option['active']) && $low_stock_option['active'] == 'on') ? 'checked="checked"' : null); |
|
85 | + $based_on_stock = (!empty($low_stock_option) && !empty($low_stock_option['based_on_stock']) && $low_stock_option['based_on_stock'] == 'yes') ? 'checked="checked"' : null; |
|
86 | + $not_based_on_stock = (!empty($low_stock_option) && !empty($low_stock_option['based_on_stock']) && $low_stock_option['based_on_stock'] == 'no') ? 'checked="checked"' : null; |
|
87 | + $alert_limit = (!empty($low_stock_option) && !empty($low_stock_option['alert_limit'])) ? $low_stock_option['alert_limit'] : ''; |
|
88 | 88 | |
89 | - require( wpshop_tools::get_template_part( WPS_MARKETING_TOOLS_DIR, $this->template_dir, "backend", "wps_low_stock_alert_configuration_interface") ); |
|
89 | + require(wpshop_tools::get_template_part(WPS_MARKETING_TOOLS_DIR, $this->template_dir, "backend", "wps_low_stock_alert_configuration_interface")); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Display a free Shipping cost alert in cart and shop |
94 | 94 | */ |
95 | - function display_free_shipping_cost_alert () { |
|
95 | + function display_free_shipping_cost_alert() { |
|
96 | 96 | global $wpdb; |
97 | 97 | |
98 | 98 | $output = ''; |
99 | - $cart = ( !empty($_SESSION['cart']) && is_array($_SESSION['cart']) ) ? $_SESSION['cart'] : null; |
|
99 | + $cart = (!empty($_SESSION['cart']) && is_array($_SESSION['cart'])) ? $_SESSION['cart'] : null; |
|
100 | 100 | $cart_option = get_option('wpshop_cart_option'); |
101 | 101 | $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
102 | 102 | |
103 | 103 | // Get a shipping mode, in order : selected, else default, else first, else shipping_rules. |
104 | - $shipping_modes = get_option( 'wps_shipping_mode' ); |
|
105 | - if( !empty($shipping_modes) && !empty($shipping_modes['modes']) ) { |
|
106 | - if( !empty($shipping_modes['default_choice']) && !empty( $shipping_modes['modes'][$shipping_modes['default_choice']] ) ) { |
|
104 | + $shipping_modes = get_option('wps_shipping_mode'); |
|
105 | + if (!empty($shipping_modes) && !empty($shipping_modes['modes'])) { |
|
106 | + if (!empty($shipping_modes['default_choice']) && !empty($shipping_modes['modes'][$shipping_modes['default_choice']])) { |
|
107 | 107 | $shipping_rules_option = $shipping_modes['modes'][$shipping_modes['default_choice']]; |
108 | - } elseif( !empty($shipping_modes['modes']['default_shipping_mode']) ) { |
|
108 | + } elseif (!empty($shipping_modes['modes']['default_shipping_mode'])) { |
|
109 | 109 | $shipping_rules_option = $shipping_modes['modes']['default_shipping_mode']; |
110 | 110 | } else { |
111 | - $shipping_rules_option = reset( $shipping_modes['modes'] ); |
|
111 | + $shipping_rules_option = reset($shipping_modes['modes']); |
|
112 | 112 | } |
113 | 113 | } else { |
114 | - $shipping_rules_option = get_option( 'wpshop_shipping_rules' ); |
|
114 | + $shipping_rules_option = get_option('wpshop_shipping_rules'); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( !empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0 ) |
|
117 | + if (!empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0) |
|
118 | 118 | $free_shipping_cost_limit = $shipping_rules_option['free_from']; |
119 | - if ( !empty($cart_option) && !empty($cart_option['free_shipping_cost_alert']) ) { |
|
120 | - if ( !empty($cart['order_items']) && !empty($cart['order_grand_total'])) { |
|
121 | - $order_amount = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? number_format((float)$cart['order_total_ht'], 2, '.', '') : number_format((float)$cart['order_total_ttc'], 2, '.', ''); |
|
122 | - if ( $order_amount < $free_shipping_cost_limit ) { |
|
119 | + if (!empty($cart_option) && !empty($cart_option['free_shipping_cost_alert'])) { |
|
120 | + if (!empty($cart['order_items']) && !empty($cart['order_grand_total'])) { |
|
121 | + $order_amount = (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? number_format((float)$cart['order_total_ht'], 2, '.', '') : number_format((float)$cart['order_total_ttc'], 2, '.', ''); |
|
122 | + if ($order_amount < $free_shipping_cost_limit) { |
|
123 | 123 | $free_in = number_format((float)($free_shipping_cost_limit - $order_amount), 2, '.', ''); |
124 | 124 | $currency = wpshop_tools::wpshop_get_currency(); |
125 | - $output = sprintf(__('Free shipping cost in %s', 'wpshop'), $free_in. ' ' . $currency); |
|
125 | + $output = sprintf(__('Free shipping cost in %s', 'wpshop'), $free_in . ' ' . $currency); |
|
126 | 126 | } |
127 | 127 | else { |
128 | 128 | $output = __('Free shipping cost', 'wpshop'); |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | * @param string $price_infos |
138 | 138 | * @return string |
139 | 139 | */ |
140 | - function display_message_you_save_money ( $price_infos ) { |
|
140 | + function display_message_you_save_money($price_infos) { |
|
141 | 141 | $output = ''; |
142 | - if ( !empty($price_infos) ) { |
|
143 | - if ( !empty($price_infos) && !empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist']) ) { |
|
142 | + if (!empty($price_infos)) { |
|
143 | + if (!empty($price_infos) && !empty($price_infos['discount']) && !empty($price_infos['discount']['discount_exist'])) { |
|
144 | 144 | $tax_piloting_option = get_option('wpshop_shop_price_piloting'); |
145 | - $save_amount = ( !empty($tax_piloting_option) && $tax_piloting_option == 'HT') ? ( $price_infos['et'] - $price_infos['discount']['discount_et_price'] ) : ( $price_infos['ati'] - $price_infos['discount']['discount_ati_price'] ); |
|
145 | + $save_amount = (!empty($tax_piloting_option) && $tax_piloting_option == 'HT') ? ($price_infos['et'] - $price_infos['discount']['discount_et_price']) : ($price_infos['ati'] - $price_infos['discount']['discount_ati_price']); |
|
146 | 146 | ob_start(); |
147 | - require( wpshop_tools::get_template_part( WPS_MARKETING_TOOLS_DIR, $this->template_dir, "frontend", "wps_marketing_save_money_message") ); |
|
147 | + require(wpshop_tools::get_template_part(WPS_MARKETING_TOOLS_DIR, $this->template_dir, "frontend", "wps_marketing_save_money_message")); |
|
148 | 148 | $message .= ob_get_contents(); |
149 | 149 | ob_end_clean(); |
150 | 150 | } |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | * @param integer $order_id |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - function display_ecommerce_ga_tracker( $order_id ) { |
|
160 | + function display_ecommerce_ga_tracker($order_id) { |
|
161 | 161 | global $wpdb; |
162 | 162 | $tracker = ''; |
163 | - if( !empty($order_id) ) { |
|
163 | + if (!empty($order_id)) { |
|
164 | 164 | $ga_account_id = get_option('wpshop_ga_account_id'); |
165 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true); |
|
166 | - $order_info = get_post_meta( $order_id, '_order_info', true); |
|
167 | - if( !empty($ga_account_id) && !empty($order_meta) && !empty($order_info) ) { |
|
165 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
166 | + $order_info = get_post_meta($order_id, '_order_info', true); |
|
167 | + if (!empty($ga_account_id) && !empty($order_meta) && !empty($order_info)) { |
|
168 | 168 | ob_start(); |
169 | - require( wpshop_tools::get_template_part( WPS_MARKETING_TOOLS_DIR, $this->template_dir, "backend", "wps_ga_order_tracker") ); |
|
169 | + require(wpshop_tools::get_template_part(WPS_MARKETING_TOOLS_DIR, $this->template_dir, "backend", "wps_ga_order_tracker")); |
|
170 | 170 | $message .= ob_get_contents(); |
171 | 171 | ob_end_clean(); |
172 | 172 | } |
@@ -179,20 +179,20 @@ discard block |
||
179 | 179 | * @param string $args |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - function display_alert_stock_message( $args ) { |
|
182 | + function display_alert_stock_message($args) { |
|
183 | 183 | $message = ''; |
184 | - $post_ID = ( !empty($args) && !empty($args['id']) ) ? $args['id'] : ''; |
|
185 | - $low_stock_alert_option = get_option('wpshop_low_stock_alert_options'); |
|
184 | + $post_ID = (!empty($args) && !empty($args['id'])) ? $args['id'] : ''; |
|
185 | + $low_stock_alert_option = get_option('wpshop_low_stock_alert_options'); |
|
186 | 186 | |
187 | - if ( !empty( $low_stock_alert_option ) && !empty($low_stock_alert_option['active']) && !empty($post_ID) ) { |
|
188 | - $product = wpshop_products::get_product_data( $post_ID ); |
|
187 | + if (!empty($low_stock_alert_option) && !empty($low_stock_alert_option['active']) && !empty($post_ID)) { |
|
188 | + $product = wpshop_products::get_product_data($post_ID); |
|
189 | 189 | |
190 | 190 | $product_stock = $product['product_stock']; |
191 | - $manage_product_stock = (!empty($product['manage_stock']) && ( strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop')) )) ? true : false; |
|
191 | + $manage_product_stock = (!empty($product['manage_stock']) && (strtolower(__($product['manage_stock'], 'wpshop')) == strtolower(__('Yes', 'wpshop')))) ? true : false; |
|
192 | 192 | |
193 | - if ( ( $product_stock > 0 ) && ( empty( $low_stock_alert_option['based_on_stock'] ) || ( ('no' == $low_stock_alert_option['based_on_stock'] ) || ( ( 'yes' == $low_stock_alert_option['based_on_stock'] ) && ( $low_stock_alert_option[ 'alert_limit' ] >= $product_stock ) ) ) ) ) { |
|
193 | + if (($product_stock > 0) && (empty($low_stock_alert_option['based_on_stock']) || (('no' == $low_stock_alert_option['based_on_stock']) || (('yes' == $low_stock_alert_option['based_on_stock']) && ($low_stock_alert_option['alert_limit'] >= $product_stock))))) { |
|
194 | 194 | ob_start(); |
195 | - require( wpshop_tools::get_template_part( WPS_MARKETING_TOOLS_DIR, $this->template_dir, "frontend", "wps_low_stock_alert_message") ); |
|
195 | + require(wpshop_tools::get_template_part(WPS_MARKETING_TOOLS_DIR, $this->template_dir, "frontend", "wps_low_stock_alert_message")); |
|
196 | 196 | $message .= ob_get_contents(); |
197 | 197 | ob_end_clean(); |
198 | 198 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_marketing_tools_ctr { |
3 | 5 | /** Define the main directory containing the template for the current plugin |
4 | 6 | * @var string |
@@ -114,8 +116,9 @@ discard block |
||
114 | 116 | $shipping_rules_option = get_option( 'wpshop_shipping_rules' ); |
115 | 117 | } |
116 | 118 | |
117 | - if ( !empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0 ) |
|
118 | - $free_shipping_cost_limit = $shipping_rules_option['free_from']; |
|
119 | + if ( !empty($shipping_rules_option) && !empty($shipping_rules_option['free_from']) && $shipping_rules_option['free_from'] > 0 ) { |
|
120 | + $free_shipping_cost_limit = $shipping_rules_option['free_from']; |
|
121 | + } |
|
119 | 122 | if ( !empty($cart_option) && !empty($cart_option['free_shipping_cost_alert']) ) { |
120 | 123 | if ( !empty($cart['order_items']) && !empty($cart['order_grand_total'])) { |
121 | 124 | $order_amount = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? number_format((float)$cart['order_total_ht'], 2, '.', '') : number_format((float)$cart['order_total_ttc'], 2, '.', ''); |
@@ -123,8 +126,7 @@ discard block |
||
123 | 126 | $free_in = number_format((float)($free_shipping_cost_limit - $order_amount), 2, '.', ''); |
124 | 127 | $currency = wpshop_tools::wpshop_get_currency(); |
125 | 128 | $output = sprintf(__('Free shipping cost in %s', 'wpshop'), $free_in. ' ' . $currency); |
126 | - } |
|
127 | - else { |
|
129 | + } else { |
|
128 | 130 | $output = __('Free shipping cost', 'wpshop'); |
129 | 131 | } |
130 | 132 | } |
@@ -1,5 +1,5 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <span class="wpshop_save_money_message wps-label-vert"> |
4 | - <?php _e('Saving', 'wpshop'); ?> <?php echo number_format($save_amount,2); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?> |
|
4 | + <?php _e('Saving', 'wpshop'); ?> <?php echo number_format($save_amount, 2); ?> <?php echo wpshop_tools::wpshop_get_currency(); ?> |
|
5 | 5 | </span> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,8 +1,8 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | $extradata = ''; |
3 | -if ( !empty($low_stock_alert_option['based_on_stock']) && $low_stock_alert_option['based_on_stock'] == 'yes' && !empty( $low_stock_alert_option['alert_limit']) ) : ?> |
|
4 | - <?php if ( $product_stock <= $low_stock_alert_option['alert_limit'] ) : |
|
5 | - $extradata = ', '. sprintf( __('%s products in stock', 'wpshop'), number_format( $product_stock, 0 ) ); |
|
3 | +if (!empty($low_stock_alert_option['based_on_stock']) && $low_stock_alert_option['based_on_stock'] == 'yes' && !empty($low_stock_alert_option['alert_limit'])) : ?> |
|
4 | + <?php if ($product_stock <= $low_stock_alert_option['alert_limit']) : |
|
5 | + $extradata = ', ' . sprintf(__('%s products in stock', 'wpshop'), number_format($product_stock, 0)); |
|
6 | 6 | endif; ?> |
7 | 7 | <?php endif; ?> |
8 | 8 | <div class="wps-product-section"> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Fichier de définition du modèle des taxinomies / File for term model definition |
4 | 6 | * |
@@ -1,34 +1,34 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | - $company_infos = get_option( 'wpshop_company_info' ); ?> |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | + $company_infos = get_option('wpshop_company_info'); ?> |
|
3 | 3 | <script type="text/javascript"> |
4 | 4 | var _gaq = _gaq || []; |
5 | 5 | _gaq.push( ['_setAccount', '<?php echo $ga_account_id; ?>'] ); |
6 | 6 | _gaq.push( ['_trackPageview'] ); |
7 | 7 | _gaq.push(['_addTrans', |
8 | 8 | '<?php echo $order_id; ?>', |
9 | - '<?php echo ( !empty($company_infos) && !empty($company_infos['company_name']) ? $company_infos['company_name'] : '' ) ; ?>', |
|
9 | + '<?php echo (!empty($company_infos) && !empty($company_infos['company_name']) ? $company_infos['company_name'] : ''); ?>', |
|
10 | 10 | '<?php echo number_format($order_meta['order_grand_total'], 2, '.', ''); ?>', '<?php echo number_format($total_tva, 2, '.', ''); ?>', |
11 | - '<?php echo ( ( !empty($order_meta['order_shipping_cost']) ) ? $order_meta['order_shipping_cost'] : 0); ?>', |
|
12 | - '<?php echo ( ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['city']) ) ? $order_info['billing']['address']['city'] : ''); ?>', |
|
13 | - '<?php echo ( ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['state']) ) ? $order_info['billing']['address']['state'] : ''); ?>', |
|
14 | - '<?php echo ( ( !empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['country']) ) ? $order_info['billing']['address']['country'] : ''); ?>']); |
|
11 | + '<?php echo ((!empty($order_meta['order_shipping_cost'])) ? $order_meta['order_shipping_cost'] : 0); ?>', |
|
12 | + '<?php echo ((!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['city'])) ? $order_info['billing']['address']['city'] : ''); ?>', |
|
13 | + '<?php echo ((!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['state'])) ? $order_info['billing']['address']['state'] : ''); ?>', |
|
14 | + '<?php echo ((!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['country'])) ? $order_info['billing']['address']['country'] : ''); ?>']); |
|
15 | 15 | |
16 | - <?php if ( !empty( $order_meta['order_items'] ) && is_array( $order_meta['order_items'] ) ) : ?> |
|
17 | - <?php foreach( $order_meta['order_items'] as $item ) : |
|
16 | + <?php if (!empty($order_meta['order_items']) && is_array($order_meta['order_items'])) : ?> |
|
17 | + <?php foreach ($order_meta['order_items'] as $item) : |
|
18 | 18 | /** Variation **/ |
19 | 19 | $variation = ''; |
20 | - $variation_definition = get_post_meta( $item['item_id'], '_wpshop_variations_attribute_def', true); |
|
21 | - if ( !empty($variation_definition) && is_array($variation_definition) ) : |
|
22 | - foreach( $variation_definition as $k => $value ) : |
|
23 | - $attribute_def = wpshop_attributes::getElement( $k, '"valid"', 'code' ); |
|
24 | - if ( !empty($attribute_def) ) : |
|
25 | - $variation .= $attribute_def->frontend_label.' : '; |
|
26 | - if ( $attribute_def->data_type_to_use == 'custom' ) : |
|
27 | - $query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $value ); |
|
28 | - $variation .= $wpdb->get_var( $query ); |
|
20 | + $variation_definition = get_post_meta($item['item_id'], '_wpshop_variations_attribute_def', true); |
|
21 | + if (!empty($variation_definition) && is_array($variation_definition)) : |
|
22 | + foreach ($variation_definition as $k => $value) : |
|
23 | + $attribute_def = wpshop_attributes::getElement($k, '"valid"', 'code'); |
|
24 | + if (!empty($attribute_def)) : |
|
25 | + $variation .= $attribute_def->frontend_label . ' : '; |
|
26 | + if ($attribute_def->data_type_to_use == 'custom') : |
|
27 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $value); |
|
28 | + $variation .= $wpdb->get_var($query); |
|
29 | 29 | |
30 | 30 | else : |
31 | - $variation .= get_the_title( $value ); |
|
31 | + $variation .= get_the_title($value); |
|
32 | 32 | endif; |
33 | 33 | endif; |
34 | 34 | endforeach; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ?> |
38 | 38 | _gaq.push(['_addItem', |
39 | 39 | '<?php echo $order_id; ?>', |
40 | - '<?php echo ( (!empty($item_meta) && !empty($item_meta['barcode']) ) ? $item_meta['barcode'] : ''); ?>', |
|
40 | + '<?php echo ((!empty($item_meta) && !empty($item_meta['barcode'])) ? $item_meta['barcode'] : ''); ?>', |
|
41 | 41 | '<?php echo $item['item_name']; ?>', |
42 | 42 | '<?php echo $variation; ?>', |
43 | 43 | '<?php echo $item['item_pu_ttc']; ?>', |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | $company_infos = get_option( 'wpshop_company_info' ); ?> |
3 | 5 | <script type="text/javascript"> |
4 | 6 | var _gaq = _gaq || []; |
@@ -27,8 +29,10 @@ discard block |
||
27 | 29 | $query = $wpdb->prepare( 'SELECT label FROM ' .WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $value ); |
28 | 30 | $variation .= $wpdb->get_var( $query ); |
29 | 31 | |
30 | - else : |
|
32 | + else { |
|
33 | + : |
|
31 | 34 | $variation .= get_the_title( $value ); |
35 | + } |
|
32 | 36 | endif; |
33 | 37 | endif; |
34 | 38 | endforeach; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * WpShop Breadcrumb bootstrap file |
4 | 4 | * @author Jérôme ALLEGRE - Eoxia dev team <[email protected]> |
@@ -8,21 +8,21 @@ discard block |
||
8 | 8 | * |
9 | 9 | */ |
10 | 10 | |
11 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
12 | - die( __("You are not allowed to use this service.", 'wpshop') ); |
|
11 | +if (!defined('WPSHOP_VERSION')) { |
|
12 | + die(__("You are not allowed to use this service.", 'wpshop')); |
|
13 | 13 | } |
14 | -if ( !class_exists("wpshop_breadcrumb") ) { |
|
14 | +if (!class_exists("wpshop_breadcrumb")) { |
|
15 | 15 | class wpshop_breadcrumb { |
16 | - function __construct () { |
|
17 | - add_filter( 'wpshop_custom_template', array( &$this, 'custom_template_load' ) ); |
|
16 | + function __construct() { |
|
17 | + add_filter('wpshop_custom_template', array(&$this, 'custom_template_load')); |
|
18 | 18 | add_shortcode('wpshop_breadcrumb', array(&$this, 'display_wpshop_breadcrumb')); |
19 | - add_action( 'wp_enqueue_scripts', array( 'wpshop_breadcrumb', 'frontend_css' ) ); |
|
19 | + add_action('wp_enqueue_scripts', array('wpshop_breadcrumb', 'frontend_css')); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function frontend_css() { |
23 | 23 | /** Include CSS **/ |
24 | - wp_register_style( 'wpshop_breadcrumb_css', plugins_url('templates/wpshop/css/wpshop_breadcrumb.css', __FILE__) ); |
|
25 | - wp_enqueue_style( 'wpshop_breadcrumb_css' ); |
|
24 | + wp_register_style('wpshop_breadcrumb_css', plugins_url('templates/wpshop/css/wpshop_breadcrumb.css', __FILE__)); |
|
25 | + wp_enqueue_style('wpshop_breadcrumb_css'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** Load module/addon automatically to existing template list |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return array The template with new elements |
33 | 33 | */ |
34 | - function custom_template_load( $templates ) { |
|
34 | + function custom_template_load($templates) { |
|
35 | 35 | include('templates/wpshop/main_elements.tpl.php'); |
36 | 36 | $wpshop_display = new wpshop_display(); |
37 | - $templates = $wpshop_display->add_modules_template_to_internal( $tpl_element, $templates ); |
|
37 | + $templates = $wpshop_display->add_modules_template_to_internal($tpl_element, $templates); |
|
38 | 38 | unset($tpl_element); |
39 | 39 | |
40 | 40 | return $templates; |
@@ -43,45 +43,45 @@ discard block |
||
43 | 43 | /** |
44 | 44 | * Display the WPShop Breadcrumb |
45 | 45 | */ |
46 | - function display_wpshop_breadcrumb () { |
|
46 | + function display_wpshop_breadcrumb() { |
|
47 | 47 | global $wpdb; global $wp_query; global $wpdb; |
48 | 48 | $output = $breadcrumb = ''; |
49 | 49 | /** Check if the queried object is aproduct or a category **/ |
50 | - if ( !empty($wp_query) && !empty($wp_query->queried_object_id) ) { |
|
50 | + if (!empty($wp_query) && !empty($wp_query->queried_object_id)) { |
|
51 | 51 | $current_id = $wp_query->queried_object_id; |
52 | 52 | $object = $wp_query; |
53 | - $taxonomy = !empty($object->queried_object->taxonomy) ? $object->queried_object->taxonomy : ''; |
|
53 | + $taxonomy = !empty($object->queried_object->taxonomy) ? $object->queried_object->taxonomy : ''; |
|
54 | 54 | $on_product_page = false; |
55 | 55 | /** Check if we are on a product_page OR Taxonomy Page**/ |
56 | - if ( !empty($object->queried_object->post_type) && $object->queried_object->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
56 | + if (!empty($object->queried_object->post_type) && $object->queried_object->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
57 | 57 | $taxonomy = WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES; |
58 | 58 | $breadcrumb_definition = array(); |
59 | - $query = $wpdb->prepare ('SELECT term_taxonomy_id FROM '.$wpdb->term_relationships. ' WHERE object_id = %d', $wp_query->queried_object_id); |
|
60 | - $product_categories = $wpdb->get_results( $query ); |
|
59 | + $query = $wpdb->prepare('SELECT term_taxonomy_id FROM ' . $wpdb->term_relationships . ' WHERE object_id = %d', $wp_query->queried_object_id); |
|
60 | + $product_categories = $wpdb->get_results($query); |
|
61 | 61 | $max = $deeper_category_id = 0; |
62 | - if ( !empty($product_categories) ) { |
|
63 | - foreach( $product_categories as $product_category ) { |
|
64 | - $query = $wpdb->prepare( 'SELECT term_id FROM '.$wpdb->term_taxonomy.' WHERE term_taxonomy_id = %d LIMIT 1',$product_category->term_taxonomy_id ); |
|
65 | - $cat_id = $wpdb->get_var( $query ); |
|
66 | - |
|
67 | - $tmp_breadcrumb_definition = $this->get_breadcrumb ( $cat_id ); |
|
68 | - if ($max <= count( $tmp_breadcrumb_definition ) ) { |
|
69 | - $max = count( $tmp_breadcrumb_definition ); |
|
62 | + if (!empty($product_categories)) { |
|
63 | + foreach ($product_categories as $product_category) { |
|
64 | + $query = $wpdb->prepare('SELECT term_id FROM ' . $wpdb->term_taxonomy . ' WHERE term_taxonomy_id = %d LIMIT 1', $product_category->term_taxonomy_id); |
|
65 | + $cat_id = $wpdb->get_var($query); |
|
66 | + |
|
67 | + $tmp_breadcrumb_definition = $this->get_breadcrumb($cat_id); |
|
68 | + if ($max <= count($tmp_breadcrumb_definition)) { |
|
69 | + $max = count($tmp_breadcrumb_definition); |
|
70 | 70 | $deeper_category_id = $product_category->term_taxonomy_id; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - $deeper_category_id = ( !empty($cat_id) ) ? $cat_id : $deeper_category_id; |
|
76 | - $breadcrumb_definition = $this->get_breadcrumb ( $deeper_category_id ); |
|
75 | + $deeper_category_id = (!empty($cat_id)) ? $cat_id : $deeper_category_id; |
|
76 | + $breadcrumb_definition = $this->get_breadcrumb($deeper_category_id); |
|
77 | 77 | $on_product_page = true; |
78 | 78 | } |
79 | 79 | /** If it is a custom post type **/ |
80 | - elseif( !empty($object->queried_object->post_type) && $object->queried_object->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
81 | - $breadcrumb_definition = $this->get_breadcrumb ( $object->queried_object->ID, 'custom_post_type', $object->queried_object->post_type ); |
|
80 | + elseif (!empty($object->queried_object->post_type) && $object->queried_object->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
81 | + $breadcrumb_definition = $this->get_breadcrumb($object->queried_object->ID, 'custom_post_type', $object->queried_object->post_type); |
|
82 | 82 | } |
83 | - elseif( !empty($object->queried_object->taxonomy) ) { |
|
84 | - $breadcrumb_definition = $this->get_breadcrumb ( $object->queried_object->term_id, 'taxonomy', $object->queried_object->taxonomy ); |
|
83 | + elseif (!empty($object->queried_object->taxonomy)) { |
|
84 | + $breadcrumb_definition = $this->get_breadcrumb($object->queried_object->term_id, 'taxonomy', $object->queried_object->taxonomy); |
|
85 | 85 | } |
86 | 86 | else { |
87 | 87 | $breadcrumb_definition = array(); |
@@ -89,40 +89,40 @@ discard block |
||
89 | 89 | |
90 | 90 | |
91 | 91 | /** Construct the breadcrumb **/ |
92 | - if ( !empty($breadcrumb_definition) ) { |
|
92 | + if (!empty($breadcrumb_definition)) { |
|
93 | 93 | $count_breadcrumb_definition = count($breadcrumb_definition); |
94 | - for ( $i = ($count_breadcrumb_definition - 1); $i >= 0; $i-- ) { |
|
94 | + for ($i = ($count_breadcrumb_definition - 1); $i >= 0; $i--) { |
|
95 | 95 | |
96 | - if ( $breadcrumb_definition[$i]['category_parent_id'] == 0 ) { |
|
96 | + if ($breadcrumb_definition[$i]['category_parent_id'] == 0) { |
|
97 | 97 | $category_name = get_bloginfo(); |
98 | 98 | $category_link = site_url(); |
99 | 99 | } |
100 | 100 | else { |
101 | 101 | |
102 | - if ( !empty($taxonomy) ) { |
|
103 | - $term = get_term( $breadcrumb_definition[$i]['category_parent_id'], $taxonomy ); |
|
104 | - $category_name = (!empty($term) && !empty( $term->name) ) ? $term->name : ''; |
|
105 | - $category_link = (!empty($term) && !empty($term->slug) ) ? get_term_link( $term->slug, $taxonomy ) : ''; |
|
102 | + if (!empty($taxonomy)) { |
|
103 | + $term = get_term($breadcrumb_definition[$i]['category_parent_id'], $taxonomy); |
|
104 | + $category_name = (!empty($term) && !empty($term->name)) ? $term->name : ''; |
|
105 | + $category_link = (!empty($term) && !empty($term->slug)) ? get_term_link($term->slug, $taxonomy) : ''; |
|
106 | 106 | } |
107 | - elseif( !empty($object->queried_object->post_type) && $object->queried_object->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
108 | - $post = get_post( $breadcrumb_definition[$i]['category_parent_id'] ); |
|
107 | + elseif (!empty($object->queried_object->post_type) && $object->queried_object->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
108 | + $post = get_post($breadcrumb_definition[$i]['category_parent_id']); |
|
109 | 109 | $category_name = $post->post_title; |
110 | - $category_link = get_permalink( $breadcrumb_definition[$i]['category_parent_id'] ); |
|
110 | + $category_link = get_permalink($breadcrumb_definition[$i]['category_parent_id']); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
114 | - if ( $i == 0 && !$on_product_page ) { |
|
115 | - $output .= wpshop_display::display_template_element('wpshop_breadcrumb_first_element', array('CATEGORY_NAME' => $category_name ), array(), 'wpshop'); |
|
114 | + if ($i == 0 && !$on_product_page) { |
|
115 | + $output .= wpshop_display::display_template_element('wpshop_breadcrumb_first_element', array('CATEGORY_NAME' => $category_name), array(), 'wpshop'); |
|
116 | 116 | } |
117 | 117 | else { |
118 | 118 | $tpl_component = $sub_tpl_component = array(); |
119 | 119 | $elements_list = $element_list = $tpl_component['OTHERS_CATEGORIES_LIST'] = ''; |
120 | - if( isset( $breadcrumb_definition[$i]['category_parent_id']) ) { |
|
121 | - if ( !empty( $breadcrumb_definition[$i]['category_children'] ) && is_array($breadcrumb_definition[$i]['category_children']) ) { |
|
122 | - foreach( $breadcrumb_definition[$i]['category_children'] as $child_category ) { |
|
123 | - $child_term = get_term( $child_category, $taxonomy ); |
|
120 | + if (isset($breadcrumb_definition[$i]['category_parent_id'])) { |
|
121 | + if (!empty($breadcrumb_definition[$i]['category_children']) && is_array($breadcrumb_definition[$i]['category_children'])) { |
|
122 | + foreach ($breadcrumb_definition[$i]['category_children'] as $child_category) { |
|
123 | + $child_term = get_term($child_category, $taxonomy); |
|
124 | 124 | $child_category_name = $child_term->name; |
125 | - $child_category_link = get_term_link( $child_term->slug, $taxonomy ); |
|
125 | + $child_category_link = get_term_link($child_term->slug, $taxonomy); |
|
126 | 126 | $element_list .= wpshop_display::display_template_element('wpshop_breadcrumb_others_categories_list_element', array('ELEMENT_LIST_CATEGORY_NAME' => $child_category_name, 'ELEMENT_LIST_CATEGORY_LINK' => $child_category_link), array(), 'wpshop'); |
127 | 127 | } |
128 | 128 | |
@@ -132,74 +132,74 @@ discard block |
||
132 | 132 | $tpl_component['OTHERS_CATEGORIES_LIST'] = $elements_list; |
133 | 133 | $tpl_component['CATEGORY_NAME'] = $category_name; |
134 | 134 | $output .= wpshop_display::display_template_element('wpshop_breadcrumb_element', $tpl_component, array(), 'wpshop'); |
135 | - unset( $tpl_component ); |
|
135 | + unset($tpl_component); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | } |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | - if ( !empty($post) && !empty( $post->ID ) && !empty($post->post_type) && $post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
142 | + if (!empty($post) && !empty($post->ID) && !empty($post->post_type) && $post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
143 | 143 | // $tpl_component['CATEGORY_LINK'] = get_permalink( $post->ID ); |
144 | 144 | // $tpl_component['OTHERS_CATEGORIES_LIST'] = ''; |
145 | 145 | // $tpl_component['CATEGORY_NAME'] = $post->post_title; |
146 | 146 | // $output .= wpshop_display::display_template_element('wpshop_breadcrumb_element', $tpl_component, array(), 'wpshop'); |
147 | 147 | |
148 | - $output .= '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="#">' .$post->post_title. '</a></li>'; |
|
148 | + $output .= '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="#">' . $post->post_title . '</a></li>'; |
|
149 | 149 | } |
150 | 150 | $breadcrumb = wpshop_display::display_template_element('wpshop_breadcrumb', array('BREADCRUMB_CONTENT' => $output), array(), 'wpshop'); |
151 | 151 | return $breadcrumb; |
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | - function get_breadcrumb( $current_category_id, $element_type = 'taxonomy', $identifer = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
155 | + function get_breadcrumb($current_category_id, $element_type = 'taxonomy', $identifer = WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
156 | 156 | global $wpdb; |
157 | 157 | $categories_id = array(); |
158 | - if ( isset($current_category_id) ) { |
|
158 | + if (isset($current_category_id)) { |
|
159 | 159 | |
160 | - if ( $element_type == 'taxonomy' || $element_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
160 | + if ($element_type == 'taxonomy' || $element_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
161 | 161 | $first_parent_category = false; |
162 | - if ( !empty($current_category_id) ) { |
|
163 | - $categories_id[] = array('category_parent_id' => $current_category_id, 'category_children' => '' ); |
|
162 | + if (!empty($current_category_id)) { |
|
163 | + $categories_id[] = array('category_parent_id' => $current_category_id, 'category_children' => ''); |
|
164 | 164 | } |
165 | 165 | do { |
166 | 166 | $children_list = array(); |
167 | - $query = $wpdb->prepare( 'SELECT parent FROM ' .$wpdb->term_taxonomy. ' WHERE term_id = %d', $current_category_id ); |
|
168 | - $current_parent_id = $wpdb->get_var( $query ); |
|
169 | - if ( $current_parent_id == 0 ) { |
|
167 | + $query = $wpdb->prepare('SELECT parent FROM ' . $wpdb->term_taxonomy . ' WHERE term_id = %d', $current_category_id); |
|
168 | + $current_parent_id = $wpdb->get_var($query); |
|
169 | + if ($current_parent_id == 0) { |
|
170 | 170 | $first_parent_category = true; |
171 | 171 | } |
172 | 172 | else { |
173 | - $children_list = $this->get_categories_for_parent ( $current_parent_id ); |
|
173 | + $children_list = $this->get_categories_for_parent($current_parent_id); |
|
174 | 174 | } |
175 | - $categories_id[] = array('category_parent_id' => $current_parent_id, 'category_children' => $children_list ); |
|
175 | + $categories_id[] = array('category_parent_id' => $current_parent_id, 'category_children' => $children_list); |
|
176 | 176 | |
177 | 177 | $current_category_id = $current_parent_id; |
178 | - } while ( $first_parent_category == false ); |
|
178 | + } while ($first_parent_category == false); |
|
179 | 179 | } |
180 | - elseif ( $element_type == 'custom_post_type' ) { |
|
181 | - if ( !empty($current_category_id) ) { |
|
182 | - $categories_id[] = array('category_parent_id' => $current_category_id, 'category_children' => array() ); |
|
180 | + elseif ($element_type == 'custom_post_type') { |
|
181 | + if (!empty($current_category_id)) { |
|
182 | + $categories_id[] = array('category_parent_id' => $current_category_id, 'category_children' => array()); |
|
183 | 183 | } |
184 | - if ( $identifer != 'page' ) { |
|
185 | - $categories_id[] = array('category_parent_id' => wpshop_entities::get_entity_identifier_from_code( $identifer ), 'category_children' => array() ); |
|
184 | + if ($identifer != 'page') { |
|
185 | + $categories_id[] = array('category_parent_id' => wpshop_entities::get_entity_identifier_from_code($identifer), 'category_children' => array()); |
|
186 | 186 | } |
187 | - $categories_id[] = array('category_parent_id' => 0, 'category_children' => array() ); |
|
187 | + $categories_id[] = array('category_parent_id' => 0, 'category_children' => array()); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
191 | 191 | return $categories_id; |
192 | 192 | } |
193 | 193 | |
194 | - function get_categories_for_parent ( $parent_id ) { |
|
194 | + function get_categories_for_parent($parent_id) { |
|
195 | 195 | global $wpdb; |
196 | 196 | $children_list = array(); |
197 | - if ( !empty($parent_id) ) { |
|
198 | - $query = $wpdb->prepare('SELECT term_id FROM ' .$wpdb->term_taxonomy. ' WHERE parent = %d', $parent_id); |
|
199 | - $children = $wpdb->get_results( $query ); |
|
197 | + if (!empty($parent_id)) { |
|
198 | + $query = $wpdb->prepare('SELECT term_id FROM ' . $wpdb->term_taxonomy . ' WHERE parent = %d', $parent_id); |
|
199 | + $children = $wpdb->get_results($query); |
|
200 | 200 | |
201 | - if ( !empty( $children ) ) { |
|
202 | - foreach ( $children as $child ) { |
|
201 | + if (!empty($children)) { |
|
202 | + foreach ($children as $child) { |
|
203 | 203 | $children_list[] = $child->term_id; |
204 | 204 | } |
205 | 205 | } |
@@ -210,6 +210,6 @@ discard block |
||
210 | 210 | } |
211 | 211 | |
212 | 212 | /** Instanciate the module utilities if not */ |
213 | -if ( class_exists("wpshop_breadcrumb") ) { |
|
213 | +if (class_exists("wpshop_breadcrumb")) { |
|
214 | 214 | $wpshop_breadcrumb = new wpshop_breadcrumb(); |
215 | 215 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * WpShop Breadcrumb bootstrap file |
4 | 6 | * @author Jérôme ALLEGRE - Eoxia dev team <[email protected]> |
@@ -79,11 +81,9 @@ discard block |
||
79 | 81 | /** If it is a custom post type **/ |
80 | 82 | elseif( !empty($object->queried_object->post_type) && $object->queried_object->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
81 | 83 | $breadcrumb_definition = $this->get_breadcrumb ( $object->queried_object->ID, 'custom_post_type', $object->queried_object->post_type ); |
82 | - } |
|
83 | - elseif( !empty($object->queried_object->taxonomy) ) { |
|
84 | + } elseif( !empty($object->queried_object->taxonomy) ) { |
|
84 | 85 | $breadcrumb_definition = $this->get_breadcrumb ( $object->queried_object->term_id, 'taxonomy', $object->queried_object->taxonomy ); |
85 | - } |
|
86 | - else { |
|
86 | + } else { |
|
87 | 87 | $breadcrumb_definition = array(); |
88 | 88 | } |
89 | 89 | |
@@ -96,15 +96,13 @@ discard block |
||
96 | 96 | if ( $breadcrumb_definition[$i]['category_parent_id'] == 0 ) { |
97 | 97 | $category_name = get_bloginfo(); |
98 | 98 | $category_link = site_url(); |
99 | - } |
|
100 | - else { |
|
99 | + } else { |
|
101 | 100 | |
102 | 101 | if ( !empty($taxonomy) ) { |
103 | 102 | $term = get_term( $breadcrumb_definition[$i]['category_parent_id'], $taxonomy ); |
104 | 103 | $category_name = (!empty($term) && !empty( $term->name) ) ? $term->name : ''; |
105 | 104 | $category_link = (!empty($term) && !empty($term->slug) ) ? get_term_link( $term->slug, $taxonomy ) : ''; |
106 | - } |
|
107 | - elseif( !empty($object->queried_object->post_type) && $object->queried_object->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
105 | + } elseif( !empty($object->queried_object->post_type) && $object->queried_object->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
108 | 106 | $post = get_post( $breadcrumb_definition[$i]['category_parent_id'] ); |
109 | 107 | $category_name = $post->post_title; |
110 | 108 | $category_link = get_permalink( $breadcrumb_definition[$i]['category_parent_id'] ); |
@@ -113,8 +111,7 @@ discard block |
||
113 | 111 | } |
114 | 112 | if ( $i == 0 && !$on_product_page ) { |
115 | 113 | $output .= wpshop_display::display_template_element('wpshop_breadcrumb_first_element', array('CATEGORY_NAME' => $category_name ), array(), 'wpshop'); |
116 | - } |
|
117 | - else { |
|
114 | + } else { |
|
118 | 115 | $tpl_component = $sub_tpl_component = array(); |
119 | 116 | $elements_list = $element_list = $tpl_component['OTHERS_CATEGORIES_LIST'] = ''; |
120 | 117 | if( isset( $breadcrumb_definition[$i]['category_parent_id']) ) { |
@@ -168,16 +165,14 @@ discard block |
||
168 | 165 | $current_parent_id = $wpdb->get_var( $query ); |
169 | 166 | if ( $current_parent_id == 0 ) { |
170 | 167 | $first_parent_category = true; |
171 | - } |
|
172 | - else { |
|
168 | + } else { |
|
173 | 169 | $children_list = $this->get_categories_for_parent ( $current_parent_id ); |
174 | 170 | } |
175 | 171 | $categories_id[] = array('category_parent_id' => $current_parent_id, 'category_children' => $children_list ); |
176 | 172 | |
177 | 173 | $current_category_id = $current_parent_id; |
178 | 174 | } while ( $first_parent_category == false ); |
179 | - } |
|
180 | - elseif ( $element_type == 'custom_post_type' ) { |
|
175 | + } elseif ( $element_type == 'custom_post_type' ) { |
|
181 | 176 | if ( !empty($current_category_id) ) { |
182 | 177 | $categories_id[] = array('category_parent_id' => $current_category_id, 'category_children' => array() ); |
183 | 178 | } |
@@ -20,18 +20,18 @@ discard block |
||
20 | 20 | ini_set('memory_limit', '512M'); |
21 | 21 | |
22 | 22 | /** Check if file is include. No direct access possible with file url */ |
23 | -if ( !defined( 'ABSPATH' ) ) { |
|
24 | - die( 'Access is not allowed by this way' ); |
|
23 | +if (!defined('ABSPATH')) { |
|
24 | + die('Access is not allowed by this way'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** Allows to refresh css and js file in final user browser */ |
28 | 28 | DEFINE('WPSHOP_VERSION', '1.4.1.6'); |
29 | 29 | |
30 | 30 | /** Allows to avoid problem with theme not supporting thumbnail for post */ |
31 | -add_theme_support( 'post-thumbnails' ); |
|
32 | -add_image_size( 'wpshop-product-galery', 270, 270, true ); |
|
33 | -add_image_size( 'wps-categorie-mini-display', 80, 80, true ); |
|
34 | -add_image_size( 'wps-categorie-display', 480, 340, true ); |
|
31 | +add_theme_support('post-thumbnails'); |
|
32 | +add_image_size('wpshop-product-galery', 270, 270, true); |
|
33 | +add_image_size('wps-categorie-mini-display', 80, 80, true); |
|
34 | +add_image_size('wps-categorie-display', 480, 340, true); |
|
35 | 35 | |
36 | 36 | /** First thing we define the main directory for our plugin in a super global var */ |
37 | 37 | DEFINE('WPSHOP_PLUGIN_DIR', basename(dirname(__FILE__))); |
@@ -39,26 +39,26 @@ discard block |
||
39 | 39 | /** Get the current language to translate the different text in plugin */ |
40 | 40 | $locale = get_locale(); |
41 | 41 | global $wpdb; |
42 | -if ( defined("ICL_LANGUAGE_CODE") ) { |
|
42 | +if (defined("ICL_LANGUAGE_CODE")) { |
|
43 | 43 | $query = $wpdb->prepare("SELECT locale FROM " . $wpdb->prefix . "icl_locale_map WHERE code = %s", ICL_LANGUAGE_CODE); |
44 | 44 | $local = $wpdb->get_var($query); |
45 | 45 | $locale = !empty($local) ? $local : $locale; |
46 | 46 | } |
47 | 47 | DEFINE('WPSHOP_CURRENT_LOCALE', $locale); |
48 | 48 | /** Load plugin translation */ |
49 | -load_plugin_textdomain( 'wpshop', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/'); |
|
49 | +load_plugin_textdomain('wpshop', false, dirname(plugin_basename(__FILE__)) . '/languages/'); |
|
50 | 50 | |
51 | 51 | /** Include the config file */ |
52 | 52 | require(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/includes/config.php'); |
53 | 53 | |
54 | 54 | /** Allow to get errors back when debug mode is set to true */ |
55 | -if ( WPSHOP_DEBUG_MODE && (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP)) ) ) { |
|
55 | +if (WPSHOP_DEBUG_MODE && (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP)))) { |
|
56 | 56 | ini_set('display_errors', true); |
57 | 57 | error_reporting(E_ALL); |
58 | 58 | } |
59 | 59 | |
60 | 60 | include_once(WPSHOP_LIBRAIRIES_DIR . 'init.class.php'); |
61 | -$current_installation_step = get_option( 'wps-installation-current-step', 1 ); |
|
61 | +$current_installation_step = get_option('wps-installation-current-step', 1); |
|
62 | 62 | |
63 | 63 | /** Get current plugin version */ |
64 | 64 | $current_db_version = get_option('wpshop_db_options', 0); |
@@ -76,32 +76,32 @@ discard block |
||
76 | 76 | |
77 | 77 | /** Call function to create the main left menu */ |
78 | 78 | //if ( ( WPSINSTALLER_STEPS_COUNT <= $current_installation_step ) || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'db_version' ] ) && ( 51 < $current_db_version[ 'db_version' ] ) ) || ( !empty( $_GET ) && !empty( $_GET[ 'installation_state' ] ) && ( "ignored" == $_GET[ 'installation_state' ] ) ) ) { |
79 | - add_action('admin_menu', array( 'wpshop_init', 'admin_menu' ) ); |
|
80 | - add_action( 'menu_order', array( 'wpshop_init', 'admin_menu_order' ) ); |
|
81 | - add_action( 'custom_menu_order', array( 'wpshop_init', 'admin_custom_menu_order' ) ); |
|
79 | + add_action('admin_menu', array('wpshop_init', 'admin_menu')); |
|
80 | + add_action('menu_order', array('wpshop_init', 'admin_menu_order')); |
|
81 | + add_action('custom_menu_order', array('wpshop_init', 'admin_custom_menu_order')); |
|
82 | 82 | |
83 | 83 | /* Call function for new wordpress element creating [term (product_category) / post (product)] */ |
84 | - add_action( 'init', array( 'wpshop_init', 'add_new_wp_type' ) ); |
|
84 | + add_action('init', array('wpshop_init', 'add_new_wp_type')); |
|
85 | 85 | |
86 | 86 | /* Call function allowing to change element front output */ |
87 | - add_action( 'the_content', array( 'wpshop_display', 'products_page' ), 1 ); |
|
87 | + add_action('the_content', array('wpshop_display', 'products_page'), 1); |
|
88 | 88 | // add_action('archive_template', array('wpshop_categories', 'category_template_switcher')); |
89 | 89 | //} |
90 | 90 | |
91 | 91 | /** On plugin activation create the default parameters to use the ecommerce */ |
92 | -register_activation_hook( __FILE__ , array('wpshop_install', 'install_on_activation') ); |
|
92 | +register_activation_hook(__FILE__, array('wpshop_install', 'install_on_activation')); |
|
93 | 93 | |
94 | 94 | /** On plugin deactivation call the function to clean the wordpress installation */ |
95 | -register_deactivation_hook( __FILE__ , array('wpshop_install', 'uninstall_wpshop') ); |
|
95 | +register_deactivation_hook(__FILE__, array('wpshop_install', 'uninstall_wpshop')); |
|
96 | 96 | |
97 | 97 | /** Get current plugin version */ |
98 | 98 | $current_db_version = get_option('wpshop_db_options', 0); |
99 | 99 | |
100 | 100 | /** Add the database content */ |
101 | 101 | add_action('admin_init', array('wpshop_install', 'update_wpshop')); |
102 | -if ( ( defined( 'WPSINSTALLER_STEPS_COUNT' ) && ( WPSINSTALLER_STEPS_COUNT <= $current_installation_step ) ) || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'db_version' ] ) && ( 51 < $current_db_version[ 'db_version' ] ) ) || ( !empty( $current_db_version ) && !empty( $current_db_version[ 'installation_state' ] ) && ( "ignore" == $current_db_version[ 'installation_state' ] ) ) ) { |
|
103 | - if ( in_array( long2ip( ip2long($_SERVER['REMOTE_ADDR'] ) ), unserialize( WPSHOP_DEBUG_MODE_ALLOWED_IP ) ) ) { |
|
104 | - add_action( 'admin_init', array( 'wpshop_install', 'update_wpshop_dev' ) ); |
|
102 | +if ((defined('WPSINSTALLER_STEPS_COUNT') && (WPSINSTALLER_STEPS_COUNT <= $current_installation_step)) || (!empty($current_db_version) && !empty($current_db_version['db_version']) && (51 < $current_db_version['db_version'])) || (!empty($current_db_version) && !empty($current_db_version['installation_state']) && ("ignore" == $current_db_version['installation_state']))) { |
|
103 | + if (in_array(long2ip(ip2long($_SERVER['REMOTE_ADDR'])), unserialize(WPSHOP_DEBUG_MODE_ALLOWED_IP))) { |
|
104 | + add_action('admin_init', array('wpshop_install', 'update_wpshop_dev')); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * The template for displaying Archive pages. |
4 | 4 | * |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * We reset this later so we can run the loop |
24 | 24 | * properly with a call to rewind_posts(). |
25 | 25 | */ |
26 | - if ( have_posts() ) |
|
26 | + if (have_posts()) |
|
27 | 27 | the_post(); |
28 | 28 | |
29 | 29 | |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | $category_has_content = false; |
35 | 35 | $category_has_sub_content = false; |
36 | 36 | /* Check what must be outputed on the page (Defined in plugin option) */ |
37 | - if(!is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) || in_array('category_description', $wpshop_display_option['wpshop_display_cat_sheet_output'])): |
|
37 | + if (!is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) || in_array('category_description', $wpshop_display_option['wpshop_display_cat_sheet_output'])): |
|
38 | 38 | $category_has_content = true; |
39 | 39 | |
40 | 40 | $taxonomy_informations = get_option(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_' . $wp_query->queried_object->term_id); |
41 | - if ( !empty($taxonomy_informations['wpshop_category_picture']) ) { |
|
42 | - $image_post = wp_get_attachment_image( $taxonomy_informations['wpshop_category_picture'], 'wps-categorie-mini-display', false, array('class' => 'category_thumbnail_preview') ); |
|
41 | + if (!empty($taxonomy_informations['wpshop_category_picture'])) { |
|
42 | + $image_post = wp_get_attachment_image($taxonomy_informations['wpshop_category_picture'], 'wps-categorie-mini-display', false, array('class' => 'category_thumbnail_preview')); |
|
43 | 43 | } |
44 | - $category_thumbnail_preview = ( !empty($image_post) ) ? $image_post : ''; |
|
44 | + $category_thumbnail_preview = (!empty($image_post)) ? $image_post : ''; |
|
45 | 45 | ?> |
46 | 46 | <div class="wps-taxonomy-wrapper"> |
47 | 47 | <?php echo do_shortcode('[wpshop_filter_search]'); ?> |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | <div class="wps-entry-thumbnail"><?php echo $category_thumbnail_preview; ?></div> |
51 | 51 | <div class="wps-entry-caption"> |
52 | 52 | <h1 class="wps-entry-title"><?php echo $wp_query->queried_object->name; ?></h1> |
53 | - <p class="wps-entry-description"><?php echo do_shortcode( wp_trim_words( $wp_query->queried_object->description, 30, ' [...]' ) ); ?></p> |
|
53 | + <p class="wps-entry-description"><?php echo do_shortcode(wp_trim_words($wp_query->queried_object->description, 30, ' [...]')); ?></p> |
|
54 | 54 | </div> |
55 | 55 | </header><!-- .entry-header --> |
56 | 56 | <?php |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | <div class="wps-categorie-wrapper" > |
60 | 60 | <?php |
61 | 61 | /* Check what must be outputed on the page (Defined in plugin option) */ |
62 | - if(!is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) || in_array('category_subcategory', $wpshop_display_option['wpshop_display_cat_sheet_output'])): |
|
62 | + if (!is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) || in_array('category_subcategory', $wpshop_display_option['wpshop_display_cat_sheet_output'])): |
|
63 | 63 | $category_tree = wpshop_categories::category_tree($wp_query->queried_object->term_id); |
64 | - if(is_array($category_tree) && (count($category_tree) > 0)): |
|
64 | + if (is_array($category_tree) && (count($category_tree) > 0)): |
|
65 | 65 | $category_has_content = true; |
66 | 66 | $category_has_sub_content = true; |
67 | 67 | ?> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | <div class="wps-categorie-content <?php echo $wpshop_display_option['wpshop_display_list_type'] ?>wrapper<?php echo $wpshop_display_option['wpshop_display_grid_element_number'] ?>" > |
70 | 70 | <!-- <h2 class="category_content_part_title" ><?php _e('Category\'s sub-category list', 'wpshop'); ?></h2> --> |
71 | 71 | <?php |
72 | - foreach($category_tree as $sub_category_id => $sub_category_content){ |
|
72 | + foreach ($category_tree as $sub_category_id => $sub_category_content) { |
|
73 | 73 | $sub_category_definition = get_term($sub_category_id, WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES); |
74 | 74 | echo wpshop_categories::category_mini_output($sub_category_definition, $output_type); |
75 | 75 | } |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | <?php |
83 | 83 | |
84 | 84 | /* Check what must be outputed on the page (Defined in plugin option) */ |
85 | - if(!is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) || in_array('category_subproduct', $wpshop_display_option['wpshop_display_cat_sheet_output'])): |
|
86 | - if ( count( wpshop_categories::get_product_of_category( $wp_query->queried_object->term_taxonomy_id ) ) > 0 ) : |
|
85 | + if (!is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) || in_array('category_subproduct', $wpshop_display_option['wpshop_display_cat_sheet_output'])): |
|
86 | + if (count(wpshop_categories::get_product_of_category($wp_query->queried_object->term_taxonomy_id)) > 0) : |
|
87 | 87 | $category_has_content = true; |
88 | 88 | $category_has_sub_content = true; |
89 | - echo do_shortcode('[wpshop_products cid="'.$wp_query->queried_object->term_id.'" type="'.$output_type.'"]'); |
|
89 | + echo do_shortcode('[wpshop_products cid="' . $wp_query->queried_object->term_id . '" type="' . $output_type . '"]'); |
|
90 | 90 | endif; |
91 | - elseif(is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) && !in_array('category_subproduct', $wpshop_display_option['wpshop_display_cat_sheet_output'])): |
|
91 | + elseif (is_array($wpshop_display_option['wpshop_display_cat_sheet_output']) && !in_array('category_subproduct', $wpshop_display_option['wpshop_display_cat_sheet_output'])): |
|
92 | 92 | $category_has_sub_content = true; |
93 | 93 | endif; |
94 | 94 | ?> |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * The template for displaying Archive pages. |
4 | 6 | * |
@@ -23,8 +25,9 @@ discard block |
||
23 | 25 | * We reset this later so we can run the loop |
24 | 26 | * properly with a call to rewind_posts(). |
25 | 27 | */ |
26 | - if ( have_posts() ) |
|
27 | - the_post(); |
|
28 | + if ( have_posts() ) { |
|
29 | + the_post(); |
|
30 | + } |
|
28 | 31 | |
29 | 32 | |
30 | 33 | //$wpshop_display_option = get_option('wpshop_display_option'); |