Passed
Push — master ( c00bf2...a0fba5 )
by Brian
04:10
created
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,27 +21,27 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <style>
46 46
             #poststuff .input-group-text,
47 47
             #poststuff .form-control {
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
         </style>
56 56
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
57 57
 
58
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
58
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
59 59
             <div class="form-group row">
60
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
60
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
61 61
                 <div class="col-sm-8">
62 62
                     <div class="row">
63 63
                         <div class="col-sm-4 getpaid-price-input">
64 64
                             <div class="input-group input-group-sm">
65
-                                <?php if( 'left' == $position ) : ?>
65
+                                <?php if ('left' == $position) : ?>
66 66
                                 <div class="input-group-prepend">
67 67
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
68 68
                                 </div>
69 69
                                 <?php endif; ?>
70
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
70
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
71 71
 
72
-                                <?php if( 'left' != $position ) : ?>
72
+                                <?php if ('left' != $position) : ?>
73 73
                                 <div class="input-group-append">
74 74
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
75 75
                                 </div>
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
                         </div>
80 80
                         <div class="col-sm-4 wpinv_show_if_recurring">
81 81
                             <?php
82
-                                _e( 'every' );
82
+                                _e('every');
83 83
                                 echo "&nbsp;";
84 84
                             ?>
85
-                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
85
+                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
86 86
                         </div>
87 87
                         <div class="col-sm-4 wpinv_show_if_recurring">
88 88
                             <?php
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
                                     array(
91 91
                                         'id'               => 'wpinv_recurring_period',
92 92
                                         'name'             => 'wpinv_recurring_period',
93
-                                        'label'            => __( 'Period', 'invoicing' ),
94
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
95
-                                        'value'            => $item->get_recurring_period( 'edit' ),
93
+                                        'label'            => __('Period', 'invoicing'),
94
+                                        'placeholder'      => __('Select Period', 'invoicing'),
95
+                                        'value'            => $item->get_recurring_period('edit'),
96 96
                                         'select2'          => true,
97 97
                                         'data-allow-clear' => 'false',
98 98
                                         'options'     => array(
99
-                                            'D'  => __( 'day(s)', 'invoicing' ),
100
-                                            'W'  => __( 'week(s)', 'invoicing' ),
101
-                                            'M'  => __( 'month(s)', 'invoicing' ),
102
-                                            'Y'  => __( 'year(s)', 'invoicing' ),
99
+                                            'D'  => __('day(s)', 'invoicing'),
100
+                                            'W'  => __('week(s)', 'invoicing'),
101
+                                            'M'  => __('month(s)', 'invoicing'),
102
+                                            'Y'  => __('year(s)', 'invoicing'),
103 103
                                         )
104 104
                                     )
105 105
                                 );
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
                             <?php
112 112
 
113 113
                                 // Dynamic pricing.
114
-                                if( $item->supports_dynamic_pricing() ) {
114
+                                if ($item->supports_dynamic_pricing()) {
115 115
 
116
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
116
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
117 117
 
118 118
                                     // NYP toggle.
119 119
                                     echo aui()->input(
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
                                             'id'          => 'wpinv_name_your_price',
122 122
                                             'name'        => 'wpinv_name_your_price',
123 123
                                             'type'        => 'checkbox',
124
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
124
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
125 125
                                             'value'       => '1',
126 126
                                             'checked'     => $item->user_can_set_their_price(),
127 127
                                             'no_wrap'     => true,
128 128
                                         )
129 129
                                     );
130 130
 
131
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
131
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
132 132
 
133 133
                                 }
134 134
 
135 135
                                 // Subscriptions.
136
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
136
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
137 137
                                 echo aui()->input(
138 138
                                     array(
139 139
                                         'id'          => 'wpinv_is_recurring',
140 140
                                         'name'        => 'wpinv_is_recurring',
141 141
                                         'type'        => 'checkbox',
142
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
142
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
143 143
                                         'value'       => '1',
144 144
                                         'checked'     => $item->is_recurring(),
145 145
                                         'no_wrap'     => true,
146 146
                                     )
147 147
                                 );
148
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
148
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
149 149
 
150 150
                             ?>
151 151
                             <div class="wpinv_show_if_recurring">
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
                     </div>
156 156
                 </div>
157 157
                 <div class="col-sm-1 pt-2 pl-0">
158
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
158
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
159 159
                 </div>
160 160
             </div>
161
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
161
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
162 162
 
