@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) { exit; |
|
| 2 | 2 | } |
| 3 | 3 | class wps_message_ctr { |
| 4 | 4 | |
@@ -18,19 +18,19 @@ discard block |
||
| 18 | 18 | function __construct() { |
| 19 | 19 | |
| 20 | 20 | /** Js */ |
| 21 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 21 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 22 | 22 | // End if(). |
| 23 | 23 | $this->template_dir = WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/'; |
| 24 | 24 | // WP General actions |
| 25 | - add_action( 'admin_init', array( $this, 'wps_messages_init_actions' ) ); |
|
| 26 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
|
| 27 | - add_action( 'manage_' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_posts_custom_column', array( $this, 'messages_custom_columns' ) ); |
|
| 28 | - add_filter( 'manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_columns', array( $this, 'messages_edit_columns' ) ); |
|
| 25 | + add_action('admin_init', array($this, 'wps_messages_init_actions')); |
|
| 26 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes')); |
|
| 27 | + add_action('manage_' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_posts_custom_column', array($this, 'messages_custom_columns')); |
|
| 28 | + add_filter('manage_edit-' . WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE . '_columns', array($this, 'messages_edit_columns')); |
|
| 29 | 29 | // Shortcodes |
| 30 | - add_shortcode( 'wps_message_histo', array( $this, 'display_message_histo_per_customer' ) ); |
|
| 31 | - add_shortcode( 'order_customer_personnal_informations', array( $this, 'order_personnal_informations' ) ); |
|
| 30 | + add_shortcode('wps_message_histo', array($this, 'display_message_histo_per_customer')); |
|
| 31 | + add_shortcode('order_customer_personnal_informations', array($this, 'order_personnal_informations')); |
|
| 32 | 32 | /** Ajax */ |
| 33 | - add_action( 'wp_ajax_get_content_message', array( $this, 'get_content_message' ) ); |
|
| 33 | + add_action('wp_ajax_get_content_message', array($this, 'get_content_message')); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | /** Css */ |
| 42 | 42 | add_thickbox(); |
| 43 | - wp_register_style( 'wpeo-message-css', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/css/frontend.css', '', WPS_MESSAGE_VERSION ); |
|
| 44 | - wp_enqueue_style( 'wpeo-message-css' ); |
|
| 43 | + wp_register_style('wpeo-message-css', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/css/frontend.css', '', WPS_MESSAGE_VERSION); |
|
| 44 | + wp_enqueue_style('wpeo-message-css'); |
|
| 45 | 45 | /** My js */ |
| 46 | - wp_enqueue_script( 'wps-message-js', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/js/frontend.js', array( 'jquery', 'thickbox' ), WPS_MESSAGE_VERSION ); |
|
| 46 | + wp_enqueue_script('wps-message-js', WPS_MESSAGE_URL . WPS_MESSAGE_DIR . '/assets/js/frontend.js', array('jquery', 'thickbox'), WPS_MESSAGE_VERSION); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -59,23 +59,23 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function create_message_type() { |
| 61 | 61 | |
| 62 | - register_post_type( WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, array( |
|
| 62 | + register_post_type(WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, array( |
|
| 63 | 63 | 'labels' => array( |
| 64 | - 'name' => __( 'Message', 'wpshop' ), |
|
| 65 | - 'singular_name' => __( 'message', 'wpshop' ), |
|
| 66 | - 'add_new' => __( 'Add message', 'wpshop' ), |
|
| 67 | - 'add_new_item' => __( 'Add New message', 'wpshop' ), |
|
| 68 | - 'edit' => __( 'Edit', 'wpshop' ), |
|
| 69 | - 'edit_item' => __( 'Edit message', 'wpshop' ), |
|
| 70 | - 'new_item' => __( 'New message', 'wpshop' ), |
|
| 71 | - 'view' => __( 'View message', 'wpshop' ), |
|
| 72 | - 'view_item' => __( 'View message', 'wpshop' ), |
|
| 73 | - 'search_items' => __( 'Search messages', 'wpshop' ), |
|
| 74 | - 'not_found' => __( 'No message found', 'wpshop' ), |
|
| 75 | - 'not_found_in_trash' => __( 'No message found in trash', 'wpshop' ), |
|
| 64 | + 'name' => __('Message', 'wpshop'), |
|
| 65 | + 'singular_name' => __('message', 'wpshop'), |
|
| 66 | + 'add_new' => __('Add message', 'wpshop'), |
|
| 67 | + 'add_new_item' => __('Add New message', 'wpshop'), |
|
| 68 | + 'edit' => __('Edit', 'wpshop'), |
|
| 69 | + 'edit_item' => __('Edit message', 'wpshop'), |
|
| 70 | + 'new_item' => __('New message', 'wpshop'), |
|
| 71 | + 'view' => __('View message', 'wpshop'), |
|
| 72 | + 'view_item' => __('View message', 'wpshop'), |
|
| 73 | + 'search_items' => __('Search messages', 'wpshop'), |
|
| 74 | + 'not_found' => __('No message found', 'wpshop'), |
|
| 75 | + 'not_found_in_trash' => __('No message found in trash', 'wpshop'), |
|
| 76 | 76 | 'parent-item-colon' => '', |
| 77 | 77 | ), |
| 78 | - 'description' => __( 'This is where store messages are stored.', 'wpshop' ), |
|
| 78 | + 'description' => __('This is where store messages are stored.', 'wpshop'), |
|
| 79 | 79 | 'public' => true, |
| 80 | 80 | 'show_ui' => true, |
| 81 | 81 | 'capability_type' => 'post', |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | 'show_in_nav_menus' => false, |
| 87 | 87 | 'rewrite' => false, |
| 88 | 88 | 'query_var' => true, |
| 89 | - 'supports' => array( 'title', 'editor' ), |
|
| 89 | + 'supports' => array('title', 'editor'), |
|
| 90 | 90 | 'has_archive' => false, |
| 91 | - ) ); |
|
| 91 | + )); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | function add_meta_boxes() { |
| 98 | 98 | |
| 99 | 99 | // Add message sending historic meta box |
| 100 | - add_meta_box( 'wpshop_message_histo', |
|
| 101 | - __( 'Message historic', 'wpshop' ), |
|
| 102 | - array( $this, 'message_histo_box' ), |
|
| 103 | - WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, 'normal', 'high' ); |
|
| 100 | + add_meta_box('wpshop_message_histo', |
|
| 101 | + __('Message historic', 'wpshop'), |
|
| 102 | + array($this, 'message_histo_box'), |
|
| 103 | + WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, 'normal', 'high'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | * @param unknown_type $post |
| 110 | 110 | * @param unknown_type $params |
| 111 | 111 | */ |
| 112 | - function message_histo_box( $post, $params ) { |
|
| 112 | + function message_histo_box($post, $params) { |
|
| 113 | 113 | |
| 114 | 114 | $output = '<div id="message_histo_container">'; |
| 115 | - $output .= $this->get_historic_message_by_type( $post->ID ); |
|
| 115 | + $output .= $this->get_historic_message_by_type($post->ID); |
|
| 116 | 116 | $output .= '</div>'; |
| 117 | 117 | echo $output; |
| 118 | 118 | } |
@@ -123,39 +123,39 @@ discard block |
||
| 123 | 123 | * @param integer $message_type_id : Message type ID |
| 124 | 124 | * @return string |
| 125 | 125 | */ |
| 126 | - function get_historic_message_by_type( $message_type_id ) { |
|
| 126 | + function get_historic_message_by_type($message_type_id) { |
|
| 127 | 127 | |
| 128 | 128 | global $wpdb; |
| 129 | 129 | $output = ''; |
| 130 | - if ( ! empty( $message_type_id ) ) { |
|
| 130 | + if (!empty($message_type_id)) { |
|
| 131 | 131 | // Recover all sended messages |
| 132 | 132 | $wps_message_mdl = new wps_message_mdl(); |
| 133 | - $messages = $wps_message_mdl->get_messages_histo( $message_type_id ); |
|
| 133 | + $messages = $wps_message_mdl->get_messages_histo($message_type_id); |
|
| 134 | 134 | ob_start(); |
| 135 | - require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend', 'message_historic' ) ); |
|
| 135 | + require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend', 'message_historic')); |
|
| 136 | 136 | $output .= ob_get_contents(); |
| 137 | 137 | ob_end_clean(); |
| 138 | 138 | } |
| 139 | 139 | return $output; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public static function get_xml_messages( $code = null ) { |
|
| 143 | - if ( is_null( self::$xml_messages ) ) { |
|
| 144 | - $xml_default_emails = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml' ); |
|
| 145 | - $default_emails = new SimpleXMLElement( $xml_default_emails ); |
|
| 142 | + public static function get_xml_messages($code = null) { |
|
| 143 | + if (is_null(self::$xml_messages)) { |
|
| 144 | + $xml_default_emails = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml'); |
|
| 145 | + $default_emails = new SimpleXMLElement($xml_default_emails); |
|
| 146 | 146 | self::$xml_messages = array(); |
| 147 | - foreach ( $default_emails->xpath( '//emails/email' ) as $email ) { |
|
| 148 | - self::$xml_messages[ (string) $email->attributes()->code ] = array( |
|
| 149 | - 'shop_type' => (string) $email->attributes()->shop_type, |
|
| 150 | - 'object' => (string) $email->subject, |
|
| 151 | - 'message' => (string) $email->content, |
|
| 147 | + foreach ($default_emails->xpath('//emails/email') as $email) { |
|
| 148 | + self::$xml_messages[(string)$email->attributes()->code] = array( |
|
| 149 | + 'shop_type' => (string)$email->attributes()->shop_type, |
|
| 150 | + 'object' => (string)$email->subject, |
|
| 151 | + 'message' => (string)$email->content, |
|
| 152 | 152 | ); |
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | - if ( is_null( $code ) ) { |
|
| 155 | + if (is_null($code)) { |
|
| 156 | 156 | return self::$xml_messages; |
| 157 | - } elseif ( isset( self::$xml_messages[ $code ] ) ) { |
|
| 158 | - return self::$xml_messages[ $code ]; |
|
| 157 | + } elseif (isset(self::$xml_messages[$code])) { |
|
| 158 | + return self::$xml_messages[$code]; |
|
| 159 | 159 | } else { |
| 160 | 160 | return false; |
| 161 | 161 | } |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | public static function create_default_message() { |
| 167 | 167 | // Read default emails for options creation |
| 168 | - foreach ( self::get_xml_messages() as $code => $email ) { |
|
| 169 | - if ( ( WPSHOP_DEFINED_SHOP_TYPE == $email['shop_type'] ) || ( 'sale' == WPSHOP_DEFINED_SHOP_TYPE ) ) { |
|
| 170 | - self::createMessage( $code, $email['object'], $email['message'] ); |
|
| 168 | + foreach (self::get_xml_messages() as $code => $email) { |
|
| 169 | + if ((WPSHOP_DEFINED_SHOP_TYPE == $email['shop_type']) || ('sale' == WPSHOP_DEFINED_SHOP_TYPE)) { |
|
| 170 | + self::createMessage($code, $email['object'], $email['message']); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -180,25 +180,25 @@ discard block |
||
| 180 | 180 | * @param string $message : Message content |
| 181 | 181 | * @return integer message ID |
| 182 | 182 | */ |
| 183 | - public static function createMessage( $code, $object = '', $message = '' ) { |
|
| 183 | + public static function createMessage($code, $object = '', $message = '') { |
|
| 184 | 184 | $id = 0; |
| 185 | - $xml_message = self::get_xml_messages( $code ); |
|
| 186 | - $object = empty( $object ) ? $xml_message['object'] : $object; |
|
| 187 | - $message = empty( $message ) ? $xml_message['message'] : $message; |
|
| 188 | - $message_option = get_option( $code, null ); |
|
| 189 | - if ( empty( $message_option ) || false === get_post_status( $message_option ) ) { |
|
| 190 | - $id = post_exists( __( $object , 'wpshop' ), self::customize_message( __( $message, 'wpshop' ) ) ); |
|
| 191 | - if( $id == 0 ) { |
|
| 185 | + $xml_message = self::get_xml_messages($code); |
|
| 186 | + $object = empty($object) ? $xml_message['object'] : $object; |
|
| 187 | + $message = empty($message) ? $xml_message['message'] : $message; |
|
| 188 | + $message_option = get_option($code, null); |
|
| 189 | + if (empty($message_option) || false === get_post_status($message_option)) { |
|
| 190 | + $id = post_exists(__($object, 'wpshop'), self::customize_message(__($message, 'wpshop'))); |
|
| 191 | + if ($id == 0) { |
|
| 192 | 192 | $new_message = array( |
| 193 | - 'post_title' => __( $object , 'wpshop' ), |
|
| 194 | - 'post_content' => self::customize_message( __( $message, 'wpshop' ) ), |
|
| 193 | + 'post_title' => __($object, 'wpshop'), |
|
| 194 | + 'post_content' => self::customize_message(__($message, 'wpshop')), |
|
| 195 | 195 | 'post_status' => 'publish', |
| 196 | 196 | 'post_author' => 1, |
| 197 | 197 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, |
| 198 | 198 | ); |
| 199 | - $id = wp_insert_post( $new_message ); |
|
| 199 | + $id = wp_insert_post($new_message); |
|
| 200 | 200 | } |
| 201 | - update_option( $code, $id ); |
|
| 201 | + update_option($code, $id); |
|
| 202 | 202 | } else { |
| 203 | 203 | $id = $message_option; |
| 204 | 204 | } |
@@ -211,17 +211,17 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @return array |
| 213 | 213 | */ |
| 214 | - function messages_custom_columns( $column ) { |
|
| 214 | + function messages_custom_columns($column) { |
|
| 215 | 215 | |
| 216 | 216 | global $post; |
| 217 | 217 | $metadata = get_post_custom(); |
| 218 | - switch ( $column ) { |
|
| 218 | + switch ($column) { |
|
| 219 | 219 | case 'extract': |
| 220 | - echo wp_trim_words( $post->post_content, 55 ); |
|
| 220 | + echo wp_trim_words($post->post_content, 55); |
|
| 221 | 221 | break; |
| 222 | 222 | case 'last_dispatch_date': |
| 223 | - if ( ! empty( $metadata['wpshop_message_last_dispatch_date'][0] ) ) { |
|
| 224 | - echo mysql2date( 'd F Y, H:i:s',$metadata['wpshop_message_last_dispatch_date'][0], true ); |
|
| 223 | + if (!empty($metadata['wpshop_message_last_dispatch_date'][0])) { |
|
| 224 | + echo mysql2date('d F Y, H:i:s', $metadata['wpshop_message_last_dispatch_date'][0], true); |
|
| 225 | 225 | } else { echo '-'; |
| 226 | 226 | } |
| 227 | 227 | break; |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return array |
| 235 | 235 | */ |
| 236 | - function messages_edit_columns( $columns ) { |
|
| 236 | + function messages_edit_columns($columns) { |
|
| 237 | 237 | |
| 238 | 238 | $columns = array( |
| 239 | 239 | 'cb' => '<input type="checkbox" />', |
| 240 | - 'title' => __( 'Name', 'wpshop' ), |
|
| 241 | - 'extract' => __( 'Extract from the message','wpshop' ), |
|
| 242 | - 'date' => __( 'Creation date','wpshop' ), |
|
| 243 | - 'last_dispatch_date' => __( 'Last dispatch date','wpshop' ), |
|
| 240 | + 'title' => __('Name', 'wpshop'), |
|
| 241 | + 'extract' => __('Extract from the message', 'wpshop'), |
|
| 242 | + 'date' => __('Creation date', 'wpshop'), |
|
| 243 | + 'last_dispatch_date' => __('Last dispatch date', 'wpshop'), |
|
| 244 | 244 | ); |
| 245 | 245 | return $columns; |
| 246 | 246 | } |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | * @param integer $current |
| 252 | 252 | * @return string |
| 253 | 253 | */ |
| 254 | - function getMessageListOption( $current = 0 ) { |
|
| 254 | + function getMessageListOption($current = 0) { |
|
| 255 | 255 | |
| 256 | - $posts = query_posts( array( |
|
| 256 | + $posts = query_posts(array( |
|
| 257 | 257 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_MESSAGE, |
| 258 | 258 | 'posts_per_page' => '-1', |
| 259 | - ) ); |
|
| 259 | + )); |
|
| 260 | 260 | $options = ''; |
| 261 | - if ( ! empty( $posts ) ) { |
|
| 262 | - $options = '<option value="0">' . __( 'Select values from list', 'wpshop' ) . '</option>'; |
|
| 263 | - foreach ( $posts as $p ) { |
|
| 264 | - $selected = $p->ID == $current ? ' selected="selected"': ''; |
|
| 261 | + if (!empty($posts)) { |
|
| 262 | + $options = '<option value="0">' . __('Select values from list', 'wpshop') . '</option>'; |
|
| 263 | + foreach ($posts as $p) { |
|
| 264 | + $selected = $p->ID == $current ? ' selected="selected"' : ''; |
|
| 265 | 265 | $options .= '<option value="' . $p->ID . '"' . $selected . '>' . $p->post_title . '</option>'; |
| 266 | 266 | } |
| 267 | 267 | } |
@@ -276,35 +276,35 @@ discard block |
||
| 276 | 276 | * @param integer $customer_id : ID to identifiate the customer |
| 277 | 277 | * @return string |
| 278 | 278 | */ |
| 279 | - function display_message_histo_per_customer( $args, $customer_id = '' ) { |
|
| 280 | - $customer_id = ( ! empty( $customer_id ) ) ? $customer_id : ( isset( $args['cid'] ) && ! empty( $args['cid'] ) ? $args['cid'] : get_current_user_id() ); |
|
| 281 | - $message_id = ( ! empty( $args ) && ! empty( $args['message_id'] ) ) ? $args['message_id'] : ''; |
|
| 279 | + function display_message_histo_per_customer($args, $customer_id = '') { |
|
| 280 | + $customer_id = (!empty($customer_id)) ? $customer_id : (isset($args['cid']) && !empty($args['cid']) ? $args['cid'] : get_current_user_id()); |
|
| 281 | + $message_id = (!empty($args) && !empty($args['message_id'])) ? $args['message_id'] : ''; |
|
| 282 | 282 | $message_elements = ''; |
| 283 | 283 | $wps_message_mdl = new wps_message_mdl(); |
| 284 | - $messages_data = $wps_message_mdl->get_messages_histo( $message_id, $customer_id ); |
|
| 284 | + $messages_data = $wps_message_mdl->get_messages_histo($message_id, $customer_id); |
|
| 285 | 285 | |
| 286 | 286 | $current_user = wp_get_current_user(); |
| 287 | 287 | |
| 288 | 288 | $messages_histo = array(); |
| 289 | - foreach ( $messages_data as $meta_id => $messages ) : |
|
| 289 | + foreach ($messages_data as $meta_id => $messages) : |
|
| 290 | 290 | $i = 0; |
| 291 | - foreach ( $messages as $message ) : |
|
| 292 | - if ( $current_user->user_email === $message['mess_user_email'] ) : |
|
| 293 | - $messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['title'] = $message['mess_title']; |
|
| 294 | - $messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['message'] = $message['mess_message']; |
|
| 295 | - $messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['dates'] = $message['mess_dispatch_date']; |
|
| 296 | - if ( ! empty( $message['mess_object_id'] ) ) { |
|
| 297 | - $messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['object'] = $message['mess_object_id']; |
|
| 291 | + foreach ($messages as $message) : |
|
| 292 | + if ($current_user->user_email === $message['mess_user_email']) : |
|
| 293 | + $messages_histo[$message['mess_dispatch_date'][0]][$i]['title'] = $message['mess_title']; |
|
| 294 | + $messages_histo[$message['mess_dispatch_date'][0]][$i]['message'] = $message['mess_message']; |
|
| 295 | + $messages_histo[$message['mess_dispatch_date'][0]][$i]['dates'] = $message['mess_dispatch_date']; |
|
| 296 | + if (!empty($message['mess_object_id'])) { |
|
| 297 | + $messages_histo[$message['mess_dispatch_date'][0]][$i]['object'] = $message['mess_object_id']; |
|
| 298 | 298 | } |
| 299 | 299 | $i++; |
| 300 | 300 | endif; |
| 301 | 301 | endforeach; |
| 302 | 302 | endforeach; |
| 303 | 303 | |
| 304 | - ksort( $messages_histo ); |
|
| 305 | - $messages_histo = array_reverse( $messages_histo ); |
|
| 304 | + ksort($messages_histo); |
|
| 305 | + $messages_histo = array_reverse($messages_histo); |
|
| 306 | 306 | ob_start(); |
| 307 | - require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'frontend', 'customer', 'messages' ) ); |
|
| 307 | + require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'frontend', 'customer', 'messages')); |
|
| 308 | 308 | $output = ob_get_contents(); |
| 309 | 309 | ob_end_clean(); |
| 310 | 310 | |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | * @param string $message : message content |
| 318 | 318 | * @return string |
| 319 | 319 | */ |
| 320 | - public static function customize_message( $message ) { |
|
| 320 | + public static function customize_message($message) { |
|
| 321 | 321 | |
| 322 | - if ( ! empty( $message ) ) { |
|
| 322 | + if (!empty($message)) { |
|
| 323 | 323 | ob_start(); |
| 324 | - require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/', 'backend', 'message_html_structure' ) ); |
|
| 324 | + require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, WPS_MESSAGE_PATH . WPS_MESSAGE_DIR . '/templates/', 'backend', 'message_html_structure')); |
|
| 325 | 325 | $message = ob_get_contents(); |
| 326 | 326 | ob_end_clean(); |
| 327 | 327 | } |
@@ -332,15 +332,15 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * @return boolean |
| 334 | 334 | */ |
| 335 | - function add_message( $recipient_id = 0, $email, $title, $message, $model_id, $object, $date = null ) { |
|
| 335 | + function add_message($recipient_id = 0, $email, $title, $message, $model_id, $object, $date = null) { |
|
| 336 | 336 | |
| 337 | - $date = empty( $date ) ? current_time( 'mysql', 0 ) : $date; |
|
| 337 | + $date = empty($date) ? current_time('mysql', 0) : $date; |
|
| 338 | 338 | $object_empty = array( |
| 339 | 339 | 'object_type' => '', |
| 340 | 340 | 'object_id' => 0, |
| 341 | 341 | ); |
| 342 | - $object = array_merge( $object_empty, $object ); |
|
| 343 | - $historic = get_post_meta( $recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr( $date, 0, 7 ), true ); |
|
| 342 | + $object = array_merge($object_empty, $object); |
|
| 343 | + $historic = get_post_meta($recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr($date, 0, 7), true); |
|
| 344 | 344 | $data_to_insert = array( |
| 345 | 345 | 'mess_user_id' => $recipient_id, |
| 346 | 346 | 'mess_user_email' => $email, |
@@ -348,10 +348,10 @@ discard block |
||
| 348 | 348 | 'mess_object_id' => $object['object_id'], |
| 349 | 349 | 'mess_title' => $title, |
| 350 | 350 | 'mess_message' => $message, |
| 351 | - 'mess_dispatch_date' => array( $date ), |
|
| 351 | + 'mess_dispatch_date' => array($date), |
|
| 352 | 352 | ); |
| 353 | 353 | $historic[] = $data_to_insert; |
| 354 | - update_post_meta( $recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr( $date, 0, 7 ), $historic ); |
|
| 354 | + update_post_meta($recipient_id, '_wpshop_messages_histo_' . $model_id . '_' . substr($date, 0, 7), $historic); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | /** |
@@ -363,49 +363,49 @@ discard block |
||
| 363 | 363 | * @param boolean $duplicate_message : Duplicate a light message for historic storage |
| 364 | 364 | * @return string |
| 365 | 365 | */ |
| 366 | - function customMessage( $string, $data, $model_name = '', $duplicate_message = false ) { |
|
| 366 | + function customMessage($string, $data, $model_name = '', $duplicate_message = false) { |
|
| 367 | 367 | |
| 368 | 368 | $avant = array(); |
| 369 | 369 | $apres = array(); |
| 370 | - $logo_option = get_option( 'wpshop_logo' ); |
|
| 370 | + $logo_option = get_option('wpshop_logo'); |
|
| 371 | 371 | |
| 372 | - $data['your_shop_logo'] = ( ! empty( $logo_option ) ) ? '<img src="' . $logo_option . '" alt="' . get_bloginfo( 'name' ) . '" />' : ''; |
|
| 372 | + $data['your_shop_logo'] = (!empty($logo_option)) ? '<img src="' . $logo_option . '" alt="' . get_bloginfo('name') . '" />' : ''; |
|
| 373 | 373 | |
| 374 | - foreach ( $data as $key => $value ) { |
|
| 374 | + foreach ($data as $key => $value) { |
|
| 375 | 375 | $avant[] = '[' . $key . ']'; |
| 376 | - switch ( $key ) { |
|
| 376 | + switch ($key) { |
|
| 377 | 377 | case 'order_content' : |
| 378 | - $apres[] = ( $duplicate_message ) ? '[order_content]' : $this->order_content_template_for_mail( $data['order_id'] ); |
|
| 378 | + $apres[] = ($duplicate_message) ? '[order_content]' : $this->order_content_template_for_mail($data['order_id']); |
|
| 379 | 379 | break; |
| 380 | 380 | case 'order_addresses' : |
| 381 | - $apres[] = ( $duplicate_message ) ? '[order_addresses]' : $this->order_addresses_template_for_mail( $data['order_id'] ); |
|
| 381 | + $apres[] = ($duplicate_message) ? '[order_addresses]' : $this->order_addresses_template_for_mail($data['order_id']); |
|
| 382 | 382 | break; |
| 383 | 383 | |
| 384 | 384 | case 'order_billing_address' : |
| 385 | - $apres[] = ( $duplicate_message ) ? '[order_billing_address]' : $this->order_addresses_template_for_mail( $data['order_id'], 'billing' ); |
|
| 385 | + $apres[] = ($duplicate_message) ? '[order_billing_address]' : $this->order_addresses_template_for_mail($data['order_id'], 'billing'); |
|
| 386 | 386 | break; |
| 387 | 387 | |
| 388 | 388 | case 'order_shipping_address' : |
| 389 | - $apres[] = ( $duplicate_message ) ? '[order_shipping_address]' : $this->order_addresses_template_for_mail( $data['order_id'], 'shipping' ); |
|
| 389 | + $apres[] = ($duplicate_message) ? '[order_shipping_address]' : $this->order_addresses_template_for_mail($data['order_id'], 'shipping'); |
|
| 390 | 390 | break; |
| 391 | 391 | |
| 392 | 392 | case 'order_customer_comments' : |
| 393 | - $apres[] = ( $duplicate_message ) ? '[order_customer_comments]' : $this->order_customer_comment_template_for_mail( $data['order_id'] ); |
|
| 393 | + $apres[] = ($duplicate_message) ? '[order_customer_comments]' : $this->order_customer_comment_template_for_mail($data['order_id']); |
|
| 394 | 394 | break; |
| 395 | 395 | case 'order_personnal_informations' : |
| 396 | - $apres[] = ( $duplicate_message ) ? '[order_personnal_informations]' : $this->order_personnal_informations(); |
|
| 396 | + $apres[] = ($duplicate_message) ? '[order_personnal_informations]' : $this->order_personnal_informations(); |
|
| 397 | 397 | break; |
| 398 | 398 | default : |
| 399 | 399 | $apres[] = $value; |
| 400 | 400 | break; |
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | - $string = str_replace( $avant, $apres, $string ); |
|
| 403 | + $string = str_replace($avant, $apres, $string); |
|
| 404 | 404 | |
| 405 | - $string = apply_filters( 'wps_more_customized_message', $string, $data, $duplicate_message ); |
|
| 405 | + $string = apply_filters('wps_more_customized_message', $string, $data, $duplicate_message); |
|
| 406 | 406 | |
| 407 | - if ( ($model_name != 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE') ) { |
|
| 408 | - $string = preg_replace( '/\[(.*)\]/Usi', '', $string ); |
|
| 407 | + if (($model_name != 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE')) { |
|
| 408 | + $string = preg_replace('/\[(.*)\]/Usi', '', $string); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | return $string; |
@@ -420,22 +420,22 @@ discard block |
||
| 420 | 420 | * @param string $object : message object |
| 421 | 421 | * @param file $attached_file : File to attached to e-mail |
| 422 | 422 | */ |
| 423 | - function wpshop_prepared_email( $email, $model_name, $data = array(), $object = array(), $attached_file = '' ) { |
|
| 423 | + function wpshop_prepared_email($email, $model_name, $data = array(), $object = array(), $attached_file = '') { |
|
| 424 | 424 | global $wpdb; |
| 425 | - $data = apply_filters( 'wps_extra_data_to_send_in_email', $data ); |
|
| 426 | - $model_id = get_option( $model_name, 0 ); |
|
| 427 | - $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE ID = %s', $model_id ); |
|
| 428 | - $post_message = $wpdb->get_row( $query ); |
|
| 425 | + $data = apply_filters('wps_extra_data_to_send_in_email', $data); |
|
| 426 | + $model_id = get_option($model_name, 0); |
|
| 427 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE ID = %s', $model_id); |
|
| 428 | + $post_message = $wpdb->get_row($query); |
|
| 429 | 429 | $duplicate_message = ''; |
| 430 | - if ( ! empty( $post_message ) ) { |
|
| 431 | - $title = $this->customMessage( $post_message->post_title, $data, $model_name ); |
|
| 432 | - $message = $this->customMessage( $post_message->post_content, $data, $model_name ); |
|
| 430 | + if (!empty($post_message)) { |
|
| 431 | + $title = $this->customMessage($post_message->post_title, $data, $model_name); |
|
| 432 | + $message = $this->customMessage($post_message->post_content, $data, $model_name); |
|
| 433 | 433 | // End if(). |
| 434 | - if ( array_key_exists( 'order_content', $data ) || array_key_exists( 'order_addresses', $data ) || array_key_exists( 'order_customer_comments', $data ) ) { |
|
| 435 | - $duplicate_message = $this->customMessage( $post_message->post_content, $data, $model_name, true ); |
|
| 434 | + if (array_key_exists('order_content', $data) || array_key_exists('order_addresses', $data) || array_key_exists('order_customer_comments', $data)) { |
|
| 435 | + $duplicate_message = $this->customMessage($post_message->post_content, $data, $model_name, true); |
|
| 436 | 436 | } |
| 437 | - if ( ! empty( $email ) ) { |
|
| 438 | - $this->wpshop_email( $email, $title, $message, true, $model_id, $object, $attached_file, $duplicate_message ); |
|
| 437 | + if (!empty($email)) { |
|
| 438 | + $this->wpshop_email($email, $title, $message, true, $model_id, $object, $attached_file, $duplicate_message); |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | } |
@@ -452,37 +452,37 @@ discard block |
||
| 452 | 452 | * @param file $attachments : File to attached to e-mail |
| 453 | 453 | * @param string $duplicate_message : lighter message to store |
| 454 | 454 | */ |
| 455 | - function wpshop_email( $email, $title, $message, $save = true, $model_id, $object = array(), $attachments = '', $duplicate_message = '' ) { |
|
| 455 | + function wpshop_email($email, $title, $message, $save = true, $model_id, $object = array(), $attachments = '', $duplicate_message = '') { |
|
| 456 | 456 | global $wpdb; |
| 457 | 457 | // Sauvegarde |
| 458 | - if ( $save ) { |
|
| 459 | - $user = $wpdb->get_row( 'SELECT ID FROM ' . $wpdb->users . ' WHERE user_email="' . $email . '";' ); |
|
| 458 | + if ($save) { |
|
| 459 | + $user = $wpdb->get_row('SELECT ID FROM ' . $wpdb->users . ' WHERE user_email="' . $email . '";'); |
|
| 460 | 460 | $user_id = $user ? $user->ID : get_current_user_id(); |
| 461 | - $query = $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s ', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 462 | - $user_post_id = $wpdb->get_var( $query ); |
|
| 461 | + $query = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s ', $user_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 462 | + $user_post_id = $wpdb->get_var($query); |
|
| 463 | 463 | |
| 464 | - if ( ! empty( $duplicate_message ) ) { |
|
| 465 | - $this->add_message( $user_post_id, $email, $title, $duplicate_message, $model_id, $object ); |
|
| 464 | + if (!empty($duplicate_message)) { |
|
| 465 | + $this->add_message($user_post_id, $email, $title, $duplicate_message, $model_id, $object); |
|
| 466 | 466 | } else { |
| 467 | - $this->add_message( $user_post_id, $email, $title, $message, $model_id, $object ); |
|
| 467 | + $this->add_message($user_post_id, $email, $title, $message, $model_id, $object); |
|
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - $emails = get_option( 'wpshop_emails', array() ); |
|
| 471 | + $emails = get_option('wpshop_emails', array()); |
|
| 472 | 472 | $noreply_email = $emails['noreply_email']; |
| 473 | 473 | // Split the email to get the name |
| 474 | - $vers_nom = substr( $email, 0, strpos( $email,'@' ) ); |
|
| 474 | + $vers_nom = substr($email, 0, strpos($email, '@')); |
|
| 475 | 475 | |
| 476 | 476 | // Headers du mail |
| 477 | 477 | $headers = "MIME-Version: 1.0\r\n"; |
| 478 | 478 | $headers .= "Content-type: text/html; charset=UTF-8\r\n"; |
| 479 | - $headers .= 'From: ' . get_bloginfo( 'name' ) . ' <' . $noreply_email . '>' . "\r\n"; |
|
| 479 | + $headers .= 'From: ' . get_bloginfo('name') . ' <' . $noreply_email . '>' . "\r\n"; |
|
| 480 | 480 | |
| 481 | 481 | // Mail en HTML |
| 482 | - @wp_mail( $email, $title, $message, $headers, $attachments ); |
|
| 482 | + @wp_mail($email, $title, $message, $headers, $attachments); |
|
| 483 | 483 | |
| 484 | - if ( ! empty( $attachments ) ) { |
|
| 485 | - unlink( $attachments ); |
|
| 484 | + if (!empty($attachments)) { |
|
| 485 | + unlink($attachments); |
|
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | |
@@ -492,13 +492,13 @@ discard block |
||
| 492 | 492 | * @param integer $order_id : Order ID |
| 493 | 493 | * @return string |
| 494 | 494 | */ |
| 495 | - function order_content_template_for_mail( $order_id ) { |
|
| 495 | + function order_content_template_for_mail($order_id) { |
|
| 496 | 496 | $message = ''; |
| 497 | - if ( ! empty( $order_id ) ) { |
|
| 498 | - $currency_code = wpshop_tools::wpshop_get_currency( false ); |
|
| 499 | - $orders_infos = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 497 | + if (!empty($order_id)) { |
|
| 498 | + $currency_code = wpshop_tools::wpshop_get_currency(false); |
|
| 499 | + $orders_infos = get_post_meta($order_id, '_order_postmeta', true); |
|
| 500 | 500 | ob_start(); |
| 501 | - require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_content_mail_template' ) ); |
|
| 501 | + require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_content_mail_template')); |
|
| 502 | 502 | $message .= ob_get_contents(); |
| 503 | 503 | ob_end_clean(); |
| 504 | 504 | } |
@@ -512,44 +512,44 @@ discard block |
||
| 512 | 512 | * @param integer $address_type : Address type ID |
| 513 | 513 | * @return string |
| 514 | 514 | */ |
| 515 | - function order_addresses_template_for_mail( $order_id, $address_type = '' ) { |
|
| 515 | + function order_addresses_template_for_mail($order_id, $address_type = '') { |
|
| 516 | 516 | global $wpdb; |
| 517 | - $shipping_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 518 | - $display_shipping = ( ! empty( $shipping_option ) && ! empty( $shipping_option['activate'] ) ) ? true : false; |
|
| 517 | + $shipping_option = get_option('wpshop_shipping_address_choice'); |
|
| 518 | + $display_shipping = (!empty($shipping_option) && !empty($shipping_option['activate'])) ? true : false; |
|
| 519 | 519 | $message = ''; |
| 520 | - if ( ! empty( $order_id ) ) { |
|
| 521 | - $order_addresses = get_post_meta( $order_id, '_order_info', true ); |
|
| 522 | - if ( ! empty( $order_addresses ) ) { |
|
| 523 | - foreach ( $order_addresses as $key => $order_address ) { |
|
| 524 | - if ( ! empty( $order_address ) && ( empty( $address_type ) || $address_type == $key ) ) { |
|
| 525 | - |
|
| 526 | - if ( $key != 'shipping' || ($key == 'shipping' && $display_shipping) ) { |
|
| 527 | - $address_type_title = ( ! empty( $key ) && $key == 'billing' ) ? __( 'Billing address', 'wpshop' ) : __( 'Shipping address', 'wpshop' ); |
|
| 520 | + if (!empty($order_id)) { |
|
| 521 | + $order_addresses = get_post_meta($order_id, '_order_info', true); |
|
| 522 | + if (!empty($order_addresses)) { |
|
| 523 | + foreach ($order_addresses as $key => $order_address) { |
|
| 524 | + if (!empty($order_address) && (empty($address_type) || $address_type == $key)) { |
|
| 525 | + |
|
| 526 | + if ($key != 'shipping' || ($key == 'shipping' && $display_shipping)) { |
|
| 527 | + $address_type_title = (!empty($key) && $key == 'billing') ? __('Billing address', 'wpshop') : __('Shipping address', 'wpshop'); |
|
| 528 | 528 | $civility = ''; |
| 529 | - if ( ! empty( $order_address['address']['civility'] ) ) { |
|
| 530 | - $query = $wpdb->prepare( 'SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $order_address['address']['civility'] ); |
|
| 531 | - $civility = $wpdb->get_var( $query ); |
|
| 529 | + if (!empty($order_address['address']['civility'])) { |
|
| 530 | + $query = $wpdb->prepare('SELECT label FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . ' WHERE id = %d', $order_address['address']['civility']); |
|
| 531 | + $civility = $wpdb->get_var($query); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | // Address informations |
| 535 | - $customer_last_name = ( ! empty( $order_address['address']['address_last_name'] ) ) ? $order_address['address']['address_last_name'] : ''; |
|
| 536 | - $customer_firtsname = ( ! empty( $order_address['address']['address_first_name'] ) ) ? $order_address['address']['address_first_name'] : ''; |
|
| 537 | - $customer_company = ( ! empty( $order_address['address']['company'] ) ) ? $order_address['address']['company'] : ''; |
|
| 538 | - $customer_address = ( ! empty( $order_address['address']['address'] ) ) ? $order_address['address']['address'] : ''; |
|
| 539 | - $customer_zip_code = ( ! empty( $order_address['address']['postcode'] ) ) ? $order_address['address']['postcode'] : ''; |
|
| 540 | - $customer_city = ( ! empty( $order_address['address']['city'] ) ) ? $order_address['address']['city'] : ''; |
|
| 541 | - $customer_state = ( ! empty( $order_address['address']['state'] ) ) ? $order_address['address']['state'] : ''; |
|
| 542 | - $customer_phone = ( ! empty( $order_address['address']['phone'] ) ) ? ' Tel. : ' . $order_address['address']['phone'] : ''; |
|
| 535 | + $customer_last_name = (!empty($order_address['address']['address_last_name'])) ? $order_address['address']['address_last_name'] : ''; |
|
| 536 | + $customer_firtsname = (!empty($order_address['address']['address_first_name'])) ? $order_address['address']['address_first_name'] : ''; |
|
| 537 | + $customer_company = (!empty($order_address['address']['company'])) ? $order_address['address']['company'] : ''; |
|
| 538 | + $customer_address = (!empty($order_address['address']['address'])) ? $order_address['address']['address'] : ''; |
|
| 539 | + $customer_zip_code = (!empty($order_address['address']['postcode'])) ? $order_address['address']['postcode'] : ''; |
|
| 540 | + $customer_city = (!empty($order_address['address']['city'])) ? $order_address['address']['city'] : ''; |
|
| 541 | + $customer_state = (!empty($order_address['address']['state'])) ? $order_address['address']['state'] : ''; |
|
| 542 | + $customer_phone = (!empty($order_address['address']['phone'])) ? ' Tel. : ' . $order_address['address']['phone'] : ''; |
|
| 543 | 543 | $country = ''; |
| 544 | - foreach ( unserialize( WPSHOP_COUNTRY_LIST ) as $key => $value ) { |
|
| 545 | - if ( ! empty( $order_address['address']['country'] ) && $key == $order_address['address']['country'] ) { |
|
| 544 | + foreach (unserialize(WPSHOP_COUNTRY_LIST) as $key => $value) { |
|
| 545 | + if (!empty($order_address['address']['country']) && $key == $order_address['address']['country']) { |
|
| 546 | 546 | $country = $value; |
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | 549 | $customer_country = $country; |
| 550 | 550 | |
| 551 | 551 | ob_start(); |
| 552 | - require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_addresses_template_for_mail' ) ); |
|
| 552 | + require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_addresses_template_for_mail')); |
|
| 553 | 553 | $message .= ob_get_contents(); |
| 554 | 554 | ob_end_clean(); |
| 555 | 555 | } |
@@ -566,20 +566,20 @@ discard block |
||
| 566 | 566 | * @param integer $order_id : Order ID |
| 567 | 567 | * @return string |
| 568 | 568 | */ |
| 569 | - function order_customer_comment_template_for_mail( $order_id ) { |
|
| 569 | + function order_customer_comment_template_for_mail($order_id) { |
|
| 570 | 570 | global $wpdb; |
| 571 | 571 | $message = ''; |
| 572 | - if ( ! empty( $order_id ) ) { |
|
| 573 | - $query = $wpdb->prepare( 'SELECT post_excerpt FROM ' . $wpdb->posts . ' WHERE ID = %d', $order_id ); |
|
| 574 | - $comment = $wpdb->get_var( $query ); |
|
| 575 | - $order_infos = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 576 | - if ( ! empty( $order_infos['order_key'] ) ) { |
|
| 577 | - $comment_title = __( 'Comments about the order', 'wpshop' ); |
|
| 572 | + if (!empty($order_id)) { |
|
| 573 | + $query = $wpdb->prepare('SELECT post_excerpt FROM ' . $wpdb->posts . ' WHERE ID = %d', $order_id); |
|
| 574 | + $comment = $wpdb->get_var($query); |
|
| 575 | + $order_infos = get_post_meta($order_id, '_order_postmeta', true); |
|
| 576 | + if (!empty($order_infos['order_key'])) { |
|
| 577 | + $comment_title = __('Comments about the order', 'wpshop'); |
|
| 578 | 578 | } else { |
| 579 | - $comment_title = __( 'Comments about the quotation', 'wpshop' ); |
|
| 579 | + $comment_title = __('Comments about the quotation', 'wpshop'); |
|
| 580 | 580 | } |
| 581 | 581 | ob_start(); |
| 582 | - require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_email_customer_comments' ) ); |
|
| 582 | + require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_email_customer_comments')); |
|
| 583 | 583 | $message .= ob_get_contents(); |
| 584 | 584 | ob_end_clean(); |
| 585 | 585 | } |
@@ -595,15 +595,15 @@ discard block |
||
| 595 | 595 | global $wpdb; |
| 596 | 596 | $user_id = get_current_user_id(); |
| 597 | 597 | $message = ''; |
| 598 | - $customer_entity = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 599 | - if ( ! empty( $customer_entity ) ) { |
|
| 598 | + $customer_entity = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 599 | + if (!empty($customer_entity)) { |
|
| 600 | 600 | |
| 601 | - $query = $wpdb->prepare( 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s', $customer_entity, 'valid' ); |
|
| 602 | - $attributes_sets = $wpdb->get_results( $query ); |
|
| 601 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s', $customer_entity, 'valid'); |
|
| 602 | + $attributes_sets = $wpdb->get_results($query); |
|
| 603 | 603 | |
| 604 | - if ( ! empty( $attributes_sets ) ) { |
|
| 604 | + if (!empty($attributes_sets)) { |
|
| 605 | 605 | ob_start(); |
| 606 | - require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_personnal_informations_template_for_mail' ) ); |
|
| 606 | + require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'backend/mails', 'order_personnal_informations_template_for_mail')); |
|
| 607 | 607 | $message .= ob_get_contents(); |
| 608 | 608 | ob_end_clean(); |
| 609 | 609 | } |
@@ -616,17 +616,17 @@ discard block |
||
| 616 | 616 | */ |
| 617 | 617 | function wpshop_messages_historic_correction() { |
| 618 | 618 | global $wpdb; |
| 619 | - $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s', '_wpshop_messages_histo_%' ); |
|
| 620 | - $messages_histo = $wpdb->get_results( $query ); |
|
| 619 | + $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->postmeta . ' WHERE meta_key LIKE %s', '_wpshop_messages_histo_%'); |
|
| 620 | + $messages_histo = $wpdb->get_results($query); |
|
| 621 | 621 | |
| 622 | - foreach ( $messages_histo as $message ) { |
|
| 623 | - $query_user = $wpdb->prepare( 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $message->post_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 624 | - $user_post_id = $wpdb->get_var( $query_user ); |
|
| 625 | - $wpdb->update( $wpdb->postmeta, array( |
|
| 622 | + foreach ($messages_histo as $message) { |
|
| 623 | + $query_user = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_author = %d AND post_type = %s', $message->post_id, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 624 | + $user_post_id = $wpdb->get_var($query_user); |
|
| 625 | + $wpdb->update($wpdb->postmeta, array( |
|
| 626 | 626 | 'post_id' => $user_post_id, |
| 627 | 627 | ), array( |
| 628 | 628 | 'meta_id' => $message->meta_id, |
| 629 | - ) ); |
|
| 629 | + )); |
|
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | |
@@ -635,20 +635,20 @@ discard block |
||
| 635 | 635 | * Récupères le contenu du message |
| 636 | 636 | */ |
| 637 | 637 | public function get_content_message() { |
| 638 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
| 638 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
| 639 | 639 | |
| 640 | - if ( ! wp_verify_nonce( $_wpnonce, 'get_content_message' ) ) { |
|
| 640 | + if (!wp_verify_nonce($_wpnonce, 'get_content_message')) { |
|
| 641 | 641 | wp_die(); |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | global $wpdb; |
| 645 | - $meta_id = (int) $_GET['meta_id']; |
|
| 645 | + $meta_id = (int)$_GET['meta_id']; |
|
| 646 | 646 | |
| 647 | - $result = $wpdb->get_results( $wpdb->prepare( 'SELECT meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_id=%d', array( ($meta_id) ) ) ); |
|
| 648 | - $result = unserialize( $result[0]->meta_value ); |
|
| 647 | + $result = $wpdb->get_results($wpdb->prepare('SELECT meta_value FROM ' . $wpdb->postmeta . ' WHERE meta_id=%d', array(($meta_id)))); |
|
| 648 | + $result = unserialize($result[0]->meta_value); |
|
| 649 | 649 | $result = $result[0]['mess_message']; |
| 650 | 650 | |
| 651 | - wp_die( $result ); |
|
| 651 | + wp_die($result); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | } |
@@ -1,11 +1,11 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | ?> |
| 3 | 3 | <div class="wps-boxed"> |
| 4 | 4 | <?php echo $attributes_sections_tpl; ?> |
| 5 | - <?php if ( $customer_link ) : ?> |
|
| 6 | - <div><a href="<?php echo get_edit_post_link( $cid ); ?>"><?php esc_html_e( 'See customer', 'wpshop' ); ?></a></div> |
|
| 7 | - <?php apply_filters( 'wps_filter_customer_in_order', $cid, wps_customer_ctr::get_author_id_by_customer_id( $cid ) ); ?> |
|
| 8 | - <?php elseif ( ! is_admin() || strpos( $_SERVER['REQUEST_URI'], 'admin-ajax.php' ) ) : ?> |
|
| 9 | - <div><button data-nonce="<?php echo esc_attr( wp_create_nonce( 'wps_fill_account_informations_modal' ) ); ?>" data-customer-id="<?php echo esc_attr( $cid ); ?>" class="wps-link wps-alignright" id="wps_modal_account_informations_opener"><i class="wps-icon-pencil"></i><?php esc_html_e( 'Edit your account informations', 'wpshop' ); ?></button></div> |
|
| 5 | + <?php if ($customer_link) : ?> |
|
| 6 | + <div><a href="<?php echo get_edit_post_link($cid); ?>"><?php esc_html_e('See customer', 'wpshop'); ?></a></div> |
|
| 7 | + <?php apply_filters('wps_filter_customer_in_order', $cid, wps_customer_ctr::get_author_id_by_customer_id($cid)); ?> |
|
| 8 | + <?php elseif (!is_admin() || strpos($_SERVER['REQUEST_URI'], 'admin-ajax.php')) : ?> |
|
| 9 | + <div><button data-nonce="<?php echo esc_attr(wp_create_nonce('wps_fill_account_informations_modal')); ?>" data-customer-id="<?php echo esc_attr($cid); ?>" class="wps-link wps-alignright" id="wps_modal_account_informations_opener"><i class="wps-icon-pencil"></i><?php esc_html_e('Edit your account informations', 'wpshop'); ?></button></div> |
|
| 10 | 10 | <?php endif; ?> |
| 11 | 11 | </div> |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | class wps_account_ctr { |
| 3 | 3 | |
| 4 | 4 | private $redirect = false; |
@@ -8,50 +8,50 @@ discard block |
||
| 8 | 8 | function __construct() { |
| 9 | 9 | /** Shortcodes **/ |
| 10 | 10 | // Sign up Display Shortcode |
| 11 | - add_shortcode( 'wps_signup', array( &$this, 'display_signup' ) ); |
|
| 11 | + add_shortcode('wps_signup', array(&$this, 'display_signup')); |
|
| 12 | 12 | // Log in Form Display Shortcode |
| 13 | - add_shortcode( 'wpshop_login', array( &$this, 'get_login_form')); |
|
| 13 | + add_shortcode('wpshop_login', array(&$this, 'get_login_form')); |
|
| 14 | 14 | //Log in first step |
| 15 | - add_shortcode( 'wps_first_login', array( &$this, 'get_login_first_step')); |
|
| 15 | + add_shortcode('wps_first_login', array(&$this, 'get_login_first_step')); |
|
| 16 | 16 | // Forgot password Form |
| 17 | - add_shortcode( 'wps_forgot_password', array( &$this, 'get_forgot_password_form')); |
|
| 17 | + add_shortcode('wps_forgot_password', array(&$this, 'get_forgot_password_form')); |
|
| 18 | 18 | // Renew password form |
| 19 | - add_shortcode( 'wps_renew_password', array( &$this, 'get_renew_password_form')); |
|
| 19 | + add_shortcode('wps_renew_password', array(&$this, 'get_renew_password_form')); |
|
| 20 | 20 | //Account informations |
| 21 | - add_shortcode( 'wps_account_informations', array($this, 'shortcode_callback_display_account_informations') ); |
|
| 21 | + add_shortcode('wps_account_informations', array($this, 'shortcode_callback_display_account_informations')); |
|
| 22 | 22 | //Account form |
| 23 | - add_shortcode( 'wps_account_informations_form', array($this, 'account_informations_form') ); |
|
| 23 | + add_shortcode('wps_account_informations_form', array($this, 'account_informations_form')); |
|
| 24 | 24 | |
| 25 | 25 | /** Ajax Actions **/ |
| 26 | 26 | // add_action('wap_ajax_wps_display_connexion_form', array(&$this, 'wps_ajax_get_login_form_interface') ); |
| 27 | 27 | // add_action('wap_ajax_nopriv_wps_display_connexion_form', array(&$this, 'wps_ajax_get_login_form_interface') ); |
| 28 | 28 | |
| 29 | - add_action('wp_ajax_wps_login_request', array(&$this, 'control_login_form_request') ); |
|
| 30 | - add_action('wp_ajax_nopriv_wps_login_request', array(&$this, 'control_login_form_request') ); |
|
| 29 | + add_action('wp_ajax_wps_login_request', array(&$this, 'control_login_form_request')); |
|
| 30 | + add_action('wp_ajax_nopriv_wps_login_request', array(&$this, 'control_login_form_request')); |
|
| 31 | 31 | |
| 32 | - add_action('wp_ajax_wps_forgot_password_request', array(&$this, 'wps_forgot_password_request') ); |
|
| 33 | - add_action('wp_ajax_nopriv_wps_forgot_password_request', array(&$this, 'wps_forgot_password_request') ); |
|
| 32 | + add_action('wp_ajax_wps_forgot_password_request', array(&$this, 'wps_forgot_password_request')); |
|
| 33 | + add_action('wp_ajax_nopriv_wps_forgot_password_request', array(&$this, 'wps_forgot_password_request')); |
|
| 34 | 34 | |
| 35 | - add_action('wp_ajax_wps_forgot_password_renew', array(&$this, 'wps_forgot_password_renew') ); |
|
| 36 | - add_action('wp_ajax_nopriv_wps_forgot_password_renew', array(&$this, 'wps_forgot_password_renew') ); |
|
| 35 | + add_action('wp_ajax_wps_forgot_password_renew', array(&$this, 'wps_forgot_password_renew')); |
|
| 36 | + add_action('wp_ajax_nopriv_wps_forgot_password_renew', array(&$this, 'wps_forgot_password_renew')); |
|
| 37 | 37 | |
| 38 | - add_action('wp_ajax_wps_signup_request', array(&$this, 'wps_save_signup_form') ); |
|
| 39 | - add_action('wp_ajax_nopriv_wps_signup_request', array(&$this, 'wps_save_signup_form_nopriv') ); |
|
| 38 | + add_action('wp_ajax_wps_signup_request', array(&$this, 'wps_save_signup_form')); |
|
| 39 | + add_action('wp_ajax_nopriv_wps_signup_request', array(&$this, 'wps_save_signup_form_nopriv')); |
|
| 40 | 40 | |
| 41 | - add_action('wp_ajax_wps_login_first_request', array(&$this, 'wps_login_first_request') ); |
|
| 42 | - add_action('wp_ajax_nopriv_wps_login_first_request', array(&$this, 'wps_login_first_request') ); |
|
| 41 | + add_action('wp_ajax_wps_login_first_request', array(&$this, 'wps_login_first_request')); |
|
| 42 | + add_action('wp_ajax_nopriv_wps_login_first_request', array(&$this, 'wps_login_first_request')); |
|
| 43 | 43 | |
| 44 | - add_action( 'wp_ajax_wps_save_account_informations', array($this, 'wps_save_account_informations') ); |
|
| 44 | + add_action('wp_ajax_wps_save_account_informations', array($this, 'wps_save_account_informations')); |
|
| 45 | 45 | |
| 46 | - add_action( 'wp_ajax_wps_account_reload_informations', array($this, 'wps_account_reload_informations') ); |
|
| 46 | + add_action('wp_ajax_wps_account_reload_informations', array($this, 'wps_account_reload_informations')); |
|
| 47 | 47 | |
| 48 | - add_action( 'wp_ajax_wps_fill_forgot_password_modal', array($this, 'wps_fill_forgot_password_modal') ); |
|
| 49 | - add_action( 'wp_ajax_nopriv_wps_fill_forgot_password_modal', array($this, 'wps_fill_forgot_password_modal') ); |
|
| 48 | + add_action('wp_ajax_wps_fill_forgot_password_modal', array($this, 'wps_fill_forgot_password_modal')); |
|
| 49 | + add_action('wp_ajax_nopriv_wps_fill_forgot_password_modal', array($this, 'wps_fill_forgot_password_modal')); |
|
| 50 | 50 | |
| 51 | - add_action( 'wp_ajax_wps_fill_account_informations_modal', array($this, 'wps_fill_account_informations_modal') ); |
|
| 52 | - add_action( 'wp_ajax_nopriv_wps_fill_account_informations_modal', array($this, 'wps_fill_account_informations_modal') ); |
|
| 51 | + add_action('wp_ajax_wps_fill_account_informations_modal', array($this, 'wps_fill_account_informations_modal')); |
|
| 52 | + add_action('wp_ajax_nopriv_wps_fill_account_informations_modal', array($this, 'wps_fill_account_informations_modal')); |
|
| 53 | 53 | |
| 54 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts') ); |
|
| 54 | + add_action('wp_enqueue_scripts', array($this, 'add_scripts')); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -59,33 +59,33 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function add_scripts() { |
| 61 | 61 | wp_enqueue_script('jquery'); |
| 62 | - wp_enqueue_script( 'wps_forgot_password_js', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/js/wps_forgot_password.js' ); |
|
| 63 | - wp_enqueue_script( 'wps_login_js', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/js/wps_login.js' ); |
|
| 64 | - wp_enqueue_script( 'wps_signup_js', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/js/wps_signup.js' ); |
|
| 65 | - wp_enqueue_script( 'wps_account_js', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/js/wps_account.js' ); |
|
| 66 | - wp_enqueue_style( 'wps_account_css', WPS_ACCOUNT_URL.'wps_customer/assets/frontend/css/frontend.css' ); |
|
| 62 | + wp_enqueue_script('wps_forgot_password_js', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/js/wps_forgot_password.js'); |
|
| 63 | + wp_enqueue_script('wps_login_js', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/js/wps_login.js'); |
|
| 64 | + wp_enqueue_script('wps_signup_js', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/js/wps_signup.js'); |
|
| 65 | + wp_enqueue_script('wps_account_js', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/js/wps_account.js'); |
|
| 66 | + wp_enqueue_style('wps_account_css', WPS_ACCOUNT_URL . 'wps_customer/assets/frontend/css/frontend.css'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** LOG IN - Display log in Form **/ |
| 70 | - function get_login_form( $force_login = false ) { |
|
| 70 | + function get_login_form($force_login = false) { |
|
| 71 | 71 | $args = array(); |
| 72 | - if ( get_current_user_id() != 0 ) { |
|
| 73 | - return __( 'You are already logged', 'wpshop'); |
|
| 72 | + if (get_current_user_id() != 0) { |
|
| 73 | + return __('You are already logged', 'wpshop'); |
|
| 74 | 74 | } |
| 75 | 75 | else { |
| 76 | - $action = !empty( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ''; |
|
| 77 | - $key = !empty( $_GET['key'] ) ? sanitize_text_field( $_GET['key'] ) : ''; |
|
| 78 | - $login = !empty( $_GET['login'] ) ? sanitize_text_field( $_GET['login'] ) : 0; |
|
| 79 | - if ( !empty($action) && $action == 'retrieve_password' && !empty($key) && !empty($login) && !$force_login ) { |
|
| 76 | + $action = !empty($_GET['action']) ? sanitize_text_field($_GET['action']) : ''; |
|
| 77 | + $key = !empty($_GET['key']) ? sanitize_text_field($_GET['key']) : ''; |
|
| 78 | + $login = !empty($_GET['login']) ? sanitize_text_field($_GET['login']) : 0; |
|
| 79 | + if (!empty($action) && $action == 'retrieve_password' && !empty($key) && !empty($login) && !$force_login) { |
|
| 80 | 80 | $output = self::get_renew_password_form(); |
| 81 | 81 | } |
| 82 | 82 | else { |
| 83 | 83 | ob_start(); |
| 84 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "login/login-form") ); |
|
| 84 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "login/login-form")); |
|
| 85 | 85 | $output = ob_get_contents(); |
| 86 | 86 | ob_end_clean(); |
| 87 | - if ( !$force_login ) { |
|
| 88 | - $output .= do_shortcode( '[wps_signup]' ); |
|
| 87 | + if (!$force_login) { |
|
| 88 | + $output .= do_shortcode('[wps_signup]'); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | return $output; |
@@ -95,53 +95,53 @@ discard block |
||
| 95 | 95 | /** LOG IN - AJAX - Action to connect **/ |
| 96 | 96 | function control_login_form_request() { |
| 97 | 97 | |
| 98 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 98 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 99 | 99 | |
| 100 | - if ( !wp_verify_nonce( $_wpnonce, 'control_login_form_request' ) ) |
|
| 100 | + if (!wp_verify_nonce($_wpnonce, 'control_login_form_request')) |
|
| 101 | 101 | wp_die(); |
| 102 | 102 | |
| 103 | 103 | $result = ''; |
| 104 | 104 | $status = false; |
| 105 | - $origin = sanitize_text_field( $_POST['wps-checking-origin'] ); |
|
| 106 | - $wps_login_user_login = !empty( $_POST['wps_login_user_login'] ) ? sanitize_text_field( $_POST['wps_login_user_login' ] ) : ''; |
|
| 107 | - $wps_login_password = !empty( $_POST['wps_login_password'] ) ? sanitize_text_field( $_POST['wps_login_password' ] ) : ''; |
|
| 108 | - $page_account_id = wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id') ); |
|
| 109 | - if ( !empty($wps_login_user_login) && !empty($wps_login_password) ) { |
|
| 105 | + $origin = sanitize_text_field($_POST['wps-checking-origin']); |
|
| 106 | + $wps_login_user_login = !empty($_POST['wps_login_user_login']) ? sanitize_text_field($_POST['wps_login_user_login']) : ''; |
|
| 107 | + $wps_login_password = !empty($_POST['wps_login_password']) ? sanitize_text_field($_POST['wps_login_password']) : ''; |
|
| 108 | + $page_account_id = wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')); |
|
| 109 | + if (!empty($wps_login_user_login) && !empty($wps_login_password)) { |
|
| 110 | 110 | $creds = array(); |
| 111 | 111 | // Test if an user exist with this login |
| 112 | - $user_checking = get_user_by( 'login', $wps_login_user_login ); |
|
| 113 | - if( !empty($user_checking) ) { |
|
| 112 | + $user_checking = get_user_by('login', $wps_login_user_login); |
|
| 113 | + if (!empty($user_checking)) { |
|
| 114 | 114 | $creds['user_login'] = $wps_login_user_login; |
| 115 | 115 | } |
| 116 | 116 | else { |
| 117 | - if ( is_email($wps_login_user_login) ) { |
|
| 118 | - $user_checking = get_user_by( 'email', $wps_login_user_login ); |
|
| 117 | + if (is_email($wps_login_user_login)) { |
|
| 118 | + $user_checking = get_user_by('email', $wps_login_user_login); |
|
| 119 | 119 | $creds['user_login'] = $user_checking->user_login; |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | - $creds['user_password'] = wpshop_tools::varSanitizer( $_POST['wps_login_password'] ); |
|
| 123 | - $creds['remember'] = !empty( $_POST['wps_login_remember_me'] ) ? (int) $_POST['wps_login_remember_me'] : false; |
|
| 124 | - $user = wp_signon( $creds, false ); |
|
| 125 | - if ( is_wp_error($user) ) { |
|
| 126 | - $result = '<div class="wps-alert-error">' .__('Connexion error', 'wpshop'). '</div>'; |
|
| 122 | + $creds['user_password'] = wpshop_tools::varSanitizer($_POST['wps_login_password']); |
|
| 123 | + $creds['remember'] = !empty($_POST['wps_login_remember_me']) ? (int)$_POST['wps_login_remember_me'] : false; |
|
| 124 | + $user = wp_signon($creds, false); |
|
| 125 | + if (is_wp_error($user)) { |
|
| 126 | + $result = '<div class="wps-alert-error">' . __('Connexion error', 'wpshop') . '</div>'; |
|
| 127 | 127 | } |
| 128 | 128 | else { |
| 129 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 130 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' ) ); |
|
| 131 | - if( $origin == $page_account_id ) { |
|
| 132 | - $result = get_permalink( $page_account_id ); |
|
| 129 | + $permalink_option = get_option('permalink_structure'); |
|
| 130 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 131 | + if ($origin == $page_account_id) { |
|
| 132 | + $result = get_permalink($page_account_id); |
|
| 133 | 133 | } |
| 134 | 134 | else { |
| 135 | - $result = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
|
| 135 | + $result = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=3'; |
|
| 136 | 136 | } |
| 137 | 137 | $status = true; |
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | else { |
| 141 | - $result = '<div class="wps-alert-error">' .__('E-Mail and Password are required', 'wpshop'). '</div>'; |
|
| 141 | + $result = '<div class="wps-alert-error">' . __('E-Mail and Password are required', 'wpshop') . '</div>'; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - echo json_encode( array( $status, $result) ); |
|
| 144 | + echo json_encode(array($status, $result)); |
|
| 145 | 145 | die(); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | * LOG IN - AJAX - Display log in Form in Ajax |
| 150 | 150 | */ |
| 151 | 151 | function wps_ajax_get_login_form_interface() { |
| 152 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 152 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 153 | 153 | |
| 154 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_ajax_get_login_form_interface' ) ) |
|
| 154 | + if (!wp_verify_nonce($_wpnonce, 'wps_ajax_get_login_form_interface')) |
|
| 155 | 155 | wp_die(); |
| 156 | 156 | |
| 157 | - $response = array( 'status' => true, 'response' => self::get_login_form() ); |
|
| 158 | - echo json_encode( $response ); |
|
| 157 | + $response = array('status' => true, 'response' => self::get_login_form()); |
|
| 158 | + echo json_encode($response); |
|
| 159 | 159 | die(); |
| 160 | 160 | } |
| 161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | function get_login_first_step() { |
| 164 | 164 | $output = ''; |
| 165 | 165 | ob_start(); |
| 166 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "login/login-form", "first") ); |
|
| 166 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "login/login-form", "first")); |
|
| 167 | 167 | $output .= ob_get_contents(); |
| 168 | 168 | ob_end_clean(); |
| 169 | 169 | return $output; |
@@ -173,39 +173,39 @@ discard block |
||
| 173 | 173 | * LOG IN - First Step log in request |
| 174 | 174 | */ |
| 175 | 175 | function wps_login_first_request() { |
| 176 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 176 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 177 | 177 | |
| 178 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_login_first_request' ) ) |
|
| 178 | + if (!wp_verify_nonce($_wpnonce, 'wps_login_first_request')) |
|
| 179 | 179 | wp_die(); |
| 180 | 180 | |
| 181 | 181 | $status = false; $login_action = false; $response = ''; |
| 182 | - $user_email = ( !empty($_POST['email_address']) ) ? wpshop_tools::varSanitizer( $_POST['email_address'] ) : null; |
|
| 183 | - if ( !empty($user_email) ) { |
|
| 182 | + $user_email = (!empty($_POST['email_address'])) ? wpshop_tools::varSanitizer($_POST['email_address']) : null; |
|
| 183 | + if (!empty($user_email)) { |
|
| 184 | 184 | $status = true; |
| 185 | 185 | /** Check if a user exist with it's email **/ |
| 186 | - $checking_user = get_user_by( 'login', $user_email); |
|
| 187 | - if ( !empty($checking_user) ) { |
|
| 186 | + $checking_user = get_user_by('login', $user_email); |
|
| 187 | + if (!empty($checking_user)) { |
|
| 188 | 188 | $login_action = true; |
| 189 | - $user_firstname = get_user_meta( $checking_user->ID, 'first_name', true ); |
|
| 189 | + $user_firstname = get_user_meta($checking_user->ID, 'first_name', true); |
|
| 190 | 190 | $response = $user_firstname; |
| 191 | 191 | } |
| 192 | 192 | else { |
| 193 | - $checking_user = get_user_by( 'email', $user_email); |
|
| 194 | - if ( !empty( $checking_user ) ) { |
|
| 193 | + $checking_user = get_user_by('email', $user_email); |
|
| 194 | + if (!empty($checking_user)) { |
|
| 195 | 195 | $login_action = true; |
| 196 | - $user_firstname = get_user_meta( $checking_user->ID, 'first_name', true ); |
|
| 196 | + $user_firstname = get_user_meta($checking_user->ID, 'first_name', true); |
|
| 197 | 197 | $response = $user_firstname; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if( !$login_action && is_email($user_email) ) { |
|
| 201 | + if (!$login_action && is_email($user_email)) { |
|
| 202 | 202 | $response = $user_email; |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | else { |
| 206 | - $response = '<div class="wps-alert-error">' .__( 'An e-mail address is required', 'wpshop' ). '</div>'; |
|
| 206 | + $response = '<div class="wps-alert-error">' . __('An e-mail address is required', 'wpshop') . '</div>'; |
|
| 207 | 207 | } |
| 208 | - echo json_encode( array( 'status'=> $status, 'response' => $response, 'login_action' => $login_action) ); |
|
| 208 | + echo json_encode(array('status'=> $status, 'response' => $response, 'login_action' => $login_action)); |
|
| 209 | 209 | die(); |
| 210 | 210 | } |
| 211 | 211 | |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | function get_forgot_password_form() { |
| 216 | 216 | $output = ''; |
| 217 | - if ( get_current_user_id() == 0 ) { |
|
| 217 | + if (get_current_user_id() == 0) { |
|
| 218 | 218 | ob_start(); |
| 219 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "forgot-password/forgot-password") ); |
|
| 219 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "forgot-password/forgot-password")); |
|
| 220 | 220 | $output = ob_get_contents(); |
| 221 | 221 | ob_end_clean(); |
| 222 | 222 | } |
@@ -227,16 +227,16 @@ discard block |
||
| 227 | 227 | * FORGOT PASSWORD - AJAX - Fill the forgot password modal |
| 228 | 228 | */ |
| 229 | 229 | function wps_fill_forgot_password_modal() { |
| 230 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 230 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 231 | 231 | |
| 232 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_fill_forgot_password_modal' ) ) |
|
| 232 | + if (!wp_verify_nonce($_wpnonce, 'wps_fill_forgot_password_modal')) |
|
| 233 | 233 | wp_die(); |
| 234 | 234 | |
| 235 | 235 | $status = false; $title = $content = ''; |
| 236 | - $title = __( 'Forgot password', 'wpshop' ); |
|
| 236 | + $title = __('Forgot password', 'wpshop'); |
|
| 237 | 237 | $content = do_shortcode('[wps_forgot_password]'); |
| 238 | 238 | $status = true; |
| 239 | - echo json_encode( array('status' => $status, 'title' => $title, 'content' => $content) ); |
|
| 239 | + echo json_encode(array('status' => $status, 'title' => $title, 'content' => $content)); |
|
| 240 | 240 | wp_die(); |
| 241 | 241 | } |
| 242 | 242 | |
@@ -244,48 +244,48 @@ discard block |
||
| 244 | 244 | * FORGOT PASSWORD- AJAX - Forgot Password Request |
| 245 | 245 | */ |
| 246 | 246 | function wps_forgot_password_request() { |
| 247 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 247 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 248 | 248 | |
| 249 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_forgot_password_request' ) ) |
|
| 249 | + if (!wp_verify_nonce($_wpnonce, 'wps_forgot_password_request')) |
|
| 250 | 250 | wp_die(); |
| 251 | 251 | |
| 252 | 252 | global $wpdb; |
| 253 | 253 | $status = false; $result = ''; |
| 254 | - $user_login = ( !empty( $_POST['wps_user_login']) ) ? wpshop_tools::varSanitizer($_POST['wps_user_login']) : null; |
|
| 255 | - if ( !empty($user_login) ) { |
|
| 254 | + $user_login = (!empty($_POST['wps_user_login'])) ? wpshop_tools::varSanitizer($_POST['wps_user_login']) : null; |
|
| 255 | + if (!empty($user_login)) { |
|
| 256 | 256 | $existing_user = false; |
| 257 | 257 | $key_for_update = 'user_login'; |
| 258 | 258 | $exist_user = get_user_by('login', $user_login); |
| 259 | - if( !empty($exist_user) ) { |
|
| 259 | + if (!empty($exist_user)) { |
|
| 260 | 260 | $existing_user = true; |
| 261 | 261 | } |
| 262 | 262 | else { |
| 263 | 263 | $exist_user = get_user_by('email', $user_login); |
| 264 | 264 | $key_for_update = 'user_email'; |
| 265 | - if ( !empty($exist_user) ) { |
|
| 265 | + if (!empty($exist_user)) { |
|
| 266 | 266 | $existing_user = true; |
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - if ( $existing_user ) { |
|
| 270 | + if ($existing_user) { |
|
| 271 | 271 | $key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE $key_for_update = %s", $user_login)); |
| 272 | - if ( empty($key) ) { |
|
| 272 | + if (empty($key)) { |
|
| 273 | 273 | $key = wp_generate_password(20, false); |
| 274 | 274 | $wpdb->update($wpdb->users, array('user_activation_key' => $key), array('user_login' => $user_login)); |
| 275 | 275 | } |
| 276 | 276 | $this->send_forgot_password_email($key, $user_login, $exist_user); |
| 277 | - $result = '<div class="wps-alert-info">' .__('An e-mail with an password renew link has been sent to you', 'wpshop'). '</div>'; |
|
| 277 | + $result = '<div class="wps-alert-info">' . __('An e-mail with an password renew link has been sent to you', 'wpshop') . '</div>'; |
|
| 278 | 278 | $status = true; |
| 279 | 279 | } |
| 280 | 280 | else { |
| 281 | - $result = '<div class="wps-alert-error">' .__('No customer account corresponds to this email', 'wpshop'). '</div>'; |
|
| 281 | + $result = '<div class="wps-alert-error">' . __('No customer account corresponds to this email', 'wpshop') . '</div>'; |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | else { |
| 285 | - $result = '<div class="wps-alert-error">' .__('Please fill the required field', 'wpshop'). '</div>'; |
|
| 285 | + $result = '<div class="wps-alert-error">' . __('Please fill the required field', 'wpshop') . '</div>'; |
|
| 286 | 286 | } |
| 287 | - $response = array( $status, $result ); |
|
| 288 | - echo json_encode( $response ); |
|
| 287 | + $response = array($status, $result); |
|
| 288 | + echo json_encode($response); |
|
| 289 | 289 | die(); |
| 290 | 290 | } |
| 291 | 291 | |
@@ -294,67 +294,67 @@ discard block |
||
| 294 | 294 | * @param string $key |
| 295 | 295 | * @param string $user_login |
| 296 | 296 | */ |
| 297 | - function send_forgot_password_email($key, $user_login, $exist_user){ |
|
| 297 | + function send_forgot_password_email($key, $user_login, $exist_user) { |
|
| 298 | 298 | $user_data = $exist_user->data; |
| 299 | 299 | $email = $user_data->user_email; |
| 300 | 300 | $wps_message = new wps_message_ctr(); |
| 301 | - $first_name = get_user_meta( $user_data->ID, 'first_name', true ); |
|
| 302 | - $last_name = get_user_meta( $user_data->ID, 'last_name', true ); |
|
| 303 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 304 | - $link = '<a href="' .get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ).( (!empty($permalink_option)) ? '?' : '&').'order_step=2&action=retrieve_password&key=' .$key. '&login=' .rawurlencode($user_login). '">' .get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ). '&action=retrieve_password&key=' .$key. '&login=' .rawurlencode($user_login). '</a>'; |
|
| 305 | - if( !empty($key) && !empty( $user_login ) ) { |
|
| 301 | + $first_name = get_user_meta($user_data->ID, 'first_name', true); |
|
| 302 | + $last_name = get_user_meta($user_data->ID, 'last_name', true); |
|
| 303 | + $permalink_option = get_option('permalink_structure'); |
|
| 304 | + $link = '<a href="' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=2&action=retrieve_password&key=' . $key . '&login=' . rawurlencode($user_login) . '">' . get_permalink(wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id'))) . '&action=retrieve_password&key=' . $key . '&login=' . rawurlencode($user_login) . '</a>'; |
|
| 305 | + if (!empty($key) && !empty($user_login)) { |
|
| 306 | 306 | $wps_message->wpshop_prepared_email($email, |
| 307 | 307 | 'WPSHOP_FORGOT_PASSWORD_MESSAGE', |
| 308 | - array( 'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'forgot_password_link' => $link) |
|
| 308 | + array('customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'forgot_password_link' => $link) |
|
| 309 | 309 | ); |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** FORGOT PASSWORD - AJAX - Make renew password action **/ |
| 314 | 314 | function wps_forgot_password_renew() { |
| 315 | - check_ajax_referer( 'wps_forgot_password_renew' ); |
|
| 315 | + check_ajax_referer('wps_forgot_password_renew'); |
|
| 316 | 316 | |
| 317 | 317 | global $wpdb; |
| 318 | 318 | $status = false; $result = $form = ''; |
| 319 | - $password = ( !empty( $_POST['pass1']) ) ? wpshop_tools::varSanitizer( $_POST['pass1'] ) : null; |
|
| 320 | - $confirm_password = ( !empty( $_POST['pass2']) ) ? wpshop_tools::varSanitizer( $_POST['pass2'] ) : null; |
|
| 321 | - $activation_key = ( !empty( $_POST['activation_key']) ) ? wpshop_tools::varSanitizer( $_POST['activation_key'] ) : null; |
|
| 322 | - $login = ( !empty( $_POST['user_login']) ) ? wpshop_tools::varSanitizer( $_POST['user_login'] ) : null; |
|
| 323 | - if ( !empty($password) && !empty($confirm_password) && $confirm_password == $password ) { |
|
| 324 | - if ( !empty($activation_key) && !empty($login) ) { |
|
| 319 | + $password = (!empty($_POST['pass1'])) ? wpshop_tools::varSanitizer($_POST['pass1']) : null; |
|
| 320 | + $confirm_password = (!empty($_POST['pass2'])) ? wpshop_tools::varSanitizer($_POST['pass2']) : null; |
|
| 321 | + $activation_key = (!empty($_POST['activation_key'])) ? wpshop_tools::varSanitizer($_POST['activation_key']) : null; |
|
| 322 | + $login = (!empty($_POST['user_login'])) ? wpshop_tools::varSanitizer($_POST['user_login']) : null; |
|
| 323 | + if (!empty($password) && !empty($confirm_password) && $confirm_password == $password) { |
|
| 324 | + if (!empty($activation_key) && !empty($login)) { |
|
| 325 | 325 | $existing_user = false; |
| 326 | - $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $activation_key, $login ) ); |
|
| 327 | - if( !empty($user) ) { |
|
| 326 | + $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_login = %s", $activation_key, $login)); |
|
| 327 | + if (!empty($user)) { |
|
| 328 | 328 | $existing_user = true; |
| 329 | 329 | } |
| 330 | 330 | else { |
| 331 | - $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_email = %s", $activation_key, $login ) ); |
|
| 332 | - if( !empty($user) ) { |
|
| 331 | + $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->users WHERE user_activation_key = %s AND user_email = %s", $activation_key, $login)); |
|
| 332 | + if (!empty($user)) { |
|
| 333 | 333 | $existing_user = true; |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if ( $existing_user ){ |
|
| 337 | + if ($existing_user) { |
|
| 338 | 338 | wp_set_password($password, $user->ID); |
| 339 | 339 | wp_password_change_notification($user); |
| 340 | 340 | $status = true; |
| 341 | - $result = '<div class="wps-alert-success">' .__('Your password has been updated', 'wpshop'). '. <a href="#" id="display_connexion_form"> ' .__('Connect you', 'wpshop').' !</a></div>'; |
|
| 342 | - $form = self::get_login_form( true ); |
|
| 341 | + $result = '<div class="wps-alert-success">' . __('Your password has been updated', 'wpshop') . '. <a href="#" id="display_connexion_form"> ' . __('Connect you', 'wpshop') . ' !</a></div>'; |
|
| 342 | + $form = self::get_login_form(true); |
|
| 343 | 343 | } |
| 344 | 344 | else { |
| 345 | - $result = '<div class=" wps-alert-error">' .__('Invalid activation key', 'wpshop'). '</div>'; |
|
| 345 | + $result = '<div class=" wps-alert-error">' . __('Invalid activation key', 'wpshop') . '</div>'; |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | else { |
| 349 | - $result = '<div class=" wps-alert-error">' .__('Invalid activation key', 'wpshop'). '</div>'; |
|
| 349 | + $result = '<div class=" wps-alert-error">' . __('Invalid activation key', 'wpshop') . '</div>'; |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | else { |
| 353 | - $result = '<div class="wps-alert-error">' .__('Password and confirmation password are differents', 'wpshop'). '</div>'; |
|
| 353 | + $result = '<div class="wps-alert-error">' . __('Password and confirmation password are differents', 'wpshop') . '</div>'; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - $response = array( $status, $result, $form ); |
|
| 357 | - echo json_encode( $response); |
|
| 356 | + $response = array($status, $result, $form); |
|
| 357 | + echo json_encode($response); |
|
| 358 | 358 | die(); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -363,9 +363,9 @@ discard block |
||
| 363 | 363 | * @return string |
| 364 | 364 | */ |
| 365 | 365 | function get_renew_password_form() { |
| 366 | - if ( get_current_user_id() == 0 ) { |
|
| 366 | + if (get_current_user_id() == 0) { |
|
| 367 | 367 | ob_start(); |
| 368 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "forgot-password/password-renew") ); |
|
| 368 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "forgot-password/password-renew")); |
|
| 369 | 369 | $output = ob_get_contents(); |
| 370 | 370 | ob_end_clean(); |
| 371 | 371 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | |
| 375 | 375 | /** FORGOT PASSWORD - AJAX - Get Forgot Password form **/ |
| 376 | 376 | function wps_ajax_get_forgot_password_form() { |
| 377 | - echo json_encode( array(self::get_forgot_password_form() ) ); |
|
| 377 | + echo json_encode(array(self::get_forgot_password_form())); |
|
| 378 | 378 | die(); |
| 379 | 379 | } |
| 380 | 380 | |
@@ -382,29 +382,29 @@ discard block |
||
| 382 | 382 | * SIGN UP - Display Sign up form |
| 383 | 383 | * @return string |
| 384 | 384 | */ |
| 385 | - function display_signup( $args = array() ) { |
|
| 385 | + function display_signup($args = array()) { |
|
| 386 | 386 | global $wpdb; |
| 387 | 387 | $output = ''; |
| 388 | - if ( get_current_user_id() == 0 || !empty($args) ) { |
|
| 388 | + if (get_current_user_id() == 0 || !empty($args)) { |
|
| 389 | 389 | $fields_to_output = $signup_fields = array(); |
| 390 | 390 | |
| 391 | - $password_attribute = $signup_form_attributes = array(); |
|
| 391 | + $password_attribute = $signup_form_attributes = array(); |
|
| 392 | 392 | |
| 393 | - $entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 393 | + $entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 394 | 394 | |
| 395 | - $query = $wpdb->prepare('SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE_SET.' WHERE entity_id = %d', $entity_id); |
|
| 396 | - $customer_entity_id = $wpdb->get_var( $query ); |
|
| 395 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $entity_id); |
|
| 396 | + $customer_entity_id = $wpdb->get_var($query); |
|
| 397 | 397 | $attributes_set = wpshop_attributes_set::getElement($customer_entity_id); |
| 398 | - $account_attributes = wpshop_attributes_set::getAttributeSetDetails( ( !empty($attributes_set->id) ) ? $attributes_set->id : '', "'valid'"); |
|
| 399 | - $query = $wpdb->prepare('SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE_GROUP.' WHERE attribute_set_id = %d AND status = %s', $attributes_set->id, 'valid' ); |
|
| 400 | - $customer_attributes_sections = $wpdb->get_results( $query ); |
|
| 401 | - foreach( $customer_attributes_sections as $k => $customer_attributes_section ) { |
|
| 402 | - foreach( $account_attributes[$customer_attributes_section->id]['attribut'] as $attribute ) { |
|
| 398 | + $account_attributes = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
| 399 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d AND status = %s', $attributes_set->id, 'valid'); |
|
| 400 | + $customer_attributes_sections = $wpdb->get_results($query); |
|
| 401 | + foreach ($customer_attributes_sections as $k => $customer_attributes_section) { |
|
| 402 | + foreach ($account_attributes[$customer_attributes_section->id]['attribut'] as $attribute) { |
|
| 403 | 403 | $signup_fields[] = $attribute; |
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | ob_start(); |
| 407 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "signup/signup") ); |
|
| 407 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "signup/signup")); |
|
| 408 | 408 | $output = ob_get_contents(); |
| 409 | 409 | ob_end_clean(); |
| 410 | 410 | } |
@@ -412,119 +412,119 @@ discard block |
||
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | function wps_save_signup_form_nopriv() { |
| 415 | - $this->wps_save_signup_form( true ); |
|
| 415 | + $this->wps_save_signup_form(true); |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * SIGN UP - Save sign up form |
| 420 | 420 | */ |
| 421 | - function wps_save_signup_form( $connect = false ) { |
|
| 422 | - $_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
| 421 | + function wps_save_signup_form($connect = false) { |
|
| 422 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
| 423 | 423 | |
| 424 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_save_signup_form' ) ) |
|
| 424 | + if (!wp_verify_nonce($_wpnonce, 'wps_save_signup_form')) |
|
| 425 | 425 | wp_die(); |
| 426 | 426 | |
| 427 | 427 | global $wpdb, $wpshop; |
| 428 | - $user_id = ( !empty( $_POST['wps_sign_up_request_from_admin'] ) ) ? (int) $_POST['wps_sign_up_request_from_admin'] : get_current_user_id(); |
|
| 428 | + $user_id = (!empty($_POST['wps_sign_up_request_from_admin'])) ? (int)$_POST['wps_sign_up_request_from_admin'] : get_current_user_id(); |
|
| 429 | 429 | $wps_message = new wps_message_ctr(); |
| 430 | 430 | $status = $account_creation = false; $result = ''; |
| 431 | - $exclude_user_meta = array( 'user_email', 'user_pass' ); |
|
| 432 | - $attribute = !empty( $_POST['attribute'] ) ? (array) $_POST['attribute'] : array(); |
|
| 433 | - $element_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 434 | - if ( !empty( $element_id) ){ |
|
| 435 | - $query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $element_id ); |
|
| 436 | - $attribute_set_id = $wpdb->get_var( $query ); |
|
| 437 | - if ( !empty($attribute_set_id) ){ |
|
| 438 | - $group = wps_address::get_addresss_form_fields_by_type( $attribute_set_id ); |
|
| 439 | - foreach ( $group as $attribute_sets ) { |
|
| 440 | - foreach ( $attribute_sets as $attribute_set_field ) { |
|
| 441 | - if( !empty($user_id) ) { |
|
| 442 | - foreach( $attribute_set_field['content'] as $attribute_code => $att_def ) { |
|
| 443 | - if( $attribute_code != 'account_user_email' ) { |
|
| 431 | + $exclude_user_meta = array('user_email', 'user_pass'); |
|
| 432 | + $attribute = !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array(); |
|
| 433 | + $element_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 434 | + if (!empty($element_id)) { |
|
| 435 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $element_id); |
|
| 436 | + $attribute_set_id = $wpdb->get_var($query); |
|
| 437 | + if (!empty($attribute_set_id)) { |
|
| 438 | + $group = wps_address::get_addresss_form_fields_by_type($attribute_set_id); |
|
| 439 | + foreach ($group as $attribute_sets) { |
|
| 440 | + foreach ($attribute_sets as $attribute_set_field) { |
|
| 441 | + if (!empty($user_id)) { |
|
| 442 | + foreach ($attribute_set_field['content'] as $attribute_code => $att_def) { |
|
| 443 | + if ($attribute_code != 'account_user_email') { |
|
| 444 | 444 | $attribute_set_field['content'][$attribute_code]['required'] = 'no'; |
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | - $validate = $wpshop->validateForm($attribute_set_field['content'], $attribute ); |
|
| 448 | + $validate = $wpshop->validateForm($attribute_set_field['content'], $attribute); |
|
| 449 | 449 | } |
| 450 | - if ( empty($wpshop->errors) ) { |
|
| 451 | - $user_name = !empty($attribute['varchar']['user_login']) ? sanitize_text_field( $attribute['varchar']['user_login'] ) : sanitize_email( $attribute['varchar']['user_email'] ); |
|
| 452 | - $user_pass = ( !empty($attribute['varchar']['user_pass']) && !empty($_POST['wps_signup_account_creation']) ) ? sanitize_text_field( $attribute['varchar']['user_pass'] ) : wp_generate_password( 12, false ); |
|
| 450 | + if (empty($wpshop->errors)) { |
|
| 451 | + $user_name = !empty($attribute['varchar']['user_login']) ? sanitize_text_field($attribute['varchar']['user_login']) : sanitize_email($attribute['varchar']['user_email']); |
|
| 452 | + $user_pass = (!empty($attribute['varchar']['user_pass']) && !empty($_POST['wps_signup_account_creation'])) ? sanitize_text_field($attribute['varchar']['user_pass']) : wp_generate_password(12, false); |
|
| 453 | 453 | |
| 454 | - if ( $user_id == 0 ) { |
|
| 455 | - $user_id = wp_create_user($user_name, $user_pass, sanitize_email( $attribute['varchar']['user_email'] ) ); |
|
| 456 | - if ( !is_object( $user_id) ) { |
|
| 454 | + if ($user_id == 0) { |
|
| 455 | + $user_id = wp_create_user($user_name, $user_pass, sanitize_email($attribute['varchar']['user_email'])); |
|
| 456 | + if (!is_object($user_id)) { |
|
| 457 | 457 | $account_creation = true; |
| 458 | 458 | /** Update newsletter user preferences **/ |
| 459 | 459 | $newsletter_preferences = array(); |
| 460 | - $newsletters_site = !empty( $_POST['newsletters_site'] ) ? (bool) $_POST['newsletters_site'] : false; |
|
| 461 | - if( $newsletters_site ) { |
|
| 460 | + $newsletters_site = !empty($_POST['newsletters_site']) ? (bool)$_POST['newsletters_site'] : false; |
|
| 461 | + if ($newsletters_site) { |
|
| 462 | 462 | $newsletter_preferences['newsletters_site'] = 1; |
| 463 | 463 | } |
| 464 | - $newsletters_site_partners = !empty( $_POST['newsletters_site_partners'] ) ? (bool) $_POST['newsletters_site_partners'] : false; |
|
| 465 | - if( $newsletters_site_partners ) { |
|
| 464 | + $newsletters_site_partners = !empty($_POST['newsletters_site_partners']) ? (bool)$_POST['newsletters_site_partners'] : false; |
|
| 465 | + if ($newsletters_site_partners) { |
|
| 466 | 466 | $newsletter_preferences['newsletters_site_partners'] = 1; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - update_user_meta( $user_id, 'user_preferences', $newsletter_preferences); |
|
| 469 | + update_user_meta($user_id, 'user_preferences', $newsletter_preferences); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $customer_entity_request = $wpdb->prepare( 'SELECT ID FROM ' .$wpdb->posts. ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id); |
|
| 474 | - $customer_post_ID = $wpdb->get_var( $customer_entity_request ); |
|
| 473 | + $customer_entity_request = $wpdb->prepare('SELECT ID FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_author = %d', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, $user_id); |
|
| 474 | + $customer_post_ID = $wpdb->get_var($customer_entity_request); |
|
| 475 | 475 | |
| 476 | - if( !empty( $attribute ) ) { |
|
| 476 | + if (!empty($attribute)) { |
|
| 477 | 477 | $user_info = $address_forms = $all_addresses_form = array(); |
| 478 | - $billing_option = get_option( 'wpshop_billing_address' ); |
|
| 479 | - foreach( $attribute as $type => $attributes ) { |
|
| 480 | - if( !empty( $billing_option['integrate_into_register_form'] ) && $billing_option['integrate_into_register_form'] == 'yes' && ctype_digit( (string) $type ) ) { |
|
| 478 | + $billing_option = get_option('wpshop_billing_address'); |
|
| 479 | + foreach ($attribute as $type => $attributes) { |
|
| 480 | + if (!empty($billing_option['integrate_into_register_form']) && $billing_option['integrate_into_register_form'] == 'yes' && ctype_digit((string)$type)) { |
|
| 481 | 481 | //wps_address::save_address_infos( (int) $type ); |
| 482 | - foreach( $attributes as $sub_type => $sub_attributes ) { |
|
| 483 | - if( !is_array( $sub_attributes ) ) { |
|
| 484 | - $address_forms[$type][$sub_type] = sanitize_text_field( $sub_attributes ); |
|
| 482 | + foreach ($attributes as $sub_type => $sub_attributes) { |
|
| 483 | + if (!is_array($sub_attributes)) { |
|
| 484 | + $address_forms[$type][$sub_type] = sanitize_text_field($sub_attributes); |
|
| 485 | 485 | continue; |
| 486 | 486 | } |
| 487 | - foreach( $sub_attributes as $sub_meta => $sub_attribute_value ) { |
|
| 488 | - $address_forms[$type][$sub_type][$sub_meta] = sanitize_text_field( $sub_attribute_value ); |
|
| 487 | + foreach ($sub_attributes as $sub_meta => $sub_attribute_value) { |
|
| 488 | + $address_forms[$type][$sub_type][$sub_meta] = sanitize_text_field($sub_attribute_value); |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | } else { |
| 492 | - foreach( $attributes as $meta => $attribute_value ) { |
|
| 493 | - $user_info[$meta] = sanitize_text_field( $attribute_value ); |
|
| 494 | - if( !empty( $billing_option['integrate_into_register_form'] ) && $billing_option['integrate_into_register_form'] == 'yes' && isset( $billing_option['integrate_into_register_form_matching_field'], $billing_option['integrate_into_register_form_matching_field'][$meta] ) ) { |
|
| 492 | + foreach ($attributes as $meta => $attribute_value) { |
|
| 493 | + $user_info[$meta] = sanitize_text_field($attribute_value); |
|
| 494 | + if (!empty($billing_option['integrate_into_register_form']) && $billing_option['integrate_into_register_form'] == 'yes' && isset($billing_option['integrate_into_register_form_matching_field'], $billing_option['integrate_into_register_form_matching_field'][$meta])) { |
|
| 495 | 495 | $all_addresses_form[$type][$meta] = $user_info[$meta]; |
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | - wps_customer_ctr::save_customer_synchronize( $customer_post_ID, $user_id, $user_info ); |
|
| 501 | - foreach( $address_forms as $type_of_form => $address_form ) { |
|
| 502 | - $address_form = array_merge_recursive( $all_addresses_form, $address_form ); |
|
| 503 | - wps_address::save_address_infos( (int) $type_of_form, 0, array( 'type_of_form' => (int) $type_of_form, 'attribute' => array( $type_of_form => $address_form ) ), $customer_post_ID ); |
|
| 500 | + wps_customer_ctr::save_customer_synchronize($customer_post_ID, $user_id, $user_info); |
|
| 501 | + foreach ($address_forms as $type_of_form => $address_form) { |
|
| 502 | + $address_form = array_merge_recursive($all_addresses_form, $address_form); |
|
| 503 | + wps_address::save_address_infos((int)$type_of_form, 0, array('type_of_form' => (int)$type_of_form, 'attribute' => array($type_of_form => $address_form)), $customer_post_ID); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - if ( !empty( $_SESSION ) && !empty( $_SESSION[ 'cart' ] ) ) { |
|
| 508 | - $permalink_option = get_option( 'permalink_structure' ); |
|
| 509 | - $checkout_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_checkout_page_id' )); |
|
| 510 | - $result = get_permalink( $checkout_page_id ).( ( !empty($permalink_option) ) ? '?' : '&').'order_step=3'; |
|
| 507 | + if (!empty($_SESSION) && !empty($_SESSION['cart'])) { |
|
| 508 | + $permalink_option = get_option('permalink_structure'); |
|
| 509 | + $checkout_page_id = wpshop_tools::get_page_id(get_option('wpshop_checkout_page_id')); |
|
| 510 | + $result = get_permalink($checkout_page_id) . ((!empty($permalink_option)) ? '?' : '&') . 'order_step=3'; |
|
| 511 | 511 | } |
| 512 | 512 | else { |
| 513 | - $account_page_id = wpshop_tools::get_page_id( get_option( 'wpshop_myaccount_page_id' )); |
|
| 514 | - $result = get_permalink( $account_page_id ); |
|
| 513 | + $account_page_id = wpshop_tools::get_page_id(get_option('wpshop_myaccount_page_id')); |
|
| 514 | + $result = get_permalink($account_page_id); |
|
| 515 | 515 | } |
| 516 | 516 | $status = true; |
| 517 | 517 | |
| 518 | - if ( $account_creation && !empty( $user_id ) && $connect ) { |
|
| 518 | + if ($account_creation && !empty($user_id) && $connect) { |
|
| 519 | 519 | $secure_cookie = is_ssl() ? true : false; |
| 520 | - wp_set_auth_cookie( $user_id, true, $secure_cookie ); |
|
| 520 | + wp_set_auth_cookie($user_id, true, $secure_cookie); |
|
| 521 | 521 | } |
| 522 | - $wps_message->wpshop_prepared_email( sanitize_email($attribute['varchar']['user_email']), 'WPSHOP_SIGNUP_MESSAGE', array('customer_first_name' => ( !empty($attribute['varchar']['first_name']) ) ? sanitize_text_field( $attribute['varchar']['first_name'] ) : '', 'customer_last_name' => ( !empty($attribute['varchar']['last_name']) ) ? sanitize_text_field( $attribute['varchar']['last_name'] ) : '', 'customer_user_email' => ( !empty($attribute['varchar']['user_email']) ) ? sanitize_email( $attribute['varchar']['user_email'] ) : '') ); |
|
| 522 | + $wps_message->wpshop_prepared_email(sanitize_email($attribute['varchar']['user_email']), 'WPSHOP_SIGNUP_MESSAGE', array('customer_first_name' => (!empty($attribute['varchar']['first_name'])) ? sanitize_text_field($attribute['varchar']['first_name']) : '', 'customer_last_name' => (!empty($attribute['varchar']['last_name'])) ? sanitize_text_field($attribute['varchar']['last_name']) : '', 'customer_user_email' => (!empty($attribute['varchar']['user_email'])) ? sanitize_email($attribute['varchar']['user_email']) : '')); |
|
| 523 | 523 | |
| 524 | 524 | } else { |
| 525 | - $result = '<div class="wps-alert-error">' .__('Some errors have been detected', 'wpshop') . ' : <ul>'; |
|
| 526 | - foreach( $wpshop->errors as $error ){ |
|
| 527 | - $result .= '<li>' .$error. '</li>'; |
|
| 525 | + $result = '<div class="wps-alert-error">' . __('Some errors have been detected', 'wpshop') . ' : <ul>'; |
|
| 526 | + foreach ($wpshop->errors as $error) { |
|
| 527 | + $result .= '<li>' . $error . '</li>'; |
|
| 528 | 528 | } |
| 529 | 529 | $result .= '</div>'; |
| 530 | 530 | } |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - wp_die( json_encode( array( $status, $result, $user_id ) ) ); |
|
| 536 | + wp_die(json_encode(array($status, $result, $user_id))); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** SIGN UP - Display the commercial & newsletter form |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | */ |
| 542 | 542 | function display_commercial_newsletter_form() { |
| 543 | 543 | $output = ''; |
| 544 | - $user_preferences = get_user_meta( get_current_user_id(), 'user_preferences', true ); |
|
| 545 | - $wpshop_cart_option = get_option( 'wpshop_cart_option' ); |
|
| 544 | + $user_preferences = get_user_meta(get_current_user_id(), 'user_preferences', true); |
|
| 545 | + $wpshop_cart_option = get_option('wpshop_cart_option'); |
|
| 546 | 546 | ob_start(); |
| 547 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "signup/signup", "newsletter") ); |
|
| 547 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "signup/signup", "newsletter")); |
|
| 548 | 548 | $output = ob_get_contents(); |
| 549 | 549 | ob_end_clean(); |
| 550 | 550 | |
@@ -558,9 +558,9 @@ discard block |
||
| 558 | 558 | * |
| 559 | 559 | * @param array $args Les arguments passés au shortcode. |
| 560 | 560 | */ |
| 561 | - function shortcode_callback_display_account_informations( $args ) { |
|
| 562 | - $customer_id = ! empty( $args ) && ! empty( $args['cid'] ) ? (int) $args['cid'] : wps_customer_ctr::get_customer_id_by_author_id( get_current_user_id() ); |
|
| 563 | - return $this->display_account_informations( $customer_id ); |
|
| 561 | + function shortcode_callback_display_account_informations($args) { |
|
| 562 | + $customer_id = !empty($args) && !empty($args['cid']) ? (int)$args['cid'] : wps_customer_ctr::get_customer_id_by_author_id(get_current_user_id()); |
|
| 563 | + return $this->display_account_informations($customer_id); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | /** |
@@ -570,29 +570,29 @@ discard block |
||
| 570 | 570 | * |
| 571 | 571 | * @return string L'afficahge HTML des champs |
| 572 | 572 | */ |
| 573 | - function display_account_form_fields( $cid ) { |
|
| 573 | + function display_account_form_fields($cid) { |
|
| 574 | 574 | global $wpdb; |
| 575 | 575 | |
| 576 | - $customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 576 | + $customer_entity_type_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 577 | 577 | $fields_to_output = $signup_form_section = $password_attribute = $signup_form_attributes = array(); |
| 578 | 578 | |
| 579 | - $query = $wpdb->prepare( 'SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $customer_entity_type_id ); |
|
| 580 | - $customer_entity_id = $wpdb->get_var( $query ); |
|
| 581 | - $attributes_set = wpshop_attributes_set::getElement( $customer_entity_id ); |
|
| 582 | - $account_attributes = wpshop_attributes_set::getAttributeSetDetails( ( ! empty( $attributes_set->id ) ) ? $attributes_set->id : '', "'valid'" ); |
|
| 583 | - $query = $wpdb->prepare( 'SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d', $attributes_set->id ); |
|
| 584 | - $customer_attributes_sections = $wpdb->get_results( $query ); |
|
| 585 | - foreach ( $customer_attributes_sections as $k => $customer_attributes_section ) { |
|
| 586 | - $signup_form_section[ $customer_attributes_section->name ] = array(); |
|
| 587 | - if ( ! empty( $account_attributes[ $customer_attributes_section->id ] ) ) { |
|
| 588 | - foreach ( $account_attributes[ $customer_attributes_section->id ]['attribut'] as $attribute ) { |
|
| 589 | - $signup_form_section[ $customer_attributes_section->name ][] = $attribute; |
|
| 579 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $customer_entity_type_id); |
|
| 580 | + $customer_entity_id = $wpdb->get_var($query); |
|
| 581 | + $attributes_set = wpshop_attributes_set::getElement($customer_entity_id); |
|
| 582 | + $account_attributes = wpshop_attributes_set::getAttributeSetDetails((!empty($attributes_set->id)) ? $attributes_set->id : '', "'valid'"); |
|
| 583 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d', $attributes_set->id); |
|
| 584 | + $customer_attributes_sections = $wpdb->get_results($query); |
|
| 585 | + foreach ($customer_attributes_sections as $k => $customer_attributes_section) { |
|
| 586 | + $signup_form_section[$customer_attributes_section->name] = array(); |
|
| 587 | + if (!empty($account_attributes[$customer_attributes_section->id])) { |
|
| 588 | + foreach ($account_attributes[$customer_attributes_section->id]['attribut'] as $attribute) { |
|
| 589 | + $signup_form_section[$customer_attributes_section->name][] = $attribute; |
|
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | ob_start(); |
| 595 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'common/account', 'account', 'form' ) ); |
|
| 595 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'common/account', 'account', 'form')); |
|
| 596 | 596 | $output = ob_get_contents(); |
| 597 | 597 | ob_end_clean(); |
| 598 | 598 | |
@@ -604,61 +604,61 @@ discard block |
||
| 604 | 604 | * |
| 605 | 605 | * @return string |
| 606 | 606 | */ |
| 607 | - function display_account_informations( $customer_id = '', $force_edition_form = false, $customer_link = false ) { |
|
| 607 | + function display_account_informations($customer_id = '', $force_edition_form = false, $customer_link = false) { |
|
| 608 | 608 | global $wpdb; |
| 609 | 609 | $output = $attributes_sections_tpl = $attribute_details = ''; |
| 610 | - $customer_id = ( ! empty( $customer_id ) ) ? $customer_id : get_current_user_id(); |
|
| 611 | - if ( 0 !== $customer_id ) { |
|
| 610 | + $customer_id = (!empty($customer_id)) ? $customer_id : get_current_user_id(); |
|
| 611 | + if (0 !== $customer_id) { |
|
| 612 | 612 | $screen = get_current_screen(); |
| 613 | - $customer_entity_id = wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 613 | + $customer_entity_id = wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 614 | 614 | $cid = $customer_id; |
| 615 | 615 | |
| 616 | - if ( ( is_admin() && isset( $screen ) && is_object( $screen ) && ( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS == $screen->post_type ) ) || $force_edition_form ) { |
|
| 616 | + if ((is_admin() && isset($screen) && is_object($screen) && (WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS == $screen->post_type)) || $force_edition_form) { |
|
| 617 | 617 | ob_start(); |
| 618 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'backend/customer-informations', 'form' ) ); |
|
| 618 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'backend/customer-informations', 'form')); |
|
| 619 | 619 | $output = ob_get_contents(); |
| 620 | 620 | ob_end_clean(); |
| 621 | 621 | } else { |
| 622 | - if ( ! empty( $customer_entity_id ) ) { |
|
| 623 | - $query = $wpdb->prepare( 'SELECT * FROM '.WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d AND status = %s AND default_set = %s', $customer_entity_id, 'valid', 'yes' ); |
|
| 624 | - $attributes_sets = $wpdb->get_results( $query ); |
|
| 625 | - foreach( $attributes_sets as $attributes_set ) { |
|
| 626 | - if( !empty($attributes_set->id) ) { |
|
| 627 | - $query = $wpdb->prepare( 'SELECT * FROM '. WPSHOP_DBT_ATTRIBUTE_GROUP. ' WHERE attribute_set_id = %d AND status = %s', $attributes_set->id, 'valid'); |
|
| 628 | - $attributes_sections = $wpdb->get_results( $query ); |
|
| 629 | - |
|
| 630 | - if( !empty($attributes_sections) ) { |
|
| 631 | - foreach( $attributes_sections as $attributes_section ) { |
|
| 632 | - $query = $wpdb->prepare( 'SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_DETAILS. ' WHERE status = %s AND entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', 'valid', $customer_entity_id, $attributes_set->id, $attributes_section->id); |
|
| 633 | - $attributes_details = $wpdb->get_results( $query ); |
|
| 622 | + if (!empty($customer_entity_id)) { |
|
| 623 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d AND status = %s AND default_set = %s', $customer_entity_id, 'valid', 'yes'); |
|
| 624 | + $attributes_sets = $wpdb->get_results($query); |
|
| 625 | + foreach ($attributes_sets as $attributes_set) { |
|
| 626 | + if (!empty($attributes_set->id)) { |
|
| 627 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_GROUP . ' WHERE attribute_set_id = %d AND status = %s', $attributes_set->id, 'valid'); |
|
| 628 | + $attributes_sections = $wpdb->get_results($query); |
|
| 629 | + |
|
| 630 | + if (!empty($attributes_sections)) { |
|
| 631 | + foreach ($attributes_sections as $attributes_section) { |
|
| 632 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_DETAILS . ' WHERE status = %s AND entity_type_id = %d AND attribute_set_id = %d AND attribute_group_id = %d', 'valid', $customer_entity_id, $attributes_set->id, $attributes_section->id); |
|
| 633 | + $attributes_details = $wpdb->get_results($query); |
|
| 634 | 634 | $attribute_details = ''; |
| 635 | - foreach( $attributes_details as $attributes_detail ) { |
|
| 636 | - $query = $wpdb->prepare( 'SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE. ' WHERE id = %d AND status = %s', $attributes_detail->attribute_id, 'valid' ); |
|
| 637 | - $attribute_def = $wpdb->get_row( $query ); |
|
| 635 | + foreach ($attributes_details as $attributes_detail) { |
|
| 636 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE . ' WHERE id = %d AND status = %s', $attributes_detail->attribute_id, 'valid'); |
|
| 637 | + $attribute_def = $wpdb->get_row($query); |
|
| 638 | 638 | |
| 639 | - $query = $wpdb->prepare( 'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.strtolower($attribute_def->data_type). ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d ', $customer_entity_id, $attribute_def->id, $cid ); |
|
| 640 | - $attribute_value = $wpdb->get_var( $query ); |
|
| 639 | + $query = $wpdb->prepare('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . strtolower($attribute_def->data_type) . ' WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d ', $customer_entity_id, $attribute_def->id, $cid); |
|
| 640 | + $attribute_value = $wpdb->get_var($query); |
|
| 641 | 641 | |
| 642 | 642 | /** Check attribute type for specific type display */ |
| 643 | - if ( "datetime" == $attribute_def->data_type ) { |
|
| 644 | - $attribute_value = mysql2date( get_option( 'date_format' ) . ( ( substr( $attribute_value, -9 ) != ' 00:00:00' ) ? ' ' . get_option( 'time_format' ) : '' ), $attribute_value, true); |
|
| 643 | + if ("datetime" == $attribute_def->data_type) { |
|
| 644 | + $attribute_value = mysql2date(get_option('date_format') . ((substr($attribute_value, -9) != ' 00:00:00') ? ' ' . get_option('time_format') : ''), $attribute_value, true); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | /** Check attribute input type in order to get specific value */ |
| 648 | - if ( in_array( $attribute_def->backend_input, array( 'multiple-select', 'select', 'radio', 'checkbox' ) ) ) { |
|
| 649 | - if ( $attribute_def->data_type_to_use == 'custom' ) { |
|
| 650 | - $query = $wpdb->prepare("SELECT label FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' AND id = %d", $attribute_def->id, $attribute_value ); |
|
| 651 | - $attribute_value = $wpdb->get_var( $query ); |
|
| 652 | - } elseif ( $attribute_def->data_type_to_use == 'internal' ) { |
|
| 653 | - $associated_post = get_post( $atribute_value ); |
|
| 648 | + if (in_array($attribute_def->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) { |
|
| 649 | + if ($attribute_def->data_type_to_use == 'custom') { |
|
| 650 | + $query = $wpdb->prepare("SELECT label FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' AND id = %d", $attribute_def->id, $attribute_value); |
|
| 651 | + $attribute_value = $wpdb->get_var($query); |
|
| 652 | + } elseif ($attribute_def->data_type_to_use == 'internal') { |
|
| 653 | + $associated_post = get_post($atribute_value); |
|
| 654 | 654 | $attribute_value = $associated_post->post_title; |
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - if( !empty( $attribute_def ) ) { |
|
| 659 | - if( $attribute_def->frontend_input != 'password' ) { |
|
| 658 | + if (!empty($attribute_def)) { |
|
| 659 | + if ($attribute_def->frontend_input != 'password') { |
|
| 660 | 660 | ob_start(); |
| 661 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "account/account_informations_element") ); |
|
| 661 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "account/account_informations_element")); |
|
| 662 | 662 | $attribute_details .= ob_get_contents(); |
| 663 | 663 | ob_end_clean(); |
| 664 | 664 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | ob_start(); |
| 669 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "account/account_informations_group_element") ); |
|
| 669 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, "frontend", "account/account_informations_group_element")); |
|
| 670 | 670 | $attributes_sections_tpl .= ob_get_contents(); |
| 671 | 671 | ob_end_clean(); |
| 672 | 672 | } |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | ob_start(); |
| 679 | - require_once( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'frontend', 'account/account_informations' ) ); |
|
| 679 | + require_once(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'frontend', 'account/account_informations')); |
|
| 680 | 680 | $output = ob_get_contents(); |
| 681 | 681 | ob_end_clean(); |
| 682 | 682 | } |
@@ -689,15 +689,15 @@ discard block |
||
| 689 | 689 | * ACCOUNT - AJAX - Fill account informations modal |
| 690 | 690 | */ |
| 691 | 691 | function wps_fill_account_informations_modal() { |
| 692 | - check_ajax_referer( 'wps_fill_account_informations_modal' ); |
|
| 692 | + check_ajax_referer('wps_fill_account_informations_modal'); |
|
| 693 | 693 | |
| 694 | - $customer_id_from_cookie = ! empty( $_COOKIE ) && ! empty( $_COOKIE['wps_current_connected_customer'] ) ? (int) $_COOKIE['wps_current_connected_customer'] : wps_customer_ctr::get_customer_id_by_author_id( get_current_user_id() ); |
|
| 695 | - $customer_id = ! empty( $_POST ) && ! empty( $_POST['customer_id'] ) && is_int( (int) $_POST['customer_id'] ) ? (int) $_POST['customer_id'] : $customer_id_from_cookie; |
|
| 694 | + $customer_id_from_cookie = !empty($_COOKIE) && !empty($_COOKIE['wps_current_connected_customer']) ? (int)$_COOKIE['wps_current_connected_customer'] : wps_customer_ctr::get_customer_id_by_author_id(get_current_user_id()); |
|
| 695 | + $customer_id = !empty($_POST) && !empty($_POST['customer_id']) && is_int((int)$_POST['customer_id']) ? (int)$_POST['customer_id'] : $customer_id_from_cookie; |
|
| 696 | 696 | |
| 697 | - $title = __( 'Edit your account informations', 'wpshop' ); |
|
| 698 | - $content = $this->account_informations_form( $customer_id ); |
|
| 697 | + $title = __('Edit your account informations', 'wpshop'); |
|
| 698 | + $content = $this->account_informations_form($customer_id); |
|
| 699 | 699 | |
| 700 | - wp_die( wp_json_encode( array( 'status' => true, 'title' => $title, 'content' => $content ) ) ); |
|
| 700 | + wp_die(wp_json_encode(array('status' => true, 'title' => $title, 'content' => $content))); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
@@ -705,13 +705,13 @@ discard block |
||
| 705 | 705 | * |
| 706 | 706 | * @param integer $cid L'identifiant du client pour lequel on veut modifier les informations. |
| 707 | 707 | */ |
| 708 | - function account_informations_form( $cid = 0 ) { |
|
| 708 | + function account_informations_form($cid = 0) { |
|
| 709 | 709 | global $wpdb; |
| 710 | 710 | $output = ''; |
| 711 | 711 | |
| 712 | - if ( 0 !== $cid ) { |
|
| 712 | + if (0 !== $cid) { |
|
| 713 | 713 | ob_start(); |
| 714 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'frontend', 'account/account_form' ) ); |
|
| 714 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'frontend', 'account/account_form')); |
|
| 715 | 715 | $output = ob_get_contents(); |
| 716 | 716 | ob_end_clean(); |
| 717 | 717 | } |
@@ -719,49 +719,49 @@ discard block |
||
| 719 | 719 | return $output; |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - function save_account_informations( $cid, $args, $admin = true ) { |
|
| 722 | + function save_account_informations($cid, $args, $admin = true) { |
|
| 723 | 723 | global $wpdb, $wpshop; |
| 724 | 724 | |
| 725 | - $exclude_user_meta = array( 'user_email', 'user_pass' ); |
|
| 725 | + $exclude_user_meta = array('user_email', 'user_pass'); |
|
| 726 | 726 | $wps_entities = new wpshop_entities(); |
| 727 | - $element_id = $wps_entities->get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ); |
|
| 727 | + $element_id = $wps_entities->get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS); |
|
| 728 | 728 | |
| 729 | - $user_id = wps_customer_ctr::get_author_id_by_customer_id( $cid ); |
|
| 729 | + $user_id = wps_customer_ctr::get_author_id_by_customer_id($cid); |
|
| 730 | 730 | |
| 731 | - $user_name = ! empty( $args['attribute']['varchar']['user_login'] ) ? $args['attribute']['varchar']['user_login'] : $args['attribute']['varchar']['user_email']; |
|
| 732 | - $user_pass = ! empty( $args['attribute']['varchar']['user_pass'] ) ? $args['attribute']['varchar']['user_pass'] : ''; |
|
| 731 | + $user_name = !empty($args['attribute']['varchar']['user_login']) ? $args['attribute']['varchar']['user_login'] : $args['attribute']['varchar']['user_email']; |
|
| 732 | + $user_pass = !empty($args['attribute']['varchar']['user_pass']) ? $args['attribute']['varchar']['user_pass'] : ''; |
|
| 733 | 733 | |
| 734 | - $query = $wpdb->prepare('SELECT id FROM ' .WPSHOP_DBT_ATTRIBUTE_SET. ' WHERE entity_id = %d', $element_id ); |
|
| 735 | - $attribute_set_id = $wpdb->get_var( $query ); |
|
| 736 | - if ( !empty($attribute_set_id) ) { |
|
| 737 | - $group = wps_address::get_addresss_form_fields_by_type( $attribute_set_id ); |
|
| 734 | + $query = $wpdb->prepare('SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE_SET . ' WHERE entity_id = %d', $element_id); |
|
| 735 | + $attribute_set_id = $wpdb->get_var($query); |
|
| 736 | + if (!empty($attribute_set_id)) { |
|
| 737 | + $group = wps_address::get_addresss_form_fields_by_type($attribute_set_id); |
|
| 738 | 738 | //Save data in attribute tables, ckeck first if exist to know if Insert or Update |
| 739 | - wpshop_attributes::saveAttributeForEntity( $args['attribute'], $element_id, $cid ); |
|
| 740 | - foreach ( $group as $attribute_sets ) { |
|
| 741 | - foreach ( $attribute_sets as $attribute_set_field ) { |
|
| 742 | - if ( $admin ) { |
|
| 743 | - $validate = $wpshop->validateForm( $attribute_set_field['content'], $args['attribute'] ); |
|
| 739 | + wpshop_attributes::saveAttributeForEntity($args['attribute'], $element_id, $cid); |
|
| 740 | + foreach ($group as $attribute_sets) { |
|
| 741 | + foreach ($attribute_sets as $attribute_set_field) { |
|
| 742 | + if ($admin) { |
|
| 743 | + $validate = $wpshop->validateForm($attribute_set_field['content'], $args['attribute']); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - if ( empty($wpshop->errors) || !$admin ) { |
|
| 746 | + if (empty($wpshop->errors) || !$admin) { |
|
| 747 | 747 | $wpshop_attributes = new wpshop_attributes(); |
| 748 | - foreach( $attribute_set_field['content'] as $attribute ) { |
|
| 749 | - $attribute_def = wpshop_attributes::getElement( $attribute['name'], "'valid'", 'code'); |
|
| 750 | - if ( !in_array( $attribute['name'], $exclude_user_meta ) ) { |
|
| 751 | - update_user_meta( $user_id, $attribute['name'], wpshop_tools::varSanitizer( $args['attribute'][$attribute['data_type']][$attribute['name']]) ); |
|
| 748 | + foreach ($attribute_set_field['content'] as $attribute) { |
|
| 749 | + $attribute_def = wpshop_attributes::getElement($attribute['name'], "'valid'", 'code'); |
|
| 750 | + if (!in_array($attribute['name'], $exclude_user_meta)) { |
|
| 751 | + update_user_meta($user_id, $attribute['name'], wpshop_tools::varSanitizer($args['attribute'][$attribute['data_type']][$attribute['name']])); |
|
| 752 | 752 | } else { |
| 753 | - wp_update_user( array( 'ID' => $user_id, $attribute['name'] => wpshop_tools::varSanitizer( $args['attribute'][$attribute['data_type']][$attribute['name']]) ) ); |
|
| 753 | + wp_update_user(array('ID' => $user_id, $attribute['name'] => wpshop_tools::varSanitizer($args['attribute'][$attribute['data_type']][$attribute['name']]))); |
|
| 754 | 754 | } |
| 755 | 755 | } |
| 756 | 756 | /** Update newsletter user preferences **/ |
| 757 | 757 | $newsletter_preferences = array(); |
| 758 | - if( !empty($args['newsletters_site']) ) { |
|
| 758 | + if (!empty($args['newsletters_site'])) { |
|
| 759 | 759 | $newsletter_preferences['newsletters_site'] = 1; |
| 760 | 760 | } |
| 761 | - if( !empty($args['newsletters_site_partners']) ) { |
|
| 761 | + if (!empty($args['newsletters_site_partners'])) { |
|
| 762 | 762 | $newsletter_preferences['newsletters_site_partners'] = 1; |
| 763 | 763 | } |
| 764 | - update_user_meta( $user_id, 'user_preferences', $newsletter_preferences); |
|
| 764 | + update_user_meta($user_id, 'user_preferences', $newsletter_preferences); |
|
| 765 | 765 | } else { |
| 766 | 766 | return $wpshop->errors; |
| 767 | 767 | } |
@@ -774,18 +774,18 @@ discard block |
||
| 774 | 774 | * ACCOUNT - Save account informations |
| 775 | 775 | */ |
| 776 | 776 | function wps_save_account_informations() { |
| 777 | - check_ajax_referer( 'wps_save_account_informations' ); |
|
| 777 | + check_ajax_referer('wps_save_account_informations'); |
|
| 778 | 778 | |
| 779 | 779 | $status = true; |
| 780 | 780 | $response = ''; |
| 781 | 781 | |
| 782 | - $customer_id_from_cookie = ! empty( $_COOKIE ) && ! empty( $_COOKIE['wps_current_connected_customer'] ) ? (int) $_COOKIE['wps_current_connected_customer'] : wps_customer_ctr::get_customer_id_by_author_id( get_current_user_id() ); |
|
| 783 | - $customer_id = ! empty( $_POST ) && ! empty( $_POST['customer_id'] ) && is_int( (int) $_POST['customer_id'] ) ? (int) $_POST['customer_id'] : $customer_id_from_cookie; |
|
| 782 | + $customer_id_from_cookie = !empty($_COOKIE) && !empty($_COOKIE['wps_current_connected_customer']) ? (int)$_COOKIE['wps_current_connected_customer'] : wps_customer_ctr::get_customer_id_by_author_id(get_current_user_id()); |
|
| 783 | + $customer_id = !empty($_POST) && !empty($_POST['customer_id']) && is_int((int)$_POST['customer_id']) ? (int)$_POST['customer_id'] : $customer_id_from_cookie; |
|
| 784 | 784 | |
| 785 | - $errors = $this->save_account_informations( $customer_id, $_POST ); |
|
| 786 | - if ( ! empty( $errors ) ) { |
|
| 787 | - $response = '<div class="wps-alert-error">' . __( 'Some errors have been detected', 'wpshop' ) . ' : <ul>'; |
|
| 788 | - foreach ( $errors as $error ) { |
|
| 785 | + $errors = $this->save_account_informations($customer_id, $_POST); |
|
| 786 | + if (!empty($errors)) { |
|
| 787 | + $response = '<div class="wps-alert-error">' . __('Some errors have been detected', 'wpshop') . ' : <ul>'; |
|
| 788 | + foreach ($errors as $error) { |
|
| 789 | 789 | $response .= '<li>' . $error . '</li>'; |
| 790 | 790 | } |
| 791 | 791 | $response .= '</div>'; |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | $response = $customer_id; |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - wp_die( wp_json_encode( array( 'status' => $status, 'response' => $response ) ) ); |
|
| 797 | + wp_die(wp_json_encode(array('status' => $status, 'response' => $response))); |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | /** |
@@ -803,16 +803,16 @@ discard block |
||
| 803 | 803 | function wps_account_reload_informations() { |
| 804 | 804 | // check_ajax_referer( 'wps_account_reload_informations' ); |
| 805 | 805 | |
| 806 | - $customer_id_from_cookie = ! empty( $_COOKIE ) && ! empty( $_COOKIE['wps_current_connected_customer'] ) ? (int) $_COOKIE['wps_current_connected_customer'] : wps_customer_ctr::get_customer_id_by_author_id( get_current_user_id() ); |
|
| 807 | - $customer_id = ! empty( $_POST ) && ! empty( $_POST['customer_id'] ) && is_int( (int) $_POST['customer_id'] ) ? (int) $_POST['customer_id'] : $customer_id_from_cookie; |
|
| 806 | + $customer_id_from_cookie = !empty($_COOKIE) && !empty($_COOKIE['wps_current_connected_customer']) ? (int)$_COOKIE['wps_current_connected_customer'] : wps_customer_ctr::get_customer_id_by_author_id(get_current_user_id()); |
|
| 807 | + $customer_id = !empty($_POST) && !empty($_POST['customer_id']) && is_int((int)$_POST['customer_id']) ? (int)$_POST['customer_id'] : $customer_id_from_cookie; |
|
| 808 | 808 | |
| 809 | 809 | $status = false; |
| 810 | - $response = $this->display_account_informations( $customer_id ); |
|
| 811 | - if ( ! empty( $response ) ) { |
|
| 810 | + $response = $this->display_account_informations($customer_id); |
|
| 811 | + if (!empty($response)) { |
|
| 812 | 812 | $status = true; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - wp_die( wp_json_encode( array( 'status' => $status, 'response' => $response ) ) ); |
|
| 815 | + wp_die(wp_json_encode(array('status' => $status, 'response' => $response))); |
|
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @subpackage Customer |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -26,20 +26,20 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @since 1.4.4.3 |
| 28 | 28 | */ |
| 29 | - add_filter( 'gettext', array( $this, 'change_admin_cpt_text_filter' ), 20, 3 ); |
|
| 29 | + add_filter('gettext', array($this, 'change_admin_cpt_text_filter'), 20, 3); |
|
| 30 | 30 | |
| 31 | 31 | /** Define templates path */ |
| 32 | 32 | $this->template_dir = WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . '/templates/'; |
| 33 | 33 | |
| 34 | 34 | /** WordPress hooks */ |
| 35 | - add_action( 'admin_enqueue_scripts', array( $this, 'customer_admin_assets' ) ); |
|
| 36 | - add_action( 'save_post', array( $this, 'save_entity_customer' ), 10, 2 ); |
|
| 37 | - add_filter( 'post_updated_messages', array( $this, 'customer_post_messages' ) ); |
|
| 35 | + add_action('admin_enqueue_scripts', array($this, 'customer_admin_assets')); |
|
| 36 | + add_action('save_post', array($this, 'save_entity_customer'), 10, 2); |
|
| 37 | + add_filter('post_updated_messages', array($this, 'customer_post_messages')); |
|
| 38 | 38 | |
| 39 | 39 | /** Ajax Listener */ |
| 40 | - add_action( 'wp_ajax_wps_order_refresh_customer_informations', array( $this, 'wps_order_refresh_customer_informations' ) ); |
|
| 41 | - add_action( 'wp_ajax_wps_load_customer_creation_form_in_admin', array( $this, 'wps_load_customer_creation_form_in_admin' ) ); |
|
| 42 | - add_action( 'wp_ajax_wps_order_refresh_customer_list', array( $this, 'wps_order_refresh_customer_list' ) ); |
|
| 40 | + add_action('wp_ajax_wps_order_refresh_customer_informations', array($this, 'wps_order_refresh_customer_informations')); |
|
| 41 | + add_action('wp_ajax_wps_load_customer_creation_form_in_admin', array($this, 'wps_load_customer_creation_form_in_admin')); |
|
| 42 | + add_action('wp_ajax_wps_order_refresh_customer_list', array($this, 'wps_order_refresh_customer_list')); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,13 +51,13 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return string [description] |
| 53 | 53 | */ |
| 54 | - function change_admin_cpt_text_filter( $translated_text, $untranslated_text, $domain ) { |
|
| 54 | + function change_admin_cpt_text_filter($translated_text, $untranslated_text, $domain) { |
|
| 55 | 55 | global $typenow; |
| 56 | 56 | |
| 57 | - if ( is_admin() && WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS === $typenow ) { |
|
| 58 | - switch ( $untranslated_text ) { |
|
| 57 | + if (is_admin() && WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS === $typenow) { |
|
| 58 | + switch ($untranslated_text) { |
|
| 59 | 59 | case 'Publish': |
| 60 | - $translated_text = __( 'Save','wpshop' ); |
|
| 60 | + $translated_text = __('Save', 'wpshop'); |
|
| 61 | 61 | break; |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | * @param integer $post_id The current saved post id / L'identifiant post qui vient d'être sauvegardé. |
| 71 | 71 | * @param WP_Post $post THe entire post currently saved / Le post qui vient d'être sauvegardé. |
| 72 | 72 | */ |
| 73 | - public function save_entity_customer( $post_id, $post ) { |
|
| 74 | - if ( ( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS !== $post->post_type ) || ( 'auto-draft' === $post->post_status ) || wp_is_post_revision( $post_id ) ) { |
|
| 73 | + public function save_entity_customer($post_id, $post) { |
|
| 74 | + if ((WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS !== $post->post_type) || ('auto-draft' === $post->post_status) || wp_is_post_revision($post_id)) { |
|
| 75 | 75 | return; |
| 76 | 76 | } |
| 77 | 77 | $custom_args = array(); |
@@ -81,17 +81,17 @@ discard block |
||
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | 83 | /** Récupération des informations envoyées par l'administrateur et ajout de la possibilité d'étendre/modifier les données envoyées avec un filtre */ |
| 84 | - $sended_attributes = ( ! empty( $_POST ) && ! empty( $_POST['attribute'] ) ? (array) $_POST['attribute'] : array() ); // WPCS: CSRF ok. |
|
| 85 | - $data_to_save = apply_filters( 'wps_save_customer_extra_filter', $sended_attributes ); |
|
| 86 | - if ( ! empty( $sended_attributes ) ) { |
|
| 84 | + $sended_attributes = (!empty($_POST) && !empty($_POST['attribute']) ? (array)$_POST['attribute'] : array()); // WPCS: CSRF ok. |
|
| 85 | + $data_to_save = apply_filters('wps_save_customer_extra_filter', $sended_attributes); |
|
| 86 | + if (!empty($sended_attributes)) { |
|
| 87 | 87 | /* Save the attributes values into wpshop eav database */ |
| 88 | 88 | $update_from = ''; |
| 89 | 89 | $lang = WPSHOP_CURRENT_LOCALE; |
| 90 | - if ( ! empty( $data_to_save['icl_post_language'] ) ) { |
|
| 91 | - $query = $wpdb->prepare( "SELECT locale FROM {$wpdb->prefix}icl_locale_map WHERE code = %s", $data_to_save['icl_post_language'] ); |
|
| 92 | - $lang = $wpdb->get_var( $query ); // WPCS: unprepared SQL ok. |
|
| 90 | + if (!empty($data_to_save['icl_post_language'])) { |
|
| 91 | + $query = $wpdb->prepare("SELECT locale FROM {$wpdb->prefix}icl_locale_map WHERE code = %s", $data_to_save['icl_post_language']); |
|
| 92 | + $lang = $wpdb->get_var($query); // WPCS: unprepared SQL ok. |
|
| 93 | 93 | } |
| 94 | - wpshop_attributes::saveAttributeForEntity( $sended_attributes, wpshop_entities::get_entity_identifier_from_code( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ), $post_id, $lang, $update_from ); |
|
| 94 | + wpshop_attributes::saveAttributeForEntity($sended_attributes, wpshop_entities::get_entity_identifier_from_code(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS), $post_id, $lang, $update_from); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @see https://codex.wordpress.org/Function_Reference/wp_update_post |
| 103 | 103 | */ |
| 104 | - remove_action( 'save_post', array( $this, 'save_entity_customer' ) ); |
|
| 105 | - wp_update_post( wp_parse_args( $custom_args, $default_args ) ); |
|
| 106 | - add_action( 'save_post', array( $this, 'save_entity_customer' ) ); |
|
| 104 | + remove_action('save_post', array($this, 'save_entity_customer')); |
|
| 105 | + wp_update_post(wp_parse_args($custom_args, $default_args)); |
|
| 106 | + add_action('save_post', array($this, 'save_entity_customer')); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -114,24 +114,24 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return array New messages list. |
| 116 | 116 | */ |
| 117 | - function customer_post_messages( $messages ) { |
|
| 117 | + function customer_post_messages($messages) { |
|
| 118 | 118 | $customer = get_post(); |
| 119 | 119 | |
| 120 | - $messages[ WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ] = array( |
|
| 120 | + $messages[WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS] = array( |
|
| 121 | 121 | 0 => '', // Unused. Messages start at index 1. |
| 122 | - 1 => __( 'Customer updated.', 'wpshop' ), |
|
| 123 | - 2 => __( 'Custom field updated.', 'wpshop' ), |
|
| 124 | - 3 => __( 'Custom field deleted.', 'wpshop' ), |
|
| 125 | - 4 => __( 'Customer updated.', 'wpshop' ), |
|
| 126 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Customer restored to revision from %s', 'wpshop' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 127 | - 6 => __( 'Customer saved.', 'wpshop' ), |
|
| 128 | - 7 => __( 'Customer saved.', 'wpshop' ), |
|
| 129 | - 8 => __( 'Customer submitted.', 'wpshop' ), |
|
| 122 | + 1 => __('Customer updated.', 'wpshop'), |
|
| 123 | + 2 => __('Custom field updated.', 'wpshop'), |
|
| 124 | + 3 => __('Custom field deleted.', 'wpshop'), |
|
| 125 | + 4 => __('Customer updated.', 'wpshop'), |
|
| 126 | + 5 => isset($_GET['revision']) ? sprintf(__('Customer restored to revision from %s', 'wpshop'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
| 127 | + 6 => __('Customer saved.', 'wpshop'), |
|
| 128 | + 7 => __('Customer saved.', 'wpshop'), |
|
| 129 | + 8 => __('Customer submitted.', 'wpshop'), |
|
| 130 | 130 | 9 => sprintf( |
| 131 | - __( 'Customer scheduled for: <strong>%1$s</strong>.', 'wpshop' ), |
|
| 132 | - date_i18n( __( 'M j, Y @ G:i', 'wpshop' ), strtotime( $customer->post_date ) ) |
|
| 131 | + __('Customer scheduled for: <strong>%1$s</strong>.', 'wpshop'), |
|
| 132 | + date_i18n(__('M j, Y @ G:i', 'wpshop'), strtotime($customer->post_date)) |
|
| 133 | 133 | ), |
| 134 | - 10 => __( 'Customer saved.', 'wpshop' ), |
|
| 134 | + 10 => __('Customer saved.', 'wpshop'), |
|
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | 137 | return $messages; |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | $module_folder = WPS_ACCOUNT_PATH . WPS_ACCOUNT_DIR . '/modules/'; |
| 146 | 146 | |
| 147 | 147 | /** Check if the defined directory exists for reading and including the different modules */ |
| 148 | - if ( is_dir( $module_folder ) ) { |
|
| 149 | - $parent_folder_content = scandir( $module_folder ); |
|
| 150 | - foreach ( $parent_folder_content as $folder ) { |
|
| 151 | - if ( $folder && '.' !== substr( $folder, 0, 1 ) && is_dir( $module_folder . $folder ) ) { |
|
| 152 | - $child_folder_content = scandir( $module_folder . $folder ); |
|
| 153 | - if ( file_exists( $module_folder . $folder . '/' . $folder . '.php' ) ) { |
|
| 148 | + if (is_dir($module_folder)) { |
|
| 149 | + $parent_folder_content = scandir($module_folder); |
|
| 150 | + foreach ($parent_folder_content as $folder) { |
|
| 151 | + if ($folder && '.' !== substr($folder, 0, 1) && is_dir($module_folder . $folder)) { |
|
| 152 | + $child_folder_content = scandir($module_folder . $folder); |
|
| 153 | + if (file_exists($module_folder . $folder . '/' . $folder . '.php')) { |
|
| 154 | 154 | $f = $module_folder . $folder . '/' . $folder . '.php'; |
| 155 | - include( $f ); |
|
| 155 | + include($f); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | function customer_admin_assets() { |
| 166 | 166 | global $current_screen; |
| 167 | - if ( in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ), true ) ) { |
|
| 168 | - wp_enqueue_script( 'wps_customer_admin_js', WPS_ACCOUNT_URL . '/' . WPS_ACCOUNT_DIR . '/assets/backend/js/wps_customer_backend.js', '', WPSHOP_VERSION ); |
|
| 169 | - wp_register_style( 'wpshop-modules-customer-backend-styles', WPS_ACCOUNT_URL . '/' . WPS_ACCOUNT_DIR . '/assets/backend/css/backend.css', '', WPSHOP_VERSION ); |
|
| 170 | - wp_enqueue_style( 'wpshop-modules-customer-backend-styles' ); |
|
| 167 | + if (in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_ORDER, WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS), true)) { |
|
| 168 | + wp_enqueue_script('wps_customer_admin_js', WPS_ACCOUNT_URL . '/' . WPS_ACCOUNT_DIR . '/assets/backend/js/wps_customer_backend.js', '', WPSHOP_VERSION); |
|
| 169 | + wp_register_style('wpshop-modules-customer-backend-styles', WPS_ACCOUNT_URL . '/' . WPS_ACCOUNT_DIR . '/assets/backend/css/backend.css', '', WPSHOP_VERSION); |
|
| 170 | + wp_enqueue_style('wpshop-modules-customer-backend-styles'); |
|
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | * AJAX - Customer creation form |
| 177 | 177 | */ |
| 178 | 178 | function wps_load_customer_creation_form_in_admin() { |
| 179 | - check_ajax_referer( 'wps_load_customer_creation_form_in_admin' ); |
|
| 179 | + check_ajax_referer('wps_load_customer_creation_form_in_admin'); |
|
| 180 | 180 | |
| 181 | - echo do_shortcode( '[wps_signup display="admin"]' ); |
|
| 181 | + echo do_shortcode('[wps_signup display="admin"]'); |
|
| 182 | 182 | wp_die(); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -187,18 +187,18 @@ discard block |
||
| 187 | 187 | * AJAX - Reload Customer list |
| 188 | 188 | */ |
| 189 | 189 | function wps_order_refresh_customer_list() { |
| 190 | - check_ajax_referer( 'wps_order_refresh_customer_list' ); |
|
| 190 | + check_ajax_referer('wps_order_refresh_customer_list'); |
|
| 191 | 191 | |
| 192 | 192 | $status = false; |
| 193 | 193 | $response = ''; |
| 194 | - $customer_id = ( ! empty( $_POST['customer_id'] ) ) ? intval( $_POST['customer_id'] ) : null; |
|
| 195 | - if ( ! empty( $customer_id ) ) { |
|
| 194 | + $customer_id = (!empty($_POST['customer_id'])) ? intval($_POST['customer_id']) : null; |
|
| 195 | + if (!empty($customer_id)) { |
|
| 196 | 196 | $wps_customer = new wps_customer_ctr(); |
| 197 | - $response = $wps_customer->customer_select( $customer_id ); |
|
| 197 | + $response = $wps_customer->customer_select($customer_id); |
|
| 198 | 198 | $status = true; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - wp_die( wp_json_encode( array( 'status' => $status, 'response' => $response ) ) ); |
|
| 201 | + wp_die(wp_json_encode(array('status' => $status, 'response' => $response))); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -207,20 +207,20 @@ discard block |
||
| 207 | 207 | * @version 1.4.4.3 |
| 208 | 208 | */ |
| 209 | 209 | function wps_order_refresh_customer_informations() { |
| 210 | - check_ajax_referer( 'wps_order_refresh_customer_informations' ); |
|
| 210 | + check_ajax_referer('wps_order_refresh_customer_informations'); |
|
| 211 | 211 | |
| 212 | 212 | $status = false; |
| 213 | 213 | $output = ''; |
| 214 | - $customer_id = ( ! empty( $_POST['customer_id'] ) ) ? intval( $_POST['customer_id'] ) : null; |
|
| 215 | - $order_id = ( ! empty( $_POST['order_id'] ) ) ? intval( $_POST['order_id'] ) : null; |
|
| 216 | - if ( ! empty( $order_id ) && ! empty( $customer_id ) ) { |
|
| 214 | + $customer_id = (!empty($_POST['customer_id'])) ? intval($_POST['customer_id']) : null; |
|
| 215 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
| 216 | + if (!empty($order_id) && !empty($customer_id)) { |
|
| 217 | 217 | ob_start(); |
| 218 | - self::display_customer_informations_in_order( $order_id, $customer_id ); |
|
| 218 | + self::display_customer_informations_in_order($order_id, $customer_id); |
|
| 219 | 219 | $output = ob_get_clean(); |
| 220 | 220 | $status = true; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - wp_die( wp_json_encode( array( 'status' => $status, 'output' => $output ) ) ); |
|
| 223 | + wp_die(wp_json_encode(array('status' => $status, 'output' => $output))); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -231,49 +231,49 @@ discard block |
||
| 231 | 231 | * @param integer $order_id L'identifiant de la commande sur laquelle on se trouve / The order identifier we are on. |
| 232 | 232 | * @param integer $customer_id L'identifiant du client pour lequel on veut afficher les informations / The customer identifier we want to display information for. |
| 233 | 233 | */ |
| 234 | - public static function display_customer_informations_in_order( $order_id, $customer_id = 0 ) { |
|
| 234 | + public static function display_customer_informations_in_order($order_id, $customer_id = 0) { |
|
| 235 | 235 | // Récupération des informations de la commande dans la base de données / Retrieve order information from database. |
| 236 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
| 237 | - $order_infos = get_post_meta( $order_id, '_order_info', true ); |
|
| 236 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
| 237 | + $order_infos = get_post_meta($order_id, '_order_info', true); |
|
| 238 | 238 | |
| 239 | 239 | // On vérifie si un client est doit être sélectionné / Check if a customer is already selected. |
| 240 | - $customer_id = ( ! empty( $customer_id ) ? (int) $customer_id : ( ! empty( $order_metadata['customer_id'] ) ? $order_metadata['customer_id'] : '' ) ); |
|
| 240 | + $customer_id = (!empty($customer_id) ? (int)$customer_id : (!empty($order_metadata['customer_id']) ? $order_metadata['customer_id'] : '')); |
|
| 241 | 241 | |
| 242 | 242 | // Récupération des informations d'adresses du client connecté / Retrieve addresses informations for the current customer. |
| 243 | 243 | // Adresse de facturation / Billing address. |
| 244 | - $billing_address_option = get_option( 'wpshop_billing_address' ); |
|
| 245 | - $billing_address_option = ( ! empty( $billing_address_option ) && ! empty( $billing_address_option['choice'] ) ) ? $billing_address_option['choice'] : ''; |
|
| 244 | + $billing_address_option = get_option('wpshop_billing_address'); |
|
| 245 | + $billing_address_option = (!empty($billing_address_option) && !empty($billing_address_option['choice'])) ? $billing_address_option['choice'] : ''; |
|
| 246 | 246 | |
| 247 | 247 | // Adresse de livraison / Shipping address. |
| 248 | 248 | $shipping_address_content = ''; |
| 249 | - $shipping_address_option = get_option( 'wpshop_shipping_address_choice' ); |
|
| 249 | + $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
|
| 250 | 250 | // Vérification de l'activation ou non des livraisons pour l'affichage des adresses correspondantes / Check shipping addresses state in order to display or not addresses. |
| 251 | - $shipping_addresses_activated = ( ! empty( $shipping_address_option ) && ! empty( $shipping_address_option['activate'] ) ) ? true : false; |
|
| 251 | + $shipping_addresses_activated = (!empty($shipping_address_option) && !empty($shipping_address_option['activate'])) ? true : false; |
|
| 252 | 252 | |
| 253 | 253 | // Vérification du statut de la commande pour définir les actions disponibles / Check order status in order to know what action are available. |
| 254 | 254 | $order_update_close = false; |
| 255 | - if ( empty( $order_metadata ) || empty( $order_metadata['customer_id'] ) || ( 'awaiting_payment' === $order_metadata['order_status'] ) ) { |
|
| 255 | + if (empty($order_metadata) || empty($order_metadata['customer_id']) || ('awaiting_payment' === $order_metadata['order_status'])) { |
|
| 256 | 256 | $order_update_close = true; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( ! empty( $customer_id ) ) { |
|
| 259 | + if (!empty($customer_id)) { |
|
| 260 | 260 | // Récupération des informations sur le client / Retrieve customer datas. |
| 261 | 261 | $wps_account = new wps_account_ctr(); |
| 262 | - $customer_datas = $wps_account->display_account_informations( $customer_id, false, true ); |
|
| 262 | + $customer_datas = $wps_account->display_account_informations($customer_id, false, true); |
|
| 263 | 263 | |
| 264 | - if ( true === $order_update_close ) { |
|
| 264 | + if (true === $order_update_close) { |
|
| 265 | 265 | $wps_address = new wps_address(); |
| 266 | - $addresses = $wps_address->display_addresses_interface( $customer_id, true ); |
|
| 266 | + $addresses = $wps_address->display_addresses_interface($customer_id, true); |
|
| 267 | 267 | } else { |
| 268 | 268 | $wps_address_admin = new wps_address_admin(); |
| 269 | - $addresses = $wps_address_admin->display_customer_address_in_order( $order_id, 'billing' ); |
|
| 270 | - if ( true === $shipping_addresses_activated ) { |
|
| 271 | - $addresses .= $wps_address_admin->display_customer_address_in_order( $order_id, 'shipping' ); |
|
| 269 | + $addresses = $wps_address_admin->display_customer_address_in_order($order_id, 'billing'); |
|
| 270 | + if (true === $shipping_addresses_activated) { |
|
| 271 | + $addresses .= $wps_address_admin->display_customer_address_in_order($order_id, 'shipping'); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - require( wpshop_tools::get_template_part( WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'backend/customer-informations', 'wps-order-customer-informations' ) ); |
|
| 276 | + require(wpshop_tools::get_template_part(WPS_ACCOUNT_DIR, WPS_ACCOUNT_TPL, 'backend/customer-informations', 'wps-order-customer-informations')); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | } |