@@ -1,21 +1,21 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | class wps_quotation_backend_ctr { |
| 3 | 3 | /* |
| 4 | 4 | * Declare filter and actions |
| 5 | 5 | */ |
| 6 | 6 | public function __construct() { |
| 7 | 7 | /** Appel des styles pour l'administration / Call style for administration */ |
| 8 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_assets' ) ); |
|
| 8 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_assets')); |
|
| 9 | 9 | |
| 10 | 10 | /** Définition du filtre permettant le champs d'activation du module avec un code obtenu sur la boutique / Define the filter allowing to display an input for module activation with a given code from the shop */ |
| 11 | - add_filter( 'wps-addon-extra-info', array( $this, 'display_addon_activation_form' ) ); |
|
| 11 | + add_filter('wps-addon-extra-info', array($this, 'display_addon_activation_form')); |
|
| 12 | 12 | /** Déclaration de la requête Ajax permettant de vérifier le code d'activation et d'activer le module le cas échéant / Declare ajax request allowing to check the code and activate addon in case the code is correct */ |
| 13 | - add_action( 'wp_ajax_check_code_for_activation', array( $this, 'check_code_for_activation' ) ); |
|
| 13 | + add_action('wp_ajax_check_code_for_activation', array($this, 'check_code_for_activation')); |
|
| 14 | 14 | |
| 15 | - add_filter( 'wps-filter-free-product-bton-tpl', array( $this, 'wps_free_product_bton_tpl' ) ); |
|
| 16 | - add_action( 'wp_ajax_wps_free_product_form_page_tpl', array( $this, 'wps_free_product_form_page_tpl' ) ); |
|
| 17 | - add_action( 'wp_ajax_wps_create_new_free_product', array( $this, 'wps_create_new_free_product' ) ); |
|
| 18 | - add_action( 'init', array( $this, 'wps_free_product_post_status' ) ); |
|
| 15 | + add_filter('wps-filter-free-product-bton-tpl', array($this, 'wps_free_product_bton_tpl')); |
|
| 16 | + add_action('wp_ajax_wps_free_product_form_page_tpl', array($this, 'wps_free_product_form_page_tpl')); |
|
| 17 | + add_action('wp_ajax_wps_create_new_free_product', array($this, 'wps_create_new_free_product')); |
|
| 18 | + add_action('init', array($this, 'wps_free_product_post_status')); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | * Inclusion des feuilles de styles pour l'administration / Admin css enqueue |
| 24 | 24 | */ |
| 25 | 25 | function admin_assets($hook) { |
| 26 | - if ( $hook != 'settings_page_wpshop_option' ) |
|
| 26 | + if ($hook != 'settings_page_wpshop_option') |
|
| 27 | 27 | return; |
| 28 | 28 | |
| 29 | - wp_enqueue_script( 'wps_quotation_admin_js', WPS_QUOTATION_URL . '/assets/js/backend.js', array( 'jquery', ), WPSHOP_VERSION ); |
|
| 29 | + wp_enqueue_script('wps_quotation_admin_js', WPS_QUOTATION_URL . '/assets/js/backend.js', array('jquery',), WPSHOP_VERSION); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
@@ -34,36 +34,36 @@ discard block |
||
| 34 | 34 | /* |
| 35 | 35 | * Create a new post status for free products |
| 36 | 36 | */ |
| 37 | - function wps_free_product_post_status(){ |
|
| 38 | - register_post_status( 'free_product', array( |
|
| 39 | - 'label' => __( 'Free product', 'wpshop' ), |
|
| 37 | + function wps_free_product_post_status() { |
|
| 38 | + register_post_status('free_product', array( |
|
| 39 | + 'label' => __('Free product', 'wpshop'), |
|
| 40 | 40 | 'public' => false, |
| 41 | 41 | 'exclude_from_search' => true, |
| 42 | 42 | 'show_in_admin_all_list' => false, |
| 43 | 43 | 'show_in_admin_status_list' => false, |
| 44 | - ) ); |
|
| 44 | + )); |
|
| 45 | 45 | } |
| 46 | 46 | /* |
| 47 | 47 | * Template for display button - Filter : 'wps_orders\templates\backend\product-listing\wps_orders_product_listing.php' |
| 48 | 48 | * @param integer $order_id ID of order |
| 49 | 49 | */ |
| 50 | 50 | public function wps_free_product_bton_tpl($order_id) { |
| 51 | - $order_post_meta = get_post_meta( $order_id, '_wpshop_order_status', true ); |
|
| 52 | - if ( 'completed' != $order_post_meta ) { |
|
| 53 | - require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_bton_tpl") ); |
|
| 51 | + $order_post_meta = get_post_meta($order_id, '_wpshop_order_status', true); |
|
| 52 | + if ('completed' != $order_post_meta) { |
|
| 53 | + require (wpshop_tools::get_template_part(WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_bton_tpl")); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | /* |
| 57 | 57 | * Template for display form (AjaxForm) - Call from : Line 3 'templates\backend\add_free_product_form_page_tpl.php' |
| 58 | 58 | */ |
| 59 | 59 | public function wps_free_product_form_page_tpl() { |
| 60 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 60 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 61 | 61 | |
| 62 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_free_product_form_page_tpl' ) ) |
|
| 62 | + if (!wp_verify_nonce($_wpnonce, 'wps_free_product_form_page_tpl')) |
|
| 63 | 63 | wp_die(); |
| 64 | 64 | |
| 65 | - $order_id = ( !empty($_GET['oid']) ) ? intval( $_GET['oid']) : null; |
|
| 66 | - require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_form_page_tpl") ); |
|
| 65 | + $order_id = (!empty($_GET['oid'])) ? intval($_GET['oid']) : null; |
|
| 66 | + require (wpshop_tools::get_template_part(WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "add_free_product_form_page_tpl")); |
|
| 67 | 67 | wp_die(); |
| 68 | 68 | } |
| 69 | 69 | /* |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | * @return integer $pid Product ID |
| 74 | 74 | */ |
| 75 | 75 | public function wps_create_new_free_product() { |
| 76 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 76 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 77 | 77 | |
| 78 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_create_new_free_product' ) ) |
|
| 78 | + if (!wp_verify_nonce($_wpnonce, 'wps_create_new_free_product')) |
|
| 79 | 79 | wp_die(); |
| 80 | 80 | |
| 81 | 81 | global $wpdb; |
@@ -83,43 +83,43 @@ discard block |
||
| 83 | 83 | $output = __('Error at product creation!', 'wpshop'); |
| 84 | 84 | $new_product_id = -1; |
| 85 | 85 | |
| 86 | - $post_title = ( !empty($_POST['post_title']) ) ? sanitize_text_field( $_POST['post_title'] ) : -1; |
|
| 87 | - $post_content = ( !empty($_POST['post_content']) ) ? nl2br( esc_textarea( $_POST['post_content'] ) ) : ''; |
|
| 88 | - $attributes = ( !empty($_POST['attribute']) ) ? (array) $_POST['attribute'] : array(); |
|
| 86 | + $post_title = (!empty($_POST['post_title'])) ? sanitize_text_field($_POST['post_title']) : -1; |
|
| 87 | + $post_content = (!empty($_POST['post_content'])) ? nl2br(esc_textarea($_POST['post_content'])) : ''; |
|
| 88 | + $attributes = (!empty($_POST['attribute'])) ? (array)$_POST['attribute'] : array(); |
|
| 89 | 89 | |
| 90 | - if( $post_title != -1 ) { |
|
| 91 | - $new_product_id = wp_insert_post( array( |
|
| 90 | + if ($post_title != -1) { |
|
| 91 | + $new_product_id = wp_insert_post(array( |
|
| 92 | 92 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, |
| 93 | 93 | 'post_status' => 'free_product', |
| 94 | 94 | 'post_title' => $post_title, |
| 95 | 95 | 'post_content' => $post_content, |
| 96 | - ) ); |
|
| 97 | - if( !is_object( $new_product_id ) ) { |
|
| 96 | + )); |
|
| 97 | + if (!is_object($new_product_id)) { |
|
| 98 | 98 | $attribute_set_list = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code('wpshop_product')); |
| 99 | 99 | $id_attribute_set = null; |
| 100 | - foreach( $attribute_set_list as $attribute_set ) { |
|
| 101 | - if( $attribute_set->slug == 'free_product' ) { |
|
| 100 | + foreach ($attribute_set_list as $attribute_set) { |
|
| 101 | + if ($attribute_set->slug == 'free_product') { |
|
| 102 | 102 | $id_attribute_set = $attribute_set->id; |
| 103 | 103 | break; |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | - update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set ); |
|
| 107 | - $data_to_save['post_ID'] = $data_to_save['product_id'] = intval( $new_product_id ); |
|
| 108 | - $data_to_save['wpshop_product_attribute'] = ( !empty($attributes) ) ? $attributes : array(); |
|
| 106 | + update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $id_attribute_set); |
|
| 107 | + $data_to_save['post_ID'] = $data_to_save['product_id'] = intval($new_product_id); |
|
| 108 | + $data_to_save['wpshop_product_attribute'] = (!empty($attributes)) ? $attributes : array(); |
|
| 109 | 109 | $data_to_save['user_ID'] = get_current_user_id(); |
| 110 | 110 | $data_to_save['action'] = 'editpost'; |
| 111 | 111 | $status = false; |
| 112 | 112 | $output = __('Product created partially!', 'wpshop'); |
| 113 | - if( !empty($new_product_id) && !empty( $data_to_save['user_ID'] ) ) { |
|
| 113 | + if (!empty($new_product_id) && !empty($data_to_save['user_ID'])) { |
|
| 114 | 114 | $product_class = new wpshop_products(); |
| 115 | - $product_class->save_product_custom_informations( $new_product_id, $data_to_save ); |
|
| 115 | + $product_class->save_product_custom_informations($new_product_id, $data_to_save); |
|
| 116 | 116 | $status = true; |
| 117 | 117 | $output = __('Product created successfully.', 'wpshop'); |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - echo json_encode( array( 'status' => $status, 'message' => $output, 'pid' => $new_product_id ) ); |
|
| 122 | + echo json_encode(array('status' => $status, 'message' => $output, 'pid' => $new_product_id)); |
|
| 123 | 123 | wp_die(); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -129,78 +129,78 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @param string $module Le nom du module en cours d'affichage et pour lequel il faut afficher le champs/ The module being displayed and to add input for |
| 131 | 131 | */ |
| 132 | - function display_addon_activation_form( $module ) { |
|
| 133 | - if ( WPS_QUOTATION_DIR == $module ) { |
|
| 132 | + function display_addon_activation_form($module) { |
|
| 133 | + if (WPS_QUOTATION_DIR == $module) { |
|
| 134 | 134 | |
| 135 | 135 | /** Récupération du statut du module devis / Get current quotation addon state */ |
| 136 | - $addon_option = get_option( 'wpshop_addons' ); |
|
| 136 | + $addon_option = get_option('wpshop_addons'); |
|
| 137 | 137 | |
| 138 | - if ( empty( $addon_option ) || ( !empty( $addon_option[ 'WPSHOP_ADDONS_QUOTATION' ] ) && ( false === ( $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] ) ) ) ) { |
|
| 139 | - $quotation_module_def = get_plugin_data( WPS_QUOTATION_PATH . '/wps_quotation.php' ); |
|
| 140 | - require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activation" ) ); |
|
| 138 | + if (empty($addon_option) || (!empty($addon_option['WPSHOP_ADDONS_QUOTATION']) && (false === ($addon_option['WPSHOP_ADDONS_QUOTATION']['activate'])))) { |
|
| 139 | + $quotation_module_def = get_plugin_data(WPS_QUOTATION_PATH . '/wps_quotation.php'); |
|
| 140 | + require (wpshop_tools::get_template_part(WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activation")); |
|
| 141 | 141 | } |
| 142 | - else if ( !empty( $addon_option[ 'WPSHOP_ADDONS_QUOTATION' ] ) && ( true === ( $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] ) ) ) { |
|
| 143 | - require ( wpshop_tools::get_template_part( WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activated" ) ); |
|
| 142 | + else if (!empty($addon_option['WPSHOP_ADDONS_QUOTATION']) && (true === ($addon_option['WPSHOP_ADDONS_QUOTATION']['activate']))) { |
|
| 143 | + require (wpshop_tools::get_template_part(WPS_QUOTATION_DIR, WPS_QUOTATION_TEMPLATES_MAIN_DIR, "backend", "addon", "activated")); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | function check_code_for_activation() { |
| 149 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 149 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 150 | 150 | |
| 151 | - if ( !wp_verify_nonce( $_wpnonce, 'check_code_for_activation' ) ) |
|
| 151 | + if (!wp_verify_nonce($_wpnonce, 'check_code_for_activation')) |
|
| 152 | 152 | wp_die(); |
| 153 | 153 | |
| 154 | 154 | $response = array( |
| 155 | 155 | 'status' => false, |
| 156 | - 'message' => __( 'Activation code for quotation addon is invalid, please check it and try again.', 'wpshop' ), |
|
| 156 | + 'message' => __('Activation code for quotation addon is invalid, please check it and try again.', 'wpshop'), |
|
| 157 | 157 | ); |
| 158 | - $required_code = wpshop_tools::get_plugin_validation_code( WPS_QUOTATION_DIR, site_url() ); |
|
| 159 | - $code = sanitize_text_field( $_POST[ 'code' ] ); |
|
| 160 | - if ( $code === $required_code ) { |
|
| 158 | + $required_code = wpshop_tools::get_plugin_validation_code(WPS_QUOTATION_DIR, site_url()); |
|
| 159 | + $code = sanitize_text_field($_POST['code']); |
|
| 160 | + if ($code === $required_code) { |
|
| 161 | 161 | $this->action_to_do_to_activate(); |
| 162 | 162 | $response = array( |
| 163 | 163 | 'status' => true, |
| 164 | - 'message' => __( 'Quotation addon have been successfully activated.', 'wpshop' ), |
|
| 164 | + 'message' => __('Quotation addon have been successfully activated.', 'wpshop'), |
|
| 165 | 165 | ); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - wp_die( json_encode( $response ) ); |
|
| 168 | + wp_die(json_encode($response)); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Action to do when the activation code is OK |
| 173 | 173 | */ |
| 174 | - function action_to_do_to_activate(){ |
|
| 174 | + function action_to_do_to_activate() { |
|
| 175 | 175 | global $wpdb; |
| 176 | 176 | /** Activate the plug in **/ |
| 177 | - $addon_option = get_option( 'wpshop_addons' ); |
|
| 177 | + $addon_option = get_option('wpshop_addons'); |
|
| 178 | 178 | $addon_option['WPSHOP_ADDONS_QUOTATION']['activate'] = true; |
| 179 | 179 | $addon_option['WPSHOP_ADDONS_QUOTATION']['activation_date'] = current_time('mysql', 0); |
| 180 | 180 | |
| 181 | - update_option( 'wpshop_addons', $addon_option ); |
|
| 181 | + update_option('wpshop_addons', $addon_option); |
|
| 182 | 182 | |
| 183 | 183 | /** Activate the Quotation attribute **/ |
| 184 | - $wpdb->update( WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => 'quotation_allowed') ); |
|
| 184 | + $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('status' => 'valid'), array('code' => 'quotation_allowed')); |
|
| 185 | 185 | |
| 186 | - $attribute_def = wpshop_attributes::getElement( 'quotation_allowed', '"valid"', 'code' ); |
|
| 186 | + $attribute_def = wpshop_attributes::getElement('quotation_allowed', '"valid"', 'code'); |
|
| 187 | 187 | |
| 188 | 188 | /** Add the attribute in attributes groups section **/ |
| 189 | - $query = $wpdb->prepare('SELECT id, attribute_set_id FROM ' .WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE code = %s', 'general'); |
|
| 190 | - $attribute_set_sections = $wpdb->get_results( $query ); |
|
| 191 | - |
|
| 192 | - if ( !empty($attribute_set_sections) ) { |
|
| 193 | - $entity_type_def = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
| 194 | - if ( !empty( $entity_type_def) ) { |
|
| 195 | - foreach ( $attribute_set_sections as $attribute_set_section ) { |
|
| 196 | - $query = $wpdb->prepare('SELECT COUNT(*) AS count_attribute_affectation FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d', $entity_type_def, $attribute_set_section->attribute_set_id, $attribute_set_section->id, $attribute_def->id); |
|
| 197 | - $count_attribute_affectation = $wpdb->get_var( $query ); |
|
| 198 | - |
|
| 199 | - if ( $count_attribute_affectation == 0 ) { |
|
| 200 | - $query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $entity_type_def, $attribute_set_section->attribute_set_id, $attribute_set_section->id); |
|
| 201 | - $max_position = $wpdb->get_var( $query ); |
|
| 189 | + $query = $wpdb->prepare('SELECT id, attribute_set_id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE code = %s', 'general'); |
|
| 190 | + $attribute_set_sections = $wpdb->get_results($query); |
|
| 191 | + |
|
| 192 | + if (!empty($attribute_set_sections)) { |
|
| 193 | + $entity_type_def = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
| 194 | + if (!empty($entity_type_def)) { |
|
| 195 | + foreach ($attribute_set_sections as $attribute_set_section) { |
|
| 196 | + $query = $wpdb->prepare('SELECT COUNT(*) AS count_attribute_affectation FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d AND attribute_id = %d', $entity_type_def, $attribute_set_section->attribute_set_id, $attribute_set_section->id, $attribute_def->id); |
|
| 197 | + $count_attribute_affectation = $wpdb->get_var($query); |
|
| 198 | + |
|
| 199 | + if ($count_attribute_affectation == 0) { |
|
| 200 | + $query = $wpdb->prepare('SELECT MAX(position) AS max_position FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', $entity_type_def, $attribute_set_section->attribute_set_id, $attribute_set_section->id); |
|
| 201 | + $max_position = $wpdb->get_var($query); |
|
| 202 | 202 | /** Insert attribute detail **/ |
| 203 | - $wpdb->insert( WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_type_def, 'attribute_set_id' => $attribute_set_section->attribute_set_id, 'attribute_group_id' => $attribute_set_section->id, 'attribute_id' => $attribute_def->id, 'position' => (int)$max_position + 1) ); |
|
| 203 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $entity_type_def, 'attribute_set_id' => $attribute_set_section->attribute_set_id, 'attribute_group_id' => $attribute_set_section->id, 'attribute_id' => $attribute_def->id, 'position' => (int)$max_position + 1)); |
|
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | } |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | add_settings_field('wpshop_billing_address_choice', __('Billing address choice', 'wpshop'), array(&$this, 'wpshop_billing_address_choice_field'), 'wpshop_billing_info', 'wpshop_billing_info'); |
| 104 | 104 | add_settings_field('wpshop_billing_address_include_into_register', '', array(&$this, 'wpshop_billing_address_include_into_register_field'), 'wpshop_billing_info', 'wpshop_billing_info'); |
| 105 | 105 | |
| 106 | - register_setting( 'wpshop_options', 'wpshop_billing_invoice_footer_area' ); |
|
| 107 | - add_settings_field( 'wpshop_billing_invoice_footer_area', __( 'Free text for invoice footer', 'wpshop' ), array( $this, 'wpshop_billing_invoice_footer_area' ), 'wpshop_billing_info', 'wpshop_billing_info' ); |
|
| 106 | + register_setting('wpshop_options', 'wpshop_billing_invoice_footer_area'); |
|
| 107 | + add_settings_field('wpshop_billing_invoice_footer_area', __('Free text for invoice footer', 'wpshop'), array($this, 'wpshop_billing_invoice_footer_area'), 'wpshop_billing_info', 'wpshop_billing_info'); |
|
| 108 | 108 | |
| 109 | 109 | $quotation_option = get_option('wpshop_addons'); |
| 110 | 110 | if (!empty($quotation_option) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']) && !empty($quotation_option['WPSHOP_ADDONS_QUOTATION']['activate'])) { |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | * Define the field allowing to define the invoice footer |
| 166 | 166 | */ |
| 167 | 167 | public function wpshop_billing_invoice_footer_area() { |
| 168 | - $wpshop_billing_invoice_footer_area = get_option( 'wpshop_billing_invoice_footer_area' ); |
|
| 168 | + $wpshop_billing_invoice_footer_area = get_option('wpshop_billing_invoice_footer_area'); |
|
| 169 | 169 | $wp_editor_args = array( |
| 170 | 170 | 'media_buttons' => false, |
| 171 | 171 | ); |
| 172 | - wp_editor( $wpshop_billing_invoice_footer_area, 'wpshop_billing_invoice_footer_area', $wp_editor_args ); |
|
| 172 | + wp_editor($wpshop_billing_invoice_footer_area, 'wpshop_billing_invoice_footer_area', $wp_editor_args); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | public function wpshop_options_validate_billing_number_figures($input) |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | update_option('wpshop_billing_current_number', $billing_current_number); |
| 308 | 308 | |
| 309 | 309 | /** Create the new invoice number with all parameters viewed above */ |
| 310 | - $invoice_ref = WPSHOP_BILLING_REFERENCE_PREFIX . ((string) sprintf('%0' . $number_figures . 'd', $billing_current_number)); |
|
| 310 | + $invoice_ref = WPSHOP_BILLING_REFERENCE_PREFIX . ((string)sprintf('%0' . $number_figures . 'd', $billing_current_number)); |
|
| 311 | 311 | |
| 312 | 312 | return $invoice_ref; |
| 313 | 313 | } |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | $item_title = $item['item_name']; |
| 472 | 472 | } |
| 473 | 473 | $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = $item_title; |
| 474 | - if ( 'free_product' === get_post_status( $item_id ) ) { |
|
| 474 | + if ('free_product' === get_post_status($item_id)) { |
|
| 475 | 475 | $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] = '<b>' . $sub_tpl_component['INVOICE_ROW_ITEM_NAME'] . '</b><br>' . get_post_field('post_content', $item_id); |
| 476 | 476 | } |
| 477 | 477 | /** Get attribute order for current product */ |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | unset($sub_tpl_component); |
| 609 | 609 | $total_partial_payment += (!empty($received_payment['received_amount'])) ? $received_payment['received_amount'] : 0; |
| 610 | - } else if ( !empty( $received_payment['status'] ) && 'payment_received' == $received_payment['status'] ) { |
|
| 610 | + } else if (!empty($received_payment['status']) && 'payment_received' == $received_payment['status']) { |
|
| 611 | 611 | $last_payment += (!empty($received_payment['received_amount'])) ? $received_payment['received_amount'] : 0; |
| 612 | 612 | } |
| 613 | 613 | |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | public static function generate_footer_invoice() { |
| 993 | 993 | $output = ''; |
| 994 | 994 | $emails = get_option('wpshop_emails', array()); |
| 995 | - $wpshop_billing_invoice_footer_area = get_option( 'wpshop_billing_invoice_footer_area' ); |
|
| 995 | + $wpshop_billing_invoice_footer_area = get_option('wpshop_billing_invoice_footer_area'); |
|
| 996 | 996 | |
| 997 | 997 | $tpl_component['COMPANY_EMAIL'] = (!empty($emails) && !empty($emails['contact_email'])) ? $emails['contact_email'] : ''; |
| 998 | 998 | $tpl_component['COMPANY_WEBSITE'] = site_url(); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @package wps-mass-interface3 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 8 | +if (!defined('ABSPATH')) { |
|
| 9 | 9 | exit; |
| 10 | 10 | } |
| 11 | 11 | /** |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | * @method __construct |
| 63 | 63 | */ |
| 64 | 64 | public function __construct() { |
| 65 | - add_action( 'admin_menu', array( $this, 'mass_init' ), 350 ); |
|
| 66 | - add_action( 'wp_ajax_wps_mass_3_new', array( $this, 'ajax_new' ) ); |
|
| 67 | - add_action( 'wp_ajax_wps_mass_3_save', array( $this, 'ajax_save' ) ); |
|
| 68 | - add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 ); |
|
| 65 | + add_action('admin_menu', array($this, 'mass_init'), 350); |
|
| 66 | + add_action('wp_ajax_wps_mass_3_new', array($this, 'ajax_new')); |
|
| 67 | + add_action('wp_ajax_wps_mass_3_save', array($this, 'ajax_save')); |
|
| 68 | + add_filter('set-screen-option', array($this, 'set_screen_option'), 10, 3); |
|
| 69 | 69 | } |
| 70 | 70 | /** |
| 71 | 71 | * Page Initialisation |
@@ -74,18 +74,18 @@ discard block |
||
| 74 | 74 | * @return void |
| 75 | 75 | */ |
| 76 | 76 | public function mass_init() { |
| 77 | - $page = ( isset( $_GET['page'] ) && strpos( $_GET['page'] , 'mass_edit_interface3_att_set_' ) !== false ) ? $_GET['page'] : 'mass_edit_interface3_att_set_1'; |
|
| 77 | + $page = (isset($_GET['page']) && strpos($_GET['page'], 'mass_edit_interface3_att_set_') !== false) ? $_GET['page'] : 'mass_edit_interface3_att_set_1'; |
|
| 78 | 78 | $this->hook = add_submenu_page( |
| 79 | 79 | 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, |
| 80 | - __( 'Mass product edit', 'wpshop' ), |
|
| 81 | - __( 'Mass product edit', 'wpshop' ), |
|
| 80 | + __('Mass product edit', 'wpshop'), |
|
| 81 | + __('Mass product edit', 'wpshop'), |
|
| 82 | 82 | 'manage_options', |
| 83 | 83 | $page, |
| 84 | - array( $this, 'mass_interface' ) |
|
| 84 | + array($this, 'mass_interface') |
|
| 85 | 85 | ); |
| 86 | - add_action( "load-{$this->hook}", array( $this, 'mass_interface_screen_option' ) ); |
|
| 87 | - add_action( "admin_print_scripts-{$this->hook}", array( $this, 'scripts' ) ); |
|
| 88 | - add_action( "admin_print_styles-{$this->hook}", array( $this, 'styles' ) ); |
|
| 86 | + add_action("load-{$this->hook}", array($this, 'mass_interface_screen_option')); |
|
| 87 | + add_action("admin_print_scripts-{$this->hook}", array($this, 'scripts')); |
|
| 88 | + add_action("admin_print_styles-{$this->hook}", array($this, 'styles')); |
|
| 89 | 89 | } |
| 90 | 90 | /** |
| 91 | 91 | * Page content. |
@@ -94,48 +94,48 @@ discard block |
||
| 94 | 94 | * @return void Direct display. |
| 95 | 95 | */ |
| 96 | 96 | public function mass_interface() { |
| 97 | - $wp_list_table = $this->wp_list_table( $this->hook ); |
|
| 97 | + $wp_list_table = $this->wp_list_table($this->hook); |
|
| 98 | 98 | $wp_list_table->prepare_items(); ?> |
| 99 | 99 | <div class="wrap"> |
| 100 | 100 | <h1 class="wp-heading-inline"><?php |
| 101 | - echo esc_html( $this->post_type_object->labels->name ); |
|
| 101 | + echo esc_html($this->post_type_object->labels->name); |
|
| 102 | 102 | ?></h1> |
| 103 | 103 | <?php |
| 104 | - if ( current_user_can( $this->post_type_object->cap->create_posts ) ) { |
|
| 105 | - echo ' <a href="#addPost" class="page-title-action" data-nonce="' . esc_attr( wp_create_nonce( 'add_post-' . sanitize_title( get_class() ) ) ) . '">'; |
|
| 106 | - echo esc_html( $this->post_type_object->labels->add_new ) . '</a>'; |
|
| 104 | + if (current_user_can($this->post_type_object->cap->create_posts)) { |
|
| 105 | + echo ' <a href="#addPost" class="page-title-action" data-nonce="' . esc_attr(wp_create_nonce('add_post-' . sanitize_title(get_class()))) . '">'; |
|
| 106 | + echo esc_html($this->post_type_object->labels->add_new) . '</a>'; |
|
| 107 | 107 | } |
| 108 | 108 | ?> |
| 109 | 109 | <hr class="wp-header-end"> |
| 110 | - <?php echo '<input type="hidden" id="hook" value="' . esc_attr( $this->hook ) . '">'; ?> |
|
| 110 | + <?php echo '<input type="hidden" id="hook" value="' . esc_attr($this->hook) . '">'; ?> |
|
| 111 | 111 | <form id="posts-filter" method="get"> |
| 112 | 112 | <?php $wp_list_table->views(); ?> |
| 113 | - <?php $wp_list_table->search_box( $this->post_type_object->labels->search_items, 'post' ); ?> |
|
| 113 | + <?php $wp_list_table->search_box($this->post_type_object->labels->search_items, 'post'); ?> |
|
| 114 | 114 | <input type="hidden" name="page" value="<?php |
| 115 | - echo esc_attr( str_replace( |
|
| 115 | + echo esc_attr(str_replace( |
|
| 116 | 116 | "{$wp_list_table->screen->post_type}_page_", |
| 117 | 117 | '', |
| 118 | 118 | $wp_list_table->screen->id |
| 119 | - ) ); ?>"> |
|
| 120 | - <input type="hidden" name="post_type" value="<?php echo esc_attr( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); ?>"> |
|
| 119 | + )); ?>"> |
|
| 120 | + <input type="hidden" name="post_type" value="<?php echo esc_attr(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); ?>"> |
|
| 121 | 121 | </form> |
| 122 | 122 | <?php $wp_list_table->display(); ?> |
| 123 | 123 | <table style="display:none;"> |
| 124 | 124 | <tbody id="posts-add"> |
| 125 | - <tr id="inline-edit" class="inline-edit-row inline-edit-row-post <?php echo esc_attr( "inline-edit-{$this->post_type_object->name} quick-edit-row quick-edit-row-post inline-edit-{$this->post_type_object->name}" ); ?>" style="display: none"> |
|
| 126 | - <td colspan="<?php echo esc_attr( $wp_list_table->get_column_count() ); ?>" class="colspanchange"> |
|
| 125 | + <tr id="inline-edit" class="inline-edit-row inline-edit-row-post <?php echo esc_attr("inline-edit-{$this->post_type_object->name} quick-edit-row quick-edit-row-post inline-edit-{$this->post_type_object->name}"); ?>" style="display: none"> |
|
| 126 | + <td colspan="<?php echo esc_attr($wp_list_table->get_column_count()); ?>" class="colspanchange"> |
|
| 127 | 127 | <fieldset class="inline-edit-col"> |
| 128 | - <legend class="inline-edit-legend"><?php echo esc_html( $this->post_type_object->labels->add_new ) ?></legend> |
|
| 128 | + <legend class="inline-edit-legend"><?php echo esc_html($this->post_type_object->labels->add_new) ?></legend> |
|
| 129 | 129 | <div class="inline-edit-col"> |
| 130 | 130 | <label> |
| 131 | - <span class="title"><?php esc_html_e( 'Title' ); ?></span> |
|
| 131 | + <span class="title"><?php esc_html_e('Title'); ?></span> |
|
| 132 | 132 | <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
| 133 | 133 | </label> |
| 134 | 134 | </div> |
| 135 | 135 | </fieldset> |
| 136 | 136 | <p class="submit inline-edit-save"> |
| 137 | - <button type="button" class="button cancel alignleft"><?php esc_html_e( 'Cancel' ); ?></button> |
|
| 138 | - <button type="button" class="button button-primary save alignright"><?php echo esc_html( $this->post_type_object->labels->add_new ); ?></button> |
|
| 137 | + <button type="button" class="button cancel alignleft"><?php esc_html_e('Cancel'); ?></button> |
|
| 138 | + <button type="button" class="button button-primary save alignright"><?php echo esc_html($this->post_type_object->labels->add_new); ?></button> |
|
| 139 | 139 | <span class="spinner"></span> |
| 140 | 140 | <span class="error" style="display:none"></span> |
| 141 | 141 | <br class="clear" /> |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | * @return void |
| 155 | 155 | */ |
| 156 | 156 | public function mass_interface_screen_option() { |
| 157 | - add_action( 'admin_notices', array( $this, 'ajax_admin_notice' ) ); |
|
| 158 | - add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 ); |
|
| 159 | - $this->wp_list_table( $this->hook ); |
|
| 157 | + add_action('admin_notices', array($this, 'ajax_admin_notice')); |
|
| 158 | + add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2); |
|
| 159 | + $this->wp_list_table($this->hook); |
|
| 160 | 160 | } |
| 161 | 161 | /** |
| 162 | 162 | * Instance WPS_Mass_List_Table. |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | * @param string $screen Current screen. |
| 166 | 166 | * @return WPS_Mass_List_Table Table class. |
| 167 | 167 | */ |
| 168 | - public function wp_list_table( $screen ) { |
|
| 169 | - if ( is_null( $this->wp_list_table ) ) { |
|
| 170 | - $this->post_type_object = get_post_type_object( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
| 171 | - include_once( WPS_PDCT_MASS_INCLUDE_PATH . 'class-wps-mass-list-table.php' ); |
|
| 168 | + public function wp_list_table($screen) { |
|
| 169 | + if (is_null($this->wp_list_table)) { |
|
| 170 | + $this->post_type_object = get_post_type_object(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
| 171 | + include_once(WPS_PDCT_MASS_INCLUDE_PATH . 'class-wps-mass-list-table.php'); |
|
| 172 | 172 | $this->wp_list_table = new WPS_Mass_List_Table( |
| 173 | 173 | array( |
| 174 | 174 | 'screen' => $screen, |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | 'heading_list' => $this->post_type_object->labels->items_list, |
| 183 | 183 | ) |
| 184 | 184 | ); |
| 185 | - $class = sanitize_title( get_class() ); |
|
| 185 | + $class = sanitize_title(get_class()); |
|
| 186 | 186 | $this->wp_list_table->screen->add_option( |
| 187 | 187 | 'per_page', array( |
| 188 | 188 | 'default' => 20, |
@@ -200,10 +200,10 @@ discard block |
||
| 200 | 200 | * @param WP_Screen $screen Current screen. |
| 201 | 201 | * @return array Return of filter. |
| 202 | 202 | */ |
| 203 | - public function hidden_columns( $hidden, $screen ) { |
|
| 204 | - $wp_list_table = $this->wp_list_table( $this->hook ); |
|
| 205 | - if ( $screen === $wp_list_table->screen ) { |
|
| 206 | - $hidden = array_diff( array_flip( $wp_list_table->get_columns() ), $this->default_show_columns ); |
|
| 203 | + public function hidden_columns($hidden, $screen) { |
|
| 204 | + $wp_list_table = $this->wp_list_table($this->hook); |
|
| 205 | + if ($screen === $wp_list_table->screen) { |
|
| 206 | + $hidden = array_diff(array_flip($wp_list_table->get_columns()), $this->default_show_columns); |
|
| 207 | 207 | $hidden[] = 'thumbnail'; |
| 208 | 208 | } |
| 209 | 209 | return $hidden; |
@@ -216,11 +216,11 @@ discard block |
||
| 216 | 216 | * @param string $option Actual option to save. |
| 217 | 217 | * @param mixed $value Actual value to save. |
| 218 | 218 | */ |
| 219 | - public function set_screen_option( $string, $option, $value ) { |
|
| 220 | - $class = sanitize_title( get_class() ); |
|
| 221 | - if ( "{$class}_per_page" === $option ) { |
|
| 222 | - $value = (int) $value; |
|
| 223 | - if ( $value < 1 || $value > 999 ) { |
|
| 219 | + public function set_screen_option($string, $option, $value) { |
|
| 220 | + $class = sanitize_title(get_class()); |
|
| 221 | + if ("{$class}_per_page" === $option) { |
|
| 222 | + $value = (int)$value; |
|
| 223 | + if ($value < 1 || $value > 999) { |
|
| 224 | 224 | $string = false; |
| 225 | 225 | } |
| 226 | 226 | return $value; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @return void Direct display. |
| 235 | 235 | */ |
| 236 | 236 | public function ajax_admin_notice() { |
| 237 | - printf( '<div class="%1$s"><p></p></div>', esc_attr( 'hidden is-dismissible notice' ) ); |
|
| 237 | + printf('<div class="%1$s"><p></p></div>', esc_attr('hidden is-dismissible notice')); |
|
| 238 | 238 | } |
| 239 | 239 | /** |
| 240 | 240 | * Enqueue scripts. |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | wp_enqueue_script( |
| 247 | 247 | 'jquery_chosen_js', |
| 248 | 248 | WPS_PDCT_MASS_CHOSEN_JS . 'chosen.jquery.min.js', |
| 249 | - array( 'jquery' ), |
|
| 249 | + array('jquery'), |
|
| 250 | 250 | true |
| 251 | 251 | ); |
| 252 | 252 | wp_enqueue_script( |
| 253 | 253 | 'mass_interface3-ajax', |
| 254 | 254 | WPS_PDCT_MASS_JS . 'wps-mass-interface3.js', |
| 255 | - array( 'jquery', 'jquery-form' ), |
|
| 255 | + array('jquery', 'jquery-form'), |
|
| 256 | 256 | true |
| 257 | 257 | ); |
| 258 | 258 | wp_enqueue_media(); |
@@ -264,11 +264,11 @@ discard block |
||
| 264 | 264 | * @return void |
| 265 | 265 | */ |
| 266 | 266 | public function styles() { |
| 267 | - wp_register_style( 'jquery_chosen_css', WPS_PDCT_MASS_CHOSEN_CSS . 'chosen.min.css' ); |
|
| 268 | - wp_register_style( 'mass_interface3_css', WPS_PDCT_MASS_CSS . 'wps-mass-interface3.css' ); |
|
| 269 | - wp_enqueue_style( 'jquery_chosen_css' ); |
|
| 270 | - wp_enqueue_style( 'mass_interface3_css' ); |
|
| 271 | - wp_deregister_style( 'wpshop_main_css' ); |
|
| 267 | + wp_register_style('jquery_chosen_css', WPS_PDCT_MASS_CHOSEN_CSS . 'chosen.min.css'); |
|
| 268 | + wp_register_style('mass_interface3_css', WPS_PDCT_MASS_CSS . 'wps-mass-interface3.css'); |
|
| 269 | + wp_enqueue_style('jquery_chosen_css'); |
|
| 270 | + wp_enqueue_style('mass_interface3_css'); |
|
| 271 | + wp_deregister_style('wpshop_main_css'); |
|
| 272 | 272 | } |
| 273 | 273 | /** |
| 274 | 274 | * Change default url for set_url_scheme(). See pagination & get_views. Impossible to re-use set_url_sheme inner. |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @param string $url Given url. |
| 278 | 278 | * @param string | null $scheme Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', 'relative', 'rest', 'rpc', or null. |
| 279 | 279 | */ |
| 280 | - public function set_current_url( $url, $scheme ) { |
|
| 280 | + public function set_current_url($url, $scheme) { |
|
| 281 | 281 | /* |
| 282 | 282 | Remove_filter( 'set_url_scheme', array( $this, 'set_current_url' ), 10 ); |
| 283 | 283 | $url = set_url_sheme( esc_url( $_POST['current_url'] ) ); |
@@ -292,23 +292,23 @@ discard block |
||
| 292 | 292 | * @return void JSON with all elements to update. |
| 293 | 293 | */ |
| 294 | 294 | public function ajax_new() { |
| 295 | - check_ajax_referer( 'add_post-' . sanitize_title( get_class() ) ); |
|
| 296 | - add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 ); |
|
| 297 | - add_filter( 'set_url_scheme', array( $this, 'set_current_url' ), 10, 2 ); |
|
| 298 | - $wp_list_table = $this->wp_list_table( sanitize_title( $_POST['hook'] ) ); |
|
| 295 | + check_ajax_referer('add_post-' . sanitize_title(get_class())); |
|
| 296 | + add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2); |
|
| 297 | + add_filter('set_url_scheme', array($this, 'set_current_url'), 10, 2); |
|
| 298 | + $wp_list_table = $this->wp_list_table(sanitize_title($_POST['hook'])); |
|
| 299 | 299 | $wpshop_product_attribute = array(); |
| 300 | - foreach ( $wp_list_table->request_items_columns() as $key_var => $var ) { |
|
| 301 | - $wpshop_product_attribute[ $var['data'] ][ $key_var ] = null; |
|
| 300 | + foreach ($wp_list_table->request_items_columns() as $key_var => $var) { |
|
| 301 | + $wpshop_product_attribute[$var['data']][$key_var] = null; |
|
| 302 | 302 | } |
| 303 | 303 | $new_product_id = wp_insert_post( |
| 304 | 304 | array( |
| 305 | 305 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, |
| 306 | 306 | 'post_status' => 'publish', |
| 307 | - 'post_title' => sanitize_text_field( $_POST['title'] ), |
|
| 307 | + 'post_title' => sanitize_text_field($_POST['title']), |
|
| 308 | 308 | ) |
| 309 | 309 | ); |
| 310 | - if ( ! empty( $new_product_id ) ) { |
|
| 311 | - update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $wp_list_table->current_view ); |
|
| 310 | + if (!empty($new_product_id)) { |
|
| 311 | + update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $wp_list_table->current_view); |
|
| 312 | 312 | $product_class = new wpshop_products(); |
| 313 | 313 | $product_class->save_product_custom_informations( |
| 314 | 314 | $new_product_id, array( |
@@ -320,30 +320,30 @@ discard block |
||
| 320 | 320 | ) |
| 321 | 321 | ); |
| 322 | 322 | } else { |
| 323 | - wp_die( 1 ); |
|
| 323 | + wp_die(1); |
|
| 324 | 324 | } |
| 325 | - $data = $wp_list_table->request( $new_product_id ); |
|
| 326 | - $per_page = $wp_list_table->screen->get_option( 'per_page', 'option' ); |
|
| 325 | + $data = $wp_list_table->request($new_product_id); |
|
| 326 | + $per_page = $wp_list_table->screen->get_option('per_page', 'option'); |
|
| 327 | 327 | $wp_list_table->column_headers(); |
| 328 | 328 | $wp_list_table->items = true; |
| 329 | 329 | ob_start(); |
| 330 | 330 | $wp_list_table->views(); |
| 331 | 331 | $subsubsub = ob_get_clean(); |
| 332 | 332 | ob_start(); |
| 333 | - $wp_list_table->display_tablenav( 'top' ); |
|
| 333 | + $wp_list_table->display_tablenav('top'); |
|
| 334 | 334 | $tablenav_top = ob_get_clean(); |
| 335 | 335 | ob_start(); |
| 336 | - $wp_list_table->display_tablenav( 'bottom' ); |
|
| 336 | + $wp_list_table->display_tablenav('bottom'); |
|
| 337 | 337 | $tablenav_bottom = ob_get_clean(); |
| 338 | 338 | ob_start(); |
| 339 | - $wp_list_table->single_row( $data[0] ); |
|
| 340 | - wp_send_json_success( array( |
|
| 339 | + $wp_list_table->single_row($data[0]); |
|
| 340 | + wp_send_json_success(array( |
|
| 341 | 341 | 'row' => ob_get_clean(), |
| 342 | 342 | 'per_page' => $per_page, |
| 343 | 343 | 'tablenav_top' => $tablenav_top, |
| 344 | 344 | 'tablenav_bottom' => $tablenav_bottom, |
| 345 | 345 | 'subsubsub' => $subsubsub, |
| 346 | - ) ); |
|
| 346 | + )); |
|
| 347 | 347 | } |
| 348 | 348 | /** |
| 349 | 349 | * Ajax callback for save selected elements. |
@@ -352,22 +352,22 @@ discard block |
||
| 352 | 352 | * @return void JSON with number of saved elements (not used). |
| 353 | 353 | */ |
| 354 | 354 | public function ajax_save() { |
| 355 | - check_ajax_referer( 'bulk-save-mass-edit-interface-3' ); |
|
| 355 | + check_ajax_referer('bulk-save-mass-edit-interface-3'); |
|
| 356 | 356 | $i = 0; |
| 357 | 357 | $product_class = new wpshop_products(); |
| 358 | - if ( ! empty( $_REQUEST['cb'] ) ) { |
|
| 359 | - foreach ( $_REQUEST['cb'] as $id ) { |
|
| 360 | - $id = intval( $id ); |
|
| 361 | - if ( isset( $_REQUEST[ 'row_' . $id ]['thumbnail'] ) ) { |
|
| 362 | - intval( $_REQUEST[ 'row_' . $id ]['thumbnail'] ); |
|
| 363 | - update_post_meta( $id, '_thumbnail_id', intval( $_REQUEST[ 'row_' . $id ]['thumbnail'] ) ); |
|
| 364 | - unset( $_REQUEST[ 'row_' . $id ]['thumbnail'] ); |
|
| 358 | + if (!empty($_REQUEST['cb'])) { |
|
| 359 | + foreach ($_REQUEST['cb'] as $id) { |
|
| 360 | + $id = intval($id); |
|
| 361 | + if (isset($_REQUEST['row_' . $id]['thumbnail'])) { |
|
| 362 | + intval($_REQUEST['row_' . $id]['thumbnail']); |
|
| 363 | + update_post_meta($id, '_thumbnail_id', intval($_REQUEST['row_' . $id]['thumbnail'])); |
|
| 364 | + unset($_REQUEST['row_' . $id]['thumbnail']); |
|
| 365 | 365 | } |
| 366 | - if ( ! empty( $_REQUEST[ 'row_' . $id ] ) ) { |
|
| 366 | + if (!empty($_REQUEST['row_' . $id])) { |
|
| 367 | 367 | $product_class->save_product_custom_informations( |
| 368 | 368 | $id, |
| 369 | 369 | array_merge( |
| 370 | - $_REQUEST[ 'row_' . $id ], |
|
| 370 | + $_REQUEST['row_' . $id], |
|
| 371 | 371 | array( |
| 372 | 372 | 'post_ID' => $id, |
| 373 | 373 | 'product_id' => $id, |
@@ -5,14 +5,14 @@ discard block |
||
| 5 | 5 | * @package wps-mass-interface3 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 8 | +if (!defined('ABSPATH')) { |
|
| 9 | 9 | exit; |
| 10 | 10 | } |
| 11 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 11 | +if (!class_exists('WP_List_Table')) { |
|
| 12 | 12 | include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
| 13 | 13 | } |
| 14 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 15 | - exit( 'class-wp-list-table.php not found.' ); |
|
| 14 | +if (!class_exists('WP_List_Table')) { |
|
| 15 | + exit('class-wp-list-table.php not found.'); |
|
| 16 | 16 | } |
| 17 | 17 | /** |
| 18 | 18 | * Custom WP_List_Table to edit attributes from WPShop EAV. |
@@ -78,20 +78,20 @@ discard block |
||
| 78 | 78 | * @method __construct |
| 79 | 79 | * @param array $args New key : exclude_attribute_codes. |
| 80 | 80 | */ |
| 81 | - public function __construct( $args ) { |
|
| 82 | - if ( isset( $args['exclude_attribute_codes'] ) ) { |
|
| 81 | + public function __construct($args) { |
|
| 82 | + if (isset($args['exclude_attribute_codes'])) { |
|
| 83 | 83 | $this->exclude_attribute_codes = $args['exclude_attribute_codes']; |
| 84 | 84 | } |
| 85 | 85 | parent::__construct( |
| 86 | 86 | array( |
| 87 | 87 | 'plural' => 'posts', |
| 88 | 88 | 'ajax' => true, |
| 89 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
| 89 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
| 90 | 90 | ) |
| 91 | 91 | ); |
| 92 | - $this->current_view = (int) substr( $this->screen->id, strpos( $this->screen->id, '_att_set_' ) + 9 ); |
|
| 93 | - $this->entity_id = (int) wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
| 94 | - $this->_post_types = array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION ); |
|
| 92 | + $this->current_view = (int)substr($this->screen->id, strpos($this->screen->id, '_att_set_') + 9); |
|
| 93 | + $this->entity_id = (int)wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
| 94 | + $this->_post_types = array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION); |
|
| 95 | 95 | } |
| 96 | 96 | /** |
| 97 | 97 | * List columns. |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | public function get_columns() { |
| 103 | 103 | $columns = array( |
| 104 | 104 | 'cb' => '<input type="checkbox" />', |
| 105 | - 'title' => __( 'Title' ), |
|
| 106 | - 'thumbnail' => __( 'Thumbnail' ), |
|
| 105 | + 'title' => __('Title'), |
|
| 106 | + 'thumbnail' => __('Thumbnail'), |
|
| 107 | 107 | ); |
| 108 | - foreach ( $this->request_items_columns() as $column => $data_column ) { |
|
| 109 | - if ( ! empty( $column ) && ! empty( $data_column ) ) { |
|
| 110 | - $columns[ $column ] = $data_column['name']; |
|
| 108 | + foreach ($this->request_items_columns() as $column => $data_column) { |
|
| 109 | + if (!empty($column) && !empty($data_column)) { |
|
| 110 | + $columns[$column] = $data_column['name']; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | - $columns['date'] = __( 'Date' ); |
|
| 113 | + $columns['date'] = __('Date'); |
|
| 114 | 114 | return $columns; |
| 115 | 115 | } |
| 116 | 116 | /** |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function get_sortable_columns() { |
| 123 | 123 | $sortable_columns = array( |
| 124 | - 'title' => array( 'title', false ), |
|
| 125 | - 'thumbnail' => array( 'thumbnail', false ), |
|
| 126 | - 'date' => array( 'p.post_date', false ), |
|
| 124 | + 'title' => array('title', false), |
|
| 125 | + 'thumbnail' => array('thumbnail', false), |
|
| 126 | + 'date' => array('p.post_date', false), |
|
| 127 | 127 | ); |
| 128 | - foreach ( $this->request_items_columns() as $column => $data_column ) { |
|
| 129 | - $sortable_columns[ $column ] = array( $data_column['code'], false ); |
|
| 128 | + foreach ($this->request_items_columns() as $column => $data_column) { |
|
| 129 | + $sortable_columns[$column] = array($data_column['code'], false); |
|
| 130 | 130 | } |
| 131 | 131 | return $sortable_columns; |
| 132 | 132 | } |
@@ -138,22 +138,22 @@ discard block |
||
| 138 | 138 | * @param string $column_name Current column. |
| 139 | 139 | * @return string |
| 140 | 140 | */ |
| 141 | - public function column_default( $item, $column_name ) { |
|
| 142 | - if ( isset( $this->columns_items[ $column_name ] ) && is_callable( array( $this, "column_data_{$this->columns_items[ $column_name ]['type']}" ) ) ) { |
|
| 143 | - $callable_ext = str_replace( '-', '_', $this->columns_items[ $column_name ]['type'] ); |
|
| 144 | - $callable = array( $this, "column_data_{$callable_ext}" ); |
|
| 145 | - if ( ! is_callable( $callable ) ) { |
|
| 146 | - $callable = array( $this, 'column_data_text' ); |
|
| 141 | + public function column_default($item, $column_name) { |
|
| 142 | + if (isset($this->columns_items[$column_name]) && is_callable(array($this, "column_data_{$this->columns_items[$column_name]['type']}"))) { |
|
| 143 | + $callable_ext = str_replace('-', '_', $this->columns_items[$column_name]['type']); |
|
| 144 | + $callable = array($this, "column_data_{$callable_ext}"); |
|
| 145 | + if (!is_callable($callable)) { |
|
| 146 | + $callable = array($this, 'column_data_text'); |
|
| 147 | 147 | } |
| 148 | 148 | return call_user_func( |
| 149 | 149 | $callable, |
| 150 | - (int) $this->columns_items[ $column_name ]['id'], |
|
| 151 | - $this->columns_items[ $column_name ]['code'], |
|
| 152 | - $this->columns_items[ $column_name ]['data'], |
|
| 150 | + (int)$this->columns_items[$column_name]['id'], |
|
| 151 | + $this->columns_items[$column_name]['code'], |
|
| 152 | + $this->columns_items[$column_name]['data'], |
|
| 153 | 153 | $item |
| 154 | 154 | ); |
| 155 | 155 | } |
| 156 | - return print_r( $item[ $column_name ], true ); |
|
| 156 | + return print_r($item[$column_name], true); |
|
| 157 | 157 | } |
| 158 | 158 | /** |
| 159 | 159 | * Column content for checkbox. |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param array $item Result of sql query. |
| 163 | 163 | * @return string |
| 164 | 164 | */ |
| 165 | - public function column_cb( $item ) { |
|
| 165 | + public function column_cb($item) { |
|
| 166 | 166 | return sprintf( |
| 167 | 167 | '<input type="checkbox" name="cb[]" value="%d" />', |
| 168 | 168 | $item['ID'] |
@@ -175,52 +175,52 @@ discard block |
||
| 175 | 175 | * @param array $item Result of sql query. |
| 176 | 176 | * @return string |
| 177 | 177 | */ |
| 178 | - public function column_thumbnail( $item ) { |
|
| 178 | + public function column_thumbnail($item) { |
|
| 179 | 179 | $thumbnail_id = ''; |
| 180 | - $link_content = get_the_post_thumbnail( $item['ID'], array( 25, 25 ) ); |
|
| 181 | - if ( ! empty( $link_content ) ) { |
|
| 180 | + $link_content = get_the_post_thumbnail($item['ID'], array(25, 25)); |
|
| 181 | + if (!empty($link_content)) { |
|
| 182 | 182 | $link_content = "<span class=\"img\">{$link_content}</span>"; |
| 183 | - $thumbnail_id = get_post_thumbnail_id( $item['ID'] ); |
|
| 183 | + $thumbnail_id = get_post_thumbnail_id($item['ID']); |
|
| 184 | 184 | } |
| 185 | - $popup_title = __( 'Choose Image' ); |
|
| 185 | + $popup_title = __('Choose Image'); |
|
| 186 | 186 | return sprintf( |
| 187 | 187 | '<input type="hidden" name="row_%1$s[thumbnail]" value="%2$s"><a href="#thumbnail" data-media-title="%3$s">%4$s<span class="text">%3$s</span></a>', |
| 188 | 188 | $item['ID'], |
| 189 | 189 | $thumbnail_id, |
| 190 | - __( 'Choose Image' ), |
|
| 190 | + __('Choose Image'), |
|
| 191 | 191 | $link_content |
| 192 | 192 | ); |
| 193 | 193 | } |
| 194 | - public function column_date( $item ) { |
|
| 194 | + public function column_date($item) { |
|
| 195 | 195 | global $mode; |
| 196 | 196 | |
| 197 | - if ( '0000-00-00 00:00:00' === $item['pdate'] ) { |
|
| 198 | - $t_time = $h_time = __( 'Unpublished' ); |
|
| 197 | + if ('0000-00-00 00:00:00' === $item['pdate']) { |
|
| 198 | + $t_time = $h_time = __('Unpublished'); |
|
| 199 | 199 | $time_diff = 0; |
| 200 | 200 | } else { |
| 201 | - $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); |
|
| 201 | + $t_time = get_the_time(__('Y/m/d g:i:s a')); |
|
| 202 | 202 | $m_time = $item['pdate']; |
| 203 | - $time = get_post_time( 'G', true, $item['ID'] ); |
|
| 203 | + $time = get_post_time('G', true, $item['ID']); |
|
| 204 | 204 | |
| 205 | 205 | $time_diff = time() - $time; |
| 206 | 206 | |
| 207 | - if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { |
|
| 208 | - $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
| 207 | + if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { |
|
| 208 | + $h_time = sprintf(__('%s ago'), human_time_diff($time)); |
|
| 209 | 209 | } else { |
| 210 | - $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
|
| 210 | + $h_time = mysql2date(__('Y/m/d'), $m_time); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if ( 'publish' === $item['status'] ) { |
|
| 215 | - _e( 'Published' ); |
|
| 216 | - } elseif ( 'future' === $item['status'] ) { |
|
| 217 | - if ( $time_diff > 0 ) { |
|
| 218 | - echo '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; |
|
| 214 | + if ('publish' === $item['status']) { |
|
| 215 | + _e('Published'); |
|
| 216 | + } elseif ('future' === $item['status']) { |
|
| 217 | + if ($time_diff > 0) { |
|
| 218 | + echo '<strong class="error-message">' . __('Missed schedule') . '</strong>'; |
|
| 219 | 219 | } else { |
| 220 | - _e( 'Scheduled' ); |
|
| 220 | + _e('Scheduled'); |
|
| 221 | 221 | } |
| 222 | 222 | } else { |
| 223 | - _e( 'Last Modified' ); |
|
| 223 | + _e('Last Modified'); |
|
| 224 | 224 | } |
| 225 | 225 | echo '<br />'; |
| 226 | 226 | echo '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
@@ -232,39 +232,39 @@ discard block |
||
| 232 | 232 | * @param array $item Result of sql query. |
| 233 | 233 | * @return string |
| 234 | 234 | */ |
| 235 | - public function column_title( $item ) { |
|
| 236 | - if ( 'private' === $item['status'] ) { |
|
| 237 | - $post_states['private'] = __( 'Private' ); |
|
| 235 | + public function column_title($item) { |
|
| 236 | + if ('private' === $item['status']) { |
|
| 237 | + $post_states['private'] = __('Private'); |
|
| 238 | 238 | } |
| 239 | - if ( 'draft' === $item['status'] ) { |
|
| 240 | - $post_states['draft'] = __( 'Draft' ); |
|
| 239 | + if ('draft' === $item['status']) { |
|
| 240 | + $post_states['draft'] = __('Draft'); |
|
| 241 | 241 | } |
| 242 | - if ( 'pending' === $item['status'] ) { |
|
| 243 | - $post_states['pending'] = _x( 'Pending', 'post status' ); |
|
| 242 | + if ('pending' === $item['status']) { |
|
| 243 | + $post_states['pending'] = _x('Pending', 'post status'); |
|
| 244 | 244 | } |
| 245 | - if ( 'future' === $item['status'] ) { |
|
| 246 | - $post_states['scheduled'] = __( 'Scheduled' ); |
|
| 245 | + if ('future' === $item['status']) { |
|
| 246 | + $post_states['scheduled'] = __('Scheduled'); |
|
| 247 | 247 | } |
| 248 | - if ( current_user_can( 'edit_post', $item['ID'] ) && 'trash' !== $item['status'] ) { |
|
| 248 | + if (current_user_can('edit_post', $item['ID']) && 'trash' !== $item['status']) { |
|
| 249 | 249 | $result = sprintf( |
| 250 | 250 | '<a class="row-title" href="%s" aria-label="%s">%s</a>', |
| 251 | - get_edit_post_link( $item['ID'] ), |
|
| 251 | + get_edit_post_link($item['ID']), |
|
| 252 | 252 | // translators: WordPress translate. |
| 253 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $item['title'] ) ), |
|
| 253 | + esc_attr(sprintf(__('“%s” (Edit)'), $item['title'])), |
|
| 254 | 254 | $item['title'] |
| 255 | 255 | ); |
| 256 | 256 | } else { |
| 257 | 257 | $result = $item['title']; |
| 258 | 258 | } |
| 259 | - if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item['type'] ) { |
|
| 260 | - $attr_def = get_post_meta( $item['ID'], '_wpshop_variations_attribute_def', true ); |
|
| 259 | + if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item['type']) { |
|
| 260 | + $attr_def = get_post_meta($item['ID'], '_wpshop_variations_attribute_def', true); |
|
| 261 | 261 | $columns_items = $this->request_items_columns(); |
| 262 | 262 | $first_variation = true; |
| 263 | - $parent = $this->items[ $item['parent'] ]; |
|
| 264 | - foreach ( $attr_def as $key => $value ) { |
|
| 265 | - foreach ( $this->get_select_items_option( $columns_items[ $key ]['id'] ) as $all_value ) { |
|
| 266 | - if ( $all_value['id'] === $value ) { |
|
| 267 | - if ( $first_variation ) { |
|
| 263 | + $parent = $this->items[$item['parent']]; |
|
| 264 | + foreach ($attr_def as $key => $value) { |
|
| 265 | + foreach ($this->get_select_items_option($columns_items[$key]['id']) as $all_value) { |
|
| 266 | + if ($all_value['id'] === $value) { |
|
| 267 | + if ($first_variation) { |
|
| 268 | 268 | $result = $parent['title'] . ' : '; |
| 269 | 269 | $first_variation = false; |
| 270 | 270 | } else { |
@@ -276,19 +276,19 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | - if ( ! empty( $post_states ) ) { |
|
| 280 | - $state_count = count( $post_states ); |
|
| 279 | + if (!empty($post_states)) { |
|
| 280 | + $state_count = count($post_states); |
|
| 281 | 281 | $i = 0; |
| 282 | 282 | $result .= ' — '; |
| 283 | - foreach ( $post_states as $state ) { |
|
| 283 | + foreach ($post_states as $state) { |
|
| 284 | 284 | ++$i; |
| 285 | - ( $i === $state_count ) ? $sep = '' : $sep = ', '; |
|
| 285 | + ($i === $state_count) ? $sep = '' : $sep = ', '; |
|
| 286 | 286 | $result .= "<span class='post-state'>$state$sep</span>"; |
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | return sprintf( |
| 290 | 290 | '<strong>%s</strong>', |
| 291 | - isset( $item['lvl'] ) ? $item['lvl'] . $result : $result |
|
| 291 | + isset($item['lvl']) ? $item['lvl'] . $result : $result |
|
| 292 | 292 | ); |
| 293 | 293 | } |
| 294 | 294 | /** |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param array $item Result of sql query. |
| 302 | 302 | * @return string |
| 303 | 303 | */ |
| 304 | - public function column_data_default( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 304 | + public function column_data_default($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 305 | 305 | return 'default'; |
| 306 | 306 | } |
| 307 | 307 | /** |
@@ -314,13 +314,13 @@ discard block |
||
| 314 | 314 | * @param array $item Result of sql query. |
| 315 | 315 | * @return string |
| 316 | 316 | */ |
| 317 | - public function column_data_text( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 317 | + public function column_data_text($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 318 | 318 | $unit = ''; |
| 319 | - if ( is_array( $item[ $attribute_code ] ) ) { |
|
| 320 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 321 | - $value = $item[ $attribute_code ]['value']; |
|
| 319 | + if (is_array($item[$attribute_code])) { |
|
| 320 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 321 | + $value = $item[$attribute_code]['value']; |
|
| 322 | 322 | } else { |
| 323 | - $value = $item[ $attribute_code ]; |
|
| 323 | + $value = $item[$attribute_code]; |
|
| 324 | 324 | } |
| 325 | 325 | return sprintf( |
| 326 | 326 | '<input type="text" name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]" value="%4$s">', |
@@ -341,34 +341,34 @@ discard block |
||
| 341 | 341 | * @param array $item Result of sql query. |
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | - public function column_data_select( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 344 | + public function column_data_select($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 345 | 345 | $unit = ''; |
| 346 | - if ( is_array( $item[ $attribute_code ] ) && isset( $item[ $attribute_code ]['unit'] ) ) { |
|
| 347 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 348 | - $value = $item[ $attribute_code ]['value']; |
|
| 346 | + if (is_array($item[$attribute_code]) && isset($item[$attribute_code]['unit'])) { |
|
| 347 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 348 | + $value = $item[$attribute_code]['value']; |
|
| 349 | 349 | } else { |
| 350 | - $value = $item[ $attribute_code ]; |
|
| 350 | + $value = $item[$attribute_code]; |
|
| 351 | 351 | } |
| 352 | 352 | $has_selected = false; |
| 353 | 353 | $select_items = array(); |
| 354 | - foreach ( $this->get_select_items_option( $attribute_id ) as $option_item ) { |
|
| 355 | - if ( is_array( $value ) ) { |
|
| 356 | - foreach ( $value as $val ) { |
|
| 357 | - $selected = selected( $val, $option_item['id'], false ); |
|
| 358 | - if ( ! empty( $selected ) ) { |
|
| 354 | + foreach ($this->get_select_items_option($attribute_id) as $option_item) { |
|
| 355 | + if (is_array($value)) { |
|
| 356 | + foreach ($value as $val) { |
|
| 357 | + $selected = selected($val, $option_item['id'], false); |
|
| 358 | + if (!empty($selected)) { |
|
| 359 | 359 | break; |
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | } else { |
| 363 | - $selected = selected( $value, $option_item['id'], false ); |
|
| 363 | + $selected = selected($value, $option_item['id'], false); |
|
| 364 | 364 | } |
| 365 | - $has_selected = empty( $selected ) ? $has_selected : true; |
|
| 365 | + $has_selected = empty($selected) ? $has_selected : true; |
|
| 366 | 366 | $select_items[] = "<option value=\"{$option_item['id']}\"{$selected}>{$option_item['label']}</option>"; |
| 367 | 367 | } |
| 368 | - if ( ! $has_selected ) { |
|
| 369 | - array_unshift( $select_items, '<option selected disabled>' . __( 'None' ) . '</option>' ); |
|
| 368 | + if (!$has_selected) { |
|
| 369 | + array_unshift($select_items, '<option selected disabled>' . __('None') . '</option>'); |
|
| 370 | 370 | } |
| 371 | - $select_items = implode( '', $select_items ); |
|
| 371 | + $select_items = implode('', $select_items); |
|
| 372 | 372 | return sprintf( |
| 373 | 373 | '<select name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]">%4$s</select>', |
| 374 | 374 | $attribute_code, |
@@ -388,13 +388,13 @@ discard block |
||
| 388 | 388 | * @param array $item Result of sql query. |
| 389 | 389 | * @return string |
| 390 | 390 | */ |
| 391 | - public function column_data_textarea( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 391 | + public function column_data_textarea($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 392 | 392 | $unit = ''; |
| 393 | - if ( is_array( $item[ $attribute_code ] ) ) { |
|
| 394 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 395 | - $value = $item[ $attribute_code ]['value']; |
|
| 393 | + if (is_array($item[$attribute_code])) { |
|
| 394 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 395 | + $value = $item[$attribute_code]['value']; |
|
| 396 | 396 | } else { |
| 397 | - $value = $item[ $attribute_code ]; |
|
| 397 | + $value = $item[$attribute_code]; |
|
| 398 | 398 | } |
| 399 | 399 | return sprintf( |
| 400 | 400 | '<textarea name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]">%4$s</textarea>', |
@@ -415,29 +415,29 @@ discard block |
||
| 415 | 415 | * @param array $item Result of sql query. |
| 416 | 416 | * @return string |
| 417 | 417 | */ |
| 418 | - public function column_data_multiple_select( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 418 | + public function column_data_multiple_select($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 419 | 419 | $unit = ''; |
| 420 | - if ( is_array( $item[ $attribute_code ] ) && isset( $item[ $attribute_code ]['unit'] ) ) { |
|
| 421 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 422 | - $value = $item[ $attribute_code ]['value']; |
|
| 420 | + if (is_array($item[$attribute_code]) && isset($item[$attribute_code]['unit'])) { |
|
| 421 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 422 | + $value = $item[$attribute_code]['value']; |
|
| 423 | 423 | } else { |
| 424 | - $value = $item[ $attribute_code ]; |
|
| 424 | + $value = $item[$attribute_code]; |
|
| 425 | 425 | } |
| 426 | 426 | $select_items = array(); |
| 427 | - foreach ( $this->get_select_items_option( $attribute_id ) as $option_item ) { |
|
| 428 | - if ( is_array( $value ) ) { |
|
| 429 | - foreach ( $value as $val ) { |
|
| 430 | - $selected = selected( $val, $option_item['id'], false ); |
|
| 431 | - if ( ! empty( $selected ) ) { |
|
| 427 | + foreach ($this->get_select_items_option($attribute_id) as $option_item) { |
|
| 428 | + if (is_array($value)) { |
|
| 429 | + foreach ($value as $val) { |
|
| 430 | + $selected = selected($val, $option_item['id'], false); |
|
| 431 | + if (!empty($selected)) { |
|
| 432 | 432 | break; |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | } else { |
| 436 | - $selected = selected( $value, $option_item['id'], false ); |
|
| 436 | + $selected = selected($value, $option_item['id'], false); |
|
| 437 | 437 | } |
| 438 | 438 | $select_items[] = "<option value=\"{$option_item['id']}\"{$selected}>{$option_item['label']}</option>"; |
| 439 | 439 | } |
| 440 | - $select_items = implode( '', $select_items ); |
|
| 440 | + $select_items = implode('', $select_items); |
|
| 441 | 441 | return sprintf( |
| 442 | 442 | '<select class="chosen-select" multiple data-placeholder="%6$s" name="row_%2$s[wpshop_product_attribute][%3$s][%1$s][]">%4$s</select>', |
| 443 | 443 | $attribute_code, |
@@ -455,9 +455,9 @@ discard block |
||
| 455 | 455 | * @param Mixed $id_post Null = all / Int = single. |
| 456 | 456 | * @return array Return all values with ARRAY_A. |
| 457 | 457 | */ |
| 458 | - public function request( $id_post = null ) { |
|
| 458 | + public function request($id_post = null) { |
|
| 459 | 459 | global $wpdb; |
| 460 | - $per_page = $this->get_items_per_page( $this->screen->get_option( 'per_page', 'option' ) ); |
|
| 460 | + $per_page = $this->get_items_per_page($this->screen->get_option('per_page', 'option')); |
|
| 461 | 461 | $include_states = array( |
| 462 | 462 | 'publish', |
| 463 | 463 | 'future', |
@@ -467,17 +467,17 @@ discard block |
||
| 467 | 467 | 'trash', |
| 468 | 468 | 'scheduled', |
| 469 | 469 | ); |
| 470 | - $include_states = implode( "','", $include_states ); |
|
| 471 | - $post_types = implode( "','", $this->_post_types ); |
|
| 472 | - $orderby = isset( $_REQUEST['orderby'] ) ? esc_sql( $_REQUEST['orderby'] ) : 'p.post_date'; // WPCS: CSRF ok. |
|
| 473 | - $order = isset( $_REQUEST['order'] ) ? esc_sql( strtoupper( $_REQUEST['order'] ) ) : 'DESC'; // WPCS: CSRF ok. |
|
| 474 | - $cast = isset( $_REQUEST['cast'] ) ? esc_sql( $_REQUEST['cast'] ) : ''; // WPCS: CSRF ok. |
|
| 475 | - $cast = strtoupper( $cast ); |
|
| 476 | - $s = isset( $_REQUEST['s'] ) ? esc_sql( $_REQUEST['s'] ) : ''; // WPCS: CSRF ok. |
|
| 477 | - $exclude_attribute_codes = implode( "','", $this->exclude_attribute_codes ); |
|
| 478 | - $items_count = $wpdb->prepare( "SELECT FOUND_ROWS() FROM {$wpdb->posts} WHERE 1 = %d", 1 ); |
|
| 470 | + $include_states = implode("','", $include_states); |
|
| 471 | + $post_types = implode("','", $this->_post_types); |
|
| 472 | + $orderby = isset($_REQUEST['orderby']) ? esc_sql($_REQUEST['orderby']) : 'p.post_date'; // WPCS: CSRF ok. |
|
| 473 | + $order = isset($_REQUEST['order']) ? esc_sql(strtoupper($_REQUEST['order'])) : 'DESC'; // WPCS: CSRF ok. |
|
| 474 | + $cast = isset($_REQUEST['cast']) ? esc_sql($_REQUEST['cast']) : ''; // WPCS: CSRF ok. |
|
| 475 | + $cast = strtoupper($cast); |
|
| 476 | + $s = isset($_REQUEST['s']) ? esc_sql($_REQUEST['s']) : ''; // WPCS: CSRF ok. |
|
| 477 | + $exclude_attribute_codes = implode("','", $this->exclude_attribute_codes); |
|
| 478 | + $items_count = $wpdb->prepare("SELECT FOUND_ROWS() FROM {$wpdb->posts} WHERE 1 = %d", 1); |
|
| 479 | 479 | $true = true; |
| 480 | - if ( $true ) { // FOUND_ROWS incompatibilities ? |
|
| 480 | + if ($true) { // FOUND_ROWS incompatibilities ? |
|
| 481 | 481 | $items_count = $wpdb->prepare( |
| 482 | 482 | "SELECT COUNT(*) |
| 483 | 483 | FROM {$wpdb->posts} p |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | $wpsdb_values_text = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; |
| 500 | 500 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
| 501 | 501 | $extra_select = ''; |
| 502 | - if ( ! in_array( $orderby, apply_filters( 'wps_mass_list_custom_orderby', array( 'title', 'ID', 'thumbnail', 'p.post_date' ) ), true ) ) { |
|
| 502 | + if (!in_array($orderby, apply_filters('wps_mass_list_custom_orderby', array('title', 'ID', 'thumbnail', 'p.post_date')), true)) { |
|
| 503 | 503 | $extra_select = "SELECT GROUP_CONCAT( IFNULL( val_dec1.value, |
| 504 | 504 | IFNULL( val_dat1.value, |
| 505 | 505 | IFNULL( val_tex1.value, |
@@ -521,14 +521,14 @@ discard block |
||
| 521 | 521 | LEFT JOIN {$wpsdb_values_options} val_opt1 ON val_opt1.attribute_id = attr1.id AND val_opt1.id = val_int1.value |
| 522 | 522 | WHERE p1.ID = p.ID"; |
| 523 | 523 | $extra_select = "( {$extra_select} )"; |
| 524 | - if ( ! empty( $cast ) ) { |
|
| 524 | + if (!empty($cast)) { |
|
| 525 | 525 | $extra_select = "CAST( {$extra_select} AS {$cast} )"; |
| 526 | 526 | } |
| 527 | 527 | $extra_select = ", |
| 528 | 528 | {$extra_select} AS {$orderby}"; |
| 529 | 529 | } |
| 530 | - if ( 'thumbnail' === $orderby ) { |
|
| 531 | - $ids = $wpdb->get_col( $wpdb->prepare( |
|
| 530 | + if ('thumbnail' === $orderby) { |
|
| 531 | + $ids = $wpdb->get_col($wpdb->prepare( |
|
| 532 | 532 | "SELECT CAST( pm.post_id AS SIGNED INTEGER ) as col |
| 533 | 533 | FROM {$wpdb->postmeta} pm |
| 534 | 534 | JOIN {$wpdb->posts} p ON pm.post_id = p.ID AND p.post_type IN ( '{$post_types}' ) |
@@ -537,21 +537,21 @@ discard block |
||
| 537 | 537 | ORDER BY pm.meta_value {$order}", |
| 538 | 538 | '_thumbnail_id', |
| 539 | 539 | 0 |
| 540 | - ) ); |
|
| 541 | - $ids = implode( ', ', $ids ); |
|
| 540 | + )); |
|
| 541 | + $ids = implode(', ', $ids); |
|
| 542 | 542 | $orderby = "FIELD( p.ID, {$ids} )"; |
| 543 | 543 | } |
| 544 | - $orderby = apply_filters( 'wps_mass_list_custom_orderby_query', $orderby ); |
|
| 544 | + $orderby = apply_filters('wps_mass_list_custom_orderby_query', $orderby); |
|
| 545 | 545 | $extra = "GROUP BY p.ID |
| 546 | 546 | ORDER BY {$orderby} {$order} |
| 547 | 547 | LIMIT %d, %d"; |
| 548 | - if ( ! is_null( $id_post ) ) { |
|
| 549 | - $id_post = intval( $id_post ); |
|
| 548 | + if (!is_null($id_post)) { |
|
| 549 | + $id_post = intval($id_post); |
|
| 550 | 550 | $extra = "AND p.ID = {$id_post}"; |
| 551 | 551 | $s = ''; |
| 552 | 552 | } |
| 553 | 553 | $wpdb->query( |
| 554 | - $wpdb->prepare( 'SET SESSION group_concat_max_len = %d', 1000000 ) |
|
| 554 | + $wpdb->prepare('SET SESSION group_concat_max_len = %d', 1000000) |
|
| 555 | 555 | ); |
| 556 | 556 | $datas = $wpdb->get_results( |
| 557 | 557 | $wpdb->prepare( |
@@ -606,23 +606,23 @@ discard block |
||
| 606 | 606 | $this->request_current_view(), |
| 607 | 607 | $this->entity_id, |
| 608 | 608 | '%' . $s . '%', |
| 609 | - ( $this->get_pagenum() -1 ) * $per_page, |
|
| 609 | + ($this->get_pagenum() - 1) * $per_page, |
|
| 610 | 610 | $per_page |
| 611 | 611 | ), |
| 612 | 612 | ARRAY_A |
| 613 | 613 | ); |
| 614 | - if ( ! is_array( $datas ) ) { |
|
| 614 | + if (!is_array($datas)) { |
|
| 615 | 615 | $datas = array(); |
| 616 | 616 | } |
| 617 | - if ( ! isset( $this->_pagination_args['total_items'] ) && ! isset( $this->_pagination_args['per_page'] ) ) { |
|
| 617 | + if (!isset($this->_pagination_args['total_items']) && !isset($this->_pagination_args['per_page'])) { |
|
| 618 | 618 | $this->set_pagination_args( |
| 619 | 619 | array( |
| 620 | - 'total_items' => (int) $wpdb->get_var( $items_count ), |
|
| 621 | - 'per_page' => $this->get_items_per_page( $this->screen->get_option( 'per_page', 'option' ) ), |
|
| 620 | + 'total_items' => (int)$wpdb->get_var($items_count), |
|
| 621 | + 'per_page' => $this->get_items_per_page($this->screen->get_option('per_page', 'option')), |
|
| 622 | 622 | ) |
| 623 | 623 | ); |
| 624 | 624 | } |
| 625 | - return array_map( array( $this, 'data_reorganize' ), $datas ); |
|
| 625 | + return array_map(array($this, 'data_reorganize'), $datas); |
|
| 626 | 626 | } |
| 627 | 627 | /** |
| 628 | 628 | * Main function to call before display WP_List_Table. See parent class. |
@@ -631,8 +631,8 @@ discard block |
||
| 631 | 631 | * @return void Same results as request() but id as key. |
| 632 | 632 | */ |
| 633 | 633 | public function prepare_items() { |
| 634 | - foreach ( $this->request() as $item ) { |
|
| 635 | - $this->items[ $item['ID'] ] = $item; |
|
| 634 | + foreach ($this->request() as $item) { |
|
| 635 | + $this->items[$item['ID']] = $item; |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | /** |
@@ -642,20 +642,20 @@ discard block |
||
| 642 | 642 | * @param string $column_key Current column. |
| 643 | 643 | * @return string |
| 644 | 644 | */ |
| 645 | - public function cast_column( $column_key ) { |
|
| 645 | + public function cast_column($column_key) { |
|
| 646 | 646 | $columns_items = $this->request_items_columns(); |
| 647 | - if ( isset( $columns_items[ $column_key ] ) ) { |
|
| 648 | - $cast = $columns_items[ $column_key ]['data']; |
|
| 649 | - if ( in_array( $cast, array( 'varchar', 'text' ), true ) ) { |
|
| 647 | + if (isset($columns_items[$column_key])) { |
|
| 648 | + $cast = $columns_items[$column_key]['data']; |
|
| 649 | + if (in_array($cast, array('varchar', 'text'), true)) { |
|
| 650 | 650 | $cast = 'char'; |
| 651 | 651 | } |
| 652 | - if ( 'tx_tva' === $column_key ) { |
|
| 652 | + if ('tx_tva' === $column_key) { |
|
| 653 | 653 | return 'decimal'; |
| 654 | 654 | } |
| 655 | - if ( 'integer' === $cast && 'select' === $columns_items[ $column_key ]['type'] ) { |
|
| 655 | + if ('integer' === $cast && 'select' === $columns_items[$column_key]['type']) { |
|
| 656 | 656 | return null; |
| 657 | 657 | } |
| 658 | - if ( 'integer' === $cast && 'multiple-select' === $columns_items[ $column_key ]['type'] ) { |
|
| 658 | + if ('integer' === $cast && 'multiple-select' === $columns_items[$column_key]['type']) { |
|
| 659 | 659 | return null; |
| 660 | 660 | } |
| 661 | 661 | return $cast; |
@@ -669,12 +669,12 @@ discard block |
||
| 669 | 669 | * @param array $item Result of sql query. |
| 670 | 670 | * @return array Item reorganized. |
| 671 | 671 | */ |
| 672 | - public function data_reorganize( $item ) { |
|
| 673 | - $values = explode( ';', $item['data'] ); |
|
| 674 | - foreach ( $values as $value ) { |
|
| 675 | - $value = explode( ':', $value ); |
|
| 676 | - if ( ! isset( $this->columns_items[ $value[1] ] ) ) { |
|
| 677 | - $this->columns_items[ $value[1] ] = array( |
|
| 672 | + public function data_reorganize($item) { |
|
| 673 | + $values = explode(';', $item['data']); |
|
| 674 | + foreach ($values as $value) { |
|
| 675 | + $value = explode(':', $value); |
|
| 676 | + if (!isset($this->columns_items[$value[1]])) { |
|
| 677 | + $this->columns_items[$value[1]] = array( |
|
| 678 | 678 | 'id' => $value[0], |
| 679 | 679 | 'code' => $value[1], |
| 680 | 680 | 'name' => $value[2], |
@@ -682,32 +682,32 @@ discard block |
||
| 682 | 682 | 'data' => $value[7], |
| 683 | 683 | ); |
| 684 | 684 | } |
| 685 | - if ( 'yes' === $value[4] ) { |
|
| 686 | - if ( isset( $item[ $value[1] ]['value'] ) ) { |
|
| 687 | - if ( is_array( $item[ $value[1] ]['value'] ) ) { |
|
| 688 | - $item[ $value[1] ]['value'][] = $value[3]; |
|
| 685 | + if ('yes' === $value[4]) { |
|
| 686 | + if (isset($item[$value[1]]['value'])) { |
|
| 687 | + if (is_array($item[$value[1]]['value'])) { |
|
| 688 | + $item[$value[1]]['value'][] = $value[3]; |
|
| 689 | 689 | } else { |
| 690 | - $item[ $value[1] ]['value'] = array( $item[ $value[1] ]['value'], $value[3] ); |
|
| 690 | + $item[$value[1]]['value'] = array($item[$value[1]]['value'], $value[3]); |
|
| 691 | 691 | } |
| 692 | 692 | } else { |
| 693 | - $item[ $value[1] ] = array( |
|
| 693 | + $item[$value[1]] = array( |
|
| 694 | 694 | 'value' => $value[3], |
| 695 | 695 | 'unit' => $value[5], |
| 696 | 696 | ); |
| 697 | 697 | } |
| 698 | 698 | } else { |
| 699 | - if ( isset( $item[ $value[1] ] ) ) { |
|
| 700 | - if ( is_array( $item[ $value[1] ] ) ) { |
|
| 701 | - $item[ $value[1] ][] = $value[3]; |
|
| 702 | - } elseif ( $item[ $value[1] ] !== $value[3] ) { |
|
| 703 | - $item[ $value[1] ] = array( $item[ $value[1] ], $value[3] ); |
|
| 699 | + if (isset($item[$value[1]])) { |
|
| 700 | + if (is_array($item[$value[1]])) { |
|
| 701 | + $item[$value[1]][] = $value[3]; |
|
| 702 | + } elseif ($item[$value[1]] !== $value[3]) { |
|
| 703 | + $item[$value[1]] = array($item[$value[1]], $value[3]); |
|
| 704 | 704 | } |
| 705 | 705 | } else { |
| 706 | - $item[ $value[1] ] = $value[3]; |
|
| 706 | + $item[$value[1]] = $value[3]; |
|
| 707 | 707 | } |
| 708 | 708 | } |
| 709 | 709 | }// End foreach(). |
| 710 | - unset( $item['data'] ); |
|
| 710 | + unset($item['data']); |
|
| 711 | 711 | return $item; |
| 712 | 712 | } |
| 713 | 713 | /** |
@@ -717,11 +717,11 @@ discard block |
||
| 717 | 717 | * @param int $attribute_id Attribute ID. |
| 718 | 718 | * @return array |
| 719 | 719 | */ |
| 720 | - public function get_select_items_option( $attribute_id ) { |
|
| 721 | - if ( ! isset( self::$wpsdb_values_options[ $attribute_id ] ) ) { |
|
| 720 | + public function get_select_items_option($attribute_id) { |
|
| 721 | + if (!isset(self::$wpsdb_values_options[$attribute_id])) { |
|
| 722 | 722 | global $wpdb; |
| 723 | 723 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
| 724 | - self::$wpsdb_values_options[ $attribute_id ] = $wpdb->get_results( |
|
| 724 | + self::$wpsdb_values_options[$attribute_id] = $wpdb->get_results( |
|
| 725 | 725 | $wpdb->prepare( |
| 726 | 726 | "SELECT * |
| 727 | 727 | FROM {$wpsdb_values_options} |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | ARRAY_A |
| 733 | 733 | ); |
| 734 | 734 | } |
| 735 | - return self::$wpsdb_values_options[ $attribute_id ]; |
|
| 735 | + return self::$wpsdb_values_options[$attribute_id]; |
|
| 736 | 736 | } |
| 737 | 737 | /** |
| 738 | 738 | * Get all views available. |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | */ |
| 743 | 743 | public function request_views() { |
| 744 | 744 | global $wpdb; |
| 745 | - if ( is_null( $this->_views ) ) { |
|
| 745 | + if (is_null($this->_views)) { |
|
| 746 | 746 | $wpsdb_sets = WPSHOP_DBT_ATTRIBUTE_SET; |
| 747 | 747 | $include_states = array( |
| 748 | 748 | 'publish', |
@@ -753,8 +753,8 @@ discard block |
||
| 753 | 753 | 'trash', |
| 754 | 754 | 'scheduled', |
| 755 | 755 | ); |
| 756 | - $include_states = implode( "','", $include_states ); |
|
| 757 | - $post_types = implode( "','", $this->_post_types ); |
|
| 756 | + $include_states = implode("','", $include_states); |
|
| 757 | + $post_types = implode("','", $this->_post_types); |
|
| 758 | 758 | $this->_views = $wpdb->get_results( |
| 759 | 759 | $wpdb->prepare( |
| 760 | 760 | "SELECT s.id, name, slug, default_set, COUNT(p.ID) AS count |
@@ -780,9 +780,9 @@ discard block |
||
| 780 | 780 | * @return [type] [description] |
| 781 | 781 | */ |
| 782 | 782 | public function request_current_view() { |
| 783 | - if ( is_null( $this->current_view ) ) { |
|
| 784 | - foreach ( $this->request_views() as $view ) { |
|
| 785 | - if ( filter_var( $view['default_set'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 783 | + if (is_null($this->current_view)) { |
|
| 784 | + foreach ($this->request_views() as $view) { |
|
| 785 | + if (filter_var($view['default_set'], FILTER_VALIDATE_BOOLEAN)) { |
|
| 786 | 786 | $this->current_view = $view['id']; |
| 787 | 787 | } |
| 788 | 788 | } |
@@ -796,12 +796,12 @@ discard block |
||
| 796 | 796 | * @return array See :754 order columns. |
| 797 | 797 | */ |
| 798 | 798 | public function request_items_columns() { |
| 799 | - if ( empty( $this->columns_items ) ) { |
|
| 799 | + if (empty($this->columns_items)) { |
|
| 800 | 800 | global $wpdb; |
| 801 | 801 | $wpsdb_attribute = WPSHOP_DBT_ATTRIBUTE; |
| 802 | 802 | $wpsdb_attribute_set = WPSHOP_DBT_ATTRIBUTE_DETAILS; |
| 803 | - $exclude_attribute_codes = implode( "','", $this->exclude_attribute_codes ); |
|
| 804 | - foreach ( $wpdb->get_results( |
|
| 803 | + $exclude_attribute_codes = implode("','", $this->exclude_attribute_codes); |
|
| 804 | + foreach ($wpdb->get_results( |
|
| 805 | 805 | $wpdb->prepare( |
| 806 | 806 | "SELECT attr.id, attr.code, attr.frontend_label AS name, attr.backend_input AS type, attr.data_type AS data |
| 807 | 807 | FROM {$wpsdb_attribute} attr |
@@ -815,11 +815,11 @@ discard block |
||
| 815 | 815 | $this->entity_id |
| 816 | 816 | ), |
| 817 | 817 | ARRAY_A |
| 818 | - ) as $column ) { |
|
| 819 | - $this->columns_items[ $column['code'] ] = $column; |
|
| 818 | + ) as $column) { |
|
| 819 | + $this->columns_items[$column['code']] = $column; |
|
| 820 | 820 | } |
| 821 | 821 | } |
| 822 | - ksort( $this->columns_items ); |
|
| 822 | + ksort($this->columns_items); |
|
| 823 | 823 | return $this->columns_items; |
| 824 | 824 | } |
| 825 | 825 | /** |
@@ -830,30 +830,30 @@ discard block |
||
| 830 | 830 | */ |
| 831 | 831 | public function get_views() { |
| 832 | 832 | $result = array(); |
| 833 | - foreach ( $this->request_views() as $view ) { |
|
| 833 | + foreach ($this->request_views() as $view) { |
|
| 834 | 834 | $class = ''; |
| 835 | - if ( (int) $view['id'] === (int) $this->request_current_view() ) { |
|
| 835 | + if ((int)$view['id'] === (int)$this->request_current_view()) { |
|
| 836 | 836 | $class = ' class="current"'; |
| 837 | 837 | } |
| 838 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
| 838 | + $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
| 839 | 839 | $link = add_query_arg( |
| 840 | 840 | array( |
| 841 | 841 | 'page' => |
| 842 | 842 | str_replace( |
| 843 | 843 | "{$this->screen->post_type}_page_", |
| 844 | 844 | '', |
| 845 | - substr( $this->screen->id, 0, strpos( $this->screen->id, '_att_set_' ) ) . '_att_set_' . $view['id'] |
|
| 845 | + substr($this->screen->id, 0, strpos($this->screen->id, '_att_set_')) . '_att_set_' . $view['id'] |
|
| 846 | 846 | ), |
| 847 | 847 | ), |
| 848 | 848 | $current_url |
| 849 | 849 | ); |
| 850 | - $link = remove_query_arg( 'paged', $link ); |
|
| 851 | - $result[ $view['id'] ] = sprintf( |
|
| 850 | + $link = remove_query_arg('paged', $link); |
|
| 851 | + $result[$view['id']] = sprintf( |
|
| 852 | 852 | '<a href="%s"%s>%s <span class="count">(%s)</span></a>', |
| 853 | - esc_url( $link ), |
|
| 853 | + esc_url($link), |
|
| 854 | 854 | $class, |
| 855 | 855 | $view['name'], |
| 856 | - number_format_i18n( $view['count'] ) |
|
| 856 | + number_format_i18n($view['count']) |
|
| 857 | 857 | ); |
| 858 | 858 | } |
| 859 | 859 | return $result; |
@@ -865,10 +865,10 @@ discard block |
||
| 865 | 865 | * @param string $which Can be top or bottom. |
| 866 | 866 | * @return void Direct display. |
| 867 | 867 | */ |
| 868 | - public function bulk_actions( $which = '' ) { |
|
| 869 | - submit_button( __( 'Save changes', 'wpshop' ), 'bulk-save', 'bulk-save', false, array( |
|
| 870 | - 'data-nonce' => wp_create_nonce( 'bulk-save-mass-edit-interface-3' ), |
|
| 871 | - ) ); |
|
| 868 | + public function bulk_actions($which = '') { |
|
| 869 | + submit_button(__('Save changes', 'wpshop'), 'bulk-save', 'bulk-save', false, array( |
|
| 870 | + 'data-nonce' => wp_create_nonce('bulk-save-mass-edit-interface-3'), |
|
| 871 | + )); |
|
| 872 | 872 | ?><span class="spinner"></span><?php |
| 873 | 873 | } |
| 874 | 874 | /** |
@@ -882,34 +882,34 @@ discard block |
||
| 882 | 882 | * @param array $rows List of rows always traited. |
| 883 | 883 | * @return void |
| 884 | 884 | */ |
| 885 | - private function _display_row( &$lvl, $item_id, $item, &$rows ) { |
|
| 886 | - if ( array_key_exists( $item_id, $rows ) ) { |
|
| 885 | + private function _display_row(&$lvl, $item_id, $item, &$rows) { |
|
| 886 | + if (array_key_exists($item_id, $rows)) { |
|
| 887 | 887 | return; |
| 888 | 888 | } |
| 889 | - if ( ! array_key_exists( $item['parent'], $this->items ) && 0 !== (int) $item['parent'] ) { |
|
| 890 | - $parent_item = $this->request( $item['parent'] ); |
|
| 891 | - if ( isset( $parent_item[0] ) ) { |
|
| 892 | - $this->items[ $item['parent'] ] = $parent_item[0]; |
|
| 889 | + if (!array_key_exists($item['parent'], $this->items) && 0 !== (int)$item['parent']) { |
|
| 890 | + $parent_item = $this->request($item['parent']); |
|
| 891 | + if (isset($parent_item[0])) { |
|
| 892 | + $this->items[$item['parent']] = $parent_item[0]; |
|
| 893 | 893 | } else { |
| 894 | - $this->items[ $item['parent'] ] = null; |
|
| 894 | + $this->items[$item['parent']] = null; |
|
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | - if ( array_key_exists( $item['parent'], $rows ) ) { |
|
| 898 | - $offset = array_search( $item['parent'], array_keys( $rows ), true ); |
|
| 899 | - $rows_a = array_slice( $rows, $offset, null, true ); |
|
| 900 | - $rows_a[ $item_id ] = $item; |
|
| 901 | - $rows_b = array_slice( $rows, 0, $offset, true ); |
|
| 902 | - $rows = array_replace( $rows_a, $rows_b ); |
|
| 897 | + if (array_key_exists($item['parent'], $rows)) { |
|
| 898 | + $offset = array_search($item['parent'], array_keys($rows), true); |
|
| 899 | + $rows_a = array_slice($rows, $offset, null, true); |
|
| 900 | + $rows_a[$item_id] = $item; |
|
| 901 | + $rows_b = array_slice($rows, 0, $offset, true); |
|
| 902 | + $rows = array_replace($rows_a, $rows_b); |
|
| 903 | 903 | // $rows = $rows_a + $rows_b; FASTER ? |
| 904 | 904 | $lvl++; |
| 905 | - } elseif ( 0 !== (int) $item['parent'] ) { |
|
| 906 | - $this->_display_row( $lvl, $item['parent'], $this->items[ $item['parent'] ], $rows ); |
|
| 905 | + } elseif (0 !== (int)$item['parent']) { |
|
| 906 | + $this->_display_row($lvl, $item['parent'], $this->items[$item['parent']], $rows); |
|
| 907 | 907 | $lvl++; |
| 908 | 908 | } |
| 909 | - if ( ! empty( $item ) ) { |
|
| 910 | - $item['lvl'] = str_repeat( '— ', $lvl ); |
|
| 909 | + if (!empty($item)) { |
|
| 910 | + $item['lvl'] = str_repeat('— ', $lvl); |
|
| 911 | 911 | } |
| 912 | - $rows[ $item_id ] = $item; |
|
| 912 | + $rows[$item_id] = $item; |
|
| 913 | 913 | } |
| 914 | 914 | /** |
| 915 | 915 | * See WP_List_Table. |
@@ -919,13 +919,13 @@ discard block |
||
| 919 | 919 | */ |
| 920 | 920 | public function display_rows() { |
| 921 | 921 | $rows = array(); |
| 922 | - foreach ( $this->items as $item_id => $item ) { |
|
| 922 | + foreach ($this->items as $item_id => $item) { |
|
| 923 | 923 | $lvl = 0; |
| 924 | - $this->_display_row( $lvl, $item_id, $item, $rows ); |
|
| 924 | + $this->_display_row($lvl, $item_id, $item, $rows); |
|
| 925 | 925 | } |
| 926 | - foreach ( $rows as $item ) { |
|
| 927 | - if ( ! empty( $item ) ) { |
|
| 928 | - $this->single_row( $item ); |
|
| 926 | + foreach ($rows as $item) { |
|
| 927 | + if (!empty($item)) { |
|
| 928 | + $this->single_row($item); |
|
| 929 | 929 | } |
| 930 | 930 | } |
| 931 | 931 | } |
@@ -946,52 +946,52 @@ discard block |
||
| 946 | 946 | * @param boolean $with_id See wp_list_table::print_column_headers. |
| 947 | 947 | * @return void Direct display. |
| 948 | 948 | */ |
| 949 | - public function print_column_headers( $with_id = true ) { |
|
| 950 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
| 949 | + public function print_column_headers($with_id = true) { |
|
| 950 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
| 951 | 951 | |
| 952 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
| 953 | - $current_url = remove_query_arg( 'paged', $current_url ); |
|
| 952 | + $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
| 953 | + $current_url = remove_query_arg('paged', $current_url); |
|
| 954 | 954 | |
| 955 | - if ( isset( $_GET['orderby'] ) ) { // WPCS: CSRF ok. |
|
| 955 | + if (isset($_GET['orderby'])) { // WPCS: CSRF ok. |
|
| 956 | 956 | $current_orderby = $_GET['orderby']; // WPCS: CSRF ok. |
| 957 | 957 | } else { |
| 958 | 958 | $current_orderby = ''; |
| 959 | 959 | } |
| 960 | 960 | |
| 961 | - if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { // WPCS: CSRF ok. |
|
| 961 | + if (isset($_GET['order']) && 'desc' === $_GET['order']) { // WPCS: CSRF ok. |
|
| 962 | 962 | $current_order = 'desc'; |
| 963 | 963 | } else { |
| 964 | 964 | $current_order = 'asc'; |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | - if ( ! empty( $columns['cb'] ) ) { |
|
| 967 | + if (!empty($columns['cb'])) { |
|
| 968 | 968 | static $cb_counter = 1; |
| 969 | - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
|
| 969 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>' |
|
| 970 | 970 | . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
| 971 | 971 | $cb_counter++; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - foreach ( $columns as $column_key => $column_display_name ) { |
|
| 975 | - $class = array( 'manage-column', "column-$column_key" ); |
|
| 974 | + foreach ($columns as $column_key => $column_display_name) { |
|
| 975 | + $class = array('manage-column', "column-$column_key"); |
|
| 976 | 976 | |
| 977 | - if ( in_array( $column_key, $hidden, true ) ) { |
|
| 977 | + if (in_array($column_key, $hidden, true)) { |
|
| 978 | 978 | $class[] = 'hidden'; |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - if ( 'cb' === $column_key ) { |
|
| 981 | + if ('cb' === $column_key) { |
|
| 982 | 982 | $class[] = 'check-column'; |
| 983 | - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { |
|
| 983 | + } elseif (in_array($column_key, array('posts', 'comments', 'links'), true)) { |
|
| 984 | 984 | $class[] = 'num'; |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | - if ( $column_key === $primary ) { |
|
| 987 | + if ($column_key === $primary) { |
|
| 988 | 988 | $class[] = 'column-primary'; |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
| 992 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
| 991 | + if (isset($sortable[$column_key])) { |
|
| 992 | + list($orderby, $desc_first) = $sortable[$column_key]; |
|
| 993 | 993 | |
| 994 | - if ( $current_orderby === $orderby ) { |
|
| 994 | + if ($current_orderby === $orderby) { |
|
| 995 | 995 | $order = 'asc' === $current_order ? 'desc' : 'asc'; |
| 996 | 996 | $class[] = 'sorted'; |
| 997 | 997 | $class[] = $current_order; |
@@ -1001,17 +1001,17 @@ discard block |
||
| 1001 | 1001 | $class[] = $desc_first ? 'asc' : 'desc'; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | - $cast = $this->cast_column( $column_key ); |
|
| 1004 | + $cast = $this->cast_column($column_key); |
|
| 1005 | 1005 | |
| 1006 | - $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order', 'cast' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; |
|
| 1006 | + $column_display_name = '<a href="' . esc_url(add_query_arg(compact('orderby', 'order', 'cast'), $current_url)) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; |
|
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
|
| 1010 | - $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
|
| 1009 | + $tag = ('cb' === $column_key) ? 'td' : 'th'; |
|
| 1010 | + $scope = ('th' === $tag) ? 'scope="col"' : ''; |
|
| 1011 | 1011 | $id = $with_id ? "id='$column_key'" : ''; |
| 1012 | 1012 | |
| 1013 | - if ( ! empty( $class ) ) { |
|
| 1014 | - $class = "class='" . join( ' ', $class ) . "'"; |
|
| 1013 | + if (!empty($class)) { |
|
| 1014 | + $class = "class='" . join(' ', $class) . "'"; |
|
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | 1017 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; // WPCS: XSS ok. |
@@ -1,81 +1,81 @@ |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) { exit; |
|
| 2 | 2 | } |
| 3 | - $order_post_meta = ! empty( $post ) ? get_post_meta( $post->ID, '_wpshop_order_status', true ) : ''; ?> |
|
| 3 | + $order_post_meta = !empty($post) ? get_post_meta($post->ID, '_wpshop_order_status', true) : ''; ?> |
|
| 4 | 4 | <div class="wps-table"> |
| 5 | 5 | <div class="wps-table-header wps-table-row"> |
| 6 | - <div class="wps-table-cell"><?php _e( 'Picture', 'wpshop' ); ?></div> |
|
| 7 | - <div class="wps-table-cell"><?php _e( 'Product reference', 'wpshop' ); ?></div> |
|
| 8 | - <div class="wps-table-cell"><?php _e( 'Product name', 'wpshop' ); ?></div> |
|
| 9 | - <div class="wps-table-cell"><?php _e( 'Price', 'wpshop' ); ?></div> |
|
| 6 | + <div class="wps-table-cell"><?php _e('Picture', 'wpshop'); ?></div> |
|
| 7 | + <div class="wps-table-cell"><?php _e('Product reference', 'wpshop'); ?></div> |
|
| 8 | + <div class="wps-table-cell"><?php _e('Product name', 'wpshop'); ?></div> |
|
| 9 | + <div class="wps-table-cell"><?php _e('Price', 'wpshop'); ?></div> |
|
| 10 | 10 | |
| 11 | - <?php if ( 'completed' != $order_post_meta ) : ?> |
|
| 12 | - <div class="wps-table-cell"><?php _e( 'Quantity', 'wpshop' ); ?></div> |
|
| 13 | - <div class="wps-table-cell"><?php _e( 'Add to order', 'wpshop' ); ?></div> |
|
| 11 | + <?php if ('completed' != $order_post_meta) : ?> |
|
| 12 | + <div class="wps-table-cell"><?php _e('Quantity', 'wpshop'); ?></div> |
|
| 13 | + <div class="wps-table-cell"><?php _e('Add to order', 'wpshop'); ?></div> |
|
| 14 | 14 | <?php endif; ?> |
| 15 | 15 | </div> |
| 16 | - <?php if ( ! empty( $products ) ) : |
|
| 17 | - $total_products = count( $products ); |
|
| 16 | + <?php if (!empty($products)) : |
|
| 17 | + $total_products = count($products); |
|
| 18 | 18 | $i = 0; |
| 19 | 19 | $elements_per_page = 20; |
| 20 | - $paged = absint( isset( $_REQUEST['paged_order'] ) ? $_REQUEST['paged_order'] : 1 ); |
|
| 21 | - $paginate_links = paginate_links( array( |
|
| 20 | + $paged = absint(isset($_REQUEST['paged_order']) ? $_REQUEST['paged_order'] : 1); |
|
| 21 | + $paginate_links = paginate_links(array( |
|
| 22 | 22 | 'base' => '%_%', |
| 23 | 23 | 'format' => '?paged_order=%#%', |
| 24 | 24 | 'current' => $paged, |
| 25 | - 'total' => ceil( $total_products / $elements_per_page ), |
|
| 25 | + 'total' => ceil($total_products / $elements_per_page), |
|
| 26 | 26 | 'type' => 'list', |
| 27 | 27 | 'prev_next' => true, |
| 28 | - ) ); |
|
| 29 | - foreach ( $products as $product ) : |
|
| 30 | - if ( ( $elements_per_page * ( $paged - 1 ) ) > $i ) { |
|
| 28 | + )); |
|
| 29 | + foreach ($products as $product) : |
|
| 30 | + if (($elements_per_page * ($paged - 1)) > $i) { |
|
| 31 | 31 | $i++; |
| 32 | 32 | continue; |
| 33 | - } elseif ( ( $elements_per_page * $paged ) <= $i ) { |
|
| 33 | + } elseif (($elements_per_page * $paged) <= $i) { |
|
| 34 | 34 | break; |
| 35 | 35 | } |
| 36 | 36 | $i++; |
| 37 | 37 | $pid = $product->ID; |
| 38 | 38 | ?> |
| 39 | - <?php $product_metadata = get_post_meta( $product->ID, '_wpshop_product_metadata', true ); ?> |
|
| 39 | + <?php $product_metadata = get_post_meta($product->ID, '_wpshop_product_metadata', true); ?> |
|
| 40 | 40 | <div class="wps-table-content wps-table-row"> |
| 41 | - <div class="wps-table-cell wps-cart-item-img"><?php echo get_the_post_thumbnail( $product->ID, 'thumbnail' ); ?></div> |
|
| 42 | - <div class="wps-table-cell"><?php echo ( ! empty( $product_metadata ) && $product_metadata['product_reference']) ? $product_metadata['product_reference'] : ''; ?></div> |
|
| 41 | + <div class="wps-table-cell wps-cart-item-img"><?php echo get_the_post_thumbnail($product->ID, 'thumbnail'); ?></div> |
|
| 42 | + <div class="wps-table-cell"><?php echo (!empty($product_metadata) && $product_metadata['product_reference']) ? $product_metadata['product_reference'] : ''; ?></div> |
|
| 43 | 43 | <div class="wps-table-cell"><?php echo $product->post_title; ?></div> |
| 44 | 44 | <div class="wps-table-cell"> |
| 45 | 45 | <?php |
| 46 | - $product = wpshop_products::get_product_data( $product->ID ); |
|
| 47 | - echo wpshop_prices::get_product_price( $product, 'price_display', array( 'mini_output', 'grid' ) ); |
|
| 46 | + $product = wpshop_products::get_product_data($product->ID); |
|
| 47 | + echo wpshop_prices::get_product_price($product, 'price_display', array('mini_output', 'grid')); |
|
| 48 | 48 | ?> |
| 49 | 49 | </div> |
| 50 | - <?php if ( 'completed' != $order_post_meta ) : ?> |
|
| 50 | + <?php if ('completed' != $order_post_meta) : ?> |
|
| 51 | 51 | <div class="wps-table-cell"> |
| 52 | - <a class="wps-bton-icon-minus-small wps-cart-reduce-product-qty" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" href=""></a> |
|
| 52 | + <a class="wps-bton-icon-minus-small wps-cart-reduce-product-qty" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" href=""></a> |
|
| 53 | 53 | <input id="wps-cart-product-qty-<?php echo $pid; ?>" class="wps-cart-product-qty" type="text" value="1" name="french-hens" size="3" style="text-align : center"> |
| 54 | - <a class="wps-bton-icon-plus-small wps-cart-add-product-qty" data-nonce="<?php echo wp_create_nonce( 'ajax_wpshop_set_qty_for_product_into_cart' ); ?>" href=""></a> |
|
| 54 | + <a class="wps-bton-icon-plus-small wps-cart-add-product-qty" data-nonce="<?php echo wp_create_nonce('ajax_wpshop_set_qty_for_product_into_cart'); ?>" href=""></a> |
|
| 55 | 55 | </div> |
| 56 | 56 | <div class="wps-table-cell"> |
| 57 | - <a href="#" data-nonce="<?php echo wp_create_nonce( 'wps_add_product_to_order_admin' ); ?>" class="wps-bton-first-mini-rounded wps-order-add-product" id="wps-order-add-product-<?php echo $pid; ?>"><i class="wps-icon-basket"></i> <?php _e( 'Add to order', 'wpshop' ); ?></a> |
|
| 57 | + <a href="#" data-nonce="<?php echo wp_create_nonce('wps_add_product_to_order_admin'); ?>" class="wps-bton-first-mini-rounded wps-order-add-product" id="wps-order-add-product-<?php echo $pid; ?>"><i class="wps-icon-basket"></i> <?php _e('Add to order', 'wpshop'); ?></a> |
|
| 58 | 58 | </div> |
| 59 | 59 | <?php endif; ?> |
| 60 | 60 | </div> |
| 61 | 61 | <?php endforeach; |
| 62 | 62 | else : |
| 63 | - if ( ! empty( $research ) ) : ?> |
|
| 64 | - <div class="wps-alert-info"><?php printf( __( 'No products corresponds to the search <strong>"%s"</strong>', 'wpshop' ), $research ); ?></div> |
|
| 63 | + if (!empty($research)) : ?> |
|
| 64 | + <div class="wps-alert-info"><?php printf(__('No products corresponds to the search <strong>"%s"</strong>', 'wpshop'), $research); ?></div> |
|
| 65 | 65 | <?php else : |
| 66 | - $letter_display = ( strtoupper( $current_letter ) != 'ALL' ) ? $current_letter : __( 'ALL', 'wpshop' ); ?> |
|
| 67 | - <div class="wps-alert-info"><?php printf( __( 'No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop' ), strtoupper( $letter_display ) ); ?></div> |
|
| 66 | + $letter_display = (strtoupper($current_letter) != 'ALL') ? $current_letter : __('ALL', 'wpshop'); ?> |
|
| 67 | + <div class="wps-alert-info"><?php printf(__('No products corresponds to the letter <strong>"%s"</strong> search', 'wpshop'), strtoupper($letter_display)); ?></div> |
|
| 68 | 68 | <?php endif; |
| 69 | 69 | endif; ?> |
| 70 | 70 | </div> |
| 71 | 71 | <?php |
| 72 | -if ( ! empty( $products ) && $total_products > $elements_per_page ) : |
|
| 72 | +if (!empty($products) && $total_products > $elements_per_page) : |
|
| 73 | 73 | echo $paginate_links; |
| 74 | 74 | ?> |
| 75 | 75 | <input type="hidden" name="last_query[oid]" value="<?php echo $post->ID; ?>"> |
| 76 | - <input type="hidden" name="last_query[letter]" value="<?php echo strtoupper( $current_letter ); ?>"> |
|
| 77 | - <input type="hidden" name="last_query[research]" value="<?php echo isset( $research ) ? $research : ''; ?>"> |
|
| 78 | - <input type="hidden" name="last_query[_wpnonce]" value="<?php echo wp_create_nonce( 'refresh_product_list_' . strtolower( $current_letter ) ); ?>"> |
|
| 76 | + <input type="hidden" name="last_query[letter]" value="<?php echo strtoupper($current_letter); ?>"> |
|
| 77 | + <input type="hidden" name="last_query[research]" value="<?php echo isset($research) ? $research : ''; ?>"> |
|
| 78 | + <input type="hidden" name="last_query[_wpnonce]" value="<?php echo wp_create_nonce('refresh_product_list_' . strtolower($current_letter)); ?>"> |
|
| 79 | 79 | <?php |
| 80 | 80 | endif; |
| 81 | 81 | ?> |
@@ -2,25 +2,25 @@ discard block |
||
| 2 | 2 | class WPS_EAV_Revisions { |
| 3 | 3 | public static $created_revisions = array(); |
| 4 | 4 | public function __construct() { |
| 5 | - add_action( 'save_post', array( $this, 'save_post' ), 100, 2 ); |
|
| 6 | - add_action( 'wp_restore_post_revision', array( $this, 'wp_restore_post_revision' ), 10, 2 ); |
|
| 7 | - add_filter( '_wp_post_revision_fields', array( $this, 'wp_post_revision_fields' ), 10, 2 ); |
|
| 5 | + add_action('save_post', array($this, 'save_post'), 100, 2); |
|
| 6 | + add_action('wp_restore_post_revision', array($this, 'wp_restore_post_revision'), 10, 2); |
|
| 7 | + add_filter('_wp_post_revision_fields', array($this, 'wp_post_revision_fields'), 10, 2); |
|
| 8 | 8 | } |
| 9 | - public function save_post( $post_id, $post ) { |
|
| 10 | - if ( false === wp_is_post_revision( $post_id ) ) { |
|
| 11 | - if ( ( ! isset( self::$created_revisions[ $post_id ] ) || true !== self::$created_revisions[ $post_id ] ) && post_type_supports( $post->post_type, 'revisions' ) ) { |
|
| 12 | - self::$created_revisions[ wp_is_post_revision( $post_id ) ] = true; |
|
| 13 | - add_filter( 'wp_save_post_revision_post_has_changed', array( $this, 'wp_save_post_revision_post_has_changed' ), 10, 3 ); |
|
| 14 | - wp_save_post_revision( $post_id ); |
|
| 9 | + public function save_post($post_id, $post) { |
|
| 10 | + if (false === wp_is_post_revision($post_id)) { |
|
| 11 | + if ((!isset(self::$created_revisions[$post_id]) || true !== self::$created_revisions[$post_id]) && post_type_supports($post->post_type, 'revisions')) { |
|
| 12 | + self::$created_revisions[wp_is_post_revision($post_id)] = true; |
|
| 13 | + add_filter('wp_save_post_revision_post_has_changed', array($this, 'wp_save_post_revision_post_has_changed'), 10, 3); |
|
| 14 | + wp_save_post_revision($post_id); |
|
| 15 | 15 | } |
| 16 | 16 | } else { |
| 17 | - self::$created_revisions[ wp_is_post_revision( $post_id ) ] = true; |
|
| 17 | + self::$created_revisions[wp_is_post_revision($post_id)] = true; |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | - public function wp_save_post_revision_post_has_changed( $post_has_changed, $last_revision, $post ) { |
|
| 20 | + public function wp_save_post_revision_post_has_changed($post_has_changed, $last_revision, $post) { |
|
| 21 | 21 | return true; |
| 22 | 22 | } |
| 23 | - public function wp_restore_post_revision( $post_id, $revision_id ) { |
|
| 23 | + public function wp_restore_post_revision($post_id, $revision_id) { |
|
| 24 | 24 | /* |
| 25 | 25 | $post = get_post( $post_id ); |
| 26 | 26 | $revision = get_post( $revision_id ); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | update_post_meta( $post_id, 'foo', $meta ); |
| 32 | 32 | }*/ |
| 33 | 33 | } |
| 34 | - public function wp_post_revision_fields( $fields, $post ) { |
|
| 34 | + public function wp_post_revision_fields($fields, $post) { |
|
| 35 | 35 | global $wpdb; |
| 36 | 36 | $wpsdb_attribute = WPSHOP_DBT_ATTRIBUTE; |
| 37 | 37 | $wpsdb_attribute_set = WPSHOP_DBT_ATTRIBUTE_DETAILS; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $wpsdb_values_varchar = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; |
| 43 | 43 | $wpsdb_values_text = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; |
| 44 | 44 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
| 45 | - $datas = $wpdb->get_results( $wpdb->prepare( |
|
| 45 | + $datas = $wpdb->get_results($wpdb->prepare( |
|
| 46 | 46 | "SELECT attr.id, |
| 47 | 47 | attr.code, |
| 48 | 48 | attr.frontend_label, |
@@ -71,18 +71,18 @@ discard block |
||
| 71 | 71 | WHERE p.ID = %d |
| 72 | 72 | GROUP BY attr.code", |
| 73 | 73 | $post['ID'] |
| 74 | - ), ARRAY_A ); |
|
| 75 | - foreach ( $datas as $data ) { |
|
| 76 | - $fields[ $data['id'] ] = $data['frontend_label']; |
|
| 77 | - add_filter( "_wp_post_revision_field_{$data['id']}", array( $this, 'wp_post_revision_field' ), 10, 4 ); |
|
| 74 | + ), ARRAY_A); |
|
| 75 | + foreach ($datas as $data) { |
|
| 76 | + $fields[$data['id']] = $data['frontend_label']; |
|
| 77 | + add_filter("_wp_post_revision_field_{$data['id']}", array($this, 'wp_post_revision_field'), 10, 4); |
|
| 78 | 78 | } |
| 79 | 79 | return $fields; |
| 80 | 80 | } |
| 81 | - public function wp_post_revision_field( $value, $field, $revision, $fromto ) { |
|
| 81 | + public function wp_post_revision_field($value, $field, $revision, $fromto) { |
|
| 82 | 82 | global $wpdb; |
| 83 | 83 | $wpsdb_histo = WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO; |
| 84 | 84 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
| 85 | - $result = $wpdb->get_var( $wpdb->prepare( |
|
| 85 | + $result = $wpdb->get_var($wpdb->prepare( |
|
| 86 | 86 | "SELECT IFNULL( val_opt.label, |
| 87 | 87 | histo.value |
| 88 | 88 | ) |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | $revision->post_date, |
| 96 | 96 | $field, |
| 97 | 97 | $revision->post_parent |
| 98 | - ) ); |
|
| 99 | - $result = ( '0' === $result ) ? null : $result; |
|
| 98 | + )); |
|
| 99 | + $result = ('0' === $result) ? null : $result; |
|
| 100 | 100 | return $result; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) { exit; |
|
| 2 | 2 | } |
| 3 | 3 | /** |
| 4 | 4 | * Plugin configuration file. |
@@ -12,322 +12,322 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // End if(). |
| 15 | -if ( ! defined( 'WPSHOP_VERSION' ) ) { |
|
| 16 | - die( __( 'Access is not allowed by this way', 'wpshop' ) ); |
|
| 15 | +if (!defined('WPSHOP_VERSION')) { |
|
| 16 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | // End if(). |
| 20 | 20 | global $wpdb; |
| 21 | 21 | /* Define the shop type */ |
| 22 | -DEFINE( 'WPSHOP_DEFAULT_SHOP_TYPE', 'sale' ); |
|
| 23 | -$wpshop_shop_type = get_option( 'wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE ); |
|
| 24 | -DEFINE( 'WPSHOP_DEFINED_SHOP_TYPE', $wpshop_shop_type ); |
|
| 22 | +DEFINE('WPSHOP_DEFAULT_SHOP_TYPE', 'sale'); |
|
| 23 | +$wpshop_shop_type = get_option('wpshop_shop_type', WPSHOP_DEFAULT_SHOP_TYPE); |
|
| 24 | +DEFINE('WPSHOP_DEFINED_SHOP_TYPE', $wpshop_shop_type); |
|
| 25 | 25 | |
| 26 | 26 | /* |
| 27 | 27 | Define the different path for the plugin */ |
| 28 | 28 | /* Define main plugin directory for our plugin */ |
| 29 | - DEFINE( 'WPSHOP_DIR', WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR ); |
|
| 30 | - DEFINE( 'WPSHOP_URL', WP_PLUGIN_URL . '/' . WPSHOP_PLUGIN_DIR ); |
|
| 29 | + DEFINE('WPSHOP_DIR', WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR); |
|
| 30 | + DEFINE('WPSHOP_URL', WP_PLUGIN_URL . '/' . WPSHOP_PLUGIN_DIR); |
|
| 31 | 31 | |
| 32 | 32 | /* Define languages directory for our plugin */ |
| 33 | - DEFINE( 'WPSHOP_LANGUAGES_DIR', WPSHOP_DIR . '/languages/' ); |
|
| 34 | - DEFINE( 'WPSHOP_LANGUAGES_URL', WPSHOP_URL . '/languages/' ); |
|
| 33 | + DEFINE('WPSHOP_LANGUAGES_DIR', WPSHOP_DIR . '/languages/'); |
|
| 34 | + DEFINE('WPSHOP_LANGUAGES_URL', WPSHOP_URL . '/languages/'); |
|
| 35 | 35 | |
| 36 | 36 | /* Define includes directory for our plugin */ |
| 37 | - DEFINE( 'WPSHOP_INCLUDES_DIR', WPSHOP_DIR . '/includes/' ); |
|
| 38 | - DEFINE( 'WPSHOP_INCLUDES_URL', WPSHOP_URL . '/includes/' ); |
|
| 39 | - DEFINE( 'WPSHOP_MODULES_DIR', WPSHOP_INCLUDES_DIR . 'modules/' ); |
|
| 37 | + DEFINE('WPSHOP_INCLUDES_DIR', WPSHOP_DIR . '/includes/'); |
|
| 38 | + DEFINE('WPSHOP_INCLUDES_URL', WPSHOP_URL . '/includes/'); |
|
| 39 | + DEFINE('WPSHOP_MODULES_DIR', WPSHOP_INCLUDES_DIR . 'modules/'); |
|
| 40 | 40 | /* Define librairies directory for our plugin */ |
| 41 | - DEFINE( 'WPSHOP_LIBRAIRIES_DIR', WPSHOP_INCLUDES_DIR . 'librairies/' ); |
|
| 42 | - DEFINE( 'WPSHOP_LIBRAIRIES_URL', WPSHOP_INCLUDES_URL . 'librairies/' ); |
|
| 41 | + DEFINE('WPSHOP_LIBRAIRIES_DIR', WPSHOP_INCLUDES_DIR . 'librairies/'); |
|
| 42 | + DEFINE('WPSHOP_LIBRAIRIES_URL', WPSHOP_INCLUDES_URL . 'librairies/'); |
|
| 43 | 43 | |
| 44 | 44 | /* Define templates directory for our plugin */ |
| 45 | - DEFINE( 'WPSHOP_TEMPLATES_DIR', WPSHOP_DIR . '/templates/' ); |
|
| 46 | - DEFINE( 'WPSHOP_TEMPLATES_URL', WPSHOP_URL . '/templates/' ); |
|
| 45 | + DEFINE('WPSHOP_TEMPLATES_DIR', WPSHOP_DIR . '/templates/'); |
|
| 46 | + DEFINE('WPSHOP_TEMPLATES_URL', WPSHOP_URL . '/templates/'); |
|
| 47 | 47 | /* Define medias directory for our plugin */ |
| 48 | - DEFINE( 'WPSHOP_MEDIAS_DIR', WPSHOP_TEMPLATES_DIR . 'admin/medias/' ); |
|
| 49 | - DEFINE( 'WPSHOP_MEDIAS_URL', WPSHOP_TEMPLATES_URL . 'admin/medias/' ); |
|
| 48 | + DEFINE('WPSHOP_MEDIAS_DIR', WPSHOP_TEMPLATES_DIR . 'admin/medias/'); |
|
| 49 | + DEFINE('WPSHOP_MEDIAS_URL', WPSHOP_TEMPLATES_URL . 'admin/medias/'); |
|
| 50 | 50 | /* Define plugin icon directory */ |
| 51 | - DEFINE( 'WPSHOP_MEDIAS_ICON_DIR', WPSHOP_MEDIAS_DIR . 'icones/' ); |
|
| 52 | - DEFINE( 'WPSHOP_MEDIAS_ICON_URL', WPSHOP_MEDIAS_URL . 'icones/' ); |
|
| 51 | + DEFINE('WPSHOP_MEDIAS_ICON_DIR', WPSHOP_MEDIAS_DIR . 'icones/'); |
|
| 52 | + DEFINE('WPSHOP_MEDIAS_ICON_URL', WPSHOP_MEDIAS_URL . 'icones/'); |
|
| 53 | 53 | /* Define plugin picture directory */ |
| 54 | - DEFINE( 'WPSHOP_MEDIAS_IMAGES_DIR', WPSHOP_MEDIAS_DIR . 'images/' ); |
|
| 55 | - DEFINE( 'WPSHOP_MEDIAS_IMAGES_URL', WPSHOP_MEDIAS_URL . 'images/' ); |
|
| 54 | + DEFINE('WPSHOP_MEDIAS_IMAGES_DIR', WPSHOP_MEDIAS_DIR . 'images/'); |
|
| 55 | + DEFINE('WPSHOP_MEDIAS_IMAGES_URL', WPSHOP_MEDIAS_URL . 'images/'); |
|
| 56 | 56 | /* Define medias directory for our plugin */ |
| 57 | - DEFINE( 'WPSHOP_JS_DIR', WPSHOP_TEMPLATES_DIR . 'admin/js/' ); |
|
| 58 | - DEFINE( 'WPSHOP_JS_URL', WPSHOP_TEMPLATES_URL . 'admin/js/' ); |
|
| 57 | + DEFINE('WPSHOP_JS_DIR', WPSHOP_TEMPLATES_DIR . 'admin/js/'); |
|
| 58 | + DEFINE('WPSHOP_JS_URL', WPSHOP_TEMPLATES_URL . 'admin/js/'); |
|
| 59 | 59 | /* Define medias directory for our plugin */ |
| 60 | - DEFINE( 'WPSHOP_CSS_DIR', WPSHOP_TEMPLATES_DIR . 'admin/css/' ); |
|
| 61 | - DEFINE( 'WPSHOP_CSS_URL', WPSHOP_TEMPLATES_URL . 'admin/css/' ); |
|
| 60 | + DEFINE('WPSHOP_CSS_DIR', WPSHOP_TEMPLATES_DIR . 'admin/css/'); |
|
| 61 | + DEFINE('WPSHOP_CSS_URL', WPSHOP_TEMPLATES_URL . 'admin/css/'); |
|
| 62 | 62 | /* Define upload dir */ |
| 63 | 63 | $wp_upload_dir = wp_upload_dir(); |
| 64 | - DEFINE( 'WPSHOP_UPLOAD_DIR', $wp_upload_dir['basedir'] . '/' ); |
|
| 65 | - DEFINE( 'WPSHOP_UPLOAD_URL', $wp_upload_dir['baseurl'] . '/' ); |
|
| 66 | - DEFINE( 'WPSHOP_WP_UPLOAD_DIR', $wp_upload_dir['basedir'] . '/' ); |
|
| 67 | - DEFINE( 'WPSHOP_WP_UPLOAD_URL', $wp_upload_dir['baseurl'] . '/' ); |
|
| 64 | + DEFINE('WPSHOP_UPLOAD_DIR', $wp_upload_dir['basedir'] . '/'); |
|
| 65 | + DEFINE('WPSHOP_UPLOAD_URL', $wp_upload_dir['baseurl'] . '/'); |
|
| 66 | + DEFINE('WPSHOP_WP_UPLOAD_DIR', $wp_upload_dir['basedir'] . '/'); |
|
| 67 | + DEFINE('WPSHOP_WP_UPLOAD_URL', $wp_upload_dir['baseurl'] . '/'); |
|
| 68 | 68 | |
| 69 | 69 | /* |
| 70 | 70 | Define external ajax file url */ |
| 71 | 71 | // DEFINE('WPSHOP_AJAX_FILE_URL', WPSHOP_INCLUDES_URL . 'ajax.php'); |
| 72 | 72 | /* Define element for new type creation */ |
| 73 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES', 'wpshop_entities' ); |
|
| 74 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS', 'wpshop_customers' ); |
|
| 75 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT', 'wpshop_product' ); |
|
| 76 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS', 'wpshop_address' ); |
|
| 77 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION', 'wps_pdt_variations' ); |
|
| 78 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS_GROUP', 'wps_customer_group' ); |
|
| 79 | - DEFINE( 'WPSHOP_IDENTIFIER_PRODUCT', 'P' ); |
|
| 80 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_ORDER', 'wpshop_shop_order' ); |
|
| 81 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_COUPON', 'wpshop_shop_coupon' ); |
|
| 82 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE', 'wpshop_shop_message' ); |
|
| 83 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_GROUP', 'wpshop_shop_group' ); |
|
| 84 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_ADDONS', 'wpshop_shop_addons' ); |
|
| 85 | - DEFINE( 'WPSHOP_ATTRIBUTE_SET_ID_META_KEY', '_%s_attribute_set_id' ); |
|
| 86 | - DEFINE( 'WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id' ); |
|
| 87 | - DEFINE( 'WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY', '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_attribute_set_id' ); |
|
| 88 | - DEFINE( 'WPSHOP_PRODUCT_ATTRIBUTE_META_KEY', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_metadata' ); |
|
| 89 | - DEFINE( 'WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES', 'wpshop_product_category' ); |
|
| 90 | - DEFINE( 'WPSHOP_PRODUCT_RELATED_PRODUCTS', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_related_products' ); |
|
| 91 | - DEFINE( 'WPSHOP_PRODUCT_PROVIDER', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_provider' ); |
|
| 92 | - DEFINE( 'WPSHOP_PRODUCT_VIEW_NB', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_view_nb' ); |
|
| 93 | - DEFINE( 'WPSHOP_PRODUCT_FRONT_DISPLAY_CONF', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attributes_frontend_display' ); |
|
| 94 | - |
|
| 95 | - DEFINE( 'WPSHOP_DEFAULT_CUSTOM_TYPES', serialize( array( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS ) ) ); |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - DEFINE( 'WPSHOP_IDENTIFIER_CUSTOMER', 'U' ); |
|
| 99 | - $cat_options = get_option( 'wpshop_catalog_categories_option' ); |
|
| 100 | - DEFINE( 'WPSHOP_UNCATEGORIZED_PRODUCT_SLUG', ! empty( $cat_options['wpshop_catalog_no_category_slug'] ) ? $cat_options['wpshop_catalog_no_category_slug'] : 'no-category' ); |
|
| 101 | - DEFINE( 'WPSHOP_CATALOG_PRODUCT_SLUG', 'catalog' ); |
|
| 102 | - DEFINE( 'WPSHOP_CATALOG_CATEGORIES_SLUG', 'catalog' ); |
|
| 103 | - DEFINE( 'WPSHOP_CATALOG_PRODUCT_NO_CATEGORY', 'no-categories' ); |
|
| 104 | - include_once( WPSHOP_LIBRAIRIES_DIR . 'purchase/list_countries.php' ); |
|
| 105 | - DEFINE( 'WPSHOP_COUNTRY_LIST', serialize( $wpshop_tab_countries ) ); |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - DEFINE( 'WPSHOP_COMMON_ATTRIBUTES_PARENT_VARIATION_PRODUCT', serialize( array( 'tx_tva' ) ) ); |
|
| 73 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES', 'wpshop_entities'); |
|
| 74 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS', 'wpshop_customers'); |
|
| 75 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT', 'wpshop_product'); |
|
| 76 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS', 'wpshop_address'); |
|
| 77 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION', 'wps_pdt_variations'); |
|
| 78 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS_GROUP', 'wps_customer_group'); |
|
| 79 | + DEFINE('WPSHOP_IDENTIFIER_PRODUCT', 'P'); |
|
| 80 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_ORDER', 'wpshop_shop_order'); |
|
| 81 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_COUPON', 'wpshop_shop_coupon'); |
|
| 82 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE', 'wpshop_shop_message'); |
|
| 83 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_GROUP', 'wpshop_shop_group'); |
|
| 84 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_ADDONS', 'wpshop_shop_addons'); |
|
| 85 | + DEFINE('WPSHOP_ATTRIBUTE_SET_ID_META_KEY', '_%s_attribute_set_id'); |
|
| 86 | + DEFINE('WPSHOP_PRODUCT_ATTRIBUTE_SET_ID_META_KEY', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id'); |
|
| 87 | + DEFINE('WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY', '_' . WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS . '_attribute_set_id'); |
|
| 88 | + DEFINE('WPSHOP_PRODUCT_ATTRIBUTE_META_KEY', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_metadata'); |
|
| 89 | + DEFINE('WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES', 'wpshop_product_category'); |
|
| 90 | + DEFINE('WPSHOP_PRODUCT_RELATED_PRODUCTS', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_related_products'); |
|
| 91 | + DEFINE('WPSHOP_PRODUCT_PROVIDER', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_provider'); |
|
| 92 | + DEFINE('WPSHOP_PRODUCT_VIEW_NB', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_view_nb'); |
|
| 93 | + DEFINE('WPSHOP_PRODUCT_FRONT_DISPLAY_CONF', '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attributes_frontend_display'); |
|
| 94 | + |
|
| 95 | + DEFINE('WPSHOP_DEFAULT_CUSTOM_TYPES', serialize(array(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS))); |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + DEFINE('WPSHOP_IDENTIFIER_CUSTOMER', 'U'); |
|
| 99 | + $cat_options = get_option('wpshop_catalog_categories_option'); |
|
| 100 | + DEFINE('WPSHOP_UNCATEGORIZED_PRODUCT_SLUG', !empty($cat_options['wpshop_catalog_no_category_slug']) ? $cat_options['wpshop_catalog_no_category_slug'] : 'no-category'); |
|
| 101 | + DEFINE('WPSHOP_CATALOG_PRODUCT_SLUG', 'catalog'); |
|
| 102 | + DEFINE('WPSHOP_CATALOG_CATEGORIES_SLUG', 'catalog'); |
|
| 103 | + DEFINE('WPSHOP_CATALOG_PRODUCT_NO_CATEGORY', 'no-categories'); |
|
| 104 | + include_once(WPSHOP_LIBRAIRIES_DIR . 'purchase/list_countries.php'); |
|
| 105 | + DEFINE('WPSHOP_COUNTRY_LIST', serialize($wpshop_tab_countries)); |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + DEFINE('WPSHOP_COMMON_ATTRIBUTES_PARENT_VARIATION_PRODUCT', serialize(array('tx_tva'))); |
|
| 109 | 109 | /* Define database table names */ |
| 110 | - DEFINE( 'WPSHOP_DBT_ENTITIES', $wpdb->prefix . 'wpshop__entity' ); |
|
| 111 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_SET', $wpdb->prefix . 'wpshop__attribute_set' ); |
|
| 112 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_GROUP', $wpdb->prefix . 'wpshop__attribute_set_section' ); |
|
| 113 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_DETAILS', $wpdb->prefix . 'wpshop__attribute_set_section_details' ); |
|
| 114 | - |
|
| 115 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_UNIT', $wpdb->prefix . 'wpshop__attributes_unit' ); |
|
| 116 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP', $wpdb->prefix . 'wpshop__attributes_unit_groups' ); |
|
| 117 | - |
|
| 118 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE', $wpdb->prefix . 'wpshop__attribute' ); |
|
| 119 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX', $wpdb->prefix . 'wpshop__attribute_value_' ); |
|
| 120 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'varchar' ); |
|
| 121 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'datetime' ); |
|
| 122 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'decimal' ); |
|
| 123 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'integer' ); |
|
| 124 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'text' ); |
|
| 125 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . '_histo' ); |
|
| 126 | - DEFINE( 'WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'options' ); |
|
| 127 | - |
|
| 128 | - DEFINE( 'WPSHOP_DBT_HISTORIC', $wpdb->prefix . 'wpshop__historique' ); |
|
| 129 | - DEFINE( 'WPSHOP_DBT_MESSAGES', $wpdb->prefix . 'wpshop__message' ); |
|
| 110 | + DEFINE('WPSHOP_DBT_ENTITIES', $wpdb->prefix . 'wpshop__entity'); |
|
| 111 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_SET', $wpdb->prefix . 'wpshop__attribute_set'); |
|
| 112 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_GROUP', $wpdb->prefix . 'wpshop__attribute_set_section'); |
|
| 113 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_DETAILS', $wpdb->prefix . 'wpshop__attribute_set_section_details'); |
|
| 114 | + |
|
| 115 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_UNIT', $wpdb->prefix . 'wpshop__attributes_unit'); |
|
| 116 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_UNIT_GROUP', $wpdb->prefix . 'wpshop__attributes_unit_groups'); |
|
| 117 | + |
|
| 118 | + DEFINE('WPSHOP_DBT_ATTRIBUTE', $wpdb->prefix . 'wpshop__attribute'); |
|
| 119 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX', $wpdb->prefix . 'wpshop__attribute_value_'); |
|
| 120 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'varchar'); |
|
| 121 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'datetime'); |
|
| 122 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'decimal'); |
|
| 123 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'integer'); |
|
| 124 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'text'); |
|
| 125 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . '_histo'); |
|
| 126 | + DEFINE('WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS', WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . 'options'); |
|
| 127 | + |
|
| 128 | + DEFINE('WPSHOP_DBT_HISTORIC', $wpdb->prefix . 'wpshop__historique'); |
|
| 129 | + DEFINE('WPSHOP_DBT_MESSAGES', $wpdb->prefix . 'wpshop__message'); |
|
| 130 | 130 | |
| 131 | 131 | /* Delete table at database version 12 for new cart management with session and usermeta database */ |
| 132 | - DEFINE( 'WPSHOP_DBT_CART', $wpdb->prefix . 'wpshop__cart' ); |
|
| 133 | - DEFINE( 'WPSHOP_DBT_CART_CONTENTS', $wpdb->prefix . 'wpshop__cart_contents' ); |
|
| 132 | + DEFINE('WPSHOP_DBT_CART', $wpdb->prefix . 'wpshop__cart'); |
|
| 133 | + DEFINE('WPSHOP_DBT_CART_CONTENTS', $wpdb->prefix . 'wpshop__cart_contents'); |
|
| 134 | 134 | /* Define the different url for the plugin */ |
| 135 | - DEFINE( 'WPSHOP_URL_SLUG_DASHBOARD', 'wpshop_dashboard' ); |
|
| 136 | - DEFINE( 'WPSHOP_URL_SLUG_ATTRIBUTE_LISTING', 'wpshop_attribute' ); |
|
| 137 | - DEFINE( 'WPSHOP_URL_SLUG_SHORTCODES', 'wpshop_shortcodes' ); |
|
| 138 | - DEFINE( 'WPSHOP_URL_SLUG_ABOUT', 'wpshop_about' ); |
|
| 139 | - DEFINE( 'WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING', 'wpshop_attribute_group' ); |
|
| 140 | - DEFINE( 'WPSHOP_URL_SLUG_OPTION', 'wpshop_option' ); |
|
| 141 | - DEFINE( 'WPSHOP_URL_SLUG_MESSAGES', 'wpshop_messages' ); |
|
| 142 | - DEFINE( 'WPSHOP_URL_SLUG_TOOLS', 'wpshop_tools' ); |
|
| 135 | + DEFINE('WPSHOP_URL_SLUG_DASHBOARD', 'wpshop_dashboard'); |
|
| 136 | + DEFINE('WPSHOP_URL_SLUG_ATTRIBUTE_LISTING', 'wpshop_attribute'); |
|
| 137 | + DEFINE('WPSHOP_URL_SLUG_SHORTCODES', 'wpshop_shortcodes'); |
|
| 138 | + DEFINE('WPSHOP_URL_SLUG_ABOUT', 'wpshop_about'); |
|
| 139 | + DEFINE('WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING', 'wpshop_attribute_group'); |
|
| 140 | + DEFINE('WPSHOP_URL_SLUG_OPTION', 'wpshop_option'); |
|
| 141 | + DEFINE('WPSHOP_URL_SLUG_MESSAGES', 'wpshop_messages'); |
|
| 142 | + DEFINE('WPSHOP_URL_SLUG_TOOLS', 'wpshop_tools'); |
|
| 143 | 143 | /* Define the different pictures for the plugin */ |
| 144 | - DEFINE( 'WPSHOP_AUTHORIZED_PICS_EXTENSIONS', 'gif|jp(e)*g|png' ); |
|
| 145 | - DEFINE( 'WPSHOP_LOADING_ICON', admin_url( 'images/loading.gif' ) ); |
|
| 146 | - DEFINE( 'WPSHOP_ERROR_ICON', WPSHOP_MEDIAS_URL . 'icones/informations/error_s.png' ); |
|
| 147 | - DEFINE( 'WPSHOP_SUCCES_ICON', WPSHOP_MEDIAS_URL . 'icones/informations/success_s.png' ); |
|
| 148 | - DEFINE( 'WPSHOP_DEFAULT_PRODUCT_PICTURE', WPSHOP_MEDIAS_IMAGES_URL . 'no_picture.png' ); |
|
| 149 | - DEFINE( 'WPSHOP_DEFAULT_CATEGORY_PICTURE', WPSHOP_MEDIAS_IMAGES_URL . 'no_picture.png' ); |
|
| 150 | - DEFINE( 'WPSHOP_PRODUCT_NOT_EXIST', WPSHOP_MEDIAS_IMAGES_URL . 'not_exist.gif' ); |
|
| 144 | + DEFINE('WPSHOP_AUTHORIZED_PICS_EXTENSIONS', 'gif|jp(e)*g|png'); |
|
| 145 | + DEFINE('WPSHOP_LOADING_ICON', admin_url('images/loading.gif')); |
|
| 146 | + DEFINE('WPSHOP_ERROR_ICON', WPSHOP_MEDIAS_URL . 'icones/informations/error_s.png'); |
|
| 147 | + DEFINE('WPSHOP_SUCCES_ICON', WPSHOP_MEDIAS_URL . 'icones/informations/success_s.png'); |
|
| 148 | + DEFINE('WPSHOP_DEFAULT_PRODUCT_PICTURE', WPSHOP_MEDIAS_IMAGES_URL . 'no_picture.png'); |
|
| 149 | + DEFINE('WPSHOP_DEFAULT_CATEGORY_PICTURE', WPSHOP_MEDIAS_IMAGES_URL . 'no_picture.png'); |
|
| 150 | + DEFINE('WPSHOP_PRODUCT_NOT_EXIST', WPSHOP_MEDIAS_IMAGES_URL . 'not_exist.gif'); |
|
| 151 | 151 | |
| 152 | 152 | /* |
| 153 | 153 | Define various configuration vars */ |
| 154 | 154 | /* FRONTEND DISPLAY */ |
| 155 | - $wpshop_display_option = get_option( 'wpshop_display_option' ); |
|
| 156 | - DEFINE( 'WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE', (isset( $wpshop_display_option['wpshop_display_grid_element_number'] ) && ($wpshop_display_option['wpshop_display_grid_element_number'] >= 1) ? $wpshop_display_option['wpshop_display_grid_element_number'] : 1) ); |
|
| 157 | - DEFINE( 'WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MIN_RANGE', 1 ); |
|
| 158 | - DEFINE( 'WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MAX_RANGE', 6 ); |
|
| 155 | + $wpshop_display_option = get_option('wpshop_display_option'); |
|
| 156 | + DEFINE('WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE', (isset($wpshop_display_option['wpshop_display_grid_element_number']) && ($wpshop_display_option['wpshop_display_grid_element_number'] >= 1) ? $wpshop_display_option['wpshop_display_grid_element_number'] : 1)); |
|
| 157 | + DEFINE('WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MIN_RANGE', 1); |
|
| 158 | + DEFINE('WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE_MAX_RANGE', 6); |
|
| 159 | 159 | |
| 160 | - DEFINE( 'WPSHOP_ELEMENT_NB_PER_PAGE', ! empty( $wpshop_display_option['wpshop_display_element_per_page'] ) ? $wpshop_display_option['wpshop_display_element_per_page'] : 20 ); |
|
| 161 | - DEFINE( 'WPSHOP_DISPLAY_GALLERY_ELEMENT_NUMBER_PER_LINE', 3 ); |
|
| 162 | - DEFINE( 'WPSHOP_DISPLAY_LIST_TYPE', $wpshop_display_option['wpshop_display_list_type'] ); |
|
| 160 | + DEFINE('WPSHOP_ELEMENT_NB_PER_PAGE', !empty($wpshop_display_option['wpshop_display_element_per_page']) ? $wpshop_display_option['wpshop_display_element_per_page'] : 20); |
|
| 161 | + DEFINE('WPSHOP_DISPLAY_GALLERY_ELEMENT_NUMBER_PER_LINE', 3); |
|
| 162 | + DEFINE('WPSHOP_DISPLAY_LIST_TYPE', $wpshop_display_option['wpshop_display_list_type']); |
|
| 163 | 163 | |
| 164 | 164 | /* ADMIN DISPLAY */ |
| 165 | 165 | $attribute_page_layout_types = array( |
| 166 | - 'tab' => __( 'Tabs', 'wpshop' ), |
|
| 167 | - 'separated_bloc' => __( 'Separated bloc', 'wpshop' ), |
|
| 166 | + 'tab' => __('Tabs', 'wpshop'), |
|
| 167 | + 'separated_bloc' => __('Separated bloc', 'wpshop'), |
|
| 168 | 168 | ); |
| 169 | - $wpshop_admin_display_option = get_option( 'wpshop_admin_display_option', array() ); |
|
| 170 | - DEFINE( 'WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT', ( ! empty( $wpshop_admin_display_option['wpshop_admin_attr_set_layout'] )?$wpshop_admin_display_option['wpshop_admin_attr_set_layout']:'separated_bloc') ); |
|
| 171 | - DEFINE( 'WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT', ( ! empty( $wpshop_admin_display_option['wpshop_admin_attr_layout'] )?$wpshop_admin_display_option['wpshop_admin_attr_layout']:'tab') ); |
|
| 169 | + $wpshop_admin_display_option = get_option('wpshop_admin_display_option', array()); |
|
| 170 | + DEFINE('WPSHOP_ATTRIBUTE_SET_EDITION_PAGE_LAYOUT', (!empty($wpshop_admin_display_option['wpshop_admin_attr_set_layout']) ? $wpshop_admin_display_option['wpshop_admin_attr_set_layout'] : 'separated_bloc')); |
|
| 171 | + DEFINE('WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT', (!empty($wpshop_admin_display_option['wpshop_admin_attr_layout']) ? $wpshop_admin_display_option['wpshop_admin_attr_layout'] : 'tab')); |
|
| 172 | 172 | $product_page_layout_types = array( |
| 173 | - 'movable-tab' => __( 'Separated box in product page', 'wpshop' ), |
|
| 174 | - 'fixed-tab' => __( 'A tab in product data box "Product data"', 'wpshop' ), |
|
| 175 | - 'each-box' => __( 'In each attribute group section "Product data"', 'wpshop' ), |
|
| 173 | + 'movable-tab' => __('Separated box in product page', 'wpshop'), |
|
| 174 | + 'fixed-tab' => __('A tab in product data box "Product data"', 'wpshop'), |
|
| 175 | + 'each-box' => __('In each attribute group section "Product data"', 'wpshop'), |
|
| 176 | 176 | ); |
| 177 | - DEFINE( 'WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE', ( ! empty( $wpshop_admin_display_option['wpshop_admin_product_shortcode_display'] )?$wpshop_admin_display_option['wpshop_admin_product_shortcode_display']:'each-box') ); |
|
| 177 | + DEFINE('WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE', (!empty($wpshop_admin_display_option['wpshop_admin_product_shortcode_display']) ? $wpshop_admin_display_option['wpshop_admin_product_shortcode_display'] : 'each-box')); |
|
| 178 | 178 | /* Define debug vars */ |
| 179 | - $extra_options = get_option( 'wpshop_extra_options', array() ); |
|
| 180 | - DEFINE( 'WPSHOP_ADDONS_OPTION_NAME', 'wpshop_addons' ); |
|
| 181 | - $wpshop_addons_state = get_option( WPSHOP_ADDONS_OPTION_NAME, array() ); |
|
| 179 | + $extra_options = get_option('wpshop_extra_options', array()); |
|
| 180 | + DEFINE('WPSHOP_ADDONS_OPTION_NAME', 'wpshop_addons'); |
|
| 181 | + $wpshop_addons_state = get_option(WPSHOP_ADDONS_OPTION_NAME, array()); |
|
| 182 | 182 | |
| 183 | 183 | /* ALLOWED IPS */ |
| 184 | - $default_ip = array( '127.0.0.1', '0.0.0.0' ); |
|
| 185 | - DEFINE( 'WPSHOP_DEBUG_MODE_ALLOWED_IP', ( ! empty( $extra_options['WPSHOP_DEBUG_MODE_ALLOWED_IP'] )?serialize( array_merge( $default_ip, array( $extra_options['WPSHOP_DEBUG_MODE_ALLOWED_IP'] ) ) ):serialize( $default_ip )) ); |
|
| 184 | + $default_ip = array('127.0.0.1', '0.0.0.0'); |
|
| 185 | + DEFINE('WPSHOP_DEBUG_MODE_ALLOWED_IP', (!empty($extra_options['WPSHOP_DEBUG_MODE_ALLOWED_IP']) ? serialize(array_merge($default_ip, array($extra_options['WPSHOP_DEBUG_MODE_ALLOWED_IP']))) : serialize($default_ip))); |
|
| 186 | 186 | /* DEBUG MODE */ |
| 187 | 187 | $debug_mode = false; |
| 188 | - if ( ! empty( $extra_options['WPSHOP_DEBUG_MODE'] ) && ($extra_options['WPSHOP_DEBUG_MODE'] == 'true') ) { |
|
| 188 | + if (!empty($extra_options['WPSHOP_DEBUG_MODE']) && ($extra_options['WPSHOP_DEBUG_MODE'] == 'true')) { |
|
| 189 | 189 | $debug_mode = true; |
| 190 | 190 | } |
| 191 | - DEFINE( 'WPSHOP_DEBUG_MODE', $debug_mode ); |
|
| 191 | + DEFINE('WPSHOP_DEBUG_MODE', $debug_mode); |
|
| 192 | 192 | // End if(). |
| 193 | 193 | $delete_data = false; |
| 194 | - if ( ! empty( $extra_options['WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION'] ) && ($extra_options['WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION'] == 'true') ) { |
|
| 194 | + if (!empty($extra_options['WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION']) && ($extra_options['WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION'] == 'true')) { |
|
| 195 | 195 | $delete_data = true; |
| 196 | 196 | } |
| 197 | - DEFINE( 'WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION', $delete_data ); |
|
| 197 | + DEFINE('WPSHOP_DEBUG_MODE_ALLOW_DATA_DELETION', $delete_data); |
|
| 198 | 198 | |
| 199 | 199 | // End if(). |
| 200 | 200 | $tools_menu_display = false; |
| 201 | - if ( ! empty( $extra_options['WPSHOP_DISPLAY_TOOLS_MENU'] ) && ($extra_options['WPSHOP_DISPLAY_TOOLS_MENU'] == 'true') ) { |
|
| 201 | + if (!empty($extra_options['WPSHOP_DISPLAY_TOOLS_MENU']) && ($extra_options['WPSHOP_DISPLAY_TOOLS_MENU'] == 'true')) { |
|
| 202 | 202 | $tools_menu_display = true; |
| 203 | 203 | } |
| 204 | - DEFINE( 'WPSHOP_DISPLAY_TOOLS_MENU', $tools_menu_display ); |
|
| 204 | + DEFINE('WPSHOP_DISPLAY_TOOLS_MENU', $tools_menu_display); |
|
| 205 | 205 | |
| 206 | 206 | // End if(). |
| 207 | 207 | $attr_value_per_user = false; |
| 208 | - if ( ! empty( $extra_options['WPSHOP_ATTRIBUTE_VALUE_PER_USER'] ) && ($extra_options['WPSHOP_ATTRIBUTE_VALUE_PER_USER'] == 'true') ) { |
|
| 208 | + if (!empty($extra_options['WPSHOP_ATTRIBUTE_VALUE_PER_USER']) && ($extra_options['WPSHOP_ATTRIBUTE_VALUE_PER_USER'] == 'true')) { |
|
| 209 | 209 | $attr_value_per_user = true; |
| 210 | 210 | } |
| 211 | - DEFINE( 'WPSHOP_ATTRIBUTE_VALUE_PER_USER', $attr_value_per_user ); |
|
| 211 | + DEFINE('WPSHOP_ATTRIBUTE_VALUE_PER_USER', $attr_value_per_user); |
|
| 212 | 212 | |
| 213 | 213 | // End if(). |
| 214 | 214 | $display_available_keys_for_template = false; |
| 215 | - if ( ! empty( $extra_options['WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE'] ) && ($extra_options['WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE'] == 'true') ) { |
|
| 215 | + if (!empty($extra_options['WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE']) && ($extra_options['WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE'] == 'true')) { |
|
| 216 | 216 | $display_available_keys_for_template = true; |
| 217 | 217 | } |
| 218 | - DEFINE( 'WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE', $display_available_keys_for_template ); |
|
| 218 | + DEFINE('WPSHOP_DISPLAY_AVAILABLE_KEYS_FOR_TEMPLATE', $display_available_keys_for_template); |
|
| 219 | 219 | |
| 220 | 220 | // End if(). |
| 221 | 221 | $display_value_attribute_type_select = false; |
| 222 | - if ( ! empty( $extra_options['WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT'] ) && ($extra_options['WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT'] == 'true') ) { |
|
| 222 | + if (!empty($extra_options['WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT']) && ($extra_options['WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT'] == 'true')) { |
|
| 223 | 223 | $display_value_attribute_type_select = true; |
| 224 | 224 | } |
| 225 | - DEFINE( 'WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT', $display_value_attribute_type_select ); |
|
| 225 | + DEFINE('WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT', $display_value_attribute_type_select); |
|
| 226 | 226 | // End if(). |
| 227 | - DEFINE( 'WPSHOP_PRODUCT_REFERENCE_PREFIX', 'PDCT' ); |
|
| 228 | - DEFINE( 'WPSHOP_PRODUCT_REFERENCE_PREFIX_NB_FILL', 5 ); |
|
| 229 | - DEFINE( 'WPSHOP_BILLING_REFERENCE_PREFIX', 'FA' ); |
|
| 230 | - DEFINE( 'WPSHOP_CREDIT_SLIP_REFERENCE_PREFIX', 'AV' ); |
|
| 231 | - DEFINE( 'WPSHOP_ORDER_REFERENCE_PREFIX', 'OR' ); |
|
| 232 | - DEFINE( 'WPSHOP_PREORDER_REFERENCE_PREFIX', 'D' ); |
|
| 227 | + DEFINE('WPSHOP_PRODUCT_REFERENCE_PREFIX', 'PDCT'); |
|
| 228 | + DEFINE('WPSHOP_PRODUCT_REFERENCE_PREFIX_NB_FILL', 5); |
|
| 229 | + DEFINE('WPSHOP_BILLING_REFERENCE_PREFIX', 'FA'); |
|
| 230 | + DEFINE('WPSHOP_CREDIT_SLIP_REFERENCE_PREFIX', 'AV'); |
|
| 231 | + DEFINE('WPSHOP_ORDER_REFERENCE_PREFIX', 'OR'); |
|
| 232 | + DEFINE('WPSHOP_PREORDER_REFERENCE_PREFIX', 'D'); |
|
| 233 | 233 | /* Define the different pages to create for basic usage */ |
| 234 | 234 | $default_pages = array(); |
| 235 | - $product_options = get_option( 'wpshop_catalog_product_option' ); |
|
| 235 | + $product_options = get_option('wpshop_catalog_product_option'); |
|
| 236 | 236 | $default_pages['presentation'][] = array( |
| 237 | 237 | 'page_code' => 'wpshop_product_page_id', |
| 238 | - 'post_title' => __( 'Shop', 'wpshop' ), |
|
| 239 | - 'post_name' => ! empty( $product_options['wpshop_catalog_product_slug'] ) ? $product_options['wpshop_catalog_product_slug'] : 'catalog', |
|
| 238 | + 'post_title' => __('Shop', 'wpshop'), |
|
| 239 | + 'post_name' => !empty($product_options['wpshop_catalog_product_slug']) ? $product_options['wpshop_catalog_product_slug'] : 'catalog', |
|
| 240 | 240 | 'post_content' => '[wpshop_products]', |
| 241 | 241 | 'menu_order' => 569841, |
| 242 | 242 | ); |
| 243 | 243 | $default_pages['presentation'][] = array( |
| 244 | 244 | 'page_code' => 'wpshop_cart_page_id', |
| 245 | - 'post_title' => __( 'Cart', 'wpshop' ), |
|
| 245 | + 'post_title' => __('Cart', 'wpshop'), |
|
| 246 | 246 | 'post_name' => 'cart', |
| 247 | 247 | 'post_content' => '[wpshop_cart]', |
| 248 | 248 | 'menu_order' => 569842, |
| 249 | 249 | ); |
| 250 | 250 | $default_pages['presentation'][] = array( |
| 251 | 251 | 'page_code' => 'wpshop_checkout_page_id', |
| 252 | - 'post_title' => __( 'Checkout', 'wpshop' ), |
|
| 252 | + 'post_title' => __('Checkout', 'wpshop'), |
|
| 253 | 253 | 'post_name' => 'checkout', |
| 254 | 254 | 'post_content' => '[wpshop_checkout]', |
| 255 | 255 | 'menu_order' => 569843, |
| 256 | 256 | ); |
| 257 | 257 | $default_pages['presentation'][] = array( |
| 258 | 258 | 'page_code' => 'wpshop_myaccount_page_id', |
| 259 | - 'post_title' => __( 'My account', 'wpshop' ), |
|
| 259 | + 'post_title' => __('My account', 'wpshop'), |
|
| 260 | 260 | 'post_name' => 'myaccount', |
| 261 | 261 | 'post_content' => '[wpshop_myaccount]', |
| 262 | 262 | 'menu_order' => 569844, |
| 263 | 263 | ); |
| 264 | 264 | $default_pages['presentation'][] = array( |
| 265 | 265 | 'page_code' => 'wpshop_signup_page_id', |
| 266 | - 'post_title' => __( 'Signup', 'wpshop' ), |
|
| 266 | + 'post_title' => __('Signup', 'wpshop'), |
|
| 267 | 267 | 'post_name' => 'signup', |
| 268 | 268 | 'post_content' => '[wpshop_signup]', |
| 269 | 269 | 'menu_order' => 569845, |
| 270 | 270 | ); |
| 271 | 271 | $default_pages['sale'][] = array( |
| 272 | 272 | 'page_code' => 'wpshop_payment_return_page_id', |
| 273 | - 'post_title' => __( 'Payment return successfull', 'wpshop' ), |
|
| 273 | + 'post_title' => __('Payment return successfull', 'wpshop'), |
|
| 274 | 274 | 'post_name' => 'return', |
| 275 | 275 | 'post_content' => '[wpshop_payment_result]', |
| 276 | 276 | 'menu_order' => 569846, |
| 277 | 277 | ); |
| 278 | 278 | $default_pages['sale'][] = array( |
| 279 | 279 | 'page_code' => 'wpshop_payment_return_nok_page_id', |
| 280 | - 'post_title' => __( 'Payment return unsuccessfull', 'wpshop' ), |
|
| 280 | + 'post_title' => __('Payment return unsuccessfull', 'wpshop'), |
|
| 281 | 281 | 'post_name' => 'unsuccessfull_payment_return', |
| 282 | 282 | 'post_content' => '[wpshop_payment_result_unsuccessfull]', |
| 283 | 283 | 'menu_order' => 569848, |
| 284 | 284 | ); |
| 285 | 285 | $default_pages['presentation'][] = array( |
| 286 | 286 | 'page_code' => 'wpshop_terms_of_sale_page_id', |
| 287 | - 'post_title' => __( 'Terms of sale', 'wpshop' ), |
|
| 287 | + 'post_title' => __('Terms of sale', 'wpshop'), |
|
| 288 | 288 | 'post_name' => 'terms-of-sale', |
| 289 | 289 | 'post_content' => '[wpshop_terms_of_sale]', |
| 290 | 290 | 'menu_order' => 569847, |
| 291 | 291 | ); |
| 292 | 292 | |
| 293 | - DEFINE( 'WPSHOP_DEFAULT_PAGES', serialize( $default_pages ) ); |
|
| 293 | + DEFINE('WPSHOP_DEFAULT_PAGES', serialize($default_pages)); |
|
| 294 | 294 | /* Define the different vars used for price calculation */ |
| 295 | - $wpshop_shop_price_piloting = get_option( 'wpshop_shop_price_piloting' ); |
|
| 296 | - DEFINE( 'WPSHOP_PRODUCT_PRICE_PILOT', ( ! empty( $wpshop_shop_price_piloting ) ? $wpshop_shop_price_piloting : 'TTC') ); |
|
| 297 | - |
|
| 298 | - DEFINE( 'WPSHOP_COST_OF_POSTAGE', 'cost_of_postage' ); |
|
| 299 | - DEFINE( 'WPSHOP_PRODUCT_PRICE_HT', 'price_ht' ); |
|
| 300 | - DEFINE( 'WPSHOP_PRODUCT_PRICE_TAX', 'tx_tva' ); |
|
| 301 | - DEFINE( 'WPSHOP_PRODUCT_PRICE_TTC', 'product_price' ); |
|
| 302 | - DEFINE( 'WPSHOP_PRODUCT_PRICE_TAX_AMOUNT', 'tva' ); |
|
| 303 | - DEFINE( 'WPSHOP_PRODUCT_WEIGHT', 'product_weight' ); |
|
| 304 | - DEFINE( 'WPSHOP_PRODUCT_SPECIAL_PRICE', 'special_price' ); |
|
| 305 | - DEFINE( 'WPSHOP_PRODUCT_SPECIAL_PRICE_DATE_FROM', 'special_from' ); |
|
| 306 | - DEFINE( 'WPSHOP_PRODUCT_SPECIAL_PRICE_DATE_TO', 'special_to' ); |
|
| 307 | - DEFINE( 'WPSHOP_PRODUCT_DISCOUNT_AMOUNT', 'discount_amount' ); |
|
| 308 | - DEFINE( 'WPSHOP_VAT_ON_SHIPPING_COST', apply_filters( 'wps_change_shipping_vat', 20 ) ); |
|
| 309 | - |
|
| 310 | - DEFINE( 'WPSHOP_ATTRIBUTE_PRICES', serialize( array( WPSHOP_PRODUCT_PRICE_HT, WPSHOP_PRODUCT_PRICE_TAX, WPSHOP_PRODUCT_PRICE_TTC, WPSHOP_PRODUCT_PRICE_TAX_AMOUNT ) ) ); |
|
| 311 | - DEFINE( 'WPSHOP_ATTRIBUTE_WEIGHT', serialize( array( WPSHOP_PRODUCT_WEIGHT ) ) ); |
|
| 295 | + $wpshop_shop_price_piloting = get_option('wpshop_shop_price_piloting'); |
|
| 296 | + DEFINE('WPSHOP_PRODUCT_PRICE_PILOT', (!empty($wpshop_shop_price_piloting) ? $wpshop_shop_price_piloting : 'TTC')); |
|
| 297 | + |
|
| 298 | + DEFINE('WPSHOP_COST_OF_POSTAGE', 'cost_of_postage'); |
|
| 299 | + DEFINE('WPSHOP_PRODUCT_PRICE_HT', 'price_ht'); |
|
| 300 | + DEFINE('WPSHOP_PRODUCT_PRICE_TAX', 'tx_tva'); |
|
| 301 | + DEFINE('WPSHOP_PRODUCT_PRICE_TTC', 'product_price'); |
|
| 302 | + DEFINE('WPSHOP_PRODUCT_PRICE_TAX_AMOUNT', 'tva'); |
|
| 303 | + DEFINE('WPSHOP_PRODUCT_WEIGHT', 'product_weight'); |
|
| 304 | + DEFINE('WPSHOP_PRODUCT_SPECIAL_PRICE', 'special_price'); |
|
| 305 | + DEFINE('WPSHOP_PRODUCT_SPECIAL_PRICE_DATE_FROM', 'special_from'); |
|
| 306 | + DEFINE('WPSHOP_PRODUCT_SPECIAL_PRICE_DATE_TO', 'special_to'); |
|
| 307 | + DEFINE('WPSHOP_PRODUCT_DISCOUNT_AMOUNT', 'discount_amount'); |
|
| 308 | + DEFINE('WPSHOP_VAT_ON_SHIPPING_COST', apply_filters('wps_change_shipping_vat', 20)); |
|
| 309 | + |
|
| 310 | + DEFINE('WPSHOP_ATTRIBUTE_PRICES', serialize(array(WPSHOP_PRODUCT_PRICE_HT, WPSHOP_PRODUCT_PRICE_TAX, WPSHOP_PRODUCT_PRICE_TTC, WPSHOP_PRODUCT_PRICE_TAX_AMOUNT))); |
|
| 311 | + DEFINE('WPSHOP_ATTRIBUTE_WEIGHT', serialize(array(WPSHOP_PRODUCT_WEIGHT))); |
|
| 312 | 312 | /* Define the different attribute that user won't be able to delete from interface */ |
| 313 | - DEFINE( 'WPSHOP_ATTRIBUTE_UNDELETABLE', serialize( array_merge( array(), unserialize( WPSHOP_ATTRIBUTE_PRICES ) ) ) ); |
|
| 313 | + DEFINE('WPSHOP_ATTRIBUTE_UNDELETABLE', serialize(array_merge(array(), unserialize(WPSHOP_ATTRIBUTE_PRICES)))); |
|
| 314 | 314 | /* Define the attribute list to hide or variation creation */ |
| 315 | - DEFINE( 'WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE', serialize( array_merge( unserialize( WPSHOP_ATTRIBUTE_PRICES ), array( 'product_attribute_set_id', 'product_reference' ) ) ) ); |
|
| 315 | + DEFINE('WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE', serialize(array_merge(unserialize(WPSHOP_ATTRIBUTE_PRICES), array('product_attribute_set_id', 'product_reference')))); |
|
| 316 | 316 | /* Define the default currency */ |
| 317 | - DEFINE( 'WPSHOP_SHOP_DEFAULT_CURRENCY', 'EUR' ); |
|
| 318 | - DEFINE( 'WPSHOP_SHOP_CURRENCIES', serialize( array( |
|
| 317 | + DEFINE('WPSHOP_SHOP_DEFAULT_CURRENCY', 'EUR'); |
|
| 318 | + DEFINE('WPSHOP_SHOP_CURRENCIES', serialize(array( |
|
| 319 | 319 | 'EUR' => 'euro', |
| 320 | 320 | 'USD' => 'dollar', |
| 321 | - ) ) ); |
|
| 321 | + ))); |
|
| 322 | 322 | |
| 323 | 323 | /* Define the shipping default rules */ |
| 324 | - DEFINE( 'WPSHOP_SHOP_SHIPPING_RULES', serialize( array( |
|
| 324 | + DEFINE('WPSHOP_SHOP_SHIPPING_RULES', serialize(array( |
|
| 325 | 325 | 'min_max' => array( |
| 326 | 326 | 'min' => 0, |
| 327 | 327 | 'max' => 30, |
| 328 | 328 | ), |
| 329 | 329 | 'free_from' => 4500, |
| 330 | - ) ) ); |
|
| 330 | + ))); |
|
| 331 | 331 | $shipping_fees_array = array( |
| 332 | 332 | 'active' => false, |
| 333 | 333 | 'fees' => array( |
@@ -351,66 +351,66 @@ discard block |
||
| 351 | 351 | ), |
| 352 | 352 | ), |
| 353 | 353 | ); |
| 354 | - DEFINE( 'WPSHOP_SHOP_CUSTOM_SHIPPING', serialize( $shipping_fees_array ) ); |
|
| 354 | + DEFINE('WPSHOP_SHOP_CUSTOM_SHIPPING', serialize($shipping_fees_array)); |
|
| 355 | 355 | |
| 356 | 356 | /* Define addons modules */ |
| 357 | - DEFINE( 'WPSHOP_ADDONS_KEY_IS', '48' ); |
|
| 358 | - DEFINE( 'WPSHOP_ADDONS_STATES_CLASS', serialize( array( |
|
| 357 | + DEFINE('WPSHOP_ADDONS_KEY_IS', '48'); |
|
| 358 | + DEFINE('WPSHOP_ADDONS_STATES_CLASS', serialize(array( |
|
| 359 | 359 | true => 'wpshop_addons_state wpshop_addons_state_activated', |
| 360 | 360 | false => 'wpshop_addons_state wpshop_addons_state_deactivated', |
| 361 | - ) ) ); |
|
| 362 | - DEFINE( 'WPSHOP_ADDONS_LIST', serialize( array( |
|
| 363 | - 'WPSHOP_ADDONS_QUOTATION' => array( __( 'Quotation','wpshop' ), '48', 'per_site', 'quotation_allowed', 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE' ), |
|
| 364 | - 'WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC' => array( __( 'Payment gateway CIC','wpshop' ), '32', 'per_site', '' ),/* , 'WPSHOP_ADDONS_PRICE_PER_GROUP' => array(__('Price per user group','wpshop'), '13', 'free') */ |
|
| 365 | - ) ) ); |
|
| 366 | - DEFINE( 'WPSHOP_ADDONS_QUOTATION', ( ! empty( $wpshop_addons_state['WPSHOP_ADDONS_QUOTATION']['activate'] )?$wpshop_addons_state['WPSHOP_ADDONS_QUOTATION']['activate']:false) ); |
|
| 367 | - DEFINE( 'WPSHOP_ADDONS_PRICE_PER_GROUP', ( ! empty( $wpshop_addons_state['WPSHOP_ADDONS_PRICE_PER_GROUP']['activate'] )?$wpshop_addons_state['WPSHOP_ADDONS_PRICE_PER_GROUP']['activate']:false) ); |
|
| 368 | - DEFINE( 'WPSHOP_PAYMENT_METHOD_CIC', ( ! empty( $wpshop_addons_state['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC']['activate'] )?$wpshop_addons_state['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC']['activate']:false) ); |
|
| 369 | - DEFINE( 'WPSHOP_ADDONS_QUOTATION_CODE', 'nfdJK-AsBCO-%AZDZA' ); |
|
| 370 | - DEFINE( 'WPSHOP_ADDONS_PRICE_PER_GROUP_CODE', '7GnnQ-5FeqZ-BiKz3' ); |
|
| 371 | - DEFINE( 'WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC', 'nZYsM-vQ8qC-VfVfA' ); |
|
| 361 | + ))); |
|
| 362 | + DEFINE('WPSHOP_ADDONS_LIST', serialize(array( |
|
| 363 | + 'WPSHOP_ADDONS_QUOTATION' => array(__('Quotation', 'wpshop'), '48', 'per_site', 'quotation_allowed', 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE'), |
|
| 364 | + 'WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC' => array(__('Payment gateway CIC', 'wpshop'), '32', 'per_site', ''), /* , 'WPSHOP_ADDONS_PRICE_PER_GROUP' => array(__('Price per user group','wpshop'), '13', 'free') */ |
|
| 365 | + ))); |
|
| 366 | + DEFINE('WPSHOP_ADDONS_QUOTATION', (!empty($wpshop_addons_state['WPSHOP_ADDONS_QUOTATION']['activate']) ? $wpshop_addons_state['WPSHOP_ADDONS_QUOTATION']['activate'] : false)); |
|
| 367 | + DEFINE('WPSHOP_ADDONS_PRICE_PER_GROUP', (!empty($wpshop_addons_state['WPSHOP_ADDONS_PRICE_PER_GROUP']['activate']) ? $wpshop_addons_state['WPSHOP_ADDONS_PRICE_PER_GROUP']['activate'] : false)); |
|
| 368 | + DEFINE('WPSHOP_PAYMENT_METHOD_CIC', (!empty($wpshop_addons_state['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC']['activate']) ? $wpshop_addons_state['WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC']['activate'] : false)); |
|
| 369 | + DEFINE('WPSHOP_ADDONS_QUOTATION_CODE', 'nfdJK-AsBCO-%AZDZA'); |
|
| 370 | + DEFINE('WPSHOP_ADDONS_PRICE_PER_GROUP_CODE', '7GnnQ-5FeqZ-BiKz3'); |
|
| 371 | + DEFINE('WPSHOP_ADDONS_PAYMENT_GATEWAY_CB_CIC', 'nZYsM-vQ8qC-VfVfA'); |
|
| 372 | 372 | |
| 373 | 373 | /* Define payment method params */ |
| 374 | - $wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 375 | - if ( WPSHOP_PAYMENT_METHOD_CIC || ! empty( $wpshop_paymentMethod['mode'] ) && ! empty( $wpshop_paymentMethod['mode']['cic'] ) ) { |
|
| 376 | - $cmcic_params = get_option( 'wpshop_cmcic_params', array() ); |
|
| 377 | - if ( ! empty( $cmcic_params ) ) { |
|
| 378 | - DEFINE( 'CMCIC_CLE', $cmcic_params['cle'] ); |
|
| 379 | - DEFINE( 'CMCIC_TPE', $cmcic_params['tpe'] ); |
|
| 380 | - DEFINE( 'CMCIC_VERSION', $cmcic_params['version'] ); |
|
| 381 | - DEFINE( 'CMCIC_SERVEUR', $cmcic_params['serveur'] ); |
|
| 382 | - DEFINE( 'CMCIC_CODESOCIETE', $cmcic_params['codesociete'] ); |
|
| 383 | - DEFINE( 'CMCIC_URLOK', '' ); |
|
| 384 | - DEFINE( 'CMCIC_URLKO', '' ); |
|
| 374 | + $wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 375 | + if (WPSHOP_PAYMENT_METHOD_CIC || !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) { |
|
| 376 | + $cmcic_params = get_option('wpshop_cmcic_params', array()); |
|
| 377 | + if (!empty($cmcic_params)) { |
|
| 378 | + DEFINE('CMCIC_CLE', $cmcic_params['cle']); |
|
| 379 | + DEFINE('CMCIC_TPE', $cmcic_params['tpe']); |
|
| 380 | + DEFINE('CMCIC_VERSION', $cmcic_params['version']); |
|
| 381 | + DEFINE('CMCIC_SERVEUR', $cmcic_params['serveur']); |
|
| 382 | + DEFINE('CMCIC_CODESOCIETE', $cmcic_params['codesociete']); |
|
| 383 | + DEFINE('CMCIC_URLOK', ''); |
|
| 384 | + DEFINE('CMCIC_URLKO', ''); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** Civility */ |
| 389 | 389 | $civility = array( |
| 390 | - 1 => __( 'Mr.','wpshop' ), |
|
| 391 | - __( 'Mrs.','wpshop' ), |
|
| 392 | - __( 'Miss','wpshop' ), |
|
| 390 | + 1 => __('Mr.', 'wpshop'), |
|
| 391 | + __('Mrs.', 'wpshop'), |
|
| 392 | + __('Miss', 'wpshop'), |
|
| 393 | 393 | ); |
| 394 | 394 | /** Status */ |
| 395 | 395 | $order_status = array( |
| 396 | - '' => __( 'Awaiting treatment', 'wpshop' ), |
|
| 397 | - 'awaiting_payment' => __( 'Awaiting payment', 'wpshop' ), |
|
| 398 | - 'partially_paid' => __( 'Partially paid', 'wpshop' ), |
|
| 399 | - 'completed' => __( 'Paid', 'wpshop' ), |
|
| 400 | - 'shipped' => __( 'Shipped', 'wpshop' ), |
|
| 401 | - 'denied' => __( 'Denied', 'wpshop' ), |
|
| 402 | - 'incorrect_amount' => __( 'Incorrect amount', 'wpshop' ), |
|
| 403 | - 'canceled' => __( 'Canceled', 'wpshop' ), |
|
| 404 | - 'payment_refused' => __( 'Refused payment', 'wpshop' ), |
|
| 405 | - 'refunded' => __( 'Refunded', 'wpshop' ), |
|
| 406 | - 'pos' => __( 'Taken in store', 'wpshop' ), |
|
| 396 | + '' => __('Awaiting treatment', 'wpshop'), |
|
| 397 | + 'awaiting_payment' => __('Awaiting payment', 'wpshop'), |
|
| 398 | + 'partially_paid' => __('Partially paid', 'wpshop'), |
|
| 399 | + 'completed' => __('Paid', 'wpshop'), |
|
| 400 | + 'shipped' => __('Shipped', 'wpshop'), |
|
| 401 | + 'denied' => __('Denied', 'wpshop'), |
|
| 402 | + 'incorrect_amount' => __('Incorrect amount', 'wpshop'), |
|
| 403 | + 'canceled' => __('Canceled', 'wpshop'), |
|
| 404 | + 'payment_refused' => __('Refused payment', 'wpshop'), |
|
| 405 | + 'refunded' => __('Refunded', 'wpshop'), |
|
| 406 | + 'pos' => __('Taken in store', 'wpshop'), |
|
| 407 | 407 | ); |
| 408 | - DEFINE( 'WPSHOP_ORDER_STATUS', serialize( $order_status ) ); |
|
| 408 | + DEFINE('WPSHOP_ORDER_STATUS', serialize($order_status)); |
|
| 409 | 409 | |
| 410 | 410 | // End if(). |
| 411 | - DEFINE( 'WPSHOP_REGISTER_POST_TYPE_SUPPORT', serialize( array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions' ) ) ); |
|
| 411 | + DEFINE('WPSHOP_REGISTER_POST_TYPE_SUPPORT', serialize(array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions'))); |
|
| 412 | 412 | $register_post_type_args = array( |
| 413 | - 'labels' => array( 'name', 'singular_name', 'add_new', 'add_new_item', 'edit', 'edit_item', 'new_item', 'view', 'view_item', 'search_items', 'not_found', 'not_found_in_trash' ), |
|
| 413 | + 'labels' => array('name', 'singular_name', 'add_new', 'add_new_item', 'edit', 'edit_item', 'new_item', 'view', 'view_item', 'search_items', 'not_found', 'not_found_in_trash'), |
|
| 414 | 414 | 'description' => 'text', |
| 415 | 415 | 'public' => 'boolean', |
| 416 | 416 | 'exclude_from_search' => 'boolean', |
@@ -418,64 +418,64 @@ discard block |
||
| 418 | 418 | 'show_ui' => 'boolean', |
| 419 | 419 | 'show_in_nav_menus' => 'boolean', |
| 420 | 420 | 'show_in_menu' => 'boolean|text', |
| 421 | - 'capabilities' => array( 'publish_posts', 'edit_posts', 'edit_others_posts', 'delete_posts', 'delete_others_posts', 'read_private_posts', 'edit_post', 'delete_post', 'read_post' ), |
|
| 421 | + 'capabilities' => array('publish_posts', 'edit_posts', 'edit_others_posts', 'delete_posts', 'delete_others_posts', 'read_private_posts', 'edit_post', 'delete_post', 'read_post'), |
|
| 422 | 422 | 'hierarchical' => false, |
| 423 | 423 | 'rewrite' => false, |
| 424 | 424 | 'query_var' => true, |
| 425 | - 'supports' => unserialize( WPSHOP_REGISTER_POST_TYPE_SUPPORT ), |
|
| 425 | + 'supports' => unserialize(WPSHOP_REGISTER_POST_TYPE_SUPPORT), |
|
| 426 | 426 | ); |
| 427 | - DEFINE( 'WPSHOP_REGISTER_POST_TYPE_ARGS', serialize( $register_post_type_args ) ); |
|
| 428 | - DEFINE( 'WPSHOP_REGISTER_POST_TYPE_MANDATORY_SUPPORTS', serialize( array( 'title', 'editor', 'thumbnail', 'excerpt' ) ) ); |
|
| 429 | - DEFINE( 'WPSHOP_PRODUCT_HIDDEN_METABOX', serialize( array( 'formatdiv', 'pageparentdiv', 'postexcerpt', 'trackbacksdiv', 'postcustom', 'commentstatusdiv', 'commentsdiv', 'slugdiv', 'authordiv', 'revisionsdiv' ) ) ); |
|
| 427 | + DEFINE('WPSHOP_REGISTER_POST_TYPE_ARGS', serialize($register_post_type_args)); |
|
| 428 | + DEFINE('WPSHOP_REGISTER_POST_TYPE_MANDATORY_SUPPORTS', serialize(array('title', 'editor', 'thumbnail', 'excerpt'))); |
|
| 429 | + DEFINE('WPSHOP_PRODUCT_HIDDEN_METABOX', serialize(array('formatdiv', 'pageparentdiv', 'postexcerpt', 'trackbacksdiv', 'postcustom', 'commentstatusdiv', 'commentsdiv', 'slugdiv', 'authordiv', 'revisionsdiv'))); |
|
| 430 | 430 | |
| 431 | 431 | /* Shop type */ |
| 432 | - DEFINE( 'WPSHOP_SHOP_TYPES', serialize( array( 'presentation', 'sale' ) ) ); |
|
| 432 | + DEFINE('WPSHOP_SHOP_TYPES', serialize(array('presentation', 'sale'))); |
|
| 433 | 433 | |
| 434 | 434 | /* Attribute select_data_type */ |
| 435 | - DEFINE( 'WPSHOP_ATTR_SELECT_TYPE', serialize( array( |
|
| 435 | + DEFINE('WPSHOP_ATTR_SELECT_TYPE', serialize(array( |
|
| 436 | 436 | 'custom' => 'custom_data', |
| 437 | 437 | 'internal' => 'internal_data', |
| 438 | - ) ) ); |
|
| 439 | - DEFINE( 'WPSHOP_ATTR_SELECT_TYPE_TOGGLED', serialize( array( |
|
| 438 | + ))); |
|
| 439 | + DEFINE('WPSHOP_ATTR_SELECT_TYPE_TOGGLED', serialize(array( |
|
| 440 | 440 | 'custom' => 'internal_data', |
| 441 | 441 | 'internal' => 'custom_data', |
| 442 | - ) ) ); |
|
| 442 | + ))); |
|
| 443 | 443 | |
| 444 | 444 | /* Define the types existing into the current WordPress installation */ |
| 445 | - $default_to_exclude = array( 'attachment', 'revision', 'nav_menu_item', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE ); |
|
| 446 | - DEFINE( 'WPSHOP_INTERNAL_TYPES_TO_EXCLUDE', ( ! empty( $extra_options['WPSHOP_INTERNAL_TYPES_TO_EXCLUDE'] )?serialize( array_merge( array( $extra_options['WPSHOP_INTERNAL_TYPES_TO_EXCLUDE'] ),$default_to_exclude ) ):serialize( $default_to_exclude )) ); |
|
| 445 | + $default_to_exclude = array('attachment', 'revision', 'nav_menu_item', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE); |
|
| 446 | + DEFINE('WPSHOP_INTERNAL_TYPES_TO_EXCLUDE', (!empty($extra_options['WPSHOP_INTERNAL_TYPES_TO_EXCLUDE']) ? serialize(array_merge(array($extra_options['WPSHOP_INTERNAL_TYPES_TO_EXCLUDE']), $default_to_exclude)) : serialize($default_to_exclude))); |
|
| 447 | 447 | |
| 448 | 448 | /* |
| 449 | 449 | Start form field display config */ |
| 450 | 450 | /* Get the list of possible posts status */ |
| 451 | - $posts_status = array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ); |
|
| 451 | + $posts_status = array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'); |
|
| 452 | 452 | |
| 453 | 453 | /* General configuration */ |
| 454 | - $comboxOptionToHide = array( 'deleted' ); |
|
| 454 | + $comboxOptionToHide = array('deleted'); |
|
| 455 | 455 | |
| 456 | 456 | /* Attributes form */ |
| 457 | - $attribute_displayed_field = array( 'id', 'status', 'entity_id', 'is_required', 'is_unique', 'is_visible_in_front', 'is_visible_in_front_listing', 'frontend_input', 'backend_input', 'frontend_label', 'default_value', 'is_requiring_unit', '_unit_group_id', '_default_unit', 'is_historisable', 'is_intrinsic', 'is_filterable', 'code', 'is_used_for_sort_by', 'is_visible_in_advanced_search', 'is_used_in_admin_listing_column', 'is_used_in_quick_add_form', 'frontend_verification', 'is_user_defined', 'is_used_in_variation', 'is_used_for_variation', '_need_verification', '_display_informations_about_value', 'frontend_css_class', 'backend_css_class', 'frontend_help_message', 'is_searchable' ); |
|
| 457 | + $attribute_displayed_field = array('id', 'status', 'entity_id', 'is_required', 'is_unique', 'is_visible_in_front', 'is_visible_in_front_listing', 'frontend_input', 'backend_input', 'frontend_label', 'default_value', 'is_requiring_unit', '_unit_group_id', '_default_unit', 'is_historisable', 'is_intrinsic', 'is_filterable', 'code', 'is_used_for_sort_by', 'is_visible_in_advanced_search', 'is_used_in_admin_listing_column', 'is_used_in_quick_add_form', 'frontend_verification', 'is_user_defined', 'is_used_in_variation', 'is_used_for_variation', '_need_verification', '_display_informations_about_value', 'frontend_css_class', 'backend_css_class', 'frontend_help_message', 'is_searchable'); |
|
| 458 | 458 | $attribute_options_group = array( |
| 459 | - __( 'Attribute unit', 'wpshop' ) => array( 'is_requiring_unit', '_unit_group_id', '_default_unit' ), |
|
| 460 | - __( 'Frontend option', 'wpshop' ) => array( 'is_visible_in_front', 'is_visible_in_front_listing', 'is_used_for_sort_by', 'is_visible_in_advanced_search', 'is_searchable', '_display_informations_about_value' ), |
|
| 461 | - __( 'Variations', 'wpshop' ) => array( 'is_user_defined', 'is_used_in_variation', 'is_used_for_variation', 'frontend_input' ), |
|
| 459 | + __('Attribute unit', 'wpshop') => array('is_requiring_unit', '_unit_group_id', '_default_unit'), |
|
| 460 | + __('Frontend option', 'wpshop') => array('is_visible_in_front', 'is_visible_in_front_listing', 'is_used_for_sort_by', 'is_visible_in_advanced_search', 'is_searchable', '_display_informations_about_value'), |
|
| 461 | + __('Variations', 'wpshop') => array('is_user_defined', 'is_used_in_variation', 'is_used_for_variation', 'frontend_input'), |
|
| 462 | 462 | ); |
| 463 | - DEFINE( 'WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS', serialize( array( '_need_verification', 'frontend_verification', 'frontend_css_class', 'backend_css_class', 'frontend_help_message', 'frontend_help_message' ) ) ); |
|
| 463 | + DEFINE('WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS', serialize(array('_need_verification', 'frontend_verification', 'frontend_css_class', 'backend_css_class', 'frontend_help_message', 'frontend_help_message'))); |
|
| 464 | 464 | |
| 465 | 465 | /* General form */ |
| 466 | - $attribute_hidden_field = array( 'position' ); |
|
| 466 | + $attribute_hidden_field = array('position'); |
|
| 467 | 467 | |
| 468 | 468 | /* Definition des differents champs pour les formulaires */ |
| 469 | 469 | $customer_adress_information_field = array( |
| 470 | - 'civility' => __( 'Civility', 'wpshop' ), |
|
| 471 | - 'first_name' => __( 'First name', 'wpshop' ), |
|
| 472 | - 'last_name' => __( 'Last name', 'wpshop' ), |
|
| 473 | - 'email' => __( 'Email adress', 'wpshop' ), |
|
| 474 | - 'phone' => __( 'Phone number', 'wpshop' ), |
|
| 475 | - 'company' => __( 'Company', 'wpshop' ), |
|
| 476 | - 'address' => __( 'Adresse', 'wpshop' ), |
|
| 477 | - 'postcode' => __( 'Postcode', 'wpshop' ), |
|
| 478 | - 'city' => __( 'City', 'wpshop' ), |
|
| 479 | - 'country' => __( 'Country', 'wpshop' ), |
|
| 470 | + 'civility' => __('Civility', 'wpshop'), |
|
| 471 | + 'first_name' => __('First name', 'wpshop'), |
|
| 472 | + 'last_name' => __('Last name', 'wpshop'), |
|
| 473 | + 'email' => __('Email adress', 'wpshop'), |
|
| 474 | + 'phone' => __('Phone number', 'wpshop'), |
|
| 475 | + 'company' => __('Company', 'wpshop'), |
|
| 476 | + 'address' => __('Adresse', 'wpshop'), |
|
| 477 | + 'postcode' => __('Postcode', 'wpshop'), |
|
| 478 | + 'city' => __('City', 'wpshop'), |
|
| 479 | + 'country' => __('Country', 'wpshop'), |
|
| 480 | 480 | ); |
| 481 | 481 | /* End form field display config */ |
@@ -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 */ |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string The table of the class |
| 52 | 52 | */ |
| 53 | - function setMessage($message){ |
|
| 53 | + function setMessage($message) { |
|
| 54 | 54 | $this->pageMessage = $message; |
| 55 | 55 | } |
| 56 | 56 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * |
| 59 | 59 | * @return string The table of the class |
| 60 | 60 | */ |
| 61 | - function getListingSlug(){ |
|
| 61 | + function getListingSlug() { |
|
| 62 | 62 | return self::urlSlugListing; |
| 63 | 63 | } |
| 64 | 64 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return string The table of the class |
| 68 | 68 | */ |
| 69 | - function getEditionSlug(){ |
|
| 69 | + function getEditionSlug() { |
|
| 70 | 70 | return self::urlSlugEdition; |
| 71 | 71 | } |
| 72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return string The table of the class |
| 76 | 76 | */ |
| 77 | - public static function getDbTable(){ |
|
| 77 | + public static function getDbTable() { |
|
| 78 | 78 | return self::dbTable; |
| 79 | 79 | } |
| 80 | 80 | /** |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return string $title The title of the page looking at the environnement |
| 84 | 84 | */ |
| 85 | - function pageTitle(){ |
|
| 85 | + function pageTitle() { |
|
| 86 | 86 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 87 | 87 | $objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : ''; |
| 88 | - $page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
| 88 | + $page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
| 89 | 89 | |
| 90 | - $title = __(self::pageTitle, 'wpshop' ); |
|
| 91 | - if($action != ''){ |
|
| 92 | - if(($action == 'edit') || ($action == 'delete')){ |
|
| 90 | + $title = __(self::pageTitle, 'wpshop'); |
|
| 91 | + if ($action != '') { |
|
| 92 | + if (($action == 'edit') || ($action == 'delete')) { |
|
| 93 | 93 | $editedItem = self::getElement($objectInEdition); |
| 94 | 94 | $title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label)); |
| 95 | 95 | } |
| 96 | - elseif($action == 'add') |
|
| 96 | + elseif ($action == 'add') |
|
| 97 | 97 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 98 | 98 | } |
| 99 | - elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) |
|
| 99 | + elseif ((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) |
|
| 100 | 100 | $title = __(self::pageAddingTitle, 'wpshop'); |
| 101 | 101 | |
| 102 | 102 | return $title; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * Define the different message and action after an action is send through the element interface |
| 107 | 107 | */ |
| 108 | - function elementAction(){ |
|
| 108 | + function elementAction() { |
|
| 109 | 109 | global $wpdb, $initialEavData; |
| 110 | 110 | |
| 111 | 111 | $pageMessage = $actionResult = ''; |
@@ -118,75 +118,75 @@ discard block |
||
| 118 | 118 | $saveditem = isset($_REQUEST['saveditem']) ? sanitize_text_field($_REQUEST['saveditem']) : ''; |
| 119 | 119 | $set_section = !empty($_REQUEST[self::getDbTable()]['set_section']) ? sanitize_text_field($_REQUEST[self::getDbTable()]['set_section']) : ''; |
| 120 | 120 | //@TODO $_REQUEST |
| 121 | - $id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : null; |
|
| 122 | - if(!empty($action) && ($action=='activate') ){ |
|
| 123 | - if( isset($id) ) { |
|
| 121 | + $id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : null; |
|
| 122 | + if (!empty($action) && ($action == 'activate')) { |
|
| 123 | + if (isset($id)) { |
|
| 124 | 124 | $query = $wpdb->update(self::getDbTable(), array('status'=>'moderated'), array('id'=>$id)); |
| 125 | 125 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | - if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){ |
|
| 128 | + if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) { |
|
| 129 | 129 | $editedElement = self::getElement($saveditem); |
| 130 | 130 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 131 | 131 | } |
| 132 | - elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){ |
|
| 132 | + elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) { |
|
| 133 | 133 | $editedElement = self::getElement($saveditem, "'deleted'"); |
| 134 | 134 | $pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>'); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $attribute_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 138 | - if ( !empty($set_section) ) unset($attribute_parameter['set_section']); |
|
| 137 | + $attribute_parameter = !empty($_REQUEST[self::getDbTable()]) ? (array)$_REQUEST[self::getDbTable()] : array(); |
|
| 138 | + if (!empty($set_section)) unset($attribute_parameter['set_section']); |
|
| 139 | 139 | |
| 140 | 140 | $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(); |
| 141 | 141 | // @TODO $_REQUEST |
| 142 | 142 | // unset($_REQUEST[self::getDbTable()]['wpshop_attribute_combo_values_list_order_def']); |
| 143 | 143 | |
| 144 | - if(!isset($attribute_parameter['status'])){ |
|
| 144 | + if (!isset($attribute_parameter['status'])) { |
|
| 145 | 145 | $attribute_parameter['status'] = 'moderated'; |
| 146 | 146 | } |
| 147 | - if(!isset($attribute_parameter['is_historisable'])){ |
|
| 147 | + if (!isset($attribute_parameter['is_historisable'])) { |
|
| 148 | 148 | $attribute_parameter['is_historisable'] = 'no'; |
| 149 | 149 | } |
| 150 | - if(!isset($attribute_parameter['is_required'])){ |
|
| 150 | + if (!isset($attribute_parameter['is_required'])) { |
|
| 151 | 151 | $attribute_parameter['is_required'] = 'no'; |
| 152 | 152 | } |
| 153 | - if(!isset($attribute_parameter['is_used_in_admin_listing_column'])){ |
|
| 153 | + if (!isset($attribute_parameter['is_used_in_admin_listing_column'])) { |
|
| 154 | 154 | $attribute_parameter['is_used_in_admin_listing_column'] = 'no'; |
| 155 | 155 | } |
| 156 | - if(!isset($attribute_parameter['is_used_in_quick_add_form'])){ |
|
| 156 | + if (!isset($attribute_parameter['is_used_in_quick_add_form'])) { |
|
| 157 | 157 | $attribute_parameter['is_used_in_quick_add_form'] = 'no'; |
| 158 | 158 | } |
| 159 | - if(!isset($attribute_parameter['is_intrinsic'])){ |
|
| 159 | + if (!isset($attribute_parameter['is_intrinsic'])) { |
|
| 160 | 160 | $attribute_parameter['is_intrinsic'] = 'no'; |
| 161 | 161 | } |
| 162 | - if(!isset($attribute_parameter['is_requiring_unit'])){ |
|
| 162 | + if (!isset($attribute_parameter['is_requiring_unit'])) { |
|
| 163 | 163 | $attribute_parameter['is_requiring_unit'] = 'no'; |
| 164 | 164 | } |
| 165 | - if(!isset($attribute_parameter['is_visible_in_front'])){ |
|
| 165 | + if (!isset($attribute_parameter['is_visible_in_front'])) { |
|
| 166 | 166 | $attribute_parameter['is_visible_in_front'] = 'no'; |
| 167 | 167 | } |
| 168 | - if(!isset($attribute_parameter['is_visible_in_front_listing'])){ |
|
| 168 | + if (!isset($attribute_parameter['is_visible_in_front_listing'])) { |
|
| 169 | 169 | $attribute_parameter['is_visible_in_front_listing'] = 'no'; |
| 170 | 170 | } |
| 171 | - if(!isset($attribute_parameter['is_used_for_sort_by'])){ |
|
| 171 | + if (!isset($attribute_parameter['is_used_for_sort_by'])) { |
|
| 172 | 172 | $attribute_parameter['is_used_for_sort_by'] = 'no'; |
| 173 | 173 | } |
| 174 | - if(!isset($attribute_parameter['is_visible_in_advanced_search'])){ |
|
| 174 | + if (!isset($attribute_parameter['is_visible_in_advanced_search'])) { |
|
| 175 | 175 | $attribute_parameter['is_visible_in_advanced_search'] = 'no'; |
| 176 | 176 | } |
| 177 | - if(!isset($attribute_parameter['is_searchable'])){ |
|
| 177 | + if (!isset($attribute_parameter['is_searchable'])) { |
|
| 178 | 178 | $attribute_parameter['is_searchable'] = 'no'; |
| 179 | 179 | } |
| 180 | - if(!isset($attribute_parameter['is_used_for_variation'])){ |
|
| 180 | + if (!isset($attribute_parameter['is_used_for_variation'])) { |
|
| 181 | 181 | $attribute_parameter['is_used_for_variation'] = 'no'; |
| 182 | 182 | } |
| 183 | - if(!isset($attribute_parameter['is_used_in_variation'])){ |
|
| 183 | + if (!isset($attribute_parameter['is_used_in_variation'])) { |
|
| 184 | 184 | $attribute_parameter['is_used_in_variation'] = 'no'; |
| 185 | 185 | } |
| 186 | - if(!isset($attribute_parameter['is_user_defined'])){ |
|
| 186 | + if (!isset($attribute_parameter['is_user_defined'])) { |
|
| 187 | 187 | $attribute_parameter['is_user_defined'] = 'no'; |
| 188 | 188 | } |
| 189 | - if(!isset($attribute_parameter['_display_informations_about_value'])){ |
|
| 189 | + if (!isset($attribute_parameter['_display_informations_about_value'])) { |
|
| 190 | 190 | $attribute_parameter['_display_informations_about_value'] = 'no'; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -195,58 +195,58 @@ discard block |
||
| 195 | 195 | switch ($attribute_parameter['frontend_input']) { |
| 196 | 196 | case 'short_text': |
| 197 | 197 | $attribute_parameter['frontend_input'] = 'text'; |
| 198 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 198 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 199 | 199 | $attribute_parameter['data_type'] = 'varchar'; |
| 200 | 200 | break; |
| 201 | 201 | case 'date_field': |
| 202 | 202 | $attribute_parameter['frontend_input'] = 'text'; |
| 203 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 203 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 204 | 204 | $attribute_parameter['data_type'] = 'datetime'; |
| 205 | 205 | break; |
| 206 | 206 | case 'float_field': |
| 207 | 207 | $attribute_parameter['frontend_input'] = 'text'; |
| 208 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 208 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 209 | 209 | $attribute_parameter['data_type'] = 'decimal'; |
| 210 | 210 | break; |
| 211 | 211 | case 'hidden_field': |
| 212 | 212 | $attribute_parameter['frontend_input'] = 'hidden'; |
| 213 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 213 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 214 | 214 | $attribute_parameter['data_type'] = 'varchar'; |
| 215 | 215 | break; |
| 216 | 216 | case 'pass_field': |
| 217 | 217 | $attribute_parameter['frontend_input'] = 'password'; |
| 218 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 218 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 219 | 219 | $attribute_parameter['data_type'] = 'varchar'; |
| 220 | 220 | break; |
| 221 | 221 | |
| 222 | 222 | case 'select': |
| 223 | 223 | $attribute_parameter['frontend_input'] = 'select'; |
| 224 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 224 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 225 | 225 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 226 | 226 | $attribute_parameter['data_type'] = 'integer'; |
| 227 | 227 | break; |
| 228 | 228 | case 'multiple-select': |
| 229 | 229 | $attribute_parameter['frontend_input'] = 'multiple-select'; |
| 230 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 230 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 231 | 231 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 232 | 232 | $attribute_parameter['data_type'] = 'integer'; |
| 233 | 233 | break; |
| 234 | 234 | case 'radio': |
| 235 | 235 | $attribute_parameter['frontend_input'] = 'radio'; |
| 236 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 236 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 237 | 237 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 238 | 238 | $attribute_parameter['data_type'] = 'integer'; |
| 239 | 239 | break; |
| 240 | 240 | case 'checkbox': |
| 241 | 241 | $attribute_parameter['frontend_input'] = 'checkbox'; |
| 242 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 242 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 243 | 243 | $attribute_parameter['backend_input'] = 'multiple-select'; |
| 244 | 244 | $attribute_parameter['data_type'] = 'integer'; |
| 245 | 245 | break; |
| 246 | 246 | |
| 247 | 247 | case 'textarea': |
| 248 | 248 | $attribute_parameter['frontend_input'] = 'textarea'; |
| 249 | - if ( empty($attribute_parameter['backend_input']) || empty($id) ) |
|
| 249 | + if (empty($attribute_parameter['backend_input']) || empty($id)) |
|
| 250 | 250 | $attribute_parameter['backend_input'] = 'textarea'; |
| 251 | 251 | $attribute_parameter['data_type'] = 'text'; |
| 252 | 252 | break; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | else { |
| 256 | 256 | $attribute_parameter['frontend_input'] = 'text'; |
| 257 | - if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text'; |
|
| 257 | + if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text'; |
|
| 258 | 258 | $attribute_parameter['data_type'] = 'varchar'; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -263,55 +263,55 @@ discard block |
||
| 263 | 263 | // $attribute_parameter['use_ajax_for_filling_field']='no'; |
| 264 | 264 | // } |
| 265 | 265 | $attribute_parameter['use_ajax_for_filling_field'] = 'yes'; |
| 266 | - if( $attribute_parameter['backend_input'] == 'multiple-select' ) { |
|
| 266 | + if ($attribute_parameter['backend_input'] == 'multiple-select') { |
|
| 267 | 267 | $attribute_parameter['is_used_for_variation'] = 'yes'; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /* Define the database operation type from action launched by the user */ |
| 271 | 271 | $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']) : ''); |
| 272 | - if ( $attribute_parameter['data_type'] == 'datetime' ) { |
|
| 272 | + if ($attribute_parameter['data_type'] == 'datetime') { |
|
| 273 | 273 | $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)); |
| 274 | - $attribute_parameter['default_value'] = serialize( $date_default_value_trasform_into_config ); |
|
| 274 | + $attribute_parameter['default_value'] = serialize($date_default_value_trasform_into_config); |
|
| 275 | 275 | } |
| 276 | 276 | /***************************** GENERIC **************************/ |
| 277 | 277 | /*************************************************************************/ |
| 278 | - $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']) : ''); |
|
| 278 | + $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']) : ''); |
|
| 279 | 279 | $id = isset($attribute_parameter['id']) ? sanitize_key($attribute_parameter['id']) : ((!empty($_GET['id'])) ? $_GET['id'] : ''); |
| 280 | - if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))){ |
|
| 281 | - if(current_user_can('wpshop_edit_attributes')){ |
|
| 280 | + if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))) { |
|
| 281 | + if (current_user_can('wpshop_edit_attributes')) { |
|
| 282 | 282 | $attribute_parameter['last_update_date'] = date('Y-m-d H:i:s'); |
| 283 | - if($pageAction == 'delete'){ |
|
| 283 | + if ($pageAction == 'delete') { |
|
| 284 | 284 | $attribute_code = $attribute_parameter['code']; |
| 285 | - if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){ |
|
| 285 | + if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) { |
|
| 286 | 286 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id'); |
| 287 | 287 | $attribute_code = $attribute->code; |
| 288 | 288 | } |
| 289 | - if(!in_array($attribute_code, $attribute_undeletable)){ |
|
| 290 | - if(current_user_can('wpshop_delete_attributes')){ |
|
| 289 | + if (!in_array($attribute_code, $attribute_undeletable)) { |
|
| 290 | + if (current_user_can('wpshop_delete_attributes')) { |
|
| 291 | 291 | $attribute_parameter['status'] = 'deleted'; |
| 292 | 292 | } |
| 293 | - else{ |
|
| 293 | + else { |
|
| 294 | 294 | $actionResult = 'userNotAllowedForActionDelete'; |
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | - else{ |
|
| 297 | + else { |
|
| 298 | 298 | $actionResult = 'unDeletableAtribute'; |
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | $actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable()); |
| 302 | 302 | } |
| 303 | - else{ |
|
| 303 | + else { |
|
| 304 | 304 | $actionResult = 'userNotAllowedForActionEdit'; |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | - elseif(($pageAction != '') && (($pageAction == 'delete'))){ |
|
| 307 | + elseif (($pageAction != '') && (($pageAction == 'delete'))) { |
|
| 308 | 308 | $attribute_code = ''; |
| 309 | - if (empty( $attribute_parameter['code'])) { |
|
| 309 | + if (empty($attribute_parameter['code'])) { |
|
| 310 | 310 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused', 'deleted'", 'id'); |
| 311 | 311 | $attribute_code = $attribute->code; |
| 312 | 312 | } |
| 313 | 313 | if (!in_array($attribute_code, $attribute_undeletable)) { |
| 314 | - if(current_user_can('wpshop_delete_attributes')){ |
|
| 314 | + if (current_user_can('wpshop_delete_attributes')) { |
|
| 315 | 315 | $attribute_parameter['last_update_date'] = current_time('mysql', 0); |
| 316 | 316 | $attribute_parameter['status'] = 'deleted'; |
| 317 | 317 | $actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable()); |
@@ -322,21 +322,21 @@ discard block |
||
| 322 | 322 | else |
| 323 | 323 | $actionResult = 'unDeletableAtribute'; |
| 324 | 324 | } |
| 325 | - elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){ |
|
| 326 | - if(current_user_can('wpshop_add_attributes')){ |
|
| 325 | + elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) { |
|
| 326 | + if (current_user_can('wpshop_add_attributes')) { |
|
| 327 | 327 | $attribute_parameter['creation_date'] = current_time('mysql', 0); |
| 328 | - if(trim($attribute_parameter['code']) == ''){ |
|
| 328 | + if (trim($attribute_parameter['code']) == '') { |
|
| 329 | 329 | $attribute_parameter['code'] = $attribute_parameter['frontend_label']; |
| 330 | 330 | } |
| 331 | 331 | $attribute_parameter['code'] = wpshop_tools::slugify(str_replace("\'", "_", str_replace('\"', "_", $attribute_parameter['code'])), array('noAccent', 'noSpaces', 'lowerCase', 'noPunctuation')); |
| 332 | 332 | $code_exists = self::getElement($attribute_parameter['code'], "'valid', 'moderated', 'deleted'", 'code'); |
| 333 | - if((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)){ |
|
| 333 | + if ((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)) { |
|
| 334 | 334 | $attribute_parameter['code'] = $attribute_parameter['code'] . '_' . (count($code_exists) + rand()); |
| 335 | 335 | } |
| 336 | 336 | $actionResult = wpshop_database::save($attribute_parameter, self::getDbTable()); |
| 337 | 337 | $id = $wpdb->insert_id; |
| 338 | 338 | } |
| 339 | - else{ |
|
| 339 | + else { |
|
| 340 | 340 | $actionResult = 'userNotAllowedForActionAdd'; |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | /************ CHANGE THE FIELD NAME TO TAKE TO DISPLAY *************/ |
| 346 | 346 | /************ CHANGE ERROR MESSAGE FOR SPECIFIC CASE *************/ |
| 347 | 347 | /****************************************************************************/ |
| 348 | - if($actionResult != ''){ |
|
| 348 | + if ($actionResult != '') { |
|
| 349 | 349 | $elementIdentifierForMessage = __('the attribute', 'wpshop'); |
| 350 | - if(!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>'; |
|
| 350 | + if (!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>'; |
|
| 351 | 351 | if ($actionResult == 'error') {/* CHANGE HERE FOR SPECIFIC CASE */ |
| 352 | 352 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage, ' -> ' . $wpdb->last_error); |
| 353 | 353 | } |
@@ -359,11 +359,11 @@ discard block |
||
| 359 | 359 | $done_options_value = array(); |
| 360 | 360 | $default_value = $attribute_parameter['default_value']; |
| 361 | 361 | $i = 1; |
| 362 | - $options = !empty($_REQUEST['options']) ? (array) $_REQUEST['options'] : array(); |
|
| 363 | - $optionsValue = !empty($_REQUEST['optionsValue']) ? (array) $_REQUEST['optionsValue'] : array(); |
|
| 364 | - $optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array) $_REQUEST['optionsUpdate'] : array(); |
|
| 365 | - $optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array) $_REQUEST['optionsUpdateValue'] : array(); |
|
| 366 | - if ( !empty($optionsUpdate) ) { |
|
| 362 | + $options = !empty($_REQUEST['options']) ? (array)$_REQUEST['options'] : array(); |
|
| 363 | + $optionsValue = !empty($_REQUEST['optionsValue']) ? (array)$_REQUEST['optionsValue'] : array(); |
|
| 364 | + $optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array)$_REQUEST['optionsUpdate'] : array(); |
|
| 365 | + $optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array)$_REQUEST['optionsUpdateValue'] : array(); |
|
| 366 | + if (!empty($optionsUpdate)) { |
|
| 367 | 367 | /** |
| 368 | 368 | * Check if there is an attribute code into sended request or if we have to get the code from database (Bug fix) |
| 369 | 369 | */ |
@@ -377,25 +377,25 @@ discard block |
||
| 377 | 377 | foreach ($optionsUpdate as $option_key => $option_label) { |
| 378 | 378 | $option_value = !empty($optionsUpdateValue[$option_key]) ? str_replace(",", ".", $optionsUpdateValue[$option_key]) : ''; |
| 379 | 379 | |
| 380 | - if ( empty($option_value) || !in_array($option_value, $done_options_value) ) { |
|
| 380 | + if (empty($option_value) || !in_array($option_value, $done_options_value)) { |
|
| 381 | 381 | /* Update an existing value only if the value does not exist into existing list */ |
| 382 | 382 | $label = (($option_label != '') ? $option_label : str_replace(",", ".", $option_value)); |
| 383 | 383 | $value = str_replace(",", ".", $option_value); |
| 384 | - if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT ) { |
|
| 384 | + if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT) { |
|
| 385 | 385 | $label = $option_label; |
| 386 | - $value = str_replace(",", ".", $label); |
|
| 386 | + $value = str_replace(",", ".", $label); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $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)); |
| 390 | 390 | $done_options_value[] = str_replace(",", ".", $option_value); |
| 391 | 391 | |
| 392 | 392 | /* Check if this value is used for price calculation and make update on the different product using this value */ |
| 393 | - if($attribute_code == WPSHOP_PRODUCT_PRICE_TAX){ |
|
| 393 | + if ($attribute_code == WPSHOP_PRODUCT_PRICE_TAX) { |
|
| 394 | 394 | $action = wpshop_prices::mass_update_prices(); |
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - if($default_value == $option_key) { |
|
| 398 | + if ($default_value == $option_key) { |
|
| 399 | 399 | /* Update an existing a only if the value does not exist into existing list */ |
| 400 | 400 | $wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $option_key), array('id' => $id)); |
| 401 | 401 | $done_options_value[] = str_replace(",", ".", $option_value); |
@@ -403,13 +403,13 @@ discard block |
||
| 403 | 403 | $i++; |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | - if ( !empty($options) ) { |
|
| 407 | - foreach ( $options as $option_key => $option_label ) { |
|
| 406 | + if (!empty($options)) { |
|
| 407 | + foreach ($options as $option_key => $option_label) { |
|
| 408 | 408 | $option_value = !empty($optionsValue[$option_key]) ? str_replace(",", ".", $optionsValue[$option_key]) : sanitize_title($option_label); |
| 409 | 409 | |
| 410 | 410 | /* Check what value to use for the new values */ |
| 411 | 411 | $label = (!empty($option_label) ? $option_label : str_replace(",", ".", $option_value)); |
| 412 | - if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value) ) { |
|
| 412 | + if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value)) { |
|
| 413 | 413 | $label = $option_label; |
| 414 | 414 | $option_value = sanitize_title($label); |
| 415 | 415 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | // If the optionsUpdateValue is empty, set it a empty array to avoid error calling the in_array() function |
| 418 | 418 | // $_REQUEST['optionsUpdateValue'] = !empty($_REQUEST['optionsUpdateValue']) ? $_REQUEST['optionsUpdateValue'] : array(); |
| 419 | 419 | |
| 420 | - if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue) ) { |
|
| 420 | + if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue)) { |
|
| 421 | 421 | |
| 422 | 422 | $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))); |
| 423 | 423 | $done_options_value[] = str_replace(",", ".", $option_value); |
@@ -435,19 +435,19 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | // If the is_used_for_sort_by is mark as yes, we have to get out some attributes and save it separately |
| 438 | - 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')) ){ |
|
| 438 | + 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'))) { |
|
| 439 | 439 | $attribute_code = $attribute_parameter['code']; |
| 440 | - if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){ |
|
| 440 | + if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) { |
|
| 441 | 441 | $attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id'); |
| 442 | 442 | $attribute_code = $attribute->code; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | $count_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
| 446 | - for( $i = 0; $i <= $count_products->publish; $i+= 20 ) { |
|
| 447 | - $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' ); |
|
| 448 | - $products = $wpdb->get_results( $query ); |
|
| 449 | - if ( !empty($products) ) { |
|
| 450 | - foreach( $products as $product ) { |
|
| 446 | + for ($i = 0; $i <= $count_products->publish; $i += 20) { |
|
| 447 | + $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'); |
|
| 448 | + $products = $wpdb->get_results($query); |
|
| 449 | + if (!empty($products)) { |
|
| 450 | + foreach ($products as $product) { |
|
| 451 | 451 | $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); |
| 452 | 452 | $value = $wpdb->get_var($query); |
| 453 | 453 | update_post_meta($product->ID, '_' . $attribute_code, $value); |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | wp_reset_query(); |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if ( $pageAction != 'delete' ) {/* Add the new attribute in the additionnal informations attribute group */ |
|
| 461 | - if ( !empty($set_section) ) { |
|
| 460 | + if ($pageAction != 'delete') {/* Add the new attribute in the additionnal informations attribute group */ |
|
| 461 | + if (!empty($set_section)) { |
|
| 462 | 462 | $choosen_set_section = explode('_', $set_section); |
| 463 | 463 | $set_id = $choosen_set_section[0]; |
| 464 | 464 | $group_id = $choosen_set_section[1]; |
| 465 | 465 | } |
| 466 | - else{ |
|
| 466 | + else { |
|
| 467 | 467 | $attribute_current_attribute_set = 0; |
| 468 | 468 | $query = $wpdb->prepare(" |
| 469 | 469 | SELECT id |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | AND ATTRIBUTE_SET_DETAILS.entity_type_id = %d", $id, $attribute_parameter['entity_id']); |
| 474 | 474 | $attribute_current_attribute_set = $wpdb->get_results($query); |
| 475 | 475 | |
| 476 | - if ( empty($attribute_current_attribute_set) ) { |
|
| 476 | + if (empty($attribute_current_attribute_set)) { |
|
| 477 | 477 | $query = $wpdb->prepare(" |
| 478 | 478 | SELECT |
| 479 | 479 | ( |
@@ -494,12 +494,12 @@ discard block |
||
| 494 | 494 | $wpshop_default_group = $wpdb->get_row($query); |
| 495 | 495 | |
| 496 | 496 | $set_id = $wpshop_default_group->attribute_set_id; |
| 497 | - $default_group_id = ( !empty( $wpshop_default_group->default_attribute_group_id) ) ? $wpshop_default_group->default_attribute_group_id : ''; |
|
| 497 | + $default_group_id = (!empty($wpshop_default_group->default_attribute_group_id)) ? $wpshop_default_group->default_attribute_group_id : ''; |
|
| 498 | 498 | $group_id = !empty($default_group_id) ? $default_group_id : $wpshop_default_group->attribute_group_id; |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if ( !empty($set_id) && !empty($group_id) ) { |
|
| 502 | + if (!empty($set_id) && !empty($group_id)) { |
|
| 503 | 503 | $query = $wpdb->prepare( |
| 504 | 504 | "SELECT (MAX(position) + 1) AS position |
| 505 | 505 | FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " |
@@ -511,12 +511,12 @@ discard block |
||
| 511 | 511 | $attribute_parameter['entity_id'] |
| 512 | 512 | ); |
| 513 | 513 | $wpshopAttributePosition = $wpdb->get_var($query); |
| 514 | - if($wpshopAttributePosition == 0)$wpshopAttributePosition = 1; |
|
| 514 | + if ($wpshopAttributePosition == 0)$wpshopAttributePosition = 1; |
|
| 515 | 515 | $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)); |
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if ( !empty($wpshop_attribute_combo_values_list_order_def) ) { |
|
| 519 | + if (!empty($wpshop_attribute_combo_values_list_order_def)) { |
|
| 520 | 520 | $post_order = explode(',', $wpshop_attribute_combo_values_list_order_def); |
| 521 | 521 | $position = 1; |
| 522 | 522 | foreach ($post_order as $post_id) { |
@@ -532,19 +532,19 @@ discard block |
||
| 532 | 532 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id)); |
| 533 | 533 | } |
| 534 | 534 | else */ |
| 535 | - if ( $pageAction == 'add' ) |
|
| 535 | + if ($pageAction == 'add') |
|
| 536 | 536 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id)); |
| 537 | - elseif ( $pageAction == 'delete' ) |
|
| 537 | + elseif ($pageAction == 'delete') |
|
| 538 | 538 | wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id)); |
| 539 | 539 | } |
| 540 | - elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){ |
|
| 540 | + elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) { |
|
| 541 | 541 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop'); |
| 542 | 542 | } |
| 543 | - elseif(($actionResult == 'unDeletableAtribute')){ |
|
| 543 | + elseif (($actionResult == 'unDeletableAtribute')) { |
|
| 544 | 544 | $pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('This attribute could not be deleted due to configuration', 'wpshop'); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - if(empty($attribute_parameter['frontend_label']) && ($pageAction!='delete')){ |
|
| 547 | + if (empty($attribute_parameter['frontend_label']) && ($pageAction != 'delete')) { |
|
| 548 | 548 | $pageMessage .= __('Please enter an label for the attribut', 'wpshop'); |
| 549 | 549 | } |
| 550 | 550 | } |
@@ -562,37 +562,37 @@ discard block |
||
| 562 | 562 | //Create an instance of our package class... |
| 563 | 563 | $wpshop_list_table = new wpshop_attributes_custom_List_table(); |
| 564 | 564 | //Fetch, prepare, sort, and filter our data... |
| 565 | - $status="'valid'"; |
|
| 566 | - $attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : null; |
|
| 567 | - $s = !empty($_REQUEST['s']) ? sanitize_text_field( $_REQUEST['s'] ) : null; |
|
| 565 | + $status = "'valid'"; |
|
| 566 | + $attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : null; |
|
| 567 | + $s = !empty($_REQUEST['s']) ? sanitize_text_field($_REQUEST['s']) : null; |
|
| 568 | 568 | $order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : null; |
| 569 | 569 | $orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : null; |
| 570 | - if(!empty($attribute_status)){ |
|
| 571 | - switch($attribute_status){ |
|
| 570 | + if (!empty($attribute_status)) { |
|
| 571 | + switch ($attribute_status) { |
|
| 572 | 572 | case 'unactive': |
| 573 | - $status="'moderated', 'notused'"; |
|
| 574 | - if(empty($order_by) && empty($order)){ |
|
| 573 | + $status = "'moderated', 'notused'"; |
|
| 574 | + if (empty($order_by) && empty($order)) { |
|
| 575 | 575 | // @TODO : REQUEST |
| 576 | 576 | // $_REQUEST['orderby']='status'; |
| 577 | 577 | // $_REQUEST['order']='asc'; |
| 578 | 578 | } |
| 579 | 579 | break; |
| 580 | 580 | default: |
| 581 | - $status="'".sanitize_text_field($_REQUEST['attribute_status'])."'"; |
|
| 581 | + $status = "'" . sanitize_text_field($_REQUEST['attribute_status']) . "'"; |
|
| 582 | 582 | break; |
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | - if ( !empty($s) ) { |
|
| 586 | - $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') ); |
|
| 587 | - $attr_set_list = $wpdb->get_results( $query ); |
|
| 585 | + if (!empty($s)) { |
|
| 586 | + $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')); |
|
| 587 | + $attr_set_list = $wpdb->get_results($query); |
|
| 588 | 588 | } |
| 589 | 589 | else { |
| 590 | - $attr_set_list = self::getElement( '', $status ); |
|
| 590 | + $attr_set_list = self::getElement('', $status); |
|
| 591 | 591 | } |
| 592 | - $i=0; |
|
| 593 | - $attribute_set_list=array(); |
|
| 594 | - foreach($attr_set_list as $attr_set){ |
|
| 595 | - if(!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id') ){ |
|
| 592 | + $i = 0; |
|
| 593 | + $attribute_set_list = array(); |
|
| 594 | + foreach ($attr_set_list as $attr_set) { |
|
| 595 | + if (!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id')) { |
|
| 596 | 596 | $attribute_set_list[$i]['id'] = $attr_set->id; |
| 597 | 597 | $attribute_set_list[$i]['name'] = $attr_set->frontend_label; |
| 598 | 598 | $attribute_set_list[$i]['status'] = $attr_set->status; |
@@ -640,31 +640,31 @@ discard block |
||
| 640 | 640 | global $attribute_displayed_field, $attribute_options_group; |
| 641 | 641 | $dbFieldList = wpshop_database::fields_to_input(self::getDbTable()); |
| 642 | 642 | $editedItem = ''; |
| 643 | - if($itemToEdit != '') |
|
| 643 | + if ($itemToEdit != '') |
|
| 644 | 644 | $editedItem = self::getElement($itemToEdit); |
| 645 | 645 | |
| 646 | 646 | $the_form_content_hidden = $the_form_general_content = ''; |
| 647 | 647 | $the_form_option_content_list = array(); |
| 648 | - foreach($dbFieldList as $input_key => $input_def){ |
|
| 648 | + foreach ($dbFieldList as $input_key => $input_def) { |
|
| 649 | 649 | |
| 650 | - if(!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)){ |
|
| 650 | + if (!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)) { |
|
| 651 | 651 | $input_def['label'] = $input_def['name']; |
| 652 | - $input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_def['label']; |
|
| 652 | + $input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_def['label']; |
|
| 653 | 653 | |
| 654 | 654 | $pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ''; |
| 655 | 655 | $requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : ''; |
| 656 | 656 | $currentFieldValue = $input_def['value']; |
| 657 | - if(is_object($editedItem)) |
|
| 657 | + if (is_object($editedItem)) |
|
| 658 | 658 | $currentFieldValue = $editedItem->{$input_def['label']}; |
| 659 | - elseif(($pageAction != '') && ($requestFormValue != '')) |
|
| 659 | + elseif (($pageAction != '') && ($requestFormValue != '')) |
|
| 660 | 660 | $currentFieldValue = $requestFormValue; |
| 661 | 661 | |
| 662 | - if($input_def['label'] == 'status'){ |
|
| 663 | - if(in_array('notused', $input_def['possible_value'])){ |
|
| 662 | + if ($input_def['label'] == 'status') { |
|
| 663 | + if (in_array('notused', $input_def['possible_value'])) { |
|
| 664 | 664 | $key = array_keys($input_def['possible_value'], 'notused'); |
| 665 | 665 | unset($input_def['possible_value'][$key[0]]); |
| 666 | 666 | } |
| 667 | - if(in_array('dbl', $input_def['possible_value'])){ |
|
| 667 | + if (in_array('dbl', $input_def['possible_value'])) { |
|
| 668 | 668 | $key = array_keys($input_def['possible_value'], 'dbl'); |
| 669 | 669 | unset($input_def['possible_value'][$key[0]]); |
| 670 | 670 | } |
@@ -672,94 +672,94 @@ discard block |
||
| 672 | 672 | $input_def['type'] = 'checkbox'; |
| 673 | 673 | $input_def['label'] = __('Use this attribute', 'wpshop'); |
| 674 | 674 | $input_def['possible_value'] = array('valid'); |
| 675 | - $input_def_id.='_valid'; |
|
| 676 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 675 | + $input_def_id .= '_valid'; |
|
| 676 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - if ( (substr($input_def['label'], 0, 3) == 'is_') || ( $input_def['label'] == '_display_informations_about_value') ) { |
|
| 679 | + if ((substr($input_def['label'], 0, 3) == 'is_') || ($input_def['label'] == '_display_informations_about_value')) { |
|
| 680 | 680 | $input_def['type'] = 'checkbox'; |
| 681 | 681 | $input_def['possible_value'] = 'yes'; |
| 682 | 682 | } |
| 683 | - switch($input_def['label']){ |
|
| 683 | + switch ($input_def['label']) { |
|
| 684 | 684 | case 'is_requiring_unit': |
| 685 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using unit with this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 685 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using unit with this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 686 | 686 | break; |
| 687 | 687 | case 'is_visible_in_front': |
| 688 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 688 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 689 | 689 | break; |
| 690 | 690 | case 'is_visible_in_front_listing': |
| 691 | - $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>'; |
|
| 691 | + $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>'; |
|
| 692 | 692 | break; |
| 693 | 693 | case 'is_used_for_sort_by': |
| 694 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute into sortbar', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 694 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute into sortbar', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 695 | 695 | break; |
| 696 | 696 | case 'is_searchable': |
| 697 | - $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>'; |
|
| 697 | + $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>'; |
|
| 698 | 698 | break; |
| 699 | 699 | case 'is_visible_in_advanced_search': |
| 700 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using in advanced search form', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 700 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using in advanced search form', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 701 | 701 | break; |
| 702 | 702 | case 'frontend_css_class': |
| 703 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 703 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 704 | 704 | break; |
| 705 | 705 | case 'backend_css_class': |
| 706 | - $input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>'; |
|
| 706 | + $input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 707 | 707 | break; |
| 708 | 708 | case 'is_historisable': |
| 709 | - $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>'; |
|
| 709 | + $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>'; |
|
| 710 | 710 | break; |
| 711 | 711 | case 'is_filterable': |
| 712 | - $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>'; |
|
| 712 | + $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>'; |
|
| 713 | 713 | break; |
| 714 | 714 | case 'is_intrinsic': |
| 715 | - $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>'; |
|
| 715 | + $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>'; |
|
| 716 | 716 | break; |
| 717 | 717 | case 'is_used_for_variation': |
| 718 | - $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>'; |
|
| 718 | + $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>'; |
|
| 719 | 719 | break; |
| 720 | 720 | case 'is_used_in_variation': |
| 721 | - $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>'; |
|
| 722 | - if ( !empty($editedItem) && ($editedItem->is_used_for_variation == 'yes') ) { |
|
| 721 | + $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>'; |
|
| 722 | + if (!empty($editedItem) && ($editedItem->is_used_for_variation == 'yes')) { |
|
| 723 | 723 | $input_def['option'] = 'disabled="disabled"'; |
| 724 | 724 | } |
| 725 | 725 | break; |
| 726 | 726 | case 'is_user_defined': |
| 727 | - $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>'; |
|
| 727 | + $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>'; |
|
| 728 | 728 | break; |
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | $input_def['value'] = $currentFieldValue; |
| 732 | - if($input_def['label'] == 'code') |
|
| 732 | + if ($input_def['label'] == 'code') |
|
| 733 | 733 | $input_def['type'] = 'hidden'; |
| 734 | - elseif($input_def['label'] == 'entity_id'){ |
|
| 734 | + elseif ($input_def['label'] == 'entity_id') { |
|
| 735 | 735 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
| 736 | 736 | $input_def['valueToPut'] = 'index'; |
| 737 | 737 | $input_def['type'] = 'select'; |
| 738 | 738 | |
| 739 | - $i=0; |
|
| 740 | - foreach($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 741 | - if($i <= 0){ |
|
| 739 | + $i = 0; |
|
| 740 | + foreach ($input_def['possible_value'] as $entity_id => $entity_name) { |
|
| 741 | + if ($i <= 0) { |
|
| 742 | 742 | $current_entity_id = $entity_id; |
| 743 | 743 | } |
| 744 | 744 | $i++; |
| 745 | 745 | } |
| 746 | 746 | } |
| 747 | - elseif($input_def['label'] == '_unit_group_id'){ |
|
| 747 | + elseif ($input_def['label'] == '_unit_group_id') { |
|
| 748 | 748 | $input_def['possible_value'] = wpshop_attributes_unit::get_unit_group(); |
| 749 | 749 | $input_def['type'] = 'select'; |
| 750 | 750 | } |
| 751 | - elseif($input_def['label'] == '_default_unit'){ |
|
| 751 | + elseif ($input_def['label'] == '_default_unit') { |
|
| 752 | 752 | $unit_group_list = wpshop_attributes_unit::get_unit_group(); |
| 753 | - $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:'')); |
|
| 753 | + $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 : '')); |
|
| 754 | 754 | $input_def['type'] = 'select'; |
| 755 | 755 | } |
| 756 | 756 | elseif ($input_def['label'] == 'backend_input') { |
| 757 | - if ( !is_object($editedItem) ) { |
|
| 757 | + if (!is_object($editedItem)) { |
|
| 758 | 758 | $input_def['type'] = 'hidden'; |
| 759 | 759 | } |
| 760 | 760 | else { |
| 761 | 761 | $new_possible_value = array(); |
| 762 | - switch ( $editedItem->data_type) { |
|
| 762 | + switch ($editedItem->data_type) { |
|
| 763 | 763 | case 'integer': |
| 764 | 764 | $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; |
| 765 | 765 | $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; |
| 768 | 768 | break; |
| 769 | 769 | case 'varchar': |
| 770 | - switch ( $input_def['value'] ) { |
|
| 770 | + switch ($input_def['value']) { |
|
| 771 | 771 | case 'hidden': |
| 772 | 772 | $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; |
| 773 | 773 | break; |
@@ -795,8 +795,8 @@ discard block |
||
| 795 | 795 | elseif ($input_def['label'] == 'frontend_input') { |
| 796 | 796 | $new_possible_value = array(); |
| 797 | 797 | |
| 798 | - if ( is_object($editedItem) ) { |
|
| 799 | - switch ( $editedItem->data_type) { |
|
| 798 | + if (is_object($editedItem)) { |
|
| 799 | + switch ($editedItem->data_type) { |
|
| 800 | 800 | case 'integer': |
| 801 | 801 | $new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox'; |
| 802 | 802 | $new_possible_value[__('Radio button', 'wpshop')] = 'radio'; |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | $new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select'; |
| 805 | 805 | break; |
| 806 | 806 | case 'varchar': |
| 807 | - switch ( $input_def['value'] ) { |
|
| 807 | + switch ($input_def['value']) { |
|
| 808 | 808 | case 'hidden': |
| 809 | 809 | $new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field'; |
| 810 | 810 | break; |
@@ -842,10 +842,10 @@ discard block |
||
| 842 | 842 | |
| 843 | 843 | $input_def['possible_value'] = $new_possible_value; |
| 844 | 844 | |
| 845 | - if ( !empty($editedItem->frontend_input) ) { |
|
| 846 | - switch ( $editedItem->frontend_input ) { |
|
| 845 | + if (!empty($editedItem->frontend_input)) { |
|
| 846 | + switch ($editedItem->frontend_input) { |
|
| 847 | 847 | case 'text': |
| 848 | - switch ( $editedItem->data_type ) { |
|
| 848 | + switch ($editedItem->data_type) { |
|
| 849 | 849 | case 'varchar': |
| 850 | 850 | $input_def['value'] = 'short_text'; |
| 851 | 851 | break; |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | } |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - if(is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))){ |
|
| 873 | + if (is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))) { |
|
| 874 | 874 | // $input_def['type'] = 'hidden'; |
| 875 | 875 | $input_def['option'] = ' disabled="disabled" '; |
| 876 | 876 | $the_form_content_hidden .= '<input type="hidden" name="' . self::getDbTable() . '[' . $input_def['name'] . ']" value="' . $input_def['value'] . '" />'; |
@@ -881,16 +881,16 @@ discard block |
||
| 881 | 881 | $input_def['value'] = str_replace("\\", "", $input_def['value']); |
| 882 | 882 | |
| 883 | 883 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 884 | - if ( $input_def['label'] == 'default_value' ) { |
|
| 885 | - if ( !empty($editedItem->frontend_input) ) { |
|
| 886 | - switch ( $editedItem->frontend_input ) { |
|
| 884 | + if ($input_def['label'] == 'default_value') { |
|
| 885 | + if (!empty($editedItem->frontend_input)) { |
|
| 886 | + switch ($editedItem->frontend_input) { |
|
| 887 | 887 | case 'text': |
| 888 | 888 | $input_def['type'] = 'text'; |
| 889 | - switch ( $editedItem->data_type ) { |
|
| 889 | + switch ($editedItem->data_type) { |
|
| 890 | 890 | case 'datetime': |
| 891 | - $the_input = wpshop_attributes::attribute_type_date_config( unserialize($input_def['value']) ); |
|
| 891 | + $the_input = wpshop_attributes::attribute_type_date_config(unserialize($input_def['value'])); |
|
| 892 | 892 | |
| 893 | - $input_def['label'] = __('Date field configuration','wpshop'); |
|
| 893 | + $input_def['label'] = __('Date field configuration', 'wpshop'); |
|
| 894 | 894 | break; |
| 895 | 895 | default: |
| 896 | 896 | $the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
@@ -907,7 +907,7 @@ discard block |
||
| 907 | 907 | case 'multiple-select': |
| 908 | 908 | case 'radio': |
| 909 | 909 | case 'checkbox': |
| 910 | - $input_def['label'] = __('Options list for attribute','wpshop') . ' |
|
| 910 | + $input_def['label'] = __('Options list for attribute', 'wpshop') . ' |
|
| 911 | 911 | <div class="alignright wpshop_change_select_data_type" > |
| 912 | 912 | +' . __('Change data type for this attribute', 'wpshop') . ' |
| 913 | 913 | </div>'; |
@@ -921,50 +921,50 @@ discard block |
||
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | else { |
| 924 | - $input_def['type']='text'; |
|
| 924 | + $input_def['type'] = 'text'; |
|
| 925 | 925 | $the_input = wpshop_form::check_input_type($input_def, self::getDbTable()); |
| 926 | 926 | } |
| 927 | 927 | } |
| 928 | - if( $input_def['label'] == '_unit_group_id') { |
|
| 928 | + if ($input_def['label'] == '_unit_group_id') { |
|
| 929 | 929 | $the_input .= '<div id="wpshop_loader_input_group_unit"></div>'; |
| 930 | - $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>'; |
|
| 930 | + $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>'; |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | - if( $input_def['label'] == '_default_unit') { |
|
| 933 | + if ($input_def['label'] == '_default_unit') { |
|
| 934 | 934 | $the_input .= '<div id="wpshop_loader_input_unit"></div>'; |
| 935 | - $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>'; |
|
| 935 | + $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>'; |
|
| 936 | 936 | $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") . '" />'; |
| 937 | 937 | $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>'; |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | |
| 941 | - if($input_def['type'] != 'hidden'){ |
|
| 942 | - if ( ($input_def['label'] == 'entity_id') && is_object($editedItem) ) { |
|
| 941 | + if ($input_def['type'] != 'hidden') { |
|
| 942 | + if (($input_def['label'] == 'entity_id') && is_object($editedItem)) { |
|
| 943 | 943 | $the_input .= '<br/><span class="wpshop_duplicate_attribute" >' . __('Duplicate this attribute to . another entity', 'wpshop') . '</span>'; |
| 944 | 944 | } |
| 945 | 945 | $input = ' |
| 946 | - <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_def['name'].'" > |
|
| 947 | - <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> |
|
| 948 | - <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> |
|
| 946 | + <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_def['name'] . '" > |
|
| 947 | + <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> |
|
| 948 | + <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> |
|
| 949 | 949 | </tr>'; |
| 950 | - 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 )) ) |
|
| 950 | + 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))) |
|
| 951 | 951 | $the_form_option_content_list[$input_def['label']] = $input; |
| 952 | 952 | else { |
| 953 | 953 | $the_form_general_content .= $input; |
| 954 | - if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) { |
|
| 954 | + if (($input_def['label'] == 'frontend_input') && !is_object($editedItem)) { |
|
| 955 | 955 | |
| 956 | - $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); |
|
| 956 | + $the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode); |
|
| 957 | 957 | |
| 958 | 958 | $input = ' |
| 959 | 959 | <tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_set_section" > |
| 960 | - <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> |
|
| 960 | + <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> |
|
| 961 | 961 | <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> |
| 962 | 962 | </tr>'; |
| 963 | 963 | $the_form_general_content .= $input; |
| 964 | 964 | } |
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | - else{ |
|
| 967 | + else { |
|
| 968 | 968 | $the_form_content_hidden .= ' |
| 969 | 969 | ' . $the_input; |
| 970 | 970 | } |
@@ -980,17 +980,17 @@ discard block |
||
| 980 | 980 | $section_content = $the_form_general_content; |
| 981 | 981 | |
| 982 | 982 | ob_start(); |
| 983 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 983 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 984 | 984 | $the_form_general_content = ob_get_contents(); |
| 985 | 985 | ob_end_clean(); |
| 986 | 986 | |
| 987 | 987 | /** It is attribute TVA, add a button to calcilate price in mass **/ |
| 988 | - if ( !empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva' ) { |
|
| 989 | - $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/>'; |
|
| 990 | - $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop' ); |
|
| 988 | + if (!empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva') { |
|
| 989 | + $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/>'; |
|
| 990 | + $the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop'); |
|
| 991 | 991 | } |
| 992 | 992 | if (!empty($the_form_option_content_list)) { |
| 993 | - $the_form_option_content_section=''; |
|
| 993 | + $the_form_option_content_section = ''; |
|
| 994 | 994 | foreach ($attribute_options_group as $group_name => $group_content) { |
| 995 | 995 | $section_content = ''; |
| 996 | 996 | foreach ($group_content as $group_code) { |
@@ -999,23 +999,23 @@ discard block |
||
| 999 | 999 | unset($the_form_option_content_list[$group_code]); |
| 1000 | 1000 | } |
| 1001 | 1001 | } |
| 1002 | - $section_legend = __($group_name,'wpshop'); |
|
| 1002 | + $section_legend = __($group_name, 'wpshop'); |
|
| 1003 | 1003 | $section_page_code = self::currentPageCode; |
| 1004 | 1004 | |
| 1005 | 1005 | ob_start(); |
| 1006 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 1006 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 1007 | 1007 | $the_form_option_content_section .= ob_get_contents(); |
| 1008 | 1008 | ob_end_clean(); |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | /* Check there are other attributes to display not in defined group */ |
| 1012 | 1012 | if (!empty($the_form_option_content_list)) { |
| 1013 | - $section_legend = __('General options','wpshop'); |
|
| 1013 | + $section_legend = __('General options', 'wpshop'); |
|
| 1014 | 1014 | $section_content = implode('', $the_form_option_content_list); |
| 1015 | 1015 | $section_page_code = self::currentPageCode; |
| 1016 | 1016 | |
| 1017 | 1017 | ob_start(); |
| 1018 | - include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php'); |
|
| 1018 | + include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php'); |
|
| 1019 | 1019 | $the_form_option_content = ob_get_contents(); |
| 1020 | 1020 | ob_end_clean(); |
| 1021 | 1021 | |
@@ -1025,17 +1025,17 @@ discard block |
||
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | /* Default content for the current page */ |
| 1028 | - $bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop'); |
|
| 1028 | + $bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop'); |
|
| 1029 | 1029 | $bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content; |
| 1030 | 1030 | |
| 1031 | - $bloc_list[self::currentPageCode]['options']['title']=__('Options', 'wpshop'); |
|
| 1032 | - $bloc_list[self::currentPageCode]['options']['content']=$the_form_option_content; |
|
| 1031 | + $bloc_list[self::currentPageCode]['options']['title'] = __('Options', 'wpshop'); |
|
| 1032 | + $bloc_list[self::currentPageCode]['options']['content'] = $the_form_option_content; |
|
| 1033 | 1033 | |
| 1034 | - $action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action' ] ) : ''; |
|
| 1034 | + $action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
|
| 1035 | 1035 | $the_form = ' |
| 1036 | 1036 | <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" > |
| 1037 | - ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save') , 'hidden') . ' |
|
| 1038 | - ' . 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 | + ' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save'), 'hidden') . ' |
|
| 1038 | + ' . 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) . ' |
|
| 1039 | 1039 | </form> |
| 1040 | 1040 | <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>'; |
| 1041 | 1041 | $input_def['possible_value'] = wpshop_entities::get_entities_list(); |
@@ -1053,7 +1053,7 @@ discard block |
||
| 1053 | 1053 | $the_form .= ' |
| 1054 | 1054 | <script type="text/javascript" > |
| 1055 | 1055 | wpshop(document).ready(function(){ |
| 1056 | - 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') . '"); |
|
| 1056 | + 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') . '"); |
|
| 1057 | 1057 | |
| 1058 | 1058 | jQuery("#wpshop_dialog_duplicate_attribute").dialog({ |
| 1059 | 1059 | autoOpen: false, |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | dialogClass: "wpshop_uidialog_box", |
| 1064 | 1064 | resizable: false, |
| 1065 | 1065 | buttons:{ |
| 1066 | - "'.__('Duplicate', 'wpshop').'": function(){ |
|
| 1066 | + "'.__('Duplicate', 'wpshop') . '": function(){ |
|
| 1067 | 1067 | var data = { |
| 1068 | 1068 | action: "wpshop_duplicate_attribute", |
| 1069 | 1069 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_duplicate_attribute") . '", |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | } |
| 1080 | 1080 | }, "json"); |
| 1081 | 1081 | }, |
| 1082 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 1082 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 1083 | 1083 | jQuery(this).dialog("close"); |
| 1084 | 1084 | jQuery(".wpshop_duplicate_attribute_result").remove(); |
| 1085 | 1085 | } |
@@ -1097,7 +1097,7 @@ discard block |
||
| 1097 | 1097 | dialogClass: "wpshop_uidialog_box", |
| 1098 | 1098 | resizable: false, |
| 1099 | 1099 | buttons:{ |
| 1100 | - "'.__('Change type', 'wpshop').'": function(){ |
|
| 1100 | + "'.__('Change type', 'wpshop') . '": function(){ |
|
| 1101 | 1101 | var delete_entity = false; |
| 1102 | 1102 | if(jQuery("#delete_entity").is(":checked")){ |
| 1103 | 1103 | var delete_entity = true; |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | jQuery("#wpshop_dialog_change_select_data_type").dialog("close"); |
| 1121 | 1121 | }, "json"); |
| 1122 | 1122 | }, |
| 1123 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 1123 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 1124 | 1124 | jQuery(this).dialog("close"); |
| 1125 | 1125 | } |
| 1126 | 1126 | } |
@@ -1160,7 +1160,7 @@ discard block |
||
| 1160 | 1160 | change_unit_list(); |
| 1161 | 1161 | });'; |
| 1162 | 1162 | |
| 1163 | - if ( !is_object($editedItem) ) { |
|
| 1163 | + if (!is_object($editedItem)) { |
|
| 1164 | 1164 | $the_form .= ' |
| 1165 | 1165 | jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").change(function(){ |
| 1166 | 1166 | jQuery(".wpshop_attributes_edition_table_field_input_default_value").html(jQuery("#wpshopLoadingPicture").html()); |
@@ -1243,23 +1243,23 @@ discard block |
||
| 1243 | 1243 | * |
| 1244 | 1244 | * @return string $currentPageButton The html output code with the different button to add to the interface |
| 1245 | 1245 | */ |
| 1246 | - function getPageFormButton($element_id = 0){ |
|
| 1246 | + function getPageFormButton($element_id = 0) { |
|
| 1247 | 1247 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add'; |
| 1248 | 1248 | $currentPageButton = ''; |
| 1249 | 1249 | |
| 1250 | 1250 | //$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>'; |
| 1251 | 1251 | |
| 1252 | - if(($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1252 | + if (($action == 'add') && (current_user_can('wpshop_add_attributes'))) |
|
| 1253 | 1253 | $currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />'; |
| 1254 | 1254 | |
| 1255 | - elseif(current_user_can('wpshop_edit_attributes')) |
|
| 1255 | + elseif (current_user_can('wpshop_edit_attributes')) |
|
| 1256 | 1256 | $currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />'; |
| 1257 | 1257 | |
| 1258 | 1258 | $attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE); |
| 1259 | 1259 | $attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id'); |
| 1260 | - $attribute_code = !empty($attribute->code)?$attribute->code:''; |
|
| 1261 | - if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1262 | - $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1260 | + $attribute_code = !empty($attribute->code) ? $attribute->code : ''; |
|
| 1261 | + if (current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) |
|
| 1262 | + $currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />'; |
|
| 1263 | 1263 | |
| 1264 | 1264 | return $currentPageButton; |
| 1265 | 1265 | } |
@@ -1273,22 +1273,22 @@ discard block |
||
| 1273 | 1273 | * |
| 1274 | 1274 | * @return object $element_list A wordpress database object containing the attribute list |
| 1275 | 1275 | */ |
| 1276 | - public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false){ |
|
| 1276 | + public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false) { |
|
| 1277 | 1277 | |
| 1278 | 1278 | global $wpdb; |
| 1279 | 1279 | $element_list = array(); |
| 1280 | 1280 | $moreQuery = ""; |
| 1281 | - $moreArgs = array( 1, ); |
|
| 1281 | + $moreArgs = array(1,); |
|
| 1282 | 1282 | |
| 1283 | - $orderby = !empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
|
| 1284 | - $order = !empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
|
| 1283 | + $orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : ''; |
|
| 1284 | + $order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : ''; |
|
| 1285 | 1285 | |
| 1286 | - if($element_id != ''){ |
|
| 1286 | + if ($element_id != '') { |
|
| 1287 | 1287 | $moreQuery .= " |
| 1288 | 1288 | AND CURRENT_ELEMENT." . $field_to_search . " = %s "; |
| 1289 | 1289 | $moreArgs[] = $element_id; |
| 1290 | 1290 | } |
| 1291 | - if(!empty($orderby) && !empty($order)){ |
|
| 1291 | + if (!empty($orderby) && !empty($order)) { |
|
| 1292 | 1292 | $moreQuery .= " |
| 1293 | 1293 | ORDER BY " . $orderby . " " . $order; |
| 1294 | 1294 | } |
@@ -1297,15 +1297,15 @@ discard block |
||
| 1297 | 1297 | "SELECT CURRENT_ELEMENT.*, ENTITIES.post_name as entity |
| 1298 | 1298 | FROM " . self::getDbTable() . " AS CURRENT_ELEMENT |
| 1299 | 1299 | INNER JOIN {$wpdb->posts} AS ENTITIES ON (ENTITIES.ID = CURRENT_ELEMENT.entity_id) |
| 1300 | - WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery, |
|
| 1300 | + WHERE %d AND CURRENT_ELEMENT.status IN (" . $element_status . ") " . $moreQuery, |
|
| 1301 | 1301 | $moreArgs |
| 1302 | 1302 | ); |
| 1303 | 1303 | |
| 1304 | 1304 | /* Get the query result regarding on the function parameters. If there must be only one result or a collection */ |
| 1305 | - if(($element_id == '') || $list){ |
|
| 1305 | + if (($element_id == '') || $list) { |
|
| 1306 | 1306 | $element_list = $wpdb->get_results($query); |
| 1307 | 1307 | } |
| 1308 | - else{ |
|
| 1308 | + else { |
|
| 1309 | 1309 | $element_list = $wpdb->get_row($query); |
| 1310 | 1310 | } |
| 1311 | 1311 | |
@@ -1327,8 +1327,8 @@ discard block |
||
| 1327 | 1327 | $user_id = function_exists('is_user_logged_in') && is_user_logged_in() ? get_current_user_id() : '0'; |
| 1328 | 1328 | $sent_attribute_list = array(); |
| 1329 | 1329 | |
| 1330 | - if ( !empty($attributeToSet) ) { |
|
| 1331 | - $attributeToSet = apply_filters( 'save_attribute_for_entity', $attributeToSet, $entityTypeId, $entityId ); |
|
| 1330 | + if (!empty($attributeToSet)) { |
|
| 1331 | + $attributeToSet = apply_filters('save_attribute_for_entity', $attributeToSet, $entityTypeId, $entityId); |
|
| 1332 | 1332 | $old_attribute_to_set = $attributeToSet; |
| 1333 | 1333 | $attribute_setted = array(); |
| 1334 | 1334 | foreach ($attributeToSet as $attributeType => $attributeTypeDetails) { |
@@ -1337,39 +1337,39 @@ discard block |
||
| 1337 | 1337 | 'entity_id' => $entityId, |
| 1338 | 1338 | 'entity_type_id' => $entityTypeId |
| 1339 | 1339 | ); |
| 1340 | - if ( WPSHOP_ATTRIBUTE_VALUE_PER_USER ) { |
|
| 1340 | + if (WPSHOP_ATTRIBUTE_VALUE_PER_USER) { |
|
| 1341 | 1341 | $delete_current_attribute_values_params['user_id'] = $user_id; |
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | - if(!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) { |
|
| 1345 | - $attributeTypeDetails = apply_filters( "save_attribute_for_entity_{$attributeType}", $attributeTypeDetails, $entityTypeId, $entityId ); |
|
| 1346 | - foreach($attributeTypeDetails as $attribute_code => $attributeValue) { |
|
| 1347 | - $attributeValue = apply_filters( "save_attribute_for_entity_{$attributeType}_{$attribute_code}", apply_filters( "save_attribute_for_entity__{$attribute_code}", $attributeValue, $entityTypeId, $entityId ), $entityTypeId, $entityId ); |
|
| 1344 | + if (!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) { |
|
| 1345 | + $attributeTypeDetails = apply_filters("save_attribute_for_entity_{$attributeType}", $attributeTypeDetails, $entityTypeId, $entityId); |
|
| 1346 | + foreach ($attributeTypeDetails as $attribute_code => $attributeValue) { |
|
| 1347 | + $attributeValue = apply_filters("save_attribute_for_entity_{$attributeType}_{$attribute_code}", apply_filters("save_attribute_for_entity__{$attribute_code}", $attributeValue, $entityTypeId, $entityId), $entityTypeId, $entityId); |
|
| 1348 | 1348 | $old_attribute_value = $attributeValue; |
| 1349 | 1349 | |
| 1350 | - if ( $attributeType == 'decimal' ) { |
|
| 1350 | + if ($attributeType == 'decimal') { |
|
| 1351 | 1351 | $attributeValue = str_replace(',', '.', $attributeValue); |
| 1352 | 1352 | } |
| 1353 | - if ( ($attributeType == 'integer') && !is_array($attributeValue) ) { |
|
| 1353 | + if (($attributeType == 'integer') && !is_array($attributeValue)) { |
|
| 1354 | 1354 | $attributeValue = (int)$attributeValue; |
| 1355 | 1355 | } |
| 1356 | 1356 | $more_query_params_values = array(); |
| 1357 | - if($attribute_code != 'unit') { |
|
| 1357 | + if ($attribute_code != 'unit') { |
|
| 1358 | 1358 | |
| 1359 | 1359 | $unit_id = 0; |
| 1360 | - if(isset($attributeTypeDetails['unit'][$attribute_code])){ |
|
| 1360 | + if (isset($attributeTypeDetails['unit'][$attribute_code])) { |
|
| 1361 | 1361 | $unit_id = $attributeTypeDetails['unit'][$attribute_code]; |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | $currentAttribute = self::getElement($attribute_code, "'valid'", 'code'); |
| 1365 | - if( !empty($currentAttribute) ){ |
|
| 1365 | + if (!empty($currentAttribute)) { |
|
| 1366 | 1366 | $sent_attribute_list[] = $currentAttribute->id; |
| 1367 | 1367 | |
| 1368 | 1368 | /* Enregistrement de la valeur actuelle de l'attribut dans la table d'historique si l'option historique est activee sur l'attribut courant */ |
| 1369 | - if ( $currentAttribute->is_historisable == 'yes') { |
|
| 1369 | + if ($currentAttribute->is_historisable == 'yes') { |
|
| 1370 | 1370 | $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); |
| 1371 | 1371 | $attribute_histo = $wpdb->get_results($query); |
| 1372 | - if(!empty($attribute_histo)){ |
|
| 1372 | + if (!empty($attribute_histo)) { |
|
| 1373 | 1373 | $attribute_histo_content['status'] = 'valid'; |
| 1374 | 1374 | $attribute_histo_content['creation_date'] = current_time('mysql', 0); |
| 1375 | 1375 | $attribute_histo_content['creation_date_value'] = $attribute_histo[0]->creation_date_value; |
@@ -1387,8 +1387,8 @@ discard block |
||
| 1387 | 1387 | } |
| 1388 | 1388 | $attributeValue = str_replace("\\", "", $attributeValue); |
| 1389 | 1389 | |
| 1390 | - if ( empty($from) || (!empty($attributeValue)) ) { |
|
| 1391 | - $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id))); |
|
| 1390 | + if (empty($from) || (!empty($attributeValue))) { |
|
| 1391 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id))); |
|
| 1392 | 1392 | |
| 1393 | 1393 | /** Insertion de la nouvelle valeur de l'attribut dans la base */ |
| 1394 | 1394 | $query_params = array( |
@@ -1402,66 +1402,66 @@ discard block |
||
| 1402 | 1402 | 'creation_date_value' => current_time('mysql', 0) |
| 1403 | 1403 | ); |
| 1404 | 1404 | /** Si l'attribut courant est contenu dans un tableau (exemple: select multiple) on lit tout le tableau et on enregistre chaque valeur separement */ |
| 1405 | - if(is_array($attributeValue)){ |
|
| 1406 | - foreach($attributeValue as $a){ |
|
| 1407 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a))); |
|
| 1405 | + if (is_array($attributeValue)) { |
|
| 1406 | + foreach ($attributeValue as $a) { |
|
| 1407 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $a))); |
|
| 1408 | 1408 | } |
| 1409 | 1409 | } |
| 1410 | - else{ |
|
| 1411 | - $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue))); |
|
| 1412 | - wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array( |
|
| 1410 | + else { |
|
| 1411 | + $wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $attributeValue))); |
|
| 1412 | + wpeologs_ctr::log_datas_in_files('wpshop_attributes', array( |
|
| 1413 | 1413 | 'object_id' => $entityId, |
| 1414 | - 'message' => __( 'Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue , 'wpshop' ) ), 0 |
|
| 1414 | + 'message' => __('Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue, 'wpshop') ), 0 |
|
| 1415 | 1415 | ); |
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | 1418 | /** 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 */ |
| 1419 | - if ( ( ($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ( $currentAttribute->is_filterable == 'yes') && !empty($attributeValue) ) : |
|
| 1420 | - update_post_meta($entityId, '_'.$attribute_code, $attributeValue); |
|
| 1419 | + if ((($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ($currentAttribute->is_filterable == 'yes') && !empty($attributeValue)) : |
|
| 1420 | + update_post_meta($entityId, '_' . $attribute_code, $attributeValue); |
|
| 1421 | 1421 | endif; |
| 1422 | 1422 | |
| 1423 | 1423 | /** Enregistrement de toutes les valeurs des attributs dans une meta du produit */ |
| 1424 | - $attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array) $_POST['attribute_option'][$attribute_code] : null; |
|
| 1424 | + $attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array)$_POST['attribute_option'][$attribute_code] : null; |
|
| 1425 | 1425 | if (isset($attribute_option)) { |
| 1426 | 1426 | $value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value'); |
| 1427 | 1427 | if (strtolower($value) == 'yes') : |
| 1428 | - update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option); |
|
| 1428 | + update_post_meta($entityId, 'attribute_option_' . $attribute_code, $attribute_option); |
|
| 1429 | 1429 | else : |
| 1430 | - delete_post_meta($entityId, 'attribute_option_'.$attribute_code); |
|
| 1430 | + delete_post_meta($entityId, 'attribute_option_' . $attribute_code); |
|
| 1431 | 1431 | endif; |
| 1432 | 1432 | } |
| 1433 | 1433 | } |
| 1434 | 1434 | } |
| 1435 | 1435 | } |
| 1436 | - do_action( "saved_attribute_for_entity_{$attributeType}_{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId ); |
|
| 1437 | - do_action( "saved_attribute_for_entity__{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId ); |
|
| 1438 | - if ( isset( $attribute_setted[$attributeType][$attribute_code] ) ) { |
|
| 1439 | - if( is_array( $attribute_setted[$attributeType][$attribute_code] )) { |
|
| 1436 | + do_action("saved_attribute_for_entity_{$attributeType}_{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId); |
|
| 1437 | + do_action("saved_attribute_for_entity__{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId); |
|
| 1438 | + if (isset($attribute_setted[$attributeType][$attribute_code])) { |
|
| 1439 | + if (is_array($attribute_setted[$attributeType][$attribute_code])) { |
|
| 1440 | 1440 | $attribute_setted[$attributeType][$attribute_code][] = $attributeValue; |
| 1441 | 1441 | } else { |
| 1442 | - $attribute_setted[$attributeType][$attribute_code] = array( $attribute_setted[$attributeType][$attribute_code], $attributeValue ); |
|
| 1442 | + $attribute_setted[$attributeType][$attribute_code] = array($attribute_setted[$attributeType][$attribute_code], $attributeValue); |
|
| 1443 | 1443 | } |
| 1444 | 1444 | } else { |
| 1445 | 1445 | $attribute_setted[$attributeType][$attribute_code] = $attributeValue; |
| 1446 | 1446 | } |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | - if ( empty($from) ) { |
|
| 1450 | - $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); |
|
| 1449 | + if (empty($from)) { |
|
| 1450 | + $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); |
|
| 1451 | 1451 | $attr_to_delete = $wpdb->get_results($query); |
| 1452 | - if(!empty($attr_to_delete)){ |
|
| 1452 | + if (!empty($attr_to_delete)) { |
|
| 1453 | 1453 | foreach ($attr_to_delete as $value) { |
| 1454 | - $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id))); |
|
| 1455 | - wpeologs_ctr::log_datas_in_files( 'wpshop_attributes', array( |
|
| 1454 | + $wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id))); |
|
| 1455 | + wpeologs_ctr::log_datas_in_files('wpshop_attributes', array( |
|
| 1456 | 1456 | 'object_id' => $entityId, |
| 1457 | - 'message' => __( 'Remove the attribute : ' . $value->value_id, 'wpshop' ) ), 0 |
|
| 1457 | + 'message' => __('Remove the attribute : ' . $value->value_id, 'wpshop') ), 0 |
|
| 1458 | 1458 | ); |
| 1459 | 1459 | } |
| 1460 | 1460 | } |
| 1461 | 1461 | } |
| 1462 | 1462 | } |
| 1463 | 1463 | } |
| 1464 | - do_action( "saved_attribute_for_entity", $attribute_setted, $old_attribute_to_set, $entityTypeId, $entityId ); |
|
| 1464 | + do_action("saved_attribute_for_entity", $attribute_setted, $old_attribute_to_set, $entityTypeId, $entityId); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | } |
| 1467 | 1467 | |
@@ -1481,7 +1481,7 @@ discard block |
||
| 1481 | 1481 | |
| 1482 | 1482 | $query_params = ""; |
| 1483 | 1483 | $query_params_values = array($attributeId, $entityTypeId, $entityId); |
| 1484 | - if(WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))){ |
|
| 1484 | + if (WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))) { |
|
| 1485 | 1485 | $query_params = " |
| 1486 | 1486 | AND ATTR_VAL.user_id = %d"; |
| 1487 | 1487 | $query_params_values[] = get_current_user_id(); |
@@ -1497,20 +1497,20 @@ discard block |
||
| 1497 | 1497 | ); |
| 1498 | 1498 | $attributeValue = $wpdb->get_results($query); |
| 1499 | 1499 | |
| 1500 | - if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) { |
|
| 1500 | + if (((count($attributeValue) <= 1) && !empty($attributeValue[0])) && (empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select'))) { |
|
| 1501 | 1501 | $attributeValue = $attributeValue[0]; |
| 1502 | 1502 | } |
| 1503 | - else{ |
|
| 1503 | + else { |
|
| 1504 | 1504 | $entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true); |
| 1505 | - if ( !empty($entity_meta) ) { |
|
| 1505 | + if (!empty($entity_meta)) { |
|
| 1506 | 1506 | $query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId); |
| 1507 | 1507 | $attribute_code = $wpdb->get_var($query); |
| 1508 | 1508 | $attributeValue = !empty($entity_meta[$attribute_code]) ? $entity_meta[$attribute_code] : null; |
| 1509 | 1509 | } |
| 1510 | - if ( is_array($attributeValue) ) { |
|
| 1510 | + if (is_array($attributeValue)) { |
|
| 1511 | 1511 | $tmp_array = array(); |
| 1512 | - if ( !empty($attributeValue) ) { |
|
| 1513 | - foreach ( $attributeValue as $att ) { |
|
| 1512 | + if (!empty($attributeValue)) { |
|
| 1513 | + foreach ($attributeValue as $att) { |
|
| 1514 | 1514 | $obj = new stdClass(); |
| 1515 | 1515 | $obj->value = $att; |
| 1516 | 1516 | $obj->unit_id = 0; |
@@ -1541,9 +1541,9 @@ discard block |
||
| 1541 | 1541 | $elements = array(); |
| 1542 | 1542 | $elementsWithAttributeAndValues = self::get_attribute_list_for_item($entityId, $elementId, $language); |
| 1543 | 1543 | |
| 1544 | - foreach ( $elementsWithAttributeAndValues as $elementDefinition ) { |
|
| 1544 | + foreach ($elementsWithAttributeAndValues as $elementDefinition) { |
|
| 1545 | 1545 | $arrayKey = $elementDefinition->attribute_id; |
| 1546 | - if ( $keyForArray == 'code' ) { |
|
| 1546 | + if ($keyForArray == 'code') { |
|
| 1547 | 1547 | $arrayKey = $elementDefinition->attribute_code; |
| 1548 | 1548 | } |
| 1549 | 1549 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['code'] = $elementDefinition->attribute_set_section_code; |
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_table'] = $elementDefinition->backend_table; |
| 1554 | 1554 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_input'] = $elementDefinition->backend_input; |
| 1555 | 1555 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_input'] = $elementDefinition->frontend_input; |
| 1556 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __( $elementDefinition->frontend_label, 'wpshop' ); |
|
| 1556 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __($elementDefinition->frontend_label, 'wpshop'); |
|
| 1557 | 1557 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['attribute_code'] = $elementDefinition->attribute_code; |
| 1558 | 1558 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['data_type_to_use'] = $elementDefinition->data_type_to_use; |
| 1559 | 1559 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['is_visible_in_front'] = $elementDefinition->is_visible_in_front; |
@@ -1563,29 +1563,29 @@ discard block |
||
| 1563 | 1563 | $attributeValueField = 'attribute_value_' . $elementDefinition->data_type; |
| 1564 | 1564 | |
| 1565 | 1565 | // Manage the value differently if it is an array or not |
| 1566 | - if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) { |
|
| 1566 | + if (!empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
|
| 1567 | 1567 | if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) { |
| 1568 | 1568 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField; |
| 1569 | 1569 | } |
| 1570 | 1570 | else { |
| 1571 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField); |
|
| 1571 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'], $elementDefinition->$attributeValueField); |
|
| 1572 | 1572 | } |
| 1573 | 1573 | } |
| 1574 | 1574 | else { |
| 1575 | 1575 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField; |
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | - if ( $elementDefinition->backend_input == 'multiple-select' ) { |
|
| 1578 | + if ($elementDefinition->backend_input == 'multiple-select') { |
|
| 1579 | 1579 | $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['select_value'] = self::get_attribute_type_select_option_info($attributeValueField, 'value'); |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | 1582 | $attributeUnitField = 'attribute_unit_' . $elementDefinition->data_type; |
| 1583 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $elementDefinition->$attributeUnitField, 'wpshop' ); |
|
| 1584 | - if( !empty($elementDefinition->is_requiring_unit ) && ( $elementDefinition->is_requiring_unit == 'yes' ) && empty( $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] ) ) { |
|
| 1583 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($elementDefinition->$attributeUnitField, 'wpshop'); |
|
| 1584 | + if (!empty($elementDefinition->is_requiring_unit) && ($elementDefinition->is_requiring_unit == 'yes') && empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'])) { |
|
| 1585 | 1585 | $unit = ''; |
| 1586 | - $query = $wpdb->prepare( 'SELECT unit FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid'); |
|
| 1587 | - $unit = $wpdb->get_var( $query ); |
|
| 1588 | - $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $unit, 'wpshop' ); |
|
| 1586 | + $query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid'); |
|
| 1587 | + $unit = $wpdb->get_var($query); |
|
| 1588 | + $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($unit, 'wpshop'); |
|
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | 1591 | } |
@@ -1597,7 +1597,7 @@ discard block |
||
| 1597 | 1597 | $elementsWithAttributeAndValues = array(); |
| 1598 | 1598 | $moreQuery = ""; |
| 1599 | 1599 | |
| 1600 | - $entity_type = empty($defined_entity_type) ? get_post_type( $elementId ) : $defined_entity_type; |
|
| 1600 | + $entity_type = empty($defined_entity_type) ? get_post_type($elementId) : $defined_entity_type; |
|
| 1601 | 1601 | |
| 1602 | 1602 | $query = $wpdb->prepare( |
| 1603 | 1603 | "SELECT POST_META.*, |
@@ -1646,23 +1646,23 @@ discard block |
||
| 1646 | 1646 | * |
| 1647 | 1647 | * @return boolean The result to know if the element has to be displayed on frontend |
| 1648 | 1648 | */ |
| 1649 | - public static function check_attribute_display( $attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) { |
|
| 1650 | - if ( $attribute_main_config === 'yes' ) { |
|
| 1649 | + public static function check_attribute_display($attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) { |
|
| 1650 | + if ($attribute_main_config === 'yes') { |
|
| 1651 | 1651 | $attribute_output = true; |
| 1652 | - 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' ) |
|
| 1653 | - || empty($attribute_custom_config) ) { |
|
| 1652 | + 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') |
|
| 1653 | + || empty($attribute_custom_config)) { |
|
| 1654 | 1654 | $attribute_output = true; |
| 1655 | 1655 | } |
| 1656 | - 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')) ) { |
|
| 1656 | + 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'))) { |
|
| 1657 | 1657 | $attribute_output = false; |
| 1658 | 1658 | } |
| 1659 | 1659 | } |
| 1660 | - elseif ( $attribute_main_config === 'no' ) { |
|
| 1660 | + elseif ($attribute_main_config === 'no') { |
|
| 1661 | 1661 | $attribute_output = false; |
| 1662 | - if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) { |
|
| 1662 | + if (empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code])) { |
|
| 1663 | 1663 | $attribute_output = false; |
| 1664 | 1664 | } |
| 1665 | - 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') ) { |
|
| 1665 | + 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')) { |
|
| 1666 | 1666 | $attribute_output = true; |
| 1667 | 1667 | } |
| 1668 | 1668 | } |
@@ -1679,22 +1679,22 @@ discard block |
||
| 1679 | 1679 | global $wpdb; |
| 1680 | 1680 | global $wp_query; |
| 1681 | 1681 | |
| 1682 | - $attribute = self::getElement( $atts['attid'] ); |
|
| 1683 | - if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1684 | - $attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
|
| 1685 | - $output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output'; |
|
| 1682 | + $attribute = self::getElement($atts['attid']); |
|
| 1683 | + if (empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID; |
|
| 1684 | + $attribute_main_config = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing; |
|
| 1685 | + $output_type = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? 'complete_sheet' : 'mini_output'; |
|
| 1686 | 1686 | $product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true); |
| 1687 | - $display_attribute_value = wpshop_attributes::check_attribute_display( $attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type); |
|
| 1687 | + $display_attribute_value = wpshop_attributes::check_attribute_display($attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type); |
|
| 1688 | 1688 | |
| 1689 | - if ( !empty( $attribute->data_type ) ) { |
|
| 1689 | + if (!empty($attribute->data_type)) { |
|
| 1690 | 1690 | $attributeDefinition['unit'] = ''; |
| 1691 | 1691 | |
| 1692 | 1692 | $has_value = false; |
| 1693 | - $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'] ); |
|
| 1694 | - if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) ) { |
|
| 1693 | + $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']); |
|
| 1694 | + if (in_array($attribute->backend_input, array('multiple-select', 'checkbox'))) { |
|
| 1695 | 1695 | $list_of_value = $wpdb->get_results($query); |
| 1696 | - if ( !empty($list_of_value) ) { |
|
| 1697 | - foreach ( $list_of_value as $value ) { |
|
| 1696 | + if (!empty($list_of_value)) { |
|
| 1697 | + foreach ($list_of_value as $value) { |
|
| 1698 | 1698 | $data[] = $value->value; |
| 1699 | 1699 | } |
| 1700 | 1700 | $has_value = true; |
@@ -1702,10 +1702,10 @@ discard block |
||
| 1702 | 1702 | } |
| 1703 | 1703 | else { |
| 1704 | 1704 | $data = $wpdb->get_var($query); |
| 1705 | - if ( !empty($data) ) { |
|
| 1705 | + if (!empty($data)) { |
|
| 1706 | 1706 | $has_value = true; |
| 1707 | 1707 | } |
| 1708 | - elseif( !empty($attribute->default_value) ) { |
|
| 1708 | + elseif (!empty($attribute->default_value)) { |
|
| 1709 | 1709 | $has_value = true; |
| 1710 | 1710 | $data = $attribute->default_value; |
| 1711 | 1711 | } |
@@ -1717,7 +1717,7 @@ discard block |
||
| 1717 | 1717 | $attributeDefinition['is_requiring_unit'] = $attribute->is_requiring_unit; |
| 1718 | 1718 | $attributeDefinition['backend_input'] = $attribute->backend_input; |
| 1719 | 1719 | $attributeDefinition['data_type_to_use'] = $attribute->data_type_to_use; |
| 1720 | - $attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition ); |
|
| 1720 | + $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); |
|
| 1721 | 1721 | $attribute_value = $attribute_display[0]; |
| 1722 | 1722 | $attributeDefinition['value'] = $attribute_display[1]; |
| 1723 | 1723 | $attribute_unit_list = $attribute_display[2]; |
@@ -1737,13 +1737,13 @@ discard block |
||
| 1737 | 1737 | * @param array $specific_argument Optionnal The different parameters used for filter output |
| 1738 | 1738 | * @return array The definition for the field used to display an attribute |
| 1739 | 1739 | */ |
| 1740 | - public static function get_attribute_field_definition( $attribute, $attribute_value = '', $specific_argument = array() ) { |
|
| 1740 | + public static function get_attribute_field_definition($attribute, $attribute_value = '', $specific_argument = array()) { |
|
| 1741 | 1741 | global $wpdb; |
| 1742 | 1742 | $wpshop_price_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES); |
| 1743 | 1743 | $wpshop_weight_attributes = unserialize(WPSHOP_ATTRIBUTE_WEIGHT); |
| 1744 | 1744 | $input_def = array(); |
| 1745 | 1745 | $input_def['option'] = $input_def['field_container_class'] = ''; |
| 1746 | - $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 . ']'); |
|
| 1746 | + $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 . ']'); |
|
| 1747 | 1747 | $input_def['input_domain'] = $attributeInputDomain; |
| 1748 | 1748 | $input_def['id'] = (!empty($specific_argument) && !empty($specific_argument['field_id']) ? $specific_argument['field_id'] . '_' : '') . 'attribute_' . $attribute->id; |
| 1749 | 1749 | $input_def['intrinsec'] = $attribute->is_intrinsic; |
@@ -1763,26 +1763,26 @@ discard block |
||
| 1763 | 1763 | $input_def['frontend_type'] = $attribute->frontend_input; |
| 1764 | 1764 | $input_def['is_used_in_quick_add_form'] = $attribute->is_used_in_quick_add_form; |
| 1765 | 1765 | |
| 1766 | - if ( !empty($attribute_value) && !is_object($attribute_value) ) { |
|
| 1766 | + if (!empty($attribute_value) && !is_object($attribute_value)) { |
|
| 1767 | 1767 | $input_def['value'] = $attribute_value; |
| 1768 | 1768 | } |
| 1769 | - else if ( !empty($attribute_value->value) ) { |
|
| 1769 | + else if (!empty($attribute_value->value)) { |
|
| 1770 | 1770 | $input_def['value'] = stripslashes($attribute_value->value); |
| 1771 | 1771 | } |
| 1772 | - else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) { |
|
| 1772 | + else if (!empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft')) { |
|
| 1773 | 1773 | $input_def['value'] = ''; |
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | 1776 | $input_def['options'] = ''; |
| 1777 | 1777 | $input_more_class = !empty($specific_argument['input_class']) ? $specific_argument['input_class'] : ''; |
| 1778 | 1778 | if ($attribute->data_type == 'datetime') { |
| 1779 | - $date_config = unserialize( $attribute->default_value ); |
|
| 1779 | + $date_config = unserialize($attribute->default_value); |
|
| 1780 | 1780 | if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) { |
| 1781 | 1781 | $input_def['value'] = date('Y-m-d'); |
| 1782 | 1782 | } |
| 1783 | 1783 | else { |
| 1784 | 1784 | /** Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/ */ |
| 1785 | - $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 ) : '' ); |
|
| 1785 | + $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) : ''); |
|
| 1786 | 1786 | } |
| 1787 | 1787 | $input_more_class .= ' wpshop_input_datetime '; |
| 1788 | 1788 | $field_script = '<script type="text/javascript" > |
@@ -1795,31 +1795,31 @@ discard block |
||
| 1795 | 1795 | wpshop("#' . $input_def['id'] . '").datepicker("option", "navigationAsDateFormat", true); |
| 1796 | 1796 | wpshop("#' . $input_def['id'] . '").val("' . str_replace(" 00:00:00", "", $input_def['value']) . '");'; |
| 1797 | 1797 | |
| 1798 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']) ) { |
|
| 1799 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ) { |
|
| 1798 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur'])) { |
|
| 1799 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0])) { |
|
| 1800 | 1800 | $field_script .= ' |
| 1801 | 1801 | wpshop("#' . $input_def['id'] . '").datepicker("option", "minDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] . '");'; |
| 1802 | 1802 | } |
| 1803 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ) { |
|
| 1803 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0])) { |
|
| 1804 | 1804 | $field_script .= ' |
| 1805 | 1805 | wpshop("#' . $input_def['id'] . '").datepicker("option", "maxDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] . '");'; |
| 1806 | 1806 | } |
| 1807 | 1807 | } |
| 1808 | 1808 | |
| 1809 | 1809 | $script_options = $script_options_params = array(); |
| 1810 | - if ( !empty($date_config['field_options']['attribute_type_date_options_day_to_show']) ) { |
|
| 1810 | + if (!empty($date_config['field_options']['attribute_type_date_options_day_to_show'])) { |
|
| 1811 | 1811 | $day_to_show_list = ' '; |
| 1812 | - foreach ( $date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show ) { |
|
| 1812 | + foreach ($date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show) { |
|
| 1813 | 1813 | $day_to_show_list .= '(date.getDay() == ' . $day_to_show . ') || '; |
| 1814 | 1814 | } |
| 1815 | 1815 | $script_options[] = '( ' . substr($day_to_show_list, 0, -4) . ' )'; |
| 1816 | 1816 | } |
| 1817 | 1817 | |
| 1818 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0]) ) { |
|
| 1819 | - if ( !empty($date_config['field_options']['attribute_type_date_options_available_date']) ) { |
|
| 1818 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0])) { |
|
| 1819 | + if (!empty($date_config['field_options']['attribute_type_date_options_available_date'])) { |
|
| 1820 | 1820 | $available_date = ' '; |
| 1821 | - foreach ( $date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list ) { |
|
| 1822 | - if ( !empty($avalaible_date_list) ) { |
|
| 1821 | + foreach ($date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list) { |
|
| 1822 | + if (!empty($avalaible_date_list)) { |
|
| 1823 | 1823 | $available_date .= '"' . $avalaible_date_list . '",'; |
| 1824 | 1824 | } |
| 1825 | 1825 | } |
@@ -1828,7 +1828,7 @@ discard block |
||
| 1828 | 1828 | } |
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | - if ( !empty( $script_options ) ) { |
|
| 1831 | + if (!empty($script_options)) { |
|
| 1832 | 1832 | $field_script .= ' |
| 1833 | 1833 | wpshop("#' . $input_def['id'] . '").datepicker("option", "beforeShowDay", function(date){ |
| 1834 | 1834 | ' . implode(' ', $script_options_params) . '; |
@@ -1856,37 +1856,37 @@ discard block |
||
| 1856 | 1856 | </script>'; |
| 1857 | 1857 | $input_def['options'] .= $field_script; |
| 1858 | 1858 | } |
| 1859 | - if ( in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 1860 | - $input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select ' ); |
|
| 1859 | + if (in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 1860 | + $input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select '); |
|
| 1861 | 1861 | $input_def['type'] = ((!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend')) || (!is_admin() && empty($specific_argument['from'])) ? $attribute->frontend_input : $attribute->backend_input); |
| 1862 | 1862 | $input_def['valueToPut'] = 'index'; |
| 1863 | 1863 | |
| 1864 | 1864 | $select_display = self::get_select_output($attribute, $specific_argument); |
| 1865 | - if ( empty( $input_def[ 'options_label' ] ) && !empty( $specific_argument ) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend') ) ) { |
|
| 1866 | - $input_def[ 'options_label' ][ 'original' ] = true; |
|
| 1865 | + if (empty($input_def['options_label']) && !empty($specific_argument) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend'))) { |
|
| 1866 | + $input_def['options_label']['original'] = true; |
|
| 1867 | 1867 | } |
| 1868 | 1868 | $input_def['options'] .= $select_display['more_input']; |
| 1869 | 1869 | $input_def['possible_value'] = (!empty($select_display) && !empty($select_display['possible_value'])) ? $select_display['possible_value'] : ''; |
| 1870 | - if ( !is_admin() ) { |
|
| 1870 | + if (!is_admin()) { |
|
| 1871 | 1871 | $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" />'; |
| 1872 | 1872 | } |
| 1873 | - if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) { |
|
| 1874 | - $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'); |
|
| 1873 | + if (in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) { |
|
| 1874 | + $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'); |
|
| 1875 | 1875 | } |
| 1876 | 1876 | } |
| 1877 | 1877 | $input_def['label_pointer'] = 'for="' . $input_def['id'] . '"'; |
| 1878 | - if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){ |
|
| 1878 | + if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) { |
|
| 1879 | 1879 | $input_def['label_pointer'] = ''; |
| 1880 | 1880 | } |
| 1881 | 1881 | |
| 1882 | 1882 | /* |
| 1883 | 1883 | * Specifc treatment for price attributes |
| 1884 | 1884 | */ |
| 1885 | - if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){ |
|
| 1885 | + if ((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC)) { |
|
| 1886 | 1886 | $input_def['option'] .= ' readonly="readonly" '; |
| 1887 | 1887 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1888 | 1888 | } |
| 1889 | - elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){ |
|
| 1889 | + elseif ((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT)) { |
|
| 1890 | 1890 | $input_def['option'] .= ' readonly="readonly" '; |
| 1891 | 1891 | $input_more_class .= ' wpshop_prices_readonly'; |
| 1892 | 1892 | } |
@@ -1897,7 +1897,7 @@ discard block |
||
| 1897 | 1897 | |
| 1898 | 1898 | $input_def['label'] = str_replace("\\", "", $input_def['label']); |
| 1899 | 1899 | // $input_def['value'] = str_replace("\\", "", $input_def['value']); |
| 1900 | - $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 : '' ) . '" '; |
|
| 1900 | + $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 : '') . '" '; |
|
| 1901 | 1901 | $input_def['title'] = !empty($attribute->frontend_help_message) ? ' title="' . $attribute->frontend_help_message . '" ' : ''; |
| 1902 | 1902 | |
| 1903 | 1903 | if (($attribute->is_intrinsic == 'yes') && ((!empty($input_def['value'])) || ($input_def['value'] > 0))) { |
@@ -1908,13 +1908,13 @@ discard block |
||
| 1908 | 1908 | * Add the unit to the attribute if attribute configuration is set to yes |
| 1909 | 1909 | */ |
| 1910 | 1910 | if ($attribute->is_requiring_unit == 'yes') { |
| 1911 | - if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) { |
|
| 1911 | + if (in_array($attribute->code, $wpshop_price_attributes) || (WPSHOP_COST_OF_POSTAGE == $attribute->code)) { |
|
| 1912 | 1912 | $input_def['options'] .= ' <span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>'; |
| 1913 | 1913 | } |
| 1914 | - elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) { |
|
| 1914 | + elseif (in_array($attribute->code, $wpshop_weight_attributes)) { |
|
| 1915 | 1915 | $weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity'); |
| 1916 | - $query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
| 1917 | - $unity = $wpdb->get_var( $query ); |
|
| 1916 | + $query = $wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option); |
|
| 1917 | + $unity = $wpdb->get_var($query); |
|
| 1918 | 1918 | $input_def['options'] .= ' <span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>'; |
| 1919 | 1919 | } |
| 1920 | 1920 | else { |
@@ -1922,11 +1922,11 @@ discard block |
||
| 1922 | 1922 | $unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id); |
| 1923 | 1923 | $unit_input_def['type'] = 'select'; |
| 1924 | 1924 | $unit_input_def['option'] = ' class="wpshop_attribute_unit_input chosen_select" '; |
| 1925 | - $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; |
|
| 1925 | + $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; |
|
| 1926 | 1926 | $unit_input_def['name'] = $attribute->code; |
| 1927 | 1927 | $unit_input_def['value'] = (!empty($attribute_value->unit_id) ? $attribute_value->unit_id : ''); |
| 1928 | - if($unit_input_def['value'] == ''){ |
|
| 1929 | - if ( $attribute->_default_unit > 0 ) { |
|
| 1928 | + if ($unit_input_def['value'] == '') { |
|
| 1929 | + if ($attribute->_default_unit > 0) { |
|
| 1930 | 1930 | $unit_input_def['value'] = $attribute->_default_unit; |
| 1931 | 1931 | } |
| 1932 | 1932 | else { |
@@ -1940,18 +1940,18 @@ discard block |
||
| 1940 | 1940 | /* |
| 1941 | 1941 | * Add indication on postage cost tax |
| 1942 | 1942 | */ |
| 1943 | - if ( $attribute->code == WPSHOP_COST_OF_POSTAGE ) { |
|
| 1943 | + if ($attribute->code == WPSHOP_COST_OF_POSTAGE) { |
|
| 1944 | 1944 | $input_def['options'] .= ' <span class="attribute_currency" >' . __('ATI', 'wpshop') . '</span>'; |
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | 1947 | /* |
| 1948 | 1948 | * Create the field output |
| 1949 | 1949 | */ |
| 1950 | - if ( is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) { |
|
| 1951 | - $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')); |
|
| 1950 | + if (is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) { |
|
| 1951 | + $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')); |
|
| 1952 | 1952 | $input_def['options'] = ''; |
| 1953 | 1953 | $input_def['label_pointer'] = ''; |
| 1954 | - $input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "'; |
|
| 1954 | + $input_def['option'] = substr($input_def['option'], 0, -2) . ' wpshop_attributes_is_user_defined_admin_field "'; |
|
| 1955 | 1955 | $input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container'; |
| 1956 | 1956 | } |
| 1957 | 1957 | else { |
@@ -1966,7 +1966,7 @@ discard block |
||
| 1966 | 1966 | * @param string $output_from |
| 1967 | 1967 | * @return string The output for |
| 1968 | 1968 | */ |
| 1969 | - public static function display_attribute( $attribute_code, $output_from = 'admin', $output_specs = array() ) { |
|
| 1969 | + public static function display_attribute($attribute_code, $output_from = 'admin', $output_specs = array()) { |
|
| 1970 | 1970 | $output = ''; |
| 1971 | 1971 | /* Get the page code */ |
| 1972 | 1972 | $currentPageCode = !empty($output_specs['page_code']) ? $output_specs['page_code'] : ''; |
@@ -1977,17 +1977,17 @@ discard block |
||
| 1977 | 1977 | |
| 1978 | 1978 | /* Get attribute input definition */ |
| 1979 | 1979 | $current_value = (!empty($output_specs['current_value']) ? $output_specs['current_value'] : ''); |
| 1980 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from)) ); |
|
| 1980 | + $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from))); |
|
| 1981 | 1981 | |
| 1982 | 1982 | /* Create default output */ |
| 1983 | 1983 | $input_to_display = $input['output'] . $input['options']; |
| 1984 | 1984 | |
| 1985 | 1985 | /* Check if current field is linked to an addon, and if the addon is activated */ |
| 1986 | 1986 | $addons_list = unserialize(WPSHOP_ADDONS_LIST); |
| 1987 | - foreach ( $addons_list as $addon_code => $addon_def ) { |
|
| 1988 | - if ( in_array($attribute_code, $addon_def) ) { |
|
| 1989 | - if ( constant($addon_code) === false ) { |
|
| 1990 | - $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>'; |
|
| 1987 | + foreach ($addons_list as $addon_code => $addon_def) { |
|
| 1988 | + if (in_array($attribute_code, $addon_def)) { |
|
| 1989 | + if (constant($addon_code) === false) { |
|
| 1990 | + $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>'; |
|
| 1991 | 1991 | } |
| 1992 | 1992 | } |
| 1993 | 1993 | } |
@@ -2012,11 +2012,11 @@ discard block |
||
| 2012 | 2012 | /* |
| 2013 | 2013 | * Display attribute option if applicable |
| 2014 | 2014 | */ |
| 2015 | - if ( $output_from == 'admin') { |
|
| 2016 | - $attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop') ) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 2015 | + if ($output_from == 'admin') { |
|
| 2016 | + $attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide'; |
|
| 2017 | 2017 | |
| 2018 | 2018 | $output['field'] .= ' |
| 2019 | - <div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($element_identifier, $attribute_def->code).'</div>'; |
|
| 2019 | + <div class="attribute_option_'.$attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($element_identifier, $attribute_def->code) . '</div>'; |
|
| 2020 | 2020 | } |
| 2021 | 2021 | |
| 2022 | 2022 | $output['field'] .= '</div>'; |
@@ -2034,36 +2034,36 @@ discard block |
||
| 2034 | 2034 | * |
| 2035 | 2035 | * @return string The html code to output directly tabs |
| 2036 | 2036 | */ |
| 2037 | - public static function attribute_of_entity_to_tab( $element_code, $element_id, $element_definition ) { |
|
| 2037 | + public static function attribute_of_entity_to_tab($element_code, $element_id, $element_definition) { |
|
| 2038 | 2038 | $attributeContentOutput = ''; |
| 2039 | 2039 | |
| 2040 | 2040 | /** Get the different attribute affected to the entity */ |
| 2041 | 2041 | $element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue($element_code, $element_id, WPSHOP_CURRENT_LOCALE, '', 'frontend'); |
| 2042 | 2042 | |
| 2043 | 2043 | |
| 2044 | - if ( is_array($element_atribute_list) && (count($element_atribute_list) > 0) ) { |
|
| 2045 | - foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) { |
|
| 2044 | + if (is_array($element_atribute_list) && (count($element_atribute_list) > 0)) { |
|
| 2045 | + foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { |
|
| 2046 | 2046 | $attributeToShowNumber = 0; |
| 2047 | 2047 | $attributeOutput = ''; |
| 2048 | 2048 | |
| 2049 | - foreach ( $attributeSetContent['attributes'] as $attributeId => $attributeDefinition ) { |
|
| 2049 | + foreach ($attributeSetContent['attributes'] as $attributeId => $attributeDefinition) { |
|
| 2050 | 2050 | |
| 2051 | 2051 | /** Check the value type to check if empty or not */ |
| 2052 | - if ( $attributeDefinition['data_type'] == 'int' ) { |
|
| 2052 | + if ($attributeDefinition['data_type'] == 'int') { |
|
| 2053 | 2053 | $attributeDefinition['value'] = (int)$attributeDefinition['value']; |
| 2054 | 2054 | } |
| 2055 | - else if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2055 | + else if ($attributeDefinition['data_type'] == 'decimal') { |
|
| 2056 | 2056 | $attributeDefinition['value'] = (float)$attributeDefinition['value']; |
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | 2059 | /** Check if the attribute is set to be displayed in frontend */ |
| 2060 | - $attribute_display_state = wpshop_attributes::check_attribute_display( $attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); |
|
| 2060 | + $attribute_display_state = wpshop_attributes::check_attribute_display($attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet'); |
|
| 2061 | 2061 | |
| 2062 | 2062 | /** Output the field if the value is not null */ |
| 2063 | 2063 | |
| 2064 | - if ( (is_array($attributeDefinition['value']) || ( !empty($attributeDefinition['value']) ) ) && $attribute_display_state) { |
|
| 2064 | + if ((is_array($attributeDefinition['value']) || (!empty($attributeDefinition['value']))) && $attribute_display_state) { |
|
| 2065 | 2065 | |
| 2066 | - $attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition ); |
|
| 2066 | + $attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition); |
|
| 2067 | 2067 | $attribute_value = $attribute_display[0]; |
| 2068 | 2068 | $attributeDefinition['value'] = $attribute_display[1]; |
| 2069 | 2069 | $attribute_unit_list = $attribute_display[2]; |
@@ -2074,8 +2074,8 @@ discard block |
||
| 2074 | 2074 | $tpl_component['PDT_ENTITY_CODE'] = self::currentPageCode; |
| 2075 | 2075 | $tpl_component['ATTRIBUTE_CODE'] = $attributeDefinition['attribute_code']; |
| 2076 | 2076 | $tpl_component['ATTRIBUTE_LABEL'] = __($attributeDefinition['frontend_label'], 'wpshop'); |
| 2077 | - $tpl_component['ATTRIBUTE_VALUE'] = ( !is_array($attribute_value) ) ? stripslashes($attribute_value) : $attribute_value; |
|
| 2078 | - $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; |
|
| 2077 | + $tpl_component['ATTRIBUTE_VALUE'] = (!is_array($attribute_value)) ? stripslashes($attribute_value) : $attribute_value; |
|
| 2078 | + $tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list; |
|
| 2079 | 2079 | |
| 2080 | 2080 | /** Build template */ |
| 2081 | 2081 | $attributeOutput .= wpshop_display::display_template_element($template_part, $tpl_component); |
@@ -2086,9 +2086,9 @@ discard block |
||
| 2086 | 2086 | } |
| 2087 | 2087 | |
| 2088 | 2088 | /** Check if the attribute set section is set to be displayed in frontend */ |
| 2089 | - $attribute_set_display_state = wpshop_attributes::check_attribute_display( $attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); |
|
| 2089 | + $attribute_set_display_state = wpshop_attributes::check_attribute_display($attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet'); |
|
| 2090 | 2090 | |
| 2091 | - if ( !$attribute_set_display_state ) { |
|
| 2091 | + if (!$attribute_set_display_state) { |
|
| 2092 | 2092 | $attributeToShowNumber = 0; |
| 2093 | 2093 | $attributeOutput = ''; |
| 2094 | 2094 | } |
@@ -2098,8 +2098,8 @@ discard block |
||
| 2098 | 2098 | |
| 2099 | 2099 | /** Gestion de l'affichage */ |
| 2100 | 2100 | $tab_list = $content_list = ''; |
| 2101 | - foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) { |
|
| 2102 | - if ( !empty($attributeSetContent['count']) > 0 ) { |
|
| 2101 | + foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) { |
|
| 2102 | + if (!empty($attributeSetContent['count']) > 0) { |
|
| 2103 | 2103 | /** Template parameters */ |
| 2104 | 2104 | $template_part = 'product_attribute_tabs'; |
| 2105 | 2105 | $tpl_component = array(); |
@@ -2108,7 +2108,7 @@ discard block |
||
| 2108 | 2108 | |
| 2109 | 2109 | /** Build template */ |
| 2110 | 2110 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2111 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2111 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2112 | 2112 | /* Include the old way template part */ |
| 2113 | 2113 | ob_start(); |
| 2114 | 2114 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2128,7 +2128,7 @@ discard block |
||
| 2128 | 2128 | |
| 2129 | 2129 | /** Build template */ |
| 2130 | 2130 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2131 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2131 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2132 | 2132 | /* Include the old way template part */ |
| 2133 | 2133 | ob_start(); |
| 2134 | 2134 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2142,16 +2142,16 @@ discard block |
||
| 2142 | 2142 | } |
| 2143 | 2143 | } |
| 2144 | 2144 | |
| 2145 | - if ( $tab_list != '' ) { |
|
| 2145 | + if ($tab_list != '') { |
|
| 2146 | 2146 | /** Template parameters */ |
| 2147 | 2147 | $template_part = 'product_attribute_container'; |
| 2148 | 2148 | $tpl_component = array(); |
| 2149 | - $tpl_component['PDT_TABS'] = apply_filters( 'wpshop_extra_tabs_menu_before', '' ).$tab_list.apply_filters( 'wpshop_extra_tabs_menu_after', '' ); |
|
| 2150 | - $tpl_component['PDT_TAB_DETAIL'] = apply_filters( 'wpshop_extra_tabs_content_before', '' ).$content_list.apply_filters( 'wpshop_extra_tabs_content_after', '' ); |
|
| 2149 | + $tpl_component['PDT_TABS'] = apply_filters('wpshop_extra_tabs_menu_before', '') . $tab_list . apply_filters('wpshop_extra_tabs_menu_after', ''); |
|
| 2150 | + $tpl_component['PDT_TAB_DETAIL'] = apply_filters('wpshop_extra_tabs_content_before', '') . $content_list . apply_filters('wpshop_extra_tabs_content_after', ''); |
|
| 2151 | 2151 | |
| 2152 | 2152 | /** Build template */ |
| 2153 | 2153 | $tpl_way_to_take = wpshop_display::check_way_for_template($template_part); |
| 2154 | - if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) { |
|
| 2154 | + if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) { |
|
| 2155 | 2155 | /* Include the old way template part */ |
| 2156 | 2156 | ob_start(); |
| 2157 | 2157 | require(wpshop_display::get_template_file($tpl_way_to_take[1])); |
@@ -2174,9 +2174,9 @@ discard block |
||
| 2174 | 2174 | * @param unknown_type $attributeDefinition |
| 2175 | 2175 | * @return multitype:Ambigous <unknown, string> Ambigous <string, string> Ambigous <> |
| 2176 | 2176 | */ |
| 2177 | - public static function wps_attribute_values_display( $attributeDefinition ) { |
|
| 2177 | + public static function wps_attribute_values_display($attributeDefinition) { |
|
| 2178 | 2178 | $attribute_unit_list = ''; |
| 2179 | - if ( !empty($attributeDefinition['unit']) ) { |
|
| 2179 | + if (!empty($attributeDefinition['unit'])) { |
|
| 2180 | 2180 | /** Template parameters */ |
| 2181 | 2181 | $template_part = 'product_attribute_unit'; |
| 2182 | 2182 | $tpl_component = array(); |
@@ -2188,31 +2188,31 @@ discard block |
||
| 2188 | 2188 | } |
| 2189 | 2189 | |
| 2190 | 2190 | $attribute_value = $attributeDefinition['value']; |
| 2191 | - if ( $attributeDefinition['data_type'] == 'decimal' ) { |
|
| 2192 | - $attribute_value =(is_numeric($attribute_value) ) ? number_format($attribute_value, 2, ',', '') : $attribute_value; |
|
| 2193 | - if ( in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) { |
|
| 2194 | - if ( $attributeDefinition['is_requiring_unit'] == 'yes' ) { |
|
| 2191 | + if ($attributeDefinition['data_type'] == 'decimal') { |
|
| 2192 | + $attribute_value = (is_numeric($attribute_value)) ? number_format($attribute_value, 2, ',', '') : $attribute_value; |
|
| 2193 | + if (in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES))) { |
|
| 2194 | + if ($attributeDefinition['is_requiring_unit'] == 'yes') { |
|
| 2195 | 2195 | $attribute_unit_list = ' ' . wpshop_tools::wpshop_get_currency(); |
| 2196 | 2196 | } |
| 2197 | 2197 | $attributeDefinition['value'] = wpshop_display::format_field_output('wpshop_product_price', $attributeDefinition['value']); |
| 2198 | 2198 | } |
| 2199 | 2199 | } |
| 2200 | - if ( $attributeDefinition['data_type'] == 'datetime' ) { |
|
| 2200 | + if ($attributeDefinition['data_type'] == 'datetime') { |
|
| 2201 | 2201 | $attribute_value = mysql2date('d/m/Y', $attributeDefinition['value'], true); |
| 2202 | 2202 | } |
| 2203 | - if ( $attributeDefinition['backend_input'] == 'select' ) { |
|
| 2203 | + if ($attributeDefinition['backend_input'] == 'select') { |
|
| 2204 | 2204 | $attribute_value = wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
| 2205 | 2205 | } |
| 2206 | 2206 | /** Manage differently if its an array of values or not */ |
| 2207 | - if ( $attributeDefinition['backend_input'] == 'multiple-select') { |
|
| 2207 | + if ($attributeDefinition['backend_input'] == 'multiple-select') { |
|
| 2208 | 2208 | $attribute_value = ''; |
| 2209 | - if ( is_array($attributeDefinition['value']) ) { |
|
| 2209 | + if (is_array($attributeDefinition['value'])) { |
|
| 2210 | 2210 | foreach ($attributeDefinition['value'] as $v) { |
| 2211 | - $attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
|
| 2211 | + $attribute_value .= ' / ' . wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']); |
|
| 2212 | 2212 | } |
| 2213 | 2213 | } |
| 2214 | - else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2215 | - $attribute_value = substr($attribute_value,3); |
|
| 2214 | + else $attribute_value = ' / ' . wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']); |
|
| 2215 | + $attribute_value = substr($attribute_value, 3); |
|
| 2216 | 2216 | } |
| 2217 | 2217 | |
| 2218 | 2218 | return array($attribute_value, $attributeDefinition['value'], $attribute_unit_list); |
@@ -2222,13 +2222,13 @@ discard block |
||
| 2222 | 2222 | * Manage display for the output when user uses a shortcode for attributes display |
| 2223 | 2223 | * @param array $shorcode_args The list of argument passed through the shortcode |
| 2224 | 2224 | */ |
| 2225 | - function wpshop_attributes_shortcode( $shorcode_args ) { |
|
| 2225 | + function wpshop_attributes_shortcode($shorcode_args) { |
|
| 2226 | 2226 | $output = ''; |
| 2227 | 2227 | /* |
| 2228 | 2228 | * Read the attribute list |
| 2229 | 2229 | */ |
| 2230 | - foreach ( explode(', ', $shorcode_args['attributes']) as $attribute_code ) { |
|
| 2231 | - $attribute_output_def = wpshop_attributes::display_attribute( $attribute_code, $shorcode_args['from'] ); |
|
| 2230 | + foreach (explode(', ', $shorcode_args['attributes']) as $attribute_code) { |
|
| 2231 | + $attribute_output_def = wpshop_attributes::display_attribute($attribute_code, $shorcode_args['from']); |
|
| 2232 | 2232 | $output .= $attribute_output_def['field']; |
| 2233 | 2233 | } |
| 2234 | 2234 | |
@@ -2250,7 +2250,7 @@ discard block |
||
| 2250 | 2250 | $productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails($attributeSetId, "'valid','deleted'"); |
| 2251 | 2251 | $attribute_specification = array('page_code' => $currentPageCode, 'element_identifier' => $itemToEdit, 'field_id' => $currentPageCode . '_' . $itemToEdit . '_'); |
| 2252 | 2252 | |
| 2253 | - if ( count($productAttributeSetDetails) > 0 ) { |
|
| 2253 | + if (count($productAttributeSetDetails) > 0) { |
|
| 2254 | 2254 | /* Read the attribute list in order to output */ |
| 2255 | 2255 | $shortcodes_attr = ''; |
| 2256 | 2256 | $shortcodes_to_display = false; |
@@ -2260,80 +2260,80 @@ discard block |
||
| 2260 | 2260 | |
| 2261 | 2261 | $shortcodes = $currentTabContent = ''; |
| 2262 | 2262 | $output_nb = 0; |
| 2263 | - if(count($productAttributeSetDetail['attribut']) >= 1){ |
|
| 2264 | - foreach($productAttributeSetDetail['attribut'] as $attribute){ |
|
| 2263 | + if (count($productAttributeSetDetail['attribut']) >= 1) { |
|
| 2264 | + foreach ($productAttributeSetDetail['attribut'] as $attribute) { |
|
| 2265 | 2265 | |
| 2266 | - if ( !empty($attribute->id) ) { |
|
| 2267 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2266 | + if (!empty($attribute->id)) { |
|
| 2267 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2268 | 2268 | $attribute_set_id_is_present = true; |
| 2269 | 2269 | } |
| 2270 | 2270 | |
| 2271 | 2271 | /** Generic part for attribute field output */ |
| 2272 | 2272 | $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)); |
| 2273 | - $product_meta = get_post_meta( $itemToEdit, '_wpshop_product_metadata', true); |
|
| 2273 | + $product_meta = get_post_meta($itemToEdit, '_wpshop_product_metadata', true); |
|
| 2274 | 2274 | |
| 2275 | 2275 | /** Check if value is empty and get value in meta if not empty */ |
| 2276 | 2276 | $value = (empty($value) && !empty($product_meta[$attribute->code])) ? $product_meta[$attribute->code] : (!empty($value) ? $value : null); |
| 2277 | 2277 | |
| 2278 | 2278 | /* Manage specific field as the attribute_set_id in product form */ |
| 2279 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2279 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2280 | 2280 | |
| 2281 | 2281 | $value = empty($value) ? $attributeSetId : $value; |
| 2282 | 2282 | } |
| 2283 | 2283 | $attribute_specification['current_value'] = $value; |
| 2284 | - $attribute_output_def = apply_filters( 'wpshop_attribute_output_def', wpshop_attributes::display_attribute( $attribute->code, 'admin', $attribute_specification), $itemToEdit ); |
|
| 2285 | - if ( ($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id') ) { |
|
| 2284 | + $attribute_output_def = apply_filters('wpshop_attribute_output_def', wpshop_attributes::display_attribute($attribute->code, 'admin', $attribute_specification), $itemToEdit); |
|
| 2285 | + if (($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id')) { |
|
| 2286 | 2286 | $currentTabContent .= $attribute_output_def['field']; |
| 2287 | - $shortcode_code_def=array(); |
|
| 2288 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; |
|
| 2289 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; |
|
| 2290 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; |
|
| 2291 | - $shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; |
|
| 2287 | + $shortcode_code_def = array(); |
|
| 2288 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val'; |
|
| 2289 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type; |
|
| 2290 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id; |
|
| 2291 | + $shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit; |
|
| 2292 | 2292 | ob_start(); |
| 2293 | - 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'); |
|
| 2294 | - $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>'; |
|
| 2293 | + 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'); |
|
| 2294 | + $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>'; |
|
| 2295 | 2295 | ob_end_clean(); |
| 2296 | 2296 | } |
| 2297 | 2297 | else { |
| 2298 | - if ( $attribute->code == 'product_attribute_set_id' ) { |
|
| 2298 | + if ($attribute->code == 'product_attribute_set_id') { |
|
| 2299 | 2299 | $attribute_output_def['field_definition']['type'] = 'hidden'; |
| 2300 | 2300 | } |
| 2301 | - $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); |
|
| 2301 | + $currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']); |
|
| 2302 | 2302 | } |
| 2303 | 2303 | $output_nb++; |
| 2304 | 2304 | } |
| 2305 | 2305 | } |
| 2306 | 2306 | |
| 2307 | - $currentTabContent = apply_filters( 'wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail ); |
|
| 2307 | + $currentTabContent = apply_filters('wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail); |
|
| 2308 | 2308 | |
| 2309 | 2309 | $shortcode_code['attributes_set']['main_code'] = 'wpshop_att_group'; |
| 2310 | 2310 | $shortcode_code['attributes_set']['attrs_exemple']['pid'] = $itemToEdit; |
| 2311 | 2311 | $shortcode_code['attributes_set']['attrs_exemple']['sid'] = $productAttributeSetDetail['id']; |
| 2312 | 2312 | ob_start(); |
| 2313 | - 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'); |
|
| 2314 | - $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>'; |
|
| 2313 | + 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'); |
|
| 2314 | + $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>'; |
|
| 2315 | 2315 | ob_end_clean(); |
| 2316 | 2316 | |
| 2317 | - if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' ) |
|
| 2318 | - $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>'; |
|
| 2317 | + if (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box') |
|
| 2318 | + $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>'; |
|
| 2319 | 2319 | else |
| 2320 | 2320 | $shortcodes_attr .= $attribute_group_display; |
| 2321 | 2321 | |
| 2322 | - if ( $output_nb <= 0 ) { |
|
| 2322 | + if ($output_nb <= 0) { |
|
| 2323 | 2323 | $currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop'); |
| 2324 | 2324 | } |
| 2325 | 2325 | } |
| 2326 | 2326 | |
| 2327 | 2327 | if ($output_nb > 0) { |
| 2328 | 2328 | $shortcodes_to_display = true; |
| 2329 | - if ( $outputType == 'box' ) { |
|
| 2329 | + if ($outputType == 'box') { |
|
| 2330 | 2330 | $box['box'][$productAttributeSetDetail['code']] = $productAttributeSetDetail['name']; |
| 2331 | - $box['box'][$productAttributeSetDetail['code'].'_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; |
|
| 2331 | + $box['box'][$productAttributeSetDetail['code'] . '_backend_display_type'] = $productAttributeSetDetail['backend_display_type']; |
|
| 2332 | 2332 | $box['boxContent'][$productAttributeSetDetail['code']] = ' |
| 2333 | 2333 | <div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . ' |
| 2334 | 2334 | </div><div class="wpshop_cls" ></div>'; |
| 2335 | 2335 | } |
| 2336 | - else if ( $outputType == 'column' ) { |
|
| 2336 | + else if ($outputType == 'column') { |
|
| 2337 | 2337 | $currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent); |
| 2338 | 2338 | $currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent); |
| 2339 | 2339 | |
@@ -2343,11 +2343,11 @@ discard block |
||
| 2343 | 2343 | } |
| 2344 | 2344 | } |
| 2345 | 2345 | |
| 2346 | - if( !$attribute_set_id_is_present ) { |
|
| 2346 | + if (!$attribute_set_id_is_present) { |
|
| 2347 | 2347 | /* Get attribute definition */ |
| 2348 | 2348 | $attribute_def = wpshop_attributes::getElement('product_attribute_set_id', "'valid'", 'code'); |
| 2349 | 2349 | /* Get attribute input definition */ |
| 2350 | - $input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin')) ); |
|
| 2350 | + $input = wpshop_attributes::get_attribute_field_definition($attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin'))); |
|
| 2351 | 2351 | $input['type'] = 'hidden'; |
| 2352 | 2352 | |
| 2353 | 2353 | $box['boxMore'] = wpshop_form::check_input_type($input, $input['input_domain']); |
@@ -2358,13 +2358,13 @@ discard block |
||
| 2358 | 2358 | $dialog_identifier = 'wpshop_new_attribute_option_value_add'; |
| 2359 | 2359 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 2360 | 2360 | ob_start(); |
| 2361 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 2361 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 2362 | 2362 | $box['boxMore'] .= ob_get_contents(); |
| 2363 | 2363 | ob_end_clean(); |
| 2364 | 2364 | $box['boxMore'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />'; |
| 2365 | 2365 | |
| 2366 | - if ( $shortcodes_to_display ) { |
|
| 2367 | - switch ( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE ) { |
|
| 2366 | + if ($shortcodes_to_display) { |
|
| 2367 | + switch (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE) { |
|
| 2368 | 2368 | case 'fixed-tab': |
| 2369 | 2369 | case 'movable-tab': |
| 2370 | 2370 | if ($outputType == 'box') { |
@@ -2372,7 +2372,7 @@ discard block |
||
| 2372 | 2372 | $box['boxContent']['shortcode'] = $shortcodes_attr; |
| 2373 | 2373 | $box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE; |
| 2374 | 2374 | } |
| 2375 | - else{ |
|
| 2375 | + else { |
|
| 2376 | 2376 | $box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop'); |
| 2377 | 2377 | $box['columnContent']['shortcode'] = $shortcodes_attr; |
| 2378 | 2378 | } |
@@ -2396,12 +2396,12 @@ discard block |
||
| 2396 | 2396 | $ouput['more_input'] = ''; |
| 2397 | 2397 | |
| 2398 | 2398 | $attribute_default_value = $attribute->default_value; |
| 2399 | - if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) { |
|
| 2399 | + if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) { |
|
| 2400 | 2400 | $tmp_default_value = unserialize($attribute->default_value); |
| 2401 | 2401 | $attribute_default_value = !empty($tmp_default_value["default_value"]) ? $tmp_default_value["default_value"] : null; |
| 2402 | 2402 | } |
| 2403 | 2403 | |
| 2404 | - if ( $attribute->data_type_to_use == 'custom') { |
|
| 2404 | + if ($attribute->data_type_to_use == 'custom') { |
|
| 2405 | 2405 | $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); |
| 2406 | 2406 | $attribute_select_options = $wpdb->get_results($query); |
| 2407 | 2407 | |
@@ -2413,11 +2413,11 @@ discard block |
||
| 2413 | 2413 | // } |
| 2414 | 2414 | endforeach; |
| 2415 | 2415 | } |
| 2416 | - elseif ( $attribute->data_type_to_use == 'internal') { |
|
| 2416 | + elseif ($attribute->data_type_to_use == 'internal') { |
|
| 2417 | 2417 | switch ($attribute_default_value) { |
| 2418 | 2418 | case 'users': |
| 2419 | 2419 | $users = get_users('orderby=nicename'); |
| 2420 | - foreach($users as $user){ |
|
| 2420 | + foreach ($users as $user) { |
|
| 2421 | 2421 | $attribute_select_options_list[$user->ID] = $user->display_name; |
| 2422 | 2422 | } |
| 2423 | 2423 | break; |
@@ -2426,11 +2426,11 @@ discard block |
||
| 2426 | 2426 | $wpshop_attr_custom_post_query = new WP_Query(array( |
| 2427 | 2427 | 'post_type' => $attribute_default_value, |
| 2428 | 2428 | 'posts_per_page' => -1, |
| 2429 | - 'post_status' => array( 'publish', 'draft', 'future' ) , |
|
| 2429 | + 'post_status' => array('publish', 'draft', 'future'), |
|
| 2430 | 2430 | )); |
| 2431 | 2431 | |
| 2432 | - if($wpshop_attr_custom_post_query->have_posts()): |
|
| 2433 | - foreach($wpshop_attr_custom_post_query->posts as $post){ |
|
| 2432 | + if ($wpshop_attr_custom_post_query->have_posts()): |
|
| 2433 | + foreach ($wpshop_attr_custom_post_query->posts as $post) { |
|
| 2434 | 2434 | $attribute_select_options_list[$post->ID] = $post->post_title; |
| 2435 | 2435 | } |
| 2436 | 2436 | endif; |
@@ -2441,27 +2441,27 @@ discard block |
||
| 2441 | 2441 | |
| 2442 | 2442 | /* There is no value existing for this value */ |
| 2443 | 2443 | if (empty($attribute_select_options_list)) : |
| 2444 | - $ouput['more_input'].=__('Nothing found for this field', 'wpshop'); |
|
| 2444 | + $ouput['more_input'] .= __('Nothing found for this field', 'wpshop'); |
|
| 2445 | 2445 | else: |
| 2446 | 2446 | /* Add a default value to the combobox list */ |
| 2447 | 2447 | $default_value_is_serial = false; |
| 2448 | 2448 | $attribute_list_first_element = $attribute->default_value; |
| 2449 | - if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) { |
|
| 2449 | + if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) { |
|
| 2450 | 2450 | $default_value_is_serial = true; |
| 2451 | 2451 | $tmp_default_value = unserialize($attribute->default_value); |
| 2452 | 2452 | $attribute_list_first_element = $tmp_default_value["field_options"]["label_for_first_item"]; |
| 2453 | 2453 | } |
| 2454 | 2454 | //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'); |
| 2455 | - foreach ( $attribute_select_options_list as $option_key => $option_value ) { |
|
| 2455 | + foreach ($attribute_select_options_list as $option_key => $option_value) { |
|
| 2456 | 2456 | $ouput['possible_value'][$option_key] = stripslashes($option_value); |
| 2457 | 2457 | } |
| 2458 | 2458 | endif; |
| 2459 | 2459 | |
| 2460 | 2460 | /* Add a extra element to create a new element into list */ |
| 2461 | - if ( is_admin() && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) { |
|
| 2461 | + if (is_admin() && (empty($provenance['from']) || ($provenance['from'] != 'frontend'))) { |
|
| 2462 | 2462 | /** $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.'" />'; */ |
| 2463 | 2463 | } |
| 2464 | - else if ( 'yes' == $attribute->is_used_in_quick_add_form ) { |
|
| 2464 | + else if ('yes' == $attribute->is_used_in_quick_add_form) { |
|
| 2465 | 2465 | $tpl_component = array(); |
| 2466 | 2466 | $tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']'; |
| 2467 | 2467 | $ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component); |
@@ -2470,11 +2470,11 @@ discard block |
||
| 2470 | 2470 | return $ouput; |
| 2471 | 2471 | } |
| 2472 | 2472 | |
| 2473 | - public static function get_affected_value_for_list( $attribute_code, $element_id, $attribute_data_type ) { |
|
| 2473 | + public static function get_affected_value_for_list($attribute_code, $element_id, $attribute_data_type) { |
|
| 2474 | 2474 | global $wpdb; |
| 2475 | 2475 | $affected_value = array(); |
| 2476 | 2476 | |
| 2477 | - if ( $attribute_data_type == 'custom' ) { |
|
| 2477 | + if ($attribute_data_type == 'custom') { |
|
| 2478 | 2478 | $query = $wpdb->prepare(" |
| 2479 | 2479 | SELECT ATT_SELECT_OPTIONS_VALUE.id AS chosen_val, ATT_SELECT_OPTIONS_VALUE.value |
| 2480 | 2480 | FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT |
@@ -2496,20 +2496,20 @@ discard block |
||
| 2496 | 2496 | } |
| 2497 | 2497 | |
| 2498 | 2498 | $attribute_values_for_variations = $wpdb->get_results($query); |
| 2499 | - foreach ( $attribute_values_for_variations as $attribute_def ) { |
|
| 2500 | - $affected_value[] = (int) $attribute_def->chosen_val; |
|
| 2499 | + foreach ($attribute_values_for_variations as $attribute_def) { |
|
| 2500 | + $affected_value[] = (int)$attribute_def->chosen_val; |
|
| 2501 | 2501 | } |
| 2502 | 2502 | |
| 2503 | 2503 | return $affected_value; |
| 2504 | 2504 | } |
| 2505 | 2505 | |
| 2506 | 2506 | public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') { |
| 2507 | - switch($attr_code){ |
|
| 2507 | + switch ($attr_code) { |
|
| 2508 | 2508 | case 'is_downloadable_': |
| 2509 | - $option = get_post_meta($item['item_id'], 'attribute_option_'.$attr_code, true); |
|
| 2510 | - switch($attr_option){ |
|
| 2509 | + $option = get_post_meta($item['item_id'], 'attribute_option_' . $attr_code, true); |
|
| 2510 | + switch ($attr_option) { |
|
| 2511 | 2511 | case 'file_url': |
| 2512 | - if(in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_'.$attr_code]) && (strtolower(__($item['item_'.$attr_code], 'wpshop')) == __('yes','wpshop'))) ){ |
|
| 2512 | + if (in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_' . $attr_code]) && (strtolower(__($item['item_' . $attr_code], 'wpshop')) == __('yes', 'wpshop')))) { |
|
| 2513 | 2513 | $file_url = isset($option[$attr_option]) ? $option[$attr_option] : false; |
| 2514 | 2514 | return $file_url; |
| 2515 | 2515 | } |
@@ -2522,17 +2522,17 @@ discard block |
||
| 2522 | 2522 | |
| 2523 | 2523 | public static function get_attribute_option_fields($postid, $code) { |
| 2524 | 2524 | |
| 2525 | - switch($code){ |
|
| 2525 | + switch ($code) { |
|
| 2526 | 2526 | case 'is_downloadable_': |
| 2527 | - $data = get_post_meta($postid, 'attribute_option_'.$code, true); |
|
| 2528 | - $data['file_url'] = !empty($data['file_url'])?$data['file_url']:__('No file selected', 'wpshop'); |
|
| 2529 | - $fields = wp_nonce_field( 'ajax_wpshop_show_downloadable_interface_in_admin'.$postid, '_show_downloadable_interface_in_admin_wpnonce', true, false ); |
|
| 2527 | + $data = get_post_meta($postid, 'attribute_option_' . $code, true); |
|
| 2528 | + $data['file_url'] = !empty($data['file_url']) ? $data['file_url'] : __('No file selected', 'wpshop'); |
|
| 2529 | + $fields = wp_nonce_field('ajax_wpshop_show_downloadable_interface_in_admin' . $postid, '_show_downloadable_interface_in_admin_wpnonce', true, false); |
|
| 2530 | 2530 | $fields .= '<div class="wpshop_form_label alignleft"> </div> |
| 2531 | 2531 | <div class="wpshop_form_input_element alignleft"> |
| 2532 | - <div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid.'" title="' .__('Send the downloadable file', 'wpshop'). '"></div> |
|
| 2533 | - <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> |
|
| 2534 | - <input type="hidden" class="product_identifer_field" value="' .( !empty($postid) ? esc_attr( $postid ) : '') . '" /><br/><u>'.__('File url','wpshop').' :</u> |
|
| 2535 | - <div class="is_downloadable_statut_'.$postid.'"><a href="' .$data['file_url']. '" target="_blank" download>'.basename($data['file_url']).'</a></div> |
|
| 2532 | + <div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid . '" title="' . __('Send the downloadable file', 'wpshop') . '"></div> |
|
| 2533 | + <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> |
|
| 2534 | + <input type="hidden" class="product_identifer_field" value="' .(!empty($postid) ? esc_attr($postid) : '') . '" /><br/><u>' . __('File url', 'wpshop') . ' :</u> |
|
| 2535 | + <div class="is_downloadable_statut_'.$postid . '"><a href="' . $data['file_url'] . '" target="_blank" download>' . basename($data['file_url']) . '</a></div> |
|
| 2536 | 2536 | </div>'; |
| 2537 | 2537 | return $fields; |
| 2538 | 2538 | break; |
@@ -2557,8 +2557,8 @@ discard block |
||
| 2557 | 2557 | $attribute_value_content = ''; |
| 2558 | 2558 | |
| 2559 | 2559 | $atributes = self::getElement($attribute_code, "'valid'", 'code'); |
| 2560 | - if ( !empty($atributes) ) { |
|
| 2561 | - $attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id); |
|
| 2560 | + if (!empty($atributes)) { |
|
| 2561 | + $attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id); |
|
| 2562 | 2562 | } |
| 2563 | 2563 | |
| 2564 | 2564 | return $attribute_value_content; |
@@ -2570,14 +2570,14 @@ discard block |
||
| 2570 | 2570 | * @param mixed $value |
| 2571 | 2571 | * @return string The complete interface allowing to manage datetime attribute field |
| 2572 | 2572 | */ |
| 2573 | - function attribute_type_date_config( $value ) { |
|
| 2573 | + function attribute_type_date_config($value) { |
|
| 2574 | 2574 | $date_config_output = ''; |
| 2575 | 2575 | |
| 2576 | 2576 | $input_def['name'] = 'default_value'; |
| 2577 | 2577 | $input_def['type'] = 'checkbox'; |
| 2578 | 2578 | $input_def['possible_value'] = 'date_of_current_day'; |
| 2579 | 2579 | $input_def['value'] = !empty($value['default_value']) ? $value['default_value'] : ''; |
| 2580 | - $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>'; |
|
| 2580 | + $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>'; |
|
| 2581 | 2581 | $date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2582 | 2582 | |
| 2583 | 2583 | $input_def = array(); |
@@ -2586,35 +2586,35 @@ discard block |
||
| 2586 | 2586 | $input_def['type'] = 'checkbox'; |
| 2587 | 2587 | $input_def['valueToPut'] = 'index'; |
| 2588 | 2588 | $input_def['value'] = !empty($value['field_options']['attribute_type_date_options_day_to_show']) ? $value['field_options']['attribute_type_date_options_day_to_show'] : ''; |
| 2589 | - $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')); |
|
| 2589 | + $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')); |
|
| 2590 | 2590 | $input_def['options_label']['original'] = true; |
| 2591 | - $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>'; |
|
| 2591 | + $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>'; |
|
| 2592 | 2592 | |
| 2593 | 2593 | /** Past and futur date restriction */ |
| 2594 | 2594 | $input_def = array(); |
| 2595 | 2595 | $input_def['name'] = ''; |
| 2596 | 2596 | $input_def['type'] = 'text'; |
| 2597 | - $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/>'; |
|
| 2597 | + $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/>'; |
|
| 2598 | 2598 | $available_type_input_def = array(); |
| 2599 | 2599 | $available_type_input_def['name'] = ''; |
| 2600 | 2600 | $available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_minimum'; |
| 2601 | 2601 | $available_type_input_def['type'] = 'text'; |
| 2602 | 2602 | $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] : ''; |
| 2603 | - $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/>'; |
|
| 2603 | + $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/>'; |
|
| 2604 | 2604 | $available_type_input_def = array(); |
| 2605 | 2605 | $available_type_input_def['name'] = ''; |
| 2606 | 2606 | $available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_maximum'; |
| 2607 | 2607 | $available_type_input_def['type'] = 'text'; |
| 2608 | 2608 | $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] : ''; |
| 2609 | - $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/>'; |
|
| 2609 | + $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/>'; |
|
| 2610 | 2610 | $date_config_output .= '</div>'; |
| 2611 | 2611 | |
| 2612 | 2612 | $input_def = array(); |
| 2613 | 2613 | $input_def['name'] = ''; |
| 2614 | 2614 | $input_def['type'] = 'text'; |
| 2615 | 2615 | $date_config_output .= ' |
| 2616 | -<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> |
|
| 2617 | -<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/>'; |
|
| 2616 | +<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> |
|
| 2617 | +<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/>'; |
|
| 2618 | 2618 | |
| 2619 | 2619 | $available_type_input_def = array(); |
| 2620 | 2620 | $available_type_input_def['name'] = ''; |
@@ -2627,9 +2627,9 @@ discard block |
||
| 2627 | 2627 | $date_config_output .= wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_type]') . '<br/>'; |
| 2628 | 2628 | |
| 2629 | 2629 | $existing = 0; |
| 2630 | - if ( !empty($value['field_options']['attribute_type_date_options_available_date']) ) { |
|
| 2631 | - foreach ( $value['field_options']['attribute_type_date_options_available_date'] as $index => $value ) { |
|
| 2632 | - if ( !empty($value) ) { |
|
| 2630 | + if (!empty($value['field_options']['attribute_type_date_options_available_date'])) { |
|
| 2631 | + foreach ($value['field_options']['attribute_type_date_options_available_date'] as $index => $value) { |
|
| 2632 | + if (!empty($value)) { |
|
| 2633 | 2633 | $input_def['value'] = $value; |
| 2634 | 2634 | $input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_' . $index; |
| 2635 | 2635 | $date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '<br/>'; |
@@ -2653,20 +2653,20 @@ discard block |
||
| 2653 | 2653 | * @param array $values Valeurs d'attributs |
| 2654 | 2654 | * @return array |
| 2655 | 2655 | */ |
| 2656 | - public static function setAttributesValuesForItem($entityId, $values=array(), $defaultValueForOthers=false, $from = 'webservice') { |
|
| 2657 | - $message=''; |
|
| 2656 | + public static function setAttributesValuesForItem($entityId, $values = array(), $defaultValueForOthers = false, $from = 'webservice') { |
|
| 2657 | + $message = ''; |
|
| 2658 | 2658 | $attribute_available = array(); |
| 2659 | 2659 | $attribute_final = array(); |
| 2660 | 2660 | $entity_type = get_post_type($entityId); |
| 2661 | - $data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
|
| 2662 | - foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2661 | + $data = self::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE); |
|
| 2662 | + foreach ($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type); |
|
| 2663 | 2663 | |
| 2664 | 2664 | // Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity |
| 2665 | - foreach ( $values as $key => $value ) { |
|
| 2666 | - if ( in_array( $key, array_keys( $attribute_available ) ) ) { |
|
| 2665 | + foreach ($values as $key => $value) { |
|
| 2666 | + if (in_array($key, array_keys($attribute_available))) { |
|
| 2667 | 2667 | $attribute_final[$attribute_available[$key]['data_type']][$key] = $value; |
| 2668 | 2668 | } |
| 2669 | - else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n"; |
|
| 2669 | + else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key) . "\n"; |
|
| 2670 | 2670 | } |
| 2671 | 2671 | |
| 2672 | 2672 | // Pour les autres attributs non donné on leur affecte leur valeur par défaut |
@@ -2687,7 +2687,7 @@ discard block |
||
| 2687 | 2687 | } |
| 2688 | 2688 | } |
| 2689 | 2689 | |
| 2690 | - switch ( $entity_type ) { |
|
| 2690 | + switch ($entity_type) { |
|
| 2691 | 2691 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 2692 | 2692 | $meta_key = WPSHOP_PRODUCT_ATTRIBUTE_META_KEY; |
| 2693 | 2693 | break; |
@@ -2717,22 +2717,22 @@ discard block |
||
| 2717 | 2717 | */ |
| 2718 | 2718 | public static function get_attribute_type_select_option_info($option_id, $field = 'label', $attribute_data_type = 'custom', $only_value = false) { |
| 2719 | 2719 | global $wpdb; |
| 2720 | - if( ! is_numeric( $option_id ) ) { |
|
| 2720 | + if (!is_numeric($option_id)) { |
|
| 2721 | 2721 | return ''; |
| 2722 | 2722 | } |
| 2723 | - $option_id = (int) $option_id; |
|
| 2724 | - switch ( $attribute_data_type ) { |
|
| 2723 | + $option_id = (int)$option_id; |
|
| 2724 | + switch ($attribute_data_type) { |
|
| 2725 | 2725 | case 'internal': |
| 2726 | 2726 | $entity_infos = get_post($option_id); |
| 2727 | - if ( !empty($entity_infos) ) { |
|
| 2728 | - if ( !$only_value ) { |
|
| 2727 | + if (!empty($entity_infos)) { |
|
| 2728 | + if (!$only_value) { |
|
| 2729 | 2729 | /** Template parameters */ |
| 2730 | 2730 | $template_part = 'product_attribute_value_internal'; |
| 2731 | 2731 | $tpl_component = array(); |
| 2732 | 2732 | $tpl_component['ATTRIBUTE_VALUE_POST_LINK'] = get_permalink($option_id); |
| 2733 | 2733 | $tpl_component['ATTRIBUTE_VALUE_POST_TITLE'] = $entity_infos->post_title; |
| 2734 | 2734 | |
| 2735 | - foreach ( $entity_infos as $post_definition_key => $post_definition_value ) { |
|
| 2735 | + foreach ($entity_infos as $post_definition_key => $post_definition_value) { |
|
| 2736 | 2736 | $tpl_component['ATTRIBUTE_VALUE_' . strtoupper($post_definition_key)] = $entity_infos->$post_definition_key; |
| 2737 | 2737 | } |
| 2738 | 2738 | |
@@ -2747,8 +2747,8 @@ discard block |
||
| 2747 | 2747 | break; |
| 2748 | 2748 | |
| 2749 | 2749 | default: |
| 2750 | - if ( ! array_key_exists( $option_id, self::$select_option_info_cache ) ) { |
|
| 2751 | - $query = $wpdb->prepare("SELECT " . $field . " FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS." WHERE id=%d LIMIT 1", $option_id); |
|
| 2750 | + if (!array_key_exists($option_id, self::$select_option_info_cache)) { |
|
| 2751 | + $query = $wpdb->prepare("SELECT " . $field . " FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE id=%d LIMIT 1", $option_id); |
|
| 2752 | 2752 | self::$select_option_info_cache[$option_id] = $wpdb->get_var($query); |
| 2753 | 2753 | } |
| 2754 | 2754 | $info = self::$select_option_info_cache[$option_id]; |
@@ -2788,39 +2788,39 @@ discard block |
||
| 2788 | 2788 | * @param string $data_type optionnal Le type de donnees choisi pour cet attribut (custom | internal) |
| 2789 | 2789 | * @return string Le resultat sous forme de code html pour la liste des options |
| 2790 | 2790 | */ |
| 2791 | - function get_select_options_list($attribute_id, $data_type='custom') { |
|
| 2791 | + function get_select_options_list($attribute_id, $data_type = 'custom') { |
|
| 2792 | 2792 | global $wpdb; |
| 2793 | 2793 | $output = ''; |
| 2794 | 2794 | |
| 2795 | 2795 | $attribute_select_options = self::get_select_option_list_($attribute_id); |
| 2796 | 2796 | |
| 2797 | 2797 | /* Add possibily to choose datat type to use with list */ |
| 2798 | - if(empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))){ |
|
| 2799 | - unset($input_def);$input_def=array(); |
|
| 2798 | + if (empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))) { |
|
| 2799 | + unset($input_def); $input_def = array(); |
|
| 2800 | 2800 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 2801 | 2801 | $input_def['type'] = 'radio'; |
| 2802 | 2802 | $input_def['name'] = 'data_type_to_use'; |
| 2803 | 2803 | $input_def['valueToPut'] = 'index'; |
| 2804 | 2804 | $input_def['possible_value'] = unserialize(WPSHOP_ATTR_SELECT_TYPE); |
| 2805 | 2805 | $input_def['option'] = 'class="wpshop_cls wpshop_attr_combo_data_type"'; |
| 2806 | - $input_def['value'] = $data_type.'_data'; |
|
| 2806 | + $input_def['value'] = $data_type . '_data'; |
|
| 2807 | 2807 | $input_def['options_label']['original'] = true; |
| 2808 | 2808 | $output = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2809 | 2809 | } |
| 2810 | 2810 | |
| 2811 | - if(!empty($attribute_id) || !empty($data_type)){ |
|
| 2812 | - $defaut_value = ( !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value) ) ? $attribute_select_options[0]->default_value : null; |
|
| 2811 | + if (!empty($attribute_id) || !empty($data_type)) { |
|
| 2812 | + $defaut_value = (!empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value)) ? $attribute_select_options[0]->default_value : null; |
|
| 2813 | 2813 | $default_is_serial = false; |
| 2814 | - 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 ) ) ) { |
|
| 2814 | + 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))) { |
|
| 2815 | 2815 | $defaut_value = unserialize($attribute_select_options[0]->default_value); |
| 2816 | 2816 | $default_is_serial = true; |
| 2817 | 2817 | } |
| 2818 | 2818 | /** Add a custom text first item of list */ |
| 2819 | - $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>'; |
|
| 2819 | + $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>'; |
|
| 2820 | 2820 | |
| 2821 | - 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'))){ |
|
| 2821 | + 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'))) { |
|
| 2822 | 2822 | $sub_output = ''; |
| 2823 | - if ( !empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id) ) { |
|
| 2823 | + if (!empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id)) { |
|
| 2824 | 2824 | $sub_output .= ' |
| 2825 | 2825 | <li class="wpshop_attribute_combo_options_container ui-state-disabled" > |
| 2826 | 2826 | <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> |
@@ -2833,7 +2833,7 @@ discard block |
||
| 2833 | 2833 | $tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", $options->value); |
| 2834 | 2834 | $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"' : ''); |
| 2835 | 2835 | $tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = ''; |
| 2836 | - if( current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0) ): |
|
| 2836 | + if (current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0)): |
|
| 2837 | 2837 | $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'); |
| 2838 | 2838 | endif; |
| 2839 | 2839 | $sub_output .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin'); |
@@ -2841,13 +2841,13 @@ discard block |
||
| 2841 | 2841 | } |
| 2842 | 2842 | } |
| 2843 | 2843 | $add_button = $add_dialog_box = $user_more_script = ''; |
| 2844 | - if( current_user_can('wpshop_add_attributes_select_values') ) { |
|
| 2844 | + if (current_user_can('wpshop_add_attributes_select_values')) { |
|
| 2845 | 2845 | |
| 2846 | 2846 | $dialog_title = __('New value for attribute', 'wpshop'); |
| 2847 | 2847 | $dialog_identifier = 'wpshop_new_attribute_option_value_add'; |
| 2848 | 2848 | $dialog_input_identifier = 'wpshop_new_attribute_option_value'; |
| 2849 | 2849 | ob_start(); |
| 2850 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php'); |
|
| 2850 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php'); |
|
| 2851 | 2851 | $add_dialog_box = ob_get_contents(); |
| 2852 | 2852 | ob_end_clean(); |
| 2853 | 2853 | |
@@ -2855,23 +2855,23 @@ discard block |
||
| 2855 | 2855 | $add_button_parent_class = 'wpshop_attribute_option_value_add'; |
| 2856 | 2856 | $add_button_name = 'wpshop_add_option_to_select'; |
| 2857 | 2857 | ob_start(); |
| 2858 | - include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php'); |
|
| 2858 | + include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php'); |
|
| 2859 | 2859 | $add_button = ob_get_contents(); |
| 2860 | 2860 | ob_end_clean(); |
| 2861 | 2861 | |
| 2862 | 2862 | $user_more_script = ' |
| 2863 | - jQuery("#'.$dialog_identifier.'").dialog({ |
|
| 2863 | + jQuery("#'.$dialog_identifier . '").dialog({ |
|
| 2864 | 2864 | modal: true, |
| 2865 | 2865 | dialogClass: "wpshop_uidialog_box", |
| 2866 | 2866 | autoOpen:false, |
| 2867 | 2867 | show: "blind", |
| 2868 | 2868 | resizable: false, |
| 2869 | 2869 | buttons:{ |
| 2870 | - "'.__('Add', 'wpshop').'": function(){ |
|
| 2870 | + "'.__('Add', 'wpshop') . '": function(){ |
|
| 2871 | 2871 | var data = { |
| 2872 | 2872 | action: "new_option_for_select", |
| 2873 | 2873 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_new_option_for_attribute_creation") . '", |
| 2874 | - attribute_new_label: jQuery("#'.$dialog_input_identifier.'").val(), |
|
| 2874 | + attribute_new_label: jQuery("#'.$dialog_input_identifier . '").val(), |
|
| 2875 | 2875 | attribute_identifier: "' . $attribute_id . '" |
| 2876 | 2876 | }; |
| 2877 | 2877 | jQuery.post(ajaxurl, data, function(response) { |
@@ -2887,21 +2887,21 @@ discard block |
||
| 2887 | 2887 | |
| 2888 | 2888 | jQuery(this).children("img").show(); |
| 2889 | 2889 | }, |
| 2890 | - "'.__('Cancel', 'wpshop').'": function(){ |
|
| 2890 | + "'.__('Cancel', 'wpshop') . '": function(){ |
|
| 2891 | 2891 | jQuery(this).dialog("close"); |
| 2892 | 2892 | } |
| 2893 | 2893 | }, |
| 2894 | 2894 | close:function(){ |
| 2895 | - jQuery("#'.$dialog_input_identifier.'").val(""); |
|
| 2895 | + jQuery("#'.$dialog_input_identifier . '").val(""); |
|
| 2896 | 2896 | } |
| 2897 | 2897 | }); |
| 2898 | - jQuery(".'.$add_button_parent_class.' input").click(function(){ |
|
| 2899 | - jQuery("#'.$dialog_identifier.'").dialog("open"); |
|
| 2898 | + jQuery(".'.$add_button_parent_class . ' input").click(function(){ |
|
| 2899 | + jQuery("#'.$dialog_identifier . '").dialog("open"); |
|
| 2900 | 2900 | });'; |
| 2901 | 2901 | |
| 2902 | 2902 | } |
| 2903 | 2903 | $output .= $add_dialog_box . ' |
| 2904 | - <ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options)>5 ? $add_button : '').$sub_output.$add_button.' |
|
| 2904 | + <ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options) > 5 ? $add_button : '') . $sub_output . $add_button . ' |
|
| 2905 | 2905 | </ul> |
| 2906 | 2906 | <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" /> |
| 2907 | 2907 | <script type="text/javascript" > |
@@ -2917,7 +2917,7 @@ discard block |
||
| 2917 | 2917 | var data = { |
| 2918 | 2918 | action: "attribute_output_type", |
| 2919 | 2919 | current_type: jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").val(), |
| 2920 | - elementIdentifier: "'.$attribute_id.'", |
|
| 2920 | + elementIdentifier: "'.$attribute_id . '", |
|
| 2921 | 2921 | data_type_to_use: jQuery(this).val(), |
| 2922 | 2922 | wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_output_type_selection") . '" |
| 2923 | 2923 | }; |
@@ -2932,10 +2932,10 @@ discard block |
||
| 2932 | 2932 | }); |
| 2933 | 2933 | </script>'; |
| 2934 | 2934 | } |
| 2935 | - 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'))){ |
|
| 2936 | - $sub_output=''; |
|
| 2935 | + 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'))) { |
|
| 2936 | + $sub_output = ''; |
|
| 2937 | 2937 | $wp_types = unserialize(WPSHOP_INTERNAL_TYPES); |
| 2938 | - unset($input_def);$input_def=array(); |
|
| 2938 | + unset($input_def); $input_def = array(); |
|
| 2939 | 2939 | $input_def['label'] = __('Type of data for list', 'wpshop'); |
| 2940 | 2940 | $input_def['type'] = 'select'; |
| 2941 | 2941 | $input_def['name'] = 'default_value][default_value'; |
@@ -2944,20 +2944,20 @@ discard block |
||
| 2944 | 2944 | $input_def['possible_value'] = $wp_types; |
| 2945 | 2945 | $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)); |
| 2946 | 2946 | $combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE); |
| 2947 | - $output .= '<div class="wpshop_cls">'.$combo_wp_type.'</div>'; |
|
| 2948 | - if ( !empty($attribute_id) ) { |
|
| 2947 | + $output .= '<div class="wpshop_cls">' . $combo_wp_type . '</div>'; |
|
| 2948 | + if (!empty($attribute_id)) { |
|
| 2949 | 2949 | $option_list = '<div>' . __('You can reorder element for display them in the order you want into frontend part', 'wpshop') . '</div>'; |
| 2950 | - $options_for_current_attribute = query_posts( array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ) ); |
|
| 2951 | - if ( !empty($options_for_current_attribute) ) { |
|
| 2950 | + $options_for_current_attribute = query_posts(array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC')); |
|
| 2951 | + if (!empty($options_for_current_attribute)) { |
|
| 2952 | 2952 | $option_list .= '<ul class="wpshop_attribute_combo_values_list_container" >'; |
| 2953 | 2953 | $current_order = ' '; |
| 2954 | - foreach ( $options_for_current_attribute as $options_def ) { |
|
| 2954 | + foreach ($options_for_current_attribute as $options_def) { |
|
| 2955 | 2955 | $current_order .= 'post_' . $options_def->ID . ','; |
| 2956 | 2956 | $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>'; |
| 2957 | 2957 | } |
| 2958 | 2958 | $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" />'; |
| 2959 | 2959 | } |
| 2960 | - $output .= '<div class="wpshop_cls">'.$option_list.'</div>'; |
|
| 2960 | + $output .= '<div class="wpshop_cls">' . $option_list . '</div>'; |
|
| 2961 | 2961 | } |
| 2962 | 2962 | } |
| 2963 | 2963 | } |
@@ -2985,8 +2985,8 @@ discard block |
||
| 2985 | 2985 | $attribute_list_for_entity = self::getElement($entity_id, "'valid'", 'entity_id', true); |
| 2986 | 2986 | |
| 2987 | 2987 | /* Read the list */ |
| 2988 | - if ( !empty ($attribute_list_for_entity ) ) { |
|
| 2989 | - foreach ( $attribute_list_for_entity as $attribute) { |
|
| 2988 | + if (!empty ($attribute_list_for_entity)) { |
|
| 2989 | + foreach ($attribute_list_for_entity as $attribute) { |
|
| 2990 | 2990 | switch ($list_for) { |
| 2991 | 2991 | case 'attribute_value': |
| 2992 | 2992 | $checkbox_state = ' '; |
@@ -2995,8 +2995,8 @@ discard block |
||
| 2995 | 2995 | <select id="wpshop_shortcode_element_attribute_value_product_list_' . $attribute->id . '" class="wpshop_shortcode_element_attribute_value_product_list" >'; |
| 2996 | 2996 | |
| 2997 | 2997 | global $post; |
| 2998 | - $posts = get_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1) ); |
|
| 2999 | - foreach( $posts as $post ) : |
|
| 2998 | + $posts = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1)); |
|
| 2999 | + foreach ($posts as $post) : |
|
| 3000 | 3000 | setup_postdata($post); |
| 3001 | 3001 | $attribute_possible_values .= '<option value="' . get_the_ID() . '" >' . get_the_ID() . ' - ' . get_the_title() . '</option>'; |
| 3002 | 3002 | endforeach; |
@@ -3012,23 +3012,23 @@ discard block |
||
| 3012 | 3012 | |
| 3013 | 3013 | $checkbox_state = 'disabled '; |
| 3014 | 3014 | $attribute_possible_values = ''; |
| 3015 | - if ( !empty($attribute_values) ) { |
|
| 3015 | + if (!empty($attribute_values)) { |
|
| 3016 | 3016 | $checkbox_state = ''; |
| 3017 | 3017 | $attribute_possible_values = ' |
| 3018 | 3018 | <div class="wpshop_shortcode_element_product_listing_per_attribute_value wpshop_shortcode_element_prodcut_listing_per_attribute_value_' . $attribute->code . '_container" > |
| 3019 | 3019 | <select id="wpshop_attribute_value_for_shortcode_generation_' . $attribute->id . '" class="wpshop_shortcode_element_prodcut_listing_per_attribute_value hidden" >'; |
| 3020 | 3020 | |
| 3021 | - if ( ($attribute->data_type == 'integer') && ( ($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select') ) ) { |
|
| 3021 | + if (($attribute->data_type == 'integer') && (($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select'))) { |
|
| 3022 | 3022 | $query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id=%d ORDER BY position", $attribute->id); |
| 3023 | 3023 | $possible_values = $wpdb->get_results($query); |
| 3024 | 3024 | $already_selected_values = array(); |
| 3025 | 3025 | foreach ($attribute_values as $attribute_value) { |
| 3026 | - if ( !empty($attribute_value->value) ) { |
|
| 3026 | + if (!empty($attribute_value->value)) { |
|
| 3027 | 3027 | $already_selected_values[] = $attribute_value->value; |
| 3028 | 3028 | } |
| 3029 | 3029 | } |
| 3030 | 3030 | foreach ($possible_values as $value) { |
| 3031 | - if ( in_array( $value->id, $already_selected_values ) ) { |
|
| 3031 | + if (in_array($value->id, $already_selected_values)) { |
|
| 3032 | 3032 | $attribute_possible_values .= ' |
| 3033 | 3033 | <option value="' . $value->value . '" >' . $value->label . '</option>'; |
| 3034 | 3034 | } |
@@ -3036,7 +3036,7 @@ discard block |
||
| 3036 | 3036 | } |
| 3037 | 3037 | else { |
| 3038 | 3038 | foreach ($attribute_values as $attribute_value) { |
| 3039 | - if ( !empty($attribute_value->value) ) { |
|
| 3039 | + if (!empty($attribute_value->value)) { |
|
| 3040 | 3040 | $attribute_possible_values .= ' |
| 3041 | 3041 | <option value="' . $attribute_value->value . '" >' . $attribute_value->value . '</option>'; |
| 3042 | 3042 | } |
@@ -3065,23 +3065,23 @@ discard block |
||
| 3065 | 3065 | * |
| 3066 | 3066 | * @return object The attribute list as a wordpress database object |
| 3067 | 3067 | */ |
| 3068 | - function get_attribute_list_in_same_set_section( $attribute_code ) { |
|
| 3068 | + function get_attribute_list_in_same_set_section($attribute_code) { |
|
| 3069 | 3069 | global $wpdb; |
| 3070 | 3070 | |
| 3071 | 3071 | $attribute_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code'); |
| 3072 | 3072 | |
| 3073 | 3073 | /** Get the entire list of attribute in price set section for display */ |
| 3074 | - $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); |
|
| 3074 | + $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); |
|
| 3075 | 3075 | $attribute_attribution_def = $wpdb->get_row($query); |
| 3076 | 3076 | |
| 3077 | - $query = $wpdb->prepare( " |
|
| 3077 | + $query = $wpdb->prepare(" |
|
| 3078 | 3078 | SELECT ATTR.code, is_visible_in_front_listing, is_visible_in_front |
| 3079 | 3079 | FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS SET_SECTION_DETAIL |
| 3080 | 3080 | INNER JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR ON (ATTR.id = SET_SECTION_DETAIL.attribute_id) |
| 3081 | 3081 | WHERE entity_type_id = %d |
| 3082 | 3082 | AND attribute_set_id = %d |
| 3083 | 3083 | AND attribute_group_id = %d", |
| 3084 | - $attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id ); |
|
| 3084 | + $attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id); |
|
| 3085 | 3085 | $atribute_list = $wpdb->get_results($query); |
| 3086 | 3086 | |
| 3087 | 3087 | return $atribute_list; |
@@ -3092,7 +3092,7 @@ discard block |
||
| 3092 | 3092 | * @param unknown_type $current_entity_id |
| 3093 | 3093 | * @return Ambigous <multitype:, multitype:NULL > |
| 3094 | 3094 | */ |
| 3095 | - public static function get_variation_available_attribute( $current_entity_id ) { |
|
| 3095 | + public static function get_variation_available_attribute($current_entity_id) { |
|
| 3096 | 3096 | global $wpdb; |
| 3097 | 3097 | $final_list = array(); |
| 3098 | 3098 | |
@@ -3100,7 +3100,7 @@ discard block |
||
| 3100 | 3100 | $query = $wpdb->prepare( |
| 3101 | 3101 | "SELECT ATT.*, ENTITY_META.meta_value |
| 3102 | 3102 | FROM " . self::getDbTable() . " AS ATT |
| 3103 | - 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')) |
|
| 3103 | + 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')) |
|
| 3104 | 3104 | INNER JOIN " . $wpdb->postmeta . " AS ENTITY_META ON ((ENTITY_META.meta_key = %s) AND (ENTITY_META.meta_value = ATT_DETAILS.attribute_set_id)) |
| 3105 | 3105 | WHERE ATT.status IN ('valid') |
| 3106 | 3106 | AND ATT.is_used_for_variation = %s |
@@ -3110,10 +3110,10 @@ discard block |
||
| 3110 | 3110 | ); |
| 3111 | 3111 | $attribute_list = $wpdb->get_results($query); |
| 3112 | 3112 | foreach ($attribute_list as $attribute) { |
| 3113 | - if ( !in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select')) ) { |
|
| 3114 | - $attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list( $attribute->code, $current_entity_id, $attribute->data_type_to_use ); |
|
| 3113 | + if (!in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select'))) { |
|
| 3114 | + $attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list($attribute->code, $current_entity_id, $attribute->data_type_to_use); |
|
| 3115 | 3115 | |
| 3116 | - if ( empty($attribute_values_for_variations) ) { |
|
| 3116 | + if (empty($attribute_values_for_variations)) { |
|
| 3117 | 3117 | $final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label; |
| 3118 | 3118 | $final_list['unavailable'][$attribute->code]['values'] = array(); |
| 3119 | 3119 | $final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute; |
@@ -3133,16 +3133,16 @@ discard block |
||
| 3133 | 3133 | * @param integer $current_entity_id The current element edited |
| 3134 | 3134 | * @return Ambigous <string, string, mixed> |
| 3135 | 3135 | */ |
| 3136 | - public static function get_variation_available_attribute_display( $current_entity_id, $variation_type = 'multiple' ) { |
|
| 3136 | + public static function get_variation_available_attribute_display($current_entity_id, $variation_type = 'multiple') { |
|
| 3137 | 3137 | $attribute_list = wpshop_attributes::get_variation_available_attribute($current_entity_id); |
| 3138 | 3138 | |
| 3139 | 3139 | $attribute_defined_as_available_for_variation = ''; |
| 3140 | - if ( !empty($attribute_list) ) { |
|
| 3140 | + if (!empty($attribute_list)) { |
|
| 3141 | 3141 | foreach ($attribute_list as $list_type => $attribute_list_by_type) { |
| 3142 | 3142 | $sub_attribute_list = ''; |
| 3143 | 3143 | foreach ($attribute_list_by_type as $attribute_code => $attribute_def) { |
| 3144 | 3144 | $tpl_component = array(); |
| 3145 | - if ( $list_type == 'available' ) { |
|
| 3145 | + if ($list_type == 'available') { |
|
| 3146 | 3146 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ''; |
| 3147 | 3147 | $tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ''; |
| 3148 | 3148 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = ''; |
@@ -3156,13 +3156,13 @@ discard block |
||
| 3156 | 3156 | $tpl_component['ADMIN_ATTRIBUTE_CODE_FOR_VARIATION'] = $attribute_code; |
| 3157 | 3157 | $tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code; |
| 3158 | 3158 | $tpl_component['ADMIN_VARIATION_ATTRIBUTE_CONTAINER_CLASS'] = ' wpshop_attribute_for_variation_' . $attribute_code; |
| 3159 | - $tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __( $attribute_def['label'], 'wpshop' ); |
|
| 3159 | + $tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __($attribute_def['label'], 'wpshop'); |
|
| 3160 | 3160 | $tpl_component['ADMIN_VARIATION_NEW_SINGLE_INPUT'] = ''; |
| 3161 | - if ( $variation_type == 'single' ) { |
|
| 3162 | - $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') ); |
|
| 3163 | - if ( !empty($attribute_output_def['possible_value']) ) { |
|
| 3164 | - foreach( $attribute_output_def['possible_value'] as $value_id => $value ){ |
|
| 3165 | - if ( !in_array($value_id, $attribute_def['values']) ) { |
|
| 3161 | + if ($variation_type == 'single') { |
|
| 3162 | + $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')); |
|
| 3163 | + if (!empty($attribute_output_def['possible_value'])) { |
|
| 3164 | + foreach ($attribute_output_def['possible_value'] as $value_id => $value) { |
|
| 3165 | + if (!in_array($value_id, $attribute_def['values'])) { |
|
| 3166 | 3166 | unset($attribute_output_def['possible_value'][$value_id]); |
| 3167 | 3167 | } |
| 3168 | 3168 | } |
@@ -3177,7 +3177,7 @@ discard block |
||
| 3177 | 3177 | } |
| 3178 | 3178 | } |
| 3179 | 3179 | |
| 3180 | - return array($attribute_defined_as_available_for_variation, ( (!empty($attribute_list['available']) ) ? $attribute_list['available'] : ''), ( ( !empty($attribute_list['unavailable']) ) ? $attribute_list['unavailable'] : '')); |
|
| 3180 | + return array($attribute_defined_as_available_for_variation, ((!empty($attribute_list['available'])) ? $attribute_list['available'] : ''), ((!empty($attribute_list['unavailable'])) ? $attribute_list['unavailable'] : '')); |
|
| 3181 | 3181 | } |
| 3182 | 3182 | |
| 3183 | 3183 | /** |
@@ -3186,18 +3186,18 @@ discard block |
||
| 3186 | 3186 | * @param array $variations_attribute_parameters Allows to give some parameters for customize list |
| 3187 | 3187 | * @return string The output for all specific attribute in each product with option |
| 3188 | 3188 | */ |
| 3189 | - public static function get_variation_attribute( $variations_attribute_parameters ) { |
|
| 3189 | + public static function get_variation_attribute($variations_attribute_parameters) { |
|
| 3190 | 3190 | $output = ''; |
| 3191 | 3191 | |
| 3192 | 3192 | $attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_in_variation", true); |
| 3193 | - if ( !empty( $attribute_list ) ) { |
|
| 3193 | + if (!empty($attribute_list)) { |
|
| 3194 | 3194 | $tpl_component = array(); |
| 3195 | 3195 | $tpl_component['ADMIN_VARIATION_DETAIL'] = ''; |
| 3196 | 3196 | $price_piloting_option = get_option('wpshop_shop_price_piloting'); |
| 3197 | - foreach ( $attribute_list as $attribute_def ) { |
|
| 3197 | + foreach ($attribute_list as $attribute_def) { |
|
| 3198 | 3198 | |
| 3199 | 3199 | $variations_attribute_parameters['field_custom_name_prefix'] = $variations_attribute_parameters['field_name'] . '[attribute][' . $attribute_def->data_type . ']'; |
| 3200 | - $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 ); |
|
| 3200 | + $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); |
|
| 3201 | 3201 | |
| 3202 | 3202 | $field_output = $attribute_output_def['output']; |
| 3203 | 3203 | |
@@ -3209,9 +3209,9 @@ discard block |
||
| 3209 | 3209 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_ID'] = $attribute_output_def['id']; |
| 3210 | 3210 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_LABEL'] = $attribute_output_def['label']; |
| 3211 | 3211 | $sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] = $field_output; |
| 3212 | - if( isset( $variations_attribute_parameters['post_id'] ) ) { |
|
| 3213 | - $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'; |
|
| 3214 | - $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>'; |
|
| 3212 | + if (isset($variations_attribute_parameters['post_id'])) { |
|
| 3213 | + $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'; |
|
| 3214 | + $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>'; |
|
| 3215 | 3215 | } |
| 3216 | 3216 | $tpl_component['ADMIN_VARIATION_DETAIL'] .= wpshop_display::display_template_element('wpshop_admin_variation_item_details_line', $sub_tpl_component, array(), 'admin'); |
| 3217 | 3217 | unset($sub_tpl_component); |
@@ -3222,7 +3222,7 @@ discard block |
||
| 3222 | 3222 | return $output; |
| 3223 | 3223 | } |
| 3224 | 3224 | |
| 3225 | - public static function get_attribute_user_defined( $use_defined_parameters, $status = "'publish'" ) { |
|
| 3225 | + public static function get_attribute_user_defined($use_defined_parameters, $status = "'publish'") { |
|
| 3226 | 3226 | global $wpdb; |
| 3227 | 3227 | $attribute_user_defined_list = array(); |
| 3228 | 3228 | |
@@ -3249,12 +3249,12 @@ discard block |
||
| 3249 | 3249 | * @param string $post_type The current |
| 3250 | 3250 | * |
| 3251 | 3251 | */ |
| 3252 | - function quick_edit( $column_name, $entity ) { |
|
| 3253 | - switch ( $entity ) { |
|
| 3252 | + function quick_edit($column_name, $entity) { |
|
| 3253 | + switch ($entity) { |
|
| 3254 | 3254 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 3255 | 3255 | $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code'); |
| 3256 | - if ( !empty($attribute_def) ) { |
|
| 3257 | - $input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') ); |
|
| 3256 | + if (!empty($attribute_def)) { |
|
| 3257 | + $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input')); |
|
| 3258 | 3258 | $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']); |
| 3259 | 3259 | ?> |
| 3260 | 3260 | <div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container"> |
@@ -3274,12 +3274,12 @@ discard block |
||
| 3274 | 3274 | * @param string $post_type The current |
| 3275 | 3275 | * |
| 3276 | 3276 | */ |
| 3277 | - public static function bulk_edit( $column_name, $entity ) { |
|
| 3278 | - switch ( $entity ) { |
|
| 3277 | + public static function bulk_edit($column_name, $entity) { |
|
| 3278 | + switch ($entity) { |
|
| 3279 | 3279 | case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT: |
| 3280 | 3280 | $attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code'); |
| 3281 | - if ( !empty($attribute_def) ) { |
|
| 3282 | - $input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') ); |
|
| 3281 | + if (!empty($attribute_def)) { |
|
| 3282 | + $input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input')); |
|
| 3283 | 3283 | $input = wpshop_form::check_input_type($input_def, $input_def['input_domain']); |
| 3284 | 3284 | ?> |
| 3285 | 3285 | <div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container"> |