Passed
Push — master ( 47b6fc...99ae46 )
by Brian
05:46 queued 20s
created
includes/class-wpinv-discount.php 1 patch
Indentation   +1340 added lines, -1340 removed lines patch added patch discarded remove patch
@@ -15,30 +15,30 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class WPInv_Discount extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23 23
     protected $data_store_name = 'discount';
24 24
 
25 25
     /**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'discount';
31
-
32
-	/**
33
-	 * Discount Data array. This is the core item data exposed in APIs.
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array(
39
-		'status'         => 'draft',
40
-		'version'        => '',
41
-		'date_created'   => null,
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'discount';
31
+
32
+    /**
33
+     * Discount Data array. This is the core item data exposed in APIs.
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array(
39
+        'status'         => 'draft',
40
+        'version'        => '',
41
+        'date_created'   => null,
42 42
         'date_modified'  => null,
43 43
         'name'           => 'no-name',
44 44
         'description'    => '',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         'start'          => null,
50 50
         'items'          => array(),
51 51
         'excluded_items' => array(),
52
-		'required_items' => array(),
52
+        'required_items' => array(),
53 53
         'uses'           => 0,
54 54
         'max_uses'       => null,
55 55
         'is_recurring'   => null,
@@ -59,147 +59,147 @@  discard block
 block discarded – undo
59 59
         'amount'         => null,
60 60
     );
61 61
 
62
-	/**
63
-	 * Stores meta in cache for future reads.
64
-	 *
65
-	 * A group must be set to to enable caching.
66
-	 *
67
-	 * @var string
68
-	 */
69
-	protected $cache_group = 'getpaid_discounts';
62
+    /**
63
+     * Stores meta in cache for future reads.
64
+     *
65
+     * A group must be set to to enable caching.
66
+     *
67
+     * @var string
68
+     */
69
+    protected $cache_group = 'getpaid_discounts';
70 70
 
71 71
     /**
72 72
      * Stores a reference to the original WP_Post object
73 73
      *
74 74
      * @var WP_Post
75 75
      */
