@@ -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,13 +276,13 @@ 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 = '' ) { |
|
| 279 | + function display_message_histo_per_customer($args, $customer_id = '') { |
|
| 280 | 280 | |
| 281 | - $customer_id = ( ! empty( $customer_id ) ) ? $customer_id : get_current_user_id(); |
|
| 282 | - $message_id = ( ! empty( $args ) && ! empty( $args['message_id'] ) ) ? $args['message_id'] : ''; |
|
| 281 | + $customer_id = (!empty($customer_id)) ? $customer_id : get_current_user_id(); |
|
| 282 | + $message_id = (!empty($args) && !empty($args['message_id'])) ? $args['message_id'] : ''; |
|
| 283 | 283 | $message_elements = ''; |
| 284 | 284 | $wps_message_mdl = new wps_message_mdl(); |
| 285 | - $messages_data = $wps_message_mdl->get_messages_histo( $message_id, $customer_id ); |
|
| 285 | + $messages_data = $wps_message_mdl->get_messages_histo($message_id, $customer_id); |
|
| 286 | 286 | |
| 287 | 287 | // ob_start(); |
| 288 | 288 | // require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, "frontend", "messages") ); |
@@ -290,22 +290,22 @@ discard block |
||
| 290 | 290 | // ob_end_clean(); |
| 291 | 291 | /** Order emails */ |
| 292 | 292 | $messages_histo = array(); |
| 293 | - foreach ( $messages_data as $meta_id => $messages ) : |
|
| 293 | + foreach ($messages_data as $meta_id => $messages) : |
|
| 294 | 294 | $i = 0; |
| 295 | - foreach ( $messages as $message ) : |
|
| 296 | - $messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['title'] = $message['mess_title']; |
|
| 297 | - $messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['message'] = $message['mess_message']; |
|
| 298 | - $messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['dates'] = $message['mess_dispatch_date']; |
|
| 299 | - if ( ! empty( $message['mess_object_id'] ) ) { |
|
| 300 | - $messages_histo[ $message['mess_dispatch_date'][0] ][ $i ]['object'] = $message['mess_object_id']; |
|
| 295 | + foreach ($messages as $message) : |
|
| 296 | + $messages_histo[$message['mess_dispatch_date'][0]][$i]['title'] = $message['mess_title']; |
|
| 297 | + $messages_histo[$message['mess_dispatch_date'][0]][$i]['message'] = $message['mess_message']; |
|
| 298 | + $messages_histo[$message['mess_dispatch_date'][0]][$i]['dates'] = $message['mess_dispatch_date']; |
|
| 299 | + if (!empty($message['mess_object_id'])) { |
|
| 300 | + $messages_histo[$message['mess_dispatch_date'][0]][$i]['object'] = $message['mess_object_id']; |
|
| 301 | 301 | } |
| 302 | 302 | $i++; |
| 303 | 303 | endforeach; |
| 304 | 304 | endforeach; |
| 305 | - ksort( $messages_histo ); |
|
| 306 | - $messages_histo = array_reverse( $messages_histo ); |
|
| 305 | + ksort($messages_histo); |
|
| 306 | + $messages_histo = array_reverse($messages_histo); |
|
| 307 | 307 | ob_start(); |
| 308 | - require( wpshop_tools::get_template_part( WPS_MESSAGE_DIR, $this->template_dir, 'frontend', 'customer', 'messages' ) ); |
|
| 308 | + require(wpshop_tools::get_template_part(WPS_MESSAGE_DIR, $this->template_dir, 'frontend', 'customer', 'messages')); |
|
| 309 | 309 | $output = ob_get_contents(); |
| 310 | 310 | ob_end_clean(); |
| 311 | 311 | return $output; |
@@ -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,9 +1,9 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) { exit; |
|
| 2 | 2 | } |
| 3 | 3 | |
| 4 | 4 | // End if(). |
| 5 | -if ( ! defined( 'WPSHOP_VERSION' ) ) { |
|
| 6 | - die( __( 'Access is not allowed by this way', 'wpshop' ) ); |
|
| 5 | +if (!defined('WPSHOP_VERSION')) { |
|
| 6 | + die(__('Access is not allowed by this way', 'wpshop')); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -32,23 +32,23 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public static function declare_options() { |
| 34 | 34 | |
| 35 | - add_settings_section( 'wpshop_emails', '<span class="dashicons dashicons-email"></span>' . __( 'Email addresses', 'wpshop' ), array( 'wpshop_email_options', 'plugin_section_text' ), 'wpshop_emails' ); |
|
| 36 | - register_setting( 'wpshop_options', 'wpshop_emails', array( 'wpshop_email_options', 'wpshop_options_validate_emails' ) ); |
|
| 37 | - add_settings_field( 'wpshop_noreply_email', __( 'Mails answers address email', 'wpshop' ), array( 'wpshop_email_options', 'wpshop_noreply_email_field' ), 'wpshop_emails', 'wpshop_emails' ); |
|
| 38 | - add_settings_field( 'wpshop_contact_email', __( 'Contact email', 'wpshop' ), array( 'wpshop_email_options', 'wpshop_contact_email_field' ), 'wpshop_emails', 'wpshop_emails' ); |
|
| 39 | - add_settings_field( 'wpshop_send_confirmation_order_email', '', array( 'wpshop_email_options', 'wpshop_send_confirmation_order_message_field' ), 'wpshop_emails', 'wpshop_emails' ); |
|
| 35 | + add_settings_section('wpshop_emails', '<span class="dashicons dashicons-email"></span>' . __('Email addresses', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_emails'); |
|
| 36 | + register_setting('wpshop_options', 'wpshop_emails', array('wpshop_email_options', 'wpshop_options_validate_emails')); |
|
| 37 | + add_settings_field('wpshop_noreply_email', __('Mails answers address email', 'wpshop'), array('wpshop_email_options', 'wpshop_noreply_email_field'), 'wpshop_emails', 'wpshop_emails'); |
|
| 38 | + add_settings_field('wpshop_contact_email', __('Contact email', 'wpshop'), array('wpshop_email_options', 'wpshop_contact_email_field'), 'wpshop_emails', 'wpshop_emails'); |
|
| 39 | + add_settings_field('wpshop_send_confirmation_order_email', '', array('wpshop_email_options', 'wpshop_send_confirmation_order_message_field'), 'wpshop_emails', 'wpshop_emails'); |
|
| 40 | 40 | /** Define the settings section for message */ |
| 41 | - add_settings_section( 'wpshop_messages', '<span class="dashicons dashicons-email-alt"></span>' . __( 'Messages', 'wpshop' ), array( 'wpshop_email_options', 'plugin_section_text' ), 'wpshop_messages' ); |
|
| 41 | + add_settings_section('wpshop_messages', '<span class="dashicons dashicons-email-alt"></span>' . __('Messages', 'wpshop'), array('wpshop_email_options', 'plugin_section_text'), 'wpshop_messages'); |
|
| 42 | 42 | /** Get default messages defined into xml files */ |
| 43 | - $xml_default_emails = file_get_contents( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml' ); |
|
| 44 | - $default_emails = new SimpleXMLElement( $xml_default_emails ); |
|
| 43 | + $xml_default_emails = file_get_contents(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/assets/datas/default_emails.xml'); |
|
| 44 | + $default_emails = new SimpleXMLElement($xml_default_emails); |
|
| 45 | 45 | /** Read default emails for options creation */ |
| 46 | - foreach ( $default_emails->xpath( '//emails/email' ) as $email ) { |
|
| 47 | - if ( ( WPSHOP_DEFINED_SHOP_TYPE == (string) $email->attributes()->shop_type ) || ( 'sale' == WPSHOP_DEFINED_SHOP_TYPE ) ) { |
|
| 48 | - register_setting( 'wpshop_options', (string) $email->attributes()->code, array( 'wpshop_email_options', 'wps_options_validate_emails' ) ); |
|
| 49 | - add_settings_field( (string) $email->attributes()->code, __( (string) $email->description, 'wpshop' ), array( 'wpshop_email_options', 'wps_options_emails_field' ), 'wpshop_messages', 'wpshop_messages', array( |
|
| 50 | - 'code' => (string) $email->attributes()->code, |
|
| 51 | - ) ); |
|
| 46 | + foreach ($default_emails->xpath('//emails/email') as $email) { |
|
| 47 | + if ((WPSHOP_DEFINED_SHOP_TYPE == (string)$email->attributes()->shop_type) || ('sale' == WPSHOP_DEFINED_SHOP_TYPE)) { |
|
| 48 | + register_setting('wpshop_options', (string)$email->attributes()->code, array('wpshop_email_options', 'wps_options_validate_emails')); |
|
| 49 | + add_settings_field((string)$email->attributes()->code, __((string)$email->description, 'wpshop'), array('wpshop_email_options', 'wps_options_emails_field'), 'wpshop_messages', 'wpshop_messages', array( |
|
| 50 | + 'code' => (string)$email->attributes()->code, |
|
| 51 | + )); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -66,33 +66,33 @@ discard block |
||
| 66 | 66 | /* ------------------------ */ |
| 67 | 67 | public static function wpshop_noreply_email_field() { |
| 68 | 68 | |
| 69 | - $admin_email = get_bloginfo( 'admin_email' ); |
|
| 70 | - $emails = get_option( 'wpshop_emails', null ); |
|
| 71 | - $email = empty( $emails['noreply_email'] ) ? $admin_email : $emails['noreply_email']; |
|
| 69 | + $admin_email = get_bloginfo('admin_email'); |
|
| 70 | + $emails = get_option('wpshop_emails', null); |
|
| 71 | + $email = empty($emails['noreply_email']) ? $admin_email : $emails['noreply_email']; |
|
| 72 | 72 | echo '<input name="wpshop_emails[noreply_email]" type="text" value="' . $email . '" /> |
| 73 | - <a href="#" title="' . __( 'This is the no reply email','wpshop' ) . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 73 | + <a href="#" title="' . __('This is the no reply email', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 74 | 74 | } |
| 75 | 75 | public static function wpshop_contact_email_field() { |
| 76 | 76 | |
| 77 | - $admin_email = get_bloginfo( 'admin_email' ); |
|
| 78 | - $emails = get_option( 'wpshop_emails', null ); |
|
| 79 | - $email = empty( $emails['contact_email'] ) ? $admin_email : $emails['contact_email']; |
|
| 77 | + $admin_email = get_bloginfo('admin_email'); |
|
| 78 | + $emails = get_option('wpshop_emails', null); |
|
| 79 | + $email = empty($emails['contact_email']) ? $admin_email : $emails['contact_email']; |
|
| 80 | 80 | echo '<input name="wpshop_emails[contact_email]" type="text" value="' . $email . '" /> |
| 81 | - <a href="#" title="' . __( 'This is the email on which customers can contact you','wpshop' ) . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 81 | + <a href="#" title="' . __('This is the email on which customers can contact you', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>'; |
|
| 82 | 82 | } |
| 83 | - public static function wpshop_options_validate_emails( $input ) { |
|
| 83 | + public static function wpshop_options_validate_emails($input) { |
|
| 84 | 84 | return $input; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public static function wpshop_send_confirmation_order_message_field() { |
| 88 | 88 | |
| 89 | - $email_option = get_option( 'wpshop_emails' ); |
|
| 90 | - $output = '<input type="checkbox" name="wpshop_emails[send_confirmation_order_message]" id="wpshop_emails_send_confirmation_order_message" ' . ( ( ! empty( $email_option ) && ! empty( $email_option['send_confirmation_order_message'] ) ) ? 'checked="checked"' : '') . '/> '; |
|
| 91 | - $output .= '<label for="wpshop_emails_send_confirmation_order_message">' . __( 'Send confirmation order message when order is totally paid', 'wpshop' ) . '</label>'; |
|
| 89 | + $email_option = get_option('wpshop_emails'); |
|
| 90 | + $output = '<input type="checkbox" name="wpshop_emails[send_confirmation_order_message]" id="wpshop_emails_send_confirmation_order_message" ' . ((!empty($email_option) && !empty($email_option['send_confirmation_order_message'])) ? 'checked="checked"' : '') . '/> '; |
|
| 91 | + $output .= '<label for="wpshop_emails_send_confirmation_order_message">' . __('Send confirmation order message when order is totally paid', 'wpshop') . '</label>'; |
|
| 92 | 92 | echo $output; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - function wpshop_send_confirmation_order_message_validate( $input ) { |
|
| 95 | + function wpshop_send_confirmation_order_message_validate($input) { |
|
| 96 | 96 | |
| 97 | 97 | return $input; |
| 98 | 98 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param unknown_type $input |
| 106 | 106 | * @return unknown |
| 107 | 107 | */ |
| 108 | - public static function wps_options_validate_emails( $input ) { |
|
| 108 | + public static function wps_options_validate_emails($input) { |
|
| 109 | 109 | |
| 110 | 110 | return $input; |
| 111 | 111 | } |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param unknown_type $args |
| 116 | 116 | */ |
| 117 | - public static function wps_options_emails_field( $args ) { |
|
| 117 | + public static function wps_options_emails_field($args) { |
|
| 118 | 118 | |
| 119 | 119 | $content = ''; |
| 120 | - $current_message_id = get_option( $args['code'], '' ); |
|
| 120 | + $current_message_id = get_option($args['code'], ''); |
|
| 121 | 121 | /* |
| 122 | 122 | $wps_message = new wps_message_ctr(); |
| 123 | 123 | $options = $wps_message->getMessageListOption( $current_message_id ); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $content .= '</select> <a id="wps-email-' . $current_message_id . '" title="' . __( 'Edit current selected message', 'wpshop' ) . '" href="' . admin_url( 'post.php?post=' . $current_message_id . '&action=edit' ) . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-email dashicons dashicons-edit"></a>'; |
| 129 | 129 | }*/ |
| 130 | 130 | |
| 131 | - echo $content . '<input type="hidden" name="' . $args['code'] . '" value="' . $current_message_id . '"><a id="wps-email-' . $current_message_id . '" title="' . __( 'Edit current selected message', 'wpshop' ) . '" href="' . admin_url( 'post.php?post=' . $current_message_id . '&action=edit' ) . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-email dashicons dashicons-edit"></a>'; |
|
| 131 | + echo $content . '<input type="hidden" name="' . $args['code'] . '" value="' . $current_message_id . '"><a id="wps-email-' . $current_message_id . '" title="' . __('Edit current selected message', 'wpshop') . '" href="' . admin_url('post.php?post=' . $current_message_id . '&action=edit') . '" target="_wps_content_customisation" class="shop-content-customisation shop-content-customisation-email dashicons dashicons-edit"></a>'; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | } |