@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Main controller file for product mass modification module |
| 4 | 4 | * |
@@ -21,29 +21,29 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | function __construct() { |
| 23 | 23 | // Add submenu |
| 24 | - add_action('admin_menu', array( $this, 'register_mass_products_edit_submenu' ), 350 ); |
|
| 24 | + add_action('admin_menu', array($this, 'register_mass_products_edit_submenu'), 350); |
|
| 25 | 25 | |
| 26 | 26 | // Trigger ajax action |
| 27 | - add_action( 'wp_ajax_wps_mass_edit_change_page', array( $this, 'wps_mass_edit_change_page') ); |
|
| 28 | - add_action( 'wp_ajax_wps_mass_edit_product_save_action', array( $this, 'wps_save_product_quick_interface') ); |
|
| 29 | - add_action( 'wp_ajax_wps_mass_interface_new_product_creation', array( $this, 'wps_mass_interface_new_product_creation' ) ); |
|
| 30 | - add_action( 'wp_ajax_wps_mass_delete_file', array( $this, 'wps_mass_delete_file' ) ); |
|
| 31 | - add_action( 'wp_ajax_wps_mass_edit_update_files_list', array( $this, 'wps_mass_edit_update_files_list' ) ); |
|
| 27 | + add_action('wp_ajax_wps_mass_edit_change_page', array($this, 'wps_mass_edit_change_page')); |
|
| 28 | + add_action('wp_ajax_wps_mass_edit_product_save_action', array($this, 'wps_save_product_quick_interface')); |
|
| 29 | + add_action('wp_ajax_wps_mass_interface_new_product_creation', array($this, 'wps_mass_interface_new_product_creation')); |
|
| 30 | + add_action('wp_ajax_wps_mass_delete_file', array($this, 'wps_mass_delete_file')); |
|
| 31 | + add_action('wp_ajax_wps_mass_edit_update_files_list', array($this, 'wps_mass_edit_update_files_list')); |
|
| 32 | 32 | // add_action( 'wap_ajax_wps_mass_delete_post', array( $this, 'wps_mass_delete_post' ) ); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function register_mass_products_edit_submenu() { |
| 36 | - $this->submenu = add_submenu_page( 'edit.php?post_type=wpshop_product', __( 'Mass product edit', 'wpshop' ), __( 'Mass product edit', 'wpshop' ), 'manage_options', 'mass_edit_interface', array($this, 'wps_display_mass_edit_interface' ) ); |
|
| 36 | + $this->submenu = add_submenu_page('edit.php?post_type=wpshop_product', __('Mass product edit', 'wpshop'), __('Mass product edit', 'wpshop'), 'manage_options', 'mass_edit_interface', array($this, 'wps_display_mass_edit_interface')); |
|
| 37 | 37 | // Declare Styles and JS Files. |
| 38 | - add_action( 'admin_print_styles-' . $this->submenu, array( $this, 'admin_print_styles' ) ); |
|
| 39 | - add_action( 'admin_print_scripts-' . $this->submenu, array( $this, 'admin_print_scripts' ) ); |
|
| 38 | + add_action('admin_print_styles-' . $this->submenu, array($this, 'admin_print_styles')); |
|
| 39 | + add_action('admin_print_scripts-' . $this->submenu, array($this, 'admin_print_scripts')); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Add css to administration |
| 44 | 44 | */ |
| 45 | 45 | function admin_print_styles() { |
| 46 | - wp_enqueue_style( 'wps-mass-product-update', WPS_PDCT_MASS_URL . '/assets/css/backend.css' ); |
|
| 46 | + wp_enqueue_style('wps-mass-product-update', WPS_PDCT_MASS_URL . '/assets/css/backend.css'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function admin_print_scripts() { |
| 53 | 53 | wp_enqueue_media(); |
| 54 | - wp_enqueue_script( 'admin_product_js', WPS_PDCT_MASS_URL . '/assets/js/backend.js', '', WPS_PDCT_MASS_VERSION, true ); |
|
| 54 | + wp_enqueue_script('admin_product_js', WPS_PDCT_MASS_URL . '/assets/js/backend.js', '', WPS_PDCT_MASS_VERSION, true); |
|
| 55 | 55 | $output = '<script type="text/javascript">'; |
| 56 | - $output .= 'var WPS_MASS_ERROR_INIT = "' .__( 'An error has occured, the page cannot be initialized', 'wpshop' ). '";'; |
|
| 57 | - $output .= 'var WPS_MASS_ERROR_PRODUCT_CREATION = "' .__( 'An error was occured, the new product cannot be created', 'wpshop' ). '";'; |
|
| 58 | - $output .= 'var WPS_MASS_ERROR_PRODUCT_SAVE = "' .__( 'You must select product to save', 'wpshop' ). '";'; |
|
| 59 | - $output .= 'var WPS_MASS_CONFIRMATION_NEW_PRODUCT = "' .__( 'You will save selected products, are you sure to continue ?', 'wpshop' ). '";'; |
|
| 56 | + $output .= 'var WPS_MASS_ERROR_INIT = "' . __('An error has occured, the page cannot be initialized', 'wpshop') . '";'; |
|
| 57 | + $output .= 'var WPS_MASS_ERROR_PRODUCT_CREATION = "' . __('An error was occured, the new product cannot be created', 'wpshop') . '";'; |
|
| 58 | + $output .= 'var WPS_MASS_ERROR_PRODUCT_SAVE = "' . __('You must select product to save', 'wpshop') . '";'; |
|
| 59 | + $output .= 'var WPS_MASS_CONFIRMATION_NEW_PRODUCT = "' . __('You will save selected products, are you sure to continue ?', 'wpshop') . '";'; |
|
| 60 | 60 | $output .= '</script>'; |
| 61 | 61 | echo $output; |
| 62 | 62 | } |
@@ -68,15 +68,15 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return array |
| 70 | 70 | */ |
| 71 | - function check_attribute_to_display_for_quick_add( $attribute_list, $quick_add_form_attributes = array() ) { |
|
| 72 | - |
|
| 73 | - if ( !empty( $attribute_list ) ) { |
|
| 74 | - foreach( $attribute_list as $attributes_group ) { |
|
| 75 | - foreach( $attributes_group as $attributes_sections ) { |
|
| 76 | - if( !empty($attributes_sections) && !empty($attributes_sections['attributes']) ) { |
|
| 77 | - foreach( $attributes_sections['attributes'] as $attribute_id => $att_def ) { |
|
| 78 | - if( !empty($att_def) && !empty($att_def['is_used_in_quick_add_form']) && $att_def['is_used_in_quick_add_form'] == 'yes' ) { |
|
| 79 | - $quick_add_form_attributes[ $attribute_id ] = $att_def; |
|
| 71 | + function check_attribute_to_display_for_quick_add($attribute_list, $quick_add_form_attributes = array()) { |
|
| 72 | + |
|
| 73 | + if (!empty($attribute_list)) { |
|
| 74 | + foreach ($attribute_list as $attributes_group) { |
|
| 75 | + foreach ($attributes_group as $attributes_sections) { |
|
| 76 | + if (!empty($attributes_sections) && !empty($attributes_sections['attributes'])) { |
|
| 77 | + foreach ($attributes_sections['attributes'] as $attribute_id => $att_def) { |
|
| 78 | + if (!empty($att_def) && !empty($att_def['is_used_in_quick_add_form']) && $att_def['is_used_in_quick_add_form'] == 'yes') { |
|
| 79 | + $quick_add_form_attributes[$attribute_id] = $att_def; |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -93,29 +93,29 @@ discard block |
||
| 93 | 93 | * @param integer $page |
| 94 | 94 | * @return string |
| 95 | 95 | */ |
| 96 | - function display_products_list( $default = 1, $page = 0, $order_by = 'date', $order = 'ASC' ) { |
|
| 96 | + function display_products_list($default = 1, $page = 0, $order_by = 'date', $order = 'ASC') { |
|
| 97 | 97 | global $wpdb; |
| 98 | 98 | // Product entity |
| 99 | - $product_entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
| 99 | + $product_entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
| 100 | 100 | |
| 101 | 101 | $user_id = get_current_user_id(); |
| 102 | 102 | // Check product limit |
| 103 | - $product_limit = get_user_meta( $user_id, 'edit_wpshop_product_per_page', true ); |
|
| 104 | - $product_limit = ( !empty($product_limit) ) ? $product_limit : 20; |
|
| 103 | + $product_limit = get_user_meta($user_id, 'edit_wpshop_product_per_page', true); |
|
| 104 | + $product_limit = (!empty($product_limit)) ? $product_limit : 20; |
|
| 105 | 105 | |
| 106 | 106 | // Get products for the current page |
| 107 | 107 | $wps_product_mass_interface_mdl = new wps_product_mass_interface_mdl(); |
| 108 | - $products = $wps_product_mass_interface_mdl->get_quick_interface_products( $default, $page, $product_limit ); |
|
| 108 | + $products = $wps_product_mass_interface_mdl->get_quick_interface_products($default, $page, $product_limit); |
|
| 109 | 109 | |
| 110 | 110 | // Construct Table Head Data |
| 111 | 111 | $quick_add_form_attributes = array(); |
| 112 | 112 | $get_attributes_quick_add_form = $wps_product_mass_interface_mdl->get_attributes_quick_add_form(); |
| 113 | - foreach( $get_attributes_quick_add_form as $quick_add_form_attribute ) { |
|
| 113 | + foreach ($get_attributes_quick_add_form as $quick_add_form_attribute) { |
|
| 114 | 114 | $quick_add_form_attributes[$quick_add_form_attribute['id']] = $quick_add_form_attribute; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | ob_start(); |
| 118 | - require( wpshop_tools::get_template_part( WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface", "product_list" ) ); |
|
| 118 | + require(wpshop_tools::get_template_part(WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface", "product_list")); |
|
| 119 | 119 | $output = ob_get_contents(); |
| 120 | 120 | ob_end_clean(); |
| 121 | 121 | return $output; |
@@ -131,27 +131,27 @@ discard block |
||
| 131 | 131 | $products_attributes_groups = $wps_product_mass_interface_mdl->get_product_attributes_sets(); |
| 132 | 132 | |
| 133 | 133 | $default = ''; |
| 134 | - if( !empty($products_attributes_groups) ) { |
|
| 135 | - foreach( $products_attributes_groups as $key => $products_attributes_group ) { |
|
| 136 | - if( $products_attributes_group->slug == 'free_product' ) { |
|
| 137 | - unset( $products_attributes_groups[$key] ); |
|
| 134 | + if (!empty($products_attributes_groups)) { |
|
| 135 | + foreach ($products_attributes_groups as $key => $products_attributes_group) { |
|
| 136 | + if ($products_attributes_group->slug == 'free_product') { |
|
| 137 | + unset($products_attributes_groups[$key]); |
|
| 138 | 138 | } |
| 139 | - if( !empty($products_attributes_group->default_set) && $products_attributes_group->default_set == 'yes' ) { |
|
| 139 | + if (!empty($products_attributes_group->default_set) && $products_attributes_group->default_set == 'yes') { |
|
| 140 | 140 | $default = $products_attributes_group->id; |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | // Check page |
| 145 | - $page = ( !empty( $_GET[ 'page' ] ) && is_int( (int)$_GET[ 'page' ] ) && $_GET[ 'page' ] > 0 ) ? (int)($_GET[ 'page' ] - 1) : 0; |
|
| 145 | + $page = (!empty($_GET['page']) && is_int((int)$_GET['page']) && $_GET['page'] > 0) ? (int)($_GET['page'] - 1) : 0; |
|
| 146 | 146 | // Display product tab |
| 147 | - $order_by = !empty( $_GET[ 'order_by' ] ) ? sanitize_title( $_GET[ 'order_by' ] ) : 'date'; |
|
| 148 | - $order = !empty( $_GET[ 'order' ] ) ? sanitize_title( $_GET[ 'order' ] ) : 'ASC'; |
|
| 149 | - $product_list_interface = $this->display_products_list( $default, $page, $order_by, $order ); |
|
| 147 | + $order_by = !empty($_GET['order_by']) ? sanitize_title($_GET['order_by']) : 'date'; |
|
| 148 | + $order = !empty($_GET['order']) ? sanitize_title($_GET['order']) : 'ASC'; |
|
| 149 | + $product_list_interface = $this->display_products_list($default, $page, $order_by, $order); |
|
| 150 | 150 | |
| 151 | 151 | // Get pagination |
| 152 | - $pagination = $this->get_products_pagination( $page, $default ); |
|
| 152 | + $pagination = $this->get_products_pagination($page, $default); |
|
| 153 | 153 | |
| 154 | - require( wpshop_tools::get_template_part( WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface" ) ); |
|
| 154 | + require(wpshop_tools::get_template_part(WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface")); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return string |
| 161 | 161 | */ |
| 162 | - function get_products_pagination( $current_page, $attribute_set_id = 1 ) { |
|
| 162 | + function get_products_pagination($current_page, $attribute_set_id = 1) { |
|
| 163 | 163 | global $wpdb; |
| 164 | 164 | $user_id = get_current_user_id(); |
| 165 | 165 | $output = ''; |
| 166 | 166 | /** Define the element number per page. If the user change the default value, take this value */ |
| 167 | - $one_page_limit = get_user_meta( $user_id, 'edit_wpshop_product_per_page', true ); |
|
| 168 | - $one_page_limit = ( !empty($one_page_limit) ) ? $one_page_limit : 20; |
|
| 167 | + $one_page_limit = get_user_meta($user_id, 'edit_wpshop_product_per_page', true); |
|
| 168 | + $one_page_limit = (!empty($one_page_limit)) ? $one_page_limit : 20; |
|
| 169 | 169 | |
| 170 | 170 | /** Count the number of product existing in the shop */ |
| 171 | 171 | $query = $wpdb->prepare( |
@@ -177,37 +177,37 @@ discard block |
||
| 177 | 177 | AND meta_value = %s |
| 178 | 178 | AND post_status IN ( 'publish', 'draft' )", |
| 179 | 179 | WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, '_wpshop_product_attribute_set_id', $attribute_set_id); |
| 180 | - $products = $wpdb->get_var( $query ); |
|
| 180 | + $products = $wpdb->get_var($query); |
|
| 181 | 181 | |
| 182 | - if( !empty($products) ) { |
|
| 182 | + if (!empty($products)) { |
|
| 183 | 183 | $args = array( |
| 184 | 184 | 'base' => '%_%', |
| 185 | - 'format' => admin_url( 'admin-ajax.php?action=wps_add_quick_interface&page=%#%' ), |
|
| 186 | - 'current' => ( $current_page + 1 ), |
|
| 187 | - 'total' => ceil( $products / $one_page_limit ), |
|
| 185 | + 'format' => admin_url('admin-ajax.php?action=wps_add_quick_interface&page=%#%'), |
|
| 186 | + 'current' => ($current_page + 1), |
|
| 187 | + 'total' => ceil($products / $one_page_limit), |
|
| 188 | 188 | 'type' => 'array', |
| 189 | 189 | 'prev_next' => false, |
| 190 | 190 | 'show_all' => true, |
| 191 | 191 | ); |
| 192 | - $paginate = paginate_links( $args ); |
|
| 192 | + $paginate = paginate_links($args); |
|
| 193 | 193 | |
| 194 | 194 | $wps_product_ctr = new wps_product_ctr(); |
| 195 | 195 | ob_start(); |
| 196 | - require( wpshop_tools::get_template_part( WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface_pagination" ) ); |
|
| 196 | + require(wpshop_tools::get_template_part(WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface_pagination")); |
|
| 197 | 197 | $output = ob_get_contents(); |
| 198 | 198 | ob_end_clean(); |
| 199 | 199 | } |
| 200 | 200 | return $output; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - function wps_product_attached_files( $product_id ) { |
|
| 203 | + function wps_product_attached_files($product_id) { |
|
| 204 | 204 | global $wpdb; |
| 205 | 205 | $output = ''; |
| 206 | - $query = $wpdb->prepare( 'SELECT * FROM ' .$wpdb->posts. ' WHERE post_parent = %d AND post_type = %s AND post_mime_type LIKE %s', $product_id, 'attachment', 'application%' ); |
|
| 207 | - $files = $wpdb->get_results( $query ); |
|
| 208 | - if( !empty($files) ) { |
|
| 206 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_parent = %d AND post_type = %s AND post_mime_type LIKE %s', $product_id, 'attachment', 'application%'); |
|
| 207 | + $files = $wpdb->get_results($query); |
|
| 208 | + if (!empty($files)) { |
|
| 209 | 209 | ob_start(); |
| 210 | - require( wpshop_tools::get_template_part( WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface", "attached_files_list" ) ); |
|
| 210 | + require(wpshop_tools::get_template_part(WPS_PDCT_MASS_DIR, WPS_PDCT_MASS_TEMPLATES_MAIN_DIR, "backend", "quick_add_interface", "attached_files_list")); |
|
| 211 | 211 | $output = ob_get_contents(); |
| 212 | 212 | ob_end_clean(); |
| 213 | 213 | } |
@@ -219,23 +219,23 @@ discard block |
||
| 219 | 219 | * AJAX - Change page action on mass edit product interface |
| 220 | 220 | */ |
| 221 | 221 | function wps_mass_edit_change_page() { |
| 222 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 222 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 223 | 223 | |
| 224 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_mass_edit_change_page' ) ) |
|
| 224 | + if (!wp_verify_nonce($_wpnonce, 'wps_mass_edit_change_page')) |
|
| 225 | 225 | wp_die(); |
| 226 | 226 | |
| 227 | 227 | $status = false; $response = ''; |
| 228 | - $page = ( !empty($_POST['page_id']) ) ? intval( $_POST['page_id'] ) - 1 : 0; |
|
| 229 | - $attribute_set_id = ( !empty($_POST['att_set_id']) ) ? intval( $_POST['att_set_id'] ) : 1; |
|
| 230 | - if( !empty($attribute_set_id) ) { |
|
| 228 | + $page = (!empty($_POST['page_id'])) ? intval($_POST['page_id']) - 1 : 0; |
|
| 229 | + $attribute_set_id = (!empty($_POST['att_set_id'])) ? intval($_POST['att_set_id']) : 1; |
|
| 230 | + if (!empty($attribute_set_id)) { |
|
| 231 | 231 | // Get tab |
| 232 | - $response = $this->display_products_list( $attribute_set_id, $page ); |
|
| 233 | - $pagination = $this->get_products_pagination( $page, $attribute_set_id ); |
|
| 234 | - if( !empty($response) ) { |
|
| 232 | + $response = $this->display_products_list($attribute_set_id, $page); |
|
| 233 | + $pagination = $this->get_products_pagination($page, $attribute_set_id); |
|
| 234 | + if (!empty($response)) { |
|
| 235 | 235 | $status = true; |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | - echo json_encode( array( 'status' => $status, 'response' => $response, 'pagination' => $pagination ) ); |
|
| 238 | + echo json_encode(array('status' => $status, 'response' => $response, 'pagination' => $pagination)); |
|
| 239 | 239 | wp_die(); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -243,30 +243,30 @@ discard block |
||
| 243 | 243 | * AJAX - Create a draft product and display the line allowing to edit informations for this product |
| 244 | 244 | */ |
| 245 | 245 | function wps_mass_interface_new_product_creation() { |
| 246 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 246 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 247 | 247 | |
| 248 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_mass_interface_new_product_creation' ) ) |
|
| 248 | + if (!wp_verify_nonce($_wpnonce, 'wps_mass_interface_new_product_creation')) |
|
| 249 | 249 | wp_die(); |
| 250 | 250 | |
| 251 | 251 | global $wpdb; |
| 252 | 252 | $output = $pagination = ''; |
| 253 | 253 | $status = false; |
| 254 | 254 | |
| 255 | - $new_product_id = wp_insert_post( array( |
|
| 255 | + $new_product_id = wp_insert_post(array( |
|
| 256 | 256 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, |
| 257 | 257 | 'post_status' => 'publish', |
| 258 | - 'post_title' => __( 'New product', 'wpshop' ), |
|
| 259 | - ) ); |
|
| 258 | + 'post_title' => __('New product', 'wpshop'), |
|
| 259 | + )); |
|
| 260 | 260 | |
| 261 | - if( !is_object($new_product_id) ) { |
|
| 261 | + if (!is_object($new_product_id)) { |
|
| 262 | 262 | $status = true; |
| 263 | 263 | } |
| 264 | - if ( !empty( $new_product_id ) ) { |
|
| 265 | - $product_attribute_set_id = ( !empty($_POST['attributes_set']) ) ? intval( $_POST['attributes_set'] ) : 1; |
|
| 266 | - update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $product_attribute_set_id ); |
|
| 264 | + if (!empty($new_product_id)) { |
|
| 265 | + $product_attribute_set_id = (!empty($_POST['attributes_set'])) ? intval($_POST['attributes_set']) : 1; |
|
| 266 | + update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $product_attribute_set_id); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - echo json_encode( array( 'status' => $status, 'response' => $output, 'pagination' => $pagination ) ); |
|
| 269 | + echo json_encode(array('status' => $status, 'response' => $output, 'pagination' => $pagination)); |
|
| 270 | 270 | wp_die(); |
| 271 | 271 | } |
| 272 | 272 | |
@@ -274,32 +274,32 @@ discard block |
||
| 274 | 274 | * AJAX - Save datas |
| 275 | 275 | */ |
| 276 | 276 | function wps_save_product_quick_interface() { |
| 277 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 277 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 278 | 278 | |
| 279 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_save_product_quick_interface' ) ) |
|
| 279 | + if (!wp_verify_nonce($_wpnonce, 'wps_save_product_quick_interface')) |
|
| 280 | 280 | wp_die(); |
| 281 | 281 | |
| 282 | 282 | global $wpdb; |
| 283 | 283 | $response = ''; $status = false; |
| 284 | 284 | $count_products_to_update = 0; $total_updated_products = 0; |
| 285 | 285 | |
| 286 | - $wps_product_quick_save = !empty( $_REQUEST['wps_product_quick_save'] ) ? (array) $_REQUEST['wps_product_quick_save'] : array(); |
|
| 287 | - $wps_mass_interface = !empty( $_REQUEST['wps_mass_interface'] ) ? (array) $_REQUEST['wps_mass_interface'] : array(); |
|
| 288 | - $wpshop_product_attribute = !empty( $_REQUEST['wpshop_product_attribute'] ) ? (array) $_REQUEST['wpshop_product_attribute'] : array(); |
|
| 286 | + $wps_product_quick_save = !empty($_REQUEST['wps_product_quick_save']) ? (array)$_REQUEST['wps_product_quick_save'] : array(); |
|
| 287 | + $wps_mass_interface = !empty($_REQUEST['wps_mass_interface']) ? (array)$_REQUEST['wps_mass_interface'] : array(); |
|
| 288 | + $wpshop_product_attribute = !empty($_REQUEST['wpshop_product_attribute']) ? (array)$_REQUEST['wpshop_product_attribute'] : array(); |
|
| 289 | 289 | |
| 290 | 290 | // ------------------------------------------------------------------------------------------------------ |
| 291 | 291 | |
| 292 | - foreach( $_REQUEST['concur'] as $post_id => $columns ) { |
|
| 292 | + foreach ($_REQUEST['concur'] as $post_id => $columns) { |
|
| 293 | 293 | $concur = array(); |
| 294 | - for( $i = $count = 0; $i <= $count; $i++ ) { |
|
| 295 | - foreach( $columns as $key => $rows ) { |
|
| 296 | - $count = count( $rows )-1; |
|
| 294 | + for ($i = $count = 0; $i <= $count; $i++) { |
|
| 295 | + foreach ($columns as $key => $rows) { |
|
| 296 | + $count = count($rows) - 1; |
|
| 297 | 297 | $concur[$i][$key] = $rows[$i]; |
| 298 | 298 | } |
| 299 | - if( empty( $concur[$i]['is_row'] ) ) { |
|
| 300 | - unset( $concur[$i] ); |
|
| 299 | + if (empty($concur[$i]['is_row'])) { |
|
| 300 | + unset($concur[$i]); |
|
| 301 | 301 | } else { |
| 302 | - unset( $concur[$i]['is_row'] ); |
|
| 302 | + unset($concur[$i]['is_row']); |
|
| 303 | 303 | |
| 304 | 304 | $dotPos = strrpos($concur[$i]['price'], '.'); |
| 305 | 305 | $commaPos = strrpos($concur[$i]['price'], ','); |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | } else { |
| 310 | 310 | $concur[$i]['price'] = floatval( |
| 311 | 311 | preg_replace("/[^0-9]/", "", substr($concur[$i]['price'], 0, $sep)) . '.' . |
| 312 | - preg_replace("/[^0-9]/", "", substr($concur[$i]['price'], $sep+1, strlen($concur[$i]['price']))) |
|
| 312 | + preg_replace("/[^0-9]/", "", substr($concur[$i]['price'], $sep + 1, strlen($concur[$i]['price']))) |
|
| 313 | 313 | ); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -317,51 +317,51 @@ discard block |
||
| 317 | 317 | $concur[$i]['price'] = $concur[$i]['price']; |
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | - update_post_meta( $post_id, '_concur', $concur ); |
|
| 320 | + update_post_meta($post_id, '_concur', $concur); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // ------------------------------------------------------------------------------------------------------ |
| 324 | 324 | |
| 325 | - if( !empty($wps_product_quick_save) ) { |
|
| 326 | - $count_products_to_update = count( $wps_product_quick_save ); |
|
| 327 | - foreach( $wps_product_quick_save as $product_to_save ) { |
|
| 325 | + if (!empty($wps_product_quick_save)) { |
|
| 326 | + $count_products_to_update = count($wps_product_quick_save); |
|
| 327 | + foreach ($wps_product_quick_save as $product_to_save) { |
|
| 328 | 328 | $data_to_save = array(); |
| 329 | 329 | // Update post |
| 330 | - $updated_post = wp_update_post( array( 'ID' => $product_to_save, |
|
| 331 | - 'post_title' => sanitize_text_field( $wps_mass_interface[$product_to_save]['post_title'] ), |
|
| 332 | - 'post_content' => wp_kses_post( $wps_mass_interface[$product_to_save]['post_content'] ), |
|
| 330 | + $updated_post = wp_update_post(array('ID' => $product_to_save, |
|
| 331 | + 'post_title' => sanitize_text_field($wps_mass_interface[$product_to_save]['post_title']), |
|
| 332 | + 'post_content' => wp_kses_post($wps_mass_interface[$product_to_save]['post_content']), |
|
| 333 | 333 | ) |
| 334 | 334 | ); |
| 335 | 335 | // Update attributes |
| 336 | - if( !empty($updated_post) ) { |
|
| 336 | + if (!empty($updated_post)) { |
|
| 337 | 337 | // Update Featured picture |
| 338 | - if( !empty($wps_mass_interface[$product_to_save]['picture']) ) { |
|
| 339 | - $thumbnail_exist = get_post_meta( $updated_post, '_thumbnail_id', true ); |
|
| 340 | - if($wps_mass_interface[$product_to_save]['picture'] != 'deleted') { |
|
| 341 | - wp_update_post( array('ID' => (int)$wps_mass_interface[$product_to_save]['picture'], 'post_parent' => $updated_post) ); |
|
| 342 | - update_post_meta( $updated_post, '_thumbnail_id', (int)$wps_mass_interface[$product_to_save]['picture'] ); |
|
| 338 | + if (!empty($wps_mass_interface[$product_to_save]['picture'])) { |
|
| 339 | + $thumbnail_exist = get_post_meta($updated_post, '_thumbnail_id', true); |
|
| 340 | + if ($wps_mass_interface[$product_to_save]['picture'] != 'deleted') { |
|
| 341 | + wp_update_post(array('ID' => (int)$wps_mass_interface[$product_to_save]['picture'], 'post_parent' => $updated_post)); |
|
| 342 | + update_post_meta($updated_post, '_thumbnail_id', (int)$wps_mass_interface[$product_to_save]['picture']); |
|
| 343 | 343 | } |
| 344 | - elseif($wps_mass_interface[$product_to_save]['picture'] == 'deleted' && !empty($thumbnail_exist)) { |
|
| 345 | - delete_post_meta( $updated_post, '_thumbnail_id' ); |
|
| 344 | + elseif ($wps_mass_interface[$product_to_save]['picture'] == 'deleted' && !empty($thumbnail_exist)) { |
|
| 345 | + delete_post_meta($updated_post, '_thumbnail_id'); |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | // Update files datas |
| 350 | - if( !empty($wps_mass_interface[$product_to_save]['files']) ) { |
|
| 351 | - $files_data = explode( ',', sanitize_text_field( $_REQUEST['wps_mass_interface'][$product_to_save]['files'] ) ); |
|
| 352 | - if( !empty($files_data) && is_array($files_data) ) { |
|
| 353 | - foreach( $files_data as $file_id ) { |
|
| 354 | - if( !empty($file_id) ) { |
|
| 355 | - wp_update_post( array('ID' => $file_id, 'post_parent' => $updated_post) ); |
|
| 350 | + if (!empty($wps_mass_interface[$product_to_save]['files'])) { |
|
| 351 | + $files_data = explode(',', sanitize_text_field($_REQUEST['wps_mass_interface'][$product_to_save]['files'])); |
|
| 352 | + if (!empty($files_data) && is_array($files_data)) { |
|
| 353 | + foreach ($files_data as $file_id) { |
|
| 354 | + if (!empty($file_id)) { |
|
| 355 | + wp_update_post(array('ID' => $file_id, 'post_parent' => $updated_post)); |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - $data_to_save['post_ID'] = $data_to_save['product_id'] = intval( $product_to_save ); |
|
| 362 | - $data_to_save['wpshop_product_attribute'] = ( !empty($wpshop_product_attribute[ $product_to_save ]) ) ? $wpshop_product_attribute[ $product_to_save ] : array(); |
|
| 361 | + $data_to_save['post_ID'] = $data_to_save['product_id'] = intval($product_to_save); |
|
| 362 | + $data_to_save['wpshop_product_attribute'] = (!empty($wpshop_product_attribute[$product_to_save])) ? $wpshop_product_attribute[$product_to_save] : array(); |
|
| 363 | 363 | |
| 364 | - if(empty($data_to_save['wpshop_product_attribute']['varchar']['barcode'])) { |
|
| 364 | + if (empty($data_to_save['wpshop_product_attribute']['varchar']['barcode'])) { |
|
| 365 | 365 | // Get current barcode |
| 366 | 366 | $wps_product_mdl = new wps_product_mdl(); |
| 367 | 367 | $attid = wpshop_attributes::getElement('barcode', "'valid'", 'code')->id; |
@@ -372,34 +372,34 @@ discard block |
||
| 372 | 372 | $data_to_save['user_ID'] = get_current_user_id(); |
| 373 | 373 | $data_to_save['action'] = 'editpost'; |
| 374 | 374 | |
| 375 | - if( !empty($wps_mass_interface[$product_to_save]['post_delete']) && $wps_mass_interface[$product_to_save]['post_delete'] == "true" ) { |
|
| 376 | - wp_trash_post( $product_to_save ); |
|
| 375 | + if (!empty($wps_mass_interface[$product_to_save]['post_delete']) && $wps_mass_interface[$product_to_save]['post_delete'] == "true") { |
|
| 376 | + wp_trash_post($product_to_save); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if( !empty($product_to_save) && !empty( $data_to_save['user_ID'] ) ) { |
|
| 379 | + if (!empty($product_to_save) && !empty($data_to_save['user_ID'])) { |
|
| 380 | 380 | $product_class = new wpshop_products(); |
| 381 | - $product_class->save_product_custom_informations( $product_to_save, $data_to_save ); |
|
| 381 | + $product_class->save_product_custom_informations($product_to_save, $data_to_save); |
|
| 382 | 382 | $total_updated_products++; |
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | // Checking status |
| 388 | - $status = ( $total_updated_products == $count_products_to_update ) ? true : false; |
|
| 388 | + $status = ($total_updated_products == $count_products_to_update) ? true : false; |
|
| 389 | 389 | |
| 390 | - if( $status ) { |
|
| 391 | - $response = sprintf( __( '%d products have been successfully updated', 'wpshop'), $total_updated_products ); |
|
| 390 | + if ($status) { |
|
| 391 | + $response = sprintf(__('%d products have been successfully updated', 'wpshop'), $total_updated_products); |
|
| 392 | 392 | } |
| 393 | 393 | else { |
| 394 | - if( !empty($total_updated_products) ) { |
|
| 395 | - $response = sprintf( __( 'All selected products do not be updated. %d on %d products have been successfully updated', 'wpshop'), $total_updated_products, $count_products_to_update ); |
|
| 394 | + if (!empty($total_updated_products)) { |
|
| 395 | + $response = sprintf(__('All selected products do not be updated. %d on %d products have been successfully updated', 'wpshop'), $total_updated_products, $count_products_to_update); |
|
| 396 | 396 | } |
| 397 | 397 | else { |
| 398 | - $response = __( 'No product have been updated', 'wpshop'); |
|
| 398 | + $response = __('No product have been updated', 'wpshop'); |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - echo json_encode( array('status' => $status, 'response' => $response ) ); |
|
| 402 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 403 | 403 | wp_die(); |
| 404 | 404 | } |
| 405 | 405 | |
@@ -407,18 +407,18 @@ discard block |
||
| 407 | 407 | * Delete product list |
| 408 | 408 | **/ |
| 409 | 409 | function wps_mass_delete_file() { |
| 410 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 410 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 411 | 411 | |
| 412 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_mass_delete_file' ) ) |
|
| 412 | + if (!wp_verify_nonce($_wpnonce, 'wps_mass_delete_file')) |
|
| 413 | 413 | wp_die(); |
| 414 | 414 | |
| 415 | 415 | $status = false; |
| 416 | - $file_id = (!empty($_POST['file_id']) ) ? intval($_POST['file_id']) : null; |
|
| 417 | - if( !empty($file_id) ) { |
|
| 418 | - wp_update_post( array('ID' => $file_id, 'post_parent' => 0) ); |
|
| 416 | + $file_id = (!empty($_POST['file_id'])) ? intval($_POST['file_id']) : null; |
|
| 417 | + if (!empty($file_id)) { |
|
| 418 | + wp_update_post(array('ID' => $file_id, 'post_parent' => 0)); |
|
| 419 | 419 | $status = true; |
| 420 | 420 | } |
| 421 | - echo json_encode( array( 'status' => $status ) ); |
|
| 421 | + echo json_encode(array('status' => $status)); |
|
| 422 | 422 | wp_die(); |
| 423 | 423 | } |
| 424 | 424 | |
@@ -426,32 +426,32 @@ discard block |
||
| 426 | 426 | * Update product files list |
| 427 | 427 | */ |
| 428 | 428 | function wps_mass_edit_update_files_list() { |
| 429 | - $_wpnonce = !empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 429 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 430 | 430 | |
| 431 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_mass_edit_update_files_list' ) ) |
|
| 431 | + if (!wp_verify_nonce($_wpnonce, 'wps_mass_edit_update_files_list')) |
|
| 432 | 432 | wp_die(); |
| 433 | 433 | |
| 434 | 434 | $status = false; $response = ''; |
| 435 | - $product_id = ( !empty($_POST['product_id']) ) ? intval($_POST['product_id']) : null; |
|
| 436 | - $files = ( !empty($_POST['files']) ) ? intval($_POST['files']) : null; |
|
| 437 | - if( !empty($product_id ) ) { |
|
| 435 | + $product_id = (!empty($_POST['product_id'])) ? intval($_POST['product_id']) : null; |
|
| 436 | + $files = (!empty($_POST['files'])) ? intval($_POST['files']) : null; |
|
| 437 | + if (!empty($product_id)) { |
|
| 438 | 438 | // Update files datas |
| 439 | - if( !empty($files) ) { |
|
| 440 | - $files_data = explode( ',', $files ); |
|
| 441 | - if( !empty($files_data) && is_array($files_data) ) { |
|
| 442 | - foreach( $files_data as $file_id ) { |
|
| 443 | - if( !empty($file_id) ) { |
|
| 444 | - wp_update_post( array('ID' => $file_id, 'post_parent' => $product_id) ); |
|
| 439 | + if (!empty($files)) { |
|
| 440 | + $files_data = explode(',', $files); |
|
| 441 | + if (!empty($files_data) && is_array($files_data)) { |
|
| 442 | + foreach ($files_data as $file_id) { |
|
| 443 | + if (!empty($file_id)) { |
|
| 444 | + wp_update_post(array('ID' => $file_id, 'post_parent' => $product_id)); |
|
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | |
| 451 | - $response = $this->wps_product_attached_files( $product_id ); |
|
| 451 | + $response = $this->wps_product_attached_files($product_id); |
|
| 452 | 452 | $status = true; |
| 453 | 453 | } |
| 454 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
| 454 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
| 455 | 455 | wp_die(); |
| 456 | 456 | } |
| 457 | 457 | |
@@ -1,14 +1,14 @@ |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) { exit; |
|
| 2 | 2 | } |
| 3 | 3 | |
| 4 | -if ( false ) { |
|
| 5 | - DEFINE( 'WPS_PDCT_MASS_VERSION', '2.0' ); |
|
| 6 | - DEFINE( 'WPS_PDCT_MASS_DIR', basename( dirname( __FILE__ ) ) ); |
|
| 7 | - DEFINE( 'WPS_PDCT_MASS_PATH', dirname( __FILE__ ) ); |
|
| 8 | - DEFINE( 'WPS_PDCT_MASS_URL', str_replace( str_replace( '\\', '/', ABSPATH ), site_url() . '/', str_replace( '\\', '/', WPS_PDCT_MASS_PATH ) ) ); |
|
| 4 | +if (false) { |
|
| 5 | + DEFINE('WPS_PDCT_MASS_VERSION', '2.0'); |
|
| 6 | + DEFINE('WPS_PDCT_MASS_DIR', basename(dirname(__FILE__))); |
|
| 7 | + DEFINE('WPS_PDCT_MASS_PATH', dirname(__FILE__)); |
|
| 8 | + DEFINE('WPS_PDCT_MASS_URL', str_replace(str_replace('\\', '/', ABSPATH), site_url() . '/', str_replace('\\', '/', WPS_PDCT_MASS_PATH))); |
|
| 9 | 9 | /** Define the templates directories */ |
| 10 | - DEFINE( 'WPS_PDCT_MASS_TEMPLATES_MAIN_DIR', WPS_PDCT_MASS_PATH . '/templates/' ); |
|
| 11 | - include( plugin_dir_path( __FILE__ ) . '/controller/wps_product_mass_interface_ctr.php' ); |
|
| 12 | - include( plugin_dir_path( __FILE__ ) . '/model/wps_product_mass_interface_mdl.php' ); |
|
| 10 | + DEFINE('WPS_PDCT_MASS_TEMPLATES_MAIN_DIR', WPS_PDCT_MASS_PATH . '/templates/'); |
|
| 11 | + include(plugin_dir_path(__FILE__) . '/controller/wps_product_mass_interface_ctr.php'); |
|
| 12 | + include(plugin_dir_path(__FILE__) . '/model/wps_product_mass_interface_mdl.php'); |
|
| 13 | 13 | // $wps_product_mass_interface_ctr = new wps_product_mass_interface_ctr(); |
| 14 | 14 | } |
@@ -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,12 +102,12 @@ 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 | 113 | return $columns; |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function get_sortable_columns() { |
| 122 | 122 | $sortable_columns = array( |
| 123 | - 'title' => array( 'title', false ), |
|
| 123 | + 'title' => array('title', false), |
|
| 124 | 124 | ); |
| 125 | - foreach ( $this->request_items_columns() as $column => $data_column ) { |
|
| 126 | - $sortable_columns[ $column ] = array( $data_column['code'], false ); |
|
| 125 | + foreach ($this->request_items_columns() as $column => $data_column) { |
|
| 126 | + $sortable_columns[$column] = array($data_column['code'], false); |
|
| 127 | 127 | } |
| 128 | 128 | return $sortable_columns; |
| 129 | 129 | } |
@@ -135,22 +135,22 @@ discard block |
||
| 135 | 135 | * @param string $column_name Current column. |
| 136 | 136 | * @return string |
| 137 | 137 | */ |
| 138 | - public function column_default( $item, $column_name ) { |
|
| 139 | - if ( isset( $this->columns_items[ $column_name ] ) && is_callable( array( $this, "column_data_{$this->columns_items[ $column_name ]['type']}" ) ) ) { |
|
| 140 | - $callable_ext = str_replace( '-', '_', $this->columns_items[ $column_name ]['type'] ); |
|
| 141 | - $callable = array( $this, "column_data_{$callable_ext}" ); |
|
| 142 | - if ( ! is_callable( $callable ) ) { |
|
| 143 | - $callable = array( $this, 'column_data_text' ); |
|
| 138 | + public function column_default($item, $column_name) { |
|
| 139 | + if (isset($this->columns_items[$column_name]) && is_callable(array($this, "column_data_{$this->columns_items[$column_name]['type']}"))) { |
|
| 140 | + $callable_ext = str_replace('-', '_', $this->columns_items[$column_name]['type']); |
|
| 141 | + $callable = array($this, "column_data_{$callable_ext}"); |
|
| 142 | + if (!is_callable($callable)) { |
|
| 143 | + $callable = array($this, 'column_data_text'); |
|
| 144 | 144 | } |
| 145 | 145 | return call_user_func( |
| 146 | 146 | $callable, |
| 147 | - (int) $this->columns_items[ $column_name ]['id'], |
|
| 148 | - $this->columns_items[ $column_name ]['code'], |
|
| 149 | - $this->columns_items[ $column_name ]['data'], |
|
| 147 | + (int)$this->columns_items[$column_name]['id'], |
|
| 148 | + $this->columns_items[$column_name]['code'], |
|
| 149 | + $this->columns_items[$column_name]['data'], |
|
| 150 | 150 | $item |
| 151 | 151 | ); |
| 152 | 152 | } |
| 153 | - return print_r( $item[ $column_name ], true ); |
|
| 153 | + return print_r($item[$column_name], true); |
|
| 154 | 154 | } |
| 155 | 155 | /** |
| 156 | 156 | * Column content for checkbox. |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param array $item Result of sql query. |
| 160 | 160 | * @return string |
| 161 | 161 | */ |
| 162 | - public function column_cb( $item ) { |
|
| 162 | + public function column_cb($item) { |
|
| 163 | 163 | return sprintf( |
| 164 | 164 | '<input type="checkbox" name="cb[]" value="%d" />', |
| 165 | 165 | $item['ID'] |
@@ -172,20 +172,20 @@ discard block |
||
| 172 | 172 | * @param array $item Result of sql query. |
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | - public function column_thumbnail( $item ) { |
|
| 175 | + public function column_thumbnail($item) { |
|
| 176 | 176 | $thumbnail_id = ''; |
| 177 | - $link_content = get_the_post_thumbnail( $item['ID'], array( 25, 25 ) ); |
|
| 178 | - if ( empty( $link_content ) ) { |
|
| 179 | - $link_content = __( 'Choose Image' ); |
|
| 177 | + $link_content = get_the_post_thumbnail($item['ID'], array(25, 25)); |
|
| 178 | + if (empty($link_content)) { |
|
| 179 | + $link_content = __('Choose Image'); |
|
| 180 | 180 | } else { |
| 181 | - $thumbnail_id = get_post_thumbnail_id( $item['ID'] ); |
|
| 181 | + $thumbnail_id = get_post_thumbnail_id($item['ID']); |
|
| 182 | 182 | } |
| 183 | - $popup_title = __( 'Choose Image' ); |
|
| 183 | + $popup_title = __('Choose Image'); |
|
| 184 | 184 | return sprintf( |
| 185 | 185 | '<input type="hidden" name="row_%1$s[thumbnail]" value="%2$s"><a href="#thumbnail" data-media-title="%3$s">%4$s</a>', |
| 186 | 186 | $item['ID'], |
| 187 | 187 | $thumbnail_id, |
| 188 | - __( 'Choose Image' ), |
|
| 188 | + __('Choose Image'), |
|
| 189 | 189 | $link_content |
| 190 | 190 | ); |
| 191 | 191 | } |
@@ -196,39 +196,39 @@ discard block |
||
| 196 | 196 | * @param array $item Result of sql query. |
| 197 | 197 | * @return string |
| 198 | 198 | */ |
| 199 | - public function column_title( $item ) { |
|
| 200 | - if ( 'private' === $item['status'] ) { |
|
| 201 | - $post_states['private'] = __( 'Private' ); |
|
| 199 | + public function column_title($item) { |
|
| 200 | + if ('private' === $item['status']) { |
|
| 201 | + $post_states['private'] = __('Private'); |
|
| 202 | 202 | } |
| 203 | - if ( 'draft' === $item['status'] ) { |
|
| 204 | - $post_states['draft'] = __( 'Draft' ); |
|
| 203 | + if ('draft' === $item['status']) { |
|
| 204 | + $post_states['draft'] = __('Draft'); |
|
| 205 | 205 | } |
| 206 | - if ( 'pending' === $item['status'] ) { |
|
| 207 | - $post_states['pending'] = _x( 'Pending', 'post status' ); |
|
| 206 | + if ('pending' === $item['status']) { |
|
| 207 | + $post_states['pending'] = _x('Pending', 'post status'); |
|
| 208 | 208 | } |
| 209 | - if ( 'future' === $item['status'] ) { |
|
| 210 | - $post_states['scheduled'] = __( 'Scheduled' ); |
|
| 209 | + if ('future' === $item['status']) { |
|
| 210 | + $post_states['scheduled'] = __('Scheduled'); |
|
| 211 | 211 | } |
| 212 | - if ( current_user_can( 'edit_post', $item['ID'] ) && 'trash' !== $item['status'] ) { |
|
| 212 | + if (current_user_can('edit_post', $item['ID']) && 'trash' !== $item['status']) { |
|
| 213 | 213 | $result = sprintf( |
| 214 | 214 | '<a class="row-title" href="%s" aria-label="%s">%s</a>', |
| 215 | - get_edit_post_link( $item['ID'] ), |
|
| 215 | + get_edit_post_link($item['ID']), |
|
| 216 | 216 | // translators: WordPress translate. |
| 217 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $item['title'] ) ), |
|
| 217 | + esc_attr(sprintf(__('“%s” (Edit)'), $item['title'])), |
|
| 218 | 218 | $item['title'] |
| 219 | 219 | ); |
| 220 | 220 | } else { |
| 221 | 221 | $result = $item['title']; |
| 222 | 222 | } |
| 223 | - if ( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item['type'] ) { |
|
| 224 | - $attr_def = get_post_meta( $item['ID'], '_wpshop_variations_attribute_def', true ); |
|
| 223 | + if (WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT_VARIATION === $item['type']) { |
|
| 224 | + $attr_def = get_post_meta($item['ID'], '_wpshop_variations_attribute_def', true); |
|
| 225 | 225 | $columns_items = $this->request_items_columns(); |
| 226 | 226 | $first_variation = true; |
| 227 | - $parent = $this->items[ $item['parent'] ]; |
|
| 228 | - foreach ( $attr_def as $key => $value ) { |
|
| 229 | - foreach ( $this->get_select_items_option( $columns_items[ $key ]['id'] ) as $all_value ) { |
|
| 230 | - if ( $all_value['id'] === $value ) { |
|
| 231 | - if ( $first_variation ) { |
|
| 227 | + $parent = $this->items[$item['parent']]; |
|
| 228 | + foreach ($attr_def as $key => $value) { |
|
| 229 | + foreach ($this->get_select_items_option($columns_items[$key]['id']) as $all_value) { |
|
| 230 | + if ($all_value['id'] === $value) { |
|
| 231 | + if ($first_variation) { |
|
| 232 | 232 | $result = $parent['title'] . ' : '; |
| 233 | 233 | $first_variation = false; |
| 234 | 234 | } else { |
@@ -240,19 +240,19 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | - if ( ! empty( $post_states ) ) { |
|
| 244 | - $state_count = count( $post_states ); |
|
| 243 | + if (!empty($post_states)) { |
|
| 244 | + $state_count = count($post_states); |
|
| 245 | 245 | $i = 0; |
| 246 | 246 | $result .= ' — '; |
| 247 | - foreach ( $post_states as $state ) { |
|
| 247 | + foreach ($post_states as $state) { |
|
| 248 | 248 | ++$i; |
| 249 | - ( $i === $state_count ) ? $sep = '' : $sep = ', '; |
|
| 249 | + ($i === $state_count) ? $sep = '' : $sep = ', '; |
|
| 250 | 250 | $result .= "<span class='post-state'>$state$sep</span>"; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | return sprintf( |
| 254 | 254 | '<strong>%s</strong>', |
| 255 | - isset( $item['lvl'] ) ? $item['lvl'] . $result : $result |
|
| 255 | + isset($item['lvl']) ? $item['lvl'] . $result : $result |
|
| 256 | 256 | ); |
| 257 | 257 | } |
| 258 | 258 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @param array $item Result of sql query. |
| 266 | 266 | * @return string |
| 267 | 267 | */ |
| 268 | - public function column_data_default( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 268 | + public function column_data_default($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 269 | 269 | return 'default'; |
| 270 | 270 | } |
| 271 | 271 | /** |
@@ -278,13 +278,13 @@ discard block |
||
| 278 | 278 | * @param array $item Result of sql query. |
| 279 | 279 | * @return string |
| 280 | 280 | */ |
| 281 | - public function column_data_text( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 281 | + public function column_data_text($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 282 | 282 | $unit = ''; |
| 283 | - if ( is_array( $item[ $attribute_code ] ) ) { |
|
| 284 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 285 | - $value = $item[ $attribute_code ]['value']; |
|
| 283 | + if (is_array($item[$attribute_code])) { |
|
| 284 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 285 | + $value = $item[$attribute_code]['value']; |
|
| 286 | 286 | } else { |
| 287 | - $value = $item[ $attribute_code ]; |
|
| 287 | + $value = $item[$attribute_code]; |
|
| 288 | 288 | } |
| 289 | 289 | return sprintf( |
| 290 | 290 | '<input type="text" name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]" value="%4$s">', |
@@ -305,34 +305,34 @@ discard block |
||
| 305 | 305 | * @param array $item Result of sql query. |
| 306 | 306 | * @return string |
| 307 | 307 | */ |
| 308 | - public function column_data_select( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 308 | + public function column_data_select($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 309 | 309 | $unit = ''; |
| 310 | - if ( is_array( $item[ $attribute_code ] ) && isset( $item[ $attribute_code ]['unit'] ) ) { |
|
| 311 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 312 | - $value = $item[ $attribute_code ]['value']; |
|
| 310 | + if (is_array($item[$attribute_code]) && isset($item[$attribute_code]['unit'])) { |
|
| 311 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 312 | + $value = $item[$attribute_code]['value']; |
|
| 313 | 313 | } else { |
| 314 | - $value = $item[ $attribute_code ]; |
|
| 314 | + $value = $item[$attribute_code]; |
|
| 315 | 315 | } |
| 316 | 316 | $has_selected = false; |
| 317 | 317 | $select_items = array(); |
| 318 | - foreach ( $this->get_select_items_option( $attribute_id ) as $option_item ) { |
|
| 319 | - if ( is_array( $value ) ) { |
|
| 320 | - foreach ( $value as $val ) { |
|
| 321 | - $selected = selected( $val, $option_item['id'], false ); |
|
| 322 | - if ( ! empty( $selected ) ) { |
|
| 318 | + foreach ($this->get_select_items_option($attribute_id) as $option_item) { |
|
| 319 | + if (is_array($value)) { |
|
| 320 | + foreach ($value as $val) { |
|
| 321 | + $selected = selected($val, $option_item['id'], false); |
|
| 322 | + if (!empty($selected)) { |
|
| 323 | 323 | break; |
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | } else { |
| 327 | - $selected = selected( $value, $option_item['id'], false ); |
|
| 327 | + $selected = selected($value, $option_item['id'], false); |
|
| 328 | 328 | } |
| 329 | - $has_selected = empty( $selected ) ? $has_selected : true; |
|
| 329 | + $has_selected = empty($selected) ? $has_selected : true; |
|
| 330 | 330 | $select_items[] = "<option value=\"{$option_item['id']}\"{$selected}>{$option_item['label']}</option>"; |
| 331 | 331 | } |
| 332 | - if ( ! $has_selected ) { |
|
| 333 | - array_unshift( $select_items, '<option selected disabled>' . __( 'None' ) . '</option>' ); |
|
| 332 | + if (!$has_selected) { |
|
| 333 | + array_unshift($select_items, '<option selected disabled>' . __('None') . '</option>'); |
|
| 334 | 334 | } |
| 335 | - $select_items = implode( '', $select_items ); |
|
| 335 | + $select_items = implode('', $select_items); |
|
| 336 | 336 | return sprintf( |
| 337 | 337 | '<select name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]">%4$s</select>', |
| 338 | 338 | $attribute_code, |
@@ -352,13 +352,13 @@ discard block |
||
| 352 | 352 | * @param array $item Result of sql query. |
| 353 | 353 | * @return string |
| 354 | 354 | */ |
| 355 | - public function column_data_textarea( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 355 | + public function column_data_textarea($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 356 | 356 | $unit = ''; |
| 357 | - if ( is_array( $item[ $attribute_code ] ) ) { |
|
| 358 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 359 | - $value = $item[ $attribute_code ]['value']; |
|
| 357 | + if (is_array($item[$attribute_code])) { |
|
| 358 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 359 | + $value = $item[$attribute_code]['value']; |
|
| 360 | 360 | } else { |
| 361 | - $value = $item[ $attribute_code ]; |
|
| 361 | + $value = $item[$attribute_code]; |
|
| 362 | 362 | } |
| 363 | 363 | return sprintf( |
| 364 | 364 | '<textarea name="row_%2$s[wpshop_product_attribute][%3$s][%1$s]">%4$s</textarea>', |
@@ -379,29 +379,29 @@ discard block |
||
| 379 | 379 | * @param array $item Result of sql query. |
| 380 | 380 | * @return string |
| 381 | 381 | */ |
| 382 | - public function column_data_multiple_select( $attribute_id, $attribute_code, $attribute_data, $item ) { |
|
| 382 | + public function column_data_multiple_select($attribute_id, $attribute_code, $attribute_data, $item) { |
|
| 383 | 383 | $unit = ''; |
| 384 | - if ( is_array( $item[ $attribute_code ] ) && isset( $item[ $attribute_code ]['unit'] ) ) { |
|
| 385 | - $unit = ' ' . $item[ $attribute_code ]['unit']; |
|
| 386 | - $value = $item[ $attribute_code ]['value']; |
|
| 384 | + if (is_array($item[$attribute_code]) && isset($item[$attribute_code]['unit'])) { |
|
| 385 | + $unit = ' ' . $item[$attribute_code]['unit']; |
|
| 386 | + $value = $item[$attribute_code]['value']; |
|
| 387 | 387 | } else { |
| 388 | - $value = $item[ $attribute_code ]; |
|
| 388 | + $value = $item[$attribute_code]; |
|
| 389 | 389 | } |
| 390 | 390 | $select_items = array(); |
| 391 | - foreach ( $this->get_select_items_option( $attribute_id ) as $option_item ) { |
|
| 392 | - if ( is_array( $value ) ) { |
|
| 393 | - foreach ( $value as $val ) { |
|
| 394 | - $selected = selected( $val, $option_item['id'], false ); |
|
| 395 | - if ( ! empty( $selected ) ) { |
|
| 391 | + foreach ($this->get_select_items_option($attribute_id) as $option_item) { |
|
| 392 | + if (is_array($value)) { |
|
| 393 | + foreach ($value as $val) { |
|
| 394 | + $selected = selected($val, $option_item['id'], false); |
|
| 395 | + if (!empty($selected)) { |
|
| 396 | 396 | break; |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | } else { |
| 400 | - $selected = selected( $value, $option_item['id'], false ); |
|
| 400 | + $selected = selected($value, $option_item['id'], false); |
|
| 401 | 401 | } |
| 402 | 402 | $select_items[] = "<option value=\"{$option_item['id']}\"{$selected}>{$option_item['label']}</option>"; |
| 403 | 403 | } |
| 404 | - $select_items = implode( '', $select_items ); |
|
| 404 | + $select_items = implode('', $select_items); |
|
| 405 | 405 | return sprintf( |
| 406 | 406 | '<select class="chosen-select" multiple data-placeholder="%6$s" name="row_%2$s[wpshop_product_attribute][%3$s][%1$s][]">%4$s</select>', |
| 407 | 407 | $attribute_code, |
@@ -419,9 +419,9 @@ discard block |
||
| 419 | 419 | * @param Mixed $id_post Null = all / Int = single. |
| 420 | 420 | * @return array Return all values with ARRAY_A. |
| 421 | 421 | */ |
| 422 | - public function request( $id_post = null ) { |
|
| 422 | + public function request($id_post = null) { |
|
| 423 | 423 | global $wpdb; |
| 424 | - $per_page = $this->get_items_per_page( $this->screen->get_option( 'per_page', 'option' ) ); |
|
| 424 | + $per_page = $this->get_items_per_page($this->screen->get_option('per_page', 'option')); |
|
| 425 | 425 | $include_states = array( |
| 426 | 426 | 'publish', |
| 427 | 427 | 'future', |
@@ -431,24 +431,24 @@ discard block |
||
| 431 | 431 | 'trash', |
| 432 | 432 | 'scheduled', |
| 433 | 433 | ); |
| 434 | - $include_states = implode( "','", $include_states ); |
|
| 435 | - $post_types = implode( "','", $this->_post_types ); |
|
| 436 | - $orderby = isset( $_REQUEST['orderby'] ) ? esc_sql( $_REQUEST['orderby'] ) : 'p.post_date'; // WPCS: CSRF ok. |
|
| 437 | - $order = isset( $_REQUEST['order'] ) ? esc_sql( $_REQUEST['order'] ) : 'DESC'; // WPCS: CSRF ok. |
|
| 438 | - $cast = isset( $_REQUEST['cast'] ) ? esc_sql( $_REQUEST['cast'] ) : ''; // WPCS: CSRF ok. |
|
| 439 | - $cast = strtoupper( $cast ); |
|
| 440 | - $s = isset( $_REQUEST['s'] ) ? esc_sql( $_REQUEST['s'] ) : ''; // WPCS: CSRF ok. |
|
| 441 | - $exclude_attribute_codes = implode( "','", $this->exclude_attribute_codes ); |
|
| 434 | + $include_states = implode("','", $include_states); |
|
| 435 | + $post_types = implode("','", $this->_post_types); |
|
| 436 | + $orderby = isset($_REQUEST['orderby']) ? esc_sql($_REQUEST['orderby']) : 'p.post_date'; // WPCS: CSRF ok. |
|
| 437 | + $order = isset($_REQUEST['order']) ? esc_sql($_REQUEST['order']) : 'DESC'; // WPCS: CSRF ok. |
|
| 438 | + $cast = isset($_REQUEST['cast']) ? esc_sql($_REQUEST['cast']) : ''; // WPCS: CSRF ok. |
|
| 439 | + $cast = strtoupper($cast); |
|
| 440 | + $s = isset($_REQUEST['s']) ? esc_sql($_REQUEST['s']) : ''; // WPCS: CSRF ok. |
|
| 441 | + $exclude_attribute_codes = implode("','", $this->exclude_attribute_codes); |
|
| 442 | 442 | $extra = ''; |
| 443 | - $items_count = $wpdb->prepare( "SELECT FOUND_ROWS() FROM {$wpdb->posts} WHERE 1 = %d", 1 ); |
|
| 444 | - if ( ! is_null( $id_post ) ) { |
|
| 445 | - $id_post = intval( $id_post ); |
|
| 443 | + $items_count = $wpdb->prepare("SELECT FOUND_ROWS() FROM {$wpdb->posts} WHERE 1 = %d", 1); |
|
| 444 | + if (!is_null($id_post)) { |
|
| 445 | + $id_post = intval($id_post); |
|
| 446 | 446 | $extra = " |
| 447 | 447 | AND p.ID = {$id_post}"; |
| 448 | 448 | $s = ''; |
| 449 | 449 | } |
| 450 | 450 | $true = true; |
| 451 | - if ( $true ) { // FOUND_ROWS incompatibilities ? |
|
| 451 | + if ($true) { // FOUND_ROWS incompatibilities ? |
|
| 452 | 452 | $items_count = $wpdb->prepare( |
| 453 | 453 | "SELECT COUNT(*) |
| 454 | 454 | FROM {$wpdb->posts} p |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | $wpsdb_values_text = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; |
| 471 | 471 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
| 472 | 472 | $extra_select = ''; |
| 473 | - if ( ! in_array( $orderby, array( 'p.post_date', 'title', 'ID' ), true ) ) { |
|
| 473 | + if (!in_array($orderby, array('p.post_date', 'title', 'ID'), true)) { |
|
| 474 | 474 | $extra_select = "GROUP_CONCAT( ( SELECT IFNULL( val_dec1.value, |
| 475 | 475 | IFNULL( val_dat1.value, |
| 476 | 476 | IFNULL( val_tex1.value, |
@@ -491,15 +491,15 @@ discard block |
||
| 491 | 491 | LEFT JOIN {$wpsdb_values_varchar} val_var1 ON val_var1.attribute_id = attr1.id AND val_var1.entity_id = p1.ID |
| 492 | 492 | LEFT JOIN {$wpsdb_values_options} val_opt1 ON val_opt1.attribute_id = attr1.id AND val_opt1.id = val_int1.value |
| 493 | 493 | WHERE p1.ID = p.ID ) SEPARATOR ' ' )"; |
| 494 | - print_r( $extra_select ); |
|
| 495 | - if ( ! empty( $cast ) ) { |
|
| 494 | + print_r($extra_select); |
|
| 495 | + if (!empty($cast)) { |
|
| 496 | 496 | $extra_select = "CAST( {$extra_select} AS {$cast} )"; |
| 497 | 497 | } |
| 498 | 498 | $extra_select = ", |
| 499 | 499 | {$extra_select} AS {$orderby}"; |
| 500 | 500 | } |
| 501 | 501 | $wpdb->query( |
| 502 | - $wpdb->prepare( 'SET SESSION group_concat_max_len = %d', 1000000 ) |
|
| 502 | + $wpdb->prepare('SET SESSION group_concat_max_len = %d', 1000000) |
|
| 503 | 503 | ); |
| 504 | 504 | $datas = $wpdb->get_results( |
| 505 | 505 | $wpdb->prepare( |
@@ -555,23 +555,23 @@ discard block |
||
| 555 | 555 | $this->request_current_view(), |
| 556 | 556 | $this->entity_id, |
| 557 | 557 | '%' . $s . '%', |
| 558 | - ( $this->get_pagenum() -1 ) * $per_page, |
|
| 558 | + ($this->get_pagenum() - 1) * $per_page, |
|
| 559 | 559 | $per_page |
| 560 | 560 | ), |
| 561 | 561 | ARRAY_A |
| 562 | 562 | ); |
| 563 | - if ( ! is_array( $datas ) ) { |
|
| 563 | + if (!is_array($datas)) { |
|
| 564 | 564 | $datas = array(); |
| 565 | 565 | } |
| 566 | - if ( ! isset( $this->_pagination_args['total_items'] ) && ! isset( $this->_pagination_args['per_page'] ) ) { |
|
| 566 | + if (!isset($this->_pagination_args['total_items']) && !isset($this->_pagination_args['per_page'])) { |
|
| 567 | 567 | $this->set_pagination_args( |
| 568 | 568 | array( |
| 569 | - 'total_items' => (int) $wpdb->get_var( $items_count ), |
|
| 570 | - 'per_page' => $this->get_items_per_page( $this->screen->get_option( 'per_page', 'option' ) ), |
|
| 569 | + 'total_items' => (int)$wpdb->get_var($items_count), |
|
| 570 | + 'per_page' => $this->get_items_per_page($this->screen->get_option('per_page', 'option')), |
|
| 571 | 571 | ) |
| 572 | 572 | ); |
| 573 | 573 | } |
| 574 | - return array_map( array( $this, 'data_reorganize' ), $datas ); |
|
| 574 | + return array_map(array($this, 'data_reorganize'), $datas); |
|
| 575 | 575 | } |
| 576 | 576 | /** |
| 577 | 577 | * Main function to call before display WP_List_Table. See parent class. |
@@ -580,8 +580,8 @@ discard block |
||
| 580 | 580 | * @return void Same results as request() but id as key. |
| 581 | 581 | */ |
| 582 | 582 | public function prepare_items() { |
| 583 | - foreach ( $this->request() as $item ) { |
|
| 584 | - $this->items[ $item['ID'] ] = $item; |
|
| 583 | + foreach ($this->request() as $item) { |
|
| 584 | + $this->items[$item['ID']] = $item; |
|
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | 587 | /** |
@@ -591,20 +591,20 @@ discard block |
||
| 591 | 591 | * @param string $column_key Current column. |
| 592 | 592 | * @return string |
| 593 | 593 | */ |
| 594 | - public function cast_column( $column_key ) { |
|
| 594 | + public function cast_column($column_key) { |
|
| 595 | 595 | $columns_items = $this->request_items_columns(); |
| 596 | - if ( isset( $columns_items[ $column_key ] ) ) { |
|
| 597 | - $cast = $columns_items[ $column_key ]['data']; |
|
| 598 | - if ( in_array( $cast, array( 'varchar', 'text' ), true ) ) { |
|
| 596 | + if (isset($columns_items[$column_key])) { |
|
| 597 | + $cast = $columns_items[$column_key]['data']; |
|
| 598 | + if (in_array($cast, array('varchar', 'text'), true)) { |
|
| 599 | 599 | $cast = 'char'; |
| 600 | 600 | } |
| 601 | - if ( 'tx_tva' === $column_key ) { |
|
| 601 | + if ('tx_tva' === $column_key) { |
|
| 602 | 602 | return 'decimal'; |
| 603 | 603 | } |
| 604 | - if ( 'integer' === $cast && 'select' === $columns_items[ $column_key ]['type'] ) { |
|
| 604 | + if ('integer' === $cast && 'select' === $columns_items[$column_key]['type']) { |
|
| 605 | 605 | return null; |
| 606 | 606 | } |
| 607 | - if ( 'integer' === $cast && 'multiple-select' === $columns_items[ $column_key ]['type'] ) { |
|
| 607 | + if ('integer' === $cast && 'multiple-select' === $columns_items[$column_key]['type']) { |
|
| 608 | 608 | return null; |
| 609 | 609 | } |
| 610 | 610 | return $cast; |
@@ -618,12 +618,12 @@ discard block |
||
| 618 | 618 | * @param array $item Result of sql query. |
| 619 | 619 | * @return array Item reorganized. |
| 620 | 620 | */ |
| 621 | - public function data_reorganize( $item ) { |
|
| 622 | - $values = explode( ';', $item['data'] ); |
|
| 623 | - foreach ( $values as $value ) { |
|
| 624 | - $value = explode( ':', $value ); |
|
| 625 | - if ( ! isset( $this->columns_items[ $value[1] ] ) ) { |
|
| 626 | - $this->columns_items[ $value[1] ] = array( |
|
| 621 | + public function data_reorganize($item) { |
|
| 622 | + $values = explode(';', $item['data']); |
|
| 623 | + foreach ($values as $value) { |
|
| 624 | + $value = explode(':', $value); |
|
| 625 | + if (!isset($this->columns_items[$value[1]])) { |
|
| 626 | + $this->columns_items[$value[1]] = array( |
|
| 627 | 627 | 'id' => $value[0], |
| 628 | 628 | 'code' => $value[1], |
| 629 | 629 | 'name' => $value[2], |
@@ -631,32 +631,32 @@ discard block |
||
| 631 | 631 | 'data' => $value[7], |
| 632 | 632 | ); |
| 633 | 633 | } |
| 634 | - if ( 'yes' === $value[4] ) { |
|
| 635 | - if ( isset( $item[ $value[1] ]['value'] ) ) { |
|
| 636 | - if ( is_array( $item[ $value[1] ]['value'] ) ) { |
|
| 637 | - $item[ $value[1] ]['value'][] = $value[3]; |
|
| 634 | + if ('yes' === $value[4]) { |
|
| 635 | + if (isset($item[$value[1]]['value'])) { |
|
| 636 | + if (is_array($item[$value[1]]['value'])) { |
|
| 637 | + $item[$value[1]]['value'][] = $value[3]; |
|
| 638 | 638 | } else { |
| 639 | - $item[ $value[1] ]['value'] = array( $item[ $value[1] ]['value'], $value[3] ); |
|
| 639 | + $item[$value[1]]['value'] = array($item[$value[1]]['value'], $value[3]); |
|
| 640 | 640 | } |
| 641 | 641 | } else { |
| 642 | - $item[ $value[1] ] = array( |
|
| 642 | + $item[$value[1]] = array( |
|
| 643 | 643 | 'value' => $value[3], |
| 644 | 644 | 'unit' => $value[5], |
| 645 | 645 | ); |
| 646 | 646 | } |
| 647 | 647 | } else { |
| 648 | - if ( isset( $item[ $value[1] ] ) ) { |
|
| 649 | - if ( is_array( $item[ $value[1] ] ) ) { |
|
| 650 | - $item[ $value[1] ][] = $value[3]; |
|
| 651 | - } elseif ( $item[ $value[1] ] !== $value[3] ) { |
|
| 652 | - $item[ $value[1] ] = array( $item[ $value[1] ], $value[3] ); |
|
| 648 | + if (isset($item[$value[1]])) { |
|
| 649 | + if (is_array($item[$value[1]])) { |
|
| 650 | + $item[$value[1]][] = $value[3]; |
|
| 651 | + } elseif ($item[$value[1]] !== $value[3]) { |
|
| 652 | + $item[$value[1]] = array($item[$value[1]], $value[3]); |
|
| 653 | 653 | } |
| 654 | 654 | } else { |
| 655 | - $item[ $value[1] ] = $value[3]; |
|
| 655 | + $item[$value[1]] = $value[3]; |
|
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | 658 | }// End foreach(). |
| 659 | - unset( $item['data'] ); |
|
| 659 | + unset($item['data']); |
|
| 660 | 660 | return $item; |
| 661 | 661 | } |
| 662 | 662 | /** |
@@ -666,11 +666,11 @@ discard block |
||
| 666 | 666 | * @param int $attribute_id Attribute ID. |
| 667 | 667 | * @return array |
| 668 | 668 | */ |
| 669 | - public function get_select_items_option( $attribute_id ) { |
|
| 670 | - if ( ! isset( self::$wpsdb_values_options[ $attribute_id ] ) ) { |
|
| 669 | + public function get_select_items_option($attribute_id) { |
|
| 670 | + if (!isset(self::$wpsdb_values_options[$attribute_id])) { |
|
| 671 | 671 | global $wpdb; |
| 672 | 672 | $wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; |
| 673 | - self::$wpsdb_values_options[ $attribute_id ] = $wpdb->get_results( |
|
| 673 | + self::$wpsdb_values_options[$attribute_id] = $wpdb->get_results( |
|
| 674 | 674 | $wpdb->prepare( |
| 675 | 675 | "SELECT * |
| 676 | 676 | FROM {$wpsdb_values_options} |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | ARRAY_A |
| 682 | 682 | ); |
| 683 | 683 | } |
| 684 | - return self::$wpsdb_values_options[ $attribute_id ]; |
|
| 684 | + return self::$wpsdb_values_options[$attribute_id]; |
|
| 685 | 685 | } |
| 686 | 686 | /** |
| 687 | 687 | * Get all views available. |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | */ |
| 692 | 692 | public function request_views() { |
| 693 | 693 | global $wpdb; |
| 694 | - if ( is_null( $this->_views ) ) { |
|
| 694 | + if (is_null($this->_views)) { |
|
| 695 | 695 | $wpsdb_sets = WPSHOP_DBT_ATTRIBUTE_SET; |
| 696 | 696 | $include_states = array( |
| 697 | 697 | 'publish', |
@@ -702,8 +702,8 @@ discard block |
||
| 702 | 702 | 'trash', |
| 703 | 703 | 'scheduled', |
| 704 | 704 | ); |
| 705 | - $include_states = implode( "','", $include_states ); |
|
| 706 | - $post_types = implode( "','", $this->_post_types ); |
|
| 705 | + $include_states = implode("','", $include_states); |
|
| 706 | + $post_types = implode("','", $this->_post_types); |
|
| 707 | 707 | $this->_views = $wpdb->get_results( |
| 708 | 708 | $wpdb->prepare( |
| 709 | 709 | "SELECT s.id, name, slug, default_set, COUNT(p.ID) AS count |
@@ -729,9 +729,9 @@ discard block |
||
| 729 | 729 | * @return [type] [description] |
| 730 | 730 | */ |
| 731 | 731 | public function request_current_view() { |
| 732 | - if ( is_null( $this->current_view ) ) { |
|
| 733 | - foreach ( $this->request_views() as $view ) { |
|
| 734 | - if ( filter_var( $view['default_set'], FILTER_VALIDATE_BOOLEAN ) ) { |
|
| 732 | + if (is_null($this->current_view)) { |
|
| 733 | + foreach ($this->request_views() as $view) { |
|
| 734 | + if (filter_var($view['default_set'], FILTER_VALIDATE_BOOLEAN)) { |
|
| 735 | 735 | $this->current_view = $view['id']; |
| 736 | 736 | } |
| 737 | 737 | } |
@@ -745,12 +745,12 @@ discard block |
||
| 745 | 745 | * @return array See :754 order columns. |
| 746 | 746 | */ |
| 747 | 747 | public function request_items_columns() { |
| 748 | - if ( empty( $this->columns_items ) ) { |
|
| 748 | + if (empty($this->columns_items)) { |
|
| 749 | 749 | global $wpdb; |
| 750 | 750 | $wpsdb_attribute = WPSHOP_DBT_ATTRIBUTE; |
| 751 | 751 | $wpsdb_attribute_set = WPSHOP_DBT_ATTRIBUTE_DETAILS; |
| 752 | - $exclude_attribute_codes = implode( "','", $this->exclude_attribute_codes ); |
|
| 753 | - foreach ( $wpdb->get_results( |
|
| 752 | + $exclude_attribute_codes = implode("','", $this->exclude_attribute_codes); |
|
| 753 | + foreach ($wpdb->get_results( |
|
| 754 | 754 | $wpdb->prepare( |
| 755 | 755 | "SELECT attr.id, attr.code, attr.frontend_label AS name, attr.backend_input AS type, attr.data_type AS data |
| 756 | 756 | FROM {$wpsdb_attribute} attr |
@@ -764,11 +764,11 @@ discard block |
||
| 764 | 764 | $this->entity_id |
| 765 | 765 | ), |
| 766 | 766 | ARRAY_A |
| 767 | - ) as $column ) { |
|
| 768 | - $this->columns_items[ $column['code'] ] = $column; |
|
| 767 | + ) as $column) { |
|
| 768 | + $this->columns_items[$column['code']] = $column; |
|
| 769 | 769 | } |
| 770 | 770 | } |
| 771 | - ksort( $this->columns_items ); |
|
| 771 | + ksort($this->columns_items); |
|
| 772 | 772 | return $this->columns_items; |
| 773 | 773 | } |
| 774 | 774 | /** |
@@ -779,9 +779,9 @@ discard block |
||
| 779 | 779 | */ |
| 780 | 780 | public function get_views() { |
| 781 | 781 | $result = array(); |
| 782 | - foreach ( $this->request_views() as $view ) { |
|
| 782 | + foreach ($this->request_views() as $view) { |
|
| 783 | 783 | $class = ''; |
| 784 | - if ( (int) $view['id'] === (int) $this->request_current_view() ) { |
|
| 784 | + if ((int)$view['id'] === (int)$this->request_current_view()) { |
|
| 785 | 785 | $class = ' class="current"'; |
| 786 | 786 | } |
| 787 | 787 | $link = add_query_arg( |
@@ -790,17 +790,17 @@ discard block |
||
| 790 | 790 | str_replace( |
| 791 | 791 | "{$this->screen->post_type}_page_", |
| 792 | 792 | '', |
| 793 | - substr( $this->screen->id, 0, strpos( $this->screen->id, '_att_set_' ) ) . '_att_set_' . $view['id'] |
|
| 793 | + substr($this->screen->id, 0, strpos($this->screen->id, '_att_set_')) . '_att_set_' . $view['id'] |
|
| 794 | 794 | ), |
| 795 | 795 | ) |
| 796 | 796 | ); |
| 797 | - $link = remove_query_arg( 'paged', $link ); |
|
| 798 | - $result[ $view['id'] ] = sprintf( |
|
| 797 | + $link = remove_query_arg('paged', $link); |
|
| 798 | + $result[$view['id']] = sprintf( |
|
| 799 | 799 | '<a href="%s"%s>%s <span class="count">(%s)</span></a>', |
| 800 | - esc_url( $link ), |
|
| 800 | + esc_url($link), |
|
| 801 | 801 | $class, |
| 802 | 802 | $view['name'], |
| 803 | - number_format_i18n( $view['count'] ) |
|
| 803 | + number_format_i18n($view['count']) |
|
| 804 | 804 | ); |
| 805 | 805 | } |
| 806 | 806 | return $result; |
@@ -812,10 +812,10 @@ discard block |
||
| 812 | 812 | * @param string $which Can be top or bottom. |
| 813 | 813 | * @return void Direct display. |
| 814 | 814 | */ |
| 815 | - public function bulk_actions( $which = '' ) { |
|
| 816 | - submit_button( __( 'Save changes', 'wpshop' ), 'bulk-save', 'bulk-save', false, array( |
|
| 817 | - 'data-nonce' => wp_create_nonce( 'bulk-save-' . $this->hook ), |
|
| 818 | - ) ); |
|
| 815 | + public function bulk_actions($which = '') { |
|
| 816 | + submit_button(__('Save changes', 'wpshop'), 'bulk-save', 'bulk-save', false, array( |
|
| 817 | + 'data-nonce' => wp_create_nonce('bulk-save-' . $this->hook), |
|
| 818 | + )); |
|
| 819 | 819 | ?><span class="spinner"></span><?php |
| 820 | 820 | } |
| 821 | 821 | /** |
@@ -829,30 +829,30 @@ discard block |
||
| 829 | 829 | * @param array $rows List of rows always traited. |
| 830 | 830 | * @return void |
| 831 | 831 | */ |
| 832 | - private function _display_row( &$lvl, $item_id, $item, &$rows ) { |
|
| 833 | - if ( array_key_exists( $item_id, $rows ) ) { |
|
| 832 | + private function _display_row(&$lvl, $item_id, $item, &$rows) { |
|
| 833 | + if (array_key_exists($item_id, $rows)) { |
|
| 834 | 834 | return; |
| 835 | 835 | } |
| 836 | - if ( ! array_key_exists( $item['parent'], $this->items ) && 0 !== (int) $item['parent'] ) { |
|
| 837 | - $parent_item = $this->request( $item['parent'] ); |
|
| 838 | - $this->items[ $item['parent'] ] = $parent_item[0]; |
|
| 836 | + if (!array_key_exists($item['parent'], $this->items) && 0 !== (int)$item['parent']) { |
|
| 837 | + $parent_item = $this->request($item['parent']); |
|
| 838 | + $this->items[$item['parent']] = $parent_item[0]; |
|
| 839 | 839 | } |
| 840 | - if ( array_key_exists( $item['parent'], $rows ) ) { |
|
| 841 | - $offset = array_search( $item['parent'], array_keys( $rows ), true ); |
|
| 842 | - $rows_a = array_slice( $rows, $offset, null, true ); |
|
| 843 | - $rows_a[ $item_id ] = $item; |
|
| 844 | - $rows_b = array_slice( $rows, 0, $offset, true ); |
|
| 845 | - $rows = array_replace( $rows_a, $rows_b ); |
|
| 840 | + if (array_key_exists($item['parent'], $rows)) { |
|
| 841 | + $offset = array_search($item['parent'], array_keys($rows), true); |
|
| 842 | + $rows_a = array_slice($rows, $offset, null, true); |
|
| 843 | + $rows_a[$item_id] = $item; |
|
| 844 | + $rows_b = array_slice($rows, 0, $offset, true); |
|
| 845 | + $rows = array_replace($rows_a, $rows_b); |
|
| 846 | 846 | // $rows = $rows_a + $rows_b; FASTER ? |
| 847 | 847 | $lvl++; |
| 848 | - } elseif ( 0 !== (int) $item['parent'] ) { |
|
| 849 | - $this->_display_row( $lvl, $item['parent'], $this->items[ $item['parent'] ], $rows ); |
|
| 848 | + } elseif (0 !== (int)$item['parent']) { |
|
| 849 | + $this->_display_row($lvl, $item['parent'], $this->items[$item['parent']], $rows); |
|
| 850 | 850 | $lvl++; |
| 851 | 851 | } |
| 852 | - if ( ! empty( $item ) ) { |
|
| 853 | - $item['lvl'] = str_repeat( '— ', $lvl ); |
|
| 852 | + if (!empty($item)) { |
|
| 853 | + $item['lvl'] = str_repeat('— ', $lvl); |
|
| 854 | 854 | } |
| 855 | - $rows[ $item_id ] = $item; |
|
| 855 | + $rows[$item_id] = $item; |
|
| 856 | 856 | } |
| 857 | 857 | /** |
| 858 | 858 | * See WP_List_Table. |
@@ -862,13 +862,13 @@ discard block |
||
| 862 | 862 | */ |
| 863 | 863 | public function display_rows() { |
| 864 | 864 | $rows = array(); |
| 865 | - foreach ( $this->items as $item_id => $item ) { |
|
| 865 | + foreach ($this->items as $item_id => $item) { |
|
| 866 | 866 | $lvl = 0; |
| 867 | - $this->_display_row( $lvl, $item_id, $item, $rows ); |
|
| 867 | + $this->_display_row($lvl, $item_id, $item, $rows); |
|
| 868 | 868 | } |
| 869 | - foreach ( $rows as $item ) { |
|
| 870 | - if ( ! empty( $item ) ) { |
|
| 871 | - $this->single_row( $item ); |
|
| 869 | + foreach ($rows as $item) { |
|
| 870 | + if (!empty($item)) { |
|
| 871 | + $this->single_row($item); |
|
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | 874 | } |
@@ -889,52 +889,52 @@ discard block |
||
| 889 | 889 | * @param boolean $with_id See wp_list_table::print_column_headers. |
| 890 | 890 | * @return void Direct display. |
| 891 | 891 | */ |
| 892 | - public function print_column_headers( $with_id = true ) { |
|
| 893 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
| 892 | + public function print_column_headers($with_id = true) { |
|
| 893 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
| 894 | 894 | |
| 895 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
| 896 | - $current_url = remove_query_arg( 'paged', $current_url ); |
|
| 895 | + $current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
| 896 | + $current_url = remove_query_arg('paged', $current_url); |
|
| 897 | 897 | |
| 898 | - if ( isset( $_GET['orderby'] ) ) { // WPCS: CSRF ok. |
|
| 898 | + if (isset($_GET['orderby'])) { // WPCS: CSRF ok. |
|
| 899 | 899 | $current_orderby = $_GET['orderby']; // WPCS: CSRF ok. |
| 900 | 900 | } else { |
| 901 | 901 | $current_orderby = ''; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | - if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { // WPCS: CSRF ok. |
|
| 904 | + if (isset($_GET['order']) && 'desc' === $_GET['order']) { // WPCS: CSRF ok. |
|
| 905 | 905 | $current_order = 'desc'; |
| 906 | 906 | } else { |
| 907 | 907 | $current_order = 'asc'; |
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - if ( ! empty( $columns['cb'] ) ) { |
|
| 910 | + if (!empty($columns['cb'])) { |
|
| 911 | 911 | static $cb_counter = 1; |
| 912 | - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
|
| 912 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>' |
|
| 913 | 913 | . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
| 914 | 914 | $cb_counter++; |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | - foreach ( $columns as $column_key => $column_display_name ) { |
|
| 918 | - $class = array( 'manage-column', "column-$column_key" ); |
|
| 917 | + foreach ($columns as $column_key => $column_display_name) { |
|
| 918 | + $class = array('manage-column', "column-$column_key"); |
|
| 919 | 919 | |
| 920 | - if ( in_array( $column_key, $hidden, true ) ) { |
|
| 920 | + if (in_array($column_key, $hidden, true)) { |
|
| 921 | 921 | $class[] = 'hidden'; |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - if ( 'cb' === $column_key ) { |
|
| 924 | + if ('cb' === $column_key) { |
|
| 925 | 925 | $class[] = 'check-column'; |
| 926 | - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { |
|
| 926 | + } elseif (in_array($column_key, array('posts', 'comments', 'links'), true)) { |
|
| 927 | 927 | $class[] = 'num'; |
| 928 | 928 | } |
| 929 | 929 | |
| 930 | - if ( $column_key === $primary ) { |
|
| 930 | + if ($column_key === $primary) { |
|
| 931 | 931 | $class[] = 'column-primary'; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
| 935 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
| 934 | + if (isset($sortable[$column_key])) { |
|
| 935 | + list($orderby, $desc_first) = $sortable[$column_key]; |
|
| 936 | 936 | |
| 937 | - if ( $current_orderby === $orderby ) { |
|
| 937 | + if ($current_orderby === $orderby) { |
|
| 938 | 938 | $order = 'asc' === $current_order ? 'desc' : 'asc'; |
| 939 | 939 | $class[] = 'sorted'; |
| 940 | 940 | $class[] = $current_order; |
@@ -944,17 +944,17 @@ discard block |
||
| 944 | 944 | $class[] = $desc_first ? 'asc' : 'desc'; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - $cast = $this->cast_column( $column_key ); |
|
| 947 | + $cast = $this->cast_column($column_key); |
|
| 948 | 948 | |
| 949 | - $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>'; |
|
| 949 | + $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>'; |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | - $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
|
| 953 | - $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
|
| 952 | + $tag = ('cb' === $column_key) ? 'td' : 'th'; |
|
| 953 | + $scope = ('th' === $tag) ? 'scope="col"' : ''; |
|
| 954 | 954 | $id = $with_id ? "id='$column_key'" : ''; |
| 955 | 955 | |
| 956 | - if ( ! empty( $class ) ) { |
|
| 957 | - $class = "class='" . join( ' ', $class ) . "'"; |
|
| 956 | + if (!empty($class)) { |
|
| 957 | + $class = "class='" . join(' ', $class) . "'"; |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; // WPCS: XSS ok. |
@@ -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,47 +94,47 @@ 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-' . $this->hook ) ) . '">'; |
|
| 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-' . $this->hook)) . '">'; |
|
| 106 | + echo esc_html($this->post_type_object->labels->add_new) . '</a>'; |
|
| 107 | 107 | } |
| 108 | 108 | ?> |
| 109 | 109 | <hr class="wp-header-end"> |
| 110 | 110 | <form id="posts-filter" method="get"> |
| 111 | 111 | <?php $wp_list_table->views(); ?> |
| 112 | - <?php $wp_list_table->search_box( $this->post_type_object->labels->search_items, 'post' ); ?> |
|
| 112 | + <?php $wp_list_table->search_box($this->post_type_object->labels->search_items, 'post'); ?> |
|
| 113 | 113 | <input type="hidden" name="page" value="<?php |
| 114 | - echo esc_attr( str_replace( |
|
| 114 | + echo esc_attr(str_replace( |
|
| 115 | 115 | "{$wp_list_table->screen->post_type}_page_", |
| 116 | 116 | '', |
| 117 | 117 | $wp_list_table->screen->id |
| 118 | - ) ); ?>"> |
|
| 119 | - <input type="hidden" name="post_type" value="<?php echo esc_attr( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); ?>"> |
|
| 118 | + )); ?>"> |
|
| 119 | + <input type="hidden" name="post_type" value="<?php echo esc_attr(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); ?>"> |
|
| 120 | 120 | </form> |
| 121 | 121 | <?php $wp_list_table->display(); ?> |
| 122 | 122 | <table style="display:none;"> |
| 123 | 123 | <tbody id="posts-add"> |
| 124 | - <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"> |
|
| 125 | - <td colspan="<?php echo esc_attr( $wp_list_table->get_column_count() ); ?>" class="colspanchange"> |
|
| 124 | + <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"> |
|
| 125 | + <td colspan="<?php echo esc_attr($wp_list_table->get_column_count()); ?>" class="colspanchange"> |
|
| 126 | 126 | <fieldset class="inline-edit-col"> |
| 127 | - <legend class="inline-edit-legend"><?php echo esc_html( $this->post_type_object->labels->add_new ) ?></legend> |
|
| 127 | + <legend class="inline-edit-legend"><?php echo esc_html($this->post_type_object->labels->add_new) ?></legend> |
|
| 128 | 128 | <div class="inline-edit-col"> |
| 129 | 129 | <label> |
| 130 | - <span class="title"><?php esc_html_e( 'Title' ); ?></span> |
|
| 130 | + <span class="title"><?php esc_html_e('Title'); ?></span> |
|
| 131 | 131 | <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
| 132 | 132 | </label> |
| 133 | 133 | </div> |
| 134 | 134 | </fieldset> |
| 135 | 135 | <p class="submit inline-edit-save"> |
| 136 | - <button type="button" class="button cancel alignleft"><?php esc_html_e( 'Cancel' ); ?></button> |
|
| 137 | - <button type="button" class="button button-primary save alignright"><?php echo esc_html( $this->post_type_object->labels->add_new ); ?></button> |
|
| 136 | + <button type="button" class="button cancel alignleft"><?php esc_html_e('Cancel'); ?></button> |
|
| 137 | + <button type="button" class="button button-primary save alignright"><?php echo esc_html($this->post_type_object->labels->add_new); ?></button> |
|
| 138 | 138 | <span class="spinner"></span> |
| 139 | 139 | <span class="error" style="display:none"></span> |
| 140 | 140 | <br class="clear" /> |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | * @return void |
| 154 | 154 | */ |
| 155 | 155 | public function mass_interface_screen_option() { |
| 156 | - add_action( 'admin_notices', array( $this, 'ajax_admin_notice' ) ); |
|
| 157 | - add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 ); |
|
| 158 | - $this->wp_list_table( $this->hook ); |
|
| 156 | + add_action('admin_notices', array($this, 'ajax_admin_notice')); |
|
| 157 | + add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2); |
|
| 158 | + $this->wp_list_table($this->hook); |
|
| 159 | 159 | } |
| 160 | 160 | /** |
| 161 | 161 | * Instance WPS_Mass_List_Table. |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | * @param string $screen Current screen. |
| 165 | 165 | * @return WPS_Mass_List_Table Table class. |
| 166 | 166 | */ |
| 167 | - public function wp_list_table( $screen ) { |
|
| 168 | - if ( is_null( $this->wp_list_table ) ) { |
|
| 169 | - $this->post_type_object = get_post_type_object( WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT ); |
|
| 170 | - include_once( WPS_PDCT_MASS_INCLUDE_PATH . 'class-wps-mass-list-table.php' ); |
|
| 167 | + public function wp_list_table($screen) { |
|
| 168 | + if (is_null($this->wp_list_table)) { |
|
| 169 | + $this->post_type_object = get_post_type_object(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
|
| 170 | + include_once(WPS_PDCT_MASS_INCLUDE_PATH . 'class-wps-mass-list-table.php'); |
|
| 171 | 171 | $this->wp_list_table = new WPS_Mass_List_Table( |
| 172 | 172 | array( |
| 173 | 173 | 'screen' => $screen, |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | * @param WP_Screen $screen Current screen. |
| 200 | 200 | * @return array Return of filter. |
| 201 | 201 | */ |
| 202 | - public function hidden_columns( $hidden, $screen ) { |
|
| 203 | - $wp_list_table = $this->wp_list_table( $this->hook ); |
|
| 204 | - if ( $screen === $wp_list_table->screen ) { |
|
| 205 | - $hidden = array_diff( array_flip( $wp_list_table->get_columns() ), $this->default_show_columns ); |
|
| 202 | + public function hidden_columns($hidden, $screen) { |
|
| 203 | + $wp_list_table = $this->wp_list_table($this->hook); |
|
| 204 | + if ($screen === $wp_list_table->screen) { |
|
| 205 | + $hidden = array_diff(array_flip($wp_list_table->get_columns()), $this->default_show_columns); |
|
| 206 | 206 | $hidden[] = 'thumbnail'; |
| 207 | 207 | } |
| 208 | 208 | return $hidden; |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | * @param string $option Actual option to save. |
| 216 | 216 | * @param mixed $value Actual value to save. |
| 217 | 217 | */ |
| 218 | - public function set_screen_option( $string, $option, $value ) { |
|
| 218 | + public function set_screen_option($string, $option, $value) { |
|
| 219 | 219 | $class = get_class(); |
| 220 | - if ( "{$class}_per_page" === $option ) { |
|
| 221 | - $value = (int) $value; |
|
| 222 | - if ( $value < 1 || $value > 999 ) { |
|
| 220 | + if ("{$class}_per_page" === $option) { |
|
| 221 | + $value = (int)$value; |
|
| 222 | + if ($value < 1 || $value > 999) { |
|
| 223 | 223 | $string = false; |
| 224 | 224 | } |
| 225 | 225 | return $value; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @return void Direct display. |
| 234 | 234 | */ |
| 235 | 235 | public function ajax_admin_notice() { |
| 236 | - printf( '<div class="%1$s"><p></p></div>', esc_attr( 'hidden is-dismissible notice' ) ); |
|
| 236 | + printf('<div class="%1$s"><p></p></div>', esc_attr('hidden is-dismissible notice')); |
|
| 237 | 237 | } |
| 238 | 238 | /** |
| 239 | 239 | * Enqueue scripts. |
@@ -245,13 +245,13 @@ discard block |
||
| 245 | 245 | wp_enqueue_script( |
| 246 | 246 | 'jquery_chosen_js', |
| 247 | 247 | WPS_PDCT_MASS_CHOSEN_JS . 'chosen.jquery.min.js', |
| 248 | - array( 'jquery' ), |
|
| 248 | + array('jquery'), |
|
| 249 | 249 | true |
| 250 | 250 | ); |
| 251 | 251 | wp_enqueue_script( |
| 252 | 252 | 'mass_interface3-ajax', |
| 253 | 253 | WPS_PDCT_MASS_JS . 'wps-mass-interface3.js', |
| 254 | - array( 'jquery', 'jquery-form' ), |
|
| 254 | + array('jquery', 'jquery-form'), |
|
| 255 | 255 | true |
| 256 | 256 | ); |
| 257 | 257 | wp_enqueue_media(); |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | 265 | public function styles() { |
| 266 | - wp_register_style( 'jquery_chosen_css', WPS_PDCT_MASS_CHOSEN_CSS . 'chosen.min.css' ); |
|
| 267 | - wp_register_style( 'mass_interface3_css', WPS_PDCT_MASS_CSS . 'wps-mass-interface3.css' ); |
|
| 268 | - wp_enqueue_style( 'jquery_chosen_css' ); |
|
| 269 | - wp_enqueue_style( 'mass_interface3_css' ); |
|
| 270 | - wp_deregister_style( 'wpshop_main_css' ); |
|
| 266 | + wp_register_style('jquery_chosen_css', WPS_PDCT_MASS_CHOSEN_CSS . 'chosen.min.css'); |
|
| 267 | + wp_register_style('mass_interface3_css', WPS_PDCT_MASS_CSS . 'wps-mass-interface3.css'); |
|
| 268 | + wp_enqueue_style('jquery_chosen_css'); |
|
| 269 | + wp_enqueue_style('mass_interface3_css'); |
|
| 270 | + wp_deregister_style('wpshop_main_css'); |
|
| 271 | 271 | } |
| 272 | 272 | /** |
| 273 | 273 | * Ajax callback for new element. |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | * @return void JSON with all elements to update. |
| 277 | 277 | */ |
| 278 | 278 | public function ajax_new() { |
| 279 | - add_filter( 'default_hidden_columns', array( $this, 'hidden_columns' ), 10, 2 ); |
|
| 280 | - $wp_list_table = $this->wp_list_table( $_POST['screen'] ); |
|
| 279 | + add_filter('default_hidden_columns', array($this, 'hidden_columns'), 10, 2); |
|
| 280 | + $wp_list_table = $this->wp_list_table($_POST['screen']); |
|
| 281 | 281 | $wpshop_product_attribute = array(); |
| 282 | - foreach ( $wp_list_table->request_items_columns() as $key_var => $var ) { |
|
| 283 | - $wpshop_product_attribute[ $var['data'] ][ $key_var ] = null; |
|
| 282 | + foreach ($wp_list_table->request_items_columns() as $key_var => $var) { |
|
| 283 | + $wpshop_product_attribute[$var['data']][$key_var] = null; |
|
| 284 | 284 | } |
| 285 | 285 | $new_product_id = wp_insert_post( |
| 286 | 286 | array( |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | 'post_title' => $_POST['title'], |
| 290 | 290 | ) |
| 291 | 291 | ); |
| 292 | - if ( ! empty( $new_product_id ) ) { |
|
| 293 | - update_post_meta( $new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $wp_list_table->current_view ); |
|
| 292 | + if (!empty($new_product_id)) { |
|
| 293 | + update_post_meta($new_product_id, '_' . WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT . '_attribute_set_id', $wp_list_table->current_view); |
|
| 294 | 294 | $product_class = new wpshop_products(); |
| 295 | 295 | $product_class->save_product_custom_informations( |
| 296 | 296 | $new_product_id, array( |
@@ -302,31 +302,31 @@ discard block |
||
| 302 | 302 | ) |
| 303 | 303 | ); |
| 304 | 304 | } else { |
| 305 | - wp_die( 1 ); |
|
| 305 | + wp_die(1); |
|
| 306 | 306 | } |
| 307 | 307 | $class = get_class(); |
| 308 | - $data = $wp_list_table->request( $new_product_id ); |
|
| 309 | - $per_page = $wp_list_table->screen->get_option( 'per_page', 'option' ); |
|
| 308 | + $data = $wp_list_table->request($new_product_id); |
|
| 309 | + $per_page = $wp_list_table->screen->get_option('per_page', 'option'); |
|
| 310 | 310 | $wp_list_table->column_headers(); |
| 311 | 311 | $wp_list_table->items = true; |
| 312 | 312 | ob_start(); |
| 313 | 313 | $wp_list_table->views(); |
| 314 | 314 | $subsubsub = ob_get_clean(); |
| 315 | 315 | ob_start(); |
| 316 | - $wp_list_table->display_tablenav( 'top' ); |
|
| 316 | + $wp_list_table->display_tablenav('top'); |
|
| 317 | 317 | $tablenav_top = ob_get_clean(); |
| 318 | 318 | ob_start(); |
| 319 | - $wp_list_table->display_tablenav( 'bottom' ); |
|
| 319 | + $wp_list_table->display_tablenav('bottom'); |
|
| 320 | 320 | $tablenav_bottom = ob_get_clean(); |
| 321 | 321 | ob_start(); |
| 322 | - $wp_list_table->single_row( $data[0] ); |
|
| 323 | - wp_send_json_success( array( |
|
| 322 | + $wp_list_table->single_row($data[0]); |
|
| 323 | + wp_send_json_success(array( |
|
| 324 | 324 | 'row' => ob_get_clean(), |
| 325 | 325 | 'per_page' => $per_page, |
| 326 | 326 | 'tablenav_top' => $tablenav_top, |
| 327 | 327 | 'tablenav_bottom' => $tablenav_bottom, |
| 328 | 328 | 'subsubsub' => $subsubsub, |
| 329 | - ) ); |
|
| 329 | + )); |
|
| 330 | 330 | } |
| 331 | 331 | /** |
| 332 | 332 | * Ajax callback for save selected elements. |
@@ -337,19 +337,19 @@ discard block |
||
| 337 | 337 | public function ajax_save() { |
| 338 | 338 | $i = 0; |
| 339 | 339 | $product_class = new wpshop_products(); |
| 340 | - if ( ! empty( $_REQUEST['cb'] ) ) { |
|
| 341 | - foreach ( $_REQUEST['cb'] as $id ) { |
|
| 342 | - $id = intval( $id ); |
|
| 343 | - if ( isset( $_REQUEST[ 'row_' . $id ]['thumbnail'] ) ) { |
|
| 344 | - intval( $_REQUEST[ 'row_' . $id ]['thumbnail'] ); |
|
| 345 | - update_post_meta( $id, '_thumbnail_id', intval( $_REQUEST[ 'row_' . $id ]['thumbnail'] ) ); |
|
| 346 | - unset( $_REQUEST[ 'row_' . $id ]['thumbnail'] ); |
|
| 340 | + if (!empty($_REQUEST['cb'])) { |
|
| 341 | + foreach ($_REQUEST['cb'] as $id) { |
|
| 342 | + $id = intval($id); |
|
| 343 | + if (isset($_REQUEST['row_' . $id]['thumbnail'])) { |
|
| 344 | + intval($_REQUEST['row_' . $id]['thumbnail']); |
|
| 345 | + update_post_meta($id, '_thumbnail_id', intval($_REQUEST['row_' . $id]['thumbnail'])); |
|
| 346 | + unset($_REQUEST['row_' . $id]['thumbnail']); |
|
| 347 | 347 | } |
| 348 | - if ( ! empty( $_REQUEST[ 'row_' . $id ] ) ) { |
|
| 348 | + if (!empty($_REQUEST['row_' . $id])) { |
|
| 349 | 349 | $product_class->save_product_custom_informations( |
| 350 | 350 | $id, |
| 351 | 351 | array_merge( |
| 352 | - $_REQUEST[ 'row_' . $id ], |
|
| 352 | + $_REQUEST['row_' . $id], |
|
| 353 | 353 | array( |
| 354 | 354 | 'post_ID' => $id, |
| 355 | 355 | 'product_id' => $id, |
@@ -5,14 +5,14 @@ |
||
| 5 | 5 | * @package wps-mass-interface3 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -DEFINE( 'WPS_PDCT_MASS_VERSION', '3.0' ); |
|
| 9 | -DEFINE( 'WPS_PDCT_MASS_URL', plugin_dir_url( __FILE__ ) ); |
|
| 10 | -DEFINE( 'WPS_PDCT_MASS_INCLUDE_PATH', dirname( __FILE__ ) . '\include\\' ); |
|
| 11 | -DEFINE( 'WPS_PDCT_MASS_INCLUDE_URL', WPS_PDCT_MASS_URL . 'include/' ); |
|
| 12 | -DEFINE( 'WPS_PDCT_MASS_JS', WPS_PDCT_MASS_INCLUDE_URL . 'js/' ); |
|
| 13 | -DEFINE( 'WPS_PDCT_MASS_CSS', WPS_PDCT_MASS_INCLUDE_URL . 'css/' ); |
|
| 14 | -DEFINE( 'WPS_PDCT_MASS_CHOSEN_JS', WPS_PDCT_MASS_JS . 'chosen-v1.7.0/' ); |
|
| 15 | -DEFINE( 'WPS_PDCT_MASS_CHOSEN_CSS', WPS_PDCT_MASS_CSS . 'chosen-v1.7.0/' ); |
|
| 8 | +DEFINE('WPS_PDCT_MASS_VERSION', '3.0'); |
|
| 9 | +DEFINE('WPS_PDCT_MASS_URL', plugin_dir_url(__FILE__)); |
|
| 10 | +DEFINE('WPS_PDCT_MASS_INCLUDE_PATH', dirname(__FILE__) . '\include\\'); |
|
| 11 | +DEFINE('WPS_PDCT_MASS_INCLUDE_URL', WPS_PDCT_MASS_URL . 'include/'); |
|
| 12 | +DEFINE('WPS_PDCT_MASS_JS', WPS_PDCT_MASS_INCLUDE_URL . 'js/'); |
|
| 13 | +DEFINE('WPS_PDCT_MASS_CSS', WPS_PDCT_MASS_INCLUDE_URL . 'css/'); |
|
| 14 | +DEFINE('WPS_PDCT_MASS_CHOSEN_JS', WPS_PDCT_MASS_JS . 'chosen-v1.7.0/'); |
|
| 15 | +DEFINE('WPS_PDCT_MASS_CHOSEN_CSS', WPS_PDCT_MASS_CSS . 'chosen-v1.7.0/'); |
|
| 16 | 16 | |
| 17 | -include_once( WPS_PDCT_MASS_INCLUDE_PATH . 'class-mass-interface3.php' ); |
|
| 17 | +include_once(WPS_PDCT_MASS_INCLUDE_PATH . 'class-mass-interface3.php'); |
|
| 18 | 18 | new mass_interface3(); |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | * Call hooks. |
| 14 | 14 | */ |
| 15 | 15 | public function __construct() { |
| 16 | - add_action( 'init', array( $this, 'init' ) ); |
|
| 17 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 11, 2 ); |
|
| 18 | - add_action( 'save_post', array( $this, 'save_post' ), 10, 2 ); |
|
| 19 | - add_filter( 'wpshop_attribute_output_def', array( $this, 'wpshop_attribute_output_def' ), 10, 2 ); |
|
| 16 | + add_action('init', array($this, 'init')); |
|
| 17 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 11, 2); |
|
| 18 | + add_action('save_post', array($this, 'save_post'), 10, 2); |
|
| 19 | + add_filter('wpshop_attribute_output_def', array($this, 'wpshop_attribute_output_def'), 10, 2); |
|
| 20 | 20 | } |
| 21 | 21 | /** |
| 22 | 22 | * Call private functions if class is activate. |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | * @param array $arguments Array of arguments to pass. |
| 26 | 26 | * @return mixed Return of real function called. |
| 27 | 27 | */ |
| 28 | - public function __call( $name, $arguments ) { |
|
| 29 | - if ( method_exists( $this, $name ) ) { |
|
| 30 | - if ( $this->is_activate() ) { |
|
| 31 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
| 28 | + public function __call($name, $arguments) { |
|
| 29 | + if (method_exists($this, $name)) { |
|
| 30 | + if ($this->is_activate()) { |
|
| 31 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | * @return void |
| 40 | 40 | */ |
| 41 | 41 | public function init() { |
| 42 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // Input var okay. |
|
| 43 | - $wps_variation_interface = ! empty( $_GET['wps_variation_interface'] ) ? filter_var( wp_unslash( $_GET['wps_variation_interface'] ), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ) : null; // Input var okay. |
|
| 44 | - if ( wp_verify_nonce( $_wpnonce, 'wps_remove_variation_interface' ) && null !== $wps_variation_interface ) { |
|
| 45 | - $this->is_activate( $wps_variation_interface ); |
|
| 42 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field(wp_unslash($_REQUEST['_wpnonce'])) : ''; // Input var okay. |
|
| 43 | + $wps_variation_interface = !empty($_GET['wps_variation_interface']) ? filter_var(wp_unslash($_GET['wps_variation_interface']), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) : null; // Input var okay. |
|
| 44 | + if (wp_verify_nonce($_wpnonce, 'wps_remove_variation_interface') && null !== $wps_variation_interface) { |
|
| 45 | + $this->is_activate($wps_variation_interface); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | /** |
@@ -51,17 +51,17 @@ discard block |
||
| 51 | 51 | * @param boolean $new_val If set & db is different, save it. |
| 52 | 52 | * @return boolean Actual state of module. |
| 53 | 53 | */ |
| 54 | - public function is_activate( $new_val = null ) { |
|
| 55 | - if ( ! isset( $this->is_active ) ) { |
|
| 56 | - $option = get_option( 'wps_variation_interface_display', null ); |
|
| 57 | - if ( is_null( $option ) ) { |
|
| 54 | + public function is_activate($new_val = null) { |
|
| 55 | + if (!isset($this->is_active)) { |
|
| 56 | + $option = get_option('wps_variation_interface_display', null); |
|
| 57 | + if (is_null($option)) { |
|
| 58 | 58 | $new_val = true; |
| 59 | 59 | $option = false; |
| 60 | 60 | } |
| 61 | - $this->is_active = (bool) $option; |
|
| 61 | + $this->is_active = (bool)$option; |
|
| 62 | 62 | } |
| 63 | - if ( isset( $new_val ) && $this->is_active !== $new_val ) { |
|
| 64 | - update_option( 'wps_variation_interface_display', $new_val ); |
|
| 63 | + if (isset($new_val) && $this->is_active !== $new_val) { |
|
| 64 | + update_option('wps_variation_interface_display', $new_val); |
|
| 65 | 65 | $this->is_active = $new_val; |
| 66 | 66 | } |
| 67 | 67 | return $this->is_active; |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | * @param array $element Direct array attribute of db. |
| 73 | 73 | * @return void It set directly in variable class. |
| 74 | 74 | */ |
| 75 | - private function get_variations( $element ) { |
|
| 76 | - if ( ! isset( $this->variations ) ) { |
|
| 77 | - $variations = wpshop_attributes::get_variation_available_attribute( $element ); |
|
| 78 | - $this->variations = (array) array_merge( ( isset( $variations['available'] ) ? $variations['available'] : array()), ( isset( $variations['unavailable'] ) ? $variations['unavailable'] : array() ) ); |
|
| 79 | - unset( $variations ); |
|
| 75 | + private function get_variations($element) { |
|
| 76 | + if (!isset($this->variations)) { |
|
| 77 | + $variations = wpshop_attributes::get_variation_available_attribute($element); |
|
| 78 | + $this->variations = (array)array_merge((isset($variations['available']) ? $variations['available'] : array()), (isset($variations['unavailable']) ? $variations['unavailable'] : array())); |
|
| 79 | + unset($variations); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | /** |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | * @param string $post_status Generated by WP. |
| 87 | 87 | * @param WP_Post $post Generated by WP. |
| 88 | 88 | */ |
| 89 | - public function add_meta_boxes( $post_status, $post ) { |
|
| 89 | + public function add_meta_boxes($post_status, $post) { |
|
| 90 | 90 | global $pagenow; |
| 91 | - if ( $this->is_activate() ) { |
|
| 92 | - $this->get_variations( $post->ID ); |
|
| 93 | - remove_meta_box( 'wpshop_wpshop_variations', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal' ); |
|
| 94 | - if ( 'post-new.php' !== $pagenow && ! empty( $this->variations ) ) { |
|
| 95 | - add_meta_box( 'wpshop_wpshop_variations', __( 'Product variation', 'wpshop' ), array( $this, 'meta_box_variation' ), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'default' ); |
|
| 91 | + if ($this->is_activate()) { |
|
| 92 | + $this->get_variations($post->ID); |
|
| 93 | + remove_meta_box('wpshop_wpshop_variations', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal'); |
|
| 94 | + if ('post-new.php' !== $pagenow && !empty($this->variations)) { |
|
| 95 | + add_meta_box('wpshop_wpshop_variations', __('Product variation', 'wpshop'), array($this, 'meta_box_variation'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'default'); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -102,59 +102,59 @@ discard block |
||
| 102 | 102 | * @param object $post Given by WordPress. |
| 103 | 103 | * @return void Display directly. |
| 104 | 104 | */ |
| 105 | - private function meta_box_variation( $post ) { |
|
| 106 | - $this->get_variations( $post->ID ); |
|
| 105 | + private function meta_box_variation($post) { |
|
| 106 | + $this->get_variations($post->ID); |
|
| 107 | 107 | global $wpdb; |
| 108 | 108 | $ids = array(); |
| 109 | - foreach ( $this->variations as $key => $variation ) { |
|
| 110 | - $available = wpshop_attributes::get_select_output( $variation['attribute_complete_def'] ); |
|
| 111 | - $this->variations[ $key ]['available'] = array_keys( $available['possible_value'] ); |
|
| 112 | - $ids = array_merge( $ids, array_keys( $available['possible_value'] ) ); |
|
| 109 | + foreach ($this->variations as $key => $variation) { |
|
| 110 | + $available = wpshop_attributes::get_select_output($variation['attribute_complete_def']); |
|
| 111 | + $this->variations[$key]['available'] = array_keys($available['possible_value']); |
|
| 112 | + $ids = array_merge($ids, array_keys($available['possible_value'])); |
|
| 113 | 113 | } |
| 114 | - $sql = 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id IN (\'' . implode( '\', \'', $ids ) . '\') AND status = %s'; |
|
| 115 | - $query = call_user_func( array( $wpdb, 'prepare' ), $sql, 'valid' ); |
|
| 116 | - $product = wpshop_products::get_product_data( $post->ID, false, '"publish","draft","future","pending"' ); |
|
| 117 | - $is_used_in_variation = wpshop_attributes::getElement( 'yes', "'valid', 'notused'", 'is_used_in_variation', true ); |
|
| 114 | + $sql = 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id IN (\'' . implode('\', \'', $ids) . '\') AND status = %s'; |
|
| 115 | + $query = call_user_func(array($wpdb, 'prepare'), $sql, 'valid'); |
|
| 116 | + $product = wpshop_products::get_product_data($post->ID, false, '"publish","draft","future","pending"'); |
|
| 117 | + $is_used_in_variation = wpshop_attributes::getElement('yes', "'valid', 'notused'", 'is_used_in_variation', true); |
|
| 118 | 118 | $attribute_list = array(); |
| 119 | - foreach ( $is_used_in_variation as $attribute ) { |
|
| 120 | - if ( in_array( $attribute->backend_input, array( 'multiple-select', 'select', 'radio', 'checkbox' ), true ) ) { |
|
| 121 | - $values = wpshop_attributes::get_select_output( $attribute ); |
|
| 122 | - if ( ! empty( $values['possible_value'] ) ) { |
|
| 119 | + foreach ($is_used_in_variation as $attribute) { |
|
| 120 | + if (in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'), true)) { |
|
| 121 | + $values = wpshop_attributes::get_select_output($attribute); |
|
| 122 | + if (!empty($values['possible_value'])) { |
|
| 123 | 123 | $attribute->possible_value = $values['possible_value']; |
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | - $attribute_list[ $attribute->code ] = $attribute; |
|
| 126 | + $attribute_list[$attribute->code] = $attribute; |
|
| 127 | 127 | } |
| 128 | - $variation_defining = get_post_meta( $post->ID, '_wpshop_variation_defining', true ); |
|
| 129 | - $variations_saved = wpshop_products::get_variation( $post->ID ); |
|
| 130 | - if ( ! empty( $variations_saved ) ) { |
|
| 131 | - foreach ( $variations_saved as $variation_id => $variation ) { |
|
| 132 | - $downloadable = get_post_meta( $variation_id, 'attribute_option_is_downloadable_', true ); |
|
| 133 | - if ( ! empty( $downloadable['file_url'] ) ) { |
|
| 134 | - $variations_saved[ $variation_id ]['file']['path'] = $downloadable['file_url']; |
|
| 135 | - $variations_saved[ $variation_id ]['file']['name'] = basename( $downloadable['file_url'] ); |
|
| 128 | + $variation_defining = get_post_meta($post->ID, '_wpshop_variation_defining', true); |
|
| 129 | + $variations_saved = wpshop_products::get_variation($post->ID); |
|
| 130 | + if (!empty($variations_saved)) { |
|
| 131 | + foreach ($variations_saved as $variation_id => $variation) { |
|
| 132 | + $downloadable = get_post_meta($variation_id, 'attribute_option_is_downloadable_', true); |
|
| 133 | + if (!empty($downloadable['file_url'])) { |
|
| 134 | + $variations_saved[$variation_id]['file']['path'] = $downloadable['file_url']; |
|
| 135 | + $variations_saved[$variation_id]['file']['name'] = basename($downloadable['file_url']); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | - $price_piloting = get_option( 'wpshop_shop_price_piloting' ); |
|
| 139 | + $price_piloting = get_option('wpshop_shop_price_piloting'); |
|
| 140 | 140 | $product_currency = wpshop_tools::wpshop_get_currency(); |
| 141 | - wp_enqueue_style( 'wps-product-variation-interface-style', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/css/style-backend.css' ); |
|
| 142 | - wp_enqueue_script( 'wps-product-variation-interface-script', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/js/script-backend.js' ); |
|
| 143 | - wp_enqueue_script( 'wps-product-variation-interface-script-utils', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/js/script-backend-utils.js' ); |
|
| 144 | - wp_localize_script( 'wps-product-variation-interface-script', 'wps_product_variation_interface', apply_filters( 'wps_filters_product_variation_extra_columns_product_definition', array( |
|
| 141 | + wp_enqueue_style('wps-product-variation-interface-style', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/css/style-backend.css'); |
|
| 142 | + wp_enqueue_script('wps-product-variation-interface-script', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/js/script-backend.js'); |
|
| 143 | + wp_enqueue_script('wps-product-variation-interface-script-utils', WPSPDTVARIATION_INTERFACE_ASSETS_MAIN_DIR . '/js/script-backend-utils.js'); |
|
| 144 | + wp_localize_script('wps-product-variation-interface-script', 'wps_product_variation_interface', apply_filters('wps_filters_product_variation_extra_columns_product_definition', array( |
|
| 145 | 145 | 'variation' => $this->variations, |
| 146 | - 'nonce_delete' => wp_create_nonce( 'wpshop_variation_management' ), |
|
| 147 | - 'variation_value' => call_user_func( array( $wpdb, 'get_results' ), $query ), |
|
| 148 | - 'product_price' => ( ! empty( $price_piloting ) && 'HT' !== $price_piloting ) ? $product['product_price'] : $product['price_ht'], |
|
| 146 | + 'nonce_delete' => wp_create_nonce('wpshop_variation_management'), |
|
| 147 | + 'variation_value' => call_user_func(array($wpdb, 'get_results'), $query), |
|
| 148 | + 'product_price' => (!empty($price_piloting) && 'HT' !== $price_piloting) ? $product['product_price'] : $product['price_ht'], |
|
| 149 | 149 | 'tx_tva' => $product['tx_tva'], |
| 150 | 150 | 'attribute_in_variation' => $attribute_list, |
| 151 | 151 | 'variations_saved' => $variations_saved, |
| 152 | 152 | 'price_piloting' => $price_piloting, |
| 153 | 153 | 'currency' => $product_currency, |
| 154 | 154 | 'variation_defining' => $variation_defining, |
| 155 | - 'label_file' => __( 'Click to add file', 'wpshop' ), |
|
| 156 | - ) ) ); |
|
| 157 | - require_once wpshop_tools::get_template_part( WPSPDTVARIATION_INTERFACE_DIR, WPSPDTVARIATION_INTERFACE_TEMPLATES_MAIN_DIR, 'backend', 'meta_box_variation' ); |
|
| 155 | + 'label_file' => __('Click to add file', 'wpshop'), |
|
| 156 | + ))); |
|
| 157 | + require_once wpshop_tools::get_template_part(WPSPDTVARIATION_INTERFACE_DIR, WPSPDTVARIATION_INTERFACE_TEMPLATES_MAIN_DIR, 'backend', 'meta_box_variation'); |
|
| 158 | 158 | } |
| 159 | 159 | /** |
| 160 | 160 | * Save other values out of old variation interface. |
@@ -163,24 +163,24 @@ discard block |
||
| 163 | 163 | * @param object $post WP_Post of WordPress. |
| 164 | 164 | * @return void |
| 165 | 165 | */ |
| 166 | - private function save_post( $post_id, $post ) { |
|
| 167 | - if ( wp_is_post_revision( $post_id ) || WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT !== $post->post_type || ! isset( $_REQUEST['wpshop_variation_defining']['options'] ) || ! isset( $_REQUEST['wps_pdt_variations'] ) ) { // Input var okay. |
|
| 166 | + private function save_post($post_id, $post) { |
|
| 167 | + if (wp_is_post_revision($post_id) || WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT !== $post->post_type || !isset($_REQUEST['wpshop_variation_defining']['options']) || !isset($_REQUEST['wps_pdt_variations'])) { // Input var okay. |
|
| 168 | 168 | return; |
| 169 | 169 | } |
| 170 | - wpshop_products::variation_parameters_save( $post_id, $_REQUEST['wpshop_variation_defining']['options'] ); // Input var okay. |
|
| 171 | - remove_action( 'save_post', array( $this, 'save_post' ) ); |
|
| 172 | - foreach ( $_REQUEST['wps_pdt_variations'] as $variation_id => $data ) { // Input var okay. |
|
| 170 | + wpshop_products::variation_parameters_save($post_id, $_REQUEST['wpshop_variation_defining']['options']); // Input var okay. |
|
| 171 | + remove_action('save_post', array($this, 'save_post')); |
|
| 172 | + foreach ($_REQUEST['wps_pdt_variations'] as $variation_id => $data) { // Input var okay. |
|
| 173 | 173 | $variation = array( |
| 174 | 174 | 'ID' => $variation_id, |
| 175 | 175 | ); |
| 176 | - if ( isset( $data['status'] ) && 'on' === $data['status'] ) { |
|
| 176 | + if (isset($data['status']) && 'on' === $data['status']) { |
|
| 177 | 177 | $variation['post_status'] = 'publish'; |
| 178 | 178 | } else { |
| 179 | 179 | $variation['post_status'] = 'draft'; |
| 180 | 180 | } |
| 181 | - wp_update_post( $variation ); |
|
| 181 | + wp_update_post($variation); |
|
| 182 | 182 | } |
| 183 | - add_action( 'save_post', array( $this, 'save_post' ), 10, 2 ); |
|
| 183 | + add_action('save_post', array($this, 'save_post'), 10, 2); |
|
| 184 | 184 | } |
| 185 | 185 | /** |
| 186 | 186 | * Delete display in attributes products always in metabox. |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | * @param array $element Direct array attribute of db. |
| 190 | 190 | * @return array SAme array $output modified. |
| 191 | 191 | */ |
| 192 | - public function wpshop_attribute_output_def( $output, $element ) { |
|
| 193 | - if ( $this->is_activate() ) { |
|
| 194 | - $this->get_variations( $element ); |
|
| 195 | - if ( ! empty( $this->variations ) && in_array( $output['field_definition']['name'], array_keys( $this->variations ), true ) ) { |
|
| 192 | + public function wpshop_attribute_output_def($output, $element) { |
|
| 193 | + if ($this->is_activate()) { |
|
| 194 | + $this->get_variations($element); |
|
| 195 | + if (!empty($this->variations) && in_array($output['field_definition']['name'], array_keys($this->variations), true)) { |
|
| 196 | 196 | $output['field'] = ''; |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @return void |
| 206 | 206 | */ |
| 207 | 207 | public static function wpshop_download_file_dialog_active() { |
| 208 | - add_filter( 'wps_filters_product_variation_file', array( 'wps_product_variation_interface', 'wps_filters_product_variation_file' ), 0, 1 ); |
|
| 208 | + add_filter('wps_filters_product_variation_file', array('wps_product_variation_interface', 'wps_filters_product_variation_file'), 0, 1); |
|
| 209 | 209 | } |
| 210 | 210 | /** |
| 211 | 211 | * Add old upload box for custom php dsiplay. |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | * @param string $string Input filter. |
| 215 | 215 | * @return string The div for box. |
| 216 | 216 | */ |
| 217 | - public static function wps_filters_product_variation_file( $string ) { |
|
| 217 | + public static function wps_filters_product_variation_file($string) { |
|
| 218 | 218 | ob_start(); |
| 219 | 219 | ?> |
| 220 | - <div style="display: none;" onclick="open_dialog_box(this, %ID%, '<?php esc_html_e( 'Send the downloadable file', 'wpshop' ); ?>')"> |
|
| 220 | + <div style="display: none;" onclick="open_dialog_box(this, %ID%, '<?php esc_html_e('Send the downloadable file', 'wpshop'); ?>')"> |
|
| 221 | 221 | <div class="is_downloadable_statut_%ID%"></div> |
| 222 | 222 | </div> |
| 223 | 223 | <?php |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) { exit; |
|
| 2 | 2 | } |
| 3 | 3 | |
| 4 | 4 | // End if(). |
| 5 | -if ( ! defined( 'WPSHOP_VERSION' ) ) { |
|
| 6 | - die( __( 'Access is not allowed by this way', 'wpshop' ) ); |
|
| 5 | +if (!defined('WPSHOP_VERSION')) { |
|
| 6 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -18,58 +18,58 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | // End if(). |
| 21 | -include_once( WPSHOP_DIR . '/core/module_management/module_management.php' ); |
|
| 22 | -include_once( WPSHOP_INCLUDES_DIR . 'wpshop_ajax.php' ); |
|
| 23 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'install.class.php' ); |
|
| 24 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'permissions.class.php' ); |
|
| 25 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'options/options.class.php' ); |
|
| 26 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'notices.class.php' ); |
|
| 21 | +include_once(WPSHOP_DIR . '/core/module_management/module_management.php'); |
|
| 22 | +include_once(WPSHOP_INCLUDES_DIR . 'wpshop_ajax.php'); |
|
| 23 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'install.class.php'); |
|
| 24 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'permissions.class.php'); |
|
| 25 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'options/options.class.php'); |
|
| 26 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'notices.class.php'); |
|
| 27 | 27 | /* Purchase management */ |
| 28 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'purchase/checkout.class.php' ); |
|
| 29 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'purchase/orders.class.php' ); |
|
| 28 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'purchase/checkout.class.php'); |
|
| 29 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'purchase/orders.class.php'); |
|
| 30 | 30 | /* Database management */ |
| 31 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'db/db_structure_definition.php' ); |
|
| 32 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'db/db_data_definition.php' ); |
|
| 33 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'db/database.class.php' ); |
|
| 31 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'db/db_structure_definition.php'); |
|
| 32 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'db/db_data_definition.php'); |
|
| 33 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'db/database.class.php'); |
|
| 34 | 34 | /* Payments management */ |
| 35 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'payments/payment.class.php' ); |
|
| 36 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'payments/paypal.class.php' ); |
|
| 35 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/payment.class.php'); |
|
| 36 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/paypal.class.php'); |
|
| 37 | 37 | // If the CIC payment method is active |
| 38 | -$wpshop_paymentMethod = get_option( 'wps_payment_mode' ); |
|
| 39 | -if ( WPSHOP_PAYMENT_METHOD_CIC && ! empty( $wpshop_paymentMethod ) && ! empty( $wpshop_paymentMethod['mode'] ) && ! empty( $wpshop_paymentMethod['mode']['cic'] ) ) { |
|
| 40 | - include_once( WPSHOP_LIBRAIRIES_DIR . 'payments/cic.class.php' ); |
|
| 38 | +$wpshop_paymentMethod = get_option('wps_payment_mode'); |
|
| 39 | +if (WPSHOP_PAYMENT_METHOD_CIC && !empty($wpshop_paymentMethod) && !empty($wpshop_paymentMethod['mode']) && !empty($wpshop_paymentMethod['mode']['cic'])) { |
|
| 40 | + include_once(WPSHOP_LIBRAIRIES_DIR . 'payments/cic.class.php'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // End if(). |
| 44 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 45 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
| 44 | +if (!class_exists('WP_List_Table')) { |
|
| 45 | + require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
|
| 46 | 46 | } |
| 47 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'display/display.class.php' ); |
|
| 48 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'display/form.class.php' ); |
|
| 49 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'display/form_management.class.php' ); |
|
| 50 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'display/widgets/categories.widget.php' ); |
|
| 51 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'display/widgets/products.widget.php' ); |
|
| 47 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'display/display.class.php'); |
|
| 48 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'display/form.class.php'); |
|
| 49 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'display/form_management.class.php'); |
|
| 50 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'display/widgets/categories.widget.php'); |
|
| 51 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'display/widgets/products.widget.php'); |
|
| 52 | 52 | // End if(). |
| 53 | -add_action( 'admin_init', array( 'wpshop_display', 'check_template_file' ) ); |
|
| 53 | +add_action('admin_init', array('wpshop_display', 'check_template_file')); |
|
| 54 | 54 | /* Files management */ |
| 55 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'documents/documents.class.php' ); |
|
| 56 | -add_action( 'admin_head', array( 'wpshop_documents', 'galery_manager_css' ) ); |
|
| 57 | -add_filter( 'attachment_fields_to_edit', array( 'wpshop_documents', 'attachment_fields' ), 11, 2 ); |
|
| 58 | -add_filter( 'gettext', array( 'wpshop_documents', 'change_picture_translation' ), 11, 2 ); |
|
| 55 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'documents/documents.class.php'); |
|
| 56 | +add_action('admin_head', array('wpshop_documents', 'galery_manager_css')); |
|
| 57 | +add_filter('attachment_fields_to_edit', array('wpshop_documents', 'attachment_fields'), 11, 2); |
|
| 58 | +add_filter('gettext', array('wpshop_documents', 'change_picture_translation'), 11, 2); |
|
| 59 | 59 | /* Catalog management */ |
| 60 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'catalog/products.class.php' ); |
|
| 61 | -include_once( WPSHOP_LIBRAIRIES_DIR . 'catalog/categories.class.php' ); |
|
| 62 | -add_filter( 'manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_columns', array( 'wpshop_categories', 'category_manage_columns' ) ); |
|
| 63 | -add_filter( 'manage_' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_custom_column', array( 'wpshop_categories', 'category_manage_columns_content' ), 10, 3 ); |
|
| 64 | -add_action( WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_edit_form_fields', array( 'wpshop_categories', 'category_edit_fields' ) ); |
|
| 65 | -add_action( 'created_' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array( 'wpshop_categories', 'category_fields_saver' ), 10, 2 ); |
|
| 66 | -add_action( 'edited_' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array( 'wpshop_categories', 'category_fields_saver' ), 10, 2 ); |
|
| 60 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'catalog/products.class.php'); |
|
| 61 | +include_once(WPSHOP_LIBRAIRIES_DIR . 'catalog/categories.class.php'); |
|
| 62 | +add_filter('manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_columns', array('wpshop_categories', 'category_manage_columns')); |
|
| 63 | +add_filter('manage_' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_custom_column', array('wpshop_categories', 'category_manage_columns_content'), 10, 3); |
|
| 64 | +add_action(WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES . '_edit_form_fields', array('wpshop_categories', 'category_edit_fields')); |
|
| 65 | +add_action('created_' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array('wpshop_categories', 'category_fields_saver'), 10, 2); |
|
| 66 | +add_action('edited_' . WPSHOP_NEWTYPE_IDENTIFIER_CATEGORIES, array('wpshop_categories', 'category_fields_saver'), 10, 2); |
|
| 67 | 67 | /* EAV management */ |
| 68 | -include( WPSHOP_LIBRAIRIES_DIR . 'eav/wp_list_custom_attributes.class.php' ); |
|
| 69 | -include( WPSHOP_LIBRAIRIES_DIR . 'eav/attributes.class.php' ); |
|
| 70 | -include( WPSHOP_LIBRAIRIES_DIR . 'eav/attributes_unit.class.php' ); |
|
| 71 | -include( WPSHOP_LIBRAIRIES_DIR . 'eav/wp_list_custom_attributes_set.class.php' ); |
|
| 72 | -include( WPSHOP_LIBRAIRIES_DIR . 'eav/attributes_set.class.php' ); |
|
| 73 | -include( WPSHOP_LIBRAIRIES_DIR . 'eav/entities.class.php' ); |
|
| 68 | +include(WPSHOP_LIBRAIRIES_DIR . 'eav/wp_list_custom_attributes.class.php'); |
|
| 69 | +include(WPSHOP_LIBRAIRIES_DIR . 'eav/attributes.class.php'); |
|
| 70 | +include(WPSHOP_LIBRAIRIES_DIR . 'eav/attributes_unit.class.php'); |
|
| 71 | +include(WPSHOP_LIBRAIRIES_DIR . 'eav/wp_list_custom_attributes_set.class.php'); |
|
| 72 | +include(WPSHOP_LIBRAIRIES_DIR . 'eav/attributes_set.class.php'); |
|
| 73 | +include(WPSHOP_LIBRAIRIES_DIR . 'eav/entities.class.php'); |
|
| 74 | 74 | /* Modules management */ |
| 75 | 75 | eo_module_management::extra_modules(); |
@@ -184,20 +184,20 @@ discard block |
||
| 184 | 184 | public static function admin_menu() { |
| 185 | 185 | global $submenu; |
| 186 | 186 | $attributeEntitySetList = wpshop_attributes_set::get_attribute_set_list_for_entity(wpshop_entities::get_entity_identifier_from_code(self::currentPageCode)); |
| 187 | - $entities_to_unset = array( 'free_product', 'default' ); |
|
| 187 | + $entities_to_unset = array('free_product', 'default'); |
|
| 188 | 188 | $submenu_before = $submenu['edit.php?post_type=wpshop_product']; |
| 189 | 189 | foreach ($attributeEntitySetList as $key_attribute_set => $attribute_set) { |
| 190 | - if ( !( in_array( $attribute_set->slug, $entities_to_unset ) || in_array( $attribute_set->name, $entities_to_unset ) ) ) { |
|
| 191 | - add_submenu_page( 'edit.php?post_type=wpshop_product', sprintf( __( 'Add %s', 'wpshop' ), $attribute_set->name), sprintf( __( 'Add %s', 'wpshop' ), $attribute_set->name), 'edit_posts', 'post-new.php?attribute_set=' . $attribute_set->id . '&post_type=wpshop_product'); |
|
| 190 | + if (!(in_array($attribute_set->slug, $entities_to_unset) || in_array($attribute_set->name, $entities_to_unset))) { |
|
| 191 | + add_submenu_page('edit.php?post_type=wpshop_product', sprintf(__('Add %s', 'wpshop'), $attribute_set->name), sprintf(__('Add %s', 'wpshop'), $attribute_set->name), 'edit_posts', 'post-new.php?attribute_set=' . $attribute_set->id . '&post_type=wpshop_product'); |
|
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | - $submenu_new_elements = array_diff_key ( $submenu['edit.php?post_type=wpshop_product'], $submenu_before ); |
|
| 194 | + $submenu_new_elements = array_diff_key($submenu['edit.php?post_type=wpshop_product'], $submenu_before); |
|
| 195 | 195 | $submenu_reorder = array(); |
| 196 | - foreach( $submenu_before as $key => $element ) { |
|
| 197 | - if( empty( $submenu_reorder[$key] ) ) { |
|
| 196 | + foreach ($submenu_before as $key => $element) { |
|
| 197 | + if (empty($submenu_reorder[$key])) { |
|
| 198 | 198 | $submenu_reorder[$key] = $element; |
| 199 | - if( in_array( 'post-new.php?post_type=wpshop_product', $element ) ) { |
|
| 200 | - $submenu_reorder = array_merge( $submenu_reorder, array_values( $submenu_new_elements ) ); |
|
| 199 | + if (in_array('post-new.php?post_type=wpshop_product', $element)) { |
|
| 200 | + $submenu_reorder = array_merge($submenu_reorder, array_values($submenu_new_elements)); |
|
| 201 | 201 | } |
| 202 | 202 | } else { |
| 203 | 203 | $submenu_reorder[] = $element; |
@@ -604,12 +604,12 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | $products = array(); |
| 606 | 606 | $query = "SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE code=%s"; |
| 607 | - $data = (array) $wpdb->get_row($wpdb->prepare($query, $attr_name)); |
|
| 607 | + $data = (array)$wpdb->get_row($wpdb->prepare($query, $attr_name)); |
|
| 608 | 608 | |
| 609 | 609 | if (!empty($data)) { |
| 610 | 610 | if ($data['data_type_to_use'] == 'custom') { |
| 611 | 611 | // Find which table to take |
| 612 | - if ($data['data_type'] == 'datetime') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME;} elseif ($data['data_type'] == 'decimal') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL;} elseif ($data['data_type'] == 'integer') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER;} elseif ($data['data_type'] == 'options') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS;} elseif ($data['data_type'] == 'text') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT;} elseif ($data['data_type'] == 'varchar') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR;} |
|
| 612 | + if ($data['data_type'] == 'datetime') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DATETIME; } elseif ($data['data_type'] == 'decimal') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL; } elseif ($data['data_type'] == 'integer') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_INTEGER; } elseif ($data['data_type'] == 'options') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS; } elseif ($data['data_type'] == 'text') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT; } elseif ($data['data_type'] == 'varchar') {$table_name = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR; } |
|
| 613 | 613 | |
| 614 | 614 | if (isset($table_name)) { |
| 615 | 615 | // If the value is an id of a select, radio or checkbox |
@@ -759,11 +759,11 @@ discard block |
||
| 759 | 759 | if (!empty($atts['product_type'])) { |
| 760 | 760 | switch ($atts['product_type']) { |
| 761 | 761 | case 'related': |
| 762 | - $product_id = !empty($atts['pid']) ? (int) $atts['pid'] : get_the_ID(); |
|
| 762 | + $product_id = !empty($atts['pid']) ? (int)$atts['pid'] : get_the_ID(); |
|
| 763 | 763 | $type = !empty($atts['display_mode']) && in_array($atts['display_mode'], array('list', 'grid')) ? $atts['display_mode'] : WPSHOP_DISPLAY_LIST_TYPE; |
| 764 | 764 | $grid_element_nb_per_line = !empty($atts['grid_element_nb_per_line']) ? $atts['grid_element_nb_per_line'] : WPSHOP_DISPLAY_GRID_ELEMENT_NUMBER_PER_LINE; |
| 765 | 765 | |
| 766 | - $pids = get_post_meta((int) $product_id, WPSHOP_PRODUCT_RELATED_PRODUCTS, true); |
|
| 766 | + $pids = get_post_meta((int)$product_id, WPSHOP_PRODUCT_RELATED_PRODUCTS, true); |
|
| 767 | 767 | if (!empty($pids) && !empty($pids[0])) { |
| 768 | 768 | $pid = implode(',', $pids); |
| 769 | 769 | } |
@@ -832,8 +832,8 @@ discard block |
||
| 832 | 832 | $sub_tpl_component = array(); |
| 833 | 833 | $criteria = ''; |
| 834 | 834 | foreach ($sorting_criteria as $c): |
| 835 | - $selected = isset( $atts['order'] ) ? $atts['order'] : null; |
|
| 836 | - $criteria .= '<option value="' . $c['code'] . '" ' . selected( $selected, $c['code'], false ) . '>' . __($c['frontend_label'], 'wpshop') . '</option>'; |
|
| 835 | + $selected = isset($atts['order']) ? $atts['order'] : null; |
|
| 836 | + $criteria .= '<option value="' . $c['code'] . '" ' . selected($selected, $c['code'], false) . '>' . __($c['frontend_label'], 'wpshop') . '</option>'; |
|
| 837 | 837 | endforeach; |
| 838 | 838 | $sub_tpl_component['SORTING_CRITERIA_LIST'] = $criteria; |
| 839 | 839 | $tpl_component['SORTING_CRITERIA'] = wpshop_display::display_template_element($sub_template_part, $sub_tpl_component); |
@@ -1002,7 +1002,7 @@ discard block |
||
| 1002 | 1002 | // --------------------- // |
| 1003 | 1003 | // Pagination management // |
| 1004 | 1004 | // --------------------- // |
| 1005 | - if ( $display_pagination ) { |
|
| 1005 | + if ($display_pagination) { |
|
| 1006 | 1006 | if ($nb_of_product_limit == 0) { |
| 1007 | 1007 | |
| 1008 | 1008 | $paginate = paginate_links(array( |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | { |
| 1284 | 1284 | global $wpdb; |
| 1285 | 1285 | |
| 1286 | - $data_to_save = (!empty($data_to_save)) ? $data_to_save : (array) $_REQUEST; |
|
| 1286 | + $data_to_save = (!empty($data_to_save)) ? $data_to_save : (array)$_REQUEST; |
|
| 1287 | 1287 | // Apply a filter to extra actions |
| 1288 | 1288 | $data_to_save = apply_filters('wps_save_product_extra_filter', $data_to_save); |
| 1289 | 1289 | |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | $attributeValue = str_replace(',', '.', $attributeValue); |
| 1340 | 1340 | } |
| 1341 | 1341 | if (($attributeType == 'integer') && !is_array($attributeValue)) { |
| 1342 | - $attributeValue = (int) $attributeValue; |
|
| 1342 | + $attributeValue = (int)$attributeValue; |
|
| 1343 | 1343 | } |
| 1344 | 1344 | $productMetaDatas[$attributeCode] = $attributeValue; |
| 1345 | 1345 | } |
@@ -1389,7 +1389,7 @@ discard block |
||
| 1389 | 1389 | $attributeValue = str_replace(',', '.', $attribute->$value_key); |
| 1390 | 1390 | } |
| 1391 | 1391 | if (($attribute->data_type == 'integer') && !is_array($attributeValue)) { |
| 1392 | - $attributeValue = (int) $attribute->$value_key; |
|
| 1392 | + $attributeValue = (int)$attribute->$value_key; |
|
| 1393 | 1393 | } |
| 1394 | 1394 | $variation_metadata[$attribute->code] = $attribute->$value_key; |
| 1395 | 1395 | } |
@@ -1402,7 +1402,7 @@ discard block |
||
| 1402 | 1402 | $attributeValue = str_replace(',', '.', $attributeValue); |
| 1403 | 1403 | } |
| 1404 | 1404 | if (($attributeType == 'integer') && !is_array($attributeValue)) { |
| 1405 | - $attributeValue = (int) $attributeValue; |
|
| 1405 | + $attributeValue = (int)$attributeValue; |
|
| 1406 | 1406 | } |
| 1407 | 1407 | $variation_metadata[$attributeCode] = $attributeValue; |
| 1408 | 1408 | } |
@@ -1738,13 +1738,13 @@ discard block |
||
| 1738 | 1738 | if (!empty($product_price_infos)) { |
| 1739 | 1739 | $tpl_component_price = array(); |
| 1740 | 1740 | /** Price piloting **/ |
| 1741 | - $price_display_option = get_option( 'wpshop_catalog_product_option' ); |
|
| 1742 | - $tpl_component['PRICE_FROM'] = (!empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from']) ) ? 'on' : ''; |
|
| 1741 | + $price_display_option = get_option('wpshop_catalog_product_option'); |
|
| 1742 | + $tpl_component['PRICE_FROM'] = (!empty($price_display_option) && !empty($price_display_option['price_display']) && !empty($price_display_option['price_display']['text_from'])) ? 'on' : ''; |
|
| 1743 | 1743 | $price_ploting = get_option('wpshop_shop_price_piloting'); |
| 1744 | 1744 | $tpl_component_price['CROSSED_OUT_PRICE'] = (!empty($product_price_infos['CROSSED_OUT_PRICE'])) ? ((!empty($product_price_infos['PRICE_FROM'])) ? __('Price from', 'wpshop') . ' ' : '') . wpshop_display::display_template_element('product_price_template_crossed_out_price', array('CROSSED_OUT_PRICE_VALUE' => $product_price_infos['CROSSED_OUT_PRICE'])) : ''; |
| 1745 | 1745 | $variations = wpshop_products::get_variation($product_id); |
| 1746 | 1746 | $tpl_component_price['PRODUCT_PRICE'] = $product_price_infos['PRODUCT_PRICE']; |
| 1747 | - if(empty($product_price_infos['CROSSED_OUT_PRICE']) && (!empty($variations) && (!empty($product_price_infos['PRICE_FROM']) || !empty( $tpl_component['PRICE_FROM'] ) ))) { |
|
| 1747 | + if (empty($product_price_infos['CROSSED_OUT_PRICE']) && (!empty($variations) && (!empty($product_price_infos['PRICE_FROM']) || !empty($tpl_component['PRICE_FROM'])))) { |
|
| 1748 | 1748 | $tpl_component_price['PRODUCT_PRICE'] = __('Price from', 'wpshop') . ' ' . $tpl_component_price['PRODUCT_PRICE']; |
| 1749 | 1749 | } |
| 1750 | 1750 | $tpl_component_price['MESSAGE_SAVE_MONEY'] = $product_price_infos['MESSAGE_SAVE_MONEY']; |
@@ -2187,7 +2187,7 @@ discard block |
||
| 2187 | 2187 | } |
| 2188 | 2188 | |
| 2189 | 2189 | $template_part = ($variations_list && ($output_type == 'mini')) ? 'configure_product_button' : (!empty($productStock) ? 'add_to_cart_button' : 'unavailable_product_button'); |
| 2190 | - $template_part = apply_filters( 'wps_custom_add_to_cart_button', $template_part, $product_id ); |
|
| 2190 | + $template_part = apply_filters('wps_custom_add_to_cart_button', $template_part, $product_id); |
|
| 2191 | 2191 | |
| 2192 | 2192 | $tpl_component = array(); |
| 2193 | 2193 | $tpl_component['PRODUCT_ID'] = $product_id; |
@@ -3049,7 +3049,7 @@ discard block |
||
| 3049 | 3049 | $single_variations = array(); |
| 3050 | 3050 | foreach ($selected_variation as $attribute_code => $attribute_value) { |
| 3051 | 3051 | if (isset($attribute_value) && $attribute_code != 'free') { |
| 3052 | - $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_value = '" . serialize(array($attribute_code => $attribute_value)) . "' OR P_META.meta_value = '" . serialize(array($attribute_code => (int) $attribute_value)) . "'", $product_id); |
|
| 3052 | + $query = $wpdb->prepare("SELECT ID FROM " . $wpdb->postmeta . " AS P_META INNER JOIN " . $wpdb->posts . " as P ON ((P.ID = P_META.post_id) AND (P.post_parent = %d)) WHERE P_META.meta_value = '" . serialize(array($attribute_code => $attribute_value)) . "' OR P_META.meta_value = '" . serialize(array($attribute_code => (int)$attribute_value)) . "'", $product_id); |
|
| 3053 | 3053 | $single_variation_id = $wpdb->get_var($query); |
| 3054 | 3054 | if (!empty($single_variation_id)) { |
| 3055 | 3055 | $single_variations[] = $single_variation_id; |
@@ -3151,7 +3151,7 @@ discard block |
||
| 3151 | 3151 | * Since 1.4.3.7 |
| 3152 | 3152 | * L'option du produit remplace le prix du produit de tête. |
| 3153 | 3153 | */ |
| 3154 | - if( true ) { |
|
| 3154 | + if (true) { |
|
| 3155 | 3155 | //Replace the product price |
| 3156 | 3156 | if (!empty($variations_discount_total_price) && !empty($variations_discount_total_price['price_ati'])) { |
| 3157 | 3157 | $product_into_cart['price_ttc_before_discount'] = $variations_total_price['price_ati']; |
@@ -3518,16 +3518,16 @@ discard block |
||
| 3518 | 3518 | $variation_post_meta = get_post_meta($current_post_id, '_wpshop_variation_defining', true); |
| 3519 | 3519 | $variation_post_meta['options'] = $options; |
| 3520 | 3520 | $variation_post_meta['follow_general_config'] = true; |
| 3521 | - if( $variation_post_meta['follow_general_config'] ) { |
|
| 3521 | + if ($variation_post_meta['follow_general_config']) { |
|
| 3522 | 3522 | $shop_option = get_option('wpshop_catalog_product_option', array()); |
| 3523 | - if( isset( $shop_option ) ) { |
|
| 3523 | + if (isset($shop_option)) { |
|
| 3524 | 3524 | $variation_post_meta['options']['price_display'] = $shop_option['price_display']; |
| 3525 | 3525 | } |
| 3526 | 3526 | } |
| 3527 | 3527 | $variations = wpshop_attributes::get_variation_available_attribute($current_post_id); |
| 3528 | - if( !empty( $variations['available'] ) ) { |
|
| 3529 | - foreach( $variations['available'] as $key => $value ) { |
|
| 3530 | - if( !in_array( $value['attribute_complete_def']->code, $variation_post_meta['attributes'] ) ) { |
|
| 3528 | + if (!empty($variations['available'])) { |
|
| 3529 | + foreach ($variations['available'] as $key => $value) { |
|
| 3530 | + if (!in_array($value['attribute_complete_def']->code, $variation_post_meta['attributes'])) { |
|
| 3531 | 3531 | $variation_post_meta['attributes'][] = $value['attribute_complete_def']->code; |
| 3532 | 3532 | } |
| 3533 | 3533 | } |