76
-	protected $post = null;
77
-
78
-	/**
79
-	 * Get the discount if ID is passed, otherwise the discount is new and empty.
80
-	 *
81
-	 * @param int|array|string|WPInv_Discount|WP_Post $discount discount data, object, ID or code.
82
-	 */
83
-	public function __construct( $discount = 0 ) {
84
-		parent::__construct( $discount );
85
-
86
-		if ( is_numeric( $discount ) && 'wpi_discount' === get_post_type( $discount ) ) {
87
-			$this->set_id( $discount );
88
-		} elseif ( $discount instanceof self ) {
89
-			$this->set_id( $discount->get_id() );
90
-		} elseif ( ! empty( $discount->ID ) ) {
91
-			$this->set_id( $discount->ID );
92
-		} elseif ( is_array( $discount ) ) {
93
-			$this->set_props( $discount );
94
-
95
-			if ( isset( $discount['ID'] ) ) {
96
-				$this->set_id( $discount['ID'] );
97
-			}
76
+    protected $post = null;
77
+
78
+    /**
79
+     * Get the discount if ID is passed, otherwise the discount is new and empty.
80
+     *
81
+     * @param int|array|string|WPInv_Discount|WP_Post $discount discount data, object, ID or code.
82
+     */
83
+    public function __construct( $discount = 0 ) {
84
+        parent::__construct( $discount );
85
+
86
+        if ( is_numeric( $discount ) && 'wpi_discount' === get_post_type( $discount ) ) {
87
+            $this->set_id( $discount );
88
+        } elseif ( $discount instanceof self ) {
89
+            $this->set_id( $discount->get_id() );
90
+        } elseif ( ! empty( $discount->ID ) ) {
91
+            $this->set_id( $discount->ID );
92
+        } elseif ( is_array( $discount ) ) {
93
+            $this->set_props( $discount );
94
+
95
+            if ( isset( $discount['ID'] ) ) {
96
+                $this->set_id( $discount['ID'] );
97
+            }
98 98
 } elseif ( is_scalar( $discount ) && $discount = self::get_discount_id_by_code( $discount ) ) {
99
-			$this->set_id( $discount );
100
-		} else {
101
-			$this->set_object_read( true );
102
-		}
99
+            $this->set_id( $discount );
100
+        } else {
101
+            $this->set_object_read( true );
102
+        }
103 103
 
104 104
         // Load the datastore.
105
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
105
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
106 106
 
107
-		if ( $this->get_id() > 0 ) {
107
+        if ( $this->get_id() > 0 ) {
108 108
             $this->post = get_post( $this->get_id() );
109 109
             $this->ID   = $this->get_id();
110
-			$this->data_store->read( $this );
110
+            $this->data_store->read( $this );
111 111
         }
112 112
 
113
-	}
114
-
115
-	/**
116
-	 * Fetch a discount from the db/cache
117
-	 *
118
-	 *
119
-	 * @static
120
-	 * @param string $field The field to query against: 'ID', 'discount_code'
121
-	 * @param string|int $value The field value
122
-	 * @deprecated
123
-	 * @since 1.0.15
124
-	 * @return array|bool array of discount details on success. False otherwise.
125
-	 */
126
-	public static function get_data_by( $field, $value ) {
127
-
128
-		if ( 'id' == strtolower( $field ) ) {
129
-			// Make sure the value is numeric to avoid casting objects, for example,
130
-			// to int 1.
131
-			if ( ! is_numeric( $value ) ) {
132
-				return false;
113
+    }
114
+
115
+    /**
116
+     * Fetch a discount from the db/cache
117
+     *
118
+     *
119
+     * @static
120
+     * @param string $field The field to query against: 'ID', 'discount_code'
121
+     * @param string|int $value The field value
122
+     * @deprecated
123
+     * @since 1.0.15
124
+     * @return array|bool array of discount details on success. False otherwise.
125
+     */
126
+    public static function get_data_by( $field, $value ) {
127
+
128
+        if ( 'id' == strtolower( $field ) ) {
129
+            // Make sure the value is numeric to avoid casting objects, for example,
130
+            // to int 1.
131
+            if ( ! is_numeric( $value ) ) {
132
+                return false;
133 133
             }
134
-			$value = intval( $value );
135
-			if ( $value < 1 ) {
136
-				return false;
134
+            $value = intval( $value );
135
+            if ( $value < 1 ) {
136
+                return false;
137 137
             }
138
-		}
139
-
140
-		if ( ! $value || ! is_string( $field ) ) {
141
-			return false;
142
-		}
143
-
144
-		$field = trim( $field );
145
-
146
-		// prepare query args
147
-		switch ( strtolower( $field ) ) {
148
-			case 'id':
149
-				$discount_id = $value;
150
-				$args        = array( 'include' => array( $value ) );
151
-				break;
152
-			case 'discount_code':
153
-			case 'code':
154
-				$value       = trim( $value );
155
-				$discount_id = wp_cache_get( $value, 'WPInv_Discount_Codes' );
156
-				$args        = array(
157
-					'meta_key'   => '_wpi_discount_code',
158
-					'meta_value' => $value,
159
-				);
160
-				break;
161
-			case 'name':
162
-				$discount_id = 0;
163
-				$args        = array( 'name' => trim( $value ) );
164
-				break;
165
-			default:
166
-				$args        = apply_filters( "wpinv_discount_get_data_by_{$field}_args", null, $value );
167
-				if ( ! is_array( $args ) ) {
168
-					return apply_filters( "wpinv_discount_get_data_by_$field", false, $value );
169
-				}
138
+        }
139
+
140
+        if ( ! $value || ! is_string( $field ) ) {
141
+            return false;
142
+        }
143
+
144
+        $field = trim( $field );
145
+
146
+        // prepare query args
147
+        switch ( strtolower( $field ) ) {
148
+            case 'id':
149
+                $discount_id = $value;
150
+                $args        = array( 'include' => array( $value ) );
151
+                break;
152
+            case 'discount_code':
153
+            case 'code':
154
+                $value       = trim( $value );
155
+                $discount_id = wp_cache_get( $value, 'WPInv_Discount_Codes' );
156
+                $args        = array(
157
+                    'meta_key'   => '_wpi_discount_code',
158
+                    'meta_value' => $value,
159
+                );
160
+                break;
161
+            case 'name':
162
+                $discount_id = 0;
163
+                $args        = array( 'name' => trim( $value ) );
164
+                break;
165
+            default:
166
+                $args        = apply_filters( "wpinv_discount_get_data_by_{$field}_args", null, $value );
167
+                if ( ! is_array( $args ) ) {
168
+                    return apply_filters( "wpinv_discount_get_data_by_$field", false, $value );
169
+                }
170 170
 }
171 171
 
172
-		// Check if there is a cached value.
173
-		if ( ! empty( $discount_id ) && $discount = wp_cache_get( (int) $discount_id, 'WPInv_Discounts' ) ) {
174
-			return $discount;
175
-		}
172
+        // Check if there is a cached value.
173
+        if ( ! empty( $discount_id ) && $discount = wp_cache_get( (int) $discount_id, 'WPInv_Discounts' ) ) {
174
+            return $discount;
175
+        }
176 176
 
177
-		$args = array_merge(
178
-			$args,
179
-			array(
180
-				'post_type'      => 'wpi_discount',
181
-				'posts_per_page' => 1,
182
-				'post_status'    => array( 'publish', 'pending', 'draft', 'expired' ),
183
-			)
184
-		);
177
+        $args = array_merge(
178
+            $args,
179
+            array(
180
+                'post_type'      => 'wpi_discount',
181
+                'posts_per_page' => 1,
182
+                'post_status'    => array( 'publish', 'pending', 'draft', 'expired' ),
183
+            )
184
+        );
185 185
 
186
-		$discount = get_posts( $args );
186
+        $discount = get_posts( $args );
187 187
 
188
-		if ( empty( $discount ) ) {
189
-			return false;
190
-		}
188
+        if ( empty( $discount ) ) {
189
+            return false;
190
+        }
191 191
 
192
-		$discount = $discount[0];
192
+        $discount = $discount[0];
193 193
 
194
-		// Prepare the return data.
195
-		$return = array(
194
+        // Prepare the return data.
195
+        $return = array(
196 196
             'ID'             => $discount->ID,
197 197
             'code'           => get_post_meta( $discount->ID, '_wpi_discount_code', true ),
198 198
             'amount'         => get_post_meta( $discount->ID, '_wpi_discount_amount', true ),
199 199
             'date_created'   => $discount->post_date,
200
-			'date_modified'  => $discount->post_modified,
201
-			'status'         => $discount->post_status,
202
-			'start'          => get_post_meta( $discount->ID, '_wpi_discount_start', true ),
200
+            'date_modified'  => $discount->post_modified,
201
+            'status'         => $discount->post_status,
202
+            'start'          => get_post_meta( $discount->ID, '_wpi_discount_start', true ),
203 203
             'expiration'     => get_post_meta( $discount->ID, '_wpi_discount_expiration', true ),
204 204
             'type'           => get_post_meta( $discount->ID, '_wpi_discount_type', true ),
205 205
             'description'    => $discount->post_excerpt,
@@ -207,84 +207,84 @@  discard block
 block discarded – undo
207 207
             'is_single_use'  => get_post_meta( $discount->ID, '_wpi_discount_is_single_use', true ),
208 208
             'items'          => get_post_meta( $discount->ID, '_wpi_discount_items', true ),
209 209
             'excluded_items' => get_post_meta( $discount->ID, '_wpi_discount_excluded_items', true ),
210
-			'required_items' => get_post_meta( $discount->ID, '_wpi_discount_required_items', true ),
210
+            'required_items' => get_post_meta( $discount->ID, '_wpi_discount_required_items', true ),
211 211
             'max_uses'       => get_post_meta( $discount->ID, '_wpi_discount_max_uses', true ),
212 212
             'is_recurring'   => get_post_meta( $discount->ID, '_wpi_discount_is_recurring', true ),
213 213
             'min_total'      => get_post_meta( $discount->ID, '_wpi_discount_min_total', true ),
214 214
             'max_total'      => get_post_meta( $discount->ID, '_wpi_discount_max_total', true ),
215 215
         );
216 216
 
217
-		$return = apply_filters( 'wpinv_discount_properties', $return );
218
-
219
-		// Update the cache with our data
220
-		wp_cache_add( $discount->ID, $return, 'WPInv_Discounts' );
221
-		wp_cache_add( $return['code'], $discount->ID, 'WPInv_Discount_Codes' );
222
-
223
-		return $return;
224
-	}
225
-
226
-	/**
227
-	 * Given a discount code, it returns a discount id.
228
-	 *
229
-	 *
230
-	 * @static
231
-	 * @param string $discount_code
232
-	 * @since 1.0.15
233
-	 * @return int
234
-	 */
235
-	public static function get_discount_id_by_code( $discount_code ) {
236
-
237
-		// Trim the code.
238
-		$discount_code = trim( $discount_code );
239
-
240
-		// Ensure a value has been passed.
241
-		if ( empty( $discount_code ) ) {
242
-			return 0;
243
-		}
244
-
245
-		// Maybe retrieve from the cache.
246
-		$discount_id   = wp_cache_get( $discount_code, 'getpaid_discount_codes' );
247
-		if ( ! empty( $discount_id ) ) {
248
-			return $discount_id;
249
-		}
250
-
251
-		// Fetch the first discount codes.
252
-		$discounts = get_posts(
253
-			array(
254
-				'meta_key'       => '_wpi_discount_code',
255
-				'meta_value'     => $discount_code,
256
-				'post_type'      => 'wpi_discount',
257
-				'posts_per_page' => 1,
258
-				'post_status'    => array( 'publish', 'pending', 'draft', 'expired' ),
259
-				'fields'         => 'ids',
260
-			)
261
-		);
262
-
263
-		if ( empty( $discounts ) ) {
264
-			return 0;
265
-		}
266
-
267
-		$discount_id = $discounts[0];
268
-
269
-		// Update the cache with our data
270
-		wp_cache_add( get_post_meta( $discount_id, '_wpi_discount_code', true ), $discount_id, 'getpaid_discount_codes' );
271
-
272
-		return $discount_id;
273
-	}
274
-
275
-	/**
276
-	 * Magic method for checking the existence of a certain custom field.
277
-	 *
278
-	 * @since 1.0.15
279
-	 * @access public
280
-	 *
281
-	 * @return bool Whether the given discount field is set.
282
-	 */
283
-	public function __isset( $key ) {
284
-		return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
285
-	}
286
-
287
-	/*
217
+        $return = apply_filters( 'wpinv_discount_properties', $return );
218
+
219
+        // Update the cache with our data
220
+        wp_cache_add( $discount->ID, $return, 'WPInv_Discounts' );
221
+        wp_cache_add( $return['code'], $discount->ID, 'WPInv_Discount_Codes' );
222
+
223
+        return $return;
224
+    }
225
+
226
+    /**
227
+     * Given a discount code, it returns a discount id.
228
+     *
229
+     *
230
+     * @static
231
+     * @param string $discount_code
232
+     * @since 1.0.15
233
+     * @return int
234
+     */
235
+    public static function get_discount_id_by_code( $discount_code ) {
236
+
237
+        // Trim the code.
238
+        $discount_code = trim( $discount_code );
239
+
240
+        // Ensure a value has been passed.
241
+        if ( empty( $discount_code ) ) {
242
+            return 0;
243
+        }
244
+
245
+        // Maybe retrieve from the cache.
246
+        $discount_id   = wp_cache_get( $discount_code, 'getpaid_discount_codes' );
247
+        if ( ! empty( $discount_id ) ) {
248
+            return $discount_id;
249
+        }
250
+
251
+        // Fetch the first discount codes.
252
+        $discounts = get_posts(
253
+            array(
254
+                'meta_key'       => '_wpi_discount_code',
255
+                'meta_value'     => $discount_code,
256
+                'post_type'      => 'wpi_discount',
257
+                'posts_per_page' => 1,
258
+                'post_status'    => array( 'publish', 'pending', 'draft', 'expired' ),
259
+                'fields'         => 'ids',
260
+            )
261
+        );
262
+
263
+        if ( empty( $discounts ) ) {
264
+            return 0;
265
+        }
266
+
267
+        $discount_id = $discounts[0];
268
+
269
+        // Update the cache with our data
270
+        wp_cache_add( get_post_meta( $discount_id, '_wpi_discount_code', true ), $discount_id, 'getpaid_discount_codes' );
271
+
272
+        return $discount_id;
273
+    }
274
+
275
+    /**
276
+     * Magic method for checking the existence of a certain custom field.
277
+     *
278
+     * @since 1.0.15
279
+     * @access public
280
+     *
281
+     * @return bool Whether the given discount field is set.
282
+     */
283
+    public function __isset( $key ) {
284
+        return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
285
+    }
286
+
287
+    /*
288 288
 	|--------------------------------------------------------------------------
289 289
 	| CRUD methods
290 290
 	|--------------------------------------------------------------------------
@@ -299,441 +299,441 @@  discard block
 block discarded – undo
299 299
 	|--------------------------------------------------------------------------
300 300
 	*/
301 301
 
302
-	/**
303
-	 * Get discount status.
304
-	 *
305
-	 * @since 1.0.19
306
-	 * @param  string $context View or edit context.
307
-	 * @return string
308
-	 */
309
-	public function get_status( $context = 'view' ) {
310
-		return $this->get_prop( 'status', $context );
302
+    /**
303
+     * Get discount status.
304
+     *
305
+     * @since 1.0.19
306
+     * @param  string $context View or edit context.
307
+     * @return string
308
+     */
309
+    public function get_status( $context = 'view' ) {
310
+        return $this->get_prop( 'status', $context );
311 311
     }
312 312
 
313 313
     /**
314
-	 * Get plugin version when the discount was created.
315
-	 *
316
-	 * @since 1.0.19
317
-	 * @param  string $context View or edit context.
318
-	 * @return string
319
-	 */
320
-	public function get_version( $context = 'view' ) {
321
-		return $this->get_prop( 'version', $context );
314
+     * Get plugin version when the discount was created.
315
+     *
316
+     * @since 1.0.19
317
+     * @param  string $context View or edit context.
318
+     * @return string
319
+     */
320
+    public function get_version( $context = 'view' ) {
321
+        return $this->get_prop( 'version', $context );
322 322
     }
323 323
 
324 324
     /**
325
-	 * Get date when the discount was created.
326
-	 *
327
-	 * @since 1.0.19
328
-	 * @param  string $context View or edit context.
329
-	 * @return string
330
-	 */
331
-	public function get_date_created( $context = 'view' ) {
332
-		return $this->get_prop( 'date_created', $context );
325
+     * Get date when the discount was created.
326
+     *
327
+     * @since 1.0.19
328
+     * @param  string $context View or edit context.
329
+     * @return string
330
+     */
331
+    public function get_date_created( $context = 'view' ) {
332
+        return $this->get_prop( 'date_created', $context );
333 333
     }
334 334
 
335 335
     /**
336
-	 * Get GMT date when the discount was created.
337
-	 *
338
-	 * @since 1.0.19
339
-	 * @param  string $context View or edit context.
340
-	 * @return string
341
-	 */
342
-	public function get_date_created_gmt( $context = 'view' ) {
336
+     * Get GMT date when the discount was created.
337
+     *
338
+     * @since 1.0.19
339
+     * @param  string $context View or edit context.
340
+     * @return string
341
+     */
342
+    public function get_date_created_gmt( $context = 'view' ) {
343 343
         $date = $this->get_date_created( $context );
344 344
 
345 345
         if ( $date ) {
346 346
             $date = get_gmt_from_date( $date );
347 347
         }
348
-		return $date;
348
+        return $date;
349 349
     }
350 350
 
351 351
     /**
352
-	 * Get date when the discount was last modified.
353
-	 *
354
-	 * @since 1.0.19
355
-	 * @param  string $context View or edit context.
356
-	 * @return string
357
-	 */
358
-	public function get_date_modified( $context = 'view' ) {
359
-		return $this->get_prop( 'date_modified', $context );
352
+     * Get date when the discount was last modified.
353
+     *
354
+     * @since 1.0.19
355
+     * @param  string $context View or edit context.
356
+     * @return string
357
+     */
358
+    public function get_date_modified( $context = 'view' ) {
359
+        return $this->get_prop( 'date_modified', $context );
360 360
     }
361 361
 
362 362
     /**
363
-	 * Get GMT date when the discount was last modified.
364
-	 *
365
-	 * @since 1.0.19
366
-	 * @param  string $context View or edit context.
367
-	 * @return string
368
-	 */
369
-	public function get_date_modified_gmt( $context = 'view' ) {
363
+     * Get GMT date when the discount was last modified.
364
+     *
365
+     * @since 1.0.19
366
+     * @param  string $context View or edit context.
367
+     * @return string
368
+     */
369
+    public function get_date_modified_gmt( $context = 'view' ) {
370 370
         $date = $this->get_date_modified( $context );
371 371
 
372 372
         if ( $date ) {
373 373
             $date = get_gmt_from_date( $date );
374 374
         }
375
-		return $date;
376
-    }
377
-
378
-    /**
379
-	 * Get the discount name.
380
-	 *
381
-	 * @since 1.0.19
382
-	 * @param  string $context View or edit context.
383
-	 * @return string
384
-	 */
385
-	public function get_name( $context = 'view' ) {
386
-		return $this->get_prop( 'name', $context );
387
-    }
388
-
389
-    /**
390
-	 * Alias of self::get_name().
391
-	 *
392
-	 * @since 1.0.19
393
-	 * @param  string $context View or edit context.
394
-	 * @return string
395
-	 */
396
-	public function get_title( $context = 'view' ) {
397
-		return $this->get_name( $context );
398
-    }
399
-
400
-    /**
401
-	 * Get the discount description.
402
-	 *
403
-	 * @since 1.0.19
404
-	 * @param  string $context View or edit context.
405
-	 * @return string
406
-	 */
407
-	public function get_description( $context = 'view' ) {
408
-		return $this->get_prop( 'description', $context );
409
-    }
410
-
411
-    /**
412
-	 * Alias of self::get_description().
413
-	 *
414
-	 * @since 1.0.19
415
-	 * @param  string $context View or edit context.
416
-	 * @return string
417
-	 */
418
-	public function get_excerpt( $context = 'view' ) {
419
-		return $this->get_description( $context );
420
-    }
421
-
422
-    /**
423
-	 * Alias of self::get_description().
424
-	 *
425
-	 * @since 1.0.19
426
-	 * @param  string $context View or edit context.
427
-	 * @return string
428
-	 */
429
-	public function get_summary( $context = 'view' ) {
430
-		return $this->get_description( $context );
431
-    }
432
-
433
-    /**
434
-	 * Get the owner of the discount.
435
-	 *
436
-	 * @since 1.0.19
437
-	 * @param  string $context View or edit context.
438
-	 * @return string
439
-	 */
440
-	public function get_author( $context = 'view' ) {
441
-		return (int) $this->get_prop( 'author', $context );
442
-	}
443
-
444
-	/**
445
-	 * Get the discount code.
446
-	 *
447
-	 * @since 1.0.19
448
-	 * @param  string $context View or edit context.
449
-	 * @return string
450
-	 */
451
-	public function get_code( $context = 'view' ) {
452
-		return $this->get_prop( 'code', $context );
453
-	}
454
-
455
-	/**
456
-	 * Alias for self::get_code().
457
-	 *
458
-	 * @since 1.0.19
459
-	 * @param  string $context View or edit context.
460
-	 * @return string
461
-	 */
462
-	public function get_coupon_code( $context = 'view' ) {
463
-		return $this->get_code( $context );
464
-	}
465
-
466
-	/**
467
-	 * Alias for self::get_code().
468
-	 *
469
-	 * @since 1.0.19
470
-	 * @param  string $context View or edit context.
471
-	 * @return string
472
-	 */
473
-	public function get_discount_code( $context = 'view' ) {
474
-		return $this->get_code( $context );
475
-	}
476
-
477
-	/**
478
-	 * Get the discount's amount.
479
-	 *
480
-	 * @since 1.0.19
481
-	 * @param  string $context View or edit context.
482
-	 * @return float
483
-	 */
484
-	public function get_amount( $context = 'view' ) {
485
-		return $context == 'view' ? floatval( $this->get_prop( 'amount', $context ) ) : $this->get_prop( 'amount', $context );
486
-	}
487
-
488
-	/**
489
-	 * Get the discount's formated amount/rate.
490
-	 *
491
-	 * @since 1.0.19
492
-	 * @return string
493
-	 */
494
-	public function get_formatted_amount() {
495
-
496
-		if ( $this->is_type( 'flat' ) ) {
497
-			$rate = wpinv_price( $this->get_amount() );
498
-		} else {
499
-			$rate = $this->get_amount() . '%';
500
-		}
501
-
502
-		return apply_filters( 'wpinv_format_discount_rate', $rate, $this->get_type(), $this->get_amount() );
503
-	}
504
-
505
-	/**
506
-	 * Get the discount's start date.
507
-	 *
508
-	 * @since 1.0.19
509
-	 * @param  string $context View or edit context.
510
-	 * @return string
511
-	 */
512
-	public function get_start( $context = 'view' ) {
513
-		return $this->get_prop( 'start', $context );
514
-	}
515
-
516
-	/**
517
-	 * Alias for self::get_start().
518
-	 *
519
-	 * @since 1.0.19
520
-	 * @param  string $context View or edit context.
521
-	 * @return string
522
-	 */
523
-	public function get_start_date( $context = 'view' ) {
524
-		return $this->get_start( $context );
525
-	}
526
-
527
-	/**
528
-	 * Get the discount's expiration date.
529
-	 *
530
-	 * @since 1.0.19
531
-	 * @param  string $context View or edit context.
532
-	 * @return string
533
-	 */
534
-	public function get_expiration( $context = 'view' ) {
535
-		return $this->get_prop( 'expiration', $context );
536
-	}
537
-
538
-	/**
539
-	 * Alias for self::get_expiration().
540
-	 *
541
-	 * @since 1.0.19
542
-	 * @param  string $context View or edit context.
543
-	 * @return string
544
-	 */
545
-	public function get_expiration_date( $context = 'view' ) {
546
-		return $this->get_expiration( $context );
547
-	}
548
-
549
-	/**
550
-	 * Alias for self::get_expiration().
551
-	 *
552
-	 * @since 1.0.19
553
-	 * @param  string $context View or edit context.
554
-	 * @return string
555
-	 */
556
-	public function get_end_date( $context = 'view' ) {
557
-		return $this->get_expiration( $context );
558
-	}
559
-
560
-	/**
561
-	 * Get the discount's type.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @param  string $context View or edit context.
565
-	 * @return string
566
-	 */
567
-	public function get_type( $context = 'view' ) {
568
-		return $this->get_prop( 'type', $context );
569
-	}
570
-
571
-	/**
572
-	 * Get the number of times a discount has been used.
573
-	 *
574
-	 * @since 1.0.19
575
-	 * @param  string $context View or edit context.
576
-	 * @return int
577
-	 */
578
-	public function get_uses( $context = 'view' ) {
579
-		return (int) $this->get_prop( 'uses', $context );
580
-	}
581
-
582
-	/**
583
-	 * Get the discount's usage, i.e uses / max uses.
584
-	 *
585
-	 * @since 1.0.19
586
-	 * @return string
587
-	 */
588
-	public function get_usage() {
589
-
590
-		if ( ! $this->has_limit() ) {
591
-			return $this->get_uses() . ' / ' . ' &infin;';
592
-		}
593
-
594
-		return $this->get_uses() . ' / ' . (int) $this->get_max_uses();
595
-
596
-	}
597
-
598
-	/**
599
-	 * Get the maximum number of time a discount can be used.
600
-	 *
601
-	 * @since 1.0.19
602
-	 * @param  string $context View or edit context.
603
-	 * @return int
604
-	 */
605
-	public function get_max_uses( $context = 'view' ) {
606
-		$max_uses = $this->get_prop( 'max_uses', $context );
607
-		return empty( $max_uses ) ? null : $max_uses;
608
-	}
609
-
610
-	/**
611
-	 * Checks if this is a single use discount or not.
612
-	 *
613
-	 * @since 1.0.19
614
-	 * @param  string $context View or edit context.
615
-	 * @return bool
616
-	 */
617
-	public function get_is_single_use( $context = 'view' ) {
618
-		return $this->get_prop( 'is_single_use', $context );
619
-	}
620
-
621
-	/**
622
-	 * Get the items that can be used with this discount.
623
-	 *
624
-	 * @since 1.0.19
625
-	 * @param  string $context View or edit context.
626
-	 * @return array
627
-	 */
628
-	public function get_items( $context = 'view' ) {
629
-		return array_filter( wp_parse_id_list( $this->get_prop( 'items', $context ) ) );
630
-	}
631
-
632
-	/**
633
-	 * Alias for self::get_items().
634
-	 *
635
-	 * @since 1.0.19
636
-	 * @param  string $context View or edit context.
637
-	 * @return array
638
-	 */
639
-	public function get_allowed_items( $context = 'view' ) {
640
-		return $this->get_items( $context );
641
-	}
642
-
643
-	/**
644
-	 * Get the items that are not allowed to use this discount.
645
-	 *
646
-	 * @since 1.0.19
647
-	 * @param  string $context View or edit context.
648
-	 * @return array
649
-	 */
650
-	public function get_excluded_items( $context = 'view' ) {
651
-		return array_filter( wp_parse_id_list( $this->get_prop( 'excluded_items', $context ) ) );
652
-	}
653
-
654
-	/**
655
-	 * Get the items that are required to be in the cart before using this discount.
656
-	 *
657
-	 * @since 1.0.19
658
-	 * @param  string $context View or edit context.
659
-	 * @return array
660
-	 */
661
-	public function get_required_items( $context = 'view' ) {
662
-		return array_filter( wp_parse_id_list( $this->get_prop( 'required_items', $context ) ) );
663
-	}
664
-
665
-	/**
666
-	 * Checks if this is a recurring discount or not.
667
-	 *
668
-	 * @since 1.0.19
669
-	 * @param  string $context View or edit context.
670
-	 * @return int|string|bool
671
-	 */
672
-	public function get_is_recurring( $context = 'view' ) {
673
-		return $this->get_prop( 'is_recurring', $context );
674
-	}
675
-
676
-	/**
677
-	 * Get's the minimum total amount allowed for this discount.
678
-	 *
679
-	 * @since 1.0.19
680
-	 * @param  string $context View or edit context.
681
-	 * @return float
682
-	 */
683
-	public function get_min_total( $context = 'view' ) {
684
-		$minimum = $this->get_prop( 'min_total', $context );
685
-		return empty( $minimum ) ? null : $minimum;
686
-	}
687
-
688
-	/**
689
-	 * Alias for self::get_min_total().
690
-	 *
691
-	 * @since 1.0.19
692
-	 * @param  string $context View or edit context.
693
-	 * @return float
694
-	 */
695
-	public function get_minimum_total( $context = 'view' ) {
696
-		return $this->get_min_total( $context );
697
-	}
698
-
699
-	/**
700
-	 * Get's the maximum total amount allowed for this discount.
701
-	 *
702
-	 * @since 1.0.19
703
-	 * @param  string $context View or edit context.
704
-	 * @return float
705
-	 */
706
-	public function get_max_total( $context = 'view' ) {
707
-		$maximum = $this->get_prop( 'max_total', $context );
708
-		return empty( $maximum ) ? null : $maximum;
709
-	}
710
-
711
-	/**
712
-	 * Alias for self::get_max_total().
713
-	 *
714
-	 * @since 1.0.19
715
-	 * @param  string $context View or edit context.
716
-	 * @return float
717
-	 */
718
-	public function get_maximum_total( $context = 'view' ) {
719
-		return $this->get_max_total( $context );
720
-	}
721
-
722
-	/**
723
-	 * Magic method for accessing discount properties.
724
-	 *
725
-	 * @since 1.0.15
726
-	 * @access public
727
-	 *
728
-	 * @param string $key Discount data to retrieve
729
-	 * @param  string $context View or edit context.
730
-	 * @return mixed Value of the given discount property (if set).
731
-	 */
732
-	public function get( $key, $context = 'view' ) {
375
+        return $date;
376
+    }
377
+
378
+    /**
379
+     * Get the discount name.
380
+     *
381
+     * @since 1.0.19
382
+     * @param  string $context View or edit context.
383
+     * @return string
384
+     */
385
+    public function get_name( $context = 'view' ) {
386
+        return $this->get_prop( 'name', $context );
387
+    }
388
+
389
+    /**
390
+     * Alias of self::get_name().
391
+     *
392
+     * @since 1.0.19
393
+     * @param  string $context View or edit context.
394
+     * @return string
395
+     */
396
+    public function get_title( $context = 'view' ) {
397
+        return $this->get_name( $context );
398
+    }
399
+
400
+    /**
401
+     * Get the discount description.
402
+     *
403
+     * @since 1.0.19
404
+     * @param  string $context View or edit context.
405
+     * @return string
406
+     */
407
+    public function get_description( $context = 'view' ) {
408
+        return $this->get_prop( 'description', $context );
409
+    }
410
+
411
+    /**
412
+     * Alias of self::get_description().
413
+     *
414
+     * @since 1.0.19
415
+     * @param  string $context View or edit context.
416
+     * @return string
417
+     */
418
+    public function get_excerpt( $context = 'view' ) {
419
+        return $this->get_description( $context );
420
+    }
421
+
422
+    /**
423
+     * Alias of self::get_description().
424
+     *
425
+     * @since 1.0.19
426
+     * @param  string $context View or edit context.
427
+     * @return string
428
+     */
429
+    public function get_summary( $context = 'view' ) {
430
+        return $this->get_description( $context );
431
+    }
432
+
433
+    /**
434
+     * Get the owner of the discount.
435
+     *
436
+     * @since 1.0.19
437
+     * @param  string $context View or edit context.
438
+     * @return string
439
+     */
440
+    public function get_author( $context = 'view' ) {
441
+        return (int) $this->get_prop( 'author', $context );
442
+    }
443
+
444
+    /**
445
+     * Get the discount code.
446
+     *
447
+     * @since 1.0.19
448
+     * @param  string $context View or edit context.
449
+     * @return string
450
+     */
451
+    public function get_code( $context = 'view' ) {
452
+        return $this->get_prop( 'code', $context );
453
+    }
454
+
455
+    /**
456
+     * Alias for self::get_code().
457
+     *
458
+     * @since 1.0.19
459
+     * @param  string $context View or edit context.
460
+     * @return string
461
+     */
462
+    public function get_coupon_code( $context = 'view' ) {
463
+        return $this->get_code( $context );
464
+    }
465
+
466
+    /**
467
+     * Alias for self::get_code().
468
+     *
469
+     * @since 1.0.19
470
+     * @param  string $context View or edit context.
471
+     * @return string
472
+     */
473
+    public function get_discount_code( $context = 'view' ) {
474
+        return $this->get_code( $context );
475
+    }
476
+
477
+    /**
478
+     * Get the discount's amount.
479
+     *
480
+     * @since 1.0.19
481
+     * @param  string $context View or edit context.
482
+     * @return float
483
+     */
484
+    public function get_amount( $context = 'view' ) {
485
+        return $context == 'view' ? floatval( $this->get_prop( 'amount', $context ) ) : $this->get_prop( 'amount', $context );
486
+    }
487
+
488
+    /**
489
+     * Get the discount's formated amount/rate.
490
+     *
491
+     * @since 1.0.19
492
+     * @return string
493
+     */
494
+    public function get_formatted_amount() {
495
+
496
+        if ( $this->is_type( 'flat' ) ) {
497
+            $rate = wpinv_price( $this->get_amount() );
498
+        } else {
499
+            $rate = $this->get_amount() . '%';
500
+        }
501
+
502
+        return apply_filters( 'wpinv_format_discount_rate', $rate, $this->get_type(), $this->get_amount() );
503
+    }
504
+
505
+    /**
506
+     * Get the discount's start date.
507
+     *
508
+     * @since 1.0.19
509
+     * @param  string $context View or edit context.
510
+     * @return string
511
+     */
512
+    public function get_start( $context = 'view' ) {
513
+        return $this->get_prop( 'start', $context );
514
+    }
515
+
516
+    /**
517
+     * Alias for self::get_start().
518
+     *
519
+     * @since 1.0.19
520
+     * @param  string $context View or edit context.
521
+     * @return string
522
+     */
523
+    public function get_start_date( $context = 'view' ) {
524
+        return $this->get_start( $context );
525
+    }
526
+
527
+    /**
528
+     * Get the discount's expiration date.
529
+     *
530
+     * @since 1.0.19
531
+     * @param  string $context View or edit context.
532
+     * @return string
533
+     */
534
+    public function get_expiration( $context = 'view' ) {
535
+        return $this->get_prop( 'expiration', $context );
536
+    }
537
+
538
+    /**
539
+     * Alias for self::get_expiration().
540
+     *
541
+     * @since 1.0.19
542
+     * @param  string $context View or edit context.
543
+     * @return string
544
+     */
545
+    public function get_expiration_date( $context = 'view' ) {
546
+        return $this->get_expiration( $context );
547
+    }
548
+
549
+    /**
550
+     * Alias for self::get_expiration().
551
+     *
552
+     * @since 1.0.19
553
+     * @param  string $context View or edit context.
554
+     * @return string
555
+     */
556
+    public function get_end_date( $context = 'view' ) {
557
+        return $this->get_expiration( $context );
558
+    }
559
+
560
+    /**
561
+     * Get the discount's type.
562
+     *
563
+     * @since 1.0.19
564
+     * @param  string $context View or edit context.
565
+     * @return string
566
+     */
567
+    public function get_type( $context = 'view' ) {
568
+        return $this->get_prop( 'type', $context );
569
+    }
570
+
571
+    /**
572
+     * Get the number of times a discount has been used.
573
+     *
574
+     * @since 1.0.19
575
+     * @param  string $context View or edit context.
576
+     * @return int
577
+     */
578
+    public function get_uses( $context = 'view' ) {
579
+        return (int) $this->get_prop( 'uses', $context );
580
+    }
581
+
582
+    /**
583
+     * Get the discount's usage, i.e uses / max uses.
584
+     *
585
+     * @since 1.0.19
586
+     * @return string
587
+     */
588
+    public function get_usage() {
589
+
590
+        if ( ! $this->has_limit() ) {
591
+            return $this->get_uses() . ' / ' . ' &infin;';
592
+        }
593
+
594
+        return $this->get_uses() . ' / ' . (int) $this->get_max_uses();
595
+
596
+    }
597
+
598
+    /**
599
+     * Get the maximum number of time a discount can be used.
600
+     *
601
+     * @since 1.0.19
602
+     * @param  string $context View or edit context.
603
+     * @return int
604
+     */
605
+    public function get_max_uses( $context = 'view' ) {
606
+        $max_uses = $this->get_prop( 'max_uses', $context );
607
+        return empty( $max_uses ) ? null : $max_uses;
608
+    }
609
+
610
+    /**
611
+     * Checks if this is a single use discount or not.
612
+     *
613
+     * @since 1.0.19
614
+     * @param  string $context View or edit context.
615
+     * @return bool
616
+     */
617
+    public function get_is_single_use( $context = 'view' ) {
618
+        return $this->get_prop( 'is_single_use', $context );
619
+    }
620
+
621
+    /**
622
+     * Get the items that can be used with this discount.
623
+     *
624
+     * @since 1.0.19
625
+     * @param  string $context View or edit context.
626
+     * @return array
627
+     */
628
+    public function get_items( $context = 'view' ) {
629
+        return array_filter( wp_parse_id_list( $this->get_prop( 'items', $context ) ) );
630
+    }
631
+
632
+    /**
633
+     * Alias for self::get_items().
634
+     *
635
+     * @since 1.0.19
636
+     * @param  string $context View or edit context.
637
+     * @return array
638
+     */
639
+    public function get_allowed_items( $context = 'view' ) {
640
+        return $this->get_items( $context );
641
+    }
642
+
643
+    /**
644
+     * Get the items that are not allowed to use this discount.
645
+     *
646
+     * @since 1.0.19
647
+     * @param  string $context View or edit context.
648
+     * @return array
649
+     */
650
+    public function get_excluded_items( $context = 'view' ) {
651
+        return array_filter( wp_parse_id_list( $this->get_prop( 'excluded_items', $context ) ) );
652
+    }
653
+
654
+    /**
655
+     * Get the items that are required to be in the cart before using this discount.
656
+     *
657
+     * @since 1.0.19
658
+     * @param  string $context View or edit context.
659
+     * @return array
660
+     */
661
+    public function get_required_items( $context = 'view' ) {
662
+        return array_filter( wp_parse_id_list( $this->get_prop( 'required_items', $context ) ) );
663
+    }
664
+
665
+    /**
666
+     * Checks if this is a recurring discount or not.
667
+     *
668
+     * @since 1.0.19
669
+     * @param  string $context View or edit context.
670
+     * @return int|string|bool
671
+     */
672
+    public function get_is_recurring( $context = 'view' ) {
673
+        return $this->get_prop( 'is_recurring', $context );
674
+    }
675
+
676
+    /**
677
+     * Get's the minimum total amount allowed for this discount.
678
+     *
679
+     * @since 1.0.19
680
+     * @param  string $context View or edit context.
681
+     * @return float
682
+     */
683
+    public function get_min_total( $context = 'view' ) {
684
+        $minimum = $this->get_prop( 'min_total', $context );
685
+        return empty( $minimum ) ? null : $minimum;
686
+    }
687
+
688
+    /**
689
+     * Alias for self::get_min_total().
690
+     *
691
+     * @since 1.0.19
692
+     * @param  string $context View or edit context.
693
+     * @return float
694
+     */
695
+    public function get_minimum_total( $context = 'view' ) {
696
+        return $this->get_min_total( $context );
697
+    }
698
+
699
+    /**
700
+     * Get's the maximum total amount allowed for this discount.
701
+     *
702
+     * @since 1.0.19
703
+     * @param  string $context View or edit context.
704
+     * @return float
705
+     */
706
+    public function get_max_total( $context = 'view' ) {
707
+        $maximum = $this->get_prop( 'max_total', $context );
708
+        return empty( $maximum ) ? null : $maximum;
709
+    }
710
+
711
+    /**
712
+     * Alias for self::get_max_total().
713
+     *
714
+     * @since 1.0.19
715
+     * @param  string $context View or edit context.
716
+     * @return float
717
+     */
718
+    public function get_maximum_total( $context = 'view' ) {
719
+        return $this->get_max_total( $context );
720
+    }
721
+
722
+    /**
723
+     * Magic method for accessing discount properties.
724
+     *
725
+     * @since 1.0.15
726
+     * @access public
727
+     *
728
+     * @param string $key Discount data to retrieve
729
+     * @param  string $context View or edit context.
730
+     * @return mixed Value of the given discount property (if set).
731
+     */
732
+    public function get( $key, $context = 'view' ) {
733 733
         return $this->get_prop( $key, $context );
734
-	}
734
+    }
735 735
 
736
-	/*
736
+    /*
737 737
 	|--------------------------------------------------------------------------
738 738
 	| Setters
739 739
 	|--------------------------------------------------------------------------
@@ -743,41 +743,41 @@  discard block
 block discarded – undo
743 743
 	| object.
744 744
 	*/
745 745
 
746
-	/**
747
-	 * Sets discount status.
748
-	 *
749
-	 * @since 1.0.19
750
-	 * @param  string $status New status.
751
-	 * @return array details of change.
752
-	 */
753
-	public function set_status( $status ) {
746
+    /**
747
+     * Sets discount status.
748
+     *
749
+     * @since 1.0.19
750
+     * @param  string $status New status.
751
+     * @return array details of change.
752
+     */
753
+    public function set_status( $status ) {
754 754
         $old_status = $this->get_status();
755 755
 
756 756
         $this->set_prop( 'status', $status );
757 757
 
758
-		return array(
759
-			'from' => $old_status,
760
-			'to'   => $status,
761
-		);
758
+        return array(
759
+            'from' => $old_status,
760
+            'to'   => $status,
761
+        );
762 762
     }
763 763
 
764 764
     /**
765
-	 * Set plugin version when the discount was created.
766
-	 *
767
-	 * @since 1.0.19
768
-	 */
769
-	public function set_version( $value ) {
770
-		$this->set_prop( 'version', $value );
765
+     * Set plugin version when the discount was created.
766
+     *
767
+     * @since 1.0.19
768
+     */
769
+    public function set_version( $value ) {
770
+        $this->set_prop( 'version', $value );
771 771
     }
772 772
 
773 773
     /**
774
-	 * Set date when the discount was created.
775
-	 *
776
-	 * @since 1.0.19
777
-	 * @param string $value Value to set.
774
+     * Set date when the discount was created.
775
+     *
776
+     * @since 1.0.19
777
+     * @param string $value Value to set.
778 778
      * @return bool Whether or not the date was set.
779
-	 */
780
-	public function set_date_created( $value ) {
779
+     */
780
+    public function set_date_created( $value ) {
781 781
         $date = strtotime( $value );
782 782
 
783 783
         if ( $date ) {
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
     }
791 791
 
792 792
     /**
793
-	 * Set date when the discount was last modified.
794
-	 *
795
-	 * @since 1.0.19
796
-	 * @param string $value Value to set.
793
+     * Set date when the discount was last modified.
794
+     *
795
+     * @since 1.0.19
796
+     * @param string $value Value to set.
797 797
      * @return bool Whether or not the date was set.
798
-	 */
799
-	public function set_date_modified( $value ) {
798
+     */
799
+    public function set_date_modified( $value ) {
800 800
         $date = strtotime( $value );
801 801
 
802 802
         if ( $date ) {
@@ -809,334 +809,334 @@  discard block
 block discarded – undo
809 809
     }
810 810
 
811 811
     /**
812
-	 * Set the discount name.
813
-	 *
814
-	 * @since 1.0.19
815
-	 * @param  string $value New name.
816
-	 */
817
-	public function set_name( $value ) {
812
+     * Set the discount name.
813
+     *
814
+     * @since 1.0.19
815
+     * @param  string $value New name.
816
+     */
817
+    public function set_name( $value ) {
818 818
         $name = sanitize_text_field( $value );
819
-		$this->set_prop( 'name', $name );
819
+        $this->set_prop( 'name', $name );
820 820
     }
821 821
 
822 822
     /**
823
-	 * Alias of self::set_name().
824
-	 *
825
-	 * @since 1.0.19
826
-	 * @param  string $value New name.
827
-	 */
828
-	public function set_title( $value ) {
829
-		$this->set_name( $value );
823
+     * Alias of self::set_name().
824
+     *
825
+     * @since 1.0.19
826
+     * @param  string $value New name.
827
+     */
828
+    public function set_title( $value ) {
829
+        $this->set_name( $value );
830 830
     }
831 831
 
832 832
     /**
833
-	 * Set the discount description.
834
-	 *
835
-	 * @since 1.0.19
836
-	 * @param  string $value New description.
837
-	 */
838
-	public function set_description( $value ) {
833
+     * Set the discount description.
834
+     *
835
+     * @since 1.0.19
836
+     * @param  string $value New description.
837
+     */
838
+    public function set_description( $value ) {
839 839
         $description = wp_kses_post( $value );
840
-		return $this->set_prop( 'description', $description );
841
-    }
842
-
843
-    /**
844
-	 * Alias of self::set_description().
845
-	 *
846
-	 * @since 1.0.19
847
-	 * @param  string $value New description.
848
-	 */
849
-	public function set_excerpt( $value ) {
850
-		$this->set_description( $value );
851
-    }
852
-
853
-    /**
854
-	 * Alias of self::set_description().
855
-	 *
856
-	 * @since 1.0.19
857
-	 * @param  string $value New description.
858
-	 */
859
-	public function set_summary( $value ) {
860
-		$this->set_description( $value );
861
-    }
862
-
863
-    /**
864
-	 * Set the owner of the discount.
865
-	 *
866
-	 * @since 1.0.19
867
-	 * @param  int $value New author.
868
-	 */
869
-	public function set_author( $value ) {
870
-		$this->set_prop( 'author', (int) $value );
871
-	}
872
-
873
-	/**
874
-	 * Sets the discount code.
875
-	 *
876
-	 * @since 1.0.19
877
-	 * @param string $value New discount code.
878
-	 */
879
-	public function set_code( $value ) {
880
-		$code = sanitize_text_field( $value );
881
-		$this->set_prop( 'code', $code );
882
-	}
883
-
884
-	/**
885
-	 * Alias of self::set_code().
886
-	 *
887
-	 * @since 1.0.19
888
-	 * @param string $value New discount code.
889
-	 */
890
-	public function set_coupon_code( $value ) {
891
-		$this->set_code( $value );
892
-	}
893
-
894
-	/**
895
-	 * Alias of self::set_code().
896
-	 *
897
-	 * @since 1.0.19
898
-	 * @param string $value New discount code.
899
-	 */
900
-	public function set_discount_code( $value ) {
901
-		$this->set_code( $value );
902
-	}
903
-
904
-	/**
905
-	 * Sets the discount amount.
906
-	 *
907
-	 * @since 1.0.19
908
-	 * @param float $value New discount code.
909
-	 */
910
-	public function set_amount( $value ) {
911
-		$amount = floatval( wpinv_sanitize_amount( $value ) );
912
-		$this->set_prop( 'amount', $amount );
913
-	}
914
-
915
-	/**
916
-	 * Sets the discount's start date.
917
-	 *
918
-	 * @since 1.0.19
919
-	 * @param float $value New start date.
920
-	 */
921
-	public function set_start( $value ) {
922
-		$date = strtotime( $value );
840
+        return $this->set_prop( 'description', $description );
841
+    }
842
+
843
+    /**
844
+     * Alias of self::set_description().
845
+     *
846
+     * @since 1.0.19
847
+     * @param  string $value New description.
848
+     */
849
+    public function set_excerpt( $value ) {
850
+        $this->set_description( $value );
851
+    }
852
+
853
+    /**
854
+     * Alias of self::set_description().
855
+     *
856
+     * @since 1.0.19
857
+     * @param  string $value New description.
858
+     */
859
+    public function set_summary( $value ) {
860
+        $this->set_description( $value );
861
+    }
862
+
863
+    /**
864
+     * Set the owner of the discount.
865
+     *
866
+     * @since 1.0.19
867
+     * @param  int $value New author.
868
+     */
869
+    public function set_author( $value ) {
870
+        $this->set_prop( 'author', (int) $value );
871
+    }
872
+
873
+    /**
874
+     * Sets the discount code.
875
+     *
876
+     * @since 1.0.19
877
+     * @param string $value New discount code.
878
+     */
879
+    public function set_code( $value ) {
880
+        $code = sanitize_text_field( $value );
881
+        $this->set_prop( 'code', $code );
882
+    }
883
+
884
+    /**
885
+     * Alias of self::set_code().
886
+     *
887
+     * @since 1.0.19
888
+     * @param string $value New discount code.
889
+     */
890
+    public function set_coupon_code( $value ) {
891
+        $this->set_code( $value );
892
+    }
893
+
894
+    /**
895
+     * Alias of self::set_code().
896
+     *
897
+     * @since 1.0.19
898
+     * @param string $value New discount code.
899
+     */
900
+    public function set_discount_code( $value ) {
901
+        $this->set_code( $value );
902
+    }
903
+
904
+    /**
905
+     * Sets the discount amount.
906
+     *
907
+     * @since 1.0.19
908
+     * @param float $value New discount code.
909
+     */
910
+    public function set_amount( $value ) {
911
+        $amount = floatval( wpinv_sanitize_amount( $value ) );
912
+        $this->set_prop( 'amount', $amount );
913
+    }
914
+
915
+    /**
916
+     * Sets the discount's start date.
917
+     *
918
+     * @since 1.0.19
919
+     * @param float $value New start date.
920
+     */
921
+    public function set_start( $value ) {
922
+        $date = strtotime( $value );
923 923
 
924 924
         if ( $date ) {
925 925
             $this->set_prop( 'start', date( 'Y-m-d H:i', $date ) );
926 926
             return true;
927
-		}
927
+        }
928 928
 
929
-		$this->set_prop( 'start', '' );
929
+        $this->set_prop( 'start', '' );
930 930
 
931 931
         return false;
932
-	}
933
-
934
-	/**
935
-	 * Alias of self::set_start().
936
-	 *
937
-	 * @since 1.0.19
938
-	 * @param string $value New start date.
939
-	 */
940
-	public function set_start_date( $value ) {
941
-		$this->set_start( $value );
942
-	}
943
-
944
-	/**
945
-	 * Sets the discount's expiration date.
946
-	 *
947
-	 * @since 1.0.19
948
-	 * @param float $value New expiration date.
949
-	 */
950
-	public function set_expiration( $value ) {
951
-		$date = strtotime( $value );
932
+    }
933
+
934
+    /**
935
+     * Alias of self::set_start().
936
+     *
937
+     * @since 1.0.19
938
+     * @param string $value New start date.
939
+     */
940
+    public function set_start_date( $value ) {
941
+        $this->set_start( $value );
942
+    }
943
+
944
+    /**
945
+     * Sets the discount's expiration date.
946
+     *
947
+     * @since 1.0.19
948
+     * @param float $value New expiration date.
949
+     */
950
+    public function set_expiration( $value ) {
951
+        $date = strtotime( $value );
952 952
 
953 953
         if ( $date ) {
954 954
             $this->set_prop( 'expiration', date( 'Y-m-d H:i', $date ) );
955 955
             return true;
956 956
         }
957 957
 
958
-		$this->set_prop( 'expiration', '' );
958
+        $this->set_prop( 'expiration', '' );
959 959
         return false;
960
-	}
961
-
962
-	/**
963
-	 * Alias of self::set_expiration().
964
-	 *
965
-	 * @since 1.0.19
966
-	 * @param string $value New expiration date.
967
-	 */
968
-	public function set_expiration_date( $value ) {
969
-		$this->set_expiration( $value );
970
-	}
971
-
972
-	/**
973
-	 * Alias of self::set_expiration().
974
-	 *
975
-	 * @since 1.0.19
976
-	 * @param string $value New expiration date.
977
-	 */
978
-	public function set_end_date( $value ) {
979
-		$this->set_expiration( $value );
980
-	}
981
-
982
-	/**
983
-	 * Sets the discount type.
984
-	 *
985
-	 * @since 1.0.19
986
-	 * @param string $value New discount type.
987
-	 */
988
-	public function set_type( $value ) {
989
-		if ( $value && array_key_exists( sanitize_text_field( $value ), wpinv_get_discount_types() ) ) {
990
-			$this->set_prop( 'type', sanitize_text_field( $value ) );
991
-		}
992
-	}
993
-
994
-	/**
995
-	 * Sets the number of times a discount has been used.
996
-	 *
997
-	 * @since 1.0.19
998
-	 * @param int $value usage count.
999
-	 */
1000
-	public function set_uses( $value ) {
1001
-
1002
-		$value = (int) $value;
1003
-
1004
-		if ( $value < 0 ) {
1005
-			$value = 0;
1006
-		}
1007
-
1008
-		$this->set_prop( 'uses', (int) $value );
1009
-	}
1010
-
1011
-	/**
1012
-	 * Sets the maximum number of times a discount can be used.
1013
-	 *
1014
-	 * @since 1.0.19
1015
-	 * @param int $value maximum usage count.
1016
-	 */
1017
-	public function set_max_uses( $value ) {
1018
-		$this->set_prop( 'max_uses', absint( $value ) );
1019
-	}
1020
-
1021
-	/**
1022
-	 * Sets if this is a single use discount or not.
1023
-	 *
1024
-	 * @since 1.0.19
1025
-	 * @param int|bool $value is single use.
1026
-	 */
1027
-	public function set_is_single_use( $value ) {
1028
-		$this->set_prop( 'is_single_use', (bool) $value );
1029
-	}
1030
-
1031
-	/**
1032
-	 * Sets the items that can be used with this discount.
1033
-	 *
1034
-	 * @since 1.0.19
1035
-	 * @param array $value items.
1036
-	 */
1037
-	public function set_items( $value ) {
1038
-		$this->set_prop( 'items', array_filter( wp_parse_id_list( $value ) ) );
1039
-	}
1040
-
1041
-	/**
1042
-	 * Alias for self::set_items().
1043
-	 *
1044
-	 * @since 1.0.19
1045
-	 * @param array $value items.
1046
-	 */
1047
-	public function set_allowed_items( $value ) {
1048
-		$this->set_items( $value );
1049
-	}
1050
-
1051
-	/**
1052
-	 * Sets the items that can not be used with this discount.
1053
-	 *
1054
-	 * @since 1.0.19
1055
-	 * @param array $value items.
1056
-	 */
1057
-	public function set_excluded_items( $value ) {
1058
-		$this->set_prop( 'excluded_items', array_filter( wp_parse_id_list( $value ) ) );
1059
-	}
1060
-
1061
-	/**
1062
-	 * Sets the items that are required to be in the cart before using this discount.
1063
-	 *
1064
-	 * @since 1.0.19
1065
-	 * @param array $value items.
1066
-	 */
1067
-	public function set_required_items( $value ) {
1068
-		$this->set_prop( 'required_items', array_filter( wp_parse_id_list( $value ) ) );
1069
-	}
1070
-
1071
-	/**
1072
-	 * Sets if this is a recurring discounts or not.
1073
-	 *
1074
-	 * @since 1.0.19
1075
-	 * @param int|bool $value is recurring.
1076
-	 */
1077
-	public function set_is_recurring( $value ) {
1078
-		$this->set_prop( 'is_recurring', (bool) $value );
1079
-	}
1080
-
1081
-	/**
1082
-	 * Sets the minimum total that can not be used with this discount.
1083
-	 *
1084
-	 * @since 1.0.19
1085
-	 * @param float $value minimum total.
1086
-	 */
1087
-	public function set_min_total( $value ) {
1088
-		$this->set_prop( 'min_total', (float) wpinv_sanitize_amount( $value ) );
1089
-	}
1090
-
1091
-	/**
1092
-	 * Alias for self::set_min_total().
1093
-	 *
1094
-	 * @since 1.0.19
1095
-	 * @param float $value minimum total.
1096
-	 */
1097
-	public function set_minimum_total( $value ) {
1098
-		$this->set_min_total( $value );
1099
-	}
1100
-
1101
-	/**
1102
-	 * Sets the maximum total that can not be used with this discount.
1103
-	 *
1104
-	 * @since 1.0.19
1105
-	 * @param float $value maximum total.
1106
-	 */
1107
-	public function set_max_total( $value ) {
1108
-		$this->set_prop( 'max_total', (float) wpinv_sanitize_amount( $value ) );
1109
-	}
1110
-
1111
-	/**
1112
-	 * Alias for self::set_max_total().
1113
-	 *
1114
-	 * @since 1.0.19
1115
-	 * @param float $value maximum total.
1116
-	 */
1117
-	public function set_maximum_total( $value ) {
1118
-		$this->set_max_total( $value );
1119
-	}
1120
-
1121
-	/**
1122
-	 * @deprecated
1123
-	 */
1124
-	public function refresh(){}
1125
-
1126
-	/**
1127
-	 * @deprecated
1128
-	 *
1129
-	 */
1130
-	public function update_status( $status = 'publish' ) {
1131
-
1132
-		if ( $this->exists() && $this->get_status() != $status ) {
1133
-			$this->set_status( $status );
1134
-			$this->save();
1135
-		}
1136
-
1137
-	}
1138
-
1139
-	/*
960
+    }
961
+
962
+    /**
963
+     * Alias of self::set_expiration().
964
+     *
965
+     * @since 1.0.19
966
+     * @param string $value New expiration date.
967
+     */
968
+    public function set_expiration_date( $value ) {
969
+        $this->set_expiration( $value );
970
+    }
971
+
972
+    /**
973
+     * Alias of self::set_expiration().
974
+     *
975
+     * @since 1.0.19
976
+     * @param string $value New expiration date.
977
+     */
978
+    public function set_end_date( $value ) {
979
+        $this->set_expiration( $value );
980
+    }
981
+
982
+    /**
983
+     * Sets the discount type.
984
+     *
985
+     * @since 1.0.19
986
+     * @param string $value New discount type.
987
+     */
988
+    public function set_type( $value ) {
989
+        if ( $value && array_key_exists( sanitize_text_field( $value ), wpinv_get_discount_types() ) ) {
990
+            $this->set_prop( 'type', sanitize_text_field( $value ) );
991
+        }
992
+    }
993
+
994
+    /**
995
+     * Sets the number of times a discount has been used.
996
+     *
997
+     * @since 1.0.19
998
+     * @param int $value usage count.
999
+     */
1000
+    public function set_uses( $value ) {
1001
+
1002
+        $value = (int) $value;
1003
+
1004
+        if ( $value < 0 ) {
1005
+            $value = 0;
1006
+        }
1007
+
1008
+        $this->set_prop( 'uses', (int) $value );
1009
+    }
1010
+
1011
+    /**
1012
+     * Sets the maximum number of times a discount can be used.
1013
+     *
1014
+     * @since 1.0.19
1015
+     * @param int $value maximum usage count.
1016
+     */
1017
+    public function set_max_uses( $value ) {
1018
+        $this->set_prop( 'max_uses', absint( $value ) );
1019
+    }
1020
+
1021
+    /**
1022
+     * Sets if this is a single use discount or not.
1023
+     *
1024
+     * @since 1.0.19
1025
+     * @param int|bool $value is single use.
1026
+     */
1027
+    public function set_is_single_use( $value ) {
1028
+        $this->set_prop( 'is_single_use', (bool) $value );
1029
+    }
1030
+
1031
+    /**
1032
+     * Sets the items that can be used with this discount.
1033
+     *
1034
+     * @since 1.0.19
1035
+     * @param array $value items.
1036
+     */
1037
+    public function set_items( $value ) {
1038
+        $this->set_prop( 'items', array_filter( wp_parse_id_list( $value ) ) );
1039
+    }
1040
+
1041
+    /**
1042
+     * Alias for self::set_items().
1043
+     *
1044
+     * @since 1.0.19
1045
+     * @param array $value items.
1046
+     */
1047
+    public function set_allowed_items( $value ) {
1048
+        $this->set_items( $value );
1049
+    }
1050
+
1051
+    /**
1052
+     * Sets the items that can not be used with this discount.
1053
+     *
1054
+     * @since 1.0.19
1055
+     * @param array $value items.
1056
+     */
1057
+    public function set_excluded_items( $value ) {
1058
+        $this->set_prop( 'excluded_items', array_filter( wp_parse_id_list( $value ) ) );
1059
+    }
1060
+
1061
+    /**
1062
+     * Sets the items that are required to be in the cart before using this discount.
1063
+     *
1064
+     * @since 1.0.19
1065
+     * @param array $value items.
1066
+     */
1067
+    public function set_required_items( $value ) {
1068
+        $this->set_prop( 'required_items', array_filter( wp_parse_id_list( $value ) ) );
1069
+    }
1070
+
1071
+    /**
1072
+     * Sets if this is a recurring discounts or not.
1073
+     *
1074
+     * @since 1.0.19
1075
+     * @param int|bool $value is recurring.
1076
+     */
1077
+    public function set_is_recurring( $value ) {
1078
+        $this->set_prop( 'is_recurring', (bool) $value );
1079
+    }
1080
+
1081
+    /**
1082
+     * Sets the minimum total that can not be used with this discount.
1083
+     *
1084
+     * @since 1.0.19
1085
+     * @param float $value minimum total.
1086
+     */
1087
+    public function set_min_total( $value ) {
1088
+        $this->set_prop( 'min_total', (float) wpinv_sanitize_amount( $value ) );
1089
+    }
1090
+
1091
+    /**
1092
+     * Alias for self::set_min_total().
1093
+     *
1094
+     * @since 1.0.19
1095
+     * @param float $value minimum total.
1096
+     */
1097
+    public function set_minimum_total( $value ) {
1098
+        $this->set_min_total( $value );
1099
+    }
1100
+
1101
+    /**
1102
+     * Sets the maximum total that can not be used with this discount.
1103
+     *
1104
+     * @since 1.0.19
1105
+     * @param float $value maximum total.
1106
+     */
1107
+    public function set_max_total( $value ) {
1108
+        $this->set_prop( 'max_total', (float) wpinv_sanitize_amount( $value ) );
1109
+    }
1110
+
1111
+    /**
1112
+     * Alias for self::set_max_total().
1113
+     *
1114
+     * @since 1.0.19
1115
+     * @param float $value maximum total.
1116
+     */
1117
+    public function set_maximum_total( $value ) {
1118
+        $this->set_max_total( $value );
1119
+    }
1120
+
1121
+    /**
1122
+     * @deprecated
1123
+     */
1124
+    public function refresh(){}
1125
+
1126
+    /**
1127
+     * @deprecated
1128
+     *
1129
+     */
1130
+    public function update_status( $status = 'publish' ) {
1131
+
1132
+        if ( $this->exists() && $this->get_status() != $status ) {
1133
+            $this->set_status( $status );
1134
+            $this->save();
1135
+        }
1136
+
1137
+    }
1138
+
1139
+    /*
1140 1140
 	|--------------------------------------------------------------------------
1141 1141
 	| Conditionals
1142 1142
 	|--------------------------------------------------------------------------
@@ -1145,290 +1145,290 @@  discard block
 block discarded – undo
1145 1145
 	|
1146 1146
 	*/
1147 1147
 
1148
-	/**
1149
-	 * Checks whether a discount exists in the database or not
1150
-	 *
1151
-	 * @since 1.0.15
1152
-	 */
1153
-	public function exists() {
1154
-		$id = $this->get_id();
1155
-		return ! empty( $id );
1156
-	}
1157
-
1158
-	/**
1159
-	 * Checks the discount type.
1160
-	 *
1161
-	 *
1162
-	 * @param  string $type the discount type to check against
1163
-	 * @since 1.0.15
1164
-	 * @return bool
1165
-	 */
1166
-	public function is_type( $type ) {
1167
-		return $this->get_type() == $type;
1168
-	}
1169
-
1170
-	/**
1171
-	 * Checks whether the discount is published or not
1172
-	 *
1173
-	 * @since 1.0.15
1174
-	 * @return bool
1175
-	 */
1176
-	public function is_active() {
1177
-		return $this->get_status() == 'publish';
1178
-	}
1179
-
1180
-	/**
1181
-	 * Checks whether the discount has max uses
1182
-	 *
1183
-	 * @since 1.0.15
1184
-	 * @return bool
1185
-	 */
1186
-	public function has_limit() {
1187
-		$limit = $this->get_max_uses();
1188
-		return ! empty( $limit );
1189
-	}
1190
-
1191
-	/**
1192
-	 * Checks whether the discount has ever been used.
1193
-	 *
1194
-	 * @since 1.0.15
1195
-	 * @return bool
1196
-	 */
1197
-	public function has_uses() {
1198
-		return $this->get_uses() > 0;
1199
-	}
1200
-
1201
-	/**
1202
-	 * Checks whether the discount is has exided the usage limit or not
1203
-	 *
1204
-	 * @since 1.0.15
1205
-	 * @return bool
1206
-	 */
1207
-	public function has_exceeded_limit() {
1208
-
1209
-		if ( ! $this->has_limit() || ! $this->has_uses() ) {
1210
-			$exceeded = false;
1211
-		} else {
1212
-			$exceeded = (int) $this->get_max_uses() <= $this->get_uses();
1213
-		}
1214
-
1215
-		return apply_filters( 'wpinv_is_discount_maxed_out', $exceeded, $this->get_id(), $this, $this->get_code() );
1216
-	}
1217
-
1218
-	/**
1219
-	 * Checks whether the discount has an expiration date.
1220
-	 *
1221
-	 * @since 1.0.15
1222
-	 * @return bool
1223
-	 */
1224
-	public function has_expiration_date() {
1225
-		$date = $this->get_expiration_date();
1226
-		return ! empty( $date );
1227
-	}
1228
-
1229
-	/**
1230
-	 * Checks if the discount is expired
1231
-	 *
1232
-	 * @since 1.0.15
1233
-	 * @return bool
1234
-	 */
1235
-	public function is_expired() {
1236
-		$expired = $this->has_expiration_date() ? current_time( 'timestamp' ) > strtotime( $this->get_expiration_date() ) : false;
1237
-		return apply_filters( 'wpinv_is_discount_expired', $expired, $this->get_id(), $this, $this->get_code() );
1238
-	}
1239
-
1240
-	/**
1241
-	 * Checks whether the discount has a start date.
1242
-	 *
1243
-	 * @since 1.0.15
1244
-	 * @return bool
1245
-	 */
1246
-	public function has_start_date() {
1247
-		$date = $this->get_start_date();
1248
-		return ! empty( $date );
1249
-	}
1250
-
1251
-	/**
1252
-	 * Checks the discount start date.
1253
-	 *
1254
-	 * @since 1.0.15
1255
-	 * @return bool
1256
-	 */
1257
-	public function has_started() {
1258
-		$started = $this->has_start_date() ? true : current_time( 'timestamp' ) > strtotime( $this->get_start_date() );
1259
-		return apply_filters( 'wpinv_is_discount_started', $started, $this->get_id(), $this, $this->get_code() );
1260
-	}
1261
-
1262
-	/**
1263
-	 * Checks the discount has allowed items or not.
1264
-	 *
1265
-	 * @since 1.0.15
1266
-	 * @return bool
1267
-	 */
1268
-	public function has_allowed_items() {
1269
-		$allowed_items = $this->get_allowed_items();
1270
-		return ! empty( $allowed_items );
1271
-	}
1272
-
1273
-	/**
1274
-	 * Checks the discount has excluded items or not.
1275
-	 *
1276
-	 * @since 1.0.15
1277
-	 * @return bool
1278
-	 */
1279
-	public function has_excluded_items() {
1280
-		$excluded_items = $this->get_excluded_items();
1281
-		return ! empty( $excluded_items );
1282
-	}
1283
-
1284
-	/**
1285
-	 * Check if a discount is valid for a given item id.
1286
-	 *
1287
-	 * @param  int|int[]  $item_ids
1288
-	 * @since 1.0.15
1289
-	 * @return boolean
1290
-	 */
1291
-	public function is_valid_for_items( $item_ids ) {
1292
-
1293
-		$item_ids = array_filter( wp_parse_id_list( $item_ids ) );
1294
-		$included = array_intersect( $item_ids, $this->get_allowed_items() );
1295
-		$excluded = array_intersect( $item_ids, $this->get_excluded_items() );
1296
-
1297
-		if ( $this->has_excluded_items() && ! empty( $excluded ) ) {
1298
-			return false;
1299
-		}
1300
-
1301
-		if ( $this->has_allowed_items() && empty( $included ) ) {
1302
-			return false;
1303
-		}
1304
-
1305
-		return true;
1306
-	}
1307
-
1308
-	/**
1309
-	 * Checks the discount has required items or not.
1310
-	 *
1311
-	 * @since 1.0.15
1312
-	 * @return bool
1313
-	 */
1314
-	public function has_required_items() {
1315
-		$required_items = $this->get_required_items();
1316
-		return ! empty( $required_items );
1317
-	}
1318
-
1319
-	/**
1320
-	 * Checks if the required items are met
1321
-	 *
1322
-	 * @param  int|int[]  $item_ids
1323
-	 * @since 1.0.15
1324
-	 * @return boolean
1325
-	 */
1326
-	public function is_required_items_met( $item_ids ) {
1327
-
1328
-		if ( ! $this->has_required_items() ) {
1329
-			return true;
1330
-		}
1331
-
1332
-		return ! array_diff( $this->get_required_items(), array_filter( wp_parse_id_list( $item_ids ) ) );
1333
-	}
1334
-
1335
-	/**
1336
-	 * Check if a discount is valid for the given amount
1337
-	 *
1338
-	 * @param  float  $amount The amount to check against
1339
-	 * @since 1.0.15
1340
-	 * @return boolean
1341
-	 */
1342
-	public function is_valid_for_amount( $amount ) {
1343
-		return $this->is_minimum_amount_met( $amount ) && $this->is_maximum_amount_met( $amount );
1344
-	}
1345
-
1346
-	/**
1347
-	 * Checks if the minimum amount is set
1348
-	 *
1349
-	 * @since 1.0.15
1350
-	 * @return boolean
1351
-	 */
1352
-	public function has_minimum_amount() {
1353
-		$minimum = $this->get_minimum_total();
1354
-		return ! empty( $minimum );
1355
-	}
1356
-
1357
-	/**
1358
-	 * Checks if the minimum amount is met
1359
-	 *
1360
-	 * @param  float  $amount The amount to check against
1361
-	 * @since 1.0.15
1362
-	 * @return boolean
1363
-	 */
1364
-	public function is_minimum_amount_met( $amount ) {
1365
-		$amount = floatval( wpinv_sanitize_amount( $amount ) );
1366
-		$min_met = ! ( $this->has_minimum_amount() && $amount < floatval( wpinv_sanitize_amount( $this->get_minimum_total() ) ) );
1367
-		return apply_filters( 'wpinv_is_discount_min_met', $min_met, $this->get_id(), $this, $this->get_code(), $amount );
1368
-	}
1369
-
1370
-	/**
1371
-	 * Checks if the maximum amount is set
1372
-	 *
1373
-	 * @since 1.0.15
1374
-	 * @return boolean
1375
-	 */
1376
-	public function has_maximum_amount() {
1377
-		$maximum = $this->get_maximum_total();
1378
-		return ! empty( $maximum );
1379
-	}
1380
-
1381
-	/**
1382
-	 * Checks if the maximum amount is met
1383
-	 *
1384
-	 * @param  float  $amount The amount to check against
1385
-	 * @since 1.0.15
1386
-	 * @return boolean
1387
-	 */
1388
-	public function is_maximum_amount_met( $amount ) {
1389
-		$amount = floatval( wpinv_sanitize_amount( $amount ) );
1390
-		$max_met = ! ( $this->has_maximum_amount() && $amount > floatval( wpinv_sanitize_amount( $this->get_maximum_total() ) ) );
1391
-		return apply_filters( 'wpinv_is_discount_max_met', $max_met, $this->get_id(), $this, $this->get_code(), $amount );
1392
-	}
1393
-
1394
-	/**
1395
-	 * Checks if the discount is recurring.
1396
-	 *
1397
-	 * @since 1.0.15
1398
-	 * @return boolean
1399
-	 */
1400
-	public function is_recurring() {
1401
-		$recurring = $this->get_is_recurring();
1402
-		return ! empty( $recurring );
1403
-	}
1404
-
1405
-	/**
1406
-	 * Checks if the discount is single use.
1407
-	 *
1408
-	 * @since 1.0.15
1409
-	 * @return boolean
1410
-	 */
1411
-	public function is_single_use() {
1412
-		$usage = $this->get_is_single_use();
1413
-		return ! empty( $usage );
1414
-	}
1415
-
1416
-	/**
1417
-	 * Check if a discount is valid for the given user
1418
-	 *
1419
-	 * @param  int|string  $user
1420
-	 * @since 1.0.15
1421
-	 * @return boolean
1422
-	 */
1423
-	public function is_valid_for_user( $user ) {
1424
-
1425
-		// Ensure that the discount is single use.
1426
-		if ( empty( $user ) || ! $this->is_single_use() ) {
1427
-			return true;
1428
-		}
1429
-
1430
-		// Prepare the user id.
1431
-		$user_id = 0;
1148
+    /**
1149
+     * Checks whether a discount exists in the database or not
1150
+     *
1151
+     * @since 1.0.15
1152
+     */
1153
+    public function exists() {
1154
+        $id = $this->get_id();
1155
+        return ! empty( $id );
1156
+    }
1157
+
1158
+    /**
1159
+     * Checks the discount type.
1160
+     *
1161
+     *
1162
+     * @param  string $type the discount type to check against
1163
+     * @since 1.0.15
1164
+     * @return bool
1165
+     */
1166
+    public function is_type( $type ) {
1167
+        return $this->get_type() == $type;
1168
+    }
1169
+
1170
+    /**
1171
+     * Checks whether the discount is published or not
1172
+     *
1173
+     * @since 1.0.15
1174
+     * @return bool
1175
+     */
1176
+    public function is_active() {
1177
+        return $this->get_status() == 'publish';
1178
+    }
1179
+
1180
+    /**
1181
+     * Checks whether the discount has max uses
1182
+     *
1183
+     * @since 1.0.15
1184
+     * @return bool
1185
+     */
1186
+    public function has_limit() {
1187
+        $limit = $this->get_max_uses();
1188
+        return ! empty( $limit );
1189
+    }
1190
+
1191
+    /**
1192
+     * Checks whether the discount has ever been used.
1193
+     *
1194
+     * @since 1.0.15
1195
+     * @return bool
1196
+     */
1197
+    public function has_uses() {
1198
+        return $this->get_uses() > 0;
1199
+    }
1200
+
1201
+    /**
1202
+     * Checks whether the discount is has exided the usage limit or not
1203
+     *
1204
+     * @since 1.0.15
1205
+     * @return bool
1206
+     */
1207
+    public function has_exceeded_limit() {
1208
+
1209
+        if ( ! $this->has_limit() || ! $this->has_uses() ) {
1210
+            $exceeded = false;
1211
+        } else {
1212
+            $exceeded = (int) $this->get_max_uses() <= $this->get_uses();
1213
+        }
1214
+
1215
+        return apply_filters( 'wpinv_is_discount_maxed_out', $exceeded, $this->get_id(), $this, $this->get_code() );
1216
+    }
1217
+
1218
+    /**
1219
+     * Checks whether the discount has an expiration date.
1220
+     *
1221
+     * @since 1.0.15
1222
+     * @return bool
1223
+     */
1224
+    public function has_expiration_date() {
1225
+        $date = $this->get_expiration_date();
1226
+        return ! empty( $date );
1227
+    }
1228
+
1229
+    /**
1230
+     * Checks if the discount is expired
1231
+     *
1232
+     * @since 1.0.15
1233
+     * @return bool
1234
+     */
1235
+    public function is_expired() {
1236
+        $expired = $this->has_expiration_date() ? current_time( 'timestamp' ) > strtotime( $this->get_expiration_date() ) : false;
1237
+        return apply_filters( 'wpinv_is_discount_expired', $expired, $this->get_id(), $this, $this->get_code() );
1238
+    }
1239
+
1240
+    /**
1241
+     * Checks whether the discount has a start date.
1242
+     *
1243
+     * @since 1.0.15
1244
+     * @return bool
1245
+     */
1246
+    public function has_start_date() {
1247
+        $date = $this->get_start_date();
1248
+        return ! empty( $date );
1249
+    }
1250
+
1251
+    /**
1252
+     * Checks the discount start date.
1253
+     *
1254
+     * @since 1.0.15
1255
+     * @return bool
1256
+     */
1257
+    public function has_started() {
1258
+        $started = $this->has_start_date() ? true : current_time( 'timestamp' ) > strtotime( $this->get_start_date() );
1259
+        return apply_filters( 'wpinv_is_discount_started', $started, $this->get_id(), $this, $this->get_code() );
1260
+    }
1261
+
1262
+    /**
1263
+     * Checks the discount has allowed items or not.
1264
+     *
1265
+     * @since 1.0.15
1266
+     * @return bool
1267
+     */
1268
+    public function has_allowed_items() {
1269
+        $allowed_items = $this->get_allowed_items();
1270
+        return ! empty( $allowed_items );
1271
+    }
1272
+
1273
+    /**
1274
+     * Checks the discount has excluded items or not.
1275
+     *
1276
+     * @since 1.0.15
1277
+     * @return bool
1278
+     */
1279
+    public function has_excluded_items() {
1280
+        $excluded_items = $this->get_excluded_items();
1281
+        return ! empty( $excluded_items );
1282
+    }
1283
+
1284
+    /**
1285
+     * Check if a discount is valid for a given item id.
1286
+     *
1287
+     * @param  int|int[]  $item_ids
1288
+     * @since 1.0.15
1289
+     * @return boolean
1290
+     */
1291
+    public function is_valid_for_items( $item_ids ) {
1292
+
1293
+        $item_ids = array_filter( wp_parse_id_list( $item_ids ) );
1294
+        $included = array_intersect( $item_ids, $this->get_allowed_items() );
1295
+        $excluded = array_intersect( $item_ids, $this->get_excluded_items() );
1296
+
1297
+        if ( $this->has_excluded_items() && ! empty( $excluded ) ) {
1298
+            return false;
1299
+        }
1300
+
1301
+        if ( $this->has_allowed_items() && empty( $included ) ) {
1302
+            return false;
1303
+        }
1304
+
1305
+        return true;
1306
+    }
1307
+
1308
+    /**
1309
+     * Checks the discount has required items or not.
1310
+     *
1311
+     * @since 1.0.15
1312
+     * @return bool
1313
+     */
1314
+    public function has_required_items() {
1315
+        $required_items = $this->get_required_items();
1316
+        return ! empty( $required_items );
1317
+    }
1318
+
1319
+    /**
1320
+     * Checks if the required items are met
1321
+     *
1322
+     * @param  int|int[]  $item_ids
1323
+     * @since 1.0.15
1324
+     * @return boolean
1325
+     */
1326
+    public function is_required_items_met( $item_ids ) {
1327
+
1328
+        if ( ! $this->has_required_items() ) {
1329
+            return true;
1330
+        }
1331
+
1332
+        return ! array_diff( $this->get_required_items(), array_filter( wp_parse_id_list( $item_ids ) ) );
1333
+    }
1334
+
1335
+    /**
1336
+     * Check if a discount is valid for the given amount
1337
+     *
1338
+     * @param  float  $amount The amount to check against
1339
+     * @since 1.0.15
1340
+     * @return boolean
1341
+     */
1342
+    public function is_valid_for_amount( $amount ) {
1343
+        return $this->is_minimum_amount_met( $amount ) && $this->is_maximum_amount_met( $amount );
1344
+    }
1345
+
1346
+    /**
1347
+     * Checks if the minimum amount is set
1348
+     *
1349
+     * @since 1.0.15
1350
+     * @return boolean
1351
+     */
1352
+    public function has_minimum_amount() {
1353
+        $minimum = $this->get_minimum_total();
1354
+        return ! empty( $minimum );
1355
+    }
1356
+
1357
+    /**
1358
+     * Checks if the minimum amount is met
1359
+     *
1360
+     * @param  float  $amount The amount to check against
1361
+     * @since 1.0.15
1362
+     * @return boolean
1363
+     */
1364
+    public function is_minimum_amount_met( $amount ) {
1365
+        $amount = floatval( wpinv_sanitize_amount( $amount ) );
1366
+        $min_met = ! ( $this->has_minimum_amount() && $amount < floatval( wpinv_sanitize_amount( $this->get_minimum_total() ) ) );
1367
+        return apply_filters( 'wpinv_is_discount_min_met', $min_met, $this->get_id(), $this, $this->get_code(), $amount );
1368
+    }
1369
+
1370
+    /**
1371
+     * Checks if the maximum amount is set
1372
+     *
1373
+     * @since 1.0.15
1374
+     * @return boolean
1375
+     */
1376
+    public function has_maximum_amount() {
1377
+        $maximum = $this->get_maximum_total();
1378
+        return ! empty( $maximum );
1379
+    }
1380
+
1381
+    /**
1382
+     * Checks if the maximum amount is met
1383
+     *
1384
+     * @param  float  $amount The amount to check against
1385
+     * @since 1.0.15
1386
+     * @return boolean
1387
+     */
1388
+    public function is_maximum_amount_met( $amount ) {
1389
+        $amount = floatval( wpinv_sanitize_amount( $amount ) );
1390
+        $max_met = ! ( $this->has_maximum_amount() && $amount > floatval( wpinv_sanitize_amount( $this->get_maximum_total() ) ) );
1391
+        return apply_filters( 'wpinv_is_discount_max_met', $max_met, $this->get_id(), $this, $this->get_code(), $amount );
1392
+    }
1393
+
1394
+    /**
1395
+     * Checks if the discount is recurring.
1396
+     *
1397
+     * @since 1.0.15
1398
+     * @return boolean
1399
+     */
1400
+    public function is_recurring() {
1401
+        $recurring = $this->get_is_recurring();
1402
+        return ! empty( $recurring );
1403
+    }
1404
+
1405
+    /**
1406
+     * Checks if the discount is single use.
1407
+     *
1408
+     * @since 1.0.15
1409
+     * @return boolean
1410
+     */
1411
+    public function is_single_use() {
1412
+        $usage = $this->get_is_single_use();
1413
+        return ! empty( $usage );
1414
+    }
1415
+
1416
+    /**
1417
+     * Check if a discount is valid for the given user
1418
+     *
1419
+     * @param  int|string  $user
1420
+     * @since 1.0.15
1421
+     * @return boolean
1422
+     */
1423
+    public function is_valid_for_user( $user ) {
1424
+
1425
+        // Ensure that the discount is single use.
1426
+        if ( empty( $user ) || ! $this->is_single_use() ) {
1427
+            return true;
1428
+        }
1429
+
1430
+        // Prepare the user id.
1431
+        $user_id = 0;
1432 1432
         if ( is_numeric( $user ) ) {
1433 1433
             $user_id = absint( $user );
1434 1434
         } elseif ( is_email( $user ) && $user_data = get_user_by( 'email', $user ) ) {
@@ -1437,122 +1437,122 @@  discard block
 block discarded – undo
1437 1437
             $user_id = $user_data->ID;
1438 1438
         }
1439 1439
 
1440
-		// Ensure that we have a user.
1441
-		if ( empty( $user_id ) ) {
1442
-			return true;
1443
-		}
1440
+        // Ensure that we have a user.
1441
+        if ( empty( $user_id ) ) {
1442
+            return true;
1443
+        }
1444 1444
 
1445
-		// Get all payments with matching user id.
1445
+        // Get all payments with matching user id.
1446 1446
         $payments = wpinv_get_invoices(
1447 1447
             array(
1448
-				'user'     => $user_id,
1449
-				'limit'    => false,
1450
-				'paginate' => false,
1448
+                'user'     => $user_id,
1449
+                'limit'    => false,
1450
+                'paginate' => false,
1451 1451
             )
1452 1452
         );
1453
-		$code     = strtolower( $this->get_code() );
1453
+        $code     = strtolower( $this->get_code() );
1454 1454
 
1455
-		// For each payment...
1456
-		foreach ( $payments as $payment ) {
1455
+        // For each payment...
1456
+        foreach ( $payments as $payment ) {
1457 1457
 
1458
-			// Only check for paid invoices.
1459
-			if ( $payment->is_paid() && strtolower( $payment->get_discount_code() ) == $code ) {
1460
-				return false;
1461
-			}
1458
+            // Only check for paid invoices.
1459
+            if ( $payment->is_paid() && strtolower( $payment->get_discount_code() ) == $code ) {
1460
+                return false;
1461
+            }
1462 1462
 }
1463 1463
 
1464
-		return true;
1465
-	}
1466
-
1467
-	/**
1468
-	 * Deletes the discount from the database
1469
-	 *
1470
-	 * @since 1.0.15
1471
-	 * @return boolean
1472
-	 */
1473
-	public function remove() {
1474
-		return $this->delete();
1475
-	}
1476
-
1477
-	/**
1478
-	 * Increases a discount's usage.
1479
-	 *
1480
-	 * @since 1.0.15
1481
-	 * @param int $by The number of usages to increas by.
1482
-	 * @return int
1483
-	 */
1484
-	public function increase_usage( $by = 1 ) {
1485
-
1486
-		// Abort if zero.
1487
-		if ( empty( $by ) ) {
1488
-			return;
1489
-		}
1490
-
1491
-		// Increase the usage.
1492
-		$this->set_uses( $this->get_uses() + (int) $by );
1493
-
1494
-		// Save the discount.
1495
-		$this->save();
1496
-
1497
-		// Fire relevant hooks.
1498
-		if ( (int) $by > 0 ) {
1499
-			do_action( 'wpinv_discount_increase_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) );
1500
-		} else {
1501
-			do_action( 'wpinv_discount_decrease_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) );
1502
-		}
1503
-
1504
-		// Return the number of times the discount has been used.
1505
-		return $this->get_uses();
1506
-	}
1507
-
1508
-	/**
1509
-	 * Alias of self::__toString()
1510
-	 *
1511
-	 * @since 1.0.15
1512
-	 * @return string|false
1513
-	 */
1514
-	public function get_data_as_json() {
1515
-		return $this->__toString();
1516
-	}
1517
-
1518
-	/**
1519
-	 * Returns a discount's discounted amount.
1520
-	 *
1521
-	 * @since 1.0.15
1522
-	 * @param float $amount
1523
-	 * @return float
1524
-	 */
1525
-	public function get_discounted_amount( $amount ) {
1526
-
1527
-		// Convert amount to float.
1528
-		$amount = (float) $amount;
1529
-
1530
-		// Get discount amount.
1531
-		$discount_amount = $this->get_amount();
1532
-
1533
-		if ( empty( $discount_amount ) ) {
1534
-			return 0;
1535
-		}
1536
-
1537
-		// Format the amount.
1538
-		$discount_amount = floatval( wpinv_sanitize_amount( $discount_amount ) );
1539
-
1540
-		// If this is a percentage discount.
1541
-		if ( $this->is_type( 'percent' ) ) {
1464
+        return true;
1465
+    }
1466
+
1467
+    /**
1468
+     * Deletes the discount from the database
1469
+     *
1470
+     * @since 1.0.15
1471
+     * @return boolean
1472
+     */
1473
+    public function remove() {
1474
+        return $this->delete();
1475
+    }
1476
+
1477
+    /**
1478
+     * Increases a discount's usage.
1479
+     *
1480
+     * @since 1.0.15
1481
+     * @param int $by The number of usages to increas by.
1482
+     * @return int
1483
+     */
1484
+    public function increase_usage( $by = 1 ) {
1485
+
1486
+        // Abort if zero.
1487
+        if ( empty( $by ) ) {
1488
+            return;
1489
+        }
1490
+
1491
+        // Increase the usage.
1492
+        $this->set_uses( $this->get_uses() + (int) $by );
1493
+
1494
+        // Save the discount.
1495
+        $this->save();
1496
+
1497
+        // Fire relevant hooks.
1498
+        if ( (int) $by > 0 ) {
1499
+            do_action( 'wpinv_discount_increase_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) );
1500
+        } else {
1501
+            do_action( 'wpinv_discount_decrease_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) );
1502
+        }
1503
+
1504
+        // Return the number of times the discount has been used.
1505
+        return $this->get_uses();
1506
+    }
1507
+
1508
+    /**
1509
+     * Alias of self::__toString()
1510
+     *
1511
+     * @since 1.0.15
1512
+     * @return string|false
1513
+     */
1514
+    public function get_data_as_json() {
1515
+        return $this->__toString();
1516
+    }
1517
+
1518
+    /**
1519
+     * Returns a discount's discounted amount.
1520
+     *
1521
+     * @since 1.0.15
1522
+     * @param float $amount
1523
+     * @return float
1524
+     */
1525
+    public function get_discounted_amount( $amount ) {
1526
+
1527
+        // Convert amount to float.
1528
+        $amount = (float) $amount;
1529
+
1530
+        // Get discount amount.
1531
+        $discount_amount = $this->get_amount();
1532
+
1533
+        if ( empty( $discount_amount ) ) {
1534
+            return 0;
1535
+        }
1536
+
1537
+        // Format the amount.
1538
+        $discount_amount = floatval( wpinv_sanitize_amount( $discount_amount ) );
1539
+
1540
+        // If this is a percentage discount.
1541
+        if ( $this->is_type( 'percent' ) ) {
1542 1542
             $discount_amount = $amount * ( $discount_amount / 100 );
1543
-		}
1543
+        }
1544 1544
 
1545
-		// Discount can not be less than zero...
1546
-		if ( $discount_amount < 0 ) {
1547
-			$discount_amount = 0;
1548
-		}
1545
+        // Discount can not be less than zero...
1546
+        if ( $discount_amount < 0 ) {
1547
+            $discount_amount = 0;
1548
+        }
1549 1549
 
1550
-		// ... or more than the amount.
1551
-		if ( $discount_amount > $amount ) {
1552
-			$discount_amount = $amount;
1553
-		}
1550
+        // ... or more than the amount.
1551
+        if ( $discount_amount > $amount ) {
1552
+            $discount_amount = $amount;
1553
+        }
1554 1554
 
1555
-		return apply_filters( 'wpinv_discount_total_discount_amount', $discount_amount, $amount, $this );
1556
-	}
1555
+        return apply_filters( 'wpinv_discount_total_discount_amount', $discount_amount, $amount, $this );
1556
+    }
1557 1557
 
1558 1558
 }
Please login to merge, or discard this patch.
includes/class-wpinv-legacy-invoice.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -775,10 +775,10 @@  discard block
 block discarded – undo
775 775
         $allowed_fee_keys = apply_filters(
776 776
             'wpinv_fee_keys',
777 777
             array(
778
-				'index',
779
-				'label',
780
-				'amount',
781
-				'type',
778
+                'index',
779
+                'label',
780
+                'amount',
781
+                'type',
782 782
             )
783 783
         );
784 784
 
@@ -850,19 +850,19 @@  discard block
 block discarded – undo
850 850
         $note_id = wp_insert_comment(
851 851
             wp_filter_comment(
852 852
                 array(
853
-					'comment_post_ID'      => $this->ID,
854
-					'comment_content'      => $note,
855
-					'comment_agent'        => 'WPInvoicing',
856
-					'user_id'              => is_admin() ? get_current_user_id() : 0,
857
-					'comment_date'         => current_time( 'mysql' ),
858
-					'comment_date_gmt'     => current_time( 'mysql', 1 ),
859
-					'comment_approved'     => 1,
860
-					'comment_parent'       => 0,
861
-					'comment_author'       => $comment_author,
862
-					'comment_author_IP'    => wpinv_get_ip(),
863
-					'comment_author_url'   => '',
864
-					'comment_author_email' => $comment_author_email,
865
-					'comment_type'         => 'wpinv_note',
853
+                    'comment_post_ID'      => $this->ID,
854
+                    'comment_content'      => $note,
855
+                    'comment_agent'        => 'WPInvoicing',
856
+                    'user_id'              => is_admin() ? get_current_user_id() : 0,
857
+                    'comment_date'         => current_time( 'mysql' ),
858
+                    'comment_date_gmt'     => current_time( 'mysql', 1 ),
859
+                    'comment_approved'     => 1,
860
+                    'comment_parent'       => 0,
861
+                    'comment_author'       => $comment_author,
862
+                    'comment_author_IP'    => wpinv_get_ip(),
863
+                    'comment_author_url'   => '',
864
+                    'comment_author_email' => $comment_author_email,
865
+                    'comment_type'         => 'wpinv_note',
866 866
                 )
867 867
             )
868 868
         );
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
             do_action(
876 876
                 'wpinv_new_customer_note',
877 877
                 array(
878
-					'invoice_id' => $this->ID,
879
-					'user_note'  => $note,
878
+                    'invoice_id' => $this->ID,
879
+                    'user_note'  => $note,
880 880
                 )
881 881
             );
882 882
         }
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
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' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
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' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
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';
51
+        // Prepare variables.
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';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
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 );
70
-					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-					$url   = esc_url(
68
+                    $key   = sanitize_key( $key );
69
+                    $label = esc_html( $label );
70
+                    $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                    $url   = esc_url(
72 72
                         add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73 73
                     );
74 74
 
75
-				echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
75
+                echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
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 );
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 );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	/**
97
-	 * Retrieves reports page tabs.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	public function get_tabs() {
96
+    /**
97
+     * Retrieves reports page tabs.
98
+     *
99
+     * @return array
100
+     */
101
+    public function get_tabs() {
102 102
 
103
-		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
106
-		);
103
+        $tabs = array(
104
+            'reports' => __( 'Reports', 'invoicing' ),
105
+            'export'  => __( 'Export', 'invoicing' ),
106
+        );
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
-	}
108
+        return apply_filters( 'getpaid_report_tabs', $tabs );
109
+    }
110 110
 
111
-	/**
112
-	 * Displays the reports tab.
113
-	 *
114
-	 */
115
-	public function display_reports_tab() {
111
+    /**
112
+     * Displays the reports tab.
113
+     *
114
+     */
115
+    public function display_reports_tab() {
116 116
 
117
-		$reports = new GetPaid_Reports_Report();
118
-		$reports->display();
117
+        $reports = new GetPaid_Reports_Report();
118
+        $reports->display();
119 119
 
120
-	}
120
+    }
121 121
 
122
-	/**
123
-	 * Displays the exports tab.
124
-	 *
125
-	 */
126
-	public function display_exports_tab() {
122
+    /**
123
+     * Displays the exports tab.
124
+     *
125
+     */
126
+    public function display_exports_tab() {
127 127
 
128
-		$exports = new GetPaid_Reports_Export();
129
-		$exports->display();
128
+        $exports = new GetPaid_Reports_Export();
129
+        $exports->display();
130 130
 
131
-	}
131
+    }
132 132
 
133
-	/**
134
-	 * Donwnloads a graph.
135
-	 *
136
-	 * @param array $args
137
-	 */
138
-	public function download_graph( $args ) {
133
+    /**
134
+     * Donwnloads a graph.
135
+     *
136
+     * @param array $args
137
+     */
138
+    public function download_graph( $args ) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
141
-			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
143
-		}
140
+        if ( ! empty( $args['graph'] ) ) {
141
+            $downloader = new GetPaid_Graph_Downloader();
142
+            $downloader->download( $args['graph'] );
143
+        }
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Exports invoices.
149
-	 *
150
-	 * @param array $args
151
-	 */
152
-	public function export_invoices( $args ) {
147
+    /**
148
+     * Exports invoices.
149
+     *
150
+     * @param array $args
151
+     */
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'] ) {
157
-				$downloader = new GetPaid_Subscription_Exporter();
158
-			} else {
159
-				$downloader = new GetPaid_Invoice_Exporter();
160
-			}
156
+            if ( 'subscriptions' === $args['post_type'] ) {
157
+                $downloader = new GetPaid_Subscription_Exporter();
158
+            } else {
159
+                $downloader = new GetPaid_Invoice_Exporter();
160
+            }
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
163
-		}
162
+            $downloader->export( $args['post_type'], $args );
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -26,58 +26,58 @@  discard block
 block discarded – undo
26 26
 
27 27
 				<?php
28 28
 
29
-					// Fires before printing a line item column.
30
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
31
-
32
-					// Item name.
33
-					if ( 'name' == $key ) {
34
-
35
-					ob_start();
36
-					// And an optional description.
37
-					$description = $item->get_description();
38
-
39
-					if ( ! empty( $description ) ) {
40
-						$description = wp_kses_post( $description );
41
-						echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42
-						}
43
-
44
-					// Price help text.
45
-					$description = getpaid_item_recurring_price_help_text( $item, $currency );
46
-					if ( $description ) {
47
-						echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48
-						}
49
-
50
-					do_action( 'getpaid_payment_form_cart_item_description', $item, $form );
51
-
52
-					if ( wpinv_current_user_can_manage_invoicing() ) {
53
-
54
-						edit_post_link(
55
-							__( 'Edit this item.', 'invoicing' ),
56
-							'<small class="form-text text-muted">',
57
-							'</small>',
58
-							$item->get_id(),
59
-							'text-danger'
60
-						);
61
-
62
-					}
63
-
64
-					$description = ob_get_clean();
65
-
66
-					// Display the name.
67
-					$tootip = empty( $description ) ? '' : '&nbsp;' . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
68
-					echo '<div class="mb-1">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>';
69
-
70
-					if ( ! empty( $description ) ) {
71
-						printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description );
72
-						}
73
-
74
-					if ( $item->allows_quantities() ) {
75
-						printf(
76
-							'<small class="d-sm-none text-muted form-text">%s</small>',
77
-							sprintf(
78
-								__( 'Qty %s', 'invoicing' ),
79
-								sprintf(
80
-									'<input
29
+                    // Fires before printing a line item column.
30
+                    do_action( "getpaid_form_cart_item_before_$key", $item, $form );
31
+
32
+                    // Item name.
33
+                    if ( 'name' == $key ) {
34
+
35
+                    ob_start();
36
+                    // And an optional description.
37
+                    $description = $item->get_description();
38
+
39
+                    if ( ! empty( $description ) ) {
40
+                        $description = wp_kses_post( $description );
41
+                        echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42
+                        }
43
+
44
+                    // Price help text.
45
+                    $description = getpaid_item_recurring_price_help_text( $item, $currency );
46
+                    if ( $description ) {
47
+                        echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48
+                        }
49
+
50
+                    do_action( 'getpaid_payment_form_cart_item_description', $item, $form );
51
+
52
+                    if ( wpinv_current_user_can_manage_invoicing() ) {
53
+
54
+                        edit_post_link(
55
+                            __( 'Edit this item.', 'invoicing' ),
56
+                            '<small class="form-text text-muted">',
57
+                            '</small>',
58
+                            $item->get_id(),
59
+                            'text-danger'
60
+                        );
61
+
62
+                    }
63
+
64
+                    $description = ob_get_clean();
65
+
66
+                    // Display the name.
67
+                    $tootip = empty( $description ) ? '' : '&nbsp;' . '<i class="fas fa-xs fa-info gp-tooltip d-sm-none text-muted"></i>';
68
+                    echo '<div class="mb-1">' . esc_html( $item->get_name() ) . wp_kses_post( $tootip ) . '</div>';
69
+
70
+                    if ( ! empty( $description ) ) {
71
+                        printf( '<span class="d-none d-sm-block getpaid-item-desc">%s</span>', $description );
72
+                        }
73
+
74
+                    if ( $item->allows_quantities() ) {
75
+                        printf(
76
+                            '<small class="d-sm-none text-muted form-text">%s</small>',
77
+                            sprintf(
78
+                                __( 'Qty %s', 'invoicing' ),
79
+                                sprintf(
80
+                                    '<input
81 81
 											type="number"
82 82
 											step="0.01"
83 83
 											style="width: 48px;"
@@ -87,53 +87,53 @@  discard block
 block discarded – undo
87 87
 											%s>',
88 88
                                     (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(),
89 89
                                     null !== $max_qty ? 'max="' . (float) $max_qty . '"' : ''
90
-								)
91
-							)
92
-						);
93
-					} else {
94
-						printf(
95
-							'<small class="d-sm-none text-muted form-text">%s</small>',
96
-							sprintf(
97
-								__( 'Qty %s', 'invoicing' ),
98
-								(float) $item->get_quantity()
99
-							)
100
-						);
101
-						}
90
+                                )
91
+                            )
92
+                        );
93
+                    } else {
94
+                        printf(
95
+                            '<small class="d-sm-none text-muted form-text">%s</small>',
96
+                            sprintf(
97
+                                __( 'Qty %s', 'invoicing' ),
98
+                                (float) $item->get_quantity()
99
+                            )
100
+                        );
101
+                        }
102 102
 }
103 103
 
104
-					// Item price.
105
-					if ( 'price' == $key ) {
104
+                    // Item price.
105
+                    if ( 'price' == $key ) {
106 106
 
107
-					// Set the currency position.
108
-					$position = wpinv_currency_position();
107
+                    // Set the currency position.
108
+                    $position = wpinv_currency_position();
109 109
 
110
-					if ( $position == 'left_space' ) {
111
-						$position = 'left';
112
-						}
110
+                    if ( $position == 'left_space' ) {
111
+                        $position = 'left';
112
+                        }
113 113
 
114
-					if ( $position == 'right_space' ) {
115
-						$position = 'right';
116
-						}
114
+                    if ( $position == 'right_space' ) {
115
+                        $position = 'right';
116
+                        }
117 117
 
118
-					if ( $item->user_can_set_their_price() ) {
119
-						$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
120
-						$minimum          = (float) $item->get_minimum_price();
121
-						$validate_minimum = '';
122
-						$class            = '';
123
-						$data_minimum     = '';
118
+                    if ( $item->user_can_set_their_price() ) {
119
+                        $price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
120
+                        $minimum          = (float) $item->get_minimum_price();
121
+                        $validate_minimum = '';
122
+                        $class            = '';
123
+                        $data_minimum     = '';
124 124
 
125
-						if ( $minimum > 0 ) {
126
-							$validate_minimum = sprintf(
127
-								esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
128
-								strip_tags( wpinv_price( $minimum, $currency ) )
129
-							);
125
+                        if ( $minimum > 0 ) {
126
+                            $validate_minimum = sprintf(
127
+                                esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
128
+                                strip_tags( wpinv_price( $minimum, $currency ) )
129
+                            );
130 130
 
131
-							$class = 'getpaid-validate-minimum-amount';
131
+                            $class = 'getpaid-validate-minimum-amount';
132 132
 
133
-							$data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
134
-						}
133
+                            $data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
134
+                        }
135 135
 
136
-						?>
136
+                        ?>
137 137
 								<div class="input-group input-group-sm">
138 138
 								<?php if ( 'left' == $position ) : ?>
139 139
 										<div class="input-group-prepend">
@@ -158,43 +158,43 @@  discard block
 block discarded – undo
158 158
 
159 159
 							<?php
160 160
 
161
-						} else {
162
-						echo wpinv_price( $item->get_price(), $currency );
161
+                        } else {
162
+                        echo wpinv_price( $item->get_price(), $currency );
163 163
 
164
-						?>
164
+                        ?>
165 165
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
166 166
 						<?php
167
-						}
167
+                        }
168 168
 
169
-					printf(
169
+                    printf(
170 170
                         '<small class="d-sm-none text-muted form-text getpaid-mobile-item-subtotal">%s</small>',
171 171
                         sprintf( __( 'Subtotal: %s', 'invoicing' ), wpinv_price( $item->get_sub_total(), $currency ) )
172 172
                     );
173
-					}
173
+                    }
174 174
 
175
-					// Item quantity.
176
-					if ( 'quantity' == $key ) {
175
+                    // Item quantity.
176
+                    if ( 'quantity' == $key ) {
177 177
 
178
-					if ( $item->allows_quantities() ) {
179
-						?>
178
+                    if ( $item->allows_quantities() ) {
179
+                        ?>
180 180
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type="number" step="0.01" style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' <?php echo null !== $max_qty ? 'max="' . (float) $max_qty . '"' : ''; ?> required>
181 181
 							<?php
182
-						} else {
183
-						echo (float) $item->get_quantity();
184
-						echo '&nbsp;&nbsp;&nbsp;';
185
-						?>
182
+                        } else {
183
+                        echo (float) $item->get_quantity();
184
+                        echo '&nbsp;&nbsp;&nbsp;';
185
+                        ?>
186 186
 								<input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'>
187 187
 						<?php
188
-						}
188
+                        }
189 189
 }
190 190
 
191
-					// Item sub total.
192
-					if ( 'subtotal' == $key ) {
193
-					echo wpinv_price( $item->get_sub_total(), $currency );
194
-					}
191
+                    // Item sub total.
192
+                    if ( 'subtotal' == $key ) {
193
+                    echo wpinv_price( $item->get_sub_total(), $currency );
194
+                    }
195 195
 
196
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
197
-				?>
196
+                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
197
+                ?>
198 198
 
199 199
 			</div>
200 200
 
Please login to merge, or discard this patch.
templates/payment-forms/embed.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,32 +1,32 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-	// Is the request set up correctly?
4
-	if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
5
-	return aui()->alert(
3
+    // Is the request set up correctly?
4
+    if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
5
+    return aui()->alert(
6 6
         array(
7
-	'type'    => 'warning',
8
-	'content' => __( 'No payment form or item selected', 'invoicing' ),
7
+    'type'    => 'warning',
8
+    'content' => __( 'No payment form or item selected', 'invoicing' ),
9 9
         )
10 10
 );
11 11
 wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 );
12
-	}
12
+    }
13 13
 
14
-	// Payment form or button?
15
-	if ( ! empty( $_GET['form'] ) ) {
14
+    // Payment form or button?
15
+    if ( ! empty( $_GET['form'] ) ) {
16 16
 
17
-	$shortcode = sprintf(
17
+    $shortcode = sprintf(
18 18
         '[getpaid form=%s]',
19 19
         (int) $_GET['form']
20 20
 );
21 21
 
22
-	} else {
22
+    } else {
23 23
 
24
-	$shortcode = sprintf(
24
+    $shortcode = sprintf(
25 25
         '[getpaid item=%s]',
26 26
         esc_attr( urldecode( $_GET['item'] ) )
27
-	);
27
+    );
28 28
 
29
-	}
29
+    }
30 30
 
31 31
 ?>
32 32
 
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 
45 45
         <title>GetPaid</title>
46 46
 		<?php
47
-			wp_enqueue_scripts();
48
-			wp_print_styles();
49
-			wp_print_head_scripts();
50
-			wp_custom_css_cb();
51
-			wpinv_get_template( 'frontend-head.php' );
52
-		?>
47
+            wp_enqueue_scripts();
48
+            wp_print_styles();
49
+            wp_print_head_scripts();
50
+            wp_custom_css_cb();
51
+            wpinv_get_template( 'frontend-head.php' );
52
+        ?>
53 53
 
54 54
 		<style type="text/css">
55 55
 			.body{ 
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 	<body class="body page-template-default page">
84 84
 		<div id="getpaid-form-embed" class="container my-5 page type-page status-publish hentry post post-content">
85 85
 			<?php
86
-				do_action( 'getpaid_payment_form_embed_top' );
87
-				echo do_shortcode( $shortcode );
88
-				do_action( 'getpaid_payment_form_embed_bottom' );
89
-				wpinv_get_template( 'frontend-footer.php' );
90
-			?>
86
+                do_action( 'getpaid_payment_form_embed_top' );
87
+                echo do_shortcode( $shortcode );
88
+                do_action( 'getpaid_payment_form_embed_bottom' );
89
+                wpinv_get_template( 'frontend-footer.php' );
90
+            ?>
91 91
 		</div>
92 92
 		<?php wp_footer(); ?>
93 93
 	</body>
Please login to merge, or discard this patch.
templates/subscriptions/subscriptions-table-row.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,42 +13,42 @@
 block discarded – undo
13 13
 
14 14
 foreach ( array_keys( $widget->get_subscriptions_table_columns() ) as $column ) :
15 15
 
16
-	$class = sanitize_html_class( $column );
17
-	echo "<td class='getpaid-subscriptions-table-column-" . esc_attr( $class ) . "'>";
16
+    $class = sanitize_html_class( $column );
17
+    echo "<td class='getpaid-subscriptions-table-column-" . esc_attr( $class ) . "'>";
18 18
 
19
-		do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription );
19
+        do_action( "getpaid_subscriptions_before_frontend_subscription_table_$column", $subscription );
20 20
 
21
-		switch ( $column ) :
21
+        switch ( $column ) :
22 22
 
23
-		case 'subscription':
24
-			$subscription_id = (int) $subscription->get_id();
25
-			$url             = esc_url( $subscription->get_view_url() );
26
-			$id_label        = sprintf(
27
-				esc_attr_x( '#%s', 'subscription id', 'invoicing' ),
28
-				(int) $subscription->get_id()
29
-			);
30
-			echo wp_kses_post( $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription ) );
31
-			break;
23
+        case 'subscription':
24
+            $subscription_id = (int) $subscription->get_id();
25
+            $url             = esc_url( $subscription->get_view_url() );
26
+            $id_label        = sprintf(
27
+                esc_attr_x( '#%s', 'subscription id', 'invoicing' ),
28
+                (int) $subscription->get_id()
29
+            );
30
+            echo wp_kses_post( $widget->add_row_actions( "<a href='$url' class='font-weight-bold text-decoration-none'>$id_label</a>", $subscription ) );
31
+            break;
32 32
 
33
-		case 'status':
34
-			echo esc_html( $subscription->get_status_label() );
35
-			break;
33
+        case 'status':
34
+            echo esc_html( $subscription->get_status_label() );
35
+            break;
36 36
 
37
-		case 'renewal-date':
38
-			$renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() );
39
-			echo $subscription->is_active() ? esc_html( $renewal ) : '&mdash;';
40
-			break;
37
+        case 'renewal-date':
38
+            $renewal = getpaid_format_date_value( $subscription->get_next_renewal_date() );
39
+            echo $subscription->is_active() ? esc_html( $renewal ) : '&mdash;';
40
+            break;
41 41
 
42
-		case 'amount':
43
-			$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
44
-			$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
45
-			echo wp_kses_post( "<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>" );
46
-			break;
42
+        case 'amount':
43
+            $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
44
+            $amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
45
+            echo wp_kses_post( "<span>$amount</span> / <span class='getpaid-item-recurring-period'>$frequency</span>" );
46
+            break;
47 47
 
48
-		endswitch;
48
+        endswitch;
49 49
 
50
-		do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription );
50
+        do_action( "getpaid_subscriptions_frontend_subscription_table_$column", $subscription );
51 51
 
52
-	echo '</td>';
52
+    echo '</td>';
53 53
 
54 54
 endforeach;
Please login to merge, or discard this patch.
templates/subscriptions/subscription-details.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -46,62 +46,62 @@  discard block
 block discarded – undo
46 46
 				<td style="width: 65%">
47 47
 					<?php
48 48
 
49
-						switch ( $key ) {
49
+                        switch ( $key ) {
50 50
 
51
-						case 'status':
52
-							echo esc_html( $subscription->get_status_label() );
53
-							break;
51
+                        case 'status':
52
+                            echo esc_html( $subscription->get_status_label() );
53
+                            break;
54 54
 
55
-						case 'start_date':
56
-							echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
57
-							break;
55
+                        case 'start_date':
56
+                            echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
57
+                            break;
58 58
 
59
-						case 'expiry_date':
60
-							echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
61
-							break;
59
+                        case 'expiry_date':
60
+                            echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
61
+                            break;
62 62
 
63
-						case 'initial_amount':
64
-							echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
63
+                        case 'initial_amount':
64
+                            echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
65 65
 
66
-							if ( $subscription->has_trial_period() ) {
66
+                            if ( $subscription->has_trial_period() ) {
67 67
 
68
-								echo "<small class='text-muted'>&nbsp;";
69
-								printf(
70
-									esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
71
-									esc_html( $subscription->get_trial_period() )
72
-								);
73
-								echo '</small>';
68
+                                echo "<small class='text-muted'>&nbsp;";
69
+                                printf(
70
+                                    esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
71
+                                    esc_html( $subscription->get_trial_period() )
72
+                                );
73
+                                echo '</small>';
74 74
 
75
-							}
75
+                            }
76 76
 
77
-							break;
77
+                            break;
78 78
 
79
-						case 'recurring_amount':
80
-							$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
81
-							$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
82
-							echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
83
-							break;
79
+                        case 'recurring_amount':
80
+                            $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
81
+                            $amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
82
+                            echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
83
+                            break;
84 84
 
85
-						case 'item':
86
-							if ( empty( $subscription_group ) ) {
87
-								echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
88
-								} else {
89
-								$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
90
-								echo wp_kses_post( implode( ' | ', $markup ) );
91
-								}
85
+                        case 'item':
86
+                            if ( empty( $subscription_group ) ) {
87
+                                echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
88
+                                } else {
89
+                                $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
90
+                                echo wp_kses_post( implode( ' | ', $markup ) );
91
+                                }
92 92
 
93
-							break;
93
+                            break;
94 94
 
95
-						case 'payments':
96
-							$max_activations = (int) $subscription->get_bill_times();
97
-							echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
95
+                        case 'payments':
96
+                            $max_activations = (int) $subscription->get_bill_times();
97
+                            echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
98 98
 
99
-							break;
99
+                            break;
100 100
 
101
-						}
102
-						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
101
+                        }
102
+                        do_action( "getpaid_render_single_subscription_column_$key", $subscription );
103 103
 
104
-					?>
104
+                    ?>
105 105
 				</td>
106 106
 
107 107
 			</tr>
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 <span class="form-text">
129 129
 
130 130
 	<?php
131
-		if ( $subscription->can_cancel() ) {
132
-		printf(
131
+        if ( $subscription->can_cancel() ) {
132
+        printf(
133 133
             '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
134 134
             esc_url( $subscription->get_cancel_url() ),
135 135
             esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
136 136
             esc_html__( 'Cancel Subscription', 'invoicing' )
137 137
         );
138
-		}
138
+        }
139 139
 
140
-		do_action( 'getpaid-single-subscription-page-actions', $subscription );
141
-	?>
140
+        do_action( 'getpaid-single-subscription-page-actions', $subscription );
141
+    ?>
142 142
 
143 143
 	<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>
144 144
 </span>
Please login to merge, or discard this patch.
includes/libraries/wp-all-import/rapid-addon.php 1 patch
Indentation   +802 added lines, -802 removed lines patch added patch discarded remove patch
@@ -10,232 +10,232 @@  discard block
 block discarded – undo
10 10
 
11 11
 if (!class_exists('RapidAddon')) {
12 12
 	
13
-	class RapidAddon {
14
-
15
-		public $name;
16
-		public $slug;
17
-		public $fields;
18
-		public $options = array();
19
-		public $accordions = array();
20
-		public $image_sections = array();
21
-		public $import_function;
22
-		public $post_saved_function;
23
-		public $notice_text;
24
-		public $logger = null;
25
-		public $when_to_run = false;
26
-		public $image_options = array(
27
-			'download_images' => 'yes', 
28
-			'download_featured_delim' => ',', 
29
-			'download_featured_image' => '',
30
-			'gallery_featured_image' => '',
31
-			'gallery_featured_delim' => ',',
32
-			'featured_image' => '',
33
-			'featured_delim' => ',', 
34
-			'search_existing_images' => 1,
35
-			'is_featured' => 0,
36
-			'create_draft' => 'no',
37
-			'set_image_meta_title' => 0,
38
-			'image_meta_title_delim' => ',',
39
-			'image_meta_title' => '',
40
-			'set_image_meta_caption' => 0,
41
-			'image_meta_caption_delim' => ',',
42
-			'image_meta_caption' => '',
43
-			'set_image_meta_alt' => 0,
44
-			'image_meta_alt_delim' => ',',
45
-			'image_meta_alt' => '',
46
-			'set_image_meta_description' => 0,
47
-			'image_meta_description_delim' => ',',
48
-			'image_meta_description_delim_logic' => 'separate',
49
-			'image_meta_description' => '',
50
-			'auto_rename_images' => 0,
51
-			'auto_rename_images_suffix' => '',
52
-			'auto_set_extension' => 0,
53
-			'new_extension' => '',
54
-			'do_not_remove_images' => 1,
13
+    class RapidAddon {
14
+
15
+        public $name;
16
+        public $slug;
17
+        public $fields;
18
+        public $options = array();
19
+        public $accordions = array();
20
+        public $image_sections = array();
21
+        public $import_function;
22
+        public $post_saved_function;
23
+        public $notice_text;
24
+        public $logger = null;
25
+        public $when_to_run = false;
26
+        public $image_options = array(
27
+            'download_images' => 'yes', 
28
+            'download_featured_delim' => ',', 
29
+            'download_featured_image' => '',
30
+            'gallery_featured_image' => '',
31
+            'gallery_featured_delim' => ',',
32
+            'featured_image' => '',
33
+            'featured_delim' => ',', 
34
+            'search_existing_images' => 1,
35
+            'is_featured' => 0,
36
+            'create_draft' => 'no',
37
+            'set_image_meta_title' => 0,
38
+            'image_meta_title_delim' => ',',
39
+            'image_meta_title' => '',
40
+            'set_image_meta_caption' => 0,
41
+            'image_meta_caption_delim' => ',',
42
+            'image_meta_caption' => '',
43
+            'set_image_meta_alt' => 0,
44
+            'image_meta_alt_delim' => ',',
45
+            'image_meta_alt' => '',
46
+            'set_image_meta_description' => 0,
47
+            'image_meta_description_delim' => ',',
48
+            'image_meta_description_delim_logic' => 'separate',
49
+            'image_meta_description' => '',
50
+            'auto_rename_images' => 0,
51
+            'auto_rename_images_suffix' => '',
52
+            'auto_set_extension' => 0,
53
+            'new_extension' => '',
54
+            'do_not_remove_images' => 1,
55 55
             'search_existing_images_logic' => 'by_url'
56
-		);
56
+        );
57 57
 
58
-		protected $isWizard = true;
58
+        protected $isWizard = true;
59 59
 
60
-		function __construct($name, $slug) {
61
-			$this->name = $name;
62
-			$this->slug = $slug;
63
-			if (!empty($_GET['id'])){
64
-				$this->isWizard = false;
65
-			}
60
+        function __construct($name, $slug) {
61
+            $this->name = $name;
62
+            $this->slug = $slug;
63
+            if (!empty($_GET['id'])){
64
+                $this->isWizard = false;
65
+            }
66 66
         }
67 67
         
68
-		function set_import_function($name) {
69
-			$this->import_function = $name;
70
-		}
68
+        function set_import_function($name) {
69
+            $this->import_function = $name;
70
+        }
71 71
 
72
-		function set_post_saved_function($name) {
73
-			$this->post_saved_function = $name;
74
-		}
72
+        function set_post_saved_function($name) {
73
+            $this->post_saved_function = $name;
74
+        }
75 75
 
76
-		function is_active_addon($post_type = null) {
76
+        function is_active_addon($post_type = null) {
77 77
 			
78
-			if ( ! class_exists( 'PMXI_Plugin' ) ) {
79
-				return false;
80
-			}
78
+            if ( ! class_exists( 'PMXI_Plugin' ) ) {
79
+                return false;
80
+            }
81 81
 
82
-			$addon_active = false;
82
+            $addon_active = false;
83 83
 
84
-			if ($post_type !== null) {
85
-				if (@in_array($post_type, $this->active_post_types) or empty($this->active_post_types)) {
86
-					$addon_active = true;
87
-				}
88
-			}
84
+            if ($post_type !== null) {
85
+                if (@in_array($post_type, $this->active_post_types) or empty($this->active_post_types)) {
86
+                    $addon_active = true;
87
+                }
88
+            }
89 89
 
90
-			if ($addon_active){
90
+            if ($addon_active){
91 91
 				
92
-				$current_theme = wp_get_theme();
92
+                $current_theme = wp_get_theme();
93 93
 
94
-				$parent_theme = $current_theme->parent();				
94
+                $parent_theme = $current_theme->parent();				
95 95
 
96
-				$theme_name = $current_theme->get('Name');
96
+                $theme_name = $current_theme->get('Name');
97 97
 				
98
-				$addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
98
+                $addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
99 99
 
100
-				if ( ! $addon_active and $parent_theme ){
101
-					$parent_theme_name = $parent_theme->get('Name');
102
-					$addon_active = (@in_array($parent_theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
100
+                if ( ! $addon_active and $parent_theme ){
101
+                    $parent_theme_name = $parent_theme->get('Name');
102
+                    $addon_active = (@in_array($parent_theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
103 103
 
104
-				}
104
+                }
105 105
 				
106
-				if ( $addon_active and ! empty($this->active_plugins) ){
106
+                if ( $addon_active and ! empty($this->active_plugins) ){
107 107
 
108
-					include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
108
+                    include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
109 109
 
110
-					foreach ($this->active_plugins as $plugin) {
111
-						if ( ! is_plugin_active($plugin) ) {
112
-							$addon_active = false;
113
-							break;
114
-						}
115
-					}					
116
-				}
110
+                    foreach ($this->active_plugins as $plugin) {
111
+                        if ( ! is_plugin_active($plugin) ) {
112
+                            $addon_active = false;
113
+                            break;
114
+                        }
115
+                    }					
116
+                }
117 117
 
118
-			}
118
+            }
119 119
 
120
-			if ($this->when_to_run == "always") {
121
-				$addon_active = true;
122
-			}
120
+            if ($this->when_to_run == "always") {
121
+                $addon_active = true;
122
+            }
123 123
 
124
-			return apply_filters('rapid_is_active_add_on', $addon_active, $post_type, $this->slug);
125
-		}
124
+            return apply_filters('rapid_is_active_add_on', $addon_active, $post_type, $this->slug);
125
+        }
126 126
 		
127
-		/**
128
-		* 
129
-		* Add-On Initialization
130
-		*
131
-		* @param array $conditions - list of supported themes and post types
132
-		*
133
-		*/
134
-		function run($conditions = array()) {
135
-
136
-			if (empty($conditions)) {
137
-				$this->when_to_run = "always";
138
-			}
127
+        /**
128
+         * 
129
+         * Add-On Initialization
130
+         *
131
+         * @param array $conditions - list of supported themes and post types
132
+         *
133
+         */
134
+        function run($conditions = array()) {
135
+
136
+            if (empty($conditions)) {
137
+                $this->when_to_run = "always";
138
+            }
139 139
 
140
-			@$this->active_post_types = ( ! empty($conditions['post_types'])) ? $conditions['post_types'] : array();
141
-			@$this->active_themes = ( ! empty($conditions['themes'])) ? $conditions['themes'] : array();
142
-			@$this->active_plugins = ( ! empty($conditions['plugins'])) ? $conditions['plugins'] : array();			
140
+            @$this->active_post_types = ( ! empty($conditions['post_types'])) ? $conditions['post_types'] : array();
141
+            @$this->active_themes = ( ! empty($conditions['themes'])) ? $conditions['themes'] : array();
142
+            @$this->active_plugins = ( ! empty($conditions['plugins'])) ? $conditions['plugins'] : array();			
143 143
 
144
-			add_filter('pmxi_addons', array($this, 'wpai_api_register'));
145
-			add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
146
-			add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
147
-			add_filter('wp_all_import_addon_saved_post', array($this, 'wpai_api_post_saved'));
148
-			add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
144
+            add_filter('pmxi_addons', array($this, 'wpai_api_register'));
145
+            add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
146
+            add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
147
+            add_filter('wp_all_import_addon_saved_post', array($this, 'wpai_api_post_saved'));
148
+            add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
149 149
             add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1);
150 150
             add_filter('pmxi_custom_types', array($this, 'filter_post_types'), 10, 2);
151 151
             add_filter('pmxi_post_list_order', array($this,'sort_post_types'), 10, 1);
152 152
             add_filter('wp_all_import_post_type_image', array($this, 'post_type_image'), 10, 1 );
153
-			add_action('pmxi_extend_options_featured',  array($this, 'wpai_api_metabox'), 10, 2);
153
+            add_action('pmxi_extend_options_featured',  array($this, 'wpai_api_metabox'), 10, 2);
154 154
             add_action('admin_init', array($this, 'admin_notice_ignore'));
155 155
         }        
156 156
 
157
-		function parse($data) {
157
+        function parse($data) {
158 158
 			
159
-			if ( ! $this->is_active_addon($data['import']->options['custom_type'])) return false;
159
+            if ( ! $this->is_active_addon($data['import']->options['custom_type'])) return false;
160 160
 
161
-			$parsedData = $this->helper_parse($data, $this->options_array());
162
-			return $parsedData;
161
+            $parsedData = $this->helper_parse($data, $this->options_array());
162
+            return $parsedData;
163 163
 
164
-		}
164
+        }
165 165
 
166 166
 
167
-		function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true, $default_text = '') {
167
+        function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "", $is_html = true, $default_text = '') {
168 168
 
169
-			$field =  array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text);
169
+            $field =  array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug, "is_html" => $is_html, 'default_text' => $default_text);
170 170
 
171
-			$this->fields[$field_slug] = $field;
171
+            $this->fields[$field_slug] = $field;
172 172
 
173
-			if ( ! empty($enum_values) ){
174
-				foreach ($enum_values as $key => $value) {
175
-					if (is_array($value))
176
-					{
177
-						if ($field['type'] == 'accordion')
178
-						{
179
-							$this->fields[$value['slug']]['is_sub_field'] = true;
180
-						}
181
-						else
182
-						{
183
-							foreach ($value as $n => $param) {							
184
-								if (is_array($param) and ! empty($this->fields[$param['slug']])){
185
-									$this->fields[$param['slug']]['is_sub_field'] = true;								
186
-								}
187
-							}
188
-						}
189
-					}
190
-				}
191
-			}
173
+            if ( ! empty($enum_values) ){
174
+                foreach ($enum_values as $key => $value) {
175
+                    if (is_array($value))
176
+                    {
177
+                        if ($field['type'] == 'accordion')
178
+                        {
179
+                            $this->fields[$value['slug']]['is_sub_field'] = true;
180
+                        }
181
+                        else
182
+                        {
183
+                            foreach ($value as $n => $param) {							
184
+                                if (is_array($param) and ! empty($this->fields[$param['slug']])){
185
+                                    $this->fields[$param['slug']]['is_sub_field'] = true;								
186
+                                }
187
+                            }
188
+                        }
189
+                    }
190
+                }
191
+            }
192 192
 
193
-			return $field;
193
+            return $field;
194 194
 
195
-		}
195
+        }
196 196
 
197
-		function add_acf_field($field){
198
-			$this->fields[$field->post_name] = array(
199
-				'type' => 'acf',
200
-				'field_obj' => $field
201
-			);
202
-		}
197
+        function add_acf_field($field){
198
+            $this->fields[$field->post_name] = array(
199
+                'type' => 'acf',
200
+                'field_obj' => $field
201
+            );
202
+        }
203 203
 
204
-		private $acfGroups = array();
204
+        private $acfGroups = array();
205 205
 
206
-		function use_acf_group($acf_group){
207
-			$this->add_text(
208
-				'<div class="postbox acf_postbox default acf_signle_group rad4">
206
+        function use_acf_group($acf_group){
207
+            $this->add_text(
208
+                '<div class="postbox acf_postbox default acf_signle_group rad4">
209 209
     <h3 class="hndle" style="margin-top:0;"><span>'.$acf_group['title'].'</span></h3>
210 210
 	    <div class="inside">');
211
-			$acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
212
-			if (!empty($acf_fields)){
213
-				foreach ($acf_fields as $field) {
214
-					$this->add_acf_field($field);
215
-				}
216
-			}
217
-			$this->add_text('</div></div>');
218
-			$this->acfGroups[] = $acf_group['ID'];
219
-			add_filter('wp_all_import_acf_is_show_group', array($this, 'acf_is_show_group'), 10, 2);
220
-		}
221
-
222
-		function acf_is_show_group($is_show, $acf_group){
223
-			return (in_array($acf_group['ID'], $this->acfGroups)) ? false : true;
224
-		}
225
-
226
-		/**
227
-		* 
228
-		* Add an option to WP All Import options list
229
-		*
230
-		* @param string $slug - option name
231
-		* @param string $default_value - default option value
232
-		*
233
-		*/
234
-		function add_option($slug, $default_value = ''){
235
-			$this->options[$slug] = $default_value;
236
-		}
211
+            $acf_fields = get_posts(array('posts_per_page' => -1, 'post_type' => 'acf-field', 'post_parent' => $acf_group['ID'], 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC'));
212
+            if (!empty($acf_fields)){
213
+                foreach ($acf_fields as $field) {
214
+                    $this->add_acf_field($field);
215
+                }
216
+            }
217
+            $this->add_text('</div></div>');
218
+            $this->acfGroups[] = $acf_group['ID'];
219
+            add_filter('wp_all_import_acf_is_show_group', array($this, 'acf_is_show_group'), 10, 2);
220
+        }
237 221
 
238
-		function options_array() {
222
+        function acf_is_show_group($is_show, $acf_group){
223
+            return (in_array($acf_group['ID'], $this->acfGroups)) ? false : true;
224
+        }
225
+
226
+        /**
227
+         * 
228
+         * Add an option to WP All Import options list
229
+         *
230
+         * @param string $slug - option name
231
+         * @param string $default_value - default option value
232
+         *
233
+         */
234
+        function add_option($slug, $default_value = ''){
235
+            $this->options[$slug] = $default_value;
236
+        }
237
+
238
+        function options_array() {
239 239
 
240 240
             $options_list = array();
241 241
             
@@ -255,528 +255,528 @@  discard block
 block discarded – undo
255 255
 
256 256
             }			
257 257
 
258
-			if ( ! empty($this->options) ){
259
-				foreach ($this->options as $slug => $value) {
260
-					$options_arr[$slug] = $value;
261
-				}
262
-			}
258
+            if ( ! empty($this->options) ){
259
+                foreach ($this->options as $slug => $value) {
260
+                    $options_arr[$slug] = $value;
261
+                }
262
+            }
263 263
 
264
-			$options_arr[$this->slug]   = $options_list;
265
-			$options_arr['rapid_addon'] = plugin_basename( __FILE__ );
264
+            $options_arr[$this->slug]   = $options_list;
265
+            $options_arr['rapid_addon'] = plugin_basename( __FILE__ );
266 266
 
267
-			return $options_arr;
267
+            return $options_arr;
268 268
 
269
-		}
269
+        }
270 270
 
271
-		function wpai_api_options($all_options) {
271
+        function wpai_api_options($all_options) {
272 272
 
273
-			$all_options = $all_options + $this->options_array();
273
+            $all_options = $all_options + $this->options_array();
274 274
 
275
-			return $all_options;
275
+            return $all_options;
276 276
 
277
-		}
277
+        }
278 278
 
279 279
 
280
-		function wpai_api_register($addons) {
280
+        function wpai_api_register($addons) {
281 281
 
282
-			if (empty($addons[$this->slug])) {
283
-				$addons[$this->slug] = 1;
284
-			}
282
+            if (empty($addons[$this->slug])) {
283
+                $addons[$this->slug] = 1;
284
+            }
285 285
 
286
-			return $addons;
286
+            return $addons;
287 287
 
288
-		}
288
+        }
289 289
 
290 290
 
291
-		function wpai_api_parse($functions) {
291
+        function wpai_api_parse($functions) {
292 292
 
293
-			$functions[$this->slug] = array($this, 'parse');
294
-			return $functions;
293
+            $functions[$this->slug] = array($this, 'parse');
294
+            return $functions;
295 295
 
296
-		}
296
+        }
297 297
 
298
-		function wpai_api_post_saved($functions){
299
-			$functions[$this->slug] = array($this, 'post_saved');
300
-			return $functions;
301
-		}
298
+        function wpai_api_post_saved($functions){
299
+            $functions[$this->slug] = array($this, 'post_saved');
300
+            return $functions;
301
+        }
302 302
 
303 303
 
304
-		function wpai_api_import($functions) {
304
+        function wpai_api_import($functions) {
305 305
 
306
-			$functions[$this->slug] = array($this, 'import');
307
-			return $functions;
306
+            $functions[$this->slug] = array($this, 'import');
307
+            return $functions;
308 308
 
309
-		}
309
+        }
310 310
 
311
-		function post_saved( $importData ){
311
+        function post_saved( $importData ){
312 312
 
313
-			if (is_callable($this->post_saved_function))
314
-				call_user_func($this->post_saved_function, $importData['pid'], $importData['import'], $importData['logger']);
313
+            if (is_callable($this->post_saved_function))
314
+                call_user_func($this->post_saved_function, $importData['pid'], $importData['import'], $importData['logger']);
315 315
 			
316
-		}
316
+        }
317 317
 
318
-		function import($importData, $parsedData) {
318
+        function import($importData, $parsedData) {
319 319
 
320
-			if (!$this->is_active_addon($importData['post_type'])) {
321
-				return;
322
-			}
320
+            if (!$this->is_active_addon($importData['post_type'])) {
321
+                return;
322
+            }
323 323
 
324
-			$import_options = $importData['import']['options'][$this->slug];
324
+            $import_options = $importData['import']['options'][$this->slug];
325 325
 
326
-	//		echo "<pre>";
327
-	//		print_r($import_options);
328
-	//		echo "</pre>";
326
+    //		echo "<pre>";
327
+    //		print_r($import_options);
328
+    //		echo "</pre>";
329 329
 
330
-			if ( ! empty($parsedData) )	{
330
+            if ( ! empty($parsedData) )	{
331 331
 
332
-				$this->logger = $importData['logger'];
332
+                $this->logger = $importData['logger'];
333 333
 
334
-				$post_id = $importData['pid'];
335
-				$index = $importData['i'];
336
-				$data = array();
337
-				if (!empty($this->fields)){
338
-					foreach ($this->fields as $field_slug => $field_params) {
339
-						if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
340
-						switch ($field_params['type']) {
334
+                $post_id = $importData['pid'];
335
+                $index = $importData['i'];
336
+                $data = array();
337
+                if (!empty($this->fields)){
338
+                    foreach ($this->fields as $field_slug => $field_params) {
339
+                        if (in_array($field_params['type'], array('title', 'plain_text'))) continue;
340
+                        switch ($field_params['type']) {
341 341
 
342
-							case 'image':
342
+                            case 'image':
343 343
 								
344
-								// import the specified image, then set the value of the field to the image ID in the media library
344
+                                // import the specified image, then set the value of the field to the image ID in the media library
345 345
 
346
-								$image_url_or_path = $parsedData[$field_slug][$index];
346
+                                $image_url_or_path = $parsedData[$field_slug][$index];
347 347
 
348
-								if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
349
-									continue 2;
350
-								}
348
+                                if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
349
+                                    continue 2;
350
+                                }
351 351
 
352
-								$download = $import_options['download_image'][$field_slug];
352
+                                $download = $import_options['download_image'][$field_slug];
353 353
 
354
-								$uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "images", true, $importData['articleData']);
354
+                                $uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "images", true, $importData['articleData']);
355 355
 
356
-								$data[$field_slug] = array(
357
-									"attachment_id" => $uploaded_image,
358
-									"image_url_or_path" => $image_url_or_path,
359
-									"download" => $download
360
-								);
356
+                                $data[$field_slug] = array(
357
+                                    "attachment_id" => $uploaded_image,
358
+                                    "image_url_or_path" => $image_url_or_path,
359
+                                    "download" => $download
360
+                                );
361 361
 
362
-								break;
362
+                                break;
363 363
 
364
-							case 'file':
364
+                            case 'file':
365 365
 
366
-								$image_url_or_path = $parsedData[$field_slug][$index];
366
+                                $image_url_or_path = $parsedData[$field_slug][$index];
367 367
 
368
-								if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
369
-									continue 2;
370
-								}
368
+                                if ( ! array_key_exists( $field_slug, $import_options['download_image'] ) ) {
369
+                                    continue 2;
370
+                                }
371 371
 
372
-								$download = $import_options['download_image'][$field_slug];
372
+                                $download = $import_options['download_image'][$field_slug];
373 373
 
374
-								$uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files", true, $importData['articleData']);
374
+                                $uploaded_file = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true, "", "files", true, $importData['articleData']);
375 375
 
376
-								$data[$field_slug] = array(
377
-									"attachment_id" => $uploaded_file,
378
-									"image_url_or_path" => $image_url_or_path,
379
-									"download" => $download
380
-								);
376
+                                $data[$field_slug] = array(
377
+                                    "attachment_id" => $uploaded_file,
378
+                                    "image_url_or_path" => $image_url_or_path,
379
+                                    "download" => $download
380
+                                );
381 381
 
382
-								break;
382
+                                break;
383 383
 							
384
-							default:
385
-								// set the field data to the value of the field after it's been parsed
386
-								$data[$field_slug] = $parsedData[$field_slug][$index];
387
-								break;
388
-						}					
384
+                            default:
385
+                                // set the field data to the value of the field after it's been parsed
386
+                                $data[$field_slug] = $parsedData[$field_slug][$index];
387
+                                break;
388
+                        }					
389
+
390
+                        // apply mapping rules if they exist
391
+                        if (!empty($import_options['mapping'][$field_slug])) {
392
+                            $mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
393
+
394
+                            if (!empty($mapping_rules) and is_array($mapping_rules)) {
395
+                                foreach ($mapping_rules as $rule_number => $map_to) {
396
+                                    if (isset($map_to[trim($data[$field_slug])])){
397
+                                        $data[$field_slug] = trim($map_to[trim($data[$field_slug])]);
398
+                                        break;
399
+                                    }
400
+                                }
401
+                            }
402
+                        }
403
+                        // --------------------
404
+                    }
405
+                }				
389 406
 
390
-						// apply mapping rules if they exist
391
-						if (!empty($import_options['mapping'][$field_slug])) {
392
-							$mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
407
+                call_user_func($this->import_function, $post_id, $data, $importData['import'], $importData['articleData'], $importData['logger']);
408
+            }
393 409
 
394
-							if (!empty($mapping_rules) and is_array($mapping_rules)) {
395
-								foreach ($mapping_rules as $rule_number => $map_to) {
396
-									if (isset($map_to[trim($data[$field_slug])])){
397
-										$data[$field_slug] = trim($map_to[trim($data[$field_slug])]);
398
-										break;
399
-									}
400
-								}
401
-							}
402
-						}
403
-						// --------------------
404
-					}
405
-				}				
410
+        }
406 411
 
407
-				call_user_func($this->import_function, $post_id, $data, $importData['import'], $importData['articleData'], $importData['logger']);
408
-			}
409 412
 
410
-		}
413
+        function wpai_api_metabox($post_type, $current_values) {
411 414
 
415
+            if (!$this->is_active_addon($post_type)) {
416
+                return;
417
+            }
412 418
 
413
-		function wpai_api_metabox($post_type, $current_values) {
419
+            echo $this->helper_metabox_top($this->name);
414 420
 
415
-			if (!$this->is_active_addon($post_type)) {
416
-				return;
417
-			}
421
+            $visible_fields = 0;
418 422
 
419
-			echo $this->helper_metabox_top($this->name);
423
+            foreach ($this->fields as $field_slug => $field_params) {
424
+                if ($field_params['is_sub_field']) continue;
425
+                $visible_fields++;
426
+            }
420 427
 
421
-			$visible_fields = 0;
428
+            $counter = 0;
422 429
 
423
-			foreach ($this->fields as $field_slug => $field_params) {
424
-				if ($field_params['is_sub_field']) continue;
425
-				$visible_fields++;
426
-			}
430
+            foreach ($this->fields as $field_slug => $field_params) {				
427 431
 
428
-			$counter = 0;
432
+                // do not render sub fields
433
+                if ($field_params['is_sub_field']) continue;		
429 434
 
430
-			foreach ($this->fields as $field_slug => $field_params) {				
435
+                $counter++;		
431 436
 
432
-				// do not render sub fields
433
-				if ($field_params['is_sub_field']) continue;		
437
+                $this->render_field($field_params, $field_slug, $current_values, $visible_fields == $counter);										
434 438
 
435
-				$counter++;		
439
+                //if ( $field_params['type'] != 'accordion' ) echo "<br />";				
436 440
 
437
-				$this->render_field($field_params, $field_slug, $current_values, $visible_fields == $counter);										
441
+            }
438 442
 
439
-				//if ( $field_params['type'] != 'accordion' ) echo "<br />";				
443
+            echo $this->helper_metabox_bottom();
444
+
445
+            if ( ! empty($this->image_sections) ){				
446
+                $is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type);						
447
+                foreach ($this->image_sections as $k => $section) {
448
+                    $section_options = array();
449
+                    foreach ($this->image_options as $slug => $value) {
450
+                        $section_options[$section['slug'] . $slug] = $value;
451
+                    }										
452
+                    if ( ! $is_images_section_enabled and ! $k ){
453
+                        $section_options[$section['slug'] . 'is_featured'] = 1;
454
+                    }
455
+                    PMXI_API::add_additional_images_section($section['title'], $section['slug'], $current_values, '', true, false, $section['type']);
456
+                }
457
+            }
440 458
 
441
-			}
459
+        }		
442 460
 
443
-			echo $this->helper_metabox_bottom();
461
+        function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){
444 462
 
445
-			if ( ! empty($this->image_sections) ){				
446
-				$is_images_section_enabled = apply_filters('wp_all_import_is_images_section_enabled', true, $post_type);						
447
-				foreach ($this->image_sections as $k => $section) {
448
-					$section_options = array();
449
-					foreach ($this->image_options as $slug => $value) {
450
-						$section_options[$section['slug'] . $slug] = $value;
451
-					}										
452
-					if ( ! $is_images_section_enabled and ! $k ){
453
-						$section_options[$section['slug'] . 'is_featured'] = 1;
454
-					}
455
-					PMXI_API::add_additional_images_section($section['title'], $section['slug'], $current_values, '', true, false, $section['type']);
456
-				}
457
-			}
458
-
459
-		}		
460
-
461
-		function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){
462
-
463
-			if (!isset($current_values[$this->slug][$field_slug])) {
464
-				$current_values[$this->slug][$field_slug] = isset($field_params['default_text']) ? $field_params['default_text'] : '';
465
-			}
466
-
467
-			if ($field_params['type'] == 'text') {
468
-
469
-				PMXI_API::add_field(
470
-					'simple',
471
-					$field_params['name'],
472
-					array(
473
-						'tooltip' => $field_params['tooltip'],
474
-						'field_name' => $this->slug."[".$field_slug."]",
475
-						'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
476
-					)
477
-				);
478
-
479
-			} else if ($field_params['type'] == 'textarea') {
480
-
481
-				PMXI_API::add_field(
482
-					'textarea',
483
-					$field_params['name'],
484
-					array(
485
-						'tooltip' => $field_params['tooltip'],
486
-						'field_name' => $this->slug."[".$field_slug."]",
487
-						'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
488
-					)
489
-				);
490
-
491
-			} else if ($field_params['type'] == 'wp_editor') {
492
-
493
-				PMXI_API::add_field(
494
-					'wp_editor',
495
-					$field_params['name'],
496
-					array(
497
-						'tooltip' => $field_params['tooltip'],
498
-						'field_name' => $this->slug."[".$field_slug."]",
499
-						'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
500
-					)
501
-				);
502
-
503
-			} else if ($field_params['type'] == 'image' or $field_params['type'] == 'file') {
463
+            if (!isset($current_values[$this->slug][$field_slug])) {
464
+                $current_values[$this->slug][$field_slug] = isset($field_params['default_text']) ? $field_params['default_text'] : '';
465
+            }
466
+
467
+            if ($field_params['type'] == 'text') {
468
+
469
+                PMXI_API::add_field(
470
+                    'simple',
471
+                    $field_params['name'],
472
+                    array(
473
+                        'tooltip' => $field_params['tooltip'],
474
+                        'field_name' => $this->slug."[".$field_slug."]",
475
+                        'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
476
+                    )
477
+                );
478
+
479
+            } else if ($field_params['type'] == 'textarea') {
480
+
481
+                PMXI_API::add_field(
482
+                    'textarea',
483
+                    $field_params['name'],
484
+                    array(
485
+                        'tooltip' => $field_params['tooltip'],
486
+                        'field_name' => $this->slug."[".$field_slug."]",
487
+                        'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
488
+                    )
489
+                );
490
+
491
+            } else if ($field_params['type'] == 'wp_editor') {
492
+
493
+                PMXI_API::add_field(
494
+                    'wp_editor',
495
+                    $field_params['name'],
496
+                    array(
497
+                        'tooltip' => $field_params['tooltip'],
498
+                        'field_name' => $this->slug."[".$field_slug."]",
499
+                        'field_value' => ( $current_values[$this->slug][$field_slug] == '' && $this->isWizard ) ? $field_params['default_text'] : $current_values[$this->slug][$field_slug]
500
+                    )
501
+                );
502
+
503
+            } else if ($field_params['type'] == 'image' or $field_params['type'] == 'file') {
504 504
 				
505
-				if (!isset($current_values[$this->slug]['download_image'][$field_slug])) { $current_values[$this->slug]['download_image'][$field_slug] = ''; }
506
-
507
-				PMXI_API::add_field(
508
-					$field_params['type'],
509
-					$field_params['name'],
510
-					array(
511
-						'tooltip' => $field_params['tooltip'],
512
-						'field_name' => $this->slug."[".$field_slug."]",
513
-						'field_value' => $current_values[$this->slug][$field_slug],
514
-						'download_image' => $current_values[$this->slug]['download_image'][$field_slug],
515
-						'field_key' => $field_slug,
516
-						'addon_prefix' => $this->slug
517
-
518
-					)
519
-				);
520
-
521
-			} else if ($field_params['type'] == 'radio') {					
505
+                if (!isset($current_values[$this->slug]['download_image'][$field_slug])) { $current_values[$this->slug]['download_image'][$field_slug] = ''; }
506
+
507
+                PMXI_API::add_field(
508
+                    $field_params['type'],
509
+                    $field_params['name'],
510
+                    array(
511
+                        'tooltip' => $field_params['tooltip'],
512
+                        'field_name' => $this->slug."[".$field_slug."]",
513
+                        'field_value' => $current_values[$this->slug][$field_slug],
514
+                        'download_image' => $current_values[$this->slug]['download_image'][$field_slug],
515
+                        'field_key' => $field_slug,
516
+                        'addon_prefix' => $this->slug
517
+
518
+                    )
519
+                );
520
+
521
+            } else if ($field_params['type'] == 'radio') {					
522 522
 				
523
-				if (!isset($current_values[$this->slug]['mapping'][$field_slug])) { $current_values[$this->slug]['mapping'][$field_slug] = array(); }
524
-				if (!isset($current_values[$this->slug]['xpaths'][$field_slug])) { $current_values[$this->slug]['xpaths'][$field_slug] = ''; }
525
-
526
-				PMXI_API::add_field(
527
-					'enum',
528
-					$field_params['name'],
529
-					array(
530
-						'tooltip' => $field_params['tooltip'],
531
-						'field_name' => $this->slug."[".$field_slug."]",
532
-						'field_value' => $current_values[$this->slug][$field_slug],
533
-						'enum_values' => $field_params['enum_values'],
534
-						'mapping' => true,
535
-						'field_key' => $field_slug,
536
-						'mapping_rules' => $current_values[$this->slug]['mapping'][$field_slug],
537
-						'xpath' => $current_values[$this->slug]['xpaths'][$field_slug],
538
-						'addon_prefix' => $this->slug,
539
-						'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values)
540
-					)
541
-				);
542
-
543
-			} else if($field_params['type'] == 'accordion') {
544
-
545
-				PMXI_API::add_field(
546
-					'accordion',
547
-					$field_params['name'],
548
-					array(						
549
-						'tooltip' => $field_params['tooltip'],
550
-						'field_name' => $this->slug."[".$field_slug."]",																
551
-						'field_key' => $field_slug,								
552
-						'addon_prefix' => $this->slug,
553
-						'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values),
554
-						'in_the_bottom' => $in_the_bottom						
555
-					)
556
-				);
557
-
558
-			} else if($field_params['type'] == 'acf') {
559
-				$fieldData = (!empty($field_params['field_obj']->post_content)) ? unserialize($field_params['field_obj']->post_content) : array();
560
-				$fieldData['ID']    = $field_params['field_obj']->ID;
561
-				$fieldData['id']    = $field_params['field_obj']->ID;
562
-				$fieldData['label'] = $field_params['field_obj']->post_title;
563
-				$fieldData['key']   = $field_params['field_obj']->post_name;
564
-				if (empty($fieldData['name'])) $fieldData['name'] = $field_params['field_obj']->post_excerpt;
565
-				if (function_exists('pmai_render_field')) {
566
-					echo pmai_render_field($fieldData, ( ! empty($current_values) ) ? $current_values : array() );
567
-				}
568
-			} else if($field_params['type'] == 'title'){
569
-				?>
523
+                if (!isset($current_values[$this->slug]['mapping'][$field_slug])) { $current_values[$this->slug]['mapping'][$field_slug] = array(); }
524
+                if (!isset($current_values[$this->slug]['xpaths'][$field_slug])) { $current_values[$this->slug]['xpaths'][$field_slug] = ''; }
525
+
526
+                PMXI_API::add_field(
527
+                    'enum',
528
+                    $field_params['name'],
529
+                    array(
530
+                        'tooltip' => $field_params['tooltip'],
531
+                        'field_name' => $this->slug."[".$field_slug."]",
532
+                        'field_value' => $current_values[$this->slug][$field_slug],
533
+                        'enum_values' => $field_params['enum_values'],
534
+                        'mapping' => true,
535
+                        'field_key' => $field_slug,
536
+                        'mapping_rules' => $current_values[$this->slug]['mapping'][$field_slug],
537
+                        'xpath' => $current_values[$this->slug]['xpaths'][$field_slug],
538
+                        'addon_prefix' => $this->slug,
539
+                        'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values)
540
+                    )
541
+                );
542
+
543
+            } else if($field_params['type'] == 'accordion') {
544
+
545
+                PMXI_API::add_field(
546
+                    'accordion',
547
+                    $field_params['name'],
548
+                    array(						
549
+                        'tooltip' => $field_params['tooltip'],
550
+                        'field_name' => $this->slug."[".$field_slug."]",																
551
+                        'field_key' => $field_slug,								
552
+                        'addon_prefix' => $this->slug,
553
+                        'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values),
554
+                        'in_the_bottom' => $in_the_bottom						
555
+                    )
556
+                );
557
+
558
+            } else if($field_params['type'] == 'acf') {
559
+                $fieldData = (!empty($field_params['field_obj']->post_content)) ? unserialize($field_params['field_obj']->post_content) : array();
560
+                $fieldData['ID']    = $field_params['field_obj']->ID;
561
+                $fieldData['id']    = $field_params['field_obj']->ID;
562
+                $fieldData['label'] = $field_params['field_obj']->post_title;
563
+                $fieldData['key']   = $field_params['field_obj']->post_name;
564
+                if (empty($fieldData['name'])) $fieldData['name'] = $field_params['field_obj']->post_excerpt;
565
+                if (function_exists('pmai_render_field')) {
566
+                    echo pmai_render_field($fieldData, ( ! empty($current_values) ) ? $current_values : array() );
567
+                }
568
+            } else if($field_params['type'] == 'title'){
569
+                ?>
570 570
 				<h4 class="wpallimport-add-on-options-title"><?php esc_html_e($field_params['name'], 'wp_all_import_plugin'); ?><?php if ( ! empty($field_params['tooltip'])): ?><a href="#help" class="wpallimport-help" title="<?php echo $field_params['tooltip']; ?>" style="position:relative; top: -1px;">?</a><?php endif; ?></h4>				
571 571
 				<?php
572 572
 
573
-			} else if($field_params['type'] == 'plain_text'){
574
-				if ($field_params['is_html']):					
575
-					echo $field_params['name'];				
576
-				else:
577
-					?>
573
+            } else if($field_params['type'] == 'plain_text'){
574
+                if ($field_params['is_html']):					
575
+                    echo $field_params['name'];				
576
+                else:
577
+                    ?>
578 578
 					<p style="margin: 0 0 12px 0;"><?php echo $field_params['name'];?></p>
579 579
 					<?php
580
-				endif;
581
-			}
580
+                endif;
581
+            }
582 582
 
583 583
 
584
-		}
585
-		/**
586
-		*
587
-		* Helper function for nested radio fields
588
-		*
589
-		*/
590
-		function get_sub_fields($field_params, $field_slug, $current_values){
591
-			$sub_fields = array();	
592
-			if ( ! empty($field_params['enum_values']) ){										
593
-				foreach ($field_params['enum_values'] as $key => $value) {					
594
-					$sub_fields[$key] = array();	
595
-					if (is_array($value)){
596
-						if ($field_params['type'] == 'accordion'){								
597
-							$sub_fields[$key][] = $this->convert_field($value, $current_values);
598
-						}
599
-						else
600
-						{
601
-							foreach ($value as $k => $sub_field) {								
602
-								if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
603
-								{									
604
-									$sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
605
-								}								
606
-							}
607
-						}
608
-					}
609
-				}
610
-			}
611
-			return $sub_fields;
612
-		}			
613
-
614
-		function convert_field($sub_field, $current_values){
615
-			$field = array();
616
-			if (!isset($current_values[$this->slug][$sub_field['slug']])) {
617
-				$current_values[$this->slug][$sub_field['slug']] = isset($sub_field['default_text']) ? $sub_field['default_text'] : '';
618
-			}
619
-			switch ($this->fields[$sub_field['slug']]['type']) {
620
-				case 'text':
621
-					$field = array(
622
-						'type'   => 'simple',
623
-						'label'  => $this->fields[$sub_field['slug']]['name'],
624
-						'params' => array(
625
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
626
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
627
-							'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
628
-							'is_main_field' => $sub_field['is_main_field']
629
-						)
630
-					);
631
-					break;
632
-				case 'textarea':
633
-					$field = array(
634
-						'type'   => 'textarea',
635
-						'label'  => $this->fields[$sub_field['slug']]['name'],
636
-						'params' => array(
637
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
638
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
639
-							'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
640
-							'is_main_field' => $sub_field['is_main_field']
641
-						)
642
-					);
643
-					break;
644
-				case 'wp_editor':
645
-					$field = array(
646
-						'type'   => 'wp_editor',
647
-						'label'  => $this->fields[$sub_field['slug']]['name'],
648
-						'params' => array(
649
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
650
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
651
-							'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
652
-							'is_main_field' => $sub_field['is_main_field']
653
-						)
654
-					);
655
-					break;
656
-				case 'image':
657
-					$field = array(
658
-						'type'   => 'image',
659
-						'label'  => $this->fields[$sub_field['slug']]['name'],
660
-						'params' => array(
661
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
662
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
663
-							'field_value' => $current_values[$this->slug][$sub_field['slug']],
664
-							'download_image' => null,
665
-							'field_key' => $sub_field['slug'],
666
-							'addon_prefix' => $this->slug,
667
-							'is_main_field' => $sub_field['is_main_field']
668
-						)
669
-					);
670
-
671
-					if ( array_key_exists( 'download_image', $current_values[$this->slug] ) && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) {
672
-						$field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
673
-					}
584
+        }
585
+        /**
586
+         *
587
+         * Helper function for nested radio fields
588
+         *
589
+         */
590
+        function get_sub_fields($field_params, $field_slug, $current_values){
591
+            $sub_fields = array();	
592
+            if ( ! empty($field_params['enum_values']) ){										
593
+                foreach ($field_params['enum_values'] as $key => $value) {					
594
+                    $sub_fields[$key] = array();	
595
+                    if (is_array($value)){
596
+                        if ($field_params['type'] == 'accordion'){								
597
+                            $sub_fields[$key][] = $this->convert_field($value, $current_values);
598
+                        }
599
+                        else
600
+                        {
601
+                            foreach ($value as $k => $sub_field) {								
602
+                                if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
603
+                                {									
604
+                                    $sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
605
+                                }								
606
+                            }
607
+                        }
608
+                    }
609
+                }
610
+            }
611
+            return $sub_fields;
612
+        }			
613
+
614
+        function convert_field($sub_field, $current_values){
615
+            $field = array();
616
+            if (!isset($current_values[$this->slug][$sub_field['slug']])) {
617
+                $current_values[$this->slug][$sub_field['slug']] = isset($sub_field['default_text']) ? $sub_field['default_text'] : '';
618
+            }
619
+            switch ($this->fields[$sub_field['slug']]['type']) {
620
+                case 'text':
621
+                    $field = array(
622
+                        'type'   => 'simple',
623
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
624
+                        'params' => array(
625
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
626
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
627
+                            'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
628
+                            'is_main_field' => $sub_field['is_main_field']
629
+                        )
630
+                    );
674 631
                     break;
675
-				case 'file':
676
-					$field = array(
677
-						'type'   => 'file',
678
-						'label'  => $this->fields[$sub_field['slug']]['name'],
679
-						'params' => array(
680
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
681
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
682
-							'field_value' => $current_values[$this->slug][$sub_field['slug']],
683
-							'download_image' => null,
684
-							'field_key' => $sub_field['slug'],
685
-							'addon_prefix' => $this->slug,
686
-							'is_main_field' => $sub_field['is_main_field']
687
-						)
688
-					);
689
-
690
-					if ( array_key_exists( 'download_image', $current_values[$this->slug] )  && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) {
691
-						$field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
692
-					}
693
-
694
-					break;
695
-				case 'radio':
696
-					$field = array(
697
-						'type'   => 'enum',
698
-						'label'  => $this->fields[$sub_field['slug']]['name'],
699
-						'params' => array(
700
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
701
-							'field_name' => $this->slug."[".$sub_field['slug']."]",
702
-							'field_value' => $current_values[$this->slug][$sub_field['slug']],
703
-							'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
704
-							'mapping' => true,
705
-							'field_key' => $sub_field['slug'],
706
-							'mapping_rules' => isset($current_values[$this->slug]['mapping'][$sub_field['slug']]) ? $current_values[$this->slug]['mapping'][$sub_field['slug']] : array(),
707
-							'xpath' => isset($current_values[$this->slug]['xpaths'][$sub_field['slug']]) ? $current_values[$this->slug]['xpaths'][$sub_field['slug']] : '',
708
-							'addon_prefix' => $this->slug,
709
-							'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
710
-							'is_main_field' => $sub_field['is_main_field']
711
-						)
712
-					);
713
-					break;
714
-				case 'accordion':
715
-					$field = array(
716
-						'type'   => 'accordion',
717
-						'label'  => $this->fields[$sub_field['slug']]['name'],
718
-						'params' => array(
719
-							'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
720
-							'field_name' => $this->slug."[".$sub_field['slug']."]",																
721
-							'field_key' => $sub_field['slug'],								
722
-							'addon_prefix' => $this->slug,
723
-							'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
724
-							'in_the_bottom' => false
725
-						)
726
-					);						
727
-					break;
728
-				default:
729
-					# code...
730
-					break;
731
-			}
732
-			return $field;
733
-		}				
734
-
735
-		/**
736
-		* 
737
-		* Add accordion options
738
-		*
739
-		*
740
-		*/
741
-		function add_options( $main_field = false, $title = '', $fields = array() ){
632
+                case 'textarea':
633
+                    $field = array(
634
+                        'type'   => 'textarea',
635
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
636
+                        'params' => array(
637
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
638
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
639
+                            'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
640
+                            'is_main_field' => $sub_field['is_main_field']
641
+                        )
642
+                    );
643
+                    break;
644
+                case 'wp_editor':
645
+                    $field = array(
646
+                        'type'   => 'wp_editor',
647
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
648
+                        'params' => array(
649
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
650
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
651
+                            'field_value' => ($current_values[$this->slug][$sub_field['slug']] == '' && $this->isWizard) ? $sub_field['default_text'] : $current_values[$this->slug][$sub_field['slug']],
652
+                            'is_main_field' => $sub_field['is_main_field']
653
+                        )
654
+                    );
655
+                    break;
656
+                case 'image':
657
+                    $field = array(
658
+                        'type'   => 'image',
659
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
660
+                        'params' => array(
661
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
662
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
663
+                            'field_value' => $current_values[$this->slug][$sub_field['slug']],
664
+                            'download_image' => null,
665
+                            'field_key' => $sub_field['slug'],
666
+                            'addon_prefix' => $this->slug,
667
+                            'is_main_field' => $sub_field['is_main_field']
668
+                        )
669
+                    );
670
+
671
+                    if ( array_key_exists( 'download_image', $current_values[$this->slug] ) && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) {
672
+                        $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
673
+                    }
674
+                    break;
675
+                case 'file':
676
+                    $field = array(
677
+                        'type'   => 'file',
678
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
679
+                        'params' => array(
680
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
681
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
682
+                            'field_value' => $current_values[$this->slug][$sub_field['slug']],
683
+                            'download_image' => null,
684
+                            'field_key' => $sub_field['slug'],
685
+                            'addon_prefix' => $this->slug,
686
+                            'is_main_field' => $sub_field['is_main_field']
687
+                        )
688
+                    );
689
+
690
+                    if ( array_key_exists( 'download_image', $current_values[$this->slug] )  && array_key_exists( $sub_field['slug'], $current_values[$this->slug]['download_image'] ) ) {
691
+                        $field['params']['download_image'] = $current_values[$this->slug]['download_image'][$sub_field['slug']];
692
+                    }
693
+
694
+                    break;
695
+                case 'radio':
696
+                    $field = array(
697
+                        'type'   => 'enum',
698
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
699
+                        'params' => array(
700
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
701
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",
702
+                            'field_value' => $current_values[$this->slug][$sub_field['slug']],
703
+                            'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
704
+                            'mapping' => true,
705
+                            'field_key' => $sub_field['slug'],
706
+                            'mapping_rules' => isset($current_values[$this->slug]['mapping'][$sub_field['slug']]) ? $current_values[$this->slug]['mapping'][$sub_field['slug']] : array(),
707
+                            'xpath' => isset($current_values[$this->slug]['xpaths'][$sub_field['slug']]) ? $current_values[$this->slug]['xpaths'][$sub_field['slug']] : '',
708
+                            'addon_prefix' => $this->slug,
709
+                            'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
710
+                            'is_main_field' => $sub_field['is_main_field']
711
+                        )
712
+                    );
713
+                    break;
714
+                case 'accordion':
715
+                    $field = array(
716
+                        'type'   => 'accordion',
717
+                        'label'  => $this->fields[$sub_field['slug']]['name'],
718
+                        'params' => array(
719
+                            'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
720
+                            'field_name' => $this->slug."[".$sub_field['slug']."]",																
721
+                            'field_key' => $sub_field['slug'],								
722
+                            'addon_prefix' => $this->slug,
723
+                            'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
724
+                            'in_the_bottom' => false
725
+                        )
726
+                    );						
727
+                    break;
728
+                default:
729
+                    # code...
730
+                    break;
731
+            }
732
+            return $field;
733
+        }				
734
+
735
+        /**
736
+         * 
737
+         * Add accordion options
738
+         *
739
+         *
740
+         */
741
+        function add_options( $main_field = false, $title = '', $fields = array() ){
742 742
 			
743
-			if ( ! empty($fields) )
744
-			{				
743
+            if ( ! empty($fields) )
744
+            {				
745 745
 				
746
-				if ($main_field){
746
+                if ($main_field){
747 747
 
748
-					$main_field['is_main_field'] = true;
749
-					$fields[] = $main_field;
748
+                    $main_field['is_main_field'] = true;
749
+                    $fields[] = $main_field;
750 750
 
751
-				}
751
+                }
752 752
 
753
-				return $this->add_field('accordion_' . $fields[0]['slug'], $title, 'accordion', $fields);							
753
+                return $this->add_field('accordion_' . $fields[0]['slug'], $title, 'accordion', $fields);							
754 754
 			
755
-			}
755
+            }
756 756
 
757
-		}			
757
+        }			
758 758
 
759
-		function add_title($title = '', $tooltip = ''){
759
+        function add_title($title = '', $tooltip = ''){
760 760
 
761
-			if (empty($title)) return;
761
+            if (empty($title)) return;
762 762
 
763
-			return $this->add_field(sanitize_key($title) . time(), $title, 'title', null, $tooltip);			
763
+            return $this->add_field(sanitize_key($title) . time(), $title, 'title', null, $tooltip);			
764 764
 
765
-		}		
765
+        }		
766 766
 
767
-		function add_text($text = '', $is_html = false){
767
+        function add_text($text = '', $is_html = false){
768 768
 
769
-			if (empty($text)) return;
769
+            if (empty($text)) return;
770 770
 
771
-			$count = is_array($this->fields) ? count($this->fields) : 0;
771
+            $count = is_array($this->fields) ? count($this->fields) : 0;
772 772
 
773
-			return $this->add_field(sanitize_key($text) . time() . uniqid() . $count, $text, 'plain_text', null, "", $is_html);
773
+            return $this->add_field(sanitize_key($text) . time() . uniqid() . $count, $text, 'plain_text', null, "", $is_html);
774 774
 
775
-		}			
775
+        }			
776 776
 
777
-		function helper_metabox_top($name) {
777
+        function helper_metabox_top($name) {
778 778
 
779
-			return '
779
+            return '
780 780
 			<style type="text/css">
781 781
 				.wpallimport-plugin .wpallimport-addon div.input {
782 782
 					margin-bottom: 15px;
@@ -872,11 +872,11 @@  discard block
 block discarded – undo
872 872
 							<table class="form-table" style="max-width:none;">
873 873
 								<tr>
874 874
 									<td colspan="3">';
875
-		}
875
+        }
876 876
 
877
-		function helper_metabox_bottom() {
877
+        function helper_metabox_bottom() {
878 878
 
879
-			return '				</td>
879
+            return '				</td>
880 880
 								</tr>
881 881
 							</table>
882 882
 						</div>
@@ -884,298 +884,298 @@  discard block
 block discarded – undo
884 884
 				</div>
885 885
 			</div>';
886 886
 
887
-		}
887
+        }
888 888
 
889
-		/**
890
-		*
891
-		* simply add an additional section for attachments
892
-		*
893
-		*/
894
-		function import_files( $slug, $title, $callback = NULL ){
895
-			$this->import_images( $slug, $title, 'files', $callback);
896
-		}
889
+        /**
890
+         *
891
+         * simply add an additional section for attachments
892
+         *
893
+         */
894
+        function import_files( $slug, $title, $callback = NULL ){
895
+            $this->import_images( $slug, $title, 'files', $callback);
896
+        }
897 897
 
898
-		/**
899
-		*
900
-		* simply add an additional section 
901
-		*
902
-		*/
903
-		function import_images( $slug, $title, $type = 'images', $callback = NULL ){
898
+        /**
899
+         *
900
+         * simply add an additional section 
901
+         *
902
+         */
903
+        function import_images( $slug, $title, $type = 'images', $callback = NULL ){
904 904
 			
905
-			if ( empty($title) or empty($slug) ) return;
905
+            if ( empty($title) or empty($slug) ) return;
906 906
 
907
-			if (is_array($slug)) {
907
+            if (is_array($slug)) {
908 908
                 $section_slug = 'pmxi_' . md5(serialize($slug));
909 909
             } else {
910 910
                 $section_slug = 'pmxi_' . $slug;
911 911
             }
912 912
 
913
-			$this->image_sections[] = array(
914
-				'title' => $title,
915
-				'slug'  => $section_slug,
916
-				'type'  => $type
917
-			);			
913
+            $this->image_sections[] = array(
914
+                'title' => $title,
915
+                'slug'  => $section_slug,
916
+                'type'  => $type
917
+            );			
918 918
 			
919
-			foreach ($this->image_options as $option_slug => $value) {
920
-				$this->add_option($section_slug . $option_slug, $value);
921
-			}
919
+            foreach ($this->image_options as $option_slug => $value) {
920
+                $this->add_option($section_slug . $option_slug, $value);
921
+            }
922 922
 
923
-			if (count($this->image_sections) > 1){
924
-				add_filter('wp_all_import_is_show_add_new_images', array($this, 'filter_is_show_add_new_images'), 10, 2);
925
-			}
923
+            if (count($this->image_sections) > 1){
924
+                add_filter('wp_all_import_is_show_add_new_images', array($this, 'filter_is_show_add_new_images'), 10, 2);
925
+            }
926 926
 
927
-			add_filter('wp_all_import_is_allow_import_images', array($this, 'is_allow_import_images'), 10, 2);			
927
+            add_filter('wp_all_import_is_allow_import_images', array($this, 'is_allow_import_images'), 10, 2);			
928 928
 
929
-			if ($callback && is_callable($callback)) {
929
+            if ($callback && is_callable($callback)) {
930 930
                 add_action( $section_slug, $callback, 10, 4);
931 931
             } else {
932 932
                 if (function_exists($slug)) {
933 933
                     add_action( $section_slug, $slug, 10, 4);
934 934
                 }
935 935
             }
936
-		}			
937
-			/**
938
-			*
939
-			* filter to allow import images for free edition of WP All Import
940
-			*
941
-			*/
942
-			function is_allow_import_images($is_allow, $post_type){
943
-				return ($this->is_active_addon($post_type)) ? true : $is_allow;
944
-			}
945
-
946
-		/**
947
-		*
948
-		* filter to control additional images sections
949
-		*
950
-		*/
951
-		function additional_sections($sections){
952
-			if ( ! empty($this->image_sections) ){
953
-				foreach ($this->image_sections as $add_section) {
954
-					$sections[] = $add_section;
955
-				}
956
-			}
936
+        }			
937
+            /**
938
+             *
939
+             * filter to allow import images for free edition of WP All Import
940
+             *
941
+             */
942
+            function is_allow_import_images($is_allow, $post_type){
943
+                return ($this->is_active_addon($post_type)) ? true : $is_allow;
944
+            }
945
+
946
+        /**
947
+         *
948
+         * filter to control additional images sections
949
+         *
950
+         */
951
+        function additional_sections($sections){
952
+            if ( ! empty($this->image_sections) ){
953
+                foreach ($this->image_sections as $add_section) {
954
+                    $sections[] = $add_section;
955
+                }
956
+            }
957 957
 			
958
-			return $sections;
959
-		}
960
-			/**
961
-			*
962
-			* remove the 'Don't touch existing images, append new images' when more than one image section is in use.
963
-			*
964
-			*/
965
-			function filter_is_show_add_new_images($is_show, $post_type){
966
-				return ($this->is_active_addon($post_type)) ? false : $is_show;
967
-			}
968
-
969
-		/**
970
-		*
971
-		* disable the default images section
972
-		*
973
-		*/		
974
-		function disable_default_images($post_type = false){
958
+            return $sections;
959
+        }
960
+            /**
961
+             *
962
+             * remove the 'Don't touch existing images, append new images' when more than one image section is in use.
963
+             *
964
+             */
965
+            function filter_is_show_add_new_images($is_show, $post_type){
966
+                return ($this->is_active_addon($post_type)) ? false : $is_show;
967
+            }
968
+
969
+        /**
970
+         *
971
+         * disable the default images section
972
+         *
973
+         */		
974
+        function disable_default_images($post_type = false){
975 975
 									
976
-			add_filter('wp_all_import_is_images_section_enabled', array($this, 'is_enable_default_images_section'), 10, 2);
976
+            add_filter('wp_all_import_is_images_section_enabled', array($this, 'is_enable_default_images_section'), 10, 2);
977 977
 
978
-		}
979
-			function is_enable_default_images_section($is_enabled, $post_type){						
978
+        }
979
+            function is_enable_default_images_section($is_enabled, $post_type){						
980 980
 				
981
-				return ($this->is_active_addon($post_type)) ? false : true;
981
+                return ($this->is_active_addon($post_type)) ? false : true;
982 982
 								
983
-			}
983
+            }
984 984
 
985
-		function helper_parse($parsingData, $options) {
985
+        function helper_parse($parsingData, $options) {
986 986
 
987
-			extract($parsingData);
987
+            extract($parsingData);
988 988
 
989
-			$data = array(); // parsed data
989
+            $data = array(); // parsed data
990 990
 
991
-			if ( ! empty($import->options[$this->slug])){
991
+            if ( ! empty($import->options[$this->slug])){
992 992
 
993
-				$this->logger = $parsingData['logger'];
993
+                $this->logger = $parsingData['logger'];
994 994
 
995
-				$cxpath = $xpath_prefix . $import->xpath;
995
+                $cxpath = $xpath_prefix . $import->xpath;
996 996
 
997
-				$tmp_files = array();
997
+                $tmp_files = array();
998 998
 
999
-				foreach ($options[$this->slug] as $option_name => $option_value) {					
1000
-					if ( isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') {						
1001
-						if ($import->options[$this->slug][$option_name] == "xpath") {
1002
-							if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
1003
-								$count and $data[$option_name] = array_fill(0, $count, "");
1004
-							} else {
1005
-								$data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse();
1006
-								$tmp_files[] = $file;						
1007
-							}
1008
-						} 
1009
-						else {							
1010
-							$data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug][$option_name], $file)->parse();
1011
-							$tmp_files[] = $file;
1012
-						}
999
+                foreach ($options[$this->slug] as $option_name => $option_value) {					
1000
+                    if ( isset($import->options[$this->slug][$option_name]) and $import->options[$this->slug][$option_name] != '') {						
1001
+                        if ($import->options[$this->slug][$option_name] == "xpath") {
1002
+                            if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
1003
+                                $count and $data[$option_name] = array_fill(0, $count, "");
1004
+                            } else {
1005
+                                $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug]['xpaths'][$option_name], $file)->parse();
1006
+                                $tmp_files[] = $file;						
1007
+                            }
1008
+                        } 
1009
+                        else {							
1010
+                            $data[$option_name] = XmlImportParser::factory($xml, $cxpath, (string) $import->options[$this->slug][$option_name], $file)->parse();
1011
+                            $tmp_files[] = $file;
1012
+                        }
1013 1013
 
1014 1014
 
1015
-					} else {
1016
-						$data[$option_name] = array_fill(0, $count, "");
1017
-					}
1015
+                    } else {
1016
+                        $data[$option_name] = array_fill(0, $count, "");
1017
+                    }
1018 1018
 
1019
-				}
1019
+                }
1020 1020
 
1021
-				foreach ($tmp_files as $file) { // remove all temporary files created
1022
-					unlink($file);
1023
-				}
1021
+                foreach ($tmp_files as $file) { // remove all temporary files created
1022
+                    unlink($file);
1023
+                }
1024 1024
 
1025
-			}
1025
+            }
1026 1026
 
1027
-			return $data;
1028
-		}
1027
+            return $data;
1028
+        }
1029 1029
 
1030 1030
 
1031
-		function can_update_meta($meta_key, $import_options) {
1031
+        function can_update_meta($meta_key, $import_options) {
1032 1032
 
1033
-			//echo "<pre>";
1034
-			//print_r($import_options['options']);
1035
-			//echo "</pre>";
1033
+            //echo "<pre>";
1034
+            //print_r($import_options['options']);
1035
+            //echo "</pre>";
1036 1036
 			
1037
-			$import_options = $import_options['options'];
1037
+            $import_options = $import_options['options'];
1038 1038
 
1039
-			if ($import_options['update_all_data'] == 'yes') return true;
1039
+            if ($import_options['update_all_data'] == 'yes') return true;
1040 1040
 
1041
-			if ( ! $import_options['is_update_custom_fields'] ) return false;			
1041
+            if ( ! $import_options['is_update_custom_fields'] ) return false;			
1042 1042
 
1043
-			if ($import_options['update_custom_fields_logic'] == "full_update") return true;
1044
-			if ($import_options['update_custom_fields_logic'] == "only" and ! empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list']) ) return true;
1045
-			if ($import_options['update_custom_fields_logic'] == "all_except" and ( empty($import_options['custom_fields_list']) or ! in_array($meta_key, $import_options['custom_fields_list']) )) return true;
1043
+            if ($import_options['update_custom_fields_logic'] == "full_update") return true;
1044
+            if ($import_options['update_custom_fields_logic'] == "only" and ! empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list']) ) return true;
1045
+            if ($import_options['update_custom_fields_logic'] == "all_except" and ( empty($import_options['custom_fields_list']) or ! in_array($meta_key, $import_options['custom_fields_list']) )) return true;
1046 1046
 
1047
-			return false;
1047
+            return false;
1048 1048
 
1049
-		}
1049
+        }
1050 1050
 
1051
-		function can_update_taxonomy($tax_name, $import_options) {
1051
+        function can_update_taxonomy($tax_name, $import_options) {
1052 1052
 
1053
-			//echo "<pre>";
1054
-			//print_r($import_options['options']);
1055
-			//echo "</pre>";
1053
+            //echo "<pre>";
1054
+            //print_r($import_options['options']);
1055
+            //echo "</pre>";
1056 1056
 			
1057
-			$import_options = $import_options['options'];
1057
+            $import_options = $import_options['options'];
1058 1058
 
1059
-			if ($import_options['update_all_data'] == 'yes') return true;
1059
+            if ($import_options['update_all_data'] == 'yes') return true;
1060 1060
 
1061
-			if ( ! $import_options['is_update_categories'] ) return false;			
1061
+            if ( ! $import_options['is_update_categories'] ) return false;			
1062 1062
 
1063
-			if ($import_options['update_categories_logic'] == "full_update") return true;
1064
-			if ($import_options['update_categories_logic'] == "only" and ! empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list']) ) return true;
1065
-			if ($import_options['update_categories_logic'] == "all_except" and ( empty($import_options['taxonomies_list']) or ! in_array($tax_name, $import_options['taxonomies_list']) )) return true;
1063
+            if ($import_options['update_categories_logic'] == "full_update") return true;
1064
+            if ($import_options['update_categories_logic'] == "only" and ! empty($import_options['taxonomies_list']) and is_array($import_options['taxonomies_list']) and in_array($tax_name, $import_options['taxonomies_list']) ) return true;
1065
+            if ($import_options['update_categories_logic'] == "all_except" and ( empty($import_options['taxonomies_list']) or ! in_array($tax_name, $import_options['taxonomies_list']) )) return true;
1066 1066
 
1067
-			return false;
1067
+            return false;
1068 1068
 
1069
-		}
1069
+        }
1070 1070
 
1071
-		function can_update_image($import_options) {
1071
+        function can_update_image($import_options) {
1072 1072
 
1073
-			$import_options = $import_options['options'];
1073
+            $import_options = $import_options['options'];
1074 1074
 
1075
-			if ($import_options['update_all_data'] == 'yes') return true;
1075
+            if ($import_options['update_all_data'] == 'yes') return true;
1076 1076
 
1077
-			if (!$import_options['is_update_images']) return false;			
1077
+            if (!$import_options['is_update_images']) return false;			
1078 1078
 
1079
-			if ($import_options['is_update_images']) return true;			
1079
+            if ($import_options['is_update_images']) return true;			
1080 1080
 
1081
-			return false;
1082
-		}
1081
+            return false;
1082
+        }
1083 1083
 
1084 1084
 
1085
-		function admin_notice_ignore() {
1086
-			if (isset($_GET[$this->slug.'_ignore']) && '0' == $_GET[$this->slug.'_ignore'] ) {
1087
-				update_option($this->slug.'_ignore', 'true');
1088
-			}
1089
-		}
1085
+        function admin_notice_ignore() {
1086
+            if (isset($_GET[$this->slug.'_ignore']) && '0' == $_GET[$this->slug.'_ignore'] ) {
1087
+                update_option($this->slug.'_ignore', 'true');
1088
+            }
1089
+        }
1090 1090
 
1091
-		function display_admin_notice() {
1091
+        function display_admin_notice() {
1092 1092
 
1093 1093
 
1094
-			if ($this->notice_text) {
1095
-				$notice_text = $this->notice_text;
1096
-			} else {
1097
-				$notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.';
1098
-			}
1094
+            if ($this->notice_text) {
1095
+                $notice_text = $this->notice_text;
1096
+            } else {
1097
+                $notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.';
1098
+            }
1099 1099
 
1100
-			if (!get_option(sanitize_key($this->slug).'_notice_ignore')) {
1100
+            if (!get_option(sanitize_key($this->slug).'_notice_ignore')) {
1101 1101
 
1102
-				?>
1102
+                ?>
1103 1103
 
1104 1104
 	    		<div class="error notice is-dismissible wpallimport-dismissible" style="margin-top: 10px;" rel="<?php echo sanitize_key($this->slug); ?>">
1105 1105
 	    		    <p><?php echo wp_kses_post(__(
1106
-		    		    	sprintf(
1107
-	    			    		$notice_text,
1108
-	    			    		'?'.$this->slug.'_ignore=0'
1109
-	    			    	), 
1110
-	    		    		'rapid_addon_'.$this->slug
1111
-	    		    	)); ?></p>
1106
+                            sprintf(
1107
+                                $notice_text,
1108
+                                '?'.$this->slug.'_ignore=0'
1109
+                            ), 
1110
+                            'rapid_addon_'.$this->slug
1111
+                        )); ?></p>
1112 1112
 			    </div>
1113 1113
 
1114 1114
 				<?php
1115 1115
 
1116
-			}
1116
+            }
1117 1117
 
1118
-		}
1118
+        }
1119 1119
 
1120
-		/*
1120
+        /*
1121 1121
 		*
1122 1122
 		* $conditions - array('themes' => array('Realia'), 'plugins' => array('plugin-directory/plugin-file.php', 'plugin-directory2/plugin-file.php')) 
1123 1123
 		*
1124 1124
 		*/
1125
-		function admin_notice($notice_text = '', $conditions = array()) {
1125
+        function admin_notice($notice_text = '', $conditions = array()) {
1126 1126
 
1127
-			$is_show_notice = false;
1127
+            $is_show_notice = false;
1128 1128
 
1129
-			include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1129
+            include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1130 1130
 
1131
-			if ( ! class_exists( 'PMXI_Plugin' ) ) {
1132
-				$is_show_notice = true;
1133
-			}
1131
+            if ( ! class_exists( 'PMXI_Plugin' ) ) {
1132
+                $is_show_notice = true;
1133
+            }
1134 1134
 
1135
-			// Supported Themes
1136
-			if ( ! $is_show_notice and ! empty($conditions['themes']) ){
1135
+            // Supported Themes
1136
+            if ( ! $is_show_notice and ! empty($conditions['themes']) ){
1137 1137
 
1138
-				$themeInfo    = wp_get_theme();
1139
-				$parentInfo = $themeInfo->parent();				
1140
-				$currentTheme = $themeInfo->get('Name');
1138
+                $themeInfo    = wp_get_theme();
1139
+                $parentInfo = $themeInfo->parent();				
1140
+                $currentTheme = $themeInfo->get('Name');
1141 1141
 				
1142
-				$is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true;				
1142
+                $is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true;				
1143 1143
 
1144
-				if ( $is_show_notice and $parentInfo ){
1145
-					$parent_theme = $parentInfo->get('Name');
1146
-					$is_show_notice = in_array($parent_theme, $conditions['themes']) ? false : true;					
1147
-				}
1144
+                if ( $is_show_notice and $parentInfo ){
1145
+                    $parent_theme = $parentInfo->get('Name');
1146
+                    $is_show_notice = in_array($parent_theme, $conditions['themes']) ? false : true;					
1147
+                }
1148 1148
 
1149
-			}			
1149
+            }			
1150 1150
 
1151
-			// Required Plugins
1152
-			if ( ! $is_show_notice and ! empty($conditions['plugins']) ){				
1151
+            // Required Plugins
1152
+            if ( ! $is_show_notice and ! empty($conditions['plugins']) ){				
1153 1153
 
1154
-				$requires_counter = 0;
1155
-				foreach ($conditions['plugins'] as $plugin) {
1156
-					if ( is_plugin_active($plugin) ) $requires_counter++;
1157
-				}
1154
+                $requires_counter = 0;
1155
+                foreach ($conditions['plugins'] as $plugin) {
1156
+                    if ( is_plugin_active($plugin) ) $requires_counter++;
1157
+                }
1158 1158
 
1159
-				if ($requires_counter != count($conditions['plugins'])){ 					
1160
-					$is_show_notice = true;			
1161
-				}
1159
+                if ($requires_counter != count($conditions['plugins'])){ 					
1160
+                    $is_show_notice = true;			
1161
+                }
1162 1162
 
1163
-			}
1163
+            }
1164 1164
 
1165
-			if ( $is_show_notice ){
1165
+            if ( $is_show_notice ){
1166 1166
 
1167
-				if ( $notice_text != '' ) {
1168
-					$this->notice_text = $notice_text;
1169
-				}
1167
+                if ( $notice_text != '' ) {
1168
+                    $this->notice_text = $notice_text;
1169
+                }
1170 1170
 
1171
-				add_action('admin_notices', array($this, 'display_admin_notice'));
1172
-			}
1171
+                add_action('admin_notices', array($this, 'display_admin_notice'));
1172
+            }
1173 1173
 
1174
-		}
1174
+        }
1175 1175
 
1176
-		function log( $m = false){		
1176
+        function log( $m = false){		
1177 1177
 
1178
-			$m and $this->logger and call_user_func($this->logger, $m);
1178
+            $m and $this->logger and call_user_func($this->logger, $m);
1179 1179
 
1180 1180
         }
1181 1181
         
@@ -1293,5 +1293,5 @@  discard block
 block discarded – undo
1293 1293
             }
1294 1294
             return $image;
1295 1295
         }
1296
-	}	
1296
+    }	
1297 1297
 }
1298 1298
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
     $name       = isset( $option['name'] ) ? $option['name'] : '';
193 193
     $cb         = "wpinv_{$option['type']}_callback";
194 194
     $section    = "wpinv_settings_{$tab}_$section";
195
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
195
+    $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
196 196
 
197
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
-		$tip   = wpinv_clean( $option['desc'] );
199
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
-		unset( $option['desc'] );
201
-	}
197
+    if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
+        $tip   = wpinv_clean( $option['desc'] );
199
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
+        unset( $option['desc'] );
201
+    }
202 202
 
203 203
     // Loop through all tabs.
204 204
     add_settings_field(
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
             'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
226 226
             'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
227 227
             'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
228
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
228
+            'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
+            'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
+            'style'           => isset( $option['style'] ) ? $option['style'] : '',
231 231
             'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232 232
             'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
244
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245 245
 }
246 246
 
247 247
 /**
@@ -260,18 +260,18 @@  discard block
 block discarded – undo
260 260
  */
261 261
 function wpinv_settings_sanitize( $input = array() ) {
262 262
 
263
-	$wpinv_options = wpinv_get_options();
264
-	$raw_referrer  = wp_get_raw_referer();
263
+    $wpinv_options = wpinv_get_options();
264
+    $raw_referrer  = wp_get_raw_referer();
265 265
 
266 266
     if ( empty( $raw_referrer ) ) {
267
-		return array_merge( $wpinv_options, $input );
267
+        return array_merge( $wpinv_options, $input );
268 268
     }
269 269
 
270 270
     wp_parse_str( $raw_referrer, $referrer );
271 271
 
272
-	if ( in_array( 'gp-setup', $referrer ) ) {
273
-		return array_merge( $wpinv_options, $input );
274
-	}
272
+    if ( in_array( 'gp-setup', $referrer ) ) {
273
+        return array_merge( $wpinv_options, $input );
274
+    }
275 275
 
276 276
     $settings = wpinv_get_registered_settings();
277 277
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
         }
294 294
 
295 295
         // General filter
296
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
296
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
297 297
 
298
-		// Key specific filter.
299
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
298
+        // Key specific filter.
299
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
300 300
     }
301 301
 
302 302
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 
340 340
     foreach ( $new_rates as $rate ) {
341 341
 
342
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-		$rate['name']    = sanitize_text_field( $rate['name'] );
344
-		$rate['state']   = sanitize_text_field( $rate['state'] );
345
-		$rate['country'] = sanitize_text_field( $rate['country'] );
346
-		$rate['global']  = empty( $rate['state'] );
347
-		$tax_rates[]     = $rate;
342
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
+        $rate['name']    = sanitize_text_field( $rate['name'] );
344
+        $rate['state']   = sanitize_text_field( $rate['state'] );
345
+        $rate['country'] = sanitize_text_field( $rate['country'] );
346
+        $rate['global']  = empty( $rate['state'] );
347
+        $tax_rates[]     = $rate;
348 348
 
349
-	}
349
+    }
350 350
 
351 351
     update_option( 'wpinv_tax_rates', $tax_rates );
352 352
 
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
     $tabs['general']  = __( 'General', 'invoicing' );
360 360
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
361 361
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
362
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
362
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
363 363
 
364
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
366
-	}
364
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
366
+    }
367 367
 
368 368
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
369 369
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -394,52 +394,52 @@  discard block
 block discarded – undo
394 394
         'general'      => apply_filters(
395 395
             'wpinv_settings_sections_general',
396 396
             array(
397
-				'main'             => __( 'General Settings', 'invoicing' ),
398
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
399
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
-				'labels'           => __( 'Label Texts', 'invoicing' ),
397
+                'main'             => __( 'General Settings', 'invoicing' ),
398
+                'page_section'     => __( 'Page Settings', 'invoicing' ),
399
+                'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
+                'labels'           => __( 'Label Texts', 'invoicing' ),
401 401
             )
402 402
         ),
403 403
         'gateways'     => apply_filters(
404 404
             'wpinv_settings_sections_gateways',
405 405
             array(
406
-				'main' => __( 'Gateway Settings', 'invoicing' ),
406
+                'main' => __( 'Gateway Settings', 'invoicing' ),
407 407
             )
408 408
         ),
409 409
         'taxes'        => apply_filters(
410 410
             'wpinv_settings_sections_taxes',
411 411
             array(
412
-				'main'  => __( 'Tax Settings', 'invoicing' ),
413
-				'rates' => __( 'Tax Rates', 'invoicing' ),
414
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
412
+                'main'  => __( 'Tax Settings', 'invoicing' ),
413
+                'rates' => __( 'Tax Rates', 'invoicing' ),
414
+                'vat'   => __( 'EU VAT Settings', 'invoicing' ),
415 415
             )
416 416
         ),
417 417
         'emails'       => apply_filters(
418 418
             'wpinv_settings_sections_emails',
419 419
             array(
420
-				'main' => __( 'Email Settings', 'invoicing' ),
420
+                'main' => __( 'Email Settings', 'invoicing' ),
421 421
             )
422 422
         ),
423 423
 
424
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
424
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
425 425
 
426 426
         'privacy'      => apply_filters(
427 427
             'wpinv_settings_sections_privacy',
428 428
             array(
429
-				'main' => __( 'Privacy policy', 'invoicing' ),
429
+                'main' => __( 'Privacy policy', 'invoicing' ),
430 430
             )
431 431
         ),
432 432
         'misc'         => apply_filters(
433 433
             'wpinv_settings_sections_misc',
434 434
             array(
435
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
436
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
+                'main'       => __( 'Miscellaneous', 'invoicing' ),
436
+                'custom-css' => __( 'Custom CSS', 'invoicing' ),
437 437
             )
438 438
         ),
439 439
         'tools'        => apply_filters(
440 440
             'wpinv_settings_sections_tools',
441 441
             array(
442
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
442
+                'main' => __( 'Diagnostic Tools', 'invoicing' ),
443 443
             )
444 444
         ),
445 445
     );
@@ -450,46 +450,46 @@  discard block
 block discarded – undo
450 450
 }
451 451
 
452 452
 function wpinv_get_pages( $with_slug = false, $default_label = null ) {
453
-	$pages_options = array();
453
+    $pages_options = array();
454 454
 
455
-	if ( $default_label !== null && $default_label !== false ) {
456
-		$pages_options = array( '' => $default_label ); // Blank option
457
-	}
455
+    if ( $default_label !== null && $default_label !== false ) {
456
+        $pages_options = array( '' => $default_label ); // Blank option
457
+    }
458 458
 
459
-	$pages = get_pages();
460
-	if ( $pages ) {
461
-		foreach ( $pages as $page ) {
462
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
459
+    $pages = get_pages();
460
+    if ( $pages ) {
461
+        foreach ( $pages as $page ) {
462
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
463 463
             $pages_options[ $page->ID ] = $title;
464
-		}
465
-	}
464
+        }
465
+    }
466 466
 
467
-	return $pages_options;
467
+    return $pages_options;
468 468
 }
469 469
 
470 470
 function wpinv_header_callback( $args ) {
471
-	if ( ! empty( $args['desc'] ) ) {
471
+    if ( ! empty( $args['desc'] ) ) {
472 472
         echo wp_kses_post( $args['desc'] );
473 473
     }
474 474
 }
475 475
 
476 476
 function wpinv_hidden_callback( $args ) {
477 477
 
478
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
479
-	$value   = wpinv_get_option( $args['id'], $std );
478
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
479
+    $value   = wpinv_get_option( $args['id'], $std );
480 480
 
481
-	if ( isset( $args['set_value'] ) ) {
482
-		$value = $args['set_value'];
483
-	}
481
+    if ( isset( $args['set_value'] ) ) {
482
+        $value = $args['set_value'];
483
+    }
484 484
 
485
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
-		$args['readonly'] = true;
487
-		$name  = '';
488
-	} else {
489
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
490
-	}
485
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
+        $args['readonly'] = true;
487
+        $name  = '';
488
+    } else {
489
+        $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
490
+    }
491 491
 
492
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
492
+    echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
493 493
 
494 494
 }
