@@ -8,19 +8,19 @@ discard block |
||
| 8 | 8 | * @subpackage modules |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if (!defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -if ( ! defined( 'WPSHOP_VERSION' ) ) { |
|
| 16 | - die( __( 'You are not allowed to use this service.', 'wpshop' ) ); |
|
| 15 | +if (!defined('WPSHOP_VERSION')) { |
|
| 16 | + die(__('You are not allowed to use this service.', 'wpshop')); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** Test if userswithcing module is active */ |
| 20 | -if ( class_exists( 'user_switching' ) ) { |
|
| 21 | - add_filter( 'wps_filter_customer_action_metabox', 'wps_display_user_switching_link', 10, 2 ); |
|
| 22 | - add_filter( 'wps_filter_customer_list_actions', 'wps_display_user_switching_link', 10, 2 ); |
|
| 23 | - add_filter( 'wps_filter_customer_in_order', 'wps_display_user_switching_link', 10, 2 ); |
|
| 20 | +if (class_exists('user_switching')) { |
|
| 21 | + add_filter('wps_filter_customer_action_metabox', 'wps_display_user_switching_link', 10, 2); |
|
| 22 | + add_filter('wps_filter_customer_list_actions', 'wps_display_user_switching_link', 10, 2); |
|
| 23 | + add_filter('wps_filter_customer_in_order', 'wps_display_user_switching_link', 10, 2); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Display the link allowing to switch to another user everywhere it is possible |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | * @param integer $customer_id The WPShop customer id (equals to post id). |
| 29 | 29 | * @param integer $wp_user_id Corresponding user id. |
| 30 | 30 | */ |
| 31 | - function wps_display_user_switching_link( $customer_id, $wp_user_id, $need_separator = true ) { |
|
| 32 | - $user = get_user_by( 'id', $wp_user_id ); |
|
| 33 | - $output = '<a href="' . esc_url( user_switching::switch_to_url( $user ) ) . '" >' . esc_html( 'Switch to user', 'wpshop' ) . '</a>'; |
|
| 31 | + function wps_display_user_switching_link($customer_id, $wp_user_id, $need_separator = true) { |
|
| 32 | + $user = get_user_by('id', $wp_user_id); |
|
| 33 | + $output = '<a href="' . esc_url(user_switching::switch_to_url($user)) . '" >' . esc_html('Switch to user', 'wpshop') . '</a>'; |
|
| 34 | 34 | |
| 35 | 35 | echo $output; |
| 36 | 36 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Fichier du controleur des metaboxes pour l'administration des clients dans wpshop / Controller file for managing metaboxes into customer administration interface |
| 4 | 4 | * |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * Instanciation de la gestion des metaboxes / Insctanciate metaboxes management |
| 19 | 19 | */ |
| 20 | 20 | function __construct() { |
| 21 | - add_action( 'add_meta_boxes_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array( $this, 'add_meta_box' ) ); |
|
| 21 | + add_action('add_meta_boxes_' . WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, array($this, 'add_meta_box')); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param WP_Post $customer Le client actuel / The current customer |
| 29 | 29 | */ |
| 30 | - function add_meta_box( $customer ) { |
|
| 31 | - remove_meta_box( 'submitdiv', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal' ); |
|
| 32 | - add_meta_box( 'submitdiv', __( 'Save' ), array( $this, 'wps_customer_informations_save' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'high' ); |
|
| 33 | - add_meta_box( 'wps_customer_informations', __( 'Customer\'s account informations', 'wpshop' ), array( $this, 'wps_customer_account_informations' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'high' ); |
|
| 34 | - if ( 'auto-draft' !== $customer->post_status ) { |
|
| 35 | - add_meta_box( 'wps_customer_orders', __( 'Customer\'s orders', 'wpshop' ), array( $this, 'wps_customer_orders_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low' ); |
|
| 36 | - add_meta_box( 'wps_customer_messages_list', __( 'Customer\'s send messages', 'wpshop' ), array( $this, 'wps_customer_messages_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low' ); |
|
| 37 | - add_meta_box( 'wps_customer_coupons_list', __( 'Customer\'s coupons list', 'wpshop' ), array( $this, 'wps_customer_coupons_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low' ); |
|
| 38 | - add_meta_box( 'wps_customer_addresses_list', __( 'Customer\'s addresses', 'wpshop' ), array( $this, 'wps_customer_addresses_list' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low' ); |
|
| 30 | + function add_meta_box($customer) { |
|
| 31 | + remove_meta_box('submitdiv', WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal'); |
|
| 32 | + add_meta_box('submitdiv', __('Save'), array($this, 'wps_customer_informations_save'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'high'); |
|
| 33 | + add_meta_box('wps_customer_informations', __('Customer\'s account informations', 'wpshop'), array($this, 'wps_customer_account_informations'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'high'); |
|
| 34 | + if ('auto-draft' !== $customer->post_status) { |
|
| 35 | + add_meta_box('wps_customer_orders', __('Customer\'s orders', 'wpshop'), array($this, 'wps_customer_orders_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low'); |
|
| 36 | + add_meta_box('wps_customer_messages_list', __('Customer\'s send messages', 'wpshop'), array($this, 'wps_customer_messages_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low'); |
|
| 37 | + add_meta_box('wps_customer_coupons_list', __('Customer\'s coupons list', 'wpshop'), array($this, 'wps_customer_coupons_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low'); |
|
| 38 | + add_meta_box('wps_customer_addresses_list', __('Customer\'s addresses', 'wpshop'), array($this, 'wps_customer_addresses_list'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'normal', 'low'); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
@@ -43,56 +43,56 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * META-BOX CONTENT - Display customer's order list in customer back-office interface |
| 45 | 45 | */ |
| 46 | - function wps_customer_orders_list( $post ) { |
|
| 46 | + function wps_customer_orders_list($post) { |
|
| 47 | 47 | $output = ''; |
| 48 | - $output .= '<p><a class="button" href="' . admin_url( 'post-new.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER ) . '&customer_id=' . $post->post_author . '">' . __('Add quotation', 'wpshop') . '</a></p>'; |
|
| 48 | + $output .= '<p><a class="button" href="' . admin_url('post-new.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER) . '&customer_id=' . $post->post_author . '">' . __('Add quotation', 'wpshop') . '</a></p>'; |
|
| 49 | 49 | $wps_orders = new wps_orders_ctr(); |
| 50 | - $output .= $wps_orders->display_orders_in_account( $post->post_author); |
|
| 50 | + $output .= $wps_orders->display_orders_in_account($post->post_author); |
|
| 51 | 51 | echo $output; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * META-BOX CONTENT - Display Customer's addresses in customer back-office interface |
| 56 | 56 | */ |
| 57 | - function wps_customer_addresses_list( $post ) { |
|
| 57 | + function wps_customer_addresses_list($post) { |
|
| 58 | 58 | global $wpdb; |
| 59 | 59 | |
| 60 | 60 | $wps_addresses = new wps_address(); |
| 61 | - $output = $wps_addresses->display_addresses_interface( $post->post_author, true ); |
|
| 61 | + $output = $wps_addresses->display_addresses_interface($post->post_author, true); |
|
| 62 | 62 | echo '<input type="hidden" name="wps_customer_id" id="wps_orders_selected_customer" value="' . $post->post_author . '">'; |
| 63 | - echo '<div data-nonce="' . wp_create_nonce( 'reload_addresses_for_customer' ) . '" id="wps_customer_addresses" class="wps-gridwrapper2-padded">' . $output . '</div>'; |
|
| 63 | + echo '<div data-nonce="' . wp_create_nonce('reload_addresses_for_customer') . '" id="wps_customer_addresses" class="wps-gridwrapper2-padded">' . $output . '</div>'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * META-BOX CONTENT - Display customer's send messages |
| 68 | 68 | */ |
| 69 | - function wps_customer_messages_list( $post ) { |
|
| 69 | + function wps_customer_messages_list($post) { |
|
| 70 | 70 | $wps_messages = new wps_message_ctr(); |
| 71 | - $output = $wps_messages->display_message_histo_per_customer( array(),$post->post_author); |
|
| 71 | + $output = $wps_messages->display_message_histo_per_customer(array(), $post->post_author); |
|
| 72 | 72 | echo $output; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * META-BOX CONTENT - Display wps_customer's coupons list |
| 77 | 77 | */ |
| 78 | - function wps_customer_coupons_list( $post ) { |
|
| 78 | + function wps_customer_coupons_list($post) { |
|
| 79 | 79 | $wps_customer = new wps_coupon_ctr(); |
| 80 | - $output = $wps_customer->display_coupons( $post->post_author ); |
|
| 80 | + $output = $wps_customer->display_coupons($post->post_author); |
|
| 81 | 81 | echo $output; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * META-BOX CONTENT - Display Customer's account informations in administration panel |
| 86 | 86 | */ |
| 87 | - function wps_customer_account_informations( $post ) { |
|
| 87 | + function wps_customer_account_informations($post) { |
|
| 88 | 88 | $wps_account = new wps_account_ctr(); |
| 89 | - $output = $wps_account->display_account_informations( $post->post_author ); |
|
| 89 | + $output = $wps_account->display_account_informations($post->post_author); |
|
| 90 | 90 | echo $output; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - function wps_customer_informations_save( $post ) { |
|
| 93 | + function wps_customer_informations_save($post) { |
|
| 94 | 94 | echo '<div class="wps-boxed"><button class="wps-bton-first-rounded" id="wps_signup_button">' . __('Save') . '</button></div>'; |
| 95 | - apply_filters( 'wps_filter_customer_action_metabox', $post->ID, wps_customer_ctr::get_author_id_by_customer_id( $post->ID ) ); |
|
| 95 | + apply_filters('wps_filter_customer_action_metabox', $post->ID, wps_customer_ctr::get_author_id_by_customer_id($post->ID)); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | } |
@@ -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( !$is_from_admin ) : ?> |
|
| 6 | - <div><button data-nonce="<?php echo wp_create_nonce( 'wps_fill_account_informations_modal' ); ?>" class="wps-link wps-alignright" id="wps_modal_account_informations_opener"><i class="wps-icon-pencil"></i><?php _e( 'Edit your account informations', 'wpshop')?></button></div> |
|
| 7 | - <?php elseif( $customer_link ) : ?> |
|
| 8 | - <div><a href="<?php echo get_edit_post_link( $cid ); ?>"><?php esc_html_e( 'See customer', 'wpshop' ); ?></a></div> |
|
| 9 | - <?php echo apply_filters( 'wps_filter_customer_in_order', $cid, wps_customer_ctr::get_author_id_by_customer_id( $cid ) ); ?> |
|
| 5 | + <?php if (!$is_from_admin) : ?> |
|
| 6 | + <div><button data-nonce="<?php echo wp_create_nonce('wps_fill_account_informations_modal'); ?>" class="wps-link wps-alignright" id="wps_modal_account_informations_opener"><i class="wps-icon-pencil"></i><?php _e('Edit your account informations', 'wpshop')?></button></div> |
|
| 7 | + <?php elseif ($customer_link) : ?> |
|
| 8 | + <div><a href="<?php echo get_edit_post_link($cid); ?>"><?php esc_html_e('See customer', 'wpshop'); ?></a></div> |
|
| 9 | + <?php echo apply_filters('wps_filter_customer_in_order', $cid, wps_customer_ctr::get_author_id_by_customer_id($cid)); ?> |
|
| 10 | 10 | <?php endif; ?> |
| 11 | 11 | </div> |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit;
|
|
| 2 | 2 | echo $customer_post->post_title; ?> |
| 3 | 3 | |
| 4 | 4 | <div class="wps-customer-name-container" > |
| 5 | 5 | <div class="wps-customer-last_name" > |
| 6 | - <?php if ( !empty( $current_user_datas->last_name ) ) : ?> |
|
| 6 | + <?php if (!empty($current_user_datas->last_name)) : ?> |
|
| 7 | 7 | <?php echo $current_user_datas->last_name; ?> |
| 8 | 8 | <?php else: ?> |
| 9 | 9 | - |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | </div> |
| 12 | 12 | |
| 13 | 13 | <div class="wps-customer-first_name" > |
| 14 | - <?php if ( !empty( $current_user_datas->first_name ) ) : ?> |
|
| 14 | + <?php if (!empty($current_user_datas->first_name)) : ?> |
|
| 15 | 15 | <?php echo $current_user_datas->first_name; ?> |
| 16 | 16 | <?php else: ?> |
| 17 | 17 | - |
@@ -20,11 +20,11 @@ discard block |
||
| 20 | 20 | </div> |
| 21 | 21 | |
| 22 | 22 | <div class="row-actions" > |
| 23 | - <a href="<?php echo admin_url( 'post.php?post=' . $post_id . '&action=edit' ); ?>" ><?php _e( 'View' ); ?></a> | |
|
| 24 | - <?php if ( current_user_can( 'edit_users' ) ) : ?> |
|
| 25 | - <a target="_wps_wpuser_edition_page" href="<?php echo esc_url( admin_url( 'user-edit.php?user_id=' . $current_user_id_in_list ) ); ?>" ><?php printf( __( 'View associated user (id: %d)', 'wpshop' ), $current_user_id_in_list ); ?></a> |
|
| 26 | - <?php apply_filters( 'wps_filter_customer_list_actions', $post_id, $current_user_id_in_list ); ?> |
|
| 23 | + <a href="<?php echo admin_url('post.php?post=' . $post_id . '&action=edit'); ?>" ><?php _e('View'); ?></a> |
|
|
| 24 | + <?php if (current_user_can('edit_users')) : ?>
|
|
| 25 | + <a target="_wps_wpuser_edition_page" href="<?php echo esc_url(admin_url('user-edit.php?user_id=' . $current_user_id_in_list)); ?>" ><?php printf(__('View associated user (id: %d)', 'wpshop'), $current_user_id_in_list); ?></a>
|
|
| 26 | + <?php apply_filters('wps_filter_customer_list_actions', $post_id, $current_user_id_in_list); ?>
|
|
| 27 | 27 | <?php else: ?> |
| 28 | - <?php printf( __( 'WP-User %d', 'wpshop' ), $current_user_id_in_list); ?> |
|
| 28 | + <?php printf(__('WP-User %d', 'wpshop'), $current_user_id_in_list); ?>
|
|
| 29 | 29 | <?php endif; ?> |
| 30 | 30 | </div> |
@@ -1,21 +1,29 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | echo $customer_post->post_title; ?> |
| 3 | 5 | |
| 4 | 6 | <div class="wps-customer-name-container" > |
| 5 | 7 | <div class="wps-customer-last_name" > |
| 6 | 8 | <?php if ( !empty( $current_user_datas->last_name ) ) : ?> |
| 7 | 9 | <?php echo $current_user_datas->last_name; ?> |
| 8 | - <?php else: ?> |
|
| 10 | + <?php else { |
|
| 11 | + : ?> |
|
| 9 | 12 | - |
| 10 | - <?php endif; ?> |
|
| 13 | + <?php endif; |
|
| 14 | +} |
|
| 15 | +?> |
|
| 11 | 16 | </div> |
| 12 | 17 | |
| 13 | 18 | <div class="wps-customer-first_name" > |
| 14 | 19 | <?php if ( !empty( $current_user_datas->first_name ) ) : ?> |
| 15 | 20 | <?php echo $current_user_datas->first_name; ?> |
| 16 | - <?php else: ?> |
|
| 21 | + <?php else { |
|
| 22 | + : ?> |
|
| 17 | 23 | - |
| 18 | - <?php endif; ?> |
|
| 24 | + <?php endif; |
|
| 25 | +} |
|
| 26 | +?> |
|
| 19 | 27 | </div> |
| 20 | 28 | </div> |
| 21 | 29 | |
@@ -24,7 +32,10 @@ discard block |
||
| 24 | 32 | <?php if ( current_user_can( 'edit_users' ) ) : ?> |
| 25 | 33 | <a target="_wps_wpuser_edition_page" href="<?php echo esc_url( admin_url( 'user-edit.php?user_id=' . $current_user_id_in_list ) ); ?>" ><?php printf( __( 'View associated user (id: %d)', 'wpshop' ), $current_user_id_in_list ); ?></a> |
| 26 | 34 | <?php apply_filters( 'wps_filter_customer_list_actions', $post_id, $current_user_id_in_list ); ?> |
| 27 | - <?php else: ?> |
|
| 28 | - <?php printf( __( 'WP-User %d', 'wpshop' ), $current_user_id_in_list); ?> |
|
| 35 | + <?php else { |
|
| 36 | + : ?> |
|
| 37 | + <?php printf( __( 'WP-User %d', 'wpshop' ), $current_user_id_in_list); |
|
| 38 | +} |
|
| 39 | +?> |
|
| 29 | 40 | <?php endif; ?> |
| 30 | 41 | </div> |