@@ -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 | } |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Define utilities to manage entities |
| 4 | 6 | * |
@@ -213,8 +215,7 @@ discard block |
||
| 213 | 215 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 214 | 216 | if ( !empty($current_entity_params['display_admin_menu']) ) { |
| 215 | 217 | $show_in_menu = WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES; |
| 216 | - } |
|
| 217 | - else { |
|
| 218 | + } else { |
|
| 218 | 219 | $show_in_menu = false; |
| 219 | 220 | } |
| 220 | 221 | $post_type_params = array( |
@@ -328,15 +329,15 @@ discard block |
||
| 328 | 329 | foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
| 329 | 330 | if (!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='movable-tab')) { |
| 330 | 331 | add_meta_box($post->post_type . '_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'default', array('currentTabContent' => $currentTabContent['boxContent'][$boxIdentifier])); |
| 332 | + } else { |
|
| 333 | + $fixed_box_exist = true; |
|
| 331 | 334 | } |
| 332 | - else $fixed_box_exist = true; |
|
| 333 | 335 | } |
| 334 | 336 | } |
| 335 | 337 | if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) { |
| 336 | 338 | add_meta_box($post->post_type . '_fixed_tab', __('Informations', 'wpshop'), array('wpshop_entities', 'meta_box_content_datas'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
| 337 | 339 | } |
| 338 | - } |
|
| 339 | - elseif (count($attribute_set_list) > 1) { |
|
| 340 | + } elseif (count($attribute_set_list) > 1) { |
|
| 340 | 341 | $input_def['id'] = $post->post_type.'_attribute_set_id'; |
| 341 | 342 | $input_def['name'] = $post->post_type.'_attribute_set_id'; |
| 342 | 343 | $input_def['value'] = ''; |
@@ -485,8 +486,7 @@ discard block |
||
| 485 | 486 | if( !empty( $current_id ) ) { |
| 486 | 487 | update_post_meta ($_REQUEST['post_ID'], '_wpshop_attached_address', $current_id); |
| 487 | 488 | } |
| 488 | - } |
|
| 489 | - else { |
|
| 489 | + } else { |
|
| 490 | 490 | $current_id = array(); |
| 491 | 491 | if ( !empty ($_REQUEST['address_type']) ) { |
| 492 | 492 | foreach ( $_REQUEST['address_type'] as $key=>$value ) { |
@@ -606,8 +606,7 @@ discard block |
||
| 606 | 606 | $new_element_link = '<a class="wpshop_cls wpshop_duplicate_entity_element_link" href="' . admin_url('post.php?post=' . $last_post . '&action=edit') . '" >' . __('Go on the new element edit page', 'wpshop') . '</a>'; |
| 607 | 607 | if ( $meta_creation ) { |
| 608 | 608 | return array('true', '<br/>' . $new_element_link, $last_post ); |
| 609 | - } |
|
| 610 | - else { |
|
| 609 | + } else { |
|
| 611 | 610 | return array('true', '<br/>' . __('Some errors occured while duplicating meta information, but element has been created.', 'wpshop') . ' ' . $new_element_link); |
| 612 | 611 | } |
| 613 | 612 | } |
@@ -673,18 +672,21 @@ discard block |
||
| 673 | 672 | $column_content = get_the_post_thumbnail( $post_id, 'thumbnail'); |
| 674 | 673 | break; |
| 675 | 674 | case "product_stock": |
| 676 | - if( !empty($product['product_stock']) ) |
|
| 677 | - $column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop'); |
|
| 675 | + if( !empty($product['product_stock']) ) { |
|
| 676 | + $column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop'); |
|
| 677 | + } |
|
| 678 | 678 | break; |
| 679 | 679 | |
| 680 | 680 | case "product_price": |
| 681 | - if( !empty($product['product_price']) ) |
|
| 682 | - $column_content = wpshop_prices::get_product_price( $product, 'price_display', 'complete_sheet'); |
|
| 681 | + if( !empty($product['product_price']) ) { |
|
| 682 | + $column_content = wpshop_prices::get_product_price( $product, 'price_display', 'complete_sheet'); |
|
| 683 | + } |
|
| 683 | 684 | break; |
| 684 | 685 | |
| 685 | 686 | case "tx_tva": |
| 686 | - if( !empty($product['product_price']) ) |
|
| 687 | - $column_content = number_format($product[$column],2,'.', ' ').' %'; |
|
| 687 | + if( !empty($product['product_price']) ) { |
|
| 688 | + $column_content = number_format($product[$column],2,'.', ' ').' %'; |
|
| 689 | + } |
|
| 688 | 690 | break; |
| 689 | 691 | default: |
| 690 | 692 | if ( !empty($product[$column]) ) { |
@@ -692,9 +694,9 @@ discard block |
||
| 692 | 694 | if ( in_array($column, $attribute_prices) ) { |
| 693 | 695 | $column_content = number_format($product[$column],2,'.', ' ').' '.wpshop_tools::wpshop_get_currency(); |
| 694 | 696 | |
| 697 | + } else { |
|
| 698 | + $column_content = $product[$column]; |
|
| 695 | 699 | } |
| 696 | - else |
|
| 697 | - $column_content = $product[$column]; |
|
| 698 | 700 | } |
| 699 | 701 | break; |
| 700 | 702 | } |
@@ -727,15 +729,13 @@ discard block |
||
| 727 | 729 | |
| 728 | 730 | if ( empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type']) ) { |
| 729 | 731 | $output = __('This form page is invalid because no set or type or content is defined. Please contact administrator with this error message', 'wpshop'); |
| 730 | - } |
|
| 731 | - else { |
|
| 732 | + } else { |
|
| 732 | 733 | $entity_identifier = wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']); |
| 733 | 734 | $attribute_set_def = wpshop_attributes_set::getElement($shortcode_args['attribute_set_id'], "'valid'"); |
| 734 | 735 | |
| 735 | 736 | if ( empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id) ) { |
| 736 | 737 | $output = __('This form page is invalid because type and set are not linked. Please contact administrator with this error message', 'wpshop'); |
| 737 | - } |
|
| 738 | - else { |
|
| 738 | + } else { |
|
| 739 | 739 | /** Display wordpress fields */ |
| 740 | 740 | foreach ( explode(', ', $shortcode_args['fields']) as $field_name ) { |
| 741 | 741 | $label = ''; |
@@ -842,8 +842,7 @@ discard block |
||
| 842 | 842 | $tpl_component['DIALOG_BOX'] = ''; |
| 843 | 843 | $output = wpshop_display::display_template_element($template_part, $tpl_component, array(), 'wpshop'); |
| 844 | 844 | echo $output; |
| 845 | - } |
|
| 846 | - else { |
|
| 845 | + } else { |
|
| 847 | 846 | echo $wpshop_account->display_login_form(); |
| 848 | 847 | } |
| 849 | 848 | } |
@@ -882,8 +881,7 @@ discard block |
||
| 882 | 881 | /** Update the attribute set id for the current product */ |
| 883 | 882 | if ( !empty($extra_params['attribute_set_id']) ) { |
| 884 | 883 | $attribute_set_id = $extra_params['attribute_set_id']; |
| 885 | - } |
|
| 886 | - else { |
|
| 884 | + } else { |
|
| 887 | 885 | $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE status = %s AND entity_id = %d AND default_set = %s", 'valid', wpshop_entities::get_entity_identifier_from_code($entity_type) , 'yes'); |
| 888 | 886 | $attribute_set_id = $wpdb->get_var($query); |
| 889 | 887 | } |
@@ -936,12 +934,10 @@ discard block |
||
| 936 | 934 | if ( $field_name == 'post_name' ) { |
| 937 | 935 | $db_datas_definition[] = $identifier; |
| 938 | 936 | $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
| 939 | - } |
|
| 940 | - else if ( $field_default_value == 'mandatory' ) { |
|
| 937 | + } else if ( $field_default_value == 'mandatory' ) { |
|
| 941 | 938 | $has_error = true; |
| 942 | 939 | $errors[] = $field_name; |
| 943 | - } |
|
| 944 | - else { |
|
| 940 | + } else { |
|
| 945 | 941 | $db_datas_definition[] = $field_default_value; |
| 946 | 942 | $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
| 947 | 943 | } |
@@ -951,8 +947,7 @@ discard block |
||
| 951 | 947 | if ( $has_error ) { |
| 952 | 948 | $result = false; |
| 953 | 949 | $output = sprintf( __('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors) ); |
| 954 | - } |
|
| 955 | - else { |
|
| 950 | + } else { |
|
| 956 | 951 | $custom_post_type_def = array(); |
| 957 | 952 | foreach ( $db_field_definition as $field_position => $field_name ) { |
| 958 | 953 | $custom_post_type_def['post_' . $field_name] = $db_datas_definition[$field_position]; |
@@ -994,8 +989,7 @@ discard block |
||
| 994 | 989 | $attributes_for_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, $tpl_component, $has_error ); |
| 995 | 990 | $has_error = $attributes_for_cpt[0]; |
| 996 | 991 | $tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = $attributes_for_cpt[1]; |
| 997 | - } |
|
| 998 | - else { |
|
| 992 | + } else { |
|
| 999 | 993 | $tpl_component['CUSTOM_POST_TYPE_IDENTIFIER'] = '<img class="wpshop_tools_check_icon error" src="' . WPSHOP_MEDIAS_ICON_URL . 'informations/error_s.png" /> ' . $identifier; |
| 1000 | 994 | $tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER_CLASS'] = ' error'; |
| 1001 | 995 | $template_part = 'wpshop_admin_tools_default_datas_check_main_element_content_error'; |
@@ -1033,8 +1027,7 @@ discard block |
||
| 1033 | 1027 | if ( $column_value == 'code' ) { |
| 1034 | 1028 | $code_column = $column_key; |
| 1035 | 1029 | // $available_columns[$column_value] = $column_key; |
| 1036 | - } |
|
| 1037 | - else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) { |
|
| 1030 | + } else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) { |
|
| 1038 | 1031 | $available_columns[$column_value] = $column_key; |
| 1039 | 1032 | } |
| 1040 | 1033 | } |
@@ -1050,8 +1043,7 @@ discard block |
||
| 1050 | 1043 | if ( in_array( $line_column, $available_columns ) ) { |
| 1051 | 1044 | if ( !empty($attribute) ) { |
| 1052 | 1045 | $attribute_ok .= $attribute->frontend_label . ', '; |
| 1053 | - } |
|
| 1054 | - else { |
|
| 1046 | + } else { |
|
| 1055 | 1047 | $attribute_not_ok .= $line_column_value . ', '; |
| 1056 | 1048 | $has_error = true; |
| 1057 | 1049 | } |
@@ -1122,8 +1114,7 @@ discard block |
||
| 1122 | 1114 | break; |
| 1123 | 1115 | } |
| 1124 | 1116 | $attribute_def[$column_name] = ( !empty($attribute_definition[$column_index]) ) ? $column_value : ''; |
| 1125 | - } |
|
| 1126 | - else { |
|
| 1117 | + } else { |
|
| 1127 | 1118 | switch ( $column_name ) { |
| 1128 | 1119 | case 'available_values': |
| 1129 | 1120 | $attribute_values = $attribute_definition[$column_index]; |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | 'exclude_from_search' => true, |
| 54 | 54 | 'capabilities' => array( |
| 55 | 55 | 'edit_post' => 'wpshop_view_dashboard', |
| 56 | - 'edit_posts' => 'wpshop_view_dashboard', |
|
| 57 | - 'edit_others_posts' => 'wpshop_view_dashboard', |
|
| 58 | - 'publish_posts' => 'wpshop_view_dashboard', |
|
| 59 | - 'read_post' => 'wpshop_view_dashboard', |
|
| 60 | - 'read_private_posts' => 'wpshop_view_dashboard', |
|
| 56 | + 'edit_posts' => 'wpshop_view_dashboard', |
|
| 57 | + 'edit_others_posts' => 'wpshop_view_dashboard', |
|
| 58 | + 'publish_posts' => 'wpshop_view_dashboard', |
|
| 59 | + 'read_post' => 'wpshop_view_dashboard', |
|
| 60 | + 'read_private_posts' => 'wpshop_view_dashboard', |
|
| 61 | 61 | 'delete_posts' => 'delete_product' |
| 62 | 62 | ), |
| 63 | 63 | )); |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | * Save informations for current entity |
| 422 | 422 | */ |
| 423 | 423 | public static function save_entities_custom_informations( $post_id ) { |
| 424 | - global $wpdb, $wpshop_account; |
|
| 424 | + global $wpdb, $wpshop_account; |
|
| 425 | 425 | |
| 426 | 426 | $edit_other_thing = !empty( $_POST['edit_other_thing'] ) ? (int) $_POST['edit_other_thing'] : 0; |
| 427 | 427 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Define utilities to manage entities |
| 4 | 4 | * |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | /* |
| 12 | 12 | * Check if file is include. No direct access possible with file url |
| 13 | 13 | */ |
| 14 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 15 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 14 | +if (!defined('WPSHOP_VERSION')) { |
|
| 15 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -31,20 +31,20 @@ discard block |
||
| 31 | 31 | public static function create_wpshop_entities_type() { |
| 32 | 32 | register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, array( |
| 33 | 33 | 'labels' => array( |
| 34 | - 'name' => __( 'Entities', 'wpshop' ), |
|
| 35 | - 'singular_name' => __( 'Entity', 'wpshop' ), |
|
| 36 | - 'add_new_item' => __( 'Add new entity', 'wpshop' ), |
|
| 37 | - 'add_new' => __( 'Add new entity', 'wpshop' ), |
|
| 38 | - 'add_new_item' => __( 'Add new entity', 'wpshop' ), |
|
| 39 | - 'edit_item' => __( 'Edit entity', 'wpshop' ), |
|
| 40 | - 'new_item' => __( 'New entity', 'wpshop' ), |
|
| 41 | - 'view_item' => __( 'View entity', 'wpshop' ), |
|
| 42 | - 'search_items' => __( 'Search entities', 'wpshop' ), |
|
| 43 | - 'not_found' => __( 'No entities found', 'wpshop' ), |
|
| 44 | - 'not_found_in_trash' => __( 'No entities found in Trash', 'wpshop' ), |
|
| 34 | + 'name' => __('Entities', 'wpshop'), |
|
| 35 | + 'singular_name' => __('Entity', 'wpshop'), |
|
| 36 | + 'add_new_item' => __('Add new entity', 'wpshop'), |
|
| 37 | + 'add_new' => __('Add new entity', 'wpshop'), |
|
| 38 | + 'add_new_item' => __('Add new entity', 'wpshop'), |
|
| 39 | + 'edit_item' => __('Edit entity', 'wpshop'), |
|
| 40 | + 'new_item' => __('New entity', 'wpshop'), |
|
| 41 | + 'view_item' => __('View entity', 'wpshop'), |
|
| 42 | + 'search_items' => __('Search entities', 'wpshop'), |
|
| 43 | + 'not_found' => __('No entities found', 'wpshop'), |
|
| 44 | + 'not_found_in_trash' => __('No entities found in Trash', 'wpshop'), |
|
| 45 | 45 | 'parent_item_colon' => '', |
| 46 | 46 | ), |
| 47 | - 'supports' => array( 'title', 'editor', 'page-attributes' ), |
|
| 47 | + 'supports' => array('title', 'editor', 'page-attributes'), |
|
| 48 | 48 | 'public' => true, |
| 49 | 49 | 'has_archive' => true, |
| 50 | 50 | 'publicly_queryable' => false, |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | /** Metabox allowgin to choose a custome rewrite for an entiy */ |
| 75 | 75 | add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_rewrite', __('Rewrite for entity', 'wpshop'), array('wpshop_entities', 'wpshop_entity_rewrite'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'normal', 'high'); |
| 76 | 76 | |
| 77 | - if ( !in_array( $post->post_name, unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES ) ) ) { |
|
| 77 | + if (!in_array($post->post_name, unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES))) { |
|
| 78 | 78 | /** Display or not address in admin menu */ |
| 79 | 79 | add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_admin_menu_display', __('Display in admin menu', 'wpshop'), array('wpshop_entities', 'wpshop_display_entity_in_admin_menu'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'side', 'low'); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** Join address to entity */ |
| 83 | - if ( !in_array( $post->post_name, array( WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) ) ) { |
|
| 83 | + if (!in_array($post->post_name, array(WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS))) { |
|
| 84 | 84 | add_meta_box(WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES . '_join_address_to_entity', __('Join Address to this entity', 'wpshop'), array('wpshop_entities', 'wpshop_join_address_to_entity'), WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, 'side', 'low'); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -90,24 +90,24 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param object $post The entity type being edited |
| 92 | 92 | */ |
| 93 | - public static function wpshop_entity_support_section( $entity ) { |
|
| 93 | + public static function wpshop_entity_support_section($entity) { |
|
| 94 | 94 | $output = ''; |
| 95 | 95 | $support_list = unserialize(WPSHOP_REGISTER_POST_TYPE_SUPPORT); |
| 96 | 96 | |
| 97 | 97 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 98 | 98 | |
| 99 | - unset($input_def);$input_def=array(); |
|
| 99 | + unset($input_def); $input_def = array(); |
|
| 100 | 100 | $input_def['type'] = 'checkbox'; |
| 101 | 101 | |
| 102 | - foreach ( $support_list as $support ) { |
|
| 102 | + foreach ($support_list as $support) { |
|
| 103 | 103 | $input_def['id'] = 'wpshop_entity_support'; |
| 104 | 104 | $input_def['name'] = $support; |
| 105 | 105 | $input_def['possible_value'] = array($support); |
| 106 | - if ( !empty($current_entity_params['support']) && in_array($support, $current_entity_params['support']) ) { |
|
| 106 | + if (!empty($current_entity_params['support']) && in_array($support, $current_entity_params['support'])) { |
|
| 107 | 107 | $input_def['value'] = $support; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $output .= '<p class="wpshop_entities_support_type wpshop_entities_support_type_' . $support . '" >' . wpshop_form::check_input_type($input_def, 'wpshop_entity_support') . ' <label for="'.$input_def['id'].'_'.$support.'">' . __($support, 'wpshop') . '</label></p>'; |
|
| 110 | + $output .= '<p class="wpshop_entities_support_type wpshop_entities_support_type_' . $support . '" >' . wpshop_form::check_input_type($input_def, 'wpshop_entity_support') . ' <label for="' . $input_def['id'] . '_' . $support . '">' . __($support, 'wpshop') . '</label></p>'; |
|
| 111 | 111 | } |
| 112 | 112 | $output .= '<p class="wpshop_cls" ></p>'; |
| 113 | 113 | |
@@ -119,33 +119,33 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @param unknown_type $entity |
| 121 | 121 | */ |
| 122 | - public static function wpshop_entity_rewrite( $entity ) { |
|
| 122 | + public static function wpshop_entity_rewrite($entity) { |
|
| 123 | 123 | $output = ''; |
| 124 | 124 | |
| 125 | 125 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 126 | 126 | |
| 127 | - unset($input_def);$input_def=array(); |
|
| 127 | + unset($input_def); $input_def = array(); |
|
| 128 | 128 | $input_def['type'] = 'text'; |
| 129 | 129 | $input_def['id'] = 'wpshop_entity_rewrite'; |
| 130 | 130 | $input_def['name'] = 'wpshop_entity_rewrite[slug]'; |
| 131 | - $input_def['value'] = (!empty($current_entity_params['rewrite']['slug']) ? $current_entity_params['rewrite']['slug'] :''); |
|
| 131 | + $input_def['value'] = (!empty($current_entity_params['rewrite']['slug']) ? $current_entity_params['rewrite']['slug'] : ''); |
|
| 132 | 132 | |
| 133 | - $output .= '<p><label for="'.$input_def['id'].'">' . __('Choose how this entity will be rewrite in front side. If you let it empty default will be taken', 'wpshop') . '</label><br/>' . wpshop_form::check_input_type($input_def) . '</p>'; |
|
| 133 | + $output .= '<p><label for="' . $input_def['id'] . '">' . __('Choose how this entity will be rewrite in front side. If you let it empty default will be taken', 'wpshop') . '</label><br/>' . wpshop_form::check_input_type($input_def) . '</p>'; |
|
| 134 | 134 | |
| 135 | 135 | echo $output; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | public static function wpshop_display_entity_in_admin_menu() { |
| 139 | 139 | $checked = ''; |
| 140 | - $post = !empty( $_GET['post'] ) ? (int) $_GET['post'] : 0; |
|
| 141 | - if ( !empty($post) ) { |
|
| 142 | - $current_entity_params = get_post_meta( $post, '_wpshop_entity_params', true); |
|
| 140 | + $post = !empty($_GET['post']) ? (int)$_GET['post'] : 0; |
|
| 141 | + if (!empty($post)) { |
|
| 142 | + $current_entity_params = get_post_meta($post, '_wpshop_entity_params', true); |
|
| 143 | 143 | |
| 144 | - if ( !empty($current_entity_params['display_admin_menu']) ) { |
|
| 144 | + if (!empty($current_entity_params['display_admin_menu'])) { |
|
| 145 | 145 | $checked = 'checked ="checked"'; |
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | - $output = '<input type="checkbox" id="wpshop_display_in_admin_menu" name="wpshop_display_in_admin_menu" ' .$checked. '/><label for="wpshop_display_in_admin_menu"> '.__('Display in admin menu', 'wpshop').'</label>'; |
|
| 148 | + $output = '<input type="checkbox" id="wpshop_display_in_admin_menu" name="wpshop_display_in_admin_menu" ' . $checked . '/><label for="wpshop_display_in_admin_menu"> ' . __('Display in admin menu', 'wpshop') . '</label>'; |
|
| 149 | 149 | echo $output; |
| 150 | 150 | } |
| 151 | 151 | |
@@ -153,21 +153,21 @@ discard block |
||
| 153 | 153 | * Save custom information for entity type |
| 154 | 154 | */ |
| 155 | 155 | public static function save_entity_type_custom_informations() { |
| 156 | - $post_id = !empty($_POST['post_ID']) ? intval( sanitize_key($_POST['post_ID']) ) : null; |
|
| 157 | - $post_support = !empty($_POST['wpshop_entity_support']) && is_array( (array)$_POST['wpshop_entity_support'] ) ? (array)$_POST['wpshop_entity_support'] : null; |
|
| 158 | - $wpshop_entity_rewrite = !empty($_POST['wpshop_entity_rewrite']) ? (array) $_POST['wpshop_entity_rewrite'] : null; |
|
| 156 | + $post_id = !empty($_POST['post_ID']) ? intval(sanitize_key($_POST['post_ID'])) : null; |
|
| 157 | + $post_support = !empty($_POST['wpshop_entity_support']) && is_array((array)$_POST['wpshop_entity_support']) ? (array)$_POST['wpshop_entity_support'] : null; |
|
| 158 | + $wpshop_entity_rewrite = !empty($_POST['wpshop_entity_rewrite']) ? (array)$_POST['wpshop_entity_rewrite'] : null; |
|
| 159 | 159 | $wpshop_entity_display_menu = !empty($_POST['wpshop_display_in_admin_menu']) ? sanitize_key($_POST['wpshop_display_in_admin_menu']) : null; |
| 160 | 160 | |
| 161 | - $address_type = !empty ($_POST['address_type']) ? (array) $_POST['address_type'] : null; |
|
| 162 | - if ( isset($address_type) ) { |
|
| 161 | + $address_type = !empty ($_POST['address_type']) ? (array)$_POST['address_type'] : null; |
|
| 162 | + if (isset($address_type)) { |
|
| 163 | 163 | $save_array = array(); |
| 164 | - foreach ( $address_type as $key=>$value ) { |
|
| 165 | - $save_array[] = intval( sanitize_text_field($value) ); |
|
| 164 | + foreach ($address_type as $key=>$value) { |
|
| 165 | + $save_array[] = intval(sanitize_text_field($value)); |
|
| 166 | 166 | } |
| 167 | - update_post_meta( $post_id, '_wpshop_entity_attached_address', $save_array ); |
|
| 167 | + update_post_meta($post_id, '_wpshop_entity_attached_address', $save_array); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES ) { |
|
| 170 | + if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) { |
|
| 171 | 171 | update_post_meta($post_id, '_wpshop_entity_params', array('support' => $post_support, 'rewrite' => $wpshop_entity_rewrite, 'display_admin_menu'=>$wpshop_entity_display_menu)); |
| 172 | 172 | flush_rewrite_rules(); |
| 173 | 173 | } |
@@ -176,19 +176,19 @@ discard block |
||
| 176 | 176 | /** |
| 177 | 177 | * Permite to join one or several address to an entity |
| 178 | 178 | */ |
| 179 | - public static function wpshop_join_address_to_entity () { |
|
| 179 | + public static function wpshop_join_address_to_entity() { |
|
| 180 | 180 | global $wpdb; |
| 181 | 181 | // Select the id of the entity address |
| 182 | - $query = $wpdb->prepare('SELECT id FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_name = %s', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS); |
|
| 183 | - $entity_id = $wpdb->get_var( $query ); |
|
| 182 | + $query = $wpdb->prepare('SELECT id FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_name = %s', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS); |
|
| 183 | + $entity_id = $wpdb->get_var($query); |
|
| 184 | 184 | //Get the Post_meta |
| 185 | - $attached_address_values = get_post_meta( intval(wpshop_tools::varSanitizer( (!empty($_GET['post']) ? $_GET['post'] : '') )), '_wpshop_entity_attached_address', true ); |
|
| 185 | + $attached_address_values = get_post_meta(intval(wpshop_tools::varSanitizer((!empty($_GET['post']) ? $_GET['post'] : ''))), '_wpshop_entity_attached_address', true); |
|
| 186 | 186 | //Select and Display all addresses type |
| 187 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $entity_id); |
|
| 188 | - $addresses = $wpdb->get_results( $query); |
|
| 187 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id); |
|
| 188 | + $addresses = $wpdb->get_results($query); |
|
| 189 | 189 | $output = ''; |
| 190 | - foreach ( $addresses as $address ) { |
|
| 191 | - $output .= '<p><input type="checkbox" id="' .$address->name.'_'.$address->id.'" name="address_type[' .$address->name. ']" value="'.$address->id.'" ' .( ( !empty($attached_address_values) && in_array( $address->id, $attached_address_values) ) ? 'checked="checked"' : '' ). ' /> <label for="' .$address->name.'_'.$address->id.'">'.$address->name.'</label></p>'; |
|
| 190 | + foreach ($addresses as $address) { |
|
| 191 | + $output .= '<p><input type="checkbox" id="' . $address->name . '_' . $address->id . '" name="address_type[' . $address->name . ']" value="' . $address->id . '" ' . ((!empty($attached_address_values) && in_array($address->id, $attached_address_values)) ? 'checked="checked"' : '') . ' /> <label for="' . $address->name . '_' . $address->id . '">' . $address->name . '</label></p>'; |
|
| 192 | 192 | } |
| 193 | 193 | echo $output; |
| 194 | 194 | } |
@@ -208,12 +208,12 @@ discard block |
||
| 208 | 208 | /* |
| 209 | 209 | * Read the entity list for custom type declaration |
| 210 | 210 | */ |
| 211 | - if ( !empty($entities) ) { |
|
| 212 | - foreach ( $entities as $entity ) { |
|
| 213 | - $wpshop_builtin_types = unserialize( WPSHOP_DEFAULT_CUSTOM_TYPES ); |
|
| 214 | - if ( !empty( $entity->post_name ) && !in_array( $entity->post_name, $wpshop_builtin_types ) ) { |
|
| 211 | + if (!empty($entities)) { |
|
| 212 | + foreach ($entities as $entity) { |
|
| 213 | + $wpshop_builtin_types = unserialize(WPSHOP_DEFAULT_CUSTOM_TYPES); |
|
| 214 | + if (!empty($entity->post_name) && !in_array($entity->post_name, $wpshop_builtin_types)) { |
|
| 215 | 215 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 216 | - if ( !empty($current_entity_params['display_admin_menu']) ) { |
|
| 216 | + if (!empty($current_entity_params['display_admin_menu'])) { |
|
| 217 | 217 | $show_in_menu = WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES; |
| 218 | 218 | } |
| 219 | 219 | else { |
@@ -221,17 +221,17 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | $post_type_params = array( |
| 223 | 223 | 'labels' => array( |
| 224 | - 'name' => __( $entity->post_title , 'wpshop' ), |
|
| 225 | - 'singular_name' => __( $entity->post_title, 'wpshop' ), |
|
| 226 | - 'add_new_item' => sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title), |
|
| 227 | - 'add_new' => sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title), |
|
| 228 | - 'add_new_item' => sprintf( __( 'Add new %s', 'wpshop' ), $entity->post_title), |
|
| 229 | - 'edit_item' => sprintf( __( 'Edit %s', 'wpshop' ), $entity->post_title), |
|
| 230 | - 'new_item' => sprintf( __( 'New %s', 'wpshop' ), $entity->post_title), |
|
| 231 | - 'view_item' => sprintf( __( 'View %s', 'wpshop' ), $entity->post_title), |
|
| 232 | - 'search_items' => sprintf( __( 'Search %s', 'wpshop' ), $entity->post_title), |
|
| 233 | - 'not_found' => sprintf( __( 'No %s found', 'wpshop' ), $entity->post_title), |
|
| 234 | - 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'wpshop' ), $entity->post_title), |
|
| 224 | + 'name' => __($entity->post_title, 'wpshop'), |
|
| 225 | + 'singular_name' => __($entity->post_title, 'wpshop'), |
|
| 226 | + 'add_new_item' => sprintf(__('Add new %s', 'wpshop'), $entity->post_title), |
|
| 227 | + 'add_new' => sprintf(__('Add new %s', 'wpshop'), $entity->post_title), |
|
| 228 | + 'add_new_item' => sprintf(__('Add new %s', 'wpshop'), $entity->post_title), |
|
| 229 | + 'edit_item' => sprintf(__('Edit %s', 'wpshop'), $entity->post_title), |
|
| 230 | + 'new_item' => sprintf(__('New %s', 'wpshop'), $entity->post_title), |
|
| 231 | + 'view_item' => sprintf(__('View %s', 'wpshop'), $entity->post_title), |
|
| 232 | + 'search_items' => sprintf(__('Search %s', 'wpshop'), $entity->post_title), |
|
| 233 | + 'not_found' => sprintf(__('No %s found', 'wpshop'), $entity->post_title), |
|
| 234 | + 'not_found_in_trash' => sprintf(__('No %s found in Trash', 'wpshop'), $entity->post_title), |
|
| 235 | 235 | 'parent_item_colon' => '', |
| 236 | 236 | ), |
| 237 | 237 | 'description' => $entity->post_content, |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | 'rewrite' => !empty($current_entity_params['rewrite']) ? $current_entity_params['rewrite'] : array(), |
| 246 | 246 | 'hierarchical' => true, |
| 247 | 247 | ); |
| 248 | - register_post_type($entity->post_name, $post_type_params ); |
|
| 248 | + register_post_type($entity->post_name, $post_type_params); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** Add basic metabox */ |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - add_filter( 'map_meta_cap', array('wpshop_entities', 'map_meta_cap'), 10, 4 ); |
|
| 259 | + add_filter('map_meta_cap', array('wpshop_entities', 'map_meta_cap'), 10, 4); |
|
| 260 | 260 | /* |
| 261 | 261 | * Reset query for security reasons |
| 262 | 262 | */ |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | * @param integer $user_id |
| 272 | 272 | * @param array $args |
| 273 | 273 | */ |
| 274 | - public static function map_meta_cap( $caps, $cap, $user_id, $args ) { |
|
| 275 | - if ( !empty($args) ) { |
|
| 274 | + public static function map_meta_cap($caps, $cap, $user_id, $args) { |
|
| 275 | + if (!empty($args)) { |
|
| 276 | 276 | $post = get_post($args[0]); |
| 277 | - if ( false && !empty($post) && is_object($post) && ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) && (($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS)) && ($cap == 'delete_product') ) { |
|
| 277 | + if (false && !empty($post) && is_object($post) && ($post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES) && (($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) || ($post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS)) && ($cap == 'delete_product')) { |
|
| 278 | 278 | $caps = 'wpshop_view_dashboard'; |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | /** |
| 287 | 287 | * Add metaboxes to the custom post types defined by entities |
| 288 | 288 | */ |
| 289 | - public static function add_meta_boxes_to_custom_types( $post ) { |
|
| 289 | + public static function add_meta_boxes_to_custom_types($post) { |
|
| 290 | 290 | global $post, |
| 291 | 291 | $wpdb; |
| 292 | 292 | |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | /* |
| 302 | 302 | * Product are managed from another place |
| 303 | 303 | */ |
| 304 | - if ( $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ) { |
|
| 304 | + if ($post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT) { |
|
| 305 | 305 | /* |
| 306 | 306 | * Get the attribute set list for current entity |
| 307 | 307 | */ |
@@ -312,8 +312,8 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | $attribute_set_id = get_post_meta($post->ID, sprintf(WPSHOP_ATTRIBUTE_SET_ID_META_KEY, $post->post_type), true); |
| 314 | 314 | |
| 315 | - if(((count($attribute_set_list) == 1) || ((count($attribute_set_list) > 1) && !empty($attribute_set_id)))){ |
|
| 316 | - if((count($attribute_set_list) == 1) || empty($attribute_set_id)){ |
|
| 315 | + if (((count($attribute_set_list) == 1) || ((count($attribute_set_list) > 1) && !empty($attribute_set_id)))) { |
|
| 316 | + if ((count($attribute_set_list) == 1) || empty($attribute_set_id)) { |
|
| 317 | 317 | $attribute_set_id = $attribute_set_list[0]->id; |
| 318 | 318 | } |
| 319 | 319 | |
@@ -326,28 +326,28 @@ discard block |
||
| 326 | 326 | /* |
| 327 | 327 | * Read the different element for building output for current entity |
| 328 | 328 | */ |
| 329 | - if ( !empty($currentTabContent['box']) && is_array($currentTabContent['box']) ) { |
|
| 329 | + if (!empty($currentTabContent['box']) && is_array($currentTabContent['box'])) { |
|
| 330 | 330 | foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
| 331 | - if (!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='movable-tab')) { |
|
| 331 | + if (!empty($currentTabContent['box'][$boxIdentifier . '_backend_display_type']) && ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'movable-tab')) { |
|
| 332 | 332 | add_meta_box($post->post_type . '_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'default', array('currentTabContent' => $currentTabContent['boxContent'][$boxIdentifier])); |
| 333 | 333 | } |
| 334 | 334 | else $fixed_box_exist = true; |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | - if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) { |
|
| 337 | + if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) { |
|
| 338 | 338 | add_meta_box($post->post_type . '_fixed_tab', __('Informations', 'wpshop'), array('wpshop_entities', 'meta_box_content_datas'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | elseif (count($attribute_set_list) > 1) { |
| 342 | - $input_def['id'] = $post->post_type.'_attribute_set_id'; |
|
| 343 | - $input_def['name'] = $post->post_type.'_attribute_set_id'; |
|
| 342 | + $input_def['id'] = $post->post_type . '_attribute_set_id'; |
|
| 343 | + $input_def['name'] = $post->post_type . '_attribute_set_id'; |
|
| 344 | 344 | $input_def['value'] = ''; |
| 345 | 345 | $input_def['type'] = 'select'; |
| 346 | 346 | $input_def['possible_value'] = $attribute_set_list; |
| 347 | 347 | |
| 348 | 348 | $input_def['value'] = ''; |
| 349 | 349 | foreach ($attribute_set_list as $set) { |
| 350 | - if( $set->default_set == 'yes' ) { |
|
| 350 | + if ($set->default_set == 'yes') { |
|
| 351 | 351 | $input_def['value'] = $set->id; |
| 352 | 352 | } |
| 353 | 353 | } |
@@ -355,12 +355,12 @@ discard block |
||
| 355 | 355 | $currentTabContent = ' |
| 356 | 356 | <ul class="attribute_set_selector" > |
| 357 | 357 | <li class="attribute_set_selector_title_select" ><label for="title" >' . sprintf(__('Choose a title for the %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label></li> |
| 358 | - <li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . sprintf(__('Choose an attribute group for this %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label> '.wpshop_form::check_input_type($input_def).'</li> |
|
| 358 | + <li class="attribute_set_selector_group_selector" ><label for="' . $input_def['id'] . '" >' . sprintf(__('Choose an attribute group for this %s', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</label> ' . wpshop_form::check_input_type($input_def) . '</li> |
|
| 359 | 359 | <li class="attribute_set_selector_save_instruction" >' . sprintf(__('Save the %s with the "Save draft" button on the right side', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))) . '</li> |
| 360 | 360 | <li class="attribute_set_selector_after_save_instruction" >' . __('Once the group chosen, the different attribute will be displayed here', 'wpshop') . '</li> |
| 361 | 361 | </ul>'; |
| 362 | 362 | |
| 363 | - add_meta_box($post->post_type . '_attribute_set_selector',sprintf( __('%s attributes', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
|
| 363 | + add_meta_box($post->post_type . '_attribute_set_selector', sprintf(__('%s attributes', 'wpshop'), get_the_title(wpshop_entities::get_entity_identifier_from_code($post->post_type))), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | } |
@@ -390,22 +390,22 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | echo '<div id="fixed-tabs" class="wpshop_tabs wpshop_detail_tabs entities_attribute_tabs ' . $post->post_type . '_attribute_tabs" > |
| 392 | 392 | <ul>'; |
| 393 | - if(!empty($currentTabContent['box'])){ |
|
| 394 | - foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){ |
|
| 395 | - if(!empty($currentTabContent['boxContent'][$boxIdentifier])) { |
|
| 396 | - if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') { |
|
| 397 | - echo '<li><a href="#tabs-'.$boxIdentifier.'">'.__($boxTitle, 'wpshop').'</a></li>'; |
|
| 393 | + if (!empty($currentTabContent['box'])) { |
|
| 394 | + foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
|
| 395 | + if (!empty($currentTabContent['boxContent'][$boxIdentifier])) { |
|
| 396 | + if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') { |
|
| 397 | + echo '<li><a href="#tabs-' . $boxIdentifier . '">' . __($boxTitle, 'wpshop') . '</a></li>'; |
|
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | echo '</ul>'; |
| 403 | 403 | |
| 404 | - if(!empty($currentTabContent['box'])){ |
|
| 405 | - foreach($currentTabContent['box'] as $boxIdentifier => $boxTitle){ |
|
| 406 | - if(!empty($currentTabContent['boxContent'][$boxIdentifier])) { |
|
| 407 | - if($currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='fixed-tab') { |
|
| 408 | - echo '<div id="tabs-'.$boxIdentifier.'">'.$currentTabContent['boxContent'][$boxIdentifier].'</div>'; |
|
| 404 | + if (!empty($currentTabContent['box'])) { |
|
| 405 | + foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
|
| 406 | + if (!empty($currentTabContent['boxContent'][$boxIdentifier])) { |
|
| 407 | + if ($currentTabContent['box'][$boxIdentifier . '_backend_display_type'] == 'fixed-tab') { |
|
| 408 | + echo '<div id="tabs-' . $boxIdentifier . '">' . $currentTabContent['boxContent'][$boxIdentifier] . '</div>'; |
|
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | } |
@@ -420,32 +420,32 @@ discard block |
||
| 420 | 420 | /** |
| 421 | 421 | * Save informations for current entity |
| 422 | 422 | */ |
| 423 | - public static function save_entities_custom_informations( $post_id ) { |
|
| 423 | + public static function save_entities_custom_informations($post_id) { |
|
| 424 | 424 | global $wpdb, $wpshop_account; |
| 425 | 425 | |
| 426 | - $edit_other_thing = !empty( $_POST['edit_other_thing'] ) ? (int) $_POST['edit_other_thing'] : 0; |
|
| 426 | + $edit_other_thing = !empty($_POST['edit_other_thing']) ? (int)$_POST['edit_other_thing'] : 0; |
|
| 427 | 427 | |
| 428 | - if ( ( ( !empty($post_id) && empty( $edit_other_thing ) ) || ( !empty($post_id) && !(bool)$edit_other_thing ) ) |
|
| 429 | - && ( get_post_type( $post_id ) != WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) ) { |
|
| 430 | - $current_post_type = get_post_type( $post_id ); |
|
| 431 | - $current_post_type_text = !empty( $_REQUEST[$current_post_type . '_attribute_set_id'] ) ? sanitize_text_field( $_REQUEST[$current_post_type . '_attribute_set_id'] ) : ''; |
|
| 428 | + if (((!empty($post_id) && empty($edit_other_thing)) || (!empty($post_id) && !(bool)$edit_other_thing)) |
|
| 429 | + && (get_post_type($post_id) != WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) { |
|
| 430 | + $current_post_type = get_post_type($post_id); |
|
| 431 | + $current_post_type_text = !empty($_REQUEST[$current_post_type . '_attribute_set_id']) ? sanitize_text_field($_REQUEST[$current_post_type . '_attribute_set_id']) : ''; |
|
| 432 | 432 | /* Vérification de l'existence de l'envoi de l'identifiant du set d'attribut */ |
| 433 | - if ( !empty($current_post_type_text) ) { |
|
| 434 | - $attribute_set_id = intval( $current_post_type_text ); |
|
| 433 | + if (!empty($current_post_type_text)) { |
|
| 434 | + $attribute_set_id = intval($current_post_type_text); |
|
| 435 | 435 | $attribet_set_infos = wpshop_attributes_set::getElement($attribute_set_id, "'valid'", 'id'); |
| 436 | 436 | |
| 437 | - if ( $attribet_set_infos->entity == sanitize_key( $current_post_type ) ) { |
|
| 437 | + if ($attribet_set_infos->entity == sanitize_key($current_post_type)) { |
|
| 438 | 438 | /* Enregistrement de l'identifiant du set d'attribut associé à l'entité */ |
| 439 | 439 | update_post_meta($post_id, sprintf(WPSHOP_ATTRIBUTE_SET_ID_META_KEY, $current_post_type), $attribute_set_id); |
| 440 | 440 | |
| 441 | 441 | /* Enregistrement de tous les attributs */ |
| 442 | 442 | $current_post_type_attributes = !empty($_REQUEST[$current_post_type . '_attribute']) ? (array)$_REQUEST[$current_post_type . '_attribute'] : null; |
| 443 | - if ( isset($current_post_type_attributes) ) { |
|
| 443 | + if (isset($current_post_type_attributes)) { |
|
| 444 | 444 | /* Traduction des virgule en point pour la base de donnees */ |
| 445 | - if ( !empty($current_post_type_attributes['decimal']) ) { |
|
| 446 | - foreach($current_post_type_attributes['decimal'] as $attributeName => $attributeValue){ |
|
| 447 | - if(!is_array($attributeValue)){ |
|
| 448 | - $current_post_type_attributes['decimal'][$attributeName] = str_replace(',','.',$current_post_type_attributes['decimal'][$attributeName]); |
|
| 445 | + if (!empty($current_post_type_attributes['decimal'])) { |
|
| 446 | + foreach ($current_post_type_attributes['decimal'] as $attributeName => $attributeValue) { |
|
| 447 | + if (!is_array($attributeValue)) { |
|
| 448 | + $current_post_type_attributes['decimal'][$attributeName] = str_replace(',', '.', $current_post_type_attributes['decimal'][$attributeName]); |
|
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | 451 | } |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | /* Enregistrement des valeurs des attributs dans les metas de l'entité => Permet de profiter de la recherche native de wordpress */ |
| 456 | 456 | $productMetaDatas = array(); |
| 457 | - foreach ( $current_post_type_attributes as $attributeType => $attributeValues ) { |
|
| 458 | - foreach ( $attributeValues as $attributeCode => $attributeValue ) { |
|
| 457 | + foreach ($current_post_type_attributes as $attributeType => $attributeValues) { |
|
| 458 | + foreach ($attributeValues as $attributeCode => $attributeValue) { |
|
| 459 | 459 | $productMetaDatas[$attributeCode] = $attributeValue; |
| 460 | 460 | } |
| 461 | 461 | } |
@@ -465,42 +465,42 @@ discard block |
||
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - $attribute = !empty($_REQUEST['attribute']) ? (array) $_REQUEST['attribute'] : null; |
|
| 469 | - $post_id = !empty($_REQUEST['post_ID']) ? (int) $_REQUEST['post_ID'] : null; |
|
| 470 | - if ( isset($attribute) ) { |
|
| 468 | + $attribute = !empty($_REQUEST['attribute']) ? (array)$_REQUEST['attribute'] : null; |
|
| 469 | + $post_id = !empty($_REQUEST['post_ID']) ? (int)$_REQUEST['post_ID'] : null; |
|
| 470 | + if (isset($attribute)) { |
|
| 471 | 471 | $current_id = array(); |
| 472 | - foreach ( $attribute as $key=>$values ) { |
|
| 472 | + foreach ($attribute as $key=>$values) { |
|
| 473 | 473 | $ad_id = ''; |
| 474 | 474 | $addresses_id = get_post_meta($post_id, '_wpshop_attached_address', true); |
| 475 | - if ( !empty($addresses_id) ) { |
|
| 476 | - foreach ( $addresses_id as $address_id) { |
|
| 475 | + if (!empty($addresses_id)) { |
|
| 476 | + foreach ($addresses_id as $address_id) { |
|
| 477 | 477 | $address_type = get_post_meta($address_id, '_wpshop_address_attribute_set_id', true); |
| 478 | 478 | if ($address_type == $key) { |
| 479 | 479 | $ad_id = $address_id; |
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | - if( !empty( $ad_id ) ) { |
|
| 483 | + if (!empty($ad_id)) { |
|
| 484 | 484 | // @TODO : REQUEST |
| 485 | 485 | // $_REQUEST['item_id'] = $ad_id; |
| 486 | - $result = wps_address::save_address_infos( $key ); |
|
| 486 | + $result = wps_address::save_address_infos($key); |
|
| 487 | 487 | $current_id[] = $result['current_id']; |
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | - if( !empty( $current_id ) ) { |
|
| 491 | - update_post_meta ($post_id, '_wpshop_attached_address', $current_id); |
|
| 490 | + if (!empty($current_id)) { |
|
| 491 | + update_post_meta($post_id, '_wpshop_attached_address', $current_id); |
|
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | 494 | else { |
| 495 | 495 | $current_id = array(); |
| 496 | 496 | |
| 497 | - $address_type = !empty($_REQUEST['address_type']) ? (array) $_REQUEST['address_type'] : null; |
|
| 498 | - if ( isset($address_type) ) { |
|
| 499 | - foreach ( $address_type as $key=>$value ) { |
|
| 497 | + $address_type = !empty($_REQUEST['address_type']) ? (array)$_REQUEST['address_type'] : null; |
|
| 498 | + if (isset($address_type)) { |
|
| 499 | + foreach ($address_type as $key=>$value) { |
|
| 500 | 500 | $current_id[] = $value; |
| 501 | 501 | } |
| 502 | 502 | } |
| 503 | - update_post_meta ($post_id, '_wpshop_entity_attached_address', $current_id); |
|
| 503 | + update_post_meta($post_id, '_wpshop_entity_attached_address', $current_id); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | 'posts_per_page' => '-1', |
| 524 | 524 | )); |
| 525 | 525 | |
| 526 | - if ( !empty($entities) ) { |
|
| 526 | + if (!empty($entities)) { |
|
| 527 | 527 | foreach ($entities as $entity_index => $entity) { |
| 528 | 528 | $entities_list[$entity->ID] = $entity->post_title; |
| 529 | 529 | } |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | global $wpdb; |
| 561 | 561 | |
| 562 | 562 | /* Get current post information */ |
| 563 | - $post_infos = get_post( $post_id, ARRAY_A ); |
|
| 563 | + $post_infos = get_post($post_id, ARRAY_A); |
|
| 564 | 564 | /* Set new information for post that will be created */ |
| 565 | 565 | unset($post_infos['ID']); |
| 566 | 566 | $post_infos['post_date'] = current_time('mysql', 1); |
@@ -578,18 +578,18 @@ discard block |
||
| 578 | 578 | $last_post = wp_insert_post($post_infos); |
| 579 | 579 | |
| 580 | 580 | /* If there is no error then duplicate meta informations */ |
| 581 | - if ( is_int($last_post) && !empty($last_post) ) { |
|
| 581 | + if (is_int($last_post) && !empty($last_post)) { |
|
| 582 | 582 | $meta_creation = true; |
| 583 | 583 | |
| 584 | 584 | $current_post_meta = get_post_meta($post_id); |
| 585 | - foreach ( $current_post_meta as $post_meta_key => $post_meta_value ) { |
|
| 586 | - $meta_is_array = ( !empty( $post_meta_value[0] ) && wpshop_tools::is_serialized( $post_meta_value[0] ) ) ? unserialize( $post_meta_value[0] ) : ''; |
|
| 585 | + foreach ($current_post_meta as $post_meta_key => $post_meta_value) { |
|
| 586 | + $meta_is_array = (!empty($post_meta_value[0]) && wpshop_tools::is_serialized($post_meta_value[0])) ? unserialize($post_meta_value[0]) : ''; |
|
| 587 | 587 | $meta_real_value = (is_array($meta_is_array) ? $meta_is_array : $post_meta_value[0]); |
| 588 | 588 | $meta_creation = update_post_meta($last_post, $post_meta_key, $meta_real_value); |
| 589 | 589 | } |
| 590 | 590 | /* Duplicate element taxonomy */ |
| 591 | 591 | /* Check the taxonomy to get */ |
| 592 | - switch ( get_post_type($post_id) ) { |
|
| 592 | + switch (get_post_type($post_id)) { |
|
| 593 | 593 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 594 | 594 | $taxonomy = WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES; |
| 595 | 595 | break; |
@@ -597,17 +597,17 @@ discard block |
||
| 597 | 597 | $taxonomy = ''; |
| 598 | 598 | break; |
| 599 | 599 | } |
| 600 | - $post_taxonomies = wp_get_post_terms( $post_id, $taxonomy); |
|
| 601 | - foreach ( $post_taxonomies as $post_taxonomy ) { |
|
| 602 | - wp_set_post_terms( $last_post, $post_taxonomy->term_id, $taxonomy, true); |
|
| 600 | + $post_taxonomies = wp_get_post_terms($post_id, $taxonomy); |
|
| 601 | + foreach ($post_taxonomies as $post_taxonomy) { |
|
| 602 | + wp_set_post_terms($last_post, $post_taxonomy->term_id, $taxonomy, true); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | /* Create a post meta allowing to know if the element has been duplicated from another */ |
| 606 | 606 | update_post_meta($last_post, '_wpshop_duplicate_element', $post_id); |
| 607 | 607 | |
| 608 | 608 | $new_element_link = '<a class="wpshop_cls wpshop_duplicate_entity_element_link" href="' . admin_url('post.php?post=' . $last_post . '&action=edit') . '" >' . __('Go on the new element edit page', 'wpshop') . '</a>'; |
| 609 | - if ( $meta_creation ) { |
|
| 610 | - return array('true', '<br/>' . $new_element_link, $last_post ); |
|
| 609 | + if ($meta_creation) { |
|
| 610 | + return array('true', '<br/>' . $new_element_link, $last_post); |
|
| 611 | 611 | } |
| 612 | 612 | else { |
| 613 | 613 | return array('true', '<br/>' . __('Some errors occured while duplicating meta information, but element has been created.', 'wpshop') . ' ' . $new_element_link); |
@@ -633,12 +633,12 @@ discard block |
||
| 633 | 633 | $query = $wpdb->prepare("SELECT code, frontend_label FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT WHERE status=%s AND is_used_in_admin_listing_column=%s AND entity_id=%d", 'valid', 'yes', self::get_entity_identifier_from_code($post_type)); |
| 634 | 634 | $attributes_list = $wpdb->get_results($query); |
| 635 | 635 | $wpshop_custom_columns = array(); |
| 636 | - foreach ( $attributes_list as $attribute ) { |
|
| 636 | + foreach ($attributes_list as $attribute) { |
|
| 637 | 637 | $wpshop_custom_columns[$attribute->code] = __($attribute->frontend_label, 'wpshop'); |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | /* Check the current entity to display custom column correctly. Add the custom column into default column list */ |
| 641 | - switch ( $post_type ) { |
|
| 641 | + switch ($post_type) { |
|
| 642 | 642 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 643 | 643 | $columns = array_merge(array( |
| 644 | 644 | 'cb' => '<input type="checkbox" />', |
@@ -665,34 +665,34 @@ discard block |
||
| 665 | 665 | public static function custom_columns_content($column, $post_id) { |
| 666 | 666 | $post_type = get_post_type($post_id); |
| 667 | 667 | |
| 668 | - switch ( $post_type ) { |
|
| 668 | + switch ($post_type) { |
|
| 669 | 669 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 670 | 670 | $column_content = '<strong>-</strong>'; |
| 671 | 671 | $product = wpshop_products::get_product_data($post_id); |
| 672 | 672 | |
| 673 | 673 | switch ($column) { |
| 674 | 674 | case 'picture' : |
| 675 | - $column_content = get_the_post_thumbnail( $post_id, 'thumbnail'); |
|
| 675 | + $column_content = get_the_post_thumbnail($post_id, 'thumbnail'); |
|
| 676 | 676 | break; |
| 677 | 677 | case "product_stock": |
| 678 | - if( !empty($product['product_stock']) ) |
|
| 679 | - $column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop'); |
|
| 678 | + if (!empty($product['product_stock'])) |
|
| 679 | + $column_content = (int)$product['product_stock'] . ' ' . __('unit(s)', 'wpshop'); |
|
| 680 | 680 | break; |
| 681 | 681 | |
| 682 | 682 | case "product_price": |
| 683 | - if( !empty($product['product_price']) ) |
|
| 684 | - $column_content = wpshop_prices::get_product_price( $product, 'price_display', 'complete_sheet'); |
|
| 683 | + if (!empty($product['product_price'])) |
|
| 684 | + $column_content = wpshop_prices::get_product_price($product, 'price_display', 'complete_sheet'); |
|
| 685 | 685 | break; |
| 686 | 686 | |
| 687 | 687 | case "tx_tva": |
| 688 | - if( !empty($product['product_price']) ) |
|
| 689 | - $column_content = number_format($product[$column],2,'.', ' ').' %'; |
|
| 688 | + if (!empty($product['product_price'])) |
|
| 689 | + $column_content = number_format($product[$column], 2, '.', ' ') . ' %'; |
|
| 690 | 690 | break; |
| 691 | 691 | default: |
| 692 | - if ( !empty($product[$column]) ) { |
|
| 692 | + if (!empty($product[$column])) { |
|
| 693 | 693 | $attribute_prices = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 694 | - if ( in_array($column, $attribute_prices) ) { |
|
| 695 | - $column_content = number_format($product[$column],2,'.', ' ').' '.wpshop_tools::wpshop_get_currency(); |
|
| 694 | + if (in_array($column, $attribute_prices)) { |
|
| 695 | + $column_content = number_format($product[$column], 2, '.', ' ') . ' ' . wpshop_tools::wpshop_get_currency(); |
|
| 696 | 696 | |
| 697 | 697 | } |
| 698 | 698 | else |
@@ -713,16 +713,16 @@ discard block |
||
| 713 | 713 | * Display a form allowing to create an entity from frontend with a shortcode |
| 714 | 714 | * @param array $shortcode_args The different parameters for the shortocde: the field list for the form, different parameters for the entity to create |
| 715 | 715 | */ |
| 716 | - public static function wpshop_entities_shortcode( $shortcode_args ) { |
|
| 716 | + public static function wpshop_entities_shortcode($shortcode_args) { |
|
| 717 | 717 | global $wpshop_account, $wpdb; |
| 718 | 718 | $output = $form_content = ''; |
| 719 | - $quick_entity_add_button = !empty( $_POST['quick_entity_add_button'] ) ? (int) $_POST['quick_entity_add_button'] : 0; |
|
| 720 | - if ( get_current_user_id() > 0 ) { |
|
| 721 | - if ( !empty( $quick_entity_add_button ) ) { |
|
| 719 | + $quick_entity_add_button = !empty($_POST['quick_entity_add_button']) ? (int)$_POST['quick_entity_add_button'] : 0; |
|
| 720 | + if (get_current_user_id() > 0) { |
|
| 721 | + if (!empty($quick_entity_add_button)) { |
|
| 722 | 722 | $attributes = array(); |
| 723 | - $attribute = !empty($_POST['attribute']) ? (array) $_POST['attribute'] : array(); |
|
| 724 | - foreach ( $attribute as $attribute_type => $attribute ) { |
|
| 725 | - foreach ( $attribute as $attribute_code => $attribute_value ) { |
|
| 723 | + $attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array(); |
|
| 724 | + foreach ($attribute as $attribute_type => $attribute) { |
|
| 725 | + foreach ($attribute as $attribute_code => $attribute_value) { |
|
| 726 | 726 | $attributes[$attribute_code] = $attribute_value; |
| 727 | 727 | } |
| 728 | 728 | } |
@@ -730,23 +730,23 @@ discard block |
||
| 730 | 730 | $result = wpshop_products::addProduct($title, '', $attributes, 'complete'); |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - if ( empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type']) ) { |
|
| 733 | + if (empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type'])) { |
|
| 734 | 734 | $output = __('This form page is invalid because no set or type or content is defined. Please contact administrator with this error message', 'wpshop'); |
| 735 | 735 | } |
| 736 | 736 | else { |
| 737 | 737 | $entity_identifier = wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']); |
| 738 | 738 | $attribute_set_def = wpshop_attributes_set::getElement($shortcode_args['attribute_set_id'], "'valid'"); |
| 739 | 739 | |
| 740 | - if ( empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id) ) { |
|
| 740 | + if (empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id)) { |
|
| 741 | 741 | $output = __('This form page is invalid because type and set are not linked. Please contact administrator with this error message', 'wpshop'); |
| 742 | 742 | } |
| 743 | 743 | else { |
| 744 | 744 | /** Display wordpress fields */ |
| 745 | - foreach ( explode(', ', $shortcode_args['fields']) as $field_name ) { |
|
| 745 | + foreach (explode(', ', $shortcode_args['fields']) as $field_name) { |
|
| 746 | 746 | $label = ''; |
| 747 | - switch ( $field_name ) { |
|
| 747 | + switch ($field_name) { |
|
| 748 | 748 | case 'post_title': |
| 749 | - switch ( $shortcode_args['post_type'] ) { |
|
| 749 | + switch ($shortcode_args['post_type']) { |
|
| 750 | 750 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 751 | 751 | $label = __('Product title', 'wpshop'); |
| 752 | 752 | break; |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | $field_type = 'text'; |
| 759 | 759 | break; |
| 760 | 760 | case 'post_thumbnail': |
| 761 | - switch ( $shortcode_args['post_type'] ) { |
|
| 761 | + switch ($shortcode_args['post_type']) { |
|
| 762 | 762 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 763 | 763 | $label = __('Product picture', 'wpshop'); |
| 764 | 764 | break; |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | break; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - if ( !empty( $label ) ) { |
|
| 774 | + if (!empty($label)) { |
|
| 775 | 775 | $template_part = 'quick_entity_wp_internal_field_' . $field_type; |
| 776 | 776 | $tpl_component = array(); |
| 777 | 777 | $tpl_component['WP_FIELD_NAME'] = $field_name; |
@@ -804,20 +804,20 @@ discard block |
||
| 804 | 804 | ORDER BY ATT_GROUP.position, ATTR_DET.position" |
| 805 | 805 | , 'yes', 'valid', wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']), $shortcode_args['attribute_set_id']); |
| 806 | 806 | $attribute_for_creation = $wpdb->get_results($query); |
| 807 | - foreach ( $attribute_for_creation as $attribute ) { |
|
| 808 | - $attr_field = wpshop_attributes::display_attribute( $attribute->code, 'frontend'/* (is_admin() ? 'admin' : 'frontend') */ ); |
|
| 807 | + foreach ($attribute_for_creation as $attribute) { |
|
| 808 | + $attr_field = wpshop_attributes::display_attribute($attribute->code, 'frontend'/* (is_admin() ? 'admin' : 'frontend') */); |
|
| 809 | 809 | $form_content .= $attr_field['field']; |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | /** Check if there are extra parameters */ |
| 813 | - if ( !empty( $shortcode_args['extra_element'] ) ) { |
|
| 813 | + if (!empty($shortcode_args['extra_element'])) { |
|
| 814 | 814 | $extra_element = explode(', ', $shortcode_args['extra_element']); |
| 815 | - foreach ( $extra_element as $element) { |
|
| 815 | + foreach ($extra_element as $element) { |
|
| 816 | 816 | $element_def = explode('!#wps#!', $element); |
| 817 | 817 | $element_type = $element_def[0]; |
| 818 | 818 | $element_id = $element_def[1]; |
| 819 | 819 | |
| 820 | - if ( $element_type == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) { |
|
| 820 | + if ($element_type == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) { |
|
| 821 | 821 | $form_content .= '<div class="wpshop_entity_address_container">'; |
| 822 | 822 | // $form_content .= $wpshop_account->display_form_fields($element_id, null, 'not'); |
| 823 | 823 | $form_content .= '</div><div class="wpshop_cls"></div>'; |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | $template_part = 'quick_entity_add_form'; |
| 831 | 831 | $tpl_component = array(); |
| 832 | 832 | $tpl_component['ENTITY_TYPE'] = $shortcode_args['post_type']; |
| 833 | - $tpl_component['ENTITY_ATTRIBUTE_SET_ID'] = !empty( $shortcode_args['attribute_set_id'] ) ? $shortcode_args['attribute_set_id'] : 0; |
|
| 833 | + $tpl_component['ENTITY_ATTRIBUTE_SET_ID'] = !empty($shortcode_args['attribute_set_id']) ? $shortcode_args['attribute_set_id'] : 0; |
|
| 834 | 834 | $tpl_component['NEW_ENTITY_FORM_DETAILS'] = $form_content; |
| 835 | 835 | $tpl_component['ENTITY_QUICK_ADDING_FORM_NONCE'] = wp_create_nonce("wpshop_add_new_entity_ajax_nonce"); |
| 836 | 836 | $tpl_component['ENTITY_QUICK_ADD_BUTTON_TEXT'] = __($shortcode_args['button_text'], 'wpshop'); |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | $dialog_identifier = 'new_value_for_entity'; |
| 841 | 841 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 842 | 842 | ob_start(); |
| 843 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 843 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 844 | 844 | $tpl_component['DIALOG_BOX'] = ob_get_contents(); |
| 845 | 845 | ob_end_clean(); |
| 846 | 846 | $tpl_component['DIALOG_BOX'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />'; |
@@ -882,14 +882,14 @@ discard block |
||
| 882 | 882 | /** Add the new product */ |
| 883 | 883 | $entity_id = wp_insert_post($entity_args); |
| 884 | 884 | |
| 885 | - do_action( 'wps_entity_more_action' , $entity_id, $attributes); |
|
| 885 | + do_action('wps_entity_more_action', $entity_id, $attributes); |
|
| 886 | 886 | |
| 887 | 887 | /** Update the attribute set id for the current product */ |
| 888 | - if ( !empty($extra_params['attribute_set_id']) ) { |
|
| 888 | + if (!empty($extra_params['attribute_set_id'])) { |
|
| 889 | 889 | $attribute_set_id = $extra_params['attribute_set_id']; |
| 890 | 890 | } |
| 891 | 891 | else { |
| 892 | - $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE status = %s AND entity_id = %d AND default_set = %s", 'valid', wpshop_entities::get_entity_identifier_from_code($entity_type) , 'yes'); |
|
| 892 | + $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE status = %s AND entity_id = %d AND default_set = %s", 'valid', wpshop_entities::get_entity_identifier_from_code($entity_type), 'yes'); |
|
| 893 | 893 | $attribute_set_id = $wpdb->get_var($query); |
| 894 | 894 | } |
| 895 | 895 | update_post_meta($entity_id, '_' . $entity_type . '_attribute_set_id', $attribute_set_id); |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | * |
| 908 | 908 | * @return array The different response element for the request. $result: Boolean representing if creation is OK / $container: Where the result must be placed into output code / $output: The html content to output |
| 909 | 909 | */ |
| 910 | - public static function create_cpt_from_csv_file( $identifier, $custom_file = '' ) { |
|
| 910 | + public static function create_cpt_from_csv_file($identifier, $custom_file = '') { |
|
| 911 | 911 | global $wpdb; |
| 912 | 912 | $output = ''; |
| 913 | 913 | $container = ''; |
@@ -927,47 +927,47 @@ discard block |
||
| 927 | 927 | $custom_post_type_identifier = $wpdb->get_var($query); |
| 928 | 928 | $container = 'wpshop_cpt_' . $identifier; |
| 929 | 929 | |
| 930 | - $file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '.csv'; |
|
| 931 | - if ( is_file( $file_uri ) && empty($custom_post_type_identifier) ) { |
|
| 930 | + $file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '.csv'; |
|
| 931 | + if (is_file($file_uri) && empty($custom_post_type_identifier)) { |
|
| 932 | 932 | $csv_file_default_data = file($file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 933 | 933 | |
| 934 | - $db_field_definition = explode( ";", $csv_file_default_data[0] ); |
|
| 935 | - $db_datas_definition = explode( ";", $csv_file_default_data[1] ); |
|
| 934 | + $db_field_definition = explode(";", $csv_file_default_data[0]); |
|
| 935 | + $db_datas_definition = explode(";", $csv_file_default_data[1]); |
|
| 936 | 936 | |
| 937 | 937 | $has_error = false; |
| 938 | 938 | $errors = array(); |
| 939 | - foreach ( $custom_post_type_default_structure as $field_name => $field_default_value ) { |
|
| 940 | - if ( !in_array( str_replace( 'post_', '', $field_name ) , $db_field_definition ) ) { |
|
| 941 | - if ( $field_name == 'post_name' ) { |
|
| 939 | + foreach ($custom_post_type_default_structure as $field_name => $field_default_value) { |
|
| 940 | + if (!in_array(str_replace('post_', '', $field_name), $db_field_definition)) { |
|
| 941 | + if ($field_name == 'post_name') { |
|
| 942 | 942 | $db_datas_definition[] = $identifier; |
| 943 | - $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
|
| 943 | + $db_field_definition[] = str_replace('post_', '', $field_name); |
|
| 944 | 944 | } |
| 945 | - else if ( $field_default_value == 'mandatory' ) { |
|
| 945 | + else if ($field_default_value == 'mandatory') { |
|
| 946 | 946 | $has_error = true; |
| 947 | 947 | $errors[] = $field_name; |
| 948 | 948 | } |
| 949 | 949 | else { |
| 950 | 950 | $db_datas_definition[] = $field_default_value; |
| 951 | - $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
|
| 951 | + $db_field_definition[] = str_replace('post_', '', $field_name); |
|
| 952 | 952 | } |
| 953 | 953 | } |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | - if ( $has_error ) { |
|
| 956 | + if ($has_error) { |
|
| 957 | 957 | $result = false; |
| 958 | - $output = sprintf( __('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors) ); |
|
| 958 | + $output = sprintf(__('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors)); |
|
| 959 | 959 | } |
| 960 | 960 | else { |
| 961 | 961 | $custom_post_type_def = array(); |
| 962 | - foreach ( $db_field_definition as $field_position => $field_name ) { |
|
| 962 | + foreach ($db_field_definition as $field_position => $field_name) { |
|
| 963 | 963 | $custom_post_type_def['post_' . $field_name] = $db_datas_definition[$field_position]; |
| 964 | 964 | } |
| 965 | - $new_custom_post_type = wp_insert_post( $custom_post_type_def ); |
|
| 966 | - if ( is_int($new_custom_post_type) && !empty($new_custom_post_type) ) { |
|
| 965 | + $new_custom_post_type = wp_insert_post($custom_post_type_def); |
|
| 966 | + if (is_int($new_custom_post_type) && !empty($new_custom_post_type)) { |
|
| 967 | 967 | $result = true; |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | - $check_cpt = wpshop_entities::check_default_custom_post_type( $identifier, array(), $result, $custom_file ); |
|
| 970 | + $check_cpt = wpshop_entities::check_default_custom_post_type($identifier, array(), $result, $custom_file); |
|
| 971 | 971 | $output = $check_cpt[1]; |
| 972 | 972 | } |
| 973 | 973 | } |
@@ -983,20 +983,20 @@ discard block |
||
| 983 | 983 | * |
| 984 | 984 | * @return array The different response element for the request. $has_error: A boolean result of request / $output: The complete html output for custom post type check / $tpl_componene: A mode complete list of element of templates |
| 985 | 985 | */ |
| 986 | - public static function check_default_custom_post_type( $identifier, $tpl_component ) { |
|
| 986 | + public static function check_default_custom_post_type($identifier, $tpl_component) { |
|
| 987 | 987 | global $wpdb; |
| 988 | 988 | $has_error = false; |
| 989 | 989 | |
| 990 | 990 | /** Check if custom post type exists */ |
| 991 | 991 | $query = $wpdb->prepare("SELECT post_title FROM " . $wpdb->posts . " WHERE post_name = %s", $identifier); |
| 992 | 992 | $custom_post_type_title = $wpdb->get_var($query); |
| 993 | - if ( !empty($custom_post_type_title) ) { |
|
| 993 | + if (!empty($custom_post_type_title)) { |
|
| 994 | 994 | $tpl_component['CUSTOM_POST_TYPE_IDENTIFIER'] = '<img class="wpshop_tools_check_icon no_error" src="' . WPSHOP_MEDIAS_ICON_URL . 'informations/success_s.png" /> ' . $custom_post_type_title . ' (' . $identifier . ')'; |
| 995 | 995 | $tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER_CLASS'] = ' no_error'; |
| 996 | 996 | $tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = ''; |
| 997 | 997 | $template_part = 'wpshop_admin_tools_default_datas_check_main_element_content_no_error'; |
| 998 | 998 | |
| 999 | - $attributes_for_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, $tpl_component, $has_error ); |
|
| 999 | + $attributes_for_cpt = wpshop_entities::check_default_cpt_attributes($identifier, $tpl_component, $has_error); |
|
| 1000 | 1000 | $has_error = $attributes_for_cpt[0]; |
| 1001 | 1001 | $tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = $attributes_for_cpt[1]; |
| 1002 | 1002 | } |
@@ -1021,39 +1021,39 @@ discard block |
||
| 1021 | 1021 | * |
| 1022 | 1022 | * @return array The different response element for the request. $has_error: A boolean information for request result / $output: The complete html output for attribute check |
| 1023 | 1023 | */ |
| 1024 | - public static function check_default_cpt_attributes( $identifier, $tpl_component, $has_error, $custom_file = '' ) { |
|
| 1024 | + public static function check_default_cpt_attributes($identifier, $tpl_component, $has_error, $custom_file = '') { |
|
| 1025 | 1025 | global $wpdb, $attribute_displayed_field; |
| 1026 | 1026 | $output = ''; |
| 1027 | 1027 | |
| 1028 | - $cpt_attributes_file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv'; |
|
| 1029 | - if ( is_file( $cpt_attributes_file_uri ) ) { |
|
| 1028 | + $cpt_attributes_file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv'; |
|
| 1029 | + if (is_file($cpt_attributes_file_uri)) { |
|
| 1030 | 1030 | /** Read lines into file defining default datas */ |
| 1031 | 1031 | $csv_file_default_data = file($cpt_attributes_file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 1032 | - if ( !empty($csv_file_default_data) ) { |
|
| 1032 | + if (!empty($csv_file_default_data)) { |
|
| 1033 | 1033 | $header_line = explode(';', $csv_file_default_data[0]); |
| 1034 | 1034 | unset($csv_file_default_data[0]); |
| 1035 | 1035 | $code_column = null; |
| 1036 | 1036 | $available_columns = array(); |
| 1037 | - foreach ( $header_line as $column_key => $column_value ) { |
|
| 1038 | - if ( $column_value == 'code' ) { |
|
| 1037 | + foreach ($header_line as $column_key => $column_value) { |
|
| 1038 | + if ($column_value == 'code') { |
|
| 1039 | 1039 | $code_column = $column_key; |
| 1040 | 1040 | // $available_columns[$column_value] = $column_key; |
| 1041 | 1041 | } |
| 1042 | - else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) { |
|
| 1042 | + else if (in_array($column_value, array('frontend_label')/* $attribute_displayed_field */)) { |
|
| 1043 | 1043 | $available_columns[$column_value] = $column_key; |
| 1044 | 1044 | } |
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | /** Read the complete file content */ |
| 1048 | 1048 | $attribute_ok = $attribute_not_ok = ' '; |
| 1049 | - foreach ( $csv_file_default_data as $line_index => $line_content ) { |
|
| 1049 | + foreach ($csv_file_default_data as $line_index => $line_content) { |
|
| 1050 | 1050 | $line_contents = explode(';', $line_content); |
| 1051 | 1051 | $query = $wpdb->prepare("SELECT id, frontend_label FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $line_contents[$code_column], wpshop_entities::get_entity_identifier_from_code($identifier)); |
| 1052 | - $attribute = $wpdb->get_row( $query ); |
|
| 1053 | - if ( !empty($line_contents) ) { |
|
| 1054 | - foreach ( $line_contents as $line_column => $line_column_value ) { |
|
| 1055 | - if ( in_array( $line_column, $available_columns ) ) { |
|
| 1056 | - if ( !empty($attribute) ) { |
|
| 1052 | + $attribute = $wpdb->get_row($query); |
|
| 1053 | + if (!empty($line_contents)) { |
|
| 1054 | + foreach ($line_contents as $line_column => $line_column_value) { |
|
| 1055 | + if (in_array($line_column, $available_columns)) { |
|
| 1056 | + if (!empty($attribute)) { |
|
| 1057 | 1057 | $attribute_ok .= $attribute->frontend_label . ', '; |
| 1058 | 1058 | } |
| 1059 | 1059 | else { |
@@ -1064,18 +1064,18 @@ discard block |
||
| 1064 | 1064 | } |
| 1065 | 1065 | } |
| 1066 | 1066 | } |
| 1067 | - $attribute_not_ok = substr( $attribute_not_ok, 2, -2 ); |
|
| 1068 | - if ( !empty($attribute_not_ok) ) { |
|
| 1069 | - $output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_error', array_merge( $tpl_component, array( 'CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_not_ok )), array(), 'admin'); |
|
| 1067 | + $attribute_not_ok = substr($attribute_not_ok, 2, -2); |
|
| 1068 | + if (!empty($attribute_not_ok)) { |
|
| 1069 | + $output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_error', array_merge($tpl_component, array('CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_not_ok)), array(), 'admin'); |
|
| 1070 | 1070 | } |
| 1071 | - $attribute_ok = substr( $attribute_ok, 2, -2 ); |
|
| 1072 | - if ( !empty($attribute_ok) ) { |
|
| 1073 | - $output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_no_error', array_merge( $tpl_component, array( 'CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_ok )), array(), 'admin'); |
|
| 1071 | + $attribute_ok = substr($attribute_ok, 2, -2); |
|
| 1072 | + if (!empty($attribute_ok)) { |
|
| 1073 | + $output .= wpshop_display::display_template_element('wpshop_admin_tools_default_datas_check_main_element_content_attributes_no_error', array_merge($tpl_component, array('CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES_LIST' => $attribute_ok)), array(), 'admin'); |
|
| 1074 | 1074 | } |
| 1075 | 1075 | } |
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | - return array( $has_error, $output ); |
|
| 1078 | + return array($has_error, $output); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
@@ -1085,60 +1085,60 @@ discard block |
||
| 1085 | 1085 | * |
| 1086 | 1086 | * @return array The different response element for the request. $result: Boolean representing if creation is OK / $container: Where the result must be placed into output code / $output: The html content to output |
| 1087 | 1087 | */ |
| 1088 | - public static function create_cpt_attributes_from_csv_file( $identifier, $custom_file = '' ) { |
|
| 1088 | + public static function create_cpt_attributes_from_csv_file($identifier, $custom_file = '') { |
|
| 1089 | 1089 | global $wpdb; |
| 1090 | 1090 | |
| 1091 | 1091 | $output = $container = ''; |
| 1092 | 1092 | $result = true; |
| 1093 | 1093 | $container = 'wpshop_cpt_' . $identifier . ' ul.wpshop_tools_default_datas_repair_attribute_container'; |
| 1094 | - $excluded_column = array( 'available_values' ); |
|
| 1094 | + $excluded_column = array('available_values'); |
|
| 1095 | 1095 | |
| 1096 | - $file_uri = !empty( $custom_file ) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv'; |
|
| 1097 | - if ( is_file( $file_uri ) ) { |
|
| 1096 | + $file_uri = !empty($custom_file) ? $custom_file : WPSHOP_TEMPLATES_DIR . 'default_datas/' . $identifier . '-attributes.csv'; |
|
| 1097 | + if (is_file($file_uri)) { |
|
| 1098 | 1098 | $entity_id = wpshop_entities::get_entity_identifier_from_code($identifier); |
| 1099 | 1099 | $csv_file_default_data = file($file_uri, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
| 1100 | 1100 | |
| 1101 | - $db_field_definition = explode( ";", $csv_file_default_data[0] ); |
|
| 1101 | + $db_field_definition = explode(";", $csv_file_default_data[0]); |
|
| 1102 | 1102 | $code_column = null; |
| 1103 | - foreach ( $db_field_definition as $column_index => $column_name ) { |
|
| 1104 | - if ( $column_name == 'code' ) { |
|
| 1103 | + foreach ($db_field_definition as $column_index => $column_name) { |
|
| 1104 | + if ($column_name == 'code') { |
|
| 1105 | 1105 | $code_column = $column_index; |
| 1106 | 1106 | continue; |
| 1107 | 1107 | } |
| 1108 | 1108 | } |
| 1109 | 1109 | unset($csv_file_default_data[0]); |
| 1110 | 1110 | |
| 1111 | - if ( !empty($code_column) || ($code_column == 0) ) { |
|
| 1112 | - foreach ( $csv_file_default_data as $line_index => $line_content ) { |
|
| 1113 | - $attribute_definition = explode( ";", $line_content ); |
|
| 1114 | - $query = $wpdb->prepare( "SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_definition[$code_column], $entity_id); |
|
| 1111 | + if (!empty($code_column) || ($code_column == 0)) { |
|
| 1112 | + foreach ($csv_file_default_data as $line_index => $line_content) { |
|
| 1113 | + $attribute_definition = explode(";", $line_content); |
|
| 1114 | + $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s AND entity_id = %d", $attribute_definition[$code_column], $entity_id); |
|
| 1115 | 1115 | $attribute_identifier = $wpdb->get_var($query); |
| 1116 | 1116 | |
| 1117 | - if ( empty($attribute_identifier) ) { |
|
| 1117 | + if (empty($attribute_identifier)) { |
|
| 1118 | 1118 | $attribute_def = array(); |
| 1119 | 1119 | $attribute_values = $default_value = null; |
| 1120 | - foreach ( $db_field_definition as $column_index => $column_name ) { |
|
| 1120 | + foreach ($db_field_definition as $column_index => $column_name) { |
|
| 1121 | 1121 | $column_name = trim($column_name); |
| 1122 | - if ( !empty($column_name) && !in_array($column_name, $excluded_column) ) { |
|
| 1122 | + if (!empty($column_name) && !in_array($column_name, $excluded_column)) { |
|
| 1123 | 1123 | $column_value = $attribute_definition[$column_index]; |
| 1124 | - switch ( $column_name ) { |
|
| 1124 | + switch ($column_name) { |
|
| 1125 | 1125 | case 'frontend_label': |
| 1126 | - $column_value = __( $column_value, 'wpshop' ); |
|
| 1126 | + $column_value = __($column_value, 'wpshop'); |
|
| 1127 | 1127 | break; |
| 1128 | 1128 | } |
| 1129 | - $attribute_def[$column_name] = ( !empty($attribute_definition[$column_index]) ) ? $column_value : ''; |
|
| 1129 | + $attribute_def[$column_name] = (!empty($attribute_definition[$column_index])) ? $column_value : ''; |
|
| 1130 | 1130 | } |
| 1131 | 1131 | else { |
| 1132 | - switch ( $column_name ) { |
|
| 1132 | + switch ($column_name) { |
|
| 1133 | 1133 | case 'available_values': |
| 1134 | 1134 | $attribute_values = $attribute_definition[$column_index]; |
| 1135 | 1135 | break; |
| 1136 | 1136 | } |
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | - switch ( $column_name ) { |
|
| 1139 | + switch ($column_name) { |
|
| 1140 | 1140 | case 'default_value': |
| 1141 | - $default_value = __( $attribute_definition[$column_index], 'wpshop' ); |
|
| 1141 | + $default_value = __($attribute_definition[$column_index], 'wpshop'); |
|
| 1142 | 1142 | break; |
| 1143 | 1143 | } |
| 1144 | 1144 | } |
@@ -1147,14 +1147,14 @@ discard block |
||
| 1147 | 1147 | $last_attribute_id = $wpdb->insert_id; |
| 1148 | 1148 | |
| 1149 | 1149 | /** Create values for select element */ |
| 1150 | - if ( !empty($attribute_values) ) { |
|
| 1151 | - $list_of_values_to_create = explode( ',', $attribute_values ); |
|
| 1152 | - if ( !empty($list_of_values_to_create) ) { |
|
| 1153 | - foreach ( $list_of_values_to_create as $value ) { |
|
| 1154 | - $value_element = explode( '!:!:!', $value); |
|
| 1155 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' => $last_attribute_id, 'label' => __( $value_element[0], 'wpshop' ), 'value' => __( (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0]) ), 'wpshop' ))); |
|
| 1156 | - |
|
| 1157 | - if ( $default_value == (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0])) ) { |
|
| 1150 | + if (!empty($attribute_values)) { |
|
| 1151 | + $list_of_values_to_create = explode(',', $attribute_values); |
|
| 1152 | + if (!empty($list_of_values_to_create)) { |
|
| 1153 | + foreach ($list_of_values_to_create as $value) { |
|
| 1154 | + $value_element = explode('!:!:!', $value); |
|
| 1155 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'attribute_id' => $last_attribute_id, 'label' => __($value_element[0], 'wpshop'), 'value' => __((!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0])), 'wpshop'))); |
|
| 1156 | + |
|
| 1157 | + if ($default_value == (!empty($value_element[1]) ? $value_element[1] : strtolower($value_element[0]))) { |
|
| 1158 | 1158 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $wpdb->insert_id), array('id' => $last_attribute_id, 'default_value' => $default_value)); |
| 1159 | 1159 | } |
| 1160 | 1160 | } |
@@ -1166,7 +1166,7 @@ discard block |
||
| 1166 | 1166 | } |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | - $check_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, array(), false, $custom_file ); |
|
| 1169 | + $check_cpt = wpshop_entities::check_default_cpt_attributes($identifier, array(), false, $custom_file); |
|
| 1170 | 1170 | $output = $check_cpt[1]; |
| 1171 | 1171 | |
| 1172 | 1172 | return array($result, $container, $output); |
@@ -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,28 +19,28 @@ 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 | - $attribute_group_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : ''; |
|
| 40 | + $attribute_group_status = !empty($_REQUEST['attribute_groups_status']) ? sanitize_text_field($_REQUEST['attribute_groups_status']) : ''; |
|
| 41 | 41 | |
| 42 | - $wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_valid'.(empty($attribute_group_status)?' current':'')] = '<a href="'.admin_url('admin.php?page='.wpshop_attributes_set::getEditionSlug()).'" >'.__('Attribute groups', 'wpshop').' ('.count($active_nb).')</a>'; |
|
| 43 | - $wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_deleted'.(!empty($attribute_group_status) && ($attribute_group_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 | + $wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_valid' . (empty($attribute_group_status) ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . wpshop_attributes_set::getEditionSlug()) . '" >' . __('Attribute groups', 'wpshop') . ' (' . count($active_nb) . ')</a>'; |
|
| 43 | + $wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_deleted' . (!empty($attribute_group_status) && ($attribute_group_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>'; |
|
| 44 | 44 | |
| 45 | 45 | return $wpshop_attribute_links; |
| 46 | 46 | } |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | * @see WP_List_Table::::single_row_columns() |
| 59 | 59 | * @return array An associative array containing column information: 'slugs'=>'Visible Titles' |
| 60 | 60 | **************************************************************************/ |
| 61 | - function get_columns(){ |
|
| 61 | + function get_columns() { |
|
| 62 | 62 | $columns = array( |
| 63 | - 'cb' => '',//'<input type="checkbox" />', //Render a checkbox instead of text |
|
| 63 | + 'cb' => '', //'<input type="checkbox" />', //Render a checkbox instead of text |
|
| 64 | 64 | 'id' => 'Id.', |
| 65 | 65 | 'name' => 'Nom', |
| 66 | 66 | 'status' => 'Statut', |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | * @param array $column_name The name/slug of the column to be processed |
| 92 | 92 | * @return string Text or HTML to be placed inside the column <td> |
| 93 | 93 | **************************************************************************/ |
| 94 | - function column_default($item, $column_name){ |
|
| 95 | - switch($column_name){ |
|
| 94 | + function column_default($item, $column_name) { |
|
| 95 | + switch ($column_name) { |
|
| 96 | 96 | default: |
| 97 | - return print_r($item,true); //Show the whole array for troubleshooting purposes |
|
| 97 | + return print_r($item, true); //Show the whole array for troubleshooting purposes |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param array $item A singular item (one full row's worth of data) |
| 115 | 115 | * @return string Text to be placed inside the column <td> (movie title only) |
| 116 | 116 | **************************************************************************/ |
| 117 | - function column_id($item){ |
|
| 117 | + function column_id($item) { |
|
| 118 | 118 | return $item['id']; |
| 119 | 119 | } |
| 120 | 120 | /** ************************************************************************ |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param array $item A singular item (one full row's worth of data) |
| 134 | 134 | * @return string Text to be placed inside the column <td> (movie title only) |
| 135 | 135 | **************************************************************************/ |
| 136 | - function column_status($item){ |
|
| 136 | + function column_status($item) { |
|
| 137 | 137 | return __($item['status'], 'wpshop'); |
| 138 | 138 | } |
| 139 | 139 | /** ************************************************************************ |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param array $item A singular item (one full row's worth of data) |
| 153 | 153 | * @return string Text to be placed inside the column <td> (movie title only) |
| 154 | 154 | **************************************************************************/ |
| 155 | - function column_content($item){ |
|
| 155 | + function column_content($item) { |
|
| 156 | 156 | return $item['content']; |
| 157 | 157 | } |
| 158 | 158 | /** ************************************************************************ |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @param array $item A singular item (one full row's worth of data) |
| 172 | 172 | * @return string Text to be placed inside the column <td> (movie title only) |
| 173 | 173 | **************************************************************************/ |
| 174 | - function column_entity($item){ |
|
| 175 | - return __($item['entity'],'wpshop'); |
|
| 174 | + function column_entity($item) { |
|
| 175 | + return __($item['entity'], 'wpshop'); |
|
| 176 | 176 | } |
| 177 | 177 | /** ************************************************************************ |
| 178 | 178 | * Recommended. This is a custom column method and is responsible for what |
@@ -190,23 +190,23 @@ discard block |
||
| 190 | 190 | * @param array $item A singular item (one full row's worth of data) |
| 191 | 191 | * @return string Text to be placed inside the column <td> (movie title only) |
| 192 | 192 | **************************************************************************/ |
| 193 | - function column_name($item){ |
|
| 193 | + function column_name($item) { |
|
| 194 | 194 | //Build row actions |
| 195 | - $default_action='edit'; |
|
| 196 | - $default_action_text=__('Edit', 'wpshop'); |
|
| 197 | - $attribute_groups_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : ''; |
|
| 198 | - if( !empty( $attribute_groups_status ) && ( $attribute_groups_status=='deleted' ) ){ |
|
| 199 | - $default_action='activate'; |
|
| 200 | - $default_action_text=__('Restore', 'wpshop'); |
|
| 195 | + $default_action = 'edit'; |
|
| 196 | + $default_action_text = __('Edit', 'wpshop'); |
|
| 197 | + $attribute_groups_status = !empty($_REQUEST['attribute_groups_status']) ? sanitize_text_field($_REQUEST['attribute_groups_status']) : ''; |
|
| 198 | + if (!empty($attribute_groups_status) && ($attribute_groups_status == 'deleted')) { |
|
| 199 | + $default_action = 'activate'; |
|
| 200 | + $default_action_text = __('Restore', 'wpshop'); |
|
| 201 | 201 | } |
| 202 | - $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']); |
|
| 202 | + $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']); |
|
| 203 | 203 | |
| 204 | 204 | if (empty($attribute_groups_status)) |
| 205 | - $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 | + $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']); |
|
| 206 | 206 | |
| 207 | 207 | //Return the title contents |
| 208 | 208 | return sprintf('%1$s%2$s', |
| 209 | - /*$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']), |
|
| 209 | + /*$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']), |
|
| 210 | 210 | /*$3%s*/ $this->row_actions($actions) |
| 211 | 211 | ); |
| 212 | 212 | } |
@@ -219,11 +219,11 @@ discard block |
||
| 219 | 219 | * @param array $item A singular item (one full row's worth of data) |
| 220 | 220 | * @return string Text to be placed inside the column <td> (movie title only) |
| 221 | 221 | **************************************************************************/ |
| 222 | - function column_cb($item){ |
|
| 222 | + function column_cb($item) { |
|
| 223 | 223 | return ''; |
| 224 | 224 | return sprintf( |
| 225 | 225 | '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
| 226 | - /*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie") |
|
| 226 | + /*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie") |
|
| 227 | 227 | /*$2%s*/ $item['id'] //The value of the checkbox should be the record's id |
| 228 | 228 | ); |
| 229 | 229 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | **************************************************************************/ |
| 280 | 280 | function process_bulk_action() { |
| 281 | 281 | //Detect when a bulk action is being triggered... |
| 282 | - if( 'delete'===$this->current_action() ) { |
|
| 282 | + if ('delete' === $this->current_action()) { |
|
| 283 | 283 | wp_die('Items deleted (or they would be if we had items to delete)!'); |
| 284 | 284 | } |
| 285 | 285 | } |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * to ensure that the data is trimmed to only the current page. We can use |
| 359 | 359 | * array_slice() to |
| 360 | 360 | */ |
| 361 | - $data = array_slice($data,(($current_page-1)*$per_page),$per_page); |
|
| 361 | + $data = array_slice($data, (($current_page - 1) * $per_page), $per_page); |
|
| 362 | 362 | |
| 363 | 363 | /** |
| 364 | 364 | * REQUIRED. Now we can add our *sorted* data to the items property, where |
@@ -369,11 +369,11 @@ discard block |
||
| 369 | 369 | /** |
| 370 | 370 | * REQUIRED. We also have to register our pagination options & calculations. |
| 371 | 371 | */ |
| 372 | - $this->set_pagination_args( array( |
|
| 373 | - 'total_items' => $total_items, //WE have to calculate the total number of items |
|
| 374 | - 'per_page' => $per_page, //WE have to determine how many items to show on a page |
|
| 375 | - 'total_pages' => ceil($total_items/$per_page) //WE have to calculate the total number of pages |
|
| 376 | - ) ); |
|
| 372 | + $this->set_pagination_args(array( |
|
| 373 | + 'total_items' => $total_items, //WE have to calculate the total number of items |
|
| 374 | + 'per_page' => $per_page, //WE have to determine how many items to show on a page |
|
| 375 | + 'total_pages' => ceil($total_items / $per_page) //WE have to calculate the total number of pages |
|
| 376 | + )); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | } |
@@ -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' ) ) { |
@@ -201,8 +203,9 @@ discard block |
||
| 201 | 203 | } |
| 202 | 204 | $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']); |
| 203 | 205 | |
| 204 | - if (empty($attribute_groups_status)) |
|
| 205 | - $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']); |
|
| 206 | + if (empty($attribute_groups_status)) { |
|
| 207 | + $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']); |
|
| 208 | + } |
|
| 206 | 209 | |
| 207 | 210 | //Return the title contents |
| 208 | 211 | return sprintf('%1$s%2$s', |
@@ -24,89 +24,89 @@ discard block |
||
| 24 | 24 | class wpshop_attributes_unit |
| 25 | 25 | { |
| 26 | 26 | /** |
| 27 | - * Define the database table used in the current class |
|
| 28 | - */ |
|
| 27 | + * Define the database table used in the current class |
|
| 28 | + */ |
|
| 29 | 29 | const dbTable = WPSHOP_DBT_ATTRIBUTE_UNIT; |
| 30 | 30 | /** |
| 31 | - * Define the url listing slug used in the current class |
|
| 32 | - */ |
|
| 31 | + * Define the url listing slug used in the current class |
|
| 32 | + */ |
|
| 33 | 33 | const urlSlugListing = WPSHOP_URL_SLUG_ATTRIBUTE_LISTING; |
| 34 | 34 | /** |
| 35 | - * Define the url edition slug used in the current class |
|
| 36 | - */ |
|
| 35 | + * Define the url edition slug used in the current class |
|
| 36 | + */ |
|
| 37 | 37 | const urlSlugEdition = WPSHOP_URL_SLUG_ATTRIBUTE_LISTING; |
| 38 | 38 | /** |
| 39 | - * Define the current entity code |
|
| 40 | - */ |
|
| 39 | + * Define the current entity code |
|
| 40 | + */ |
|
| 41 | 41 | const currentPageCode = 'attributes_unit'; |
| 42 | 42 | /** |
| 43 | - * Define the page title |
|
| 44 | - */ |
|
| 43 | + * Define the page title |
|
| 44 | + */ |
|
| 45 | 45 | const pageContentTitle = 'Attributes unit'; |
| 46 | 46 | /** |
| 47 | - * Define the page title when adding an attribute |
|
| 48 | - */ |
|
| 47 | + * Define the page title when adding an attribute |
|
| 48 | + */ |
|
| 49 | 49 | const pageAddingTitle = 'Add an unit'; |
| 50 | 50 | /** |
| 51 | - * Define the page title when editing an attribute |
|
| 52 | - */ |
|
| 51 | + * Define the page title when editing an attribute |
|
| 52 | + */ |
|
| 53 | 53 | const pageEditingTitle = 'Unit "%s" edit'; |
| 54 | 54 | /** |
| 55 | - * Define the page title when editing an attribute |
|
| 56 | - */ |
|
| 55 | + * Define the page title when editing an attribute |
|
| 56 | + */ |
|
| 57 | 57 | const pageTitle = 'Attributes unit list'; |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * Define the path to page main icon |
|
| 61 | - */ |
|
| 60 | + * Define the path to page main icon |
|
| 61 | + */ |
|
| 62 | 62 | public $pageIcon = ''; |
| 63 | 63 | /** |
| 64 | - * Define the message to output after an action |
|
| 65 | - */ |
|
| 64 | + * Define the message to output after an action |
|
| 65 | + */ |
|
| 66 | 66 | public $pageMessage = ''; |
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | - * Get the url listing slug of the current class |
|
| 70 | - * |
|
| 71 | - * @return string The table of the class |
|
| 72 | - */ |
|
| 69 | + * Get the url listing slug of the current class |
|
| 70 | + * |
|
| 71 | + * @return string The table of the class |
|
| 72 | + */ |
|
| 73 | 73 | function setMessage($message) |
| 74 | 74 | { |
| 75 | 75 | $this->pageMessage = $message; |
| 76 | 76 | } |
| 77 | 77 | /** |
| 78 | - * Get the url listing slug of the current class |
|
| 79 | - * |
|
| 80 | - * @return string The table of the class |
|
| 81 | - */ |
|
| 78 | + * Get the url listing slug of the current class |
|
| 79 | + * |
|
| 80 | + * @return string The table of the class |
|
| 81 | + */ |
|
| 82 | 82 | public static function getListingSlug() |
| 83 | 83 | { |
| 84 | 84 | return self::urlSlugListing; |
| 85 | 85 | } |
| 86 | 86 | /** |
| 87 | - * Get the url edition slug of the current class |
|
| 88 | - * |
|
| 89 | - * @return string The table of the class |
|
| 90 | - */ |
|
| 87 | + * Get the url edition slug of the current class |
|
| 88 | + * |
|
| 89 | + * @return string The table of the class |
|
| 90 | + */ |
|
| 91 | 91 | public static function getEditionSlug() |
| 92 | 92 | { |
| 93 | 93 | return self::urlSlugEdition; |
| 94 | 94 | } |
| 95 | 95 | /** |
| 96 | - * Get the database table of the current class |
|
| 97 | - * |
|
| 98 | - * @return string The table of the class |
|
| 99 | - */ |
|
| 96 | + * Get the database table of the current class |
|
| 97 | + * |
|
| 98 | + * @return string The table of the class |
|
| 99 | + */ |
|
| 100 | 100 | public static function getDbTable() |
| 101 | 101 | { |
| 102 | 102 | return self::dbTable; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * Define the title of the page |
|
| 107 | - * |
|
| 108 | - * @return string $title The title of the page looking at the environnement |
|
| 109 | - */ |
|
| 106 | + * Define the title of the page |
|
| 107 | + * |
|
| 108 | + * @return string $title The title of the page looking at the environnement |
|
| 109 | + */ |
|
| 110 | 110 | function pageTitle() |
| 111 | 111 | { |
| 112 | 112 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : ''; |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | - * Define the different message and action after an action is send through the element interface |
|
| 137 | - */ |
|
| 136 | + * Define the different message and action after an action is send through the element interface |
|
| 137 | + */ |
|
| 138 | 138 | function elementAction() |
| 139 | 139 | { |
| 140 | 140 | global $wpdb, $initialEavData; |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | - * Return the list page content, containing the table that present the item list |
|
| 267 | - * |
|
| 268 | - * @return string $listItemOutput The html code that output the item list |
|
| 269 | - */ |
|
| 266 | + * Return the list page content, containing the table that present the item list |
|
| 267 | + * |
|
| 268 | + * @return string $listItemOutput The html code that output the item list |
|
| 269 | + */ |
|
| 270 | 270 | public static function elementList() |
| 271 | 271 | { |
| 272 | 272 | $listItemOutput = ''; |
@@ -387,10 +387,10 @@ discard block |
||
| 387 | 387 | return $listItemOutput; |
| 388 | 388 | } |
| 389 | 389 | /** |
| 390 | - * Return the page content to add a new item |
|
| 391 | - * |
|
| 392 | - * @return string The html code that output the interface for adding a nem item |
|
| 393 | - */ |
|
| 390 | + * Return the page content to add a new item |
|
| 391 | + * |
|
| 392 | + * @return string The html code that output the interface for adding a nem item |
|
| 393 | + */ |
|
| 394 | 394 | public static function elementEdition($itemToEdit = ''){ |
| 395 | 395 | global $attribute_displayed_field; global $wpdb; |
| 396 | 396 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
@@ -484,10 +484,10 @@ discard block |
||
| 484 | 484 | return $the_form; |
| 485 | 485 | } |
| 486 | 486 | /** |
| 487 | - * Return the different button to save the item currently being added or edited |
|
| 488 | - * |
|
| 489 | - * @return string $currentPageButton The html output code with the different button to add to the interface |
|
| 490 | - */ |
|
| 487 | + * Return the different button to save the item currently being added or edited |
|
| 488 | + * |
|
| 489 | + * @return string $currentPageButton The html output code with the different button to add to the interface |
|
| 490 | + */ |
|
| 491 | 491 | function getPageFormButton($element_id = 0) |
| 492 | 492 | { |
| 493 | 493 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add'; |
@@ -515,14 +515,14 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
| 518 | - * Get the existing attribute list into database |
|
| 519 | - * |
|
| 520 | - * @param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned |
|
| 521 | - * @param string $element_status optionnal The status of element to get into database. Default is set to valid element |
|
| 522 | - * @param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id |
|
| 523 | - * |
|
| 524 | - * @return object $element_list A wordpress database object containing the attribute list |
|
| 525 | - */ |
|
| 518 | + * Get the existing attribute list into database |
|
| 519 | + * |
|
| 520 | + * @param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned |
|
| 521 | + * @param string $element_status optionnal The status of element to get into database. Default is set to valid element |
|
| 522 | + * @param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id |
|
| 523 | + * |
|
| 524 | + * @return object $element_list A wordpress database object containing the attribute list |
|
| 525 | + */ |
|
| 526 | 526 | public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){ |
| 527 | 527 | global $wpdb; |
| 528 | 528 | $element_list = array(); |
@@ -554,8 +554,8 @@ discard block |
||
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | /** |
| 557 | - * |
|
| 558 | - */ |
|
| 557 | + * |
|
| 558 | + */ |
|
| 559 | 559 | public static function get_unit_list_for_group($group_id){ |
| 560 | 560 | global $wpdb; |
| 561 | 561 | $unit_list_for_group = ''; |
@@ -569,8 +569,8 @@ discard block |
||
| 569 | 569 | return $unit_list_for_group; |
| 570 | 570 | } |
| 571 | 571 | /** |
| 572 | - * |
|
| 573 | - */ |
|
| 572 | + * |
|
| 573 | + */ |
|
| 574 | 574 | public static function get_default_unit_for_group($group_id){ |
| 575 | 575 | global $wpdb; |
| 576 | 576 | $default_unit_for_group = ''; |
@@ -583,10 +583,10 @@ discard block |
||
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | /** |
| 586 | - * Get the unit group existing list in database |
|
| 587 | - * |
|
| 588 | - * @return object $attribute_unit_group_list The list of existing unit group |
|
| 589 | - */ |
|
| 586 | + * Get the unit group existing list in database |
|
| 587 | + * |
|
| 588 | + * @return object $attribute_unit_group_list The list of existing unit group |
|
| 589 | + */ |
|
| 590 | 590 | public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){ |
| 591 | 591 | global $wpdb; |
| 592 | 592 | $element_list = array(); |
@@ -619,10 +619,10 @@ discard block |
||
| 619 | 619 | // return $attribute_unit_group_list; |
| 620 | 620 | } |
| 621 | 621 | /** |
| 622 | - * Return the list page content, containing the table that present the item list |
|
| 623 | - * |
|
| 624 | - * @return string $listItemOutput The html code that output the item list |
|
| 625 | - */ |
|
| 622 | + * Return the list page content, containing the table that present the item list |
|
| 623 | + * |
|
| 624 | + * @return string $listItemOutput The html code that output the item list |
|
| 625 | + */ |
|
| 626 | 626 | public static function unit_group_list(){ |
| 627 | 627 | $listItemOutput = ''; |
| 628 | 628 | |
@@ -734,10 +734,10 @@ discard block |
||
| 734 | 734 | return $listItemOutput; |
| 735 | 735 | } |
| 736 | 736 | /** |
| 737 | - * Return the page content to add a new item |
|
| 738 | - * |
|
| 739 | - * @return string The html code that output the interface for adding a nem item |
|
| 740 | - */ |
|
| 737 | + * Return the page content to add a new item |
|
| 738 | + * |
|
| 739 | + * @return string The html code that output the interface for adding a nem item |
|
| 740 | + */ |
|
| 741 | 741 | public static function unit_group_edition($itemToEdit = ''){ |
| 742 | 742 | global $attribute_displayed_field; |
| 743 | 743 | $dbFieldList = wpshop_database::fields_to_input(WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
@@ -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' ) ) { |
@@ -120,13 +122,11 @@ discard block |
||
| 120 | 122 | { |
| 121 | 123 | $editedItem = self::getElement($objectInEdition); |
| 122 | 124 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . ' (' . $editedItem->code . ')'); |
| 123 | - } |
|
| 124 | - elseif($action == 'add') |
|
| 125 | + } elseif($action == 'add') |
|
| 125 | 126 | { |
| 126 | 127 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 127 | 128 | } |
| 128 | - } |
|
| 129 | - elseif((self::getEditionSlug() != self::getListingSlug()) && (sanitize_text_field($page) == self::getEditionSlug())) |
|
| 129 | + } elseif((self::getEditionSlug() != self::getListingSlug()) && (sanitize_text_field($page) == self::getEditionSlug())) |
|
| 130 | 130 | { |
| 131 | 131 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 132 | 132 | } |
@@ -151,8 +151,7 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | $editedElement = self::getElement($saveditem); |
| 153 | 153 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 154 | - } |
|
| 155 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)) |
|
| 154 | + } elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)) |
|
| 156 | 155 | { |
| 157 | 156 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 158 | 157 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
@@ -174,32 +173,27 @@ discard block |
||
| 174 | 173 | if(current_user_can('wpshop_delete_attributes')) |
| 175 | 174 | { |
| 176 | 175 | $attribute_group_parameter['status'] = 'deleted'; |
| 177 | - } |
|
| 178 | - else |
|
| 176 | + } else |
|
| 179 | 177 | { |
| 180 | 178 | $actionResult = 'userNotAllowedForActionDelete'; |
| 181 | 179 | } |
| 182 | 180 | } |
| 183 | 181 | $actionResult = wpshop_database::update($attribute_group_parameter, $id, self::getDbTable()); |
| 184 | - } |
|
| 185 | - else |
|
| 182 | + } else |
|
| 186 | 183 | { |
| 187 | 184 | $actionResult = 'userNotAllowedForActionEdit'; |
| 188 | 185 | } |
| 189 | - } |
|
| 190 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 186 | + } elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 191 | 187 | if(current_user_can('wpshop_delete_attributes')) |
| 192 | 188 | { |
| 193 | 189 | $attribute_group_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 194 | 190 | $attribute_group_parameter['status'] = 'deleted'; |
| 195 | 191 | $actionResult = wpshop_database::update($attribute_group_parameter, $id, self::getDbTable()); |
| 196 | - } |
|
| 197 | - else |
|
| 192 | + } else |
|
| 198 | 193 | { |
| 199 | 194 | $actionResult = 'userNotAllowedForActionDelete'; |
| 200 | 195 | } |
| 201 | - } |
|
| 202 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 196 | + } elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 203 | 197 | if(current_user_can('wpshop_add_attributes')){ |
| 204 | 198 | $attribute_group_parameter['creation_date'] = date('Y-m-d H:i:s'); |
| 205 | 199 | if(trim($attribute_group_parameter['code']) == ''){ |
@@ -212,8 +206,7 @@ discard block |
||
| 212 | 206 | } |
| 213 | 207 | $actionResult = wpshop_database::save($attribute_group_parameter, self::getDbTable()); |
| 214 | 208 | $id = $wpdb->insert_id; |
| 215 | - } |
|
| 216 | - else{ |
|
| 209 | + } else{ |
|
| 217 | 210 | $actionResult = 'userNotAllowedForActionAdd'; |
| 218 | 211 | } |
| 219 | 212 | } |
@@ -231,8 +224,7 @@ discard block |
||
| 231 | 224 | { |
| 232 | 225 | $pageMessage .= '<br/>' . $wpdb->last_error; |
| 233 | 226 | } |
| 234 | - } |
|
| 235 | - elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) |
|
| 227 | + } elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) |
|
| 236 | 228 | {/* CHANGE HERE FOR SPECIFIC CASE */ |
| 237 | 229 | /*****************************************************************************************************************/ |
| 238 | 230 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ******************/ |
@@ -245,17 +237,14 @@ discard block |
||
| 245 | 237 | if(($pageAction == 'edit') || ($pageAction == 'save')) |
| 246 | 238 | { |
| 247 | 239 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 248 | - } |
|
| 249 | - elseif($pageAction == 'add') |
|
| 240 | + } elseif($pageAction == 'add') |
|
| 250 | 241 | { |
| 251 | 242 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 252 | - } |
|
| 253 | - elseif($pageAction == 'delete') |
|
| 243 | + } elseif($pageAction == 'delete') |
|
| 254 | 244 | { |
| 255 | 245 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
| 256 | 246 | } |
| 257 | - } |
|
| 258 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 247 | + } elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 259 | 248 | { |
| 260 | 249 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 261 | 250 | } |
@@ -304,8 +293,7 @@ discard block |
||
| 304 | 293 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 305 | 294 | $subRowActions .= ' |
| 306 | 295 | <a href="#" id="edit_attribute_unit_' . $element->id . '" class="edit_attribute_unit" >' . __('Edit', 'wpshop') . '</a>'; |
| 307 | - } |
|
| 308 | - elseif(current_user_can('wpshop_view_attributes_unit')) |
|
| 296 | + } elseif(current_user_can('wpshop_view_attributes_unit')) |
|
| 309 | 297 | { |
| 310 | 298 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 311 | 299 | } |
@@ -331,8 +319,7 @@ discard block |
||
| 331 | 319 | |
| 332 | 320 | $line++; |
| 333 | 321 | } |
| 334 | - } |
|
| 335 | - else{ |
|
| 322 | + } else{ |
|
| 336 | 323 | unset($tableRowValue); |
| 337 | 324 | $tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop')); |
| 338 | 325 | $tableRowValue[] = array('class' => self::currentPageCode . '_name_cell', 'value' => ''); |
@@ -411,8 +398,7 @@ discard block |
||
| 411 | 398 | $currentFieldValue = $input_def['value']; |
| 412 | 399 | if(is_object($editedItem)){ |
| 413 | 400 | $currentFieldValue = $editedItem->{$input_def['name']}; |
| 414 | - } |
|
| 415 | - elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 401 | + } elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 416 | 402 | $currentFieldValue = $requestFormValue; |
| 417 | 403 | } |
| 418 | 404 | |
@@ -444,8 +430,7 @@ discard block |
||
| 444 | 430 | </div>'; |
| 445 | 431 | |
| 446 | 432 | |
| 447 | - } |
|
| 448 | - else{ |
|
| 433 | + } else{ |
|
| 449 | 434 | $the_form_content_hidden .= ' |
| 450 | 435 | ' . $the_input; |
| 451 | 436 | } |
@@ -496,8 +481,7 @@ discard block |
||
| 496 | 481 | { |
| 497 | 482 | $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 498 | 483 | } |
| 499 | - } |
|
| 500 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 484 | + } elseif(current_user_can('wpshop_edit_attributes')) |
|
| 501 | 485 | { |
| 502 | 486 | $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" /><input type="button" class="button-primary" id="saveandcontinue" name="saveandcontinue" value="' . __('Save and continue edit', 'wpshop') . '" />'; |
| 503 | 487 | } |
@@ -542,8 +526,7 @@ discard block |
||
| 542 | 526 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 543 | 527 | if($element_id == ''){ |
| 544 | 528 | $element_list = $wpdb->get_results($query); |
| 545 | - } |
|
| 546 | - else{ |
|
| 529 | + } else{ |
|
| 547 | 530 | $element_list = $wpdb->get_row($query); |
| 548 | 531 | } |
| 549 | 532 | |
@@ -603,10 +586,11 @@ discard block |
||
| 603 | 586 | ); |
| 604 | 587 | |
| 605 | 588 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 606 | - if($element_id == '') |
|
| 607 | - $element_list = $wpdb->get_results($query); |
|
| 608 | - else |
|
| 609 | - $element_list = $wpdb->get_row($query); |
|
| 589 | + if($element_id == '') { |
|
| 590 | + $element_list = $wpdb->get_results($query); |
|
| 591 | + } else { |
|
| 592 | + $element_list = $wpdb->get_row($query); |
|
| 593 | + } |
|
| 610 | 594 | |
| 611 | 595 | return $element_list; |
| 612 | 596 | |
@@ -650,8 +634,7 @@ discard block |
||
| 650 | 634 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 651 | 635 | $subRowActions .= ' |
| 652 | 636 | <a href="#" id="edit_attribute_unit_group_' . $element->id . '" class="edit_attribute_unit_group" >' . __('Edit', 'wpshop') . '</a>'; |
| 653 | - } |
|
| 654 | - elseif(current_user_can('wpshop_view_attributes_unit_group')) |
|
| 637 | + } elseif(current_user_can('wpshop_view_attributes_unit_group')) |
|
| 655 | 638 | { |
| 656 | 639 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 657 | 640 | } |
@@ -675,8 +658,7 @@ discard block |
||
| 675 | 658 | |
| 676 | 659 | $line++; |
| 677 | 660 | } |
| 678 | - } |
|
| 679 | - else{ |
|
| 661 | + } else{ |
|
| 680 | 662 | unset($tableRowValue); |
| 681 | 663 | $tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop')); |
| 682 | 664 | $tableRows[] = $tableRowValue; |
@@ -749,8 +731,7 @@ discard block |
||
| 749 | 731 | $currentFieldValue = $input_def['value']; |
| 750 | 732 | if(is_object($editedItem)){ |
| 751 | 733 | $currentFieldValue = $editedItem->{$input_def['name']}; |
| 752 | - } |
|
| 753 | - elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 734 | + } elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 754 | 735 | $currentFieldValue = $requestFormValue; |
| 755 | 736 | } |
| 756 | 737 | |
@@ -775,12 +756,10 @@ discard block |
||
| 775 | 756 | </div>'; |
| 776 | 757 | if(substr($input_def['name'], 0, 3) == 'is_'){ |
| 777 | 758 | $the_form_option_content .= $input; |
| 778 | - } |
|
| 779 | - else{ |
|
| 759 | + } else{ |
|
| 780 | 760 | $the_form_general_content .= $input; |
| 781 | 761 | } |
| 782 | - } |
|
| 783 | - else{ |
|
| 762 | + } else{ |
|
| 784 | 763 | $the_form_content_hidden .= ' |
| 785 | 764 | ' . $the_input; |
| 786 | 765 | } |
@@ -831,8 +810,7 @@ discard block |
||
| 831 | 810 | foreach ( $currencies as $currency) { |
| 832 | 811 | $currencies_options .= '<option value="'.$currency->id.'"'.(($currency->id == $current_currency) ? ' selected="selected"' : null).'>'.$currency->name.' ('.$currency->unit.')</option>'; |
| 833 | 812 | } |
| 834 | - } |
|
| 835 | - else { |
|
| 813 | + } else { |
|
| 836 | 814 | foreach($wpshop_shop_currencies as $k => $v) { |
| 837 | 815 | $currencies_options .= '<option value="'.$k.'"'.(($k==$current_currency) ? ' selected="selected"' : null).'>'.$k.' ('.$v.')</option>'; |
| 838 | 816 | } |
@@ -864,14 +842,16 @@ discard block |
||
| 864 | 842 | public static function get_the_attribute_unit_by_code_for_product($product_id, $attribute_code) { |
| 865 | 843 | $unit = self::get_default_unit_attribute( $attribute_code ); |
| 866 | 844 | |
| 867 | - if(empty($unit)) |
|
| 868 | - return null; |
|
| 845 | + if(empty($unit)) { |
|
| 846 | + return null; |
|
| 847 | + } |
|
| 869 | 848 | |
| 870 | 849 | $post_meta = get_post_meta($product_id, '_wpshop_product_metadata', true); |
| 871 | 850 | |
| 872 | 851 | /** Si on trouve une unité */ |
| 873 | - if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) |
|
| 874 | - $unit->_default_unit = $post_meta['unit'][$attribute_code]; |
|
| 852 | + if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) { |
|
| 853 | + $unit->_default_unit = $post_meta['unit'][$attribute_code]; |
|
| 854 | + } |
|
| 875 | 855 | |
| 876 | 856 | return $unit; |
| 877 | 857 | } |
@@ -885,8 +865,9 @@ discard block |
||
| 885 | 865 | public static function the_attribute_unit_by_code_for_product($product_id, $attribute_code) { |
| 886 | 866 | $unit = self::get_the_attribute_unit_by_code_for_product($product_id, $attribute_code); |
| 887 | 867 | |
| 888 | - if(empty($unit)) |
|
| 889 | - return null; |
|
| 868 | + if(empty($unit)) { |
|
| 869 | + return null; |
|
| 870 | + } |
|
| 890 | 871 | |
| 891 | 872 | echo self::get_the_subname_unit($unit->_unit_group_id, $unit->_default_unit); |
| 892 | 873 | } |
@@ -902,8 +883,9 @@ discard block |
||
| 902 | 883 | global $wpdb; |
| 903 | 884 | |
| 904 | 885 | /** Si pas d'unité ou de groupe, null */ |
| 905 | - if(0 === $unit_id || 0 === $group_id) |
|
| 906 | - return null; |
|
| 886 | + if(0 === $unit_id || 0 === $group_id) { |
|
| 887 | + return null; |
|
| 888 | + } |
|
| 907 | 889 | |
| 908 | 890 | return $wpdb->get_var( $wpdb->prepare( 'SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) ); |
| 909 | 891 | } |
@@ -919,8 +901,9 @@ discard block |
||
| 919 | 901 | global $wpdb; |
| 920 | 902 | |
| 921 | 903 | /** Si pas d'unité ou de groupe, null */ |
| 922 | - if(0 === $unit_id || 0 === $group_id) |
|
| 923 | - return null; |
|
| 904 | + if(0 === $unit_id || 0 === $group_id) { |
|
| 905 | + return null; |
|
| 906 | + } |
|
| 924 | 907 | |
| 925 | 908 | return $wpdb->get_var( $wpdb->prepare( 'SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) ); |
| 926 | 909 | } |
@@ -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 | /** |
@@ -111,22 +111,22 @@ discard block |
||
| 111 | 111 | { |
| 112 | 112 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 113 | 113 | $objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : ''; |
| 114 | - $page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
| 114 | + $page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
| 115 | 115 | |
| 116 | - $title = __(self::pageTitle, 'wpshop' ); |
|
| 117 | - if($action != '') |
|
| 116 | + $title = __(self::pageTitle, 'wpshop'); |
|
| 117 | + if ($action != '') |
|
| 118 | 118 | { |
| 119 | - if(($action == 'edit') || ($action == 'delete')) |
|
| 119 | + if (($action == 'edit') || ($action == 'delete')) |
|
| 120 | 120 | { |
| 121 | 121 | $editedItem = self::getElement($objectInEdition); |
| 122 | 122 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label) . ' (' . $editedItem->code . ')'); |
| 123 | 123 | } |
| 124 | - elseif($action == 'add') |
|
| 124 | + elseif ($action == 'add') |
|
| 125 | 125 | { |
| 126 | 126 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | - elseif((self::getEditionSlug() != self::getListingSlug()) && (sanitize_text_field($page) == self::getEditionSlug())) |
|
| 129 | + elseif ((self::getEditionSlug() != self::getListingSlug()) && (sanitize_text_field($page) == self::getEditionSlug())) |
|
| 130 | 130 | { |
| 131 | 131 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 132 | 132 | } |
@@ -147,31 +147,31 @@ discard block |
||
| 147 | 147 | /****************************************************************************/ |
| 148 | 148 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add'; |
| 149 | 149 | $saveditem = isset($_REQUEST['saveditem']) ? wpshop_tools::varSanitizer($_REQUEST['saveditem']) : ''; |
| 150 | - if(($action != '') && ($action == 'saveok') && ($saveditem > 0)) |
|
| 150 | + if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) |
|
| 151 | 151 | { |
| 152 | 152 | $editedElement = self::getElement($saveditem); |
| 153 | 153 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 154 | 154 | } |
| 155 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)) |
|
| 155 | + elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) |
|
| 156 | 156 | { |
| 157 | 157 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 158 | 158 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /* Define the database operation type from action launched by the user */ |
| 162 | - $attribute_group_parameter = (!empty($_REQUEST[self::getDbTable()])) ? (array) $_REQUEST[self::getDbTable()] : array(); |
|
| 163 | - $attribute_group_parameter['default_value'] = str_replace('"', "'", sanitize_text_field( $attribute_group_parameter['default_value'])); |
|
| 162 | + $attribute_group_parameter = (!empty($_REQUEST[self::getDbTable()])) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 163 | + $attribute_group_parameter['default_value'] = str_replace('"', "'", sanitize_text_field($attribute_group_parameter['default_value'])); |
|
| 164 | 164 | /************************* GENERIC **************************/ |
| 165 | 165 | /*************************************************************************/ |
| 166 | 166 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 167 | 167 | $id = isset($attribute_group_parameter['id']) ? sanitize_key($attribute_group_parameter['id']) : ''; |
| 168 | - if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))){ |
|
| 169 | - if(current_user_can('wpshop_edit_attributes')) |
|
| 168 | + if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))) { |
|
| 169 | + if (current_user_can('wpshop_edit_attributes')) |
|
| 170 | 170 | { |
| 171 | 171 | $attribute_group_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 172 | - if($pageAction == 'delete') |
|
| 172 | + if ($pageAction == 'delete') |
|
| 173 | 173 | { |
| 174 | - if(current_user_can('wpshop_delete_attributes')) |
|
| 174 | + if (current_user_can('wpshop_delete_attributes')) |
|
| 175 | 175 | { |
| 176 | 176 | $attribute_group_parameter['status'] = 'deleted'; |
| 177 | 177 | } |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | $actionResult = 'userNotAllowedForActionEdit'; |
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 191 | - if(current_user_can('wpshop_delete_attributes')) |
|
| 190 | + elseif (($pageAction != '') && (($pageAction == 'delete'))) { |
|
| 191 | + if (current_user_can('wpshop_delete_attributes')) |
|
| 192 | 192 | { |
| 193 | 193 | $attribute_group_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 194 | 194 | $attribute_group_parameter['status'] = 'deleted'; |
@@ -199,21 +199,21 @@ discard block |
||
| 199 | 199 | $actionResult = 'userNotAllowedForActionDelete'; |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 203 | - if(current_user_can('wpshop_add_attributes')){ |
|
| 202 | + elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) { |
|
| 203 | + if (current_user_can('wpshop_add_attributes')) { |
|
| 204 | 204 | $attribute_group_parameter['creation_date'] = date('Y-m-d H:i:s'); |
| 205 | - if(trim($attribute_group_parameter['code']) == ''){ |
|
| 205 | + if (trim($attribute_group_parameter['code']) == '') { |
|
| 206 | 206 | $attribute_group_parameter['code'] = $attribute_group_parameter['frontend_label']; |
| 207 | 207 | } |
| 208 | 208 | $attribute_group_parameter['code'] = wpshop_tools::slugify(str_replace("\'", "_", str_replace('\"', "_", $attribute_group_parameter['code'])), array('noAccent', 'noSpaces', 'lowerCase', 'noPunctuation')); |
| 209 | 209 | $code_exists = self::getElement($attribute_group_parameter['code'], "'valid', 'moderated', 'deleted'", 'code'); |
| 210 | - if((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)){ |
|
| 210 | + if ((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)) { |
|
| 211 | 211 | $attribute_group_parameter['code'] = $attribute_group_parameter['code'] . '_' . (count($code_exists) + 1); |
| 212 | 212 | } |
| 213 | 213 | $actionResult = wpshop_database::save($attribute_group_parameter, self::getDbTable()); |
| 214 | 214 | $id = $wpdb->insert_id; |
| 215 | 215 | } |
| 216 | - else{ |
|
| 216 | + else { |
|
| 217 | 217 | $actionResult = 'userNotAllowedForActionAdd'; |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -223,16 +223,16 @@ discard block |
||
| 223 | 223 | /************ CHANGE THE FIELD NAME TO TAKE TO DISPLAY *************/ |
| 224 | 224 | /************ CHANGE ERROR MESSAGE FOR SPECIFIC CASE *************/ |
| 225 | 225 | /****************************************************************************/ |
| 226 | - if($actionResult != ''){ |
|
| 226 | + if ($actionResult != '') { |
|
| 227 | 227 | $elementIdentifierForMessage = '<span class="bold" >' . $attribute_group_parameter['frontend_label'] . '</span>'; |
| 228 | 228 | if ($actionResult == 'error') { |
| 229 | 229 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage); |
| 230 | - if(WPSHOP_DEBUG_MODE) |
|
| 230 | + if (WPSHOP_DEBUG_MODE) |
|
| 231 | 231 | { |
| 232 | 232 | $pageMessage .= '<br/>' . $wpdb->last_error; |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | - elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) |
|
| 235 | + elseif (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) |
|
| 236 | 236 | {/* CHANGE HERE FOR SPECIFIC CASE */ |
| 237 | 237 | /*****************************************************************************************************************/ |
| 238 | 238 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ******************/ |
@@ -242,20 +242,20 @@ discard block |
||
| 242 | 242 | /************************* GENERIC ****************************/ |
| 243 | 243 | /***********************************************************************************/ |
| 244 | 244 | $pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage); |
| 245 | - if(($pageAction == 'edit') || ($pageAction == 'save')) |
|
| 245 | + if (($pageAction == 'edit') || ($pageAction == 'save')) |
|
| 246 | 246 | { |
| 247 | 247 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 248 | 248 | } |
| 249 | - elseif($pageAction == 'add') |
|
| 249 | + elseif ($pageAction == 'add') |
|
| 250 | 250 | { |
| 251 | 251 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 252 | 252 | } |
| 253 | - elseif($pageAction == 'delete') |
|
| 253 | + elseif ($pageAction == 'delete') |
|
| 254 | 254 | { |
| 255 | 255 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 258 | + elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 259 | 259 | { |
| 260 | 260 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 261 | 261 | } |
@@ -287,36 +287,36 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | $line = 0; |
| 289 | 289 | $elementList = self::getElement(); |
| 290 | - if(is_array($elementList) && (count($elementList) > 0)){ |
|
| 291 | - foreach($elementList as $element) |
|
| 290 | + if (is_array($elementList) && (count($elementList) > 0)) { |
|
| 291 | + foreach ($elementList as $element) |
|
| 292 | 292 | { |
| 293 | 293 | $tableRowsId[$line] = self::getDbTable() . '_' . $element->id; |
| 294 | 294 | |
| 295 | 295 | $elementLabel = __($element->name, 'wpshop'); |
| 296 | 296 | $subRowActions = ''; |
| 297 | 297 | $attributeSlugUrl = self::getListingSlug(); |
| 298 | - if(current_user_can('wpshop_add_attributes_unit')) |
|
| 298 | + if (current_user_can('wpshop_add_attributes_unit')) |
|
| 299 | 299 | { |
| 300 | 300 | $attributeSlugUrl = self::getEditionSlug(); |
| 301 | 301 | } |
| 302 | - if(current_user_can('wpshop_edit_attributes_unit')) |
|
| 302 | + if (current_user_can('wpshop_edit_attributes_unit')) |
|
| 303 | 303 | { |
| 304 | 304 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 305 | 305 | $subRowActions .= ' |
| 306 | - <a href="#" id="edit_attribute_unit_' . $element->id . '" class="edit_attribute_unit" data-nonce="' . wp_create_nonce( 'edit_attribute_unit_' . $element->id ) . '" >' . __('Edit', 'wpshop') . '</a>'; |
|
| 306 | + <a href="#" id="edit_attribute_unit_' . $element->id . '" class="edit_attribute_unit" data-nonce="' . wp_create_nonce('edit_attribute_unit_' . $element->id) . '" >' . __('Edit', 'wpshop') . '</a>'; |
|
| 307 | 307 | } |
| 308 | - elseif(current_user_can('wpshop_view_attributes_unit')) |
|
| 308 | + elseif (current_user_can('wpshop_view_attributes_unit')) |
|
| 309 | 309 | { |
| 310 | 310 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 311 | 311 | } |
| 312 | - if(current_user_can('wpshop_delete_attributes_unit')) |
|
| 312 | + if (current_user_can('wpshop_delete_attributes_unit')) |
|
| 313 | 313 | { |
| 314 | - if($subRowActions != '') |
|
| 314 | + if ($subRowActions != '') |
|
| 315 | 315 | { |
| 316 | 316 | $subRowActions .= ' | '; |
| 317 | 317 | } |
| 318 | 318 | $subRowActions .= ' |
| 319 | - <a href="#" id="delete_attribute_unit_' . $element->id . '" class="delete_attribute_unit" data-nonce="' . wp_create_nonce( 'delete_attribute_unit_' . $element->id ) . '" >' . __('Delete', 'wpshop') . '</a>'; |
|
| 319 | + <a href="#" id="delete_attribute_unit_' . $element->id . '" class="delete_attribute_unit" data-nonce="' . wp_create_nonce('delete_attribute_unit_' . $element->id) . '" >' . __('Delete', 'wpshop') . '</a>'; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | $rowActions = ' |
@@ -332,14 +332,14 @@ discard block |
||
| 332 | 332 | $line++; |
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | - else{ |
|
| 335 | + else { |
|
| 336 | 336 | unset($tableRowValue); |
| 337 | 337 | $tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop')); |
| 338 | 338 | $tableRowValue[] = array('class' => self::currentPageCode . '_name_cell', 'value' => ''); |
| 339 | 339 | $tableRowValue[] = array('class' => self::currentPageCode . '_code_cell', 'value' => ''); |
| 340 | 340 | $tableRows[] = $tableRowValue; |
| 341 | 341 | } |
| 342 | - if(current_user_can('wpshop_add_attributes_unit')){ |
|
| 342 | + if (current_user_can('wpshop_add_attributes_unit')) { |
|
| 343 | 343 | $listItemOutput .= ' |
| 344 | 344 | <input type="button" value="' . __('Add an unit', 'wpshop') . '" class="button-secondary alignleft" name="add_attribute_unit" id="add_attribute_unit" />'; |
| 345 | 345 | } |
@@ -348,11 +348,11 @@ discard block |
||
| 348 | 348 | wpshop(document).ready(function(){ |
| 349 | 349 | jQuery("#' . $tableId . '").dataTable(); |
| 350 | 350 | jQuery("#wpshop_unit_group_list_tab").show();'; |
| 351 | - if(current_user_can('wpshop_delete_attributes_unit')){ |
|
| 351 | + if (current_user_can('wpshop_delete_attributes_unit')) { |
|
| 352 | 352 | $listItemOutput .= ' |
| 353 | 353 | wpshop(document).on("click", ".delete_attribute_unit", function() { |
| 354 | 354 | var nonce = jQuery( this ).data( "nonce" ); |
| 355 | - if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit', 'wpshop') .' ?"))){ |
|
| 355 | + if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit', 'wpshop') . ' ?"))){ |
|
| 356 | 356 | wpshop("#wpshop_unit_list").load(ajaxurl,{ |
| 357 | 357 | "action": "wps_attribute_unit_delete", |
| 358 | 358 | "elementIdentifier": wpshop(this).attr("id").replace("delete_attribute_unit_", ""), |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | });'; |
| 363 | 363 | } |
| 364 | - if(current_user_can('wpshop_edit_attributes_unit')){ |
|
| 364 | + if (current_user_can('wpshop_edit_attributes_unit')) { |
|
| 365 | 365 | $listItemOutput .= ' |
| 366 | 366 | wpshop(document).on("click", ".edit_attribute_unit", function() { |
| 367 | 367 | var nonce = jQuery( this ).data( "nonce" ); |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | }); |
| 373 | 373 | });'; |
| 374 | 374 | } |
| 375 | - if(current_user_can('wpshop_add_attributes_unit')){ |
|
| 375 | + if (current_user_can('wpshop_add_attributes_unit')) { |
|
| 376 | 376 | $listItemOutput .= ' |
| 377 | 377 | jQuery("#add_attribute_unit").click(function(){ |
| 378 | 378 | jQuery("#wpshop_unit_list").load(ajaxurl,{ |
@@ -392,34 +392,34 @@ discard block |
||
| 392 | 392 | * |
| 393 | 393 | * @return string The html code that output the interface for adding a nem item |
| 394 | 394 | */ |
| 395 | - public static function elementEdition($itemToEdit = ''){ |
|
| 395 | + public static function elementEdition($itemToEdit = '') { |
|
| 396 | 396 | global $attribute_displayed_field; global $wpdb; |
| 397 | 397 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 398 | 398 | |
| 399 | 399 | $editedItem = ''; |
| 400 | 400 | // @TODO : Request |
| 401 | 401 | // $_REQUEST['action'] = 'save_new_attribute_unit'; |
| 402 | - if($itemToEdit != ''){ |
|
| 402 | + if ($itemToEdit != '') { |
|
| 403 | 403 | $editedItem = self::getElement($itemToEdit); |
| 404 | 404 | // $_REQUEST['action'] = 'update_attribute_unit'; |
| 405 | 405 | } |
| 406 | - $query = $wpdb->prepare('SELECT unit FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id = ' .get_option('wpshop_shop_default_currency'). '', ''); |
|
| 406 | + $query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = ' . get_option('wpshop_shop_default_currency') . '', ''); |
|
| 407 | 407 | $default_unit = $wpdb->get_var($query); |
| 408 | 408 | |
| 409 | 409 | $the_form_content_hidden = $the_form_general_content = $the_form_option_content = ''; |
| 410 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 410 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 411 | 411 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 412 | 412 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['name']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['name']]) : ''; |
| 413 | 413 | $currentFieldValue = $input_def['value']; |
| 414 | - if(is_object($editedItem)){ |
|
| 414 | + if (is_object($editedItem)) { |
|
| 415 | 415 | $currentFieldValue = $editedItem->{$input_def['name']}; |
| 416 | 416 | } |
| 417 | - elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 417 | + elseif (($pageAction != '') && ($requestFormValue != '')) { |
|
| 418 | 418 | $currentFieldValue = $requestFormValue; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | $input_def['value'] = $currentFieldValue; |
| 422 | - if($input_def['name'] == 'group_id'){ |
|
| 422 | + if ($input_def['name'] == 'group_id') { |
|
| 423 | 423 | $attribute_unit_group_list = self::get_unit_group(); |
| 424 | 424 | $input_def['possible_value'] = $attribute_unit_group_list; |
| 425 | 425 | $input_def['type'] = 'select'; |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 430 | 430 | |
| 431 | 431 | |
| 432 | - if($input_def['type'] != 'hidden'){ |
|
| 432 | + if ($input_def['type'] != 'hidden') { |
|
| 433 | 433 | $label = 'for="' . $input_def['name'] . '"'; |
| 434 | - if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){ |
|
| 434 | + if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) { |
|
| 435 | 435 | $label = ''; |
| 436 | 436 | } |
| 437 | 437 | |
@@ -441,29 +441,29 @@ discard block |
||
| 441 | 441 | <label ' . $label . ' >' . __($input_def['name'], 'wpshop') . '</label> |
| 442 | 442 | </div> |
| 443 | 443 | <div class="wpshop_form_input wpshop_' . self::currentPageCode . '_' . $input_def['name'] . '_input alignleft" > |
| 444 | - ' . $the_input . ' ' .( ($input_def['name'] == 'change_rate') ? $default_unit : ''). ' |
|
| 444 | + ' . $the_input . ' ' . (($input_def['name'] == 'change_rate') ? $default_unit : '') . ' |
|
| 445 | 445 | </div> |
| 446 | 446 | </div>'; |
| 447 | 447 | |
| 448 | 448 | |
| 449 | 449 | } |
| 450 | - else{ |
|
| 450 | + else { |
|
| 451 | 451 | $the_form_content_hidden .= ' |
| 452 | 452 | ' . $the_input; |
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - $the_form = '<form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="' . admin_url( 'admin-ajax.php' ) . '" >'; |
|
| 457 | - if( ctype_digit( (string) $itemToEdit ) ) { |
|
| 456 | + $the_form = '<form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="' . admin_url('admin-ajax.php') . '" >'; |
|
| 457 | + if (ctype_digit((string)$itemToEdit)) { |
|
| 458 | 458 | $the_form .= wpshop_form::form_input('action', 'action', 'wps_attribute_unit_update', 'hidden'); |
| 459 | - $the_form .= wp_nonce_field( 'update_attribute_unit', '_wpnonce' ); |
|
| 459 | + $the_form .= wp_nonce_field('update_attribute_unit', '_wpnonce'); |
|
| 460 | 460 | } else { |
| 461 | 461 | $the_form .= wpshop_form::form_input('action', 'action', 'wps_attribute_unit_new', 'hidden'); |
| 462 | - $the_form .= wp_nonce_field( 'save_new_attribute_unit', '_wpnonce' ); |
|
| 462 | + $the_form .= wp_nonce_field('save_new_attribute_unit', '_wpnonce'); |
|
| 463 | 463 | } |
| 464 | - $the_form .= wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden'); |
|
| 464 | + $the_form .= wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden'); |
|
| 465 | 465 | $the_form .= $the_form_content_hidden . $the_form_general_content; |
| 466 | - $the_form .= '<input type="button" value="' . __('Back', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_edition" id="cancel_unit_edition" data-nonce="' . wp_create_nonce( 'load_attribute_units' ) . '" /> |
|
| 466 | + $the_form .= '<input type="button" value="' . __('Back', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_edition" id="cancel_unit_edition" data-nonce="' . wp_create_nonce('load_attribute_units') . '" /> |
|
| 467 | 467 | <input type="submit" value="' . __('Save', 'wpshop') . '" class="button-primary alignright" name="save_new_unit" id="save_new_unit" /> |
| 468 | 468 | </form> |
| 469 | 469 | <script type="text/javascript" > |
@@ -497,18 +497,18 @@ discard block |
||
| 497 | 497 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add'; |
| 498 | 498 | $currentPageButton = ''; |
| 499 | 499 | |
| 500 | - if($action == 'add') |
|
| 500 | + if ($action == 'add') |
|
| 501 | 501 | { |
| 502 | - if(current_user_can('wpshop_add_attributes')) |
|
| 502 | + if (current_user_can('wpshop_add_attributes')) |
|
| 503 | 503 | { |
| 504 | 504 | $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 507 | + elseif (current_user_can('wpshop_edit_attributes')) |
|
| 508 | 508 | { |
| 509 | 509 | $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" /><input type="button" class="button-primary" id="saveandcontinue" name="saveandcontinue" value="' . __('Save and continue edit', 'wpshop') . '" />'; |
| 510 | 510 | } |
| 511 | - if(current_user_can('wpshop_delete_attributes') && ($action != 'add')) |
|
| 511 | + if (current_user_can('wpshop_delete_attributes') && ($action != 'add')) |
|
| 512 | 512 | { |
| 513 | 513 | $currentPageButton .= '<input type="button" class="button-primary" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
| 514 | 514 | } |
@@ -527,13 +527,13 @@ discard block |
||
| 527 | 527 | * |
| 528 | 528 | * @return object $element_list A wordpress database object containing the attribute list |
| 529 | 529 | */ |
| 530 | - public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){ |
|
| 530 | + public static function getElement($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id') { |
|
| 531 | 531 | global $wpdb; |
| 532 | 532 | $element_list = array(); |
| 533 | 533 | $moreQuery = ""; |
| 534 | - $moreQueryArgs = array( 1, ); |
|
| 534 | + $moreQueryArgs = array(1,); |
|
| 535 | 535 | |
| 536 | - if($element_id != ''){ |
|
| 536 | + if ($element_id != '') { |
|
| 537 | 537 | $moreQuery = " |
| 538 | 538 | AND CURRENT_ELEMENT." . $field_to_search . " = %s "; |
| 539 | 539 | $moreQueryArgs[] = $element_id; |
@@ -543,14 +543,14 @@ discard block |
||
| 543 | 543 | "SELECT CURRENT_ELEMENT.*, UNIT_GROUP.name as group_name |
| 544 | 544 | FROM " . self::getDbTable() . " AS CURRENT_ELEMENT |
| 545 | 545 | LEFT JOIN " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " AS UNIT_GROUP ON (UNIT_GROUP.id = CURRENT_ELEMENT.group_id) |
| 546 | - WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, $moreQueryArgs |
|
| 546 | + WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status . ") " . $moreQuery, $moreQueryArgs |
|
| 547 | 547 | ); |
| 548 | 548 | |
| 549 | 549 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 550 | - if($element_id == ''){ |
|
| 550 | + if ($element_id == '') { |
|
| 551 | 551 | $element_list = $wpdb->get_results($query); |
| 552 | 552 | } |
| 553 | - else{ |
|
| 553 | + else { |
|
| 554 | 554 | $element_list = $wpdb->get_row($query); |
| 555 | 555 | } |
| 556 | 556 | |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | /** |
| 561 | 561 | * |
| 562 | 562 | */ |
| 563 | - public static function get_unit_list_for_group($group_id){ |
|
| 563 | + public static function get_unit_list_for_group($group_id) { |
|
| 564 | 564 | global $wpdb; |
| 565 | 565 | $unit_list_for_group = ''; |
| 566 | 566 | |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | /** |
| 576 | 576 | * |
| 577 | 577 | */ |
| 578 | - public static function get_default_unit_for_group($group_id){ |
|
| 578 | + public static function get_default_unit_for_group($group_id) { |
|
| 579 | 579 | global $wpdb; |
| 580 | 580 | $default_unit_for_group = ''; |
| 581 | 581 | |
@@ -591,13 +591,13 @@ discard block |
||
| 591 | 591 | * |
| 592 | 592 | * @return object $attribute_unit_group_list The list of existing unit group |
| 593 | 593 | */ |
| 594 | - public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id'){ |
|
| 594 | + public static function get_unit_group($element_id = '', $element_status = "'valid', 'moderated'", $field_to_search = 'id') { |
|
| 595 | 595 | global $wpdb; |
| 596 | 596 | $element_list = array(); |
| 597 | 597 | $moreQuery = ""; |
| 598 | - $moreQueryArgs = array( 1, ); |
|
| 598 | + $moreQueryArgs = array(1,); |
|
| 599 | 599 | |
| 600 | - if($element_id != ''){ |
|
| 600 | + if ($element_id != '') { |
|
| 601 | 601 | $moreQuery = " |
| 602 | 602 | AND CURRENT_ELEMENT." . $field_to_search . " = %d "; |
| 603 | 603 | $moreQueryArgs[] = $element_id; |
@@ -606,11 +606,11 @@ discard block |
||
| 606 | 606 | $query = $wpdb->prepare( |
| 607 | 607 | "SELECT CURRENT_ELEMENT.* |
| 608 | 608 | FROM " . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . " AS CURRENT_ELEMENT |
| 609 | - WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, $moreQueryArgs |
|
| 609 | + WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status . ") " . $moreQuery, $moreQueryArgs |
|
| 610 | 610 | ); |
| 611 | 611 | |
| 612 | 612 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 613 | - if($element_id == '') |
|
| 613 | + if ($element_id == '') |
|
| 614 | 614 | $element_list = $wpdb->get_results($query); |
| 615 | 615 | else |
| 616 | 616 | $element_list = $wpdb->get_row($query); |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | * |
| 628 | 628 | * @return string $listItemOutput The html code that output the item list |
| 629 | 629 | */ |
| 630 | - public static function unit_group_list(){ |
|
| 630 | + public static function unit_group_list() { |
|
| 631 | 631 | $listItemOutput = ''; |
| 632 | 632 | |
| 633 | 633 | /* Start the table definition */ |
@@ -640,36 +640,36 @@ discard block |
||
| 640 | 640 | |
| 641 | 641 | $line = 0; |
| 642 | 642 | $elementList = self::get_unit_group(); |
| 643 | - if(is_array($elementList) && (count($elementList) > 0)){ |
|
| 644 | - foreach($elementList as $element) |
|
| 643 | + if (is_array($elementList) && (count($elementList) > 0)) { |
|
| 644 | + foreach ($elementList as $element) |
|
| 645 | 645 | { |
| 646 | 646 | $tableRowsId[$line] = self::getDbTable() . '_' . $element->id; |
| 647 | 647 | |
| 648 | 648 | $elementLabel = __($element->name, 'wpshop'); |
| 649 | 649 | $subRowActions = ''; |
| 650 | 650 | $attributeSlugUrl = self::getListingSlug(); |
| 651 | - if(current_user_can('wpshop_add_attributes_unit_group')) |
|
| 651 | + if (current_user_can('wpshop_add_attributes_unit_group')) |
|
| 652 | 652 | { |
| 653 | 653 | $attributeSlugUrl = self::getEditionSlug(); |
| 654 | 654 | } |
| 655 | - if(current_user_can('wpshop_edit_attributes_unit_group')) |
|
| 655 | + if (current_user_can('wpshop_edit_attributes_unit_group')) |
|
| 656 | 656 | { |
| 657 | 657 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 658 | 658 | $subRowActions .= ' |
| 659 | - <a href="#" id="edit_attribute_unit_group_' . $element->id . '" class="edit_attribute_unit_group" data-nonce="' . wp_create_nonce( 'edit_attribute_unit_group_' . $element->id ) . '" >' . __('Edit', 'wpshop') . '</a>'; |
|
| 659 | + <a href="#" id="edit_attribute_unit_group_' . $element->id . '" class="edit_attribute_unit_group" data-nonce="' . wp_create_nonce('edit_attribute_unit_group_' . $element->id) . '" >' . __('Edit', 'wpshop') . '</a>'; |
|
| 660 | 660 | } |
| 661 | - elseif(current_user_can('wpshop_view_attributes_unit_group')) |
|
| 661 | + elseif (current_user_can('wpshop_view_attributes_unit_group')) |
|
| 662 | 662 | { |
| 663 | 663 | $editAction = admin_url('admin.php?page=' . $attributeSlugUrl . '&action=edit&id=' . $element->id); |
| 664 | 664 | } |
| 665 | - if(current_user_can('wpshop_delete_attributes_unit_group')) |
|
| 665 | + if (current_user_can('wpshop_delete_attributes_unit_group')) |
|
| 666 | 666 | { |
| 667 | - if($subRowActions != '') |
|
| 667 | + if ($subRowActions != '') |
|
| 668 | 668 | { |
| 669 | 669 | $subRowActions .= ' | '; |
| 670 | 670 | } |
| 671 | 671 | $subRowActions .= ' |
| 672 | - <a href="#" id="delete_attribute_unit_group_' . $element->id . '" class="delete_attribute_unit_group" data-nonce="' . wp_create_nonce( 'delete_attribute_unit_group_' . $element->id ) . '" >' . __('Delete', 'wpshop') . '</a>'; |
|
| 672 | + <a href="#" id="delete_attribute_unit_group_' . $element->id . '" class="delete_attribute_unit_group" data-nonce="' . wp_create_nonce('delete_attribute_unit_group_' . $element->id) . '" >' . __('Delete', 'wpshop') . '</a>'; |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | $rowActions = ' |
@@ -683,24 +683,24 @@ discard block |
||
| 683 | 683 | $line++; |
| 684 | 684 | } |
| 685 | 685 | } |
| 686 | - else{ |
|
| 686 | + else { |
|
| 687 | 687 | unset($tableRowValue); |
| 688 | 688 | $tableRowValue[] = array('class' => self::currentPageCode . '_label_cell', 'value' => __('No element to ouput here', 'wpshop')); |
| 689 | 689 | $tableRows[] = $tableRowValue; |
| 690 | 690 | } |
| 691 | - if(current_user_can('wpshop_add_attributes_unit_group')){ |
|
| 691 | + if (current_user_can('wpshop_add_attributes_unit_group')) { |
|
| 692 | 692 | $listItemOutput .= ' |
| 693 | -<input type="button" value="' . __('Add an unit group', 'wpshop') . '" class="button-secondary alignleft" name="add_attribute_unit_group" id="add_attribute_unit_group" data-nonce="' . wp_create_nonce( 'add_attribute_unit_group' ) . '" />'; |
|
| 693 | +<input type="button" value="' . __('Add an unit group', 'wpshop') . '" class="button-secondary alignleft" name="add_attribute_unit_group" id="add_attribute_unit_group" data-nonce="' . wp_create_nonce('add_attribute_unit_group') . '" />'; |
|
| 694 | 694 | } |
| 695 | 695 | $listItemOutput .= wpshop_display::getTable($tableId, $tableTitles, $tableRows, $tableClasses, $tableRowsId, $tableSummary, true) . ' |
| 696 | 696 | <script type="text/javascript" > |
| 697 | 697 | wpshop(document).ready(function(){ |
| 698 | 698 | jQuery("#' . $tableId . '").dataTable(); |
| 699 | 699 | jQuery("#wpshop_unit_list_tab").show();'; |
| 700 | - if(current_user_can('wpshop_delete_attributes_unit_group')){ |
|
| 700 | + if (current_user_can('wpshop_delete_attributes_unit_group')) { |
|
| 701 | 701 | $listItemOutput .= ' |
| 702 | 702 | wpshop(document).on("click", ".delete_attribute_unit_group", function() { |
| 703 | - if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit group', 'wpshop') .' ?"))){ |
|
| 703 | + if(confirm(wpshopConvertAccentTojs("' . __('Are you sure you want to delete this unit group', 'wpshop') . ' ?"))){ |
|
| 704 | 704 | wpshop("#wpshop_unit_group_list").load(ajaxurl, { |
| 705 | 705 | "action": "wps_attribute_group_unit_delete", |
| 706 | 706 | "elementIdentifier": wpshop(this).attr("id").replace("delete_attribute_unit_group_", ""), |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | } |
| 710 | 710 | });'; |
| 711 | 711 | } |
| 712 | - if(current_user_can('wpshop_edit_attributes_unit_group')){ |
|
| 712 | + if (current_user_can('wpshop_edit_attributes_unit_group')) { |
|
| 713 | 713 | $listItemOutput .= ' |
| 714 | 714 | wpshop(document).on("click", ".edit_attribute_unit_group", function() { |
| 715 | 715 | wpshop("#wpshop_unit_group_list").load(ajaxurl, { |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | }); |
| 720 | 720 | });'; |
| 721 | 721 | } |
| 722 | - if(current_user_can('wpshop_add_attributes_unit_group')){ |
|
| 722 | + if (current_user_can('wpshop_add_attributes_unit_group')) { |
|
| 723 | 723 | $listItemOutput .= ' |
| 724 | 724 | wpshop("#add_attribute_unit_group").click(function(){ |
| 725 | 725 | wpshop("#wpshop_unit_group_list").load(ajaxurl, { |
@@ -739,25 +739,25 @@ discard block |
||
| 739 | 739 | * |
| 740 | 740 | * @return string The html code that output the interface for adding a nem item |
| 741 | 741 | */ |
| 742 | - public static function unit_group_edition($itemToEdit = ''){ |
|
| 742 | + public static function unit_group_edition($itemToEdit = '') { |
|
| 743 | 743 | global $attribute_displayed_field; |
| 744 | 744 | $dbFieldList = wpshop_database::fields_to_input(WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
| 745 | 745 | |
| 746 | - if( ctype_digit( (string) $itemToEdit ) ) { |
|
| 747 | - $editedItem = self::get_unit_group( (int) $itemToEdit ); |
|
| 746 | + if (ctype_digit((string)$itemToEdit)) { |
|
| 747 | + $editedItem = self::get_unit_group((int)$itemToEdit); |
|
| 748 | 748 | } else { |
| 749 | 749 | $editedItem = ''; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | $the_form_content_hidden = $the_form_general_content = $the_form_option_content = ''; |
| 753 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 753 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 754 | 754 | $pageAction = isset($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) ? wpshop_tools::varSanitizer($_REQUEST[WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_action']) : ''; |
| 755 | 755 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['name']]) ? wpshop_tools::varSanitizer($_REQUEST[self::currentPageCode][$input_def['name']]) : ''; |
| 756 | 756 | $currentFieldValue = $input_def['value']; |
| 757 | - if(is_object($editedItem)){ |
|
| 757 | + if (is_object($editedItem)) { |
|
| 758 | 758 | $currentFieldValue = $editedItem->{$input_def['name']}; |
| 759 | 759 | } |
| 760 | - elseif(($pageAction != '') && ($requestFormValue != '')){ |
|
| 760 | + elseif (($pageAction != '') && ($requestFormValue != '')) { |
|
| 761 | 761 | $currentFieldValue = $requestFormValue; |
| 762 | 762 | } |
| 763 | 763 | |
@@ -766,9 +766,9 @@ discard block |
||
| 766 | 766 | $input_def['value'] = __(str_replace("\\", "", $input_def['value']), 'wpshop'); |
| 767 | 767 | $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP); |
| 768 | 768 | |
| 769 | - if($input_def['type'] != 'hidden'){ |
|
| 769 | + if ($input_def['type'] != 'hidden') { |
|
| 770 | 770 | $label = 'for="' . $input_def['name'] . '"'; |
| 771 | - if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){ |
|
| 771 | + if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) { |
|
| 772 | 772 | $label = ''; |
| 773 | 773 | } |
| 774 | 774 | $input = ' |
@@ -780,30 +780,30 @@ discard block |
||
| 780 | 780 | ' . $the_input . ' |
| 781 | 781 | </div> |
| 782 | 782 | </div>'; |
| 783 | - if(substr($input_def['name'], 0, 3) == 'is_'){ |
|
| 783 | + if (substr($input_def['name'], 0, 3) == 'is_') { |
|
| 784 | 784 | $the_form_option_content .= $input; |
| 785 | 785 | } |
| 786 | - else{ |
|
| 786 | + else { |
|
| 787 | 787 | $the_form_general_content .= $input; |
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | - else{ |
|
| 790 | + else { |
|
| 791 | 791 | $the_form_content_hidden .= ' |
| 792 | 792 | ' . $the_input; |
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | $the_form = '<form name="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" id="' . WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP . '_form" method="post" action="' . admin_url('admin-ajax.php') . '" >'; |
| 797 | - if( ctype_digit( (string) $itemToEdit ) ) { |
|
| 797 | + if (ctype_digit((string)$itemToEdit)) { |
|
| 798 | 798 | $the_form .= wpshop_form::form_input('action', 'action', 'wps_attribute_group_unit_update', 'hidden'); |
| 799 | - $the_form .= wp_nonce_field( 'update_attribute_unit_group', '_wpnonce' ); |
|
| 799 | + $the_form .= wp_nonce_field('update_attribute_unit_group', '_wpnonce'); |
|
| 800 | 800 | } else { |
| 801 | 801 | $the_form .= wpshop_form::form_input('action', 'action', 'wps_attribute_group_unit_new', 'hidden'); |
| 802 | - $the_form .= wp_nonce_field( 'save_new_attribute_unit_group', '_wpnonce' ); |
|
| 802 | + $the_form .= wp_nonce_field('save_new_attribute_unit_group', '_wpnonce'); |
|
| 803 | 803 | } |
| 804 | - $the_form .= wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden'); |
|
| 804 | + $the_form .= wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden'); |
|
| 805 | 805 | $the_form .= $the_form_content_hidden . $the_form_general_content; |
| 806 | - $the_form .= '<input type="button" value="' . __('Retour', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_group_edition" id="cancel_unit_group_edition" data-nonce="' . wp_create_nonce( 'load_attribute_unit_groups' ) . '"/> |
|
| 806 | + $the_form .= '<input type="button" value="' . __('Retour', 'wpshop') . '" class="button-primary alignright" name="cancel_unit_group_edition" id="cancel_unit_group_edition" data-nonce="' . wp_create_nonce('load_attribute_unit_groups') . '"/> |
|
| 807 | 807 | <input type="submit" value="' . __('Save', 'wpshop') . '" class="button-primary alignright" name="save_new_unit_group" id="save_new_unit_group" /> |
| 808 | 808 | </form> |
| 809 | 809 | <script type="text/javascript" > |
@@ -837,19 +837,19 @@ discard block |
||
| 837 | 837 | $current_currency = get_option('wpshop_shop_default_currency'); |
| 838 | 838 | |
| 839 | 839 | $currencies_options = ''; |
| 840 | - if ( !empty ($currency_group) ) { |
|
| 841 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE group_id = %d', $currency_group); |
|
| 840 | + if (!empty ($currency_group)) { |
|
| 841 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id = %d', $currency_group); |
|
| 842 | 842 | $currencies = $wpdb->get_results($query); |
| 843 | - foreach ( $currencies as $currency) { |
|
| 844 | - $currencies_options .= '<option value="'.$currency->id.'"'.(($currency->id == $current_currency) ? ' selected="selected"' : null).'>'.$currency->name.' ('.$currency->unit.')</option>'; |
|
| 843 | + foreach ($currencies as $currency) { |
|
| 844 | + $currencies_options .= '<option value="' . $currency->id . '"' . (($currency->id == $current_currency) ? ' selected="selected"' : null) . '>' . $currency->name . ' (' . $currency->unit . ')</option>'; |
|
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | 847 | else { |
| 848 | - foreach($wpshop_shop_currencies as $k => $v) { |
|
| 849 | - $currencies_options .= '<option value="'.$k.'"'.(($k==$current_currency) ? ' selected="selected"' : null).'>'.$k.' ('.$v.')</option>'; |
|
| 848 | + foreach ($wpshop_shop_currencies as $k => $v) { |
|
| 849 | + $currencies_options .= '<option value="' . $k . '"' . (($k == $current_currency) ? ' selected="selected"' : null) . '>' . $k . ' (' . $v . ')</option>'; |
|
| 850 | 850 | } |
| 851 | 851 | } |
| 852 | - return '<select name="wpshop_shop_default_currency" class="wpshop_currency_field" >'.$currencies_options.'</select>'; |
|
| 852 | + return '<select name="wpshop_shop_default_currency" class="wpshop_currency_field" >' . $currencies_options . '</select>'; |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | /** |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | global $wpdb; |
| 863 | 863 | |
| 864 | 864 | /** Get the _unit_group_id and _default_unit */ |
| 865 | - return $wpdb->get_row( $wpdb->prepare( 'SELECT _unit_group_id, _default_unit FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code=%s', array( $attribute_code ) ) ); |
|
| 865 | + return $wpdb->get_row($wpdb->prepare('SELECT _unit_group_id, _default_unit FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE code=%s', array($attribute_code))); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | /** |
@@ -874,15 +874,15 @@ discard block |
||
| 874 | 874 | * @return stdClass Object [_unit_group_id], [_default_unit] |
| 875 | 875 | */ |
| 876 | 876 | public static function get_the_attribute_unit_by_code_for_product($product_id, $attribute_code) { |
| 877 | - $unit = self::get_default_unit_attribute( $attribute_code ); |
|
| 877 | + $unit = self::get_default_unit_attribute($attribute_code); |
|
| 878 | 878 | |
| 879 | - if(empty($unit)) |
|
| 879 | + if (empty($unit)) |
|
| 880 | 880 | return null; |
| 881 | 881 | |
| 882 | 882 | $post_meta = get_post_meta($product_id, '_wpshop_product_metadata', true); |
| 883 | 883 | |
| 884 | 884 | /** Si on trouve une unité */ |
| 885 | - if(!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) |
|
| 885 | + if (!empty($post_meta) && !empty($post_meta['unit']) && !empty($post_meta['unit'][$attribute_code])) |
|
| 886 | 886 | $unit->_default_unit = $post_meta['unit'][$attribute_code]; |
| 887 | 887 | |
| 888 | 888 | return $unit; |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | public static function the_attribute_unit_by_code_for_product($product_id, $attribute_code) { |
| 898 | 898 | $unit = self::get_the_attribute_unit_by_code_for_product($product_id, $attribute_code); |
| 899 | 899 | |
| 900 | - if(empty($unit)) |
|
| 900 | + if (empty($unit)) |
|
| 901 | 901 | return null; |
| 902 | 902 | |
| 903 | 903 | echo self::get_the_subname_unit($unit->_unit_group_id, $unit->_default_unit); |
@@ -914,10 +914,10 @@ discard block |
||
| 914 | 914 | global $wpdb; |
| 915 | 915 | |
| 916 | 916 | /** Si pas d'unité ou de groupe, null */ |
| 917 | - if(0 === $unit_id || 0 === $group_id) |
|
| 917 | + if (0 === $unit_id || 0 === $group_id) |
|
| 918 | 918 | return null; |
| 919 | 919 | |
| 920 | - return $wpdb->get_var( $wpdb->prepare( 'SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) ); |
|
| 920 | + return $wpdb->get_var($wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array($group_id, $unit_id))); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -931,9 +931,9 @@ discard block |
||
| 931 | 931 | global $wpdb; |
| 932 | 932 | |
| 933 | 933 | /** Si pas d'unité ou de groupe, null */ |
| 934 | - if(0 === $unit_id || 0 === $group_id) |
|
| 934 | + if (0 === $unit_id || 0 === $group_id) |
|
| 935 | 935 | return null; |
| 936 | 936 | |
| 937 | - return $wpdb->get_var( $wpdb->prepare( 'SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array( $group_id, $unit_id ) ) ); |
|
| 937 | + return $wpdb->get_var($wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE group_id=%d AND id=%d', array($group_id, $unit_id))); |
|
| 938 | 938 | } |
| 939 | 939 | } |
@@ -43,42 +43,42 @@ discard block |
||
| 43 | 43 | public $pageMessage = ''; |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | - * Get the url listing slug of the current class |
|
| 47 | - * |
|
| 48 | - * @return string The table of the class |
|
| 49 | - */ |
|
| 46 | + * Get the url listing slug of the current class |
|
| 47 | + * |
|
| 48 | + * @return string The table of the class |
|
| 49 | + */ |
|
| 50 | 50 | function setMessage($message){ |
| 51 | 51 | $this->pageMessage = $message; |
| 52 | 52 | } |
| 53 | 53 | /** |
| 54 | - * Get the url listing slug of the current class |
|
| 55 | - * |
|
| 56 | - * @return string The table of the class |
|
| 57 | - */ |
|
| 54 | + * Get the url listing slug of the current class |
|
| 55 | + * |
|
| 56 | + * @return string The table of the class |
|
| 57 | + */ |
|
| 58 | 58 | function getListingSlug(){ |
| 59 | 59 | return self::urlSlugListing; |
| 60 | 60 | } |
| 61 | 61 | /** |
| 62 | - * Get the url edition slug of the current class |
|
| 63 | - * |
|
| 64 | - * @return string The table of the class |
|
| 65 | - */ |
|
| 62 | + * Get the url edition slug of the current class |
|
| 63 | + * |
|
| 64 | + * @return string The table of the class |
|
| 65 | + */ |
|
| 66 | 66 | public static function getEditionSlug(){ |
| 67 | 67 | return self::urlSlugEdition; |
| 68 | 68 | } |
| 69 | 69 | /** |
| 70 | - * Get the database table of the current class |
|
| 71 | - * |
|
| 72 | - * @return string The table of the class |
|
| 73 | - */ |
|
| 70 | + * Get the database table of the current class |
|
| 71 | + * |
|
| 72 | + * @return string The table of the class |
|
| 73 | + */ |
|
| 74 | 74 | public static function getDbTable(){ |
| 75 | 75 | return self::dbTable; |
| 76 | 76 | } |
| 77 | 77 | /** |
| 78 | - * Define the title of the page |
|
| 79 | - * |
|
| 80 | - * @return string $title The title of the page looking at the environnement |
|
| 81 | - */ |
|
| 78 | + * Define the title of the page |
|
| 79 | + * |
|
| 80 | + * @return string $title The title of the page looking at the environnement |
|
| 81 | + */ |
|
| 82 | 82 | function pageTitle(){ |
| 83 | 83 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : ''; |
| 84 | 84 | $objectInEdition = isset($_REQUEST['id']) ? wpshop_tools::varSanitizer($_REQUEST['id']) : ''; |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | - * Define the different message and action after an action is send through the element interface |
|
| 100 | - */ |
|
| 99 | + * Define the different message and action after an action is send through the element interface |
|
| 100 | + */ |
|
| 101 | 101 | function elementAction(){ |
| 102 | 102 | global $wpdb, $initialEavData; |
| 103 | 103 | $pageMessage = $actionResult = ''; |
@@ -355,14 +355,14 @@ discard block |
||
| 355 | 355 | self::setMessage($pageMessage); |
| 356 | 356 | } |
| 357 | 357 | /** |
| 358 | - * Return the list page content, containing the table that present the item list |
|
| 359 | - * |
|
| 360 | - * @return string $listItemOutput The html code that output the item list |
|
| 361 | - */ |
|
| 358 | + * Return the list page content, containing the table that present the item list |
|
| 359 | + * |
|
| 360 | + * @return string $listItemOutput The html code that output the item list |
|
| 361 | + */ |
|
| 362 | 362 | function elementList() { |
| 363 | - //Create an instance of our package class... |
|
| 364 | - $wpshop_list_table = new wpshop_attributes_set_custom_List_table(); |
|
| 365 | - //Fetch, prepare, sort, and filter our data... |
|
| 363 | + //Create an instance of our package class... |
|
| 364 | + $wpshop_list_table = new wpshop_attributes_set_custom_List_table(); |
|
| 365 | + //Fetch, prepare, sort, and filter our data... |
|
| 366 | 366 | $status="'valid', 'moderated'"; |
| 367 | 367 | $attribute_set_list = array(); |
| 368 | 368 | if(!empty($_REQUEST['attribute_groups_status'])){ |
@@ -423,10 +423,10 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /** |
| 426 | - * Return the page content to add a new item |
|
| 427 | - * |
|
| 428 | - * @return string The html code that output the interface for adding a nem item |
|
| 429 | - */ |
|
| 426 | + * Return the page content to add a new item |
|
| 427 | + * |
|
| 428 | + * @return string The html code that output the interface for adding a nem item |
|
| 429 | + */ |
|
| 430 | 430 | function elementEdition($itemToEdit = '') { |
| 431 | 431 | global $attribute_hidden_field; |
| 432 | 432 | |
@@ -574,10 +574,10 @@ discard block |
||
| 574 | 574 | return $the_form; |
| 575 | 575 | } |
| 576 | 576 | /** |
| 577 | - * Return the different button to save the item currently being added or edited |
|
| 578 | - * |
|
| 579 | - * @return string $currentPageButton The html output code with the different button to add to the interface |
|
| 580 | - */ |
|
| 577 | + * Return the different button to save the item currently being added or edited |
|
| 578 | + * |
|
| 579 | + * @return string $currentPageButton The html output code with the different button to add to the interface |
|
| 580 | + */ |
|
| 581 | 581 | function getPageFormButton($element_id = 0){ |
| 582 | 582 | $action = isset($_REQUEST['action']) ? wpshop_tools::varSanitizer($_REQUEST['action']) : 'add'; |
| 583 | 583 | $currentPageButton = ''; |
@@ -586,13 +586,13 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | /** |
| 589 | - * Get the existing element list into database |
|
| 590 | - * |
|
| 591 | - * @param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned |
|
| 592 | - * @param string $elementStatus optionnal The status of element to get into database. Default is set to valid element |
|
| 593 | - * |
|
| 594 | - * @return object $elements A wordpress database object containing the element list |
|
| 595 | - */ |
|
| 589 | + * Get the existing element list into database |
|
| 590 | + * |
|
| 591 | + * @param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned |
|
| 592 | + * @param string $elementStatus optionnal The status of element to get into database. Default is set to valid element |
|
| 593 | + * |
|
| 594 | + * @return object $elements A wordpress database object containing the element list |
|
| 595 | + */ |
|
| 596 | 596 | public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = ''){ |
| 597 | 597 | global $wpdb; |
| 598 | 598 | $elements = array(); |
@@ -663,12 +663,12 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | /** |
| 666 | - * Display inteface allowing to manage the attribute set and group details |
|
| 667 | - * |
|
| 668 | - * @param object $atributeSetId The element's identifier we have to manage the details for |
|
| 669 | - * |
|
| 670 | - * @return string $attributeSetDetailsManagement The html output of management interface |
|
| 671 | - */ |
|
| 666 | + * Display inteface allowing to manage the attribute set and group details |
|
| 667 | + * |
|
| 668 | + * @param object $atributeSetId The element's identifier we have to manage the details for |
|
| 669 | + * |
|
| 670 | + * @return string $attributeSetDetailsManagement The html output of management interface |
|
| 671 | + */ |
|
| 672 | 672 | public static function attributeSetDetailsManagement($attributeSetId = ''){ |
| 673 | 673 | global $validAttributeList; global $wpdb; |
| 674 | 674 | $user_more_script = $add_button = ''; |
@@ -944,13 +944,13 @@ discard block |
||
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | /** |
| 947 | - * Get the complete details about attributes sets |
|
| 948 | - * |
|
| 949 | - * @param integer $attributeSetId The attribute set identifier we want to get the details for |
|
| 950 | - * @param string $attributeSetStatus optionnal The attribute set status. Allows to define if we want all attribute sets or a deleted or valid and so on |
|
| 951 | - * |
|
| 952 | - * @return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set |
|
| 953 | - */ |
|
| 947 | + * Get the complete details about attributes sets |
|
| 948 | + * |
|
| 949 | + * @param integer $attributeSetId The attribute set identifier we want to get the details for |
|
| 950 | + * @param string $attributeSetStatus optionnal The attribute set status. Allows to define if we want all attribute sets or a deleted or valid and so on |
|
| 951 | + * |
|
| 952 | + * @return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set |
|
| 953 | + */ |
|
| 954 | 954 | public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'"){ |
| 955 | 955 | global $wpdb, $validAttributeList; |
| 956 | 956 | $attributeSetDetailsGroups = ''; |
@@ -1002,12 +1002,12 @@ discard block |
||
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | /** |
| 1005 | - * Get the attribute list of attribute not associated to he set we are editing |
|
| 1006 | - * |
|
| 1007 | - * @param integer $attributeSetId The attribute set identifier we want to get the details for |
|
| 1008 | - * |
|
| 1009 | - * @return array $attributeSetDetails The List of attribute not affected |
|
| 1010 | - */ |
|
| 1005 | + * Get the attribute list of attribute not associated to he set we are editing |
|
| 1006 | + * |
|
| 1007 | + * @param integer $attributeSetId The attribute set identifier we want to get the details for |
|
| 1008 | + * |
|
| 1009 | + * @return array $attributeSetDetails The List of attribute not affected |
|
| 1010 | + */ |
|
| 1011 | 1011 | public static function get_not_affected_attribute($attributeSetId, $entity_set_id){ |
| 1012 | 1012 | global $wpdb; |
| 1013 | 1013 | |
@@ -1042,12 +1042,12 @@ discard block |
||
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | /** |
| 1045 | - * Get the existing attribute set for an entity |
|
| 1046 | - * |
|
| 1047 | - * @param integer $entityId The entity identifier we want to get the entity set list for |
|
| 1048 | - * |
|
| 1049 | - * @return object $entitySets The entity sets list for the given entity |
|
| 1050 | - */ |
|
| 1045 | + * Get the existing attribute set for an entity |
|
| 1046 | + * |
|
| 1047 | + * @param integer $entityId The entity identifier we want to get the entity set list for |
|
| 1048 | + * |
|
| 1049 | + * @return object $entitySets The entity sets list for the given entity |
|
| 1050 | + */ |
|
| 1051 | 1051 | public static function get_attribute_set_list_for_entity($entityId){ |
| 1052 | 1052 | global $wpdb; |
| 1053 | 1053 | $entitySetList = ''; |
@@ -1064,10 +1064,10 @@ discard block |
||
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | /** |
| 1067 | - * Traduit le shortcode et affiche un groupe d'attributs |
|
| 1068 | - * @param array $atts : tableau de param�tre du shortcode |
|
| 1069 | - * @return mixed |
|
| 1070 | - **/ |
|
| 1067 | + * Traduit le shortcode et affiche un groupe d'attributs |
|
| 1068 | + * @param array $atts : tableau de param�tre du shortcode |
|
| 1069 | + * @return mixed |
|
| 1070 | + **/ |
|
| 1071 | 1071 | function wpshop_att_group_func($atts) { |
| 1072 | 1072 | global $wpdb; |
| 1073 | 1073 | |
@@ -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' ) ) { |
@@ -88,9 +90,9 @@ discard block |
||
| 88 | 90 | if($action == 'edit'){ |
| 89 | 91 | $editedItem = self::getElement($objectInEdition); |
| 90 | 92 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), __($editedItem->name, 'wpshop'), __($editedItem->entity, 'wpshop')); |
| 93 | + } elseif($action == 'add') { |
|
| 94 | + $title = __(self::pageAddingTitle, 'wpshop'); |
|
| 91 | 95 | } |
| 92 | - elseif($action == 'add') |
|
| 93 | - $title = __(self::pageAddingTitle, 'wpshop'); |
|
| 94 | 96 | } |
| 95 | 97 | return $title; |
| 96 | 98 | } |
@@ -114,8 +116,7 @@ discard block |
||
| 114 | 116 | if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){ |
| 115 | 117 | $editedElement = self::getElement($saveditem); |
| 116 | 118 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>'); |
| 117 | - } |
|
| 118 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 119 | + } elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 119 | 120 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 120 | 121 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>'); |
| 121 | 122 | } |
@@ -141,14 +142,14 @@ discard block |
||
| 141 | 142 | if(current_user_can('wpshop_edit_attribute_set')){ |
| 142 | 143 | $attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 143 | 144 | if($pageAction == 'delete'){ |
| 144 | - if(current_user_can('wpshop_delete_attribute_set')) |
|
| 145 | - $attribute_set_parameter['status'] = 'deleted'; |
|
| 146 | - else |
|
| 147 | - $actionResult = 'userNotAllowedForActionDelete'; |
|
| 145 | + if(current_user_can('wpshop_delete_attribute_set')) { |
|
| 146 | + $attribute_set_parameter['status'] = 'deleted'; |
|
| 147 | + } else { |
|
| 148 | + $actionResult = 'userNotAllowedForActionDelete'; |
|
| 149 | + } |
|
| 148 | 150 | } |
| 149 | 151 | $actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable()); |
| 150 | - } |
|
| 151 | - else{ |
|
| 152 | + } else{ |
|
| 152 | 153 | $actionResult = 'userNotAllowedForActionEdit'; |
| 153 | 154 | } |
| 154 | 155 | |
@@ -199,17 +200,15 @@ discard block |
||
| 199 | 200 | |
| 200 | 201 | } |
| 201 | 202 | |
| 202 | - } |
|
| 203 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 203 | + } elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 204 | 204 | if(current_user_can('wpshop_delete_attribute_set')){ |
| 205 | 205 | $attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 206 | 206 | $attribute_set_parameter['status'] = 'deleted'; |
| 207 | 207 | $actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable()); |
| 208 | + } else { |
|
| 209 | + $actionResult = 'userNotAllowedForActionDelete'; |
|
| 208 | 210 | } |
| 209 | - else |
|
| 210 | - $actionResult = 'userNotAllowedForActionDelete'; |
|
| 211 | - } |
|
| 212 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 211 | + } elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 213 | 212 | if(current_user_can('wpshop_add_attribute_set')){ |
| 214 | 213 | $attribute_set_parameter['creation_date'] = date('Y-m-d H:i:s'); |
| 215 | 214 | $actionResult = wpshop_database::save($attribute_set_parameter, self::getDbTable()); |
@@ -244,9 +243,9 @@ discard block |
||
| 244 | 243 | } |
| 245 | 244 | } |
| 246 | 245 | } |
| 246 | + } else { |
|
| 247 | + $actionResult = 'userNotAllowedForActionAdd'; |
|
| 247 | 248 | } |
| 248 | - else |
|
| 249 | - $actionResult = 'userNotAllowedForActionAdd'; |
|
| 250 | 249 | } |
| 251 | 250 | |
| 252 | 251 | /* When an action is launched and there is a result message */ |
@@ -255,11 +254,12 @@ discard block |
||
| 255 | 254 | /****************************************************************************/ |
| 256 | 255 | if($actionResult != ''){ |
| 257 | 256 | $elementIdentifierForMessage = __('the attribute group', 'wpshop'); |
| 258 | - if(!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>'; |
|
| 257 | + if(!empty($attribute_set_parameter['name'])) { |
|
| 258 | + $elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>'; |
|
| 259 | + } |
|
| 259 | 260 | if($actionResult == 'error'){/* CHANGE HERE FOR SPECIFIC CASE */ |
| 260 | 261 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage); |
| 261 | - } |
|
| 262 | - elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){ |
|
| 262 | + } elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){ |
|
| 263 | 263 | /*****************************************************************************************************************/ |
| 264 | 264 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ******************/ |
| 265 | 265 | /*****************************************************************************************************************/ |
@@ -284,13 +284,11 @@ discard block |
||
| 284 | 284 | $validElement = $wpdb->get_var($query); |
| 285 | 285 | if(!empty($validElement)){ |
| 286 | 286 | $query = $wpdb->prepare("UPDATE " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " SET position = %d, attribute_group_id = %d, last_update_date = NOW() WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $i, $groupId, $element, 'valid', $id); |
| 287 | - } |
|
| 288 | - else{ |
|
| 287 | + } else{ |
|
| 289 | 288 | $query = $wpdb->prepare("INSERT INTO " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " (id, status, creation_date, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, position) VALUES ('', 'valid', NOW(), %d, %d, %d, %d, %d)", $attribute_set_parameter['entity_id'], $id, $groupId, $element, $i); |
| 290 | 289 | } |
| 291 | 290 | $wpdb->query($query); |
| 292 | - } |
|
| 293 | - else{ |
|
| 291 | + } else{ |
|
| 294 | 292 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0), 'position' => 0), array('attribute_id' => $element, 'status' => 'valid', 'attribute_set_id' => $id)); |
| 295 | 293 | } |
| 296 | 294 | $i++; |
@@ -344,13 +342,14 @@ discard block |
||
| 344 | 342 | $pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage); |
| 345 | 343 | /* if(($pageAction == 'edit') || ($pageAction == 'save')) |
| 346 | 344 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 347 | - else */if($pageAction == 'add') |
|
| 348 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id)); |
|
| 349 | - elseif($pageAction == 'delete') |
|
| 350 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id)); |
|
| 345 | + else */if($pageAction == 'add') { |
|
| 346 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id)); |
|
| 347 | + } elseif($pageAction == 'delete') { |
|
| 348 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id)); |
|
| 349 | + } |
|
| 350 | + } elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) { |
|
| 351 | + $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
|
| 351 | 352 | } |
| 352 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 353 | - $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
|
| 354 | 353 | } |
| 355 | 354 | |
| 356 | 355 | self::setMessage($pageMessage); |
@@ -391,7 +390,9 @@ discard block |
||
| 391 | 390 | } |
| 392 | 391 | } |
| 393 | 392 | if(!empty($attribute_set_list[$i]['content'])){ |
| 394 | - if($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2); |
|
| 393 | + if($has_att) { |
|
| 394 | + $attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2); |
|
| 395 | + } |
|
| 395 | 396 | $attribute_set_list[$i]['content'] .= '</div>'; |
| 396 | 397 | } |
| 397 | 398 | } |
@@ -433,8 +434,9 @@ discard block |
||
| 433 | 434 | $bloc_list=array(); |
| 434 | 435 | |
| 435 | 436 | $editedItem = ''; |
| 436 | - if($itemToEdit != '') |
|
| 437 | - $editedItem = self::getElement($itemToEdit); |
|
| 437 | + if($itemToEdit != '') { |
|
| 438 | + $editedItem = self::getElement($itemToEdit); |
|
| 439 | + } |
|
| 438 | 440 | |
| 439 | 441 | foreach($dbFieldList as $input_key => $input_def){ |
| 440 | 442 | $input_name = $input_def['name']; |
@@ -446,14 +448,16 @@ discard block |
||
| 446 | 448 | |
| 447 | 449 | /* Get value by checking current object type */ |
| 448 | 450 | $currentFieldValue = $input_value; |
| 449 | - if(is_object($editedItem)) |
|
| 450 | - $currentFieldValue = $editedItem->$input_name; |
|
| 451 | - elseif(($attributeAction != '') && ($attributeFormValue != '')) |
|
| 452 | - $currentFieldValue = $attributeFormValue; |
|
| 451 | + if(is_object($editedItem)) { |
|
| 452 | + $currentFieldValue = $editedItem->$input_name; |
|
| 453 | + } elseif(($attributeAction != '') && ($attributeFormValue != '')) { |
|
| 454 | + $currentFieldValue = $attributeFormValue; |
|
| 455 | + } |
|
| 453 | 456 | |
| 454 | 457 | /* Check if the field must be hidden */ |
| 455 | - if(in_array($input_name, $attribute_hidden_field)) |
|
| 456 | - $input_def['type'] = 'hidden'; |
|
| 458 | + if(in_array($input_name, $attribute_hidden_field)) { |
|
| 459 | + $input_def['type'] = 'hidden'; |
|
| 460 | + } |
|
| 457 | 461 | if ($input_name == 'entity_id') { |
| 458 | 462 | $input_def['type'] = 'select'; |
| 459 | 463 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
@@ -475,8 +479,7 @@ discard block |
||
| 475 | 479 | } |
| 476 | 480 | |
| 477 | 481 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 478 | - } |
|
| 479 | - else { |
|
| 482 | + } else { |
|
| 480 | 483 | if(in_array($input_name, array('status', 'default_set'))){ |
| 481 | 484 | $input_def['type'] = 'checkbox'; |
| 482 | 485 | switch($input_name){ |
@@ -503,8 +506,7 @@ discard block |
||
| 503 | 506 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_name.'" ><label for="'.$input_def_id.'" >' . __($input_name, 'wpshop') . '</label></td> |
| 504 | 507 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_name.'" >' . $the_input . '</td> |
| 505 | 508 | </tr>'; |
| 506 | - } |
|
| 507 | - else{ |
|
| 509 | + } else{ |
|
| 508 | 510 | $the_form_content_hidden .= ' |
| 509 | 511 | ' . $the_input; |
| 510 | 512 | } |
@@ -538,13 +540,15 @@ discard block |
||
| 538 | 540 | ' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . ' |
| 539 | 541 | <div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode.'" >'; |
| 540 | 542 | |
| 541 | - if(($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) |
|
| 542 | - $the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
|
| 543 | - elseif(current_user_can('wpshop_edit_attribute_set')) |
|
| 544 | - $the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
|
| 543 | + if(($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) { |
|
| 544 | + $the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
|
| 545 | + } elseif(current_user_can('wpshop_edit_attribute_set')) { |
|
| 546 | + $the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
|
| 547 | + } |
|
| 545 | 548 | |
| 546 | - if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) |
|
| 547 | - $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 549 | + if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) { |
|
| 550 | + $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 551 | + } |
|
| 548 | 552 | |
| 549 | 553 | $the_form .= ' |
| 550 | 554 | </div> |
@@ -650,8 +654,7 @@ discard block |
||
| 650 | 654 | if(($elementId == '') || ($resultList == 'all')) |
| 651 | 655 | { |
| 652 | 656 | $elements = $wpdb->get_results($query); |
| 653 | - } |
|
| 654 | - else |
|
| 657 | + } else |
|
| 655 | 658 | { |
| 656 | 659 | $elements = $wpdb->get_row($query); |
| 657 | 660 | } |
@@ -1149,8 +1152,7 @@ discard block |
||
| 1149 | 1152 | $the_input .= '<option'.$selected.' value="'.$attr_set->id.'_'.$set_details['id'].'">'.__($set_details['name'],'wpshop').'</option>'; |
| 1150 | 1153 | } |
| 1151 | 1154 | $the_input .= '</optgroup>'; |
| 1152 | - } |
|
| 1153 | - else { |
|
| 1155 | + } else { |
|
| 1154 | 1156 | $the_input .= '<option value="'.$attr_set->id.'">'.__($attr_set->name, 'wpshop').'</option>'; |
| 1155 | 1157 | } |
| 1156 | 1158 | } |
@@ -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 | /** |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @package wpshop |
| 22 | 22 | * @subpackage librairies |
| 23 | 23 | */ |
| 24 | -class wpshop_attributes_set{ |
|
| 24 | +class wpshop_attributes_set { |
|
| 25 | 25 | /* Define the database table used in the current class */ |
| 26 | 26 | const dbTable = WPSHOP_DBT_ATTRIBUTE_SET; |
| 27 | 27 | /* Define the url listing slug used in the current class */ |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @return string The table of the class |
| 49 | 49 | */ |
| 50 | - function setMessage($message){ |
|
| 50 | + function setMessage($message) { |
|
| 51 | 51 | $this->pageMessage = $message; |
| 52 | 52 | } |
| 53 | 53 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return string The table of the class |
| 57 | 57 | */ |
| 58 | - function getListingSlug(){ |
|
| 58 | + function getListingSlug() { |
|
| 59 | 59 | return self::urlSlugListing; |
| 60 | 60 | } |
| 61 | 61 | /** |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return string The table of the class |
| 65 | 65 | */ |
| 66 | - public static function getEditionSlug(){ |
|
| 66 | + public static function getEditionSlug() { |
|
| 67 | 67 | return self::urlSlugEdition; |
| 68 | 68 | } |
| 69 | 69 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return string The table of the class |
| 73 | 73 | */ |
| 74 | - public static function getDbTable(){ |
|
| 74 | + public static function getDbTable() { |
|
| 75 | 75 | return self::dbTable; |
| 76 | 76 | } |
| 77 | 77 | /** |
@@ -79,17 +79,17 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return string $title The title of the page looking at the environnement |
| 81 | 81 | */ |
| 82 | - function pageTitle(){ |
|
| 82 | + function pageTitle() { |
|
| 83 | 83 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 84 | 84 | $objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : ''; |
| 85 | 85 | |
| 86 | - $title = __(self::pageTitle, 'wpshop' ); |
|
| 87 | - if($action != ''){ |
|
| 88 | - if($action == 'edit'){ |
|
| 86 | + $title = __(self::pageTitle, 'wpshop'); |
|
| 87 | + if ($action != '') { |
|
| 88 | + if ($action == 'edit') { |
|
| 89 | 89 | $editedItem = self::getElement($objectInEdition); |
| 90 | 90 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), __($editedItem->name, 'wpshop'), __($editedItem->entity, 'wpshop')); |
| 91 | 91 | } |
| 92 | - elseif($action == 'add') |
|
| 92 | + elseif ($action == 'add') |
|
| 93 | 93 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 94 | 94 | } |
| 95 | 95 | return $title; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * Define the different message and action after an action is send through the element interface |
| 100 | 100 | */ |
| 101 | - function elementAction(){ |
|
| 101 | + function elementAction() { |
|
| 102 | 102 | global $wpdb, $initialEavData; |
| 103 | 103 | $pageMessage = $actionResult = ''; |
| 104 | 104 | |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | /****************************************************************************/ |
| 108 | 108 | $saveditem = isset($_REQUEST['saveditem']) ? sanitize_text_field($_REQUEST['saveditem']) : ''; |
| 109 | 109 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 110 | - $id = !empty( $_REQUEST['id'] ) ? (int)$_REQUEST['id'] : 0; |
|
| 111 | - if(!empty($action) && ($action=='activate') && (!empty($id))){ |
|
| 110 | + $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; |
|
| 111 | + if (!empty($action) && ($action == 'activate') && (!empty($id))) { |
|
| 112 | 112 | $query = $wpdb->update(self::getDbTable(), array('status'=>'moderated'), array('id'=>sanitize_key($id))); |
| 113 | 113 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . sanitize_key($id))); |
| 114 | 114 | } |
| 115 | - if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){ |
|
| 115 | + if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) { |
|
| 116 | 116 | $editedElement = self::getElement($saveditem); |
| 117 | 117 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>'); |
| 118 | 118 | } |
| 119 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 119 | + elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) { |
|
| 120 | 120 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 121 | 121 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->name . '</span>'); |
| 122 | 122 | } |
@@ -124,63 +124,63 @@ discard block |
||
| 124 | 124 | /* Define the database operation type from action launched by the user */ |
| 125 | 125 | /************************* GENERIC ****************************/ |
| 126 | 126 | /*************************************************************************/ |
| 127 | - $attribute_set_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 128 | - $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action']=='delete')) ? sanitize_text_field($_GET['action']) : ''); |
|
| 127 | + $attribute_set_parameter = !empty($_REQUEST[self::getDbTable()]) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 128 | + $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action'] == 'delete')) ? sanitize_text_field($_GET['action']) : ''); |
|
| 129 | 129 | $id = isset($attribute_set_parameter['id']) ? sanitize_key($attribute_set_parameter['id']) : ((!empty($_GET['id'])) ? sanitize_key($_GET['id']) : ''); |
| 130 | 130 | $set_section = !empty($attribute_set_parameter['set_section']) ? sanitize_text_field($attribute_set_parameter['set_section']) : ''; |
| 131 | 131 | unset($attribute_set_parameter['set_section']); |
| 132 | 132 | |
| 133 | 133 | /* Specific case for the attribute groups */ |
| 134 | - if(!isset($attribute_set_parameter['status'])){ |
|
| 134 | + if (!isset($attribute_set_parameter['status'])) { |
|
| 135 | 135 | $attribute_set_parameter['status'] = 'moderated'; |
| 136 | 136 | } |
| 137 | - if(!isset($attribute_set_parameter['default_set'])){ |
|
| 137 | + if (!isset($attribute_set_parameter['default_set'])) { |
|
| 138 | 138 | $attribute_set_parameter['default_set'] = 'no'; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue') || ($pageAction == 'delete'))){ |
|
| 142 | - if(current_user_can('wpshop_edit_attribute_set')){ |
|
| 141 | + if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue') || ($pageAction == 'delete'))) { |
|
| 142 | + if (current_user_can('wpshop_edit_attribute_set')) { |
|
| 143 | 143 | $attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 144 | - if($pageAction == 'delete'){ |
|
| 145 | - if(current_user_can('wpshop_delete_attribute_set')) |
|
| 144 | + if ($pageAction == 'delete') { |
|
| 145 | + if (current_user_can('wpshop_delete_attribute_set')) |
|
| 146 | 146 | $attribute_set_parameter['status'] = 'deleted'; |
| 147 | 147 | else |
| 148 | 148 | $actionResult = 'userNotAllowedForActionDelete'; |
| 149 | 149 | } |
| 150 | 150 | $actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable()); |
| 151 | 151 | } |
| 152 | - else{ |
|
| 152 | + else { |
|
| 153 | 153 | $actionResult = 'userNotAllowedForActionEdit'; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** Address display managment **/ |
| 157 | - if ( !empty($id) ) { |
|
| 157 | + if (!empty($id)) { |
|
| 158 | 158 | $is_billing = $is_shipping = false; |
| 159 | 159 | /** Get billing option **/ |
| 160 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 161 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 160 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 161 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 162 | 162 | |
| 163 | - if( !empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $id ) { |
|
| 163 | + if (!empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $id) { |
|
| 164 | 164 | $is_billing = true; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if( !empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $id ) { |
|
| 167 | + if (!empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $id) { |
|
| 168 | 168 | $is_shipping = true; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $attribute_group_order = !empty( $_REQUEST['attribute_group_order'] ) ? (array) $_REQUEST['attribute_group_order'] : array(); |
|
| 171 | + $attribute_group_order = !empty($_REQUEST['attribute_group_order']) ? (array)$_REQUEST['attribute_group_order'] : array(); |
|
| 172 | 172 | |
| 173 | 173 | $attribute_display = array(); |
| 174 | - if ( !empty($attribute_group_order)) { |
|
| 174 | + if (!empty($attribute_group_order)) { |
|
| 175 | 175 | |
| 176 | - foreach( $attribute_group_order as $group_id => $group_def ) { |
|
| 176 | + foreach ($attribute_group_order as $group_id => $group_def) { |
|
| 177 | 177 | $end_line_element_id = 0; |
| 178 | - if( $group_id != 'newOrderNotAffectedAttribute' ) { |
|
| 179 | - $attribute_display[ str_replace('newOrder', '', $group_id) ] = explode( ',', $group_def ); |
|
| 178 | + if ($group_id != 'newOrderNotAffectedAttribute') { |
|
| 179 | + $attribute_display[str_replace('newOrder', '', $group_id)] = explode(',', $group_def); |
|
| 180 | 180 | |
| 181 | - foreach( $attribute_display[ str_replace('newOrder', '', $group_id) ] as $att_id => $att ) { |
|
| 182 | - if( $att == 'wps-attribute-end-line' ) { |
|
| 183 | - $attribute_display[ str_replace('newOrder', '', $group_id) ][$att_id] = 'wps-attribute-end-line-'.$end_line_element_id; |
|
| 181 | + foreach ($attribute_display[str_replace('newOrder', '', $group_id)] as $att_id => $att) { |
|
| 182 | + if ($att == 'wps-attribute-end-line') { |
|
| 183 | + $attribute_display[str_replace('newOrder', '', $group_id)][$att_id] = 'wps-attribute-end-line-' . $end_line_element_id; |
|
| 184 | 184 | $end_line_element_id++; |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -190,21 +190,21 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | |
| 193 | - if ( $is_billing && !$is_shipping ) { |
|
| 193 | + if ($is_billing && !$is_shipping) { |
|
| 194 | 194 | $billing_option['display_model'] = $attribute_display; |
| 195 | - update_option( 'wpshop_billing_address', $billing_option ); |
|
| 195 | + update_option('wpshop_billing_address', $billing_option); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( !$is_billing && $is_shipping ) { |
|
| 198 | + if (!$is_billing && $is_shipping) { |
|
| 199 | 199 | $shipping_option['display_model'] = $attribute_display; |
| 200 | - update_option( 'wpshop_shipping_address_choice', $shipping_option ); |
|
| 200 | + update_option('wpshop_shipping_address_choice', $shipping_option); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | } |
| 206 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 207 | - if(current_user_can('wpshop_delete_attribute_set')){ |
|
| 206 | + elseif (($pageAction != '') && (($pageAction == 'delete'))) { |
|
| 207 | + if (current_user_can('wpshop_delete_attribute_set')) { |
|
| 208 | 208 | $attribute_set_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 209 | 209 | $attribute_set_parameter['status'] = 'deleted'; |
| 210 | 210 | $actionResult = wpshop_database::update($attribute_set_parameter, $id, self::getDbTable()); |
@@ -212,32 +212,32 @@ discard block |
||
| 212 | 212 | else |
| 213 | 213 | $actionResult = 'userNotAllowedForActionDelete'; |
| 214 | 214 | } |
| 215 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 216 | - if(current_user_can('wpshop_add_attribute_set')){ |
|
| 215 | + elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) { |
|
| 216 | + if (current_user_can('wpshop_add_attribute_set')) { |
|
| 217 | 217 | $attribute_set_parameter['creation_date'] = date('Y-m-d H:i:s'); |
| 218 | 218 | $actionResult = wpshop_database::save($attribute_set_parameter, self::getDbTable()); |
| 219 | 219 | $id = $wpdb->insert_id; |
| 220 | - if ( empty( $set_section ) ) { |
|
| 221 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql',0), 'code' => 'general', 'default_group' => 'yes', 'name' => __('Main information', 'wpshop'))); |
|
| 220 | + if (empty($set_section)) { |
|
| 221 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql', 0), 'code' => 'general', 'default_group' => 'yes', 'name' => __('Main information', 'wpshop'))); |
|
| 222 | 222 | |
| 223 | 223 | $selected_entity_query = $wpdb->prepare("SELECT post_name FROM " . $wpdb->posts . " WHERE ID = %d", $attribute_set_parameter['entity_id']); |
| 224 | 224 | if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT == $wpdb->get_var($selected_entity_query)) { |
| 225 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql',0), 'code' => 'prices', 'default_group' => 'no', 'name' => __('Prices', 'wpshop'))); |
|
| 225 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status' => 'valid', 'attribute_set_id' => $id, 'position' => 1, 'creation_date' => current_time('mysql', 0), 'code' => 'prices', 'default_group' => 'no', 'name' => __('Prices', 'wpshop'))); |
|
| 226 | 226 | $price_attribute_set_id = $wpdb->insert_id; |
| 227 | 227 | $price_tab = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 228 | 228 | unset($price_tab[array_search(WPSHOP_COST_OF_POSTAGE, $price_tab)]); |
| 229 | - foreach($price_tab as $price_code){ |
|
| 229 | + foreach ($price_tab as $price_code) { |
|
| 230 | 230 | $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code = %s", $price_code); |
| 231 | 231 | $attribute_id = $wpdb->get_var($query); |
| 232 | - switch($price_code){ |
|
| 232 | + switch ($price_code) { |
|
| 233 | 233 | case WPSHOP_PRODUCT_PRICE_HT: |
| 234 | - $position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 1 : 3; |
|
| 234 | + $position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 1 : 3; |
|
| 235 | 235 | break; |
| 236 | 236 | case WPSHOP_PRODUCT_PRICE_TAX: |
| 237 | 237 | $position = 2; |
| 238 | 238 | break; |
| 239 | 239 | case WPSHOP_PRODUCT_PRICE_TTC: |
| 240 | - $position = ( WPSHOP_PRODUCT_PRICE_PILOT == 'HT' ) ? 3 : 1; |
|
| 240 | + $position = (WPSHOP_PRODUCT_PRICE_PILOT == 'HT') ? 3 : 1; |
|
| 241 | 241 | break; |
| 242 | 242 | case WPSHOP_PRODUCT_PRICE_TAX_AMOUNT: |
| 243 | 243 | $position = 4; |
@@ -256,47 +256,47 @@ discard block |
||
| 256 | 256 | /************ CHANGE THE FIELD NAME TO TAKE TO DISPLAY *************/ |
| 257 | 257 | /************ CHANGE ERROR MESSAGE FOR SPECIFIC CASE *************/ |
| 258 | 258 | /****************************************************************************/ |
| 259 | - if($actionResult != ''){ |
|
| 259 | + if ($actionResult != '') { |
|
| 260 | 260 | $elementIdentifierForMessage = __('the attribute group', 'wpshop'); |
| 261 | - if(!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>'; |
|
| 262 | - if($actionResult == 'error'){/* CHANGE HERE FOR SPECIFIC CASE */ |
|
| 261 | + if (!empty($attribute_set_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_set_parameter['name'] . '</span>'; |
|
| 262 | + if ($actionResult == 'error') {/* CHANGE HERE FOR SPECIFIC CASE */ |
|
| 263 | 263 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage); |
| 264 | 264 | } |
| 265 | - elseif(($actionResult == 'done') || ($actionResult == 'nothingToUpdate')){ |
|
| 265 | + elseif (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) { |
|
| 266 | 266 | /*****************************************************************************************************************/ |
| 267 | 267 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ******************/ |
| 268 | 268 | /*****************************************************************************************************************/ |
| 269 | - $wpshop_attribute_set_section_order = !empty( $_POST['wpshop_attribute_set_section_order'] ) ? (array)$_POST['wpshop_attribute_set_section_order'] : array(); |
|
| 270 | - $wpshop_attribute_set_section = !empty( $_POST['wpshop_attribute_set_section'] ) ? (array)$_POST['wpshop_attribute_set_section'] : array(); |
|
| 271 | - if ( !empty($wpshop_attribute_set_section_order) ) { |
|
| 269 | + $wpshop_attribute_set_section_order = !empty($_POST['wpshop_attribute_set_section_order']) ? (array)$_POST['wpshop_attribute_set_section_order'] : array(); |
|
| 270 | + $wpshop_attribute_set_section = !empty($_POST['wpshop_attribute_set_section']) ? (array)$_POST['wpshop_attribute_set_section'] : array(); |
|
| 271 | + if (!empty($wpshop_attribute_set_section_order)) { |
|
| 272 | 272 | $newOrder = str_replace('attribute_group_', '', $wpshop_attribute_set_section_order); |
| 273 | 273 | $order = explode(',', $newOrder); |
| 274 | - foreach($order as $position => $set_section_id){ |
|
| 275 | - $wpshop_attribute_set_section[$set_section_id]['position']=$position; |
|
| 274 | + foreach ($order as $position => $set_section_id) { |
|
| 275 | + $wpshop_attribute_set_section[$set_section_id]['position'] = $position; |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - $attribute_group_order = !empty( $_REQUEST['attribute_group_order'] ) ? (array)$_REQUEST['attribute_group_order'] : array(); |
|
| 280 | - if(isset($attribute_group_order)){ |
|
| 281 | - foreach($attribute_group_order as $groupIdentifier => $newOrder){ |
|
| 279 | + $attribute_group_order = !empty($_REQUEST['attribute_group_order']) ? (array)$_REQUEST['attribute_group_order'] : array(); |
|
| 280 | + if (isset($attribute_group_order)) { |
|
| 281 | + foreach ($attribute_group_order as $groupIdentifier => $newOrder) { |
|
| 282 | 282 | $newOrder = str_replace('attribute_', '', $newOrder); |
| 283 | 283 | $order = explode(',', $newOrder); |
| 284 | 284 | $groupId = str_replace('newOrder', '', $groupIdentifier); |
| 285 | 285 | $i = 1; |
| 286 | - foreach($order as $element){ |
|
| 287 | - if($element != ''){ |
|
| 288 | - if((int)$groupId > 0){ |
|
| 286 | + foreach ($order as $element) { |
|
| 287 | + if ($element != '') { |
|
| 288 | + if ((int)$groupId > 0) { |
|
| 289 | 289 | $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $element, 'valid', $id); |
| 290 | 290 | $validElement = $wpdb->get_var($query); |
| 291 | - if(!empty($validElement)){ |
|
| 291 | + if (!empty($validElement)) { |
|
| 292 | 292 | $query = $wpdb->prepare("UPDATE " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " SET position = %d, attribute_group_id = %d, last_update_date = NOW() WHERE attribute_id = %d AND status = %s AND attribute_set_id = %d", $i, $groupId, $element, 'valid', $id); |
| 293 | 293 | } |
| 294 | - else{ |
|
| 294 | + else { |
|
| 295 | 295 | $query = $wpdb->prepare("INSERT INTO " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " (id, status, creation_date, entity_type_id, attribute_set_id, attribute_group_id, attribute_id, position) VALUES ('', 'valid', NOW(), %d, %d, %d, %d, %d)", $attribute_set_parameter['entity_id'], $id, $groupId, $element, $i); |
| 296 | 296 | } |
| 297 | 297 | $wpdb->query($query); |
| 298 | 298 | } |
| 299 | - else{ |
|
| 299 | + else { |
|
| 300 | 300 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'deleted', 'last_update_date' => current_time('mysql', 0), 'position' => 0), array('attribute_id' => $element, 'status' => 'valid', 'attribute_set_id' => $id)); |
| 301 | 301 | } |
| 302 | 302 | $i++; |
@@ -305,10 +305,10 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $wpshop_attribute_set_section_is_default_of_set = !empty( $_REQUEST['wpshop_attribute_set_section_is_default_of_set'] ) ? sanitize_key( $_REQUEST['wpshop_attribute_set_section_is_default_of_set'] ) : ''; |
|
| 309 | - if(!empty($wpshop_attribute_set_section)){ |
|
| 310 | - foreach($wpshop_attribute_set_section as $set_section_id => $set_section_options){ |
|
| 311 | - if(!empty($set_section_options) && is_array($set_section_options)){ |
|
| 308 | + $wpshop_attribute_set_section_is_default_of_set = !empty($_REQUEST['wpshop_attribute_set_section_is_default_of_set']) ? sanitize_key($_REQUEST['wpshop_attribute_set_section_is_default_of_set']) : ''; |
|
| 309 | + if (!empty($wpshop_attribute_set_section)) { |
|
| 310 | + foreach ($wpshop_attribute_set_section as $set_section_id => $set_section_options) { |
|
| 311 | + if (!empty($set_section_options) && is_array($set_section_options)) { |
|
| 312 | 312 | $set_section_options['default_group'] = (!empty($wpshop_attribute_set_section_is_default_of_set) && $wpshop_attribute_set_section_is_default_of_set == $set_section_id) ? 'yes' : 'no'; |
| 313 | 313 | $set_section_options['last_update_date'] = current_time('mysql', 0); |
| 314 | 314 | $set_section_options['display_on_frontend'] = (!empty($set_section_options['display_on_frontend']) && ($set_section_options['display_on_frontend'] == 'yes')) ? 'yes' : 'no'; |
@@ -317,9 +317,9 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( !empty( $set_section ) ) { |
|
| 320 | + if (!empty($set_section)) { |
|
| 321 | 321 | $parent_attribute_set_detail = self::getAttributeSetDetails($set_section, "'valid'"); |
| 322 | - if ( !empty($parent_attribute_set_detail) ) { |
|
| 322 | + if (!empty($parent_attribute_set_detail)) { |
|
| 323 | 323 | |
| 324 | 324 | foreach ($parent_attribute_set_detail as $section => $section_detail) { |
| 325 | 325 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_GROUP, array('status'=>'valid', 'attribute_set_id' => $id, 'creation_date'=>current_time('mysql', 0), 'code'=>$section_detail['code'], 'name'=>$section_detail['name'], 'default_group'=>$section_detail['is_default_group'], 'backend_display_type'=>$section_detail['backend_display_type'], 'used_in_shop_type'=>$section_detail['used_in_shop_type'], 'display_on_frontend'=>$section_detail['display_on_frontend'])); |
@@ -332,17 +332,17 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - $attribute_set_group_id = !empty( $_REQUEST['attribute_set_group_id'] ) ? (int) $_REQUEST['attribute_set_group_id'] : 0; |
|
| 335 | + $attribute_set_group_id = !empty($_REQUEST['attribute_set_group_id']) ? (int)$_REQUEST['attribute_set_group_id'] : 0; |
|
| 336 | 336 | /* If the current group is selected as default group set all others for current entity at no */ |
| 337 | - if($attribute_set_parameter['default_set'] == 'yes'){ |
|
| 337 | + if ($attribute_set_parameter['default_set'] == 'yes') { |
|
| 338 | 338 | $entity_to_take = 0; |
| 339 | - if(isset($attribute_set_group_id) && ($attribute_set_group_id != '')){ |
|
| 339 | + if (isset($attribute_set_group_id) && ($attribute_set_group_id != '')) { |
|
| 340 | 340 | $entity_to_take = $attribute_set_group_id; |
| 341 | 341 | } |
| 342 | - if(isset($attribute_set_parameter['entity_id']) && ($attribute_set_parameter['entity_id'] != '')){ |
|
| 342 | + if (isset($attribute_set_parameter['entity_id']) && ($attribute_set_parameter['entity_id'] != '')) { |
|
| 343 | 343 | $entity_to_take = $attribute_set_parameter['entity_id']; |
| 344 | 344 | } |
| 345 | - if($entity_to_take > 0){ |
|
| 345 | + if ($entity_to_take > 0) { |
|
| 346 | 346 | $query = $wpdb->prepare("UPDATE " . self::getDbTable() . " SET default_set = 'no' WHERE id != %d AND entity_id = %d", $id, $entity_to_take); |
| 347 | 347 | $wpdb->query($query); |
| 348 | 348 | } |
@@ -353,12 +353,12 @@ discard block |
||
| 353 | 353 | $pageMessage .= '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), $elementIdentifierForMessage); |
| 354 | 354 | /* if(($pageAction == 'edit') || ($pageAction == 'save')) |
| 355 | 355 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 356 | - else */if($pageAction == 'add') |
|
| 357 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$id)); |
|
| 358 | - elseif($pageAction == 'delete') |
|
| 359 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page='.self::getListingSlug()."&action=deleteok&saveditem=" . $id)); |
|
| 356 | + else */if ($pageAction == 'add') |
|
| 357 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
|
| 358 | + elseif ($pageAction == 'delete') |
|
| 359 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
|
| 360 | 360 | } |
| 361 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 361 | + elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) |
|
| 362 | 362 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 363 | 363 | } |
| 364 | 364 | |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | //Create an instance of our package class... |
| 374 | 374 | $wpshop_list_table = new wpshop_attributes_set_custom_List_table(); |
| 375 | 375 | //Fetch, prepare, sort, and filter our data... |
| 376 | - $status="'valid', 'moderated'"; |
|
| 376 | + $status = "'valid', 'moderated'"; |
|
| 377 | 377 | $attribute_set_list = array(); |
| 378 | - $attribute_group_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : ''; |
|
| 379 | - if(!empty($attribute_group_status)){ |
|
| 380 | - $status="'".$attribute_group_status."'"; |
|
| 378 | + $attribute_group_status = !empty($_REQUEST['attribute_groups_status']) ? sanitize_text_field($_REQUEST['attribute_groups_status']) : ''; |
|
| 379 | + if (!empty($attribute_group_status)) { |
|
| 380 | + $status = "'" . $attribute_group_status . "'"; |
|
| 381 | 381 | } |
| 382 | 382 | $attr_set_list = wpshop_attributes_set::getElement('', $status); |
| 383 | - $i=0; |
|
| 384 | - foreach($attr_set_list as $attr_set){ |
|
| 385 | - if(!empty($attr_set->id)){ |
|
| 383 | + $i = 0; |
|
| 384 | + foreach ($attr_set_list as $attr_set) { |
|
| 385 | + if (!empty($attr_set->id)) { |
|
| 386 | 386 | $attribute_set_list[$i]['id'] = $attr_set->id; |
| 387 | 387 | $attribute_set_list[$i]['name'] = $attr_set->name; |
| 388 | 388 | $attribute_set_list[$i]['status'] = $attr_set->status; |
@@ -390,18 +390,18 @@ discard block |
||
| 390 | 390 | $attribute_set_details = self::getAttributeSetDetails($attr_set->id, "'valid'"); |
| 391 | 391 | |
| 392 | 392 | $attribute_set_list[$i]['content'] = ''; |
| 393 | - if(!empty($attribute_set_details)){ |
|
| 394 | - foreach($attribute_set_details as $set_details){ |
|
| 395 | - $attribute_set_list[$i]['content'] .= '<div><a href="'.admin_url('admin.php?page='.self::getListingSlug()."&action=edit&id=".$attr_set->id.'#attribute_group_'.$set_details['id']).'" >'.__($set_details['name'],'wpshop').'</a> '; |
|
| 396 | - $has_att=false; |
|
| 397 | - foreach($set_details['attribut'] as $set_detail){ |
|
| 398 | - if(!empty($set_detail->frontend_label) && ( $set_detail->code != 'product_attribute_set_id' ) ){ |
|
| 399 | - $attribute_set_list[$i]['content'] .= __($set_detail->frontend_label,'wpshop').', '; |
|
| 400 | - $has_att=true; |
|
| 393 | + if (!empty($attribute_set_details)) { |
|
| 394 | + foreach ($attribute_set_details as $set_details) { |
|
| 395 | + $attribute_set_list[$i]['content'] .= '<div><a href="' . admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $attr_set->id . '#attribute_group_' . $set_details['id']) . '" >' . __($set_details['name'], 'wpshop') . '</a> '; |
|
| 396 | + $has_att = false; |
|
| 397 | + foreach ($set_details['attribut'] as $set_detail) { |
|
| 398 | + if (!empty($set_detail->frontend_label) && ($set_detail->code != 'product_attribute_set_id')) { |
|
| 399 | + $attribute_set_list[$i]['content'] .= __($set_detail->frontend_label, 'wpshop') . ', '; |
|
| 400 | + $has_att = true; |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | - if(!empty($attribute_set_list[$i]['content'])){ |
|
| 404 | - if($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'],0,-2); |
|
| 403 | + if (!empty($attribute_set_list[$i]['content'])) { |
|
| 404 | + if ($has_att)$attribute_set_list[$i]['content'] = substr($attribute_set_list[$i]['content'], 0, -2); |
|
| 405 | 405 | $attribute_set_list[$i]['content'] .= '</div>'; |
| 406 | 406 | } |
| 407 | 407 | } |
@@ -440,45 +440,45 @@ discard block |
||
| 440 | 440 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 441 | 441 | $form_more_content = $the_form_content_hidden = $the_form_general_content = ''; |
| 442 | 442 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 443 | - $bloc_list=array(); |
|
| 443 | + $bloc_list = array(); |
|
| 444 | 444 | |
| 445 | 445 | $editedItem = ''; |
| 446 | - if($itemToEdit != '') |
|
| 446 | + if ($itemToEdit != '') |
|
| 447 | 447 | $editedItem = self::getElement($itemToEdit); |
| 448 | 448 | |
| 449 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 449 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 450 | 450 | $input_name = $input_def['name']; |
| 451 | 451 | $input_value = $input_def['value']; |
| 452 | - $input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_name; |
|
| 452 | + $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_name; |
|
| 453 | 453 | |
| 454 | 454 | $attributeAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 455 | 455 | $attributeFormValue = isset($_REQUEST[self::getDbTable()][$input_name]) ? sanitize_text_field($_REQUEST[self::getDbTable()][$input_name]) : ''; |
| 456 | 456 | |
| 457 | 457 | /* Get value by checking current object type */ |
| 458 | 458 | $currentFieldValue = $input_value; |
| 459 | - if(is_object($editedItem)) |
|
| 459 | + if (is_object($editedItem)) |
|
| 460 | 460 | $currentFieldValue = $editedItem->$input_name; |
| 461 | - elseif(($attributeAction != '') && ($attributeFormValue != '')) |
|
| 461 | + elseif (($attributeAction != '') && ($attributeFormValue != '')) |
|
| 462 | 462 | $currentFieldValue = $attributeFormValue; |
| 463 | 463 | |
| 464 | 464 | /* Check if the field must be hidden */ |
| 465 | - if(in_array($input_name, $attribute_hidden_field)) |
|
| 465 | + if (in_array($input_name, $attribute_hidden_field)) |
|
| 466 | 466 | $input_def['type'] = 'hidden'; |
| 467 | 467 | if ($input_name == 'entity_id') { |
| 468 | 468 | $input_def['type'] = 'select'; |
| 469 | 469 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
| 470 | 470 | |
| 471 | 471 | $input_def['valueToPut'] = 'index'; |
| 472 | - if ( is_object($editedItem) || (count($input_def['possible_value'])==1) ) { |
|
| 472 | + if (is_object($editedItem) || (count($input_def['possible_value']) == 1)) { |
|
| 473 | 473 | $input_def['type'] = 'hidden'; |
| 474 | - $currentFieldValue=(count($input_def['possible_value'])==1)?$input_def['possible_value'][0]->id:$currentFieldValue; |
|
| 474 | + $currentFieldValue = (count($input_def['possible_value']) == 1) ? $input_def['possible_value'][0]->id : $currentFieldValue; |
|
| 475 | 475 | } |
| 476 | 476 | $input_def['name'] = $input_name; |
| 477 | 477 | $input_def['value'] = $currentFieldValue; |
| 478 | 478 | |
| 479 | - $i=0; |
|
| 480 | - foreach($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 481 | - if($i <= 0){ |
|
| 479 | + $i = 0; |
|
| 480 | + foreach ($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 481 | + if ($i <= 0) { |
|
| 482 | 482 | $current_entity_id = $entity_id; |
| 483 | 483 | } |
| 484 | 484 | $i++; |
@@ -487,19 +487,19 @@ discard block |
||
| 487 | 487 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 488 | 488 | } |
| 489 | 489 | else { |
| 490 | - if(in_array($input_name, array('status', 'default_set'))){ |
|
| 490 | + if (in_array($input_name, array('status', 'default_set'))) { |
|
| 491 | 491 | $input_def['type'] = 'checkbox'; |
| 492 | - switch($input_name){ |
|
| 492 | + switch ($input_name) { |
|
| 493 | 493 | case 'status': |
| 494 | 494 | $input_name = __('Use this attribute group', 'wpshop'); |
| 495 | 495 | $input_def['possible_value'] = array('valid'); |
| 496 | - $input_def_id.='_valid'; |
|
| 497 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute group', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 496 | + $input_def_id .= '_valid'; |
|
| 497 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 498 | 498 | break; |
| 499 | 499 | case 'default_set': |
| 500 | 500 | $input_def['possible_value'] = array('yes'); |
| 501 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute group as default group in selected element', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 502 | - $input_def_id.='_yes'; |
|
| 501 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute group as default group in selected element', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 502 | + $input_def_id .= '_yes'; |
|
| 503 | 503 | break; |
| 504 | 504 | } |
| 505 | 505 | } |
@@ -507,61 +507,61 @@ discard block |
||
| 507 | 507 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if($input_def['type'] != 'hidden'){ |
|
| 510 | + if ($input_def['type'] != 'hidden') { |
|
| 511 | 511 | $the_form_general_content .= ' |
| 512 | - <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_name.'" > |
|
| 513 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_name.'" ><label for="'.$input_def_id.'" >' . __($input_name, 'wpshop') . '</label></td> |
|
| 514 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_name.'" >' . $the_input . '</td> |
|
| 512 | + <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_name . '" > |
|
| 513 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_name . '" ><label for="' . $input_def_id . '" >' . __($input_name, 'wpshop') . '</label></td> |
|
| 514 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_name . '" >' . $the_input . '</td> |
|
| 515 | 515 | </tr>'; |
| 516 | 516 | } |
| 517 | - else{ |
|
| 517 | + else { |
|
| 518 | 518 | $the_form_content_hidden .= ' |
| 519 | 519 | ' . $the_input; |
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - if( empty($itemToEdit) ) { |
|
| 524 | - $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode, false); |
|
| 523 | + if (empty($itemToEdit)) { |
|
| 524 | + $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode, false); |
|
| 525 | 525 | $the_form_general_content .= ' |
| 526 | 526 | <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_existing_attribute_set_copy_from" > |
| 527 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_existing_attribute_set_copy_from" ><label for="'.$input_def_id.'" >' . __('Create the new group from an existing', 'wpshop') . '</label></td> |
|
| 527 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_existing_attribute_set_copy_from" ><label for="' . $input_def_id . '" >' . __('Create the new group from an existing', 'wpshop') . '</label></td> |
|
| 528 | 528 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_existing_attribute_set_copy_from" >' . $the_input . '</td> |
| 529 | 529 | </tr>'; |
| 530 | 530 | } |
| 531 | 531 | $the_form_general_content = ' |
| 532 | 532 | <table class="wpshop_' . self::currentPageCode . '_edition_table wpshop_' . self::currentPageCode . '_edition_table_main_info" > |
| 533 | -'.$the_form_general_content.' |
|
| 533 | +'.$the_form_general_content . ' |
|
| 534 | 534 | </table>'; |
| 535 | 535 | |
| 536 | 536 | /* Default content for the current page */ |
| 537 | - $bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop'); |
|
| 538 | - $bloc_list[self::currentPageCode]['main_info']['content']=$the_form_general_content; |
|
| 537 | + $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop'); |
|
| 538 | + $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content; |
|
| 539 | 539 | |
| 540 | - if(is_object($editedItem)){ |
|
| 541 | - $bloc_list[self::currentPageCode]['detail']['title']=__('Attribute group section details', 'wpshop'); |
|
| 542 | - $bloc_list[self::currentPageCode]['detail']['content']=self::attributeSetDetailsManagement($itemToEdit); |
|
| 540 | + if (is_object($editedItem)) { |
|
| 541 | + $bloc_list[self::currentPageCode]['detail']['title'] = __('Attribute group section details', 'wpshop'); |
|
| 542 | + $bloc_list[self::currentPageCode]['detail']['content'] = self::attributeSetDetailsManagement($itemToEdit); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | $the_form = ' |
| 546 | 546 | <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" > |
| 547 | -' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (!empty($_REQUEST['action'])?sanitize_text_field($_REQUEST['action']):'save'), 'hidden') . ' |
|
| 548 | -' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . ' |
|
| 549 | - <div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode.'" >'; |
|
| 547 | +' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (!empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'save'), 'hidden') . ' |
|
| 548 | +' . wpshop_form::form_input(self::getDbTable() . '_form_has_modification', self::getDbTable() . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT) . ' |
|
| 549 | + <div class="wpshop_edition_button wpshop_edition_button_'.self::currentPageCode . '" >'; |
|
| 550 | 550 | |
| 551 | - if(($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) |
|
| 551 | + if (($action == 'add') && (current_user_can('wpshop_add_attribute_set'))) |
|
| 552 | 552 | $the_form .= '<input type="submit" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 553 | - elseif(current_user_can('wpshop_edit_attribute_set')) |
|
| 553 | + elseif (current_user_can('wpshop_edit_attribute_set')) |
|
| 554 | 554 | $the_form .= '<input type="submit" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
| 555 | 555 | |
| 556 | - if(current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) |
|
| 557 | - $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 556 | + if (current_user_can('wpshop_delete_attribute_set') && ($action != 'add')) |
|
| 557 | + $the_form .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 558 | 558 | |
| 559 | 559 | $the_form .= ' |
| 560 | 560 | </div> |
| 561 | 561 | </form> |
| 562 | 562 | <script type="text/javascript" > |
| 563 | 563 | wpshop(document).ready(function(){ |
| 564 | - wpshopMainInterface("'.self::getDbTable().'", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); |
|
| 564 | + wpshopMainInterface("'.self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); |
|
| 565 | 565 | |
| 566 | 566 | jQuery("#wpshop_attribute_set_edition_table_field_id_entity_id").change(function(){ |
| 567 | 567 | jQuery(".wpshop_attribute_set_edition_table_field_input_existing_attribute_set_copy_from").html(jQuery("#wpshopLoadingPicture").html()); |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * |
| 586 | 586 | * @return string $currentPageButton The html output code with the different button to add to the interface |
| 587 | 587 | */ |
| 588 | - function getPageFormButton($element_id = 0){ |
|
| 588 | + function getPageFormButton($element_id = 0) { |
|
| 589 | 589 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 590 | 590 | $currentPageButton = ''; |
| 591 | 591 | |
@@ -600,15 +600,15 @@ discard block |
||
| 600 | 600 | * |
| 601 | 601 | * @return object $elements A wordpress database object containing the element list |
| 602 | 602 | */ |
| 603 | - public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = ''){ |
|
| 603 | + public static function getElement($elementId = '', $elementStatus = "'valid', 'moderated'", $whatToSearch = 'id', $resultList = '', $entity_id = '') { |
|
| 604 | 604 | global $wpdb; |
| 605 | 605 | $elements = array(); |
| 606 | 606 | $moreQuery = ""; |
| 607 | 607 | $moreQueryArgs = array(); |
| 608 | 608 | |
| 609 | - if($elementId != '') |
|
| 609 | + if ($elementId != '') |
|
| 610 | 610 | { |
| 611 | - switch($whatToSearch) |
|
| 611 | + switch ($whatToSearch) |
|
| 612 | 612 | { |
| 613 | 613 | case 'entity_code': |
| 614 | 614 | $moreQuery = " |
@@ -638,13 +638,13 @@ discard block |
||
| 638 | 638 | $moreQueryArgs[] = $elementId; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - if ( !empty($entity_id) ) { |
|
| 641 | + if (!empty($entity_id)) { |
|
| 642 | 642 | $moreQuery .= " |
| 643 | 643 | AND ATTRIBUTE_SET.entity_id = %d "; |
| 644 | 644 | $moreQueryArgs[] = $entity_id; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - if( empty($entity_id) ) { |
|
| 647 | + if (empty($entity_id)) { |
|
| 648 | 648 | $moreQuery .= "AND 1=%d"; |
| 649 | 649 | $moreQueryArgs[] = 1; |
| 650 | 650 | } |
@@ -653,11 +653,11 @@ discard block |
||
| 653 | 653 | "SELECT ATTRIBUTE_SET.*, ENTITIES.post_name as entity |
| 654 | 654 | FROM " . self::getDbTable() . " AS ATTRIBUTE_SET |
| 655 | 655 | INNER JOIN " . $wpdb->posts . " AS ENTITIES ON (ENTITIES.ID = ATTRIBUTE_SET.entity_id) |
| 656 | - WHERE ATTRIBUTE_SET.status IN (".$elementStatus.") " . $moreQuery, $moreQueryArgs |
|
| 656 | + WHERE ATTRIBUTE_SET.status IN (".$elementStatus . ") " . $moreQuery, $moreQueryArgs |
|
| 657 | 657 | ); |
| 658 | 658 | |
| 659 | 659 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 660 | - if(($elementId == '') || ($resultList == 'all')) |
|
| 660 | + if (($elementId == '') || ($resultList == 'all')) |
|
| 661 | 661 | { |
| 662 | 662 | $elements = $wpdb->get_results($query); |
| 663 | 663 | } |
@@ -676,21 +676,21 @@ discard block |
||
| 676 | 676 | * |
| 677 | 677 | * @return string $attributeSetDetailsManagement The html output of management interface |
| 678 | 678 | */ |
| 679 | - public static function attributeSetDetailsManagement($attributeSetId = ''){ |
|
| 679 | + public static function attributeSetDetailsManagement($attributeSetId = '') { |
|
| 680 | 680 | global $validAttributeList; global $wpdb; |
| 681 | 681 | $user_more_script = $add_button = ''; |
| 682 | 682 | $end_line_display = array(); |
| 683 | 683 | /** Check if it's billing or Shipping **/ |
| 684 | - if ( !empty($attributeSetId) ) { |
|
| 685 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 686 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 684 | + if (!empty($attributeSetId)) { |
|
| 685 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 686 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 687 | 687 | |
| 688 | - if ( !empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $attributeSetId ) { |
|
| 689 | - $end_line_display = ( !empty( $shipping_option['display_model'] ) ) ? $shipping_option['display_model'] : array(); |
|
| 688 | + if (!empty($shipping_option) && !empty($shipping_option['choice']) && $shipping_option['choice'] == $attributeSetId) { |
|
| 689 | + $end_line_display = (!empty($shipping_option['display_model'])) ? $shipping_option['display_model'] : array(); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - if ( !empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $attributeSetId ) { |
|
| 693 | - $end_line_display = ( !empty( $billing_option['display_model'] ) ) ? $billing_option['display_model'] : array(); |
|
| 692 | + if (!empty($billing_option) && !empty($billing_option['choice']) && $billing_option['choice'] == $attributeSetId) { |
|
| 693 | + $end_line_display = (!empty($billing_option['display_model'])) ? $billing_option['display_model'] : array(); |
|
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | 696 | |
@@ -698,12 +698,12 @@ discard block |
||
| 698 | 698 | |
| 699 | 699 | $attributeSetDetailsManagement = ' |
| 700 | 700 | <div id="managementContainer" >'; |
| 701 | - if(current_user_can('wpshop_add_attribute_group')){ |
|
| 701 | + if (current_user_can('wpshop_add_attribute_group')) { |
|
| 702 | 702 | $dialog_title = __('New attribute set section name', 'wpshop'); |
| 703 | 703 | $dialog_identifier = 'wpshop_new_set_section_add'; |
| 704 | 704 | $dialog_input_identifier = 'wpshop_new_attribute_set_section_name'; |
| 705 | 705 | ob_start(); |
| 706 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 706 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 707 | 707 | $attributeSetDetailsManagement .= ob_get_contents(); |
| 708 | 708 | ob_end_clean(); |
| 709 | 709 | |
@@ -711,37 +711,37 @@ discard block |
||
| 711 | 711 | $add_button_parent_class = 'attribute_set_section_add_new_button'; |
| 712 | 712 | $add_button_name = 'wpshop_create_new_set_section_top'; |
| 713 | 713 | ob_start(); |
| 714 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php'); |
|
| 714 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php'); |
|
| 715 | 715 | $add_button = ob_get_contents(); |
| 716 | 716 | ob_end_clean(); |
| 717 | 717 | |
| 718 | 718 | $user_more_script .= ' |
| 719 | - jQuery("#'.$dialog_identifier.'").dialog({ |
|
| 719 | + jQuery("#'.$dialog_identifier . '").dialog({ |
|
| 720 | 720 | modal: true, |
| 721 | 721 | dialogClass: "wpshop_uidialog_box", |
| 722 | 722 | autoOpen:false, |
| 723 | 723 | show: "blind", |
| 724 | 724 | resizable: false, |
| 725 | 725 | buttons:{ |
| 726 | - "'.__('Add', 'wpshop').'": function(){ |
|
| 726 | + "'.__('Add', 'wpshop') . '": function(){ |
|
| 727 | 727 | jQuery("#managementContainer").load(ajaxurl,{ |
| 728 | 728 | "action": "wps_attribute_set_section_new", |
| 729 | 729 | "_wpnonce": "' . wp_create_nonce("saveNewAttributeSetSection") . '", |
| 730 | 730 | "elementIdentifier": "' . $attributeSetId . '", |
| 731 | - "attributeSetSectionName": jQuery("#'.$dialog_input_identifier.'").val() |
|
| 731 | + "attributeSetSectionName": jQuery("#'.$dialog_input_identifier . '").val() |
|
| 732 | 732 | }); |
| 733 | 733 | jQuery(this).children("img").show(); |
| 734 | 734 | }, |
| 735 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 735 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 736 | 736 | jQuery(this).dialog("close"); |
| 737 | 737 | } |
| 738 | 738 | }, |
| 739 | 739 | close:function(){ |
| 740 | - jQuery("#'.$dialog_input_identifier.'").val(""); |
|
| 740 | + jQuery("#'.$dialog_input_identifier . '").val(""); |
|
| 741 | 741 | } |
| 742 | 742 | }); |
| 743 | - jQuery(".'.$add_button_parent_class.' input").click(function(){ |
|
| 744 | - jQuery("#'.$dialog_identifier.'").dialog("open"); |
|
| 743 | + jQuery(".'.$add_button_parent_class . ' input").click(function(){ |
|
| 744 | + jQuery("#'.$dialog_identifier . '").dialog("open"); |
|
| 745 | 745 | });'; |
| 746 | 746 | } |
| 747 | 747 | $attributeSetDetailsManagement .= ' |
@@ -750,62 +750,62 @@ discard block |
||
| 750 | 750 | |
| 751 | 751 | /* Get information about the current attribute set we are editing */ |
| 752 | 752 | $attributeSetDetails = self::getAttributeSetDetails($attributeSetId); |
| 753 | - if(is_array($attributeSetDetails) && (count($attributeSetDetails) > 0)){ |
|
| 753 | + if (is_array($attributeSetDetails) && (count($attributeSetDetails) > 0)) { |
|
| 754 | 754 | /* Build output with the current attribute set details */ |
| 755 | - foreach($attributeSetDetails as $attributeSetIDGroup => $attributeSetDetailsGroup){ |
|
| 755 | + foreach ($attributeSetDetails as $attributeSetIDGroup => $attributeSetDetailsGroup) { |
|
| 756 | 756 | /* Check possible action for general code */ |
| 757 | 757 | $elementActionClass = 'wpshop_attr_set_section_name'; |
| 758 | 758 | $edition_area = $edit_button = ''; |
| 759 | - if ( current_user_can('wpshop_edit_attribute_group') ) { |
|
| 759 | + if (current_user_can('wpshop_edit_attribute_group')) { |
|
| 760 | 760 | $elementActionClass = 'wpshop_attr_set_section_name_editable'; |
| 761 | 761 | $edit_button = ' |
| 762 | - <a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_edit wpshop_attr_tool_box_edit_attribute_set_section" id="wpshop_set_section_edit_'.$attributeSetDetailsGroup['id'].'" title="'.__('Edit this section', 'wpshop').'"></a>'; |
|
| 762 | + <a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_edit wpshop_attr_tool_box_edit_attribute_set_section" id="wpshop_set_section_edit_'.$attributeSetDetailsGroup['id'] . '" title="' . __('Edit this section', 'wpshop') . '"></a>'; |
|
| 763 | 763 | |
| 764 | 764 | $tpl_component = array(); |
| 765 | 765 | $tpl_component['ADMIN_GROUP_IDENTIFIER'] = str_replace('-', '_', sanitize_title($attributeSetDetailsGroup['id'])); |
| 766 | 766 | $tpl_component['ADMIN_GROUP_ID'] = $attributeSetDetailsGroup['id']; |
| 767 | 767 | $tpl_component['ADMIN_GROUP_NAME'] = __($attributeSetDetailsGroup['name'], 'wpshop'); |
| 768 | - $tpl_component['ADMIN_GROUP_DISPLAY_TYPE_TAB'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type']=='fixed-tab')?' selected="selected"':''); |
|
| 769 | - $tpl_component['ADMIN_GROUP_DISPLAY_TYPE_BOX'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type']=='movable-tab')?' selected="selected"':''); |
|
| 770 | - $tpl_component['ADMIN_GROUP_DISPLAY_ON_FRONTEND'] = (!empty($attributeSetDetailsGroup['display_on_frontend']) && ($attributeSetDetailsGroup['display_on_frontend']=='yes')?' checked="checked"':''); |
|
| 768 | + $tpl_component['ADMIN_GROUP_DISPLAY_TYPE_TAB'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type'] == 'fixed-tab') ? ' selected="selected"' : ''); |
|
| 769 | + $tpl_component['ADMIN_GROUP_DISPLAY_TYPE_BOX'] = (!empty($attributeSetDetailsGroup['backend_display_type']) && ($attributeSetDetailsGroup['backend_display_type'] == 'movable-tab') ? ' selected="selected"' : ''); |
|
| 770 | + $tpl_component['ADMIN_GROUP_DISPLAY_ON_FRONTEND'] = (!empty($attributeSetDetailsGroup['display_on_frontend']) && ($attributeSetDetailsGroup['display_on_frontend'] == 'yes') ? ' checked="checked"' : ''); |
|
| 771 | 771 | $edition_area = wpshop_display::display_template_element('wpshop_admin_attr_set_section_params', $tpl_component, array(), 'admin'); |
| 772 | 772 | unset($tpl_component); |
| 773 | 773 | } |
| 774 | 774 | //<td rowspan="2" class="wpshop_attribute_set_section_detail_table_default_td" ><input title="'.__('Default section', 'wpshop').'" type="radio" name="wpshop_attribute_set_section_is_default_of_set" '.($is_default?'checked="checked" ':'').'id="wpshop_attribute_set_section_is_default_of_set_'.$attributeSetDetailsGroup['id'].'" value="'.$attributeSetDetailsGroup['id'].'" /></td> |
| 775 | - $is_default = (!empty($attributeSetDetailsGroup['is_default_group']) && ($attributeSetDetailsGroup['is_default_group']=='yes')?true:false); |
|
| 775 | + $is_default = (!empty($attributeSetDetailsGroup['is_default_group']) && ($attributeSetDetailsGroup['is_default_group'] == 'yes') ? true : false); |
|
| 776 | 776 | $attributeSetDetailsManagement .= ' |
| 777 | - <li id="attribute_group_' . $attributeSetIDGroup . '" class="attribute_set_section_container attribute_set_section_container_'.($is_default?'is_default':'normal').'" > |
|
| 777 | + <li id="attribute_group_' . $attributeSetIDGroup . '" class="attribute_set_section_container attribute_set_section_container_' . ($is_default ? 'is_default' : 'normal') . '" > |
|
| 778 | 778 | <table class="wpshpop_attribute_set_section_detail_table" > |
| 779 | 779 | <tr> |
| 780 | 780 | <td id="wpshop_attr_set_section_name_' . $attributeSetDetailsGroup['id'] . '" class="' . $elementActionClass . '" >' . __($attributeSetDetailsGroup['name'], 'wpshop') . '</td> |
| 781 | 781 | </tr> |
| 782 | 782 | <tr> |
| 783 | 783 | <td> |
| 784 | - <input class="newOrder" type="hidden" name="attribute_group_order[newOrder' . $attributeSetIDGroup . ']" id="newOrder' . $attributeSetIDGroup . '" value="' .( ( !empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup]) ) ? implode( ',', $end_line_display[$attributeSetIDGroup] ) : '' ). '" />'; |
|
| 784 | + <input class="newOrder" type="hidden" name="attribute_group_order[newOrder' . $attributeSetIDGroup . ']" id="newOrder' . $attributeSetIDGroup . '" value="' . ((!empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup])) ? implode(',', $end_line_display[$attributeSetIDGroup]) : '') . '" />'; |
|
| 785 | 785 | |
| 786 | 786 | /* Add the set section details */ |
| 787 | 787 | $price_tab = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 788 | 788 | unset($price_tab[array_search(WPSHOP_COST_OF_POSTAGE, $price_tab)]); |
| 789 | 789 | $no_delete_button = false; |
| 790 | - if ( is_array($attributeSetDetailsGroup['attribut']) && (count($attributeSetDetailsGroup['attribut']) >= 1) ) { |
|
| 790 | + if (is_array($attributeSetDetailsGroup['attribut']) && (count($attributeSetDetailsGroup['attribut']) >= 1)) { |
|
| 791 | 791 | $attributeSetDetailsManagement .= ' |
| 792 | 792 | <ul id="attribute_group_' . $attributeSetIDGroup . '_details" class="wpshop_attr_set_section_details" >'; |
| 793 | 793 | ksort($attributeSetDetailsGroup['attribut']); |
| 794 | 794 | $end_line_id = 0; |
| 795 | - foreach ( $attributeSetDetailsGroup['attribut'] as $attributInGroup ) { |
|
| 796 | - if ( in_array($attributInGroup->code, $price_tab) ){ |
|
| 795 | + foreach ($attributeSetDetailsGroup['attribut'] as $attributInGroup) { |
|
| 796 | + if (in_array($attributInGroup->code, $price_tab)) { |
|
| 797 | 797 | $no_delete_button = true; |
| 798 | 798 | } |
| 799 | - if ( !empty($attributInGroup->id) && ( $attributInGroup->code != 'product_attribute_set_id' ) ) { |
|
| 799 | + if (!empty($attributInGroup->id) && ($attributInGroup->code != 'product_attribute_set_id')) { |
|
| 800 | 800 | |
| 801 | 801 | $attributeSetDetailsManagement .= ' |
| 802 | - <li class="ui-state-default attribute' . (in_array($attributInGroup->code, $price_tab) ? ' ui-state-disabled' : '') . '" id="attribute_' . $attributInGroup->id . '" >' . __($attributInGroup->frontend_label, 'wpshop') . '</li>'; |
|
| 802 | + <li class="ui-state-default attribute' . (in_array($attributInGroup->code, $price_tab) ? ' ui-state-disabled' : '') . '" id="attribute_' . $attributInGroup->id . '" >' . __($attributInGroup->frontend_label, 'wpshop') . '</li>'; |
|
| 803 | 803 | |
| 804 | 804 | |
| 805 | - if ( !empty($end_line_display) && !empty($end_line_display[ $attributeSetIDGroup ]) && in_array('attribute_' .$attributInGroup->id, $end_line_display[ $attributeSetIDGroup ]) ) { |
|
| 806 | - $key = array_search('attribute_' .$attributInGroup->id, $end_line_display[ $attributeSetIDGroup ] ); |
|
| 807 | - if ( !empty($end_line_display[ $attributeSetIDGroup ][$key + 1]) && $end_line_display[ $attributeSetIDGroup ][$key + 1] == 'wps-attribute-end-line-'.$end_line_id ) { |
|
| 808 | - $attributeSetDetailsManagement .= '<li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' .__( 'End line', 'wpshop' ). '</li>'; |
|
| 805 | + if (!empty($end_line_display) && !empty($end_line_display[$attributeSetIDGroup]) && in_array('attribute_' . $attributInGroup->id, $end_line_display[$attributeSetIDGroup])) { |
|
| 806 | + $key = array_search('attribute_' . $attributInGroup->id, $end_line_display[$attributeSetIDGroup]); |
|
| 807 | + if (!empty($end_line_display[$attributeSetIDGroup][$key + 1]) && $end_line_display[$attributeSetIDGroup][$key + 1] == 'wps-attribute-end-line-' . $end_line_id) { |
|
| 808 | + $attributeSetDetailsManagement .= '<li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' . __('End line', 'wpshop') . '</li>'; |
|
| 809 | 809 | $end_line_id++; |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -817,15 +817,15 @@ discard block |
||
| 817 | 817 | </ul>'; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - $attributeSetDetailsManagement .= $edition_area.' |
|
| 820 | + $attributeSetDetailsManagement .= $edition_area . ' |
|
| 821 | 821 | </td> |
| 822 | 822 | </tr> |
| 823 | 823 | </table> |
| 824 | 824 | |
| 825 | 825 | <div class="wpshop_admin_toolbox wpshop_attr_set_section_tool_box" >' . $edit_button; |
| 826 | - if ( current_user_can('wpshop_delete_attribute_group') && !$no_delete_button ) { |
|
| 826 | + if (current_user_can('wpshop_delete_attribute_group') && !$no_delete_button) { |
|
| 827 | 827 | $attributeSetDetailsManagement .= ' |
| 828 | - <a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_delete wpshop_attr_tool_box_delete_attribute_set_section" id="wpshop_set_section_delete_'.$attributeSetDetailsGroup['id'].'" title="'.__('Delete this section', 'wpshop').'"></a>'; |
|
| 828 | + <a class="wpshop_attr_tool_box_button wpshop_attr_tool_box_delete wpshop_attr_tool_box_delete_attribute_set_section" id="wpshop_set_section_delete_'.$attributeSetDetailsGroup['id'] . '" title="' . __('Delete this section', 'wpshop') . '"></a>'; |
|
| 829 | 829 | } |
| 830 | 830 | $attributeSetDetailsManagement .= ' |
| 831 | 831 | </div> |
@@ -845,9 +845,9 @@ discard block |
||
| 845 | 845 | |
| 846 | 846 | /* Get the not affected attribute list */ |
| 847 | 847 | $notAffectedAttributeList = self::get_not_affected_attribute($attributeSetId, $attributeSetDetailsGroup['entity_id']); |
| 848 | - if(count($notAffectedAttributeList) > 0){ |
|
| 849 | - foreach($notAffectedAttributeList as $notAffectedAttribute){ |
|
| 850 | - if( (is_null($validAttributeList) || !in_array($notAffectedAttribute->id, $validAttributeList)) && ( $notAffectedAttribute->code != 'product_attribute_set_id' ) && ($attributeSetDetailsGroup['entity_id'] == $notAffectedAttribute->entity_id) ){ |
|
| 848 | + if (count($notAffectedAttributeList) > 0) { |
|
| 849 | + foreach ($notAffectedAttributeList as $notAffectedAttribute) { |
|
| 850 | + if ((is_null($validAttributeList) || !in_array($notAffectedAttribute->id, $validAttributeList)) && ($notAffectedAttribute->code != 'product_attribute_set_id') && ($attributeSetDetailsGroup['entity_id'] == $notAffectedAttribute->entity_id)) { |
|
| 851 | 851 | |
| 852 | 852 | $attributeSetDetailsManagement .= ' |
| 853 | 853 | <li class="ui-state-default attribute" id="attribute_' . $notAffectedAttribute->id . '" >' . __($notAffectedAttribute->frontend_label, 'wpshop') . '</li>'; |
@@ -861,20 +861,20 @@ discard block |
||
| 861 | 861 | </fieldset> |
| 862 | 862 | </div>'; |
| 863 | 863 | |
| 864 | - if ( !empty($attributeSetId) ) { |
|
| 865 | - $query = $wpdb->prepare( 'SELECT entity_id FROM '.WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE id = %d', $attributeSetId ); |
|
| 866 | - $entity_id = $wpdb->get_var( $query ); |
|
| 867 | - if ( !empty($entity_id) ) { |
|
| 868 | - $entity_post = get_post( $entity_id ); |
|
| 869 | - if( !empty( $entity_post) && !empty($entity_post->post_type) && $entity_post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES && !empty($entity_post->post_name) && $entity_post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) { |
|
| 870 | - $attributeSetDetailsManagement .= '<ul class="wps_attribute_set_end_line"><li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' .__( 'End line', 'wpshop' ). '</li></ul>'; |
|
| 864 | + if (!empty($attributeSetId)) { |
|
| 865 | + $query = $wpdb->prepare('SELECT entity_id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE id = %d', $attributeSetId); |
|
| 866 | + $entity_id = $wpdb->get_var($query); |
|
| 867 | + if (!empty($entity_id)) { |
|
| 868 | + $entity_post = get_post($entity_id); |
|
| 869 | + if (!empty($entity_post) && !empty($entity_post->post_type) && $entity_post->post_type == WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES && !empty($entity_post->post_name) && $entity_post->post_name == WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS) { |
|
| 870 | + $attributeSetDetailsManagement .= '<ul class="wps_attribute_set_end_line"><li class="ui-state-green attribute_end_line" id="wps-attribute-end-line">' . __('End line', 'wpshop') . '</li></ul>'; |
|
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | - if(current_user_can('wpshop_delete_attribute_group')){ |
|
| 874 | + if (current_user_can('wpshop_delete_attribute_group')) { |
|
| 875 | 875 | $user_more_script .= ' |
| 876 | 876 | jQuery(".wpshop_attr_tool_box_delete").click(function(){ |
| 877 | - if(confirm(wpshopConvertAccentTojs("'.__('Are you sure you want to delete this atribute set section?', 'wpshop').'"))){ |
|
| 877 | + if(confirm(wpshopConvertAccentTojs("'.__('Are you sure you want to delete this atribute set section?', 'wpshop') . '"))){ |
|
| 878 | 878 | jQuery("#ajax-response").load(ajaxurl,{ |
| 879 | 879 | "action": "wps_attribute_set_section_delete", |
| 880 | 880 | "_wpnonce": "' . wp_create_nonce("deleteAttributeSetSection") . '", |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | $attributeSetDetailsManagement .= ' |
| 887 | 887 | <script type="text/javascript" > |
| 888 | 888 | wpshop(document).ready(function(){ |
| 889 | - make_list_sortable("' . WPSHOP_DBT_ATTRIBUTE_SET . '");'.$user_more_script.' |
|
| 889 | + make_list_sortable("' . WPSHOP_DBT_ATTRIBUTE_SET . '");' . $user_more_script . ' |
|
| 890 | 890 | }); |
| 891 | 891 | </script> |
| 892 | 892 | <div class="wpshop_cls"></div> |
@@ -953,7 +953,7 @@ discard block |
||
| 953 | 953 | * |
| 954 | 954 | * @return array $attributeSetDetailsGroups The List of attribute and attribute groups for the given attribute set |
| 955 | 955 | */ |
| 956 | - public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'"){ |
|
| 956 | + public static function getAttributeSetDetails($attributeSetId, $attributeSetStatus = "'valid', 'moderated'") { |
|
| 957 | 957 | global $wpdb, $validAttributeList; |
| 958 | 958 | $attributeSetDetailsGroups = ''; |
| 959 | 959 | |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | $attributeSetId); |
| 974 | 974 | $attributeSetDetails = $wpdb->get_results($query); |
| 975 | 975 | |
| 976 | - foreach ( $attributeSetDetails as $attributeGroup ) { |
|
| 976 | + foreach ($attributeSetDetails as $attributeGroup) { |
|
| 977 | 977 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['attribute_set_id'] = $attributeGroup->attribute_set_id; |
| 978 | 978 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['id'] = $attributeGroup->attribute_detail_id; |
| 979 | 979 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['code'] = $attributeGroup->attr_group_code; |
@@ -984,17 +984,17 @@ discard block |
||
| 984 | 984 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['display_on_frontend'] = $attributeGroup->display_on_frontend; |
| 985 | 985 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['entity_id'] = $attributeGroup->entity_id; |
| 986 | 986 | |
| 987 | - if ( empty($done_position) || empty($done_position[$attributeGroup->attr_group_id]) ) { |
|
| 987 | + if (empty($done_position) || empty($done_position[$attributeGroup->attr_group_id])) { |
|
| 988 | 988 | $done_position[$attributeGroup->attr_group_id] = array(); |
| 989 | 989 | } |
| 990 | 990 | $position_to_take = $attributeGroup->attr_position_in_group; |
| 991 | - if ( in_array($position_to_take, $done_position[$attributeGroup->attr_group_id]) ) { |
|
| 991 | + if (in_array($position_to_take, $done_position[$attributeGroup->attr_group_id])) { |
|
| 992 | 992 | $position_to_take = max($done_position[$attributeGroup->attr_group_id]) + 1; |
| 993 | 993 | } |
| 994 | 994 | $done_position[$attributeGroup->attr_group_id][] = $position_to_take; |
| 995 | 995 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['attribut'][$position_to_take] = $attributeGroup; |
| 996 | 996 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['is_used_in_quick_add_form'] = $attributeGroup->is_used_in_quick_add_form; |
| 997 | - if ( in_array($attributeGroup->code, unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) { |
|
| 997 | + if (in_array($attributeGroup->code, unserialize(WPSHOP_ATTRIBUTE_PRICES))) { |
|
| 998 | 998 | $attributeSetDetailsGroups[$attributeGroup->attr_group_id]['prices'][$attributeGroup->code] = $attributeGroup; |
| 999 | 999 | } |
| 1000 | 1000 | $validAttributeList[] = $attributeGroup->id; |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | * |
| 1011 | 1011 | * @return array $attributeSetDetails The List of attribute not affected |
| 1012 | 1012 | */ |
| 1013 | - public static function get_not_affected_attribute($attributeSetId, $entity_set_id){ |
|
| 1013 | + public static function get_not_affected_attribute($attributeSetId, $entity_set_id) { |
|
| 1014 | 1014 | global $wpdb; |
| 1015 | 1015 | |
| 1016 | 1016 | $query = $wpdb->prepare( |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | * |
| 1051 | 1051 | * @return object $entitySets The entity sets list for the given entity |
| 1052 | 1052 | */ |
| 1053 | - public static function get_attribute_set_list_for_entity($entityId){ |
|
| 1053 | + public static function get_attribute_set_list_for_entity($entityId) { |
|
| 1054 | 1054 | global $wpdb; |
| 1055 | 1055 | $entitySetList = ''; |
| 1056 | 1056 | |
@@ -1074,39 +1074,39 @@ discard block |
||
| 1074 | 1074 | global $wpdb; |
| 1075 | 1075 | |
| 1076 | 1076 | $query = ' |
| 1077 | - SELECT '.WPSHOP_DBT_ATTRIBUTE.'.frontend_label, '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.value AS value_decimal, '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.value AS value_datetime, '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.value AS value_integer, |
|
| 1078 | - '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.value AS value_text, '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.value AS value_varchar, '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.unit AS unit, '.WPSHOP_DBT_ATTRIBUTE.'.frontend_verification |
|
| 1079 | - FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS.' |
|
| 1080 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE.' ON '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1081 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1082 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1083 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1084 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1085 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.' ON '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.attribute_id='.WPSHOP_DBT_ATTRIBUTE.'.id |
|
| 1086 | - LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_UNIT.' ON ( |
|
| 1087 | - '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.unit_id |
|
| 1088 | - OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.unit_id |
|
| 1089 | - OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.unit_id |
|
| 1090 | - OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.unit_id |
|
| 1091 | - OR '.WPSHOP_DBT_ATTRIBUTE_UNIT.'.id='.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.'.unit_id |
|
| 1077 | + SELECT '.WPSHOP_DBT_ATTRIBUTE . '.frontend_label, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.value AS value_decimal, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.value AS value_datetime, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.value AS value_integer, |
|
| 1078 | + '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.value AS value_text, ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.value AS value_varchar, ' . WPSHOP_DBT_ATTRIBUTE_UNIT . '.unit AS unit, ' . WPSHOP_DBT_ATTRIBUTE . '.frontend_verification |
|
| 1079 | + FROM '.WPSHOP_DBT_ATTRIBUTE_DETAILS . ' |
|
| 1080 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE . ' ON ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1081 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1082 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1083 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1084 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1085 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . ' ON ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.attribute_id=' . WPSHOP_DBT_ATTRIBUTE . '.id |
|
| 1086 | + LEFT JOIN '.WPSHOP_DBT_ATTRIBUTE_UNIT . ' ON ( |
|
| 1087 | + '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.unit_id |
|
| 1088 | + OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.unit_id |
|
| 1089 | + OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.unit_id |
|
| 1090 | + OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.unit_id |
|
| 1091 | + OR '.WPSHOP_DBT_ATTRIBUTE_UNIT . '.id=' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR . '.unit_id |
|
| 1092 | 1092 | ) |
| 1093 | 1093 | WHERE |
| 1094 | - '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.status="valid" |
|
| 1095 | - AND '.WPSHOP_DBT_ATTRIBUTE.'.status="valid" |
|
| 1096 | - AND '.WPSHOP_DBT_ATTRIBUTE_DETAILS.'.attribute_group_id IN ('.$atts['sid'].') |
|
| 1094 | + '.WPSHOP_DBT_ATTRIBUTE_DETAILS . '.status="valid" |
|
| 1095 | + AND '.WPSHOP_DBT_ATTRIBUTE . '.status="valid" |
|
| 1096 | + AND '.WPSHOP_DBT_ATTRIBUTE_DETAILS . '.attribute_group_id IN (' . $atts['sid'] . ') |
|
| 1097 | 1097 | AND ( |
| 1098 | - '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.'.entity_id='.$atts['pid'].' |
|
| 1099 | - OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME.'.entity_id='.$atts['pid'].' |
|
| 1100 | - OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER.'.entity_id='.$atts['pid'].' |
|
| 1101 | - OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT.'.entity_id='.$atts['pid'].' |
|
| 1102 | - OR '.WPSHOP_DBT_ATTRIBUTE.'_value_varchar.entity_id='.$atts['pid'].' |
|
| 1098 | + '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL . '.entity_id=' . $atts['pid'] . ' |
|
| 1099 | + OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME . '.entity_id=' . $atts['pid'] . ' |
|
| 1100 | + OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER . '.entity_id=' . $atts['pid'] . ' |
|
| 1101 | + OR '.WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT . '.entity_id=' . $atts['pid'] . ' |
|
| 1102 | + OR '.WPSHOP_DBT_ATTRIBUTE . '_value_varchar.entity_id=' . $atts['pid'] . ' |
|
| 1103 | 1103 | ) |
| 1104 | 1104 | '; |
| 1105 | 1105 | $data = $wpdb->get_results($query); |
| 1106 | - foreach($data as $d) { |
|
| 1106 | + foreach ($data as $d) { |
|
| 1107 | 1107 | $value_style_start = $value_style_end = ''; |
| 1108 | - if ( !empty($d->frontend_verification) ) { |
|
| 1109 | - switch ( $d->frontend_verification ) { |
|
| 1108 | + if (!empty($d->frontend_verification)) { |
|
| 1109 | + switch ($d->frontend_verification) { |
|
| 1110 | 1110 | case 'phone': |
| 1111 | 1111 | $value_style_start = '<a href="tel:' . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . '" >'; |
| 1112 | 1112 | $value_style_end = '</a>'; |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | break; |
| 1118 | 1118 | } |
| 1119 | 1119 | } |
| 1120 | - echo '<strong>'.__($d->frontend_label, 'wpshop').'</strong> : ' . $value_style_start . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . $value_style_end . ( !empty($d->unit) ? ' ('.$d->unit.')' : '' ) . '<br />'; |
|
| 1120 | + echo '<strong>' . __($d->frontend_label, 'wpshop') . '</strong> : ' . $value_style_start . $d->value_decimal . $d->value_datetime . $d->value_integer . $d->value_text . $d->value_varchar . $value_style_end . (!empty($d->unit) ? ' (' . $d->unit . ')' : '') . '<br />'; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | |
@@ -1132,31 +1132,31 @@ discard block |
||
| 1132 | 1132 | * |
| 1133 | 1133 | * @return string Le code html permettant d'afficher la liste des groupes et/ou sous-groupes d'attributs |
| 1134 | 1134 | */ |
| 1135 | - public static function get_attribute_set_complete_list($entity_id, $table, $page_code, $complete_tree = true){ |
|
| 1135 | + public static function get_attribute_set_complete_list($entity_id, $table, $page_code, $complete_tree = true) { |
|
| 1136 | 1136 | $the_input = __('There is no attribute set for this entity', 'wpshop'); |
| 1137 | 1137 | |
| 1138 | 1138 | $attr_set_list = wpshop_attributes_set::getElement($entity_id, "'valid'", 'entity_id', 'all'); |
| 1139 | - if ( !empty($attr_set_list) ) { |
|
| 1139 | + if (!empty($attr_set_list)) { |
|
| 1140 | 1140 | $the_input = '<select name="' . $table . '[set_section]" class="wpshop_' . $page_code . '_set_section" >'; |
| 1141 | 1141 | if (!$complete_tree) { |
| 1142 | - $the_input .= '<option value="0">'.__('None', 'wpshop').'</option>'; |
|
| 1142 | + $the_input .= '<option value="0">' . __('None', 'wpshop') . '</option>'; |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | - foreach ( $attr_set_list as $attr_set_index => $attr_set ) { |
|
| 1146 | - if ( !empty($attr_set->id) ) { |
|
| 1145 | + foreach ($attr_set_list as $attr_set_index => $attr_set) { |
|
| 1146 | + if (!empty($attr_set->id)) { |
|
| 1147 | 1147 | $attribute_set_details = wpshop_attributes_set::getAttributeSetDetails($attr_set->id, "'valid'"); |
| 1148 | - if ( !empty($attribute_set_details) ) { |
|
| 1148 | + if (!empty($attribute_set_details)) { |
|
| 1149 | 1149 | |
| 1150 | 1150 | if ($complete_tree) { |
| 1151 | - $the_input .= '<optgroup label="'.__($attr_set->name, 'wpshop').'" >'; |
|
| 1152 | - foreach ( $attribute_set_details as $set_details ) { |
|
| 1153 | - $selected = ( ( $attr_set->default_set == 'yes' ) && ( $set_details['is_default_group'] == 'yes' ) ? ' selected="selected"' : '' ); |
|
| 1154 | - $the_input .= '<option'.$selected.' value="'.$attr_set->id.'_'.$set_details['id'].'">'.__($set_details['name'],'wpshop').'</option>'; |
|
| 1151 | + $the_input .= '<optgroup label="' . __($attr_set->name, 'wpshop') . '" >'; |
|
| 1152 | + foreach ($attribute_set_details as $set_details) { |
|
| 1153 | + $selected = (($attr_set->default_set == 'yes') && ($set_details['is_default_group'] == 'yes') ? ' selected="selected"' : ''); |
|
| 1154 | + $the_input .= '<option' . $selected . ' value="' . $attr_set->id . '_' . $set_details['id'] . '">' . __($set_details['name'], 'wpshop') . '</option>'; |
|
| 1155 | 1155 | } |
| 1156 | 1156 | $the_input .= '</optgroup>'; |
| 1157 | 1157 | } |
| 1158 | 1158 | else { |
| 1159 | - $the_input .= '<option value="'.$attr_set->id.'">'.__($attr_set->name, 'wpshop').'</option>'; |
|
| 1159 | + $the_input .= '<option value="' . $attr_set->id . '">' . __($attr_set->name, 'wpshop') . '</option>'; |
|
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | 1162 | } |
@@ -1423,7 +1423,7 @@ |
||
| 1423 | 1423 | * @param string $attributeType The extension of the database table to get the attribute value in |
| 1424 | 1424 | * @param integer $attributeId The attribute identifier we want to get the value for |
| 1425 | 1425 | * @param integer $entityTypeId The entity type identifier we want to get the attribute value for (example: product = 1) |
| 1426 | - * @param integer $entityId The entity id we want the attribute value for |
|
| 1426 | + * @param integer $entityId The entity id we want the attribute value for |
|
| 1427 | 1427 | * |
| 1428 | 1428 | * @return object $attributeValue A wordpress database object containing the value of the attribute for the selected entity |
| 1429 | 1429 | */ |
@@ -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' ) ) { |
@@ -90,12 +92,12 @@ discard block |
||
| 90 | 92 | if(($action == 'edit') || ($action == 'delete')){ |
| 91 | 93 | $editedItem = self::getElement($objectInEdition); |
| 92 | 94 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label)); |
| 95 | + } elseif($action == 'add') { |
|
| 96 | + $title = __(self::pageAddingTitle, 'wpshop'); |
|
| 93 | 97 | } |
| 94 | - elseif($action == 'add') |
|
| 95 | - $title = __(self::pageAddingTitle, 'wpshop'); |
|
| 98 | + } elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) { |
|
| 99 | + $title = __(self::pageAddingTitle, 'wpshop'); |
|
| 96 | 100 | } |
| 97 | - elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) |
|
| 98 | - $title = __(self::pageAddingTitle, 'wpshop'); |
|
| 99 | 101 | |
| 100 | 102 | return $title; |
| 101 | 103 | } |
@@ -126,14 +128,15 @@ discard block |
||
| 126 | 128 | if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){ |
| 127 | 129 | $editedElement = self::getElement($saveditem); |
| 128 | 130 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 129 | - } |
|
| 130 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 131 | + } elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 131 | 132 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 132 | 133 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 133 | 134 | } |
| 134 | 135 | |
| 135 | 136 | $attribute_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array(); |
| 136 | - if ( !empty($set_section) ) unset($attribute_parameter['set_section']); |
|
| 137 | + if ( !empty($set_section) ) { |
|
| 138 | + unset($attribute_parameter['set_section']); |
|
| 139 | + } |
|
| 137 | 140 | |
| 138 | 141 | $wpshop_attribute_combo_values_list_order_def = !empty($attribute_parameter['wpshop_attribute_combo_values_list_order_def']) ? $attribute_parameter['wpshop_attribute_combo_values_list_order_def'] : array(); |
| 139 | 142 | // @TODO $_REQUEST |
@@ -193,66 +196,82 @@ discard block |
||
| 193 | 196 | switch ($attribute_parameter['frontend_input']) { |
| 194 | 197 | case 'short_text': |
| 195 | 198 | $attribute_parameter['frontend_input'] = 'text'; |
| 196 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 199 | + if ( empty($attribute_parameter['backend_input']) ) { |
|
| 200 | + $attribute_parameter['backend_input'] = 'text'; |
|
| 201 | + } |
|
| 197 | 202 | $attribute_parameter['data_type'] = 'varchar'; |
| 198 | 203 | break; |
| 199 | 204 | case 'date_field': |
| 200 | 205 | $attribute_parameter['frontend_input'] = 'text'; |
| 201 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 206 | + if ( empty($attribute_parameter['backend_input']) ) { |
|
| 207 | + $attribute_parameter['backend_input'] = 'text'; |
|
| 208 | + } |
|
| 202 | 209 | $attribute_parameter['data_type'] = 'datetime'; |
| 203 | 210 | break; |
| 204 | 211 | case 'float_field': |
| 205 | 212 | $attribute_parameter['frontend_input'] = 'text'; |
| 206 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 213 | + if ( empty($attribute_parameter['backend_input']) ) { |
|
| 214 | + $attribute_parameter['backend_input'] = 'text'; |
|
| 215 | + } |
|
| 207 | 216 | $attribute_parameter['data_type'] = 'decimal'; |
| 208 | 217 | break; |
| 209 | 218 | case 'hidden_field': |
| 210 | 219 | $attribute_parameter['frontend_input'] = 'hidden'; |
| 211 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 220 | + if ( empty($attribute_parameter['backend_input']) ) { |
|
| 221 | + $attribute_parameter['backend_input'] = 'text'; |
|
| 222 | + } |
|
| 212 | 223 | $attribute_parameter['data_type'] = 'varchar'; |
| 213 | 224 | break; |
| 214 | 225 | case 'pass_field': |
| 215 | 226 | $attribute_parameter['frontend_input'] = 'password'; |
| 216 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 227 | + if ( empty($attribute_parameter['backend_input']) ) { |
|
| 228 | + $attribute_parameter['backend_input'] = 'text'; |
|
| 229 | + } |
|
| 217 | 230 | $attribute_parameter['data_type'] = 'varchar'; |
| 218 | 231 | break; |
| 219 | 232 | |
| 220 | 233 | case 'select': |
| 221 | 234 | $attribute_parameter['frontend_input'] = 'select'; |
| 222 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 223 | - $attribute_parameter['backend_input'] = 'multiple-select'; |
|
| 235 | + if ( empty($attribute_parameter['backend_input']) || empty($id) ) { |
|
| 236 | + $attribute_parameter['backend_input'] = 'multiple-select'; |
|
| 237 | + } |
|
| 224 | 238 | $attribute_parameter['data_type'] = 'integer'; |
| 225 | 239 | break; |
| 226 | 240 | case 'multiple-select': |
| 227 | 241 | $attribute_parameter['frontend_input'] = 'multiple-select'; |
| 228 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 229 | - $attribute_parameter['backend_input'] = 'multiple-select'; |
|
| 242 | + if ( empty($attribute_parameter['backend_input']) || empty($id) ) { |
|
| 243 | + $attribute_parameter['backend_input'] = 'multiple-select'; |
|
| 244 | + } |
|
| 230 | 245 | $attribute_parameter['data_type'] = 'integer'; |
| 231 | 246 | break; |
| 232 | 247 | case 'radio': |
| 233 | 248 | $attribute_parameter['frontend_input'] = 'radio'; |
| 234 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 235 | - $attribute_parameter['backend_input'] = 'multiple-select'; |
|
| 249 | + if ( empty($attribute_parameter['backend_input']) || empty($id) ) { |
|
| 250 | + $attribute_parameter['backend_input'] = 'multiple-select'; |
|
| 251 | + } |
|
| 236 | 252 | $attribute_parameter['data_type'] = 'integer'; |
| 237 | 253 | break; |
| 238 | 254 | case 'checkbox': |
| 239 | 255 | $attribute_parameter['frontend_input'] = 'checkbox'; |
| 240 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 241 | - $attribute_parameter['backend_input'] = 'multiple-select'; |
|
| 256 | + if ( empty($attribute_parameter['backend_input']) || empty($id) ) { |
|
| 257 | + $attribute_parameter['backend_input'] = 'multiple-select'; |
|
| 258 | + } |
|
| 242 | 259 | $attribute_parameter['data_type'] = 'integer'; |
| 243 | 260 | break; |
| 244 | 261 | |
| 245 | 262 | case 'textarea': |
| 246 | 263 | $attribute_parameter['frontend_input'] = 'textarea'; |
| 247 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 248 | - $attribute_parameter['backend_input'] = 'textarea'; |
|
| 264 | + if ( empty($attribute_parameter['backend_input']) || empty($id) ) { |
|
| 265 | + $attribute_parameter['backend_input'] = 'textarea'; |
|
| 266 | + } |
|
| 249 | 267 | $attribute_parameter['data_type'] = 'text'; |
| 250 | 268 | break; |
| 251 | 269 | } |
| 252 | - } |
|
| 253 | - else { |
|
| 270 | + } else { |
|
| 254 | 271 | $attribute_parameter['frontend_input'] = 'text'; |
| 255 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 272 | + if ( empty($attribute_parameter['backend_input']) ) { |
|
| 273 | + $attribute_parameter['backend_input'] = 'text'; |
|
| 274 | + } |
|
| 256 | 275 | $attribute_parameter['data_type'] = 'varchar'; |
| 257 | 276 | } |
| 258 | 277 | |
@@ -284,22 +303,18 @@ discard block |
||
| 284 | 303 | if(!in_array($attribute_code, $attribute_undeletable)){ |
| 285 | 304 | if(current_user_can('wpshop_delete_attributes')){ |
| 286 | 305 | $attribute_parameter['status'] = 'deleted'; |
| 287 | - } |
|
| 288 | - else{ |
|
| 306 | + } else{ |
|
| 289 | 307 | $actionResult = 'userNotAllowedForActionDelete'; |
| 290 | 308 | } |
| 291 | - } |
|
| 292 | - else{ |
|
| 309 | + } else{ |
|
| 293 | 310 | $actionResult = 'unDeletableAtribute'; |
| 294 | 311 | } |
| 295 | 312 | } |
| 296 | 313 | $actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable()); |
| 297 | - } |
|
| 298 | - else{ |
|
| 314 | + } else{ |
|
| 299 | 315 | $actionResult = 'userNotAllowedForActionEdit'; |
| 300 | 316 | } |
| 301 | - } |
|
| 302 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 317 | + } elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 303 | 318 | $attribute_code = ''; |
| 304 | 319 | if (empty( $attribute_parameter['code'])) { |
| 305 | 320 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused', 'deleted'", 'id'); |
@@ -310,14 +325,13 @@ discard block |
||
| 310 | 325 | $attribute_parameter['last_update_date'] = current_time('mysql', 0); |
| 311 | 326 | $attribute_parameter['status'] = 'deleted'; |
| 312 | 327 | $actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable()); |
| 328 | + } else { |
|
| 329 | + $actionResult = 'userNotAllowedForActionDelete'; |
|
| 313 | 330 | } |
| 314 | - else |
|
| 315 | - $actionResult = 'userNotAllowedForActionDelete'; |
|
| 331 | + } else { |
|
| 332 | + $actionResult = 'unDeletableAtribute'; |
|
| 316 | 333 | } |
| 317 | - else |
|
| 318 | - $actionResult = 'unDeletableAtribute'; |
|
| 319 | - } |
|
| 320 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 334 | + } elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 321 | 335 | if(current_user_can('wpshop_add_attributes')){ |
| 322 | 336 | $attribute_parameter['creation_date'] = current_time('mysql', 0); |
| 323 | 337 | if(trim($attribute_parameter['code']) == ''){ |
@@ -330,8 +344,7 @@ discard block |
||
| 330 | 344 | } |
| 331 | 345 | $actionResult = wpshop_database::save($attribute_parameter, self::getDbTable()); |
| 332 | 346 | $id = $wpdb->insert_id; |
| 333 | - } |
|
| 334 | - else{ |
|
| 347 | + } else{ |
|
| 335 | 348 | $actionResult = 'userNotAllowedForActionAdd'; |
| 336 | 349 | } |
| 337 | 350 | } |
@@ -342,11 +355,12 @@ discard block |
||
| 342 | 355 | /****************************************************************************/ |
| 343 | 356 | if($actionResult != ''){ |
| 344 | 357 | $elementIdentifierForMessage = __('the attribute', 'wpshop'); |
| 345 | - if(!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>'; |
|
| 358 | + if(!empty($attribute_parameter['name'])) { |
|
| 359 | + $elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>'; |
|
| 360 | + } |
|
| 346 | 361 | if ($actionResult == 'error') {/* CHANGE HERE FOR SPECIFIC CASE */ |
| 347 | 362 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage, ' -> ' . $wpdb->last_error); |
| 348 | - } |
|
| 349 | - else if (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) {/* CHANGE HERE FOR SPECIFIC CASE */ |
|
| 363 | + } else if (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) {/* CHANGE HERE FOR SPECIFIC CASE */ |
|
| 350 | 364 | /*****************************************************************************************************************/ |
| 351 | 365 | /************************* CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT ****************************/ |
| 352 | 366 | /*****************************************************************************************************************/ |
@@ -365,8 +379,7 @@ discard block |
||
| 365 | 379 | if (empty($attribute_parameter['code'])) { |
| 366 | 380 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id'); |
| 367 | 381 | $attribute_code = $attribute->code; |
| 368 | - } |
|
| 369 | - else { |
|
| 382 | + } else { |
|
| 370 | 383 | $attribute_code = $attribute_parameter['code']; |
| 371 | 384 | } |
| 372 | 385 | foreach ($optionsUpdate as $option_key => $option_label) { |
@@ -457,8 +470,7 @@ discard block |
||
| 457 | 470 | $choosen_set_section = explode('_', $set_section); |
| 458 | 471 | $set_id = $choosen_set_section[0]; |
| 459 | 472 | $group_id = $choosen_set_section[1]; |
| 460 | - } |
|
| 461 | - else{ |
|
| 473 | + } else{ |
|
| 462 | 474 | $attribute_current_attribute_set = 0; |
| 463 | 475 | $query = $wpdb->prepare(" |
| 464 | 476 | SELECT id |
@@ -506,7 +518,9 @@ discard block |
||
| 506 | 518 | $attribute_parameter['entity_id'] |
| 507 | 519 | ); |
| 508 | 520 | $wpshopAttributePosition = $wpdb->get_var($query); |
| 509 | - if($wpshopAttributePosition == 0)$wpshopAttributePosition = 1; |
|
| 521 | + if($wpshopAttributePosition == 0) { |
|
| 522 | + $wpshopAttributePosition = 1; |
|
| 523 | + } |
|
| 510 | 524 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_parameter['entity_id'], 'attribute_set_id' => $set_id, 'attribute_group_id' => $group_id, 'attribute_id' => $id, 'position' => $wpshopAttributePosition)); |
| 511 | 525 | } |
| 512 | 526 | } |
@@ -527,15 +541,14 @@ discard block |
||
| 527 | 541 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 528 | 542 | } |
| 529 | 543 | else */ |
| 530 | - if ( $pageAction == 'add' ) |
|
| 531 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
|
| 532 | - elseif ( $pageAction == 'delete' ) |
|
| 533 | - wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
|
| 534 | - } |
|
| 535 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){ |
|
| 544 | + if ( $pageAction == 'add' ) { |
|
| 545 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
|
| 546 | + } elseif ( $pageAction == 'delete' ) { |
|
| 547 | + wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
|
| 548 | + } |
|
| 549 | + } elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){ |
|
| 536 | 550 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 537 | - } |
|
| 538 | - elseif(($actionResult == 'unDeletableAtribute')){ |
|
| 551 | + } elseif(($actionResult == 'unDeletableAtribute')){ |
|
| 539 | 552 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('This attribute could not be deleted due to configuration', 'wpshop'); |
| 540 | 553 | } |
| 541 | 554 | |
@@ -580,8 +593,7 @@ discard block |
||
| 580 | 593 | if ( !empty($s) ) { |
| 581 | 594 | $query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop') ); |
| 582 | 595 | $attr_set_list = $wpdb->get_results( $query ); |
| 583 | - } |
|
| 584 | - else { |
|
| 596 | + } else { |
|
| 585 | 597 | $attr_set_list = self::getElement( '', $status ); |
| 586 | 598 | } |
| 587 | 599 | $i=0; |
@@ -635,8 +647,9 @@ discard block |
||
| 635 | 647 | global $attribute_displayed_field, $attribute_options_group; |
| 636 | 648 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 637 | 649 | $editedItem = ''; |
| 638 | - if($itemToEdit != '') |
|
| 639 | - $editedItem = self::getElement($itemToEdit); |
|
| 650 | + if($itemToEdit != '') { |
|
| 651 | + $editedItem = self::getElement($itemToEdit); |
|
| 652 | + } |
|
| 640 | 653 | |
| 641 | 654 | $the_form_content_hidden = $the_form_general_content = ''; |
| 642 | 655 | $the_form_option_content_list = array(); |
@@ -649,10 +662,11 @@ discard block |
||
| 649 | 662 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 650 | 663 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : ''; |
| 651 | 664 | $currentFieldValue = $input_def['value']; |
| 652 | - if(is_object($editedItem)) |
|
| 653 | - $currentFieldValue = $editedItem->{$input_def['label']}; |
|
| 654 | - elseif(($pageAction != '') && ($requestFormValue != '')) |
|
| 655 | - $currentFieldValue = $requestFormValue; |
|
| 665 | + if(is_object($editedItem)) { |
|
| 666 | + $currentFieldValue = $editedItem->{$input_def['label']}; |
|
| 667 | + } elseif(($pageAction != '') && ($requestFormValue != '')) { |
|
| 668 | + $currentFieldValue = $requestFormValue; |
|
| 669 | + } |
|
| 656 | 670 | |
| 657 | 671 | if($input_def['label'] == 'status'){ |
| 658 | 672 | if(in_array('notused', $input_def['possible_value'])){ |
@@ -724,9 +738,9 @@ discard block |
||
| 724 | 738 | } |
| 725 | 739 | |
| 726 | 740 | $input_def['value'] = $currentFieldValue; |
| 727 | - if($input_def['label'] == 'code') |
|
| 728 | - $input_def['type'] = 'hidden'; |
|
| 729 | - elseif($input_def['label'] == 'entity_id'){ |
|
| 741 | + if($input_def['label'] == 'code') { |
|
| 742 | + $input_def['type'] = 'hidden'; |
|
| 743 | + } elseif($input_def['label'] == 'entity_id'){ |
|
| 730 | 744 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
| 731 | 745 | $input_def['valueToPut'] = 'index'; |
| 732 | 746 | $input_def['type'] = 'select'; |
@@ -738,21 +752,17 @@ discard block |
||
| 738 | 752 | } |
| 739 | 753 | $i++; |
| 740 | 754 | } |
| 741 | - } |
|
| 742 | - elseif($input_def['label'] == '_unit_group_id'){ |
|
| 755 | + } elseif($input_def['label'] == '_unit_group_id'){ |
|
| 743 | 756 | $input_def['possible_value'] = wpshop_attributes_unit::get_unit_group(); |
| 744 | 757 | $input_def['type'] = 'select'; |
| 745 | - } |
|
| 746 | - elseif($input_def['label'] == '_default_unit'){ |
|
| 758 | + } elseif($input_def['label'] == '_default_unit'){ |
|
| 747 | 759 | $unit_group_list = wpshop_attributes_unit::get_unit_group(); |
| 748 | 760 | $input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id)?$editedItem->_unit_group_id:(!empty($unit_group_list)?$unit_group_list[0]->id:'')); |
| 749 | 761 | $input_def['type'] = 'select'; |
| 750 | - } |
|
| 751 | - elseif ($input_def['label'] == 'backend_input') { |
|
| 762 | + } elseif ($input_def['label'] == 'backend_input') { |
|
| 752 | 763 | if ( !is_object($editedItem) ) { |
| 753 | 764 | $input_def['type'] = 'hidden'; |
| 754 | - } |
|
| 755 | - else { |
|
| 765 | + } else { |
|
| 756 | 766 | $new_possible_value = array(); |
| 757 | 767 | switch ( $editedItem->data_type) { |
| 758 | 768 | case 'integer': |
@@ -786,8 +796,7 @@ discard block |
||
| 786 | 796 | } |
| 787 | 797 | $input_def['possible_value'] = $new_possible_value; |
| 788 | 798 | } |
| 789 | - } |
|
| 790 | - elseif ($input_def['label'] == 'frontend_input') { |
|
| 799 | + } elseif ($input_def['label'] == 'frontend_input') { |
|
| 791 | 800 | $new_possible_value = array(); |
| 792 | 801 | |
| 793 | 802 | if ( is_object($editedItem) ) { |
@@ -821,8 +830,7 @@ discard block |
||
| 821 | 830 | $new_possible_value[__('Date field', 'wpshop')] = 'date_field'; |
| 822 | 831 | break; |
| 823 | 832 | } |
| 824 | - } |
|
| 825 | - else { |
|
| 833 | + } else { |
|
| 826 | 834 | $new_possible_value[__('Text field', 'wpshop')] = 'short_text'; |
| 827 | 835 | $new_possible_value[__('Number field', 'wpshop')] = 'float_field'; |
| 828 | 836 | $new_possible_value[__('Date field', 'wpshop')] = 'date_field'; |
@@ -914,8 +922,7 @@ discard block |
||
| 914 | 922 | $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 915 | 923 | break; |
| 916 | 924 | } |
| 917 | - } |
|
| 918 | - else { |
|
| 925 | + } else { |
|
| 919 | 926 | $input_def['type']='text'; |
| 920 | 927 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 921 | 928 | } |
@@ -942,9 +949,9 @@ discard block |
||
| 942 | 949 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_def['name'].'" ><label for="'.$input_def_id.'" >' . __($input_def['label'], 'wpshop') . '</label></td> |
| 943 | 950 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_def['name'].'" >' . $the_input . '</td> |
| 944 | 951 | </tr>'; |
| 945 | - if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) ) |
|
| 946 | - $the_form_option_content_list[$input_def['label']] = $input; |
|
| 947 | - else { |
|
| 952 | + if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) ) { |
|
| 953 | + $the_form_option_content_list[$input_def['label']] = $input; |
|
| 954 | + } else { |
|
| 948 | 955 | $the_form_general_content .= $input; |
| 949 | 956 | if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) { |
| 950 | 957 | |
@@ -958,8 +965,7 @@ discard block |
||
| 958 | 965 | $the_form_general_content .= $input; |
| 959 | 966 | } |
| 960 | 967 | } |
| 961 | - } |
|
| 962 | - else{ |
|
| 968 | + } else{ |
|
| 963 | 969 | $the_form_content_hidden .= ' |
| 964 | 970 | ' . $the_input; |
| 965 | 971 | } |
@@ -1244,17 +1250,18 @@ discard block |
||
| 1244 | 1250 | |
| 1245 | 1251 | //$currentPageButton .= '<h2 class="cancelButton alignleft" ><a href="' . admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&page=' . self::getListingSlug()) . '" class="button add-new-h2" >' . __('Back', 'wpshop') . '</a></h2>'; |
| 1246 | 1252 | |
| 1247 | - if(($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1248 | - $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
|
| 1249 | - |
|
| 1250 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 1251 | - $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
|
| 1253 | + if(($action == 'add') && (current_user_can('wpshop_add_attributes'))) { |
|
| 1254 | + $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
|
| 1255 | + } elseif(current_user_can('wpshop_edit_attributes')) { |
|
| 1256 | + $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
|
| 1257 | + } |
|
| 1252 | 1258 | |
| 1253 | 1259 | $attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE); |
| 1254 | 1260 | $attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id'); |
| 1255 | 1261 | $attribute_code = !empty($attribute->code)?$attribute->code:''; |
| 1256 | - if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1257 | - $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1262 | + if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) { |
|
| 1263 | + $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1264 | + } |
|
| 1258 | 1265 | |
| 1259 | 1266 | return $currentPageButton; |
| 1260 | 1267 | } |
@@ -1299,8 +1306,7 @@ discard block |
||
| 1299 | 1306 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 1300 | 1307 | if(($element_id == '') || $list){ |
| 1301 | 1308 | $element_list = $wpdb->get_results($query); |
| 1302 | - } |
|
| 1303 | - else{ |
|
| 1309 | + } else{ |
|
| 1304 | 1310 | $element_list = $wpdb->get_row($query); |
| 1305 | 1311 | } |
| 1306 | 1312 | |
@@ -1394,8 +1400,7 @@ discard block |
||
| 1394 | 1400 | foreach($attributeValue as $a){ |
| 1395 | 1401 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a))); |
| 1396 | 1402 | } |
| 1397 | - } |
|
| 1398 | - else{ |
|
| 1403 | + } else{ |
|
| 1399 | 1404 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue))); |
| 1400 | 1405 | wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array( |
| 1401 | 1406 | 'object_id' => $entityId, |
@@ -1414,8 +1419,10 @@ discard block |
||
| 1414 | 1419 | $value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value'); |
| 1415 | 1420 | if (strtolower($value) == 'yes') : |
| 1416 | 1421 | update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option); |
| 1417 | - else : |
|
| 1422 | + else { |
|
| 1423 | + : |
|
| 1418 | 1424 | delete_post_meta($entityId, 'attribute_option_'.$attribute_code); |
| 1425 | + } |
|
| 1419 | 1426 | endif; |
| 1420 | 1427 | } |
| 1421 | 1428 | } |
@@ -1475,8 +1482,7 @@ discard block |
||
| 1475 | 1482 | |
| 1476 | 1483 | if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) { |
| 1477 | 1484 | $attributeValue = $attributeValue[0]; |
| 1478 | - } |
|
| 1479 | - else{ |
|
| 1485 | + } else{ |
|
| 1480 | 1486 | $entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true); |
| 1481 | 1487 | if ( !empty($entity_meta) ) { |
| 1482 | 1488 | $query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId); |
@@ -1542,12 +1548,10 @@ discard block |
||
| 1542 | 1548 | if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) { |
| 1543 | 1549 | if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
| 1544 | 1550 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField; |
| 1545 | - } |
|
| 1546 | - else { |
|
| 1551 | + } else { |
|
| 1547 | 1552 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField); |
| 1548 | 1553 | } |
| 1549 | - } |
|
| 1550 | - else { |
|
| 1554 | + } else { |
|
| 1551 | 1555 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField; |
| 1552 | 1556 | } |
| 1553 | 1557 | |
@@ -1628,17 +1632,14 @@ discard block |
||
| 1628 | 1632 | if ( ( is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes' ) |
| 1629 | 1633 | || empty($attribute_custom_config) ) { |
| 1630 | 1634 | $attribute_output = true; |
| 1631 | - } |
|
| 1632 | - else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) ) { |
|
| 1635 | + } else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) ) { |
|
| 1633 | 1636 | $attribute_output = false; |
| 1634 | 1637 | } |
| 1635 | - } |
|
| 1636 | - elseif ( $attribute_main_config === 'no' ) { |
|
| 1638 | + } elseif ( $attribute_main_config === 'no' ) { |
|
| 1637 | 1639 | $attribute_output = false; |
| 1638 | 1640 | if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) { |
| 1639 | 1641 | $attribute_output = false; |
| 1640 | - } |
|
| 1641 | - else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') ) { |
|
| 1642 | + } else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') ) { |
|
| 1642 | 1643 | $attribute_output = true; |
| 1643 | 1644 | } |
| 1644 | 1645 | } |
@@ -1656,7 +1657,9 @@ discard block |
||
| 1656 | 1657 | global $wp_query; |
| 1657 | 1658 | |
| 1658 | 1659 | $attribute = self::getElement( $atts['attid'] ); |
| 1659 | - if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1660 | + if(empty($atts['pid'])) { |
|
| 1661 | + $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1662 | + } |
|
| 1660 | 1663 | $attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
| 1661 | 1664 | $output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output'; |
| 1662 | 1665 | $product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true); |
@@ -1675,13 +1678,11 @@ discard block |
||
| 1675 | 1678 | } |
| 1676 | 1679 | $has_value = true; |
| 1677 | 1680 | } |
| 1678 | - } |
|
| 1679 | - else { |
|
| 1681 | + } else { |
|
| 1680 | 1682 | $data = $wpdb->get_var($query); |
| 1681 | 1683 | if ( !empty($data) ) { |
| 1682 | 1684 | $has_value = true; |
| 1683 | - } |
|
| 1684 | - elseif( !empty($attribute->default_value) ) { |
|
| 1685 | + } elseif( !empty($attribute->default_value) ) { |
|
| 1685 | 1686 | $has_value = true; |
| 1686 | 1687 | $data = $attribute->default_value; |
| 1687 | 1688 | } |
@@ -1741,11 +1742,9 @@ discard block |
||
| 1741 | 1742 | |
| 1742 | 1743 | if ( !empty($attribute_value) && !is_object($attribute_value) ) { |
| 1743 | 1744 | $input_def['value'] = $attribute_value; |
| 1744 | - } |
|
| 1745 | - else if ( !empty($attribute_value->value) ) { |
|
| 1745 | + } else if ( !empty($attribute_value->value) ) { |
|
| 1746 | 1746 | $input_def['value'] = stripslashes($attribute_value->value); |
| 1747 | - } |
|
| 1748 | - else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) { |
|
| 1747 | + } else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) { |
|
| 1749 | 1748 | $input_def['value'] = ''; |
| 1750 | 1749 | } |
| 1751 | 1750 | |
@@ -1755,8 +1754,7 @@ discard block |
||
| 1755 | 1754 | $date_config = unserialize( $attribute->default_value ); |
| 1756 | 1755 | if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) { |
| 1757 | 1756 | $input_def['value'] = date('Y-m-d'); |
| 1758 | - } |
|
| 1759 | - else { |
|
| 1757 | + } else { |
|
| 1760 | 1758 | /** Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/ */ |
| 1761 | 1759 | $input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace( " 00:00:00", "", $attribute_value->value ) : ( !empty($attribute_value) && is_string($attribute_value) ? str_replace( " 00:00:00", "", $attribute_value ) : '' ); |
| 1762 | 1760 | } |
@@ -1861,8 +1859,7 @@ discard block |
||
| 1861 | 1859 | if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){ |
| 1862 | 1860 | $input_def['option'] .= ' readonly="readonly" '; |
| 1863 | 1861 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1864 | - } |
|
| 1865 | - elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){ |
|
| 1862 | + } elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){ |
|
| 1866 | 1863 | $input_def['option'] .= ' readonly="readonly" '; |
| 1867 | 1864 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1868 | 1865 | } |
@@ -1886,14 +1883,12 @@ discard block |
||
| 1886 | 1883 | if ($attribute->is_requiring_unit == 'yes') { |
| 1887 | 1884 | if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) { |
| 1888 | 1885 | $input_def['options'] .= ' <span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>'; |
| 1889 | - } |
|
| 1890 | - elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) { |
|
| 1886 | + } elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) { |
|
| 1891 | 1887 | $weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity'); |
| 1892 | 1888 | $query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
| 1893 | 1889 | $unity = $wpdb->get_var( $query ); |
| 1894 | 1890 | $input_def['options'] .= ' <span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>'; |
| 1895 | - } |
|
| 1896 | - else { |
|
| 1891 | + } else { |
|
| 1897 | 1892 | unset($unit_input_def); |
| 1898 | 1893 | $unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id); |
| 1899 | 1894 | $unit_input_def['type'] = 'select'; |
@@ -1904,8 +1899,7 @@ discard block |
||
| 1904 | 1899 | if($unit_input_def['value'] == ''){ |
| 1905 | 1900 | if ( $attribute->_default_unit > 0 ) { |
| 1906 | 1901 | $unit_input_def['value'] = $attribute->_default_unit; |
| 1907 | - } |
|
| 1908 | - else { |
|
| 1902 | + } else { |
|
| 1909 | 1903 | $unit_input_def['value'] = wpshop_attributes_unit::get_default_unit_for_group($attribute->_unit_group_id); |
| 1910 | 1904 | } |
| 1911 | 1905 | } |
@@ -1929,8 +1923,7 @@ discard block |
||
| 1929 | 1923 | $input_def['label_pointer'] = ''; |
| 1930 | 1924 | $input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "'; |
| 1931 | 1925 | $input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container'; |
| 1932 | - } |
|
| 1933 | - else { |
|
| 1926 | + } else { |
|
| 1934 | 1927 | $input_def['output'] = wpshop_form::check_input_type($input_def, $attributeInputDomain); |
| 1935 | 1928 | } |
| 1936 | 1929 | return $input_def; |
@@ -2027,8 +2020,7 @@ discard block |
||
| 2027 | 2020 | /** Check the value type to check if empty or not */ |
| 2028 | 2021 | if ( $attributeDefinition['data_type'] == 'int' ) { |
| 2029 | 2022 | $attributeDefinition['value'] = (int)$attributeDefinition['value']; |
| 2030 | - } |
|
| 2031 | - else if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2023 | + } else if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2032 | 2024 | $attributeDefinition['value'] = (float)$attributeDefinition['value']; |
| 2033 | 2025 | } |
| 2034 | 2026 | |
@@ -2090,8 +2082,7 @@ discard block |
||
| 2090 | 2082 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
| 2091 | 2083 | $tab_list .= ob_get_contents(); |
| 2092 | 2084 | ob_end_clean(); |
| 2093 | - } |
|
| 2094 | - else { |
|
| 2085 | + } else { |
|
| 2095 | 2086 | $tab_list .= wpshop_display::display_template_element($template_part, $tpl_component); |
| 2096 | 2087 | } |
| 2097 | 2088 | unset($tpl_component); |
@@ -2110,8 +2101,7 @@ discard block |
||
| 2110 | 2101 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
| 2111 | 2102 | $content_list .= ob_get_contents(); |
| 2112 | 2103 | ob_end_clean(); |
| 2113 | - } |
|
| 2114 | - else { |
|
| 2104 | + } else { |
|
| 2115 | 2105 | $content_list .= wpshop_display::display_template_element($template_part, $tpl_component); |
| 2116 | 2106 | } |
| 2117 | 2107 | unset($tpl_component); |
@@ -2133,8 +2123,7 @@ discard block |
||
| 2133 | 2123 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
| 2134 | 2124 | $attributeContentOutput = ob_get_contents(); |
| 2135 | 2125 | ob_end_clean(); |
| 2136 | - } |
|
| 2137 | - else { |
|
| 2126 | + } else { |
|
| 2138 | 2127 | $attributeContentOutput = wpshop_display::display_template_element($template_part, $tpl_component); |
| 2139 | 2128 | } |
| 2140 | 2129 | unset($tpl_component); |
@@ -2186,8 +2175,9 @@ discard block |
||
| 2186 | 2175 | foreach ($attributeDefinition['value'] as $v) { |
| 2187 | 2176 | $attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
| 2188 | 2177 | } |
| 2178 | + } else { |
|
| 2179 | + $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2189 | 2180 | } |
| 2190 | - else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2191 | 2181 | $attribute_value = substr($attribute_value,3); |
| 2192 | 2182 | } |
| 2193 | 2183 | |
@@ -2269,8 +2259,7 @@ discard block |
||
| 2269 | 2259 | wps_shortcodes_ctr::output_shortcode('attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])).' wpshop_cls'); |
| 2270 | 2260 | $shortcodes .= '<li class="wpshop_cls" >'.sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>'.__($attribute_output_def['field_definition']['label'], 'wpshop').'</span>').ob_get_contents().'</li>'; |
| 2271 | 2261 | ob_end_clean(); |
| 2272 | - } |
|
| 2273 | - else { |
|
| 2262 | + } else { |
|
| 2274 | 2263 | if ( $attribute->code == 'product_attribute_set_id' ) { |
| 2275 | 2264 | $attribute_output_def['field_definition']['type'] = 'hidden'; |
| 2276 | 2265 | } |
@@ -2290,10 +2279,11 @@ discard block |
||
| 2290 | 2279 | $attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>'.$productAttributeSetDetail['name'].'</span>').ob_get_contents().'<ul class="" >'.$shortcodes.'</ul>'; |
| 2291 | 2280 | ob_end_clean(); |
| 2292 | 2281 | |
| 2293 | - if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' ) |
|
| 2294 | - $currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>'; |
|
| 2295 | - else |
|
| 2296 | - $shortcodes_attr .= $attribute_group_display; |
|
| 2282 | + if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' ) { |
|
| 2283 | + $currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>'; |
|
| 2284 | + } else { |
|
| 2285 | + $shortcodes_attr .= $attribute_group_display; |
|
| 2286 | + } |
|
| 2297 | 2287 | |
| 2298 | 2288 | if ( $output_nb <= 0 ) { |
| 2299 | 2289 | $currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop'); |
@@ -2308,8 +2298,7 @@ discard block |
||
| 2308 | 2298 | $box['boxContent'][$productAttributeSetDetail['code']] = ' |
| 2309 | 2299 | <div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . ' |
| 2310 | 2300 | </div><div class="wpshop_cls" ></div>'; |
| 2311 | - } |
|
| 2312 | - else if ( $outputType == 'column' ) { |
|
| 2301 | + } else if ( $outputType == 'column' ) { |
|
| 2313 | 2302 | $currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent); |
| 2314 | 2303 | $currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent); |
| 2315 | 2304 | |
@@ -2347,8 +2336,7 @@ discard block |
||
| 2347 | 2336 | $box['box']['shortcode'] = __('Product Shortcodes', 'wpshop'); |
| 2348 | 2337 | $box['boxContent']['shortcode'] = $shortcodes_attr; |
| 2349 | 2338 | $box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE; |
| 2350 | - } |
|
| 2351 | - else{ |
|
| 2339 | + } else{ |
|
| 2352 | 2340 | $box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop'); |
| 2353 | 2341 | $box['columnContent']['shortcode'] = $shortcodes_attr; |
| 2354 | 2342 | } |
@@ -2388,8 +2376,7 @@ discard block |
||
| 2388 | 2376 | // $ouput['more_input'] .= '<input type="hidden" value="' . (WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT ? str_replace("\\", "", $option->value) : str_replace("\\", "", $option->label)) . '" name="wpshop_product_attribute_' . $attribute->code . '_value_' . $option->id . '" id="wpshop_product_attribute_' . $attribute->code . '_value_' . $option->id . '" />'; |
| 2389 | 2377 | // } |
| 2390 | 2378 | endforeach; |
| 2391 | - } |
|
| 2392 | - elseif ( $attribute->data_type_to_use == 'internal') { |
|
| 2379 | + } elseif ( $attribute->data_type_to_use == 'internal') { |
|
| 2393 | 2380 | switch ($attribute_default_value) { |
| 2394 | 2381 | case 'users': |
| 2395 | 2382 | $users = get_users('orderby=nicename'); |
@@ -2418,9 +2405,11 @@ discard block |
||
| 2418 | 2405 | /* There is no value existing for this value */ |
| 2419 | 2406 | if (empty($attribute_select_options_list)) : |
| 2420 | 2407 | $ouput['more_input'].=__('Nothing found for this field', 'wpshop'); |
| 2421 | - else: |
|
| 2408 | + else { |
|
| 2409 | + : |
|
| 2422 | 2410 | /* Add a default value to the combobox list */ |
| 2423 | 2411 | $default_value_is_serial = false; |
| 2412 | + } |
|
| 2424 | 2413 | $attribute_list_first_element = $attribute->default_value; |
| 2425 | 2414 | if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || @unserialize($attribute->default_value) !== false) ) { |
| 2426 | 2415 | $default_value_is_serial = true; |
@@ -2436,8 +2425,7 @@ discard block |
||
| 2436 | 2425 | /* Add a extra element to create a new element into list */ |
| 2437 | 2426 | if ( is_admin() && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) { |
| 2438 | 2427 | /** $ouput['more_input'] .= '<img src="'.WPSHOP_MEDIAS_ICON_URL.'add.png" id="new_value_pict_' . $attribute->code . '" alt="'.__('Add a new value for this attribute', 'wpshop').'" title="'.__('Add a new value for this attribute', 'wpshop').'" class="wpshop_icons wpshop_icons_add_new_value_to_option_list wpshop_icons_add_new_value_to_option_list_'.$attribute->code.'" />'; */ |
| 2439 | - } |
|
| 2440 | - else if ( 'yes' == $attribute->is_used_in_quick_add_form ) { |
|
| 2428 | + } else if ( 'yes' == $attribute->is_used_in_quick_add_form ) { |
|
| 2441 | 2429 | $tpl_component = array(); |
| 2442 | 2430 | $tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']'; |
| 2443 | 2431 | $ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component); |
@@ -2459,8 +2447,7 @@ discard block |
||
| 2459 | 2447 | WHERE ATT.code = %s |
| 2460 | 2448 | AND ATT_SELECT_OPTIONS_VALUE.status = 'valid' |
| 2461 | 2449 | GROUP BY ATT.id, chosen_val", $element_id, $attribute_code); |
| 2462 | - } |
|
| 2463 | - else { |
|
| 2450 | + } else { |
|
| 2464 | 2451 | $query = $wpdb->prepare(" |
| 2465 | 2452 | SELECT P.ID AS chosen_val, P.post_title |
| 2466 | 2453 | FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT |
@@ -2634,14 +2621,17 @@ discard block |
||
| 2634 | 2621 | $attribute_final = array(); |
| 2635 | 2622 | $entity_type = get_post_type($entityId); |
| 2636 | 2623 | $data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
| 2637 | - foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2624 | + foreach($data as $d) { |
|
| 2625 | + $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2626 | + } |
|
| 2638 | 2627 | |
| 2639 | 2628 | // Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity |
| 2640 | 2629 | foreach ( $values as $key => $value ) { |
| 2641 | 2630 | if ( in_array( $key, array_keys( $attribute_available ) ) ) { |
| 2642 | 2631 | $attribute_final[$attribute_available[$key]['data_type']][$key] = $value; |
| 2632 | + } else { |
|
| 2633 | + $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n"; |
|
| 2643 | 2634 | } |
| 2644 | - else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n"; |
|
| 2645 | 2635 | } |
| 2646 | 2636 | |
| 2647 | 2637 | // Pour les autres attributs non donné on leur affecte leur valeur par défaut |
@@ -2711,8 +2701,7 @@ discard block |
||
| 2711 | 2701 | /** Build template */ |
| 2712 | 2702 | $info = wpshop_display::display_template_element($template_part, $tpl_component); |
| 2713 | 2703 | unset($tpl_component); |
| 2714 | - } |
|
| 2715 | - else { |
|
| 2704 | + } else { |
|
| 2716 | 2705 | $info = $entity_infos->post_title; |
| 2717 | 2706 | } |
| 2718 | 2707 | } |
@@ -2900,8 +2889,7 @@ discard block |
||
| 2900 | 2889 | |
| 2901 | 2890 | }); |
| 2902 | 2891 | </script>'; |
| 2903 | - } |
|
| 2904 | - elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){ |
|
| 2892 | + } elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){ |
|
| 2905 | 2893 | $sub_output=''; |
| 2906 | 2894 | $wp_types = unserialize(WPSHOP_INTERNAL_TYPES); |
| 2907 | 2895 | unset($input_def);$input_def=array(); |
@@ -3002,8 +2990,7 @@ discard block |
||
| 3002 | 2990 | <option value="' . $value->value . '" >' . $value->label . '</option>'; |
| 3003 | 2991 | } |
| 3004 | 2992 | } |
| 3005 | - } |
|
| 3006 | - else { |
|
| 2993 | + } else { |
|
| 3007 | 2994 | foreach ($attribute_values as $attribute_value) { |
| 3008 | 2995 | if ( !empty($attribute_value->value) ) { |
| 3009 | 2996 | $attribute_possible_values .= ' |
@@ -3086,8 +3073,7 @@ discard block |
||
| 3086 | 3073 | $final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label; |
| 3087 | 3074 | $final_list['unavailable'][$attribute->code]['values'] = array(); |
| 3088 | 3075 | $final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute; |
| 3089 | - } |
|
| 3090 | - else { |
|
| 3076 | + } else { |
|
| 3091 | 3077 | $final_list['available'][$attribute->code]['label'] = $attribute->frontend_label; |
| 3092 | 3078 | $final_list['available'][$attribute->code]['values'] = $attribute_values_for_variations; |
| 3093 | 3079 | $final_list['available'][$attribute->code]['attribute_complete_def'] = $attribute; |
@@ -3115,8 +3101,7 @@ discard block |
||
| 3115 | 3101 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ''; |
| 3116 | 3102 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ''; |
| 3117 | 3103 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; |
| 3118 | - } |
|
| 3119 | - else { |
|
| 3104 | + } else { |
|
| 3120 | 3105 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ' class="wpshop_unavailable_label_variation_definition" '; |
| 3121 | 3106 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ' disabled="disabled"'; |
| 3122 | 3107 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; |
@@ -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 | /** |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @package wpshop |
| 21 | 21 | * @subpackage librairies |
| 22 | 22 | */ |
| 23 | -class wpshop_attributes{ |
|
| 23 | +class wpshop_attributes { |
|
| 24 | 24 | /* Define the database table used in the current class */ |
| 25 | 25 | const dbTable = WPSHOP_DBT_ATTRIBUTE; |
| 26 | 26 | /* Define the url listing slug used in the current class */ |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return string The table of the class |
| 50 | 50 | */ |
| 51 | - function setMessage($message){ |
|
| 51 | + function setMessage($message) { |
|
| 52 | 52 | $this->pageMessage = $message; |
| 53 | 53 | } |
| 54 | 54 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @return string The table of the class |
| 58 | 58 | */ |
| 59 | - function getListingSlug(){ |
|
| 59 | + function getListingSlug() { |
|
| 60 | 60 | return self::urlSlugListing; |
| 61 | 61 | } |
| 62 | 62 | /** |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return string The table of the class |
| 66 | 66 | */ |
| 67 | - function getEditionSlug(){ |
|
| 67 | + function getEditionSlug() { |
|
| 68 | 68 | return self::urlSlugEdition; |
| 69 | 69 | } |
| 70 | 70 | /** |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return string The table of the class |
| 74 | 74 | */ |
| 75 | - public static function getDbTable(){ |
|
| 75 | + public static function getDbTable() { |
|
| 76 | 76 | return self::dbTable; |
| 77 | 77 | } |
| 78 | 78 | /** |
@@ -80,21 +80,21 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return string $title The title of the page looking at the environnement |
| 82 | 82 | */ |
| 83 | - function pageTitle(){ |
|
| 83 | + function pageTitle() { |
|
| 84 | 84 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 85 | 85 | $objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : ''; |
| 86 | - $page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
| 86 | + $page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
| 87 | 87 | |
| 88 | - $title = __(self::pageTitle, 'wpshop' ); |
|
| 89 | - if($action != ''){ |
|
| 90 | - if(($action == 'edit') || ($action == 'delete')){ |
|
| 88 | + $title = __(self::pageTitle, 'wpshop'); |
|
| 89 | + if ($action != '') { |
|
| 90 | + if (($action == 'edit') || ($action == 'delete')) { |
|
| 91 | 91 | $editedItem = self::getElement($objectInEdition); |
| 92 | 92 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label)); |
| 93 | 93 | } |
| 94 | - elseif($action == 'add') |
|
| 94 | + elseif ($action == 'add') |
|
| 95 | 95 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 96 | 96 | } |
| 97 | - elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) |
|
| 97 | + elseif ((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) |
|
| 98 | 98 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 99 | 99 | |
| 100 | 100 | return $title; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * Define the different message and action after an action is send through the element interface |
| 105 | 105 | */ |
| 106 | - function elementAction(){ |
|
| 106 | + function elementAction() { |
|
| 107 | 107 | global $wpdb, $initialEavData; |
| 108 | 108 | |
| 109 | 109 | $pageMessage = $actionResult = ''; |
@@ -116,75 +116,75 @@ discard block |
||
| 116 | 116 | $saveditem = isset($_REQUEST['saveditem']) ? sanitize_text_field($_REQUEST['saveditem']) : ''; |
| 117 | 117 | $set_section = !empty($_REQUEST[self::getDbTable()]['set_section']) ? sanitize_text_field($_REQUEST[self::getDbTable()]['set_section']) : ''; |
| 118 | 118 | //@TODO $_REQUEST |
| 119 | - $id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : null; |
|
| 120 | - if(!empty($action) && ($action=='activate') ){ |
|
| 121 | - if( isset($id) ) { |
|
| 119 | + $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : null; |
|
| 120 | + if (!empty($action) && ($action == 'activate')) { |
|
| 121 | + if (isset($id)) { |
|
| 122 | 122 | $query = $wpdb->update(self::getDbTable(), array('status'=>'moderated'), array('id'=>$id)); |
| 123 | 123 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | - if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){ |
|
| 126 | + if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) { |
|
| 127 | 127 | $editedElement = self::getElement($saveditem); |
| 128 | 128 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 129 | 129 | } |
| 130 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 130 | + elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) { |
|
| 131 | 131 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 132 | 132 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $attribute_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 136 | - if ( !empty($set_section) ) unset($attribute_parameter['set_section']); |
|
| 135 | + $attribute_parameter = !empty($_REQUEST[self::getDbTable()]) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 136 | + if (!empty($set_section)) unset($attribute_parameter['set_section']); |
|
| 137 | 137 | |
| 138 | 138 | $wpshop_attribute_combo_values_list_order_def = !empty($attribute_parameter['wpshop_attribute_combo_values_list_order_def']) ? $attribute_parameter['wpshop_attribute_combo_values_list_order_def'] : array(); |
| 139 | 139 | // @TODO $_REQUEST |
| 140 | 140 | // unset($_REQUEST[self::getDbTable()]['wpshop_attribute_combo_values_list_order_def']); |
| 141 | 141 | |
| 142 | - if(!isset($attribute_parameter['status'])){ |
|
| 142 | + if (!isset($attribute_parameter['status'])) { |
|
| 143 | 143 | $attribute_parameter['status'] = 'moderated'; |
| 144 | 144 | } |
| 145 | - if(!isset($attribute_parameter['is_historisable'])){ |
|
| 145 | + if (!isset($attribute_parameter['is_historisable'])) { |
|
| 146 | 146 | $attribute_parameter['is_historisable'] = 'no'; |
| 147 | 147 | } |
| 148 | - if(!isset($attribute_parameter['is_required'])){ |
|
| 148 | + if (!isset($attribute_parameter['is_required'])) { |
|
| 149 | 149 | $attribute_parameter['is_required'] = 'no'; |
| 150 | 150 | } |
| 151 | - if(!isset($attribute_parameter['is_used_in_admin_listing_column'])){ |
|
| 151 | + if (!isset($attribute_parameter['is_used_in_admin_listing_column'])) { |
|
| 152 | 152 | $attribute_parameter['is_used_in_admin_listing_column'] = 'no'; |
| 153 | 153 | } |
| 154 | - if(!isset($attribute_parameter['is_used_in_quick_add_form'])){ |
|
| 154 | + if (!isset($attribute_parameter['is_used_in_quick_add_form'])) { |
|
| 155 | 155 | $attribute_parameter['is_used_in_quick_add_form'] = 'no'; |
| 156 | 156 | } |
| 157 | - if(!isset($attribute_parameter['is_intrinsic'])){ |
|
| 157 | + if (!isset($attribute_parameter['is_intrinsic'])) { |
|
| 158 | 158 | $attribute_parameter['is_intrinsic'] = 'no'; |
| 159 | 159 | } |
| 160 | - if(!isset($attribute_parameter['is_requiring_unit'])){ |
|
| 160 | + if (!isset($attribute_parameter['is_requiring_unit'])) { |
|
| 161 | 161 | $attribute_parameter['is_requiring_unit'] = 'no'; |
| 162 | 162 | } |
| 163 | - if(!isset($attribute_parameter['is_visible_in_front'])){ |
|
| 163 | + if (!isset($attribute_parameter['is_visible_in_front'])) { |
|
| 164 | 164 | $attribute_parameter['is_visible_in_front'] = 'no'; |
| 165 | 165 | } |
| 166 | - if(!isset($attribute_parameter['is_visible_in_front_listing'])){ |
|
| 166 | + if (!isset($attribute_parameter['is_visible_in_front_listing'])) { |
|
| 167 | 167 | $attribute_parameter['is_visible_in_front_listing'] = 'no'; |
| 168 | 168 | } |
| 169 | - if(!isset($attribute_parameter['is_used_for_sort_by'])){ |
|
| 169 | + if (!isset($attribute_parameter['is_used_for_sort_by'])) { |
|
| 170 | 170 | $attribute_parameter['is_used_for_sort_by'] = 'no'; |
| 171 | 171 | } |
| 172 | - if(!isset($attribute_parameter['is_visible_in_advanced_search'])){ |
|
| 172 | + if (!isset($attribute_parameter['is_visible_in_advanced_search'])) { |
|
| 173 | 173 | $attribute_parameter['is_visible_in_advanced_search'] = 'no'; |
| 174 | 174 | } |
| 175 | - if(!isset($attribute_parameter['is_searchable'])){ |
|
| 175 | + if (!isset($attribute_parameter['is_searchable'])) { |
|
| 176 | 176 | $attribute_parameter['is_searchable'] = 'no'; |
| 177 | 177 | } |
| 178 | - if(!isset($attribute_parameter['is_used_for_variation'])){ |
|
| 178 | + if (!isset($attribute_parameter['is_used_for_variation'])) { |
|
| 179 | 179 | $attribute_parameter['is_used_for_variation'] = 'no'; |
| 180 | 180 | } |
| 181 | - if(!isset($attribute_parameter['is_used_in_variation'])){ |
|
| 181 | + if (!isset($attribute_parameter['is_used_in_variation'])) { |
|
| 182 | 182 | $attribute_parameter['is_used_in_variation'] = 'no'; |
| 183 | 183 | } |
| 184 | - if(!isset($attribute_parameter['is_user_defined'])){ |
|
| 184 | + if (!isset($attribute_parameter['is_user_defined'])) { |
|
| 185 | 185 | $attribute_parameter['is_user_defined'] = 'no'; |
| 186 | 186 | } |
| 187 | - if(!isset($attribute_parameter['_display_informations_about_value'])){ |
|
| 187 | + if (!isset($attribute_parameter['_display_informations_about_value'])) { |
|
| 188 | 188 | $attribute_parameter['_display_informations_about_value'] = 'no'; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -193,58 +193,58 @@ discard block |
||
| 193 | 193 | switch ($attribute_parameter['frontend_input']) { |
| 194 | 194 | case 'short_text': |
| 195 | 195 | $attribute_parameter['frontend_input'] = 'text'; |
| 196 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 196 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 197 | 197 | $attribute_parameter['data_type'] = 'varchar'; |
| 198 | 198 | break; |
| 199 | 199 | case 'date_field': |
| 200 | 200 | $attribute_parameter['frontend_input'] = 'text'; |
| 201 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 201 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 202 | 202 | $attribute_parameter['data_type'] = 'datetime'; |
| 203 | 203 | break; |
| 204 | 204 | case 'float_field': |
| 205 | 205 | $attribute_parameter['frontend_input'] = 'text'; |
| 206 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 206 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 207 | 207 | $attribute_parameter['data_type'] = 'decimal'; |
| 208 | 208 | break; |
| 209 | 209 | case 'hidden_field': |
| 210 | 210 | $attribute_parameter['frontend_input'] = 'hidden'; |
| 211 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 211 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 212 | 212 | $attribute_parameter['data_type'] = 'varchar'; |
| 213 | 213 | break; |
| 214 | 214 | case 'pass_field': |
| 215 | 215 | $attribute_parameter['frontend_input'] = 'password'; |
| 216 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 216 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 217 | 217 | $attribute_parameter['data_type'] = 'varchar'; |
| 218 | 218 | break; |
| 219 | 219 | |
| 220 | 220 | case 'select': |
| 221 | 221 | $attribute_parameter['frontend_input'] = 'select'; |
| 222 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 222 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 223 | 223 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 224 | 224 | $attribute_parameter['data_type'] = 'integer'; |
| 225 | 225 | break; |
| 226 | 226 | case 'multiple-select': |
| 227 | 227 | $attribute_parameter['frontend_input'] = 'multiple-select'; |
| 228 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 228 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 229 | 229 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 230 | 230 | $attribute_parameter['data_type'] = 'integer'; |
| 231 | 231 | break; |
| 232 | 232 | case 'radio': |
| 233 | 233 | $attribute_parameter['frontend_input'] = 'radio'; |
| 234 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 234 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 235 | 235 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 236 | 236 | $attribute_parameter['data_type'] = 'integer'; |
| 237 | 237 | break; |
| 238 | 238 | case 'checkbox': |
| 239 | 239 | $attribute_parameter['frontend_input'] = 'checkbox'; |
| 240 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 240 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 241 | 241 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 242 | 242 | $attribute_parameter['data_type'] = 'integer'; |
| 243 | 243 | break; |
| 244 | 244 | |
| 245 | 245 | case 'textarea': |
| 246 | 246 | $attribute_parameter['frontend_input'] = 'textarea'; |
| 247 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 247 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 248 | 248 | $attribute_parameter['backend_input'] = 'textarea'; |
| 249 | 249 | $attribute_parameter['data_type'] = 'text'; |
| 250 | 250 | break; |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | else { |
| 254 | 254 | $attribute_parameter['frontend_input'] = 'text'; |
| 255 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 255 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 256 | 256 | $attribute_parameter['data_type'] = 'varchar'; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -261,55 +261,55 @@ discard block |
||
| 261 | 261 | // $attribute_parameter['use_ajax_for_filling_field']='no'; |
| 262 | 262 | // } |
| 263 | 263 | $attribute_parameter['use_ajax_for_filling_field'] = 'yes'; |
| 264 | - if( $attribute_parameter['backend_input'] == 'multiple-select' ) { |
|
| 264 | + if ($attribute_parameter['backend_input'] == 'multiple-select') { |
|
| 265 | 265 | $attribute_parameter['is_used_for_variation'] = 'yes'; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /* Define the database operation type from action launched by the user */ |
| 269 | 269 | $attribute_parameter['default_value'] = (!empty($attribute_parameter['default_value']) && is_array($attribute_parameter['default_value'])) ? serialize($attribute_parameter['default_value']) : (isset($attribute_parameter['default_value']) ? str_replace('"', "'", $attribute_parameter['default_value']) : ''); |
| 270 | - if ( $attribute_parameter['data_type'] == 'datetime' ) { |
|
| 270 | + if ($attribute_parameter['data_type'] == 'datetime') { |
|
| 271 | 271 | $date_default_value_trasform_into_config = array('default_value' => $attribute_parameter['default_value'], 'field_options' => (!empty($_POST[self::getDbTable() . '_options']) ? sanitize_text_field($_POST[self::getDbTable() . '_options']) : null)); |
| 272 | - $attribute_parameter['default_value'] = serialize( $date_default_value_trasform_into_config ); |
|
| 272 | + $attribute_parameter['default_value'] = serialize($date_default_value_trasform_into_config); |
|
| 273 | 273 | } |
| 274 | 274 | /***************************** GENERIC **************************/ |
| 275 | 275 | /*************************************************************************/ |
| 276 | - $pageAction = (!empty($attribute_parameter['frontend_label']) && isset($_REQUEST[self::getDbTable() . '_action'])) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action']=='delete')) ? sanitize_text_field($_GET['action']) : ''); |
|
| 276 | + $pageAction = (!empty($attribute_parameter['frontend_label']) && isset($_REQUEST[self::getDbTable() . '_action'])) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action'] == 'delete')) ? sanitize_text_field($_GET['action']) : ''); |
|
| 277 | 277 | $id = isset($attribute_parameter['id']) ? sanitize_key($attribute_parameter['id']) : ((!empty($_GET['id'])) ? $_GET['id'] : ''); |
| 278 | - if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))){ |
|
| 279 | - if(current_user_can('wpshop_edit_attributes')){ |
|
| 278 | + if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))) { |
|
| 279 | + if (current_user_can('wpshop_edit_attributes')) { |
|
| 280 | 280 | $attribute_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 281 | - if($pageAction == 'delete'){ |
|
| 281 | + if ($pageAction == 'delete') { |
|
| 282 | 282 | $attribute_code = $attribute_parameter['code']; |
| 283 | - if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){ |
|
| 283 | + if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) { |
|
| 284 | 284 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id'); |
| 285 | 285 | $attribute_code = $attribute->code; |
| 286 | 286 | } |
| 287 | - if(!in_array($attribute_code, $attribute_undeletable)){ |
|
| 288 | - if(current_user_can('wpshop_delete_attributes')){ |
|
| 287 | + if (!in_array($attribute_code, $attribute_undeletable)) { |
|
| 288 | + if (current_user_can('wpshop_delete_attributes')) { |
|
| 289 | 289 | $attribute_parameter['status'] = 'deleted'; |
| 290 | 290 | } |
| 291 | - else{ |
|
| 291 | + else { |
|
| 292 | 292 | $actionResult = 'userNotAllowedForActionDelete'; |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | - else{ |
|
| 295 | + else { |
|
| 296 | 296 | $actionResult = 'unDeletableAtribute'; |
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | $actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable()); |
| 300 | 300 | } |
| 301 | - else{ |
|
| 301 | + else { |
|
| 302 | 302 | $actionResult = 'userNotAllowedForActionEdit'; |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 305 | + elseif (($pageAction != '') && (($pageAction == 'delete'))) { |
|
| 306 | 306 | $attribute_code = ''; |
| 307 | - if (empty( $attribute_parameter['code'])) { |
|
| 307 | + if (empty($attribute_parameter['code'])) { |
|
| 308 | 308 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused', 'deleted'", 'id'); |
| 309 | 309 | $attribute_code = $attribute->code; |
| 310 | 310 | } |
| 311 | 311 | if (!in_array($attribute_code, $attribute_undeletable)) { |
| 312 | - if(current_user_can('wpshop_delete_attributes')){ |
|
| 312 | + if (current_user_can('wpshop_delete_attributes')) { |
|
| 313 | 313 | $attribute_parameter['last_update_date'] = current_time('mysql', 0); |
| 314 | 314 | $attribute_parameter['status'] = 'deleted'; |
| 315 | 315 | $actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable()); |
@@ -320,21 +320,21 @@ discard block |
||
| 320 | 320 | else |
| 321 | 321 | $actionResult = 'unDeletableAtribute'; |
| 322 | 322 | } |
| 323 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 324 | - if(current_user_can('wpshop_add_attributes')){ |
|
| 323 | + elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) { |
|
| 324 | + if (current_user_can('wpshop_add_attributes')) { |
|
| 325 | 325 | $attribute_parameter['creation_date'] = current_time('mysql', 0); |
| 326 | - if(trim($attribute_parameter['code']) == ''){ |
|
| 326 | + if (trim($attribute_parameter['code']) == '') { |
|
| 327 | 327 | $attribute_parameter['code'] = $attribute_parameter['frontend_label']; |
| 328 | 328 | } |
| 329 | 329 | $attribute_parameter['code'] = wpshop_tools::slugify(str_replace("\'", "_", str_replace('\"', "_", $attribute_parameter['code'])), array('noAccent', 'noSpaces', 'lowerCase', 'noPunctuation')); |
| 330 | 330 | $code_exists = self::getElement($attribute_parameter['code'], "'valid', 'moderated', 'deleted'", 'code'); |
| 331 | - if((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)){ |
|
| 331 | + if ((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)) { |
|
| 332 | 332 | $attribute_parameter['code'] = $attribute_parameter['code'] . '_' . (count($code_exists) + rand()); |
| 333 | 333 | } |
| 334 | 334 | $actionResult = wpshop_database::save($attribute_parameter, self::getDbTable()); |
| 335 | 335 | $id = $wpdb->insert_id; |
| 336 | 336 | } |
| 337 | - else{ |
|
| 337 | + else { |
|
| 338 | 338 | $actionResult = 'userNotAllowedForActionAdd'; |
| 339 | 339 | } |
| 340 | 340 | } |
@@ -343,9 +343,9 @@ discard block |
||
| 343 | 343 | /************ CHANGE THE FIELD NAME TO TAKE TO DISPLAY *************/ |
| 344 | 344 | /************ CHANGE ERROR MESSAGE FOR SPECIFIC CASE *************/ |
| 345 | 345 | /****************************************************************************/ |
| 346 | - if($actionResult != ''){ |
|
| 346 | + if ($actionResult != '') { |
|
| 347 | 347 | $elementIdentifierForMessage = __('the attribute', 'wpshop'); |
| 348 | - if(!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>'; |
|
| 348 | + if (!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>'; |
|
| 349 | 349 | if ($actionResult == 'error') {/* CHANGE HERE FOR SPECIFIC CASE */ |
| 350 | 350 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage, ' -> ' . $wpdb->last_error); |
| 351 | 351 | } |
@@ -357,11 +357,11 @@ discard block |
||
| 357 | 357 | $done_options_value = array(); |
| 358 | 358 | $default_value = $attribute_parameter['default_value']; |
| 359 | 359 | $i = 1; |
| 360 | - $options = !empty($_REQUEST['options']) ? (array) $_REQUEST['options'] : array(); |
|
| 361 | - $optionsValue = !empty($_REQUEST['optionsValue']) ? (array) $_REQUEST['optionsValue'] : array(); |
|
| 362 | - $optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array) $_REQUEST['optionsUpdate'] : array(); |
|
| 363 | - $optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array) $_REQUEST['optionsUpdateValue'] : array(); |
|
| 364 | - if ( !empty($optionsUpdate) ) { |
|
| 360 | + $options = !empty($_REQUEST['options']) ? (array)$_REQUEST['options'] : array(); |
|
| 361 | + $optionsValue = !empty($_REQUEST['optionsValue']) ? (array)$_REQUEST['optionsValue'] : array(); |
|
| 362 | + $optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array)$_REQUEST['optionsUpdate'] : array(); |
|
| 363 | + $optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array)$_REQUEST['optionsUpdateValue'] : array(); |
|
| 364 | + if (!empty($optionsUpdate)) { |
|
| 365 | 365 | /** |
| 366 | 366 | * Check if there is an attribute code into sended request or if we have to get the code from database (Bug fix) |
| 367 | 367 | */ |
@@ -375,25 +375,25 @@ discard block |
||
| 375 | 375 | foreach ($optionsUpdate as $option_key => $option_label) { |
| 376 | 376 | $option_value = !empty($optionsUpdateValue[$option_key]) ? str_replace(",", ".", $optionsUpdateValue[$option_key]) : ''; |
| 377 | 377 | |
| 378 | - if ( empty($option_value) || !in_array($option_value, $done_options_value) ) { |
|
| 378 | + if (empty($option_value) || !in_array($option_value, $done_options_value)) { |
|
| 379 | 379 | /* Update an existing value only if the value does not exist into existing list */ |
| 380 | 380 | $label = (($option_label != '') ? $option_label : str_replace(",", ".", $option_value)); |
| 381 | 381 | $value = str_replace(",", ".", $option_value); |
| 382 | - if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT ) { |
|
| 382 | + if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT) { |
|
| 383 | 383 | $label = $option_label; |
| 384 | - $value = str_replace(",", ".", $label); |
|
| 384 | + $value = str_replace(",", ".", $label); |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('last_update_date' => current_time('mysql', 0), 'position' => $i, 'label' => stripslashes($label), 'value' => stripslashes($value)), array('id' => $option_key)); |
| 388 | 388 | $done_options_value[] = str_replace(",", ".", $option_value); |
| 389 | 389 | |
| 390 | 390 | /* Check if this value is used for price calculation and make update on the different product using this value */ |
| 391 | - if($attribute_code == WPSHOP_PRODUCT_PRICE_TAX){ |
|
| 391 | + if ($attribute_code == WPSHOP_PRODUCT_PRICE_TAX) { |
|
| 392 | 392 | $action = wpshop_prices::mass_update_prices(); |
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - if($default_value == $option_key) { |
|
| 396 | + if ($default_value == $option_key) { |
|
| 397 | 397 | /* Update an existing a only if the value does not exist into existing list */ |
| 398 | 398 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $option_key), array('id' => $id)); |
| 399 | 399 | $done_options_value[] = str_replace(",", ".", $option_value); |
@@ -401,13 +401,13 @@ discard block |
||
| 401 | 401 | $i++; |
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | - if ( !empty($options) ) { |
|
| 405 | - foreach ( $options as $option_key => $option_label ) { |
|
| 404 | + if (!empty($options)) { |
|
| 405 | + foreach ($options as $option_key => $option_label) { |
|
| 406 | 406 | $option_value = !empty($optionsValue[$option_key]) ? str_replace(",", ".", $optionsValue[$option_key]) : sanitize_title($option_label); |
| 407 | 407 | |
| 408 | 408 | /* Check what value to use for the new values */ |
| 409 | 409 | $label = (!empty($option_label) ? $option_label : str_replace(",", ".", $option_value)); |
| 410 | - if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value) ) { |
|
| 410 | + if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value)) { |
|
| 411 | 411 | $label = $option_label; |
| 412 | 412 | $option_value = sanitize_title($label); |
| 413 | 413 | } |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | // If the optionsUpdateValue is empty, set it a empty array to avoid error calling the in_array() function |
| 416 | 416 | // $_REQUEST['optionsUpdateValue'] = !empty($_REQUEST['optionsUpdateValue']) ? $_REQUEST['optionsUpdateValue'] : array(); |
| 417 | 417 | |
| 418 | - if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue) ) { |
|
| 418 | + if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue)) { |
|
| 419 | 419 | |
| 420 | 420 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('creation_date' => current_time('mysql', 0), 'status' => 'valid', 'attribute_id' => $id, 'position' => $i, 'label' => stripslashes($label), 'value' => stripslashes($option_value))); |
| 421 | 421 | $done_options_value[] = str_replace(",", ".", $option_value); |
@@ -433,19 +433,19 @@ discard block |
||
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // If the is_used_for_sort_by is mark as yes, we have to get out some attributes and save it separately |
| 436 | - if( (!empty($attribute_parameter['is_used_for_sort_by']) && ($attribute_parameter['is_used_for_sort_by'] == 'yes')) || (!empty($attribute_parameter['is_filterable']) && ($attribute_parameter['is_filterable'] == 'yes')) || (!empty($attribute_parameter['is_searchable']) && ($attribute_parameter['is_searchable'] == 'yes')) ){ |
|
| 436 | + if ((!empty($attribute_parameter['is_used_for_sort_by']) && ($attribute_parameter['is_used_for_sort_by'] == 'yes')) || (!empty($attribute_parameter['is_filterable']) && ($attribute_parameter['is_filterable'] == 'yes')) || (!empty($attribute_parameter['is_searchable']) && ($attribute_parameter['is_searchable'] == 'yes'))) { |
|
| 437 | 437 | $attribute_code = $attribute_parameter['code']; |
| 438 | - if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){ |
|
| 438 | + if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) { |
|
| 439 | 439 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id'); |
| 440 | 440 | $attribute_code = $attribute->code; |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | $count_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
| 444 | - for( $i = 0; $i <= $count_products->publish; $i+= 20 ) { |
|
| 445 | - $query = $wpdb->prepare( 'SELECT * FROM '. $wpdb->posts .' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT '.$i.', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish' ); |
|
| 446 | - $products = $wpdb->get_results( $query ); |
|
| 447 | - if ( !empty($products) ) { |
|
| 448 | - foreach( $products as $product ) { |
|
| 444 | + for ($i = 0; $i <= $count_products->publish; $i += 20) { |
|
| 445 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT ' . $i . ', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish'); |
|
| 446 | + $products = $wpdb->get_results($query); |
|
| 447 | + if (!empty($products)) { |
|
| 448 | + foreach ($products as $product) { |
|
| 449 | 449 | $query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute_parameter['data_type'] . " WHERE attribute_id = %d AND entity_type_id = %d AND entity_id = %d AND value != '' ORDER BY creation_date_value DESC", $id, $attribute_parameter['entity_id'], $product->ID); |
| 450 | 450 | $value = $wpdb->get_var($query); |
| 451 | 451 | update_post_meta($product->ID, '_' . $attribute_code, $value); |
@@ -455,13 +455,13 @@ discard block |
||
| 455 | 455 | wp_reset_query(); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if ( $pageAction != 'delete' ) {/* Add the new attribute in the additionnal informations attribute group */ |
|
| 459 | - if ( !empty($set_section) ) { |
|
| 458 | + if ($pageAction != 'delete') {/* Add the new attribute in the additionnal informations attribute group */ |
|
| 459 | + if (!empty($set_section)) { |
|
| 460 | 460 | $choosen_set_section = explode('_', $set_section); |
| 461 | 461 | $set_id = $choosen_set_section[0]; |
| 462 | 462 | $group_id = $choosen_set_section[1]; |
| 463 | 463 | } |
| 464 | - else{ |
|
| 464 | + else { |
|
| 465 | 465 | $attribute_current_attribute_set = 0; |
| 466 | 466 | $query = $wpdb->prepare(" |
| 467 | 467 | SELECT id |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | AND ATTRIBUTE_SET_DETAILS.entity_type_id = %d", $id, $attribute_parameter['entity_id']); |
| 472 | 472 | $attribute_current_attribute_set = $wpdb->get_results($query); |
| 473 | 473 | |
| 474 | - if ( empty($attribute_current_attribute_set) ) { |
|
| 474 | + if (empty($attribute_current_attribute_set)) { |
|
| 475 | 475 | $query = $wpdb->prepare(" |
| 476 | 476 | SELECT |
| 477 | 477 | ( |
@@ -492,12 +492,12 @@ discard block |
||
| 492 | 492 | $wpshop_default_group = $wpdb->get_row($query); |
| 493 | 493 | |
| 494 | 494 | $set_id = $wpshop_default_group->attribute_set_id; |
| 495 | - $default_group_id = ( !empty( $wpshop_default_group->default_attribute_group_id) ) ? $wpshop_default_group->default_attribute_group_id : ''; |
|
| 495 | + $default_group_id = (!empty($wpshop_default_group->default_attribute_group_id)) ? $wpshop_default_group->default_attribute_group_id : ''; |
|
| 496 | 496 | $group_id = !empty($default_group_id) ? $default_group_id : $wpshop_default_group->attribute_group_id; |
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - if ( !empty($set_id) && !empty($group_id) ) { |
|
| 500 | + if (!empty($set_id) && !empty($group_id)) { |
|
| 501 | 501 | $query = $wpdb->prepare( |
| 502 | 502 | "SELECT (MAX(position) + 1) AS position |
| 503 | 503 | FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " |
@@ -509,12 +509,12 @@ discard block |
||
| 509 | 509 | $attribute_parameter['entity_id'] |
| 510 | 510 | ); |
| 511 | 511 | $wpshopAttributePosition = $wpdb->get_var($query); |
| 512 | - if($wpshopAttributePosition == 0)$wpshopAttributePosition = 1; |
|
| 512 | + if ($wpshopAttributePosition == 0)$wpshopAttributePosition = 1; |
|
| 513 | 513 | $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_parameter['entity_id'], 'attribute_set_id' => $set_id, 'attribute_group_id' => $group_id, 'attribute_id' => $id, 'position' => $wpshopAttributePosition)); |
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if ( !empty($wpshop_attribute_combo_values_list_order_def) ) { |
|
| 517 | + if (!empty($wpshop_attribute_combo_values_list_order_def)) { |
|
| 518 | 518 | $post_order = explode(',', $wpshop_attribute_combo_values_list_order_def); |
| 519 | 519 | $position = 1; |
| 520 | 520 | foreach ($post_order as $post_id) { |
@@ -530,19 +530,19 @@ discard block |
||
| 530 | 530 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 531 | 531 | } |
| 532 | 532 | else */ |
| 533 | - if ( $pageAction == 'add' ) |
|
| 533 | + if ($pageAction == 'add') |
|
| 534 | 534 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 535 | - elseif ( $pageAction == 'delete' ) |
|
| 535 | + elseif ($pageAction == 'delete') |
|
| 536 | 536 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
| 537 | 537 | } |
| 538 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){ |
|
| 538 | + elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) { |
|
| 539 | 539 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 540 | 540 | } |
| 541 | - elseif(($actionResult == 'unDeletableAtribute')){ |
|
| 541 | + elseif (($actionResult == 'unDeletableAtribute')) { |
|
| 542 | 542 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('This attribute could not be deleted due to configuration', 'wpshop'); |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - if(empty($attribute_parameter['frontend_label']) && ($pageAction!='delete')){ |
|
| 545 | + if (empty($attribute_parameter['frontend_label']) && ($pageAction != 'delete')) { |
|
| 546 | 546 | $pageMessage .= __('Please enter an label for the attribut', 'wpshop'); |
| 547 | 547 | } |
| 548 | 548 | } |
@@ -560,37 +560,37 @@ discard block |
||
| 560 | 560 | //Create an instance of our package class... |
| 561 | 561 | $wpshop_list_table = new wpshop_attributes_custom_List_table(); |
| 562 | 562 | //Fetch, prepare, sort, and filter our data... |
| 563 | - $status="'valid'"; |
|
| 564 | - $attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : null; |
|
| 565 | - $s = !empty($_REQUEST['s']) ? sanitize_text_field( $_REQUEST['s'] ) : null; |
|
| 563 | + $status = "'valid'"; |
|
| 564 | + $attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : null; |
|
| 565 | + $s = !empty($_REQUEST['s']) ? sanitize_text_field($_REQUEST['s']) : null; |
|
| 566 | 566 | $order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : null; |
| 567 | 567 | $orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : null; |
| 568 | - if(!empty($attribute_status)){ |
|
| 569 | - switch($attribute_status){ |
|
| 568 | + if (!empty($attribute_status)) { |
|
| 569 | + switch ($attribute_status) { |
|
| 570 | 570 | case 'unactive': |
| 571 | - $status="'moderated', 'notused'"; |
|
| 572 | - if(empty($order_by) && empty($order)){ |
|
| 571 | + $status = "'moderated', 'notused'"; |
|
| 572 | + if (empty($order_by) && empty($order)) { |
|
| 573 | 573 | // @TODO : REQUEST |
| 574 | 574 | // $_REQUEST['orderby']='status'; |
| 575 | 575 | // $_REQUEST['order']='asc'; |
| 576 | 576 | } |
| 577 | 577 | break; |
| 578 | 578 | default: |
| 579 | - $status="'".sanitize_text_field($_REQUEST['attribute_status'])."'"; |
|
| 579 | + $status = "'" . sanitize_text_field($_REQUEST['attribute_status']) . "'"; |
|
| 580 | 580 | break; |
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | - if ( !empty($s) ) { |
|
| 584 | - $query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop') ); |
|
| 585 | - $attr_set_list = $wpdb->get_results( $query ); |
|
| 583 | + if (!empty($s)) { |
|
| 584 | + $query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop')); |
|
| 585 | + $attr_set_list = $wpdb->get_results($query); |
|
| 586 | 586 | } |
| 587 | 587 | else { |
| 588 | - $attr_set_list = self::getElement( '', $status ); |
|
| 588 | + $attr_set_list = self::getElement('', $status); |
|
| 589 | 589 | } |
| 590 | - $i=0; |
|
| 591 | - $attribute_set_list=array(); |
|
| 592 | - foreach($attr_set_list as $attr_set){ |
|
| 593 | - if(!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id') ){ |
|
| 590 | + $i = 0; |
|
| 591 | + $attribute_set_list = array(); |
|
| 592 | + foreach ($attr_set_list as $attr_set) { |
|
| 593 | + if (!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id')) { |
|
| 594 | 594 | $attribute_set_list[$i]['id'] = $attr_set->id; |
| 595 | 595 | $attribute_set_list[$i]['name'] = $attr_set->frontend_label; |
| 596 | 596 | $attribute_set_list[$i]['status'] = $attr_set->status; |
@@ -638,31 +638,31 @@ discard block |
||
| 638 | 638 | global $attribute_displayed_field, $attribute_options_group; |
| 639 | 639 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 640 | 640 | $editedItem = ''; |
| 641 | - if($itemToEdit != '') |
|
| 641 | + if ($itemToEdit != '') |
|
| 642 | 642 | $editedItem = self::getElement($itemToEdit); |
| 643 | 643 | |
| 644 | 644 | $the_form_content_hidden = $the_form_general_content = ''; |
| 645 | 645 | $the_form_option_content_list = array(); |
| 646 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 646 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 647 | 647 | |
| 648 | - if(!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)){ |
|
| 648 | + if (!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)) { |
|
| 649 | 649 | $input_def['label'] = $input_def['name']; |
| 650 | - $input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_def['label']; |
|
| 650 | + $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_def['label']; |
|
| 651 | 651 | |
| 652 | 652 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 653 | 653 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : ''; |
| 654 | 654 | $currentFieldValue = $input_def['value']; |
| 655 | - if(is_object($editedItem)) |
|
| 655 | + if (is_object($editedItem)) |
|
| 656 | 656 | $currentFieldValue = $editedItem->{$input_def['label']}; |
| 657 | - elseif(($pageAction != '') && ($requestFormValue != '')) |
|
| 657 | + elseif (($pageAction != '') && ($requestFormValue != '')) |
|
| 658 | 658 | $currentFieldValue = $requestFormValue; |
| 659 | 659 | |
| 660 | - if($input_def['label'] == 'status'){ |
|
| 661 | - if(in_array('notused', $input_def['possible_value'])){ |
|
| 660 | + if ($input_def['label'] == 'status') { |
|
| 661 | + if (in_array('notused', $input_def['possible_value'])) { |
|
| 662 | 662 | $key = array_keys($input_def['possible_value'], 'notused'); |
| 663 | 663 | unset($input_def['possible_value'][$key[0]]); |
| 664 | 664 | } |
| 665 | - if(in_array('dbl', $input_def['possible_value'])){ |
|
| 665 | + if (in_array('dbl', $input_def['possible_value'])) { |
|
| 666 | 666 | $key = array_keys($input_def['possible_value'], 'dbl'); |
| 667 | 667 | unset($input_def['possible_value'][$key[0]]); |
| 668 | 668 | } |
@@ -670,94 +670,94 @@ discard block |
||
| 670 | 670 | $input_def['type'] = 'checkbox'; |
| 671 | 671 | $input_def['label'] = __('Use this attribute', 'wpshop'); |
| 672 | 672 | $input_def['possible_value'] = array('valid'); |
| 673 | - $input_def_id.='_valid'; |
|
| 674 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 673 | + $input_def_id .= '_valid'; |
|
| 674 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - if ( (substr($input_def['label'], 0, 3) == 'is_') || ( $input_def['label'] == '_display_informations_about_value') ) { |
|
| 677 | + if ((substr($input_def['label'], 0, 3) == 'is_') || ($input_def['label'] == '_display_informations_about_value')) { |
|
| 678 | 678 | $input_def['type'] = 'checkbox'; |
| 679 | 679 | $input_def['possible_value'] = 'yes'; |
| 680 | 680 | } |
| 681 | - switch($input_def['label']){ |
|
| 681 | + switch ($input_def['label']) { |
|
| 682 | 682 | case 'is_requiring_unit': |
| 683 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using unit with this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 683 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using unit with this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 684 | 684 | break; |
| 685 | 685 | case 'is_visible_in_front': |
| 686 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 686 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 687 | 687 | break; |
| 688 | 688 | case 'is_visible_in_front_listing': |
| 689 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in product listing in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 689 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in product listing in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 690 | 690 | break; |
| 691 | 691 | case 'is_used_for_sort_by': |
| 692 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute into sortbar', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 692 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute into sortbar', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 693 | 693 | break; |
| 694 | 694 | case 'is_searchable': |
| 695 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for including values of this attribute as search parameter', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 695 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for including values of this attribute as search parameter', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 696 | 696 | break; |
| 697 | 697 | case 'is_visible_in_advanced_search': |
| 698 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using in advanced search form', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 698 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using in advanced search form', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 699 | 699 | break; |
| 700 | 700 | case 'frontend_css_class': |
| 701 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 701 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 702 | 702 | break; |
| 703 | 703 | case 'backend_css_class': |
| 704 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 704 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 705 | 705 | break; |
| 706 | 706 | case 'is_historisable': |
| 707 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 707 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 708 | 708 | break; |
| 709 | 709 | case 'is_filterable': |
| 710 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to use this attribute in the filter search', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 710 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute in the filter search', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 711 | 711 | break; |
| 712 | 712 | case 'is_intrinsic': |
| 713 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if this attribute is intrinsic for a product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 713 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is intrinsic for a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 714 | 714 | break; |
| 715 | 715 | case 'is_used_for_variation': |
| 716 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 716 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 717 | 717 | break; |
| 718 | 718 | case 'is_used_in_variation': |
| 719 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to use this attribute for variation definition', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 720 | - if ( !empty($editedItem) && ($editedItem->is_used_for_variation == 'yes') ) { |
|
| 719 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute for variation definition', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 720 | + if (!empty($editedItem) && ($editedItem->is_used_for_variation == 'yes')) { |
|
| 721 | 721 | $input_def['option'] = 'disabled="disabled"'; |
| 722 | 722 | } |
| 723 | 723 | break; |
| 724 | 724 | case 'is_user_defined': |
| 725 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 725 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 726 | 726 | break; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | $input_def['value'] = $currentFieldValue; |
| 730 | - if($input_def['label'] == 'code') |
|
| 730 | + if ($input_def['label'] == 'code') |
|
| 731 | 731 | $input_def['type'] = 'hidden'; |
| 732 | - elseif($input_def['label'] == 'entity_id'){ |
|
| 732 | + elseif ($input_def['label'] == 'entity_id') { |
|
| 733 | 733 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
| 734 | 734 | $input_def['valueToPut'] = 'index'; |
| 735 | 735 | $input_def['type'] = 'select'; |
| 736 | 736 | |
| 737 | - $i=0; |
|
| 738 | - foreach($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 739 | - if($i <= 0){ |
|
| 737 | + $i = 0; |
|
| 738 | + foreach ($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 739 | + if ($i <= 0) { |
|
| 740 | 740 | $current_entity_id = $entity_id; |
| 741 | 741 | } |
| 742 | 742 | $i++; |
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | - elseif($input_def['label'] == '_unit_group_id'){ |
|
| 745 | + elseif ($input_def['label'] == '_unit_group_id') { |
|
| 746 | 746 | $input_def['possible_value'] = wpshop_attributes_unit::get_unit_group(); |
| 747 | 747 | $input_def['type'] = 'select'; |
| 748 | 748 | } |
| 749 | - elseif($input_def['label'] == '_default_unit'){ |
|
| 749 | + elseif ($input_def['label'] == '_default_unit') { |
|
| 750 | 750 | $unit_group_list = wpshop_attributes_unit::get_unit_group(); |
| 751 | - $input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id)?$editedItem->_unit_group_id:(!empty($unit_group_list)?$unit_group_list[0]->id:'')); |
|
| 751 | + $input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id) ? $editedItem->_unit_group_id : (!empty($unit_group_list) ? $unit_group_list[0]->id : '')); |
|
| 752 | 752 | $input_def['type'] = 'select'; |
| 753 | 753 | } |
| 754 | 754 | elseif ($input_def['label'] == 'backend_input') { |
| 755 | - if ( !is_object($editedItem) ) { |
|
| 755 | + if (!is_object($editedItem)) { |
|
| 756 | 756 | $input_def['type'] = 'hidden'; |
| 757 | 757 | } |
| 758 | 758 | else { |
| 759 | 759 | $new_possible_value = array(); |
| 760 | - switch ( $editedItem->data_type) { |
|
| 760 | + switch ($editedItem->data_type) { |
|
| 761 | 761 | case 'integer': |
| 762 | 762 | $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; |
| 763 | 763 | $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; |
| 766 | 766 | break; |
| 767 | 767 | case 'varchar': |
| 768 | - switch ( $input_def['value'] ) { |
|
| 768 | + switch ($input_def['value']) { |
|
| 769 | 769 | case 'hidden': |
| 770 | 770 | $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; |
| 771 | 771 | break; |
@@ -793,8 +793,8 @@ discard block |
||
| 793 | 793 | elseif ($input_def['label'] == 'frontend_input') { |
| 794 | 794 | $new_possible_value = array(); |
| 795 | 795 | |
| 796 | - if ( is_object($editedItem) ) { |
|
| 797 | - switch ( $editedItem->data_type) { |
|
| 796 | + if (is_object($editedItem)) { |
|
| 797 | + switch ($editedItem->data_type) { |
|
| 798 | 798 | case 'integer': |
| 799 | 799 | $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; |
| 800 | 800 | $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; |
| 803 | 803 | break; |
| 804 | 804 | case 'varchar': |
| 805 | - switch ( $input_def['value'] ) { |
|
| 805 | + switch ($input_def['value']) { |
|
| 806 | 806 | case 'hidden': |
| 807 | 807 | $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; |
| 808 | 808 | break; |
@@ -840,10 +840,10 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | $input_def['possible_value'] = $new_possible_value; |
| 842 | 842 | |
| 843 | - if ( !empty($editedItem->frontend_input) ) { |
|
| 844 | - switch ( $editedItem->frontend_input ) { |
|
| 843 | + if (!empty($editedItem->frontend_input)) { |
|
| 844 | + switch ($editedItem->frontend_input) { |
|
| 845 | 845 | case 'text': |
| 846 | - switch ( $editedItem->data_type ) { |
|
| 846 | + switch ($editedItem->data_type) { |
|
| 847 | 847 | case 'varchar': |
| 848 | 848 | $input_def['value'] = 'short_text'; |
| 849 | 849 | break; |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if(is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))){ |
|
| 871 | + if (is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))) { |
|
| 872 | 872 | // $input_def['type'] = 'hidden'; |
| 873 | 873 | $input_def['option'] = ' disabled="disabled" '; |
| 874 | 874 | $the_form_content_hidden .= '<input type="hidden" name="' . self::getDbTable() . '[' . $input_def['name'] . ']" value="' . $input_def['value'] . '" />'; |
@@ -879,16 +879,16 @@ discard block |
||
| 879 | 879 | $input_def['value'] = str_replace("\\", "", $input_def['value']); |
| 880 | 880 | |
| 881 | 881 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 882 | - if ( $input_def['label'] == 'default_value' ) { |
|
| 883 | - if ( !empty($editedItem->frontend_input) ) { |
|
| 884 | - switch ( $editedItem->frontend_input ) { |
|
| 882 | + if ($input_def['label'] == 'default_value') { |
|
| 883 | + if (!empty($editedItem->frontend_input)) { |
|
| 884 | + switch ($editedItem->frontend_input) { |
|
| 885 | 885 | case 'text': |
| 886 | 886 | $input_def['type'] = 'text'; |
| 887 | - switch ( $editedItem->data_type ) { |
|
| 887 | + switch ($editedItem->data_type) { |
|
| 888 | 888 | case 'datetime': |
| 889 | - $the_input = wpshop_attributes::attribute_type_date_config( unserialize($input_def['value']) ); |
|
| 889 | + $the_input = wpshop_attributes::attribute_type_date_config(unserialize($input_def['value'])); |
|
| 890 | 890 | |
| 891 | - $input_def['label'] = __('Date field configuration','wpshop'); |
|
| 891 | + $input_def['label'] = __('Date field configuration', 'wpshop'); |
|
| 892 | 892 | break; |
| 893 | 893 | default: |
| 894 | 894 | $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | case 'multiple-select': |
| 906 | 906 | case 'radio': |
| 907 | 907 | case 'checkbox': |
| 908 | - $input_def['label'] = __('Options list for attribute','wpshop') . ' |
|
| 908 | + $input_def['label'] = __('Options list for attribute', 'wpshop') . ' |
|
| 909 | 909 | <div class="alignright wpshop_change_select_data_type" > |
| 910 | 910 | +' . __('Change data type for this attribute', 'wpshop') . ' |
| 911 | 911 | </div>'; |
@@ -919,50 +919,50 @@ discard block |
||
| 919 | 919 | } |
| 920 | 920 | } |
| 921 | 921 | else { |
| 922 | - $input_def['type']='text'; |
|
| 922 | + $input_def['type'] = 'text'; |
|
| 923 | 923 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 924 | 924 | } |
| 925 | 925 | } |
| 926 | - if( $input_def['label'] == '_unit_group_id') { |
|
| 926 | + if ($input_def['label'] == '_unit_group_id') { |
|
| 927 | 927 | $the_input .= '<div id="wpshop_loader_input_group_unit"></div>'; |
| 928 | - $the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Manage group unit', 'wpshop').'</a>'; |
|
| 928 | + $the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Manage group unit', 'wpshop') . '</a>'; |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - if( $input_def['label'] == '_default_unit') { |
|
| 931 | + if ($input_def['label'] == '_default_unit') { |
|
| 932 | 932 | $the_input .= '<div id="wpshop_loader_input_unit"></div>'; |
| 933 | - $the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Manage units', 'wpshop').'</a>'; |
|
| 933 | + $the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Manage units', 'wpshop') . '</a>'; |
|
| 934 | 934 | $the_input .= '<input type="hidden" name="input_wpshop_load_attribute_unit_list" id="input_wpshop_load_attribute_unit_list" value="' . wp_create_nonce("wpshop_load_attribute_unit_list") . '" />'; |
| 935 | 935 | $the_input .= '<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>'; |
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | |
| 939 | - if($input_def['type'] != 'hidden'){ |
|
| 940 | - if ( ($input_def['label'] == 'entity_id') && is_object($editedItem) ) { |
|
| 939 | + if ($input_def['type'] != 'hidden') { |
|
| 940 | + if (($input_def['label'] == 'entity_id') && is_object($editedItem)) { |
|
| 941 | 941 | $the_input .= '<br/><span class="wpshop_duplicate_attribute" >' . __('Duplicate this attribute to . another entity', 'wpshop') . '</span>'; |
| 942 | 942 | } |
| 943 | 943 | $input = ' |
| 944 | - <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_def['name'].'" > |
|
| 945 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_def['name'].'" ><label for="'.$input_def_id.'" >' . __($input_def['label'], 'wpshop') . '</label></td> |
|
| 946 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_def['name'].'" >' . $the_input . '</td> |
|
| 944 | + <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_def['name'] . '" > |
|
| 945 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_def['name'] . '" ><label for="' . $input_def_id . '" >' . __($input_def['label'], 'wpshop') . '</label></td> |
|
| 946 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_def['name'] . '" >' . $the_input . '</td> |
|
| 947 | 947 | </tr>'; |
| 948 | - if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) ) |
|
| 948 | + if ((substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize(WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS))) |
|
| 949 | 949 | $the_form_option_content_list[$input_def['label']] = $input; |
| 950 | 950 | else { |
| 951 | 951 | $the_form_general_content .= $input; |
| 952 | - if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) { |
|
| 952 | + if (($input_def['label'] == 'frontend_input') && !is_object($editedItem)) { |
|
| 953 | 953 | |
| 954 | - $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); |
|
| 954 | + $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); |
|
| 955 | 955 | |
| 956 | 956 | $input = ' |
| 957 | 957 | <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_set_section" > |
| 958 | - <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="'.self::currentPageCode.'_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td> |
|
| 958 | + <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="' . self::currentPageCode . '_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td> |
|
| 959 | 959 | <td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_set_section" >' . $the_input . '</td> |
| 960 | 960 | </tr>'; |
| 961 | 961 | $the_form_general_content .= $input; |
| 962 | 962 | } |
| 963 | 963 | } |
| 964 | 964 | } |
| 965 | - else{ |
|
| 965 | + else { |
|
| 966 | 966 | $the_form_content_hidden .= ' |
| 967 | 967 | ' . $the_input; |
| 968 | 968 | } |
@@ -978,17 +978,17 @@ discard block |
||
| 978 | 978 | $section_content = $the_form_general_content; |
| 979 | 979 | |
| 980 | 980 | ob_start(); |
| 981 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 981 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 982 | 982 | $the_form_general_content = ob_get_contents(); |
| 983 | 983 | ob_end_clean(); |
| 984 | 984 | |
| 985 | 985 | /** It is attribute TVA, add a button to calcilate price in mass **/ |
| 986 | - if ( !empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva' ) { |
|
| 987 | - $the_form_general_content .= '<input type="button" data-nonce="' . wp_create_nonce( 'wps_update_products_prices' ) . '" id="wps_update_price_infos" value="' .__('Update all products price', 'wpshop').'" /> <img src="' .WPSHOP_LOADING_ICON. '" alt="" id="update_products_loader" /> <br/>'; |
|
| 988 | - $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop' ); |
|
| 986 | + if (!empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva') { |
|
| 987 | + $the_form_general_content .= '<input type="button" data-nonce="' . wp_create_nonce('wps_update_products_prices') . '" id="wps_update_price_infos" value="' . __('Update all products price', 'wpshop') . '" /> <img src="' . WPSHOP_LOADING_ICON . '" alt="" id="update_products_loader" /> <br/>'; |
|
| 988 | + $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop'); |
|
| 989 | 989 | } |
| 990 | 990 | if (!empty($the_form_option_content_list)) { |
| 991 | - $the_form_option_content_section=''; |
|
| 991 | + $the_form_option_content_section = ''; |
|
| 992 | 992 | foreach ($attribute_options_group as $group_name => $group_content) { |
| 993 | 993 | $section_content = ''; |
| 994 | 994 | foreach ($group_content as $group_code) { |
@@ -997,23 +997,23 @@ discard block |
||
| 997 | 997 | unset($the_form_option_content_list[$group_code]); |
| 998 | 998 | } |
| 999 | 999 | } |
| 1000 | - $section_legend = __($group_name,'wpshop'); |
|
| 1000 | + $section_legend = __($group_name, 'wpshop'); |
|
| 1001 | 1001 | $section_page_code = self::currentPageCode; |
| 1002 | 1002 | |
| 1003 | 1003 | ob_start(); |
| 1004 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 1004 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 1005 | 1005 | $the_form_option_content_section .= ob_get_contents(); |
| 1006 | 1006 | ob_end_clean(); |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | /* Check there are other attributes to display not in defined group */ |
| 1010 | 1010 | if (!empty($the_form_option_content_list)) { |
| 1011 | - $section_legend = __('General options','wpshop'); |
|
| 1011 | + $section_legend = __('General options', 'wpshop'); |
|
| 1012 | 1012 | $section_content = implode('', $the_form_option_content_list); |
| 1013 | 1013 | $section_page_code = self::currentPageCode; |
| 1014 | 1014 | |
| 1015 | 1015 | ob_start(); |
| 1016 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 1016 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 1017 | 1017 | $the_form_option_content = ob_get_contents(); |
| 1018 | 1018 | ob_end_clean(); |
| 1019 | 1019 | |
@@ -1023,17 +1023,17 @@ discard block |
||
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | /* Default content for the current page */ |
| 1026 | - $bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop'); |
|
| 1026 | + $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop'); |
|
| 1027 | 1027 | $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content; |
| 1028 | 1028 | |
| 1029 | - $bloc_list[self::currentPageCode]['options']['title']=__('Options', 'wpshop'); |
|
| 1030 | - $bloc_list[self::currentPageCode]['options']['content']=$the_form_option_content; |
|
| 1029 | + $bloc_list[self::currentPageCode]['options']['title'] = __('Options', 'wpshop'); |
|
| 1030 | + $bloc_list[self::currentPageCode]['options']['content'] = $the_form_option_content; |
|
| 1031 | 1031 | |
| 1032 | - $action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action' ] ) : ''; |
|
| 1032 | + $action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
|
| 1033 | 1033 | $the_form = ' |
| 1034 | 1034 | <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" > |
| 1035 | - ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save') , 'hidden') . ' |
|
| 1036 | - ' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . ' |
|
| 1035 | + ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save'), 'hidden') . ' |
|
| 1036 | + ' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . ' |
|
| 1037 | 1037 | </form> |
| 1038 | 1038 | <div title="' . __('Change data type for selected attribute', 'wpshop') . '" id="wpshop_dialog_change_select_data_type" ><div id="wpshop_dialog_change_select_data_type_container" ></div></div>'; |
| 1039 | 1039 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | $the_form .= ' |
| 1052 | 1052 | <script type="text/javascript" > |
| 1053 | 1053 | wpshop(document).ready(function(){ |
| 1054 | - wpshopMainInterface("'.self::getDbTable().'", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); |
|
| 1054 | + wpshopMainInterface("'.self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '"); |
|
| 1055 | 1055 | |
| 1056 | 1056 | jQuery("#wpshop_dialog_duplicate_attribute").dialog({ |
| 1057 | 1057 | autoOpen: false, |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | dialogClass: "wpshop_uidialog_box", |
| 1062 | 1062 | resizable: false, |
| 1063 | 1063 | buttons:{ |
| 1064 | - "'.__('Duplicate', 'wpshop').'": function(){ |
|
| 1064 | + "'.__('Duplicate', 'wpshop') . '": function(){ |
|
| 1065 | 1065 | var data = { |
| 1066 | 1066 | action: "wpshop_duplicate_attribute", |
| 1067 | 1067 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_duplicate_attribute") . '", |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | } |
| 1078 | 1078 | }, "json"); |
| 1079 | 1079 | }, |
| 1080 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 1080 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 1081 | 1081 | jQuery(this).dialog("close"); |
| 1082 | 1082 | jQuery(".wpshop_duplicate_attribute_result").remove(); |
| 1083 | 1083 | } |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | dialogClass: "wpshop_uidialog_box", |
| 1096 | 1096 | resizable: false, |
| 1097 | 1097 | buttons:{ |
| 1098 | - "'.__('Change type', 'wpshop').'": function(){ |
|
| 1098 | + "'.__('Change type', 'wpshop') . '": function(){ |
|
| 1099 | 1099 | var delete_entity = false; |
| 1100 | 1100 | if(jQuery("#delete_entity").is(":checked")){ |
| 1101 | 1101 | var delete_entity = true; |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | jQuery("#wpshop_dialog_change_select_data_type").dialog("close"); |
| 1119 | 1119 | }, "json"); |
| 1120 | 1120 | }, |
| 1121 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 1121 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 1122 | 1122 | jQuery(this).dialog("close"); |
| 1123 | 1123 | } |
| 1124 | 1124 | } |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | change_unit_list(); |
| 1159 | 1159 | });'; |
| 1160 | 1160 | |
| 1161 | - if ( !is_object($editedItem) ) { |
|
| 1161 | + if (!is_object($editedItem)) { |
|
| 1162 | 1162 | $the_form .= ' |
| 1163 | 1163 | jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").change(function(){ |
| 1164 | 1164 | jQuery(".wpshop_attributes_edition_table_field_input_default_value").html(jQuery("#wpshopLoadingPicture").html()); |
@@ -1241,23 +1241,23 @@ discard block |
||
| 1241 | 1241 | * |
| 1242 | 1242 | * @return string $currentPageButton The html output code with the different button to add to the interface |
| 1243 | 1243 | */ |
| 1244 | - function getPageFormButton($element_id = 0){ |
|
| 1244 | + function getPageFormButton($element_id = 0) { |
|
| 1245 | 1245 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 1246 | 1246 | $currentPageButton = ''; |
| 1247 | 1247 | |
| 1248 | 1248 | //$currentPageButton .= '<h2 class="cancelButton alignleft" ><a href="' . admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&page=' . self::getListingSlug()) . '" class="button add-new-h2" >' . __('Back', 'wpshop') . '</a></h2>'; |
| 1249 | 1249 | |
| 1250 | - if(($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1250 | + if (($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1251 | 1251 | $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 1252 | 1252 | |
| 1253 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 1253 | + elseif (current_user_can('wpshop_edit_attributes')) |
|
| 1254 | 1254 | $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
| 1255 | 1255 | |
| 1256 | 1256 | $attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE); |
| 1257 | 1257 | $attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id'); |
| 1258 | - $attribute_code = !empty($attribute->code)?$attribute->code:''; |
|
| 1259 | - if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1260 | - $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1258 | + $attribute_code = !empty($attribute->code) ? $attribute->code : ''; |
|
| 1259 | + if (current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1260 | + $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1261 | 1261 | |
| 1262 | 1262 | return $currentPageButton; |
| 1263 | 1263 | } |
@@ -1271,22 +1271,22 @@ discard block |
||
| 1271 | 1271 | * |
| 1272 | 1272 | * @return object $element_list A wordpress database object containing the attribute list |
| 1273 | 1273 | */ |
| 1274 | - public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false){ |
|
| 1274 | + public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false) { |
|
| 1275 | 1275 | |
| 1276 | 1276 | global $wpdb; |
| 1277 | 1277 | $element_list = array(); |
| 1278 | 1278 | $moreQuery = ""; |
| 1279 | - $moreArgs = array( 1, ); |
|
| 1279 | + $moreArgs = array(1,); |
|
| 1280 | 1280 | |
| 1281 | - $orderby = !empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
|
| 1282 | - $order = !empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
|
| 1281 | + $orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : ''; |
|
| 1282 | + $order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : ''; |
|
| 1283 | 1283 | |
| 1284 | - if($element_id != ''){ |
|
| 1284 | + if ($element_id != '') { |
|
| 1285 | 1285 | $moreQuery .= " |
| 1286 | 1286 | AND CURRENT_ELEMENT." . $field_to_search . " = %s "; |
| 1287 | 1287 | $moreArgs[] = $element_id; |
| 1288 | 1288 | } |
| 1289 | - if(!empty($orderby) && !empty($order)){ |
|
| 1289 | + if (!empty($orderby) && !empty($order)) { |
|
| 1290 | 1290 | $moreQuery .= " |
| 1291 | 1291 | ORDER BY " . $orderby . " " . $order; |
| 1292 | 1292 | } |
@@ -1295,15 +1295,15 @@ discard block |
||
| 1295 | 1295 | "SELECT CURRENT_ELEMENT.*, ENTITIES.post_name as entity |
| 1296 | 1296 | FROM " . self::getDbTable() . " AS CURRENT_ELEMENT |
| 1297 | 1297 | INNER JOIN {$wpdb->posts} AS ENTITIES ON (ENTITIES.ID = CURRENT_ELEMENT.entity_id) |
| 1298 | - WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, |
|
| 1298 | + WHERE %d AND CURRENT_ELEMENT.status IN (" . $element_status . ") " . $moreQuery, |
|
| 1299 | 1299 | $moreArgs |
| 1300 | 1300 | ); |
| 1301 | 1301 | |
| 1302 | 1302 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 1303 | - if(($element_id == '') || $list){ |
|
| 1303 | + if (($element_id == '') || $list) { |
|
| 1304 | 1304 | $element_list = $wpdb->get_results($query); |
| 1305 | 1305 | } |
| 1306 | - else{ |
|
| 1306 | + else { |
|
| 1307 | 1307 | $element_list = $wpdb->get_row($query); |
| 1308 | 1308 | } |
| 1309 | 1309 | |
@@ -1325,43 +1325,43 @@ discard block |
||
| 1325 | 1325 | $user_id = function_exists('is_user_logged_in') && is_user_logged_in() ? get_current_user_id() : '0'; |
| 1326 | 1326 | $sent_attribute_list = array(); |
| 1327 | 1327 | |
| 1328 | - if ( !empty($attributeToSet) ) { |
|
| 1328 | + if (!empty($attributeToSet)) { |
|
| 1329 | 1329 | foreach ($attributeToSet as $attributeType => $attributeTypeDetails) { |
| 1330 | 1330 | /** Preparation des parametres permettant de supprimer les bonnes valeurs des attributs suivant la configuration de la boutique et de la methode de mise a jour */ |
| 1331 | 1331 | $delete_current_attribute_values_params = array( |
| 1332 | 1332 | 'entity_id' => $entityId, |
| 1333 | 1333 | 'entity_type_id' => $entityTypeId |
| 1334 | 1334 | ); |
| 1335 | - if ( WPSHOP_ATTRIBUTE_VALUE_PER_USER ) { |
|
| 1335 | + if (WPSHOP_ATTRIBUTE_VALUE_PER_USER) { |
|
| 1336 | 1336 | $delete_current_attribute_values_params['user_id'] = $user_id; |
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | - if(!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) { |
|
| 1340 | - foreach($attributeTypeDetails as $attribute_code => $attributeValue) { |
|
| 1339 | + if (!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) { |
|
| 1340 | + foreach ($attributeTypeDetails as $attribute_code => $attributeValue) { |
|
| 1341 | 1341 | |
| 1342 | - if ( $attributeType == 'decimal' ) { |
|
| 1342 | + if ($attributeType == 'decimal') { |
|
| 1343 | 1343 | $attributeValue = str_replace(',', '.', $attributeValue); |
| 1344 | 1344 | } |
| 1345 | - if ( ($attributeType == 'integer') && !is_array($attributeValue) ) { |
|
| 1345 | + if (($attributeType == 'integer') && !is_array($attributeValue)) { |
|
| 1346 | 1346 | $attributeValue = (int)$attributeValue; |
| 1347 | 1347 | } |
| 1348 | 1348 | $more_query_params_values = array(); |
| 1349 | - if($attribute_code != 'unit') { |
|
| 1349 | + if ($attribute_code != 'unit') { |
|
| 1350 | 1350 | |
| 1351 | 1351 | $unit_id = 0; |
| 1352 | - if(isset($attributeTypeDetails['unit'][$attribute_code])){ |
|
| 1352 | + if (isset($attributeTypeDetails['unit'][$attribute_code])) { |
|
| 1353 | 1353 | $unit_id = $attributeTypeDetails['unit'][$attribute_code]; |
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | 1356 | $currentAttribute = self::getElement($attribute_code, "'valid'", 'code'); |
| 1357 | - if( !empty($currentAttribute) ){ |
|
| 1357 | + if (!empty($currentAttribute)) { |
|
| 1358 | 1358 | $sent_attribute_list[] = $currentAttribute->id; |
| 1359 | 1359 | |
| 1360 | 1360 | /* Enregistrement de la valeur actuelle de l'attribut dans la table d'historique si l'option historique est activee sur l'attribut courant */ |
| 1361 | - if ( $currentAttribute->is_historisable == 'yes') { |
|
| 1361 | + if ($currentAttribute->is_historisable == 'yes') { |
|
| 1362 | 1362 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType . " WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d", $entityTypeId, $currentAttribute->id, $entityId); |
| 1363 | 1363 | $attribute_histo = $wpdb->get_results($query); |
| 1364 | - if(!empty($attribute_histo)){ |
|
| 1364 | + if (!empty($attribute_histo)) { |
|
| 1365 | 1365 | $attribute_histo_content['status'] = 'valid'; |
| 1366 | 1366 | $attribute_histo_content['creation_date'] = current_time('mysql', 0); |
| 1367 | 1367 | $attribute_histo_content['creation_date_value'] = $attribute_histo[0]->creation_date_value; |
@@ -1378,8 +1378,8 @@ discard block |
||
| 1378 | 1378 | } |
| 1379 | 1379 | $attributeValue = str_replace("\\", "", $attributeValue); |
| 1380 | 1380 | |
| 1381 | - if ( empty($from) || (!empty($attributeValue)) ) { |
|
| 1382 | - $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id))); |
|
| 1381 | + if (empty($from) || (!empty($attributeValue))) { |
|
| 1382 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id))); |
|
| 1383 | 1383 | |
| 1384 | 1384 | /** Insertion de la nouvelle valeur de l'attribut dans la base */ |
| 1385 | 1385 | $query_params = array( |
@@ -1393,32 +1393,32 @@ discard block |
||
| 1393 | 1393 | 'creation_date_value' => current_time('mysql', 0) |
| 1394 | 1394 | ); |
| 1395 | 1395 | /** Si l'attribut courant est contenu dans un tableau (exemple: select multiple) on lit tout le tableau et on enregistre chaque valeur separement */ |
| 1396 | - if(is_array($attributeValue)){ |
|
| 1397 | - foreach($attributeValue as $a){ |
|
| 1398 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a))); |
|
| 1396 | + if (is_array($attributeValue)) { |
|
| 1397 | + foreach ($attributeValue as $a) { |
|
| 1398 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $a))); |
|
| 1399 | 1399 | } |
| 1400 | 1400 | } |
| 1401 | - else{ |
|
| 1402 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue))); |
|
| 1403 | - wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array( |
|
| 1401 | + else { |
|
| 1402 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $attributeValue))); |
|
| 1403 | + wpeologs_ctr::log_datas_in_files('wpshop_attributes', array( |
|
| 1404 | 1404 | 'object_id' => $entityId, |
| 1405 | - 'message' => __( 'Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue , 'wpshop' ) ), 0 |
|
| 1405 | + 'message' => __('Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue, 'wpshop') ), 0 |
|
| 1406 | 1406 | ); |
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | 1409 | /** Dans le cas ou l'attribut courant est utilise dans l'interface permettant de trier les produits (option de l'attribut) on defini une meta specifique */ |
| 1410 | - if ( ( ($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ( $currentAttribute->is_filterable == 'yes') && !empty($attributeValue) ) : |
|
| 1411 | - update_post_meta($entityId, '_'.$attribute_code, $attributeValue); |
|
| 1410 | + if ((($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ($currentAttribute->is_filterable == 'yes') && !empty($attributeValue)) : |
|
| 1411 | + update_post_meta($entityId, '_' . $attribute_code, $attributeValue); |
|
| 1412 | 1412 | endif; |
| 1413 | 1413 | |
| 1414 | 1414 | /** Enregistrement de toutes les valeurs des attributs dans une meta du produit */ |
| 1415 | - $attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array) $_POST['attribute_option'][$attribute_code] : null; |
|
| 1415 | + $attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array)$_POST['attribute_option'][$attribute_code] : null; |
|
| 1416 | 1416 | if (isset($attribute_option)) { |
| 1417 | 1417 | $value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value'); |
| 1418 | 1418 | if (strtolower($value) == 'yes') : |
| 1419 | - update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option); |
|
| 1419 | + update_post_meta($entityId, 'attribute_option_' . $attribute_code, $attribute_option); |
|
| 1420 | 1420 | else : |
| 1421 | - delete_post_meta($entityId, 'attribute_option_'.$attribute_code); |
|
| 1421 | + delete_post_meta($entityId, 'attribute_option_' . $attribute_code); |
|
| 1422 | 1422 | endif; |
| 1423 | 1423 | } |
| 1424 | 1424 | } |
@@ -1426,15 +1426,15 @@ discard block |
||
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | - if ( empty($from) ) { |
|
| 1430 | - $query = $wpdb->prepare("SELECT value_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType . " WHERE attribute_id NOT IN ('" . implode("', '", $sent_attribute_list) . "') AND entity_id = %d AND entity_type_id = %d", $entityId, $entityTypeId); |
|
| 1429 | + if (empty($from)) { |
|
| 1430 | + $query = $wpdb->prepare("SELECT value_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType . " WHERE attribute_id NOT IN ('" . implode("', '", $sent_attribute_list) . "') AND entity_id = %d AND entity_type_id = %d", $entityId, $entityTypeId); |
|
| 1431 | 1431 | $attr_to_delete = $wpdb->get_results($query); |
| 1432 | - if(!empty($attr_to_delete)){ |
|
| 1432 | + if (!empty($attr_to_delete)) { |
|
| 1433 | 1433 | foreach ($attr_to_delete as $value) { |
| 1434 | - $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id))); |
|
| 1435 | - wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array( |
|
| 1434 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id))); |
|
| 1435 | + wpeologs_ctr::log_datas_in_files('wpshop_attributes', array( |
|
| 1436 | 1436 | 'object_id' => $entityId, |
| 1437 | - 'message' => __( 'Remove the attribute : ' . $value->value_id, 'wpshop' ) ), 0 |
|
| 1437 | + 'message' => __('Remove the attribute : ' . $value->value_id, 'wpshop') ), 0 |
|
| 1438 | 1438 | ); |
| 1439 | 1439 | } |
| 1440 | 1440 | } |
@@ -1460,7 +1460,7 @@ discard block |
||
| 1460 | 1460 | |
| 1461 | 1461 | $query_params = ""; |
| 1462 | 1462 | $query_params_values = array($attributeId, $entityTypeId, $entityId); |
| 1463 | - if(WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))){ |
|
| 1463 | + if (WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))) { |
|
| 1464 | 1464 | $query_params = " |
| 1465 | 1465 | AND ATTR_VAL.user_id = %d"; |
| 1466 | 1466 | $query_params_values[] = get_current_user_id(); |
@@ -1476,20 +1476,20 @@ discard block |
||
| 1476 | 1476 | ); |
| 1477 | 1477 | $attributeValue = $wpdb->get_results($query); |
| 1478 | 1478 | |
| 1479 | - if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) { |
|
| 1479 | + if (((count($attributeValue) <= 1) && !empty($attributeValue[0])) && (empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select'))) { |
|
| 1480 | 1480 | $attributeValue = $attributeValue[0]; |
| 1481 | 1481 | } |
| 1482 | - else{ |
|
| 1482 | + else { |
|
| 1483 | 1483 | $entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true); |
| 1484 | - if ( !empty($entity_meta) ) { |
|
| 1484 | + if (!empty($entity_meta)) { |
|
| 1485 | 1485 | $query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId); |
| 1486 | 1486 | $attribute_code = $wpdb->get_var($query); |
| 1487 | 1487 | $attributeValue = !empty($entity_meta[$attribute_code]) ? $entity_meta[$attribute_code] : null; |
| 1488 | 1488 | } |
| 1489 | - if ( is_array($attributeValue) ) { |
|
| 1489 | + if (is_array($attributeValue)) { |
|
| 1490 | 1490 | $tmp_array = array(); |
| 1491 | - if ( !empty($attributeValue) ) { |
|
| 1492 | - foreach ( $attributeValue as $att ) { |
|
| 1491 | + if (!empty($attributeValue)) { |
|
| 1492 | + foreach ($attributeValue as $att) { |
|
| 1493 | 1493 | $obj = new stdClass(); |
| 1494 | 1494 | $obj->value = $att; |
| 1495 | 1495 | $obj->unit_id = 0; |
@@ -1520,9 +1520,9 @@ discard block |
||
| 1520 | 1520 | $elements = array(); |
| 1521 | 1521 | $elementsWithAttributeAndValues = self::get_attribute_list_for_item($entityId, $elementId, $language); |
| 1522 | 1522 | |
| 1523 | - foreach ( $elementsWithAttributeAndValues as $elementDefinition ) { |
|
| 1523 | + foreach ($elementsWithAttributeAndValues as $elementDefinition) { |
|
| 1524 | 1524 | $arrayKey = $elementDefinition->attribute_id; |
| 1525 | - if ( $keyForArray == 'code' ) { |
|
| 1525 | + if ($keyForArray == 'code') { |
|
| 1526 | 1526 | $arrayKey = $elementDefinition->attribute_code; |
| 1527 | 1527 | } |
| 1528 | 1528 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['code'] = $elementDefinition->attribute_set_section_code; |
@@ -1532,7 +1532,7 @@ discard block |
||
| 1532 | 1532 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_table'] = $elementDefinition->backend_table; |
| 1533 | 1533 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_input'] = $elementDefinition->backend_input; |
| 1534 | 1534 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_input'] = $elementDefinition->frontend_input; |
| 1535 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __( $elementDefinition->frontend_label, 'wpshop' ); |
|
| 1535 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __($elementDefinition->frontend_label, 'wpshop'); |
|
| 1536 | 1536 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['attribute_code'] = $elementDefinition->attribute_code; |
| 1537 | 1537 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['data_type_to_use'] = $elementDefinition->data_type_to_use; |
| 1538 | 1538 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['is_visible_in_front'] = $elementDefinition->is_visible_in_front; |
@@ -1542,29 +1542,29 @@ discard block |
||
| 1542 | 1542 | $attributeValueField = 'attribute_value_' . $elementDefinition->data_type; |
| 1543 | 1543 | |
| 1544 | 1544 | // Manage the value differently if it is an array or not |
| 1545 | - if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) { |
|
| 1545 | + if (!empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
|
| 1546 | 1546 | if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
| 1547 | 1547 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField; |
| 1548 | 1548 | } |
| 1549 | 1549 | else { |
| 1550 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField); |
|
| 1550 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'], $elementDefinition->$attributeValueField); |
|
| 1551 | 1551 | } |
| 1552 | 1552 | } |
| 1553 | 1553 | else { |
| 1554 | 1554 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField; |
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | - if ( $elementDefinition->backend_input == 'multiple-select' ) { |
|
| 1557 | + if ($elementDefinition->backend_input == 'multiple-select') { |
|
| 1558 | 1558 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['select_value'] = self::get_attribute_type_select_option_info($attributeValueField, 'value'); |
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | $attributeUnitField = 'attribute_unit_' . $elementDefinition->data_type; |
| 1562 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $elementDefinition->$attributeUnitField, 'wpshop' ); |
|
| 1563 | - if( !empty($elementDefinition->is_requiring_unit ) && ( $elementDefinition->is_requiring_unit == 'yes' ) && empty( $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] ) ) { |
|
| 1562 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($elementDefinition->$attributeUnitField, 'wpshop'); |
|
| 1563 | + if (!empty($elementDefinition->is_requiring_unit) && ($elementDefinition->is_requiring_unit == 'yes') && empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'])) { |
|
| 1564 | 1564 | $unit = ''; |
| 1565 | - $query = $wpdb->prepare( 'SELECT unit FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid'); |
|
| 1566 | - $unit = $wpdb->get_var( $query ); |
|
| 1567 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $unit, 'wpshop' ); |
|
| 1565 | + $query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid'); |
|
| 1566 | + $unit = $wpdb->get_var($query); |
|
| 1567 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($unit, 'wpshop'); |
|
| 1568 | 1568 | } |
| 1569 | 1569 | |
| 1570 | 1570 | } |
@@ -1576,7 +1576,7 @@ discard block |
||
| 1576 | 1576 | $elementsWithAttributeAndValues = array(); |
| 1577 | 1577 | $moreQuery = ""; |
| 1578 | 1578 | |
| 1579 | - $entity_type = empty($defined_entity_type) ? get_post_type( $elementId ) : $defined_entity_type; |
|
| 1579 | + $entity_type = empty($defined_entity_type) ? get_post_type($elementId) : $defined_entity_type; |
|
| 1580 | 1580 | |
| 1581 | 1581 | $query = $wpdb->prepare( |
| 1582 | 1582 | "SELECT POST_META.*, |
@@ -1625,23 +1625,23 @@ discard block |
||
| 1625 | 1625 | * |
| 1626 | 1626 | * @return boolean The result to know if the element has to be displayed on frontend |
| 1627 | 1627 | */ |
| 1628 | - public static function check_attribute_display( $attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) { |
|
| 1629 | - if ( $attribute_main_config === 'yes' ) { |
|
| 1628 | + public static function check_attribute_display($attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) { |
|
| 1629 | + if ($attribute_main_config === 'yes') { |
|
| 1630 | 1630 | $attribute_output = true; |
| 1631 | - if ( ( is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes' ) |
|
| 1632 | - || empty($attribute_custom_config) ) { |
|
| 1631 | + if ((is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') |
|
| 1632 | + || empty($attribute_custom_config)) { |
|
| 1633 | 1633 | $attribute_output = true; |
| 1634 | 1634 | } |
| 1635 | - else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) ) { |
|
| 1635 | + else if (empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no'))) { |
|
| 1636 | 1636 | $attribute_output = false; |
| 1637 | 1637 | } |
| 1638 | 1638 | } |
| 1639 | - elseif ( $attribute_main_config === 'no' ) { |
|
| 1639 | + elseif ($attribute_main_config === 'no') { |
|
| 1640 | 1640 | $attribute_output = false; |
| 1641 | - if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) { |
|
| 1641 | + if (empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code])) { |
|
| 1642 | 1642 | $attribute_output = false; |
| 1643 | 1643 | } |
| 1644 | - else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') ) { |
|
| 1644 | + else if (!empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes')) { |
|
| 1645 | 1645 | $attribute_output = true; |
| 1646 | 1646 | } |
| 1647 | 1647 | } |
@@ -1658,22 +1658,22 @@ discard block |
||
| 1658 | 1658 | global $wpdb; |
| 1659 | 1659 | global $wp_query; |
| 1660 | 1660 | |
| 1661 | - $attribute = self::getElement( $atts['attid'] ); |
|
| 1662 | - if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1663 | - $attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
|
| 1664 | - $output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output'; |
|
| 1661 | + $attribute = self::getElement($atts['attid']); |
|
| 1662 | + if (empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1663 | + $attribute_main_config = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
|
| 1664 | + $output_type = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? 'complete_sheet' : 'mini_output'; |
|
| 1665 | 1665 | $product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true); |
| 1666 | - $display_attribute_value = wpshop_attributes::check_attribute_display( $attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type); |
|
| 1666 | + $display_attribute_value = wpshop_attributes::check_attribute_display($attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type); |
|
| 1667 | 1667 | |
| 1668 | - if ( !empty( $attribute->data_type ) ) { |
|
| 1668 | + if (!empty($attribute->data_type)) { |
|
| 1669 | 1669 | $attributeDefinition['unit'] = ''; |
| 1670 | 1670 | |
| 1671 | 1671 | $has_value = false; |
| 1672 | - $query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute->data_type . " WHERE entity_id=%s AND attribute_id=%d", $atts['pid'], $atts['attid'] ); |
|
| 1673 | - if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) ) { |
|
| 1672 | + $query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute->data_type . " WHERE entity_id=%s AND attribute_id=%d", $atts['pid'], $atts['attid']); |
|
| 1673 | + if (in_array($attribute->backend_input, array('multiple-select', 'checkbox'))) { |
|
| 1674 | 1674 | $list_of_value = $wpdb->get_results($query); |
| 1675 | - if ( !empty($list_of_value) ) { |
|
| 1676 | - foreach ( $list_of_value as $value ) { |
|
| 1675 | + if (!empty($list_of_value)) { |
|
| 1676 | + foreach ($list_of_value as $value) { |
|
| 1677 | 1677 | $data[] = $value->value; |
| 1678 | 1678 | } |
| 1679 | 1679 | $has_value = true; |
@@ -1681,10 +1681,10 @@ discard block |
||
| 1681 | 1681 | } |
| 1682 | 1682 | else { |
| 1683 | 1683 | $data = $wpdb->get_var($query); |
| 1684 | - if ( !empty($data) ) { |
|
| 1684 | + if (!empty($data)) { |
|
| 1685 | 1685 | $has_value = true; |
| 1686 | 1686 | } |
| 1687 | - elseif( !empty($attribute->default_value) ) { |
|
| 1687 | + elseif (!empty($attribute->default_value)) { |
|
| 1688 | 1688 | $has_value = true; |
| 1689 | 1689 | $data = $attribute->default_value; |
| 1690 | 1690 | } |
@@ -1696,7 +1696,7 @@ discard block |
||
| 1696 | 1696 | $attributeDefinition['is_requiring_unit'] = $attribute->is_requiring_unit; |
| 1697 | 1697 | $attributeDefinition['backend_input'] = $attribute->backend_input; |
| 1698 | 1698 | $attributeDefinition['data_type_to_use'] = $attribute->data_type_to_use; |
| 1699 | - $attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition ); |
|
| 1699 | + $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); |
|
| 1700 | 1700 | $attribute_value = $attribute_display[0]; |
| 1701 | 1701 | $attributeDefinition['value'] = $attribute_display[1]; |
| 1702 | 1702 | $attribute_unit_list = $attribute_display[2]; |
@@ -1716,13 +1716,13 @@ discard block |
||
| 1716 | 1716 | * @param array $specific_argument Optionnal The different parameters used for filter output |
| 1717 | 1717 | * @return array The definition for the field used to display an attribute |
| 1718 | 1718 | */ |
| 1719 | - public static function get_attribute_field_definition( $attribute, $attribute_value = '', $specific_argument = array() ) { |
|
| 1719 | + public static function get_attribute_field_definition($attribute, $attribute_value = '', $specific_argument = array()) { |
|
| 1720 | 1720 | global $wpdb; |
| 1721 | 1721 | $wpshop_price_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 1722 | 1722 | $wpshop_weight_attributes = unserialize(WPSHOP_ATTRIBUTE_WEIGHT); |
| 1723 | 1723 | $input_def = array(); |
| 1724 | 1724 | $input_def['option'] = $input_def['field_container_class'] = ''; |
| 1725 | - $attributeInputDomain = (!empty($specific_argument['field_custom_name_prefix']) || (!empty($specific_argument['field_custom_name_prefix']) && ($specific_argument['field_custom_name_prefix'] == 'empty')) ) ? $specific_argument['field_custom_name_prefix'] : ((!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '' ) . 'attribute[' . $attribute->data_type . ']'); |
|
| 1725 | + $attributeInputDomain = (!empty($specific_argument['field_custom_name_prefix']) || (!empty($specific_argument['field_custom_name_prefix']) && ($specific_argument['field_custom_name_prefix'] == 'empty'))) ? $specific_argument['field_custom_name_prefix'] : ((!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '') . 'attribute[' . $attribute->data_type . ']'); |
|
| 1726 | 1726 | $input_def['input_domain'] = $attributeInputDomain; |
| 1727 | 1727 | $input_def['id'] = (!empty($specific_argument) && !empty($specific_argument['field_id']) ? $specific_argument['field_id'] . '_' : '') . 'attribute_' . $attribute->id; |
| 1728 | 1728 | $input_def['intrinsec'] = $attribute->is_intrinsic; |
@@ -1742,26 +1742,26 @@ discard block |
||
| 1742 | 1742 | $input_def['frontend_type'] = $attribute->frontend_input; |
| 1743 | 1743 | $input_def['is_used_in_quick_add_form'] = $attribute->is_used_in_quick_add_form; |
| 1744 | 1744 | |
| 1745 | - if ( !empty($attribute_value) && !is_object($attribute_value) ) { |
|
| 1745 | + if (!empty($attribute_value) && !is_object($attribute_value)) { |
|
| 1746 | 1746 | $input_def['value'] = $attribute_value; |
| 1747 | 1747 | } |
| 1748 | - else if ( !empty($attribute_value->value) ) { |
|
| 1748 | + else if (!empty($attribute_value->value)) { |
|
| 1749 | 1749 | $input_def['value'] = stripslashes($attribute_value->value); |
| 1750 | 1750 | } |
| 1751 | - else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) { |
|
| 1751 | + else if (!empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft')) { |
|
| 1752 | 1752 | $input_def['value'] = ''; |
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | 1755 | $input_def['options'] = ''; |
| 1756 | 1756 | $input_more_class = !empty($specific_argument['input_class']) ? $specific_argument['input_class'] : ''; |
| 1757 | 1757 | if ($attribute->data_type == 'datetime') { |
| 1758 | - $date_config = unserialize( $attribute->default_value ); |
|
| 1758 | + $date_config = unserialize($attribute->default_value); |
|
| 1759 | 1759 | if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) { |
| 1760 | 1760 | $input_def['value'] = date('Y-m-d'); |
| 1761 | 1761 | } |
| 1762 | 1762 | else { |
| 1763 | 1763 | /** Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/ */ |
| 1764 | - $input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace( " 00:00:00", "", $attribute_value->value ) : ( !empty($attribute_value) && is_string($attribute_value) ? str_replace( " 00:00:00", "", $attribute_value ) : '' ); |
|
| 1764 | + $input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace(" 00:00:00", "", $attribute_value->value) : (!empty($attribute_value) && is_string($attribute_value) ? str_replace(" 00:00:00", "", $attribute_value) : ''); |
|
| 1765 | 1765 | } |
| 1766 | 1766 | $input_more_class .= ' wpshop_input_datetime '; |
| 1767 | 1767 | $field_script = '<script type="text/javascript" > |
@@ -1774,31 +1774,31 @@ discard block |
||
| 1774 | 1774 | wpshop("#' . $input_def['id'] . '").datepicker("option", "navigationAsDateFormat", true); |
| 1775 | 1775 | wpshop("#' . $input_def['id'] . '").val("' . str_replace(" 00:00:00", "", $input_def['value']) . '");'; |
| 1776 | 1776 | |
| 1777 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']) ) { |
|
| 1778 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ) { |
|
| 1777 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur'])) { |
|
| 1778 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0])) { |
|
| 1779 | 1779 | $field_script .= ' |
| 1780 | 1780 | wpshop("#' . $input_def['id'] . '").datepicker("option", "minDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] . '");'; |
| 1781 | 1781 | } |
| 1782 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ) { |
|
| 1782 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0])) { |
|
| 1783 | 1783 | $field_script .= ' |
| 1784 | 1784 | wpshop("#' . $input_def['id'] . '").datepicker("option", "maxDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] . '");'; |
| 1785 | 1785 | } |
| 1786 | 1786 | } |
| 1787 | 1787 | |
| 1788 | 1788 | $script_options = $script_options_params = array(); |
| 1789 | - if ( !empty($date_config['field_options']['attribute_type_date_options_day_to_show']) ) { |
|
| 1789 | + if (!empty($date_config['field_options']['attribute_type_date_options_day_to_show'])) { |
|
| 1790 | 1790 | $day_to_show_list = ' '; |
| 1791 | - foreach ( $date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show ) { |
|
| 1791 | + foreach ($date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show) { |
|
| 1792 | 1792 | $day_to_show_list .= '(date.getDay() == ' . $day_to_show . ') || '; |
| 1793 | 1793 | } |
| 1794 | 1794 | $script_options[] = '( ' . substr($day_to_show_list, 0, -4) . ' )'; |
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0]) ) { |
|
| 1798 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date']) ) { |
|
| 1797 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0])) { |
|
| 1798 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date'])) { |
|
| 1799 | 1799 | $available_date = ' '; |
| 1800 | - foreach ( $date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list ) { |
|
| 1801 | - if ( !empty($avalaible_date_list) ) { |
|
| 1800 | + foreach ($date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list) { |
|
| 1801 | + if (!empty($avalaible_date_list)) { |
|
| 1802 | 1802 | $available_date .= '"' . $avalaible_date_list . '",'; |
| 1803 | 1803 | } |
| 1804 | 1804 | } |
@@ -1807,7 +1807,7 @@ discard block |
||
| 1807 | 1807 | } |
| 1808 | 1808 | } |
| 1809 | 1809 | |
| 1810 | - if ( !empty( $script_options ) ) { |
|
| 1810 | + if (!empty($script_options)) { |
|
| 1811 | 1811 | $field_script .= ' |
| 1812 | 1812 | wpshop("#' . $input_def['id'] . '").datepicker("option", "beforeShowDay", function(date){ |
| 1813 | 1813 | ' . implode(' ', $script_options_params) . '; |
@@ -1835,37 +1835,37 @@ discard block |
||
| 1835 | 1835 | </script>'; |
| 1836 | 1836 | $input_def['options'] .= $field_script; |
| 1837 | 1837 | } |
| 1838 | - if ( in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 1839 | - $input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select ' ); |
|
| 1838 | + if (in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 1839 | + $input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select '); |
|
| 1840 | 1840 | $input_def['type'] = ((!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend')) || (!is_admin() && empty($specific_argument['from'])) ? $attribute->frontend_input : $attribute->backend_input); |
| 1841 | 1841 | $input_def['valueToPut'] = 'index'; |
| 1842 | 1842 | |
| 1843 | 1843 | $select_display = self::get_select_output($attribute, $specific_argument); |
| 1844 | - if ( empty( $input_def[ 'options_label' ] ) && !empty( $specific_argument ) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend') ) ) { |
|
| 1845 | - $input_def[ 'options_label' ][ 'original' ] = true; |
|
| 1844 | + if (empty($input_def['options_label']) && !empty($specific_argument) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend'))) { |
|
| 1845 | + $input_def['options_label']['original'] = true; |
|
| 1846 | 1846 | } |
| 1847 | 1847 | $input_def['options'] .= $select_display['more_input']; |
| 1848 | 1848 | $input_def['possible_value'] = (!empty($select_display) && !empty($select_display['possible_value'])) ? $select_display['possible_value'] : ''; |
| 1849 | - if ( !is_admin() ) { |
|
| 1849 | + if (!is_admin()) { |
|
| 1850 | 1850 | $input_def['options'] .= '<input type="hidden" value="' . str_replace("\\", "", $input_def['value']) . '" name="wpshop_product_attribute_' . $attribute->code . '_current_value" id="wpshop_product_attribute_' . $attribute->code . '_current_value" />'; |
| 1851 | 1851 | } |
| 1852 | - if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) { |
|
| 1853 | - $input_def['options'] .= wpshop_display::display_template_element('select_list_multiple_bulk_action', array( 'CURRENT_ATTRIBUTE_ID' => $input_def['id'], 'CURRENT_ATTRIBUTE_CODE' => $attribute->code), array(), 'admin'); |
|
| 1852 | + if (in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) { |
|
| 1853 | + $input_def['options'] .= wpshop_display::display_template_element('select_list_multiple_bulk_action', array('CURRENT_ATTRIBUTE_ID' => $input_def['id'], 'CURRENT_ATTRIBUTE_CODE' => $attribute->code), array(), 'admin'); |
|
| 1854 | 1854 | } |
| 1855 | 1855 | } |
| 1856 | 1856 | $input_def['label_pointer'] = 'for="' . $input_def['id'] . '"'; |
| 1857 | - if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){ |
|
| 1857 | + if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) { |
|
| 1858 | 1858 | $input_def['label_pointer'] = ''; |
| 1859 | 1859 | } |
| 1860 | 1860 | |
| 1861 | 1861 | /* |
| 1862 | 1862 | * Specifc treatment for price attributes |
| 1863 | 1863 | */ |
| 1864 | - if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){ |
|
| 1864 | + if ((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC)) { |
|
| 1865 | 1865 | $input_def['option'] .= ' readonly="readonly" '; |
| 1866 | 1866 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1867 | 1867 | } |
| 1868 | - elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){ |
|
| 1868 | + elseif ((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT)) { |
|
| 1869 | 1869 | $input_def['option'] .= ' readonly="readonly" '; |
| 1870 | 1870 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1871 | 1871 | } |
@@ -1876,7 +1876,7 @@ discard block |
||
| 1876 | 1876 | |
| 1877 | 1877 | $input_def['label'] = str_replace("\\", "", $input_def['label']); |
| 1878 | 1878 | // $input_def['value'] = str_replace("\\", "", $input_def['value']); |
| 1879 | - $input_def['option'] .= ' class="wpshop_product_attribute_' . $attribute->code . $input_more_class . ' ' . (( is_admin() ) ? $attribute->backend_css_class : $attribute->frontend_css_class) . ( !empty($attribute->frontend_verification) ? ' wps_attr_verification_' . $attribute->frontend_verification : '' ) . '" '; |
|
| 1879 | + $input_def['option'] .= ' class="wpshop_product_attribute_' . $attribute->code . $input_more_class . ' ' . ((is_admin()) ? $attribute->backend_css_class : $attribute->frontend_css_class) . (!empty($attribute->frontend_verification) ? ' wps_attr_verification_' . $attribute->frontend_verification : '') . '" '; |
|
| 1880 | 1880 | $input_def['title'] = !empty($attribute->frontend_help_message) ? ' title="' . $attribute->frontend_help_message . '" ' : ''; |
| 1881 | 1881 | |
| 1882 | 1882 | if (($attribute->is_intrinsic == 'yes') && ((!empty($input_def['value'])) || ($input_def['value'] > 0))) { |
@@ -1887,13 +1887,13 @@ discard block |
||
| 1887 | 1887 | * Add the unit to the attribute if attribute configuration is set to yes |
| 1888 | 1888 | */ |
| 1889 | 1889 | if ($attribute->is_requiring_unit == 'yes') { |
| 1890 | - if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) { |
|
| 1890 | + if (in_array($attribute->code, $wpshop_price_attributes) || (WPSHOP_COST_OF_POSTAGE == $attribute->code)) { |
|
| 1891 | 1891 | $input_def['options'] .= ' <span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>'; |
| 1892 | 1892 | } |
| 1893 | - elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) { |
|
| 1893 | + elseif (in_array($attribute->code, $wpshop_weight_attributes)) { |
|
| 1894 | 1894 | $weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity'); |
| 1895 | - $query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
| 1896 | - $unity = $wpdb->get_var( $query ); |
|
| 1895 | + $query = $wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
| 1896 | + $unity = $wpdb->get_var($query); |
|
| 1897 | 1897 | $input_def['options'] .= ' <span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>'; |
| 1898 | 1898 | } |
| 1899 | 1899 | else { |
@@ -1901,11 +1901,11 @@ discard block |
||
| 1901 | 1901 | $unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id); |
| 1902 | 1902 | $unit_input_def['type'] = 'select'; |
| 1903 | 1903 | $unit_input_def['option'] = ' class="wpshop_attribute_unit_input chosen_select" '; |
| 1904 | - $unit_input_def['id'] = ( !empty($specific_argument['page_code']) ? $specific_argument['page_code'] : null ) . '_' . ( !empty($specific_argument['element_identifier']) ? $specific_argument['element_identifier'] : null ) . '_unit_attribute_' . $attribute->id; |
|
| 1904 | + $unit_input_def['id'] = (!empty($specific_argument['page_code']) ? $specific_argument['page_code'] : null) . '_' . (!empty($specific_argument['element_identifier']) ? $specific_argument['element_identifier'] : null) . '_unit_attribute_' . $attribute->id; |
|
| 1905 | 1905 | $unit_input_def['name'] = $attribute->code; |
| 1906 | 1906 | $unit_input_def['value'] = (!empty($attribute_value->unit_id) ? $attribute_value->unit_id : ''); |
| 1907 | - if($unit_input_def['value'] == ''){ |
|
| 1908 | - if ( $attribute->_default_unit > 0 ) { |
|
| 1907 | + if ($unit_input_def['value'] == '') { |
|
| 1908 | + if ($attribute->_default_unit > 0) { |
|
| 1909 | 1909 | $unit_input_def['value'] = $attribute->_default_unit; |
| 1910 | 1910 | } |
| 1911 | 1911 | else { |
@@ -1919,18 +1919,18 @@ discard block |
||
| 1919 | 1919 | /* |
| 1920 | 1920 | * Add indication on postage cost tax |
| 1921 | 1921 | */ |
| 1922 | - if ( $attribute->code == WPSHOP_COST_OF_POSTAGE ) { |
|
| 1922 | + if ($attribute->code == WPSHOP_COST_OF_POSTAGE) { |
|
| 1923 | 1923 | $input_def['options'] .= ' <span class="attribute_currency" >' . __('ATI', 'wpshop') . '</span>'; |
| 1924 | 1924 | } |
| 1925 | 1925 | |
| 1926 | 1926 | /* |
| 1927 | 1927 | * Create the field output |
| 1928 | 1928 | */ |
| 1929 | - if ( is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) { |
|
| 1930 | - $input_def['output'] = sprintf(__('You select this field to be defined by final customer into frontend part. To change this behaviour you have to change attribute option "%s"', 'wpshop'),__('is_user_defined', 'wpshop')); |
|
| 1929 | + if (is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) { |
|
| 1930 | + $input_def['output'] = sprintf(__('You select this field to be defined by final customer into frontend part. To change this behaviour you have to change attribute option "%s"', 'wpshop'), __('is_user_defined', 'wpshop')); |
|
| 1931 | 1931 | $input_def['options'] = ''; |
| 1932 | 1932 | $input_def['label_pointer'] = ''; |
| 1933 | - $input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "'; |
|
| 1933 | + $input_def['option'] = substr($input_def['option'], 0, -2) . ' wpshop_attributes_is_user_defined_admin_field "'; |
|
| 1934 | 1934 | $input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container'; |
| 1935 | 1935 | } |
| 1936 | 1936 | else { |
@@ -1945,7 +1945,7 @@ discard block |
||
| 1945 | 1945 | * @param string $output_from |
| 1946 | 1946 | * @return string The output for |
| 1947 | 1947 | */ |
| 1948 | - public static function display_attribute( $attribute_code, $output_from = 'admin', $output_specs = array() ) { |
|
| 1948 | + public static function display_attribute($attribute_code, $output_from = 'admin', $output_specs = array()) { |
|
| 1949 | 1949 | $output = ''; |
| 1950 | 1950 | /* Get the page code */ |
| 1951 | 1951 | $currentPageCode = !empty($output_specs['page_code']) ? $output_specs['page_code'] : ''; |
@@ -1956,17 +1956,17 @@ discard block |
||
| 1956 | 1956 | |
| 1957 | 1957 | /* Get attribute input definition */ |
| 1958 | 1958 | $current_value = (!empty($output_specs['current_value']) ? $output_specs['current_value'] : ''); |
| 1959 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from)) ); |
|
| 1959 | + $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from))); |
|
| 1960 | 1960 | |
| 1961 | 1961 | /* Create default output */ |
| 1962 | 1962 | $input_to_display = $input['output'] . $input['options']; |
| 1963 | 1963 | |
| 1964 | 1964 | /* Check if current field is linked to an addon, and if the addon is activated */ |
| 1965 | 1965 | $addons_list = unserialize(WPSHOP_ADDONS_LIST); |
| 1966 | - foreach ( $addons_list as $addon_code => $addon_def ) { |
|
| 1967 | - if ( in_array($attribute_code, $addon_def) ) { |
|
| 1968 | - if ( constant($addon_code) === false ) { |
|
| 1969 | - $input_to_display = '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_addons_option') . '" >' . __("This addon isn't activated, click to activate",'wpshop') . '</a>'; |
|
| 1966 | + foreach ($addons_list as $addon_code => $addon_def) { |
|
| 1967 | + if (in_array($attribute_code, $addon_def)) { |
|
| 1968 | + if (constant($addon_code) === false) { |
|
| 1969 | + $input_to_display = '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_addons_option') . '" >' . __("This addon isn't activated, click to activate", 'wpshop') . '</a>'; |
|
| 1970 | 1970 | } |
| 1971 | 1971 | } |
| 1972 | 1972 | } |
@@ -1991,11 +1991,11 @@ discard block |
||
| 1991 | 1991 | /* |
| 1992 | 1992 | * Display attribute option if applicable |
| 1993 | 1993 | */ |
| 1994 | - if ( $output_from == 'admin') { |
|
| 1995 | - $attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop') ) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 1994 | + if ($output_from == 'admin') { |
|
| 1995 | + $attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 1996 | 1996 | |
| 1997 | 1997 | $output['field'] .= ' |
| 1998 | - <div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($element_identifier, $attribute_def->code).'</div>'; |
|
| 1998 | + <div class="attribute_option_'.$attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($element_identifier, $attribute_def->code) . '</div>'; |
|
| 1999 | 1999 | } |
| 2000 | 2000 | |
| 2001 | 2001 | $output['field'] .= '</div>'; |
@@ -2013,36 +2013,36 @@ discard block |
||
| 2013 | 2013 | * |
| 2014 | 2014 | * @return string The html code to output directly tabs |
| 2015 | 2015 | */ |
| 2016 | - public static function attribute_of_entity_to_tab( $element_code, $element_id, $element_definition ) { |
|
| 2016 | + public static function attribute_of_entity_to_tab($element_code, $element_id, $element_definition) { |
|
| 2017 | 2017 | $attributeContentOutput = ''; |
| 2018 | 2018 | |
| 2019 | 2019 | /** Get the different attribute affected to the entity */ |
| 2020 | 2020 | $element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue($element_code, $element_id, WPSHOP_CURRENT_LOCALE, '', 'frontend'); |
| 2021 | 2021 | |
| 2022 | 2022 | |
| 2023 | - if ( is_array($element_atribute_list) && (count($element_atribute_list) > 0) ) { |
|
| 2024 | - foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) { |
|
| 2023 | + if (is_array($element_atribute_list) && (count($element_atribute_list) > 0)) { |
|
| 2024 | + foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { |
|
| 2025 | 2025 | $attributeToShowNumber = 0; |
| 2026 | 2026 | $attributeOutput = ''; |
| 2027 | 2027 | |
| 2028 | - foreach ( $attributeSetContent['attributes'] as $attributeId => $attributeDefinition ) { |
|
| 2028 | + foreach ($attributeSetContent['attributes'] as $attributeId => $attributeDefinition) { |
|
| 2029 | 2029 | |
| 2030 | 2030 | /** Check the value type to check if empty or not */ |
| 2031 | - if ( $attributeDefinition['data_type'] == 'int' ) { |
|
| 2031 | + if ($attributeDefinition['data_type'] == 'int') { |
|
| 2032 | 2032 | $attributeDefinition['value'] = (int)$attributeDefinition['value']; |
| 2033 | 2033 | } |
| 2034 | - else if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2034 | + else if ($attributeDefinition['data_type'] == 'decimal') { |
|
| 2035 | 2035 | $attributeDefinition['value'] = (float)$attributeDefinition['value']; |
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | 2038 | /** Check if the attribute is set to be displayed in frontend */ |
| 2039 | - $attribute_display_state = wpshop_attributes::check_attribute_display( $attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); |
|
| 2039 | + $attribute_display_state = wpshop_attributes::check_attribute_display($attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); |
|
| 2040 | 2040 | |
| 2041 | 2041 | /** Output the field if the value is not null */ |
| 2042 | 2042 | |
| 2043 | - if ( (is_array($attributeDefinition['value']) || ( !empty($attributeDefinition['value']) ) ) && $attribute_display_state) { |
|
| 2043 | + if ((is_array($attributeDefinition['value']) || (!empty($attributeDefinition['value']))) && $attribute_display_state) { |
|
| 2044 | 2044 | |
| 2045 | - $attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition ); |
|
| 2045 | + $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); |
|
| 2046 | 2046 | $attribute_value = $attribute_display[0]; |
| 2047 | 2047 | $attributeDefinition['value'] = $attribute_display[1]; |
| 2048 | 2048 | $attribute_unit_list = $attribute_display[2]; |
@@ -2053,8 +2053,8 @@ discard block |
||
| 2053 | 2053 | $tpl_component['PDT_ENTITY_CODE'] = self::currentPageCode; |
| 2054 | 2054 | $tpl_component['ATTRIBUTE_CODE'] = $attributeDefinition['attribute_code']; |
| 2055 | 2055 | $tpl_component['ATTRIBUTE_LABEL'] = __($attributeDefinition['frontend_label'], 'wpshop'); |
| 2056 | - $tpl_component['ATTRIBUTE_VALUE'] = ( !is_array($attribute_value) ) ? stripslashes($attribute_value) : $attribute_value; |
|
| 2057 | - $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; |
|
| 2056 | + $tpl_component['ATTRIBUTE_VALUE'] = (!is_array($attribute_value)) ? stripslashes($attribute_value) : $attribute_value; |
|
| 2057 | + $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; |
|
| 2058 | 2058 | |
| 2059 | 2059 | /** Build template */ |
| 2060 | 2060 | $attributeOutput .= wpshop_display::display_template_element($template_part, $tpl_component); |
@@ -2065,9 +2065,9 @@ discard block |
||
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | /** Check if the attribute set section is set to be displayed in frontend */ |
| 2068 | - $attribute_set_display_state = wpshop_attributes::check_attribute_display( $attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); |
|
| 2068 | + $attribute_set_display_state = wpshop_attributes::check_attribute_display($attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); |
|
| 2069 | 2069 | |
| 2070 | - if ( !$attribute_set_display_state ) { |
|
| 2070 | + if (!$attribute_set_display_state) { |
|
| 2071 | 2071 | $attributeToShowNumber = 0; |
| 2072 | 2072 | $attributeOutput = ''; |
| 2073 | 2073 | } |
@@ -2077,8 +2077,8 @@ discard block |
||
| 2077 | 2077 | |
| 2078 | 2078 | /** Gestion de l'affichage */ |
| 2079 | 2079 | $tab_list = $content_list = ''; |
| 2080 | - foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) { |
|
| 2081 | - if ( !empty($attributeSetContent['count']) > 0 ) { |
|
| 2080 | + foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { |
|
| 2081 | + if (!empty($attributeSetContent['count']) > 0) { |
|
| 2082 | 2082 | /** Template parameters */ |
| 2083 | 2083 | $template_part = 'product_attribute_tabs'; |
| 2084 | 2084 | $tpl_component = array(); |
@@ -2087,7 +2087,7 @@ discard block |
||
| 2087 | 2087 | |
| 2088 | 2088 | /** Build template */ |
| 2089 | 2089 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2090 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2090 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2091 | 2091 | /* Include the old way template part */ |
| 2092 | 2092 | ob_start(); |
| 2093 | 2093 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2107,7 +2107,7 @@ discard block |
||
| 2107 | 2107 | |
| 2108 | 2108 | /** Build template */ |
| 2109 | 2109 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2110 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2110 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2111 | 2111 | /* Include the old way template part */ |
| 2112 | 2112 | ob_start(); |
| 2113 | 2113 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2121,16 +2121,16 @@ discard block |
||
| 2121 | 2121 | } |
| 2122 | 2122 | } |
| 2123 | 2123 | |
| 2124 | - if ( $tab_list != '' ) { |
|
| 2124 | + if ($tab_list != '') { |
|
| 2125 | 2125 | /** Template parameters */ |
| 2126 | 2126 | $template_part = 'product_attribute_container'; |
| 2127 | 2127 | $tpl_component = array(); |
| 2128 | - $tpl_component['PDT_TABS'] = apply_filters( 'wpshop_extra_tabs_menu_before', '' ).$tab_list.apply_filters( 'wpshop_extra_tabs_menu_after', '' ); |
|
| 2129 | - $tpl_component['PDT_TAB_DETAIL'] = apply_filters( 'wpshop_extra_tabs_content_before', '' ).$content_list.apply_filters( 'wpshop_extra_tabs_content_after', '' ); |
|
| 2128 | + $tpl_component['PDT_TABS'] = apply_filters('wpshop_extra_tabs_menu_before', '') . $tab_list . apply_filters('wpshop_extra_tabs_menu_after', ''); |
|
| 2129 | + $tpl_component['PDT_TAB_DETAIL'] = apply_filters('wpshop_extra_tabs_content_before', '') . $content_list . apply_filters('wpshop_extra_tabs_content_after', ''); |
|
| 2130 | 2130 | |
| 2131 | 2131 | /** Build template */ |
| 2132 | 2132 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2133 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2133 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2134 | 2134 | /* Include the old way template part */ |
| 2135 | 2135 | ob_start(); |
| 2136 | 2136 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2153,9 +2153,9 @@ discard block |
||
| 2153 | 2153 | * @param unknown_type $attributeDefinition |
| 2154 | 2154 | * @return multitype:Ambigous <unknown, string> Ambigous <string, string> Ambigous <> |
| 2155 | 2155 | */ |
| 2156 | - public static function wps_attribute_values_display( $attributeDefinition ) { |
|
| 2156 | + public static function wps_attribute_values_display($attributeDefinition) { |
|
| 2157 | 2157 | $attribute_unit_list = ''; |
| 2158 | - if ( !empty($attributeDefinition['unit']) ) { |
|
| 2158 | + if (!empty($attributeDefinition['unit'])) { |
|
| 2159 | 2159 | /** Template parameters */ |
| 2160 | 2160 | $template_part = 'product_attribute_unit'; |
| 2161 | 2161 | $tpl_component = array(); |
@@ -2167,31 +2167,31 @@ discard block |
||
| 2167 | 2167 | } |
| 2168 | 2168 | |
| 2169 | 2169 | $attribute_value = $attributeDefinition['value']; |
| 2170 | - if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2171 | - $attribute_value =(is_numeric($attribute_value) ) ? number_format($attribute_value, 2, ',', '') : $attribute_value; |
|
| 2172 | - if ( in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) { |
|
| 2173 | - if ( $attributeDefinition['is_requiring_unit'] == 'yes' ) { |
|
| 2170 | + if ($attributeDefinition['data_type'] == 'decimal') { |
|
| 2171 | + $attribute_value = (is_numeric($attribute_value)) ? number_format($attribute_value, 2, ',', '') : $attribute_value; |
|
| 2172 | + if (in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES))) { |
|
| 2173 | + if ($attributeDefinition['is_requiring_unit'] == 'yes') { |
|
| 2174 | 2174 | $attribute_unit_list = ' ' . wpshop_tools::wpshop_get_currency(); |
| 2175 | 2175 | } |
| 2176 | 2176 | $attributeDefinition['value'] = wpshop_display::format_field_output('wpshop_product_price', $attributeDefinition['value']); |
| 2177 | 2177 | } |
| 2178 | 2178 | } |
| 2179 | - if ( $attributeDefinition['data_type'] == 'datetime' ) { |
|
| 2179 | + if ($attributeDefinition['data_type'] == 'datetime') { |
|
| 2180 | 2180 | $attribute_value = mysql2date('d/m/Y', $attributeDefinition['value'], true); |
| 2181 | 2181 | } |
| 2182 | - if ( $attributeDefinition['backend_input'] == 'select' ) { |
|
| 2182 | + if ($attributeDefinition['backend_input'] == 'select') { |
|
| 2183 | 2183 | $attribute_value = wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
| 2184 | 2184 | } |
| 2185 | 2185 | /** Manage differently if its an array of values or not */ |
| 2186 | - if ( $attributeDefinition['backend_input'] == 'multiple-select') { |
|
| 2186 | + if ($attributeDefinition['backend_input'] == 'multiple-select') { |
|
| 2187 | 2187 | $attribute_value = ''; |
| 2188 | - if ( is_array($attributeDefinition['value']) ) { |
|
| 2188 | + if (is_array($attributeDefinition['value'])) { |
|
| 2189 | 2189 | foreach ($attributeDefinition['value'] as $v) { |
| 2190 | - $attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
|
| 2190 | + $attribute_value .= ' / ' . wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
|
| 2191 | 2191 | } |
| 2192 | 2192 | } |
| 2193 | - else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2194 | - $attribute_value = substr($attribute_value,3); |
|
| 2193 | + else $attribute_value = ' / ' . wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2194 | + $attribute_value = substr($attribute_value, 3); |
|
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | 2197 | return array($attribute_value, $attributeDefinition['value'], $attribute_unit_list); |
@@ -2201,13 +2201,13 @@ discard block |
||
| 2201 | 2201 | * Manage display for the output when user uses a shortcode for attributes display |
| 2202 | 2202 | * @param array $shorcode_args The list of argument passed through the shortcode |
| 2203 | 2203 | */ |
| 2204 | - function wpshop_attributes_shortcode( $shorcode_args ) { |
|
| 2204 | + function wpshop_attributes_shortcode($shorcode_args) { |
|
| 2205 | 2205 | $output = ''; |
| 2206 | 2206 | /* |
| 2207 | 2207 | * Read the attribute list |
| 2208 | 2208 | */ |
| 2209 | - foreach ( explode(', ', $shorcode_args['attributes']) as $attribute_code ) { |
|
| 2210 | - $attribute_output_def = wpshop_attributes::display_attribute( $attribute_code, $shorcode_args['from'] ); |
|
| 2209 | + foreach (explode(', ', $shorcode_args['attributes']) as $attribute_code) { |
|
| 2210 | + $attribute_output_def = wpshop_attributes::display_attribute($attribute_code, $shorcode_args['from']); |
|
| 2211 | 2211 | $output .= $attribute_output_def['field']; |
| 2212 | 2212 | } |
| 2213 | 2213 | |
@@ -2229,7 +2229,7 @@ discard block |
||
| 2229 | 2229 | $productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails($attributeSetId, "'valid','deleted'"); |
| 2230 | 2230 | $attribute_specification = array('page_code' => $currentPageCode, 'element_identifier' => $itemToEdit, 'field_id' => $currentPageCode . '_' . $itemToEdit . '_'); |
| 2231 | 2231 | |
| 2232 | - if ( count($productAttributeSetDetails) > 0 ) { |
|
| 2232 | + if (count($productAttributeSetDetails) > 0) { |
|
| 2233 | 2233 | /* Read the attribute list in order to output */ |
| 2234 | 2234 | $shortcodes_attr = ''; |
| 2235 | 2235 | $shortcodes_to_display = false; |
@@ -2239,80 +2239,80 @@ discard block |
||
| 2239 | 2239 | |
| 2240 | 2240 | $shortcodes = $currentTabContent = ''; |
| 2241 | 2241 | $output_nb = 0; |
| 2242 | - if(count($productAttributeSetDetail['attribut']) >= 1){ |
|
| 2243 | - foreach($productAttributeSetDetail['attribut'] as $attribute){ |
|
| 2242 | + if (count($productAttributeSetDetail['attribut']) >= 1) { |
|
| 2243 | + foreach ($productAttributeSetDetail['attribut'] as $attribute) { |
|
| 2244 | 2244 | |
| 2245 | - if ( !empty($attribute->id) ) { |
|
| 2246 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2245 | + if (!empty($attribute->id)) { |
|
| 2246 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2247 | 2247 | $attribute_set_id_is_present = true; |
| 2248 | 2248 | } |
| 2249 | 2249 | |
| 2250 | 2250 | /** Generic part for attribute field output */ |
| 2251 | 2251 | $value = wpshop_attributes::getAttributeValueForEntityInSet($attribute->data_type, $attribute->id, wpshop_entities::get_entity_identifier_from_code($currentPageCode), $itemToEdit, array('intrinsic' => $attribute->is_intrinsic, 'backend_input' => $attribute->backend_input)); |
| 2252 | - $product_meta = get_post_meta( $itemToEdit, '_wpshop_product_metadata', true); |
|
| 2252 | + $product_meta = get_post_meta($itemToEdit, '_wpshop_product_metadata', true); |
|
| 2253 | 2253 | |
| 2254 | 2254 | /** Check if value is empty and get value in meta if not empty */ |
| 2255 | 2255 | $value = (empty($value) && !empty($product_meta[$attribute->code])) ? $product_meta[$attribute->code] : (!empty($value) ? $value : null); |
| 2256 | 2256 | |
| 2257 | 2257 | /* Manage specific field as the attribute_set_id in product form */ |
| 2258 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2258 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2259 | 2259 | |
| 2260 | 2260 | $value = empty($value) ? $attributeSetId : $value; |
| 2261 | 2261 | } |
| 2262 | 2262 | $attribute_specification['current_value'] = $value; |
| 2263 | - $attribute_output_def = apply_filters( 'wpshop_attribute_output_def', wpshop_attributes::display_attribute( $attribute->code, 'admin', $attribute_specification), $itemToEdit ); |
|
| 2264 | - if ( ($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id') ) { |
|
| 2263 | + $attribute_output_def = apply_filters('wpshop_attribute_output_def', wpshop_attributes::display_attribute($attribute->code, 'admin', $attribute_specification), $itemToEdit); |
|
| 2264 | + if (($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id')) { |
|
| 2265 | 2265 | $currentTabContent .= $attribute_output_def['field']; |
| 2266 | - $shortcode_code_def=array(); |
|
| 2267 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; |
|
| 2268 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; |
|
| 2269 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; |
|
| 2270 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; |
|
| 2266 | + $shortcode_code_def = array(); |
|
| 2267 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; |
|
| 2268 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; |
|
| 2269 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; |
|
| 2270 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; |
|
| 2271 | 2271 | ob_start(); |
| 2272 | - wps_shortcodes_ctr::output_shortcode('attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])).' wpshop_cls'); |
|
| 2273 | - $shortcodes .= '<li class="wpshop_cls" >'.sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>'.__($attribute_output_def['field_definition']['label'], 'wpshop').'</span>').ob_get_contents().'</li>'; |
|
| 2272 | + wps_shortcodes_ctr::output_shortcode('attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])) . ' wpshop_cls'); |
|
| 2273 | + $shortcodes .= '<li class="wpshop_cls" >' . sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>' . __($attribute_output_def['field_definition']['label'], 'wpshop') . '</span>') . ob_get_contents() . '</li>'; |
|
| 2274 | 2274 | ob_end_clean(); |
| 2275 | 2275 | } |
| 2276 | 2276 | else { |
| 2277 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2277 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2278 | 2278 | $attribute_output_def['field_definition']['type'] = 'hidden'; |
| 2279 | 2279 | } |
| 2280 | - $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); |
|
| 2280 | + $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | $output_nb++; |
| 2283 | 2283 | } |
| 2284 | 2284 | } |
| 2285 | 2285 | |
| 2286 | - $currentTabContent = apply_filters( 'wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail ); |
|
| 2286 | + $currentTabContent = apply_filters('wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail); |
|
| 2287 | 2287 | |
| 2288 | 2288 | $shortcode_code['attributes_set']['main_code'] = 'wpshop_att_group'; |
| 2289 | 2289 | $shortcode_code['attributes_set']['attrs_exemple']['pid'] = $itemToEdit; |
| 2290 | 2290 | $shortcode_code['attributes_set']['attrs_exemple']['sid'] = $productAttributeSetDetail['id']; |
| 2291 | 2291 | ob_start(); |
| 2292 | - wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_'.str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])).' cls'); |
|
| 2293 | - $attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>'.$productAttributeSetDetail['name'].'</span>').ob_get_contents().'<ul class="" >'.$shortcodes.'</ul>'; |
|
| 2292 | + wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_' . str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])) . ' cls'); |
|
| 2293 | + $attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>' . $productAttributeSetDetail['name'] . '</span>') . ob_get_contents() . '<ul class="" >' . $shortcodes . '</ul>'; |
|
| 2294 | 2294 | ob_end_clean(); |
| 2295 | 2295 | |
| 2296 | - if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' ) |
|
| 2297 | - $currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>'; |
|
| 2296 | + if (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box') |
|
| 2297 | + $currentTabContent .= '<div class="wpshop_cls" ><strong>' . __('Shortcodes', 'wpshop') . '</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>'; |
|
| 2298 | 2298 | else |
| 2299 | 2299 | $shortcodes_attr .= $attribute_group_display; |
| 2300 | 2300 | |
| 2301 | - if ( $output_nb <= 0 ) { |
|
| 2301 | + if ($output_nb <= 0) { |
|
| 2302 | 2302 | $currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop'); |
| 2303 | 2303 | } |
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | 2306 | if ($output_nb > 0) { |
| 2307 | 2307 | $shortcodes_to_display = true; |
| 2308 | - if ( $outputType == 'box' ) { |
|
| 2308 | + if ($outputType == 'box') { |
|
| 2309 | 2309 | $box['box'][$productAttributeSetDetail['code']] = $productAttributeSetDetail['name']; |
| 2310 | - $box['box'][$productAttributeSetDetail['code'].'_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; |
|
| 2310 | + $box['box'][$productAttributeSetDetail['code'] . '_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; |
|
| 2311 | 2311 | $box['boxContent'][$productAttributeSetDetail['code']] = ' |
| 2312 | 2312 | <div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . ' |
| 2313 | 2313 | </div><div class="wpshop_cls" ></div>'; |
| 2314 | 2314 | } |
| 2315 | - else if ( $outputType == 'column' ) { |
|
| 2315 | + else if ($outputType == 'column') { |
|
| 2316 | 2316 | $currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent); |
| 2317 | 2317 | $currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent); |
| 2318 | 2318 | |
@@ -2322,11 +2322,11 @@ discard block |
||
| 2322 | 2322 | } |
| 2323 | 2323 | } |
| 2324 | 2324 | |
| 2325 | - if( !$attribute_set_id_is_present ) { |
|
| 2325 | + if (!$attribute_set_id_is_present) { |
|
| 2326 | 2326 | /* Get attribute definition */ |
| 2327 | 2327 | $attribute_def = wpshop_attributes::getElement('product_attribute_set_id', "'valid'", 'code'); |
| 2328 | 2328 | /* Get attribute input definition */ |
| 2329 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin')) ); |
|
| 2329 | + $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin'))); |
|
| 2330 | 2330 | $input['type'] = 'hidden'; |
| 2331 | 2331 | |
| 2332 | 2332 | $box['boxMore'] = wpshop_form::check_input_type($input, $input['input_domain']); |
@@ -2337,13 +2337,13 @@ discard block |
||
| 2337 | 2337 | $dialog_identifier = 'wpshop_new_attribute_option_value_add'; |
| 2338 | 2338 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 2339 | 2339 | ob_start(); |
| 2340 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 2340 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 2341 | 2341 | $box['boxMore'] .= ob_get_contents(); |
| 2342 | 2342 | ob_end_clean(); |
| 2343 | 2343 | $box['boxMore'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />'; |
| 2344 | 2344 | |
| 2345 | - if ( $shortcodes_to_display ) { |
|
| 2346 | - switch ( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE ) { |
|
| 2345 | + if ($shortcodes_to_display) { |
|
| 2346 | + switch (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE) { |
|
| 2347 | 2347 | case 'fixed-tab': |
| 2348 | 2348 | case 'movable-tab': |
| 2349 | 2349 | if ($outputType == 'box') { |
@@ -2351,7 +2351,7 @@ discard block |
||
| 2351 | 2351 | $box['boxContent']['shortcode'] = $shortcodes_attr; |
| 2352 | 2352 | $box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE; |
| 2353 | 2353 | } |
| 2354 | - else{ |
|
| 2354 | + else { |
|
| 2355 | 2355 | $box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop'); |
| 2356 | 2356 | $box['columnContent']['shortcode'] = $shortcodes_attr; |
| 2357 | 2357 | } |
@@ -2375,12 +2375,12 @@ discard block |
||
| 2375 | 2375 | $ouput['more_input'] = ''; |
| 2376 | 2376 | |
| 2377 | 2377 | $attribute_default_value = $attribute->default_value; |
| 2378 | - if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) { |
|
| 2378 | + if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) { |
|
| 2379 | 2379 | $tmp_default_value = unserialize($attribute->default_value); |
| 2380 | 2380 | $attribute_default_value = !empty($tmp_default_value["default_value"]) ? $tmp_default_value["default_value"] : null; |
| 2381 | 2381 | } |
| 2382 | 2382 | |
| 2383 | - if ( $attribute->data_type_to_use == 'custom') { |
|
| 2383 | + if ($attribute->data_type_to_use == 'custom') { |
|
| 2384 | 2384 | $query = $wpdb->prepare("SELECT id, label, value, '' as name FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' ORDER BY position", $attribute->id); |
| 2385 | 2385 | $attribute_select_options = $wpdb->get_results($query); |
| 2386 | 2386 | |
@@ -2392,11 +2392,11 @@ discard block |
||
| 2392 | 2392 | // } |
| 2393 | 2393 | endforeach; |
| 2394 | 2394 | } |
| 2395 | - elseif ( $attribute->data_type_to_use == 'internal') { |
|
| 2395 | + elseif ($attribute->data_type_to_use == 'internal') { |
|
| 2396 | 2396 | switch ($attribute_default_value) { |
| 2397 | 2397 | case 'users': |
| 2398 | 2398 | $users = get_users('orderby=nicename'); |
| 2399 | - foreach($users as $user){ |
|
| 2399 | + foreach ($users as $user) { |
|
| 2400 | 2400 | $attribute_select_options_list[$user->ID] = $user->display_name; |
| 2401 | 2401 | } |
| 2402 | 2402 | break; |
@@ -2405,11 +2405,11 @@ discard block |
||
| 2405 | 2405 | $wpshop_attr_custom_post_query = new WP_Query(array( |
| 2406 | 2406 | 'post_type' => $attribute_default_value, |
| 2407 | 2407 | 'posts_per_page' => -1, |
| 2408 | - 'post_status' => array( 'publish', 'draft', 'future' ) , |
|
| 2408 | + 'post_status' => array('publish', 'draft', 'future'), |
|
| 2409 | 2409 | )); |
| 2410 | 2410 | |
| 2411 | - if($wpshop_attr_custom_post_query->have_posts()): |
|
| 2412 | - foreach($wpshop_attr_custom_post_query->posts as $post){ |
|
| 2411 | + if ($wpshop_attr_custom_post_query->have_posts()): |
|
| 2412 | + foreach ($wpshop_attr_custom_post_query->posts as $post) { |
|
| 2413 | 2413 | $attribute_select_options_list[$post->ID] = $post->post_title; |
| 2414 | 2414 | } |
| 2415 | 2415 | endif; |
@@ -2420,27 +2420,27 @@ discard block |
||
| 2420 | 2420 | |
| 2421 | 2421 | /* There is no value existing for this value */ |
| 2422 | 2422 | if (empty($attribute_select_options_list)) : |
| 2423 | - $ouput['more_input'].=__('Nothing found for this field', 'wpshop'); |
|
| 2423 | + $ouput['more_input'] .= __('Nothing found for this field', 'wpshop'); |
|
| 2424 | 2424 | else: |
| 2425 | 2425 | /* Add a default value to the combobox list */ |
| 2426 | 2426 | $default_value_is_serial = false; |
| 2427 | 2427 | $attribute_list_first_element = $attribute->default_value; |
| 2428 | - if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) { |
|
| 2428 | + if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) { |
|
| 2429 | 2429 | $default_value_is_serial = true; |
| 2430 | 2430 | $tmp_default_value = unserialize($attribute->default_value); |
| 2431 | 2431 | $attribute_list_first_element = $tmp_default_value["field_options"]["label_for_first_item"]; |
| 2432 | 2432 | } |
| 2433 | 2433 | //if ( !in_array($attribute->frontend_input, array('radio', 'checkbox')) || ($attribute_list_first_element != 'none') ) $ouput['possible_value'][] = ($default_value_is_serial && !empty($attribute_list_first_element)) ? $attribute_list_first_element : __('Choose a value', 'wpshop'); |
| 2434 | - foreach ( $attribute_select_options_list as $option_key => $option_value ) { |
|
| 2434 | + foreach ($attribute_select_options_list as $option_key => $option_value) { |
|
| 2435 | 2435 | $ouput['possible_value'][$option_key] = stripslashes($option_value); |
| 2436 | 2436 | } |
| 2437 | 2437 | endif; |
| 2438 | 2438 | |
| 2439 | 2439 | /* Add a extra element to create a new element into list */ |
| 2440 | - if ( is_admin() && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) { |
|
| 2440 | + if (is_admin() && (empty($provenance['from']) || ($provenance['from'] != 'frontend'))) { |
|
| 2441 | 2441 | /** $ouput['more_input'] .= '<img src="'.WPSHOP_MEDIAS_ICON_URL.'add.png" id="new_value_pict_' . $attribute->code . '" alt="'.__('Add a new value for this attribute', 'wpshop').'" title="'.__('Add a new value for this attribute', 'wpshop').'" class="wpshop_icons wpshop_icons_add_new_value_to_option_list wpshop_icons_add_new_value_to_option_list_'.$attribute->code.'" />'; */ |
| 2442 | 2442 | } |
| 2443 | - else if ( 'yes' == $attribute->is_used_in_quick_add_form ) { |
|
| 2443 | + else if ('yes' == $attribute->is_used_in_quick_add_form) { |
|
| 2444 | 2444 | $tpl_component = array(); |
| 2445 | 2445 | $tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']'; |
| 2446 | 2446 | $ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component); |
@@ -2449,11 +2449,11 @@ discard block |
||
| 2449 | 2449 | return $ouput; |
| 2450 | 2450 | } |
| 2451 | 2451 | |
| 2452 | - public static function get_affected_value_for_list( $attribute_code, $element_id, $attribute_data_type ) { |
|
| 2452 | + public static function get_affected_value_for_list($attribute_code, $element_id, $attribute_data_type) { |
|
| 2453 | 2453 | global $wpdb; |
| 2454 | 2454 | $affected_value = array(); |
| 2455 | 2455 | |
| 2456 | - if ( $attribute_data_type == 'custom' ) { |
|
| 2456 | + if ($attribute_data_type == 'custom') { |
|
| 2457 | 2457 | $query = $wpdb->prepare(" |
| 2458 | 2458 | SELECT ATT_SELECT_OPTIONS_VALUE.id AS chosen_val, ATT_SELECT_OPTIONS_VALUE.value |
| 2459 | 2459 | FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT |
@@ -2475,20 +2475,20 @@ discard block |
||
| 2475 | 2475 | } |
| 2476 | 2476 | |
| 2477 | 2477 | $attribute_values_for_variations = $wpdb->get_results($query); |
| 2478 | - foreach ( $attribute_values_for_variations as $attribute_def ) { |
|
| 2479 | - $affected_value[] = (int) $attribute_def->chosen_val; |
|
| 2478 | + foreach ($attribute_values_for_variations as $attribute_def) { |
|
| 2479 | + $affected_value[] = (int)$attribute_def->chosen_val; |
|
| 2480 | 2480 | } |
| 2481 | 2481 | |
| 2482 | 2482 | return $affected_value; |
| 2483 | 2483 | } |
| 2484 | 2484 | |
| 2485 | 2485 | public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') { |
| 2486 | - switch($attr_code){ |
|
| 2486 | + switch ($attr_code) { |
|
| 2487 | 2487 | case 'is_downloadable_': |
| 2488 | - $option = get_post_meta($item['item_id'], 'attribute_option_'.$attr_code, true); |
|
| 2489 | - switch($attr_option){ |
|
| 2488 | + $option = get_post_meta($item['item_id'], 'attribute_option_' . $attr_code, true); |
|
| 2489 | + switch ($attr_option) { |
|
| 2490 | 2490 | case 'file_url': |
| 2491 | - if(in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_'.$attr_code]) && (strtolower(__($item['item_'.$attr_code], 'wpshop')) == __('yes','wpshop'))) ){ |
|
| 2491 | + if (in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_' . $attr_code]) && (strtolower(__($item['item_' . $attr_code], 'wpshop')) == __('yes', 'wpshop')))) { |
|
| 2492 | 2492 | $file_url = isset($option[$attr_option]) ? $option[$attr_option] : false; |
| 2493 | 2493 | return $file_url; |
| 2494 | 2494 | } |
@@ -2501,17 +2501,17 @@ discard block |
||
| 2501 | 2501 | |
| 2502 | 2502 | public static function get_attribute_option_fields($postid, $code) { |
| 2503 | 2503 | |
| 2504 | - switch($code){ |
|
| 2504 | + switch ($code) { |
|
| 2505 | 2505 | case 'is_downloadable_': |
| 2506 | - $data = get_post_meta($postid, 'attribute_option_'.$code, true); |
|
| 2507 | - $data['file_url'] = !empty($data['file_url'])?$data['file_url']:__('No file selected', 'wpshop'); |
|
| 2508 | - $fields = wp_nonce_field( 'ajax_wpshop_show_downloadable_interface_in_admin'.$postid, '_show_downloadable_interface_in_admin_wpnonce', true, false ); |
|
| 2506 | + $data = get_post_meta($postid, 'attribute_option_' . $code, true); |
|
| 2507 | + $data['file_url'] = !empty($data['file_url']) ? $data['file_url'] : __('No file selected', 'wpshop'); |
|
| 2508 | + $fields = wp_nonce_field('ajax_wpshop_show_downloadable_interface_in_admin' . $postid, '_show_downloadable_interface_in_admin_wpnonce', true, false); |
|
| 2509 | 2509 | $fields .= '<div class="wpshop_form_label alignleft"> </div> |
| 2510 | 2510 | <div class="wpshop_form_input_element alignleft"> |
| 2511 | - <div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid.'" title="' .__('Send the downloadable file', 'wpshop'). '"></div> |
|
| 2512 | - <a data-nonce="' . wp_create_nonce( "ajax_wpshop_fill_the_downloadable_dialog".$postid ) . '" class="send_downlodable_file wps-bton-first-mini-rounded">' .__('Send a file', 'wpshop').'</a> |
|
| 2513 | - <input type="hidden" class="product_identifer_field" value="' .( !empty($postid) ? esc_attr( $postid ) : '') . '" /><br/><u>'.__('File url','wpshop').' :</u> |
|
| 2514 | - <div class="is_downloadable_statut_'.$postid.'"><a href="' .$data['file_url']. '" target="_blank" download>'.basename($data['file_url']).'</a></div> |
|
| 2511 | + <div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid . '" title="' . __('Send the downloadable file', 'wpshop') . '"></div> |
|
| 2512 | + <a data-nonce="' . wp_create_nonce("ajax_wpshop_fill_the_downloadable_dialog" . $postid) . '" class="send_downlodable_file wps-bton-first-mini-rounded">' . __('Send a file', 'wpshop') . '</a> |
|
| 2513 | + <input type="hidden" class="product_identifer_field" value="' .(!empty($postid) ? esc_attr($postid) : '') . '" /><br/><u>' . __('File url', 'wpshop') . ' :</u> |
|
| 2514 | + <div class="is_downloadable_statut_'.$postid . '"><a href="' . $data['file_url'] . '" target="_blank" download>' . basename($data['file_url']) . '</a></div> |
|
| 2515 | 2515 | </div>'; |
| 2516 | 2516 | return $fields; |
| 2517 | 2517 | break; |
@@ -2536,8 +2536,8 @@ discard block |
||
| 2536 | 2536 | $attribute_value_content = ''; |
| 2537 | 2537 | |
| 2538 | 2538 | $atributes = self::getElement($attribute_code, "'valid'", 'code'); |
| 2539 | - if ( !empty($atributes) ) { |
|
| 2540 | - $attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id); |
|
| 2539 | + if (!empty($atributes)) { |
|
| 2540 | + $attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id); |
|
| 2541 | 2541 | } |
| 2542 | 2542 | |
| 2543 | 2543 | return $attribute_value_content; |
@@ -2549,14 +2549,14 @@ discard block |
||
| 2549 | 2549 | * @param mixed $value |
| 2550 | 2550 | * @return string The complete interface allowing to manage datetime attribute field |
| 2551 | 2551 | */ |
| 2552 | - function attribute_type_date_config( $value ) { |
|
| 2552 | + function attribute_type_date_config($value) { |
|
| 2553 | 2553 | $date_config_output = ''; |
| 2554 | 2554 | |
| 2555 | 2555 | $input_def['name'] = 'default_value'; |
| 2556 | 2556 | $input_def['type'] = 'checkbox'; |
| 2557 | 2557 | $input_def['possible_value'] = 'date_of_current_day'; |
| 2558 | 2558 | $input_def['value'] = !empty($value['default_value']) ? $value['default_value'] : ''; |
| 2559 | - $input_def['options_label']['custom'] = ' ' . __('Use the date of the day as default value', 'wpshop') . ' <a href="#" title="'.__('Check this box for using date of the day as value when editing a product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 2559 | + $input_def['options_label']['custom'] = ' ' . __('Use the date of the day as default value', 'wpshop') . ' <a href="#" title="' . __('Check this box for using date of the day as value when editing a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 2560 | 2560 | $date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2561 | 2561 | |
| 2562 | 2562 | $input_def = array(); |
@@ -2565,35 +2565,35 @@ discard block |
||
| 2565 | 2565 | $input_def['type'] = 'checkbox'; |
| 2566 | 2566 | $input_def['valueToPut'] = 'index'; |
| 2567 | 2567 | $input_def['value'] = !empty($value['field_options']['attribute_type_date_options_day_to_show']) ? $value['field_options']['attribute_type_date_options_day_to_show'] : ''; |
| 2568 | - $input_def['possible_value'] = array('1' => ' ' . __('Monday', 'wpshop'), '2' => ' ' .__('Tuesday', 'wpshop'), '3' => ' ' .__('Wednesday', 'wpshop'), '4' => ' ' .__('Thursday', 'wpshop'), '5' => ' ' .__('Friday', 'wpshop'), '6' => ' ' .__('Saturday', 'wpshop'), '0' => ' ' .__('Sunday', 'wpshop')); |
|
| 2568 | + $input_def['possible_value'] = array('1' => ' ' . __('Monday', 'wpshop'), '2' => ' ' . __('Tuesday', 'wpshop'), '3' => ' ' . __('Wednesday', 'wpshop'), '4' => ' ' . __('Thursday', 'wpshop'), '5' => ' ' . __('Friday', 'wpshop'), '6' => ' ' . __('Saturday', 'wpshop'), '0' => ' ' . __('Sunday', 'wpshop')); |
|
| 2569 | 2569 | $input_def['options_label']['original'] = true; |
| 2570 | - $date_config_output .= '<div>' . __('Choose available days in date picker', 'wpshop') . '<a href="#" title="'.__('This option allows you to define the available day in final datepicker', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . '<br/>' . wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_day_to_show]') . '</div>'; |
|
| 2570 | + $date_config_output .= '<div>' . __('Choose available days in date picker', 'wpshop') . '<a href="#" title="' . __('This option allows you to define the available day in final datepicker', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . '<br/>' . wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_day_to_show]') . '</div>'; |
|
| 2571 | 2571 | |
| 2572 | 2572 | /** Past and futur date restriction */ |
| 2573 | 2573 | $input_def = array(); |
| 2574 | 2574 | $input_def['name'] = ''; |
| 2575 | 2575 | $input_def['type'] = 'text'; |
| 2576 | - $date_config_output .= '<div id="wpshop_avalaible_date_for_past_and_futur" >' . __('Calendar past and futur date available', 'wpshop') . '<a href="#" title="'.__('Define if the end user is allowed to choose past and/or futur date', 'wpshop').'" class="wpshop_infobulle_marker">?</a><br/>'; |
|
| 2576 | + $date_config_output .= '<div id="wpshop_avalaible_date_for_past_and_futur" >' . __('Calendar past and futur date available', 'wpshop') . '<a href="#" title="' . __('Define if the end user is allowed to choose past and/or futur date', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br/>'; |
|
| 2577 | 2577 | $available_type_input_def = array(); |
| 2578 | 2578 | $available_type_input_def['name'] = ''; |
| 2579 | 2579 | $available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_minimum'; |
| 2580 | 2580 | $available_type_input_def['type'] = 'text'; |
| 2581 | 2581 | $available_type_input_def['value'] = !empty($value['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ? $value['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] : ''; |
| 2582 | - $date_config_output .= __('Minimum date to show', 'wpshop') . '<a href="#" title="'.__('If you want the calendar to start today put only 0, if you want to show anterior date, put the number of Day or Month or Year (ex: -1D)', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][minDate]') . '<br/>'; |
|
| 2582 | + $date_config_output .= __('Minimum date to show', 'wpshop') . '<a href="#" title="' . __('If you want the calendar to start today put only 0, if you want to show anterior date, put the number of Day or Month or Year (ex: -1D)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][minDate]') . '<br/>'; |
|
| 2583 | 2583 | $available_type_input_def = array(); |
| 2584 | 2584 | $available_type_input_def['name'] = ''; |
| 2585 | 2585 | $available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_maximum'; |
| 2586 | 2586 | $available_type_input_def['type'] = 'text'; |
| 2587 | 2587 | $available_type_input_def['value'] = !empty($value['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ? $value['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] : ''; |
| 2588 | - $date_config_output .= __('Maximum date to show', 'wpshop') . '<a href="#" title="'.__('If you want the calendar to end today put only 0, if you want to show date in futur, put the number of Day or Month or Year (ex: +1M)', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][maxDate]') . '<br/>'; |
|
| 2588 | + $date_config_output .= __('Maximum date to show', 'wpshop') . '<a href="#" title="' . __('If you want the calendar to end today put only 0, if you want to show date in futur, put the number of Day or Month or Year (ex: +1M)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][maxDate]') . '<br/>'; |
|
| 2589 | 2589 | $date_config_output .= '</div>'; |
| 2590 | 2590 | |
| 2591 | 2591 | $input_def = array(); |
| 2592 | 2592 | $input_def['name'] = ''; |
| 2593 | 2593 | $input_def['type'] = 'text'; |
| 2594 | 2594 | $date_config_output .= ' |
| 2595 | -<div id="wpshop_attribute_date_empy_field" class="wpshopHide" ><br/>' . wpshop_form::check_input_type(array_merge($input_def, array('value' => '', 'id' => 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_new_input')), WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') .'</div> |
|
| 2596 | -<div id="wpshop_avalaible_date_list_container" >' . __('Choose available date in date picker', 'wpshop') . '<a href="#" title="'.__('This option allows you to define the available date in final datepicker', 'wpshop').'" class="wpshop_infobulle_marker">?</a><br/>'; |
|
| 2595 | +<div id="wpshop_attribute_date_empy_field" class="wpshopHide" ><br/>' . wpshop_form::check_input_type(array_merge($input_def, array('value' => '', 'id' => 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_new_input')), WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '</div> |
|
| 2596 | +<div id="wpshop_avalaible_date_list_container" >' . __('Choose available date in date picker', 'wpshop') . '<a href="#" title="' . __('This option allows you to define the available date in final datepicker', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br/>'; |
|
| 2597 | 2597 | |
| 2598 | 2598 | $available_type_input_def = array(); |
| 2599 | 2599 | $available_type_input_def['name'] = ''; |
@@ -2606,9 +2606,9 @@ discard block |
||
| 2606 | 2606 | $date_config_output .= wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_type]') . '<br/>'; |
| 2607 | 2607 | |
| 2608 | 2608 | $existing = 0; |
| 2609 | - if ( !empty($value['field_options']['attribute_type_date_options_available_date']) ) { |
|
| 2610 | - foreach ( $value['field_options']['attribute_type_date_options_available_date'] as $index => $value ) { |
|
| 2611 | - if ( !empty($value) ) { |
|
| 2609 | + if (!empty($value['field_options']['attribute_type_date_options_available_date'])) { |
|
| 2610 | + foreach ($value['field_options']['attribute_type_date_options_available_date'] as $index => $value) { |
|
| 2611 | + if (!empty($value)) { |
|
| 2612 | 2612 | $input_def['value'] = $value; |
| 2613 | 2613 | $input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_' . $index; |
| 2614 | 2614 | $date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '<br/>'; |
@@ -2632,20 +2632,20 @@ discard block |
||
| 2632 | 2632 | * @param array $values Valeurs d'attributs |
| 2633 | 2633 | * @return array |
| 2634 | 2634 | */ |
| 2635 | - public static function setAttributesValuesForItem($entityId, $values=array(), $defaultValueForOthers=false, $from = 'webservice') { |
|
| 2636 | - $message=''; |
|
| 2635 | + public static function setAttributesValuesForItem($entityId, $values = array(), $defaultValueForOthers = false, $from = 'webservice') { |
|
| 2636 | + $message = ''; |
|
| 2637 | 2637 | $attribute_available = array(); |
| 2638 | 2638 | $attribute_final = array(); |
| 2639 | 2639 | $entity_type = get_post_type($entityId); |
| 2640 | - $data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
|
| 2641 | - foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2640 | + $data = self::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
|
| 2641 | + foreach ($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2642 | 2642 | |
| 2643 | 2643 | // Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity |
| 2644 | - foreach ( $values as $key => $value ) { |
|
| 2645 | - if ( in_array( $key, array_keys( $attribute_available ) ) ) { |
|
| 2644 | + foreach ($values as $key => $value) { |
|
| 2645 | + if (in_array($key, array_keys($attribute_available))) { |
|
| 2646 | 2646 | $attribute_final[$attribute_available[$key]['data_type']][$key] = $value; |
| 2647 | 2647 | } |
| 2648 | - else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n"; |
|
| 2648 | + else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key) . "\n"; |
|
| 2649 | 2649 | } |
| 2650 | 2650 | |
| 2651 | 2651 | // Pour les autres attributs non donné on leur affecte leur valeur par défaut |
@@ -2666,7 +2666,7 @@ discard block |
||
| 2666 | 2666 | } |
| 2667 | 2667 | } |
| 2668 | 2668 | |
| 2669 | - switch ( $entity_type ) { |
|
| 2669 | + switch ($entity_type) { |
|
| 2670 | 2670 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 2671 | 2671 | $meta_key = WPSHOP_PRODUCT_ATTRIBUTE_META_KEY; |
| 2672 | 2672 | break; |
@@ -2697,18 +2697,18 @@ discard block |
||
| 2697 | 2697 | public static function get_attribute_type_select_option_info($option_id, $field = 'label', $attribute_data_type = 'custom', $only_value = false) { |
| 2698 | 2698 | global $wpdb; |
| 2699 | 2699 | |
| 2700 | - switch ( $attribute_data_type ) { |
|
| 2700 | + switch ($attribute_data_type) { |
|
| 2701 | 2701 | case 'internal': |
| 2702 | 2702 | $entity_infos = get_post($option_id); |
| 2703 | - if ( !empty($entity_infos) ) { |
|
| 2704 | - if ( !$only_value ) { |
|
| 2703 | + if (!empty($entity_infos)) { |
|
| 2704 | + if (!$only_value) { |
|
| 2705 | 2705 | /** Template parameters */ |
| 2706 | 2706 | $template_part = 'product_attribute_value_internal'; |
| 2707 | 2707 | $tpl_component = array(); |
| 2708 | 2708 | $tpl_component['ATTRIBUTE_VALUE_POST_LINK'] = get_permalink($option_id); |
| 2709 | 2709 | $tpl_component['ATTRIBUTE_VALUE_POST_TITLE'] = $entity_infos->post_title; |
| 2710 | 2710 | |
| 2711 | - foreach ( $entity_infos as $post_definition_key => $post_definition_value ) { |
|
| 2711 | + foreach ($entity_infos as $post_definition_key => $post_definition_value) { |
|
| 2712 | 2712 | $tpl_component['ATTRIBUTE_VALUE_' . strtoupper($post_definition_key)] = $entity_infos->$post_definition_key; |
| 2713 | 2713 | } |
| 2714 | 2714 | |
@@ -2723,7 +2723,7 @@ discard block |
||
| 2723 | 2723 | break; |
| 2724 | 2724 | |
| 2725 | 2725 | default: |
| 2726 | - $query = $wpdb->prepare("SELECT " . $field . " FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS." WHERE id=%d LIMIT 1", $option_id); |
|
| 2726 | + $query = $wpdb->prepare("SELECT " . $field . " FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE id=%d LIMIT 1", $option_id); |
|
| 2727 | 2727 | $info = $wpdb->get_var($query); |
| 2728 | 2728 | break; |
| 2729 | 2729 | } |
@@ -2761,39 +2761,39 @@ discard block |
||
| 2761 | 2761 | * @param string $data_type optionnal Le type de donnees choisi pour cet attribut (custom | internal) |
| 2762 | 2762 | * @return string Le resultat sous forme de code html pour la liste des options |
| 2763 | 2763 | */ |
| 2764 | - function get_select_options_list($attribute_id, $data_type='custom') { |
|
| 2764 | + function get_select_options_list($attribute_id, $data_type = 'custom') { |
|
| 2765 | 2765 | global $wpdb; |
| 2766 | 2766 | $output = ''; |
| 2767 | 2767 | |
| 2768 | 2768 | $attribute_select_options = self::get_select_option_list_($attribute_id); |
| 2769 | 2769 | |
| 2770 | 2770 | /* Add possibily to choose datat type to use with list */ |
| 2771 | - if(empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))){ |
|
| 2772 | - unset($input_def);$input_def=array(); |
|
| 2771 | + if (empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))) { |
|
| 2772 | + unset($input_def); $input_def = array(); |
|
| 2773 | 2773 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 2774 | 2774 | $input_def['type'] = 'radio'; |
| 2775 | 2775 | $input_def['name'] = 'data_type_to_use'; |
| 2776 | 2776 | $input_def['valueToPut'] = 'index'; |
| 2777 | 2777 | $input_def['possible_value'] = unserialize(WPSHOP_ATTR_SELECT_TYPE); |
| 2778 | 2778 | $input_def['option'] = 'class="wpshop_cls wpshop_attr_combo_data_type"'; |
| 2779 | - $input_def['value'] = $data_type.'_data'; |
|
| 2779 | + $input_def['value'] = $data_type . '_data'; |
|
| 2780 | 2780 | $input_def['options_label']['original'] = true; |
| 2781 | 2781 | $output = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2782 | 2782 | } |
| 2783 | 2783 | |
| 2784 | - if(!empty($attribute_id) || !empty($data_type)){ |
|
| 2785 | - $defaut_value = ( !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value) ) ? $attribute_select_options[0]->default_value : null; |
|
| 2784 | + if (!empty($attribute_id) || !empty($data_type)) { |
|
| 2785 | + $defaut_value = (!empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value)) ? $attribute_select_options[0]->default_value : null; |
|
| 2786 | 2786 | $default_is_serial = false; |
| 2787 | - if ( !empty($attribute_select_options[0]->default_value) && ($attribute_select_options[0]->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute_select_options[0]->default_value ) ) ) { |
|
| 2787 | + if (!empty($attribute_select_options[0]->default_value) && ($attribute_select_options[0]->default_value == serialize(false) || wpshop_tools::is_serialized($attribute_select_options[0]->default_value))) { |
|
| 2788 | 2788 | $defaut_value = unserialize($attribute_select_options[0]->default_value); |
| 2789 | 2789 | $default_is_serial = true; |
| 2790 | 2790 | } |
| 2791 | 2791 | /** Add a custom text first item of list */ |
| 2792 | - $output .= '<div class="wpshop_cls" ><label for="text_for_empty_value" >' . __('Text displayed when no value selected', 'wpshop') . '</label> <input type="text" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][field_options][label_for_first_item]" value="' . (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["field_options"]["label_for_first_item"])) ? stripslashes( $defaut_value["field_options"]["label_for_first_item"] ) : __('Choose a value', 'wpshop')) . '" id="text_for_empty_value" /></div>'; |
|
| 2792 | + $output .= '<div class="wpshop_cls" ><label for="text_for_empty_value" >' . __('Text displayed when no value selected', 'wpshop') . '</label> <input type="text" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][field_options][label_for_first_item]" value="' . (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["field_options"]["label_for_first_item"])) ? stripslashes($defaut_value["field_options"]["label_for_first_item"]) : __('Choose a value', 'wpshop')) . '" id="text_for_empty_value" /></div>'; |
|
| 2793 | 2793 | |
| 2794 | - if((($data_type == 'custom') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'custom'))){ |
|
| 2794 | + if ((($data_type == 'custom') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'custom'))) { |
|
| 2795 | 2795 | $sub_output = ''; |
| 2796 | - if ( !empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id) ) { |
|
| 2796 | + if (!empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id)) { |
|
| 2797 | 2797 | $sub_output .= ' |
| 2798 | 2798 | <li class="wpshop_attribute_combo_options_container ui-state-disabled" > |
| 2799 | 2799 | <input type="radio" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][default_value]" value="" id="default_value_empty" ' . (($default_is_serial && is_array($defaut_value) && empty($defaut_value["default_value"])) || empty($defaut_value) ? 'checked ' : '') . '/> <label for="default_value_empty">' . __('No default value', 'wpshop') . '</label> |
@@ -2806,7 +2806,7 @@ discard block |
||
| 2806 | 2806 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", $options->value); |
| 2807 | 2807 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = (!empty($options->id) && (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["default_value"]) && ($defaut_value["default_value"] == $options->id))) ? ' checked="checked"' : ''); |
| 2808 | 2808 | $tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = ''; |
| 2809 | - if( current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0) ): |
|
| 2809 | + if (current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0)): |
|
| 2810 | 2810 | $tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item_deletion', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin'); |
| 2811 | 2811 | endif; |
| 2812 | 2812 | $sub_output .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin'); |
@@ -2814,13 +2814,13 @@ discard block |
||
| 2814 | 2814 | } |
| 2815 | 2815 | } |
| 2816 | 2816 | $add_button = $add_dialog_box = $user_more_script = ''; |
| 2817 | - if( current_user_can('wpshop_add_attributes_select_values') ) { |
|
| 2817 | + if (current_user_can('wpshop_add_attributes_select_values')) { |
|
| 2818 | 2818 | |
| 2819 | 2819 | $dialog_title = __('New value for attribute', 'wpshop'); |
| 2820 | 2820 | $dialog_identifier = 'wpshop_new_attribute_option_value_add'; |
| 2821 | 2821 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 2822 | 2822 | ob_start(); |
| 2823 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 2823 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 2824 | 2824 | $add_dialog_box = ob_get_contents(); |
| 2825 | 2825 | ob_end_clean(); |
| 2826 | 2826 | |
@@ -2828,23 +2828,23 @@ discard block |
||
| 2828 | 2828 | $add_button_parent_class = 'wpshop_attribute_option_value_add'; |
| 2829 | 2829 | $add_button_name = 'wpshop_add_option_to_select'; |
| 2830 | 2830 | ob_start(); |
| 2831 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php'); |
|
| 2831 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php'); |
|
| 2832 | 2832 | $add_button = ob_get_contents(); |
| 2833 | 2833 | ob_end_clean(); |
| 2834 | 2834 | |
| 2835 | 2835 | $user_more_script = ' |
| 2836 | - jQuery("#'.$dialog_identifier.'").dialog({ |
|
| 2836 | + jQuery("#'.$dialog_identifier . '").dialog({ |
|
| 2837 | 2837 | modal: true, |
| 2838 | 2838 | dialogClass: "wpshop_uidialog_box", |
| 2839 | 2839 | autoOpen:false, |
| 2840 | 2840 | show: "blind", |
| 2841 | 2841 | resizable: false, |
| 2842 | 2842 | buttons:{ |
| 2843 | - "'.__('Add', 'wpshop').'": function(){ |
|
| 2843 | + "'.__('Add', 'wpshop') . '": function(){ |
|
| 2844 | 2844 | var data = { |
| 2845 | 2845 | action: "new_option_for_select", |
| 2846 | 2846 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_new_option_for_attribute_creation") . '", |
| 2847 | - attribute_new_label: jQuery("#'.$dialog_input_identifier.'").val(), |
|
| 2847 | + attribute_new_label: jQuery("#'.$dialog_input_identifier . '").val(), |
|
| 2848 | 2848 | attribute_identifier: "' . $attribute_id . '" |
| 2849 | 2849 | }; |
| 2850 | 2850 | jQuery.post(ajaxurl, data, function(response) { |
@@ -2860,21 +2860,21 @@ discard block |
||
| 2860 | 2860 | |
| 2861 | 2861 | jQuery(this).children("img").show(); |
| 2862 | 2862 | }, |
| 2863 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 2863 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 2864 | 2864 | jQuery(this).dialog("close"); |
| 2865 | 2865 | } |
| 2866 | 2866 | }, |
| 2867 | 2867 | close:function(){ |
| 2868 | - jQuery("#'.$dialog_input_identifier.'").val(""); |
|
| 2868 | + jQuery("#'.$dialog_input_identifier . '").val(""); |
|
| 2869 | 2869 | } |
| 2870 | 2870 | }); |
| 2871 | - jQuery(".'.$add_button_parent_class.' input").click(function(){ |
|
| 2872 | - jQuery("#'.$dialog_identifier.'").dialog("open"); |
|
| 2871 | + jQuery(".'.$add_button_parent_class . ' input").click(function(){ |
|
| 2872 | + jQuery("#'.$dialog_identifier . '").dialog("open"); |
|
| 2873 | 2873 | });'; |
| 2874 | 2874 | |
| 2875 | 2875 | } |
| 2876 | 2876 | $output .= $add_dialog_box . ' |
| 2877 | - <ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options)>5 ? $add_button : '').$sub_output.$add_button.' |
|
| 2877 | + <ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options) > 5 ? $add_button : '') . $sub_output . $add_button . ' |
|
| 2878 | 2878 | </ul> |
| 2879 | 2879 | <input type="hidden" value="' . wp_create_nonce("wpshop_new_option_for_attribute_deletion") . '" name="wpshop_new_option_for_attribute_deletion_nonce" id="wpshop_new_option_for_attribute_deletion_nonce" /> |
| 2880 | 2880 | <script type="text/javascript" > |
@@ -2890,7 +2890,7 @@ discard block |
||
| 2890 | 2890 | var data = { |
| 2891 | 2891 | action: "attribute_output_type", |
| 2892 | 2892 | current_type: jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").val(), |
| 2893 | - elementIdentifier: "'.$attribute_id.'", |
|
| 2893 | + elementIdentifier: "'.$attribute_id . '", |
|
| 2894 | 2894 | data_type_to_use: jQuery(this).val(), |
| 2895 | 2895 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_output_type_selection") . '" |
| 2896 | 2896 | }; |
@@ -2905,10 +2905,10 @@ discard block |
||
| 2905 | 2905 | }); |
| 2906 | 2906 | </script>'; |
| 2907 | 2907 | } |
| 2908 | - elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){ |
|
| 2909 | - $sub_output=''; |
|
| 2908 | + elseif ((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))) { |
|
| 2909 | + $sub_output = ''; |
|
| 2910 | 2910 | $wp_types = unserialize(WPSHOP_INTERNAL_TYPES); |
| 2911 | - unset($input_def);$input_def=array(); |
|
| 2911 | + unset($input_def); $input_def = array(); |
|
| 2912 | 2912 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 2913 | 2913 | $input_def['type'] = 'select'; |
| 2914 | 2914 | $input_def['name'] = 'default_value][default_value'; |
@@ -2917,20 +2917,20 @@ discard block |
||
| 2917 | 2917 | $input_def['possible_value'] = $wp_types; |
| 2918 | 2918 | $input_def['value'] = (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["default_value"])) ? $defaut_value["default_value"] : (!empty($defaut_value) ? $defaut_value : null)); |
| 2919 | 2919 | $combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2920 | - $output .= '<div class="wpshop_cls">'.$combo_wp_type.'</div>'; |
|
| 2921 | - if ( !empty($attribute_id) ) { |
|
| 2920 | + $output .= '<div class="wpshop_cls">' . $combo_wp_type . '</div>'; |
|
| 2921 | + if (!empty($attribute_id)) { |
|
| 2922 | 2922 | $option_list = '<div>' . __('You can reorder element for display them in the order you want into frontend part', 'wpshop') . '</div>'; |
| 2923 | - $options_for_current_attribute = query_posts( array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ) ); |
|
| 2924 | - if ( !empty($options_for_current_attribute) ) { |
|
| 2923 | + $options_for_current_attribute = query_posts(array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC')); |
|
| 2924 | + if (!empty($options_for_current_attribute)) { |
|
| 2925 | 2925 | $option_list .= '<ul class="wpshop_attribute_combo_values_list_container" >'; |
| 2926 | 2926 | $current_order = ' '; |
| 2927 | - foreach ( $options_for_current_attribute as $options_def ) { |
|
| 2927 | + foreach ($options_for_current_attribute as $options_def) { |
|
| 2928 | 2928 | $current_order .= 'post_' . $options_def->ID . ','; |
| 2929 | 2929 | $option_list .= '<li id="post_' . $options_def->ID . '" class="wpshop_attribute_combo_values_list_item wpshop_attribute_combo_values_list_item_' . $options_def->ID . '" ><span class="wpshop_internal_value_for_option_list_identifier" >#' . $options_def->ID . '</span> ' . $options_def->post_title . '</li>'; |
| 2930 | 2930 | } |
| 2931 | 2931 | $option_list .= '</ul><input type="hidden" value="' . substr($current_order, 0, -1) . '" name="' . WPSHOP_DBT_ATTRIBUTE . '[wpshop_attribute_combo_values_list_order_def]" id="wpshop_attribute_combo_values_list_order_def" />'; |
| 2932 | 2932 | } |
| 2933 | - $output .= '<div class="wpshop_cls">'.$option_list.'</div>'; |
|
| 2933 | + $output .= '<div class="wpshop_cls">' . $option_list . '</div>'; |
|
| 2934 | 2934 | } |
| 2935 | 2935 | } |
| 2936 | 2936 | } |
@@ -2958,8 +2958,8 @@ discard block |
||
| 2958 | 2958 | $attribute_list_for_entity = self::getElement($entity_id, "'valid'", 'entity_id', true); |
| 2959 | 2959 | |
| 2960 | 2960 | /* Read the list */ |
| 2961 | - if ( !empty ($attribute_list_for_entity ) ) { |
|
| 2962 | - foreach ( $attribute_list_for_entity as $attribute) { |
|
| 2961 | + if (!empty ($attribute_list_for_entity)) { |
|
| 2962 | + foreach ($attribute_list_for_entity as $attribute) { |
|
| 2963 | 2963 | switch ($list_for) { |
| 2964 | 2964 | case 'attribute_value': |
| 2965 | 2965 | $checkbox_state = ' '; |
@@ -2968,8 +2968,8 @@ discard block |
||
| 2968 | 2968 | <select id="wpshop_shortcode_element_attribute_value_product_list_' . $attribute->id . '" class="wpshop_shortcode_element_attribute_value_product_list" >'; |
| 2969 | 2969 | |
| 2970 | 2970 | global $post; |
| 2971 | - $posts = get_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1) ); |
|
| 2972 | - foreach( $posts as $post ) : |
|
| 2971 | + $posts = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1)); |
|
| 2972 | + foreach ($posts as $post) : |
|
| 2973 | 2973 | setup_postdata($post); |
| 2974 | 2974 | $attribute_possible_values .= '<option value="' . get_the_ID() . '" >' . get_the_ID() . ' - ' . get_the_title() . '</option>'; |
| 2975 | 2975 | endforeach; |
@@ -2985,23 +2985,23 @@ discard block |
||
| 2985 | 2985 | |
| 2986 | 2986 | $checkbox_state = 'disabled '; |
| 2987 | 2987 | $attribute_possible_values = ''; |
| 2988 | - if ( !empty($attribute_values) ) { |
|
| 2988 | + if (!empty($attribute_values)) { |
|
| 2989 | 2989 | $checkbox_state = ''; |
| 2990 | 2990 | $attribute_possible_values = ' |
| 2991 | 2991 | <div class="wpshop_shortcode_element_product_listing_per_attribute_value wpshop_shortcode_element_prodcut_listing_per_attribute_value_' . $attribute->code . '_container" > |
| 2992 | 2992 | <select id="wpshop_attribute_value_for_shortcode_generation_' . $attribute->id . '" class="wpshop_shortcode_element_prodcut_listing_per_attribute_value hidden" >'; |
| 2993 | 2993 | |
| 2994 | - if ( ($attribute->data_type == 'integer') && ( ($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select') ) ) { |
|
| 2994 | + if (($attribute->data_type == 'integer') && (($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select'))) { |
|
| 2995 | 2995 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id=%d ORDER BY position", $attribute->id); |
| 2996 | 2996 | $possible_values = $wpdb->get_results($query); |
| 2997 | 2997 | $already_selected_values = array(); |
| 2998 | 2998 | foreach ($attribute_values as $attribute_value) { |
| 2999 | - if ( !empty($attribute_value->value) ) { |
|
| 2999 | + if (!empty($attribute_value->value)) { |
|
| 3000 | 3000 | $already_selected_values[] = $attribute_value->value; |
| 3001 | 3001 | } |
| 3002 | 3002 | } |
| 3003 | 3003 | foreach ($possible_values as $value) { |
| 3004 | - if ( in_array( $value->id, $already_selected_values ) ) { |
|
| 3004 | + if (in_array($value->id, $already_selected_values)) { |
|
| 3005 | 3005 | $attribute_possible_values .= ' |
| 3006 | 3006 | <option value="' . $value->value . '" >' . $value->label . '</option>'; |
| 3007 | 3007 | } |
@@ -3009,7 +3009,7 @@ discard block |
||
| 3009 | 3009 | } |
| 3010 | 3010 | else { |
| 3011 | 3011 | foreach ($attribute_values as $attribute_value) { |
| 3012 | - if ( !empty($attribute_value->value) ) { |
|
| 3012 | + if (!empty($attribute_value->value)) { |
|
| 3013 | 3013 | $attribute_possible_values .= ' |
| 3014 | 3014 | <option value="' . $attribute_value->value . '" >' . $attribute_value->value . '</option>'; |
| 3015 | 3015 | } |
@@ -3038,23 +3038,23 @@ discard block |
||
| 3038 | 3038 | * |
| 3039 | 3039 | * @return object The attribute list as a wordpress database object |
| 3040 | 3040 | */ |
| 3041 | - function get_attribute_list_in_same_set_section( $attribute_code ) { |
|
| 3041 | + function get_attribute_list_in_same_set_section($attribute_code) { |
|
| 3042 | 3042 | global $wpdb; |
| 3043 | 3043 | |
| 3044 | 3044 | $attribute_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code'); |
| 3045 | 3045 | |
| 3046 | 3046 | /** Get the entire list of attribute in price set section for display */ |
| 3047 | - $query = $wpdb->prepare( "SELECT entity_type_id, attribute_set_id, attribute_group_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = 'valid'", $attribute_def->id); |
|
| 3047 | + $query = $wpdb->prepare("SELECT entity_type_id, attribute_set_id, attribute_group_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = 'valid'", $attribute_def->id); |
|
| 3048 | 3048 | $attribute_attribution_def = $wpdb->get_row($query); |
| 3049 | 3049 | |
| 3050 | - $query = $wpdb->prepare( " |
|
| 3050 | + $query = $wpdb->prepare(" |
|
| 3051 | 3051 | SELECT ATTR.code, is_visible_in_front_listing, is_visible_in_front |
| 3052 | 3052 | FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS SET_SECTION_DETAIL |
| 3053 | 3053 | INNER JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR ON (ATTR.id = SET_SECTION_DETAIL.attribute_id) |
| 3054 | 3054 | WHERE entity_type_id = %d |
| 3055 | 3055 | AND attribute_set_id = %d |
| 3056 | 3056 | AND attribute_group_id = %d", |
| 3057 | - $attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id ); |
|
| 3057 | + $attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id); |
|
| 3058 | 3058 | $atribute_list = $wpdb->get_results($query); |
| 3059 | 3059 | |
| 3060 | 3060 | return $atribute_list; |
@@ -3065,7 +3065,7 @@ discard block |
||
| 3065 | 3065 | * @param unknown_type $current_entity_id |
| 3066 | 3066 | * @return Ambigous <multitype:, multitype:NULL > |
| 3067 | 3067 | */ |
| 3068 | - public static function get_variation_available_attribute( $current_entity_id ) { |
|
| 3068 | + public static function get_variation_available_attribute($current_entity_id) { |
|
| 3069 | 3069 | global $wpdb; |
| 3070 | 3070 | $final_list = array(); |
| 3071 | 3071 | |
@@ -3073,7 +3073,7 @@ discard block |
||
| 3073 | 3073 | $query = $wpdb->prepare( |
| 3074 | 3074 | "SELECT ATT.*, ENTITY_META.meta_value |
| 3075 | 3075 | FROM " . self::getDbTable() . " AS ATT |
| 3076 | - INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_DETAILS. " AS ATT_DETAILS ON ((ATT_DETAILS.attribute_id = ATT.id) AND (ATT_DETAILS.entity_type_id = %d) AND (ATT_DETAILS.status = 'valid')) |
|
| 3076 | + INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS ATT_DETAILS ON ((ATT_DETAILS.attribute_id = ATT.id) AND (ATT_DETAILS.entity_type_id = %d) AND (ATT_DETAILS.status = 'valid')) |
|
| 3077 | 3077 | INNER JOIN " . $wpdb->postmeta . " AS ENTITY_META ON ((ENTITY_META.meta_key = %s) AND (ENTITY_META.meta_value = ATT_DETAILS.attribute_set_id)) |
| 3078 | 3078 | WHERE ATT.status IN ('valid') |
| 3079 | 3079 | AND ATT.is_used_for_variation = %s |
@@ -3083,10 +3083,10 @@ discard block |
||
| 3083 | 3083 | ); |
| 3084 | 3084 | $attribute_list = $wpdb->get_results($query); |
| 3085 | 3085 | foreach ($attribute_list as $attribute) { |
| 3086 | - if ( !in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select')) ) { |
|
| 3087 | - $attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list( $attribute->code, $current_entity_id, $attribute->data_type_to_use ); |
|
| 3086 | + if (!in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select'))) { |
|
| 3087 | + $attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list($attribute->code, $current_entity_id, $attribute->data_type_to_use); |
|
| 3088 | 3088 | |
| 3089 | - if ( empty($attribute_values_for_variations) ) { |
|
| 3089 | + if (empty($attribute_values_for_variations)) { |
|
| 3090 | 3090 | $final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label; |
| 3091 | 3091 | $final_list['unavailable'][$attribute->code]['values'] = array(); |
| 3092 | 3092 | $final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute; |
@@ -3106,16 +3106,16 @@ discard block |
||
| 3106 | 3106 | * @param integer $current_entity_id The current element edited |
| 3107 | 3107 | * @return Ambigous <string, string, mixed> |
| 3108 | 3108 | */ |
| 3109 | - public static function get_variation_available_attribute_display( $current_entity_id, $variation_type = 'multiple' ) { |
|
| 3109 | + public static function get_variation_available_attribute_display($current_entity_id, $variation_type = 'multiple') { |
|
| 3110 | 3110 | $attribute_list = wpshop_attributes::get_variation_available_attribute($current_entity_id); |
| 3111 | 3111 | |
| 3112 | 3112 | $attribute_defined_as_available_for_variation = ''; |
| 3113 | - if ( !empty($attribute_list) ) { |
|
| 3113 | + if (!empty($attribute_list)) { |
|
| 3114 | 3114 | foreach ($attribute_list as $list_type => $attribute_list_by_type) { |
| 3115 | 3115 | $sub_attribute_list = ''; |
| 3116 | 3116 | foreach ($attribute_list_by_type as $attribute_code => $attribute_def) { |
| 3117 | 3117 | $tpl_component = array(); |
| 3118 | - if ( $list_type == 'available' ) { |
|
| 3118 | + if ($list_type == 'available') { |
|
| 3119 | 3119 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ''; |
| 3120 | 3120 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ''; |
| 3121 | 3121 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; |
@@ -3129,13 +3129,13 @@ discard block |
||
| 3129 | 3129 | $tpl_component['ADMIN_ATTRIBUTE_CODE_FOR_VARIATION'] = $attribute_code; |
| 3130 | 3130 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code; |
| 3131 | 3131 | $tpl_component['ADMIN_VARIATION_ATTRIBUTE_CONTAINER_CLASS'] = ' wpshop_attribute_for_variation_' . $attribute_code; |
| 3132 | - $tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __( $attribute_def['label'], 'wpshop' ); |
|
| 3132 | + $tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __($attribute_def['label'], 'wpshop'); |
|
| 3133 | 3133 | $tpl_component['ADMIN_VARIATION_NEW_SINGLE_INPUT'] = ''; |
| 3134 | - if ( $variation_type == 'single' ) { |
|
| 3135 | - $attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_def['attribute_complete_def'], $attribute_def['values'], array('from' => 'frontend', 'field_custom_name_prefix' => 'variation_attr', 'input_class' => ' variation_attribute_usable_input') ); |
|
| 3136 | - if ( !empty($attribute_output_def['possible_value']) ) { |
|
| 3137 | - foreach( $attribute_output_def['possible_value'] as $value_id => $value ){ |
|
| 3138 | - if ( !in_array($value_id, $attribute_def['values']) ) { |
|
| 3134 | + if ($variation_type == 'single') { |
|
| 3135 | + $attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_def['attribute_complete_def'], $attribute_def['values'], array('from' => 'frontend', 'field_custom_name_prefix' => 'variation_attr', 'input_class' => ' variation_attribute_usable_input')); |
|
| 3136 | + if (!empty($attribute_output_def['possible_value'])) { |
|
| 3137 | + foreach ($attribute_output_def['possible_value'] as $value_id => $value) { |
|
| 3138 | + if (!in_array($value_id, $attribute_def['values'])) { |
|
| 3139 | 3139 | unset($attribute_output_def['possible_value'][$value_id]); |
| 3140 | 3140 | } |
| 3141 | 3141 | } |
@@ -3150,7 +3150,7 @@ discard block |
||
| 3150 | 3150 | } |
| 3151 | 3151 | } |
| 3152 | 3152 | |
| 3153 | - return array($attribute_defined_as_available_for_variation, ( (!empty($attribute_list['available']) ) ? $attribute_list['available'] : ''), ( ( !empty($attribute_list['unavailable']) ) ? $attribute_list['unavailable'] : '')); |
|
| 3153 | + return array($attribute_defined_as_available_for_variation, ((!empty($attribute_list['available'])) ? $attribute_list['available'] : ''), ((!empty($attribute_list['unavailable'])) ? $attribute_list['unavailable'] : '')); |
|
| 3154 | 3154 | } |
| 3155 | 3155 | |
| 3156 | 3156 | /** |
@@ -3159,18 +3159,18 @@ discard block |
||
| 3159 | 3159 | * @param array $variations_attribute_parameters Allows to give some parameters for customize list |
| 3160 | 3160 | * @return string The output for all specific attribute in each product with option |
| 3161 | 3161 | */ |
| 3162 | - public static function get_variation_attribute( $variations_attribute_parameters ) { |
|
| 3162 | + public static function get_variation_attribute($variations_attribute_parameters) { |
|
| 3163 | 3163 | $output = ''; |
| 3164 | 3164 | |
| 3165 | 3165 | $attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_in_variation", true); |
| 3166 | - if ( !empty( $attribute_list ) ) { |
|
| 3166 | + if (!empty($attribute_list)) { |
|
| 3167 | 3167 | $tpl_component = array(); |
| 3168 | 3168 | $tpl_component['ADMIN_VARIATION_DETAIL'] = ''; |
| 3169 | 3169 | $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
| 3170 | - foreach ( $attribute_list as $attribute_def ) { |
|
| 3170 | + foreach ($attribute_list as $attribute_def) { |
|
| 3171 | 3171 | |
| 3172 | 3172 | $variations_attribute_parameters['field_custom_name_prefix'] = $variations_attribute_parameters['field_name'] . '[attribute][' . $attribute_def->data_type . ']'; |
| 3173 | - $attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_def, (!empty($variations_attribute_parameters['variation_dif_values'][$attribute_def->code]) ? $variations_attribute_parameters['variation_dif_values'][$attribute_def->code] : ''), $variations_attribute_parameters ); |
|
| 3173 | + $attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_def, (!empty($variations_attribute_parameters['variation_dif_values'][$attribute_def->code]) ? $variations_attribute_parameters['variation_dif_values'][$attribute_def->code] : ''), $variations_attribute_parameters); |
|
| 3174 | 3174 | |
| 3175 | 3175 | $field_output = $attribute_output_def['output']; |
| 3176 | 3176 | |
@@ -3182,9 +3182,9 @@ discard block |
||
| 3182 | 3182 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_ID'] = $attribute_output_def['id']; |
| 3183 | 3183 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_LABEL'] = $attribute_output_def['label']; |
| 3184 | 3184 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] = $field_output; |
| 3185 | - if( isset( $variations_attribute_parameters['post_id'] ) ) { |
|
| 3186 | - $attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($attribute_output_def['value'], 'value'), 'wpshop') ) == strtolower( __('yes', 'wpshop') )) ? '' : ' wpshopHide'; |
|
| 3187 | - $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] .= '<div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($variations_attribute_parameters['post_id'], $attribute_def->code).'</div>'; |
|
| 3185 | + if (isset($variations_attribute_parameters['post_id'])) { |
|
| 3186 | + $attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($attribute_output_def['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 3187 | + $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] .= '<div class="attribute_option_' . $attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($variations_attribute_parameters['post_id'], $attribute_def->code) . '</div>'; |
|
| 3188 | 3188 | } |
| 3189 | 3189 | $tpl_component['ADMIN_VARIATION_DETAIL'] .= wpshop_display::display_template_element('wpshop_admin_variation_item_details_line', $sub_tpl_component, array(), 'admin'); |
| 3190 | 3190 | unset($sub_tpl_component); |
@@ -3195,7 +3195,7 @@ discard block |
||
| 3195 | 3195 | return $output; |
| 3196 | 3196 | } |
| 3197 | 3197 | |
| 3198 | - public static function get_attribute_user_defined( $use_defined_parameters, $status = "'publish'" ) { |
|
| 3198 | + public static function get_attribute_user_defined($use_defined_parameters, $status = "'publish'") { |
|
| 3199 | 3199 | global $wpdb; |
| 3200 | 3200 | $attribute_user_defined_list = array(); |
| 3201 | 3201 | |
@@ -3222,12 +3222,12 @@ discard block |
||
| 3222 | 3222 | * @param string $post_type The current |
| 3223 | 3223 | * |
| 3224 | 3224 | */ |
| 3225 | - function quick_edit( $column_name, $entity ) { |
|
| 3226 | - switch ( $entity ) { |
|
| 3225 | + function quick_edit($column_name, $entity) { |
|
| 3226 | + switch ($entity) { |
|
| 3227 | 3227 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 3228 | 3228 | $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code'); |
| 3229 | - if ( !empty($attribute_def) ) { |
|
| 3230 | - $input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') ); |
|
| 3229 | + if (!empty($attribute_def)) { |
|
| 3230 | + $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input')); |
|
| 3231 | 3231 | $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']); |
| 3232 | 3232 | ?> |
| 3233 | 3233 | <div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container"> |
@@ -3247,12 +3247,12 @@ discard block |
||
| 3247 | 3247 | * @param string $post_type The current |
| 3248 | 3248 | * |
| 3249 | 3249 | */ |
| 3250 | - public static function bulk_edit( $column_name, $entity ) { |
|
| 3251 | - switch ( $entity ) { |
|
| 3250 | + public static function bulk_edit($column_name, $entity) { |
|
| 3251 | + switch ($entity) { |
|
| 3252 | 3252 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 3253 | 3253 | $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code'); |
| 3254 | - if ( !empty($attribute_def) ) { |
|
| 3255 | - $input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') ); |
|
| 3254 | + if (!empty($attribute_def)) { |
|
| 3255 | + $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input')); |
|
| 3256 | 3256 | $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']); |
| 3257 | 3257 | ?> |
| 3258 | 3258 | <div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container"> |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | /** Generate the billing reference regarding the order $order_id |
| 245 | 245 | * @return void |
| 246 | - */ |
|
| 246 | + */ |
|
| 247 | 247 | function order_generate_billing_number($order_id, $force_invoicing = false){ |
| 248 | 248 | global $wpdb, $wpshop_modules_billing; |
| 249 | 249 | |
@@ -264,8 +264,8 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | |
| 266 | 266 | /** Renvoi une nouvelle r�f�rence unique pour une commande |
| 267 | - * @return int |
|
| 268 | - */ |
|
| 267 | + * @return int |
|
| 268 | + */ |
|
| 269 | 269 | public static function get_new_order_reference(){ |
| 270 | 270 | $number_figures = get_option('wpshop_order_number_figures', false); |
| 271 | 271 | /* If the number doesn't exist, we create a default one */ |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** Renvoi une nouvelle r�f�rence unique pour un devis |
| 288 | - * @return int |
|
| 289 | - */ |
|
| 288 | + * @return int |
|
| 289 | + */ |
|
| 290 | 290 | public static function get_new_pre_order_reference($save = true){ |
| 291 | 291 | $number_figures = get_option('wpshop_order_number_figures', false); |
| 292 | 292 | /* If the number doesn't exist, we create a default one */ |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | /** Set the custom colums |
| 350 | 350 | * @return array |
| 351 | - */ |
|
| 351 | + */ |
|
| 352 | 352 | static function orders_edit_columns($columns){ |
| 353 | 353 | $columns = array( |
| 354 | 354 | 'cb' => '<input type="checkbox" />', |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | /** Give the content by column |
| 369 | 369 | * @return array |
| 370 | - */ |
|
| 370 | + */ |
|
| 371 | 371 | public static function orders_custom_columns($column, $post_id) { |
| 372 | 372 | if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) { |
| 373 | 373 | global $civility, $order_status; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Products management method file |
| 4 | 6 | * |
@@ -132,8 +134,7 @@ discard block |
||
| 132 | 134 | $order_main_info .= '<div class="wps-product-section">'; |
| 133 | 135 | if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){ |
| 134 | 136 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>'; |
| 135 | - } |
|
| 136 | - else{ |
|
| 137 | + } else{ |
|
| 137 | 138 | if(!empty($order_postmeta['order_key'])){ |
| 138 | 139 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>'; |
| 139 | 140 | } |
@@ -148,8 +149,7 @@ discard block |
||
| 148 | 149 | $sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID; |
| 149 | 150 | $order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin'); |
| 150 | 151 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . ''; |
| 151 | - } |
|
| 152 | - else { |
|
| 152 | + } else { |
|
| 153 | 153 | $order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin'); |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -195,8 +195,7 @@ discard block |
||
| 195 | 195 | if ( empty($credit_meta) ) { |
| 196 | 196 | if( $order_postmeta['order_status'] == 'refunded') { |
| 197 | 197 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .WPSHOP_TEMPLATES_URL. 'invoice.php?order_id=' .$order->ID. '&invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>'; |
| 198 | - } |
|
| 199 | - else { |
|
| 198 | + } else { |
|
| 200 | 199 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>'; |
| 201 | 200 | } |
| 202 | 201 | } |
@@ -276,8 +275,7 @@ discard block |
||
| 276 | 275 | |
| 277 | 276 | $order_current_number = get_option('wpshop_order_current_number', false); |
| 278 | 277 | /* If the counter doesn't exist, we initiate it */ |
| 279 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 280 | - else { $order_current_number++; } |
|
| 278 | + if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; } |
|
| 281 | 279 | update_option('wpshop_order_current_number', $order_current_number); |
| 282 | 280 | |
| 283 | 281 | $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
@@ -297,8 +295,7 @@ discard block |
||
| 297 | 295 | |
| 298 | 296 | $order_current_number = get_option('wpshop_preorder_current_number', false); |
| 299 | 297 | /* If the counter doesn't exist, we initiate it */ |
| 300 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 301 | - else { $order_current_number++; } |
|
| 298 | + if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; } |
|
| 302 | 299 | if($save){ |
| 303 | 300 | update_option('wpshop_preorder_current_number', $order_current_number); |
| 304 | 301 | } |
@@ -332,8 +329,7 @@ discard block |
||
| 332 | 329 | $shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
| 333 | 330 | } |
| 334 | 331 | } |
| 335 | - } |
|
| 336 | - else { |
|
| 332 | + } else { |
|
| 337 | 333 | $shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 338 | 334 | $shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
| 339 | 335 | $shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : ''; |
@@ -394,8 +390,7 @@ discard block |
||
| 394 | 390 | case "order_billing": |
| 395 | 391 | if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) { |
| 396 | 392 | $billing = $addresses['billing']['address']; |
| 397 | - } |
|
| 398 | - else if ( !empty($addresses['billing']) ) { |
|
| 393 | + } else if ( !empty($addresses['billing']) ) { |
|
| 399 | 394 | $billing = $addresses['billing']; |
| 400 | 395 | } |
| 401 | 396 | if ( !empty($billing) ) { |
@@ -403,8 +398,7 @@ discard block |
||
| 403 | 398 | echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />'; |
| 404 | 399 | echo (!empty($billing['address']) ? $billing['address'] : null).'<br />'; |
| 405 | 400 | echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null); |
| 406 | - } |
|
| 407 | - else { |
|
| 401 | + } else { |
|
| 408 | 402 | echo __('No information available for user billing', 'wpshop'); |
| 409 | 403 | } |
| 410 | 404 | break; |
@@ -412,8 +406,7 @@ discard block |
||
| 412 | 406 | case "order_shipping": |
| 413 | 407 | if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) { |
| 414 | 408 | $shipping = $addresses['shipping']['address']; |
| 415 | - } |
|
| 416 | - else if ( !empty($addresses['shipping']) ) { |
|
| 409 | + } else if ( !empty($addresses['shipping']) ) { |
|
| 417 | 410 | $shipping = $addresses['shipping']; |
| 418 | 411 | } |
| 419 | 412 | if ( !empty($shipping) ) { |
@@ -421,8 +414,7 @@ discard block |
||
| 421 | 414 | echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />'; |
| 422 | 415 | echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />'; |
| 423 | 416 | echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null); |
| 424 | - } |
|
| 425 | - else{ |
|
| 417 | + } else{ |
|
| 426 | 418 | echo __('No information available for user shipping', 'wpshop'); |
| 427 | 419 | } |
| 428 | 420 | break; |
@@ -435,8 +427,7 @@ discard block |
||
| 435 | 427 | // Marquer comme envoy� |
| 436 | 428 | if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) { |
| 437 | 429 | $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> '; |
| 438 | - } |
|
| 439 | - else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 430 | + } else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 440 | 431 | // $buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' '; |
| 441 | 432 | } |
| 442 | 433 | $buttons .= '</p>'; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Products management method file |
| 4 | 4 | * |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | /* Check if file is include. No direct access possible with file url */ |
| 13 | -if ( !defined( 'WPSHOP_VERSION' ) ) { |
|
| 14 | - die( __('Access is not allowed by this way', 'wpshop') ); |
|
| 13 | +if (!defined('WPSHOP_VERSION')) { |
|
| 14 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | /** Add action button */ |
| 71 | 71 | add_meta_box( |
| 72 | 72 | 'wpshop_order_actions', |
| 73 | - '<span class="dashicons dashicons-info"></span> '.__('Actions on order', 'wpshop'), |
|
| 73 | + '<span class="dashicons dashicons-info"></span> ' . __('Actions on order', 'wpshop'), |
|
| 74 | 74 | array('wpshop_orders', 'order_actions'), |
| 75 | 75 | WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'high' |
| 76 | 76 | ); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @param object $order The current order being edited |
| 112 | 112 | */ |
| 113 | - public static function order_actions( $order ) { |
|
| 113 | + public static function order_actions($order) { |
|
| 114 | 114 | $output = ''; |
| 115 | 115 | |
| 116 | 116 | $order_status = unserialize(WPSHOP_ORDER_STATUS); |
@@ -118,37 +118,37 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $tpl_component = array(); |
| 120 | 120 | |
| 121 | - $delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url( get_delete_post_link($order->ID) ) , 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') : __('Move to Trash', 'wpshop'))), array(), 'admin'); |
|
| 122 | - $tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can( "delete_post", $order->ID ) ? $delete_button : ''; |
|
| 121 | + $delete_button = wpshop_display::display_template_element('wpshop_admin_order_action_del_button', array('ADMIN_ORDER_DELETE_LINK' => esc_url(get_delete_post_link($order->ID)), 'ADMIN_ORDER_DELETE_TEXT' => (!EMPTY_TRASH_DAYS ? __('Delete Permanently', 'wpshop') : __('Move to Trash', 'wpshop'))), array(), 'admin'); |
|
| 122 | + $tpl_component['ADMIN_ORDER_DELETE_ORDER'] = current_user_can("delete_post", $order->ID) ? $delete_button : ''; |
|
| 123 | 123 | |
| 124 | 124 | /** Add an action list */ |
| 125 | 125 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] = ''; |
| 126 | 126 | |
| 127 | 127 | /** Display main information about the order */ |
| 128 | 128 | $order_main_info = ''; |
| 129 | - if(!empty($order_postmeta['order_date'])){ |
|
| 130 | - $order_main_info .= '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>'.__('Order date','wpshop').' : </strong><br/>'.mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true).'</div>'; |
|
| 129 | + if (!empty($order_postmeta['order_date'])) { |
|
| 130 | + $order_main_info .= '<div class="wps-product-section"><span class="dashicons dashicons-calendar-alt"></span> <strong>' . __('Order date', 'wpshop') . ' : </strong><br/>' . mysql2date('d F Y H:i:s', $order_postmeta['order_date'], true) . '</div>'; |
|
| 131 | 131 | } |
| 132 | 132 | $order_main_info .= '<div class="wps-product-section">'; |
| 133 | - if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){ |
|
| 134 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>'; |
|
| 133 | + if (empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))) { |
|
| 134 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Temporary quotation reference', 'wpshop') . ': </strong>' . self::get_new_pre_order_reference(false) . '<br/>'; |
|
| 135 | 135 | } |
| 136 | - else{ |
|
| 137 | - if(!empty($order_postmeta['order_key'])){ |
|
| 138 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>'; |
|
| 136 | + else { |
|
| 137 | + if (!empty($order_postmeta['order_key'])) { |
|
| 138 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Order reference', 'wpshop') . ' : </strong>' . $order_postmeta['order_key'] . '<br/>'; |
|
| 139 | 139 | } |
| 140 | - if(!empty($order_postmeta['order_temporary_key'])){ |
|
| 141 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Pre-order reference','wpshop').': </strong>'.$order_postmeta['order_temporary_key'].'<br/>'; |
|
| 142 | - $post_ID = !empty( $_GET['post'] ) ? (int) $_GET['post'] : 0; |
|
| 143 | - $order_main_info .= '<a href="' .admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $post_ID . '&mode=pdf' ) . '">' .__('Download the quotation', 'wpshop'). '</a><br />'; |
|
| 140 | + if (!empty($order_postmeta['order_temporary_key'])) { |
|
| 141 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Pre-order reference', 'wpshop') . ': </strong>' . $order_postmeta['order_temporary_key'] . '<br/>'; |
|
| 142 | + $post_ID = !empty($_GET['post']) ? (int)$_GET['post'] : 0; |
|
| 143 | + $order_main_info .= '<a href="' . admin_url('admin-post.php?action=wps_invoice&order_id=' . $post_ID . '&mode=pdf') . '">' . __('Download the quotation', 'wpshop') . '</a><br />'; |
|
| 144 | 144 | } |
| 145 | - if(!empty($order_postmeta['order_invoice_ref'])){ |
|
| 145 | + if (!empty($order_postmeta['order_invoice_ref'])) { |
|
| 146 | 146 | $sub_tpl_component = array(); |
| 147 | 147 | $sub_tpl_component['ADMIN_ORDER_RECEIVED_PAYMENT_INVOICE_REF'] = $order_postmeta['order_invoice_ref']; |
| 148 | 148 | $sub_tpl_component['ADMIN_ORDER_PAYMENT_RECEIVED_LINE_CLASSES'] = ''; |
| 149 | - $sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = admin_url( 'admin-post.php?action=wps_invoice&order_id=' . $order->ID ); |
|
| 149 | + $sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = admin_url('admin-post.php?action=wps_invoice&order_id=' . $order->ID); |
|
| 150 | 150 | $order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin'); |
| 151 | - $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . ''; |
|
| 151 | + $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>' . __('Invoice number', 'wpshop') . ': </strong>' . $order_postmeta['order_invoice_ref'] . '<br/>' . $order_invoice_download . ''; |
|
| 152 | 152 | } |
| 153 | 153 | else { |
| 154 | 154 | $order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin'); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | /*Add the current order status in display**/ |
| 161 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= ( !empty($order_postmeta['order_status']) ) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) ) : ''; |
|
| 161 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= (!empty($order_postmeta['order_status'])) ? (sprintf('<span class="order_status_' . $order->ID . ' wpshop_order_status_container wpshop_order_status_%1$s ">%2$s</span>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop'))) : ''; |
|
| 162 | 162 | |
| 163 | 163 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= $order_main_info; |
| 164 | 164 | |
@@ -184,21 +184,21 @@ discard block |
||
| 184 | 184 | }*/ |
| 185 | 185 | |
| 186 | 186 | /*Add the button regarding the order status**/ |
| 187 | - if ( !empty($order_postmeta['order_status']) ) { |
|
| 188 | - if( in_array( $order_postmeta['order_status'], array( 'awaiting_payment', 'partially_paid' ) ) ) { |
|
| 189 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><input id="wps_direct_link_url" type="text" value="' . wpshop_checkout::wps_direct_payment_link_url( $order->ID ) . '"/><a class="wps-bton-second-mini-rounded" data-copy-target="#wps_direct_link_url" title="' . __( 'Copy', 'wpshop' ) . '"><span class="dashicons dashicons-editor-paste-text"></span></a><a data-nonce="' . wp_create_nonce( 'wps_send_direct_payment_link' ) . '" role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" title="' . __( 'Send by mail', 'wpshop' ) . '"><span class="dashicons dashicons-email"></span></a><p>' . sprintf( __( 'Link is valid until %s', 'wpshop' ), mysql2date( get_option( 'date_format' ), date_format( date_create( date('Y-m') . ' + 1month - 1day' ), 'Y-m-d H:i:s' ), true ) ) . '</div>'; |
|
| 187 | + if (!empty($order_postmeta['order_status'])) { |
|
| 188 | + if (in_array($order_postmeta['order_status'], array('awaiting_payment', 'partially_paid'))) { |
|
| 189 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><input id="wps_direct_link_url" type="text" value="' . wpshop_checkout::wps_direct_payment_link_url($order->ID) . '"/><a class="wps-bton-second-mini-rounded" data-copy-target="#wps_direct_link_url" title="' . __('Copy', 'wpshop') . '"><span class="dashicons dashicons-editor-paste-text"></span></a><a data-nonce="' . wp_create_nonce('wps_send_direct_payment_link') . '" role="button" class="wps-bton-second-mini-rounded send_direct_payment_link" href="#" title="' . __('Send by mail', 'wpshop') . '"><span class="dashicons dashicons-email"></span></a><p>' . sprintf(__('Link is valid until %s', 'wpshop'), mysql2date(get_option('date_format'), date_format(date_create(date('Y-m') . ' + 1month - 1day'), 'Y-m-d H:i:s'), true)) . '</div>'; |
|
| 190 | 190 | } |
| 191 | - if( $order_postmeta['order_status'] == 'awaiting_payment' ) { |
|
| 192 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_'.$order->ID.'" >'.__('Cancel this order', 'wpshop').'</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>'; |
|
| 191 | + if ($order_postmeta['order_status'] == 'awaiting_payment') { |
|
| 192 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section"><button class="wps-bton-second-mini-rounded markAsCanceled order_' . $order->ID . '" >' . __('Cancel this order', 'wpshop') . '</button><input type="hidden" id="markascanceled_order_hidden_indicator" name="markascanceled_order_hidden_indicator" /></div>'; |
|
| 193 | 193 | } |
| 194 | - $credit_meta = get_post_meta( $order->ID, '_wps_order_credit', true ); |
|
| 194 | + $credit_meta = get_post_meta($order->ID, '_wps_order_credit', true); |
|
| 195 | 195 | |
| 196 | - if ( empty($credit_meta) ) { |
|
| 197 | - if( $order_postmeta['order_status'] == 'refunded') { |
|
| 198 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .admin_url( 'admin-post.php?action=wps_invoice&order_id=' .$order->ID. '&invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok' ). '" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>'; |
|
| 196 | + if (empty($credit_meta)) { |
|
| 197 | + if ($order_postmeta['order_status'] == 'refunded') { |
|
| 198 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' . __('Credit Slip number', 'wpshop') . ' : <strong>' . ((!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref'])) ? '<a href="' . admin_url('admin-post.php?action=wps_invoice&order_id=' . $order->ID . '&invoice_ref=' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '&credit_slip=ok') . '" target="_blank">' . $order_postmeta['order_payment']['refunded_action']['credit_slip_ref'] . '</a>' : '') . '</strong></div>'; |
|
| 199 | 199 | } |
| 200 | 200 | else { |
| 201 | - $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>'; |
|
| 201 | + $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' . $order->ID . '">' . __('Refund this order', 'wpshop') . '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>'; |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | function order_container_in_admin() { |
| 211 | 211 | global $post; |
| 212 | 212 | $output = '<div id="wps_order_content_container">'; |
| 213 | - $output .= self::order_content( $post ); |
|
| 213 | + $output .= self::order_content($post); |
|
| 214 | 214 | $output .= '</div>'; |
| 215 | 215 | echo $output; |
| 216 | 216 | } |
@@ -221,13 +221,13 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @param order $post The complete order content |
| 223 | 223 | */ |
| 224 | - function order_content( $post ) { |
|
| 224 | + function order_content($post) { |
|
| 225 | 225 | $order_content = ''; |
| 226 | 226 | |
| 227 | 227 | $order = get_post_meta($post->ID, '_order_postmeta', true); |
| 228 | 228 | |
| 229 | 229 | $order_content .= '<div id="order_product_container" class="order_product_container wpshop_cls" >'; |
| 230 | - if($order){/* Read the order content if the order has product */ |
|
| 230 | + if ($order) {/* Read the order content if the order has product */ |
|
| 231 | 231 | $order_content .= '<input type="hidden" value="" name="order_products_to_delete" id="order_products_to_delete" />' . wpshop_cart::display_cart(true, $order, 'admin'); |
| 232 | 232 | if (empty($order['order_invoice_ref'])) { |
| 233 | 233 | $order_content .= '<div id="order_refresh_button_container" class="wpshop_clear_block" ><input type="button" class="button-primary alignright wpshopHide" id="wpshop_admin_order_recalculate" value="' . __('Refresh order informations', 'wpshop') . '" /></div>'; |
@@ -245,18 +245,18 @@ discard block |
||
| 245 | 245 | /** Generate the billing reference regarding the order $order_id |
| 246 | 246 | * @return void |
| 247 | 247 | */ |
| 248 | - function order_generate_billing_number($order_id, $force_invoicing = false){ |
|
| 248 | + function order_generate_billing_number($order_id, $force_invoicing = false) { |
|
| 249 | 249 | global $wpdb, $wpshop_modules_billing; |
| 250 | 250 | |
| 251 | 251 | // Get the order from the db |
| 252 | 252 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 253 | 253 | |
| 254 | 254 | // If the payment is completed |
| 255 | - if(($order['order_status']=='completed') || $force_invoicing) { |
|
| 255 | + if (($order['order_status'] == 'completed') || $force_invoicing) { |
|
| 256 | 256 | |
| 257 | 257 | // If the reference hasn't been generated yet |
| 258 | - if(empty($order['order_invoice_ref'])) { |
|
| 259 | - $order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number( $order_id ); |
|
| 258 | + if (empty($order['order_invoice_ref'])) { |
|
| 259 | + $order['order_invoice_ref'] = $wpshop_modules_billing->generate_invoice_number($order_id); |
|
| 260 | 260 | |
| 261 | 261 | update_post_meta($order_id, '_order_postmeta', $order); |
| 262 | 262 | } |
@@ -267,45 +267,45 @@ discard block |
||
| 267 | 267 | /** Renvoi une nouvelle r�f�rence unique pour une commande |
| 268 | 268 | * @return int |
| 269 | 269 | */ |
| 270 | - public static function get_new_order_reference(){ |
|
| 270 | + public static function get_new_order_reference() { |
|
| 271 | 271 | $number_figures = get_option('wpshop_order_number_figures', false); |
| 272 | 272 | /* If the number doesn't exist, we create a default one */ |
| 273 | - if(!$number_figures){ |
|
| 273 | + if (!$number_figures) { |
|
| 274 | 274 | $number_figures = 5; |
| 275 | 275 | update_option('wpshop_order_number_figures', $number_figures); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | $order_current_number = get_option('wpshop_order_current_number', false); |
| 279 | 279 | /* If the counter doesn't exist, we initiate it */ |
| 280 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 280 | + if (!$order_current_number) { $order_current_number = 1; } |
|
| 281 | 281 | else { $order_current_number++; } |
| 282 | 282 | update_option('wpshop_order_current_number', $order_current_number); |
| 283 | 283 | |
| 284 | - $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
|
| 285 | - return WPSHOP_ORDER_REFERENCE_PREFIX.$order_ref; |
|
| 284 | + $order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number); |
|
| 285 | + return WPSHOP_ORDER_REFERENCE_PREFIX . $order_ref; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** Renvoi une nouvelle r�f�rence unique pour un devis |
| 289 | 289 | * @return int |
| 290 | 290 | */ |
| 291 | - public static function get_new_pre_order_reference($save = true){ |
|
| 291 | + public static function get_new_pre_order_reference($save = true) { |
|
| 292 | 292 | $number_figures = get_option('wpshop_order_number_figures', false); |
| 293 | 293 | /* If the number doesn't exist, we create a default one */ |
| 294 | - if(!$number_figures){ |
|
| 294 | + if (!$number_figures) { |
|
| 295 | 295 | $number_figures = 5; |
| 296 | 296 | update_option('wpshop_order_number_figures', $number_figures); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | $order_current_number = get_option('wpshop_preorder_current_number', false); |
| 300 | 300 | /* If the counter doesn't exist, we initiate it */ |
| 301 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 301 | + if (!$order_current_number) { $order_current_number = 1; } |
|
| 302 | 302 | else { $order_current_number++; } |
| 303 | - if($save){ |
|
| 303 | + if ($save) { |
|
| 304 | 304 | update_option('wpshop_preorder_current_number', $order_current_number); |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
|
| 308 | - return WPSHOP_PREORDER_REFERENCE_PREFIX.$order_ref; |
|
| 307 | + $order_ref = (string)sprintf('%0' . $number_figures . 'd', $order_current_number); |
|
| 308 | + return WPSHOP_PREORDER_REFERENCE_PREFIX . $order_ref; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | |
@@ -320,24 +320,24 @@ discard block |
||
| 320 | 320 | * |
| 321 | 321 | * @return void |
| 322 | 322 | */ |
| 323 | - public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id='', $billing_address_id=''){ |
|
| 323 | + public static function set_order_customer_addresses($user_id, $order_id, $shipping_address_id = '', $billing_address_id = '') { |
|
| 324 | 324 | /** Get order informations */ |
| 325 | 325 | $billing_info['id'] = get_post_meta($billing_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 326 | - $billing_info['address'] = get_post_meta($billing_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 327 | - $billing_info['address_id'] = ( !empty($_SESSION['billing_address']) ) ? intval( $_SESSION['billing_address'] ) : ''; |
|
| 328 | - if ( !empty($_SESSION['shipping_partner_id']) ) { |
|
| 329 | - $partner_address_id = get_post_meta( $_SESSION['shipping_partner_id'], '_wpshop_attached_address', true); |
|
| 326 | + $billing_info['address'] = get_post_meta($billing_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 327 | + $billing_info['address_id'] = (!empty($_SESSION['billing_address'])) ? intval($_SESSION['billing_address']) : ''; |
|
| 328 | + if (!empty($_SESSION['shipping_partner_id'])) { |
|
| 329 | + $partner_address_id = get_post_meta($_SESSION['shipping_partner_id'], '_wpshop_attached_address', true); |
|
| 330 | 330 | if (!empty($partner_address_id)) { |
| 331 | - foreach( $partner_address_id as $address_id ) { |
|
| 331 | + foreach ($partner_address_id as $address_id) { |
|
| 332 | 332 | $shipping_info['id'] = get_post_meta($address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 333 | - $shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 333 | + $shipping_info['address'] = get_post_meta($address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | else { |
| 338 | 338 | $shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 339 | - $shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
|
| 340 | - $shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : ''; |
|
| 339 | + $shipping_info['address'] = get_post_meta($shipping_address_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_metadata', true); |
|
| 340 | + $shipping_info['address_id'] = (!empty($_SESSION['shipping_address'])) ? intval($_SESSION['shipping_address']) : ''; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | $order_info = array('billing' => $billing_info, 'shipping' => $shipping_info); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | /** Set the custom colums |
| 351 | 351 | * @return array |
| 352 | 352 | */ |
| 353 | - static function orders_edit_columns($columns){ |
|
| 353 | + static function orders_edit_columns($columns) { |
|
| 354 | 354 | $columns = array( |
| 355 | 355 | 'cb' => '<input type="checkbox" />', |
| 356 | 356 | 'order_identifier' => __('Identifiers', 'wpshop'), |
@@ -370,42 +370,42 @@ discard block |
||
| 370 | 370 | * @return array |
| 371 | 371 | */ |
| 372 | 372 | public static function orders_custom_columns($column, $post_id) { |
| 373 | - if ( get_post_type( $post_id ) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) { |
|
| 373 | + if (get_post_type($post_id) == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) { |
|
| 374 | 374 | global $civility, $order_status; |
| 375 | 375 | |
| 376 | 376 | $metadata = get_post_custom(); |
| 377 | 377 | |
| 378 | - $order_postmeta = isset($metadata['_order_postmeta'][0])?unserialize($metadata['_order_postmeta'][0]):''; |
|
| 379 | - $addresses = get_post_meta($post_id,'_order_info', true); |
|
| 378 | + $order_postmeta = isset($metadata['_order_postmeta'][0]) ? unserialize($metadata['_order_postmeta'][0]) : ''; |
|
| 379 | + $addresses = get_post_meta($post_id, '_order_info', true); |
|
| 380 | 380 | |
| 381 | - switch($column){ |
|
| 381 | + switch ($column) { |
|
| 382 | 382 | case "order_identifier": |
| 383 | - if( !empty( $order_postmeta['order_key'] ) ) { |
|
| 383 | + if (!empty($order_postmeta['order_key'])) { |
|
| 384 | 384 | echo '<b>' . $order_postmeta['order_key'] . '</b><br>'; |
| 385 | 385 | } |
| 386 | - if( !empty( $order_postmeta['order_invoice_ref'] ) ) { |
|
| 386 | + if (!empty($order_postmeta['order_invoice_ref'])) { |
|
| 387 | 387 | echo '<i>' . $order_postmeta['order_invoice_ref'] . '</i>'; |
| 388 | - } elseif( !empty($order_postmeta['order_temporary_key'] ) ) { |
|
| 388 | + } elseif (!empty($order_postmeta['order_temporary_key'])) { |
|
| 389 | 389 | echo '<b>' . $order_postmeta['order_temporary_key'] . '</b>'; |
| 390 | 390 | } |
| 391 | 391 | break; |
| 392 | 392 | |
| 393 | 393 | case "order_status": |
| 394 | - echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_'.$post_id.'">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop'); |
|
| 394 | + echo !empty($order_postmeta['order_status']) ? sprintf('<mark class="%s" id="order_status_' . $post_id . '">%s</mark>', sanitize_title(strtolower($order_postmeta['order_status'])), __($order_status[strtolower($order_postmeta['order_status'])], 'wpshop')) : __('Unknown Status', 'wpshop'); |
|
| 395 | 395 | break; |
| 396 | 396 | |
| 397 | 397 | case "order_billing": |
| 398 | - if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) { |
|
| 398 | + if (!empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address'])) { |
|
| 399 | 399 | $billing = $addresses['billing']['address']; |
| 400 | 400 | } |
| 401 | - else if ( !empty($addresses['billing']) ) { |
|
| 401 | + else if (!empty($addresses['billing'])) { |
|
| 402 | 402 | $billing = $addresses['billing']; |
| 403 | 403 | } |
| 404 | - if ( !empty($billing) ) { |
|
| 405 | - echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null).' <strong>'.(!empty($billing['address_first_name']) ? $billing['address_first_name'] : null).' '.(!empty($billing['address_last_name']) ? $billing['address_last_name'] : null).'</strong>'; |
|
| 406 | - echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />'; |
|
| 407 | - echo (!empty($billing['address']) ? $billing['address'] : null).'<br />'; |
|
| 408 | - echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null); |
|
| 404 | + if (!empty($billing)) { |
|
| 405 | + echo (!empty($billing['civility']) ? __(wpshop_attributes::get_attribute_type_select_option_info($billing['civility'], 'label', 'custom'), 'wpshop') : null) . ' <strong>' . (!empty($billing['address_first_name']) ? $billing['address_first_name'] : null) . ' ' . (!empty($billing['address_last_name']) ? $billing['address_last_name'] : null) . '</strong>'; |
|
| 406 | + echo empty($billing['company']) ? '<br />' : ', <i>' . $billing['company'] . '</i><br />'; |
|
| 407 | + echo (!empty($billing['address']) ? $billing['address'] : null) . '<br />'; |
|
| 408 | + echo (!empty($billing['postcode']) ? $billing['postcode'] : null) . ' ' . (!empty($billing['city']) ? $billing['city'] : null) . ', ' . (!empty($billing['country']) ? $billing['country'] : null); |
|
| 409 | 409 | echo (!empty($billing['phone']) ? '<br />' . $billing['phone'] : ''); |
| 410 | 410 | } |
| 411 | 411 | else { |
@@ -414,33 +414,33 @@ discard block |
||
| 414 | 414 | break; |
| 415 | 415 | |
| 416 | 416 | case "order_shipping": |
| 417 | - if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) { |
|
| 417 | + if (!empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address'])) { |
|
| 418 | 418 | $shipping = $addresses['shipping']['address']; |
| 419 | 419 | } |
| 420 | - else if ( !empty($addresses['shipping']) ) { |
|
| 420 | + else if (!empty($addresses['shipping'])) { |
|
| 421 | 421 | $shipping = $addresses['shipping']; |
| 422 | 422 | } |
| 423 | - if ( !empty($shipping) ) { |
|
| 424 | - echo '<strong>'.(!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null).' '.(!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null).'</strong>'; |
|
| 425 | - echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />'; |
|
| 426 | - echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />'; |
|
| 427 | - echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null); |
|
| 423 | + if (!empty($shipping)) { |
|
| 424 | + echo '<strong>' . (!empty($shipping['address_first_name']) ? $shipping['address_first_name'] : null) . ' ' . (!empty($shipping['address_last_name']) ? $shipping['address_last_name'] : null) . '</strong>'; |
|
| 425 | + echo empty($shipping['company']) ? '<br />' : ', <i>' . $shipping['company'] . '</i><br />'; |
|
| 426 | + echo (!empty($shipping['address']) ? $shipping['address'] : null) . '<br />'; |
|
| 427 | + echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null) . ' ' . (!empty($shipping['city']) ? $shipping['city'] : null) . ', ' . (!empty($shipping['country']) ? $shipping['country'] : null); |
|
| 428 | 428 | } |
| 429 | - else{ |
|
| 429 | + else { |
|
| 430 | 430 | echo __('No information available for user shipping', 'wpshop'); |
| 431 | 431 | } |
| 432 | 432 | break; |
| 433 | 433 | |
| 434 | 434 | case "order_type": |
| 435 | - echo '<a href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.(!empty($order_postmeta['order_temporary_key']) ? __('Quotation','wpshop') : __('Basic order','wpshop')).'</a>'; |
|
| 435 | + echo '<a href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . (!empty($order_postmeta['order_temporary_key']) ? __('Quotation', 'wpshop') : __('Basic order', 'wpshop')) . '</a>'; |
|
| 436 | 436 | $buttons = '<p class="row-actions">'; |
| 437 | 437 | // Voir la commande |
| 438 | - $buttons .= '<a class="button button-small" href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">'.__('View', 'wpshop').'</a>'; |
|
| 438 | + $buttons .= '<a class="button button-small" href="' . admin_url('post.php?post=' . $post_id . '&action=edit') . '">' . __('View', 'wpshop') . '</a>'; |
|
| 439 | 439 | // Marquer comme envoy� |
| 440 | 440 | if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) { |
| 441 | - $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> '; |
|
| 441 | + $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_' . $post_id . ' wps-bton-loader">' . __('Mark as shipped', 'wpshop') . '</a> '; |
|
| 442 | 442 | } |
| 443 | - else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 443 | + else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment')) { |
|
| 444 | 444 | // $buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' '; |
| 445 | 445 | } |
| 446 | 446 | $buttons .= '</p>'; |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | |
| 454 | 454 | case "order_total": |
| 455 | 455 | $currency = !empty($order_postmeta['order_currency']) ? $order_postmeta['order_currency'] : get_option('wpshop_shop_default_currency'); |
| 456 | - echo isset( $order_postmeta['order_grand_total'] ) ? number_format( $order_postmeta['order_grand_total'], 2, '.', '' ).' '. wpshop_tools::wpshop_get_sigle($currency) : 'NaN'; |
|
| 456 | + echo isset($order_postmeta['order_grand_total']) ? number_format($order_postmeta['order_grand_total'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_sigle($currency) : 'NaN'; |
|
| 457 | 457 | break; |
| 458 | 458 | |
| 459 | 459 | /*case "order_actions": |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | public static function list_table_filters() { |
| 484 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
| 485 | - $entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
| 486 | - $entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : ''; |
|
| 487 | - $entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : ''; |
|
| 484 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 485 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
| 486 | + $entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : ''; |
|
| 487 | + $entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : ''; |
|
| 488 | 488 | |
| 489 | 489 | if (isset($post_type)) { |
| 490 | 490 | if (post_type_exists($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER)) { |
@@ -496,23 +496,23 @@ discard block |
||
| 496 | 496 | echo wpshop_form::form_input_select('entity_filter', 'entity_filter', $filter_possibilities, $entity_filter, '', 'index'); |
| 497 | 497 | $min = $entity_filter_btpf; |
| 498 | 498 | $max = $entity_filter_btps; |
| 499 | - echo ' <label for="entity_filter_btpf">'.__('Between two prices', 'wpshop').'</label> '; |
|
| 500 | - echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="'.__('Minimum price', 'wpshop').'"', null); |
|
| 501 | - echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="'.__('Maximum price', 'wpshop').'"', null); |
|
| 499 | + echo ' <label for="entity_filter_btpf">' . __('Between two prices', 'wpshop') . '</label> '; |
|
| 500 | + echo wpshop_form::form_input('entity_filter_btpf', 'entity_filter_btpf', $min, 'text', 'placeholder="' . __('Minimum price', 'wpshop') . '"', null); |
|
| 501 | + echo wpshop_form::form_input('entity_filter_btps', 'entity_filter_btps', $max, 'text', 'placeholder="' . __('Maximum price', 'wpshop') . '"', null); |
|
| 502 | 502 | } |
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | public static function list_table_filter_parse_query($query) { |
| 507 | 507 | global $pagenow, $wpdb; |
| 508 | - $post_type = !empty( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : ''; |
|
| 509 | - $entity_filter = !empty( $_GET['entity_filter'] ) ? sanitize_text_field( $_GET['entity_filter'] ) : ''; |
|
| 510 | - $entity_filter_btpf = !empty( $_GET['entity_filter_btpf'] ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : ''; |
|
| 511 | - $entity_filter_btps = !empty( $_GET['entity_filter_btps'] ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : ''; |
|
| 508 | + $post_type = !empty($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : ''; |
|
| 509 | + $entity_filter = !empty($_GET['entity_filter']) ? sanitize_text_field($_GET['entity_filter']) : ''; |
|
| 510 | + $entity_filter_btpf = !empty($_GET['entity_filter_btpf']) ? sanitize_text_field($_GET['entity_filter_btpf']) : ''; |
|
| 511 | + $entity_filter_btps = !empty($_GET['entity_filter_btps']) ? sanitize_text_field($_GET['entity_filter_btps']) : ''; |
|
| 512 | 512 | |
| 513 | - if ( is_admin() && ($pagenow == 'edit.php') && !empty( $post_type ) && ( $post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) && !empty( $entity_filter ) ) { |
|
| 513 | + if (is_admin() && ($pagenow == 'edit.php') && !empty($post_type) && ($post_type == WPSHOP_NEWTYPE_IDENTIFIER_ORDER) && !empty($entity_filter)) { |
|
| 514 | 514 | $check = null; |
| 515 | - switch ( $entity_filter ) { |
|
| 515 | + switch ($entity_filter) { |
|
| 516 | 516 | case 'all': |
| 517 | 517 | $sql_query = $wpdb->prepare( |
| 518 | 518 | "SELECT ID |
@@ -576,27 +576,27 @@ discard block |
||
| 576 | 576 | break; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - if ( !empty( $check ) ) { |
|
| 580 | - if( !empty($no_btp) && $no_btp == 'yes' ) { |
|
| 579 | + if (!empty($check)) { |
|
| 580 | + if (!empty($no_btp) && $no_btp == 'yes') { |
|
| 581 | 581 | $min = 'minimum'; |
| 582 | 582 | $max = 'maximum'; |
| 583 | 583 | } else { |
| 584 | - $min = ( !empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf']) ) ? sanitize_text_field( $_GET['entity_filter_btpf'] ) : 'minimum'; |
|
| 585 | - $max = ( !empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps']) ) ? sanitize_text_field( $_GET['entity_filter_btps'] ) : 'maximum'; |
|
| 584 | + $min = (!empty($_GET['entity_filter_btpf']) && is_numeric($_GET['entity_filter_btpf'])) ? sanitize_text_field($_GET['entity_filter_btpf']) : 'minimum'; |
|
| 585 | + $max = (!empty($_GET['entity_filter_btps']) && is_numeric($_GET['entity_filter_btps'])) ? sanitize_text_field($_GET['entity_filter_btps']) : 'maximum'; |
|
| 586 | 586 | } |
| 587 | 587 | $results = $wpdb->get_results($sql_query); |
| 588 | 588 | $post_id_list = array(); |
| 589 | 589 | $i = 0; |
| 590 | - foreach($results as $item){ |
|
| 590 | + foreach ($results as $item) { |
|
| 591 | 591 | $meta_value = get_post_meta($item->ID, '_order_postmeta'); |
| 592 | - $price = ( !empty( $meta_value[0]['order_grand_total'] ) ) ? $meta_value[0]['order_grand_total'] : ''; |
|
| 593 | - if( $price >= $min || $min == 'minimum' ) { |
|
| 594 | - if( $price <= $max || $max == 'maximum' ) { |
|
| 592 | + $price = (!empty($meta_value[0]['order_grand_total'])) ? $meta_value[0]['order_grand_total'] : ''; |
|
| 593 | + if ($price >= $min || $min == 'minimum') { |
|
| 594 | + if ($price <= $max || $max == 'maximum') { |
|
| 595 | 595 | $post_id_list[] = $item->ID; |
| 596 | 596 | } |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | - if( empty($post_id_list) ) { |
|
| 599 | + if (empty($post_id_list)) { |
|
| 600 | 600 | $post_id_list[] = 'no_result'; |
| 601 | 601 | } |
| 602 | 602 | $query->query_vars[$check] = $post_id_list; |
@@ -607,55 +607,55 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | |
| 609 | 609 | |
| 610 | - function latest_products_ordered ( $orders ) { |
|
| 610 | + function latest_products_ordered($orders) { |
|
| 611 | 611 | global $wpdb; |
| 612 | 612 | $product_id = $output = ''; |
| 613 | 613 | $products = array(); |
| 614 | 614 | $display_option = get_option('wpshop_display_option'); |
| 615 | - if ( !empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered']) ) { |
|
| 616 | - foreach( $orders as $order ) { |
|
| 617 | - $order_content = get_post_meta( $order->ID, '_order_postmeta', true ); |
|
| 618 | - if ( !empty($order_content) && !empty( $order_content['order_items']) ) { |
|
| 615 | + if (!empty($orders) && !empty($display_option) && !empty($display_option['latest_products_ordered'])) { |
|
| 616 | + foreach ($orders as $order) { |
|
| 617 | + $order_content = get_post_meta($order->ID, '_order_postmeta', true); |
|
| 618 | + if (!empty($order_content) && !empty($order_content['order_items'])) { |
|
| 619 | 619 | |
| 620 | - foreach( $order_content['order_items'] as $item ) { |
|
| 621 | - if ( count( $products) >= $display_option['latest_products_ordered'] ) { |
|
| 620 | + foreach ($order_content['order_items'] as $item) { |
|
| 621 | + if (count($products) >= $display_option['latest_products_ordered']) { |
|
| 622 | 622 | continue; |
| 623 | 623 | } |
| 624 | 624 | $product_id = $item['item_id']; |
| 625 | - if ( !empty( $item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition']) ) { |
|
| 626 | - $parent_def = wpshop_products::get_parent_variation( $item['item_id'] ); |
|
| 627 | - if ( !empty( $parent_def ) ) { |
|
| 625 | + if (!empty($item) && !empty($item['item_meta']) && !empty($item['item_meta']['variation_definition'])) { |
|
| 626 | + $parent_def = wpshop_products::get_parent_variation($item['item_id']); |
|
| 627 | + if (!empty($parent_def)) { |
|
| 628 | 628 | $parent_post = $parent_def['parent_post']; |
| 629 | 629 | $product_id = $parent_post->ID; |
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - if ( !in_array($product_id, $products) ) { |
|
| 633 | + if (!in_array($product_id, $products)) { |
|
| 634 | 634 | $products[] = $product_id; |
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | - if ( !empty($products) ) { |
|
| 639 | + if (!empty($products)) { |
|
| 640 | 640 | $products_id = implode(",", $products); |
| 641 | - $output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' .$products_id. '"]')) ); |
|
| 641 | + $output = wpshop_display::display_template_element('latest_products_ordered', array('LATEST_PRODUCTS_ORDERED' => do_shortcode('[wpshop_products pid="' . $products_id . '"]'))); |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | return $output; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - function get_order_list_for_customer( $customer_id ) { |
|
| 647 | + function get_order_list_for_customer($customer_id) { |
|
| 648 | 648 | global $wpdb; |
| 649 | 649 | $output = ''; |
| 650 | 650 | |
| 651 | - if( !empty($customer_id) ) { |
|
| 652 | - $query = $wpdb->prepare( 'SELECT * |
|
| 653 | - FROM ' .$wpdb->posts. ' |
|
| 651 | + if (!empty($customer_id)) { |
|
| 652 | + $query = $wpdb->prepare('SELECT * |
|
| 653 | + FROM ' .$wpdb->posts . ' |
|
| 654 | 654 | WHERE post_author = %d |
| 655 | - AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 656 | - $orders = $wpdb->get_results( $query ); |
|
| 655 | + AND post_type = %s', $customer_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 656 | + $orders = $wpdb->get_results($query); |
|
| 657 | 657 | |
| 658 | - foreach( $orders as $order ) { |
|
| 658 | + foreach ($orders as $order) { |
|
| 659 | 659 | |
| 660 | 660 | } |
| 661 | 661 | } |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | var $creating_account = true; |
| 24 | 24 | |
| 25 | 25 | /** Constructor of the class |
| 26 | - * @return void |
|
| 27 | - */ |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | 28 | function __construct () { |
| 29 | 29 | } |
| 30 | 30 | |
@@ -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 | /** |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | /** Constructor of the class |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - function __construct () { |
|
| 28 | + function __construct() { |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | - public static function process_checkout($paymentMethod='paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) { |
|
| 32 | + public static function process_checkout($paymentMethod = 'paypal', $order_id = 0, $customer_id = 0, $customer_billing_address_id = 0, $customer_shipping_address_id = 0) { |
|
| 33 | 33 | |
| 34 | 34 | global $wpdb, $wpshop, $wpshop_cart; |
| 35 | 35 | $wps_message = new wps_message_ctr(); |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | if (is_user_logged_in()) : |
| 39 | 39 | $user_id = get_current_user_id(); |
| 40 | 40 | |
| 41 | - if ( $customer_id != 0 ) { |
|
| 41 | + if ($customer_id != 0) { |
|
| 42 | 42 | $user_id = $customer_id; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // If the order is already created in the db |
| 46 | - if(!empty($order_id) && is_numeric($order_id)) { |
|
| 46 | + if (!empty($order_id) && is_numeric($order_id)) { |
|
| 47 | 47 | $order = get_post_meta($order_id, '_order_postmeta', true); |
| 48 | 48 | |
| 49 | - if(!empty($order)) { |
|
| 50 | - if($order['customer_id'] == $user_id) { |
|
| 49 | + if (!empty($order)) { |
|
| 50 | + if ($order['customer_id'] == $user_id) { |
|
| 51 | 51 | $order['payment_method'] = $paymentMethod; |
| 52 | - $_SESSION['order_id'] = (int) $order_id; |
|
| 52 | + $_SESSION['order_id'] = (int)$order_id; |
|
| 53 | 53 | // Store cart in session |
| 54 | 54 | //wpshop_cart::store_cart_in_session($order); |
| 55 | 55 | // Add a payment |
| 56 | - $order['order_payment']['received'][] = array( 'method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id() ); |
|
| 56 | + $order['order_payment']['received'][] = array('method' => $paymentMethod, 'waited_amount' => $order['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => get_current_user_id()); |
|
| 57 | 57 | |
| 58 | 58 | // On enregistre la commande |
| 59 | 59 | update_post_meta($order_id, '_order_postmeta', $order); |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | else $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop')); |
| 65 | 65 | } |
| 66 | - else{ |
|
| 66 | + else { |
|
| 67 | 67 | $order_data = array( |
| 68 | 68 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, |
| 69 | - 'post_title' => sprintf(__('Order - %s','wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)), |
|
| 69 | + 'post_title' => sprintf(__('Order - %s', 'wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)), |
|
| 70 | 70 | 'post_status' => 'publish', |
| 71 | - 'post_excerpt' => !empty($_POST['wps-customer-comment']) ? sanitize_text_field( $_POST['wps-customer-comment'] ) : '', |
|
| 71 | + 'post_excerpt' => !empty($_POST['wps-customer-comment']) ? sanitize_text_field($_POST['wps-customer-comment']) : '', |
|
| 72 | 72 | 'post_author' => $user_id, |
| 73 | 73 | 'comment_status' => 'closed' |
| 74 | 74 | ); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $order_tva = array(); |
| 79 | 79 | |
| 80 | 80 | //$cart = (array)$wpshop_cart->cart; |
| 81 | - if ( !empty($_SESSION['cart']) && !empty( $_SESSION['cart']['shipping_method']) ) { |
|
| 81 | + if (!empty($_SESSION['cart']) && !empty($_SESSION['cart']['shipping_method'])) { |
|
| 82 | 82 | $_SESSION['cart']['shipping_method'] = __('Standard shipping method', 'wpshop'); |
| 83 | 83 | } |
| 84 | 84 | $cart = (array)$_SESSION['cart']; |
@@ -90,35 +90,35 @@ discard block |
||
| 90 | 90 | $_SESSION['order_id'] = $order_id; |
| 91 | 91 | |
| 92 | 92 | // Cr�ation des codes de t�l�chargement si il y a des produits t�l�chargeable dans le panier |
| 93 | - if ( !empty( $cart['order_items'] ) ) { |
|
| 94 | - foreach($cart['order_items'] as $c) { |
|
| 93 | + if (!empty($cart['order_items'])) { |
|
| 94 | + foreach ($cart['order_items'] as $c) { |
|
| 95 | 95 | $product_id = $c['item_id']; |
| 96 | 96 | $product = null; |
| 97 | - if( isset( $c['item_meta']['variations'] ) ) { |
|
| 98 | - foreach ( $c['item_meta']['variations'] as $variation_id => $variation ) { |
|
| 99 | - if( isset( $variation['item_meta']['is_downloadable_'] ) ) { |
|
| 97 | + if (isset($c['item_meta']['variations'])) { |
|
| 98 | + foreach ($c['item_meta']['variations'] as $variation_id => $variation) { |
|
| 99 | + if (isset($variation['item_meta']['is_downloadable_'])) { |
|
| 100 | 100 | $product_id = $c['item_id'] . '__' . $variation_id; |
| 101 | - $product = wpshop_products::get_product_data( $product_id ); |
|
| 101 | + $product = wpshop_products::get_product_data($product_id); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | - if( !isset( $product ) ) { |
|
| 106 | - $product = wpshop_products::get_product_data( $c['item_id'] ); |
|
| 105 | + if (!isset($product)) { |
|
| 106 | + $product = wpshop_products::get_product_data($c['item_id']); |
|
| 107 | 107 | $product_id = $c['item_id']; |
| 108 | 108 | /** Check if it's a variation and check the parent product **/ |
| 109 | - if ( get_post_type( $c['item_id'] ) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ) { |
|
| 110 | - $parent_def = wpshop_products::get_parent_variation( $c['item_id'] ); |
|
| 111 | - if ( !empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_']) ) { |
|
| 109 | + if (get_post_type($c['item_id']) == WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION) { |
|
| 110 | + $parent_def = wpshop_products::get_parent_variation($c['item_id']); |
|
| 111 | + if (!empty($parent_def) && !empty($parent_def['parent_post_meta']) && !empty($parent_def['parent_post_meta']['is_downloadable_'])) { |
|
| 112 | 112 | $product['is_downloadable_'] = $parent_def['parent_post_meta']['is_downloadable_']; |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - if(!empty($product['is_downloadable_'])) { |
|
| 116 | + if (!empty($product['is_downloadable_'])) { |
|
| 117 | 117 | $download_codes[$product_id] = array('item_id' => $product_id, 'download_code' => uniqid('', true)); |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | - if(!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes); |
|
| 121 | + if (!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_' . $order_id, $download_codes); |
|
| 122 | 122 | |
| 123 | 123 | // Informations de commande � stocker |
| 124 | 124 | $currency = wpshop_tools::wpshop_get_currency(true); |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | 'order_payment' => array( |
| 134 | 134 | 'customer_choice' => array('method' => $paymentMethod), |
| 135 | 135 | 'received' => array('0' => array('method' => $paymentMethod, 'waited_amount' => $cart['order_amount_to_pay_now'], 'status' => 'waiting_payment', 'author' => $user_id)), |
| 136 | - 'shipping_method' => ( ( !empty( $_SESSION['shipping_method']) ) ? wpshop_tools::varSanitizer( $_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop') ) |
|
| 136 | + 'shipping_method' => ((!empty($_SESSION['shipping_method'])) ? wpshop_tools::varSanitizer($_SESSION['shipping_method']) : __('Standard shipping method', 'wpshop')) |
|
| 137 | 137 | ), |
| 138 | 138 | ), $cart); |
| 139 | 139 | |
| 140 | 140 | // Si c'est un devis |
| 141 | - if ( $paymentMethod == 'quotation' ) { |
|
| 141 | + if ($paymentMethod == 'quotation') { |
|
| 142 | 142 | $order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference(); |
| 143 | 143 | } |
| 144 | 144 | else { |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | //Round final amount |
| 149 | - $order['order_grand_total'] = number_format( round($order['order_grand_total'], 2), 2, '.', ''); |
|
| 150 | - $order['order_total_ttc'] = number_format( round($order['order_total_ttc'], 2), 2, '.', ''); |
|
| 151 | - $order['order_amount_to_pay_now'] = number_format( round($order['order_amount_to_pay_now'], 2), 2, '.', ''); |
|
| 149 | + $order['order_grand_total'] = number_format(round($order['order_grand_total'], 2), 2, '.', ''); |
|
| 150 | + $order['order_total_ttc'] = number_format(round($order['order_total_ttc'], 2), 2, '.', ''); |
|
| 151 | + $order['order_amount_to_pay_now'] = number_format(round($order['order_amount_to_pay_now'], 2), 2, '.', ''); |
|
| 152 | 152 | |
| 153 | 153 | /** On enregistre la commande */ |
| 154 | 154 | update_post_meta($order_id, '_order_postmeta', $order); |
@@ -157,75 +157,75 @@ discard block |
||
| 157 | 157 | update_post_meta($order_id, '_wpshop_order_status', $order['order_status']); |
| 158 | 158 | |
| 159 | 159 | |
| 160 | - do_action( 'wps_order_extra_save', $order_id ); |
|
| 160 | + do_action('wps_order_extra_save', $order_id); |
|
| 161 | 161 | |
| 162 | 162 | //Add an action to extra actions on order save |
| 163 | 163 | // @TODO : REQUEST |
| 164 | - $args = array( 'order_id' => $order_id, 'posted_data' => $_REQUEST ); |
|
| 165 | - wpshop_tools::create_custom_hook( 'wps_order_extra_save_action', $args ); |
|
| 164 | + $args = array('order_id' => $order_id, 'posted_data' => $_REQUEST); |
|
| 165 | + wpshop_tools::create_custom_hook('wps_order_extra_save_action', $args); |
|
| 166 | 166 | |
| 167 | 167 | /** Set custmer information for the order */ |
| 168 | - $shipping_address = ( !empty($shipping_address_option) && !empty($shipping_address_option['activate']) ) ? ( ( !empty($_SESSION['shipping_address']) ) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id ) : ''; |
|
| 169 | - $billing_address = ( !empty($_SESSION['billing_address']) ) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id; |
|
| 168 | + $shipping_address = (!empty($shipping_address_option) && !empty($shipping_address_option['activate'])) ? ((!empty($_SESSION['shipping_address'])) ? wpshop_tools::varSanitizer($_SESSION['shipping_address']) : $customer_shipping_address_id) : ''; |
|
| 169 | + $billing_address = (!empty($_SESSION['billing_address'])) ? wpshop_tools::varSanitizer($_SESSION['billing_address']) : $customer_billing_address_id; |
|
| 170 | 170 | |
| 171 | 171 | |
| 172 | - if ( !empty( $billing_address) ) { |
|
| 172 | + if (!empty($billing_address)) { |
|
| 173 | 173 | wpshop_orders::set_order_customer_addresses($user_id, $order_id, $shipping_address, $billing_address); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if ( !empty($_SESSION['shipping_address_to_save']) ) { |
|
| 176 | + if (!empty($_SESSION['shipping_address_to_save'])) { |
|
| 177 | 177 | $order_infos_postmeta = get_post_meta($order_id, '_order_info', true); |
| 178 | 178 | $order_infos_postmeta['shipping']['address'] = $_SESSION['shipping_address_to_save']; |
| 179 | 179 | $order_infos_postmeta['shipping']['address_id'] = ''; |
| 180 | 180 | update_post_meta($order_id, '_order_info', $order_infos_postmeta); |
| 181 | - unset( $_SESSION['shipping_address_to_save'] ); |
|
| 181 | + unset($_SESSION['shipping_address_to_save']); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | |
| 185 | 185 | /** Save Coupon use **/ |
| 186 | - if ( !empty($_SESSION['cart']['coupon_id']) ) { |
|
| 186 | + if (!empty($_SESSION['cart']['coupon_id'])) { |
|
| 187 | 187 | $wps_coupon_mdl = new wps_coupon_model(); |
| 188 | - $wps_coupon_mdl->save_coupon_use( $_SESSION['cart']['coupon_id'] ); |
|
| 188 | + $wps_coupon_mdl->save_coupon_use($_SESSION['cart']['coupon_id']); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** Notify the customer as the case */ |
| 192 | 192 | $user_info = get_userdata($user_id); |
| 193 | 193 | $email = $user_info->user_email; |
| 194 | - $first_name = $user_info->user_firstname ; |
|
| 194 | + $first_name = $user_info->user_firstname; |
|
| 195 | 195 | $last_name = $user_info->user_lastname; |
| 196 | 196 | |
| 197 | 197 | // Envoie du message de confirmation de commande au client |
| 198 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true); |
|
| 198 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
| 199 | 199 | |
| 200 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 201 | - $shipping_method = ( !empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ( (!empty($order_meta['order_payment']['shipping_method']) ) ? $order_meta['order_payment']['shipping_method'] : '' ); |
|
| 200 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 201 | + $shipping_method = (!empty($order_meta['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_meta['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_meta['order_payment']['shipping_method']]['name'] : ((!empty($order_meta['order_payment']['shipping_method'])) ? $order_meta['order_payment']['shipping_method'] : ''); |
|
| 202 | 202 | |
| 203 | - if ( !empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key']) ) { |
|
| 204 | - $wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '') ); |
|
| 203 | + if (!empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key'])) { |
|
| 204 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '')); |
|
| 205 | 205 | } |
| 206 | 206 | else { |
| 207 | - $email_option = get_option( 'wpshop_emails' ); |
|
| 208 | - if ( empty($email_option['send_confirmation_order_message']) ) { |
|
| 209 | - $payment_method_option = get_option( 'wps_payment_mode' ); |
|
| 210 | - $order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]) ) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; |
|
| 207 | + $email_option = get_option('wpshop_emails'); |
|
| 208 | + if (empty($email_option['send_confirmation_order_message'])) { |
|
| 209 | + $payment_method_option = get_option('wps_payment_mode'); |
|
| 210 | + $order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_meta['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_meta['order_payment']['customer_choice']['method']]['name'] : $order_meta['order_payment']['customer_choice']['method']; |
|
| 211 | 211 | |
| 212 | - $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ( ( !empty($order_meta['order_key']) ) ? $order_meta['order_key'] : ''),'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '' ) ); |
|
| 212 | + $wps_message->wpshop_prepared_email($email, 'WPSHOP_ORDER_CONFIRMATION_MESSAGE', array('order_id' => $order_id, 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_key' => ((!empty($order_meta['order_key'])) ? $order_meta['order_key'] : ''), 'order_date' => current_time('mysql', 0), 'order_payment_method' => $order_payment_method, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '')); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( empty($_SESSION['wps-pos-addon']) ) { |
|
| 216 | + if (empty($_SESSION['wps-pos-addon'])) { |
|
| 217 | 217 | $email_option = get_option('wpshop_emails'); |
| 218 | - if( empty($email_option) || ( !empty($email_option) && empty($email_option['send_confirmation_order_message']) ) ){ |
|
| 219 | - self::send_order_email_to_administrator( $order_id, $user_info ); |
|
| 218 | + if (empty($email_option) || (!empty($email_option) && empty($email_option['send_confirmation_order_message']))) { |
|
| 219 | + self::send_order_email_to_administrator($order_id, $user_info); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
| 224 | 224 | /** IF Order amount is 0, Finish the Order **/ |
| 225 | - if ( $cart['order_amount_to_pay_now'] == 0 ) { |
|
| 225 | + if ($cart['order_amount_to_pay_now'] == 0) { |
|
| 226 | 226 | $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
| 227 | 227 | $payment_status = 'completed'; |
| 228 | - $params_array = array ( |
|
| 228 | + $params_array = array( |
|
| 229 | 229 | 'method' =>'free', |
| 230 | 230 | 'waited_amount' => $order_meta['order_amount_to_pay_now'], |
| 231 | 231 | 'status' => 'payment_received', |
@@ -236,14 +236,14 @@ discard block |
||
| 236 | 236 | ); |
| 237 | 237 | wpshop_payment::check_order_payment_total_amount($order_id, $params_array, $payment_status); |
| 238 | 238 | } |
| 239 | - apply_filters( 'wpshop_finish_order_extra_actions', $order_id); |
|
| 239 | + apply_filters('wpshop_finish_order_extra_actions', $order_id); |
|
| 240 | 240 | } |
| 241 | 241 | endif; |
| 242 | 242 | return $order_id; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - public static function send_order_email_to_administrator ( $order_id, $customer_infos = '' ) { |
|
| 246 | - if ( !empty($order_id) ) { |
|
| 245 | + public static function send_order_email_to_administrator($order_id, $customer_infos = '') { |
|
| 246 | + if (!empty($order_id)) { |
|
| 247 | 247 | $wps_message = new wps_message_ctr(); |
| 248 | 248 | $order_infos = get_post_meta($order_id, '_order_postmeta', true); |
| 249 | 249 | //Send email to administrator(s) |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | $shop_admin_email = $shop_admin_email_option['contact_email']; |
| 252 | 252 | $order_tmp_key = ''; |
| 253 | 253 | |
| 254 | - $shipping_mode_option = get_option( 'wps_shipping_mode' ); |
|
| 255 | - $shipping_method = ( !empty($order_infos['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_infos['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_infos['order_payment']['shipping_method']]['name'] : ( (!empty($order_infos['order_payment']['shipping_method']) ) ? $order_infos['order_payment']['shipping_method'] : '' ); |
|
| 254 | + $shipping_mode_option = get_option('wps_shipping_mode'); |
|
| 255 | + $shipping_method = (!empty($order_infos['order_payment']['shipping_method']) && !empty($shipping_mode_option) && !empty($shipping_mode_option['modes']) && is_array($shipping_mode_option['modes']) && array_key_exists($order_infos['order_payment']['shipping_method'], $shipping_mode_option['modes'])) ? $shipping_mode_option['modes'][$order_infos['order_payment']['shipping_method']]['name'] : ((!empty($order_infos['order_payment']['shipping_method'])) ? $order_infos['order_payment']['shipping_method'] : ''); |
|
| 256 | 256 | |
| 257 | 257 | |
| 258 | - if( !empty( $order_infos ) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key']) ){ |
|
| 258 | + if (!empty($order_infos) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key'])) { |
|
| 259 | 259 | $message_type = 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE'; |
| 260 | 260 | } |
| 261 | 261 | else { |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | $order_tmp_key = $order_infos['order_temporary_key']; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $payment_method_option = get_option( 'wps_payment_mode' ); |
|
| 267 | - $order_payment_method = ( !empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_infos['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]) ) ? $payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]['name'] : $order_infos['order_payment']['customer_choice']['method']; |
|
| 266 | + $payment_method_option = get_option('wps_payment_mode'); |
|
| 267 | + $order_payment_method = (!empty($payment_method_option) && !empty($payment_method_option['mode']) && !empty($order_infos['order_payment']['customer_choice']['method']) && !empty($payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']])) ? $payment_method_option['mode'][$order_infos['order_payment']['customer_choice']['method']]['name'] : $order_infos['order_payment']['customer_choice']['method']; |
|
| 268 | 268 | |
| 269 | - $data_to_send = array('order_id' => $order_id, 'order_key' => $order_infos['order_key'], 'customer_email' => ( !empty($customer_infos) && !empty($customer_infos->user_email) ) ? $customer_infos->user_email : '' , 'customer_last_name' => ( !empty($customer_infos) && !empty($customer_infos->user_lastname) ) ? $customer_infos->user_lastname : '', 'customer_first_name' => ( !empty($customer_infos) && !empty($customer_infos->user_firstname) ) ? $customer_infos->user_firstname : '', 'order_date' => $order_infos['order_date'], 'order_payment_method' => $order_payment_method, 'order_temporary_key' => $order_tmp_key, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '','order_shipping_method' => $shipping_method, 'order_personnal_informations' => '' ); |
|
| 269 | + $data_to_send = array('order_id' => $order_id, 'order_key' => $order_infos['order_key'], 'customer_email' => (!empty($customer_infos) && !empty($customer_infos->user_email)) ? $customer_infos->user_email : '', 'customer_last_name' => (!empty($customer_infos) && !empty($customer_infos->user_lastname)) ? $customer_infos->user_lastname : '', 'customer_first_name' => (!empty($customer_infos) && !empty($customer_infos->user_firstname)) ? $customer_infos->user_firstname : '', 'order_date' => $order_infos['order_date'], 'order_payment_method' => $order_payment_method, 'order_temporary_key' => $order_tmp_key, 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => ''); |
|
| 270 | 270 | |
| 271 | - $wps_message->wpshop_prepared_email( $shop_admin_email, $message_type, $data_to_send, array('object_type' => 'order', 'object_id' => $order_id)); |
|
| 271 | + $wps_message->wpshop_prepared_email($shop_admin_email, $message_type, $data_to_send, array('object_type' => 'order', 'object_id' => $order_id)); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | * @param mixed $data Array or false. |
| 280 | 280 | * @return void |
| 281 | 281 | */ |
| 282 | - public static function wps_direct_payment_link( $data = false ) { |
|
| 283 | - $data = empty( $data ) ? self::wps_direct_payment_link_verify_token() : $data; |
|
| 284 | - if ( (bool) $data ) { |
|
| 285 | - wps_orders_ctr::pay_quotation( $data['oid'] ); |
|
| 286 | - wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ) ) . '?order_step=5' ); |
|
| 282 | + public static function wps_direct_payment_link($data = false) { |
|
| 283 | + $data = empty($data) ? self::wps_direct_payment_link_verify_token() : $data; |
|
| 284 | + if ((bool)$data) { |
|
| 285 | + wps_orders_ctr::pay_quotation($data['oid']); |
|
| 286 | + wpshop_tools::wpshop_safe_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) . '?order_step=5'); |
|
| 287 | 287 | } else { |
| 288 | - wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id' ) ) ) ); |
|
| 288 | + wpshop_tools::wpshop_safe_redirect(get_permalink(wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')))); |
|
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | /** |
@@ -295,12 +295,12 @@ discard block |
||
| 295 | 295 | * @param mixed $data Array or false. |
| 296 | 296 | * @return void |
| 297 | 297 | */ |
| 298 | - public static function wps_direct_payment_link_nopriv( $data = false ) { |
|
| 299 | - $data = empty( $data ) ? self::wps_direct_payment_link_verify_token() : $data; |
|
| 300 | - if ( (bool) $data ) { |
|
| 301 | - wp_set_auth_cookie( $data['cid'], true, is_ssl() ); |
|
| 298 | + public static function wps_direct_payment_link_nopriv($data = false) { |
|
| 299 | + $data = empty($data) ? self::wps_direct_payment_link_verify_token() : $data; |
|
| 300 | + if ((bool)$data) { |
|
| 301 | + wp_set_auth_cookie($data['cid'], true, is_ssl()); |
|
| 302 | 302 | } |
| 303 | - self::wps_direct_payment_link( $data ); |
|
| 303 | + self::wps_direct_payment_link($data); |
|
| 304 | 304 | } |
| 305 | 305 | /** |
| 306 | 306 | * Verify token in request. |
@@ -309,11 +309,11 @@ discard block |
||
| 309 | 309 | * @return mixed Customer id or false. |
| 310 | 310 | */ |
| 311 | 311 | public static function wps_direct_payment_link_verify_token() { |
| 312 | - $token = ! empty( $_GET['token'] ) ? sanitize_text_field( $_GET['token'] ) : ''; |
|
| 313 | - $order_id = ! empty( $_GET['order_id'] ) ? (int) $_GET['order_id'] : ''; |
|
| 314 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 315 | - $customer_id = ! empty( $order_metadata['customer_id'] ) ? (int) $order_metadata['customer_id'] : false; |
|
| 316 | - return ( (bool) $customer_id && wps_orders_ctr::wps_token_order_customer( $order_id ) === $token ) ? array( 'oid' => $order_id, 'cid' => $customer_id ) : false; |
|
| 312 | + $token = !empty($_GET['token']) ? sanitize_text_field($_GET['token']) : ''; |
|
| 313 | + $order_id = !empty($_GET['order_id']) ? (int)$_GET['order_id'] : ''; |
|
| 314 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 315 | + $customer_id = !empty($order_metadata['customer_id']) ? (int)$order_metadata['customer_id'] : false; |
|
| 316 | + return ((bool)$customer_id && wps_orders_ctr::wps_token_order_customer($order_id) === $token) ? array('oid' => $order_id, 'cid' => $customer_id) : false; |
|
| 317 | 317 | } |
| 318 | 318 | /** |
| 319 | 319 | * Get URL for wps_direct_link. |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @param int $order_id OrderID. |
| 323 | 323 | * @return string Url or empty string. |
| 324 | 324 | */ |
| 325 | - public static function wps_direct_payment_link_url( $order_id ) { |
|
| 326 | - return ( (bool) ( $token = wps_orders_ctr::wps_token_order_customer( (int) $order_id ) ) ) ? admin_url( 'admin-post.php?action=wps_direct_payment_link&token=' . $token . '&order_id=' . (int) $order_id ) : ''; |
|
| 325 | + public static function wps_direct_payment_link_url($order_id) { |
|
| 326 | + return ((bool)($token = wps_orders_ctr::wps_token_order_customer((int)$order_id))) ? admin_url('admin-post.php?action=wps_direct_payment_link&token=' . $token . '&order_id=' . (int)$order_id) : ''; |
|
| 327 | 327 | } |
| 328 | 328 | } |
@@ -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' ) ) { |
@@ -58,12 +60,13 @@ discard block |
||
| 58 | 60 | // On enregistre la commande |
| 59 | 61 | update_post_meta($order_id, '_order_postmeta', $order); |
| 60 | 62 | update_post_meta($order_id, '_wpshop_order_customer_id', $user_id); |
| 63 | + } else { |
|
| 64 | + $wpshop->add_error(__('You don\'t own the order', 'wpshop')); |
|
| 61 | 65 | } |
| 62 | - else $wpshop->add_error(__('You don\'t own the order', 'wpshop')); |
|
| 66 | + } else { |
|
| 67 | + $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop')); |
|
| 63 | 68 | } |
| 64 | - else $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop')); |
|
| 65 | - } |
|
| 66 | - else{ |
|
| 69 | + } else{ |
|
| 67 | 70 | $order_data = array( |
| 68 | 71 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, |
| 69 | 72 | 'post_title' => sprintf(__('Order - %s','wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)), |
@@ -118,7 +121,9 @@ discard block |
||
| 118 | 121 | } |
| 119 | 122 | } |
| 120 | 123 | } |
| 121 | - if(!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes); |
|
| 124 | + if(!empty($download_codes)) { |
|
| 125 | + update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes); |
|
| 126 | + } |
|
| 122 | 127 | |
| 123 | 128 | // Informations de commande � stocker |
| 124 | 129 | $currency = wpshop_tools::wpshop_get_currency(true); |
@@ -140,8 +145,7 @@ discard block |
||
| 140 | 145 | // Si c'est un devis |
| 141 | 146 | if ( $paymentMethod == 'quotation' ) { |
| 142 | 147 | $order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference(); |
| 143 | - } |
|
| 144 | - else { |
|
| 148 | + } else { |
|
| 145 | 149 | $order['order_key'] = wpshop_orders::get_new_order_reference(); |
| 146 | 150 | } |
| 147 | 151 | |
@@ -202,8 +206,7 @@ discard block |
||
| 202 | 206 | |
| 203 | 207 | if ( !empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key']) ) { |
| 204 | 208 | $wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '') ); |
| 205 | - } |
|
| 206 | - else { |
|
| 209 | + } else { |
|
| 207 | 210 | $email_option = get_option( 'wpshop_emails' ); |
| 208 | 211 | if ( empty($email_option['send_confirmation_order_message']) ) { |
| 209 | 212 | $payment_method_option = get_option( 'wps_payment_mode' ); |
@@ -257,8 +260,7 @@ discard block |
||
| 257 | 260 | |
| 258 | 261 | if( !empty( $order_infos ) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key']) ){ |
| 259 | 262 | $message_type = 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE'; |
| 260 | - } |
|
| 261 | - else { |
|
| 263 | + } else { |
|
| 262 | 264 | $message_type = 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE'; |
| 263 | 265 | $order_tmp_key = $order_infos['order_temporary_key']; |
| 264 | 266 | } |