495 495
 
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
  */
499 499
 function wpinv_checkbox_callback( $args ) {
500 500
 
501
-	$std = isset( $args['std'] ) ? $args['std'] : '';
502
-	$std = wpinv_get_option( $args['id'], $std );
503
-	$id  = esc_attr( $args['id'] );
501
+    $std = isset( $args['std'] ) ? $args['std'] : '';
502
+    $std = wpinv_get_option( $args['id'], $std );
503
+    $id  = esc_attr( $args['id'] );
504 504
 
505
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
506
-	?>
505
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
506
+    ?>
507 507
 		<fieldset>
508 508
 			<label>
509 509
 				<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">
@@ -515,75 +515,75 @@  discard block
 block discarded – undo
515 515
 
516 516
 function wpinv_multicheck_callback( $args ) {
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
519
+    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+    if ( ! empty( $args['options'] ) ) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = wpinv_get_option( $args['id'], $std );
523
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
524
+        $value   = wpinv_get_option( $args['id'], $std );
525 525
 
526
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
526
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
527 527
         foreach ( $args['options'] as $key => $option ) :
528
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
-			if ( in_array( $sanitize_key, $value ) ) {
530
-				$enabled = $sanitize_key;
531
-			} else {
532
-				$enabled = null;
533
-			}
534
-			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 ) . '/>&nbsp;';
535
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
536
-		endforeach;
537
-		echo '</div>';
538
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
539
-	}
528
+            $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
+            if ( in_array( $sanitize_key, $value ) ) {
530
+                $enabled = $sanitize_key;
531
+            } else {
532
+                $enabled = null;
533
+            }
534
+            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 ) . '/>&nbsp;';
535
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
536
+        endforeach;
537
+        echo '</div>';
538
+        echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
539
+    }
540 540
 }
