@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Stripe Class. |
@@ -36,18 +36,18 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return array L'ID de la session Stripe. |
38 | 38 | */ |
39 | - public function process_payment( $order ) { |
|
40 | - $stripe_options = Payment::g()->get_payment_option( 'stripe' ); |
|
39 | + public function process_payment($order) { |
|
40 | + $stripe_options = Payment::g()->get_payment_option('stripe'); |
|
41 | 41 | |
42 | - \Stripe\Stripe::setApiKey( $stripe_options['secret_key'] ); |
|
43 | - \Stripe\Stripe::setApiVersion( '2019-03-14; checkout_sessions_beta=v1' ); |
|
42 | + \Stripe\Stripe::setApiKey($stripe_options['secret_key']); |
|
43 | + \Stripe\Stripe::setApiVersion('2019-03-14; checkout_sessions_beta=v1'); |
|
44 | 44 | |
45 | 45 | $lines = array(); |
46 | 46 | |
47 | - if ( ! empty( $order->data['lines'] ) ) { |
|
48 | - foreach ( $order->data['lines'] as $line ) { |
|
47 | + if (!empty($order->data['lines'])) { |
|
48 | + foreach ($order->data['lines'] as $line) { |
|
49 | 49 | $lines[] = array( |
50 | - 'amount' => (int) $line['price_ttc'] * 100, |
|
50 | + 'amount' => (int)$line['price_ttc'] * 100, |
|
51 | 51 | 'quantity' => $line['qty'], |
52 | 52 | 'name' => $line['libelle'], |
53 | 53 | 'currency' => 'eur', |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | - $session = \Stripe\Checkout\Session::create( array( |
|
58 | + $session = \Stripe\Checkout\Session::create(array( |
|
59 | 59 | 'success_url' => Pages::g()->get_valid_checkout_link() . '?order_id=' . $order->data['id'], |
60 | 60 | 'cancel_url' => site_url(), |
61 | - 'payment_method_types' => array( 'card' ), |
|
62 | - 'line_items' => array( $lines ), |
|
63 | - ) ); |
|
61 | + 'payment_method_types' => array('card'), |
|
62 | + 'line_items' => array($lines), |
|
63 | + )); |
|
64 | 64 | |
65 | 65 | $order->data['external_data']['stripe_session_id'] = $session->id; |
66 | 66 | |
67 | - Doli_Order::g()->update( $order->data ); |
|
67 | + Doli_Order::g()->update($order->data); |
|
68 | 68 | |
69 | 69 | return array( |
70 | 70 | 'id' => $session->id, |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Stripe Action Class. |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | * @since 2.0.0 |
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | - add_action( 'wp_enqueue_scripts', array( $this, 'callback_enqueue_scripts' ), 9 ); |
|
29 | + add_action('wp_enqueue_scripts', array($this, 'callback_enqueue_scripts'), 9); |
|
30 | 30 | |
31 | - add_action( 'wps_setting_payment_method_stripe', array( $this, 'callback_setting_payment_method' ), 10, 0 ); |
|
32 | - add_action( 'admin_post_wps_update_method_payment_stripe', array( $this, 'update_method_payment_stripe' ) ); |
|
31 | + add_action('wps_setting_payment_method_stripe', array($this, 'callback_setting_payment_method'), 10, 0); |
|
32 | + add_action('admin_post_wps_update_method_payment_stripe', array($this, 'update_method_payment_stripe')); |
|
33 | 33 | |
34 | - add_action( 'wps_gateway_stripe', array( $this, 'callback_wps_gateway_stripe' ), 10, 1 ); |
|
34 | + add_action('wps_gateway_stripe', array($this, 'callback_wps_gateway_stripe'), 10, 1); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @todo: Inclusions que si on est sur la page de paieemnt. |
43 | 43 | */ |
44 | 44 | public function callback_enqueue_scripts() { |
45 | - wp_enqueue_script( 'wpshop-stripe', 'https://js.stripe.com/v3/', array(), \eoxia\Config_Util::$init['wpshop']->version ); |
|
45 | + wp_enqueue_script('wpshop-stripe', 'https://js.stripe.com/v3/', array(), \eoxia\Config_Util::$init['wpshop']->version); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | * @since 2.0.0 |
52 | 52 | */ |
53 | 53 | public function callback_setting_payment_method() { |
54 | - $stripe_options = Payment::g()->get_payment_option( 'stripe' ); |
|
55 | - \eoxia\View_Util::exec( 'wpshop', 'stripe', 'form-setting', array( |
|
54 | + $stripe_options = Payment::g()->get_payment_option('stripe'); |
|
55 | + \eoxia\View_Util::exec('wpshop', 'stripe', 'form-setting', array( |
|
56 | 56 | 'stripe_options' => $stripe_options, |
57 | - ) ); |
|
57 | + )); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | * @since 2.0.0 |
64 | 64 | */ |
65 | 65 | public function update_method_payment_stripe() { |
66 | - check_admin_referer( 'update_method_payment_stripe' ); |
|
66 | + check_admin_referer('update_method_payment_stripe'); |
|
67 | 67 | |
68 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
68 | + if (!current_user_can('manage_options')) { |
|
69 | 69 | wp_die(); |
70 | 70 | } |
71 | 71 | |
72 | - $title = ! empty( $_POST['title'] ) ? sanitize_text_field( $_POST['title'] ) : ''; |
|
73 | - $description = ! empty( $_POST['description'] ) ? sanitize_text_field( $_POST['description'] ) : ''; |
|
74 | - $publish_key = ! empty( $_POST['publish_key'] ) ? sanitize_text_field( $_POST['publish_key'] ) : ''; |
|
75 | - $secret_key = ! empty( $_POST['secret_key'] ) ? sanitize_text_field( $_POST['secret_key'] ) : ''; |
|
76 | - $use_stripe_sandbox = ( isset( $_POST['use_stripe_sandbox'] ) && 'on' == $_POST['use_stripe_sandbox'] ) ? true : false; |
|
72 | + $title = !empty($_POST['title']) ? sanitize_text_field($_POST['title']) : ''; |
|
73 | + $description = !empty($_POST['description']) ? sanitize_text_field($_POST['description']) : ''; |
|
74 | + $publish_key = !empty($_POST['publish_key']) ? sanitize_text_field($_POST['publish_key']) : ''; |
|
75 | + $secret_key = !empty($_POST['secret_key']) ? sanitize_text_field($_POST['secret_key']) : ''; |
|
76 | + $use_stripe_sandbox = (isset($_POST['use_stripe_sandbox']) && 'on' == $_POST['use_stripe_sandbox']) ? true : false; |
|
77 | 77 | |
78 | - $payment_methods_option = get_option( 'wps_payment_methods', Payment::g()->default_options ); |
|
78 | + $payment_methods_option = get_option('wps_payment_methods', Payment::g()->default_options); |
|
79 | 79 | |
80 | 80 | $payment_methods_option['stripe']['title'] = $title; |
81 | 81 | $payment_methods_option['stripe']['description'] = $description; |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | $payment_methods_option['stripe']['secret_key'] = $secret_key; |
84 | 84 | $payment_methods_option['stripe']['use_stripe_sandbox'] = $use_stripe_sandbox; |
85 | 85 | |
86 | - update_option( 'wps_payment_methods', $payment_methods_option ); |
|
86 | + update_option('wps_payment_methods', $payment_methods_option); |
|
87 | 87 | |
88 | - set_transient( 'updated_wpshop_option_' . get_current_user_id(), __( 'Your settings have been saved.', 'wpshop' ), 30 ); |
|
88 | + set_transient('updated_wpshop_option_' . get_current_user_id(), __('Your settings have been saved.', 'wpshop'), 30); |
|
89 | 89 | |
90 | - wp_redirect( admin_url( 'admin.php?page=wps-settings&tab=payment_method§ion=stripe' ) ); |
|
90 | + wp_redirect(admin_url('admin.php?page=wps-settings&tab=payment_method§ion=stripe')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param array $data Donnée reçu par Stripe. |
99 | 99 | */ |
100 | - public function callback_wps_gateway_stripe( $data ) { |
|
101 | - do_action( 'wps_payment_complete', $data ); |
|
100 | + public function callback_wps_gateway_stripe($data) { |
|
101 | + do_action('wps_payment_complete', $data); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 |
@@ -14,42 +14,42 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | -<form class="wpeo-form" action="<?php echo admin_url( 'admin-post.php' ); ?>" method="POST"> |
|
19 | +<form class="wpeo-form" action="<?php echo admin_url('admin-post.php'); ?>" method="POST"> |
|
20 | 20 | <input type="hidden" name="action" value="wps_update_method_payment_stripe" /> |
21 | - <?php wp_nonce_field( 'update_method_payment_stripe' ); ?> |
|
21 | + <?php wp_nonce_field('update_method_payment_stripe'); ?> |
|
22 | 22 | |
23 | 23 | <div class="form-element"> |
24 | - <span class="form-label"><?php esc_html_e( 'Title', 'wpshop' ); ?></span> |
|
24 | + <span class="form-label"><?php esc_html_e('Title', 'wpshop'); ?></span> |
|
25 | 25 | <label class="form-field-container"> |
26 | - <input type="text" class="form-field" name="title" value="<?php echo esc_attr( $stripe_options['title'] ); ?>" /> |
|
26 | + <input type="text" class="form-field" name="title" value="<?php echo esc_attr($stripe_options['title']); ?>" /> |
|
27 | 27 | </label> |
28 | 28 | </div> |
29 | 29 | |
30 | 30 | <div class="form-element"> |
31 | - <span class="form-label"><?php esc_html_e( 'Publish key', 'wpshop' ); ?></span> |
|
31 | + <span class="form-label"><?php esc_html_e('Publish key', 'wpshop'); ?></span> |
|
32 | 32 | <label class="form-field-container"> |
33 | - <input type="text" class="form-field" name="publish_key" value="<?php echo esc_attr( $stripe_options['publish_key'] ); ?>" /> |
|
33 | + <input type="text" class="form-field" name="publish_key" value="<?php echo esc_attr($stripe_options['publish_key']); ?>" /> |
|
34 | 34 | </label> |
35 | 35 | </div> |
36 | 36 | |
37 | 37 | <div class="form-element"> |
38 | - <span class="form-label"><?php esc_html_e( 'Secret key', 'wpshop' ); ?></span> |
|
38 | + <span class="form-label"><?php esc_html_e('Secret key', 'wpshop'); ?></span> |
|
39 | 39 | <label class="form-field-container"> |
40 | - <input type="text" class="form-field" name="secret_key" value="<?php echo esc_attr( $stripe_options['secret_key'] ); ?>" /> |
|
40 | + <input type="text" class="form-field" name="secret_key" value="<?php echo esc_attr($stripe_options['secret_key']); ?>" /> |
|
41 | 41 | </label> |
42 | 42 | </div> |
43 | 43 | |
44 | 44 | <div class="form-element form-align-horizontal"> |
45 | 45 | <div class="form-field-inline"> |
46 | 46 | <input type="checkbox" id="use-stripe-sandbox" class="form-field" <?php echo $stripe_options['use_stripe_sandbox'] ? 'checked' : ''; ?> name="use_stripe_sandbox" /> |
47 | - <label for="use-stripe-sandbox"><?php esc_html_e( 'Stripe Sandbox', 'wpshop' ); ?></label> |
|
47 | + <label for="use-stripe-sandbox"><?php esc_html_e('Stripe Sandbox', 'wpshop'); ?></label> |
|
48 | 48 | </div> |
49 | 49 | </div> |
50 | 50 | |
51 | 51 | <div class="form-element"> |
52 | - <span class="form-label"><?php esc_html_e( 'Description', 'wpshop' ); ?></span> |
|
52 | + <span class="form-label"><?php esc_html_e('Description', 'wpshop'); ?></span> |
|
53 | 53 | <label class="form-field-container"> |
54 | 54 | <textarea name="description" class="form-field" rows="3" cols="20"><?php echo $stripe_options['description']; ?></textarea> |
55 | 55 | </label> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Doli Product Class. |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * dolibarr. |
38 | 38 | * @param Product_Model $wp_product Les données du produit de WP. |
39 | 39 | */ |
40 | - public function doli_to_wp( $doli_product, $wp_product ) { |
|
41 | - if ( is_object( $wp_product ) ) { |
|
40 | + public function doli_to_wp($doli_product, $wp_product) { |
|
41 | + if (is_object($wp_product)) { |
|
42 | 42 | $wp_product->data['external_id'] = $doli_product->id; |
43 | 43 | $wp_product->data['ref'] = $doli_product->ref; |
44 | 44 | $wp_product->data['title'] = $doli_product->label; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $wp_product->data['weight'] = $doli_product->weight; |
56 | 56 | $wp_product->data['status'] = 'publish'; |
57 | 57 | |
58 | - Product::g()->update( $wp_product->data ); |
|
58 | + Product::g()->update($wp_product->data); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | namespace wpshop; |
18 | 18 | |
19 | -defined( 'ABSPATH' ) || exit; |
|
19 | +defined('ABSPATH') || exit; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Third Party Action Class. |
@@ -38,33 +38,33 @@ discard block |
||
38 | 38 | * @since 2.0.0 |
39 | 39 | */ |
40 | 40 | public function __construct() { |
41 | - add_action( 'admin_menu', array( $this, 'callback_admin_menu' ) ); |
|
41 | + add_action('admin_menu', array($this, 'callback_admin_menu')); |
|
42 | 42 | |
43 | - add_action( 'load-wpshop_page_wps-third-party', array( $this, 'callback_load' ) ); |
|
43 | + add_action('load-wpshop_page_wps-third-party', array($this, 'callback_load')); |
|
44 | 44 | |
45 | - add_action( 'wp_ajax_third_party_load_title_edit', array( $this, 'load_title_edit' ) ); |
|
46 | - add_action( 'admin_post_third_party_save_title', array( $this, 'save_third' ) ); |
|
47 | - add_action( 'wp_ajax_third_party_save_title', array( $this, 'save_third' ) ); |
|
45 | + add_action('wp_ajax_third_party_load_title_edit', array($this, 'load_title_edit')); |
|
46 | + add_action('admin_post_third_party_save_title', array($this, 'save_third')); |
|
47 | + add_action('wp_ajax_third_party_save_title', array($this, 'save_third')); |
|
48 | 48 | |
49 | - add_action( 'wp_ajax_third_party_load_address', array( $this, 'load_billing_address' ) ); |
|
50 | - add_action( 'wp_ajax_third_party_save_address', array( $this, 'save_billing_address' ) ); |
|
49 | + add_action('wp_ajax_third_party_load_address', array($this, 'load_billing_address')); |
|
50 | + add_action('wp_ajax_third_party_save_address', array($this, 'save_billing_address')); |
|
51 | 51 | |
52 | 52 | $this->metaboxes = array( |
53 | 53 | 'wps-third-party-billing' => array( |
54 | - 'title' => __( 'Billing address', 'wpshop' ), |
|
55 | - 'callback' => array( $this, 'metabox_billing_address' ), |
|
54 | + 'title' => __('Billing address', 'wpshop'), |
|
55 | + 'callback' => array($this, 'metabox_billing_address'), |
|
56 | 56 | ), |
57 | 57 | 'wps-third-party-contacts' => array( |
58 | - 'title' => __( 'Contacts', 'wpshop' ), |
|
59 | - 'callback' => array( $this, 'metabox_contacts' ), |
|
58 | + 'title' => __('Contacts', 'wpshop'), |
|
59 | + 'callback' => array($this, 'metabox_contacts'), |
|
60 | 60 | ), |
61 | 61 | 'wps-third-party-orders' => array( |
62 | - 'title' => __( 'Orders', 'wpshop' ), |
|
63 | - 'callback' => array( $this, 'metabox_orders' ), |
|
62 | + 'title' => __('Orders', 'wpshop'), |
|
63 | + 'callback' => array($this, 'metabox_orders'), |
|
64 | 64 | ), |
65 | 65 | 'wps-third-party-invoices' => array( |
66 | - 'title' => __( 'Invoices', 'wpshop' ), |
|
67 | - 'callback' => array( $this, 'metabox_invoices' ), |
|
66 | + 'title' => __('Invoices', 'wpshop'), |
|
67 | + 'callback' => array($this, 'metabox_invoices'), |
|
68 | 68 | ), |
69 | 69 | ); |
70 | 70 | } |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | public function callback_admin_menu() { |
78 | 78 | add_submenu_page( |
79 | 79 | 'wps-order', |
80 | - __( 'Third Parties', 'wpshop' ), |
|
81 | - __( 'Third Parties', 'wpshop' ), |
|
80 | + __('Third Parties', 'wpshop'), |
|
81 | + __('Third Parties', 'wpshop'), |
|
82 | 82 | 'manage_options', |
83 | 83 | 'wps-third-party', |
84 | - array( $this, 'callback_add_menu_page' ) |
|
84 | + array($this, 'callback_add_menu_page') |
|
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @since 2.0.0 |
92 | 92 | */ |
93 | 93 | public function callback_load() { |
94 | - wp_enqueue_script( 'common' ); |
|
95 | - wp_enqueue_script( 'wp-lists' ); |
|
96 | - wp_enqueue_script( 'postbox' ); |
|
94 | + wp_enqueue_script('common'); |
|
95 | + wp_enqueue_script('wp-lists'); |
|
96 | + wp_enqueue_script('postbox'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | * @since 2.0.0 |
103 | 103 | */ |
104 | 104 | public function callback_add_menu_page() { |
105 | - if ( isset( $_GET['id'] ) ) { |
|
106 | - $third_party = Third_Party::g()->get( array( 'id' => $_GET['id'] ), true ); |
|
105 | + if (isset($_GET['id'])) { |
|
106 | + $third_party = Third_Party::g()->get(array('id' => $_GET['id']), true); |
|
107 | 107 | $args_metabox = array( |
108 | 108 | 'third_party' => $third_party, |
109 | 109 | 'id' => $_GET['id'], |
110 | 110 | ); |
111 | 111 | |
112 | - if ( ! empty( $this->metaboxes ) ) { |
|
113 | - foreach ( $this->metaboxes as $key => $metabox ) { |
|
112 | + if (!empty($this->metaboxes)) { |
|
113 | + foreach ($this->metaboxes as $key => $metabox) { |
|
114 | 114 | add_meta_box( |
115 | 115 | $key, |
116 | 116 | $metabox['title'], |
@@ -123,38 +123,38 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'single', array( 'third_party' => $third_party ) ); |
|
126 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'single', array('third_party' => $third_party)); |
|
127 | 127 | } else { |
128 | 128 | $args = array( |
129 | 129 | 'post_type' => 'wps-third-party', |
130 | 130 | 'posts_per_page' => -1, |
131 | 131 | ); |
132 | 132 | |
133 | - if ( ! empty( $_GET['s'] ) ) { |
|
133 | + if (!empty($_GET['s'])) { |
|
134 | 134 | $args['s'] = $_GET['s']; |
135 | 135 | } |
136 | 136 | |
137 | - $count = count( get_posts( $args ) ); |
|
137 | + $count = count(get_posts($args)); |
|
138 | 138 | |
139 | - $number_page = ceil( $count / 25 ); |
|
140 | - $current_page = isset( $_GET['current_page'] ) ? $_GET['current_page'] : 1; |
|
139 | + $number_page = ceil($count / 25); |
|
140 | + $current_page = isset($_GET['current_page']) ? $_GET['current_page'] : 1; |
|
141 | 141 | |
142 | - $base_url = admin_url( 'admin.php?page=wps-third-party' ); |
|
142 | + $base_url = admin_url('admin.php?page=wps-third-party'); |
|
143 | 143 | |
144 | 144 | $begin_url = $base_url . '¤t_page=1'; |
145 | 145 | $end_url = $base_url . '¤t_page=' . $number_page; |
146 | 146 | |
147 | - $prev_url = $base_url . '¤t_page=' . ( $current_page - 1 ); |
|
148 | - $next_url = $base_url . '¤t_page=' . ( $current_page + 1 ); |
|
147 | + $prev_url = $base_url . '¤t_page=' . ($current_page - 1); |
|
148 | + $next_url = $base_url . '¤t_page=' . ($current_page + 1); |
|
149 | 149 | |
150 | - if ( ! empty( $_GET['s'] ) ) { |
|
150 | + if (!empty($_GET['s'])) { |
|
151 | 151 | $begin_url .= '&s=' . $_GET['s']; |
152 | 152 | $end_url .= '&s=' . $_GET['s']; |
153 | 153 | $prev_url .= '&s=' . $_GET['s']; |
154 | 154 | $next_url .= '&s=' . $_GET['s']; |
155 | 155 | } |
156 | 156 | |
157 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'main', array( |
|
157 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'main', array( |
|
158 | 158 | 'number_page' => $number_page, |
159 | 159 | 'current_page' => $current_page, |
160 | 160 | 'count' => $count, |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | 'end_url' => $end_url, |
163 | 163 | 'prev_url' => $prev_url, |
164 | 164 | 'next_url' => $next_url, |
165 | - ) ); |
|
165 | + )); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @since 2.0.0 |
176 | 176 | */ |
177 | - public function metabox_billing_address( $post, $callback_args ) { |
|
178 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'metaboxes/metabox-billing-address', array( |
|
177 | + public function metabox_billing_address($post, $callback_args) { |
|
178 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'metaboxes/metabox-billing-address', array( |
|
179 | 179 | 'third_party' => $callback_args['args']['third_party'], |
180 | - ) ); |
|
180 | + )); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @since 2.0.0 |
190 | 190 | */ |
191 | - public function metabox_contacts( $post, $callback_args ) { |
|
191 | + public function metabox_contacts($post, $callback_args) { |
|
192 | 192 | $contacts = array(); |
193 | 193 | |
194 | - if ( ! empty( $callback_args['args']['third_party']->data['contact_ids'] ) ) { |
|
195 | - $contacts = Contact::g()->get( array( 'include' => $callback_args['args']['third_party']->data['contact_ids'] ) ); |
|
194 | + if (!empty($callback_args['args']['third_party']->data['contact_ids'])) { |
|
195 | + $contacts = Contact::g()->get(array('include' => $callback_args['args']['third_party']->data['contact_ids'])); |
|
196 | 196 | } |
197 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'metaboxes/metabox-contacts', array( |
|
197 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'metaboxes/metabox-contacts', array( |
|
198 | 198 | 'third_party' => $callback_args['args']['third_party'], |
199 | 199 | 'contacts' => $contacts, |
200 | - ) ); |
|
200 | + )); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -208,18 +208,18 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @since 2.0.0 |
210 | 210 | */ |
211 | - public function metabox_orders( $post, $callback_args ) { |
|
212 | - $orders = Doli_Order::g()->get( array( 'post_parent' => $callback_args['args']['id'] ) ); |
|
211 | + public function metabox_orders($post, $callback_args) { |
|
212 | + $orders = Doli_Order::g()->get(array('post_parent' => $callback_args['args']['id'])); |
|
213 | 213 | |
214 | - if ( ! empty( $orders ) ) { |
|
215 | - foreach ( $orders as &$order ) { |
|
216 | - $order->data['invoice'] = Doli_Invoice::g()->get( array( 'post_parent' => $order->data['id'] ), true ); |
|
214 | + if (!empty($orders)) { |
|
215 | + foreach ($orders as &$order) { |
|
216 | + $order->data['invoice'] = Doli_Invoice::g()->get(array('post_parent' => $order->data['id']), true); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'metaboxes/metabox-orders', array( |
|
220 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'metaboxes/metabox-orders', array( |
|
221 | 221 | 'orders' => $orders, |
222 | - ) ); |
|
222 | + )); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -230,19 +230,19 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @since 2.0.0 |
232 | 232 | */ |
233 | - public function metabox_invoices( $post, $callback_args ) { |
|
233 | + public function metabox_invoices($post, $callback_args) { |
|
234 | 234 | |
235 | - $invoices = Doli_Invoice::g()->get( array( 'author__in' => $callback_args['args']['third_party']->data['contact_ids'] ) ); |
|
235 | + $invoices = Doli_Invoice::g()->get(array('author__in' => $callback_args['args']['third_party']->data['contact_ids'])); |
|
236 | 236 | |
237 | - if ( ! empty( $invoices ) ) { |
|
238 | - foreach ( $invoices as &$invoice ) { |
|
239 | - $invoice->data['order'] = Doli_Order::g()->get( array( 'id' => $invoice->data['parent_id'] ), true ); |
|
237 | + if (!empty($invoices)) { |
|
238 | + foreach ($invoices as &$invoice) { |
|
239 | + $invoice->data['order'] = Doli_Order::g()->get(array('id' => $invoice->data['parent_id']), true); |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'metaboxes/metabox-invoices', array( |
|
243 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'metaboxes/metabox-invoices', array( |
|
244 | 244 | 'invoices' => $invoices, |
245 | - ) ); |
|
245 | + )); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -251,26 +251,26 @@ discard block |
||
251 | 251 | * @since 2.0.0 |
252 | 252 | */ |
253 | 253 | public function load_title_edit() { |
254 | - check_ajax_referer( 'load_title_edit' ); |
|
254 | + check_ajax_referer('load_title_edit'); |
|
255 | 255 | |
256 | - $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : -1; |
|
256 | + $post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : -1; |
|
257 | 257 | |
258 | 258 | if ( -1 == $post_id ) { |
259 | 259 | exit; |
260 | 260 | } |
261 | 261 | |
262 | - $third_party = Third_Party::g()->get( array( 'id' => $post_id ), true ); |
|
262 | + $third_party = Third_Party::g()->get(array('id' => $post_id), true); |
|
263 | 263 | |
264 | 264 | ob_start(); |
265 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'single-title-edit', array( |
|
265 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'single-title-edit', array( |
|
266 | 266 | 'third_party' => $third_party, |
267 | - ) ); |
|
268 | - wp_send_json_success( array( |
|
267 | + )); |
|
268 | + wp_send_json_success(array( |
|
269 | 269 | 'namespace' => 'wpshop', |
270 | 270 | 'module' => 'thirdParties', |
271 | 271 | 'callback_success' => 'loaddedTitleEdit', |
272 | 272 | 'view' => ob_get_clean(), |
273 | - ) ); |
|
273 | + )); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -279,44 +279,44 @@ discard block |
||
279 | 279 | * @since 2.0.0 |
280 | 280 | */ |
281 | 281 | public function save_third() { |
282 | - check_ajax_referer( 'save_third' ); |
|
282 | + check_ajax_referer('save_third'); |
|
283 | 283 | |
284 | - $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : -1; |
|
285 | - $title = ! empty( $_POST['title'] ) ? sanitize_text_field( $_POST['title'] ) : ''; |
|
284 | + $post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : -1; |
|
285 | + $title = !empty($_POST['title']) ? sanitize_text_field($_POST['title']) : ''; |
|
286 | 286 | |
287 | 287 | if ( -1 == $post_id ) { |
288 | 288 | exit; |
289 | 289 | } |
290 | 290 | |
291 | - $third_party = Third_Party::g()->get( array( 'id' => $post_id ), true ); |
|
291 | + $third_party = Third_Party::g()->get(array('id' => $post_id), true); |
|
292 | 292 | |
293 | 293 | $third_party->data['id'] = $post_id; |
294 | 294 | |
295 | - if ( empty( $post_id ) ) { |
|
295 | + if (empty($post_id)) { |
|
296 | 296 | $third_party->data['status'] = 'publish'; |
297 | 297 | } |
298 | 298 | $third_party->data['title'] = $title; |
299 | 299 | |
300 | - $third_party = Third_Party::g()->update( $third_party->data ); |
|
300 | + $third_party = Third_Party::g()->update($third_party->data); |
|
301 | 301 | |
302 | - $external_id = do_action( 'wps_saved_third_party', $third_party->data ); |
|
302 | + $external_id = do_action('wps_saved_third_party', $third_party->data); |
|
303 | 303 | |
304 | 304 | $third_party->data['external_id'] = $external_id; |
305 | - $third_party = Third_Party::g()->update( $third_party->data ); |
|
305 | + $third_party = Third_Party::g()->update($third_party->data); |
|
306 | 306 | |
307 | - if ( wp_doing_ajax() ) { |
|
307 | + if (wp_doing_ajax()) { |
|
308 | 308 | ob_start(); |
309 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'single-title', array( |
|
309 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'single-title', array( |
|
310 | 310 | 'third_party' => $third_party, |
311 | - ) ); |
|
312 | - wp_send_json_success( array( |
|
311 | + )); |
|
312 | + wp_send_json_success(array( |
|
313 | 313 | 'namespace' => 'wpshop', |
314 | 314 | 'module' => 'thirdParties', |
315 | 315 | 'callback_success' => 'savedThird', |
316 | 316 | 'view' => ob_get_clean(), |
317 | - ) ); |
|
317 | + )); |
|
318 | 318 | } else { |
319 | - wp_redirect( admin_url( 'admin.php?page=wps-third-party&id=' . $third_party->data['id'] ) ); |
|
319 | + wp_redirect(admin_url('admin.php?page=wps-third-party&id=' . $third_party->data['id'])); |
|
320 | 320 | exit; |
321 | 321 | } |
322 | 322 | } |
@@ -327,26 +327,26 @@ discard block |
||
327 | 327 | * @since 2.0.0 |
328 | 328 | */ |
329 | 329 | public function load_billing_address() { |
330 | - check_ajax_referer( 'load_billing_address' ); |
|
330 | + check_ajax_referer('load_billing_address'); |
|
331 | 331 | |
332 | - $third_party_id = ! empty( $_POST['third_party_id'] ) ? (int) $_POST['third_party_id'] : 0; |
|
332 | + $third_party_id = !empty($_POST['third_party_id']) ? (int)$_POST['third_party_id'] : 0; |
|
333 | 333 | |
334 | - if ( empty( $third_party_id ) ) { |
|
334 | + if (empty($third_party_id)) { |
|
335 | 335 | wp_send_json_error(); |
336 | 336 | } |
337 | 337 | |
338 | - $third_party = Third_Party::g()->get( array( 'id' => $third_party_id ), true ); |
|
338 | + $third_party = Third_Party::g()->get(array('id' => $third_party_id), true); |
|
339 | 339 | |
340 | 340 | ob_start(); |
341 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'metaboxes/metabox-billing-address-edit', array( |
|
341 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'metaboxes/metabox-billing-address-edit', array( |
|
342 | 342 | 'third_party' => $third_party, |
343 | - ) ); |
|
344 | - wp_send_json_success( array( |
|
343 | + )); |
|
344 | + wp_send_json_success(array( |
|
345 | 345 | 'namespace' => 'wpshop', |
346 | 346 | 'module' => 'thirdParties', |
347 | 347 | 'callback_success' => 'loaddedBillingAddressSuccess', |
348 | 348 | 'view' => ob_get_clean(), |
349 | - ) ); |
|
349 | + )); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -356,16 +356,16 @@ discard block |
||
356 | 356 | * @since 2.0.0 |
357 | 357 | */ |
358 | 358 | public function save_billing_address() { |
359 | - check_ajax_referer( 'save_billing_address' ); |
|
359 | + check_ajax_referer('save_billing_address'); |
|
360 | 360 | |
361 | - $third_party_id = ! empty( $_POST['third_party_id'] ) ? (int) $_POST['third_party_id'] : 0; |
|
362 | - $third_party_form = ! empty( $_POST['third_party'] ) ? (array) $_POST['third_party'] : array(); |
|
361 | + $third_party_id = !empty($_POST['third_party_id']) ? (int)$_POST['third_party_id'] : 0; |
|
362 | + $third_party_form = !empty($_POST['third_party']) ? (array)$_POST['third_party'] : array(); |
|
363 | 363 | |
364 | - if ( empty( $third_party_id ) ) { |
|
364 | + if (empty($third_party_id)) { |
|
365 | 365 | wp_send_json_error(); |
366 | 366 | } |
367 | 367 | |
368 | - $third_party = Third_Party::g()->get( array( 'id' => $third_party_id ), true ); |
|
368 | + $third_party = Third_Party::g()->get(array('id' => $third_party_id), true); |
|
369 | 369 | |
370 | 370 | $third_party->data['title'] = $third_party_form['title']; |
371 | 371 | $third_party->data['address'] = $third_party_form['address']; |
@@ -373,20 +373,20 @@ discard block |
||
373 | 373 | $third_party->data['town'] = $third_party_form['town']; |
374 | 374 | $third_party->data['phone'] = $third_party_form['phone']; |
375 | 375 | |
376 | - $third_party = Third_Party::g()->update( $third_party->data ); |
|
376 | + $third_party = Third_Party::g()->update($third_party->data); |
|
377 | 377 | |
378 | - do_action( 'wps_saved_billing_address', $third_party ); |
|
378 | + do_action('wps_saved_billing_address', $third_party); |
|
379 | 379 | |
380 | 380 | ob_start(); |
381 | - \eoxia\View_Util::exec( 'wpshop', 'third-parties', 'metaboxes/metabox-billing-address', array( |
|
381 | + \eoxia\View_Util::exec('wpshop', 'third-parties', 'metaboxes/metabox-billing-address', array( |
|
382 | 382 | 'third_party' => $third_party, |
383 | - ) ); |
|
384 | - wp_send_json_success( array( |
|
383 | + )); |
|
384 | + wp_send_json_success(array( |
|
385 | 385 | 'namespace' => 'wpshop', |
386 | 386 | 'module' => 'thirdParties', |
387 | 387 | 'callback_success' => 'savedBillingAddressSuccess', |
388 | 388 | 'view' => ob_get_clean(), |
389 | - ) ); |
|
389 | + )); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 |
@@ -14,13 +14,13 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | -echo esc_html( $third_party->data['title'] ); |
|
19 | +echo esc_html($third_party->data['title']); |
|
20 | 20 | |
21 | 21 | ?> |
22 | 22 | <div data-action="third_party_load_title_edit" |
23 | - data-nonce="<?php echo esc_attr( wp_create_nonce( 'load_title_edit' ) ); ?>" |
|
24 | - data-post-id="<?php echo esc_attr( $third_party->data['id'] ); ?>" |
|
23 | + data-nonce="<?php echo esc_attr(wp_create_nonce('load_title_edit')); ?>" |
|
24 | + data-post-id="<?php echo esc_attr($third_party->data['id']); ?>" |
|
25 | 25 | class="action-attribute wpeo-button button-square-30"> |
26 | 26 | <i class="button-icon fas fa-pen"></i></div> |
@@ -14,27 +14,27 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | 19 | <tr> |
20 | - <td><?php echo esc_html( $contact->data['id'] ); ?></td> |
|
21 | - <td><?php echo esc_html( $contact->data['lastname'] ); ?></td> |
|
22 | - <td><?php echo esc_html( $contact->data['firstname'] ); ?></td> |
|
23 | - <td><?php echo esc_html( $contact->data['email'] ); ?></td> |
|
24 | - <td><?php echo esc_html( $contact->data['phone'] ); ?></td> |
|
20 | + <td><?php echo esc_html($contact->data['id']); ?></td> |
|
21 | + <td><?php echo esc_html($contact->data['lastname']); ?></td> |
|
22 | + <td><?php echo esc_html($contact->data['firstname']); ?></td> |
|
23 | + <td><?php echo esc_html($contact->data['email']); ?></td> |
|
24 | + <td><?php echo esc_html($contact->data['phone']); ?></td> |
|
25 | 25 | <td> |
26 | 26 | <div data-action="third_party_load_contact" |
27 | - data-nonce="<?php echo esc_attr( wp_create_nonce( 'load_contact' ) ); ?>" |
|
28 | - data-third-party_id="<?php echo esc_attr( $third_party_id ); ?>" |
|
29 | - data-contact-id="<?php echo esc_attr( $contact->data['id'] ); ?>" |
|
27 | + data-nonce="<?php echo esc_attr(wp_create_nonce('load_contact')); ?>" |
|
28 | + data-third-party_id="<?php echo esc_attr($third_party_id); ?>" |
|
29 | + data-contact-id="<?php echo esc_attr($contact->data['id']); ?>" |
|
30 | 30 | class="action-attribute wpeo-button button-square-30"> |
31 | 31 | <i class="button-icon fas fa-pen"></i> |
32 | 32 | </div> |
33 | 33 | |
34 | 34 | <div data-action="third_party_delete_contact" |
35 | - data-nonce="<?php echo esc_attr( wp_create_nonce( 'delete_contact' ) ); ?>" |
|
36 | - data-third-party_id="<?php echo esc_attr( $third_party_id ); ?>" |
|
37 | - data-contact-id="<?php echo esc_attr( $contact->data['id'] ); ?>" |
|
35 | + data-nonce="<?php echo esc_attr(wp_create_nonce('delete_contact')); ?>" |
|
36 | + data-third-party_id="<?php echo esc_attr($third_party_id); ?>" |
|
37 | + data-contact-id="<?php echo esc_attr($contact->data['id']); ?>" |
|
38 | 38 | class="action-attribute wpeo-button button-square-30"> |
39 | 39 | <i class="button-icon fas fa-trash"></i> |
40 | 40 | </div> |
@@ -14,27 +14,27 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | 19 | <div class="wpeo-gridlayout grid-2"> |
20 | 20 | <ul> |
21 | - <li>Nom <input type="text" name="third_party[title]" value="<?php echo esc_attr( $third_party->data['title'] ); ?>" /></li> |
|
22 | - <li>Adresse <input type="text" name="third_party[address]" value="<?php echo esc_attr( $third_party->data['address'] ); ?>" /></li> |
|
23 | - <li>Code postal <input type="text" name="third_party[zip]" value="<?php echo esc_attr( $third_party->data['zip'] ); ?>" /></li> |
|
21 | + <li>Nom <input type="text" name="third_party[title]" value="<?php echo esc_attr($third_party->data['title']); ?>" /></li> |
|
22 | + <li>Adresse <input type="text" name="third_party[address]" value="<?php echo esc_attr($third_party->data['address']); ?>" /></li> |
|
23 | + <li>Code postal <input type="text" name="third_party[zip]" value="<?php echo esc_attr($third_party->data['zip']); ?>" /></li> |
|
24 | 24 | </ul> |
25 | 25 | |
26 | 26 | <ul> |
27 | 27 | <li> </li> |
28 | - <li>Ville <input type="text" name="third_party[town]" value="<?php echo esc_attr( $third_party->data['town'] ); ?>" /></li> |
|
29 | - <li>Téléphone <input type="text" name="third_party[phone]" value="<?php echo esc_attr( $third_party->data['phone'] ); ?>" /></li> |
|
28 | + <li>Ville <input type="text" name="third_party[town]" value="<?php echo esc_attr($third_party->data['town']); ?>" /></li> |
|
29 | + <li>Téléphone <input type="text" name="third_party[phone]" value="<?php echo esc_attr($third_party->data['phone']); ?>" /></li> |
|
30 | 30 | </ul> |
31 | 31 | </div> |
32 | 32 | |
33 | -<?php wp_nonce_field( 'save_billing_address' ); ?> |
|
33 | +<?php wp_nonce_field('save_billing_address'); ?> |
|
34 | 34 | |
35 | 35 | <div data-parent="inside" |
36 | 36 | data-action="third_party_save_address" |
37 | - data-third-party_id="<?php echo esc_attr( $third_party->data['id'] ); ?>" |
|
37 | + data-third-party_id="<?php echo esc_attr($third_party->data['id']); ?>" |
|
38 | 38 | class="action-input wpeo-button button-square-30"> |
39 | 39 | <i class="button-icon fas fa-save"></i> |
40 | 40 | </div> |
@@ -14,11 +14,11 @@ |
||
14 | 14 | |
15 | 15 | namespace wpshop; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; ?> |
|
17 | +defined('ABSPATH') || exit; ?> |
|
18 | 18 | |
19 | 19 | <div data-action="third_party_load_address" |
20 | - data-nonce="<?php echo esc_attr( wp_create_nonce( 'load_billing_address' ) ); ?>" |
|
21 | - data-third-party_id="<?php echo esc_attr( $third_party->data['id'] ); ?>" |
|
20 | + data-nonce="<?php echo esc_attr(wp_create_nonce('load_billing_address')); ?>" |
|
21 | + data-third-party_id="<?php echo esc_attr($third_party->data['id']); ?>" |
|
22 | 22 | class="action-attribute wpeo-button button-square-30" style="float: right;"> |
23 | 23 | <i class="button-icon fas fa-pen"></i> |
24 | 24 | </div> |