@@ -196,7 +196,6 @@ discard block |
||
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Generate Shipping mode configuration back-office interface |
199 | - * @param string $key |
|
200 | 199 | * @param array $shipping_mode |
201 | 200 | * @return string |
202 | 201 | */ |
@@ -232,7 +231,7 @@ discard block |
||
232 | 231 | /** |
233 | 232 | * Generate cutom fees resume table |
234 | 233 | * @param array $fees_data |
235 | - * @param string $key |
|
234 | + * @param integer|null $shipping_mode_id |
|
236 | 235 | */ |
237 | 236 | function generate_shipping_rules_table( $fees_data, $shipping_mode_id ){ |
238 | 237 | global $wpdb; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_shipping_mode_ctr { |
3 | 3 | |
4 | 4 | /** |
@@ -18,23 +18,23 @@ discard block |
||
18 | 18 | /** Template Load **/ |
19 | 19 | // add_filter( 'wpshop_custom_template', array( $this, 'custom_template_load' ) ); |
20 | 20 | |
21 | - add_action( 'admin_init', array( $this, 'migrate_default_shipping_mode' ) ); |
|
21 | + add_action('admin_init', array($this, 'migrate_default_shipping_mode')); |
|
22 | 22 | |
23 | 23 | /** Add module option to wpshop general options */ |
24 | - add_filter('wpshop_options', array( $this, 'add_options'), 9); |
|
25 | - add_action('wsphop_options', array( $this, 'create_options'), 8); |
|
24 | + add_filter('wpshop_options', array($this, 'add_options'), 9); |
|
25 | + add_action('wsphop_options', array($this, 'create_options'), 8); |
|
26 | 26 | |
27 | 27 | // Add files in back-office |
28 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_in_admin' ) ); |
|
28 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts_in_admin')); |
|
29 | 29 | // Add files in front-office |
30 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts') ); |
|
30 | + add_action('wp_enqueue_scripts', array($this, 'add_scripts')); |
|
31 | 31 | |
32 | 32 | // Available Shortcodes |
33 | - add_shortcode( 'wps_shipping_mode', array( &$this, 'display_shipping_mode') ); |
|
34 | - add_shortcode( 'wps_shipping_method', array( &$this, 'display_shipping_methods') ); |
|
35 | - add_shortcode( 'wps_shipping_summary', array( &$this, 'display_shipping_summary') ); |
|
33 | + add_shortcode('wps_shipping_mode', array(&$this, 'display_shipping_mode')); |
|
34 | + add_shortcode('wps_shipping_method', array(&$this, 'display_shipping_methods')); |
|
35 | + add_shortcode('wps_shipping_summary', array(&$this, 'display_shipping_summary')); |
|
36 | 36 | |
37 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box') ); |
|
37 | + add_action('add_meta_boxes', array($this, 'add_meta_box')); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | function add_meta_box() { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | if (!empty($shipping_option['activate']) && $shipping_option['activate']) { |
45 | 45 | add_meta_box( |
46 | 46 | 'wpshop_order_shipping', |
47 | - '<span class="dashicons dashicons-palmtree"></span> '.__('Shipping', 'wpshop'), |
|
47 | + '<span class="dashicons dashicons-palmtree"></span> ' . __('Shipping', 'wpshop'), |
|
48 | 48 | array($this, 'order_shipping_box'), |
49 | 49 | WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low' |
50 | 50 | ); |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function add_scripts() { |
59 | 59 | //CSS files |
60 | - wp_register_style( 'wps_shipping_mode_css', WPS_SHIPPING_MODE_URL . WPS_SHIPPING_MODE_DIR .'/assets/frontend/css/wps_shipping_mode.css', false ); |
|
61 | - wp_enqueue_style( 'wps_shipping_mode_css' ); |
|
60 | + wp_register_style('wps_shipping_mode_css', WPS_SHIPPING_MODE_URL . WPS_SHIPPING_MODE_DIR . '/assets/frontend/css/wps_shipping_mode.css', false); |
|
61 | + wp_enqueue_style('wps_shipping_mode_css'); |
|
62 | 62 | // Javascript Files |
63 | - wp_enqueue_script( 'jquery' ); |
|
64 | - wp_enqueue_script( 'wps_shipping_method_js', WPS_SHIPPING_MODE_URL . WPS_SHIPPING_MODE_DIR .'/assets/frontend/js/shipping_method.js', false ); |
|
63 | + wp_enqueue_script('jquery'); |
|
64 | + wp_enqueue_script('wps_shipping_method_js', WPS_SHIPPING_MODE_URL . WPS_SHIPPING_MODE_DIR . '/assets/frontend/js/shipping_method.js', false); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | wp_enqueue_script('jquery'); |
73 | 73 | wp_enqueue_script('jquery-ui-sortable'); |
74 | 74 | // Javascript files |
75 | - wp_enqueue_script( 'wps_shipping_mode_js', WPS_SHIPPING_MODE_URL . WPS_SHIPPING_MODE_DIR .'/assets/backend/js/wps_shipping_mode.js', false ); |
|
75 | + wp_enqueue_script('wps_shipping_mode_js', WPS_SHIPPING_MODE_URL . WPS_SHIPPING_MODE_DIR . '/assets/backend/js/wps_shipping_mode.js', false); |
|
76 | 76 | //CSS files |
77 | - wp_register_style( 'wps_shipping_mode_css', WPS_SHIPPING_MODE_URL . WPS_SHIPPING_MODE_DIR .'/assets/backend/css/wps_shipping_mode.css', false ); |
|
78 | - wp_enqueue_style( 'wps_shipping_mode_css' ); |
|
77 | + wp_register_style('wps_shipping_mode_css', WPS_SHIPPING_MODE_URL . WPS_SHIPPING_MODE_DIR . '/assets/backend/css/wps_shipping_mode.css', false); |
|
78 | + wp_enqueue_style('wps_shipping_mode_css'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * Declare option groups for the module |
99 | 99 | */ |
100 | - function add_options( $option_group ) { |
|
100 | + function add_options($option_group) { |
|
101 | 101 | $option_group['wpshop_shipping_option']['subgroups']['wps_shipping_mode']['class'] = ' wpshop_admin_box_options_shipping_mode'; |
102 | 102 | return $option_group; |
103 | 103 | } |
@@ -106,38 +106,38 @@ discard block |
||
106 | 106 | * Create Options |
107 | 107 | **/ |
108 | 108 | function create_options() { |
109 | - add_settings_section('wps_shipping_mode', '<span class="dashicons dashicons-admin-site"></span>'.__('Shipping method', 'wpshop'), '', 'wps_shipping_mode'); |
|
110 | - register_setting('wpshop_options', 'wps_shipping_mode', array( $this, 'wpshop_options_validate_wps_shipping_mode')); |
|
111 | - add_settings_field('wps_shipping_mode', ''/*__('Shipping Mode', 'wpshop')*/, array( $this, 'display_shipping_mode_in_admin'), 'wps_shipping_mode', 'wps_shipping_mode'); |
|
109 | + add_settings_section('wps_shipping_mode', '<span class="dashicons dashicons-admin-site"></span>' . __('Shipping method', 'wpshop'), '', 'wps_shipping_mode'); |
|
110 | + register_setting('wpshop_options', 'wps_shipping_mode', array($this, 'wpshop_options_validate_wps_shipping_mode')); |
|
111 | + add_settings_field('wps_shipping_mode', ''/*__('Shipping Mode', 'wpshop')*/, array($this, 'display_shipping_mode_in_admin'), 'wps_shipping_mode', 'wps_shipping_mode'); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * WPS Shipping mode Option Validator |
116 | 116 | **/ |
117 | - function wpshop_options_validate_wps_shipping_mode( $input ) { |
|
117 | + function wpshop_options_validate_wps_shipping_mode($input) { |
|
118 | 118 | $wps_shipping = new wps_shipping(); |
119 | - if ( !empty($input['modes']) ) { |
|
120 | - foreach( $input['modes'] as $mode => $mode_det ) { |
|
119 | + if (!empty($input['modes'])) { |
|
120 | + foreach ($input['modes'] as $mode => $mode_det) { |
|
121 | 121 | /** Custom Shipping rules **/ |
122 | - $input['modes'][$mode]['custom_shipping_rules']['fees'] = $wps_shipping->shipping_fees_string_2_array( $input['modes'][$mode]['custom_shipping_rules']['fees'] ); |
|
122 | + $input['modes'][$mode]['custom_shipping_rules']['fees'] = $wps_shipping->shipping_fees_string_2_array($input['modes'][$mode]['custom_shipping_rules']['fees']); |
|
123 | 123 | |
124 | 124 | /** Shipping Modes Logo Treatment **/ |
125 | - if ( !empty($_FILES[$mode.'_logo']['name']) && empty($_FILES[$mode.'_logo']['error']) ) { |
|
126 | - $filename = $_FILES[$mode.'_logo']; |
|
127 | - $upload = wp_handle_upload($filename, array('test_form' => false)); |
|
128 | - $wp_filetype = wp_check_filetype(basename($filename['name']), null ); |
|
125 | + if (!empty($_FILES[$mode . '_logo']['name']) && empty($_FILES[$mode . '_logo']['error'])) { |
|
126 | + $filename = $_FILES[$mode . '_logo']; |
|
127 | + $upload = wp_handle_upload($filename, array('test_form' => false)); |
|
128 | + $wp_filetype = wp_check_filetype(basename($filename['name']), null); |
|
129 | 129 | $wp_upload_dir = wp_upload_dir(); |
130 | 130 | $attachment = array( |
131 | - 'guid' => $wp_upload_dir['url'] . '/' . basename( $filename['name'] ), |
|
131 | + 'guid' => $wp_upload_dir['url'] . '/' . basename($filename['name']), |
|
132 | 132 | 'post_mime_type' => $wp_filetype['type'], |
133 | 133 | 'post_title' => preg_replace(' /\.[^.]+$/', '', basename($filename['name'])), |
134 | 134 | 'post_content' => '', |
135 | 135 | 'post_status' => 'inherit' |
136 | 136 | ); |
137 | - $attach_id = wp_insert_attachment( $attachment, $upload['file']); |
|
137 | + $attach_id = wp_insert_attachment($attachment, $upload['file']); |
|
138 | 138 | require_once(ABSPATH . 'wp-admin/includes/image.php'); |
139 | - $attach_data = wp_generate_attachment_metadata( $attach_id, $upload['file'] ); |
|
140 | - wp_update_attachment_metadata( $attach_id, $attach_data ); |
|
139 | + $attach_data = wp_generate_attachment_metadata($attach_id, $upload['file']); |
|
140 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
141 | 141 | |
142 | 142 | $input['modes'][$mode]['logo'] = $attach_id; |
143 | 143 | } |
@@ -151,38 +151,38 @@ discard block |
||
151 | 151 | **/ |
152 | 152 | function migrate_default_shipping_mode() { |
153 | 153 | $data = array(); |
154 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
155 | - if ( empty($shipping_mode_option) ) { |
|
154 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
155 | + if (empty($shipping_mode_option)) { |
|
156 | 156 | $data['modes']['default_shipping_mode']['active'] = 'on'; |
157 | 157 | $data['modes']['default_shipping_mode']['name'] = __('Home Delivery', 'wpshop'); |
158 | 158 | $data['modes']['default_shipping_mode']['explanation'] = __('Your purchase will be delivered directly to you at home', 'wpshop'); |
159 | 159 | /** Check CUstom Shipping **/ |
160 | - $custom_shipping_option = get_option( 'wpshop_custom_shipping' ); |
|
161 | - if ( !empty($custom_shipping_option) ) { |
|
160 | + $custom_shipping_option = get_option('wpshop_custom_shipping'); |
|
161 | + if (!empty($custom_shipping_option)) { |
|
162 | 162 | $data['modes']['default_shipping_mode']['custom_shipping_rules'] = $custom_shipping_option; |
163 | 163 | } |
164 | 164 | /** Check Country Limit **/ |
165 | - $limit_destination = get_option( 'wpshop_limit_shipping_destination' ); |
|
166 | - if ( !empty($custom_shipping_option) ) { |
|
165 | + $limit_destination = get_option('wpshop_limit_shipping_destination'); |
|
166 | + if (!empty($custom_shipping_option)) { |
|
167 | 167 | $data['modes']['default_shipping_mode']['limit_destination'] = $limit_destination; |
168 | 168 | } |
169 | 169 | |
170 | 170 | /** Check Others shipping configurations **/ |
171 | 171 | $wpshop_shipping_rules_option = get_option('wpshop_shipping_rules'); |
172 | - if ( !empty($wpshop_shipping_rules_option) ){ |
|
173 | - if ( !empty($wpshop_shipping_rules_option['min_max']) ) { |
|
172 | + if (!empty($wpshop_shipping_rules_option)) { |
|
173 | + if (!empty($wpshop_shipping_rules_option['min_max'])) { |
|
174 | 174 | $data['modes']['default_shipping_mode']['min_max'] = $wpshop_shipping_rules_option['min_max']; |
175 | 175 | } |
176 | - if ( !empty($wpshop_shipping_rules_option['free_from']) ) { |
|
176 | + if (!empty($wpshop_shipping_rules_option['free_from'])) { |
|
177 | 177 | $data['modes']['default_shipping_mode']['free_from'] = $wpshop_shipping_rules_option['free_from']; |
178 | 178 | } |
179 | - if ( !empty($wpshop_shipping_rules_option['wpshop_shipping_rule_free_shipping']) ) { |
|
179 | + if (!empty($wpshop_shipping_rules_option['wpshop_shipping_rule_free_shipping'])) { |
|
180 | 180 | $data['modes']['default_shipping_mode']['free_shipping'] = $wpshop_shipping_rules_option['wpshop_shipping_rule_free_shipping']; |
181 | 181 | } |
182 | 182 | } |
183 | 183 | $data['default_choice'] = 'default_shipping_mode'; |
184 | 184 | |
185 | - update_option( 'wps_shipping_mode', $data ); |
|
185 | + update_option('wps_shipping_mode', $data); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * Display the Admin Interface for Shipping Mode |
191 | 191 | **/ |
192 | 192 | function display_shipping_mode_in_admin() { |
193 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
194 | - require_once( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, "backend", "shipping-modes") ); |
|
193 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
194 | + require_once(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $this->template_dir, "backend", "shipping-modes")); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -200,28 +200,28 @@ discard block |
||
200 | 200 | * @param array $shipping_mode |
201 | 201 | * @return string |
202 | 202 | */ |
203 | - function generate_shipping_mode_interface( $k, $shipping_mode ) { |
|
203 | + function generate_shipping_mode_interface($k, $shipping_mode) { |
|
204 | 204 | global $wpdb; |
205 | 205 | $tpl_component = array(); |
206 | 206 | |
207 | - $shipping_mode_option = get_option( 'wps_shipping_mode'); |
|
208 | - $default_shipping_mode = !empty( $shipping_mode_option['default_choice'] ) ? $shipping_mode_option['default_choice'] : ''; |
|
207 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
208 | + $default_shipping_mode = !empty($shipping_mode_option['default_choice']) ? $shipping_mode_option['default_choice'] : ''; |
|
209 | 209 | |
210 | 210 | $countries = unserialize(WPSHOP_COUNTRY_LIST); |
211 | 211 | |
212 | 212 | /** Default Weight Unity **/ |
213 | - $weight_defaut_unity_option = get_option ('wpshop_shop_default_weight_unity'); |
|
214 | - $query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
215 | - $unity = $wpdb->get_var( $query ); |
|
213 | + $weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity'); |
|
214 | + $query = $wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
215 | + $unity = $wpdb->get_var($query); |
|
216 | 216 | |
217 | 217 | |
218 | - $fees_data = ( !empty($shipping_mode) & !empty($shipping_mode['custom_shipping_rules']) && !empty($shipping_mode['custom_shipping_rules']['fees']) ) ? $shipping_mode['custom_shipping_rules']['fees'] : array(); |
|
219 | - if(is_array($fees_data)) { |
|
218 | + $fees_data = (!empty($shipping_mode) & !empty($shipping_mode['custom_shipping_rules']) && !empty($shipping_mode['custom_shipping_rules']['fees'])) ? $shipping_mode['custom_shipping_rules']['fees'] : array(); |
|
219 | + if (is_array($fees_data)) { |
|
220 | 220 | $wps_shipping = new wps_shipping(); |
221 | 221 | $fees_data = $wps_shipping->shipping_fees_array_2_string($fees_data); |
222 | 222 | } |
223 | 223 | ob_start(); |
224 | - require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, "backend", "shipping-mode-configuration-interface") ); |
|
224 | + require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $this->template_dir, "backend", "shipping-mode-configuration-interface")); |
|
225 | 225 | $output = ob_get_contents(); |
226 | 226 | ob_end_clean(); |
227 | 227 | |
@@ -234,22 +234,22 @@ discard block |
||
234 | 234 | * @param array $fees_data |
235 | 235 | * @param string $key |
236 | 236 | */ |
237 | - function generate_shipping_rules_table( $fees_data, $shipping_mode_id ){ |
|
237 | + function generate_shipping_rules_table($fees_data, $shipping_mode_id) { |
|
238 | 238 | global $wpdb; |
239 | 239 | $result = ''; |
240 | - if ( !empty( $fees_data) ) { |
|
240 | + if (!empty($fees_data)) { |
|
241 | 241 | $wps_shipping = new wps_shipping(); |
242 | - $shipping_rules =$wps_shipping->shipping_fees_string_2_array( stripslashes($fees_data) ); |
|
242 | + $shipping_rules = $wps_shipping->shipping_fees_string_2_array(stripslashes($fees_data)); |
|
243 | 243 | $result = ''; |
244 | - $tpl_component =''; |
|
244 | + $tpl_component = ''; |
|
245 | 245 | $tpl_component['CUSTOM_SHIPPING_RULES_LINES'] = ''; |
246 | 246 | $tpl_component['SHIPPING_MODE_ID'] = $shipping_mode_id; |
247 | 247 | $country_list = unserialize(WPSHOP_COUNTRY_LIST); |
248 | - $weight_defaut_unity_option = get_option ('wpshop_shop_default_weight_unity'); |
|
249 | - $query = $wpdb->prepare('SELECT unit FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
250 | - $unity = $wpdb->get_var( $query ); |
|
248 | + $weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity'); |
|
249 | + $query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
250 | + $unity = $wpdb->get_var($query); |
|
251 | 251 | ob_start(); |
252 | - require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, "backend", "shipping-mode-configuration-custom-rules-table") ); |
|
252 | + require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $this->template_dir, "backend", "shipping-mode-configuration-custom-rules-table")); |
|
253 | 253 | $result = ob_get_contents(); |
254 | 254 | ob_end_clean(); |
255 | 255 | } |
@@ -269,16 +269,16 @@ discard block |
||
269 | 269 | */ |
270 | 270 | function display_shipping_methods() { |
271 | 271 | $output = $shipping_methods = ''; $no_shipping_mode_for_area = false; |
272 | - $shipping_modes = get_option( 'wps_shipping_mode' ); |
|
273 | - if( !empty($_SESSION['shipping_address']) ) { |
|
274 | - $shipping_modes = $this->get_shipping_mode_for_address( $_SESSION['shipping_address'] ); |
|
275 | - if( empty($shipping_modes) ) { |
|
272 | + $shipping_modes = get_option('wps_shipping_mode'); |
|
273 | + if (!empty($_SESSION['shipping_address'])) { |
|
274 | + $shipping_modes = $this->get_shipping_mode_for_address($_SESSION['shipping_address']); |
|
275 | + if (empty($shipping_modes)) { |
|
276 | 276 | $no_shipping_mode_for_area = true; |
277 | 277 | } |
278 | 278 | } |
279 | - $shipping_modes = apply_filters( 'wps_filter_shipping_methods', $shipping_modes ); |
|
279 | + $shipping_modes = apply_filters('wps_filter_shipping_methods', $shipping_modes); |
|
280 | 280 | ob_start(); |
281 | - require_once( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, "frontend", "shipping-mode", "container") ); |
|
281 | + require_once(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $this->template_dir, "frontend", "shipping-mode", "container")); |
|
282 | 282 | $output = ob_get_contents(); |
283 | 283 | ob_end_clean(); |
284 | 284 | |
@@ -291,24 +291,24 @@ discard block |
||
291 | 291 | */ |
292 | 292 | function display_shipping_summary() { |
293 | 293 | $output = ''; |
294 | - $billing_address_id = ( !empty($_SESSION['billing_address']) ) ? $_SESSION['billing_address'] : null; |
|
295 | - $shipping_address_id = ( !empty($_SESSION['shipping_address']) ) ? $_SESSION['shipping_address'] : null; |
|
296 | - $shipping_mode = ( !empty($_SESSION['shipping_method']) ) ? $_SESSION['shipping_method'] : null; |
|
294 | + $billing_address_id = (!empty($_SESSION['billing_address'])) ? $_SESSION['billing_address'] : null; |
|
295 | + $shipping_address_id = (!empty($_SESSION['shipping_address'])) ? $_SESSION['shipping_address'] : null; |
|
296 | + $shipping_mode = (!empty($_SESSION['shipping_method'])) ? $_SESSION['shipping_method'] : null; |
|
297 | 297 | |
298 | - if( !empty($billing_address_id) ) { |
|
298 | + if (!empty($billing_address_id)) { |
|
299 | 299 | $billing_infos = get_post_meta($billing_address_id, '_wpshop_address_metadata', true); |
300 | - $billing_content = wps_address::display_an_address( $billing_infos, $billing_address_id); |
|
300 | + $billing_content = wps_address::display_an_address($billing_infos, $billing_address_id); |
|
301 | 301 | |
302 | - if ( !empty($shipping_address_id) && !empty($shipping_mode) ) { |
|
302 | + if (!empty($shipping_address_id) && !empty($shipping_mode)) { |
|
303 | 303 | $shipping_infos = get_post_meta($shipping_address_id, '_wpshop_address_metadata', true); |
304 | - $shipping_content = wps_address::display_an_address( $shipping_infos, $shipping_address_id); |
|
304 | + $shipping_content = wps_address::display_an_address($shipping_infos, $shipping_address_id); |
|
305 | 305 | |
306 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
307 | - $shipping_mode = ( !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && !empty($shipping_mode_option['modes'][$shipping_mode]) && !empty($shipping_mode_option['modes'][$shipping_mode]['name']) ) ? $shipping_mode_option['modes'][$shipping_mode]['name'] : ''; |
|
306 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
307 | + $shipping_mode = (!empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && !empty($shipping_mode_option['modes'][$shipping_mode]) && !empty($shipping_mode_option['modes'][$shipping_mode]['name'])) ? $shipping_mode_option['modes'][$shipping_mode]['name'] : ''; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | ob_start(); |
311 | - require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, "frontend", "shipping-infos", "summary") ); |
|
311 | + require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $this->template_dir, "frontend", "shipping-infos", "summary")); |
|
312 | 312 | $output = ob_get_contents(); |
313 | 313 | ob_end_clean(); |
314 | 314 | } |
@@ -322,42 +322,42 @@ discard block |
||
322 | 322 | * @param integer $address_id |
323 | 323 | * @return string |
324 | 324 | */ |
325 | - function get_shipping_mode_for_address( $address_id ) { |
|
325 | + function get_shipping_mode_for_address($address_id) { |
|
326 | 326 | $shipping_modes_to_display = array(); |
327 | - if( !empty($address_id) ) { |
|
328 | - $shipping_modes = get_option( 'wps_shipping_mode' ); |
|
329 | - $address_metadata = /*isset( $postcode ) ? array( 'postcode' => $postcode ) :*/ get_post_meta( $address_id, '_wpshop_address_metadata', true); |
|
330 | - if( !empty( $shipping_modes ) && !empty($shipping_modes['modes']) ){ |
|
331 | - foreach( $shipping_modes['modes'] as $k => $shipping_mode ) { |
|
332 | - if ( !empty($shipping_mode) && !empty($shipping_mode['active']) ) { |
|
327 | + if (!empty($address_id)) { |
|
328 | + $shipping_modes = get_option('wps_shipping_mode'); |
|
329 | + $address_metadata = /*isset( $postcode ) ? array( 'postcode' => $postcode ) :*/ get_post_meta($address_id, '_wpshop_address_metadata', true); |
|
330 | + if (!empty($shipping_modes) && !empty($shipping_modes['modes'])) { |
|
331 | + foreach ($shipping_modes['modes'] as $k => $shipping_mode) { |
|
332 | + if (!empty($shipping_mode) && !empty($shipping_mode['active'])) { |
|
333 | 333 | /** Check Country Shipping Limitation **/ |
334 | - if ( empty($shipping_mode['limit_destination']) || ( !empty($shipping_mode['limit_destination']) && empty($shipping_mode['limit_destination']['country']) ) || ( !empty($shipping_mode['limit_destination']) && !empty($shipping_mode['limit_destination']['country']) && in_array($address_metadata['country'], $shipping_mode['limit_destination']['country']) ) ) { |
|
334 | + if (empty($shipping_mode['limit_destination']) || (!empty($shipping_mode['limit_destination']) && empty($shipping_mode['limit_destination']['country'])) || (!empty($shipping_mode['limit_destination']) && !empty($shipping_mode['limit_destination']['country']) && in_array($address_metadata['country'], $shipping_mode['limit_destination']['country']))) { |
|
335 | 335 | /** Check Limit Destination By Postcode **/ |
336 | 336 | $visible = true; |
337 | 337 | /** Check Postcode limitation **/ |
338 | - if ( !empty($shipping_mode['limit_destination']) && !empty($shipping_mode['limit_destination']['postcode']) ) { |
|
339 | - $postcodes = explode(',', $shipping_mode['limit_destination']['postcode'] ); |
|
340 | - foreach( $postcodes as $postcode_id => $postcode ) { |
|
341 | - $postcodes[ $postcode_id ] = trim( str_replace( ' ', '', $postcode) ); |
|
338 | + if (!empty($shipping_mode['limit_destination']) && !empty($shipping_mode['limit_destination']['postcode'])) { |
|
339 | + $postcodes = explode(',', $shipping_mode['limit_destination']['postcode']); |
|
340 | + foreach ($postcodes as $postcode_id => $postcode) { |
|
341 | + $postcodes[$postcode_id] = trim(str_replace(' ', '', $postcode)); |
|
342 | 342 | } |
343 | - if ( !in_array($address_metadata['postcode'], $postcodes) ) { |
|
343 | + if (!in_array($address_metadata['postcode'], $postcodes)) { |
|
344 | 344 | $visible = false; |
345 | 345 | } |
346 | 346 | } |
347 | 347 | /** Check Department limitation **/ |
348 | - $department = substr( $address_metadata['postcode'], 0, 2 ); |
|
349 | - if ( !empty($shipping_mode['limit_destination']) && !empty($shipping_mode['limit_destination']['department']) ) { |
|
350 | - $departments = explode(',', $shipping_mode['limit_destination']['department'] ); |
|
351 | - foreach( $departments as $department_id => $d ) { |
|
352 | - $departments[ $department_id ] = trim( str_replace( ' ', '', $d) ); |
|
348 | + $department = substr($address_metadata['postcode'], 0, 2); |
|
349 | + if (!empty($shipping_mode['limit_destination']) && !empty($shipping_mode['limit_destination']['department'])) { |
|
350 | + $departments = explode(',', $shipping_mode['limit_destination']['department']); |
|
351 | + foreach ($departments as $department_id => $d) { |
|
352 | + $departments[$department_id] = trim(str_replace(' ', '', $d)); |
|
353 | 353 | } |
354 | 354 | |
355 | - if ( !in_array($department, $departments) ) { |
|
355 | + if (!in_array($department, $departments)) { |
|
356 | 356 | $visible = false; |
357 | 357 | } |
358 | 358 | } |
359 | 359 | |
360 | - if ( $visible ) { |
|
360 | + if ($visible) { |
|
361 | 361 | $shipping_modes_to_display['modes'][$k] = $shipping_mode; |
362 | 362 | } |
363 | 363 | } |
@@ -373,12 +373,12 @@ discard block |
||
373 | 373 | * Display shipping informations in order administration panel |
374 | 374 | * @param object $order : Order post infos |
375 | 375 | */ |
376 | - function order_shipping_box( $order ) { |
|
377 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
376 | + function order_shipping_box($order) { |
|
377 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
378 | 378 | $order_postmeta = get_post_meta($order->ID, '_order_postmeta', true); |
379 | - $shipping_method_name = ( !empty($order_postmeta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_postmeta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_postmeta['order_payment']['shipping_method']]['name'] : ( (!empty($order_postmeta['order_payment']['shipping_method']) ) ? $order_postmeta['order_payment']['shipping_method'] : '' ); |
|
379 | + $shipping_method_name = (!empty($order_postmeta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_postmeta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_postmeta['order_payment']['shipping_method']]['name'] : ((!empty($order_postmeta['order_payment']['shipping_method'])) ? $order_postmeta['order_payment']['shipping_method'] : ''); |
|
380 | 380 | ob_start(); |
381 | - require( wpshop_tools::get_template_part( WPS_SHIPPING_MODE_DIR, $this->template_dir, "backend", "order-shipping-infos") ); |
|
381 | + require(wpshop_tools::get_template_part(WPS_SHIPPING_MODE_DIR, $this->template_dir, "backend", "order-shipping-infos")); |
|
382 | 382 | $output = ob_get_contents(); |
383 | 383 | ob_end_clean(); |
384 | 384 | echo $output; |
@@ -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 | * |
@@ -207,6 +207,9 @@ |
||
207 | 207 | return $shortcodes; |
208 | 208 | } |
209 | 209 | |
210 | + /** |
|
211 | + * @param string $shortcode_code |
|
212 | + */ |
|
210 | 213 | public static function output_shortcode($shortcode_code, $specific_shorcode = '', $more_class_shortcode_helper = ''){ |
211 | 214 | $shortcode = ( empty($specific_shorcode) ? self::shortcode_definition() : $specific_shorcode ); |
212 | 215 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | class wps_shortcodes_ctr |
4 | 4 | { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return string The table of the class |
31 | 31 | */ |
32 | - function setMessage($message){ |
|
32 | + function setMessage($message) { |
|
33 | 33 | $this->pageMessage = $message; |
34 | 34 | } |
35 | 35 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return string The table of the class |
39 | 39 | */ |
40 | - function getListingSlug(){ |
|
40 | + function getListingSlug() { |
|
41 | 41 | return self::urlSlugListing; |
42 | 42 | } |
43 | 43 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return string The table of the class |
47 | 47 | */ |
48 | - function getEditionSlug(){ |
|
48 | + function getEditionSlug() { |
|
49 | 49 | return self::urlSlugEdition; |
50 | 50 | } |
51 | 51 | /** |
@@ -58,33 +58,33 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return string $title The title of the page looking at the environnement |
60 | 60 | */ |
61 | - function pageTitle(){ |
|
61 | + function pageTitle() { |
|
62 | 62 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : ''; |
63 | 63 | $objectInEdition = isset($_REQUEST['id']) ? wpshop_tools::varSanitizer($_REQUEST['id']) : ''; |
64 | - $page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
64 | + $page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
65 | 65 | |
66 | - $title = __(self::pageTitle, 'wpshop' ); |
|
67 | - if($action != ''){ |
|
68 | - if(($action == 'edit') || ($action == 'delete')){ |
|
66 | + $title = __(self::pageTitle, 'wpshop'); |
|
67 | + if ($action != '') { |
|
68 | + if (($action == 'edit') || ($action == 'delete')) { |
|
69 | 69 | $editedItem = self::getElement($objectInEdition); |
70 | 70 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . ' (' . $editedItem->code . ')'); |
71 | 71 | } |
72 | - elseif($action == 'add'){ |
|
72 | + elseif ($action == 'add') { |
|
73 | 73 | $title = __(self::pageAddingTitle, 'wpshop'); |
74 | 74 | } |
75 | 75 | } |
76 | - elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())){ |
|
76 | + elseif ((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) { |
|
77 | 77 | $title = __(self::pageAddingTitle, 'wpshop'); |
78 | 78 | } |
79 | 79 | return $title; |
80 | 80 | } |
81 | 81 | |
82 | - function elementAction(){ |
|
82 | + function elementAction() { |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
86 | 86 | /** Définition des shortcodes pour les afficher dans le template list-shortcode */ |
87 | - public static function shortcode_definition(){ |
|
87 | + public static function shortcode_definition() { |
|
88 | 88 | $shortcodes = array(); |
89 | 89 | |
90 | 90 | /* Product tab */ |
@@ -95,17 +95,17 @@ discard block |
||
95 | 95 | $shortcodes['simple_product']['attrs_exemple']['pid'] = '12'; |
96 | 96 | $shortcodes['simple_product']['attrs_exemple']['type'] = 'list'; |
97 | 97 | |
98 | - $shortcodes['wpshop_product_title']['main_title'] = __( 'Product title', 'wpshop' ); |
|
98 | + $shortcodes['wpshop_product_title']['main_title'] = __('Product title', 'wpshop'); |
|
99 | 99 | $shortcodes['wpshop_product_title']['main_code'] = 'wpshop_product_title'; |
100 | 100 | $shortcodes['wpshop_product_title']['attrs_def']['pid'] = 'ID_DU_PRODUIT'; |
101 | 101 | $shortcodes['wpshop_product_title']['attrs_exemple']['pid'] = '12'; |
102 | 102 | |
103 | - $shortcodes['wpshop_product_content']['main_title'] = __( 'Product content', 'wpshop' ); |
|
103 | + $shortcodes['wpshop_product_content']['main_title'] = __('Product content', 'wpshop'); |
|
104 | 104 | $shortcodes['wpshop_product_content']['main_code'] = 'wpshop_product_content'; |
105 | 105 | $shortcodes['wpshop_product_content']['attrs_def']['pid'] = 'ID_DU_PRODUIT'; |
106 | 106 | $shortcodes['wpshop_product_content']['attrs_exemple']['pid'] = '12'; |
107 | 107 | |
108 | - $shortcodes['wpshop_product_thumbnail']['main_title'] = __( 'Product thumbnail', 'wpshop' ); |
|
108 | + $shortcodes['wpshop_product_thumbnail']['main_title'] = __('Product thumbnail', 'wpshop'); |
|
109 | 109 | $shortcodes['wpshop_product_thumbnail']['main_code'] = 'wpshop_product_thumbnail'; |
110 | 110 | $shortcodes['wpshop_product_thumbnail']['attrs_def']['pid'] = 'ID_DU_PRODUIT'; |
111 | 111 | $shortcodes['wpshop_product_thumbnail']['attrs_def']['size'] = 'TAILLE_DU_PRODUIT'; |
@@ -208,32 +208,32 @@ discard block |
||
208 | 208 | return $shortcodes; |
209 | 209 | } |
210 | 210 | |
211 | - public static function output_shortcode($shortcode_code, $specific_shorcode = '', $more_class_shortcode_helper = ''){ |
|
212 | - $shortcode = ( empty($specific_shorcode) ? self::shortcode_definition() : $specific_shorcode ); |
|
211 | + public static function output_shortcode($shortcode_code, $specific_shorcode = '', $more_class_shortcode_helper = '') { |
|
212 | + $shortcode = (empty($specific_shorcode) ? self::shortcode_definition() : $specific_shorcode); |
|
213 | 213 | |
214 | - $shortcode_main_title = ( !empty($shortcode[$shortcode_code]['main_title']) ? $shortcode[$shortcode_code]['main_title'] : '' ); |
|
215 | - $shorcode_main_code = ( !empty($shortcode[$shortcode_code]['main_code']) ? $shortcode[$shortcode_code]['main_code'] : '' ); |
|
214 | + $shortcode_main_title = (!empty($shortcode[$shortcode_code]['main_title']) ? $shortcode[$shortcode_code]['main_title'] : ''); |
|
215 | + $shorcode_main_code = (!empty($shortcode[$shortcode_code]['main_code']) ? $shortcode[$shortcode_code]['main_code'] : ''); |
|
216 | 216 | $shorcode_attributes_def = ' '; |
217 | - if(!empty($shortcode[$shortcode_code]['attrs_def'])){ |
|
218 | - foreach($shortcode[$shortcode_code]['attrs_def'] as $attr_name => $attr_values){ |
|
219 | - $shorcode_attributes_def .= $attr_name.'="'.$attr_values.'" '; |
|
217 | + if (!empty($shortcode[$shortcode_code]['attrs_def'])) { |
|
218 | + foreach ($shortcode[$shortcode_code]['attrs_def'] as $attr_name => $attr_values) { |
|
219 | + $shorcode_attributes_def .= $attr_name . '="' . $attr_values . '" '; |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | $shorcode_attributes_def = substr($shorcode_attributes_def, 0, -1); |
223 | 223 | $shorcode_attributes_exemple = ' '; |
224 | - if(!empty($shortcode[$shortcode_code]['attrs_exemple'])){ |
|
225 | - foreach($shortcode[$shortcode_code]['attrs_exemple'] as $attr_name => $attr_values){ |
|
226 | - $shorcode_attributes_exemple .= $attr_name.'="'.$attr_values.'" '; |
|
224 | + if (!empty($shortcode[$shortcode_code]['attrs_exemple'])) { |
|
225 | + foreach ($shortcode[$shortcode_code]['attrs_exemple'] as $attr_name => $attr_values) { |
|
226 | + $shorcode_attributes_exemple .= $attr_name . '="' . $attr_values . '" '; |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | $shorcode_attributes_exemple = substr($shorcode_attributes_exemple, 0, -1); |
230 | 230 | |
231 | - require( wpshop_tools::get_template_part( WPS_SHORTCODES_DIR, WPS_SHORTCODES_TEMPLATES_MAIN_DIR, "backend", 'shortcode_help.tpl' ) ); |
|
231 | + require(wpshop_tools::get_template_part(WPS_SHORTCODES_DIR, WPS_SHORTCODES_TEMPLATES_MAIN_DIR, "backend", 'shortcode_help.tpl')); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | public static function wysiwyg_button() { |
235 | - if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) return; |
|
236 | - if ( get_user_option('rich_editing') == 'true') : |
|
235 | + if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return; |
|
236 | + if (get_user_option('rich_editing') == 'true') : |
|
237 | 237 | add_filter('mce_external_plugins', array('wps_shortcodes_ctr', 'add_button_to_wysiwyg')); |
238 | 238 | add_filter('mce_buttons', array('wps_shortcodes_ctr', 'register_wysiwyg_button')); |
239 | 239 | endif; |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | $ver += 3; |
243 | 243 | return $ver; |
244 | 244 | } |
245 | - public static function add_button_to_wysiwyg($plugin_array){ |
|
245 | + public static function add_button_to_wysiwyg($plugin_array) { |
|
246 | 246 | $plugin_array['wpshop_wysiwyg_shortcodes'] = WPSHOP_JS_URL . 'pages/wysiwyg_editor.js'; |
247 | 247 | return $plugin_array; |
248 | 248 | } |
249 | - public static function register_wysiwyg_button($existing_button){ |
|
249 | + public static function register_wysiwyg_button($existing_button) { |
|
250 | 250 | array_push($existing_button, "|", "wpshop_wysiwyg_button"); |
251 | 251 | return $existing_button; |
252 | 252 | } |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return string |
259 | 259 | */ |
260 | - function elementList(){ |
|
260 | + function elementList() { |
|
261 | 261 | $shortcode_list = ''; |
262 | 262 | ob_start(); |
263 | - require( wpshop_tools::get_template_part( WPS_SHORTCODES_DIR, WPS_SHORTCODES_TEMPLATES_MAIN_DIR, "backend", 'list', 'shortcode' ) ); |
|
263 | + require(wpshop_tools::get_template_part(WPS_SHORTCODES_DIR, WPS_SHORTCODES_TEMPLATES_MAIN_DIR, "backend", 'list', 'shortcode')); |
|
264 | 264 | $shortcode_list = ob_get_contents(); |
265 | 265 | ob_end_clean(); |
266 | 266 | |
@@ -274,23 +274,23 @@ discard block |
||
274 | 274 | |
275 | 275 | public function shortcode_xmlloader() { |
276 | 276 | $shortcodes_list = array(); |
277 | - $ini_get_checking = ini_get( 'allow_url_fopen' ); |
|
278 | - if ( $ini_get_checking != 0 ) { |
|
279 | - $content = @file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/lshortcodes.xml' ); |
|
280 | - $list_shortcodes_xml = ( $content !== false ) ? new SimpleXmlElement( $content ) : null; |
|
281 | - if ( !empty($list_shortcodes_xml) && !empty($list_shortcodes_xml->channel) ) { |
|
277 | + $ini_get_checking = ini_get('allow_url_fopen'); |
|
278 | + if ($ini_get_checking != 0) { |
|
279 | + $content = @file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/lshortcodes.xml'); |
|
280 | + $list_shortcodes_xml = ($content !== false) ? new SimpleXmlElement($content) : null; |
|
281 | + if (!empty($list_shortcodes_xml) && !empty($list_shortcodes_xml->channel)) { |
|
282 | 282 | global $shortcode_tags; |
283 | - foreach( $list_shortcodes_xml->channel->category as $i => $category ) { |
|
284 | - $shortcodes_list[(String) $category->title]['desc_cat_' . (String) $category->title] = (String) $category->description; |
|
285 | - foreach( $category->item as $j => $item_xml ) { |
|
283 | + foreach ($list_shortcodes_xml->channel->category as $i => $category) { |
|
284 | + $shortcodes_list[(String)$category->title]['desc_cat_' . (String)$category->title] = (String)$category->description; |
|
285 | + foreach ($category->item as $j => $item_xml) { |
|
286 | 286 | $item = array(); |
287 | - $item['title'] = (String) $item_xml->title; |
|
288 | - $item['description'] = (String) $item_xml->description; |
|
289 | - foreach( $item_xml->args as $argument) { |
|
290 | - $item['args'][(String) $argument->identifier] = (String) $argument->params; |
|
287 | + $item['title'] = (String)$item_xml->title; |
|
288 | + $item['description'] = (String)$item_xml->description; |
|
289 | + foreach ($item_xml->args as $argument) { |
|
290 | + $item['args'][(String)$argument->identifier] = (String)$argument->params; |
|
291 | 291 | } |
292 | - $item['active'] = ( array_key_exists((String) $item_xml->identifier, $shortcode_tags) ) ? 'true' : 'false'; |
|
293 | - $shortcodes_list[(String) $category->title]['items'][(String) $item_xml->identifier] = $item; |
|
292 | + $item['active'] = (array_key_exists((String)$item_xml->identifier, $shortcode_tags)) ? 'true' : 'false'; |
|
293 | + $shortcodes_list[(String)$category->title]['items'][(String)$item_xml->identifier] = $item; |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | } |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | public function help_tab_shortcodes() { |
302 | 302 | $shortcodes = $this->shortcode_xmlloader(); |
303 | 303 | ob_start(); |
304 | - require( wpshop_tools::get_template_part( WPS_SHORTCODES_DIR, WPS_SHORTCODES_TEMPLATES_MAIN_DIR, "backend", 'shortcode_help_tab' ) ); |
|
304 | + require(wpshop_tools::get_template_part(WPS_SHORTCODES_DIR, WPS_SHORTCODES_TEMPLATES_MAIN_DIR, "backend", 'shortcode_help_tab')); |
|
305 | 305 | $content = ob_get_contents(); |
306 | 306 | ob_end_clean(); |
307 | 307 | global $wps_help_tabs; |
308 | - $wps_help_tabs->set_help_tab( 'shortcodes', __( 'Shortcodes', 'wpshop' ), $content, array('edit-post', 'post', 'edit-page', 'page', 'edit-comments', 'comments', 'edit-wpshop_product', 'wpshop_product', 'edit-wpshop_product_category') ); |
|
308 | + $wps_help_tabs->set_help_tab('shortcodes', __('Shortcodes', 'wpshop'), $content, array('edit-post', 'post', 'edit-page', 'page', 'edit-comments', 'comments', 'edit-wpshop_product', 'wpshop_product', 'edit-wpshop_product_category')); |
|
309 | 309 | } |
310 | 310 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | class wps_shortcodes_ctr |
4 | 6 | { |
@@ -68,12 +70,10 @@ discard block |
||
68 | 70 | if(($action == 'edit') || ($action == 'delete')){ |
69 | 71 | $editedItem = self::getElement($objectInEdition); |
70 | 72 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . ' (' . $editedItem->code . ')'); |
71 | - } |
|
72 | - elseif($action == 'add'){ |
|
73 | + } elseif($action == 'add'){ |
|
73 | 74 | $title = __(self::pageAddingTitle, 'wpshop'); |
74 | 75 | } |
75 | - } |
|
76 | - elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())){ |
|
76 | + } elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())){ |
|
77 | 77 | $title = __(self::pageAddingTitle, 'wpshop'); |
78 | 78 | } |
79 | 79 | return $title; |
@@ -232,7 +232,9 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | public static function wysiwyg_button() { |
235 | - if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) return; |
|
235 | + if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) { |
|
236 | + return; |
|
237 | + } |
|
236 | 238 | if ( get_user_option('rich_editing') == 'true') : |
237 | 239 | add_filter('mce_external_plugins', array('wps_shortcodes_ctr', 'add_button_to_wysiwyg')); |
238 | 240 | add_filter('mce_buttons', array('wps_shortcodes_ctr', 'register_wysiwyg_button')); |
@@ -117,8 +117,6 @@ |
||
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Display Best sales Statistics |
120 | - * @param string $begindate |
|
121 | - * @param string $enddate |
|
122 | 120 | * @return string |
123 | 121 | */ |
124 | 122 | function wps_statistics_best_sales() { |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | |
26 | 26 | |
27 | 27 | /** |
28 | - * Add Javascript files |
|
29 | - */ |
|
28 | + * Add Javascript files |
|
29 | + */ |
|
30 | 30 | function add_scripts() { |
31 | 31 | wp_enqueue_script( 'jquery' ); |
32 | 32 | wp_enqueue_script( 'jquery-ui-datepicker'); |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | - * Add CSS files |
|
50 | - */ |
|
49 | + * Add CSS files |
|
50 | + */ |
|
51 | 51 | function add_css_files() { |
52 | 52 | wp_register_style('wps_statistics_css', WPS_STATISTICS_URL . '/assets/css/wps_statistics.css', '', WPS_STATISTICS_VERSION); |
53 | 53 | wp_enqueue_style('wps_statistics_css'); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | class wps_statistics_ctr { |
4 | 4 | private $wps_stats_mdl; |
@@ -6,19 +6,19 @@ discard block |
||
6 | 6 | |
7 | 7 | // WP Main Actions |
8 | 8 | add_action('admin_menu', array(&$this, 'register_stats_menu'), 250); |
9 | - add_action( 'save_post', array( &$this, 'wps_statistics_save_customer_infos') ); |
|
10 | - add_action('add_meta_boxes', array( &$this, 'add_customer_meta_box'), 1 ); |
|
9 | + add_action('save_post', array(&$this, 'wps_statistics_save_customer_infos')); |
|
10 | + add_action('add_meta_boxes', array(&$this, 'add_customer_meta_box'), 1); |
|
11 | 11 | |
12 | 12 | // Add Javascript Files in admin |
13 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts' ) ); |
|
14 | - add_action('admin_footer', array( $this, 'admin_extra_js') ); |
|
13 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts')); |
|
14 | + add_action('admin_footer', array($this, 'admin_extra_js')); |
|
15 | 15 | |
16 | 16 | // Add CSS File |
17 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_css_files' ) ); |
|
17 | + add_action('admin_enqueue_scripts', array($this, 'add_css_files')); |
|
18 | 18 | |
19 | 19 | // Ajax Actions |
20 | 20 | // add_action('wap_ajax_wps_reload_statistics', array( &$this, 'wps_reload_statistics') ); |
21 | - add_action('wp_ajax_wps_hourly_order_day', array( &$this, 'wps_hourly_order_day') ); |
|
21 | + add_action('wp_ajax_wps_hourly_order_day', array(&$this, 'wps_hourly_order_day')); |
|
22 | 22 | |
23 | 23 | $this->wps_stats_mdl = new wps_statistics_mdl(); |
24 | 24 | } |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | * Add Javascript files |
29 | 29 | */ |
30 | 30 | function add_scripts() { |
31 | - wp_enqueue_script( 'jquery' ); |
|
32 | - wp_enqueue_script( 'jquery-ui-datepicker'); |
|
33 | - wp_enqueue_script( 'postbox'); |
|
34 | - wp_enqueue_script( 'wps_statistics_js_chart', WPSHOP_JS_URL.'Chart.js' ); |
|
35 | - wp_enqueue_script( 'wps_statistics_js', WPS_STATISTICS_URL.'/assets/js/wps_statistics.js' ); |
|
36 | - wp_enqueue_script( 'wps_hourlyorders', WPS_STATISTICS_URL.'/assets/js/hourlyorders.js' ); |
|
31 | + wp_enqueue_script('jquery'); |
|
32 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
33 | + wp_enqueue_script('postbox'); |
|
34 | + wp_enqueue_script('wps_statistics_js_chart', WPSHOP_JS_URL . 'Chart.js'); |
|
35 | + wp_enqueue_script('wps_statistics_js', WPS_STATISTICS_URL . '/assets/js/wps_statistics.js'); |
|
36 | + wp_enqueue_script('wps_hourlyorders', WPS_STATISTICS_URL . '/assets/js/hourlyorders.js'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function add_customer_meta_box() { |
60 | 60 | global $post; |
61 | - add_meta_box( 'wps_statistics_customer', __( 'Statistics', 'wps_price' ), array( &$this, 'wps_statistics_meta_box_content' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low' ); |
|
61 | + add_meta_box('wps_statistics_customer', __('Statistics', 'wps_price'), array(&$this, 'wps_statistics_meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low'); |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | 65 | /** Add Statistics Meta Boxes **/ |
66 | 66 | function add_stats_meta_boxes() { |
67 | - $user_stats_order = get_user_meta( get_current_user_id(), 'meta-box-order_boutique_page_wpshop_statistics', true ); |
|
68 | - add_meta_box( 'wps-best-sales-statistics',__('Best sales', 'wpshop'), array( $this, 'wps_statistics_best_sales' ), 'wpshop_statistics', 'left_column' ); |
|
69 | - add_meta_box( 'wps-most-viewed-statistics',__('Most viewed products', 'wpshop'), array( $this, 'wps_statistics_most_viewed_products' ), 'wpshop_statistics', 'right_column' ); |
|
70 | - add_meta_box( 'wps-orders-by-month-statistics',__('Orders', 'wpshop'), array( $this, 'wps_statistics_orders_by_month' ), 'wpshop_statistics', 'left_column' ); |
|
71 | - add_meta_box( 'wps-orders-status',__('Orders status', 'wpshop'), array( $this, 'wps_statistics_orders_status' ), 'wpshop_statistics', 'left_column' ); |
|
72 | - add_meta_box( 'wps-orders-moment-statistics',__('Orders Hours', 'wpshop'), array( $this, 'wps_statistics_orders_moment' ), 'wpshop_statistics', 'right_column' ); |
|
73 | - add_meta_box( 'wps-best-customers',__('Best customers', 'wpshop'), array( $this, 'wps_statistics_best_customers' ), 'wpshop_statistics', 'right_column' ); |
|
67 | + $user_stats_order = get_user_meta(get_current_user_id(), 'meta-box-order_boutique_page_wpshop_statistics', true); |
|
68 | + add_meta_box('wps-best-sales-statistics', __('Best sales', 'wpshop'), array($this, 'wps_statistics_best_sales'), 'wpshop_statistics', 'left_column'); |
|
69 | + add_meta_box('wps-most-viewed-statistics', __('Most viewed products', 'wpshop'), array($this, 'wps_statistics_most_viewed_products'), 'wpshop_statistics', 'right_column'); |
|
70 | + add_meta_box('wps-orders-by-month-statistics', __('Orders', 'wpshop'), array($this, 'wps_statistics_orders_by_month'), 'wpshop_statistics', 'left_column'); |
|
71 | + add_meta_box('wps-orders-status', __('Orders status', 'wpshop'), array($this, 'wps_statistics_orders_status'), 'wpshop_statistics', 'left_column'); |
|
72 | + add_meta_box('wps-orders-moment-statistics', __('Orders Hours', 'wpshop'), array($this, 'wps_statistics_orders_moment'), 'wpshop_statistics', 'right_column'); |
|
73 | + add_meta_box('wps-best-customers', __('Best customers', 'wpshop'), array($this, 'wps_statistics_best_customers'), 'wpshop_statistics', 'right_column'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | function wps_statistics_meta_box_content() { |
80 | 80 | global $post; |
81 | 81 | $user_meta = ''; |
82 | - if ( !empty($post) && !empty($post->post_author) ) { |
|
83 | - $user_meta = get_user_meta( $post->post_author, 'wps_statistics_exclude_customer', true ); |
|
82 | + if (!empty($post) && !empty($post->post_author)) { |
|
83 | + $user_meta = get_user_meta($post->post_author, 'wps_statistics_exclude_customer', true); |
|
84 | 84 | } |
85 | - $output = '<input type="checkbox" name="wps_statistics_exclude_customer" id="wps_statistics_exclude_customer" ' .( (!empty($user_meta) ) ? 'checked="checked"' : '' ). '/> <label for="wps_statistics_exclude_customer">' .__('Exclude this customer from WPShop Statistics', 'wpshop'). '</label>'; |
|
85 | + $output = '<input type="checkbox" name="wps_statistics_exclude_customer" id="wps_statistics_exclude_customer" ' . ((!empty($user_meta)) ? 'checked="checked"' : '') . '/> <label for="wps_statistics_exclude_customer">' . __('Exclude this customer from WPShop Statistics', 'wpshop') . '</label>'; |
|
86 | 86 | echo $output; |
87 | 87 | } |
88 | 88 | |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | * Save action to exclude customer of statistics |
91 | 91 | */ |
92 | 92 | function wps_statistics_save_customer_infos() { |
93 | - $action = !empty( $_POST['action'] ) ? sanitize_text_field( $_POST['action'] ) : ''; |
|
94 | - $post_type = !empty( $_POST['post_type'] ) ? sanitize_text_field( $_POST['post_type'] ) : ''; |
|
95 | - $post_id = !empty( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; |
|
96 | - $wps_statistics_exclude_customer = isset( $_POST['wps_statistics_exclude_customer'] ) ? (int) $_POST['wps_statistics_exclude_customer'] : 0; |
|
97 | - |
|
98 | - if ( !empty($action) && $action != 'autosave' && !empty($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) { |
|
99 | - $customer_def = get_post( $post_id ); |
|
100 | - if( isset( $wps_statistics_exclude_customer ) ) { |
|
101 | - update_user_meta( $customer_def->post_author, 'wps_statistics_exclude_customer', $wps_statistics_exclude_customer ); |
|
93 | + $action = !empty($_POST['action']) ? sanitize_text_field($_POST['action']) : ''; |
|
94 | + $post_type = !empty($_POST['post_type']) ? sanitize_text_field($_POST['post_type']) : ''; |
|
95 | + $post_id = !empty($_POST['post_ID']) ? (int)$_POST['post_ID'] : 0; |
|
96 | + $wps_statistics_exclude_customer = isset($_POST['wps_statistics_exclude_customer']) ? (int)$_POST['wps_statistics_exclude_customer'] : 0; |
|
97 | + |
|
98 | + if (!empty($action) && $action != 'autosave' && !empty($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) { |
|
99 | + $customer_def = get_post($post_id); |
|
100 | + if (isset($wps_statistics_exclude_customer)) { |
|
101 | + update_user_meta($customer_def->post_author, 'wps_statistics_exclude_customer', $wps_statistics_exclude_customer); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * Register statistics Menu |
108 | 108 | */ |
109 | 109 | function register_stats_menu() { |
110 | - add_submenu_page( 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER, __('Statistics', 'wpshop' ), __('Statistics', 'wpshop'), 'wpshop_view_statistics', 'wpshop_statistics', array($this, 'wps_display_statistics')); |
|
110 | + add_submenu_page('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER, __('Statistics', 'wpshop'), __('Statistics', 'wpshop'), 'wpshop_view_statistics', 'wpshop_statistics', array($this, 'wps_display_statistics')); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | */ |
116 | 116 | function wps_display_statistics() { |
117 | 117 | $this->add_stats_meta_boxes(); |
118 | - echo wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
119 | - echo wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
120 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps-statistics") ); |
|
118 | + echo wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
119 | + echo wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
120 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps-statistics")); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | * @return string |
128 | 128 | */ |
129 | 129 | function wps_statistics_best_sales() { |
130 | - $begin_date = ( !empty($_POST['begin_date']) ) ? wpshop_tools::varSanitizer($_POST['begin_date']) : date( 'Y-m-d', strtotime( '1 months ago') ); |
|
131 | - $end_date = ( !empty($_POST['end_date']) ) ? wpshop_tools::varSanitizer( $_POST['end_date'] ) : date('Y-m-d'); |
|
132 | - $products = $this->wps_stats_mdl->wps_best_sales_datas($begin_date, $end_date ); |
|
133 | - $colors = array( '#69D2E7', '#E0E4CC', '#F38630', '#64BC43', '#8F33E0', '#F990E6', '#414141', '#E03E3E'); |
|
130 | + $begin_date = (!empty($_POST['begin_date'])) ? wpshop_tools::varSanitizer($_POST['begin_date']) : date('Y-m-d', strtotime('1 months ago')); |
|
131 | + $end_date = (!empty($_POST['end_date'])) ? wpshop_tools::varSanitizer($_POST['end_date']) : date('Y-m-d'); |
|
132 | + $products = $this->wps_stats_mdl->wps_best_sales_datas($begin_date, $end_date); |
|
133 | + $colors = array('#69D2E7', '#E0E4CC', '#F38630', '#64BC43', '#8F33E0', '#F990E6', '#414141', '#E03E3E'); |
|
134 | 134 | ob_start(); |
135 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_best_sales") ); |
|
135 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_best_sales")); |
|
136 | 136 | $output = ob_get_contents(); |
137 | 137 | ob_end_clean(); |
138 | 138 | echo $output; |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | /** Display most viewed products statistics **/ |
142 | 142 | function wps_statistics_most_viewed_products() { |
143 | 143 | $products = $this->wps_stats_mdl->wps_most_viewed_products_datas(); |
144 | - $colors = array( '#69D2E7', '#E0E4CC', '#F38630', '#64BC43', '#8F33E0', '#F990E6', '#414141', '#E03E3E'); |
|
144 | + $colors = array('#69D2E7', '#E0E4CC', '#F38630', '#64BC43', '#8F33E0', '#F990E6', '#414141', '#E03E3E'); |
|
145 | 145 | ob_start(); |
146 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_most_viewed_products") ); |
|
146 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_most_viewed_products")); |
|
147 | 147 | $output = ob_get_contents(); |
148 | 148 | ob_end_clean(); |
149 | 149 | echo $output; |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | */ |
155 | 155 | function wps_statistics_orders_by_month() { |
156 | 156 | $order_recap = $this->wps_stats_mdl->wps_orders_by_month(); |
157 | - $colors = array( array('#9AE5F4', '#0074A2'), array('#E0E4CC', '#A8AA99')); |
|
157 | + $colors = array(array('#9AE5F4', '#0074A2'), array('#E0E4CC', '#A8AA99')); |
|
158 | 158 | ob_start(); |
159 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_orders_by_month") ); |
|
159 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_orders_by_month")); |
|
160 | 160 | $output = ob_get_contents(); |
161 | 161 | ob_end_clean(); |
162 | 162 | echo $output; |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | * Display order status statistics |
167 | 167 | */ |
168 | 168 | function wps_statistics_orders_status() { |
169 | - $begin_date = ( !empty($_POST['begin_date']) ) ? wpshop_tools::varSanitizer( $_POST['begin_date'] ) : date( 'Y-m-d', strtotime( '1 months ago') ); |
|
170 | - $end_date = ( !empty($_POST['end_date']) ) ? wpshop_tools::varSanitizer( $_POST['end_date'] ) : date('Y-m-d'); |
|
169 | + $begin_date = (!empty($_POST['begin_date'])) ? wpshop_tools::varSanitizer($_POST['begin_date']) : date('Y-m-d', strtotime('1 months ago')); |
|
170 | + $end_date = (!empty($_POST['end_date'])) ? wpshop_tools::varSanitizer($_POST['end_date']) : date('Y-m-d'); |
|
171 | 171 | $orders_status = $this->wps_stats_mdl->wps_order_status($begin_date, $end_date); |
172 | - $colors = array( 'canceled' => '#E0E4CC', 'shipped' => '#69D2E7', 'pos' => '#6993e7', 'completed' => '#64BC43', 'refunded' => '#E03E3E', 'partially_paid' => '#FF9900','awaiting_payment' => '#F4FA58', 'denied' => '#414141', 'incorrect_amount' => '#F38630', 'payment_refused' => '#8F33E0'); |
|
173 | - $payment_status = unserialize( WPSHOP_ORDER_STATUS ); |
|
174 | - if( !empty($orders_status) ) { |
|
175 | - arsort( $orders_status ); |
|
172 | + $colors = array('canceled' => '#E0E4CC', 'shipped' => '#69D2E7', 'pos' => '#6993e7', 'completed' => '#64BC43', 'refunded' => '#E03E3E', 'partially_paid' => '#FF9900', 'awaiting_payment' => '#F4FA58', 'denied' => '#414141', 'incorrect_amount' => '#F38630', 'payment_refused' => '#8F33E0'); |
|
173 | + $payment_status = unserialize(WPSHOP_ORDER_STATUS); |
|
174 | + if (!empty($orders_status)) { |
|
175 | + arsort($orders_status); |
|
176 | 176 | ob_start(); |
177 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_orders_status") ); |
|
177 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_orders_status")); |
|
178 | 178 | $output = ob_get_contents(); |
179 | 179 | ob_end_clean(); |
180 | 180 | echo $output; |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | * Display Best customers Statistics |
186 | 186 | */ |
187 | 187 | function wps_statistics_best_customers() { |
188 | - $begin_date = ( !empty($_POST['begin_date']) ) ? wpshop_tools::varSanitizer( $_POST['begin_date'] ) : date( 'Y-m-d', strtotime( '1 months ago') ); |
|
189 | - $end_date = ( !empty($_POST['end_date']) ) ? wpshop_tools::varSanitizer( $_POST['end_date'] ) : date('Y-m-d'); |
|
190 | - $customer_recap = $this->wps_stats_mdl->wps_best_customers( $begin_date, $end_date ); |
|
191 | - $colors = array( '#69D2E7', '#E0E4CC', '#F38630', '#64BC43', '#8F33E0', '#F990E6', '#414141', '#E03E3E'); |
|
188 | + $begin_date = (!empty($_POST['begin_date'])) ? wpshop_tools::varSanitizer($_POST['begin_date']) : date('Y-m-d', strtotime('1 months ago')); |
|
189 | + $end_date = (!empty($_POST['end_date'])) ? wpshop_tools::varSanitizer($_POST['end_date']) : date('Y-m-d'); |
|
190 | + $customer_recap = $this->wps_stats_mdl->wps_best_customers($begin_date, $end_date); |
|
191 | + $colors = array('#69D2E7', '#E0E4CC', '#F38630', '#64BC43', '#8F33E0', '#F990E6', '#414141', '#E03E3E'); |
|
192 | 192 | ob_start(); |
193 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_best_customers") ); |
|
193 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_best_customers")); |
|
194 | 194 | $output = ob_get_contents(); |
195 | 195 | ob_end_clean(); |
196 | 196 | echo $output; |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | /** |
200 | 200 | * Display Orders moment in the day Statistics |
201 | 201 | */ |
202 | - function wps_statistics_orders_moment( $args = array( 'choosen_day' => '', 'return' => false ) ) { |
|
203 | - $begin_date = ( !empty($_POST['begin_date']) ) ? wpshop_tools::varSanitizer( $_POST['begin_date'] ) : date( 'Y-m-d', strtotime( '1 months ago') ); |
|
204 | - $end_date = ( !empty($_POST['end_date']) ) ? wpshop_tools::varSanitizer( $_POST['end_date'] ) : date('Y-m-d'); |
|
205 | - $datadate = $this->wps_stats_mdl->wps_get_orders_by_hours( $begin_date, $end_date, ( ( !empty($args['choosen_day']) ) ? $args['choosen_day'] : '' ) ); |
|
206 | - $days = array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); |
|
202 | + function wps_statistics_orders_moment($args = array('choosen_day' => '', 'return' => false)) { |
|
203 | + $begin_date = (!empty($_POST['begin_date'])) ? wpshop_tools::varSanitizer($_POST['begin_date']) : date('Y-m-d', strtotime('1 months ago')); |
|
204 | + $end_date = (!empty($_POST['end_date'])) ? wpshop_tools::varSanitizer($_POST['end_date']) : date('Y-m-d'); |
|
205 | + $datadate = $this->wps_stats_mdl->wps_get_orders_by_hours($begin_date, $end_date, ((!empty($args['choosen_day'])) ? $args['choosen_day'] : '')); |
|
206 | + $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); |
|
207 | 207 | ob_start(); |
208 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_orders_moment") ); |
|
208 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps_statistics_orders_moment")); |
|
209 | 209 | $output = ob_get_contents(); |
210 | 210 | ob_end_clean(); |
211 | - if( ( !empty( $args) ) && !empty( $args['return'] ) && $args['return'] ) { |
|
211 | + if ((!empty($args)) && !empty($args['return']) && $args['return']) { |
|
212 | 212 | return $output; |
213 | 213 | } |
214 | 214 | else { |
@@ -220,49 +220,49 @@ discard block |
||
220 | 220 | * AJAX - Display Orders moments according the choosen day |
221 | 221 | */ |
222 | 222 | function wps_hourly_order_day() { |
223 | - $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
223 | + $_wponce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
224 | 224 | |
225 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_hourly_order_day' ) ) |
|
225 | + if (!wp_verify_nonce($_wpnonce, 'wps_hourly_order_day')) |
|
226 | 226 | wp_die(); |
227 | 227 | |
228 | 228 | $status = false; $response = ''; |
229 | 229 | |
230 | - $day = ( !empty($_POST['day']) ) ? sanitize_text_field( $_POST['day'] ) : null; |
|
231 | - $width = !empty( $_POST['width'] ) ? (int) $_POST['width'] : 0; |
|
232 | - $height = !empty( $_POST['height'] ) ? (int) $_POST['height'] : 0; |
|
230 | + $day = (!empty($_POST['day'])) ? sanitize_text_field($_POST['day']) : null; |
|
231 | + $width = !empty($_POST['width']) ? (int)$_POST['width'] : 0; |
|
232 | + $height = !empty($_POST['height']) ? (int)$_POST['height'] : 0; |
|
233 | 233 | |
234 | - $response = $this->wps_statistics_orders_moment( array( 'choosen_day' => $day, 'return' => true, 'width' => $width, 'height' => $height ) ); |
|
234 | + $response = $this->wps_statistics_orders_moment(array('choosen_day' => $day, 'return' => true, 'width' => $width, 'height' => $height)); |
|
235 | 235 | $status = true; |
236 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
236 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
237 | 237 | wp_die(); |
238 | 238 | } |
239 | 239 | |
240 | 240 | |
241 | 241 | |
242 | - function customers_by_month(){ |
|
242 | + function customers_by_month() { |
|
243 | 243 | $canvas_js = ''; |
244 | 244 | $box_title = __('Monthly customers', 'wpshop'); |
245 | 245 | $canvas_width = 550; |
246 | 246 | $canvas_height = 400; |
247 | 247 | $products = $this->wps_stats_mdl->wps_customers_month(); |
248 | - if ( !empty($customers_recap) ) { |
|
249 | - krsort( $customers_recap ); |
|
248 | + if (!empty($customers_recap)) { |
|
249 | + krsort($customers_recap); |
|
250 | 250 | $canvas_js .= '<script type="text/javascript">'; |
251 | - $canvas_js .= 'var data = { labels : ["' .__('January', 'wpshop'). '","' .__('February', 'wpshop'). '","' .__('March', 'wpshop'). '","' .__('April', 'wpshop'). '","' .__('May', 'wpshop'). '","' .__('June', 'wpshop'). '","' .__('July', 'wpshop'). '","' .__('August', 'wpshop'). '" ,"' .__('September', 'wpshop'). '" ,"' .__('October', 'wpshop'). '","' .__('November', 'wpshop'). '","' .__('December', 'wpshop'). '"],'; |
|
251 | + $canvas_js .= 'var data = { labels : ["' . __('January', 'wpshop') . '","' . __('February', 'wpshop') . '","' . __('March', 'wpshop') . '","' . __('April', 'wpshop') . '","' . __('May', 'wpshop') . '","' . __('June', 'wpshop') . '","' . __('July', 'wpshop') . '","' . __('August', 'wpshop') . '" ,"' . __('September', 'wpshop') . '" ,"' . __('October', 'wpshop') . '","' . __('November', 'wpshop') . '","' . __('December', 'wpshop') . '"],'; |
|
252 | 252 | $canvas_js .= 'datasets : ['; |
253 | 253 | $i = 0; |
254 | - $colors = array(array('#E0E4CC', '#A8AA99') , array('#69D2E7', '#4CA3B5')); |
|
255 | - $customers_recap = array_slice( $customers_recap, 0, 2, true ); |
|
256 | - $customers_recap = array_reverse( $customers_recap, true ); |
|
257 | - foreach( $customers_recap as $y => $year ) { |
|
254 | + $colors = array(array('#E0E4CC', '#A8AA99'), array('#69D2E7', '#4CA3B5')); |
|
255 | + $customers_recap = array_slice($customers_recap, 0, 2, true); |
|
256 | + $customers_recap = array_reverse($customers_recap, true); |
|
257 | + foreach ($customers_recap as $y => $year) { |
|
258 | 258 | |
259 | - if ( $i < 2 ) { |
|
260 | - $canvas_js .= '{fillColor : "' .$colors[$i][0]. '",strokeColor :"' .$colors[$i][1]. '",'; |
|
259 | + if ($i < 2) { |
|
260 | + $canvas_js .= '{fillColor : "' . $colors[$i][0] . '",strokeColor :"' . $colors[$i][1] . '",'; |
|
261 | 261 | $canvas_js .= 'data : ['; |
262 | - for( $j = 1; $j <= 12; $j++) { |
|
263 | - if( !empty($year[$j]) ) { |
|
264 | - $canvas_js .= $year[$j].','; |
|
265 | - if ( $count_users < $year[$j] ) { |
|
262 | + for ($j = 1; $j <= 12; $j++) { |
|
263 | + if (!empty($year[$j])) { |
|
264 | + $canvas_js .= $year[$j] . ','; |
|
265 | + if ($count_users < $year[$j]) { |
|
266 | 266 | $count_users = $year[$j]; |
267 | 267 | } |
268 | 268 | } |
@@ -277,19 +277,19 @@ discard block |
||
277 | 277 | } |
278 | 278 | } |
279 | 279 | $canvas_js .= ']};'; |
280 | - $canvas_js .= 'var BarCustomers = new Chart(document.getElementById("wps_customers_account_creation").getContext("2d")).Bar(data, {scaleOverride : true, scaleSteps : ' .round( ($count_users / 5) ). ', scaleStepWidth : 5, scaleStartValue : 0});'; |
|
280 | + $canvas_js .= 'var BarCustomers = new Chart(document.getElementById("wps_customers_account_creation").getContext("2d")).Bar(data, {scaleOverride : true, scaleSteps : ' . round(($count_users / 5)) . ', scaleStepWidth : 5, scaleStartValue : 0});'; |
|
281 | 281 | $canvas_js .= '</script>'; |
282 | 282 | |
283 | 283 | /** Legend **/ |
284 | 284 | $canvas_js .= '<center><ul class="wps_statistics_legend">'; |
285 | - foreach( $colors as $color ) { |
|
286 | - if ( !empty($color) && !empty($color[2]) ) |
|
287 | - $canvas_js .= '<li style="width : auto; margin-right : 20px;"><div style="background : ' .$color[0]. ';" class="legend_indicator"></div>' .$color[2]. '</li>'; |
|
285 | + foreach ($colors as $color) { |
|
286 | + if (!empty($color) && !empty($color[2])) |
|
287 | + $canvas_js .= '<li style="width : auto; margin-right : 20px;"><div style="background : ' . $color[0] . ';" class="legend_indicator"></div>' . $color[2] . '</li>'; |
|
288 | 288 | } |
289 | 289 | $canvas_js .= '</ul></center>'; |
290 | 290 | } |
291 | 291 | else { |
292 | - $canvas_js = __( 'No customer account has been created on your shop', 'wpshop'); |
|
292 | + $canvas_js = __('No customer account has been created on your shop', 'wpshop'); |
|
293 | 293 | } |
294 | 294 | } |
295 | 295 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | class wps_statistics_ctr { |
4 | 6 | private $wps_stats_mdl; |
@@ -210,8 +212,7 @@ discard block |
||
210 | 212 | ob_end_clean(); |
211 | 213 | if( ( !empty( $args) ) && !empty( $args['return'] ) && $args['return'] ) { |
212 | 214 | return $output; |
213 | - } |
|
214 | - else { |
|
215 | + } else { |
|
215 | 216 | echo $output; |
216 | 217 | } |
217 | 218 | } |
@@ -222,8 +223,9 @@ discard block |
||
222 | 223 | function wps_hourly_order_day() { |
223 | 224 | $_wponce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
224 | 225 | |
225 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_hourly_order_day' ) ) |
|
226 | - wp_die(); |
|
226 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_hourly_order_day' ) ) { |
|
227 | + wp_die(); |
|
228 | + } |
|
227 | 229 | |
228 | 230 | $status = false; $response = ''; |
229 | 231 | |
@@ -265,8 +267,7 @@ discard block |
||
265 | 267 | if ( $count_users < $year[$j] ) { |
266 | 268 | $count_users = $year[$j]; |
267 | 269 | } |
268 | - } |
|
269 | - else { |
|
270 | + } else { |
|
270 | 271 | $canvas_js .= '0,'; |
271 | 272 | } |
272 | 273 | } |
@@ -283,12 +284,12 @@ discard block |
||
283 | 284 | /** Legend **/ |
284 | 285 | $canvas_js .= '<center><ul class="wps_statistics_legend">'; |
285 | 286 | foreach( $colors as $color ) { |
286 | - if ( !empty($color) && !empty($color[2]) ) |
|
287 | - $canvas_js .= '<li style="width : auto; margin-right : 20px;"><div style="background : ' .$color[0]. ';" class="legend_indicator"></div>' .$color[2]. '</li>'; |
|
287 | + if ( !empty($color) && !empty($color[2]) ) { |
|
288 | + $canvas_js .= '<li style="width : auto; margin-right : 20px;"><div style="background : ' .$color[0]. ';" class="legend_indicator"></div>' .$color[2]. '</li>'; |
|
289 | + } |
|
288 | 290 | } |
289 | 291 | $canvas_js .= '</ul></center>'; |
290 | - } |
|
291 | - else { |
|
292 | + } else { |
|
292 | 293 | $canvas_js = __( 'No customer account has been created on your shop', 'wpshop'); |
293 | 294 | } |
294 | 295 | } |
@@ -166,6 +166,9 @@ discard block |
||
166 | 166 | return $price_infos; |
167 | 167 | } |
168 | 168 | |
169 | + /** |
|
170 | + * @param string $return_type |
|
171 | + */ |
|
169 | 172 | public static function get_product_price($product, $return_type, $output_type = '', $only_price = false, $price_checking_done = false) { |
170 | 173 | $wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting'); |
171 | 174 | // $wpshop_price_piloting_option = 'TTC'; |
@@ -458,6 +461,7 @@ discard block |
||
458 | 461 | |
459 | 462 | /** |
460 | 463 | * Check if isset Required attributes |
464 | + * @param integer $product_id |
|
461 | 465 | */ |
462 | 466 | public static function check_required_attributes( $product_id ) { |
463 | 467 | $required_attributes_list = array(); |
@@ -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 Prices bootstrap file |
@@ -9,17 +9,17 @@ discard block |
||
9 | 9 | * |
10 | 10 | */ |
11 | 11 | |
12 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
13 | - die( __("You are not allowed to use this service.", 'wpshop') ); |
|
12 | +if (!defined('WPSHOP_VERSION')) { |
|
13 | + die(__("You are not allowed to use this service.", 'wpshop')); |
|
14 | 14 | } |
15 | -if ( !class_exists("wpshop_prices") ) { |
|
15 | +if (!class_exists("wpshop_prices")) { |
|
16 | 16 | class wpshop_prices { |
17 | 17 | |
18 | 18 | function __construct() { |
19 | 19 | add_action('wsphop_options', array('wpshop_prices', 'declare_options')); |
20 | 20 | } |
21 | 21 | |
22 | - public static function declare_options () { |
|
22 | + public static function declare_options() { |
|
23 | 23 | register_setting('wpshop_options', 'wpshop_catalog_product_option', array('wpshop_prices', 'wpshop_options_validate_prices')); |
24 | 24 | add_settings_field('wpshop_catalog_product_option_discount', __('Activate the discount on products', 'wpshop'), array('wpshop_prices', 'wpshop_activate_discount_prices_field'), 'wpshop_catalog_product_option', 'wpshop_catalog_product_section'); |
25 | 25 | } |
@@ -29,37 +29,37 @@ discard block |
||
29 | 29 | |
30 | 30 | /** Price attribute Def **/ |
31 | 31 | $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
32 | - $price_attribute_def = wpshop_attributes::getElement( ( (!empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? 'price_ht' : 'product_price' ), "'valid'", 'code'); |
|
32 | + $price_attribute_def = wpshop_attributes::getElement(((!empty($price_piloting_option) && $price_piloting_option == 'HT') ? 'price_ht' : 'product_price'), "'valid'", 'code'); |
|
33 | 33 | |
34 | 34 | /** Discount attributes **/ |
35 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s OR code = %s OR code = %s OR code = %s OR code = %s', 'discount_amount', 'discount_rate', 'special_price', 'special_from', 'special_to' ); |
|
35 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s OR code = %s OR code = %s OR code = %s OR code = %s', 'discount_amount', 'discount_rate', 'special_price', 'special_from', 'special_to'); |
|
36 | 36 | $discount_attributes = $wpdb->get_results($query); |
37 | 37 | |
38 | 38 | /** Check if discount is actived **/ |
39 | - if ( !empty( $input) && !empty($input['discount']) ) { |
|
39 | + if (!empty($input) && !empty($input['discount'])) { |
|
40 | 40 | /** Activate the attributes **/ |
41 | - if ( !empty($discount_attributes) ) { |
|
42 | - foreach ( $discount_attributes as $discount_attribute ) { |
|
43 | - $update = $wpdb->prepare('UPDATE ' .WPSHOP_DBT_ATTRIBUTE. ' SET status = "valid" WHERE code = %s', $discount_attribute->code); |
|
41 | + if (!empty($discount_attributes)) { |
|
42 | + foreach ($discount_attributes as $discount_attribute) { |
|
43 | + $update = $wpdb->prepare('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET status = "valid" WHERE code = %s', $discount_attribute->code); |
|
44 | 44 | $wpdb->query($update); |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | /** Affect discount attributes to All Attributes Set section where there is a Price attribute **/ |
49 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE attribute_id = %d', $price_attribute_def->id); |
|
50 | - $attributes_sections = $wpdb->get_results( $query ); |
|
51 | - if ( !empty($attributes_sections) ) { |
|
52 | - foreach ( $attributes_sections as $attributes_section ) { |
|
49 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %d', $price_attribute_def->id); |
|
50 | + $attributes_sections = $wpdb->get_results($query); |
|
51 | + if (!empty($attributes_sections)) { |
|
52 | + foreach ($attributes_sections as $attributes_section) { |
|
53 | 53 | /** Check the Max Position for the Attribute section */ |
54 | - $query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE attribute_set_id = %d AND attribute_group_id = %d AND entity_type_id = %s', $attributes_section->attribute_set_id, $attributes_section->attribute_group_id, $attributes_section->entity_type_id); |
|
55 | - $max_position = $wpdb->get_var( $query ); |
|
56 | - $max_position = ( !empty($max_position) ) ? $max_position : 0; |
|
54 | + $query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_set_id = %d AND attribute_group_id = %d AND entity_type_id = %s', $attributes_section->attribute_set_id, $attributes_section->attribute_group_id, $attributes_section->entity_type_id); |
|
55 | + $max_position = $wpdb->get_var($query); |
|
56 | + $max_position = (!empty($max_position)) ? $max_position : 0; |
|
57 | 57 | /** Affect the discount attributes **/ |
58 | - foreach ( $discount_attributes as $discount_attribute) { |
|
59 | - $query = $wpdb->prepare(' SELECT COUNT(*) AS count_attributes_affect FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE attribute_set_id = %d AND attribute_group_id = %d AND entity_type_id = %s AND attribute_id = %d', $attributes_section->attribute_set_id, $attributes_section->attribute_group_id, $attributes_section->entity_type_id, $discount_attribute->id); |
|
60 | - $count_attribute_affectation = $wpdb->get_row( $query ); |
|
61 | - if ( !empty($count_attribute_affectation) && ( empty($count_attribute_affectation->count_attributes_affect) || $count_attribute_affectation->count_attributes_affect == 0 ) ) { |
|
62 | - $result = $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_DETAILS, array( 'status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attributes_section->entity_type_id, 'attribute_set_id' => $attributes_section->attribute_set_id, 'attribute_group_id' => $attributes_section->attribute_group_id, 'attribute_id' => $discount_attribute->id, 'position' => $max_position) ); |
|
58 | + foreach ($discount_attributes as $discount_attribute) { |
|
59 | + $query = $wpdb->prepare(' SELECT COUNT(*) AS count_attributes_affect FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_set_id = %d AND attribute_group_id = %d AND entity_type_id = %s AND attribute_id = %d', $attributes_section->attribute_set_id, $attributes_section->attribute_group_id, $attributes_section->entity_type_id, $discount_attribute->id); |
|
60 | + $count_attribute_affectation = $wpdb->get_row($query); |
|
61 | + if (!empty($count_attribute_affectation) && (empty($count_attribute_affectation->count_attributes_affect) || $count_attribute_affectation->count_attributes_affect == 0)) { |
|
62 | + $result = $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attributes_section->entity_type_id, 'attribute_set_id' => $attributes_section->attribute_set_id, 'attribute_group_id' => $attributes_section->attribute_group_id, 'attribute_id' => $discount_attribute->id, 'position' => $max_position)); |
|
63 | 63 | $max_position += 1; |
64 | 64 | } |
65 | 65 | } |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | } |
69 | 69 | else { |
70 | 70 | /** Desactivate Discount Attributes **/ |
71 | - if ( !empty($discount_attributes) ) { |
|
72 | - foreach ( $discount_attributes as $discount_attribute ) { |
|
73 | - $update = $wpdb->prepare('UPDATE ' .WPSHOP_DBT_ATTRIBUTE. ' SET status = "notused" WHERE code = %s', $discount_attribute->code); |
|
71 | + if (!empty($discount_attributes)) { |
|
72 | + foreach ($discount_attributes as $discount_attribute) { |
|
73 | + $update = $wpdb->prepare('UPDATE ' . WPSHOP_DBT_ATTRIBUTE . ' SET status = "notused" WHERE code = %s', $discount_attribute->code); |
|
74 | 74 | $wpdb->query($update); |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** Delete the Price attribute set section affectation **/ |
79 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE attribute_id = %d', $price_attribute_def->id); |
|
80 | - $attributes_sections = $wpdb->get_results( $query ); |
|
81 | - if ( !empty($attributes_sections) ) { |
|
82 | - foreach ( $attributes_sections as $attributes_section ) { |
|
79 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE attribute_id = %d', $price_attribute_def->id); |
|
80 | + $attributes_sections = $wpdb->get_results($query); |
|
81 | + if (!empty($attributes_sections)) { |
|
82 | + foreach ($attributes_sections as $attributes_section) { |
|
83 | 83 | /** Affect the discount attributes **/ |
84 | - foreach ( $discount_attributes as $discount_attribute) { |
|
85 | - $wpdb->delete( WPSHOP_DBT_ATTRIBUTE_DETAILS, array( 'entity_type_id' => $attributes_section->entity_type_id, 'attribute_set_id' => $attributes_section->attribute_set_id, 'attribute_group_id' => $attributes_section->attribute_group_id, 'attribute_id' => $discount_attribute->id ) ); |
|
84 | + foreach ($discount_attributes as $discount_attribute) { |
|
85 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('entity_type_id' => $attributes_section->entity_type_id, 'attribute_set_id' => $attributes_section->attribute_set_id, 'attribute_group_id' => $attributes_section->attribute_group_id, 'attribute_id' => $discount_attribute->id)); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
@@ -94,72 +94,72 @@ discard block |
||
94 | 94 | public static function wpshop_activate_discount_prices_field() { |
95 | 95 | $product_discount_option = get_option('wpshop_catalog_product_option'); |
96 | 96 | |
97 | - $output = '<input type="checkbox" id="wpshop_catalog_product_option_discount" name="wpshop_catalog_product_option[discount]" ' .( (!empty($product_discount_option) && !empty($product_discount_option['discount'])) ? 'checked="checked"' : '' ). ' />'; |
|
98 | - $output .= '<a class="wpshop_infobulle_marker" title="' .__('Activate the possibility to create discount on products', 'wpshop'). '" href="#">?</a>'; |
|
97 | + $output = '<input type="checkbox" id="wpshop_catalog_product_option_discount" name="wpshop_catalog_product_option[discount]" ' . ((!empty($product_discount_option) && !empty($product_discount_option['discount'])) ? 'checked="checked"' : '') . ' />'; |
|
98 | + $output .= '<a class="wpshop_infobulle_marker" title="' . __('Activate the possibility to create discount on products', 'wpshop') . '" href="#">?</a>'; |
|
99 | 99 | echo $output; |
100 | 100 | } |
101 | 101 | |
102 | - public static function check_product_price( $product, $cart = false ) { |
|
102 | + public static function check_product_price($product, $cart = false) { |
|
103 | 103 | $price_infos = array(); |
104 | 104 | $wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting'); |
105 | - if ( !empty($product) ) { |
|
106 | - if ( $cart ) { |
|
107 | - $discount_config = self::check_discount_for_product($product['product_id'] ); |
|
108 | - if ( !empty($discount_config) ) { |
|
105 | + if (!empty($product)) { |
|
106 | + if ($cart) { |
|
107 | + $discount_config = self::check_discount_for_product($product['product_id']); |
|
108 | + if (!empty($discount_config)) { |
|
109 | 109 | $product['price_ttc_before_discount'] = $product['product_price']; |
110 | 110 | $product['price_ht_before_discount'] = $product['price_ht']; |
111 | 111 | |
112 | - if ( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'special_price' ) { |
|
113 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] /100); |
|
114 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] /100) : $discount_config['value']; |
|
115 | - $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
|
112 | + if (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'special_price') { |
|
113 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] / 100); |
|
114 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] / 100) : $discount_config['value']; |
|
115 | + $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100); |
|
116 | 116 | } |
117 | - elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
118 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht_before_discount'] - $discount_config['value'] ) : ( ( $product['price_ttc_before_discount'] - $discount_config['value'] ) / (1 + $product['tx_tva'] /100) ) ; |
|
119 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * (1 + $product['tx_tva'] /100) : $product['price_ttc_before_discount'] - $discount_config['value']; |
|
120 | - $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
|
117 | + elseif (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount') { |
|
118 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? ($product['price_ht_before_discount'] - $discount_config['value']) : (($product['price_ttc_before_discount'] - $discount_config['value']) / (1 + $product['tx_tva'] / 100)); |
|
119 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $product['price_ht'] * (1 + $product['tx_tva'] / 100) : $product['price_ttc_before_discount'] - $discount_config['value']; |
|
120 | + $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100); |
|
121 | 121 | |
122 | 122 | } |
123 | - elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
124 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht_before_discount'] * ( 1 - $discount_config['value'] / 100) ) : ( ( $product['price_ttc_before_discount'] * ( 1 - ( $discount_config['value'] / 100 ) ) ) / (1 + $product['tx_tva'] /100) ) ; |
|
125 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * ( 1 + $product['tx_tva'] /100) : $product['price_ttc_before_discount'] * ( 1 - ( $discount_config['value'] / 100 ) ); |
|
126 | - $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
|
123 | + elseif (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
124 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? ($product['price_ht_before_discount'] * (1 - $discount_config['value'] / 100)) : (($product['price_ttc_before_discount'] * (1 - ($discount_config['value'] / 100))) / (1 + $product['tx_tva'] / 100)); |
|
125 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $product['price_ht'] * (1 + $product['tx_tva'] / 100) : $product['price_ttc_before_discount'] * (1 - ($discount_config['value'] / 100)); |
|
126 | + $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100); |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | - $price_infos['ati'] = ( !empty($product['price_ttc_before_discount'] )) ? number_format((float)$product['price_ttc_before_discount'], 2, '.', '') : number_format((float)$product['product_price'], 2, '.', ''); |
|
132 | - $price_infos['et'] = ( !empty($product['price_ht_before_discount'] ) ) ? number_format((float)$product['price_ht_before_discount'], 2, '.', '') : number_format((float)$product['price_ht'], 2, '.', ''); |
|
133 | - $price_infos['tva'] = $price_infos['et'] * ( $product['tx_tva'] / 100); |
|
131 | + $price_infos['ati'] = (!empty($product['price_ttc_before_discount'])) ? number_format((float)$product['price_ttc_before_discount'], 2, '.', '') : number_format((float)$product['product_price'], 2, '.', ''); |
|
132 | + $price_infos['et'] = (!empty($product['price_ht_before_discount'])) ? number_format((float)$product['price_ht_before_discount'], 2, '.', '') : number_format((float)$product['price_ht'], 2, '.', ''); |
|
133 | + $price_infos['tva'] = $price_infos['et'] * ($product['tx_tva'] / 100); |
|
134 | 134 | |
135 | - $price_infos['discount']['discount_exist'] = ( !empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount'] ) ) ? true : false; |
|
136 | - $price_infos['discount']['discount_ati_price'] = ( !empty($product['price_ttc_before_discount']) ) ? number_format((float)$product['product_price'], 2, '.', '') : 0; |
|
137 | - $price_infos['discount']['discount_et_price'] = ( !empty($product['price_ht_before_discount']) ) ? number_format( (float)$product['price_ht'], 2, '.', '' ) : 0; |
|
138 | - $price_infos['discount']['discount_tva'] = ( !empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount']) ) ? number_format( ($price_infos['discount']['discount_ati_price'] - $price_infos['discount']['discount_et_price']), 2, '.', '') : 0; |
|
135 | + $price_infos['discount']['discount_exist'] = (!empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount'])) ? true : false; |
|
136 | + $price_infos['discount']['discount_ati_price'] = (!empty($product['price_ttc_before_discount'])) ? number_format((float)$product['product_price'], 2, '.', '') : 0; |
|
137 | + $price_infos['discount']['discount_et_price'] = (!empty($product['price_ht_before_discount'])) ? number_format((float)$product['price_ht'], 2, '.', '') : 0; |
|
138 | + $price_infos['discount']['discount_tva'] = (!empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount'])) ? number_format(($price_infos['discount']['discount_ati_price'] - $price_infos['discount']['discount_et_price']), 2, '.', '') : 0; |
|
139 | 139 | } |
140 | 140 | else { |
141 | - $price_infos['ati'] = ( !empty($product['product_price'] )) ? number_format((float)$product['product_price'], 5, '.', '') : 0; |
|
142 | - $price_infos['et'] = ( !empty($product['price_ht'] ) ) ? number_format((float)$product['price_ht'], 5, '.', '') : 0; |
|
143 | - $price_infos['tva'] = ( !empty($product['tva'] ) ) ? $product['tva'] : 0; |
|
141 | + $price_infos['ati'] = (!empty($product['product_price'])) ? number_format((float)$product['product_price'], 5, '.', '') : 0; |
|
142 | + $price_infos['et'] = (!empty($product['price_ht'])) ? number_format((float)$product['price_ht'], 5, '.', '') : 0; |
|
143 | + $price_infos['tva'] = (!empty($product['tva'])) ? $product['tva'] : 0; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | 147 | } |
148 | 148 | else { |
149 | - if ( !empty( $product['price_ttc_before_discount']) && !empty( $product['price_ht_before_discount'] ) ) { |
|
150 | - $price_infos['discount']['discount_exist'] = ( !empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount'] ) ) ? true : false; |
|
151 | - $price_infos['discount']['discount_ati_price'] = ( !empty($product['product_price']) ) ? number_format((float)$product['product_price'], 2, '.', '') : 0; |
|
152 | - $price_infos['discount']['discount_et_price'] = ( !empty($product['price_ht']) ) ? number_format( (float)$product['price_ht'], 2, '.', '' ) : 0; |
|
153 | - $price_infos['discount']['discount_tva'] = ( !empty($product['tva']) ) ? $product['tva'] : 0; |
|
154 | - |
|
155 | - $price_infos['ati'] = ( !empty($product['price_ttc_before_discount'] )) ? number_format((float)$product['price_ttc_before_discount'], 5, '.', '') : 0; |
|
156 | - $price_infos['et'] = ( !empty($product['price_ht_before_discount']) ) ? number_format((float)$product['price_ht_before_discount'], 5, '.', '') : 0; |
|
157 | - $price_infos['tva'] = $price_infos['ati'] - $price_infos['et']; |
|
149 | + if (!empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount'])) { |
|
150 | + $price_infos['discount']['discount_exist'] = (!empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount'])) ? true : false; |
|
151 | + $price_infos['discount']['discount_ati_price'] = (!empty($product['product_price'])) ? number_format((float)$product['product_price'], 2, '.', '') : 0; |
|
152 | + $price_infos['discount']['discount_et_price'] = (!empty($product['price_ht'])) ? number_format((float)$product['price_ht'], 2, '.', '') : 0; |
|
153 | + $price_infos['discount']['discount_tva'] = (!empty($product['tva'])) ? $product['tva'] : 0; |
|
154 | + |
|
155 | + $price_infos['ati'] = (!empty($product['price_ttc_before_discount'])) ? number_format((float)$product['price_ttc_before_discount'], 5, '.', '') : 0; |
|
156 | + $price_infos['et'] = (!empty($product['price_ht_before_discount'])) ? number_format((float)$product['price_ht_before_discount'], 5, '.', '') : 0; |
|
157 | + $price_infos['tva'] = $price_infos['ati'] - $price_infos['et']; |
|
158 | 158 | } |
159 | 159 | else { |
160 | - $price_infos['ati'] = ( !empty($product['product_price'] )) ? number_format((float)$product['product_price'], 5, '.', '') : 0; |
|
161 | - $price_infos['et'] = ( !empty($product['price_ht'] ) ) ? number_format((float)$product['price_ht'], 5, '.', '') : 0; |
|
162 | - $price_infos['tva'] = ( !empty($product['tva'] ) ) ? $product['tva'] : 0; |
|
160 | + $price_infos['ati'] = (!empty($product['product_price'])) ? number_format((float)$product['product_price'], 5, '.', '') : 0; |
|
161 | + $price_infos['et'] = (!empty($product['price_ht'])) ? number_format((float)$product['price_ht'], 5, '.', '') : 0; |
|
162 | + $price_infos['tva'] = (!empty($product['tva'])) ? $product['tva'] : 0; |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
@@ -170,65 +170,65 @@ discard block |
||
170 | 170 | $wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting'); |
171 | 171 | // $wpshop_price_piloting_option = 'TTC'; |
172 | 172 | /** Price for Mini-output **/ |
173 | - if( !$price_checking_done ) { |
|
173 | + if (!$price_checking_done) { |
|
174 | 174 | |
175 | 175 | /** Checking if it's a product with variation **/ |
176 | - $variation_option_checking = get_post_meta( $product['product_id'], '_wpshop_variation_defining', true ); |
|
176 | + $variation_option_checking = get_post_meta($product['product_id'], '_wpshop_variation_defining', true); |
|
177 | 177 | |
178 | - if( !empty($variation_option_checking) ) { |
|
179 | - $variations_exists = wpshop_products::get_variation( $product['product_id'] ); |
|
178 | + if (!empty($variation_option_checking)) { |
|
179 | + $variations_exists = wpshop_products::get_variation($product['product_id']); |
|
180 | 180 | } |
181 | 181 | |
182 | - if( !empty($variation_option_checking) && !empty($variations_exists) ) { |
|
183 | - if ( !empty( $variation_option_checking['attributes']) ) { |
|
184 | - foreach( $variation_option_checking['attributes'] as $attribute ) { |
|
182 | + if (!empty($variation_option_checking) && !empty($variations_exists)) { |
|
183 | + if (!empty($variation_option_checking['attributes'])) { |
|
184 | + foreach ($variation_option_checking['attributes'] as $attribute) { |
|
185 | 185 | $selected_variation[$attribute] = 0; |
186 | - if( !empty( $variation_option_checking['options'] ) && !empty( $variation_option_checking['options']['attributes_default_value'] ) && array_key_exists( $attribute, $variation_option_checking['options']['attributes_default_value']) ){ |
|
187 | - if ( $variation_option_checking['options']['attributes_default_value'][$attribute] != 'none') { |
|
186 | + if (!empty($variation_option_checking['options']) && !empty($variation_option_checking['options']['attributes_default_value']) && array_key_exists($attribute, $variation_option_checking['options']['attributes_default_value'])) { |
|
187 | + if ($variation_option_checking['options']['attributes_default_value'][$attribute] != 'none') { |
|
188 | 188 | $selected_variation[$attribute] = $variation_option_checking['options']['attributes_default_value'][$attribute]; |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
193 | - if ( !empty($selected_variation) ) { |
|
194 | - $product_with_variation = wpshop_products::get_variation_by_priority( $selected_variation, $product['product_id'] ); |
|
193 | + if (!empty($selected_variation)) { |
|
194 | + $product_with_variation = wpshop_products::get_variation_by_priority($selected_variation, $product['product_id']); |
|
195 | 195 | } |
196 | - if( empty($product_with_variation[$product['product_id']]['variations']) ) { |
|
196 | + if (empty($product_with_variation[$product['product_id']]['variations'])) { |
|
197 | 197 | $product_with_variation[$product['product_id']]['variations'] = array(); |
198 | 198 | } |
199 | - if ( !empty($product_with_variation[$product['product_id']]['variation_priority']) ) { |
|
200 | - $product = wpshop_products::get_variation_price_behaviour( $product, $product_with_variation[$product['product_id']]['variations'], $product['product_id'], array('type' => $product_with_variation[$product['product_id']]['variation_priority'], 'text_from' => !empty($product_with_variation['text_from']) ? 'on' : '' ) ); |
|
199 | + if (!empty($product_with_variation[$product['product_id']]['variation_priority'])) { |
|
200 | + $product = wpshop_products::get_variation_price_behaviour($product, $product_with_variation[$product['product_id']]['variations'], $product['product_id'], array('type' => $product_with_variation[$product['product_id']]['variation_priority'], 'text_from' => !empty($product_with_variation['text_from']) ? 'on' : '')); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | else { |
204 | 204 | /** It's Simple product Check Discounts for products **/ |
205 | - $discount_config = self::check_discount_for_product( $product['product_id'] ); |
|
206 | - if ( !empty($discount_config) ) { |
|
207 | - if ( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'special_price' ) { |
|
205 | + $discount_config = self::check_discount_for_product($product['product_id']); |
|
206 | + if (!empty($discount_config)) { |
|
207 | + if (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'special_price') { |
|
208 | 208 | $product['price_ttc_before_discount'] = $product['product_price']; |
209 | 209 | $product['price_ht_before_discount'] = $product['price_ht']; |
210 | 210 | |
211 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] /100); |
|
212 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] /100) : $discount_config['value']; |
|
213 | - $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
|
211 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] / 100); |
|
212 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] / 100) : $discount_config['value']; |
|
213 | + $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100); |
|
214 | 214 | } |
215 | - elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
215 | + elseif (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount') { |
|
216 | 216 | $product['price_ttc_before_discount'] = $product['product_price']; |
217 | 217 | $product['price_ht_before_discount'] = $product['price_ht']; |
218 | 218 | |
219 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht_before_discount'] - $discount_config['value'] ) : ( ( $product['price_ttc_before_discount'] - $discount_config['value'] ) / (1 + $product['tx_tva'] /100) ) ; |
|
220 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * (1 + $product['tx_tva'] /100) : $product['price_ttc_before_discount'] - $discount_config['value']; |
|
221 | - $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
|
219 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? ($product['price_ht_before_discount'] - $discount_config['value']) : (($product['price_ttc_before_discount'] - $discount_config['value']) / (1 + $product['tx_tva'] / 100)); |
|
220 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $product['price_ht'] * (1 + $product['tx_tva'] / 100) : $product['price_ttc_before_discount'] - $discount_config['value']; |
|
221 | + $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100); |
|
222 | 222 | |
223 | 223 | } |
224 | - elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
224 | + elseif (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
225 | 225 | $product['price_ttc_before_discount'] = $product['product_price']; |
226 | 226 | $product['price_ht_before_discount'] = $product['price_ht']; |
227 | 227 | |
228 | 228 | |
229 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht_before_discount'] * ( 1 - $discount_config['value'] / 100) ) : ( ( $product['price_ttc_before_discount'] * ( 1 - ( $discount_config['value'] / 100 ) ) ) / (1 + $product['tx_tva'] /100) ) ; |
|
230 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * ( 1 + $product['tx_tva'] /100) : $product['price_ttc_before_discount'] * ( 1 - ( $discount_config['value'] / 100 ) ); |
|
231 | - $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
|
229 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? ($product['price_ht_before_discount'] * (1 - $discount_config['value'] / 100)) : (($product['price_ttc_before_discount'] * (1 - ($discount_config['value'] / 100))) / (1 + $product['tx_tva'] / 100)); |
|
230 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $product['price_ht'] * (1 + $product['tx_tva'] / 100) : $product['price_ttc_before_discount'] * (1 - ($discount_config['value'] / 100)); |
|
231 | + $product['tva'] = $product['price_ht'] * ($product['tx_tva'] / 100); |
|
232 | 232 | |
233 | 233 | } |
234 | 234 | } |
@@ -236,116 +236,116 @@ discard block |
||
236 | 236 | |
237 | 237 | } |
238 | 238 | |
239 | - $price_infos = self::check_product_price( $product ); |
|
240 | - $productCurrency = '<span class="wps-currency">'.wpshop_tools::wpshop_get_currency().'</span>'; |
|
239 | + $price_infos = self::check_product_price($product); |
|
240 | + $productCurrency = '<span class="wps-currency">' . wpshop_tools::wpshop_get_currency() . '</span>'; |
|
241 | 241 | |
242 | 242 | $wps_marketing_tools = new wps_marketing_tools_ctr(); |
243 | 243 | |
244 | - if ( !empty($price_infos) ) { |
|
245 | - if ( $return_type == 'check_only' ) { |
|
244 | + if (!empty($price_infos)) { |
|
245 | + if ($return_type == 'check_only') { |
|
246 | 246 | /** Check if the product price has been set */ |
247 | - if( isset($price_infos['ati']) && $price_infos['ati'] === '') return __('This product cannot be purchased - the price is not yet announced', 'wpshop'); |
|
247 | + if (isset($price_infos['ati']) && $price_infos['ati'] === '') return __('This product cannot be purchased - the price is not yet announced', 'wpshop'); |
|
248 | 248 | /** Check if the product price is coherent (not less than 0) */ |
249 | - if( isset($price_infos['ati']) && $price_infos['ati'] < 0) return __('This product cannot be purchased - its price is negative', 'wpshop'); |
|
249 | + if (isset($price_infos['ati']) && $price_infos['ati'] < 0) return __('This product cannot be purchased - its price is negative', 'wpshop'); |
|
250 | 250 | |
251 | 251 | return true; |
252 | 252 | } |
253 | - elseif( $return_type == 'just_price_infos' ) { |
|
253 | + elseif ($return_type == 'just_price_infos') { |
|
254 | 254 | $tpl_component = array(); |
255 | 255 | |
256 | - $price = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $price_infos['et'] : $price_infos['ati']; |
|
257 | - $exploded_price = explode('.', number_format($price,2, '.', '')); |
|
258 | - $price = '<span class="wps-absolute-price">'.$exploded_price[0].'</span><span class="wpshop_price_centimes_display">,'.( (!empty($exploded_price[1]) ) ? $exploded_price[1] : '').'</span>'; |
|
256 | + $price = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $price_infos['et'] : $price_infos['ati']; |
|
257 | + $exploded_price = explode('.', number_format($price, 2, '.', '')); |
|
258 | + $price = '<span class="wps-absolute-price">' . $exploded_price[0] . '</span><span class="wpshop_price_centimes_display">,' . ((!empty($exploded_price[1])) ? $exploded_price[1] : '') . '</span>'; |
|
259 | 259 | |
260 | - $tpl_component['TAX_PILOTING'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? __('ET', 'wpshop') : ''; |
|
260 | + $tpl_component['TAX_PILOTING'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? __('ET', 'wpshop') : ''; |
|
261 | 261 | |
262 | 262 | $tpl_component['CROSSED_OUT_PRICE'] = ''; |
263 | 263 | $tpl_component['MESSAGE_SAVE_MONEY'] = ''; |
264 | 264 | |
265 | 265 | |
266 | 266 | |
267 | - if( !empty($price_infos['discount']['discount_exist']) ) { |
|
268 | - $crossed_out_price = ( (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? number_format($price_infos['et'], 2) : number_format($price_infos['ati'], 2) ).' '. $productCurrency; |
|
267 | + if (!empty($price_infos['discount']['discount_exist'])) { |
|
268 | + $crossed_out_price = ((!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? number_format($price_infos['et'], 2) : number_format($price_infos['ati'], 2)) . ' ' . $productCurrency; |
|
269 | 269 | $tpl_component['CROSSED_OUT_PRICE'] = $crossed_out_price; |
270 | - if(!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') { |
|
271 | - $exploded_discount_price = explode('.', number_format($price_infos['discount']['discount_et_price'],2, '.', '')); |
|
270 | + if (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') { |
|
271 | + $exploded_discount_price = explode('.', number_format($price_infos['discount']['discount_et_price'], 2, '.', '')); |
|
272 | 272 | } |
273 | 273 | else { |
274 | - $exploded_discount_price = explode('.', number_format($price_infos['discount']['discount_ati_price'],2, '.', '')); |
|
274 | + $exploded_discount_price = explode('.', number_format($price_infos['discount']['discount_ati_price'], 2, '.', '')); |
|
275 | 275 | } |
276 | 276 | |
277 | - $discount_price = $exploded_discount_price[0].'<span class="wpshop_price_centimes_display">,'.( (!empty($exploded_discount_price[1]) ) ? $exploded_discount_price[1] : '').'</span>'; |
|
278 | - $tpl_component['PRODUCT_PRICE'] = '<span class="wps-absolute-price">'.$discount_price.'</span> '.$productCurrency; |
|
277 | + $discount_price = $exploded_discount_price[0] . '<span class="wpshop_price_centimes_display">,' . ((!empty($exploded_discount_price[1])) ? $exploded_discount_price[1] : '') . '</span>'; |
|
278 | + $tpl_component['PRODUCT_PRICE'] = '<span class="wps-absolute-price">' . $discount_price . '</span> ' . $productCurrency; |
|
279 | 279 | |
280 | - $tpl_component['MESSAGE_SAVE_MONEY'] = $wps_marketing_tools->display_message_you_save_money( $price_infos ); |
|
280 | + $tpl_component['MESSAGE_SAVE_MONEY'] = $wps_marketing_tools->display_message_you_save_money($price_infos); |
|
281 | 281 | } |
282 | 282 | else { |
283 | - $tpl_component['PRODUCT_PRICE'] = $price.' '.$productCurrency; |
|
283 | + $tpl_component['PRODUCT_PRICE'] = $price . ' ' . $productCurrency; |
|
284 | 284 | } |
285 | 285 | |
286 | - $post_type = get_post_type( $product['product_id'] ); |
|
287 | - if ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
288 | - $price_display_attribute = get_post_meta( $product['product_id'], '_wpshop_variation_defining', true ); |
|
286 | + $post_type = get_post_type($product['product_id']); |
|
287 | + if ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
288 | + $price_display_attribute = get_post_meta($product['product_id'], '_wpshop_variation_defining', true); |
|
289 | 289 | } |
290 | - elseif( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
291 | - $parent_def = wpshop_products::get_parent_variation ( $product['product_id'] ); |
|
292 | - if( !empty($parent_def) && !empty($parent_def['parent_post']) ) { |
|
290 | + elseif ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
291 | + $parent_def = wpshop_products::get_parent_variation($product['product_id']); |
|
292 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
293 | 293 | $parent_post = $parent_def['parent_post']; |
294 | - $price_display_attribute = get_post_meta( $parent_post->ID, '_wpshop_variation_defining', true ); |
|
294 | + $price_display_attribute = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true); |
|
295 | 295 | } |
296 | 296 | } |
297 | - $price_display_option = get_option( 'wpshop_catalog_product_option' ); |
|
298 | - $tpl_component['PRICE_FROM'] = ( ( !empty($price_display_attribute) && empty($price_display_attribute['options'] ) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) ) || ( ( !empty($price_display_attribute) && (!empty($price_display_attribute['options'] ) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']) ) ) ) ) ) ? 'on' : ''; |
|
297 | + $price_display_option = get_option('wpshop_catalog_product_option'); |
|
298 | + $tpl_component['PRICE_FROM'] = ((!empty($price_display_attribute) && empty($price_display_attribute['options']) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from'])) || ((!empty($price_display_attribute) && (!empty($price_display_attribute['options']) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from'])))))) ? 'on' : ''; |
|
299 | 299 | |
300 | 300 | return $tpl_component; |
301 | 301 | } |
302 | - else if ( $return_type == 'price_display' ) { |
|
302 | + else if ($return_type == 'price_display') { |
|
303 | 303 | $tpl_component = array(); |
304 | - $price = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $price_infos['et'] : $price_infos['ati']; |
|
304 | + $price = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $price_infos['et'] : $price_infos['ati']; |
|
305 | 305 | |
306 | 306 | $price_data = $price_infos; |
307 | 307 | |
308 | - $exploded_price = explode('.', number_format($price,2, '.', '')); |
|
309 | - $price = '<span class="wps-absolute-price">'.$exploded_price[0].'</span><span class="wpshop_price_centimes_display">.'.( (!empty($exploded_price[1]) ) ? $exploded_price[1] : '').'</span>'; |
|
308 | + $exploded_price = explode('.', number_format($price, 2, '.', '')); |
|
309 | + $price = '<span class="wps-absolute-price">' . $exploded_price[0] . '</span><span class="wpshop_price_centimes_display">.' . ((!empty($exploded_price[1])) ? $exploded_price[1] : '') . '</span>'; |
|
310 | 310 | |
311 | - $tpl_component['TAX_PILOTING'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? __('ET', 'wpshop') : ''; |
|
311 | + $tpl_component['TAX_PILOTING'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? __('ET', 'wpshop') : ''; |
|
312 | 312 | |
313 | 313 | $tpl_component['CROSSED_OUT_PRICE'] = ''; |
314 | 314 | $tpl_component['MESSAGE_SAVE_MONEY'] = ''; |
315 | 315 | |
316 | - if( !empty($price_infos['discount']['discount_exist']) ) { |
|
316 | + if (!empty($price_infos['discount']['discount_exist'])) { |
|
317 | 317 | $text_from = false; |
318 | 318 | /** Get variation defining **/ |
319 | - $post_type = get_post_type( $product['product_id'] ); |
|
320 | - if( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
321 | - $parent_def = wpshop_products::get_parent_variation ( $product['product_id'] ); |
|
322 | - if( !empty($parent_def) && !empty($parent_def['parent_post']) ) { |
|
319 | + $post_type = get_post_type($product['product_id']); |
|
320 | + if ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
321 | + $parent_def = wpshop_products::get_parent_variation($product['product_id']); |
|
322 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
323 | 323 | $parent_post = $parent_def['parent_post']; |
324 | - $price_display_attribute = get_post_meta( $parent_post->ID, '_wpshop_variation_defining', true ); |
|
324 | + $price_display_attribute = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | else { |
328 | - $price_display_attribute = get_post_meta( $product['product_id'], '_wpshop_variation_defining', true ); |
|
328 | + $price_display_attribute = get_post_meta($product['product_id'], '_wpshop_variation_defining', true); |
|
329 | 329 | } |
330 | - $text_from = ( ( !empty($price_display_attribute) && empty($price_display_attribute['options'] ) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) ) || ( ( !empty($price_display_attribute) && (!empty($price_display_attribute['options'] ) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']) ) ) ) ) && !empty($product['text_from']) ) ? true : false; |
|
330 | + $text_from = ((!empty($price_display_attribute) && empty($price_display_attribute['options']) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from'])) || ((!empty($price_display_attribute) && (!empty($price_display_attribute['options']) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']))))) && !empty($product['text_from'])) ? true : false; |
|
331 | 331 | |
332 | 332 | |
333 | - $exploded_price = explode('.', number_format($price_infos['discount']['discount_et_price'],2, '.', '')); |
|
334 | - $price_infos['discount']['discount_et_price'] = '<span class="wps-absolute-price">'.$exploded_price[0].'</span><span class="wpshop_price_centimes_display">.'.( (!empty($exploded_price[1]) ) ? $exploded_price[1] : '').'</span>'; |
|
333 | + $exploded_price = explode('.', number_format($price_infos['discount']['discount_et_price'], 2, '.', '')); |
|
334 | + $price_infos['discount']['discount_et_price'] = '<span class="wps-absolute-price">' . $exploded_price[0] . '</span><span class="wpshop_price_centimes_display">.' . ((!empty($exploded_price[1])) ? $exploded_price[1] : '') . '</span>'; |
|
335 | 335 | |
336 | - $exploded_price = explode('.', number_format($price_infos['discount']['discount_ati_price'],2, '.', '')); |
|
337 | - $price_infos['discount']['discount_ati_price'] = '<span class="wps-absolute-price">'.$exploded_price[0].'</span><span class="wpshop_price_centimes_display">.'.( (!empty($exploded_price[1]) ) ? $exploded_price[1] : '').'</span>'; |
|
336 | + $exploded_price = explode('.', number_format($price_infos['discount']['discount_ati_price'], 2, '.', '')); |
|
337 | + $price_infos['discount']['discount_ati_price'] = '<span class="wps-absolute-price">' . $exploded_price[0] . '</span><span class="wpshop_price_centimes_display">.' . ((!empty($exploded_price[1])) ? $exploded_price[1] : '') . '</span>'; |
|
338 | 338 | |
339 | 339 | |
340 | - $crossed_out_price = ( (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? number_format($price_infos['et'], 2) : number_format($price_infos['ati'], 2) ).' '. $productCurrency; |
|
341 | - $tpl_component['CROSSED_OUT_PRICE'] = str_replace( '.', ',', ( ( $text_from ) ? __('Price from', 'wpshop') . ' ' : '' ). wpshop_display::display_template_element('product_price_template_crossed_out_price', array('CROSSED_OUT_PRICE_VALUE' => $crossed_out_price)) ); |
|
342 | - $tpl_component['PRODUCT_PRICE'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? '<span class="wps-absolute-price">'. $price_infos['discount']['discount_et_price'].'</span> '.$productCurrency : '<span class="wps-absolute-price">'.$price_infos['discount']['discount_ati_price'].'</span> '.$productCurrency; |
|
343 | - $tpl_component['MESSAGE_SAVE_MONEY'] = $wps_marketing_tools->display_message_you_save_money( $price_data ); |
|
340 | + $crossed_out_price = ((!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? number_format($price_infos['et'], 2) : number_format($price_infos['ati'], 2)) . ' ' . $productCurrency; |
|
341 | + $tpl_component['CROSSED_OUT_PRICE'] = str_replace('.', ',', (($text_from) ? __('Price from', 'wpshop') . ' ' : '') . wpshop_display::display_template_element('product_price_template_crossed_out_price', array('CROSSED_OUT_PRICE_VALUE' => $crossed_out_price))); |
|
342 | + $tpl_component['PRODUCT_PRICE'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? '<span class="wps-absolute-price">' . $price_infos['discount']['discount_et_price'] . '</span> ' . $productCurrency : '<span class="wps-absolute-price">' . $price_infos['discount']['discount_ati_price'] . '</span> ' . $productCurrency; |
|
343 | + $tpl_component['MESSAGE_SAVE_MONEY'] = $wps_marketing_tools->display_message_you_save_money($price_data); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | else { |
347 | - if( get_post_type($product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
348 | - $parent_def = wpshop_products::get_parent_variation( $product['product_id'] ); |
|
347 | + if (get_post_type($product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
348 | + $parent_def = wpshop_products::get_parent_variation($product['product_id']); |
|
349 | 349 | $pid = $parent_def['parent_post']; |
350 | 350 | $pid = $pid->ID; |
351 | 351 | } |
@@ -355,35 +355,35 @@ discard block |
||
355 | 355 | |
356 | 356 | $text_from = false; |
357 | 357 | /** Get variation defining **/ |
358 | - $post_type = get_post_type( $pid ); |
|
359 | - if( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
360 | - $parent_def = wpshop_products::get_parent_variation ( $pid ); |
|
361 | - if( !empty($parent_def) && !empty($parent_def['parent_post']) ) { |
|
358 | + $post_type = get_post_type($pid); |
|
359 | + if ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
360 | + $parent_def = wpshop_products::get_parent_variation($pid); |
|
361 | + if (!empty($parent_def) && !empty($parent_def['parent_post'])) { |
|
362 | 362 | $parent_post = $parent_def['parent_post']; |
363 | - $price_display_attribute = get_post_meta( $parent_post->ID, '_wpshop_variation_defining', true ); |
|
363 | + $price_display_attribute = get_post_meta($parent_post->ID, '_wpshop_variation_defining', true); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | else { |
367 | - $price_display_attribute = get_post_meta( $pid, '_wpshop_variation_defining', true ); |
|
367 | + $price_display_attribute = get_post_meta($pid, '_wpshop_variation_defining', true); |
|
368 | 368 | } |
369 | 369 | |
370 | - $price_display_attribute = get_post_meta( $pid, '_wpshop_variation_defining', true ); |
|
370 | + $price_display_attribute = get_post_meta($pid, '_wpshop_variation_defining', true); |
|
371 | 371 | |
372 | - $text_from = ( ( !empty($price_display_attribute) && empty($price_display_attribute['options'] ) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) ) || ( ( !empty($price_display_attribute) && (!empty($price_display_attribute['options'] ) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']) ) ) ) ) ) ? true : false; |
|
372 | + $text_from = ((!empty($price_display_attribute) && empty($price_display_attribute['options']) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from'])) || ((!empty($price_display_attribute) && (!empty($price_display_attribute['options']) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from'])))))) ? true : false; |
|
373 | 373 | |
374 | - $tpl_component['PRODUCT_PRICE'] = ( $text_from && !empty($product['text_from']) ) ? __('Price from', 'wpshop') . ' ' : ''; |
|
375 | - $tpl_component['PRODUCT_PRICE'] .= $price.' '.$productCurrency; |
|
374 | + $tpl_component['PRODUCT_PRICE'] = ($text_from && !empty($product['text_from'])) ? __('Price from', 'wpshop') . ' ' : ''; |
|
375 | + $tpl_component['PRODUCT_PRICE'] .= $price . ' ' . $productCurrency; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
379 | 379 | // Replace . by , |
380 | - $tpl_component['PRODUCT_PRICE'] = str_replace( '.',',', $tpl_component['PRODUCT_PRICE'] ); |
|
380 | + $tpl_component['PRODUCT_PRICE'] = str_replace('.', ',', $tpl_component['PRODUCT_PRICE']); |
|
381 | 381 | |
382 | - if ( $output_type == 'complete_sheet' ) { |
|
383 | - $price_tpl = wpshop_display::display_template_element('product_price_template_complete_sheet', $tpl_component ); |
|
382 | + if ($output_type == 'complete_sheet') { |
|
383 | + $price_tpl = wpshop_display::display_template_element('product_price_template_complete_sheet', $tpl_component); |
|
384 | 384 | } |
385 | - elseif ( $output_type == 'mini_output' || in_array('mini_output', $output_type ) ) { |
|
386 | - $price_tpl = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component ); |
|
385 | + elseif ($output_type == 'mini_output' || in_array('mini_output', $output_type)) { |
|
386 | + $price_tpl = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component); |
|
387 | 387 | } |
388 | 388 | return $price_tpl; |
389 | 389 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @return stdClass ( value, id ) L'id de l'attribut et le taux de TVA / |
404 | 404 | * Attribute ID and the VAT rate |
405 | 405 | */ |
406 | - public static function get_rate_vat( $product_id ) { |
|
406 | + public static function get_rate_vat($product_id) { |
|
407 | 407 | global $wpdb; |
408 | 408 | |
409 | 409 | /** |
@@ -417,18 +417,18 @@ discard block |
||
417 | 417 | INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . " as ATTR_VAL_INT ON ( ATTR_VAL_INT.attribute_id = ATTR.id AND ATTR_VAL_OPTIONS.id=ATTR_VAL_INT.value ) |
418 | 418 | WHERE ATTR.code=%s AND ATTR_VAL_INT.entity_id=%d"; |
419 | 419 | |
420 | - $request = $wpdb->prepare( $query, array( 'tx_tva', $product_id ) ); |
|
421 | - $rate_vat = $wpdb->get_row( $request ); |
|
420 | + $request = $wpdb->prepare($query, array('tx_tva', $product_id)); |
|
421 | + $rate_vat = $wpdb->get_row($request); |
|
422 | 422 | |
423 | 423 | /** |
424 | 424 | * Vérifie ensuite si elle est vide, si elle est vide met la valeur par |
425 | 425 | * défaut / Then checks if it is empty , if empty the value put the |
426 | 426 | * default value |
427 | 427 | */ |
428 | - if( empty( $rate_vat ) ) { |
|
429 | - wpeologs_ctr::log_datas_in_files( 'wps_product', array( |
|
428 | + if (empty($rate_vat)) { |
|
429 | + wpeologs_ctr::log_datas_in_files('wps_product', array( |
|
430 | 430 | 'object_id' => $product_id, |
431 | - 'message' => __( 'Use the default VAT rate', 'wpshop' ) ), 0 |
|
431 | + 'message' => __('Use the default VAT rate', 'wpshop') ), 0 |
|
432 | 432 | ); |
433 | 433 | |
434 | 434 | $query = " |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " as ATTR_VAL_OPTIONS ON ATTR_VAL_OPTIONS.attribute_id = ATTR.id |
438 | 438 | WHERE ATTR.code=%s AND ATTR_VAL_OPTIONS.id=ATTR.default_value"; |
439 | 439 | |
440 | - $request = $wpdb->prepare( $query, array( 'tx_tva' ) ); |
|
441 | - $rate_vat = $wpdb->get_row( $request ); |
|
440 | + $request = $wpdb->prepare($query, array('tx_tva')); |
|
441 | + $rate_vat = $wpdb->get_row($request); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | * dans ce cas la on utilise le log / If it is still empty , it means that no |
447 | 447 | * VAT rate found in this case the log is used |
448 | 448 | */ |
449 | - if( empty( $rate_vat ) ) { |
|
450 | - wpeologs_ctr::log_datas_in_files( 'wps_product', array( |
|
449 | + if (empty($rate_vat)) { |
|
450 | + wpeologs_ctr::log_datas_in_files('wps_product', array( |
|
451 | 451 | 'object_id' => $product_id, |
452 | - 'message' => __( 'No VAT rate in the product and no default VAT rate found', 'wpshop' ) ), 2 |
|
452 | + 'message' => __('No VAT rate in the product and no default VAT rate found', 'wpshop') ), 2 |
|
453 | 453 | ); |
454 | 454 | } |
455 | 455 | |
@@ -459,19 +459,19 @@ discard block |
||
459 | 459 | /** |
460 | 460 | * Check if isset Required attributes |
461 | 461 | */ |
462 | - public static function check_required_attributes( $product_id ) { |
|
462 | + public static function check_required_attributes($product_id) { |
|
463 | 463 | $required_attributes_list = array(); |
464 | - $variation_option = get_post_meta( $product_id, '_wpshop_variation_defining', true); |
|
465 | - if ( !empty($variation_option) && !empty($variation_option['attributes']) ) { |
|
466 | - if( !empty($variation_option['options']) && !empty($variation_option['options']['required_attributes']) ) { |
|
467 | - foreach( $variation_option['options']['required_attributes'] as $required_attribute ) { |
|
468 | - $required_attributes_list[ $required_attribute ] = $required_attribute; |
|
464 | + $variation_option = get_post_meta($product_id, '_wpshop_variation_defining', true); |
|
465 | + if (!empty($variation_option) && !empty($variation_option['attributes'])) { |
|
466 | + if (!empty($variation_option['options']) && !empty($variation_option['options']['required_attributes'])) { |
|
467 | + foreach ($variation_option['options']['required_attributes'] as $required_attribute) { |
|
468 | + $required_attributes_list[$required_attribute] = $required_attribute; |
|
469 | 469 | } |
470 | 470 | } |
471 | 471 | /** Check the attribute configuration **/ |
472 | - foreach ( $variation_option['attributes'] as $variation ) { |
|
473 | - $attribute_def = wpshop_attributes::getElement( $variation, '"valid"', 'code' ); |
|
474 | - if ( is_object($attribute_def) && !empty($attribute_def->is_required) && $attribute_def->is_required == 'yes' ) { |
|
472 | + foreach ($variation_option['attributes'] as $variation) { |
|
473 | + $attribute_def = wpshop_attributes::getElement($variation, '"valid"', 'code'); |
|
474 | + if (is_object($attribute_def) && !empty($attribute_def->is_required) && $attribute_def->is_required == 'yes') { |
|
475 | 475 | $required_attributes_list[$attribute_def->code] = $attribute_def->code; |
476 | 476 | } |
477 | 477 | } |
@@ -483,60 +483,60 @@ discard block |
||
483 | 483 | } |
484 | 484 | |
485 | 485 | /** Check the Product lower price **/ |
486 | - public static function check_product_lower_price ( $product_id ) { |
|
486 | + public static function check_product_lower_price($product_id) { |
|
487 | 487 | global $wpdb; |
488 | - $price_piloting_option = get_option( 'wpshop_shop_price_piloting' ); |
|
488 | + $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
|
489 | 489 | $lower_price_product = $min_price = 0; |
490 | - $variations = wpshop_products::get_variation( $product_id ); |
|
490 | + $variations = wpshop_products::get_variation($product_id); |
|
491 | 491 | $single_variations = $lower_price_product_combinaison = array(); |
492 | 492 | $first = true; |
493 | 493 | |
494 | 494 | /** Check variations type **/ |
495 | - $query = $wpdb->prepare( 'SELECT DISTINCT( SUBSTRING( m.meta_value, 3,1 ) ) AS attributes_count FROM ' .$wpdb->postmeta .' AS m INNER JOIN ' .$wpdb->posts. ' AS P ON ((P.ID = m.post_id) AND (P.post_parent = %d)) WHERE meta_key LIKE %s', $product_id, '_wpshop_variations_attribute_def' ); |
|
496 | - $variation_type = $wpdb->get_results( $query ); |
|
495 | + $query = $wpdb->prepare('SELECT DISTINCT( SUBSTRING( m.meta_value, 3,1 ) ) AS attributes_count FROM ' . $wpdb->postmeta . ' AS m INNER JOIN ' . $wpdb->posts . ' AS P ON ((P.ID = m.post_id) AND (P.post_parent = %d)) WHERE meta_key LIKE %s', $product_id, '_wpshop_variations_attribute_def'); |
|
496 | + $variation_type = $wpdb->get_results($query); |
|
497 | 497 | |
498 | 498 | |
499 | 499 | /** Check which type of variation contains the product **/ |
500 | 500 | $contains_simple_variation = false; |
501 | - if ( !empty($variation_type) ) { |
|
502 | - foreach( $variation_type as $k => $value ) { |
|
503 | - if( $value->attributes_count == '1' ) { |
|
501 | + if (!empty($variation_type)) { |
|
502 | + foreach ($variation_type as $k => $value) { |
|
503 | + if ($value->attributes_count == '1') { |
|
504 | 504 | $contains_simple_variation = true; |
505 | 505 | } |
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
509 | - if ( $contains_simple_variation ) { |
|
509 | + if ($contains_simple_variation) { |
|
510 | 510 | |
511 | - if( !empty($variations) ) { |
|
512 | - $attributes = get_post_meta( $product_id, '_wpshop_variation_defining', true); |
|
513 | - if ( !empty($attributes) && !empty($attributes['attributes']) ) { |
|
511 | + if (!empty($variations)) { |
|
512 | + $attributes = get_post_meta($product_id, '_wpshop_variation_defining', true); |
|
513 | + if (!empty($attributes) && !empty($attributes['attributes'])) { |
|
514 | 514 | /** Construct an array with all cheaper attributes **/ |
515 | - foreach( $attributes['attributes'] as $key=>$attribute ) { |
|
515 | + foreach ($attributes['attributes'] as $key=>$attribute) { |
|
516 | 516 | $min_price = 0; |
517 | 517 | $first = true; |
518 | - foreach( $variations as $k => $variation) { |
|
519 | - if ( !empty($variation['variation_def']) && count($variation['variation_def']) == 1 ) { |
|
520 | - if( array_key_exists($attribute, $variation['variation_def'] ) ) { |
|
521 | - $variation_price = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? $variation['variation_dif']['price_ht'] : !empty( $variation['variation_dif']['product_price'] ) ? $variation['variation_dif']['product_price'] : 0; |
|
518 | + foreach ($variations as $k => $variation) { |
|
519 | + if (!empty($variation['variation_def']) && count($variation['variation_def']) == 1) { |
|
520 | + if (array_key_exists($attribute, $variation['variation_def'])) { |
|
521 | + $variation_price = (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? $variation['variation_dif']['price_ht'] : !empty($variation['variation_dif']['product_price']) ? $variation['variation_dif']['product_price'] : 0; |
|
522 | 522 | |
523 | 523 | /** Check Discount **/ |
524 | - $variation_price = ( !empty( $variation['variation_dif']['special_price'] ) && $variation['variation_dif']['special_price'] > 0 ) ? $variation['variation_dif']['special_price'] : $variation_price; |
|
525 | - if( empty($variation['variation_dif']['special_price']) && !empty($variation['variation_dif']['discount_rate']) && $variation['variation_dif']['discount_rate'] > 0) { |
|
526 | - $query = $wpdb->prepare( 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $variation['variation_dif']['tx_tva'] ); |
|
527 | - $tx_tva = $wpdb->get_var( $query ); |
|
528 | - $variation_price = $variation['variation_dif']['price_ht'] / ( 1 + ($variation['variation_dif']['discount_rate'] / 100 ) ); |
|
529 | - $variation_price = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? $variation_price : $variation_price * 1 + ($tx_tva / 100); |
|
524 | + $variation_price = (!empty($variation['variation_dif']['special_price']) && $variation['variation_dif']['special_price'] > 0) ? $variation['variation_dif']['special_price'] : $variation_price; |
|
525 | + if (empty($variation['variation_dif']['special_price']) && !empty($variation['variation_dif']['discount_rate']) && $variation['variation_dif']['discount_rate'] > 0) { |
|
526 | + $query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $variation['variation_dif']['tx_tva']); |
|
527 | + $tx_tva = $wpdb->get_var($query); |
|
528 | + $variation_price = $variation['variation_dif']['price_ht'] / (1 + ($variation['variation_dif']['discount_rate'] / 100)); |
|
529 | + $variation_price = (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? $variation_price : $variation_price * 1 + ($tx_tva / 100); |
|
530 | 530 | } |
531 | - elseif( empty($variation['variation_dif']['special_price']) && !empty($variation['variation_dif']['discount_amount']) && $variation['variation_dif']['discount_amount'] > 0 ) { |
|
532 | - $query = $wpdb->prepare( 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $variation['variation_dif']['tx_tva'] ); |
|
533 | - $tx_tva = $wpdb->get_var( $query ); |
|
534 | - $variation_price = $variation['variation_dif']['price_ht'] - $variation['variation_dif']['discount_amount']; |
|
535 | - $variation_price = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? $variation_price : $variation_price * 1 + ($tx_tva / 100); |
|
531 | + elseif (empty($variation['variation_dif']['special_price']) && !empty($variation['variation_dif']['discount_amount']) && $variation['variation_dif']['discount_amount'] > 0) { |
|
532 | + $query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $variation['variation_dif']['tx_tva']); |
|
533 | + $tx_tva = $wpdb->get_var($query); |
|
534 | + $variation_price = $variation['variation_dif']['price_ht'] - $variation['variation_dif']['discount_amount']; |
|
535 | + $variation_price = (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? $variation_price : $variation_price * 1 + ($tx_tva / 100); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** Check the Min-price **/ |
539 | - if( $first|| $min_price >= $variation_price ) { |
|
539 | + if ($first || $min_price >= $variation_price) { |
|
540 | 540 | $first = false; |
541 | 541 | $min_price = $variation_price; |
542 | 542 | $lower_price_product_combinaison['variations'][$attribute] = $k; |
@@ -550,22 +550,22 @@ discard block |
||
550 | 550 | } |
551 | 551 | } |
552 | 552 | else { |
553 | - if ( !empty($product_id) ) { |
|
554 | - if( !empty($variations) ) { |
|
553 | + if (!empty($product_id)) { |
|
554 | + if (!empty($variations)) { |
|
555 | 555 | |
556 | - foreach( $variations as $variation_id => $variation) { |
|
557 | - if ( !empty($variation['variation_dif']) && !empty($variation['variation_def']) && count($variation['variation_def']) > 1) { |
|
558 | - $variation_price = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? ( ( !empty($variation['variation_dif']['price_ht']) ) ? $variation['variation_dif']['price_ht'] : 0) : ( ( !empty($variation['variation_dif']['product_price']) ) ? $variation['variation_dif']['product_price'] : 0); |
|
556 | + foreach ($variations as $variation_id => $variation) { |
|
557 | + if (!empty($variation['variation_dif']) && !empty($variation['variation_def']) && count($variation['variation_def']) > 1) { |
|
558 | + $variation_price = (!empty($price_piloting_option) && $price_piloting_option == 'HT') ? ((!empty($variation['variation_dif']['price_ht'])) ? $variation['variation_dif']['price_ht'] : 0) : ((!empty($variation['variation_dif']['product_price'])) ? $variation['variation_dif']['product_price'] : 0); |
|
559 | 559 | /** Check the Min-price **/ |
560 | - if( $min_price >= $variation_price || $first ) { |
|
560 | + if ($min_price >= $variation_price || $first) { |
|
561 | 561 | $min_price = $variation_price; |
562 | 562 | $var_id = $variation_id; |
563 | 563 | } |
564 | 564 | } |
565 | - $first = false; |
|
565 | + $first = false; |
|
566 | 566 | } |
567 | 567 | |
568 | - if ( !empty($var_id) ) { |
|
568 | + if (!empty($var_id)) { |
|
569 | 569 | $lower_price_product_combinaison['variations'][] = $var_id; |
570 | 570 | $lower_price_product_combinaison['variation_priority'] = 'combined'; |
571 | 571 | } |
@@ -581,25 +581,25 @@ discard block |
||
581 | 581 | * @param array $discount_config |
582 | 582 | * @return array |
583 | 583 | */ |
584 | - public static function calcul_discounted_price( $product, $discount_config ) { |
|
585 | - $wpshop_price_piloting_option = get_option( 'wpshop_shop_price_piloting'); |
|
586 | - if( !empty($discount_config) ) { |
|
584 | + public static function calcul_discounted_price($product, $discount_config) { |
|
585 | + $wpshop_price_piloting_option = get_option('wpshop_shop_price_piloting'); |
|
586 | + if (!empty($discount_config)) { |
|
587 | 587 | |
588 | - if ( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'special_price' ) { |
|
589 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] /100); |
|
590 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] /100) : $discount_config['value']; |
|
588 | + if (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'special_price') { |
|
589 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] / 100); |
|
590 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] / 100) : $discount_config['value']; |
|
591 | 591 | $product['tva'] = $product['product_price'] - $product['price_ht']; |
592 | 592 | } |
593 | - elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
594 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht'] - $discount_config['value'] ) : ( ( $product['product_price'] - $discount_config['value'] ) / (1 + $product['tx_tva'] /100) ) ; |
|
595 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * (1 + $product['tx_tva'] /100) : $product['product_price'] - $discount_config['value']; |
|
596 | - $product['tva'] = $product['product_price'] - $product['price_ht']; |
|
593 | + elseif (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount') { |
|
594 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? ($product['price_ht'] - $discount_config['value']) : (($product['product_price'] - $discount_config['value']) / (1 + $product['tx_tva'] / 100)); |
|
595 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $product['price_ht'] * (1 + $product['tx_tva'] / 100) : $product['product_price'] - $discount_config['value']; |
|
596 | + $product['tva'] = $product['product_price'] - $product['price_ht']; |
|
597 | 597 | |
598 | 598 | } |
599 | - elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
600 | - $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht'] * ( 1 - $discount_config['value'] / 100) ) : ( ( $product['product_price'] * ( 1 - ( $discount_config['value'] / 100 ) ) ) / (1 + $product['tx_tva'] /100) ) ; |
|
601 | - $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * ( 1 + $product['tx_tva'] /100) : $product['product_price'] * ( 1 - ( $discount_config['value'] / 100 ) ); |
|
602 | - $product['tva'] = $product['product_price'] - $product['price_ht']; |
|
599 | + elseif (!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
600 | + $product['price_ht'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? ($product['price_ht'] * (1 - $discount_config['value'] / 100)) : (($product['product_price'] * (1 - ($discount_config['value'] / 100))) / (1 + $product['tx_tva'] / 100)); |
|
601 | + $product['product_price'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $product['price_ht'] * (1 + $product['tx_tva'] / 100) : $product['product_price'] * (1 - ($discount_config['value'] / 100)); |
|
602 | + $product['tva'] = $product['product_price'] - $product['price_ht']; |
|
603 | 603 | } |
604 | 604 | } |
605 | 605 | return $product; |
@@ -607,39 +607,39 @@ discard block |
||
607 | 607 | |
608 | 608 | |
609 | 609 | /** Check Discount for Product **/ |
610 | - public static function check_discount_for_product( $product_id, $head_product_id = 0 ) { |
|
610 | + public static function check_discount_for_product($product_id, $head_product_id = 0) { |
|
611 | 611 | $discount_config = array(); |
612 | 612 | $time_def = array('0000-00-00 00:00:00', '0000-00-00'); |
613 | 613 | |
614 | - if( !empty($product_id) ) { |
|
615 | - if ( !empty($head_product_id) ) { |
|
616 | - $product_meta = get_post_meta( $head_product_id, '_wpshop_product_metadata', true ); |
|
617 | - $product_discount_date_from = ( !empty($product_meta['special_from']) ) ? $product_meta['special_from'] : 0; |
|
618 | - $product_discount_date_to = ( !empty($product_meta['special_to']) ) ? $product_meta['special_to'] : 0; |
|
614 | + if (!empty($product_id)) { |
|
615 | + if (!empty($head_product_id)) { |
|
616 | + $product_meta = get_post_meta($head_product_id, '_wpshop_product_metadata', true); |
|
617 | + $product_discount_date_from = (!empty($product_meta['special_from'])) ? $product_meta['special_from'] : 0; |
|
618 | + $product_discount_date_to = (!empty($product_meta['special_to'])) ? $product_meta['special_to'] : 0; |
|
619 | 619 | |
620 | - $product_meta = get_post_meta( $product_id, '_wpshop_product_metadata', true ); |
|
620 | + $product_meta = get_post_meta($product_id, '_wpshop_product_metadata', true); |
|
621 | 621 | } |
622 | 622 | else { |
623 | - $product_meta = get_post_meta( $product_id, '_wpshop_product_metadata', true ); |
|
624 | - $product_discount_date_from = ( !empty($product_meta['special_from']) ) ? $product_meta['special_from'] : 0; |
|
625 | - $product_discount_date_to = ( !empty($product_meta['special_to']) ) ? $product_meta['special_to'] : 0; |
|
623 | + $product_meta = get_post_meta($product_id, '_wpshop_product_metadata', true); |
|
624 | + $product_discount_date_from = (!empty($product_meta['special_from'])) ? $product_meta['special_from'] : 0; |
|
625 | + $product_discount_date_to = (!empty($product_meta['special_to'])) ? $product_meta['special_to'] : 0; |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | $current_date = date('Y-m-d'); |
629 | 629 | |
630 | - if ( !empty( $product_meta ) ) { |
|
630 | + if (!empty($product_meta)) { |
|
631 | 631 | |
632 | - if( ( empty($product_discount_date_from) && empty($product_discount_date_to) ) || ( in_array($product_discount_date_from, $time_def) && in_array( $product_discount_date_to, $time_def) ) || (strtotime($product_discount_date_from) < strtotime($current_date) && strtotime($current_date) < strtotime($product_discount_date_to) ) ) { |
|
632 | + if ((empty($product_discount_date_from) && empty($product_discount_date_to)) || (in_array($product_discount_date_from, $time_def) && in_array($product_discount_date_to, $time_def)) || (strtotime($product_discount_date_from) < strtotime($current_date) && strtotime($current_date) < strtotime($product_discount_date_to))) { |
|
633 | 633 | /** Special Price **/ |
634 | - if ( !empty($product_meta['special_price']) && $product_meta['special_price'] > 0 ) { |
|
634 | + if (!empty($product_meta['special_price']) && $product_meta['special_price'] > 0) { |
|
635 | 635 | $discount_config['type'] = 'special_price'; |
636 | 636 | $discount_config['value'] = $product_meta['special_price']; |
637 | 637 | } |
638 | - elseif( !empty($product_meta['discount_amount']) && $product_meta['discount_amount'] > 0) { |
|
638 | + elseif (!empty($product_meta['discount_amount']) && $product_meta['discount_amount'] > 0) { |
|
639 | 639 | $discount_config['type'] = 'discount_amount'; |
640 | 640 | $discount_config['value'] = $product_meta['discount_amount']; |
641 | 641 | } |
642 | - elseif( !empty($product_meta['discount_rate']) && $product_meta['discount_rate'] > 0 ) { |
|
642 | + elseif (!empty($product_meta['discount_rate']) && $product_meta['discount_rate'] > 0) { |
|
643 | 643 | $discount_config['type'] = 'discount_rate'; |
644 | 644 | $discount_config['value'] = $product_meta['discount_rate']; |
645 | 645 | } |
@@ -652,13 +652,13 @@ discard block |
||
652 | 652 | /** |
653 | 653 | * Check the parent product price |
654 | 654 | */ |
655 | - function check_parent_product_price( $product ) { |
|
655 | + function check_parent_product_price($product) { |
|
656 | 656 | $price_infos = array(); |
657 | - if( !empty($product) ) { |
|
657 | + if (!empty($product)) { |
|
658 | 658 | $price_infos['ati'] = $product['product_price']; |
659 | 659 | $price_infos['et'] = $product['price_ht']; |
660 | 660 | $price_infos['tva'] = $product['tva']; |
661 | - $price_infos['fork_price'] = array( 'have_fork_price' => false, 'min_product_price' => '', 'max_product_price' => ''); |
|
661 | + $price_infos['fork_price'] = array('have_fork_price' => false, 'min_product_price' => '', 'max_product_price' => ''); |
|
662 | 662 | } |
663 | 663 | return $price_infos; |
664 | 664 | } |
@@ -668,81 +668,81 @@ discard block |
||
668 | 668 | global $wpdb; |
669 | 669 | $status = false; $result = ''; |
670 | 670 | @ini_set('max_execution_time', '500'); |
671 | - $price_piloting_option = get_option( 'wpshop_shop_price_piloting' ); |
|
672 | - $output_type_option = get_option( 'wpshop_display_option' ); |
|
671 | + $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
|
672 | + $output_type_option = get_option('wpshop_display_option'); |
|
673 | 673 | $output_type = $output_type_option['wpshop_display_list_type']; |
674 | 674 | |
675 | 675 | /** Get tx_tva attribute_id **/ |
676 | - $query = $wpdb->prepare( 'SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE code = %s', 'tx_tva' ); |
|
677 | - $tx_tva_attribute_id = $wpdb->get_var( $query ); |
|
676 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code = %s', 'tx_tva'); |
|
677 | + $tx_tva_attribute_id = $wpdb->get_var($query); |
|
678 | 678 | |
679 | 679 | /** Product entity Definition **/ |
680 | - $product_entity = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
680 | + $product_entity = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
681 | 681 | |
682 | 682 | /** Attributes def **/ |
683 | - $tva_attribute_def = wpshop_attributes::getElement('tva',"'valid'", 'code'); |
|
684 | - $product_price_attribute_def = wpshop_attributes::getElement('product_price',"'valid'", 'code'); |
|
685 | - $price_ht_attribute_def = wpshop_attributes::getElement('price_ht',"'valid'", 'code'); |
|
683 | + $tva_attribute_def = wpshop_attributes::getElement('tva', "'valid'", 'code'); |
|
684 | + $product_price_attribute_def = wpshop_attributes::getElement('product_price', "'valid'", 'code'); |
|
685 | + $price_ht_attribute_def = wpshop_attributes::getElement('price_ht', "'valid'", 'code'); |
|
686 | 686 | |
687 | - if ( !empty($tx_tva_attribute_id) ) { |
|
688 | - $query = $wpdb->prepare( 'SELECT id, value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE attribute_id = %d', $tx_tva_attribute_id, 'valid' ); |
|
689 | - $tx_tva = $wpdb->get_results( $query ); |
|
687 | + if (!empty($tx_tva_attribute_id)) { |
|
688 | + $query = $wpdb->prepare('SELECT id, value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE attribute_id = %d', $tx_tva_attribute_id, 'valid'); |
|
689 | + $tx_tva = $wpdb->get_results($query); |
|
690 | 690 | |
691 | 691 | $tva_array = array(); |
692 | 692 | /** Transform array to easy teatment **/ |
693 | - foreach( $tx_tva as $t ) { |
|
694 | - $tva_array[ $t->id ] = $t->value; |
|
693 | + foreach ($tx_tva as $t) { |
|
694 | + $tva_array[$t->id] = $t->value; |
|
695 | 695 | } |
696 | 696 | |
697 | - if ( !empty($tx_tva) ) { |
|
697 | + if (!empty($tx_tva)) { |
|
698 | 698 | |
699 | 699 | $count_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
700 | 700 | |
701 | - for( $i = 0; $i <= $count_products->publish; $i+= 100 ) { |
|
702 | - $query = $wpdb->prepare( 'SELECT * FROM '. $wpdb->posts .' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT '.$i.', 150', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish' ); |
|
703 | - $products = $wpdb->get_results( $query ); |
|
701 | + for ($i = 0; $i <= $count_products->publish; $i += 100) { |
|
702 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT ' . $i . ', 150', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish'); |
|
703 | + $products = $wpdb->get_results($query); |
|
704 | 704 | |
705 | - if( !empty($products) ){ |
|
706 | - foreach( $products as $product ) { |
|
707 | - $product_data = get_post_meta( $product->ID, '_wpshop_product_metadata', true); |
|
708 | - if ( !empty($product_data) ) { |
|
709 | - if ( !empty($product_data['tx_tva']) && array_key_exists( $product_data['tx_tva'], $tva_array) ) { |
|
705 | + if (!empty($products)) { |
|
706 | + foreach ($products as $product) { |
|
707 | + $product_data = get_post_meta($product->ID, '_wpshop_product_metadata', true); |
|
708 | + if (!empty($product_data)) { |
|
709 | + if (!empty($product_data['tx_tva']) && array_key_exists($product_data['tx_tva'], $tva_array)) { |
|
710 | 710 | |
711 | - if ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) { |
|
711 | + if (!empty($price_piloting_option) && $price_piloting_option == 'HT') { |
|
712 | 712 | /** Update post meta **/ |
713 | - $product_data['price_ht'] = (float)str_replace( ',', '.', $product_data['price_ht'] ); |
|
714 | - $product_data['product_price'] = $product_data['price_ht'] * ( 1 + ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
|
715 | - $product_data['tva'] = $product_data['price_ht'] * ( ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
|
716 | - update_post_meta( $product->ID, '_wpshop_product_metadata', $product_data); |
|
713 | + $product_data['price_ht'] = (float)str_replace(',', '.', $product_data['price_ht']); |
|
714 | + $product_data['product_price'] = $product_data['price_ht'] * (1 + ($tva_array[$product_data['tx_tva']] / 100)); |
|
715 | + $product_data['tva'] = $product_data['price_ht'] * (($tva_array[$product_data['tx_tva']] / 100)); |
|
716 | + update_post_meta($product->ID, '_wpshop_product_metadata', $product_data); |
|
717 | 717 | |
718 | 718 | |
719 | 719 | /** Update attributes values **/ |
720 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => (float)$product_data['price_ht'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product->ID) ); |
|
721 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => (float)$product_data['product_price'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product->ID) ); |
|
722 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => (float)$product_data['tva'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product->ID) ); |
|
720 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => (float)$product_data['price_ht']), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product->ID)); |
|
721 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => (float)$product_data['product_price']), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product->ID)); |
|
722 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => (float)$product_data['tva']), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product->ID)); |
|
723 | 723 | |
724 | 724 | /** Update Display price meta **/ |
725 | 725 | $p = wpshop_products::get_product_data($product->ID); |
726 | - $price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type) ); |
|
727 | - update_post_meta( $product->ID, '_wps_price_infos', $price ); |
|
726 | + $price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type)); |
|
727 | + update_post_meta($product->ID, '_wps_price_infos', $price); |
|
728 | 728 | } |
729 | 729 | else { |
730 | 730 | /** Update post meta **/ |
731 | - $product_data['product_price'] = (float)str_replace( ',', '.', $product_data['product_price'] ); |
|
732 | - $product_data['price_ht'] = $product_data['product_price'] / ( 1 + ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
|
733 | - $product_data['tva'] = $product_data['price_ht'] * ( ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
|
734 | - update_post_meta( $product->ID, '_wpshop_product_metadata', $product_data); |
|
731 | + $product_data['product_price'] = (float)str_replace(',', '.', $product_data['product_price']); |
|
732 | + $product_data['price_ht'] = $product_data['product_price'] / (1 + ($tva_array[$product_data['tx_tva']] / 100)); |
|
733 | + $product_data['tva'] = $product_data['price_ht'] * (($tva_array[$product_data['tx_tva']] / 100)); |
|
734 | + update_post_meta($product->ID, '_wpshop_product_metadata', $product_data); |
|
735 | 735 | |
736 | 736 | /** Update attributes values **/ |
737 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['price_ht'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product->ID) ); |
|
738 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['tva'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product->ID) ); |
|
739 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['product_price'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product->ID) ); |
|
737 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['price_ht']), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product->ID)); |
|
738 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['tva']), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product->ID)); |
|
739 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['product_price']), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product->ID)); |
|
740 | 740 | |
741 | 741 | |
742 | 742 | /** Update Display price meta **/ |
743 | 743 | $p = wpshop_products::get_product_data($product->ID); |
744 | - $price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type) ); |
|
745 | - update_post_meta( $product->ID, '_wps_price_infos', $price ); |
|
744 | + $price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type)); |
|
745 | + update_post_meta($product->ID, '_wps_price_infos', $price); |
|
746 | 746 | } |
747 | 747 | } |
748 | 748 | } |
@@ -750,41 +750,41 @@ discard block |
||
750 | 750 | |
751 | 751 | } |
752 | 752 | } |
753 | - unset( $products ); |
|
753 | + unset($products); |
|
754 | 754 | |
755 | 755 | $count_variations = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION); |
756 | - for( $i = 0; $i <= $count_variations->publish; $i+= 100 ) { |
|
757 | - $query = $wpdb->prepare( 'SELECT * FROM '. $wpdb->posts .' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT '.$i.', 100', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'publish' ); |
|
758 | - $product_variations = $wpdb->get_results( $query ); |
|
756 | + for ($i = 0; $i <= $count_variations->publish; $i += 100) { |
|
757 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT ' . $i . ', 100', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION, 'publish'); |
|
758 | + $product_variations = $wpdb->get_results($query); |
|
759 | 759 | /** Update Products Variations **/ |
760 | - if ( !empty($product_variations) ) { |
|
761 | - foreach( $product_variations as $product_variation ) { |
|
762 | - $product_data = get_post_meta( $product_variation->ID, '_wpshop_product_metadata', true); |
|
763 | - if ( !empty($product_data) ) { |
|
764 | - if ( !empty($product_data['tx_tva']) && array_key_exists( $product_data['tx_tva'], $tva_array) ) { |
|
765 | - if ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) { |
|
760 | + if (!empty($product_variations)) { |
|
761 | + foreach ($product_variations as $product_variation) { |
|
762 | + $product_data = get_post_meta($product_variation->ID, '_wpshop_product_metadata', true); |
|
763 | + if (!empty($product_data)) { |
|
764 | + if (!empty($product_data['tx_tva']) && array_key_exists($product_data['tx_tva'], $tva_array)) { |
|
765 | + if (!empty($price_piloting_option) && $price_piloting_option == 'HT') { |
|
766 | 766 | /** Update post meta **/ |
767 | - $product_data['price_ht'] = (float)str_replace( ',', '.', $product_data['price_ht'] ); |
|
768 | - $product_data['product_price'] = $product_data['price_ht'] * ( 1 + ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
|
769 | - $product_data['tva'] = $product_data['price_ht'] * ( ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
|
770 | - update_post_meta( $product_variation->ID, '_wpshop_product_metadata', $product_data); |
|
767 | + $product_data['price_ht'] = (float)str_replace(',', '.', $product_data['price_ht']); |
|
768 | + $product_data['product_price'] = $product_data['price_ht'] * (1 + ($tva_array[$product_data['tx_tva']] / 100)); |
|
769 | + $product_data['tva'] = $product_data['price_ht'] * (($tva_array[$product_data['tx_tva']] / 100)); |
|
770 | + update_post_meta($product_variation->ID, '_wpshop_product_metadata', $product_data); |
|
771 | 771 | |
772 | 772 | /** Update attributes values **/ |
773 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['price_ht'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
|
774 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['product_price'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
|
775 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['tva'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
|
773 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['price_ht']), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product_variation->ID)); |
|
774 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['product_price']), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product_variation->ID)); |
|
775 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['tva']), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product_variation->ID)); |
|
776 | 776 | } |
777 | 777 | else { |
778 | 778 | /** Update post meta **/ |
779 | - $product_data['product_price'] = (float)str_replace( ',', '.', $product_data['product_price'] ); |
|
780 | - $product_data['price_ht'] = $product_data['product_price'] / ( 1 + ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
|
781 | - $product_data['tva'] = $product_data['price_ht'] * ( ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
|
782 | - update_post_meta( $product_variation->ID, '_wpshop_product_metadata', $product_data); |
|
779 | + $product_data['product_price'] = (float)str_replace(',', '.', $product_data['product_price']); |
|
780 | + $product_data['price_ht'] = $product_data['product_price'] / (1 + ($tva_array[$product_data['tx_tva']] / 100)); |
|
781 | + $product_data['tva'] = $product_data['price_ht'] * (($tva_array[$product_data['tx_tva']] / 100)); |
|
782 | + update_post_meta($product_variation->ID, '_wpshop_product_metadata', $product_data); |
|
783 | 783 | |
784 | 784 | /** Update attributes values **/ |
785 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['price_ht'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
|
786 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['tva'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
|
787 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['product_price'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
|
785 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['price_ht']), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product_variation->ID)); |
|
786 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['tva']), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product_variation->ID)); |
|
787 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['product_price']), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product_variation->ID)); |
|
788 | 788 | } |
789 | 789 | } |
790 | 790 | } |
@@ -801,15 +801,15 @@ discard block |
||
801 | 801 | } |
802 | 802 | } |
803 | 803 | else { |
804 | - $result = __( 'VAT rate attribute was not found', 'wpshop' ); |
|
804 | + $result = __('VAT rate attribute was not found', 'wpshop'); |
|
805 | 805 | } |
806 | - return array( $status, $result ); |
|
806 | + return array($status, $result); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | } |
810 | 810 | |
811 | 811 | } |
812 | 812 | /** Instanciate the module utilities if not */ |
813 | -if ( class_exists("wpshop_prices") ) { |
|
813 | +if (class_exists("wpshop_prices")) { |
|
814 | 814 | $wpshop_prices = new wpshop_prices(); |
815 | 815 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** |
4 | 6 | * WPSHOP Prices bootstrap file |
@@ -65,8 +67,7 @@ discard block |
||
65 | 67 | } |
66 | 68 | } |
67 | 69 | } |
68 | - } |
|
69 | - else { |
|
70 | + } else { |
|
70 | 71 | /** Desactivate Discount Attributes **/ |
71 | 72 | if ( !empty($discount_attributes) ) { |
72 | 73 | foreach ( $discount_attributes as $discount_attribute ) { |
@@ -113,14 +114,12 @@ discard block |
||
113 | 114 | $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] /100); |
114 | 115 | $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] /100) : $discount_config['value']; |
115 | 116 | $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
116 | - } |
|
117 | - elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
117 | + } elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
118 | 118 | $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht_before_discount'] - $discount_config['value'] ) : ( ( $product['price_ttc_before_discount'] - $discount_config['value'] ) / (1 + $product['tx_tva'] /100) ) ; |
119 | 119 | $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * (1 + $product['tx_tva'] /100) : $product['price_ttc_before_discount'] - $discount_config['value']; |
120 | 120 | $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
121 | 121 | |
122 | - } |
|
123 | - elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
122 | + } elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
124 | 123 | $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht_before_discount'] * ( 1 - $discount_config['value'] / 100) ) : ( ( $product['price_ttc_before_discount'] * ( 1 - ( $discount_config['value'] / 100 ) ) ) / (1 + $product['tx_tva'] /100) ) ; |
125 | 124 | $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * ( 1 + $product['tx_tva'] /100) : $product['price_ttc_before_discount'] * ( 1 - ( $discount_config['value'] / 100 ) ); |
126 | 125 | $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
@@ -136,16 +135,14 @@ discard block |
||
136 | 135 | $price_infos['discount']['discount_ati_price'] = ( !empty($product['price_ttc_before_discount']) ) ? number_format((float)$product['product_price'], 2, '.', '') : 0; |
137 | 136 | $price_infos['discount']['discount_et_price'] = ( !empty($product['price_ht_before_discount']) ) ? number_format( (float)$product['price_ht'], 2, '.', '' ) : 0; |
138 | 137 | $price_infos['discount']['discount_tva'] = ( !empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount']) ) ? number_format( ($price_infos['discount']['discount_ati_price'] - $price_infos['discount']['discount_et_price']), 2, '.', '') : 0; |
139 | - } |
|
140 | - else { |
|
138 | + } else { |
|
141 | 139 | $price_infos['ati'] = ( !empty($product['product_price'] )) ? number_format((float)$product['product_price'], 5, '.', '') : 0; |
142 | 140 | $price_infos['et'] = ( !empty($product['price_ht'] ) ) ? number_format((float)$product['price_ht'], 5, '.', '') : 0; |
143 | 141 | $price_infos['tva'] = ( !empty($product['tva'] ) ) ? $product['tva'] : 0; |
144 | 142 | } |
145 | 143 | |
146 | 144 | |
147 | - } |
|
148 | - else { |
|
145 | + } else { |
|
149 | 146 | if ( !empty( $product['price_ttc_before_discount']) && !empty( $product['price_ht_before_discount'] ) ) { |
150 | 147 | $price_infos['discount']['discount_exist'] = ( !empty($product['price_ttc_before_discount']) && !empty($product['price_ht_before_discount'] ) ) ? true : false; |
151 | 148 | $price_infos['discount']['discount_ati_price'] = ( !empty($product['product_price']) ) ? number_format((float)$product['product_price'], 2, '.', '') : 0; |
@@ -155,8 +152,7 @@ discard block |
||
155 | 152 | $price_infos['ati'] = ( !empty($product['price_ttc_before_discount'] )) ? number_format((float)$product['price_ttc_before_discount'], 5, '.', '') : 0; |
156 | 153 | $price_infos['et'] = ( !empty($product['price_ht_before_discount']) ) ? number_format((float)$product['price_ht_before_discount'], 5, '.', '') : 0; |
157 | 154 | $price_infos['tva'] = $price_infos['ati'] - $price_infos['et']; |
158 | - } |
|
159 | - else { |
|
155 | + } else { |
|
160 | 156 | $price_infos['ati'] = ( !empty($product['product_price'] )) ? number_format((float)$product['product_price'], 5, '.', '') : 0; |
161 | 157 | $price_infos['et'] = ( !empty($product['price_ht'] ) ) ? number_format((float)$product['price_ht'], 5, '.', '') : 0; |
162 | 158 | $price_infos['tva'] = ( !empty($product['tva'] ) ) ? $product['tva'] : 0; |
@@ -199,8 +195,7 @@ discard block |
||
199 | 195 | if ( !empty($product_with_variation[$product['product_id']]['variation_priority']) ) { |
200 | 196 | $product = wpshop_products::get_variation_price_behaviour( $product, $product_with_variation[$product['product_id']]['variations'], $product['product_id'], array('type' => $product_with_variation[$product['product_id']]['variation_priority'], 'text_from' => !empty($product_with_variation['text_from']) ? 'on' : '' ) ); |
201 | 197 | } |
202 | - } |
|
203 | - else { |
|
198 | + } else { |
|
204 | 199 | /** It's Simple product Check Discounts for products **/ |
205 | 200 | $discount_config = self::check_discount_for_product( $product['product_id'] ); |
206 | 201 | if ( !empty($discount_config) ) { |
@@ -211,8 +206,7 @@ discard block |
||
211 | 206 | $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] /100); |
212 | 207 | $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] /100) : $discount_config['value']; |
213 | 208 | $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
214 | - } |
|
215 | - elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
209 | + } elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
216 | 210 | $product['price_ttc_before_discount'] = $product['product_price']; |
217 | 211 | $product['price_ht_before_discount'] = $product['price_ht']; |
218 | 212 | |
@@ -220,8 +214,7 @@ discard block |
||
220 | 214 | $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * (1 + $product['tx_tva'] /100) : $product['price_ttc_before_discount'] - $discount_config['value']; |
221 | 215 | $product['tva'] = $product['price_ht'] * ( $product['tx_tva'] / 100); |
222 | 216 | |
223 | - } |
|
224 | - elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
217 | + } elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
225 | 218 | $product['price_ttc_before_discount'] = $product['product_price']; |
226 | 219 | $product['price_ht_before_discount'] = $product['price_ht']; |
227 | 220 | |
@@ -244,13 +237,16 @@ discard block |
||
244 | 237 | if ( !empty($price_infos) ) { |
245 | 238 | if ( $return_type == 'check_only' ) { |
246 | 239 | /** Check if the product price has been set */ |
247 | - if( isset($price_infos['ati']) && $price_infos['ati'] === '') return __('This product cannot be purchased - the price is not yet announced', 'wpshop'); |
|
240 | + if( isset($price_infos['ati']) && $price_infos['ati'] === '') { |
|
241 | + return __('This product cannot be purchased - the price is not yet announced', 'wpshop'); |
|
242 | + } |
|
248 | 243 | /** Check if the product price is coherent (not less than 0) */ |
249 | - if( isset($price_infos['ati']) && $price_infos['ati'] < 0) return __('This product cannot be purchased - its price is negative', 'wpshop'); |
|
244 | + if( isset($price_infos['ati']) && $price_infos['ati'] < 0) { |
|
245 | + return __('This product cannot be purchased - its price is negative', 'wpshop'); |
|
246 | + } |
|
250 | 247 | |
251 | 248 | return true; |
252 | - } |
|
253 | - elseif( $return_type == 'just_price_infos' ) { |
|
249 | + } elseif( $return_type == 'just_price_infos' ) { |
|
254 | 250 | $tpl_component = array(); |
255 | 251 | |
256 | 252 | $price = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $price_infos['et'] : $price_infos['ati']; |
@@ -269,8 +265,7 @@ discard block |
||
269 | 265 | $tpl_component['CROSSED_OUT_PRICE'] = $crossed_out_price; |
270 | 266 | if(!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') { |
271 | 267 | $exploded_discount_price = explode('.', number_format($price_infos['discount']['discount_et_price'],2, '.', '')); |
272 | - } |
|
273 | - else { |
|
268 | + } else { |
|
274 | 269 | $exploded_discount_price = explode('.', number_format($price_infos['discount']['discount_ati_price'],2, '.', '')); |
275 | 270 | } |
276 | 271 | |
@@ -278,16 +273,14 @@ discard block |
||
278 | 273 | $tpl_component['PRODUCT_PRICE'] = '<span class="wps-absolute-price">'.$discount_price.'</span> '.$productCurrency; |
279 | 274 | |
280 | 275 | $tpl_component['MESSAGE_SAVE_MONEY'] = $wps_marketing_tools->display_message_you_save_money( $price_infos ); |
281 | - } |
|
282 | - else { |
|
276 | + } else { |
|
283 | 277 | $tpl_component['PRODUCT_PRICE'] = $price.' '.$productCurrency; |
284 | 278 | } |
285 | 279 | |
286 | 280 | $post_type = get_post_type( $product['product_id'] ); |
287 | 281 | if ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
288 | 282 | $price_display_attribute = get_post_meta( $product['product_id'], '_wpshop_variation_defining', true ); |
289 | - } |
|
290 | - elseif( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
283 | + } elseif( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
291 | 284 | $parent_def = wpshop_products::get_parent_variation ( $product['product_id'] ); |
292 | 285 | if( !empty($parent_def) && !empty($parent_def['parent_post']) ) { |
293 | 286 | $parent_post = $parent_def['parent_post']; |
@@ -298,8 +291,7 @@ discard block |
||
298 | 291 | $tpl_component['PRICE_FROM'] = ( ( !empty($price_display_attribute) && empty($price_display_attribute['options'] ) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) ) || ( ( !empty($price_display_attribute) && (!empty($price_display_attribute['options'] ) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']) ) ) ) ) ) ? 'on' : ''; |
299 | 292 | |
300 | 293 | return $tpl_component; |
301 | - } |
|
302 | - else if ( $return_type == 'price_display' ) { |
|
294 | + } else if ( $return_type == 'price_display' ) { |
|
303 | 295 | $tpl_component = array(); |
304 | 296 | $price = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $price_infos['et'] : $price_infos['ati']; |
305 | 297 | |
@@ -323,8 +315,7 @@ discard block |
||
323 | 315 | $parent_post = $parent_def['parent_post']; |
324 | 316 | $price_display_attribute = get_post_meta( $parent_post->ID, '_wpshop_variation_defining', true ); |
325 | 317 | } |
326 | - } |
|
327 | - else { |
|
318 | + } else { |
|
328 | 319 | $price_display_attribute = get_post_meta( $product['product_id'], '_wpshop_variation_defining', true ); |
329 | 320 | } |
330 | 321 | $text_from = ( ( !empty($price_display_attribute) && empty($price_display_attribute['options'] ) && !empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) ) || ( ( !empty($price_display_attribute) && (!empty($price_display_attribute['options'] ) && (!empty($price_display_attribute['options']['price_display']) && !empty($price_display_attribute['options']['price_display']['text_from']) ) ) ) ) && !empty($product['text_from']) ) ? true : false; |
@@ -342,14 +333,12 @@ discard block |
||
342 | 333 | $tpl_component['PRODUCT_PRICE'] = (!empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? '<span class="wps-absolute-price">'. $price_infos['discount']['discount_et_price'].'</span> '.$productCurrency : '<span class="wps-absolute-price">'.$price_infos['discount']['discount_ati_price'].'</span> '.$productCurrency; |
343 | 334 | $tpl_component['MESSAGE_SAVE_MONEY'] = $wps_marketing_tools->display_message_you_save_money( $price_data ); |
344 | 335 | |
345 | - } |
|
346 | - else { |
|
336 | + } else { |
|
347 | 337 | if( get_post_type($product['product_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
348 | 338 | $parent_def = wpshop_products::get_parent_variation( $product['product_id'] ); |
349 | 339 | $pid = $parent_def['parent_post']; |
350 | 340 | $pid = $pid->ID; |
351 | - } |
|
352 | - else { |
|
341 | + } else { |
|
353 | 342 | $pid = $product['product_id']; |
354 | 343 | } |
355 | 344 | |
@@ -362,8 +351,7 @@ discard block |
||
362 | 351 | $parent_post = $parent_def['parent_post']; |
363 | 352 | $price_display_attribute = get_post_meta( $parent_post->ID, '_wpshop_variation_defining', true ); |
364 | 353 | } |
365 | - } |
|
366 | - else { |
|
354 | + } else { |
|
367 | 355 | $price_display_attribute = get_post_meta( $pid, '_wpshop_variation_defining', true ); |
368 | 356 | } |
369 | 357 | |
@@ -381,8 +369,7 @@ discard block |
||
381 | 369 | |
382 | 370 | if ( $output_type == 'complete_sheet' ) { |
383 | 371 | $price_tpl = wpshop_display::display_template_element('product_price_template_complete_sheet', $tpl_component ); |
384 | - } |
|
385 | - elseif ( $output_type == 'mini_output' || in_array('mini_output', $output_type ) ) { |
|
372 | + } elseif ( $output_type == 'mini_output' || in_array('mini_output', $output_type ) ) { |
|
386 | 373 | $price_tpl = wpshop_display::display_template_element('product_price_template_mini_output', $tpl_component ); |
387 | 374 | } |
388 | 375 | return $price_tpl; |
@@ -527,8 +514,7 @@ discard block |
||
527 | 514 | $tx_tva = $wpdb->get_var( $query ); |
528 | 515 | $variation_price = $variation['variation_dif']['price_ht'] / ( 1 + ($variation['variation_dif']['discount_rate'] / 100 ) ); |
529 | 516 | $variation_price = ( !empty($price_piloting_option) && $price_piloting_option == 'HT' ) ? $variation_price : $variation_price * 1 + ($tx_tva / 100); |
530 | - } |
|
531 | - elseif( empty($variation['variation_dif']['special_price']) && !empty($variation['variation_dif']['discount_amount']) && $variation['variation_dif']['discount_amount'] > 0 ) { |
|
517 | + } elseif( empty($variation['variation_dif']['special_price']) && !empty($variation['variation_dif']['discount_amount']) && $variation['variation_dif']['discount_amount'] > 0 ) { |
|
532 | 518 | $query = $wpdb->prepare( 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS. ' WHERE id = %d', $variation['variation_dif']['tx_tva'] ); |
533 | 519 | $tx_tva = $wpdb->get_var( $query ); |
534 | 520 | $variation_price = $variation['variation_dif']['price_ht'] - $variation['variation_dif']['discount_amount']; |
@@ -548,8 +534,7 @@ discard block |
||
548 | 534 | } |
549 | 535 | } |
550 | 536 | } |
551 | - } |
|
552 | - else { |
|
537 | + } else { |
|
553 | 538 | if ( !empty($product_id) ) { |
554 | 539 | if( !empty($variations) ) { |
555 | 540 | |
@@ -589,14 +574,12 @@ discard block |
||
589 | 574 | $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] : $discount_config['value'] / (1 + $product['tx_tva'] /100); |
590 | 575 | $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT') ? $discount_config['value'] * (1 + $product['tx_tva'] /100) : $discount_config['value']; |
591 | 576 | $product['tva'] = $product['product_price'] - $product['price_ht']; |
592 | - } |
|
593 | - elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
577 | + } elseif( !empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_amount' ) { |
|
594 | 578 | $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht'] - $discount_config['value'] ) : ( ( $product['product_price'] - $discount_config['value'] ) / (1 + $product['tx_tva'] /100) ) ; |
595 | 579 | $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * (1 + $product['tx_tva'] /100) : $product['product_price'] - $discount_config['value']; |
596 | 580 | $product['tva'] = $product['product_price'] - $product['price_ht']; |
597 | 581 | |
598 | - } |
|
599 | - elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
582 | + } elseif(!empty($discount_config['type']) && !empty($discount_config['value']) && $discount_config['type'] == 'discount_rate') { |
|
600 | 583 | $product['price_ht'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? ( $product['price_ht'] * ( 1 - $discount_config['value'] / 100) ) : ( ( $product['product_price'] * ( 1 - ( $discount_config['value'] / 100 ) ) ) / (1 + $product['tx_tva'] /100) ) ; |
601 | 584 | $product['product_price'] = ( !empty($wpshop_price_piloting_option) && $wpshop_price_piloting_option == 'HT' ) ? $product['price_ht'] * ( 1 + $product['tx_tva'] /100) : $product['product_price'] * ( 1 - ( $discount_config['value'] / 100 ) ); |
602 | 585 | $product['tva'] = $product['product_price'] - $product['price_ht']; |
@@ -618,8 +601,7 @@ discard block |
||
618 | 601 | $product_discount_date_to = ( !empty($product_meta['special_to']) ) ? $product_meta['special_to'] : 0; |
619 | 602 | |
620 | 603 | $product_meta = get_post_meta( $product_id, '_wpshop_product_metadata', true ); |
621 | - } |
|
622 | - else { |
|
604 | + } else { |
|
623 | 605 | $product_meta = get_post_meta( $product_id, '_wpshop_product_metadata', true ); |
624 | 606 | $product_discount_date_from = ( !empty($product_meta['special_from']) ) ? $product_meta['special_from'] : 0; |
625 | 607 | $product_discount_date_to = ( !empty($product_meta['special_to']) ) ? $product_meta['special_to'] : 0; |
@@ -634,12 +616,10 @@ discard block |
||
634 | 616 | if ( !empty($product_meta['special_price']) && $product_meta['special_price'] > 0 ) { |
635 | 617 | $discount_config['type'] = 'special_price'; |
636 | 618 | $discount_config['value'] = $product_meta['special_price']; |
637 | - } |
|
638 | - elseif( !empty($product_meta['discount_amount']) && $product_meta['discount_amount'] > 0) { |
|
619 | + } elseif( !empty($product_meta['discount_amount']) && $product_meta['discount_amount'] > 0) { |
|
639 | 620 | $discount_config['type'] = 'discount_amount'; |
640 | 621 | $discount_config['value'] = $product_meta['discount_amount']; |
641 | - } |
|
642 | - elseif( !empty($product_meta['discount_rate']) && $product_meta['discount_rate'] > 0 ) { |
|
622 | + } elseif( !empty($product_meta['discount_rate']) && $product_meta['discount_rate'] > 0 ) { |
|
643 | 623 | $discount_config['type'] = 'discount_rate'; |
644 | 624 | $discount_config['value'] = $product_meta['discount_rate']; |
645 | 625 | } |
@@ -725,8 +705,7 @@ discard block |
||
725 | 705 | $p = wpshop_products::get_product_data($product->ID); |
726 | 706 | $price = wpshop_prices::get_product_price($p, 'just_price_infos', array('mini_output', $output_type) ); |
727 | 707 | update_post_meta( $product->ID, '_wps_price_infos', $price ); |
728 | - } |
|
729 | - else { |
|
708 | + } else { |
|
730 | 709 | /** Update post meta **/ |
731 | 710 | $product_data['product_price'] = (float)str_replace( ',', '.', $product_data['product_price'] ); |
732 | 711 | $product_data['price_ht'] = $product_data['product_price'] / ( 1 + ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
@@ -773,8 +752,7 @@ discard block |
||
773 | 752 | $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['price_ht'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $price_ht_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
774 | 753 | $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['product_price'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $product_price_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
775 | 754 | $wpdb->update( WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL, array('value' => $product_data['tva'] ), array('entity_type_id' => $product_entity, 'attribute_id' => $tva_attribute_def->id, 'entity_id' => $product_variation->ID) ); |
776 | - } |
|
777 | - else { |
|
755 | + } else { |
|
778 | 756 | /** Update post meta **/ |
779 | 757 | $product_data['product_price'] = (float)str_replace( ',', '.', $product_data['product_price'] ); |
780 | 758 | $product_data['price_ht'] = $product_data['product_price'] / ( 1 + ($tva_array[ $product_data['tx_tva'] ] / 100) ); |
@@ -795,12 +773,10 @@ discard block |
||
795 | 773 | |
796 | 774 | $result = __('Prices updated', 'wpshop'); |
797 | 775 | $status = true; |
798 | - } |
|
799 | - else { |
|
776 | + } else { |
|
800 | 777 | $result = __('No VAT rates was found', 'wpshop'); |
801 | 778 | } |
802 | - } |
|
803 | - else { |
|
779 | + } else { |
|
804 | 780 | $result = __( 'VAT rate attribute was not found', 'wpshop' ); |
805 | 781 | } |
806 | 782 | return array( $status, $result ); |
@@ -110,11 +110,17 @@ discard block |
||
110 | 110 | echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL; |
111 | 111 | } |
112 | 112 | |
113 | + /** |
|
114 | + * @param string $name |
|
115 | + */ |
|
113 | 116 | function add_filter( $name, $fn, $nbr = "") |
114 | 117 | { |
115 | 118 | echo "[+] Adding filter -> " . $name . " X" . $nbr . PHP_EOL; |
116 | 119 | } |
117 | 120 | |
121 | + /** |
|
122 | + * @param string $name |
|
123 | + */ |
|
118 | 124 | function add_shortcode( $name ) |
119 | 125 | { |
120 | 126 | echo "[+] Adding shortcode -> " . $name . PHP_EOL; |
@@ -150,6 +156,9 @@ discard block |
||
150 | 156 | echo "[+] Loading text domain" . PHP_EOL; |
151 | 157 | } |
152 | 158 | |
159 | + /** |
|
160 | + * @param string $path |
|
161 | + */ |
|
153 | 162 | function plugin_dir_path($path) |
154 | 163 | { |
155 | 164 | echo "[+] Plugin path -> " . $path . PHP_EOL; |
@@ -249,6 +258,9 @@ discard block |
||
249 | 258 | return ""; |
250 | 259 | } |
251 | 260 | |
261 | + /** |
|
262 | + * @param string $str |
|
263 | + */ |
|
252 | 264 | function current_time( $str ) |
253 | 265 | { |
254 | 266 | $time = " 2005-08-05 10:41:13"; |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | |
159 | 159 | function trailingslashit( $string ) |
160 | 160 | { |
161 | - return untrailingslashit( $string ) . '/'; |
|
161 | + return untrailingslashit( $string ) . '/'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | function untrailingslashit( $string ) |
165 | 165 | { |
166 | - return rtrim( $string, '/\\' ); |
|
166 | + return rtrim( $string, '/\\' ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | function site_url() |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | public $term_relationships = "term_relationship"; |
289 | 289 | public $term_taxonomy = "term_taxonomy"; |
290 | 290 | |
291 | - } |
|
291 | + } |
|
292 | 292 | |
293 | 293 | class WP_Widget |
294 | 294 | { |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | define('ABSPATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR); |
3 | - define('WP_PLUGIN_DIR', dirname(dirname(dirname(__FILE__))) ); |
|
3 | + define('WP_PLUGIN_DIR', dirname(dirname(dirname(__FILE__)))); |
|
4 | 4 | define('WP_LANG_DIR', 'FR'); |
5 | 5 | define('WP_CONTENT_DIR', 'wp-content'); |
6 | 6 | |
7 | - function __( $str ) |
|
7 | + function __($str) |
|
8 | 8 | { |
9 | 9 | $translate = "Result Testing text"; |
10 | 10 | echo "[+] Requesting __ -> " . $str . PHP_EOL; |
11 | 11 | return $translate; |
12 | 12 | } |
13 | 13 | |
14 | - function add_action( $init, $object ) |
|
14 | + function add_action($init, $object) |
|
15 | 15 | { |
16 | 16 | $length = 0; |
17 | 17 | $hooked = ""; |
18 | 18 | $oType = gettype($object); |
19 | - if($oType == "object" || $oType == "array") |
|
19 | + if ($oType == "object" || $oType == "array") |
|
20 | 20 | { |
21 | 21 | $hooked = "["; |
22 | - foreach($object as $hook) |
|
22 | + foreach ($object as $hook) |
|
23 | 23 | { |
24 | 24 | $length++; |
25 | 25 | $type = gettype($hook); |
26 | 26 | |
27 | - switch($type) |
|
27 | + switch ($type) |
|
28 | 28 | { |
29 | 29 | case "integer": |
30 | 30 | case "boolean": |
@@ -37,27 +37,27 @@ discard block |
||
37 | 37 | break; |
38 | 38 | } |
39 | 39 | } |
40 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
40 | + if ($length > 0) $hooked = rtrim($hooked, ","); |
|
41 | 41 | $hooked .= "]"; |
42 | 42 | } |
43 | 43 | else $hooked .= $object; |
44 | 44 | echo "[+] Adding action -> " . $init . " in " . $hooked . PHP_EOL; |
45 | 45 | } |
46 | 46 | |
47 | - function register_activation_hook( $file , $object ) |
|
47 | + function register_activation_hook($file, $object) |
|
48 | 48 | { |
49 | 49 | $length = 0; |
50 | 50 | $hooked = ""; |
51 | 51 | $oType = gettype($object); |
52 | - if($oType == "object" || $oType == "array") |
|
52 | + if ($oType == "object" || $oType == "array") |
|
53 | 53 | { |
54 | 54 | $hooked = "["; |
55 | - foreach($object as $hook) |
|
55 | + foreach ($object as $hook) |
|
56 | 56 | { |
57 | 57 | $length++; |
58 | 58 | $type = gettype($hook); |
59 | 59 | |
60 | - switch($type) |
|
60 | + switch ($type) |
|
61 | 61 | { |
62 | 62 | case "integer": |
63 | 63 | case "boolean": |
@@ -70,27 +70,27 @@ discard block |
||
70 | 70 | break; |
71 | 71 | } |
72 | 72 | } |
73 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
73 | + if ($length > 0) $hooked = rtrim($hooked, ","); |
|
74 | 74 | $hooked .= "]"; |
75 | 75 | } |
76 | 76 | else $hooked .= $object; |
77 | 77 | echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL; |
78 | 78 | } |
79 | 79 | |
80 | - function register_deactivation_hook( $file , $object ) |
|
80 | + function register_deactivation_hook($file, $object) |
|
81 | 81 | { |
82 | 82 | $length = 0; |
83 | 83 | $hooked = ""; |
84 | 84 | $oType = gettype($object); |
85 | - if($oType == "object" || $oType == "array") |
|
85 | + if ($oType == "object" || $oType == "array") |
|
86 | 86 | { |
87 | 87 | $hooked = "["; |
88 | - foreach($object as $hook) |
|
88 | + foreach ($object as $hook) |
|
89 | 89 | { |
90 | 90 | $length++; |
91 | 91 | $type = gettype($hook); |
92 | 92 | |
93 | - switch($type) |
|
93 | + switch ($type) |
|
94 | 94 | { |
95 | 95 | case "integer": |
96 | 96 | case "boolean": |
@@ -103,29 +103,29 @@ discard block |
||
103 | 103 | break; |
104 | 104 | } |
105 | 105 | } |
106 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
106 | + if ($length > 0) $hooked = rtrim($hooked, ","); |
|
107 | 107 | $hooked .= "]"; |
108 | 108 | } |
109 | 109 | else $hooked .= $object; |
110 | 110 | echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL; |
111 | 111 | } |
112 | 112 | |
113 | - function add_filter( $name, $fn, $nbr = "") |
|
113 | + function add_filter($name, $fn, $nbr = "") |
|
114 | 114 | { |
115 | 115 | echo "[+] Adding filter -> " . $name . " X" . $nbr . PHP_EOL; |
116 | 116 | } |
117 | 117 | |
118 | - function add_shortcode( $name ) |
|
118 | + function add_shortcode($name) |
|
119 | 119 | { |
120 | 120 | echo "[+] Adding shortcode -> " . $name . PHP_EOL; |
121 | 121 | } |
122 | 122 | |
123 | - function add_option( $name, $conf) |
|
123 | + function add_option($name, $conf) |
|
124 | 124 | { |
125 | 125 | echo "[+] Adding option -> " . $name . " conf:" . $conf . PHP_EOL; |
126 | 126 | } |
127 | 127 | |
128 | - function update_option( $name, $conf) |
|
128 | + function update_option($name, $conf) |
|
129 | 129 | { |
130 | 130 | echo "[+] Updating option -> " . $name . " conf:" . $conf . PHP_EOL; |
131 | 131 | } |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | function plugin_dir_path($path) |
154 | 154 | { |
155 | 155 | echo "[+] Plugin path -> " . $path . PHP_EOL; |
156 | - return trailingslashit( dirname( $path ) ); |
|
156 | + return trailingslashit(dirname($path)); |
|
157 | 157 | } |
158 | 158 | |
159 | - function trailingslashit( $string ) |
|
159 | + function trailingslashit($string) |
|
160 | 160 | { |
161 | - return untrailingslashit( $string ) . '/'; |
|
161 | + return untrailingslashit($string) . '/'; |
|
162 | 162 | } |
163 | 163 | |
164 | - function untrailingslashit( $string ) |
|
164 | + function untrailingslashit($string) |
|
165 | 165 | { |
166 | - return rtrim( $string, '/\\' ); |
|
166 | + return rtrim($string, '/\\'); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | function site_url() |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | return $dir; |
216 | 216 | } |
217 | 217 | |
218 | - function add_theme_support( $theme ) |
|
218 | + function add_theme_support($theme) |
|
219 | 219 | { |
220 | 220 | echo "[+] Adding theme support -> " . $theme . PHP_EOL; |
221 | 221 | } |
222 | 222 | |
223 | - function add_image_size( $image, $x, $y, $bool ) |
|
223 | + function add_image_size($image, $x, $y, $bool) |
|
224 | 224 | { |
225 | 225 | echo "[+] Adding image size -> " . $image . " x:" . $x . " y:" . $y . " bool:" . $bool . PHP_EOL; |
226 | 226 | } |
@@ -232,24 +232,24 @@ discard block |
||
232 | 232 | return $lang; |
233 | 233 | } |
234 | 234 | |
235 | - function load_plugin_textdomain( $name, $bool, $dir) |
|
235 | + function load_plugin_textdomain($name, $bool, $dir) |
|
236 | 236 | { |
237 | 237 | echo "[+] Loading plugin textdomain -> " . $name . " bool:" . $bool . " dir:" . $dir . PHP_EOL; |
238 | 238 | } |
239 | 239 | |
240 | - function get_option( $name, $int = 0 ) |
|
240 | + function get_option($name, $int = 0) |
|
241 | 241 | { |
242 | 242 | echo "[+] Getting option -> " . $name . " int:" . $int . PHP_EOL; |
243 | 243 | return ""; |
244 | 244 | } |
245 | 245 | |
246 | - function get_site_option( $name, $int = 0 ) |
|
246 | + function get_site_option($name, $int = 0) |
|
247 | 247 | { |
248 | 248 | echo "[+] Getting site option -> " . $name . " int:" . $int . PHP_EOL; |
249 | 249 | return ""; |
250 | 250 | } |
251 | 251 | |
252 | - function current_time( $str ) |
|
252 | + function current_time($str) |
|
253 | 253 | { |
254 | 254 | $time = " 2005-08-05 10:41:13"; |
255 | 255 | echo "[+] Requesting current_time -> " . $str . PHP_EOL; |
@@ -258,17 +258,17 @@ discard block |
||
258 | 258 | |
259 | 259 | class WPDB |
260 | 260 | { |
261 | - function prepare( $request = "" ) |
|
261 | + function prepare($request = "") |
|
262 | 262 | { |
263 | 263 | echo "[+] Preparing -> " . $request . PHP_EOL; |
264 | 264 | } |
265 | 265 | |
266 | - public static function get_var( $request = "" ) |
|
266 | + public static function get_var($request = "") |
|
267 | 267 | { |
268 | 268 | echo "[+] Requesting get var -> " . $request . PHP_EOL; |
269 | 269 | } |
270 | 270 | |
271 | - public static function get_charset_collate( $request = "" ) |
|
271 | + public static function get_charset_collate($request = "") |
|
272 | 272 | { |
273 | 273 | echo "[+] Requesting get charset collate -> " . $request . PHP_EOL; |
274 | 274 | } |
@@ -37,10 +37,13 @@ discard block |
||
37 | 37 | break; |
38 | 38 | } |
39 | 39 | } |
40 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
40 | + if($length > 0) { |
|
41 | + $hooked = rtrim($hooked, ","); |
|
42 | + } |
|
41 | 43 | $hooked .= "]"; |
44 | + } else { |
|
45 | + $hooked .= $object; |
|
42 | 46 | } |
43 | - else $hooked .= $object; |
|
44 | 47 | echo "[+] Adding action -> " . $init . " in " . $hooked . PHP_EOL; |
45 | 48 | } |
46 | 49 | |
@@ -70,10 +73,13 @@ discard block |
||
70 | 73 | break; |
71 | 74 | } |
72 | 75 | } |
73 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
76 | + if($length > 0) { |
|
77 | + $hooked = rtrim($hooked, ","); |
|
78 | + } |
|
74 | 79 | $hooked .= "]"; |
80 | + } else { |
|
81 | + $hooked .= $object; |
|
75 | 82 | } |
76 | - else $hooked .= $object; |
|
77 | 83 | echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL; |
78 | 84 | } |
79 | 85 | |
@@ -103,10 +109,13 @@ discard block |
||
103 | 109 | break; |
104 | 110 | } |
105 | 111 | } |
106 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
112 | + if($length > 0) { |
|
113 | + $hooked = rtrim($hooked, ","); |
|
114 | + } |
|
107 | 115 | $hooked .= "]"; |
116 | + } else { |
|
117 | + $hooked .= $object; |
|
108 | 118 | } |
109 | - else $hooked .= $object; |
|
110 | 119 | echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL; |
111 | 120 | } |
112 | 121 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | $unitList = searchFiles('.' . DIRECTORY_SEPARATOR, END_TEST); |
11 | 11 | |
12 | 12 | // Loop on unitList |
13 | -foreach($unitList as $test) |
|
13 | +foreach ($unitList as $test) |
|
14 | 14 | { |
15 | 15 | echo "[+] Testing -> " . $test . PHP_EOL; |
16 | 16 | include($test); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $ite = new RecursiveIteratorIterator($dir); |
29 | 29 | $files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH); |
30 | 30 | $fileList = array(); |
31 | - foreach($files as $file) |
|
31 | + foreach ($files as $file) |
|
32 | 32 | { |
33 | 33 | $fileList[] = $file[0]; |
34 | 34 | } |
@@ -30,39 +30,39 @@ |
||
30 | 30 | public $pageMessage = ''; |
31 | 31 | |
32 | 32 | /** |
33 | - * Get the url listing slug of the current class |
|
34 | - * |
|
35 | - * @return string The table of the class |
|
36 | - */ |
|
33 | + * Get the url listing slug of the current class |
|
34 | + * |
|
35 | + * @return string The table of the class |
|
36 | + */ |
|
37 | 37 | function setMessage($message){ |
38 | 38 | $this->pageMessage = $message; |
39 | 39 | } |
40 | 40 | /** |
41 | - * Get the url listing slug of the current class |
|
42 | - * |
|
43 | - * @return string The table of the class |
|
44 | - */ |
|
41 | + * Get the url listing slug of the current class |
|
42 | + * |
|
43 | + * @return string The table of the class |
|
44 | + */ |
|
45 | 45 | function getListingSlug(){ |
46 | 46 | return self::urlSlugListing; |
47 | 47 | } |
48 | 48 | /** |
49 | - * Get the url edition slug of the current class |
|
50 | - * |
|
51 | - * @return string The table of the class |
|
52 | - */ |
|
49 | + * Get the url edition slug of the current class |
|
50 | + * |
|
51 | + * @return string The table of the class |
|
52 | + */ |
|
53 | 53 | function getEditionSlug(){ |
54 | 54 | return self::urlSlugEdition; |
55 | 55 | } |
56 | 56 | /** |
57 | - * Get the database table of the current class |
|
58 | - * |
|
59 | - * @return string The table of the class |
|
60 | - */ |
|
57 | + * Get the database table of the current class |
|
58 | + * |
|
59 | + * @return string The table of the class |
|
60 | + */ |
|
61 | 61 | /** |
62 | - * Define the title of the page |
|
63 | - * |
|
64 | - * @return string $title The title of the page looking at the environnement |
|
65 | - */ |
|
62 | + * Define the title of the page |
|
63 | + * |
|
64 | + * @return string $title The title of the page looking at the environnement |
|
65 | + */ |
|
66 | 66 | function pageTitle(){ |
67 | 67 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : ''; |
68 | 68 | $objectInEdition = isset($_REQUEST['id']) ? wpshop_tools::varSanitizer($_REQUEST['id']) : ''; |
@@ -207,6 +207,9 @@ |
||
207 | 207 | return $shortcodes; |
208 | 208 | } |
209 | 209 | |
210 | + /** |
|
211 | + * @param string $shortcode_code |
|
212 | + */ |
|
210 | 213 | public static function output_shortcode($shortcode_code, $specific_shorcode = '', $more_class_shortcode_helper = ''){ |
211 | 214 | $shortcode = ( empty($specific_shorcode) ? self::shortcode_definition() : $specific_shorcode ); |
212 | 215 |
@@ -1,8 +1,8 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /* Check if file is include. No direct access possible with file url */ |
4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
4 | +if (!defined('WPSHOP_VERSION')) { |
|
5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | class ewpshop_shortcodes |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return string The table of the class |
36 | 36 | */ |
37 | - function setMessage($message){ |
|
37 | + function setMessage($message) { |
|
38 | 38 | $this->pageMessage = $message; |
39 | 39 | } |
40 | 40 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return string The table of the class |
44 | 44 | */ |
45 | - function getListingSlug(){ |
|
45 | + function getListingSlug() { |
|
46 | 46 | return self::urlSlugListing; |
47 | 47 | } |
48 | 48 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return string The table of the class |
52 | 52 | */ |
53 | - function getEditionSlug(){ |
|
53 | + function getEditionSlug() { |
|
54 | 54 | return self::urlSlugEdition; |
55 | 55 | } |
56 | 56 | /** |
@@ -63,32 +63,32 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return string $title The title of the page looking at the environnement |
65 | 65 | */ |
66 | - function pageTitle(){ |
|
66 | + function pageTitle() { |
|
67 | 67 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : ''; |
68 | 68 | $objectInEdition = isset($_REQUEST['id']) ? wpshop_tools::varSanitizer($_REQUEST['id']) : ''; |
69 | - $page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
69 | + $page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
70 | 70 | |
71 | - $title = __(self::pageTitle, 'wpshop' ); |
|
72 | - if($action != ''){ |
|
73 | - if(($action == 'edit') || ($action == 'delete')){ |
|
71 | + $title = __(self::pageTitle, 'wpshop'); |
|
72 | + if ($action != '') { |
|
73 | + if (($action == 'edit') || ($action == 'delete')) { |
|
74 | 74 | $editedItem = self::getElement($objectInEdition); |
75 | 75 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . ' (' . $editedItem->code . ')'); |
76 | 76 | } |
77 | - elseif($action == 'add'){ |
|
77 | + elseif ($action == 'add') { |
|
78 | 78 | $title = __(self::pageAddingTitle, 'wpshop'); |
79 | 79 | } |
80 | 80 | } |
81 | - elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())){ |
|
81 | + elseif ((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) { |
|
82 | 82 | $title = __(self::pageAddingTitle, 'wpshop'); |
83 | 83 | } |
84 | 84 | return $title; |
85 | 85 | } |
86 | 86 | |
87 | - function elementAction(){ |
|
87 | + function elementAction() { |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
91 | - function shortcode_definition(){ |
|
91 | + function shortcode_definition() { |
|
92 | 92 | $shortcodes = array(); |
93 | 93 | |
94 | 94 | /* Product tab */ |
@@ -187,32 +187,32 @@ discard block |
||
187 | 187 | return $shortcodes; |
188 | 188 | } |
189 | 189 | |
190 | - public static function output_shortcode($shortcode_code, $specific_shorcode = '', $more_class_shortcode_helper = ''){ |
|
191 | - $shortcode = ( empty($specific_shorcode) ? self::shortcode_definition() : $specific_shorcode ); |
|
190 | + public static function output_shortcode($shortcode_code, $specific_shorcode = '', $more_class_shortcode_helper = '') { |
|
191 | + $shortcode = (empty($specific_shorcode) ? self::shortcode_definition() : $specific_shorcode); |
|
192 | 192 | |
193 | - $shortcode_main_title = ( !empty($shortcode[$shortcode_code]['main_title']) ? $shortcode[$shortcode_code]['main_title'] : '' ); |
|
194 | - $shorcode_main_code = ( !empty($shortcode[$shortcode_code]['main_code']) ? $shortcode[$shortcode_code]['main_code'] : '' ); |
|
193 | + $shortcode_main_title = (!empty($shortcode[$shortcode_code]['main_title']) ? $shortcode[$shortcode_code]['main_title'] : ''); |
|
194 | + $shorcode_main_code = (!empty($shortcode[$shortcode_code]['main_code']) ? $shortcode[$shortcode_code]['main_code'] : ''); |
|
195 | 195 | $shorcode_attributes_def = ' '; |
196 | - if(!empty($shortcode[$shortcode_code]['attrs_def'])){ |
|
197 | - foreach($shortcode[$shortcode_code]['attrs_def'] as $attr_name => $attr_values){ |
|
198 | - $shorcode_attributes_def .= $attr_name.'="'.$attr_values.'" '; |
|
196 | + if (!empty($shortcode[$shortcode_code]['attrs_def'])) { |
|
197 | + foreach ($shortcode[$shortcode_code]['attrs_def'] as $attr_name => $attr_values) { |
|
198 | + $shorcode_attributes_def .= $attr_name . '="' . $attr_values . '" '; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | $shorcode_attributes_def = substr($shorcode_attributes_def, 0, -1); |
202 | 202 | $shorcode_attributes_exemple = ' '; |
203 | - if(!empty($shortcode[$shortcode_code]['attrs_exemple'])){ |
|
204 | - foreach($shortcode[$shortcode_code]['attrs_exemple'] as $attr_name => $attr_values){ |
|
205 | - $shorcode_attributes_exemple .= $attr_name.'="'.$attr_values.'" '; |
|
203 | + if (!empty($shortcode[$shortcode_code]['attrs_exemple'])) { |
|
204 | + foreach ($shortcode[$shortcode_code]['attrs_exemple'] as $attr_name => $attr_values) { |
|
205 | + $shorcode_attributes_exemple .= $attr_name . '="' . $attr_values . '" '; |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | $shorcode_attributes_exemple = substr($shorcode_attributes_exemple, 0, -1); |
209 | 209 | |
210 | - include(WPSHOP_TEMPLATES_DIR.'admin/shortcode_help.tpl.php'); |
|
210 | + include(WPSHOP_TEMPLATES_DIR . 'admin/shortcode_help.tpl.php'); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | public static function wysiwyg_button() { |
214 | - if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) return; |
|
215 | - if ( get_user_option('rich_editing') == 'true') : |
|
214 | + if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return; |
|
215 | + if (get_user_option('rich_editing') == 'true') : |
|
216 | 216 | add_filter('mce_external_plugins', array('wpshop_shortcodes', 'add_button_to_wysiwyg')); |
217 | 217 | add_filter('mce_buttons', array('wpshop_shortcodes', 'register_wysiwyg_button')); |
218 | 218 | endif; |
@@ -221,17 +221,17 @@ discard block |
||
221 | 221 | $ver += 3; |
222 | 222 | return $ver; |
223 | 223 | } |
224 | - public static function add_button_to_wysiwyg($plugin_array){ |
|
224 | + public static function add_button_to_wysiwyg($plugin_array) { |
|
225 | 225 | $plugin_array['wpshop_wysiwyg_shortcodes'] = WPSHOP_JS_URL . 'pages/wysiwyg_editor.js'; |
226 | 226 | return $plugin_array; |
227 | 227 | } |
228 | - public static function register_wysiwyg_button($existing_button){ |
|
228 | + public static function register_wysiwyg_button($existing_button) { |
|
229 | 229 | array_push($existing_button, "|", "wpshop_wysiwyg_button"); |
230 | 230 | return $existing_button; |
231 | 231 | } |
232 | 232 | |
233 | 233 | |
234 | - function elementList(){ |
|
234 | + function elementList() { |
|
235 | 235 | |
236 | 236 | $shortcode_list = ''; |
237 | 237 | ob_start(); |
@@ -247,71 +247,71 @@ discard block |
||
247 | 247 | |
248 | 248 | <div id="products"> |
249 | 249 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_product" > |
250 | - <h3><?php _e('Simple product','wpshop'); ?></h3> |
|
250 | + <h3><?php _e('Simple product', 'wpshop'); ?></h3> |
|
251 | 251 | <?php self::output_shortcode('simple_product'); ?> |
252 | - <h3><?php _e('Products listing','wpshop'); ?></h3> |
|
252 | + <h3><?php _e('Products listing', 'wpshop'); ?></h3> |
|
253 | 253 | <?php self::output_shortcode('product_listing'); ?> |
254 | - <h3><?php _e('Products listing specific','wpshop'); ?></h3> |
|
254 | + <h3><?php _e('Products listing specific', 'wpshop'); ?></h3> |
|
255 | 255 | <?php self::output_shortcode('product_listing_specific'); ?> |
256 | - <h3><?php _e('Products listing by attributes','wpshop'); ?></h3> |
|
256 | + <h3><?php _e('Products listing by attributes', 'wpshop'); ?></h3> |
|
257 | 257 | <?php self::output_shortcode('product_by_attribute'); ?> |
258 | - <h3><?php _e( 'Related products', 'wpshop'); ?></h3> |
|
258 | + <h3><?php _e('Related products', 'wpshop'); ?></h3> |
|
259 | 259 | <?php self::output_shortcode('related_products'); ?> |
260 | 260 | </div> |
261 | 261 | </div> |
262 | 262 | |
263 | 263 | <div id="category"> |
264 | 264 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_category" > |
265 | - <h3><?php _e('Simple category','wpshop'); ?></h3> |
|
265 | + <h3><?php _e('Simple category', 'wpshop'); ?></h3> |
|
266 | 266 | <?php self::output_shortcode('simple_category'); ?> |
267 | 267 | </div> |
268 | 268 | </div> |
269 | 269 | |
270 | 270 | <div id="attributs"> |
271 | 271 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_attributes" > |
272 | - <h3><?php _e('Simple attribute','wpshop'); ?></h3> |
|
272 | + <h3><?php _e('Simple attribute', 'wpshop'); ?></h3> |
|
273 | 273 | <?php self::output_shortcode('simple_attribute'); ?> |
274 | - <h3><?php _e('Attributes set','wpshop'); ?></h3> |
|
274 | + <h3><?php _e('Attributes set', 'wpshop'); ?></h3> |
|
275 | 275 | <?php self::output_shortcode('attributes_set'); ?> |
276 | 276 | </div> |
277 | 277 | </div> |
278 | 278 | |
279 | 279 | <div id="widgets"> |
280 | 280 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_widget wpshop_admin_box_shortcode_widget_cart" > |
281 | - <h3><?php _e('Cart','wpshop'); ?></h3> |
|
281 | + <h3><?php _e('Cart', 'wpshop'); ?></h3> |
|
282 | 282 | <?php self::output_shortcode('widget_cart_full'); ?> |
283 | 283 | <?php self::output_shortcode('widget_cart_mini'); ?> |
284 | 284 | </div> |
285 | 285 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_widget wpshop_admin_box_shortcode_widget_checkout" > |
286 | - <h3><?php _e('Checkout','wpshop'); ?></h3> |
|
286 | + <h3><?php _e('Checkout', 'wpshop'); ?></h3> |
|
287 | 287 | <?php self::output_shortcode('widget_checkout'); ?> |
288 | 288 | </div> |
289 | 289 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_widget wpshop_admin_box_shortcode_widget_customer_account" > |
290 | - <h3><?php _e('Account','wpshop'); ?></h3> |
|
290 | + <h3><?php _e('Account', 'wpshop'); ?></h3> |
|
291 | 291 | <?php self::output_shortcode('widget_account'); ?> |
292 | 292 | </div> |
293 | 293 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_widget wpshop_admin_box_shortcode_widget_shop" > |
294 | - <h3><?php _e('Shop','wpshop'); ?></h3> |
|
294 | + <h3><?php _e('Shop', 'wpshop'); ?></h3> |
|
295 | 295 | <?php self::output_shortcode('widget_shop'); ?> |
296 | 296 | </div> |
297 | 297 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_widget wpshop_admin_box_shortcode_custom_search" > |
298 | - <h3><?php _e('Custom search','wpshop'); ?></h3> |
|
298 | + <h3><?php _e('Custom search', 'wpshop'); ?></h3> |
|
299 | 299 | <?php self::output_shortcode('widget_custom_search'); ?> |
300 | 300 | </div> |
301 | 301 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_widget wpshop_admin_box_shortcode_custom_search" > |
302 | - <h3><?php _e('Filter Search','wpshop'); ?></h3> |
|
302 | + <h3><?php _e('Filter Search', 'wpshop'); ?></h3> |
|
303 | 303 | <?php self::output_shortcode('widget_filter_search'); ?> |
304 | - <a href="http://www.wpshop.fr/documentations/la-recherche-par-filtre/" target="_blank"><?php _e( 'Read the filter search tutorial', 'wpshop'); ?></a> |
|
304 | + <a href="http://www.wpshop.fr/documentations/la-recherche-par-filtre/" target="_blank"><?php _e('Read the filter search tutorial', 'wpshop'); ?></a> |
|
305 | 305 | </div> |
306 | 306 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_widget wpshop_admin_box_shortcode_custom_search" > |
307 | - <h3><?php _e('Breadcrumb WPShop','wpshop'); ?></h3> |
|
307 | + <h3><?php _e('Breadcrumb WPShop', 'wpshop'); ?></h3> |
|
308 | 308 | <?php self::output_shortcode('widget_wps_breadcrumb'); ?> |
309 | 309 | </div> |
310 | 310 | </div> |
311 | 311 | |
312 | 312 | <div id="customs_emails"> |
313 | 313 | <div class="wpshop_admin_box wpshop_admin_box_shortcode wpshop_admin_box_shortcode_emails" > |
314 | - <h3><?php _e('Available tags for emails cutomization','wpshop'); ?></h3> |
|
314 | + <h3><?php _e('Available tags for emails cutomization', 'wpshop'); ?></h3> |
|
315 | 315 | <ul > |
316 | 316 | <li><span class="wpshop_customer_tag_name" ><?php _e('Customer first name', 'wpshop'); ?></span><code>[customer_first_name]</code><li> |
317 | 317 | <li><span class="wpshop_customer_tag_name" ><?php _e('Customer last name', 'wpshop'); ?></span><code>[customer_last_name]</code><li> |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | class wps_shortcodes_ctr |
4 | 6 | { |
@@ -68,12 +70,10 @@ discard block |
||
68 | 70 | if(($action == 'edit') || ($action == 'delete')){ |
69 | 71 | $editedItem = self::getElement($objectInEdition); |
70 | 72 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . ' (' . $editedItem->code . ')'); |
71 | - } |
|
72 | - elseif($action == 'add'){ |
|
73 | + } elseif($action == 'add'){ |
|
73 | 74 | $title = __(self::pageAddingTitle, 'wpshop'); |
74 | 75 | } |
75 | - } |
|
76 | - elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())){ |
|
76 | + } elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())){ |
|
77 | 77 | $title = __(self::pageAddingTitle, 'wpshop'); |
78 | 78 | } |
79 | 79 | return $title; |
@@ -232,7 +232,9 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | public static function wysiwyg_button() { |
235 | - if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) return; |
|
235 | + if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) { |
|
236 | + return; |
|
237 | + } |
|
236 | 238 | if ( get_user_option('rich_editing') == 'true') : |
237 | 239 | add_filter('mce_external_plugins', array('wps_shortcodes_ctr', 'add_button_to_wysiwyg')); |
238 | 240 | add_filter('mce_buttons', array('wps_shortcodes_ctr', 'register_wysiwyg_button')); |
@@ -1,8 +1,8 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /* Check if file is include. No direct access possible with file url */ |
4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
4 | +if (!defined('WPSHOP_VERSION')) { |
|
5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -12,36 +12,36 @@ discard block |
||
12 | 12 | * @package wpshop |
13 | 13 | * @subpackage librairies |
14 | 14 | */ |
15 | -class wpshop_attributes_custom_List_table extends WP_List_Table{ |
|
15 | +class wpshop_attributes_custom_List_table extends WP_List_Table { |
|
16 | 16 | var $datas; |
17 | 17 | |
18 | 18 | /** ************************************************************************ |
19 | 19 | * REQUIRED. Set up a constructor that references the parent constructor. We |
20 | 20 | * use the parent reference to set some default configs. |
21 | 21 | ***************************************************************************/ |
22 | - function __construct(){ |
|
22 | + function __construct() { |
|
23 | 23 | global $status, $page; |
24 | 24 | |
25 | 25 | //Set parent defaults |
26 | - parent::__construct( array( |
|
27 | - 'singular' => __('attribute\'s', 'wpshop'), //singular name of the listed records |
|
28 | - 'plural' => __('attributes\'', 'wpshop'), //plural name of the listed records |
|
26 | + parent::__construct(array( |
|
27 | + 'singular' => __('attribute\'s', 'wpshop'), //singular name of the listed records |
|
28 | + 'plural' => __('attributes\'', 'wpshop'), //plural name of the listed records |
|
29 | 29 | 'ajax' => true //does this table support ajax? |
30 | - ) ); |
|
30 | + )); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /* Allows to set different listings for attributes */ |
34 | - function get_views(){ |
|
34 | + function get_views() { |
|
35 | 35 | $wpshop_attribute_links = array(); |
36 | 36 | |
37 | 37 | $active_nb = wpshop_attributes::getElement('', "'valid'"); |
38 | 38 | $unactive_nb = wpshop_attributes::getElement('', "'moderated', 'notused'"); |
39 | 39 | $deleted_nb = wpshop_attributes::getElement('', "'deleted'"); |
40 | 40 | |
41 | - $wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_valid'.(empty($_REQUEST['attribute_status'])?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING).'" >'.__('Used attributes', 'wpshop').' ('.count($active_nb).')</a>'; |
|
42 | - $wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_moderated'.(!empty($_REQUEST['attribute_status']) && ($_REQUEST['attribute_status']=='unactive')?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING.'&attribute_status=unactive').'" >'.__('Unactive attributes', 'wpshop').' ('.count($unactive_nb).')</a>'; |
|
43 | - $wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_deleted'.(!empty($_REQUEST['attribute_status']) && ($_REQUEST['attribute_status']=='deleted')?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING.'&attribute_status=deleted').'" >'.__('Trashed attributes', 'wpshop').' ('.count($deleted_nb).')</a>'; |
|
44 | - $wpshop_attribute_links['unit_management_link'] = '<a href="#" id="wpshop_attribute_unit_manager_opener">'.__('Unit management', 'wpshop').'</a>'; |
|
41 | + $wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_valid' . (empty($_REQUEST['attribute_status']) ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING) . '" >' . __('Used attributes', 'wpshop') . ' (' . count($active_nb) . ')</a>'; |
|
42 | + $wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_moderated' . (!empty($_REQUEST['attribute_status']) && ($_REQUEST['attribute_status'] == 'unactive') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&attribute_status=unactive') . '" >' . __('Unactive attributes', 'wpshop') . ' (' . count($unactive_nb) . ')</a>'; |
|
43 | + $wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_deleted' . (!empty($_REQUEST['attribute_status']) && ($_REQUEST['attribute_status'] == 'deleted') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&attribute_status=deleted') . '" >' . __('Trashed attributes', 'wpshop') . ' (' . count($deleted_nb) . ')</a>'; |
|
44 | + $wpshop_attribute_links['unit_management_link'] = '<a href="#" id="wpshop_attribute_unit_manager_opener">' . __('Unit management', 'wpshop') . '</a>'; |
|
45 | 45 | $wpshop_attribute_links['unit_management_dialog'] = '<div id="wpshop_attribute_unit_manager"title="' . __('Unit management', 'wpshop') . '" class="wpshopHide" ><div class="loading_picture_container" id="product_chooser_picture" ><img src="' . WPSHOP_LOADING_ICON . '" alt="loading..." /></div></div>'; |
46 | 46 | return $wpshop_attribute_links; |
47 | 47 | } |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * @see WP_List_Table::::single_row_columns() |
60 | 60 | * @return array An associative array containing column information: 'slugs'=>'Visible Titles' |
61 | 61 | **************************************************************************/ |
62 | - function get_columns(){ |
|
62 | + function get_columns() { |
|
63 | 63 | $columns = array( |
64 | - 'cb' => '',//'<input type="checkbox" />', //Render a checkbox instead of text |
|
64 | + 'cb' => '', //'<input type="checkbox" />', //Render a checkbox instead of text |
|
65 | 65 | 'id' => __('Id.', 'wpshop'), |
66 | 66 | 'name' => __('Name', 'wpshop'), |
67 | 67 | 'status' => __('Status', 'wpshop'), |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * @param array $column_name The name/slug of the column to be processed |
93 | 93 | * @return string Text or HTML to be placed inside the column <td> |
94 | 94 | **************************************************************************/ |
95 | - function column_default($item, $column_name){ |
|
96 | - switch($column_name){ |
|
95 | + function column_default($item, $column_name) { |
|
96 | + switch ($column_name) { |
|
97 | 97 | default: |
98 | - return print_r($item,true); //Show the whole array for troubleshooting purposes |
|
98 | + return print_r($item, true); //Show the whole array for troubleshooting purposes |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param array $item A singular item (one full row's worth of data) |
116 | 116 | * @return string Text to be placed inside the column <td> (movie title only) |
117 | 117 | **************************************************************************/ |
118 | - function column_id($item){ |
|
118 | + function column_id($item) { |
|
119 | 119 | return $item['id']; |
120 | 120 | } |
121 | 121 | /** ************************************************************************ |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param array $item A singular item (one full row's worth of data) |
135 | 135 | * @return string Text to be placed inside the column <td> (movie title only) |
136 | 136 | **************************************************************************/ |
137 | - function column_status($item){ |
|
137 | + function column_status($item) { |
|
138 | 138 | return __($item['status'], 'wpshop'); |
139 | 139 | } |
140 | 140 | /** ************************************************************************ |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param array $item A singular item (one full row's worth of data) |
154 | 154 | * @return string Text to be placed inside the column <td> (movie title only) |
155 | 155 | **************************************************************************/ |
156 | - function column_code($item){ |
|
156 | + function column_code($item) { |
|
157 | 157 | return $item['code']; |
158 | 158 | } |
159 | 159 | /** ************************************************************************ |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @param array $item A singular item (one full row's worth of data) |
173 | 173 | * @return string Text to be placed inside the column <td> (movie title only) |
174 | 174 | **************************************************************************/ |
175 | - function column_entity($item){ |
|
176 | - return __($item['entity'],'wpshop'); |
|
175 | + function column_entity($item) { |
|
176 | + return __($item['entity'], 'wpshop'); |
|
177 | 177 | } |
178 | 178 | /** ************************************************************************ |
179 | 179 | * Recommended. This is a custom column method and is responsible for what |
@@ -191,27 +191,27 @@ discard block |
||
191 | 191 | * @param array $item A singular item (one full row's worth of data) |
192 | 192 | * @return string Text to be placed inside the column <td> (movie title only) |
193 | 193 | **************************************************************************/ |
194 | - function column_name($item){ |
|
194 | + function column_name($item) { |
|
195 | 195 | $attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE); |
196 | 196 | |
197 | - $link_format = admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s'; |
|
198 | - $default_action='edit'; |
|
199 | - $default_action_text=__('Edit', 'wpshop'); |
|
200 | - if(!empty($_REQUEST['attribute_status']) && ($_REQUEST['attribute_status']=='deleted')){ |
|
201 | - $default_action='activate'; |
|
202 | - $default_action_text=__('Restore', 'wpshop'); |
|
197 | + $link_format = admin_url('admin.php') . '?page=%2$s&action=%3$s&id=%4$s'; |
|
198 | + $default_action = 'edit'; |
|
199 | + $default_action_text = __('Edit', 'wpshop'); |
|
200 | + if (!empty($_REQUEST['attribute_status']) && ($_REQUEST['attribute_status'] == 'deleted')) { |
|
201 | + $default_action = 'activate'; |
|
202 | + $default_action_text = __('Restore', 'wpshop'); |
|
203 | 203 | } |
204 | 204 | //Build row actions |
205 | 205 | $actions = array( |
206 | - 'edit' => sprintf('<a href="'.$link_format.'">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,$default_action,$item['id']) |
|
206 | + 'edit' => sprintf('<a href="' . $link_format . '">' . $default_action_text . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, $default_action, $item['id']) |
|
207 | 207 | ); |
208 | - if(empty($_REQUEST['attribute_status']) && (!in_array($item['code'], $attribute_undeletable))){ |
|
209 | - $actions['delete'] = sprintf('<a href="'.$link_format.'">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,'delete',$item['id']); |
|
208 | + if (empty($_REQUEST['attribute_status']) && (!in_array($item['code'], $attribute_undeletable))) { |
|
209 | + $actions['delete'] = sprintf('<a href="' . $link_format . '">' . __('Delete', 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, 'delete', $item['id']); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | //Return the title contents |
213 | 213 | return sprintf('%1$s%2$s', |
214 | - /*$1%s*/ sprintf('<a href="'.$link_format.'">'.__($item['name'], 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,$default_action,$item['id']), |
|
214 | + /*$1%s*/ sprintf('<a href="' . $link_format . '">' . __($item['name'], 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, $default_action, $item['id']), |
|
215 | 215 | /*$3%s*/ $this->row_actions($actions) |
216 | 216 | ); |
217 | 217 | } |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | * @param array $item A singular item (one full row's worth of data) |
225 | 225 | * @return string Text to be placed inside the column <td> (movie title only) |
226 | 226 | **************************************************************************/ |
227 | - function column_cb($item){ |
|
227 | + function column_cb($item) { |
|
228 | 228 | return ''; |
229 | 229 | return sprintf( |
230 | 230 | '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
231 | - /*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie") |
|
231 | + /*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie") |
|
232 | 232 | /*$2%s*/ $item['id'] //The value of the checkbox should be the record's id |
233 | 233 | ); |
234 | 234 | } |
@@ -249,8 +249,8 @@ discard block |
||
249 | 249 | **************************************************************************/ |
250 | 250 | function get_sortable_columns() { |
251 | 251 | $sortable_columns = array( |
252 | - 'name' => array('frontend_label',true), //true means its already sorted |
|
253 | - 'status' => array('status',true) |
|
252 | + 'name' => array('frontend_label', true), //true means its already sorted |
|
253 | + 'status' => array('status', true) |
|
254 | 254 | ); |
255 | 255 | return $sortable_columns; |
256 | 256 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | **************************************************************************/ |
286 | 286 | function process_bulk_action() { |
287 | 287 | //Detect when a bulk action is being triggered... |
288 | - if( 'delete'===$this->current_action() ) { |
|
288 | + if ('delete' === $this->current_action()) { |
|
289 | 289 | wp_die('Items deleted (or they would be if we had items to delete)!'); |
290 | 290 | } |
291 | 291 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | **************************************************************************/ |
307 | 307 | function prepare_items() { |
308 | 308 | /* First, lets decide how many records per page to show */ |
309 | - $per_page = 10;//$this->get_items_per_page('attributes_per_page', 10); |
|
309 | + $per_page = 10; //$this->get_items_per_page('attributes_per_page', 10); |
|
310 | 310 | |
311 | 311 | /** |
312 | 312 | * REQUIRED. Now we need to define our column headers. This includes a complete |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * to ensure that the data is trimmed to only the current page. We can use |
365 | 365 | * array_slice() to |
366 | 366 | */ |
367 | - $data = array_slice($data,(($current_page-1)*$per_page),$per_page); |
|
367 | + $data = array_slice($data, (($current_page - 1) * $per_page), $per_page); |
|
368 | 368 | |
369 | 369 | /** |
370 | 370 | * REQUIRED. Now we can add our *sorted* data to the items property, where |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | $this->items = $data; |
374 | 374 | |
375 | 375 | /* REQUIRED. We also have to register our pagination options & calculations. */ |
376 | - $this->set_pagination_args( array( |
|
377 | - 'total_items' => $total_items, //WE have to calculate the total number of items |
|
378 | - 'per_page' => $per_page, //WE have to determine how many items to show on a page |
|
379 | - 'total_pages' => ceil($total_items/$per_page) //WE have to calculate the total number of pages |
|
380 | - ) ); |
|
376 | + $this->set_pagination_args(array( |
|
377 | + 'total_items' => $total_items, //WE have to calculate the total number of items |
|
378 | + 'per_page' => $per_page, //WE have to determine how many items to show on a page |
|
379 | + 'total_pages' => ceil($total_items / $per_page) //WE have to calculate the total number of pages |
|
380 | + )); |
|
381 | 381 | } |
382 | 382 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * to keep hidden, and a list of columns that are sortable. Each of these |
235 | 235 | * can be defined in another method (as we've done here) before being |
236 | 236 | * used to build the value for our _column_headers property. |
237 | - */ |
|
237 | + */ |
|
238 | 238 | $columns = $this->get_columns(); |
239 | 239 | $hidden = array(); |
240 | 240 | $sortable = $this->get_sortable_columns(); |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | * headers. The $this->_column_headers property takes an array which contains |
245 | 245 | * 3 other arrays. One for all columns, one for hidden columns, and one |
246 | 246 | * for sortable columns. |
247 | - */ |
|
247 | + */ |
|
248 | 248 | $this->_column_headers = array($columns, $hidden, $sortable); |
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Optional. You can handle your bulk actions however you see fit. In this |
252 | 252 | * case, we'll handle them within our package just to keep things clean. |
253 | - */ |
|
253 | + */ |
|
254 | 254 | $this->process_bulk_action(); |
255 | 255 | |
256 | 256 | /** |
@@ -261,14 +261,14 @@ discard block |
||
261 | 261 | * our data. In a real-world implementation, you will probably want to |
262 | 262 | * use sort and pagination data to build a custom query instead, as you'll |
263 | 263 | * be able to use your precisely-queried data immediately. |
264 | - */ |
|
264 | + */ |
|
265 | 265 | // $data = ; |
266 | 266 | |
267 | 267 | /** |
268 | 268 | * REQUIRED for pagination. Let's figure out what page the user is currently |
269 | 269 | * looking at. We'll need this later, so you should always include it in |
270 | 270 | * your own package classes. |
271 | - */ |
|
271 | + */ |
|
272 | 272 | $current_page = $this->get_pagenum(); |
273 | 273 | |
274 | 274 | /** |
@@ -276,20 +276,20 @@ discard block |
||
276 | 276 | * In real-world use, this would be the total number of items in your database, |
277 | 277 | * without filtering. We'll need this later, so you should always include it |
278 | 278 | * in your own package classes. |
279 | - */ |
|
279 | + */ |
|
280 | 280 | $total_items = count($data); |
281 | 281 | |
282 | 282 | /** |
283 | 283 | * The WP_List_Table class does not handle pagination for us, so we need |
284 | 284 | * to ensure that the data is trimmed to only the current page. We can use |
285 | 285 | * array_slice() to |
286 | - */ |
|
286 | + */ |
|
287 | 287 | $data = array_slice($data,(($current_page-1)*$per_page),$per_page); |
288 | 288 | |
289 | 289 | /** |
290 | 290 | * REQUIRED. Now we can add our *sorted* data to the items property, where |
291 | 291 | * it can be used by the rest of the class. |
292 | - */ |
|
292 | + */ |
|
293 | 293 | $this->items = $data; |
294 | 294 | |
295 | 295 | /* REQUIRED. We also have to register our pagination options & calculations. */ |
@@ -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 | * |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | var $datas; |
17 | 17 | |
18 | 18 | /** ************************************************************************ |
19 | - * REQUIRED. Set up a constructor that references the parent constructor. We |
|
20 | - * use the parent reference to set some default configs. |
|
21 | - ***************************************************************************/ |
|
19 | + * REQUIRED. Set up a constructor that references the parent constructor. We |
|
20 | + * use the parent reference to set some default configs. |
|
21 | + ***************************************************************************/ |
|
22 | 22 | function __construct(){ |
23 | 23 | global $status, $page; |
24 | 24 | |
@@ -44,18 +44,18 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | /** ************************************************************************ |
47 | - * REQUIRED! This method dictates the table's columns and titles. This should |
|
48 | - * return an array where the key is the column slug (and class) and the value |
|
49 | - * is the column's title text. If you need a checkbox for bulk actions, refer |
|
50 | - * to the $columns array below. |
|
51 | - * |
|
52 | - * The 'cb' column is treated differently than the rest. If including a checkbox |
|
53 | - * column in your table you must create a column_cb() method. If you don't need |
|
54 | - * bulk actions or checkboxes, simply leave the 'cb' entry out of your array. |
|
55 | - * |
|
56 | - * @see WP_List_Table::::single_row_columns() |
|
57 | - * @return array An associative array containing column information: 'slugs'=>'Visible Titles' |
|
58 | - **************************************************************************/ |
|
47 | + * REQUIRED! This method dictates the table's columns and titles. This should |
|
48 | + * return an array where the key is the column slug (and class) and the value |
|
49 | + * is the column's title text. If you need a checkbox for bulk actions, refer |
|
50 | + * to the $columns array below. |
|
51 | + * |
|
52 | + * The 'cb' column is treated differently than the rest. If including a checkbox |
|
53 | + * column in your table you must create a column_cb() method. If you don't need |
|
54 | + * bulk actions or checkboxes, simply leave the 'cb' entry out of your array. |
|
55 | + * |
|
56 | + * @see WP_List_Table::::single_row_columns() |
|
57 | + * @return array An associative array containing column information: 'slugs'=>'Visible Titles' |
|
58 | + **************************************************************************/ |
|
59 | 59 | function get_columns(){ |
60 | 60 | $columns = array( |
61 | 61 | 'cb' => '',//'<input type="checkbox" />', //Render a checkbox instead of text |
@@ -69,26 +69,26 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | /** ************************************************************************ |
72 | - * Recommended. This method is called when the parent class can't find a method |
|
73 | - * specifically build for a given column. Generally, it's recommended to include |
|
74 | - * one method for each column you want to render, keeping your package class |
|
75 | - * neat and organized. For example, if the class needs to process a column |
|
76 | - * named 'title', it would first see if a method named $this->column_title() |
|
77 | - * exists - if it does, that method will be used. If it doesn't, this one will |
|
78 | - * be used. Generally, you should try to use custom column methods as much as |
|
79 | - * possible. |
|
80 | - * |
|
81 | - * Since we have defined a column_title() method later on, this method doesn't |
|
82 | - * need to concern itself with any column with a name of 'title'. Instead, it |
|
83 | - * needs to handle everything else. |
|
84 | - * |
|
85 | - * For more detailed insight into how columns are handled, take a look at |
|
86 | - * WP_List_Table::single_row_columns() |
|
87 | - * |
|
88 | - * @param array $item A singular item (one full row's worth of data) |
|
89 | - * @param array $column_name The name/slug of the column to be processed |
|
90 | - * @return string Text or HTML to be placed inside the column <td> |
|
91 | - **************************************************************************/ |
|
72 | + * Recommended. This method is called when the parent class can't find a method |
|
73 | + * specifically build for a given column. Generally, it's recommended to include |
|
74 | + * one method for each column you want to render, keeping your package class |
|
75 | + * neat and organized. For example, if the class needs to process a column |
|
76 | + * named 'title', it would first see if a method named $this->column_title() |
|
77 | + * exists - if it does, that method will be used. If it doesn't, this one will |
|
78 | + * be used. Generally, you should try to use custom column methods as much as |
|
79 | + * possible. |
|
80 | + * |
|
81 | + * Since we have defined a column_title() method later on, this method doesn't |
|
82 | + * need to concern itself with any column with a name of 'title'. Instead, it |
|
83 | + * needs to handle everything else. |
|
84 | + * |
|
85 | + * For more detailed insight into how columns are handled, take a look at |
|
86 | + * WP_List_Table::single_row_columns() |
|
87 | + * |
|
88 | + * @param array $item A singular item (one full row's worth of data) |
|
89 | + * @param array $column_name The name/slug of the column to be processed |
|
90 | + * @return string Text or HTML to be placed inside the column <td> |
|
91 | + **************************************************************************/ |
|
92 | 92 | function column_default($item, $column_name){ |
93 | 93 | switch($column_name){ |
94 | 94 | default: |
@@ -97,97 +97,97 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | /** ************************************************************************ |
100 | - * Recommended. This is a custom column method and is responsible for what |
|
101 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
102 | - * needs to render a column, it first looks for a method named |
|
103 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
104 | - * exist, column_default() is called instead. |
|
105 | - * |
|
106 | - * This example also illustrates how to implement rollover actions. Actions |
|
107 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
108 | - * will need to generate the URLs yourself. You could even ensure the links |
|
109 | - * |
|
110 | - * |
|
111 | - * @see WP_List_Table::::single_row_columns() |
|
112 | - * @param array $item A singular item (one full row's worth of data) |
|
113 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
114 | - **************************************************************************/ |
|
100 | + * Recommended. This is a custom column method and is responsible for what |
|
101 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
102 | + * needs to render a column, it first looks for a method named |
|
103 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
104 | + * exist, column_default() is called instead. |
|
105 | + * |
|
106 | + * This example also illustrates how to implement rollover actions. Actions |
|
107 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
108 | + * will need to generate the URLs yourself. You could even ensure the links |
|
109 | + * |
|
110 | + * |
|
111 | + * @see WP_List_Table::::single_row_columns() |
|
112 | + * @param array $item A singular item (one full row's worth of data) |
|
113 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
114 | + **************************************************************************/ |
|
115 | 115 | function column_id($item){ |
116 | 116 | return $item['id']; |
117 | 117 | } |
118 | 118 | /** ************************************************************************ |
119 | - * Recommended. This is a custom column method and is responsible for what |
|
120 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
121 | - * needs to render a column, it first looks for a method named |
|
122 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
123 | - * exist, column_default() is called instead. |
|
124 | - * |
|
125 | - * This example also illustrates how to implement rollover actions. Actions |
|
126 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
127 | - * will need to generate the URLs yourself. You could even ensure the links |
|
128 | - * |
|
129 | - * |
|
130 | - * @see WP_List_Table::::single_row_columns() |
|
131 | - * @param array $item A singular item (one full row's worth of data) |
|
132 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
133 | - **************************************************************************/ |
|
119 | + * Recommended. This is a custom column method and is responsible for what |
|
120 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
121 | + * needs to render a column, it first looks for a method named |
|
122 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
123 | + * exist, column_default() is called instead. |
|
124 | + * |
|
125 | + * This example also illustrates how to implement rollover actions. Actions |
|
126 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
127 | + * will need to generate the URLs yourself. You could even ensure the links |
|
128 | + * |
|
129 | + * |
|
130 | + * @see WP_List_Table::::single_row_columns() |
|
131 | + * @param array $item A singular item (one full row's worth of data) |
|
132 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
133 | + **************************************************************************/ |
|
134 | 134 | function column_status($item){ |
135 | 135 | return __($item['status'], 'wpshop'); |
136 | 136 | } |
137 | 137 | /** ************************************************************************ |
138 | - * Recommended. This is a custom column method and is responsible for what |
|
139 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
140 | - * needs to render a column, it first looks for a method named |
|
141 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
142 | - * exist, column_default() is called instead. |
|
143 | - * |
|
144 | - * This example also illustrates how to implement rollover actions. Actions |
|
145 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
146 | - * will need to generate the URLs yourself. You could even ensure the links |
|
147 | - * |
|
148 | - * |
|
149 | - * @see WP_List_Table::::single_row_columns() |
|
150 | - * @param array $item A singular item (one full row's worth of data) |
|
151 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
152 | - **************************************************************************/ |
|
138 | + * Recommended. This is a custom column method and is responsible for what |
|
139 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
140 | + * needs to render a column, it first looks for a method named |
|
141 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
142 | + * exist, column_default() is called instead. |
|
143 | + * |
|
144 | + * This example also illustrates how to implement rollover actions. Actions |
|
145 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
146 | + * will need to generate the URLs yourself. You could even ensure the links |
|
147 | + * |
|
148 | + * |
|
149 | + * @see WP_List_Table::::single_row_columns() |
|
150 | + * @param array $item A singular item (one full row's worth of data) |
|
151 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
152 | + **************************************************************************/ |
|
153 | 153 | function column_content($item){ |
154 | 154 | return $item['content']; |
155 | 155 | } |
156 | 156 | /** ************************************************************************ |
157 | - * Recommended. This is a custom column method and is responsible for what |
|
158 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
159 | - * needs to render a column, it first looks for a method named |
|
160 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
161 | - * exist, column_default() is called instead. |
|
162 | - * |
|
163 | - * This example also illustrates how to implement rollover actions. Actions |
|
164 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
165 | - * will need to generate the URLs yourself. You could even ensure the links |
|
166 | - * |
|
167 | - * |
|
168 | - * @see WP_List_Table::::single_row_columns() |
|
169 | - * @param array $item A singular item (one full row's worth of data) |
|
170 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
171 | - **************************************************************************/ |
|
157 | + * Recommended. This is a custom column method and is responsible for what |
|
158 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
159 | + * needs to render a column, it first looks for a method named |
|
160 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
161 | + * exist, column_default() is called instead. |
|
162 | + * |
|
163 | + * This example also illustrates how to implement rollover actions. Actions |
|
164 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
165 | + * will need to generate the URLs yourself. You could even ensure the links |
|
166 | + * |
|
167 | + * |
|
168 | + * @see WP_List_Table::::single_row_columns() |
|
169 | + * @param array $item A singular item (one full row's worth of data) |
|
170 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
171 | + **************************************************************************/ |
|
172 | 172 | function column_entity($item){ |
173 | 173 | return __($item['entity'],'wpshop'); |
174 | 174 | } |
175 | 175 | /** ************************************************************************ |
176 | - * Recommended. This is a custom column method and is responsible for what |
|
177 | - * is rendered in any column with a name/slug of 'title'. Every time the class |
|
178 | - * needs to render a column, it first looks for a method named |
|
179 | - * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
180 | - * exist, column_default() is called instead. |
|
181 | - * |
|
182 | - * This example also illustrates how to implement rollover actions. Actions |
|
183 | - * should be an associative array formatted as 'slug'=>'link html' - and you |
|
184 | - * will need to generate the URLs yourself. You could even ensure the links |
|
185 | - * |
|
186 | - * |
|
187 | - * @see WP_List_Table::::single_row_columns() |
|
188 | - * @param array $item A singular item (one full row's worth of data) |
|
189 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
190 | - **************************************************************************/ |
|
176 | + * Recommended. This is a custom column method and is responsible for what |
|
177 | + * is rendered in any column with a name/slug of 'title'. Every time the class |
|
178 | + * needs to render a column, it first looks for a method named |
|
179 | + * column_{$column_title} - if it exists, that method is run. If it doesn't |
|
180 | + * exist, column_default() is called instead. |
|
181 | + * |
|
182 | + * This example also illustrates how to implement rollover actions. Actions |
|
183 | + * should be an associative array formatted as 'slug'=>'link html' - and you |
|
184 | + * will need to generate the URLs yourself. You could even ensure the links |
|
185 | + * |
|
186 | + * |
|
187 | + * @see WP_List_Table::::single_row_columns() |
|
188 | + * @param array $item A singular item (one full row's worth of data) |
|
189 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
190 | + **************************************************************************/ |
|
191 | 191 | function column_name($item){ |
192 | 192 | //Build row actions |
193 | 193 | $default_action='edit'; |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | ); |
209 | 209 | } |
210 | 210 | /** ************************************************************************ |
211 | - * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column |
|
212 | - * is given special treatment when columns are processed. It ALWAYS needs to |
|
213 | - * have it's own method. |
|
214 | - * |
|
215 | - * @see WP_List_Table::::single_row_columns() |
|
216 | - * @param array $item A singular item (one full row's worth of data) |
|
217 | - * @return string Text to be placed inside the column <td> (movie title only) |
|
218 | - **************************************************************************/ |
|
211 | + * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column |
|
212 | + * is given special treatment when columns are processed. It ALWAYS needs to |
|
213 | + * have it's own method. |
|
214 | + * |
|
215 | + * @see WP_List_Table::::single_row_columns() |
|
216 | + * @param array $item A singular item (one full row's worth of data) |
|
217 | + * @return string Text to be placed inside the column <td> (movie title only) |
|
218 | + **************************************************************************/ |
|
219 | 219 | function column_cb($item){ |
220 | 220 | return ''; |
221 | 221 | return sprintf( |
@@ -226,19 +226,19 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | /** ************************************************************************ |
229 | - * Optional. If you want one or more columns to be sortable (ASC/DESC toggle), |
|
230 | - * you will need to register it here. This should return an array where the |
|
231 | - * key is the column that needs to be sortable, and the value is db column to |
|
232 | - * sort by. Often, the key and value will be the same, but this is not always |
|
233 | - * the case (as the value is a column name from the database, not the list table). |
|
234 | - * |
|
235 | - * This method merely defines which columns should be sortable and makes them |
|
236 | - * clickable - it does not handle the actual sorting. You still need to detect |
|
237 | - * the ORDERBY and ORDER querystring variables within prepare_items() and sort |
|
238 | - * your data accordingly (usually by modifying your query). |
|
239 | - * |
|
240 | - * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool) |
|
241 | - **************************************************************************/ |
|
229 | + * Optional. If you want one or more columns to be sortable (ASC/DESC toggle), |
|
230 | + * you will need to register it here. This should return an array where the |
|
231 | + * key is the column that needs to be sortable, and the value is db column to |
|
232 | + * sort by. Often, the key and value will be the same, but this is not always |
|
233 | + * the case (as the value is a column name from the database, not the list table). |
|
234 | + * |
|
235 | + * This method merely defines which columns should be sortable and makes them |
|
236 | + * clickable - it does not handle the actual sorting. You still need to detect |
|
237 | + * the ORDERBY and ORDER querystring variables within prepare_items() and sort |
|
238 | + * your data accordingly (usually by modifying your query). |
|
239 | + * |
|
240 | + * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool) |
|
241 | + **************************************************************************/ |
|
242 | 242 | function get_sortable_columns() { |
243 | 243 | $sortable_columns = array( |
244 | 244 | //'name' => array('name',true) //true means its already sorted |
@@ -247,19 +247,19 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | /** ************************************************************************ |
250 | - * Optional. If you need to include bulk actions in your list table, this is |
|
251 | - * the place to define them. Bulk actions are an associative array in the format |
|
252 | - * 'slug'=>'Visible Title' |
|
253 | - * |
|
254 | - * If this method returns an empty value, no bulk action will be rendered. If |
|
255 | - * you specify any bulk actions, the bulk actions box will be rendered with |
|
256 | - * the table automatically on display(). |
|
257 | - * |
|
258 | - * Also note that list tables are not automatically wrapped in <form> elements, |
|
259 | - * so you will need to create those manually in order for bulk actions to function. |
|
260 | - * |
|
261 | - * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles' |
|
262 | - **************************************************************************/ |
|
250 | + * Optional. If you need to include bulk actions in your list table, this is |
|
251 | + * the place to define them. Bulk actions are an associative array in the format |
|
252 | + * 'slug'=>'Visible Title' |
|
253 | + * |
|
254 | + * If this method returns an empty value, no bulk action will be rendered. If |
|
255 | + * you specify any bulk actions, the bulk actions box will be rendered with |
|
256 | + * the table automatically on display(). |
|
257 | + * |
|
258 | + * Also note that list tables are not automatically wrapped in <form> elements, |
|
259 | + * so you will need to create those manually in order for bulk actions to function. |
|
260 | + * |
|
261 | + * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles' |
|
262 | + **************************************************************************/ |
|
263 | 263 | function get_bulk_actions() { |
264 | 264 | $actions = array( |
265 | 265 | // 'delete' => __('Delete','wpshop') |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | /** ************************************************************************ |
271 | - * Optional. You can handle your bulk actions anywhere or anyhow you prefer. |
|
272 | - * For this example package, we will handle it in the class to keep things |
|
273 | - * clean and organized. |
|
274 | - * |
|
275 | - * @see $this->prepare_items() |
|
276 | - **************************************************************************/ |
|
271 | + * Optional. You can handle your bulk actions anywhere or anyhow you prefer. |
|
272 | + * For this example package, we will handle it in the class to keep things |
|
273 | + * clean and organized. |
|
274 | + * |
|
275 | + * @see $this->prepare_items() |
|
276 | + **************************************************************************/ |
|
277 | 277 | function process_bulk_action() { |
278 | 278 | //Detect when a bulk action is being triggered... |
279 | 279 | if( 'delete'===$this->current_action() ) { |
@@ -282,90 +282,90 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | /** ************************************************************************ |
285 | - * REQUIRED! This is where you prepare your data for display. This method will |
|
286 | - * usually be used to query the database, sort and filter the data, and generally |
|
287 | - * get it ready to be displayed. At a minimum, we should set $this->items and |
|
288 | - * $this->set_pagination_args(), although the following properties and methods |
|
289 | - * are frequently interacted with here... |
|
290 | - * |
|
291 | - * @uses $this->_column_headers |
|
292 | - * @uses $this->items |
|
293 | - * @uses $this->get_columns() |
|
294 | - * @uses $this->get_sortable_columns() |
|
295 | - * @uses $this->get_pagenum() |
|
296 | - * @uses $this->set_pagination_args() |
|
297 | - **************************************************************************/ |
|
285 | + * REQUIRED! This is where you prepare your data for display. This method will |
|
286 | + * usually be used to query the database, sort and filter the data, and generally |
|
287 | + * get it ready to be displayed. At a minimum, we should set $this->items and |
|
288 | + * $this->set_pagination_args(), although the following properties and methods |
|
289 | + * are frequently interacted with here... |
|
290 | + * |
|
291 | + * @uses $this->_column_headers |
|
292 | + * @uses $this->items |
|
293 | + * @uses $this->get_columns() |
|
294 | + * @uses $this->get_sortable_columns() |
|
295 | + * @uses $this->get_pagenum() |
|
296 | + * @uses $this->set_pagination_args() |
|
297 | + **************************************************************************/ |
|
298 | 298 | function prepare_items() { |
299 | 299 | /* First, lets decide how many records per page to show */ |
300 | 300 | $per_page = 10; |
301 | 301 | |
302 | 302 | /** |
303 | - * REQUIRED. Now we need to define our column headers. This includes a complete |
|
304 | - * array of columns to be displayed (slugs & titles), a list of columns |
|
305 | - * to keep hidden, and a list of columns that are sortable. Each of these |
|
306 | - * can be defined in another method (as we've done here) before being |
|
307 | - * used to build the value for our _column_headers property. |
|
308 | - */ |
|
303 | + * REQUIRED. Now we need to define our column headers. This includes a complete |
|
304 | + * array of columns to be displayed (slugs & titles), a list of columns |
|
305 | + * to keep hidden, and a list of columns that are sortable. Each of these |
|
306 | + * can be defined in another method (as we've done here) before being |
|
307 | + * used to build the value for our _column_headers property. |
|
308 | + */ |
|
309 | 309 | $columns = $this->get_columns(); |
310 | 310 | $hidden = array(); |
311 | 311 | $sortable = $this->get_sortable_columns(); |
312 | 312 | |
313 | 313 | /** |
314 | - * REQUIRED. Finally, we build an array to be used by the class for column |
|
315 | - * headers. The $this->_column_headers property takes an array which contains |
|
316 | - * 3 other arrays. One for all columns, one for hidden columns, and one |
|
317 | - * for sortable columns. |
|
318 | - */ |
|
314 | + * REQUIRED. Finally, we build an array to be used by the class for column |
|
315 | + * headers. The $this->_column_headers property takes an array which contains |
|
316 | + * 3 other arrays. One for all columns, one for hidden columns, and one |
|
317 | + * for sortable columns. |
|
318 | + */ |
|
319 | 319 | $this->_column_headers = array($columns, $hidden, $sortable); |
320 | 320 | |
321 | 321 | /** |
322 | - * Optional. You can handle your bulk actions however you see fit. In this |
|
323 | - * case, we'll handle them within our package just to keep things clean. |
|
324 | - */ |
|
322 | + * Optional. You can handle your bulk actions however you see fit. In this |
|
323 | + * case, we'll handle them within our package just to keep things clean. |
|
324 | + */ |
|
325 | 325 | $this->process_bulk_action(); |
326 | 326 | |
327 | 327 | /** |
328 | - * Instead of querying a database, we're going to fetch the example data |
|
329 | - * property we created for use in this plugin. This makes this example |
|
330 | - * package slightly different than one you might build on your own. In |
|
331 | - * this example, we'll be using array manipulation to sort and paginate |
|
332 | - * our data. In a real-world implementation, you will probably want to |
|
333 | - * use sort and pagination data to build a custom query instead, as you'll |
|
334 | - * be able to use your precisely-queried data immediately. |
|
335 | - */ |
|
328 | + * Instead of querying a database, we're going to fetch the example data |
|
329 | + * property we created for use in this plugin. This makes this example |
|
330 | + * package slightly different than one you might build on your own. In |
|
331 | + * this example, we'll be using array manipulation to sort and paginate |
|
332 | + * our data. In a real-world implementation, you will probably want to |
|
333 | + * use sort and pagination data to build a custom query instead, as you'll |
|
334 | + * be able to use your precisely-queried data immediately. |
|
335 | + */ |
|
336 | 336 | $data = $this->datas; |
337 | 337 | |
338 | 338 | /** |
339 | - * REQUIRED for pagination. Let's figure out what page the user is currently |
|
340 | - * looking at. We'll need this later, so you should always include it in |
|
341 | - * your own package classes. |
|
342 | - */ |
|
339 | + * REQUIRED for pagination. Let's figure out what page the user is currently |
|
340 | + * looking at. We'll need this later, so you should always include it in |
|
341 | + * your own package classes. |
|
342 | + */ |
|
343 | 343 | $current_page = $this->get_pagenum(); |
344 | 344 | |
345 | 345 | /** |
346 | - * REQUIRED for pagination. Let's check how many items are in our data array. |
|
347 | - * In real-world use, this would be the total number of items in your database, |
|
348 | - * without filtering. We'll need this later, so you should always include it |
|
349 | - * in your own package classes. |
|
350 | - */ |
|
346 | + * REQUIRED for pagination. Let's check how many items are in our data array. |
|
347 | + * In real-world use, this would be the total number of items in your database, |
|
348 | + * without filtering. We'll need this later, so you should always include it |
|
349 | + * in your own package classes. |
|
350 | + */ |
|
351 | 351 | $total_items = count($data); |
352 | 352 | |
353 | 353 | /** |
354 | - * The WP_List_Table class does not handle pagination for us, so we need |
|
355 | - * to ensure that the data is trimmed to only the current page. We can use |
|
356 | - * array_slice() to |
|
357 | - */ |
|
354 | + * The WP_List_Table class does not handle pagination for us, so we need |
|
355 | + * to ensure that the data is trimmed to only the current page. We can use |
|
356 | + * array_slice() to |
|
357 | + */ |
|
358 | 358 | $data = array_slice($data,(($current_page-1)*$per_page),$per_page); |
359 | 359 | |
360 | 360 | /** |
361 | - * REQUIRED. Now we can add our *sorted* data to the items property, where |
|
362 | - * it can be used by the rest of the class. |
|
363 | - */ |
|
361 | + * REQUIRED. Now we can add our *sorted* data to the items property, where |
|
362 | + * it can be used by the rest of the class. |
|
363 | + */ |
|
364 | 364 | $this->items = $data; |
365 | 365 | |
366 | 366 | /** |
367 | - * REQUIRED. We also have to register our pagination options & calculations. |
|
368 | - */ |
|
367 | + * REQUIRED. We also have to register our pagination options & calculations. |
|
368 | + */ |
|
369 | 369 | $this->set_pagination_args( array( |
370 | 370 | 'total_items' => $total_items, //WE have to calculate the total number of items |
371 | 371 | 'per_page' => $per_page, //WE have to determine how many items to show on a page |
@@ -1,8 +1,8 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /* Check if file is include. No direct access possible with file url */ |
4 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
5 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
4 | +if (!defined('WPSHOP_VERSION')) { |
|
5 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @package wpshop |
12 | 12 | * @subpackage librairies |
13 | 13 | */ |
14 | -class wpshop_attributes_set_custom_List_table extends WP_List_Table{ |
|
14 | +class wpshop_attributes_set_custom_List_table extends WP_List_Table { |
|
15 | 15 | |
16 | 16 | var $datas; |
17 | 17 | |
@@ -19,26 +19,26 @@ discard block |
||
19 | 19 | * REQUIRED. Set up a constructor that references the parent constructor. We |
20 | 20 | * use the parent reference to set some default configs. |
21 | 21 | ***************************************************************************/ |
22 | - function __construct(){ |
|
22 | + function __construct() { |
|
23 | 23 | global $status, $page; |
24 | 24 | |
25 | 25 | //Set parent defaults |
26 | - parent::__construct( array( |
|
27 | - 'singular' => __('attribute\'s set', 'wpshop'), //singular name of the listed records |
|
28 | - 'plural' => __('attributes\' set', 'wpshop'), //plural name of the listed records |
|
26 | + parent::__construct(array( |
|
27 | + 'singular' => __('attribute\'s set', 'wpshop'), //singular name of the listed records |
|
28 | + 'plural' => __('attributes\' set', 'wpshop'), //plural name of the listed records |
|
29 | 29 | 'ajax' => true //does this table support ajax? |
30 | - ) ); |
|
30 | + )); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /* Allows to set different listings for attributes */ |
34 | - function get_views(){ |
|
34 | + function get_views() { |
|
35 | 35 | $wpshop_attribute_links = array(); |
36 | 36 | |
37 | 37 | $active_nb = wpshop_attributes_set::getElement('', "'moderated','valid'"); |
38 | 38 | $deleted_nb = wpshop_attributes_set::getElement('', "'deleted'"); |
39 | 39 | |
40 | - $wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_valid'.(empty($_REQUEST['attribute_groups_status'])?' current':'')] = '<a href="'.admin_url('admin.php?page='.wpshop_attributes_set::getEditionSlug()).'" >'.__('Attribute groups', 'wpshop').' ('.count($active_nb).')</a>'; |
|
41 | - $wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_deleted'.(!empty($_REQUEST['attribute_groups_status']) && ($_REQUEST['attribute_groups_status']=='deleted')?' current':'')] = '<a href="'.admin_url('admin.php?page='.wpshop_attributes_set::getEditionSlug().'&attribute_groups_status=deleted').'" >'.__('Trashed attribute groups', 'wpshop').' ('.count($deleted_nb).')</a>'; |
|
40 | + $wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_valid' . (empty($_REQUEST['attribute_groups_status']) ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . wpshop_attributes_set::getEditionSlug()) . '" >' . __('Attribute groups', 'wpshop') . ' (' . count($active_nb) . ')</a>'; |
|
41 | + $wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_deleted' . (!empty($_REQUEST['attribute_groups_status']) && ($_REQUEST['attribute_groups_status'] == 'deleted') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . wpshop_attributes_set::getEditionSlug() . '&attribute_groups_status=deleted') . '" >' . __('Trashed attribute groups', 'wpshop') . ' (' . count($deleted_nb) . ')</a>'; |
|
42 | 42 | |
43 | 43 | return $wpshop_attribute_links; |
44 | 44 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @see WP_List_Table::::single_row_columns() |
57 | 57 | * @return array An associative array containing column information: 'slugs'=>'Visible Titles' |
58 | 58 | **************************************************************************/ |
59 | - function get_columns(){ |
|
59 | + function get_columns() { |
|
60 | 60 | $columns = array( |
61 | - 'cb' => '',//'<input type="checkbox" />', //Render a checkbox instead of text |
|
61 | + 'cb' => '', //'<input type="checkbox" />', //Render a checkbox instead of text |
|
62 | 62 | 'id' => 'Id.', |
63 | 63 | 'name' => 'Nom', |
64 | 64 | 'status' => 'Statut', |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * @param array $column_name The name/slug of the column to be processed |
90 | 90 | * @return string Text or HTML to be placed inside the column <td> |
91 | 91 | **************************************************************************/ |
92 | - function column_default($item, $column_name){ |
|
93 | - switch($column_name){ |
|
92 | + function column_default($item, $column_name) { |
|
93 | + switch ($column_name) { |
|
94 | 94 | default: |
95 | - return print_r($item,true); //Show the whole array for troubleshooting purposes |
|
95 | + return print_r($item, true); //Show the whole array for troubleshooting purposes |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param array $item A singular item (one full row's worth of data) |
113 | 113 | * @return string Text to be placed inside the column <td> (movie title only) |
114 | 114 | **************************************************************************/ |
115 | - function column_id($item){ |
|
115 | + function column_id($item) { |
|
116 | 116 | return $item['id']; |
117 | 117 | } |
118 | 118 | /** ************************************************************************ |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param array $item A singular item (one full row's worth of data) |
132 | 132 | * @return string Text to be placed inside the column <td> (movie title only) |
133 | 133 | **************************************************************************/ |
134 | - function column_status($item){ |
|
134 | + function column_status($item) { |
|
135 | 135 | return __($item['status'], 'wpshop'); |
136 | 136 | } |
137 | 137 | /** ************************************************************************ |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @param array $item A singular item (one full row's worth of data) |
151 | 151 | * @return string Text to be placed inside the column <td> (movie title only) |
152 | 152 | **************************************************************************/ |
153 | - function column_content($item){ |
|
153 | + function column_content($item) { |
|
154 | 154 | return $item['content']; |
155 | 155 | } |
156 | 156 | /** ************************************************************************ |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * @param array $item A singular item (one full row's worth of data) |
170 | 170 | * @return string Text to be placed inside the column <td> (movie title only) |
171 | 171 | **************************************************************************/ |
172 | - function column_entity($item){ |
|
173 | - return __($item['entity'],'wpshop'); |
|
172 | + function column_entity($item) { |
|
173 | + return __($item['entity'], 'wpshop'); |
|
174 | 174 | } |
175 | 175 | /** ************************************************************************ |
176 | 176 | * Recommended. This is a custom column method and is responsible for what |
@@ -188,22 +188,22 @@ discard block |
||
188 | 188 | * @param array $item A singular item (one full row's worth of data) |
189 | 189 | * @return string Text to be placed inside the column <td> (movie title only) |
190 | 190 | **************************************************************************/ |
191 | - function column_name($item){ |
|
191 | + function column_name($item) { |
|
192 | 192 | //Build row actions |
193 | - $default_action='edit'; |
|
194 | - $default_action_text=__('Edit', 'wpshop'); |
|
195 | - if(!empty($_REQUEST['attribute_groups_status']) && ($_REQUEST['attribute_groups_status']=='deleted')){ |
|
196 | - $default_action='activate'; |
|
197 | - $default_action_text=__('Restore', 'wpshop'); |
|
193 | + $default_action = 'edit'; |
|
194 | + $default_action_text = __('Edit', 'wpshop'); |
|
195 | + if (!empty($_REQUEST['attribute_groups_status']) && ($_REQUEST['attribute_groups_status'] == 'deleted')) { |
|
196 | + $default_action = 'activate'; |
|
197 | + $default_action_text = __('Restore', 'wpshop'); |
|
198 | 198 | } |
199 | - $actions['edit']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,$default_action,$item['id']); |
|
199 | + $actions['edit'] = sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&action=%3$s&id=%4$s">' . $default_action_text . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, $default_action, $item['id']); |
|
200 | 200 | |
201 | 201 | if (empty($_REQUEST['attribute_groups_status'])) |
202 | - $actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']); |
|
202 | + $actions['delete'] = sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&action=%3$s&id=%4$s">' . __('Delete', 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, 'delete', $item['id']); |
|
203 | 203 | |
204 | 204 | //Return the title contents |
205 | 205 | return sprintf('%1$s%2$s', |
206 | - /*$1%s*/ sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.__($item['name'], 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'edit',$item['id']), |
|
206 | + /*$1%s*/ sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&action=%3$s&id=%4$s">' . __($item['name'], 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, 'edit', $item['id']), |
|
207 | 207 | /*$3%s*/ $this->row_actions($actions) |
208 | 208 | ); |
209 | 209 | } |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | * @param array $item A singular item (one full row's worth of data) |
217 | 217 | * @return string Text to be placed inside the column <td> (movie title only) |
218 | 218 | **************************************************************************/ |
219 | - function column_cb($item){ |
|
219 | + function column_cb($item) { |
|
220 | 220 | return ''; |
221 | 221 | return sprintf( |
222 | 222 | '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
223 | - /*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie") |
|
223 | + /*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie") |
|
224 | 224 | /*$2%s*/ $item['id'] //The value of the checkbox should be the record's id |
225 | 225 | ); |
226 | 226 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | **************************************************************************/ |
277 | 277 | function process_bulk_action() { |
278 | 278 | //Detect when a bulk action is being triggered... |
279 | - if( 'delete'===$this->current_action() ) { |
|
279 | + if ('delete' === $this->current_action()) { |
|
280 | 280 | wp_die('Items deleted (or they would be if we had items to delete)!'); |
281 | 281 | } |
282 | 282 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * to ensure that the data is trimmed to only the current page. We can use |
356 | 356 | * array_slice() to |
357 | 357 | */ |
358 | - $data = array_slice($data,(($current_page-1)*$per_page),$per_page); |
|
358 | + $data = array_slice($data, (($current_page - 1) * $per_page), $per_page); |
|
359 | 359 | |
360 | 360 | /** |
361 | 361 | * REQUIRED. Now we can add our *sorted* data to the items property, where |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | /** |
367 | 367 | * REQUIRED. We also have to register our pagination options & calculations. |
368 | 368 | */ |
369 | - $this->set_pagination_args( array( |
|
370 | - 'total_items' => $total_items, //WE have to calculate the total number of items |
|
371 | - 'per_page' => $per_page, //WE have to determine how many items to show on a page |
|
372 | - 'total_pages' => ceil($total_items/$per_page) //WE have to calculate the total number of pages |
|
373 | - ) ); |
|
369 | + $this->set_pagination_args(array( |
|
370 | + 'total_items' => $total_items, //WE have to calculate the total number of items |
|
371 | + 'per_page' => $per_page, //WE have to determine how many items to show on a page |
|
372 | + 'total_pages' => ceil($total_items / $per_page) //WE have to calculate the total number of pages |
|
373 | + )); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /* Check if file is include. No direct access possible with file url */ |
4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -198,8 +200,9 @@ discard block |
||
198 | 200 | } |
199 | 201 | $actions['edit']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,$default_action,$item['id']); |
200 | 202 | |
201 | - if (empty($_REQUEST['attribute_groups_status'])) |
|
202 | - $actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']); |
|
203 | + if (empty($_REQUEST['attribute_groups_status'])) { |
|
204 | + $actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']); |
|
205 | + } |
|
203 | 206 | |
204 | 207 | //Return the title contents |
205 | 208 | return sprintf('%1$s%2$s', |