541 541
 
542 542
 function wpinv_payment_icons_callback( $args ) {
543 543
 
544 544
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
-	$value   = wpinv_get_option( $args['id'], false );
545
+    $value   = wpinv_get_option( $args['id'], false );
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach ( $args['options'] as $key => $option ) {
547
+    if ( ! empty( $args['options'] ) ) {
548
+        foreach ( $args['options'] as $key => $option ) {
549 549
             $sanitize_key = wpinv_sanitize_key( $key );
550 550
 
551
-			if ( empty( $value ) ) {
552
-				$enabled = $option;
553
-			} else {
554
-				$enabled = null;
555
-			}
556
-
557
-			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;">';
558
-
559
-				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 ) . '/>&nbsp;';
560
-
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
-				} else {
564
-				$card = strtolower( str_replace( ' ', '', $option ) );
565
-
566
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
568
-					} else {
569
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
570
-					$content_dir = WP_CONTENT_DIR;
571
-
572
-					if ( function_exists( 'wp_normalize_path' ) ) {
573
-						// Replaces backslashes with forward slashes for Windows systems
574
-						$image = wp_normalize_path( $image );
575
-						$content_dir = wp_normalize_path( $content_dir );
576
-						}
577
-
578
-					$image = str_replace( $content_dir, content_url(), $image );
579
-					}
580
-
581
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582
-				}
583
-			echo wp_kses_post( $option ) . '</label>';
584
-		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
-	}
551
+            if ( empty( $value ) ) {
552
+                $enabled = $option;
553
+            } else {
554
+                $enabled = null;
555
+            }
556
+
557
+            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;">';
558
+
559
+                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 ) . '/>&nbsp;';
560
+
561
+                if ( wpinv_string_is_image_url( $key ) ) {
562
+                echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
+                } else {
564
+                $card = strtolower( str_replace( ' ', '', $option ) );
565
+
566
+                if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
+                    $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
568
+                    } else {
569
+                    $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
570
+                    $content_dir = WP_CONTENT_DIR;
571
+
572
+                    if ( function_exists( 'wp_normalize_path' ) ) {
573
+                        // Replaces backslashes with forward slashes for Windows systems
574
+                        $image = wp_normalize_path( $image );
575
+                        $content_dir = wp_normalize_path( $content_dir );
576
+                        }
577
+
578
+                    $image = str_replace( $content_dir, content_url(), $image );
579
+                    }
580
+
581
+                echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582
+                }
583
+            echo wp_kses_post( $option ) . '</label>';
584
+        }
585
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
+    }
587 587
 }
