@@ -10,58 +10,58 @@ discard block |
||
10 | 10 | * @var WPInv_Subscriptions_Widget $widget |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | -do_action( 'getpaid_single_subscription_before_notices', $subscription ); |
|
15 | +do_action('getpaid_single_subscription_before_notices', $subscription); |
|
16 | 16 | |
17 | 17 | // Display errors and notices. |
18 | 18 | wpinv_print_errors(); |
19 | 19 | |
20 | -$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() ); |
|
21 | -$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
20 | +$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_invoice_id()); |
|
21 | +$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
22 | 22 | |
23 | -do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups ); |
|
23 | +do_action('getpaid_before_single_subscription', $subscription, $subscription_groups); |
|
24 | 24 | |
25 | 25 | ?> |
26 | 26 | |
27 | -<h2 class="mb-1 h4"><?php esc_html_e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
27 | +<h2 class="mb-1 h4"><?php esc_html_e('Subscription Details', 'invoicing'); ?></h2> |
|
28 | 28 | <table class="table table-bordered"> |
29 | 29 | <tbody> |
30 | 30 | |
31 | - <?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?> |
|
31 | + <?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?> |
|
32 | 32 | |
33 | - <tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>"> |
|
33 | + <tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>"> |
|
34 | 34 | |
35 | 35 | <th class="font-weight-bold" style="width: 35%"> |
36 | - <?php echo esc_html( $label ); ?> |
|
36 | + <?php echo esc_html($label); ?> |
|
37 | 37 | </th> |
38 | 38 | |
39 | 39 | <td style="width: 65%"> |
40 | 40 | <?php |
41 | 41 | |
42 | - switch ( $key ) { |
|
42 | + switch ($key) { |
|
43 | 43 | |
44 | 44 | case 'status': |
45 | - echo esc_html( $subscription->get_status_label() ); |
|
45 | + echo esc_html($subscription->get_status_label()); |
|
46 | 46 | break; |
47 | 47 | |
48 | 48 | case 'start_date': |
49 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
49 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
50 | 50 | break; |
51 | 51 | |
52 | 52 | case 'expiry_date': |
53 | - echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
53 | + echo esc_html(getpaid_format_date_value($subscription->get_next_renewal_date())); |
|
54 | 54 | break; |
55 | 55 | |
56 | 56 | case 'initial_amount': |
57 | - echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) ); |
|
57 | + echo wp_kses_post(wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency())); |
|
58 | 58 | |
59 | - if ( $subscription->has_trial_period() ) { |
|
59 | + if ($subscription->has_trial_period()) { |
|
60 | 60 | |
61 | 61 | echo "<small class='text-muted'> "; |
62 | 62 | printf( |
63 | - esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
64 | - esc_html( $subscription->get_trial_period() ) |
|
63 | + esc_html_x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'), |
|
64 | + esc_html($subscription->get_trial_period()) |
|
65 | 65 | ); |
66 | 66 | echo '</small>'; |
67 | 67 | |
@@ -70,29 +70,29 @@ discard block |
||
70 | 70 | break; |
71 | 71 | |
72 | 72 | case 'recurring_amount': |
73 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
74 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
75 | - echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) ); |
|
73 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
74 | + $amount = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
75 | + echo wp_kses_post(strtolower("<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>")); |
|
76 | 76 | break; |
77 | 77 | |
78 | 78 | case 'item': |
79 | - if ( empty( $subscription_group ) ) { |
|
80 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
79 | + if (empty($subscription_group)) { |
|
80 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id())); |
|
81 | 81 | } else { |
82 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
83 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
82 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
83 | + echo wp_kses_post(implode(' | ', $markup)); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | break; |
87 | 87 | |
88 | 88 | case 'payments': |
89 | 89 | $max_activations = (int) $subscription->get_bill_times(); |
90 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '∞' : (int) $max_activations ); |
|
90 | + echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_activations) ? '∞' : (int) $max_activations); |
|
91 | 91 | |
92 | 92 | break; |
93 | 93 | |
94 | 94 | } |
95 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
95 | + do_action("getpaid_render_single_subscription_column_$key", $subscription); |
|
96 | 96 | |
97 | 97 | ?> |
98 | 98 | </td> |
@@ -104,34 +104,34 @@ discard block |
||
104 | 104 | </tbody> |
105 | 105 | </table> |
106 | 106 | |
107 | -<?php if ( ! empty( $subscription_group ) ) : ?> |
|
108 | - <h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Subscription Items', 'invoicing' ); ?></h2> |
|
109 | - <?php getpaid_admin_subscription_item_details_metabox( $subscription ); ?> |
|
107 | +<?php if (!empty($subscription_group)) : ?> |
|
108 | + <h2 class='mt-5 mb-1 h4'><?php esc_html_e('Subscription Items', 'invoicing'); ?></h2> |
|
109 | + <?php getpaid_admin_subscription_item_details_metabox($subscription); ?> |
|
110 | 110 | <?php endif; ?> |
111 | 111 | |
112 | -<h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Related Invoices', 'invoicing' ); ?></h2> |
|
112 | +<h2 class='mt-5 mb-1 h4'><?php esc_html_e('Related Invoices', 'invoicing'); ?></h2> |
|
113 | 113 | |
114 | -<?php ob_start();getpaid_admin_subscription_invoice_details_metabox( $subscription ); $invoice_details = ob_get_clean(); echo wp_kses_post( $invoice_details ); ?> |
|
114 | +<?php ob_start(); getpaid_admin_subscription_invoice_details_metabox($subscription); $invoice_details = ob_get_clean(); echo wp_kses_post($invoice_details); ?> |
|
115 | 115 | |
116 | -<?php if ( 1 < count( $subscription_groups ) ) : ?> |
|
117 | - <h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Related Subscriptions', 'invoicing' ); ?></h2> |
|
118 | - <?php getpaid_admin_subscription_related_subscriptions_metabox( $subscription ); ?> |
|
116 | +<?php if (1 < count($subscription_groups)) : ?> |
|
117 | + <h2 class='mt-5 mb-1 h4'><?php esc_html_e('Related Subscriptions', 'invoicing'); ?></h2> |
|
118 | + <?php getpaid_admin_subscription_related_subscriptions_metabox($subscription); ?> |
|
119 | 119 | <?php endif; ?> |
120 | 120 | |
121 | 121 | <span class="form-text"> |
122 | 122 | |
123 | 123 | <?php |
124 | - if ( $subscription->can_cancel() ) { |
|
124 | + if ($subscription->can_cancel()) { |
|
125 | 125 | printf( |
126 | 126 | '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
127 | - esc_url( $subscription->get_cancel_url() ), |
|
128 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
129 | - esc_html__( 'Cancel Subscription', 'invoicing' ) |
|
127 | + esc_url($subscription->get_cancel_url()), |
|
128 | + esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'), |
|
129 | + esc_html__('Cancel Subscription', 'invoicing') |
|
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
133 | - do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
133 | + do_action('getpaid-single-subscription-page-actions', $subscription); |
|
134 | 134 | ?> |
135 | 135 | |
136 | - <a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php esc_html_e( 'Go Back', 'invoicing' ); ?></a> |
|
136 | + <a href="<?php echo esc_url(getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')))); ?>" class="btn btn-secondary btn-sm"><?php esc_html_e('Go Back', 'invoicing'); ?></a> |
|
137 | 137 | </span> |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | global $wpinv_options; |
42 | 42 | |
43 | 43 | // Try fetching the saved options. |
44 | - if ( empty( $wpinv_options ) ) { |
|
45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
44 | + if (empty($wpinv_options)) { |
|
45 | + $wpinv_options = get_option('wpinv_settings'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
49 | - if ( ! is_array( $wpinv_options ) ) { |
|
49 | + if (!is_array($wpinv_options)) { |
|
50 | 50 | $wpinv_options = array(); |
51 | 51 | } |
52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
63 | +function wpinv_get_option($key = '', $default = false) { |
|
64 | 64 | |
65 | 65 | $options = wpinv_get_options(); |
66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
68 | 68 | |
69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param array $options the new options. |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | -function wpinv_update_options( $options ) { |
|
78 | +function wpinv_update_options($options) { |
|
79 | 79 | global $wpinv_options; |
80 | 80 | |
81 | 81 | // update the option. |
82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
83 | 83 | $wpinv_options = $options; |
84 | 84 | return true; |
85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * @param mixed $value The setting value. |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
97 | +function wpinv_update_option($key = '', $value = false) { |
|
98 | 98 | |
99 | 99 | // If no key, exit. |
100 | - if ( empty( $key ) ) { |
|
100 | + if (empty($key)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Maybe delete the option instead. |
105 | - if ( is_null( $value ) ) { |
|
106 | - return wpinv_delete_option( $key ); |
|
105 | + if (is_null($value)) { |
|
106 | + return wpinv_delete_option($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Prepare the new options. |
110 | 110 | $options = wpinv_get_options(); |
111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
112 | 112 | |
113 | 113 | // Save the new options. |
114 | - return wpinv_update_options( $options ); |
|
114 | + return wpinv_update_options($options); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $key the setting key. |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | -function wpinv_delete_option( $key = '' ) { |
|
124 | +function wpinv_delete_option($key = '') { |
|
125 | 125 | |
126 | 126 | // If no key, exit |
127 | - if ( empty( $key ) ) { |
|
127 | + if (empty($key)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $options = wpinv_get_options(); |
132 | 132 | |
133 | - if ( isset( $options[ $key ] ) ) { |
|
134 | - unset( $options[ $key ] ); |
|
135 | - return wpinv_update_options( $options ); |
|
133 | + if (isset($options[$key])) { |
|
134 | + unset($options[$key]); |
|
135 | + return wpinv_update_options($options); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return true; |
@@ -144,22 +144,22 @@ discard block |
||
144 | 144 | * |
145 | 145 | */ |
146 | 146 | function wpinv_register_settings() { |
147 | - do_action( 'getpaid_before_register_settings' ); |
|
147 | + do_action('getpaid_before_register_settings'); |
|
148 | 148 | |
149 | 149 | // Loop through all tabs. |
150 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
150 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
151 | 151 | |
152 | 152 | // In each tab, loop through sections. |
153 | - foreach ( $sections as $section => $settings ) { |
|
153 | + foreach ($sections as $section => $settings) { |
|
154 | 154 | |
155 | 155 | // Check for backwards compatibility |
156 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
157 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
156 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
157 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
158 | 158 | $section = 'main'; |
159 | 159 | $settings = $sections; |
160 | 160 | } |
161 | 161 | |
162 | - do_action( "getpaid_register_{$tab}_{$section}" ); |
|
162 | + do_action("getpaid_register_{$tab}_{$section}"); |
|
163 | 163 | |
164 | 164 | // Register the setting section. |
165 | 165 | add_settings_section( |
@@ -169,20 +169,20 @@ discard block |
||
169 | 169 | 'wpinv_settings_' . $tab . '_' . $section |
170 | 170 | ); |
171 | 171 | |
172 | - foreach ( $settings as $option ) { |
|
173 | - if ( ! empty( $option['id'] ) ) { |
|
174 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
172 | + foreach ($settings as $option) { |
|
173 | + if (!empty($option['id'])) { |
|
174 | + wpinv_register_settings_option($tab, $section, $option); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | |
183 | - do_action( 'getpaid_after_register_settings' ); |
|
183 | + do_action('getpaid_after_register_settings'); |
|
184 | 184 | } |
185 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
185 | +add_action('admin_init', 'wpinv_register_settings'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Register a single settings option. |
@@ -192,49 +192,49 @@ discard block |
||
192 | 192 | * @param string $option |
193 | 193 | * |
194 | 194 | */ |
195 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
195 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
196 | 196 | |
197 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
197 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
198 | 198 | $cb = "wpinv_{$option['type']}_callback"; |
199 | 199 | $section = "wpinv_settings_{$tab}_$section"; |
200 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
200 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
201 | 201 | |
202 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
203 | - $tip = wpinv_clean( $option['desc'] ); |
|
202 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
203 | + $tip = wpinv_clean($option['desc']); |
|
204 | 204 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
205 | - unset( $option['desc'] ); |
|
205 | + unset($option['desc']); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | // Loop through all tabs. |
209 | 209 | add_settings_field( |
210 | 210 | 'wpinv_settings[' . $option['id'] . ']', |
211 | 211 | $name, |
212 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
212 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
213 | 213 | $section, |
214 | 214 | $section, |
215 | 215 | array( |
216 | 216 | 'section' => $section, |
217 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
218 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
217 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
218 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
219 | 219 | 'name' => $name, |
220 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
221 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
222 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
223 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
224 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
225 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
226 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
227 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
228 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
229 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
230 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
231 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
232 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
233 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
234 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
235 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
236 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
237 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
220 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
221 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
222 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
223 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
224 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
225 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
226 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
227 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
228 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
229 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
230 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
231 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
232 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
233 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
234 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
235 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
236 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
237 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
238 | 238 | ) |
239 | 239 | ); |
240 | 240 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return array |
247 | 247 | */ |
248 | 248 | function wpinv_get_registered_settings() { |
249 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
249 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return array |
256 | 256 | */ |
257 | 257 | function getpaid_get_integration_settings() { |
258 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
258 | + return apply_filters('getpaid_integration_settings', array()); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -263,153 +263,153 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return array |
265 | 265 | */ |
266 | -function wpinv_settings_sanitize( $input = array() ) { |
|
266 | +function wpinv_settings_sanitize($input = array()) { |
|
267 | 267 | |
268 | 268 | $wpinv_options = wpinv_get_options(); |
269 | 269 | $raw_referrer = wp_get_raw_referer(); |
270 | 270 | |
271 | - if ( empty( $raw_referrer ) ) { |
|
272 | - return array_merge( $wpinv_options, $input ); |
|
271 | + if (empty($raw_referrer)) { |
|
272 | + return array_merge($wpinv_options, $input); |
|
273 | 273 | } |
274 | 274 | |
275 | - wp_parse_str( $raw_referrer, $referrer ); |
|
275 | + wp_parse_str($raw_referrer, $referrer); |
|
276 | 276 | |
277 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
278 | - return array_merge( $wpinv_options, $input ); |
|
277 | + if (in_array('gp-setup', $referrer)) { |
|
278 | + return array_merge($wpinv_options, $input); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | $settings = wpinv_get_registered_settings(); |
282 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
283 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
282 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
283 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
284 | 284 | |
285 | 285 | $input = $input ? $input : array(); |
286 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
287 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
286 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
287 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
288 | 288 | |
289 | 289 | // Loop through each setting being saved and pass it through a sanitization filter |
290 | - foreach ( $input as $key => $value ) { |
|
290 | + foreach ($input as $key => $value) { |
|
291 | 291 | |
292 | 292 | // Get the setting type (checkbox, select, etc) |
293 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
293 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
294 | 294 | |
295 | - if ( $type ) { |
|
295 | + if ($type) { |
|
296 | 296 | // Field type specific filter |
297 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
297 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | // General filter |
301 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
301 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
302 | 302 | |
303 | 303 | // Key specific filter. |
304 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
304 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | // Loop through the whitelist and unset any that are empty for the tab being saved |
308 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
309 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
308 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
309 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
310 | 310 | |
311 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
311 | + $found_settings = array_merge($main_settings, $section_settings); |
|
312 | 312 | |
313 | - if ( ! empty( $found_settings ) ) { |
|
314 | - foreach ( $found_settings as $key => $value ) { |
|
313 | + if (!empty($found_settings)) { |
|
314 | + foreach ($found_settings as $key => $value) { |
|
315 | 315 | |
316 | 316 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
317 | - if ( is_numeric( $key ) ) { |
|
317 | + if (is_numeric($key)) { |
|
318 | 318 | $key = $value['id']; |
319 | 319 | } |
320 | 320 | |
321 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
322 | - unset( $wpinv_options[ $key ] ); |
|
321 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
322 | + unset($wpinv_options[$key]); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Merge our new settings with the existing |
328 | - $output = array_merge( $wpinv_options, $input ); |
|
328 | + $output = array_merge($wpinv_options, $input); |
|
329 | 329 | |
330 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
330 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
331 | 331 | |
332 | 332 | return $output; |
333 | 333 | } |
334 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
335 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
334 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
335 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
336 | 336 | |
337 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
338 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
337 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
338 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
339 | 339 | return $input; |
340 | 340 | } |
341 | 341 | |
342 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
342 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
343 | 343 | $tax_rates = array(); |
344 | 344 | |
345 | - foreach ( $new_rates as $rate ) { |
|
345 | + foreach ($new_rates as $rate) { |
|
346 | 346 | |
347 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
348 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
349 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
350 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
351 | - $rate['global'] = empty( $rate['state'] ); |
|
347 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
348 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
349 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
350 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
351 | + $rate['global'] = empty($rate['state']); |
|
352 | 352 | $tax_rates[] = $rate; |
353 | 353 | |
354 | 354 | } |
355 | 355 | |
356 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
356 | + update_option('wpinv_tax_rates', $tax_rates); |
|
357 | 357 | |
358 | 358 | return $input; |
359 | 359 | } |
360 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
360 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
361 | 361 | |
362 | -function wpinv_settings_sanitize_tax_rules( $input ) { |
|
363 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
362 | +function wpinv_settings_sanitize_tax_rules($input) { |
|
363 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
364 | 364 | return $input; |
365 | 365 | } |
366 | 366 | |
367 | - if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) { |
|
367 | + if (empty($_POST['wpinv_tax_rules_nonce']) || !wp_verify_nonce($_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules')) { |
|
368 | 368 | return $input; |
369 | 369 | } |
370 | 370 | |
371 | - $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array(); |
|
371 | + $new_rules = !empty($_POST['tax_rules']) ? wp_kses_post_deep(array_values($_POST['tax_rules'])) : array(); |
|
372 | 372 | $tax_rules = array(); |
373 | 373 | |
374 | - foreach ( $new_rules as $rule ) { |
|
374 | + foreach ($new_rules as $rule) { |
|
375 | 375 | |
376 | - $rule['key'] = sanitize_title_with_dashes( $rule['key'] ); |
|
377 | - $rule['label'] = sanitize_text_field( $rule['label'] ); |
|
378 | - $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] ); |
|
376 | + $rule['key'] = sanitize_title_with_dashes($rule['key']); |
|
377 | + $rule['label'] = sanitize_text_field($rule['label']); |
|
378 | + $rule['tax_base'] = sanitize_text_field($rule['tax_base']); |
|
379 | 379 | $tax_rules[] = $rule; |
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - update_option( 'wpinv_tax_rules', $tax_rules ); |
|
383 | + update_option('wpinv_tax_rules', $tax_rules); |
|
384 | 384 | |
385 | 385 | return $input; |
386 | 386 | } |
387 | -add_filter( 'wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules' ); |
|
387 | +add_filter('wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules'); |
|
388 | 388 | |
389 | 389 | function wpinv_get_settings_tabs() { |
390 | 390 | $tabs = array(); |
391 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
392 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
393 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
394 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
391 | + $tabs['general'] = __('General', 'invoicing'); |
|
392 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
393 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
394 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
395 | 395 | |
396 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
397 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
396 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
397 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
398 | 398 | } |
399 | 399 | |
400 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
401 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
402 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
400 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
401 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
402 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
403 | 403 | |
404 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
404 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
405 | 405 | } |
406 | 406 | |
407 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
407 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
408 | 408 | $tabs = false; |
409 | 409 | $sections = wpinv_get_registered_settings_sections(); |
410 | 410 | |
411 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
412 | - $tabs = $sections[ $tab ]; |
|
411 | + if ($tab && !empty($sections[$tab])) { |
|
412 | + $tabs = $sections[$tab]; |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | return $tabs; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | function wpinv_get_registered_settings_sections() { |
419 | 419 | static $sections = false; |
420 | 420 | |
421 | - if ( false !== $sections ) { |
|
421 | + if (false !== $sections) { |
|
422 | 422 | return $sections; |
423 | 423 | } |
424 | 424 | |
@@ -426,90 +426,90 @@ discard block |
||
426 | 426 | 'general' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_general', |
428 | 428 | array( |
429 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
430 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
431 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
432 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
429 | + 'main' => __('General Settings', 'invoicing'), |
|
430 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
431 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
432 | + 'labels' => __('Label Texts', 'invoicing'), |
|
433 | 433 | ) |
434 | 434 | ), |
435 | 435 | 'gateways' => apply_filters( |
436 | 436 | 'wpinv_settings_sections_gateways', |
437 | 437 | array( |
438 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
438 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | 'taxes' => apply_filters( |
442 | 442 | 'wpinv_settings_sections_taxes', |
443 | 443 | array( |
444 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
445 | - 'rules' => __( 'Tax Rules', 'invoicing' ), |
|
446 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
447 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
444 | + 'main' => __('Tax Settings', 'invoicing'), |
|
445 | + 'rules' => __('Tax Rules', 'invoicing'), |
|
446 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
447 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
448 | 448 | ) |
449 | 449 | ), |
450 | 450 | 'emails' => apply_filters( |
451 | 451 | 'wpinv_settings_sections_emails', |
452 | 452 | array( |
453 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
453 | + 'main' => __('Email Settings', 'invoicing'), |
|
454 | 454 | ) |
455 | 455 | ), |
456 | 456 | |
457 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
457 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
458 | 458 | |
459 | 459 | 'privacy' => apply_filters( |
460 | 460 | 'wpinv_settings_sections_privacy', |
461 | 461 | array( |
462 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
462 | + 'main' => __('Privacy policy', 'invoicing'), |
|
463 | 463 | ) |
464 | 464 | ), |
465 | 465 | 'misc' => apply_filters( |
466 | 466 | 'wpinv_settings_sections_misc', |
467 | 467 | array( |
468 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
469 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
468 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
469 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
470 | 470 | ) |
471 | 471 | ), |
472 | 472 | 'tools' => apply_filters( |
473 | 473 | 'wpinv_settings_sections_tools', |
474 | 474 | array( |
475 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
475 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | ); |
479 | 479 | |
480 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
480 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
481 | 481 | |
482 | 482 | return $sections; |
483 | 483 | } |
484 | 484 | |
485 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
485 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
486 | 486 | global $wpdb, $gp_tmpl_page_options; |
487 | 487 | |
488 | 488 | // Same function, lets not call it twice if we don't need to. |
489 | - if ( function_exists( 'sd_template_page_options' ) ) { |
|
489 | + if (function_exists('sd_template_page_options')) { |
|
490 | 490 | $args = array( |
491 | 491 | 'with_slug' => $with_slug, |
492 | 492 | 'default_label' => $default_label |
493 | 493 | ); |
494 | 494 | |
495 | - return sd_template_page_options( $args ); |
|
495 | + return sd_template_page_options($args); |
|
496 | 496 | } |
497 | 497 | |
498 | - if ( ! empty( $gp_tmpl_page_options ) ) { |
|
498 | + if (!empty($gp_tmpl_page_options)) { |
|
499 | 499 | return $gp_tmpl_page_options; |
500 | 500 | } |
501 | 501 | |
502 | 502 | $exclude_pages = array(); |
503 | - if ( $page_on_front = get_option( 'page_on_front' ) ) { |
|
503 | + if ($page_on_front = get_option('page_on_front')) { |
|
504 | 504 | $exclude_pages[] = $page_on_front; |
505 | 505 | } |
506 | 506 | |
507 | - if ( $page_for_posts = get_option( 'page_for_posts' ) ) { |
|
507 | + if ($page_for_posts = get_option('page_for_posts')) { |
|
508 | 508 | $exclude_pages[] = $page_for_posts; |
509 | 509 | } |
510 | 510 | |
511 | 511 | $exclude_pages_placeholders = ''; |
512 | - if ( ! empty( $exclude_pages ) ) { |
|
512 | + if (!empty($exclude_pages)) { |
|
513 | 513 | // Sanitize the array of excluded pages and implode it for the SQL query |
514 | 514 | $exclude_pages_placeholders = implode(',', array_fill(0, count($exclude_pages), '%d')); |
515 | 515 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | "; |
524 | 524 | |
525 | 525 | // Add the exclusion if there are pages to exclude |
526 | - if ( ! empty( $exclude_pages ) ) { |
|
526 | + if (!empty($exclude_pages)) { |
|
527 | 527 | $sql .= " AND ID NOT IN ($exclude_pages_placeholders)"; |
528 | 528 | } |
529 | 529 | |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | $sql .= " ORDER BY post_title ASC"; |
532 | 532 | |
533 | 533 | // Add a sanity limit |
534 | - $limit = absint( apply_filters('wpinv_get_pages_limit',500) ); |
|
534 | + $limit = absint(apply_filters('wpinv_get_pages_limit', 500)); |
|
535 | 535 | $sql .= " LIMIT " . absint($limit); |
536 | 536 | |
537 | 537 | // Prepare the SQL query to include the excluded pages only if we have placeholders |
538 | - $pages = $exclude_pages_placeholders ? $wpdb->get_results( $wpdb->prepare( $sql, ...$exclude_pages ) ) : $wpdb->get_results( $sql ); |
|
538 | + $pages = $exclude_pages_placeholders ? $wpdb->get_results($wpdb->prepare($sql, ...$exclude_pages)) : $wpdb->get_results($sql); |
|
539 | 539 | |
540 | 540 | $pages_options = array(); |
541 | 541 | |
542 | - if ( $pages ) { |
|
543 | - foreach ( $pages as $page ) { |
|
542 | + if ($pages) { |
|
543 | + foreach ($pages as $page) { |
|
544 | 544 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
545 | - $pages_options[ $page->ID ] = $title; |
|
545 | + $pages_options[$page->ID] = $title; |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
@@ -550,162 +550,162 @@ discard block |
||
550 | 550 | |
551 | 551 | $gp_tmpl_page_options = $pages_options; |
552 | 552 | |
553 | - if ( $default_label !== null && $default_label !== false ) { |
|
554 | - $pages_options = array( '' => $default_label ) + $pages_options; // Blank option |
|
553 | + if ($default_label !== null && $default_label !== false) { |
|
554 | + $pages_options = array('' => $default_label) + $pages_options; // Blank option |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | return $pages_options; |
558 | 558 | } |
559 | 559 | |
560 | -function wpinv_header_callback( $args ) { |
|
561 | - if ( ! empty( $args['desc'] ) ) { |
|
562 | - echo wp_kses_post( $args['desc'] ); |
|
560 | +function wpinv_header_callback($args) { |
|
561 | + if (!empty($args['desc'])) { |
|
562 | + echo wp_kses_post($args['desc']); |
|
563 | 563 | } |
564 | 564 | } |
565 | 565 | |
566 | -function wpinv_hidden_callback( $args ) { |
|
566 | +function wpinv_hidden_callback($args) { |
|
567 | 567 | |
568 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
569 | - $value = wpinv_get_option( $args['id'], $std ); |
|
568 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
569 | + $value = wpinv_get_option($args['id'], $std); |
|
570 | 570 | |
571 | - if ( isset( $args['set_value'] ) ) { |
|
571 | + if (isset($args['set_value'])) { |
|
572 | 572 | $value = $args['set_value']; |
573 | 573 | } |
574 | 574 | |
575 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
575 | + if (isset($args['faux']) && true === $args['faux']) { |
|
576 | 576 | $args['readonly'] = true; |
577 | - $name = ''; |
|
577 | + $name = ''; |
|
578 | 578 | } else { |
579 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
579 | + $name = 'wpinv_settings[' . esc_attr($args['id']) . ']'; |
|
580 | 580 | } |
581 | 581 | |
582 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
582 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
587 | 587 | * Displays a checkbox settings callback. |
588 | 588 | */ |
589 | -function wpinv_checkbox_callback( $args ) { |
|
589 | +function wpinv_checkbox_callback($args) { |
|
590 | 590 | |
591 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
592 | - $std = wpinv_get_option( $args['id'], $std ); |
|
593 | - $id = esc_attr( $args['id'] ); |
|
591 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
592 | + $std = wpinv_get_option($args['id'], $std); |
|
593 | + $id = esc_attr($args['id']); |
|
594 | 594 | |
595 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
595 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
596 | 596 | ?> |
597 | 597 | <label> |
598 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" /> |
|
599 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
598 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox" /> |
|
599 | + <?php echo wp_kses_post($args['desc']); ?> |
|
600 | 600 | </label> |
601 | 601 | <?php |
602 | 602 | } |
603 | 603 | |
604 | -function wpinv_multicheck_callback( $args ) { |
|
604 | +function wpinv_multicheck_callback($args) { |
|
605 | 605 | |
606 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
607 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
606 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
607 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
608 | 608 | |
609 | - if ( ! empty( $args['options'] ) ) { |
|
609 | + if (!empty($args['options'])) { |
|
610 | 610 | |
611 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
612 | - $value = wpinv_get_option( $args['id'], $std ); |
|
611 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
612 | + $value = wpinv_get_option($args['id'], $std); |
|
613 | 613 | |
614 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
615 | - foreach ( $args['options'] as $key => $option ) : |
|
616 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
617 | - if ( in_array( $sanitize_key, $value ) ) { |
|
614 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">'; |
|
615 | + foreach ($args['options'] as $key => $option) : |
|
616 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
617 | + if (in_array($sanitize_key, $value)) { |
|
618 | 618 | $enabled = $sanitize_key; |
619 | 619 | } else { |
620 | 620 | $enabled = null; |
621 | 621 | } |
622 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
623 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
622 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
623 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>'; |
|
624 | 624 | endforeach; |
625 | 625 | echo '</div>'; |
626 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
626 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
630 | -function wpinv_payment_icons_callback( $args ) { |
|
630 | +function wpinv_payment_icons_callback($args) { |
|
631 | 631 | |
632 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
633 | - $value = wpinv_get_option( $args['id'], false ); |
|
632 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
633 | + $value = wpinv_get_option($args['id'], false); |
|
634 | 634 | |
635 | - if ( ! empty( $args['options'] ) ) { |
|
636 | - foreach ( $args['options'] as $key => $option ) { |
|
637 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
635 | + if (!empty($args['options'])) { |
|
636 | + foreach ($args['options'] as $key => $option) { |
|
637 | + $sanitize_key = wpinv_sanitize_key($key); |
|
638 | 638 | |
639 | - if ( empty( $value ) ) { |
|
639 | + if (empty($value)) { |
|
640 | 640 | $enabled = $option; |
641 | 641 | } else { |
642 | 642 | $enabled = null; |
643 | 643 | } |
644 | 644 | |
645 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
645 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
646 | 646 | |
647 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
647 | + echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
648 | 648 | |
649 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
650 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
649 | + if (wpinv_string_is_image_url($key)) { |
|
650 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
651 | 651 | } else { |
652 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
652 | + $card = strtolower(str_replace(' ', '', $option)); |
|
653 | 653 | |
654 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
655 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
654 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
655 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
656 | 656 | } else { |
657 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
657 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
658 | 658 | $content_dir = WP_CONTENT_DIR; |
659 | 659 | |
660 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
660 | + if (function_exists('wp_normalize_path')) { |
|
661 | 661 | // Replaces backslashes with forward slashes for Windows systems |
662 | - $image = wp_normalize_path( $image ); |
|
663 | - $content_dir = wp_normalize_path( $content_dir ); |
|
662 | + $image = wp_normalize_path($image); |
|
663 | + $content_dir = wp_normalize_path($content_dir); |
|
664 | 664 | } |
665 | 665 | |
666 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
666 | + $image = str_replace($content_dir, content_url(), $image); |
|
667 | 667 | } |
668 | 668 | |
669 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
669 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
670 | 670 | } |
671 | - echo wp_kses_post( $option ) . '</label>'; |
|
671 | + echo wp_kses_post($option) . '</label>'; |
|
672 | 672 | } |
673 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
673 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
678 | 678 | * Displays a radio settings field. |
679 | 679 | */ |
680 | -function wpinv_radio_callback( $args ) { |
|
680 | +function wpinv_radio_callback($args) { |
|
681 | 681 | |
682 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
683 | - $std = wpinv_get_option( $args['id'], $std ); |
|
682 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
683 | + $std = wpinv_get_option($args['id'], $std); |
|
684 | 684 | ?> |
685 | 685 | <fieldset> |
686 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
687 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
686 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
687 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
688 | 688 | <li> |
689 | 689 | <label> |
690 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
691 | - <?php echo wp_kses_post( $option ); ?> |
|
690 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
691 | + <?php echo wp_kses_post($option); ?> |
|
692 | 692 | </label> |
693 | 693 | </li> |
694 | 694 | <?php endforeach; ?> |
695 | 695 | </ul> |
696 | 696 | </fieldset> |
697 | 697 | <?php |
698 | - getpaid_settings_description_callback( $args ); |
|
698 | + getpaid_settings_description_callback($args); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
702 | 702 | * Displays a description if available. |
703 | 703 | */ |
704 | -function getpaid_settings_description_callback( $args ) { |
|
704 | +function getpaid_settings_description_callback($args) { |
|
705 | 705 | |
706 | - if ( ! empty( $args['desc'] ) ) { |
|
706 | + if (!empty($args['desc'])) { |
|
707 | 707 | $description = $args['desc']; |
708 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
708 | + echo wp_kses_post("<p class='description'>$description</p>"); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | } |
@@ -720,35 +720,35 @@ discard block |
||
720 | 720 | </tr> |
721 | 721 | <tr class="bsui"> |
722 | 722 | <td colspan="2" class="p-0"> |
723 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
723 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
724 | 724 | |
725 | 725 | <?php |
726 | 726 | } |
727 | 727 | |
728 | -function wpinv_gateway_select_callback( $args ) { |
|
728 | +function wpinv_gateway_select_callback($args) { |
|
729 | 729 | |
730 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
731 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
732 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
733 | - $value = wpinv_get_option( $args['id'], $std ); |
|
730 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
731 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
732 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
733 | + $value = wpinv_get_option($args['id'], $std); |
|
734 | 734 | |
735 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
735 | + echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >'; |
|
736 | 736 | |
737 | - foreach ( $args['options'] as $key => $option ) : |
|
737 | + foreach ($args['options'] as $key => $option) : |
|
738 | 738 | |
739 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
739 | + echo '<option value="' . esc_attr($key) . '" '; |
|
740 | 740 | |
741 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
742 | - selected( $key, $args['selected'] ); |
|
741 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
742 | + selected($key, $args['selected']); |
|
743 | 743 | } else { |
744 | - selected( $key, $value ); |
|
744 | + selected($key, $value); |
|
745 | 745 | } |
746 | 746 | |
747 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
747 | + echo '>' . esc_html($option['admin_label']) . '</option>'; |
|
748 | 748 | endforeach; |
749 | 749 | |
750 | 750 | echo '</select>'; |
751 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
751 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | /** |
@@ -757,16 +757,16 @@ discard block |
||
757 | 757 | * @param array $args |
758 | 758 | * @return string |
759 | 759 | */ |
760 | -function wpinv_settings_attrs_helper( $args ) { |
|
760 | +function wpinv_settings_attrs_helper($args) { |
|
761 | 761 | |
762 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
763 | - $id = esc_attr( $args['id'] ); |
|
764 | - $value = is_scalar( $value ) ? $value : ''; |
|
762 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
763 | + $id = esc_attr($args['id']); |
|
764 | + $value = is_scalar($value) ? $value : ''; |
|
765 | 765 | |
766 | 766 | $attrs = array( |
767 | - 'name' => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]", |
|
768 | - 'readonly' => ! empty( $args['faux'] ), |
|
769 | - 'value' => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ), |
|
767 | + 'name' => !empty($args['faux']) ? false : "wpinv_settings[$id]", |
|
768 | + 'readonly' => !empty($args['faux']), |
|
769 | + 'value' => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value), |
|
770 | 770 | 'id' => 'wpinv-settings-' . $args['id'], |
771 | 771 | 'style' => $args['style'], |
772 | 772 | 'class' => $args['class'], |
@@ -774,20 +774,20 @@ discard block |
||
774 | 774 | 'data-placeholder' => $args['placeholder'], |
775 | 775 | ); |
776 | 776 | |
777 | - if ( ! empty( $args['onchange'] ) ) { |
|
777 | + if (!empty($args['onchange'])) { |
|
778 | 778 | $attrs['onchange'] = $args['onchange']; |
779 | 779 | } |
780 | 780 | |
781 | - foreach ( $attrs as $key => $value ) { |
|
781 | + foreach ($attrs as $key => $value) { |
|
782 | 782 | |
783 | - if ( false === $value ) { |
|
783 | + if (false === $value) { |
|
784 | 784 | continue; |
785 | 785 | } |
786 | 786 | |
787 | - if ( true === $value ) { |
|
788 | - echo ' ' . esc_attr( $key ); |
|
787 | + if (true === $value) { |
|
788 | + echo ' ' . esc_attr($key); |
|
789 | 789 | } else { |
790 | - echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
790 | + echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | } |
@@ -797,12 +797,12 @@ discard block |
||
797 | 797 | /** |
798 | 798 | * Displays a text input settings callback. |
799 | 799 | */ |
800 | -function wpinv_text_callback( $args ) { |
|
800 | +function wpinv_text_callback($args) { |
|
801 | 801 | |
802 | 802 | ?> |
803 | 803 | <label style="width: 100%;"> |
804 | - <input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
805 | - <?php getpaid_settings_description_callback( $args ); ?> |
|
804 | + <input type="text" <?php wpinv_settings_attrs_helper($args); ?>> |
|
805 | + <?php getpaid_settings_description_callback($args); ?> |
|
806 | 806 | </label> |
807 | 807 | <?php |
808 | 808 | |
@@ -811,174 +811,174 @@ discard block |
||
811 | 811 | /** |
812 | 812 | * Displays a number input settings callback. |
813 | 813 | */ |
814 | -function wpinv_number_callback( $args ) { |
|
814 | +function wpinv_number_callback($args) { |
|
815 | 815 | |
816 | 816 | ?> |
817 | 817 | <label style="width: 100%;"> |
818 | - <input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
819 | - <?php getpaid_settings_description_callback( $args ); ?> |
|
818 | + <input type="number" step="<?php echo esc_attr($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>> |
|
819 | + <?php getpaid_settings_description_callback($args); ?> |
|
820 | 820 | </label> |
821 | 821 | <?php |
822 | 822 | |
823 | 823 | } |
824 | 824 | |
825 | -function wpinv_textarea_callback( $args ) { |
|
825 | +function wpinv_textarea_callback($args) { |
|
826 | 826 | |
827 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
828 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
829 | - $value = wpinv_get_option( $args['id'], $std ); |
|
827 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
828 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
829 | + $value = wpinv_get_option($args['id'], $std); |
|
830 | 830 | |
831 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
832 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
831 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
832 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
833 | 833 | |
834 | - echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
835 | - echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
834 | + echo '<textarea class="' . esc_attr($class) . ' txtarea-' . esc_attr($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . esc_attr($args['cols']) . '" rows="' . esc_attr($args['rows']) . '" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
835 | + echo '<br /><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
836 | 836 | |
837 | 837 | } |
838 | 838 | |
839 | -function wpinv_password_callback( $args ) { |
|
839 | +function wpinv_password_callback($args) { |
|
840 | 840 | |
841 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
842 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
843 | - $value = wpinv_get_option( $args['id'], $std ); |
|
841 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
842 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
843 | + $value = wpinv_get_option($args['id'], $std); |
|
844 | 844 | |
845 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
846 | - echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
847 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
845 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
846 | + echo '<input type="password" class="' . esc_attr($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
847 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
848 | 848 | |
849 | 849 | } |
850 | 850 | |
851 | -function wpinv_missing_callback( $args ) { |
|
851 | +function wpinv_missing_callback($args) { |
|
852 | 852 | printf( |
853 | - esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
854 | - '<strong>' . esc_html( $args['id'] ) . '</strong>' |
|
853 | + esc_html__('The callback function used for the %s setting is missing.', 'invoicing'), |
|
854 | + '<strong>' . esc_html($args['id']) . '</strong>' |
|
855 | 855 | ); |
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
859 | 859 | * Displays a number input settings callback. |
860 | 860 | */ |
861 | -function wpinv_select_callback( $args ) { |
|
861 | +function wpinv_select_callback($args) { |
|
862 | 862 | |
863 | - $desc = wp_kses_post( $args['desc'] ); |
|
864 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
865 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
866 | - $value = wpinv_get_option( $args['id'], $value ); |
|
867 | - $rand = uniqid( 'random_id' ); |
|
863 | + $desc = wp_kses_post($args['desc']); |
|
864 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
865 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
866 | + $value = wpinv_get_option($args['id'], $value); |
|
867 | + $rand = uniqid('random_id'); |
|
868 | 868 | |
869 | 869 | ?> |
870 | 870 | <label style="width: 100%;"> |
871 | - <select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true"> |
|
872 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
873 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option> |
|
871 | + <select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true"> |
|
872 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
873 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo esc_html($name); ?></option> |
|
874 | 874 | <?php endforeach; ?> |
875 | 875 | </select> |
876 | 876 | |
877 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
878 | - <a href="<?php echo esc_url( get_edit_post_link( $value ) ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a> |
|
877 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
878 | + <a href="<?php echo esc_url(get_edit_post_link($value)); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a> |
|
879 | 879 | <?php endif; ?> |
880 | 880 | |
881 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
882 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr( $rand ); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a> |
|
883 | - <div id='<?php echo esc_attr( $rand ); ?>' style='display:none;'> |
|
881 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
882 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr($rand); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a> |
|
883 | + <div id='<?php echo esc_attr($rand); ?>' style='display:none;'> |
|
884 | 884 | <div> |
885 | - <h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3> |
|
886 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post( gepaid_trim_lines( $args['default_content'] ) ); ?></textarea> |
|
887 | - <h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3> |
|
888 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : wp_kses_post( gepaid_trim_lines( $_post->post_content ) ); ?></textarea> |
|
885 | + <h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3> |
|
886 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post(gepaid_trim_lines($args['default_content'])); ?></textarea> |
|
887 | + <h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3> |
|
888 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : wp_kses_post(gepaid_trim_lines($_post->post_content)); ?></textarea> |
|
889 | 889 | </div> |
890 | 890 | </div> |
891 | 891 | <?php endif; ?> |
892 | 892 | |
893 | - <?php echo wp_kses_post( $desc ); ?> |
|
893 | + <?php echo wp_kses_post($desc); ?> |
|
894 | 894 | </label> |
895 | 895 | <?php |
896 | 896 | |
897 | 897 | } |
898 | 898 | |
899 | -function wpinv_color_select_callback( $args ) { |
|
899 | +function wpinv_color_select_callback($args) { |
|
900 | 900 | |
901 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
902 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
903 | - $value = wpinv_get_option( $args['id'], $std ); |
|
901 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
902 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
903 | + $value = wpinv_get_option($args['id'], $std); |
|
904 | 904 | |
905 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
905 | + echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
906 | 906 | |
907 | - foreach ( $args['options'] as $option => $color ) { |
|
908 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
907 | + foreach ($args['options'] as $option => $color) { |
|
908 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | echo '</select>'; |
912 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
912 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
913 | 913 | |
914 | 914 | } |
915 | 915 | |
916 | -function wpinv_rich_editor_callback( $args ) { |
|
916 | +function wpinv_rich_editor_callback($args) { |
|
917 | 917 | global $wp_version; |
918 | 918 | |
919 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
919 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
920 | 920 | |
921 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
922 | - $value = wpinv_get_option( $args['id'], $std ); |
|
921 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
922 | + $value = wpinv_get_option($args['id'], $std); |
|
923 | 923 | |
924 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
924 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
925 | 925 | $value = $std; |
926 | 926 | } |
927 | 927 | |
928 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
928 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
929 | 929 | |
930 | 930 | echo '<div class="getpaid-settings-editor-input">'; |
931 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
931 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
932 | 932 | wp_editor( |
933 | - stripslashes( $value ), |
|
934 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
933 | + stripslashes($value), |
|
934 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
935 | 935 | array( |
936 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
937 | - 'textarea_rows' => absint( $rows ), |
|
936 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
937 | + 'textarea_rows' => absint($rows), |
|
938 | 938 | 'media_buttons' => false, |
939 | 939 | ) |
940 | 940 | ); |
941 | 941 | } else { |
942 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
942 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
943 | 943 | } |
944 | 944 | |
945 | - echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
945 | + echo '</div><br/><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
946 | 946 | |
947 | 947 | } |
948 | 948 | |
949 | -function wpinv_upload_callback( $args ) { |
|
949 | +function wpinv_upload_callback($args) { |
|
950 | 950 | |
951 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
951 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
952 | 952 | |
953 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
954 | - $value = wpinv_get_option( $args['id'], $std ); |
|
953 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
954 | + $value = wpinv_get_option($args['id'], $std); |
|
955 | 955 | |
956 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
957 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
958 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
959 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
956 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
957 | + echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
958 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__('Upload File', 'invoicing') . '"/></span>'; |
|
959 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
960 | 960 | |
961 | 961 | } |
962 | 962 | |
963 | -function wpinv_color_callback( $args ) { |
|
963 | +function wpinv_color_callback($args) { |
|
964 | 964 | |
965 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
966 | - $value = wpinv_get_option( $args['id'], $std ); |
|
967 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
965 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
966 | + $value = wpinv_get_option($args['id'], $std); |
|
967 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
968 | 968 | |
969 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
970 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
969 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
970 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
971 | 971 | |
972 | 972 | } |
973 | 973 | |
974 | -function wpinv_country_states_callback( $args ) { |
|
974 | +function wpinv_country_states_callback($args) { |
|
975 | 975 | |
976 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
977 | - $value = wpinv_get_option( $args['id'], $std ); |
|
976 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
977 | + $value = wpinv_get_option($args['id'], $std); |
|
978 | 978 | |
979 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
979 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
980 | 980 | |
981 | - if ( isset( $args['placeholder'] ) ) { |
|
981 | + if (isset($args['placeholder'])) { |
|
982 | 982 | $placeholder = $args['placeholder']; |
983 | 983 | } else { |
984 | 984 | $placeholder = ''; |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | |
987 | 987 | $states = wpinv_get_country_states(); |
988 | 988 | |
989 | - $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2'; |
|
990 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
989 | + $class = empty($states) ? 'wpinv-no-states' : 'wpi_select2'; |
|
990 | + echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="' . esc_attr($class) . '" data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
991 | 991 | |
992 | - foreach ( $states as $option => $name ) { |
|
993 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
992 | + foreach ($states as $option => $name) { |
|
993 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | echo '</select>'; |
997 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
997 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
998 | 998 | |
999 | 999 | } |
1000 | 1000 | |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | </tr> |
1009 | 1009 | <tr class="bsui"> |
1010 | 1010 | <td colspan="2" class="p-0"> |
1011 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
1011 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
1012 | 1012 | |
1013 | 1013 | <?php |
1014 | 1014 | |
@@ -1017,11 +1017,11 @@ discard block |
||
1017 | 1017 | /** |
1018 | 1018 | * Displays a tax rate' edit row. |
1019 | 1019 | */ |
1020 | -function wpinv_tax_rate_callback( $tax_rate, $key ) { |
|
1020 | +function wpinv_tax_rate_callback($tax_rate, $key) { |
|
1021 | 1021 | |
1022 | - $key = sanitize_key( $key ); |
|
1023 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
1024 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
1022 | + $key = sanitize_key($key); |
|
1023 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
1024 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
1025 | 1025 | |
1026 | 1026 | } |
1027 | 1027 | |
@@ -1035,177 +1035,177 @@ discard block |
||
1035 | 1035 | </tr> |
1036 | 1036 | <tr class="bsui"> |
1037 | 1037 | <td colspan="2" class="p-0"> |
1038 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rules-edit.php'; ?> |
|
1038 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rules-edit.php'; ?> |
|
1039 | 1039 | |
1040 | 1040 | <?php |
1041 | 1041 | |
1042 | 1042 | } |
1043 | 1043 | |
1044 | -function wpinv_tools_callback( $args ) { |
|
1044 | +function wpinv_tools_callback($args) { |
|
1045 | 1045 | ?> |
1046 | 1046 | </td><tr> |
1047 | 1047 | <td colspan="2" class="wpinv_tools_tdbox"> |
1048 | 1048 | <?php |
1049 | - if ( $args['desc'] ) { |
|
1049 | + if ($args['desc']) { |
|
1050 | 1050 | ?> |
1051 | -<p><?php echo wp_kses_post( $args['desc'] ); ?></p><?php } ?> |
|
1052 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1051 | +<p><?php echo wp_kses_post($args['desc']); ?></p><?php } ?> |
|
1052 | + <?php do_action('wpinv_tools_before'); ?> |
|
1053 | 1053 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1054 | 1054 | <thead> |
1055 | 1055 | <tr> |
1056 | - <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th> |
|
1057 | - <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th> |
|
1058 | - <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th> |
|
1056 | + <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th> |
|
1057 | + <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th> |
|
1058 | + <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th> |
|
1059 | 1059 | </tr> |
1060 | 1060 | </thead> |
1061 | 1061 | |
1062 | 1062 | <tbody> |
1063 | 1063 | <tr> |
1064 | - <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td> |
|
1064 | + <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td> |
|
1065 | 1065 | <td> |
1066 | - <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
1066 | + <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
1067 | 1067 | </td> |
1068 | 1068 | <td> |
1069 | 1069 | <a href=" |
1070 | 1070 | <?php |
1071 | 1071 | echo esc_url( |
1072 | 1072 | wp_nonce_url( |
1073 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
1073 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
1074 | 1074 | 'getpaid-nonce', |
1075 | 1075 | 'getpaid-nonce' |
1076 | 1076 | ) |
1077 | 1077 | ); |
1078 | 1078 | ?> |
1079 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1079 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1080 | 1080 | </td> |
1081 | 1081 | </tr> |
1082 | 1082 | <tr> |
1083 | - <td><?php esc_html_e( 'Refresh Permalinks', 'invoicing' ); ?></td> |
|
1083 | + <td><?php esc_html_e('Refresh Permalinks', 'invoicing'); ?></td> |
|
1084 | 1084 | <td> |
1085 | - <small><?php esc_html_e( 'Might fix the page not found error when viewing an invoice.', 'invoicing' ); ?></small> |
|
1085 | + <small><?php esc_html_e('Might fix the page not found error when viewing an invoice.', 'invoicing'); ?></small> |
|
1086 | 1086 | </td> |
1087 | 1087 | <td> |
1088 | 1088 | <a href=" |
1089 | 1089 | <?php |
1090 | 1090 | echo esc_url( |
1091 | 1091 | wp_nonce_url( |
1092 | - add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ), |
|
1092 | + add_query_arg('getpaid-admin-action', 'refresh_permalinks'), |
|
1093 | 1093 | 'getpaid-nonce', |
1094 | 1094 | 'getpaid-nonce' |
1095 | 1095 | ) |
1096 | 1096 | ); |
1097 | 1097 | ?> |
1098 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1098 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1099 | 1099 | </td> |
1100 | 1100 | </tr> |
1101 | 1101 | <tr> |
1102 | - <td><?php esc_html_e( 'Repair Database Tables', 'invoicing' ); ?></td> |
|
1102 | + <td><?php esc_html_e('Repair Database Tables', 'invoicing'); ?></td> |
|
1103 | 1103 | <td> |
1104 | - <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
1104 | + <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
1105 | 1105 | </td> |
1106 | 1106 | <td> |
1107 | 1107 | <a href=" |
1108 | 1108 | <?php |
1109 | 1109 | echo esc_url( |
1110 | 1110 | wp_nonce_url( |
1111 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1111 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
1112 | 1112 | 'getpaid-nonce', |
1113 | 1113 | 'getpaid-nonce' |
1114 | 1114 | ) |
1115 | 1115 | ); |
1116 | 1116 | ?> |
1117 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1117 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1118 | 1118 | </td> |
1119 | 1119 | </tr> |
1120 | 1120 | <tr> |
1121 | - <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
1121 | + <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td> |
|
1122 | 1122 | <td> |
1123 | - <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1123 | + <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1124 | 1124 | </td> |
1125 | 1125 | <td> |
1126 | 1126 | <a href=" |
1127 | 1127 | <?php |
1128 | 1128 | echo esc_url( |
1129 | 1129 | wp_nonce_url( |
1130 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1130 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1131 | 1131 | 'getpaid-nonce', |
1132 | 1132 | 'getpaid-nonce' |
1133 | 1133 | ) |
1134 | 1134 | ); |
1135 | 1135 | ?> |
1136 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1136 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1137 | 1137 | </td> |
1138 | 1138 | </tr> |
1139 | 1139 | |
1140 | 1140 | <tr> |
1141 | - <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
1141 | + <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1142 | 1142 | <td> |
1143 | - <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1143 | + <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1144 | 1144 | </td> |
1145 | 1145 | <td> |
1146 | 1146 | <a href=" |
1147 | 1147 | <?php |
1148 | 1148 | echo esc_url( |
1149 | 1149 | wp_nonce_url( |
1150 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1150 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1151 | 1151 | 'getpaid-nonce', |
1152 | 1152 | 'getpaid-nonce' |
1153 | 1153 | ) |
1154 | 1154 | ); |
1155 | 1155 | ?> |
1156 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1156 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1157 | 1157 | </td> |
1158 | 1158 | </tr> |
1159 | 1159 | |
1160 | 1160 | <tr> |
1161 | - <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
1161 | + <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td> |
|
1162 | 1162 | <td> |
1163 | - <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
1163 | + <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
1164 | 1164 | </td> |
1165 | 1165 | <td> |
1166 | 1166 | <a href=" |
1167 | 1167 | <?php |
1168 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1168 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
1169 | 1169 | ?> |
1170 | - " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
|
1170 | + " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a> |
|
1171 | 1171 | </td> |
1172 | 1172 | </tr> |
1173 | 1173 | |
1174 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1174 | + <?php do_action('wpinv_tools_row'); ?> |
|
1175 | 1175 | </tbody> |
1176 | 1176 | </table> |
1177 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1177 | + <?php do_action('wpinv_tools_after'); ?> |
|
1178 | 1178 | <?php |
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
1182 | -function wpinv_descriptive_text_callback( $args ) { |
|
1183 | - echo wp_kses_post( $args['desc'] ); |
|
1182 | +function wpinv_descriptive_text_callback($args) { |
|
1183 | + echo wp_kses_post($args['desc']); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | -function wpinv_raw_html_callback( $args ) { |
|
1187 | - echo wp_kses( $args['desc'], getpaid_allowed_html() ); |
|
1186 | +function wpinv_raw_html_callback($args) { |
|
1187 | + echo wp_kses($args['desc'], getpaid_allowed_html()); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | -function wpinv_hook_callback( $args ) { |
|
1191 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1190 | +function wpinv_hook_callback($args) { |
|
1191 | + do_action('wpinv_' . $args['id'], $args); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | function wpinv_set_settings_cap() { |
1195 | 1195 | return wpinv_get_capability(); |
1196 | 1196 | } |
1197 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1197 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1198 | 1198 | |
1199 | 1199 | |
1200 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1201 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1202 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1200 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1201 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1202 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1203 | 1203 | |
1204 | - if ( $old != $new ) { |
|
1205 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1204 | + if ($old != $new) { |
|
1205 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1206 | 1206 | } |
1207 | 1207 | } |
1208 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1208 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1209 | 1209 | |
1210 | 1210 | |
1211 | 1211 | /** |
@@ -1217,43 +1217,43 @@ discard block |
||
1217 | 1217 | * |
1218 | 1218 | * @return array |
1219 | 1219 | */ |
1220 | -function wpinv_get_email_merge_tags( $subscription = false ) { |
|
1220 | +function wpinv_get_email_merge_tags($subscription = false) { |
|
1221 | 1221 | $merge_tags = array( |
1222 | - '{site_title}' => __( 'Site Title', 'invoicing' ), |
|
1223 | - '{name}' => __( "Customer's full name", 'invoicing' ), |
|
1224 | - '{first_name}' => __( "Customer's first name", 'invoicing' ), |
|
1225 | - '{last_name}' => __( "Customer's last name", 'invoicing' ), |
|
1226 | - '{email}' => __( "Customer's email address", 'invoicing' ), |
|
1227 | - '{invoice_number}' => __( 'The invoice number', 'invoicing' ), |
|
1228 | - '{invoice_currency}' => __( 'The invoice currency', 'invoicing' ), |
|
1229 | - '{invoice_total}' => __( 'The invoice total', 'invoicing' ), |
|
1230 | - '{invoice_link}' => __( 'The invoice link', 'invoicing' ), |
|
1231 | - '{invoice_pay_link}' => __( 'The payment link', 'invoicing' ), |
|
1232 | - '{invoice_receipt_link}' => __( 'The receipt link', 'invoicing' ), |
|
1233 | - '{invoice_date}' => __( 'The date the invoice was created', 'invoicing' ), |
|
1234 | - '{invoice_due_date}' => __( 'The date the invoice is due', 'invoicing' ), |
|
1235 | - '{date}' => __( "Today's date", 'invoicing' ), |
|
1236 | - '{is_was}' => __( 'If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing' ), |
|
1237 | - '{invoice_label}' => __( 'Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing' ), |
|
1238 | - '{invoice_quote}' => __( 'Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing' ), |
|
1239 | - '{invoice_description}' => __( 'The description of the invoice', 'invoicing' ), |
|
1222 | + '{site_title}' => __('Site Title', 'invoicing'), |
|
1223 | + '{name}' => __("Customer's full name", 'invoicing'), |
|
1224 | + '{first_name}' => __("Customer's first name", 'invoicing'), |
|
1225 | + '{last_name}' => __("Customer's last name", 'invoicing'), |
|
1226 | + '{email}' => __("Customer's email address", 'invoicing'), |
|
1227 | + '{invoice_number}' => __('The invoice number', 'invoicing'), |
|
1228 | + '{invoice_currency}' => __('The invoice currency', 'invoicing'), |
|
1229 | + '{invoice_total}' => __('The invoice total', 'invoicing'), |
|
1230 | + '{invoice_link}' => __('The invoice link', 'invoicing'), |
|
1231 | + '{invoice_pay_link}' => __('The payment link', 'invoicing'), |
|
1232 | + '{invoice_receipt_link}' => __('The receipt link', 'invoicing'), |
|
1233 | + '{invoice_date}' => __('The date the invoice was created', 'invoicing'), |
|
1234 | + '{invoice_due_date}' => __('The date the invoice is due', 'invoicing'), |
|
1235 | + '{date}' => __("Today's date", 'invoicing'), |
|
1236 | + '{is_was}' => __('If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing'), |
|
1237 | + '{invoice_label}' => __('Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing'), |
|
1238 | + '{invoice_quote}' => __('Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing'), |
|
1239 | + '{invoice_description}' => __('The description of the invoice', 'invoicing'), |
|
1240 | 1240 | ); |
1241 | 1241 | |
1242 | - if ( $subscription ) { |
|
1242 | + if ($subscription) { |
|
1243 | 1243 | $merge_tags = array_merge( |
1244 | 1244 | $merge_tags, |
1245 | 1245 | array( |
1246 | - '{subscription_renewal_date}' => __( 'The next renewal date of the subscription', 'invoicing' ), |
|
1247 | - '{subscription_created}' => __( "The subscription's creation date", 'invoicing' ), |
|
1248 | - '{subscription_status}' => __( "The subscription's status", 'invoicing' ), |
|
1249 | - '{subscription_profile_id}' => __( "The subscription's remote profile id", 'invoicing' ), |
|
1250 | - '{subscription_id}' => __( "The subscription's id", 'invoicing' ), |
|
1251 | - '{subscription_recurring_amount}' => __( 'The renewal amount of the subscription', 'invoicing' ), |
|
1252 | - '{subscription_initial_amount}' => __( 'The initial amount of the subscription', 'invoicing' ), |
|
1253 | - '{subscription_recurring_period}' => __( 'The recurring period of the subscription (e.g 1 year)', 'invoicing' ), |
|
1254 | - '{subscription_bill_times}' => __( 'The maximum number of times the subscription can be renewed', 'invoicing' ), |
|
1255 | - '{subscription_url}' => __( 'The URL to manage a subscription', 'invoicing' ), |
|
1256 | - '{subscription_name}' => __( 'The name of the recurring item', 'invoicing' ), |
|
1246 | + '{subscription_renewal_date}' => __('The next renewal date of the subscription', 'invoicing'), |
|
1247 | + '{subscription_created}' => __("The subscription's creation date", 'invoicing'), |
|
1248 | + '{subscription_status}' => __("The subscription's status", 'invoicing'), |
|
1249 | + '{subscription_profile_id}' => __("The subscription's remote profile id", 'invoicing'), |
|
1250 | + '{subscription_id}' => __("The subscription's id", 'invoicing'), |
|
1251 | + '{subscription_recurring_amount}' => __('The renewal amount of the subscription', 'invoicing'), |
|
1252 | + '{subscription_initial_amount}' => __('The initial amount of the subscription', 'invoicing'), |
|
1253 | + '{subscription_recurring_period}' => __('The recurring period of the subscription (e.g 1 year)', 'invoicing'), |
|
1254 | + '{subscription_bill_times}' => __('The maximum number of times the subscription can be renewed', 'invoicing'), |
|
1255 | + '{subscription_url}' => __('The URL to manage a subscription', 'invoicing'), |
|
1256 | + '{subscription_name}' => __('The name of the recurring item', 'invoicing'), |
|
1257 | 1257 | ) |
1258 | 1258 | ); |
1259 | 1259 | } |
@@ -1269,25 +1269,25 @@ discard block |
||
1269 | 1269 | * |
1270 | 1270 | * @return string |
1271 | 1271 | */ |
1272 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1273 | - $merge_tags = wpinv_get_email_merge_tags( $subscription ); |
|
1272 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1273 | + $merge_tags = wpinv_get_email_merge_tags($subscription); |
|
1274 | 1274 | |
1275 | 1275 | $output = '<div class="bsui">'; |
1276 | 1276 | |
1277 | 1277 | $link = sprintf( |
1278 | 1278 | '<strong class="getpaid-merge-tags text-primary" role="button">%s</strong>', |
1279 | - esc_html__( 'View available merge tags.', 'invoicing' ) |
|
1279 | + esc_html__('View available merge tags.', 'invoicing') |
|
1280 | 1280 | ); |
1281 | 1281 | |
1282 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1282 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1283 | 1283 | |
1284 | 1284 | $output .= "$description $link"; |
1285 | 1285 | |
1286 | 1286 | $output .= '<div class="getpaid-merge-tags-content mt-2 p-1 d-none">'; |
1287 | - $output .= '<p class="mb-2">' . esc_html__( 'The following wildcards can be used in email subjects, heading and content:', 'invoicing' ) . '</p>'; |
|
1287 | + $output .= '<p class="mb-2">' . esc_html__('The following wildcards can be used in email subjects, heading and content:', 'invoicing') . '</p>'; |
|
1288 | 1288 | |
1289 | 1289 | $output .= '<ul class="p-0 m-0">'; |
1290 | - foreach($merge_tags as $tag => $tag_description) { |
|
1290 | + foreach ($merge_tags as $tag => $tag_description) { |
|
1291 | 1291 | $output .= "<li class='mb-2'><strong class='text-dark'>$tag</strong> — $tag_description</li>"; |
1292 | 1292 | } |
1293 | 1293 |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | * Displays a list of all subscriptions rules |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
10 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
10 | +if (!class_exists('WP_List_Table')) { |
|
11 | 11 | include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
12 | 12 | } |
13 | 13 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | $this->prepare_query(); |
82 | 82 | |
83 | - $this->base_url = remove_query_arg( 'status' ); |
|
83 | + $this->base_url = remove_query_arg('status'); |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | $query = array( |
94 | 94 | 'number' => $this->per_page, |
95 | 95 | 'paged' => $this->get_paged(), |
96 | - 'status' => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all', |
|
97 | - 'orderby' => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id', |
|
98 | - 'order' => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC', |
|
96 | + 'status' => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? sanitize_text_field($_GET['status']) : 'all', |
|
97 | + 'orderby' => (isset($_GET['orderby'])) ? sanitize_text_field($_GET['orderby']) : 'id', |
|
98 | + 'order' => (isset($_GET['order'])) ? sanitize_text_field($_GET['order']) : 'DESC', |
|
99 | 99 | 'customer_in' => $this->get_user_in(), |
100 | 100 | ); |
101 | 101 | |
102 | - if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) { |
|
102 | + if (is_array($query['customer_in']) && empty($query['customer_in'])) { |
|
103 | 103 | $this->total_count = 0; |
104 | 104 | $this->current_total_count = 0; |
105 | 105 | $this->items = array(); |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | // Prepare class properties. |
111 | - $this->query = new GetPaid_Subscriptions_Query( $query ); |
|
111 | + $this->query = new GetPaid_Subscriptions_Query($query); |
|
112 | 112 | $this->total_count = $this->query->get_total(); |
113 | 113 | $this->current_total_count = $this->query->get_total(); |
114 | 114 | $this->items = $this->query->get_results(); |
115 | - $this->status_counts = getpaid_get_subscription_status_counts( $query ); |
|
115 | + $this->status_counts = getpaid_get_subscription_status_counts($query); |
|
116 | 116 | |
117 | - if ( 'all' != $query['status'] ) { |
|
118 | - unset( $query['status'] ); |
|
119 | - $this->total_count = getpaid_get_subscriptions( $query, 'count' ); |
|
117 | + if ('all' != $query['status']) { |
|
118 | + unset($query['status']); |
|
119 | + $this->total_count = getpaid_get_subscriptions($query, 'count'); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | } |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | public function get_user_in() { |
129 | 129 | |
130 | 130 | // Abort if no user. |
131 | - if ( empty( $_GET['s'] ) ) { |
|
131 | + if (empty($_GET['s'])) { |
|
132 | 132 | return null; |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Or invalid user. |
136 | - $user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) ); |
|
136 | + $user = wp_unslash(sanitize_text_field($_REQUEST['s'])); |
|
137 | 137 | |
138 | - if ( empty( $user ) ) { |
|
138 | + if (empty($user)) { |
|
139 | 139 | return null; |
140 | 140 | } |
141 | 141 | |
@@ -164,26 +164,26 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function get_views() { |
166 | 166 | |
167 | - $current = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all'; |
|
167 | + $current = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : 'all'; |
|
168 | 168 | $views = array( |
169 | 169 | |
170 | 170 | 'all' => sprintf( |
171 | 171 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
172 | - esc_url( add_query_arg( 'status', false, $this->base_url ) ), |
|
172 | + esc_url(add_query_arg('status', false, $this->base_url)), |
|
173 | 173 | $current === 'all' ? ' class="current"' : '', |
174 | - __( 'All', 'invoicing' ), |
|
174 | + __('All', 'invoicing'), |
|
175 | 175 | $this->total_count |
176 | 176 | ), |
177 | 177 | |
178 | 178 | ); |
179 | 179 | |
180 | - foreach ( array_filter( $this->status_counts ) as $status => $count ) { |
|
180 | + foreach (array_filter($this->status_counts) as $status => $count) { |
|
181 | 181 | |
182 | - $views[ $status ] = sprintf( |
|
182 | + $views[$status] = sprintf( |
|
183 | 183 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
184 | - esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ), |
|
184 | + esc_url(add_query_arg('status', urlencode($status), $this->base_url)), |
|
185 | 185 | $current === $status ? ' class="current"' : '', |
186 | - esc_html( getpaid_get_subscription_status_label( $status ) ), |
|
186 | + esc_html(getpaid_get_subscription_status_label($status)), |
|
187 | 187 | $count |
188 | 188 | ); |
189 | 189 | |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | * @since 1.0.0 |
201 | 201 | * @return string |
202 | 202 | */ |
203 | - public function column_default( $item, $column_name ) { |
|
204 | - return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name ); |
|
203 | + public function column_default($item, $column_name) { |
|
204 | + return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -210,8 +210,8 @@ discard block |
||
210 | 210 | * @param WPInv_Subscription $item |
211 | 211 | * @return string |
212 | 212 | */ |
213 | - public function column_cb( $item ) { |
|
214 | - return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) ); |
|
213 | + public function column_cb($item) { |
|
214 | + return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id())); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @since 1.0.0 |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - public function column_status( $item ) { |
|
224 | + public function column_status($item) { |
|
225 | 225 | return $item->get_status_label_html(); |
226 | 226 | } |
227 | 227 | |
@@ -232,26 +232,26 @@ discard block |
||
232 | 232 | * @since 1.0.0 |
233 | 233 | * @return string |
234 | 234 | */ |
235 | - public function column_subscription( $item ) { |
|
235 | + public function column_subscription($item) { |
|
236 | 236 | |
237 | - $username = __( '(Missing User)', 'invoicing' ); |
|
237 | + $username = __('(Missing User)', 'invoicing'); |
|
238 | 238 | |
239 | - $user = get_userdata( $item->get_customer_id() ); |
|
239 | + $user = get_userdata($item->get_customer_id()); |
|
240 | 240 | $capabilities = wpinv_current_user_can_manage_invoicing(); |
241 | 241 | |
242 | - if ( $user ) { |
|
242 | + if ($user) { |
|
243 | 243 | $username = sprintf( |
244 | 244 | '<a href="user-edit.php?user_id=%s">%s</a>', |
245 | - absint( $user->ID ), |
|
246 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
245 | + absint($user->ID), |
|
246 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
247 | 247 | ); |
248 | 248 | } |
249 | 249 | |
250 | 250 | // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name |
251 | 251 | $column_content = sprintf( |
252 | - _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ), |
|
253 | - '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">', |
|
254 | - '<strong>' . esc_attr( $item->get_id() ) . '</strong>', |
|
252 | + _x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'), |
|
253 | + '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">', |
|
254 | + '<strong>' . esc_attr($item->get_id()) . '</strong>', |
|
255 | 255 | '</a>', |
256 | 256 | $username |
257 | 257 | ); |
@@ -259,18 +259,18 @@ discard block |
||
259 | 259 | $row_actions = array(); |
260 | 260 | |
261 | 261 | // View subscription. |
262 | - $view_url = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ) ); |
|
263 | - $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>'; |
|
262 | + $view_url = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions'))); |
|
263 | + $row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>'; |
|
264 | 264 | |
265 | 265 | // View invoice. |
266 | - $invoice = get_post( $item->get_parent_invoice_id() ); |
|
266 | + $invoice = get_post($item->get_parent_invoice_id()); |
|
267 | 267 | |
268 | - if ( ! empty( $invoice ) ) { |
|
269 | - $invoice_url = get_edit_post_link( $invoice ); |
|
270 | - $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>'; |
|
268 | + if (!empty($invoice)) { |
|
269 | + $invoice_url = get_edit_post_link($invoice); |
|
270 | + $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __('View Invoice', 'invoicing') . '</a>'; |
|
271 | 271 | } |
272 | 272 | |
273 | - $delete_url = esc_url( |
|
273 | + $delete_url = esc_url( |
|
274 | 274 | wp_nonce_url( |
275 | 275 | add_query_arg( |
276 | 276 | array( |
@@ -282,15 +282,15 @@ discard block |
||
282 | 282 | 'getpaid-nonce' |
283 | 283 | ) |
284 | 284 | ); |
285 | - $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>'; |
|
285 | + $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __('Delete Subscription', 'invoicing') . '</a>'; |
|
286 | 286 | |
287 | - if ( ! $capabilities ) { |
|
287 | + if (!$capabilities) { |
|
288 | 288 | $row_actions = array(); |
289 | 289 | } |
290 | 290 | |
291 | - $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) ); |
|
291 | + $row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item)); |
|
292 | 292 | |
293 | - return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions; |
|
293 | + return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @since 1.0.0 |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public function column_renewal_date( $item ) { |
|
304 | - return getpaid_format_date_value( $item->get_expiration() ); |
|
303 | + public function column_renewal_date($item) { |
|
304 | + return getpaid_format_date_value($item->get_expiration()); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -311,27 +311,27 @@ discard block |
||
311 | 311 | * @since 1.0.0 |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - public function column_start_date( $item ) { |
|
314 | + public function column_start_date($item) { |
|
315 | 315 | |
316 | 316 | $gateway = $item->get_parent_invoice()->get_gateway_title(); |
317 | 317 | |
318 | - if ( empty( $gateway ) ) { |
|
319 | - return getpaid_format_date_value( $item->get_date_created() ); |
|
318 | + if (empty($gateway)) { |
|
319 | + return getpaid_format_date_value($item->get_date_created()); |
|
320 | 320 | } |
321 | 321 | |
322 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item ); |
|
323 | - if ( ! empty( $url ) ) { |
|
322 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $item); |
|
323 | + if (!empty($url)) { |
|
324 | 324 | |
325 | - return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf( |
|
326 | - __( 'Via %s', 'invoicing' ), |
|
327 | - '<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>' |
|
325 | + return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf( |
|
326 | + __('Via %s', 'invoicing'), |
|
327 | + '<strong><a href="' . esc_url($url) . '" target="_blank">' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</a></strong>' |
|
328 | 328 | ); |
329 | 329 | |
330 | 330 | } |
331 | 331 | |
332 | - return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf( |
|
333 | - __( 'Via %s', 'invoicing' ), |
|
334 | - '<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>' |
|
332 | + return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf( |
|
333 | + __('Via %s', 'invoicing'), |
|
334 | + '<strong>' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</strong>' |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | } |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | * @since 1.0.19 |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - public static function column_amount( $item ) { |
|
347 | - $amount = getpaid_get_formatted_subscription_amount( $item ); |
|
346 | + public static function column_amount($item) { |
|
347 | + $amount = getpaid_get_formatted_subscription_amount($item); |
|
348 | 348 | return "<span class='text-muted form-text mt-2 mb-2 ms-1 ml-1'>$amount</span>"; |
349 | 349 | } |
350 | 350 | |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | * @since 1.0.0 |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - public function column_renewals( $item ) { |
|
358 | + public function column_renewals($item) { |
|
359 | 359 | $max_bills = $item->get_bill_times(); |
360 | - return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? '∞' : $max_bills ); |
|
360 | + return $item->get_times_billed() . ' / ' . (empty($max_bills) ? '∞' : $max_bills); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,15 +367,15 @@ discard block |
||
367 | 367 | * @since 1.0.0 |
368 | 368 | * @return string |
369 | 369 | */ |
370 | - public function column_item( $item ) { |
|
371 | - $subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() ); |
|
370 | + public function column_item($item) { |
|
371 | + $subscription_group = getpaid_get_invoice_subscription_group($item->get_parent_invoice_id(), $item->get_id()); |
|
372 | 372 | |
373 | - if ( empty( $subscription_group ) ) { |
|
374 | - return $this->generate_item_markup( $item->get_product_id() ); |
|
373 | + if (empty($subscription_group)) { |
|
374 | + return $this->generate_item_markup($item->get_product_id()); |
|
375 | 375 | } |
376 | 376 | |
377 | - $markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
378 | - return implode( ' | ', $markup ); |
|
377 | + $markup = array_map(array($this, 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
378 | + return implode(' | ', $markup); |
|
379 | 379 | |
380 | 380 | } |
381 | 381 | |
@@ -386,15 +386,15 @@ discard block |
||
386 | 386 | * @since 1.0.0 |
387 | 387 | * @return string |
388 | 388 | */ |
389 | - public static function generate_item_markup( $item_id ) { |
|
390 | - $item = get_post( $item_id ); |
|
389 | + public static function generate_item_markup($item_id) { |
|
390 | + $item = get_post($item_id); |
|
391 | 391 | |
392 | - if ( ! empty( $item ) ) { |
|
393 | - $link = get_edit_post_link( $item ); |
|
394 | - $name = esc_html( get_the_title( $item ) ); |
|
395 | - return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$name</a>" : $name; |
|
392 | + if (!empty($item)) { |
|
393 | + $link = get_edit_post_link($item); |
|
394 | + $name = esc_html(get_the_title($item)); |
|
395 | + return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ($link ? esc_url($link) : '#') . "'>$name</a>" : $name; |
|
396 | 396 | } else { |
397 | - return sprintf( __( 'Item #%s', 'invoicing' ), $item_id ); |
|
397 | + return sprintf(__('Item #%s', 'invoicing'), $item_id); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @return int |
406 | 406 | */ |
407 | 407 | public function get_paged() { |
408 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
408 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | $hidden = array(); |
419 | 419 | $sortable = $this->get_sortable_columns(); |
420 | 420 | |
421 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
421 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
422 | 422 | |
423 | 423 | $this->set_pagination_args( |
424 | 424 | array( |
425 | 425 | 'total_items' => $this->current_total_count, |
426 | 426 | 'per_page' => $this->per_page, |
427 | - 'total_pages' => ceil( $this->current_total_count / $this->per_page ), |
|
427 | + 'total_pages' => ceil($this->current_total_count / $this->per_page), |
|
428 | 428 | ) |
429 | 429 | ); |
430 | 430 | } |
@@ -437,15 +437,15 @@ discard block |
||
437 | 437 | public function get_columns() { |
438 | 438 | $columns = array( |
439 | 439 | 'cb' => '<input type="checkbox" />', |
440 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
441 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
442 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
443 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
444 | - 'item' => __( 'Items', 'invoicing' ), |
|
445 | - 'status' => __( 'Status', 'invoicing' ), |
|
440 | + 'subscription' => __('Subscription', 'invoicing'), |
|
441 | + 'start_date' => __('Start Date', 'invoicing'), |
|
442 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
443 | + 'renewals' => __('Payments', 'invoicing'), |
|
444 | + 'item' => __('Items', 'invoicing'), |
|
445 | + 'status' => __('Status', 'invoicing'), |
|
446 | 446 | ); |
447 | 447 | |
448 | - return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns ); |
|
448 | + return apply_filters('manage_getpaid_subscriptions_table_columns', $columns); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -455,15 +455,15 @@ discard block |
||
455 | 455 | */ |
456 | 456 | public function get_sortable_columns() { |
457 | 457 | $sortable = array( |
458 | - 'subscription' => array( 'id', true ), |
|
459 | - 'start_date' => array( 'created', true ), |
|
460 | - 'renewal_date' => array( 'expiration', true ), |
|
461 | - 'renewals' => array( 'bill_times', true ), |
|
462 | - 'item' => array( 'product_id', true ), |
|
463 | - 'status' => array( 'status', true ), |
|
458 | + 'subscription' => array('id', true), |
|
459 | + 'start_date' => array('created', true), |
|
460 | + 'renewal_date' => array('expiration', true), |
|
461 | + 'renewals' => array('bill_times', true), |
|
462 | + 'item' => array('product_id', true), |
|
463 | + 'status' => array('status', true), |
|
464 | 464 | ); |
465 | 465 | |
466 | - return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable ); |
|
466 | + return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @return bool |
473 | 473 | */ |
474 | 474 | public function has_items() { |
475 | - return ! empty( $this->current_total_count ); |
|
475 | + return !empty($this->current_total_count); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,23 +17,23 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ), |
33 | 33 | true |
34 | 34 | ); |
35 | 35 | |
36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
36 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
37 | 37 | |
38 | 38 | // Display a single subscription. |
39 | 39 | wpinv_recurring_subscription_details(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | <?php $subscribers_table->views(); ?> |
68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
70 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
70 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
71 | 71 | <?php $subscribers_table->display(); ?> |
72 | 72 | </form> |
73 | 73 | <?php |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | function wpinv_recurring_subscription_details() { |
84 | 84 | |
85 | 85 | // Fetch the subscription. |
86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
87 | - if ( ! $sub->exists() ) { |
|
86 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
87 | + if (!$sub->exists()) { |
|
88 | 88 | |
89 | 89 | aui()->alert( |
90 | 90 | array( |
91 | 91 | 'type' => 'danger', |
92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
92 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
93 | 93 | ), |
94 | 94 | true |
95 | 95 | ); |
@@ -98,32 +98,32 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | // Use metaboxes to display the subscription details. |
101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
101 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
102 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
103 | 103 | |
104 | 104 | $subscription_id = $sub->get_id(); |
105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
105 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
106 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
107 | 107 | |
108 | - if ( 1 < count( $subscription_groups ) ) { |
|
109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
108 | + if (1 < count($subscription_groups)) { |
|
109 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
110 | 110 | } |
111 | 111 | |
112 | - if ( ! empty( $subscription_group ) ) { |
|
113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
112 | + if (!empty($subscription_group)) { |
|
113 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
114 | 114 | } |
115 | 115 | |
116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
116 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
117 | 117 | |
118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
118 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
119 | 119 | |
120 | 120 | ?> |
121 | 121 | |
122 | - <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
|
122 | + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>"> |
|
123 | 123 | |
124 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
125 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
126 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
124 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
125 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
126 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
127 | 127 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
128 | 128 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
129 | 129 | |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
132 | 132 | |
133 | 133 | <div id="postbox-container-1" class="postbox-container"> |
134 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
134 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
135 | 135 | </div> |
136 | 136 | |
137 | 137 | <div id="postbox-container-2" class="postbox-container"> |
138 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
139 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
138 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
139 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
140 | 140 | </div> |
141 | 141 | |
142 | 142 | </div> |
@@ -155,48 +155,48 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param WPInv_Subscription $sub |
157 | 157 | */ |
158 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
158 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
159 | 159 | |
160 | 160 | // Subscription items. |
161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
161 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
162 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
163 | 163 | |
164 | 164 | // Prepare subscription detail columns. |
165 | 165 | $fields = apply_filters( |
166 | 166 | 'getpaid_subscription_admin_page_fields', |
167 | 167 | array( |
168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
173 | - 'renewals' => __( 'Collected Payments', 'invoicing' ), |
|
174 | - 'item' => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ), |
|
175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
177 | - 'status' => __( 'Status', 'invoicing' ), |
|
168 | + 'subscription' => __('Subscription', 'invoicing'), |
|
169 | + 'customer' => __('Customer', 'invoicing'), |
|
170 | + 'amount' => __('Amount', 'invoicing'), |
|
171 | + 'start_date' => __('Start Date', 'invoicing'), |
|
172 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
173 | + 'renewals' => __('Collected Payments', 'invoicing'), |
|
174 | + 'item' => $items_count > 1 ? __('Items', 'invoicing') : __('Item', 'invoicing'), |
|
175 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
176 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
177 | + 'status' => __('Status', 'invoicing'), |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | |
181 | - if ( ! $sub->is_active() ) { |
|
181 | + if (!$sub->is_active()) { |
|
182 | 182 | |
183 | - if ( isset( $fields['renews_on'] ) ) { |
|
184 | - unset( $fields['renews_on'] ); |
|
183 | + if (isset($fields['renews_on'])) { |
|
184 | + unset($fields['renews_on']); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( isset( $fields['gateway'] ) ) { |
|
188 | - unset( $fields['gateway'] ); |
|
187 | + if (isset($fields['gateway'])) { |
|
188 | + unset($fields['gateway']); |
|
189 | 189 | } |
190 | - } elseif ( $sub->is_last_renewal() ) { |
|
190 | + } elseif ($sub->is_last_renewal()) { |
|
191 | 191 | |
192 | - if ( isset( $fields['renews_on'] ) ) { |
|
193 | - $fields['renews_on'] = __( 'End Date', 'invoicing' ); |
|
192 | + if (isset($fields['renews_on'])) { |
|
193 | + $fields['renews_on'] = __('End Date', 'invoicing'); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | 197 | $profile_id = $sub->get_profile_id(); |
198 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
199 | - unset( $fields['profile_id'] ); |
|
198 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
199 | + unset($fields['profile_id']); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | ?> |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | <table class="table table-borderless" style="font-size: 14px;"> |
205 | 205 | <tbody> |
206 | 206 | |
207 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
207 | + <?php foreach ($fields as $key => $label) : ?> |
|
208 | 208 | |
209 | - <tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>"> |
|
209 | + <tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>"> |
|
210 | 210 | |
211 | 211 | <th class="w-25" style="font-weight: 500;"> |
212 | - <?php echo esc_html( $label ); ?> |
|
212 | + <?php echo esc_html($label); ?> |
|
213 | 213 | </th> |
214 | 214 | |
215 | 215 | <td class="w-75 text-muted"> |
216 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
216 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
217 | 217 | </td> |
218 | 218 | |
219 | 219 | </tr> |
@@ -231,144 +231,144 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @param WPInv_Subscription $subscription |
233 | 233 | */ |
234 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
234 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
235 | 235 | |
236 | - $username = __( '(Missing User)', 'invoicing' ); |
|
236 | + $username = __('(Missing User)', 'invoicing'); |
|
237 | 237 | |
238 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
239 | - if ( $user ) { |
|
238 | + $user = get_userdata($subscription->get_customer_id()); |
|
239 | + if ($user) { |
|
240 | 240 | |
241 | 241 | $username = sprintf( |
242 | 242 | '<a href="user-edit.php?user_id=%s">%s</a>', |
243 | - absint( $user->ID ), |
|
244 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
243 | + absint($user->ID), |
|
244 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
245 | 245 | ); |
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - echo wp_kses_post( $username ); |
|
249 | + echo wp_kses_post($username); |
|
250 | 250 | } |
251 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
251 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * Displays the subscription amount. |
255 | 255 | * |
256 | 256 | * @param WPInv_Subscription $subscription |
257 | 257 | */ |
258 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
259 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
260 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
258 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
259 | + $amount = getpaid_get_formatted_subscription_amount($subscription); |
|
260 | + echo wp_kses_post("<span>$amount</span>"); |
|
261 | 261 | } |
262 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
262 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Displays the subscription id. |
266 | 266 | * |
267 | 267 | * @param WPInv_Subscription $subscription |
268 | 268 | */ |
269 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
269 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
270 | 270 | |
271 | 271 | printf( |
272 | 272 | '<a href="%s">#%s</a>', |
273 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
274 | - absint( $subscription->get_id() ) |
|
273 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
274 | + absint($subscription->get_id()) |
|
275 | 275 | ); |
276 | 276 | |
277 | 277 | } |
278 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
278 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
279 | 279 | |
280 | 280 | /** |
281 | 281 | * Displays the subscription renewal date. |
282 | 282 | * |
283 | 283 | * @param WPInv_Subscription $subscription |
284 | 284 | */ |
285 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
285 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
286 | 286 | |
287 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
287 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
288 | 288 | aui()->input( |
289 | 289 | array( |
290 | 290 | 'type' => 'text', |
291 | 291 | 'id' => 'wpinv_subscription_date_created', |
292 | 292 | 'name' => 'wpinv_subscription_date_created', |
293 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
293 | + 'label' => __('Start Date', 'invoicing'), |
|
294 | 294 | 'label_type' => 'hidden', |
295 | 295 | 'placeholder' => 'YYYY-MM-DD', |
296 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
296 | + 'value' => esc_attr($subscription->get_date_created('edit')), |
|
297 | 297 | 'no_wrap' => true, |
298 | 298 | 'size' => 'sm', |
299 | 299 | ), |
300 | 300 | true |
301 | 301 | ); |
302 | 302 | } else { |
303 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
303 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | } |
307 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
307 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
308 | 308 | |
309 | 309 | /** |
310 | 310 | * Displays the subscription renewal date. |
311 | 311 | * |
312 | 312 | * @param WPInv_Subscription $subscription |
313 | 313 | */ |
314 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
314 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
315 | 315 | |
316 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
316 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
317 | 317 | aui()->input( |
318 | 318 | array( |
319 | 319 | 'type' => 'text', |
320 | 320 | 'id' => 'wpinv_subscription_expiration', |
321 | 321 | 'name' => 'wpinv_subscription_expiration', |
322 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
322 | + 'label' => __('Renews On', 'invoicing'), |
|
323 | 323 | 'label_type' => 'hidden', |
324 | 324 | 'placeholder' => 'YYYY-MM-DD', |
325 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
325 | + 'value' => esc_attr($subscription->get_expiration('edit')), |
|
326 | 326 | 'no_wrap' => true, |
327 | 327 | 'size' => 'sm', |
328 | 328 | ), |
329 | 329 | true |
330 | 330 | ); |
331 | 331 | } else { |
332 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
332 | + echo esc_html(getpaid_format_date_value($subscription->get_expiration())); |
|
333 | 333 | } |
334 | 334 | } |
335 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
335 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Displays the subscription renewal count. |
339 | 339 | * |
340 | 340 | * @param WPInv_Subscription $subscription |
341 | 341 | */ |
342 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
342 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
343 | 343 | |
344 | 344 | $max_bills = $subscription->get_bill_times(); |
345 | 345 | $times_billed = (int) $subscription->get_times_billed(); |
346 | 346 | |
347 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) { |
|
347 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_bill_times_change')) { |
|
348 | 348 | aui()->input( |
349 | 349 | array( |
350 | 350 | 'type' => 'number', |
351 | 351 | 'id' => 'wpinv_subscription_max_bill_times', |
352 | 352 | 'name' => 'wpinv_subscription_max_bill_times', |
353 | - 'label' => __( 'Maximum bill times', 'invoicing' ), |
|
353 | + 'label' => __('Maximum bill times', 'invoicing'), |
|
354 | 354 | 'label_type' => 'hidden', |
355 | - 'placeholder' => __( 'Unlimited', 'invoicing' ), |
|
356 | - 'value' => empty( $max_bills ) ? '' : (int) $max_bills, |
|
355 | + 'placeholder' => __('Unlimited', 'invoicing'), |
|
356 | + 'value' => empty($max_bills) ? '' : (int) $max_bills, |
|
357 | 357 | 'no_wrap' => true, |
358 | 358 | 'size' => 'sm', |
359 | 359 | 'input_group_left' => sprintf( |
360 | 360 | // translators: %d: Number of times billed |
361 | - __( '%d of', 'invoicing' ), |
|
361 | + __('%d of', 'invoicing'), |
|
362 | 362 | $times_billed |
363 | 363 | ), |
364 | 364 | ), |
365 | 365 | true |
366 | 366 | ); |
367 | 367 | } else { |
368 | - echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
368 | + echo esc_html($times_billed) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
369 | 369 | } |
370 | 370 | } |
371 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
371 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Displays the subscription item. |
@@ -376,53 +376,53 @@ discard block |
||
376 | 376 | * @param WPInv_Subscription $subscription |
377 | 377 | * @param false|array $subscription_group |
378 | 378 | */ |
379 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
379 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
380 | 380 | |
381 | - if ( empty( $subscription_group ) ) { |
|
382 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
381 | + if (empty($subscription_group)) { |
|
382 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id())); |
|
383 | 383 | return; |
384 | 384 | } |
385 | 385 | |
386 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
387 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
386 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
387 | + echo wp_kses_post(implode(' | ', $markup)); |
|
388 | 388 | |
389 | 389 | } |
390 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
390 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
391 | 391 | |
392 | 392 | /** |
393 | 393 | * Displays the subscription gateway. |
394 | 394 | * |
395 | 395 | * @param WPInv_Subscription $subscription |
396 | 396 | */ |
397 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
397 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
398 | 398 | |
399 | 399 | $gateway = $subscription->get_gateway(); |
400 | 400 | |
401 | - if ( ! empty( $gateway ) ) { |
|
402 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
401 | + if (!empty($gateway)) { |
|
402 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
403 | 403 | } else { |
404 | 404 | echo '—'; |
405 | 405 | } |
406 | 406 | |
407 | 407 | } |
408 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
408 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
409 | 409 | |
410 | 410 | /** |
411 | 411 | * Displays the subscription status. |
412 | 412 | * |
413 | 413 | * @param WPInv_Subscription $subscription |
414 | 414 | */ |
415 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
416 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
415 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
416 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
417 | 417 | } |
418 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
418 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
419 | 419 | |
420 | 420 | /** |
421 | 421 | * Displays the subscription profile id. |
422 | 422 | * |
423 | 423 | * @param WPInv_Subscription $subscription |
424 | 424 | */ |
425 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
425 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
426 | 426 | |
427 | 427 | $profile_id = $subscription->get_profile_id(); |
428 | 428 | |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | 'type' => 'text', |
432 | 432 | 'id' => 'wpinv_subscription_profile_id', |
433 | 433 | 'name' => 'wpinv_subscription_profile_id', |
434 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
434 | + 'label' => __('Profile Id', 'invoicing'), |
|
435 | 435 | 'label_type' => 'hidden', |
436 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
437 | - 'value' => esc_attr( $profile_id ), |
|
436 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
437 | + 'value' => esc_attr($profile_id), |
|
438 | 438 | 'input_group_right' => '', |
439 | 439 | 'no_wrap' => true, |
440 | 440 | 'size' => 'sm', |
@@ -442,20 +442,20 @@ discard block |
||
442 | 442 | true |
443 | 443 | ); |
444 | 444 | |
445 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
446 | - if ( ! empty( $url ) ) { |
|
447 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
445 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
446 | + if (!empty($url)) { |
|
447 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | } |
451 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
451 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
452 | 452 | |
453 | 453 | /** |
454 | 454 | * Displays the subscriptions update metabox. |
455 | 455 | * |
456 | 456 | * @param WPInv_Subscription $subscription |
457 | 457 | */ |
458 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
458 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
459 | 459 | global $aui_bs5; |
460 | 460 | |
461 | 461 | ?> |
@@ -468,10 +468,10 @@ discard block |
||
468 | 468 | 'id' => 'subscription_status_update_select', |
469 | 469 | 'required' => true, |
470 | 470 | 'no_wrap' => false, |
471 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
472 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
471 | + 'label' => __('Subscription Status', 'invoicing'), |
|
472 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
473 | 473 | 'select2' => true, |
474 | - 'value' => $subscription->get_status( 'edit' ), |
|
474 | + 'value' => $subscription->get_status('edit'), |
|
475 | 475 | ), |
476 | 476 | true |
477 | 477 | ); |
@@ -479,14 +479,14 @@ discard block |
||
479 | 479 | |
480 | 480 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin:-12px"> |
481 | 481 | <?php |
482 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
482 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
483 | 483 | |
484 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
485 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
486 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
484 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
485 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
486 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
487 | 487 | |
488 | - if ( $subscription->is_active() ) { |
|
489 | - echo "<a href='" . esc_url( $url ) . "' class='" . ( $aui_bs5 ? 'float-end' : 'float-right' ) . " button button-secondary' onclick='return confirm(\"" . esc_attr( $title ) . "\")' title='" . esc_attr__( 'Renew subscription manually', 'invoicing' ) . "'>" . esc_html( $anchor ) . "</a>"; |
|
488 | + if ($subscription->is_active()) { |
|
489 | + echo "<a href='" . esc_url($url) . "' class='" . ($aui_bs5 ? 'float-end' : 'float-right') . " button button-secondary' onclick='return confirm(\"" . esc_attr($title) . "\")' title='" . esc_attr__('Renew subscription manually', 'invoicing') . "'>" . esc_html($anchor) . "</a>"; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | echo '</div></div>'; |
@@ -498,44 +498,44 @@ discard block |
||
498 | 498 | * @param WPInv_Subscription $subscription |
499 | 499 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
500 | 500 | */ |
501 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
501 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
502 | 502 | |
503 | 503 | $columns = apply_filters( |
504 | 504 | 'getpaid_subscription_related_invoices_columns', |
505 | 505 | array( |
506 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
507 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
508 | - 'date' => __( 'Date', 'invoicing' ), |
|
509 | - 'status' => __( 'Status', 'invoicing' ), |
|
510 | - 'total' => __( 'Total', 'invoicing' ), |
|
506 | + 'invoice' => __('Invoice', 'invoicing'), |
|
507 | + 'relationship' => __('Relationship', 'invoicing'), |
|
508 | + 'date' => __('Date', 'invoicing'), |
|
509 | + 'status' => __('Status', 'invoicing'), |
|
510 | + 'total' => __('Total', 'invoicing'), |
|
511 | 511 | ), |
512 | 512 | $subscription |
513 | 513 | ); |
514 | 514 | |
515 | 515 | // Prepare the invoices. |
516 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
516 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
517 | 517 | $parent = $subscription->get_parent_invoice(); |
518 | 518 | |
519 | - if ( $parent->exists() ) { |
|
520 | - $payments = array_merge( array( $parent ), $payments ); |
|
519 | + if ($parent->exists()) { |
|
520 | + $payments = array_merge(array($parent), $payments); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | $table_class = 'w-100 bg-white'; |
524 | 524 | |
525 | - if ( ! is_admin() ) { |
|
525 | + if (!is_admin()) { |
|
526 | 526 | $table_class = 'table table-bordered'; |
527 | 527 | } |
528 | 528 | |
529 | 529 | ?> |
530 | 530 | <div class="m-0" style="overflow: auto;"> |
531 | 531 | |
532 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
532 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
533 | 533 | |
534 | 534 | <thead> |
535 | 535 | <tr> |
536 | 536 | <?php |
537 | - foreach ( $columns as $key => $label ) { |
|
538 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
537 | + foreach ($columns as $key => $label) { |
|
538 | + echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
539 | 539 | } |
540 | 540 | ?> |
541 | 541 | </tr> |
@@ -543,72 +543,72 @@ discard block |
||
543 | 543 | |
544 | 544 | <tbody> |
545 | 545 | |
546 | - <?php if ( empty( $payments ) ) : ?> |
|
546 | + <?php if (empty($payments)) : ?> |
|
547 | 547 | <tr> |
548 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
549 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
548 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
549 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
550 | 550 | </td> |
551 | 551 | </tr> |
552 | 552 | <?php endif; ?> |
553 | 553 | |
554 | 554 | <?php |
555 | 555 | |
556 | - foreach ( $payments as $payment ) : |
|
556 | + foreach ($payments as $payment) : |
|
557 | 557 | |
558 | 558 | // Ensure that we have an invoice. |
559 | - $payment = new WPInv_Invoice( $payment ); |
|
559 | + $payment = new WPInv_Invoice($payment); |
|
560 | 560 | |
561 | 561 | // Abort if the invoice is invalid... |
562 | - if ( ! $payment->exists() ) { |
|
562 | + if (!$payment->exists()) { |
|
563 | 563 | continue; |
564 | 564 | } |
565 | 565 | |
566 | 566 | // ... or belongs to a different subscription. |
567 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
567 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
568 | 568 | continue; |
569 | 569 | } |
570 | 570 | |
571 | 571 | echo '<tr>'; |
572 | 572 | |
573 | - foreach ( array_keys( $columns ) as $key ) { |
|
573 | + foreach (array_keys($columns) as $key) { |
|
574 | 574 | |
575 | 575 | echo "<td class='p-2 text-left'>"; |
576 | 576 | |
577 | - switch ( $key ) { |
|
577 | + switch ($key) { |
|
578 | 578 | |
579 | 579 | case 'total': |
580 | 580 | echo '<strong>'; |
581 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
581 | + wpinv_the_price($payment->get_total(), $payment->get_currency()); |
|
582 | 582 | echo '</strong>'; |
583 | 583 | break; |
584 | 584 | |
585 | 585 | case 'relationship': |
586 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
586 | + echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing'); |
|
587 | 587 | break; |
588 | 588 | |
589 | 589 | case 'date': |
590 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
590 | + echo esc_html(getpaid_format_date_value($payment->get_date_created())); |
|
591 | 591 | break; |
592 | 592 | |
593 | 593 | case 'status': |
594 | 594 | $status = $payment->get_status_nicename(); |
595 | - if ( is_admin() ) { |
|
595 | + if (is_admin()) { |
|
596 | 596 | $status = $payment->get_status_label_html(); |
597 | 597 | } |
598 | 598 | |
599 | - echo wp_kses_post( $status ); |
|
599 | + echo wp_kses_post($status); |
|
600 | 600 | break; |
601 | 601 | |
602 | 602 | case 'invoice': |
603 | - if ( ! is_admin() ) { |
|
603 | + if (!is_admin()) { |
|
604 | 604 | $link = $payment->get_view_url(); |
605 | 605 | } else { |
606 | - $link = get_edit_post_link( $payment->get_id() ); |
|
606 | + $link = get_edit_post_link($payment->get_id()); |
|
607 | 607 | } |
608 | 608 | |
609 | - $invoice = esc_html( $payment->get_number() ); |
|
609 | + $invoice = esc_html($payment->get_number()); |
|
610 | 610 | |
611 | - echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" ); |
|
611 | + echo wp_kses_post("<a href='" . ($link ? esc_url($link) : '#') . "'>$invoice</a>"); |
|
612 | 612 | break; |
613 | 613 | } |
614 | 614 | |
@@ -635,12 +635,12 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @param WPInv_Subscription $subscription |
637 | 637 | */ |
638 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
638 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
639 | 639 | |
640 | 640 | // Fetch the subscription group. |
641 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
641 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
642 | 642 | |
643 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
643 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | |
@@ -648,12 +648,12 @@ discard block |
||
648 | 648 | $columns = apply_filters( |
649 | 649 | 'getpaid_subscription_item_details_columns', |
650 | 650 | array( |
651 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
652 | - 'price' => __( 'Price', 'invoicing' ), |
|
653 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
654 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
651 | + 'item_name' => __('Item', 'invoicing'), |
|
652 | + 'price' => __('Price', 'invoicing'), |
|
653 | + 'tax' => __('Tax', 'invoicing'), |
|
654 | + 'discount' => __('Discount', 'invoicing'), |
|
655 | 655 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
656 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
656 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
657 | 657 | ), |
658 | 658 | $subscription |
659 | 659 | ); |
@@ -662,27 +662,27 @@ discard block |
||
662 | 662 | |
663 | 663 | $invoice = $subscription->get_parent_invoice(); |
664 | 664 | |
665 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
666 | - unset( $columns['tax'] ); |
|
665 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
666 | + unset($columns['tax']); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | $table_class = 'w-100 bg-white'; |
670 | 670 | |
671 | - if ( ! is_admin() ) { |
|
671 | + if (!is_admin()) { |
|
672 | 672 | $table_class = 'table table-bordered'; |
673 | 673 | } |
674 | 674 | |
675 | 675 | ?> |
676 | 676 | <div class="m-0" style="overflow: auto;"> |
677 | 677 | |
678 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
678 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
679 | 679 | |
680 | 680 | <thead> |
681 | 681 | <tr> |
682 | 682 | <?php |
683 | 683 | |
684 | - foreach ( $columns as $key => $label ) { |
|
685 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
684 | + foreach ($columns as $key => $label) { |
|
685 | + echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
686 | 686 | } |
687 | 687 | ?> |
688 | 688 | </tr> |
@@ -692,48 +692,48 @@ discard block |
||
692 | 692 | |
693 | 693 | <?php |
694 | 694 | |
695 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
695 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
696 | 696 | |
697 | 697 | echo '<tr>'; |
698 | 698 | |
699 | - foreach ( array_keys( $columns ) as $key ) { |
|
699 | + foreach (array_keys($columns) as $key) { |
|
700 | 700 | |
701 | 701 | $class = 'text-left'; |
702 | 702 | |
703 | 703 | echo "<td class='p-2 text-left'>"; |
704 | 704 | |
705 | - switch ( $key ) { |
|
705 | + switch ($key) { |
|
706 | 706 | |
707 | 707 | case 'item_name': |
708 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
709 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
708 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
709 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
710 | 710 | |
711 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
712 | - echo esc_html( $item_name ); |
|
711 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
712 | + echo esc_html($item_name); |
|
713 | 713 | } else { |
714 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
714 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | break; |
718 | 718 | |
719 | 719 | case 'price': |
720 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
720 | + wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
721 | 721 | break; |
722 | 722 | |
723 | 723 | case 'tax': |
724 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
724 | + wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
725 | 725 | break; |
726 | 726 | |
727 | 727 | case 'discount': |
728 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
728 | + wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'initial': |
732 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
732 | + wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
733 | 733 | break; |
734 | 734 | |
735 | 735 | case 'recurring': |
736 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
736 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'); |
|
737 | 737 | break; |
738 | 738 | |
739 | 739 | } |
@@ -746,24 +746,24 @@ discard block |
||
746 | 746 | |
747 | 747 | endforeach; |
748 | 748 | |
749 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
749 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
750 | 750 | |
751 | 751 | echo '<tr>'; |
752 | 752 | |
753 | - foreach ( array_keys( $columns ) as $key ) { |
|
753 | + foreach (array_keys($columns) as $key) { |
|
754 | 754 | |
755 | 755 | $class = 'text-left'; |
756 | 756 | |
757 | 757 | echo "<td class='p-2 text-left'>"; |
758 | 758 | |
759 | - switch ( $key ) { |
|
759 | + switch ($key) { |
|
760 | 760 | |
761 | 761 | case 'item_name': |
762 | - echo esc_html( $subscription_group_fee['name'] ); |
|
762 | + echo esc_html($subscription_group_fee['name']); |
|
763 | 763 | break; |
764 | 764 | |
765 | 765 | case 'price': |
766 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
766 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
767 | 767 | break; |
768 | 768 | |
769 | 769 | case 'tax': |
@@ -775,11 +775,11 @@ discard block |
||
775 | 775 | break; |
776 | 776 | |
777 | 777 | case 'initial': |
778 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
778 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
779 | 779 | break; |
780 | 780 | |
781 | 781 | case 'recurring': |
782 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
782 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'); |
|
783 | 783 | break; |
784 | 784 | |
785 | 785 | } |
@@ -808,12 +808,12 @@ discard block |
||
808 | 808 | * @param WPInv_Subscription $subscription |
809 | 809 | * @param bool $skip_current |
810 | 810 | */ |
811 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
811 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
812 | 812 | |
813 | 813 | // Fetch the subscription groups. |
814 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
814 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
815 | 815 | |
816 | - if ( empty( $subscription_groups ) ) { |
|
816 | + if (empty($subscription_groups)) { |
|
817 | 817 | return; |
818 | 818 | } |
819 | 819 | |
@@ -821,37 +821,37 @@ discard block |
||
821 | 821 | $columns = apply_filters( |
822 | 822 | 'getpaid_subscription_related_subscriptions_columns', |
823 | 823 | array( |
824 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
825 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
826 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
827 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
828 | - 'item' => __( 'Items', 'invoicing' ), |
|
829 | - 'status' => __( 'Status', 'invoicing' ), |
|
824 | + 'subscription' => __('Subscription', 'invoicing'), |
|
825 | + 'start_date' => __('Start Date', 'invoicing'), |
|
826 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
827 | + 'renewals' => __('Payments', 'invoicing'), |
|
828 | + 'item' => __('Items', 'invoicing'), |
|
829 | + 'status' => __('Status', 'invoicing'), |
|
830 | 830 | ), |
831 | 831 | $subscription |
832 | 832 | ); |
833 | 833 | |
834 | - if ( $subscription->get_status() == 'pending' ) { |
|
835 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
834 | + if ($subscription->get_status() == 'pending') { |
|
835 | + unset($columns['start_date'], $columns['renewal_date']); |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | $table_class = 'w-100 bg-white'; |
839 | 839 | |
840 | - if ( ! is_admin() ) { |
|
840 | + if (!is_admin()) { |
|
841 | 841 | $table_class = 'table table-bordered'; |
842 | 842 | } |
843 | 843 | |
844 | 844 | ?> |
845 | 845 | <div class="m-0" style="overflow: auto;"> |
846 | 846 | |
847 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
847 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
848 | 848 | |
849 | 849 | <thead> |
850 | 850 | <tr> |
851 | 851 | <?php |
852 | 852 | |
853 | - foreach ( $columns as $key => $label ) { |
|
854 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
853 | + foreach ($columns as $key => $label) { |
|
854 | + echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
855 | 855 | } |
856 | 856 | ?> |
857 | 857 | </tr> |
@@ -861,62 +861,62 @@ discard block |
||
861 | 861 | |
862 | 862 | <?php |
863 | 863 | |
864 | - foreach ( $subscription_groups as $subscription_group ) : |
|
864 | + foreach ($subscription_groups as $subscription_group) : |
|
865 | 865 | |
866 | 866 | // Do not list current subscription. |
867 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
867 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
868 | 868 | continue; |
869 | 869 | } |
870 | 870 | |
871 | 871 | // Ensure the subscription exists. |
872 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
872 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
873 | 873 | |
874 | - if ( ! $_suscription->exists() ) { |
|
874 | + if (!$_suscription->exists()) { |
|
875 | 875 | continue; |
876 | 876 | } |
877 | 877 | |
878 | 878 | echo '<tr>'; |
879 | 879 | |
880 | - foreach ( array_keys( $columns ) as $key ) { |
|
880 | + foreach (array_keys($columns) as $key) { |
|
881 | 881 | |
882 | 882 | $class = 'text-left'; |
883 | 883 | |
884 | 884 | echo "<td class='p-2 text-left'>"; |
885 | 885 | |
886 | - switch ( $key ) { |
|
886 | + switch ($key) { |
|
887 | 887 | |
888 | 888 | case 'status': |
889 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
889 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
890 | 890 | break; |
891 | 891 | |
892 | 892 | case 'item': |
893 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
894 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
893 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
894 | + echo wp_kses_post(implode(' | ', $markup)); |
|
895 | 895 | break; |
896 | 896 | |
897 | 897 | case 'renewals': |
898 | 898 | $max_bills = $_suscription->get_bill_times(); |
899 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
899 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
900 | 900 | break; |
901 | 901 | |
902 | 902 | case 'renewal_date': |
903 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
903 | + echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '—'; |
|
904 | 904 | break; |
905 | 905 | |
906 | 906 | case 'start_date': |
907 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
907 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html(getpaid_format_date_value($_suscription->get_date_created())); |
|
908 | 908 | break; |
909 | 909 | |
910 | 910 | case 'subscription': |
911 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
911 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
912 | 912 | printf( |
913 | 913 | '%1$s#%2$s%3$s', |
914 | - '<a href="' . esc_url( $url ) . '">', |
|
915 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
914 | + '<a href="' . esc_url($url) . '">', |
|
915 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
916 | 916 | '</a>' |
917 | 917 | ); |
918 | 918 | |
919 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
919 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription)); |
|
920 | 920 | break; |
921 | 921 | |
922 | 922 | } |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | * @return WPInv_Subscription[]|WPInv_Subscription|false |
14 | 14 | * @since 2.3.0 |
15 | 15 | */ |
16 | -function getpaid_get_invoice_subscriptions( $invoice ) { |
|
16 | +function getpaid_get_invoice_subscriptions($invoice) { |
|
17 | 17 | |
18 | 18 | // Retrieve subscription groups. |
19 | - $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice->get_id() ), 'subscription_id' ); |
|
19 | + $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice->get_id()), 'subscription_id'); |
|
20 | 20 | |
21 | 21 | // No subscription groups, normal subscription. |
22 | - if ( empty( $subscription_ids ) ) { |
|
23 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
22 | + if (empty($subscription_ids)) { |
|
23 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // Subscription groups. |
27 | - return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) ); |
|
27 | + return array_filter(array_map('getpaid_get_subscription', $subscription_ids)); |
|
28 | 28 | |
29 | 29 | } |
30 | 30 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @return array |
36 | 36 | * @since 2.3.0 |
37 | 37 | */ |
38 | -function getpaid_get_invoice_subscription_groups( $invoice_id ) { |
|
39 | - $subscription_groups = get_post_meta( $invoice_id, 'getpaid_subscription_groups', true ); |
|
40 | - return empty( $subscription_groups ) ? array() : $subscription_groups; |
|
38 | +function getpaid_get_invoice_subscription_groups($invoice_id) { |
|
39 | + $subscription_groups = get_post_meta($invoice_id, 'getpaid_subscription_groups', true); |
|
40 | + return empty($subscription_groups) ? array() : $subscription_groups; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @return array|false |
49 | 49 | * @since 2.3.0 |
50 | 50 | */ |
51 | -function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) { |
|
52 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id ); |
|
53 | - $matching_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
54 | - return reset( $matching_group ); |
|
51 | +function getpaid_get_invoice_subscription_group($invoice_id, $subscription_id) { |
|
52 | + $subscription_groups = getpaid_get_invoice_subscription_groups($invoice_id); |
|
53 | + $matching_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
54 | + return reset($matching_group); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @since 2.3.0 |
62 | 62 | * @return WPInv_Subscription|false |
63 | 63 | */ |
64 | -function getpaid_get_subscription( $subscription ) { |
|
64 | +function getpaid_get_subscription($subscription) { |
|
65 | 65 | |
66 | - if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
67 | - $subscription = new WPInv_Subscription( $subscription ); |
|
66 | + if (!is_a($subscription, 'WPInv_Subscription')) { |
|
67 | + $subscription = new WPInv_Subscription($subscription); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return $subscription->exists() ? $subscription : false; |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query |
81 | 81 | */ |
82 | -function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
|
82 | +function getpaid_get_subscriptions($args = array(), $return = 'results') { |
|
83 | 83 | |
84 | 84 | // Do not retrieve all fields if we just want the count. |
85 | - if ( 'count' == $return ) { |
|
85 | + if ('count' == $return) { |
|
86 | 86 | $args['fields'] = 'id'; |
87 | 87 | $args['number'] = 1; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Do not count all matches if we just want the results. |
91 | - if ( 'results' == $return ) { |
|
91 | + if ('results' == $return) { |
|
92 | 92 | $args['count_total'] = false; |
93 | 93 | } |
94 | 94 | |
95 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
95 | + $query = new GetPaid_Subscriptions_Query($args); |
|
96 | 96 | |
97 | - if ( 'results' == $return ) { |
|
97 | + if ('results' == $return) { |
|
98 | 98 | return $query->get_results(); |
99 | 99 | } |
100 | 100 | |
101 | - if ( 'count' == $return ) { |
|
101 | + if ('count' == $return) { |
|
102 | 102 | return $query->get_total(); |
103 | 103 | } |
104 | 104 | |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | return apply_filters( |
116 | 116 | 'getpaid_get_subscription_statuses', |
117 | 117 | array( |
118 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
119 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
120 | - 'active' => __( 'Active', 'invoicing' ), |
|
121 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
122 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
123 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
124 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
118 | + 'pending' => __('Pending', 'invoicing'), |
|
119 | + 'trialling' => __('Trialing', 'invoicing'), |
|
120 | + 'active' => __('Active', 'invoicing'), |
|
121 | + 'failing' => __('Failing', 'invoicing'), |
|
122 | + 'expired' => __('Expired', 'invoicing'), |
|
123 | + 'completed' => __('Complete', 'invoicing'), |
|
124 | + 'cancelled' => __('Cancelled', 'invoicing'), |
|
125 | 125 | ) |
126 | 126 | ); |
127 | 127 | |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return string |
134 | 134 | */ |
135 | -function getpaid_get_subscription_status_label( $status ) { |
|
135 | +function getpaid_get_subscription_status_label($status) { |
|
136 | 136 | $statuses = getpaid_get_subscription_statuses(); |
137 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
137 | + return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_subscription_status_counts( $args = array() ) { |
|
167 | +function getpaid_get_subscription_status_counts($args = array()) { |
|
168 | 168 | |
169 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
169 | + $statuses = array_keys(getpaid_get_subscription_statuses()); |
|
170 | 170 | $counts = array(); |
171 | 171 | |
172 | - foreach ( $statuses as $status ) { |
|
173 | - $_args = wp_parse_args( "status=$status", $args ); |
|
174 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
172 | + foreach ($statuses as $status) { |
|
173 | + $_args = wp_parse_args("status=$status", $args); |
|
174 | + $counts[$status] = getpaid_get_subscriptions($_args, 'count'); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $counts; |
@@ -190,23 +190,23 @@ discard block |
||
190 | 190 | array( |
191 | 191 | |
192 | 192 | 'day' => array( |
193 | - 'singular' => __( '%s day', 'invoicing' ), |
|
194 | - 'plural' => __( '%d days', 'invoicing' ), |
|
193 | + 'singular' => __('%s day', 'invoicing'), |
|
194 | + 'plural' => __('%d days', 'invoicing'), |
|
195 | 195 | ), |
196 | 196 | |
197 | 197 | 'week' => array( |
198 | - 'singular' => __( '%s week', 'invoicing' ), |
|
199 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
198 | + 'singular' => __('%s week', 'invoicing'), |
|
199 | + 'plural' => __('%d weeks', 'invoicing'), |
|
200 | 200 | ), |
201 | 201 | |
202 | 202 | 'month' => array( |
203 | - 'singular' => __( '%s month', 'invoicing' ), |
|
204 | - 'plural' => __( '%d months', 'invoicing' ), |
|
203 | + 'singular' => __('%s month', 'invoicing'), |
|
204 | + 'plural' => __('%d months', 'invoicing'), |
|
205 | 205 | ), |
206 | 206 | |
207 | 207 | 'year' => array( |
208 | - 'singular' => __( '%s year', 'invoicing' ), |
|
209 | - 'plural' => __( '%d years', 'invoicing' ), |
|
208 | + 'singular' => __('%s year', 'invoicing'), |
|
209 | + 'plural' => __('%d years', 'invoicing'), |
|
210 | 210 | ), |
211 | 211 | |
212 | 212 | ) |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param string $trial_period |
221 | 221 | * @return int |
222 | 222 | */ |
223 | -function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
|
224 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
223 | +function getpaid_get_subscription_trial_period_interval($trial_period) { |
|
224 | + return (int) preg_replace('/[^0-9]/', '', $trial_period); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param string $trial_period |
231 | 231 | * @return string |
232 | 232 | */ |
233 | -function getpaid_get_subscription_trial_period_period( $trial_period ) { |
|
234 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
233 | +function getpaid_get_subscription_trial_period_period($trial_period) { |
|
234 | + return preg_replace('/[^a-z]/', '', strtolower($trial_period)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param int $interval |
242 | 242 | * @return string |
243 | 243 | */ |
244 | -function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
|
245 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
246 | - return strtolower( sanitize_text_field( $label ) ); |
|
244 | +function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') { |
|
245 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix); |
|
246 | + return strtolower(sanitize_text_field($label)); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -252,19 +252,19 @@ discard block |
||
252 | 252 | * @param string $period |
253 | 253 | * @return string |
254 | 254 | */ |
255 | -function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
|
255 | +function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') { |
|
256 | 256 | |
257 | 257 | $periods = getpaid_get_subscription_periods(); |
258 | - $period = strtolower( $period ); |
|
258 | + $period = strtolower($period); |
|
259 | 259 | |
260 | - if ( isset( $periods[ $period ] ) ) { |
|
261 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
260 | + if (isset($periods[$period])) { |
|
261 | + return sprintf($periods[$period]['singular'], $singular_prefix); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | // Backwards compatibility. |
265 | - foreach ( $periods as $key => $data ) { |
|
266 | - if ( strpos( $key, $period ) === 0 ) { |
|
267 | - return sprintf( $data['singular'], $singular_prefix ); |
|
265 | + foreach ($periods as $key => $data) { |
|
266 | + if (strpos($key, $period) === 0) { |
|
267 | + return sprintf($data['singular'], $singular_prefix); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | * @param int $interval |
280 | 280 | * @return string |
281 | 281 | */ |
282 | -function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
|
282 | +function getpaid_get_plural_subscription_period_label($period, $interval) { |
|
283 | 283 | |
284 | 284 | $periods = getpaid_get_subscription_periods(); |
285 | - $period = strtolower( $period ); |
|
285 | + $period = strtolower($period); |
|
286 | 286 | |
287 | - if ( isset( $periods[ $period ] ) ) { |
|
288 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
287 | + if (isset($periods[$period])) { |
|
288 | + return sprintf($periods[$period]['plural'], $interval); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | // Backwards compatibility. |
292 | - foreach ( $periods as $key => $data ) { |
|
293 | - if ( strpos( $key, $period ) === 0 ) { |
|
294 | - return sprintf( $data['plural'], $interval ); |
|
292 | + foreach ($periods as $key => $data) { |
|
293 | + if (strpos($key, $period) === 0) { |
|
294 | + return sprintf($data['plural'], $interval); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
@@ -305,33 +305,33 @@ discard block |
||
305 | 305 | * @param WPInv_Subscription $subscription |
306 | 306 | * @return string |
307 | 307 | */ |
308 | -function getpaid_get_formatted_subscription_amount( $subscription ) { |
|
308 | +function getpaid_get_formatted_subscription_amount($subscription) { |
|
309 | 309 | |
310 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
311 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
312 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
310 | + $initial = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
311 | + $recurring = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
312 | + $period = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
313 | 313 | $bill_times = $subscription->get_bill_times(); |
314 | 314 | $bill_times_less = $bill_times - 1; |
315 | 315 | |
316 | - if ( ! empty( $bill_times ) ) { |
|
316 | + if (!empty($bill_times)) { |
|
317 | 317 | $bill_times = $subscription->get_frequency() * $bill_times; |
318 | - $bill_times_less = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times - $subscription->get_frequency() ); |
|
319 | - $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times ); |
|
318 | + $bill_times_less = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times - $subscription->get_frequency()); |
|
319 | + $bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | // Trial periods. |
323 | - if ( $subscription->has_trial_period() ) { |
|
323 | + if ($subscription->has_trial_period()) { |
|
324 | 324 | |
325 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
326 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
325 | + $trial_period = getpaid_get_subscription_trial_period_period($subscription->get_trial_period()); |
|
326 | + $trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period()); |
|
327 | 327 | |
328 | - if ( empty( $bill_times ) ) { |
|
328 | + if (empty($bill_times)) { |
|
329 | 329 | |
330 | 330 | return sprintf( |
331 | 331 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
332 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
332 | + _x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
333 | 333 | $initial, |
334 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
334 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
335 | 335 | $recurring, |
336 | 336 | $period |
337 | 337 | ); |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | |
341 | 341 | return sprintf( |
342 | 342 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times |
343 | - _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
343 | + _x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
344 | 344 | $initial, |
345 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
345 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
346 | 346 | $recurring, |
347 | 347 | $period, |
348 | 348 | $bill_times |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | |
351 | 351 | } |
352 | 352 | |
353 | - if ( $initial != $recurring ) { |
|
353 | + if ($initial != $recurring) { |
|
354 | 354 | |
355 | - if ( empty( $bill_times ) ) { |
|
355 | + if (empty($bill_times)) { |
|
356 | 356 | |
357 | 357 | return sprintf( |
358 | 358 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
359 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
359 | + _x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'), |
|
360 | 360 | $initial, |
361 | 361 | $recurring, |
362 | 362 | $period |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | return sprintf( |
368 | 368 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times |
369 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ), |
|
369 | + _x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'), |
|
370 | 370 | $initial, |
371 | 371 | $recurring, |
372 | 372 | $period, |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | |
376 | 376 | } |
377 | 377 | |
378 | - if ( empty( $bill_times ) ) { |
|
378 | + if (empty($bill_times)) { |
|
379 | 379 | |
380 | 380 | return sprintf( |
381 | 381 | // translators: $1: is the recurring amount, $2: is the recurring period |
382 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
382 | + _x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
383 | 383 | $initial, |
384 | 384 | $period |
385 | 385 | ); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | |
389 | 389 | return sprintf( |
390 | 390 | // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period |
391 | - _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
391 | + _x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
392 | 392 | $bill_times, |
393 | 393 | $initial, |
394 | 394 | $period |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | * @param WPInv_Invoice $invoice |
403 | 403 | * @return WPInv_Subscription|false |
404 | 404 | */ |
405 | -function getpaid_get_invoice_subscription( $invoice ) { |
|
406 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
405 | +function getpaid_get_invoice_subscription($invoice) { |
|
406 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @param WPInv_Invoice $invoice |
413 | 413 | */ |
414 | -function getpaid_activate_invoice_subscription( $invoice ) { |
|
415 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
416 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
414 | +function getpaid_activate_invoice_subscription($invoice) { |
|
415 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
416 | + if (is_a($subscription, 'WPInv_Subscription')) { |
|
417 | 417 | $subscription->activate(); |
418 | 418 | } |
419 | 419 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @return WPInv_Subscriptions |
425 | 425 | */ |
426 | 426 | function getpaid_subscriptions() { |
427 | - return getpaid()->get( 'subscriptions' ); |
|
427 | + return getpaid()->get('subscriptions'); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | * @since 2.3.0 |
434 | 434 | * @return WPInv_Subscription|bool |
435 | 435 | */ |
436 | -function wpinv_get_invoice_subscription( $invoice ) { |
|
436 | +function wpinv_get_invoice_subscription($invoice) { |
|
437 | 437 | |
438 | 438 | // Retrieve the invoice. |
439 | - $invoice = new WPInv_Invoice( $invoice ); |
|
439 | + $invoice = new WPInv_Invoice($invoice); |
|
440 | 440 | |
441 | 441 | // Ensure it is a recurring invoice. |
442 | - if ( ! $invoice->is_recurring() ) { |
|
442 | + if (!$invoice->is_recurring()) { |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | ) |
452 | 452 | ); |
453 | 453 | |
454 | - return empty( $subscription ) ? false : $subscription[0]; |
|
454 | + return empty($subscription) ? false : $subscription[0]; |
|
455 | 455 | |
456 | 456 | } |
457 | 457 | |
@@ -466,50 +466,50 @@ discard block |
||
466 | 466 | * @param GetPaid_Form_Item|WPInv_Item $cart_item |
467 | 467 | * @return string |
468 | 468 | */ |
469 | -function getpaid_get_recurring_item_key( $cart_item ) { |
|
469 | +function getpaid_get_recurring_item_key($cart_item) { |
|
470 | 470 | |
471 | 471 | $cart_key = 'renews_'; |
472 | 472 | $interval = $cart_item->get_recurring_interval(); |
473 | - $period = $cart_item->get_recurring_period( true ); |
|
473 | + $period = $cart_item->get_recurring_period(true); |
|
474 | 474 | $length = $cart_item->get_recurring_limit() * $interval; |
475 | - $trial_period = $cart_item->get_trial_period( true ); |
|
475 | + $trial_period = $cart_item->get_trial_period(true); |
|
476 | 476 | $trial_length = $cart_item->get_trial_interval(); |
477 | 477 | |
478 | 478 | // First start with the billing interval and period |
479 | - switch ( $interval ) { |
|
479 | + switch ($interval) { |
|
480 | 480 | case 1: |
481 | - if ( 'day' == $period ) { |
|
481 | + if ('day' == $period) { |
|
482 | 482 | $cart_key .= 'daily'; |
483 | 483 | } else { |
484 | - $cart_key .= sprintf( '%sly', $period ); |
|
484 | + $cart_key .= sprintf('%sly', $period); |
|
485 | 485 | } |
486 | 486 | break; |
487 | 487 | case 2: |
488 | - $cart_key .= sprintf( 'every_2nd_%s', $period ); |
|
488 | + $cart_key .= sprintf('every_2nd_%s', $period); |
|
489 | 489 | break; |
490 | 490 | case 3: |
491 | - $cart_key .= sprintf( 'every_3rd_%s', $period ); |
|
491 | + $cart_key .= sprintf('every_3rd_%s', $period); |
|
492 | 492 | break; |
493 | 493 | default: |
494 | - $cart_key .= sprintf( 'every_%dth_%s', $interval, $period ); |
|
494 | + $cart_key .= sprintf('every_%dth_%s', $interval, $period); |
|
495 | 495 | break; |
496 | 496 | } |
497 | 497 | |
498 | 498 | // Maybe add the optional maximum billing periods... |
499 | - if ( $length > 0 ) { |
|
499 | + if ($length > 0) { |
|
500 | 500 | $cart_key .= '_for_'; |
501 | - $cart_key .= sprintf( '%d_%s', $length, $period ); |
|
502 | - if ( $length > 1 ) { |
|
501 | + $cart_key .= sprintf('%d_%s', $length, $period); |
|
502 | + if ($length > 1) { |
|
503 | 503 | $cart_key .= 's'; |
504 | 504 | } |
505 | 505 | } |
506 | 506 | |
507 | 507 | // And an optional free trial. |
508 | - if ( $cart_item->has_free_trial() ) { |
|
509 | - $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period ); |
|
508 | + if ($cart_item->has_free_trial()) { |
|
509 | + $cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period); |
|
510 | 510 | } |
511 | 511 | |
512 | - return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item ); |
|
512 | + return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
@@ -518,14 +518,14 @@ discard block |
||
518 | 518 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
519 | 519 | * @return array |
520 | 520 | */ |
521 | -function getpaid_get_subscription_groups( $invoice ) { |
|
521 | +function getpaid_get_subscription_groups($invoice) { |
|
522 | 522 | |
523 | 523 | // Generate subscription groups. |
524 | 524 | $subscription_groups = array(); |
525 | - foreach ( $invoice->get_items() as $item ) { |
|
525 | + foreach ($invoice->get_items() as $item) { |
|
526 | 526 | |
527 | - if ( $item->is_recurring() ) { |
|
528 | - $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item; |
|
527 | + if ($item->is_recurring()) { |
|
528 | + $subscription_groups[getpaid_get_recurring_item_key($item)][] = $item; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
542 | 542 | * @return array |
543 | 543 | */ |
544 | -function getpaid_calculate_subscription_totals( $invoice ) { |
|
544 | +function getpaid_calculate_subscription_totals($invoice) { |
|
545 | 545 | |
546 | 546 | // Generate subscription groups. |
547 | - $subscription_groups = getpaid_get_subscription_groups( $invoice ); |
|
547 | + $subscription_groups = getpaid_get_subscription_groups($invoice); |
|
548 | 548 | |
549 | 549 | // Now let's calculate the totals for each group of subscriptions |
550 | 550 | $subscription_totals = array(); |
551 | 551 | |
552 | - foreach ( $subscription_groups as $subscription_key => $items ) { |
|
552 | + foreach ($subscription_groups as $subscription_key => $items) { |
|
553 | 553 | |
554 | - if ( empty( $subscription_totals[ $subscription_key ] ) ) { |
|
554 | + if (empty($subscription_totals[$subscription_key])) { |
|
555 | 555 | |
556 | - $subscription_totals[ $subscription_key ] = array( |
|
556 | + $subscription_totals[$subscription_key] = array( |
|
557 | 557 | 'initial_total' => 0, |
558 | 558 | 'recurring_total' => 0, |
559 | 559 | 'items' => array(), |
@@ -566,33 +566,33 @@ discard block |
||
566 | 566 | * Get the totals of the group. |
567 | 567 | * @var GetPaid_Form_Item $item |
568 | 568 | */ |
569 | - foreach ( $items as $item ) { |
|
569 | + foreach ($items as $item) { |
|
570 | 570 | |
571 | - $subscription_totals[ $subscription_key ]['items'][ $item->get_id() ] = $item->prepare_data_for_saving(); |
|
572 | - $subscription_totals[ $subscription_key ]['item_id'] = $item->get_id(); |
|
573 | - $subscription_totals[ $subscription_key ]['period'] = $item->get_recurring_period( true ); |
|
574 | - $subscription_totals[ $subscription_key ]['interval'] = $item->get_recurring_interval(); |
|
575 | - $subscription_totals[ $subscription_key ]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
576 | - $subscription_totals[ $subscription_key ]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
577 | - $subscription_totals[ $subscription_key ]['recurring_limit'] = $item->get_recurring_limit(); |
|
571 | + $subscription_totals[$subscription_key]['items'][$item->get_id()] = $item->prepare_data_for_saving(); |
|
572 | + $subscription_totals[$subscription_key]['item_id'] = $item->get_id(); |
|
573 | + $subscription_totals[$subscription_key]['period'] = $item->get_recurring_period(true); |
|
574 | + $subscription_totals[$subscription_key]['interval'] = $item->get_recurring_interval(); |
|
575 | + $subscription_totals[$subscription_key]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
576 | + $subscription_totals[$subscription_key]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
577 | + $subscription_totals[$subscription_key]['recurring_limit'] = $item->get_recurring_limit(); |
|
578 | 578 | |
579 | 579 | // Calculate the next renewal date. |
580 | - $period = $item->get_recurring_period( true ); |
|
580 | + $period = $item->get_recurring_period(true); |
|
581 | 581 | $interval = $item->get_recurring_interval(); |
582 | 582 | |
583 | 583 | // If the subscription item has a trial period... |
584 | - if ( $item->has_free_trial() ) { |
|
585 | - $period = $item->get_trial_period( true ); |
|
584 | + if ($item->has_free_trial()) { |
|
585 | + $period = $item->get_trial_period(true); |
|
586 | 586 | $interval = $item->get_trial_interval(); |
587 | - $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period; |
|
587 | + $subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period; |
|
588 | 588 | } |
589 | 589 | |
590 | - $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) ); |
|
590 | + $subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp'))); |
|
591 | 591 | |
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | - return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice ); |
|
595 | + return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -601,18 +601,18 @@ discard block |
||
601 | 601 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
602 | 602 | * @return array |
603 | 603 | */ |
604 | -function getpaid_should_group_subscriptions( $invoice ) { |
|
604 | +function getpaid_should_group_subscriptions($invoice) { |
|
605 | 605 | |
606 | 606 | $recurring_items = 0; |
607 | 607 | |
608 | - foreach ( $invoice->get_items() as $item ) { |
|
608 | + foreach ($invoice->get_items() as $item) { |
|
609 | 609 | |
610 | - if ( $item->is_recurring() ) { |
|
611 | - $recurring_items ++; |
|
610 | + if ($item->is_recurring()) { |
|
611 | + $recurring_items++; |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | - return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice ); |
|
615 | + return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | * @param int|false $subscription_id |
623 | 623 | * @return int |
624 | 624 | */ |
625 | -function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) { |
|
625 | +function getpaid_count_subscription_invoices($parent_invoice_id, $subscription_id = false) { |
|
626 | 626 | global $wpdb; |
627 | 627 | |
628 | 628 | $parent_invoice_id = (int) $parent_invoice_id; |
629 | 629 | |
630 | - if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) { |
|
630 | + if (false === $subscription_id || !(bool) get_post_meta($parent_invoice_id, '_wpinv_subscription_id', true)) { |
|
631 | 631 | |
632 | 632 | return (int) $wpdb->get_var( |
633 | 633 | $wpdb->prepare( |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | |
650 | 650 | $count = 0; |
651 | 651 | |
652 | - foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) { |
|
652 | + foreach (wp_parse_id_list($invoice_ids) as $invoice_id) { |
|
653 | 653 | |
654 | - if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) { |
|
655 | - $count ++; |
|
654 | + if ($invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta($invoice_id, '_wpinv_subscription_id', true)) { |
|
655 | + $count++; |
|
656 | 656 | continue; |
657 | 657 | } |
658 | 658 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports Class. |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | * |
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
20 | + add_action('admin_menu', array($this, 'register_reports_page'), 20); |
|
21 | + add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab')); |
|
22 | + add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab')); |
|
23 | + add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph')); |
|
24 | + add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices')); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | add_submenu_page( |
35 | 35 | 'wpinv', |
36 | - __( 'Reports', 'invoicing' ), |
|
37 | - __( 'Reports', 'invoicing' ), |
|
36 | + __('Reports', 'invoicing'), |
|
37 | + __('Reports', 'invoicing'), |
|
38 | 38 | wpinv_get_capability(), |
39 | 39 | 'wpinv-reports', |
40 | - array( $this, 'display_reports_page' ) |
|
40 | + array($this, 'display_reports_page') |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | } |
@@ -50,46 +50,46 @@ discard block |
||
50 | 50 | |
51 | 51 | // Prepare variables. |
52 | 52 | $tabs = $this->get_tabs(); |
53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
53 | + $current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports'; |
|
54 | + $current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports'; |
|
55 | 55 | |
56 | 56 | // Display the current tab. |
57 | 57 | ?> |
58 | 58 | |
59 | 59 | <div class="wrap"> |
60 | 60 | |
61 | - <h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
|
61 | + <h1><?php echo esc_html($tabs[$current_tab]); ?></h1> |
|
62 | 62 | |
63 | 63 | <nav class="nav-tab-wrapper"> |
64 | 64 | |
65 | 65 | <?php |
66 | - foreach ( $tabs as $key => $label ) { |
|
66 | + foreach ($tabs as $key => $label) { |
|
67 | 67 | |
68 | - $key = sanitize_key( $key ); |
|
69 | - $label = esc_html( $label ); |
|
68 | + $key = sanitize_key($key); |
|
69 | + $label = esc_html($label); |
|
70 | 70 | $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab '; |
71 | 71 | $url = esc_url( |
72 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
72 | + add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports')) |
|
73 | 73 | ); |
74 | 74 | |
75 | - echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" ); |
|
75 | + echo wp_kses_post("\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>"); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | ?> |
79 | 79 | |
80 | 80 | </nav> |
81 | 81 | |
82 | - <div class="bsui <?php echo esc_attr( $current_tab ); ?>"> |
|
83 | - <?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?> |
|
82 | + <div class="bsui <?php echo esc_attr($current_tab); ?>"> |
|
83 | + <?php do_action("wpinv_reports_tab_{$current_tab}"); ?> |
|
84 | 84 | </div> |
85 | 85 | |
86 | 86 | </div> |
87 | 87 | <?php |
88 | 88 | |
89 | 89 | // Wordfence loads an unsupported version of chart js on our page. |
90 | - wp_deregister_style( 'chart-js' ); |
|
91 | - wp_deregister_script( 'chart-js' ); |
|
92 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true ); |
|
90 | + wp_deregister_style('chart-js'); |
|
91 | + wp_deregister_script('chart-js'); |
|
92 | + wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | public function get_tabs() { |
102 | 102 | |
103 | 103 | $tabs = array( |
104 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
105 | - 'export' => __( 'Export', 'invoicing' ), |
|
104 | + 'reports' => __('Reports', 'invoicing'), |
|
105 | + 'export' => __('Export', 'invoicing'), |
|
106 | 106 | ); |
107 | 107 | |
108 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
108 | + return apply_filters('getpaid_report_tabs', $tabs); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @param array $args |
137 | 137 | */ |
138 | - public function download_graph( $args ) { |
|
138 | + public function download_graph($args) { |
|
139 | 139 | |
140 | - if ( ! empty( $args['graph'] ) ) { |
|
140 | + if (!empty($args['graph'])) { |
|
141 | 141 | $downloader = new GetPaid_Graph_Downloader(); |
142 | - $downloader->download( $args['graph'] ); |
|
142 | + $downloader->download($args['graph']); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | } |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @param array $args |
151 | 151 | */ |
152 | - public function export_invoices( $args ) { |
|
152 | + public function export_invoices($args) { |
|
153 | 153 | |
154 | - if ( ! empty( $args['post_type'] ) ) { |
|
154 | + if (!empty($args['post_type'])) { |
|
155 | 155 | |
156 | - if ( 'subscriptions' === $args['post_type'] ) { |
|
156 | + if ('subscriptions' === $args['post_type']) { |
|
157 | 157 | $downloader = new GetPaid_Subscription_Exporter(); |
158 | 158 | } else { |
159 | 159 | $downloader = new GetPaid_Invoice_Exporter(); |
160 | 160 | } |
161 | 161 | |
162 | - $downloader->export( $args['post_type'], $args ); |
|
162 | + $downloader->export($args['post_type'], $args); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Daily maintenance class. |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | public function __construct() { |
19 | 19 | |
20 | 20 | // Clear deprecated events. |
21 | - add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) ); |
|
21 | + add_action('wp', array($this, 'maybe_clear_deprecated_events')); |
|
22 | 22 | |
23 | 23 | // (Maybe) schedule a cron that runs daily. |
24 | - add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) ); |
|
24 | + add_action('wp', array($this, 'maybe_create_scheduled_event')); |
|
25 | 25 | |
26 | 26 | // Fired everyday at 7 a.m (this might vary for sites with few visitors) |
27 | - add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) ); |
|
28 | - add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) ); |
|
29 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) ); |
|
30 | - add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) ); |
|
31 | - add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) ); |
|
27 | + add_action('getpaid_daily_maintenance', array($this, 'log_cron_run')); |
|
28 | + add_action('getpaid_daily_maintenance', array($this, 'backwards_compat')); |
|
29 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_expire_subscriptions')); |
|
30 | + add_action('getpaid_daily_maintenance', array($this, 'check_renewing_subscriptions')); |
|
31 | + add_action('getpaid_daily_maintenance', array($this, 'maybe_update_geoip_databases')); |
|
32 | 32 | |
33 | 33 | } |
34 | 34 | |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function maybe_create_scheduled_event() { |
40 | 40 | |
41 | - if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) { |
|
42 | - $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) ); |
|
43 | - wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' ); |
|
41 | + if (!wp_next_scheduled('getpaid_daily_maintenance')) { |
|
42 | + $timestamp = strtotime('tomorrow 07:00:00', current_time('timestamp')); |
|
43 | + wp_schedule_event($timestamp, 'daily', 'getpaid_daily_maintenance'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function maybe_clear_deprecated_events() { |
53 | 53 | |
54 | - if ( ! get_option( 'wpinv_cleared_old_events' ) ) { |
|
55 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
56 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' ); |
|
57 | - update_option( 'wpinv_cleared_old_events', 1 ); |
|
54 | + if (!get_option('wpinv_cleared_old_events')) { |
|
55 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
56 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_daily'); |
|
57 | + update_option('wpinv_cleared_old_events', 1); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | */ |
66 | 66 | public function backwards_compat() { |
67 | - do_action( 'wpinv_register_schedule_event_daily' ); |
|
67 | + do_action('wpinv_register_schedule_event_daily'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,28 +74,28 @@ discard block |
||
74 | 74 | public function check_renewing_subscriptions() { |
75 | 75 | |
76 | 76 | // Fetch subscriptions that expire today. |
77 | - $args = array( |
|
77 | + $args = array( |
|
78 | 78 | 'number' => -1, |
79 | 79 | 'count_total' => false, |
80 | 80 | 'status' => 'trialling active', |
81 | 81 | 'date_expires_query' => array( |
82 | 82 | array( |
83 | - 'year' => gmdate( 'Y' ), |
|
84 | - 'month' => gmdate( 'n' ), |
|
85 | - 'day' => gmdate( 'j' ), |
|
83 | + 'year' => gmdate('Y'), |
|
84 | + 'month' => gmdate('n'), |
|
85 | + 'day' => gmdate('j'), |
|
86 | 86 | 'compare' => '=', |
87 | 87 | ), |
88 | 88 | ), |
89 | 89 | ); |
90 | 90 | |
91 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
91 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
92 | 92 | |
93 | - foreach ( $subscriptions->get_results() as $subscription ) { |
|
93 | + foreach ($subscriptions->get_results() as $subscription) { |
|
94 | 94 | /** @var WPInv_Subscription $subscription */ |
95 | - if ( $subscription->is_last_renewal() ) { |
|
95 | + if ($subscription->is_last_renewal()) { |
|
96 | 96 | $subscription->complete(); |
97 | 97 | } else { |
98 | - do_action( 'getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice() ); |
|
98 | + do_action('getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice()); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | public function maybe_expire_subscriptions() { |
108 | 108 | |
109 | 109 | // Fetch expired subscriptions (skips those that expire today). |
110 | - $args = array( |
|
110 | + $args = array( |
|
111 | 111 | 'number' => -1, |
112 | 112 | 'count_total' => false, |
113 | 113 | 'status' => 'trialling active failing cancelled', |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | ), |
118 | 118 | ); |
119 | 119 | |
120 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
120 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
121 | 121 | |
122 | - foreach ( $subscriptions->get_results() as $subscription ) { |
|
123 | - if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) { |
|
124 | - $subscription->set_status( 'expired' ); |
|
122 | + foreach ($subscriptions->get_results() as $subscription) { |
|
123 | + if (apply_filters('getpaid_daily_maintenance_should_expire_subscription', false, $subscription)) { |
|
124 | + $subscription->set_status('expired'); |
|
125 | 125 | $subscription->save(); |
126 | 126 | } |
127 | 127 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * |
134 | 134 | */ |
135 | 135 | public function log_cron_run() { |
136 | - wpinv_error_log( 'GetPaid Daily Cron', false ); |
|
136 | + wpinv_error_log('GetPaid Daily Cron', false); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | * |
142 | 142 | */ |
143 | 143 | public function maybe_update_geoip_databases() { |
144 | - $updated = get_transient( 'getpaid_updated_geoip_databases' ); |
|
144 | + $updated = get_transient('getpaid_updated_geoip_databases'); |
|
145 | 145 | |
146 | - if ( false === $updated ) { |
|
147 | - set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS ); |
|
148 | - do_action( 'getpaid_update_geoip_databases' ); |
|
146 | + if (false === $updated) { |
|
147 | + set_transient('getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS); |
|
148 | + do_action('getpaid_update_geoip_databases'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Manual Payment Gateway class. |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | public function __construct() { |
47 | 47 | parent::__construct(); |
48 | 48 | |
49 | - $this->title = __( 'Test Gateway', 'invoicing' ); |
|
50 | - $this->method_title = __( 'Test Gateway', 'invoicing' ); |
|
49 | + $this->title = __('Test Gateway', 'invoicing'); |
|
50 | + $this->method_title = __('Test Gateway', 'invoicing'); |
|
51 | 51 | |
52 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
52 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -61,32 +61,32 @@ discard block |
||
61 | 61 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
62 | 62 | * @return array |
63 | 63 | */ |
64 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
64 | + public function process_payment($invoice, $submission_data, $submission) { |
|
65 | 65 | |
66 | 66 | // Mark it as paid. |
67 | 67 | $invoice->mark_paid(); |
68 | 68 | |
69 | 69 | // (Maybe) activate subscriptions. |
70 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
70 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
71 | 71 | |
72 | - if ( ! empty( $subscriptions ) ) { |
|
73 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
72 | + if (!empty($subscriptions)) { |
|
73 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
74 | 74 | |
75 | - foreach ( $subscriptions as $subscription ) { |
|
76 | - if ( $subscription->exists() ) { |
|
77 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
78 | - $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
75 | + foreach ($subscriptions as $subscription) { |
|
76 | + if ($subscription->exists()) { |
|
77 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
78 | + $expiry = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
79 | 79 | |
80 | - $subscription->set_next_renewal_date( $expiry ); |
|
81 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
82 | - $subscription->set_profile_id( $invoice->generate_key( 'manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
80 | + $subscription->set_next_renewal_date($expiry); |
|
81 | + $subscription->set_date_created(current_time('mysql')); |
|
82 | + $subscription->set_profile_id($invoice->generate_key('manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
83 | 83 | $subscription->activate(); |
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | 88 | // Send to the success page. |
89 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
89 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param WPInv_Subscription $subscription |
98 | 98 | */ |
99 | - public function maybe_renew_subscription( $subscription, $parent_invoice ) { |
|
99 | + public function maybe_renew_subscription($subscription, $parent_invoice) { |
|
100 | 100 | // Ensure its our subscription && it's active. |
101 | - if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
101 | + if (!empty($parent_invoice) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status('active trialling')) { |
|
102 | 102 | // Renew the subscription. |
103 | 103 | $subscription->add_payment( |
104 | 104 | array( |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | * @param GetPaid_Form_Item[] $items |
119 | 119 | * @return WPInv_Invoice |
120 | 120 | */ |
121 | - public function process_addons( $invoice, $items ) { |
|
121 | + public function process_addons($invoice, $items) { |
|
122 | 122 | |
123 | - foreach ( $items as $item ) { |
|
124 | - $invoice->add_item( $item ); |
|
123 | + foreach ($items as $item) { |
|
124 | + $invoice->add_item($item); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $invoice->recalculate_total(); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Authorize.net Payment Gateway class. |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @var array |
63 | 63 | */ |
64 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
64 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * URL to view a transaction. |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function __construct() { |
77 | 77 | |
78 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
79 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
80 | - $this->notify_url = getpaid_get_non_query_string_ipn_url( $this->id ); |
|
78 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
79 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
80 | + $this->notify_url = getpaid_get_non_query_string_ipn_url($this->id); |
|
81 | 81 | |
82 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 11, 2 ); |
|
83 | - add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
|
82 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'), 11, 2); |
|
83 | + add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice')); |
|
84 | 84 | parent::__construct(); |
85 | 85 | } |
86 | 86 | |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | * @param int $invoice_id 0 or invoice id. |
91 | 91 | * @param GetPaid_Payment_Form $form Current payment form. |
92 | 92 | */ |
93 | - public function payment_fields( $invoice_id, $form ) { |
|
93 | + public function payment_fields($invoice_id, $form) { |
|
94 | 94 | |
95 | 95 | // Let the user select a payment method. |
96 | 96 | $this->saved_payment_methods(); |
97 | 97 | |
98 | 98 | // Show the credit card entry form. |
99 | - $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
99 | + $this->new_payment_method_entry($this->get_cc_form(true)); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -109,79 +109,79 @@ discard block |
||
109 | 109 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
110 | 110 | * @return string|WP_Error Payment profile id. |
111 | 111 | */ |
112 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
112 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
113 | 113 | |
114 | 114 | // Remove non-digits from the number |
115 | - $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
115 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
116 | 116 | |
117 | 117 | // Generate args. |
118 | 118 | $args = array( |
119 | 119 | 'createCustomerProfileRequest' => array( |
120 | 120 | 'merchantAuthentication' => $this->get_auth_params(), |
121 | 121 | 'profile' => array( |
122 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
123 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
124 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
122 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
123 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
124 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
125 | 125 | 'paymentProfiles' => array( |
126 | 126 | 'customerType' => 'individual', |
127 | 127 | |
128 | 128 | // Billing information. |
129 | 129 | 'billTo' => array( |
130 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
131 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
132 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
133 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
134 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
135 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
136 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
130 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
131 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
132 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
133 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
134 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
135 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
136 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
137 | 137 | ), |
138 | 138 | |
139 | 139 | // Payment information. |
140 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
140 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
141 | 141 | ), |
142 | 142 | ), |
143 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
143 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
144 | 144 | ), |
145 | 145 | ); |
146 | 146 | |
147 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
147 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
148 | 148 | |
149 | - if ( is_wp_error( $response ) ) { |
|
149 | + if (is_wp_error($response)) { |
|
150 | 150 | |
151 | 151 | // In case the payment profile already exists remotely. |
152 | - if ( 'dup_payment_profile' === $response->get_error_code() ) { |
|
153 | - $customer_profile_id = strtok( $response->get_error_message(), '.' ); |
|
154 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id ); |
|
155 | - return strtok( '.' ); |
|
152 | + if ('dup_payment_profile' === $response->get_error_code()) { |
|
153 | + $customer_profile_id = strtok($response->get_error_message(), '.'); |
|
154 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id); |
|
155 | + return strtok('.'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // In case the customer profile already exists remotely. |
159 | - if ( 'E00039' === $response->get_error_code() ) { |
|
160 | - $customer_profile_id = str_replace( 'A duplicate record with ID ', '', $response->get_error_message() ); |
|
161 | - $customer_profile_id = str_replace( ' already exists.', '', $customer_profile_id ); |
|
162 | - return $this->create_customer_payment_profile( trim( $customer_profile_id ), $invoice, $submission_data, $save ); |
|
159 | + if ('E00039' === $response->get_error_code()) { |
|
160 | + $customer_profile_id = str_replace('A duplicate record with ID ', '', $response->get_error_message()); |
|
161 | + $customer_profile_id = str_replace(' already exists.', '', $customer_profile_id); |
|
162 | + return $this->create_customer_payment_profile(trim($customer_profile_id), $invoice, $submission_data, $save); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | return $response; |
166 | 166 | } |
167 | 167 | |
168 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
168 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
169 | 169 | |
170 | 170 | // Save the payment token. |
171 | - if ( $save ) { |
|
171 | + if ($save) { |
|
172 | 172 | $this->save_token( |
173 | 173 | array( |
174 | 174 | 'id' => $response->customerPaymentProfileIdList[0], |
175 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
175 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
176 | 176 | 'default' => true, |
177 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
177 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Add a note about the validation response. |
183 | 183 | $invoice->add_note( |
184 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
184 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
185 | 185 | false, |
186 | 186 | false, |
187 | 187 | true |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return string|WP_Error Profile id. |
199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
200 | 200 | */ |
201 | - public function get_customer_profile( $profile_id ) { |
|
201 | + public function get_customer_profile($profile_id) { |
|
202 | 202 | |
203 | 203 | // Generate args. |
204 | 204 | $args = array( |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ), |
209 | 209 | ); |
210 | 210 | |
211 | - return $this->post( $args, false ); |
|
211 | + return $this->post($args, false); |
|
212 | 212 | |
213 | 213 | } |
214 | 214 | |
@@ -223,18 +223,18 @@ discard block |
||
223 | 223 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
224 | 224 | * @return string|WP_Error Profile id. |
225 | 225 | */ |
226 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
226 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
227 | 227 | |
228 | 228 | // Remove non-digits from the number |
229 | - $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
229 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
230 | 230 | |
231 | 231 | // Prepare card details. |
232 | - $payment_information = $this->get_payment_information( $submission_data['authorizenet'] ); |
|
232 | + $payment_information = $this->get_payment_information($submission_data['authorizenet']); |
|
233 | 233 | |
234 | 234 | // Authorize.NET does not support saving the same card twice. |
235 | - $cached_information = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice ); |
|
235 | + $cached_information = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice); |
|
236 | 236 | |
237 | - if ( $cached_information ) { |
|
237 | + if ($cached_information) { |
|
238 | 238 | return $cached_information; |
239 | 239 | } |
240 | 240 | |
@@ -247,34 +247,34 @@ discard block |
||
247 | 247 | |
248 | 248 | // Billing information. |
249 | 249 | 'billTo' => array( |
250 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
251 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
252 | - 'address' => getpaid_limit_length( $invoice->get_address(), 60 ), |
|
253 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
254 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
255 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
256 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
250 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
251 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
252 | + 'address' => getpaid_limit_length($invoice->get_address(), 60), |
|
253 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
254 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
255 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
256 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
257 | 257 | ), |
258 | 258 | |
259 | 259 | // Payment information. |
260 | 260 | 'payment' => $payment_information, |
261 | 261 | ), |
262 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
262 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
263 | 263 | ), |
264 | 264 | ); |
265 | 265 | |
266 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
266 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
267 | 267 | |
268 | - if ( is_wp_error( $response ) ) { |
|
268 | + if (is_wp_error($response)) { |
|
269 | 269 | |
270 | 270 | // In case the payment profile already exists remotely. |
271 | - if ( 'dup_payment_profile' == $response->get_error_code() ) { |
|
272 | - $customer_profile_id = strtok( $response->get_error_message(), '.' ); |
|
273 | - $payment_profile_id = strtok( '.' ); |
|
274 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id ); |
|
271 | + if ('dup_payment_profile' == $response->get_error_code()) { |
|
272 | + $customer_profile_id = strtok($response->get_error_message(), '.'); |
|
273 | + $payment_profile_id = strtok('.'); |
|
274 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id); |
|
275 | 275 | |
276 | 276 | // Cache payment profile id. |
277 | - $this->add_payment_profile_to_cache( $payment_information, $payment_profile_id ); |
|
277 | + $this->add_payment_profile_to_cache($payment_information, $payment_profile_id); |
|
278 | 278 | |
279 | 279 | return $payment_profile_id; |
280 | 280 | } |
@@ -283,29 +283,29 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | // Save the payment token. |
286 | - if ( $save ) { |
|
286 | + if ($save) { |
|
287 | 287 | $this->save_token( |
288 | 288 | array( |
289 | 289 | 'id' => $response->customerPaymentProfileId, |
290 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
290 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
291 | 291 | 'default' => true, |
292 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
292 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
293 | 293 | ) |
294 | 294 | ); |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Cache payment profile id. |
298 | - $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId ); |
|
298 | + $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId); |
|
299 | 299 | |
300 | 300 | // Add a note about the validation response. |
301 | 301 | $invoice->add_note( |
302 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
302 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
303 | 303 | false, |
304 | 304 | false, |
305 | 305 | true |
306 | 306 | ); |
307 | 307 | |
308 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile ); |
|
308 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile); |
|
309 | 309 | |
310 | 310 | return $response->customerPaymentProfileId; |
311 | 311 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | * @param array $payment_details. |
318 | 318 | * @return array|false Profile id. |
319 | 319 | */ |
320 | - public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) { |
|
320 | + public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) { |
|
321 | 321 | |
322 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
323 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
322 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
323 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
324 | 324 | |
325 | - if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) { |
|
325 | + if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) { |
|
326 | 326 | return false; |
327 | 327 | } |
328 | 328 | |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | 'getCustomerPaymentProfileRequest' => array( |
332 | 332 | 'merchantAuthentication' => $this->get_auth_params(), |
333 | 333 | 'customerProfileId' => $customer_profile, |
334 | - 'customerPaymentProfileId' => $cached_information[ $payment_details ], |
|
334 | + 'customerPaymentProfileId' => $cached_information[$payment_details], |
|
335 | 335 | ), |
336 | 336 | ); |
337 | 337 | |
338 | - $response = $this->post( $args, $invoice ); |
|
338 | + $response = $this->post($args, $invoice); |
|
339 | 339 | |
340 | - return is_wp_error( $response ) ? false : $cached_information[ $payment_details ]; |
|
340 | + return is_wp_error($response) ? false : $cached_information[$payment_details]; |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * @param array $payment_details. |
349 | 349 | * @param string $payment_profile_id. |
350 | 350 | */ |
351 | - public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) { |
|
351 | + public function add_payment_profile_to_cache($payment_details, $payment_profile_id) { |
|
352 | 352 | |
353 | - $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() ); |
|
354 | - $cached_information = is_array( $cached_information ) ? $cached_information : array(); |
|
355 | - $payment_details = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY ); |
|
353 | + $cached_information = get_option('getpaid_authorize_net_cached_profiles', array()); |
|
354 | + $cached_information = is_array($cached_information) ? $cached_information : array(); |
|
355 | + $payment_details = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY); |
|
356 | 356 | |
357 | - $cached_information[ $payment_details ] = $payment_profile_id; |
|
358 | - update_option( 'getpaid_authorize_net_cached_profiles', $cached_information ); |
|
357 | + $cached_information[$payment_details] = $payment_profile_id; |
|
358 | + update_option('getpaid_authorize_net_cached_profiles', $cached_information); |
|
359 | 359 | |
360 | 360 | } |
361 | 361 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @return string|WP_Error Profile id. |
369 | 369 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
370 | 370 | */ |
371 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
371 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
372 | 372 | |
373 | 373 | // Generate args. |
374 | 374 | $args = array( |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | ), |
380 | 380 | ); |
381 | 381 | |
382 | - return $this->post( $args, false ); |
|
382 | + return $this->post($args, false); |
|
383 | 383 | |
384 | 384 | } |
385 | 385 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
393 | 393 | * @return WP_Error|object |
394 | 394 | */ |
395 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
395 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
396 | 396 | |
397 | 397 | // Generate args. |
398 | 398 | $args = array( |
@@ -412,28 +412,28 @@ discard block |
||
412 | 412 | ), |
413 | 413 | ), |
414 | 414 | 'order' => array( |
415 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
415 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
416 | 416 | ), |
417 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
417 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
418 | 418 | 'tax' => array( |
419 | 419 | 'amount' => $invoice->get_total_tax(), |
420 | - 'name' => __( 'TAX', 'invoicing' ), |
|
420 | + 'name' => __('TAX', 'invoicing'), |
|
421 | 421 | ), |
422 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
422 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
423 | 423 | 'customer' => array( |
424 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
425 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
424 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
425 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
426 | 426 | ), |
427 | 427 | 'customerIP' => $invoice->get_ip(), |
428 | 428 | ), |
429 | 429 | ), |
430 | 430 | ); |
431 | 431 | |
432 | - if ( 0 == $invoice->get_total_tax() ) { |
|
433 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
432 | + if (0 == $invoice->get_total_tax()) { |
|
433 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
434 | 434 | } |
435 | 435 | |
436 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
436 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
@@ -443,31 +443,31 @@ discard block |
||
443 | 443 | * @param stdClass $result Api response. |
444 | 444 | * @param WPInv_Invoice $invoice Invoice. |
445 | 445 | */ |
446 | - public function process_charge_response( $result, $invoice ) { |
|
446 | + public function process_charge_response($result, $invoice) { |
|
447 | 447 | |
448 | 448 | wpinv_clear_errors(); |
449 | 449 | $response_code = (int) $result->transactionResponse->responseCode; |
450 | 450 | |
451 | - $invoice->add_note( 'Transaction Response: ' . print_r( $result->transactionResponse, true ), false, false, true ); |
|
451 | + $invoice->add_note('Transaction Response: ' . print_r($result->transactionResponse, true), false, false, true); |
|
452 | 452 | |
453 | 453 | // Succeeded. |
454 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
454 | + if (1 == $response_code || 4 == $response_code) { |
|
455 | 455 | |
456 | 456 | // Maybe set a transaction id. |
457 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
458 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
457 | + if (!empty($result->transactionResponse->transId)) { |
|
458 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
459 | 459 | } |
460 | 460 | |
461 | - $invoice->add_note( sprintf( __( 'Authentication code: %1$s (%2$s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
461 | + $invoice->add_note(sprintf(__('Authentication code: %1$s (%2$s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
462 | 462 | |
463 | - if ( 1 == $response_code ) { |
|
463 | + if (1 == $response_code) { |
|
464 | 464 | return $invoice->mark_paid(); |
465 | 465 | } |
466 | 466 | |
467 | - $invoice->set_status( 'wpi-onhold' ); |
|
467 | + $invoice->set_status('wpi-onhold'); |
|
468 | 468 | $invoice->add_note( |
469 | 469 | sprintf( |
470 | - __( 'Held for review: %s', 'invoicing' ), |
|
470 | + __('Held for review: %s', 'invoicing'), |
|
471 | 471 | $result->transactionResponse->messages->message[0]->description |
472 | 472 | ) |
473 | 473 | ); |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | |
477 | 477 | } |
478 | 478 | |
479 | - wpinv_set_error( 'card_declined' ); |
|
479 | + wpinv_set_error('card_declined'); |
|
480 | 480 | |
481 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
481 | + if (!empty($result->transactionResponse->errors)) { |
|
482 | 482 | $errors = (object) $result->transactionResponse->errors; |
483 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
483 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | } |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * @param array $card Card details. |
493 | 493 | * @return array |
494 | 494 | */ |
495 | - public function get_payment_information( $card ) { |
|
495 | + public function get_payment_information($card) { |
|
496 | 496 | return array( |
497 | 497 | |
498 | 498 | 'creditCard' => array( |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | * @param WPInv_Invoice $invoice Invoice. |
512 | 512 | * @return string |
513 | 513 | */ |
514 | - public function get_customer_profile_meta_name( $invoice ) { |
|
515 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
514 | + public function get_customer_profile_meta_name($invoice) { |
|
515 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -523,34 +523,34 @@ discard block |
||
523 | 523 | * @param WPInv_Invoice $invoice |
524 | 524 | * @return WP_Error|string The payment profile id |
525 | 525 | */ |
526 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
526 | + public function validate_submission_data($submission_data, $invoice) { |
|
527 | 527 | |
528 | 528 | // Validate authentication details. |
529 | 529 | $auth = $this->get_auth_params(); |
530 | 530 | |
531 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
532 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing' ) ); |
|
531 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
532 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | // Validate the payment method. |
536 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
537 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing' ) ); |
|
536 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
537 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | // Are we adding a new payment method? |
541 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
541 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
542 | 542 | return $submission_data['getpaid-authorizenet-payment-method']; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // Retrieve the customer profile id. |
546 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
546 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
547 | 547 | |
548 | 548 | // Create payment method. |
549 | - if ( empty( $profile_id ) ) { |
|
550 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
549 | + if (empty($profile_id)) { |
|
550 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
551 | 551 | } |
552 | 552 | |
553 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
553 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
554 | 554 | |
555 | 555 | } |
556 | 556 | |
@@ -561,32 +561,32 @@ discard block |
||
561 | 561 | * @param WPInv_Invoice $invoice Invoice. |
562 | 562 | * @return array |
563 | 563 | */ |
564 | - public function get_line_items( $invoice ) { |
|
564 | + public function get_line_items($invoice) { |
|
565 | 565 | $items = array(); |
566 | 566 | |
567 | - foreach ( $invoice->get_items() as $item ) { |
|
567 | + foreach ($invoice->get_items() as $item) { |
|
568 | 568 | |
569 | 569 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
570 | 570 | $items[] = array( |
571 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
572 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
573 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
574 | - 'quantity' => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ), |
|
571 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
572 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
573 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
574 | + 'quantity' => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()), |
|
575 | 575 | 'unitPrice' => (float) $amount, |
576 | 576 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
577 | 577 | ); |
578 | 578 | |
579 | 579 | } |
580 | 580 | |
581 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
581 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
582 | 582 | |
583 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
583 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
584 | 584 | |
585 | - if ( $amount > 0 ) { |
|
585 | + if ($amount > 0) { |
|
586 | 586 | $items[] = array( |
587 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
588 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
589 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
587 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
588 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
589 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
590 | 590 | 'quantity' => '1', |
591 | 591 | 'unitPrice' => (float) $amount, |
592 | 592 | 'taxable' => false, |
@@ -606,36 +606,36 @@ discard block |
||
606 | 606 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
607 | 607 | * @return array |
608 | 608 | */ |
609 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
609 | + public function process_payment($invoice, $submission_data, $submission) { |
|
610 | 610 | |
611 | 611 | // Validate the submitted data. |
612 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
612 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
613 | 613 | |
614 | 614 | // Do we have an error? |
615 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
616 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
617 | - wpinv_send_back_to_checkout( $invoice ); |
|
615 | + if (is_wp_error($payment_profile_id)) { |
|
616 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
617 | + wpinv_send_back_to_checkout($invoice); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | // Save the payment method to the order. |
621 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
621 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
622 | 622 | |
623 | 623 | // Check if this is a subscription or not. |
624 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
625 | - if ( ! empty( $subscriptions ) ) { |
|
626 | - $this->process_subscription( $invoice, $subscriptions ); |
|
624 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
625 | + if (!empty($subscriptions)) { |
|
626 | + $this->process_subscription($invoice, $subscriptions); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | // If it is free, send to the success page. |
630 | - if ( ! $invoice->needs_payment() ) { |
|
630 | + if (!$invoice->needs_payment()) { |
|
631 | 631 | $invoice->mark_paid(); |
632 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
632 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | // Charge the payment profile. |
636 | - $this->process_initial_payment( $invoice ); |
|
636 | + $this->process_initial_payment($invoice); |
|
637 | 637 | |
638 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
638 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
639 | 639 | |
640 | 640 | exit; |
641 | 641 | |
@@ -646,23 +646,23 @@ discard block |
||
646 | 646 | * |
647 | 647 | * @param WPInv_Invoice $invoice Invoice. |
648 | 648 | */ |
649 | - protected function process_initial_payment( $invoice ) { |
|
649 | + protected function process_initial_payment($invoice) { |
|
650 | 650 | |
651 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
652 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
653 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
651 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
652 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
653 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
654 | 654 | |
655 | 655 | // Do we have an error? |
656 | - if ( is_wp_error( $result ) ) { |
|
657 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
658 | - wpinv_send_back_to_checkout( $invoice ); |
|
656 | + if (is_wp_error($result)) { |
|
657 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
658 | + wpinv_send_back_to_checkout($invoice); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | // Process the response. |
662 | - $this->process_charge_response( $result, $invoice ); |
|
662 | + $this->process_charge_response($result, $invoice); |
|
663 | 663 | |
664 | - if ( wpinv_get_errors() ) { |
|
665 | - wpinv_send_back_to_checkout( $invoice ); |
|
664 | + if (wpinv_get_errors()) { |
|
665 | + wpinv_send_back_to_checkout($invoice); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | } |
@@ -673,30 +673,30 @@ discard block |
||
673 | 673 | * @param WPInv_Invoice $invoice Invoice. |
674 | 674 | * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions. |
675 | 675 | */ |
676 | - public function process_subscription( $invoice, $subscriptions ) { |
|
676 | + public function process_subscription($invoice, $subscriptions) { |
|
677 | 677 | |
678 | 678 | // Check if there is an initial amount to charge. |
679 | - if ( (float) $invoice->get_total() > 0 ) { |
|
680 | - $this->process_initial_payment( $invoice ); |
|
679 | + if ((float) $invoice->get_total() > 0) { |
|
680 | + $this->process_initial_payment($invoice); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | // Activate the subscriptions. |
684 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
684 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
685 | 685 | |
686 | - foreach ( $subscriptions as $subscription ) { |
|
687 | - if ( $subscription->exists() ) { |
|
688 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
689 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
686 | + foreach ($subscriptions as $subscription) { |
|
687 | + if ($subscription->exists()) { |
|
688 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
689 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
690 | 690 | |
691 | - $subscription->set_next_renewal_date( $expiry ); |
|
692 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
693 | - $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) ); |
|
691 | + $subscription->set_next_renewal_date($expiry); |
|
692 | + $subscription->set_date_created(current_time('mysql')); |
|
693 | + $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id())); |
|
694 | 694 | $subscription->activate(); |
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
698 | 698 | // Redirect to the success page. |
699 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
699 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
700 | 700 | |
701 | 701 | } |
702 | 702 | |
@@ -706,10 +706,10 @@ discard block |
||
706 | 706 | * |
707 | 707 | * @param WPInv_Subscription $subscription |
708 | 708 | */ |
709 | - public function maybe_renew_subscription( $subscription, $parent_invoice ) { |
|
709 | + public function maybe_renew_subscription($subscription, $parent_invoice) { |
|
710 | 710 | // Ensure its our subscription && it's active. |
711 | - if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
712 | - $this->renew_subscription( $subscription ); |
|
711 | + if (!empty($parent_invoice) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status('active trialling')) { |
|
712 | + $this->renew_subscription($subscription); |
|
713 | 713 | } |
714 | 714 | } |
715 | 715 | |
@@ -718,28 +718,28 @@ discard block |
||
718 | 718 | * |
719 | 719 | * @param WPInv_Subscription $subscription |
720 | 720 | */ |
721 | - public function renew_subscription( $subscription ) { |
|
721 | + public function renew_subscription($subscription) { |
|
722 | 722 | |
723 | 723 | // Generate the renewal invoice. |
724 | 724 | $new_invoice = $subscription->create_payment(); |
725 | 725 | $old_invoice = $subscription->get_parent_payment(); |
726 | 726 | |
727 | - if ( empty( $new_invoice ) ) { |
|
728 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
727 | + if (empty($new_invoice)) { |
|
728 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
729 | 729 | $subscription->failing(); |
730 | 730 | return; |
731 | 731 | } |
732 | 732 | |
733 | 733 | // Charge the payment method. |
734 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
735 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
736 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
734 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
735 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
736 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
737 | 737 | |
738 | 738 | // Do we have an error? |
739 | - if ( is_wp_error( $result ) ) { |
|
739 | + if (is_wp_error($result)) { |
|
740 | 740 | |
741 | 741 | $old_invoice->add_note( |
742 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
742 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
743 | 743 | true, |
744 | 744 | false, |
745 | 745 | true |
@@ -750,12 +750,12 @@ discard block |
||
750 | 750 | } |
751 | 751 | |
752 | 752 | // Process the response. |
753 | - $this->process_charge_response( $result, $new_invoice ); |
|
753 | + $this->process_charge_response($result, $new_invoice); |
|
754 | 754 | |
755 | - if ( wpinv_get_errors() ) { |
|
755 | + if (wpinv_get_errors()) { |
|
756 | 756 | |
757 | 757 | $old_invoice->add_note( |
758 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
758 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
759 | 759 | true, |
760 | 760 | false, |
761 | 761 | true |
@@ -765,9 +765,9 @@ discard block |
||
765 | 765 | |
766 | 766 | } |
767 | 767 | |
768 | - if ( ! $new_invoice->needs_payment() ) { |
|
768 | + if (!$new_invoice->needs_payment()) { |
|
769 | 769 | $subscription->renew(); |
770 | - $subscription->after_add_payment( $new_invoice ); |
|
770 | + $subscription->after_add_payment($new_invoice); |
|
771 | 771 | } else { |
772 | 772 | $subscription->failing(); |
773 | 773 | } |
@@ -780,33 +780,33 @@ discard block |
||
780 | 780 | * @param GetPaid_Form_Item[] $items |
781 | 781 | * @return WPInv_Invoice |
782 | 782 | */ |
783 | - public function process_addons( $invoice, $items ) { |
|
783 | + public function process_addons($invoice, $items) { |
|
784 | 784 | |
785 | 785 | global $getpaid_authorize_addons; |
786 | 786 | |
787 | 787 | $getpaid_authorize_addons = array(); |
788 | - foreach ( $items as $item ) { |
|
788 | + foreach ($items as $item) { |
|
789 | 789 | |
790 | - if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) { |
|
790 | + if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) { |
|
791 | 791 | $getpaid_authorize_addons[] = $item; |
792 | 792 | } |
793 | 793 | } |
794 | 794 | |
795 | - if ( empty( $getpaid_authorize_addons ) ) { |
|
795 | + if (empty($getpaid_authorize_addons)) { |
|
796 | 796 | return; |
797 | 797 | } |
798 | 798 | |
799 | 799 | $invoice->recalculate_total(); |
800 | 800 | |
801 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
802 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
801 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
802 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
803 | 803 | |
804 | - add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 ); |
|
805 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
806 | - remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) ); |
|
804 | + add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2); |
|
805 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
806 | + remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request')); |
|
807 | 807 | |
808 | - if ( is_wp_error( $result ) ) { |
|
809 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
808 | + if (is_wp_error($result)) { |
|
809 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
810 | 810 | return; |
811 | 811 | } |
812 | 812 | |
@@ -819,19 +819,19 @@ discard block |
||
819 | 819 | * @param array $args |
820 | 820 | * @return array |
821 | 821 | */ |
822 | - public function filter_addons_request( $args ) { |
|
822 | + public function filter_addons_request($args) { |
|
823 | 823 | |
824 | 824 | global $getpaid_authorize_addons; |
825 | 825 | $total = 0; |
826 | 826 | |
827 | - foreach ( $getpaid_authorize_addons as $addon ) { |
|
827 | + foreach ($getpaid_authorize_addons as $addon) { |
|
828 | 828 | $total += $addon->get_sub_total(); |
829 | 829 | } |
830 | 830 | |
831 | 831 | $args['createTransactionRequest']['transactionRequest']['amount'] = $total; |
832 | 832 | |
833 | - if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) { |
|
834 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
833 | + if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) { |
|
834 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | return $args; |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | public function sandbox_notice() { |
845 | 845 | |
846 | 846 | return sprintf( |
847 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %1$sAuthorize.NET Sandbox Testing Guide%2$s for more details.', 'invoicing' ), |
|
847 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %1$sAuthorize.NET Sandbox Testing Guide%2$s for more details.', 'invoicing'), |
|
848 | 848 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
849 | 849 | '</a>' |
850 | 850 | ); |
@@ -856,42 +856,42 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @param array $admin_settings |
858 | 858 | */ |
859 | - public function admin_settings( $admin_settings ) { |
|
859 | + public function admin_settings($admin_settings) { |
|
860 | 860 | |
861 | 861 | $currencies = sprintf( |
862 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
863 | - implode( ', ', $this->currencies ) |
|
862 | + __('Supported Currencies: %s', 'invoicing'), |
|
863 | + implode(', ', $this->currencies) |
|
864 | 864 | ); |
865 | 865 | |
866 | 866 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
867 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
867 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
868 | 868 | |
869 | 869 | $admin_settings['authorizenet_login_id'] = array( |
870 | 870 | 'type' => 'text', |
871 | 871 | 'id' => 'authorizenet_login_id', |
872 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
873 | - 'desc' => '<a href="https://support.authorize.net/knowledgebase/Knowledgearticle/?code=000001271"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
872 | + 'name' => __('API Login ID', 'invoicing'), |
|
873 | + 'desc' => '<a href="https://support.authorize.net/knowledgebase/Knowledgearticle/?code=000001271"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
874 | 874 | ); |
875 | 875 | |
876 | 876 | $admin_settings['authorizenet_transaction_key'] = array( |
877 | 877 | 'type' => 'text', |
878 | 878 | 'id' => 'authorizenet_transaction_key', |
879 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
879 | + 'name' => __('Transaction Key', 'invoicing'), |
|
880 | 880 | ); |
881 | 881 | |
882 | 882 | $admin_settings['authorizenet_signature_key'] = array( |
883 | 883 | 'type' => 'text', |
884 | 884 | 'id' => 'authorizenet_signature_key', |
885 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
886 | - 'desc' => '<a href="https://support.authorize.net/knowledgebase/Knowledgearticle/?code=000001271"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
885 | + 'name' => __('Signature Key', 'invoicing'), |
|
886 | + 'desc' => '<a href="https://support.authorize.net/knowledgebase/Knowledgearticle/?code=000001271"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
887 | 887 | ); |
888 | 888 | |
889 | 889 | $admin_settings['authorizenet_ipn_url'] = array( |
890 | 890 | 'type' => 'ipn_url', |
891 | 891 | 'id' => 'authorizenet_ipn_url', |
892 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
892 | + 'name' => __('Webhook URL', 'invoicing'), |
|
893 | 893 | 'std' => $this->notify_url, |
894 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/knowledgebase/Knowledgearticle/?code=000001542"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
894 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/knowledgebase/Knowledgearticle/?code=000001542"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
895 | 895 | 'custom' => 'authorizenet', |
896 | 896 | 'readonly' => true, |
897 | 897 | ); |