163
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
164
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
163
+            <?php if ($item->supports_dynamic_pricing()) : ?>
164
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
165 165
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
166 166
 
167 167
                     <div class="form-group row">
168 168
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
169
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
169
+                            <?php _e('Minimum Price', 'invoicing'); ?>
170 170
                         </label>
171 171
                         <div class="col-sm-8">
172 172
                             <div class="input-group input-group-sm">
173
-                                <?php if( 'left' == $position ) : ?>
173
+                                <?php if ('left' == $position) : ?>
174 174
                                     <div class="input-group-prepend">
175 175
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
176 176
                                     </div>
177 177
                                 <?php endif; ?>
178 178
 
179
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
179
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
180 180
 
181
-                                <?php if( 'left' != $position ) : ?>
181
+                                <?php if ('left' != $position) : ?>
182 182
                                     <div class="input-group-append">
183 183
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
184 184
                                     </div>
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
                         </div>
188 188
 
189 189
                         <div class="col-sm-1 pt-2 pl-0">
190
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
190
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
191 191
                         </div>
192 192
                     </div>
193 193
 
194 194
                 </div>
195
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
195
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
196 196
             <?php endif; ?>
197 197
 
198
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
198
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
199 199
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
200 200
 
201 201
                 <div class="form-group row">
202 202
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
203
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
203
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
204 204
                     </label>
205 205
                     <div class="col-sm-8">
206
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
206
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
207 207
                     </div>
208 208
                     <div class="col-sm-1 pt-2 pl-0">
209
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
209
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
210 210
                     </div>
211 211
                 </div>
212 212
 
213 213
             </div>
214
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
214
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
215 215
 
216
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
216
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
217 217
             <div class="wpinv_show_if_recurring wpinv_free_trial">
218 218
 
219 219
                 <div class="form-group row">
220
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' )?></label>
220
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing')?></label>
221 221
 
222 222
                     <div class="col-sm-8">
223 223
                         <div class="row">
224 224
                             <div class="col-sm-6">
225
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
225
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
226 226
 
227 227
                                 <div>
228
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
228
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
229 229
                                 </div>
230 230
                             </div>
231 231
                             <div class="col-sm-6">
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
                                         array(
235 235
                                             'id'               => 'wpinv_trial_period',
236 236
                                             'name'             => 'wpinv_trial_period',
237
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
238
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
239
-                                            'value'            => $item->get_trial_period( 'edit' ),
237
+                                            'label'            => __('Trial Period', 'invoicing'),
238
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
239
+                                            'value'            => $item->get_trial_period('edit'),
240 240
                                             'select2'          => true,
241 241
                                             'data-allow-clear' => 'false',
242 242
                                             'no_wrap'          => true,
243 243
                                             'options'          => array(
244
-                                                'D'  => __( 'day(s)', 'invoicing' ),
245
-                                                'W'  => __( 'week(s)', 'invoicing' ),
246
-                                                'M'  => __( 'month(s)', 'invoicing' ),
247
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
244
+                                                'D'  => __('day(s)', 'invoicing'),
245
+                                                'W'  => __('week(s)', 'invoicing'),
246
+                                                'M'  => __('month(s)', 'invoicing'),
247
+                                                'Y'  => __('year(s)', 'invoicing'),
248 248
                                             )
249 249
                                         )
250 250
                                     );
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
                     </div>
256 256
 
257 257
                     <div class="col-sm-1 pt-2 pl-0">
258
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
258
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
259 259
                     </div>
260 260
 
261 261
                 </div>
262 262
 
263 263
             </div>
264
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
264
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
265 265
 
266
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
266
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
267 267
         </div>
268 268
         <?php
269 269
 
@@ -274,31 +274,31 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param int $post_id
276 276
 	 */
277
-	public static function save( $post_id ) {
277
+	public static function save($post_id) {
278 278
 
279 279
         // Prepare the item.
280
-        $item = new WPInv_Item( $post_id );
280
+        $item = new WPInv_Item($post_id);
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284 284
 			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
290
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
285
+				'price'                => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null,
286
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
287
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
288
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
289
+				'is_dynamic_pricing'   => isset($_POST['wpinv_name_your_price']),
290
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null,
291
+				'is_recurring'         => isset($_POST['wpinv_is_recurring']),
292
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
293
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
296
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
297
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
298 298
 			)
299 299
         );
300 300
 
301 301
 		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
302
+		do_action('getpaid_item_metabox_save', $post_id, $item);
303 303
 	}
304 304
 }
Please login to merge, or discard this patch.