588 588
 
589 589
 /**
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
  */
592 592
 function wpinv_radio_callback( $args ) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
596
-	?>
594
+    $std = isset( $args['std'] ) ? $args['std'] : '';
595
+    $std = wpinv_get_option( $args['id'], $std );
596
+    ?>
597 597
 		<fieldset>
598 598
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599 599
 				<?php foreach ( $args['options'] as $key => $option ) : ?>
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+    getpaid_settings_description_callback( $args );
611 611
 }
612 612
 
613 613
 /**
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
  */
616 616
 function getpaid_settings_description_callback( $args ) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
619
-		$description = $args['desc'];
620
-		echo wp_kses_post( "<p class='description'>$description</p>" );
621
-	}
618
+    if ( ! empty( $args['desc'] ) ) {
619
+        $description = $args['desc'];
620
+        echo wp_kses_post( "<p class='description'>$description</p>" );
621
+    }
622 622
 
623 623
 }
624 624
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
  */
628 628
 function wpinv_gateways_callback() {
629 629
 
630
-	?>
630
+    ?>
631 631
 		</td>
632 632
 	</tr>
633 633
 	<tr class="bsui">
@@ -641,26 +641,26 @@  discard block
 block discarded – undo
641 641
 
642 642
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
643 643
     $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
645
-	$value   = wpinv_get_option( $args['id'], $std );
644
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
645
+    $value   = wpinv_get_option( $args['id'], $std );
646 646
 
647
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
647
+    echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
649
+    foreach ( $args['options'] as $key => $option ) :
650 650
 
651
-		echo '<option value="' . esc_attr( $key ) . '" ';
651
+        echo '<option value="' . esc_attr( $key ) . '" ';
652 652
 
653
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654 654
             selected( $key, $args['selected'] );
655 655
         } else {
656 656
             selected( $key, $value );
657 657
         }
658 658
 
659
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
660
-	endforeach;
659
+        echo '>' . esc_html( $option['admin_label'] ) . '</option>';
660
+    endforeach;
661 661
 
662
-	echo '</select>';
663
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
662
+    echo '</select>';
663
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
664 664
 }
665 665
 
666 666
 /**
@@ -671,29 +671,29 @@  discard block
 block discarded – undo
671 671
  */
672 672
 function wpinv_settings_attrs_helper( $args ) {
673 673
 
674
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
675
-	$id           = esc_attr( $args['id'] );
676
-	$placeholder  = esc_attr( $args['placeholder'] );
674
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
675
+    $id           = esc_attr( $args['id'] );
676
+    $placeholder  = esc_attr( $args['placeholder'] );
677 677
 
678
-	if ( ! empty( $args['faux'] ) ) {
679
-		$args['readonly'] = true;
680
-		$name             = '';
681
-	} else {
682
-		$value  = wpinv_get_option( $args['id'], $value );
683
-		$name   = "wpinv_settings[$id]";
684
-	}
678
+    if ( ! empty( $args['faux'] ) ) {
679
+        $args['readonly'] = true;
680
+        $name             = '';
681
+    } else {
682
+        $value  = wpinv_get_option( $args['id'], $value );
683
+        $name   = "wpinv_settings[$id]";
684
+    }
685 685
 
686
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
687
-	$class    = esc_attr( $args['class'] );
688
-	$style    = esc_attr( $args['style'] );
689
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
686
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
687
+    $class    = esc_attr( $args['class'] );
688
+    $style    = esc_attr( $args['style'] );
689
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
690 690
 
691
-	$onchange = '';
691
+    $onchange = '';
692 692
     if ( ! empty( $args['onchange'] ) ) {
693 693
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
694
-	}
694
+    }
695 695
 
696
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
696
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
697 697
 }
698 698
 
699 699
 /**
@@ -701,9 +701,9 @@  discard block
 block discarded – undo
701 701
  */
702 702
 function wpinv_text_callback( $args ) {
703 703
 
704
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
705 705
 
706
-	?>
706
+    ?>
707 707
 		<label style="width: 100%;">
708 708
 			<input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>>
709 709
 			<?php echo wp_kses_post( $desc ); ?>
@@ -717,10 +717,10 @@  discard block
 block discarded – undo
717 717
  */
718 718
 function wpinv_number_callback( $args ) {
719 719
 
720
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
721
-	$attr = wpinv_settings_attrs_helper( $args );
720
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
721
+    $attr = wpinv_settings_attrs_helper( $args );
722 722
 
723
-	?>
723
+    ?>
724 724
 		<label style="width: 100%;">
725 725
 			<input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>>
726 726
 			<?php echo wp_kses_post( $desc ); ?>
@@ -732,34 +732,34 @@  discard block
 block discarded – undo
732 732
 function wpinv_textarea_callback( $args ) {
733 733
 
734 734
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
735
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
736
-	$value   = wpinv_get_option( $args['id'], $std );
735
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
736
+    $value   = wpinv_get_option( $args['id'], $std );
737 737
 
738 738
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
739 739
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
740 740
 
741
-	echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
742
-	echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
741
+    echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
742
+    echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
743 743
 
744 744
 }
745 745
 
746 746
 function wpinv_password_callback( $args ) {
747 747
 
748 748
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
749
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
750
-	$value   = wpinv_get_option( $args['id'], $std );
749
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
750
+    $value   = wpinv_get_option( $args['id'], $std );
751 751
 
752
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
753
-	echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
754
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
752
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
753
+    echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
754
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
755 755
 
756 756
 }
757 757
 
758 758
 function wpinv_missing_callback( $args ) {
759
-	printf(
760
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
761
-		'<strong>' . $args['id'] . '</strong>'
762
-	);
759
+    printf(
760
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
761
+        '<strong>' . $args['id'] . '</strong>'
762
+    );
763 763
 }
764 764
 
765 765
 /**
@@ -767,14 +767,14 @@  discard block
 block discarded – undo
767 767
  */
768 768
 function wpinv_select_callback( $args ) {
769 769
 
770
-	$desc   = wp_kses_post( $args['desc'] );
771
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
772
-	$attr   = wpinv_settings_attrs_helper( $args );
773
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
774
-	$value  = wpinv_get_option( $args['id'], $value );
775
-	$rand   = uniqid( 'random_id' );
770
+    $desc   = wp_kses_post( $args['desc'] );
771
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
772
+    $attr   = wpinv_settings_attrs_helper( $args );
773
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
774
+    $value  = wpinv_get_option( $args['id'], $value );
775
+    $rand   = uniqid( 'random_id' );
776 776
 
777
-	?>
777
+    ?>
778 778
 		<label style="width: 100%;">
779 779
 			<select <?php echo $attr; ?> data-allow-clear="true">
780 780
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -807,50 +807,50 @@  discard block
 block discarded – undo
807 807
 function wpinv_color_select_callback( $args ) {
808 808
 
809 809
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
810
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
811
-	$value   = wpinv_get_option( $args['id'], $std );
810
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
811
+    $value   = wpinv_get_option( $args['id'], $std );
812 812
 
813
-	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
813
+    echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
814 814
 
815
-	foreach ( $args['options'] as $option => $color ) {
816
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
817
-	}
815
+    foreach ( $args['options'] as $option => $color ) {
816
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
817
+    }
818 818
 
819
-	echo '</select>';
820
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
819
+    echo '</select>';
820
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
821 821
 
822 822
 }
823 823
 
824 824
 function wpinv_rich_editor_callback( $args ) {
825
-	global $wp_version;
825
+    global $wp_version;
826 826
 
827 827
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
828 828
 
829
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
830
-	$value   = wpinv_get_option( $args['id'], $std );
829
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
830
+    $value   = wpinv_get_option( $args['id'], $std );
831 831
 
832
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
833
-		$value = $std;
834
-	}
832
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
833
+        $value = $std;
834
+    }
835 835
 
836
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
836
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
837 837
 
838
-	echo '<div class="getpaid-settings-editor-input">';
839
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
840
-		wp_editor(
838
+    echo '<div class="getpaid-settings-editor-input">';
839
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
840
+        wp_editor(
841 841
             stripslashes( $value ),
842 842
             'wpinv_settings_' . esc_attr( $args['id'] ),
843 843
             array(
844
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
845
-				'textarea_rows' => absint( $rows ),
846
-				'media_buttons' => false,
844
+                'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
845
+                'textarea_rows' => absint( $rows ),
846
+                'media_buttons' => false,
847 847
             )
848 848
         );
849
-	} else {
850
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
851
-	}
849
+    } else {
850
+        echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
851
+    }
852 852
 
853
-	echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
853
+    echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
854 854
 
855 855
 }
856 856
 
@@ -858,51 +858,51 @@  discard block
 block discarded – undo
858 858
 
859 859
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
860 860
 
861
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
862
-	$value   = wpinv_get_option( $args['id'], $std );
861
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
862
+    $value   = wpinv_get_option( $args['id'], $std );
863 863
 
864
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
865
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
866
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
867
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
864
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
865
+    echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
866
+    echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
867
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
868 868
 
869 869
 }
870 870
 
871 871
 function wpinv_color_callback( $args ) {
872 872
 
873
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
874
-	$value       = wpinv_get_option( $args['id'], $std );
873
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
874
+    $value       = wpinv_get_option( $args['id'], $std );
875 875
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
876 876
 
877
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
878
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
877
+    echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
878
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
879 879
 
880 880
 }
881 881
 
882 882
 function wpinv_country_states_callback( $args ) {
883 883
 
884
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
885
-	$value   = wpinv_get_option( $args['id'], $std );
884
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
885
+    $value   = wpinv_get_option( $args['id'], $std );
886 886
 
887 887
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
888 888
 
889
-	if ( isset( $args['placeholder'] ) ) {
890
-		$placeholder = $args['placeholder'];
891
-	} else {
892
-		$placeholder = '';
893
-	}
889
+    if ( isset( $args['placeholder'] ) ) {
890
+        $placeholder = $args['placeholder'];
891
+    } else {
892
+        $placeholder = '';
893
+    }
894 894
 
895
-	$states = wpinv_get_country_states();
895
+    $states = wpinv_get_country_states();
896 896
 
897
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
898
-	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
897
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
898
+    echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
899 899
 
900
-	foreach ( $states as $option => $name ) {
901
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
902
-	}
900
+    foreach ( $states as $option => $name ) {
901
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
902
+    }
903 903
 
904
-	echo '</select>';
905
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
904
+    echo '</select>';
905
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
906 906
 
907 907
 }
908 908
 
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
  */
912 912
 function wpinv_tax_rates_callback() {
913 913
 
914
-	?>
914
+    ?>
915 915
 		</td>
916 916
 	</tr>
917 917
 	<tr class="bsui">
@@ -926,17 +926,17 @@  discard block
 block discarded – undo
926 926
  * Displays a tax rate' edit row.
927 927
  */
928 928
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
929
-	ob_start();
929
+    ob_start();
930 930
 
931
-	$key                      = sanitize_key( $key );
932
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
933
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
931
+    $key                      = sanitize_key( $key );
932
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
933
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
934 934
 
935
-	if ( $echo ) {
936
-		echo ob_get_clean();
937
-	} else {
938
-		return ob_get_clean();
939
-	}
935
+    if ( $echo ) {
936
+        echo ob_get_clean();
937
+    } else {
938
+        return ob_get_clean();
939
+    }
940 940
 
941 941
 }
942 942
 
@@ -968,14 +968,14 @@  discard block
 block discarded – undo
968 968
                 <td>
969 969
 					<a href="
970 970
                     <?php
971
-						echo esc_url(
972
-							wp_nonce_url(
973
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
974
-								'getpaid-nonce',
975
-								'getpaid-nonce'
976
-							)
977
-						);
978
-					?>
971
+                        echo esc_url(
972
+                            wp_nonce_url(
973
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
974
+                                'getpaid-nonce',
975
+                                'getpaid-nonce'
976
+                            )
977
+                        );
978
+                    ?>
979 979
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
980 980
                 </td>
981 981
             </tr>
@@ -987,14 +987,14 @@  discard block
 block discarded – undo
987 987
                 <td>
988 988
 					<a href="
989 989
                     <?php
990
-						echo esc_url(
991
-							wp_nonce_url(
992
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
993
-								'getpaid-nonce',
994
-								'getpaid-nonce'
995
-							)
996
-						);
997
-					?>
990
+                        echo esc_url(
991
+                            wp_nonce_url(
992
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
993
+                                'getpaid-nonce',
994
+                                'getpaid-nonce'
995
+                            )
996
+                        );
997
+                    ?>
998 998
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
999 999
                 </td>
1000 1000
             </tr>
@@ -1006,14 +1006,14 @@  discard block
 block discarded – undo
1006 1006
                 <td>
1007 1007
 					<a href="
1008 1008
                     <?php
1009
-						echo esc_url(
1010
-							wp_nonce_url(
1011
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1012
-								'getpaid-nonce',
1013
-								'getpaid-nonce'
1014
-							)
1015
-						);
1016
-					?>
1009
+                        echo esc_url(
1010
+                            wp_nonce_url(
1011
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1012
+                                'getpaid-nonce',
1013
+                                'getpaid-nonce'
1014
+                            )
1015
+                        );
1016
+                    ?>
1017 1017
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1018 1018
                 </td>
1019 1019
             </tr>
@@ -1026,14 +1026,14 @@  discard block
 block discarded – undo
1026 1026
                 <td>
1027 1027
 					<a href="
1028 1028
                     <?php
1029
-						echo esc_url(
1030
-							wp_nonce_url(
1031
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1032
-								'getpaid-nonce',
1033
-								'getpaid-nonce'
1034
-							)
1035
-						);
1036
-					?>
1029
+                        echo esc_url(
1030
+                            wp_nonce_url(
1031
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1032
+                                'getpaid-nonce',
1033
+                                'getpaid-nonce'
1034
+                            )
1035
+                        );
1036
+                    ?>
1037 1037
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1038 1038
                 </td>
1039 1039
             </tr>
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
                 <td>
1047 1047
 					<a href="
1048 1048
                     <?php
1049
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1050
-					?>
1049
+                        echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1050
+                    ?>
1051 1051
                     " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1052 1052
                 </td>
1053 1053
             </tr>
@@ -1061,19 +1061,19 @@  discard block
 block discarded – undo
1061 1061
 
1062 1062
 
1063 1063
 function wpinv_descriptive_text_callback( $args ) {
1064
-	echo wp_kses_post( $args['desc'] );
1064
+    echo wp_kses_post( $args['desc'] );
1065 1065
 }
1066 1066
 
1067 1067
 function wpinv_raw_html_callback( $args ) {
1068
-	echo wp_kses_post( $args['desc'] );
1068
+    echo wp_kses_post( $args['desc'] );
1069 1069
 }
1070 1070
 
1071 1071
 function wpinv_hook_callback( $args ) {
1072
-	do_action( 'wpinv_' . $args['id'], $args );
1072
+    do_action( 'wpinv_' . $args['id'], $args );
1073 1073
 }
1074 1074
 
1075 1075
 function wpinv_set_settings_cap() {
1076
-	return wpinv_get_capability();
1076
+    return wpinv_get_capability();
1077 1077
 }
1078 1078
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1079 1079
 
@@ -1097,15 +1097,15 @@  discard block
 block discarded – undo
1097 1097
  */
1098 1098
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1099 1099
 
1100
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1101
-	$link = sprintf(
1102
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1103
-		$url,
1104
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1105
-	);
1100
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1101
+    $link = sprintf(
1102
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1103
+        $url,
1104
+        esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1105
+    );
1106 1106
 
1107
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1107
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1108 1108
 
1109
-	return "$description $link";
1109
+    return "$description $link";
1110 1110
 
1111 1111
 }
Please login to merge, or discard this patch.