Passed
Push — master ( 330418...c4952f )
by Brian
05:45 queued 27s
created
vendor/composer/InstalledVersions.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -312,9 +312,9 @@
 block discarded – undo
312 312
             foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
313 313
                 if (isset(self::$installedByVendor[$vendorDir])) {
314 314
                     $installed[] = self::$installedByVendor[$vendorDir];
315
-                } elseif (is_file($vendorDir.'/composer/installed.php')) {
316
-                    $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
317
-                    if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
315
+                } elseif (is_file($vendorDir . '/composer/installed.php')) {
316
+                    $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir . '/composer/installed.php';
317
+                    if (null === self::$installed && strtr($vendorDir . '/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
318 318
                         self::$installed = $installed[count($installed) - 1];
319 319
                     }
320 320
                 }
Please login to merge, or discard this patch.
vendor/composer/platform_check.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@
 block discarded – undo
14 14
     }
15 15
     if (!ini_get('display_errors')) {
16 16
         if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
17
-            fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
17
+            fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL . PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL . PHP_EOL);
18 18
         } elseif (!headers_sent()) {
19
-            echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
19
+            echo 'Composer detected issues in your platform:' . PHP_EOL . PHP_EOL . str_replace('You are running ' . PHP_VERSION . '.', '', implode(PHP_EOL, $issues)) . PHP_EOL . PHP_EOL;
20 20
         }
21 21
     }
22 22
     trigger_error(
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/wp-deactivation-survey.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,103 +1,103 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
8 8
 
9
-	class AyeCode_Deactivation_Survey {
9
+    class AyeCode_Deactivation_Survey {
10 10
 
11
-		/**
12
-		 * AyeCode_Deactivation_Survey instance.
13
-		 *
14
-		 * @access private
15
-		 * @since  1.0.0
16
-		 * @var    AyeCode_Deactivation_Survey There can be only one!
17
-		 */
18
-		private static $instance = null;
11
+        /**
12
+         * AyeCode_Deactivation_Survey instance.
13
+         *
14
+         * @access private
15
+         * @since  1.0.0
16
+         * @var    AyeCode_Deactivation_Survey There can be only one!
17
+         */
18
+        private static $instance = null;
19 19
 
20
-		public static $plugins;
20
+        public static $plugins;
21 21
 
22
-		public $version = "1.0.4";
22
+        public $version = "1.0.4";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
-				self::$instance = new AyeCode_Deactivation_Survey;
27
-				self::$plugins = array();
24
+        public static function instance( $plugin = array() ) {
25
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
+                self::$instance = new AyeCode_Deactivation_Survey;
27
+                self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+                add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
32
-			}
31
+                do_action( 'ayecode_deactivation_survey_loaded' );
32
+            }
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
36
-			}
34
+            if(!empty($plugin)){
35
+                self::$plugins[] = (object)$plugin;
36
+            }
37 37
 
38
-			return self::$instance;
39
-		}
38
+            return self::$instance;
39
+        }
40 40
 
41
-		public function scripts() {
42
-			global $pagenow;
41
+        public function scripts() {
42
+            global $pagenow;
43 43
 
44
-			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
46
-				return;
47
-			}
44
+            // Bail if we are not on the plugins page
45
+            if ( $pagenow != "plugins.php" ) {
46
+                return;
47
+            }
48 48
 
49
-			// Enqueue scripts
50
-			add_thickbox();
51
-			wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
49
+            // Enqueue scripts
50
+            add_thickbox();
51
+            wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
52 52
 
53
-			/*
53
+            /*
54 54
 			 * Localized strings. Strings can be localised by plugins using this class.
55 55
 			 * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review.
56 56
 			 */
57
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
-				'quick_feedback'			=> 'Quick Feedback',
59
-				'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
-				'better_plugins_name'		=> 'Please tell us which plugin?',
61
-				'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
-				'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
-				'brief_description'			=> 'Please give us any feedback that could help us improve',
64
-				'cancel'					=> 'Cancel',
65
-				'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
-				'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
-				'please_wait'				=> 'Please wait',
68
-				'get_support'				=> 'Get Support',
69
-				'documentation'				=> 'Documentation',
70
-				'thank_you'					=> 'Thank you!',
71
-			));
72
-
73
-			// Plugins
74
-			$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
-
76
-			// Reasons
77
-			$defaultReasons = array(
78
-				'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
-				'plugin-broke-site'			=> 'The plugin broke my site',
80
-				'plugin-setup-difficult'	=> 'Too difficult to setup',
81
-				'plugin-design-difficult'	=> 'Too difficult to get the design i want',
82
-				'no-longer-needed'			=> 'I don\'t need this plugin any more',
83
-				'found-better-plugin'		=> 'I found a better plugin',
84
-				'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
85
-				'other'						=> 'Other',
86
-			);
87
-
88
-			foreach($plugins as $plugin)
89
-			{
90
-				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91
-				$plugin->url = home_url();
92
-				$plugin->activated = 0;
93
-			}
94
-
95
-			// Send plugin data
96
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
97
-
98
-		}
57
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
+                'quick_feedback'			=> 'Quick Feedback',
59
+                'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
+                'better_plugins_name'		=> 'Please tell us which plugin?',
61
+                'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
+                'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
+                'brief_description'			=> 'Please give us any feedback that could help us improve',
64
+                'cancel'					=> 'Cancel',
65
+                'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
+                'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
+                'please_wait'				=> 'Please wait',
68
+                'get_support'				=> 'Get Support',
69
+                'documentation'				=> 'Documentation',
70
+                'thank_you'					=> 'Thank you!',
71
+            ));
72
+
73
+            // Plugins
74
+            $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
+
76
+            // Reasons
77
+            $defaultReasons = array(
78
+                'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
+                'plugin-broke-site'			=> 'The plugin broke my site',
80
+                'plugin-setup-difficult'	=> 'Too difficult to setup',
81
+                'plugin-design-difficult'	=> 'Too difficult to get the design i want',
82
+                'no-longer-needed'			=> 'I don\'t need this plugin any more',
83
+                'found-better-plugin'		=> 'I found a better plugin',
84
+                'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
85
+                'other'						=> 'Other',
86
+            );
87
+
88
+            foreach($plugins as $plugin)
89
+            {
90
+                $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91
+                $plugin->url = home_url();
92
+                $plugin->activated = 0;
93
+            }
94
+
95
+            // Send plugin data
96
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
97
+
98
+        }
99 99
 		
100 100
 
101
-	}
101
+    }
102 102
 
103 103
 }
104 104
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
7
+if (!class_exists('AyeCode_Deactivation_Survey')) {
8 8
 
9 9
 	class AyeCode_Deactivation_Survey {
10 10
 
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
 
22 22
 		public $version = "1.0.4";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
24
+		public static function instance($plugin = array()) {
25
+			if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_Deactivation_Survey)) {
26 26
 				self::$instance = new AyeCode_Deactivation_Survey;
27 27
 				self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+				add_action('admin_enqueue_scripts', array(self::$instance, 'scripts'));
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
31
+				do_action('ayecode_deactivation_survey_loaded');
32 32
 			}
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
34
+			if (!empty($plugin)) {
35
+				self::$plugins[] = (object) $plugin;
36 36
 			}
37 37
 
38 38
 			return self::$instance;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			global $pagenow;
43 43
 
44 44
 			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
45
+			if ($pagenow != "plugins.php") {
46 46
 				return;
47 47
 			}
48 48
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				'other'						=> 'Other',
86 86
 			);
87 87
 
88
-			foreach($plugins as $plugin)
88
+			foreach ($plugins as $plugin)
89 89
 			{
90 90
 				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91 91
 				$plugin->url = home_url();
Please login to merge, or discard this patch.
includes/payments/class-getpaid-form-item.php 2 patches
Indentation   +359 added lines, -359 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,67 +10,67 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Form_Item  extends WPInv_Item {
11 11
 
12 12
     /**
13
-	 * Stores a custom description for the item.
14
-	 *
15
-	 * @var string
16
-	 */
17
-	protected $custom_description = null;
18
-
19
-	/**
20
-	 * Stores the item quantity.
21
-	 *
22
-	 * @var float
23
-	 */
24
-	protected $quantity = 1;
25
-
26
-	/**
27
-	 * Stores the item meta.
28
-	 *
29
-	 * @var array
30
-	 */
31
-	protected $meta = array();
32
-
33
-	/**
34
-	 * Is this item required?
35
-	 *
36
-	 * @var int
37
-	 */
38
-	protected $is_required = true;
39
-
40
-	/**
41
-	 * Are quantities allowed?
42
-	 *
43
-	 * @var int
44
-	 */
45
-	protected $allow_quantities = false;
46
-
47
-	/**
48
-	 * Associated invoice.
49
-	 *
50
-	 * @var int
51
-	 */
52
-	public $invoice_id = 0;
53
-
54
-	/**
55
-	 * Item discount.
56
-	 *
57
-	 * @var float
58
-	 */
59
-	public $item_discount = 0;
60
-
61
-	/**
62
-	 * Recurring item discount.
63
-	 *
64
-	 * @var float
65
-	 */
66
-	public $recurring_item_discount = 0;
67
-
68
-	/**
69
-	 * Item tax.
70
-	 *
71
-	 * @var float
72
-	 */
73
-	public $item_tax = 0;
13
+     * Stores a custom description for the item.
14
+     *
15
+     * @var string
16
+     */
17
+    protected $custom_description = null;
18
+
19
+    /**
20
+     * Stores the item quantity.
21
+     *
22
+     * @var float
23
+     */
24
+    protected $quantity = 1;
25
+
26
+    /**
27
+     * Stores the item meta.
28
+     *
29
+     * @var array
30
+     */
31
+    protected $meta = array();
32
+
33
+    /**
34
+     * Is this item required?
35
+     *
36
+     * @var int
37
+     */
38
+    protected $is_required = true;
39
+
40
+    /**
41
+     * Are quantities allowed?
42
+     *
43
+     * @var int
44
+     */
45
+    protected $allow_quantities = false;
46
+
47
+    /**
48
+     * Associated invoice.
49
+     *
50
+     * @var int
51
+     */
52
+    public $invoice_id = 0;
53
+
54
+    /**
55
+     * Item discount.
56
+     *
57
+     * @var float
58
+     */
59
+    public $item_discount = 0;
60
+
61
+    /**
62
+     * Recurring item discount.
63
+     *
64
+     * @var float
65
+     */
66
+    public $recurring_item_discount = 0;
67
+
68
+    /**
69
+     * Item tax.
70
+     *
71
+     * @var float
72
+     */
73
+    public $item_tax = 0;
74 74
 
75 75
     /*
76 76
 	|--------------------------------------------------------------------------
@@ -88,230 +88,230 @@  discard block
 block discarded – undo
88 88
     */
89 89
 
90 90
     /**
91
-	 * Get the item name.
92
-	 *
93
-	 * @since 1.0.19
94
-	 * @param  string $context View or edit context.
95
-	 * @return string
96
-	 */
97
-	public function get_name( $context = 'view' ) {
98
-		$name = parent::get_name( $context );
99
-		return $name . wpinv_get_item_suffix( $this );
100
-	}
101
-
102
-	/**
103
-	 * Get the item name without a suffix.
104
-	 *
105
-	 * @since 1.0.19
106
-	 * @param  string $context View or edit context.
107
-	 * @return string
108
-	 */
109
-	public function get_raw_name( $context = 'view' ) {
110
-		return parent::get_name( $context );
111
-	}
112
-
113
-	/**
114
-	 * Get the item description.
115
-	 *
116
-	 * @since 1.0.19
117
-	 * @param  string $context View or edit context.
118
-	 * @return string
119
-	 */
120
-	public function get_description( $context = 'view' ) {
121
-
122
-		if ( isset( $this->custom_description ) ) {
123
-			return $this->custom_description;
124
-		}
125
-
126
-		return parent::get_description( $context );
127
-	}
128
-
129
-	/**
130
-	 * Returns the sub total.
131
-	 *
132
-	 * @since 1.0.19
133
-	 * @param  string $context View or edit context.
134
-	 * @return float
135
-	 */
136
-	public function get_sub_total( $context = 'view' ) {
137
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context );
138
-	}
139
-
140
-	/**
141
-	 * Returns the recurring sub total.
142
-	 *
143
-	 * @since 1.0.19
144
-	 * @param  string $context View or edit context.
145
-	 * @return float
146
-	 */
147
-	public function get_recurring_sub_total( $context = 'view' ) {
148
-
149
-		if ( $this->is_recurring() ) {
150
-			return $this->get_quantity( $context ) * $this->get_price( $context );
151
-		}
152
-
153
-		return 0;
154
-	}
155
-
156
-	/**
157
-	 * @deprecated
158
-	 */
159
-	public function get_qantity( $context = 'view' ) {
160
-		return $this->get_quantity( $context );
161
-	}
162
-
163
-	/**
164
-	 * Get the item quantity.
165
-	 *
166
-	 * @since 1.0.19
167
-	 * @param  string $context View or edit context.
168
-	 * @return float
169
-	 */
170
-	public function get_quantity( $context = 'view' ) {
171
-		$quantity = (float) $this->quantity;
172
-
173
-		if ( 'view' == $context ) {
174
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
175
-		}
176
-
177
-		return $quantity;
178
-
179
-	}
180
-
181
-	/**
182
-	 * Get the item meta data.
183
-	 *
184
-	 * @since 1.0.19
185
-	 * @param  string $context View or edit context.
186
-	 * @return meta
187
-	 */
188
-	public function get_item_meta( $context = 'view' ) {
189
-		$meta = $this->meta;
190
-
191
-		if ( 'view' == $context ) {
192
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
193
-		}
194
-
195
-		return $meta;
196
-
197
-	}
198
-
199
-	/**
200
-	 * Returns whether or not customers can update the item quantity.
201
-	 *
202
-	 * @since 1.0.19
203
-	 * @param  string $context View or edit context.
204
-	 * @return bool
205
-	 */
206
-	public function get_allow_quantities( $context = 'view' ) {
207
-		$allow_quantities = (bool) $this->allow_quantities;
208
-
209
-		if ( 'view' == $context ) {
210
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
211
-		}
212
-
213
-		return $allow_quantities;
214
-
215
-	}
216
-
217
-	/**
218
-	 * Returns whether or not the item is required.
219
-	 *
220
-	 * @since 1.0.19
221
-	 * @param  string $context View or edit context.
222
-	 * @return bool
223
-	 */
224
-	public function get_is_required( $context = 'view' ) {
225
-		$is_required = (bool) $this->is_required;
226
-
227
-		if ( 'view' == $context ) {
228
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
229
-		}
230
-
231
-		return $is_required;
232
-
233
-	}
234
-
235
-	/**
236
-	 * Prepares form data for use.
237
-	 *
238
-	 * @since 1.0.19
239
-	 * @return array
240
-	 */
241
-	public function prepare_data_for_use( $required = null ) {
242
-
243
-		$required = is_null( $required ) ? $this->is_required() : $required;
244
-		return array(
245
-			'title'            => strip_tags( $this->get_name() ),
246
-			'id'               => $this->get_id(),
247
-			'price'            => $this->get_price(),
248
-			'recurring'        => $this->is_recurring(),
249
-			'description'      => $this->get_description(),
250
-			'allow_quantities' => $this->allows_quantities(),
251
-			'required'         => $required,
252
-		);
253
-
254
-	}
255
-
256
-	/**
257
-	 * Prepares form data for ajax use.
258
-	 *
259
-	 * @since 1.0.19
260
-	 * @return array
261
-	 */
262
-	public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
263
-
264
-		$description = getpaid_item_recurring_price_help_text( $this, $currency );
265
-
266
-		if ( $description ) {
267
-			$description = "<div class='getpaid-subscription-help-text'>$description</div>";
268
-		}
269
-
270
-		$price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
271
-		$subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
272
-		return array(
273
-			'id'     => $this->get_id(),
274
-			'texts'  => array(
275
-				'item-name'        => sanitize_text_field( $this->get_name() ),
276
-				'item-description' => wp_kses_post( $this->get_description() ) . $description,
277
-				'item-quantity'    => floatval( $this->get_quantity() ),
278
-				'item-price'       => wpinv_price( $price, $currency ),
279
-				'item-total'       => wpinv_price( $subtotal, $currency ),
280
-			),
281
-			'inputs' => array(
282
-				'item-id'          => $this->get_id(),
283
-				'item-name'        => sanitize_text_field( $this->get_name() ),
284
-				'item-description' => wp_kses_post( $this->get_description() ),
285
-				'item-quantity'    => floatval( $this->get_quantity() ),
286
-				'item-price'       => $price,
287
-			)
288
-		);
289
-
290
-	}
291
-
292
-	/**
293
-	 * Prepares form data for saving (cart_details).
294
-	 *
295
-	 * @since 1.0.19
296
-	 * @return array
297
-	 */
298
-	public function prepare_data_for_saving() {
299
-
300
-		return array(
301
-			'post_id'           => $this->invoice_id,
302
-			'item_id'           => $this->get_id(),
303
-			'item_name'         => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
304
-			'item_description'  => $this->get_description( 'edit' ),
305
-			'tax'               => $this->item_tax,
306
-			'item_price'        => $this->get_price( 'edit' ),
307
-			'quantity'          => (float) $this->get_quantity( 'edit' ),
308
-			'discount'          => $this->item_discount,
309
-			'subtotal'          => $this->get_sub_total( 'edit' ),
310
-			'price'             => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
311
-			'meta'              => $this->get_item_meta( 'edit' ),
312
-		);
313
-
314
-	}
91
+     * Get the item name.
92
+     *
93
+     * @since 1.0.19
94
+     * @param  string $context View or edit context.
95
+     * @return string
96
+     */
97
+    public function get_name( $context = 'view' ) {
98
+        $name = parent::get_name( $context );
99
+        return $name . wpinv_get_item_suffix( $this );
100
+    }
101
+
102
+    /**
103
+     * Get the item name without a suffix.
104
+     *
105
+     * @since 1.0.19
106
+     * @param  string $context View or edit context.
107
+     * @return string
108
+     */
109
+    public function get_raw_name( $context = 'view' ) {
110
+        return parent::get_name( $context );
111
+    }
112
+
113
+    /**
114
+     * Get the item description.
115
+     *
116
+     * @since 1.0.19
117
+     * @param  string $context View or edit context.
118
+     * @return string
119
+     */
120
+    public function get_description( $context = 'view' ) {
121
+
122
+        if ( isset( $this->custom_description ) ) {
123
+            return $this->custom_description;
124
+        }
125
+
126
+        return parent::get_description( $context );
127
+    }
128
+
129
+    /**
130
+     * Returns the sub total.
131
+     *
132
+     * @since 1.0.19
133
+     * @param  string $context View or edit context.
134
+     * @return float
135
+     */
136
+    public function get_sub_total( $context = 'view' ) {
137
+        return $this->get_quantity( $context ) * $this->get_initial_price( $context );
138
+    }
139
+
140
+    /**
141
+     * Returns the recurring sub total.
142
+     *
143
+     * @since 1.0.19
144
+     * @param  string $context View or edit context.
145
+     * @return float
146
+     */
147
+    public function get_recurring_sub_total( $context = 'view' ) {
148
+
149
+        if ( $this->is_recurring() ) {
150
+            return $this->get_quantity( $context ) * $this->get_price( $context );
151
+        }
152
+
153
+        return 0;
154
+    }
155
+
156
+    /**
157
+     * @deprecated
158
+     */
159
+    public function get_qantity( $context = 'view' ) {
160
+        return $this->get_quantity( $context );
161
+    }
162
+
163
+    /**
164
+     * Get the item quantity.
165
+     *
166
+     * @since 1.0.19
167
+     * @param  string $context View or edit context.
168
+     * @return float
169
+     */
170
+    public function get_quantity( $context = 'view' ) {
171
+        $quantity = (float) $this->quantity;
172
+
173
+        if ( 'view' == $context ) {
174
+            return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
175
+        }
176
+
177
+        return $quantity;
178
+
179
+    }
180
+
181
+    /**
182
+     * Get the item meta data.
183
+     *
184
+     * @since 1.0.19
185
+     * @param  string $context View or edit context.
186
+     * @return meta
187
+     */
188
+    public function get_item_meta( $context = 'view' ) {
189
+        $meta = $this->meta;
190
+
191
+        if ( 'view' == $context ) {
192
+            return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
193
+        }
194
+
195
+        return $meta;
196
+
197
+    }
198
+
199
+    /**
200
+     * Returns whether or not customers can update the item quantity.
201
+     *
202
+     * @since 1.0.19
203
+     * @param  string $context View or edit context.
204
+     * @return bool
205
+     */
206
+    public function get_allow_quantities( $context = 'view' ) {
207
+        $allow_quantities = (bool) $this->allow_quantities;
208
+
209
+        if ( 'view' == $context ) {
210
+            return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
211
+        }
212
+
213
+        return $allow_quantities;
214
+
215
+    }
216
+
217
+    /**
218
+     * Returns whether or not the item is required.
219
+     *
220
+     * @since 1.0.19
221
+     * @param  string $context View or edit context.
222
+     * @return bool
223
+     */
224
+    public function get_is_required( $context = 'view' ) {
225
+        $is_required = (bool) $this->is_required;
226
+
227
+        if ( 'view' == $context ) {
228
+            return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
229
+        }
230
+
231
+        return $is_required;
232
+
233
+    }
234
+
235
+    /**
236
+     * Prepares form data for use.
237
+     *
238
+     * @since 1.0.19
239
+     * @return array
240
+     */
241
+    public function prepare_data_for_use( $required = null ) {
242
+
243
+        $required = is_null( $required ) ? $this->is_required() : $required;
244
+        return array(
245
+            'title'            => strip_tags( $this->get_name() ),
246
+            'id'               => $this->get_id(),
247
+            'price'            => $this->get_price(),
248
+            'recurring'        => $this->is_recurring(),
249
+            'description'      => $this->get_description(),
250
+            'allow_quantities' => $this->allows_quantities(),
251
+            'required'         => $required,
252
+        );
253
+
254
+    }
255
+
256
+    /**
257
+     * Prepares form data for ajax use.
258
+     *
259
+     * @since 1.0.19
260
+     * @return array
261
+     */
262
+    public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
263
+
264
+        $description = getpaid_item_recurring_price_help_text( $this, $currency );
265
+
266
+        if ( $description ) {
267
+            $description = "<div class='getpaid-subscription-help-text'>$description</div>";
268
+        }
269
+
270
+        $price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
271
+        $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
272
+        return array(
273
+            'id'     => $this->get_id(),
274
+            'texts'  => array(
275
+                'item-name'        => sanitize_text_field( $this->get_name() ),
276
+                'item-description' => wp_kses_post( $this->get_description() ) . $description,
277
+                'item-quantity'    => floatval( $this->get_quantity() ),
278
+                'item-price'       => wpinv_price( $price, $currency ),
279
+                'item-total'       => wpinv_price( $subtotal, $currency ),
280
+            ),
281
+            'inputs' => array(
282
+                'item-id'          => $this->get_id(),
283
+                'item-name'        => sanitize_text_field( $this->get_name() ),
284
+                'item-description' => wp_kses_post( $this->get_description() ),
285
+                'item-quantity'    => floatval( $this->get_quantity() ),
286
+                'item-price'       => $price,
287
+            )
288
+        );
289
+
290
+    }
291
+
292
+    /**
293
+     * Prepares form data for saving (cart_details).
294
+     *
295
+     * @since 1.0.19
296
+     * @return array
297
+     */
298
+    public function prepare_data_for_saving() {
299
+
300
+        return array(
301
+            'post_id'           => $this->invoice_id,
302
+            'item_id'           => $this->get_id(),
303
+            'item_name'         => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
304
+            'item_description'  => $this->get_description( 'edit' ),
305
+            'tax'               => $this->item_tax,
306
+            'item_price'        => $this->get_price( 'edit' ),
307
+            'quantity'          => (float) $this->get_quantity( 'edit' ),
308
+            'discount'          => $this->item_discount,
309
+            'subtotal'          => $this->get_sub_total( 'edit' ),
310
+            'price'             => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
311
+            'meta'              => $this->get_item_meta( 'edit' ),
312
+        );
313
+
314
+    }
315 315
 
316 316
     /*
317 317
 	|--------------------------------------------------------------------------
@@ -323,70 +323,70 @@  discard block
 block discarded – undo
323 323
 	| object.
324 324
     */
325 325
 
326
-	/**
327
-	 * Set the item qantity.
328
-	 *
329
-	 * @since 1.0.19
330
-	 * @param  float $quantity The item quantity.
331
-	 */
332
-	public function set_quantity( $quantity ) {
333
-
334
-		if ( ! is_numeric( $quantity ) ) {
335
-			$quantity = 1;
336
-		}
337
-
338
-		$this->quantity = (float) $quantity;
339
-
340
-	}
341
-
342
-	/**
343
-	 * Set the item meta data.
344
-	 *
345
-	 * @since 1.0.19
346
-	 * @param  array $meta The item meta data.
347
-	 */
348
-	public function set_item_meta( $meta ) {
349
-		$this->meta = maybe_unserialize( $meta );
350
-	}
351
-
352
-	/**
353
-	 * Set whether or not the quantities are allowed.
354
-	 *
355
-	 * @since 1.0.19
356
-	 * @param  bool $allow_quantities
357
-	 */
358
-	public function set_allow_quantities( $allow_quantities ) {
359
-		$this->allow_quantities = (bool) $allow_quantities;
360
-	}
361
-
362
-	/**
363
-	 * Set whether or not the item is required.
364
-	 *
365
-	 * @since 1.0.19
366
-	 * @param  bool $is_required
367
-	 */
368
-	public function set_is_required( $is_required ) {
369
-		$this->is_required = (bool) $is_required;
370
-	}
371
-
372
-	/**
373
-	 * Sets the custom item description.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $description
377
-	 */
378
-	public function set_custom_description( $description ) {
379
-		$this->custom_description = $description;
380
-	}
326
+    /**
327
+     * Set the item qantity.
328
+     *
329
+     * @since 1.0.19
330
+     * @param  float $quantity The item quantity.
331
+     */
332
+    public function set_quantity( $quantity ) {
333
+
334
+        if ( ! is_numeric( $quantity ) ) {
335
+            $quantity = 1;
336
+        }
337
+
338
+        $this->quantity = (float) $quantity;
339
+
340
+    }
341
+
342
+    /**
343
+     * Set the item meta data.
344
+     *
345
+     * @since 1.0.19
346
+     * @param  array $meta The item meta data.
347
+     */
348
+    public function set_item_meta( $meta ) {
349
+        $this->meta = maybe_unserialize( $meta );
350
+    }
351
+
352
+    /**
353
+     * Set whether or not the quantities are allowed.
354
+     *
355
+     * @since 1.0.19
356
+     * @param  bool $allow_quantities
357
+     */
358
+    public function set_allow_quantities( $allow_quantities ) {
359
+        $this->allow_quantities = (bool) $allow_quantities;
360
+    }
361
+
362
+    /**
363
+     * Set whether or not the item is required.
364
+     *
365
+     * @since 1.0.19
366
+     * @param  bool $is_required
367
+     */
368
+    public function set_is_required( $is_required ) {
369
+        $this->is_required = (bool) $is_required;
370
+    }
371
+
372
+    /**
373
+     * Sets the custom item description.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $description
377
+     */
378
+    public function set_custom_description( $description ) {
379
+        $this->custom_description = $description;
380
+    }
381 381
 
382 382
     /**
383 383
      * We do not want to save items to the database.
384 384
      * 
385
-	 * @return int item id
385
+     * @return int item id
386 386
      */
387 387
     public function save( $data = array() ) {
388 388
         return $this->get_id();
389
-	}
389
+    }
390 390
 
391 391
     /*
392 392
 	|--------------------------------------------------------------------------
@@ -398,23 +398,23 @@  discard block
 block discarded – undo
398 398
 	*/
399 399
 
400 400
     /**
401
-	 * Checks whether the item has enabled dynamic pricing.
402
-	 *
403
-	 * @since 1.0.19
404
-	 * @return bool
405
-	 */
406
-	public function is_required() {
401
+     * Checks whether the item has enabled dynamic pricing.
402
+     *
403
+     * @since 1.0.19
404
+     * @return bool
405
+     */
406
+    public function is_required() {
407 407
         return (bool) $this->get_is_required();
408
-	}
409
-
410
-	/**
411
-	 * Checks whether users can edit the quantities.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @return bool
415
-	 */
416
-	public function allows_quantities() {
408
+    }
409
+
410
+    /**
411
+     * Checks whether users can edit the quantities.
412
+     *
413
+     * @since 1.0.19
414
+     * @return bool
415
+     */
416
+    public function allows_quantities() {
417 417
         return (bool) $this->get_allow_quantities();
418
-	}
418
+    }
419 419
 
420 420
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @param  string $context View or edit context.
95 95
 	 * @return string
96 96
 	 */
97
-	public function get_name( $context = 'view' ) {
98
-		$name = parent::get_name( $context );
99
-		return $name . wpinv_get_item_suffix( $this );
97
+	public function get_name($context = 'view') {
98
+		$name = parent::get_name($context);
99
+		return $name . wpinv_get_item_suffix($this);
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	 * @param  string $context View or edit context.
107 107
 	 * @return string
108 108
 	 */
109
-	public function get_raw_name( $context = 'view' ) {
110
-		return parent::get_name( $context );
109
+	public function get_raw_name($context = 'view') {
110
+		return parent::get_name($context);
111 111
 	}
112 112
 
113 113
 	/**
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
 	 * @param  string $context View or edit context.
118 118
 	 * @return string
119 119
 	 */
120
-	public function get_description( $context = 'view' ) {
120
+	public function get_description($context = 'view') {
121 121
 
122
-		if ( isset( $this->custom_description ) ) {
122
+		if (isset($this->custom_description)) {
123 123
 			return $this->custom_description;
124 124
 		}
125 125
 
126
-		return parent::get_description( $context );
126
+		return parent::get_description($context);
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @param  string $context View or edit context.
134 134
 	 * @return float
135 135
 	 */
136
-	public function get_sub_total( $context = 'view' ) {
137
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context );
136
+	public function get_sub_total($context = 'view') {
137
+		return $this->get_quantity($context) * $this->get_initial_price($context);
138 138
 	}
139 139
 
140 140
 	/**
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	 * @param  string $context View or edit context.
145 145
 	 * @return float
146 146
 	 */
147
-	public function get_recurring_sub_total( $context = 'view' ) {
147
+	public function get_recurring_sub_total($context = 'view') {
148 148
 
149
-		if ( $this->is_recurring() ) {
150
-			return $this->get_quantity( $context ) * $this->get_price( $context );
149
+		if ($this->is_recurring()) {
150
+			return $this->get_quantity($context) * $this->get_price($context);
151 151
 		}
152 152
 
153 153
 		return 0;
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	/**
157 157
 	 * @deprecated
158 158
 	 */
159
-	public function get_qantity( $context = 'view' ) {
160
-		return $this->get_quantity( $context );
159
+	public function get_qantity($context = 'view') {
160
+		return $this->get_quantity($context);
161 161
 	}
162 162
 
163 163
 	/**
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 * @param  string $context View or edit context.
168 168
 	 * @return float
169 169
 	 */
170
-	public function get_quantity( $context = 'view' ) {
170
+	public function get_quantity($context = 'view') {
171 171
 		$quantity = (float) $this->quantity;
172 172
 
173
-		if ( 'view' == $context ) {
174
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
173
+		if ('view' == $context) {
174
+			return apply_filters('getpaid_payment_form_item_quantity', $quantity, $this);
175 175
 		}
176 176
 
177 177
 		return $quantity;
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 	 * @param  string $context View or edit context.
186 186
 	 * @return meta
187 187
 	 */
188
-	public function get_item_meta( $context = 'view' ) {
188
+	public function get_item_meta($context = 'view') {
189 189
 		$meta = $this->meta;
190 190
 
191
-		if ( 'view' == $context ) {
192
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
191
+		if ('view' == $context) {
192
+			return apply_filters('getpaid_payment_form_item_meta', $meta, $this);
193 193
 		}
194 194
 
195 195
 		return $meta;
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 	 * @param  string $context View or edit context.
204 204
 	 * @return bool
205 205
 	 */
206
-	public function get_allow_quantities( $context = 'view' ) {
206
+	public function get_allow_quantities($context = 'view') {
207 207
 		$allow_quantities = (bool) $this->allow_quantities;
208 208
 
209
-		if ( 'view' == $context ) {
210
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
209
+		if ('view' == $context) {
210
+			return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this);
211 211
 		}
212 212
 
213 213
 		return $allow_quantities;
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 	 * @param  string $context View or edit context.
222 222
 	 * @return bool
223 223
 	 */
224
-	public function get_is_required( $context = 'view' ) {
224
+	public function get_is_required($context = 'view') {
225 225
 		$is_required = (bool) $this->is_required;
226 226
 
227
-		if ( 'view' == $context ) {
228
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
227
+		if ('view' == $context) {
228
+			return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this);
229 229
 		}
230 230
 
231 231
 		return $is_required;
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 	 * @since 1.0.19
239 239
 	 * @return array
240 240
 	 */
241
-	public function prepare_data_for_use( $required = null ) {
241
+	public function prepare_data_for_use($required = null) {
242 242
 
243
-		$required = is_null( $required ) ? $this->is_required() : $required;
243
+		$required = is_null($required) ? $this->is_required() : $required;
244 244
 		return array(
245
-			'title'            => strip_tags( $this->get_name() ),
245
+			'title'            => strip_tags($this->get_name()),
246 246
 			'id'               => $this->get_id(),
247 247
 			'price'            => $this->get_price(),
248 248
 			'recurring'        => $this->is_recurring(),
@@ -259,30 +259,30 @@  discard block
 block discarded – undo
259 259
 	 * @since 1.0.19
260 260
 	 * @return array
261 261
 	 */
262
-	public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
262
+	public function prepare_data_for_invoice_edit_ajax($currency = '', $is_renewal = false) {
263 263
 
264
-		$description = getpaid_item_recurring_price_help_text( $this, $currency );
264
+		$description = getpaid_item_recurring_price_help_text($this, $currency);
265 265
 
266
-		if ( $description ) {
266
+		if ($description) {
267 267
 			$description = "<div class='getpaid-subscription-help-text'>$description</div>";
268 268
 		}
269 269
 
270
-		$price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
271
-		$subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
270
+		$price    = !$is_renewal ? $this->get_price() : $this->get_recurring_price();
271
+		$subtotal = !$is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
272 272
 		return array(
273 273
 			'id'     => $this->get_id(),
274 274
 			'texts'  => array(
275
-				'item-name'        => sanitize_text_field( $this->get_name() ),
276
-				'item-description' => wp_kses_post( $this->get_description() ) . $description,
277
-				'item-quantity'    => floatval( $this->get_quantity() ),
278
-				'item-price'       => wpinv_price( $price, $currency ),
279
-				'item-total'       => wpinv_price( $subtotal, $currency ),
275
+				'item-name'        => sanitize_text_field($this->get_name()),
276
+				'item-description' => wp_kses_post($this->get_description()) . $description,
277
+				'item-quantity'    => floatval($this->get_quantity()),
278
+				'item-price'       => wpinv_price($price, $currency),
279
+				'item-total'       => wpinv_price($subtotal, $currency),
280 280
 			),
281 281
 			'inputs' => array(
282 282
 				'item-id'          => $this->get_id(),
283
-				'item-name'        => sanitize_text_field( $this->get_name() ),
284
-				'item-description' => wp_kses_post( $this->get_description() ),
285
-				'item-quantity'    => floatval( $this->get_quantity() ),
283
+				'item-name'        => sanitize_text_field($this->get_name()),
284
+				'item-description' => wp_kses_post($this->get_description()),
285
+				'item-quantity'    => floatval($this->get_quantity()),
286 286
 				'item-price'       => $price,
287 287
 			)
288 288
 		);
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
 		return array(
301 301
 			'post_id'           => $this->invoice_id,
302 302
 			'item_id'           => $this->get_id(),
303
-			'item_name'         => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
304
-			'item_description'  => $this->get_description( 'edit' ),
303
+			'item_name'         => sanitize_text_field($this->get_raw_name('edit')),
304
+			'item_description'  => $this->get_description('edit'),
305 305
 			'tax'               => $this->item_tax,
306
-			'item_price'        => $this->get_price( 'edit' ),
307
-			'quantity'          => (float) $this->get_quantity( 'edit' ),
306
+			'item_price'        => $this->get_price('edit'),
307
+			'quantity'          => (float) $this->get_quantity('edit'),
308 308
 			'discount'          => $this->item_discount,
309
-			'subtotal'          => $this->get_sub_total( 'edit' ),
310
-			'price'             => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
311
-			'meta'              => $this->get_item_meta( 'edit' ),
309
+			'subtotal'          => $this->get_sub_total('edit'),
310
+			'price'             => $this->get_sub_total('edit') + $this->item_tax - $this->item_discount,
311
+			'meta'              => $this->get_item_meta('edit'),
312 312
 		);
313 313
 
314 314
 	}
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 	 * @since 1.0.19
330 330
 	 * @param  float $quantity The item quantity.
331 331
 	 */
332
-	public function set_quantity( $quantity ) {
332
+	public function set_quantity($quantity) {
333 333
 
334
-		if ( ! is_numeric( $quantity ) ) {
334
+		if (!is_numeric($quantity)) {
335 335
 			$quantity = 1;
336 336
 		}
337 337
 
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	 * @since 1.0.19
346 346
 	 * @param  array $meta The item meta data.
347 347
 	 */
348
-	public function set_item_meta( $meta ) {
349
-		$this->meta = maybe_unserialize( $meta );
348
+	public function set_item_meta($meta) {
349
+		$this->meta = maybe_unserialize($meta);
350 350
 	}
351 351
 
352 352
 	/**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @since 1.0.19
356 356
 	 * @param  bool $allow_quantities
357 357
 	 */
358
-	public function set_allow_quantities( $allow_quantities ) {
358
+	public function set_allow_quantities($allow_quantities) {
359 359
 		$this->allow_quantities = (bool) $allow_quantities;
360 360
 	}
361 361
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 * @since 1.0.19
366 366
 	 * @param  bool $is_required
367 367
 	 */
368
-	public function set_is_required( $is_required ) {
368
+	public function set_is_required($is_required) {
369 369
 		$this->is_required = (bool) $is_required;
370 370
 	}
371 371
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 * @since 1.0.19
376 376
 	 * @param  string $description
377 377
 	 */
378
-	public function set_custom_description( $description ) {
378
+	public function set_custom_description($description) {
379 379
 		$this->custom_description = $description;
380 380
 	}
381 381
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
      * 
385 385
 	 * @return int item id
386 386
      */
387
-    public function save( $data = array() ) {
387
+    public function save($data = array()) {
388 388
         return $this->get_id();
389 389
 	}
390 390
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/file_upload.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,31 +7,31 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='form-group'>
15 15
     <label class="d-block">
16
-        <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span>
16
+        <span><?php esc_html_e('Field Label', 'invoicing'); ?></span>
17 17
         <input v-model="active_form_element.label" class="form-control" type="text"/>
18 18
     </label>
19 19
 </div>
20 20
 
21 21
 <div class='form-group'>
22 22
     <label class="d-block">
23
-        <span><?php esc_html_e( 'Max File Number', 'invoicing' ); ?></span>
23
+        <span><?php esc_html_e('Max File Number', 'invoicing'); ?></span>
24 24
         <input v-model="active_form_element.max_file_num" class="form-control" min="1" type="number" />
25
-        <small class="form-text text-muted"><?php _e( 'How many files can be uploaded?', 'invoicing' ); ?></small>
25
+        <small class="form-text text-muted"><?php _e('How many files can be uploaded?', 'invoicing'); ?></small>
26 26
     </label>
27 27
 </div>
28 28
 
29 29
 <div class='form-group'>
30 30
     <label class="d-block">
31
-        <span><?php esc_html_e( 'Allowed File types', 'invoicing' ); ?></span>
31
+        <span><?php esc_html_e('Allowed File types', 'invoicing'); ?></span>
32 32
         <gpselect2 class='form-control custom-select' v-model='active_form_element.file_types' multiple>
33
-            <?php foreach ( getpaid_get_allowed_mime_types() as $ext_regex => $mime_type ) : ?>
34
-                <option value="<?php echo esc_attr( $ext_regex ); ?>"><?php echo esc_html( "$mime_type" ) ?></option>
33
+            <?php foreach (getpaid_get_allowed_mime_types() as $ext_regex => $mime_type) : ?>
34
+                <option value="<?php echo esc_attr($ext_regex); ?>"><?php echo esc_html("$mime_type") ?></option>
35 35
             <?php endforeach; ?>
36 36
         </gpselect2>
37 37
     </label>
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
 <div class='form-group'>
41 41
     <label class="d-block">
42
-        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
43
-        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
44
-        <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small>
42
+        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
43
+        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
44
+        <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small>
45 45
     </label>
46 46
 </div>
47 47
 
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 
50 50
 <div class='form-group form-check'>
51 51
     <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' />
52
-    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label>
52
+    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label>
53 53
 </div>
54 54
 
55 55
 <div class='form-group form-check'>
56 56
     <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' />
57
-    <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label>
57
+    <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label>
58 58
 </div>
59 59
 
60 60
 <hr class='featurette-divider mt-4'>
61 61
 
62 62
 <div class='form-group'>
63 63
     <label class="d-block">
64
-        <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span>
64
+        <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span>
65 65
         <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" />
66
-        <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span>
66
+        <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span>
67 67
     </label>
68 68
 </div>
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/file_upload.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <label><span v-html="form_element.label"></span></label>
15 15
 <div class="d-flex w-100 flex-column align-items-center justify-content-center p-2" style="height: 200px; border: 3px dashed rgb(136, 136, 136); cursor: pointer;">
16 16
     <div class="h5 text-dark">
17
-        <span v-if="form_element.max_file_num > 1"><?php _e( 'Drag files to this area or click to upload', 'invoicing' ); ?></span>
18
-        <span v-if="form_element.max_file_num < 2"><?php _e( 'Drag your file to this area or click to upload', 'invoicing' ); ?></span>
17
+        <span v-if="form_element.max_file_num > 1"><?php _e('Drag files to this area or click to upload', 'invoicing'); ?></span>
18
+        <span v-if="form_element.max_file_num < 2"><?php _e('Drag your file to this area or click to upload', 'invoicing'); ?></span>
19 19
     </div>
20 20
     <small v-if='form_element.description' class='form-text text-muted' v-html='form_element.description'></small>
21 21
 </div>
Please login to merge, or discard this patch.
templates/payment-forms/elements/file_upload.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,22 +21,22 @@
 block discarded – undo
21 21
 
22 22
 foreach ( $file_types as $file_type ) {
23 23
 
24
-	if ( isset( $all_types[ $file_type ] ) ) {
25
-		$types[]   = $all_types[ $file_type ];
26
-		$file_type = explode( '|', $file_type );
24
+    if ( isset( $all_types[ $file_type ] ) ) {
25
+        $types[]   = $all_types[ $file_type ];
26
+        $file_type = explode( '|', $file_type );
27 27
 
28
-		foreach ( $file_type as $type ) {
29
-			$type     = trim( $type );
30
-			$types[]  = ".$type";
31
-			$_types[] = $type;
32
-		}
28
+        foreach ( $file_type as $type ) {
29
+            $type     = trim( $type );
30
+            $types[]  = ".$type";
31
+            $_types[] = $type;
32
+        }
33 33
 
34
-	}
34
+    }
35 35
 
36 36
 }
37 37
 
38 38
 if ( ! empty( $required ) ) {
39
-	$label .= "<span class='text-danger'> *</span>";
39
+    $label .= "<span class='text-danger'> *</span>";
40 40
 }
41 41
 
42 42
 ?>
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
11
-
12
-$label        = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class  = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14
-$id           = esc_attr( $id );
15
-$_id          = $id . uniqid( '_' );
16
-$max_file_num = empty( $max_file_num ) ? 1 : absint( $max_file_num );
17
-$file_types   = empty( $file_types ) ? array( 'jpg|jpeg|jpe', 'gif', 'png' ) : $file_types;
10
+defined('ABSPATH') || exit;
11
+
12
+$label        = empty($label) ? '' : wp_kses_post($label);
13
+$label_class  = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14
+$id           = esc_attr($id);
15
+$_id          = $id . uniqid('_');
16
+$max_file_num = empty($max_file_num) ? 1 : absint($max_file_num);
17
+$file_types   = empty($file_types) ? array('jpg|jpeg|jpe', 'gif', 'png') : $file_types;
18 18
 $all_types    = getpaid_get_allowed_mime_types();
19 19
 $types        = array();
20 20
 $_types       = array();
21 21
 
22
-foreach ( $file_types as $file_type ) {
22
+foreach ($file_types as $file_type) {
23 23
 
24
-	if ( isset( $all_types[ $file_type ] ) ) {
25
-		$types[]   = $all_types[ $file_type ];
26
-		$file_type = explode( '|', $file_type );
24
+	if (isset($all_types[$file_type])) {
25
+		$types[]   = $all_types[$file_type];
26
+		$file_type = explode('|', $file_type);
27 27
 
28
-		foreach ( $file_type as $type ) {
29
-			$type     = trim( $type );
28
+		foreach ($file_type as $type) {
29
+			$type     = trim($type);
30 30
 			$types[]  = ".$type";
31 31
 			$_types[] = $type;
32 32
 		}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 }
37 37
 
38
-if ( ! empty( $required ) ) {
38
+if (!empty($required)) {
39 39
 	$label .= "<span class='text-danger'> *</span>";
40 40
 }
41 41
 
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 
44 44
 <label><span v-html="form_element.label"></span></label>
45 45
 
46
-<div class="form-group <?php echo sanitize_html_class( $label_class ); ?>" data-name="<?php echo esc_attr( $id ); ?>" data-max="<?php echo esc_attr( $max_file_num ); ?>">
47
-	<label for="<?php echo esc_attr( $id ); ?>"><?php echo wp_kses_post( $label ); ?></label>
48
-	<input type="file" class="sr-only getpaid-files-input" id="<?php echo esc_attr( $id ); ?>" accept="<?php echo esc_attr( implode( ', ', $types ) ); ?>" data-extensions="<?php echo esc_attr( wp_json_encode( $_types ) ); ?>" <?php echo $max_file_num == 1 ? '' : 'multiple="multiple"'; ?>>
46
+<div class="form-group <?php echo sanitize_html_class($label_class); ?>" data-name="<?php echo esc_attr($id); ?>" data-max="<?php echo esc_attr($max_file_num); ?>">
47
+	<label for="<?php echo esc_attr($id); ?>"><?php echo wp_kses_post($label); ?></label>
48
+	<input type="file" class="sr-only getpaid-files-input" id="<?php echo esc_attr($id); ?>" accept="<?php echo esc_attr(implode(', ', $types)); ?>" data-extensions="<?php echo esc_attr(wp_json_encode($_types)); ?>" <?php echo $max_file_num == 1 ? '' : 'multiple="multiple"'; ?>>
49 49
 
50
-	<label for="<?php echo esc_attr( $id ); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2">
50
+	<label for="<?php echo esc_attr($id); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2">
51 51
 		<div class="h5 text-dark">
52
-			<?php echo _n( 'Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing' ); ?>
52
+			<?php echo _n('Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing'); ?>
53 53
 		</div>
54
-		<?php if ( ! empty( $description ) ) : ?>
55
-			<small class="form-text text-muted"><?php echo wp_kses_post( $description ); ?></small>
54
+		<?php if (!empty($description)) : ?>
55
+			<small class="form-text text-muted"><?php echo wp_kses_post($description); ?></small>
56 56
 		<?php endif; ?>
57 57
 	</label>
58 58
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	<div class="form-row mb-3 d-none getpaid-progress-template">
62 62
 
63 63
 		<div class="overflow-hidden text-nowrap col-7 col-sm-4">
64
-			<a href="" class="close float-none" title="<?php esc_attr_e( 'Remove File', 'invoicing' ); ?>">&times;<span class="sr-only"><?php _e( 'Close', 'invoicing' ); ?></span></a>&nbsp;
64
+			<a href="" class="close float-none" title="<?php esc_attr_e('Remove File', 'invoicing'); ?>">&times;<span class="sr-only"><?php _e('Close', 'invoicing'); ?></span></a>&nbsp;
65 65
 			<i class="fa fa-file" aria-hidden="true"></i>&nbsp; <span class="getpaid-progress-file-name"></span>&nbsp;
66 66
 		</div>
67 67
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-payment-form.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Payment_Form {
@@ -11,23 +11,23 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @param WP_Post $post
13 13
      */
14
-    public static function output_details( $post ) {
15
-        $details = get_post_meta( $post->ID, 'payment_form_data', true );
14
+    public static function output_details($post) {
15
+        $details = get_post_meta($post->ID, 'payment_form_data', true);
16 16
 
17
-        if ( ! is_array( $details ) ) {
17
+        if (!is_array($details)) {
18 18
             return;
19 19
         }
20 20
 
21 21
         echo '<div class="bsui"> <div class="form-row">';
22 22
 
23
-        foreach ( $details as $key => $value ) {
24
-            $key = esc_html( $key );
23
+        foreach ($details as $key => $value) {
24
+            $key = esc_html($key);
25 25
 
26
-            if ( is_array( $value ) ) {
27
-                $value = implode( ',', $value );
26
+            if (is_array($value)) {
27
+                $value = implode(',', $value);
28 28
             }
29 29
 
30
-            $value = wp_kses_post( $value );
30
+            $value = wp_kses_post($value);
31 31
             echo "<div class='col-12'><strong>$key:</strong></div><div class='col-12 form-group'>$value</div>";
32 32
         }
33 33
 
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @param WP_Post $post
42 42
      */
43
-    public static function output_shortcode( $post ) {
43
+    public static function output_shortcode($post) {
44 44
 
45
-        if ( ! is_numeric( $post ) ) {
45
+        if (!is_numeric($post)) {
46 46
             $post = $post->ID;
47 47
         }
48 48
 
49
-        if ( $post == wpinv_get_default_payment_form() ) {
49
+        if ($post == wpinv_get_default_payment_form()) {
50 50
             echo '&mdash;';
51 51
             return;
52 52
         }
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
  */
137 137
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
138 138
 
139
-	$invoice_statuses = array(
140
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
139
+    $invoice_statuses = array(
140
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
141 141
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
142 142
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
143
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
143
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
146 146
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
147 147
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
148 148
     );
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         $invoice = $invoice->get_post_type();
160 160
     }
161 161
 
162
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
162
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
163 163
 }
164 164
 
165 165
 /**
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
  * @return string
278 278
  */
279 279
 function getpaid_get_price_format() {
280
-	$currency_pos = wpinv_currency_position();
281
-	$format       = '%1$s%2$s';
282
-
283
-	switch ( $currency_pos ) {
284
-		case 'left':
285
-			$format = '%1$s%2$s';
286
-			break;
287
-		case 'right':
288
-			$format = '%2$s%1$s';
289
-			break;
290
-		case 'left_space':
291
-			$format = '%1$s&nbsp;%2$s';
292
-			break;
293
-		case 'right_space':
294
-			$format = '%2$s&nbsp;%1$s';
295
-			break;
296
-	}
297
-
298
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
280
+    $currency_pos = wpinv_currency_position();
281
+    $format       = '%1$s%2$s';
282
+
283
+    switch ( $currency_pos ) {
284
+        case 'left':
285
+            $format = '%1$s%2$s';
286
+            break;
287
+        case 'right':
288
+            $format = '%2$s%1$s';
289
+            break;
290
+        case 'left_space':
291
+            $format = '%1$s&nbsp;%2$s';
292
+            break;
293
+        case 'right_space':
294
+            $format = '%2$s&nbsp;%1$s';
295
+            break;
296
+    }
297
+
298
+    return apply_filters( 'getpaid_price_format', $format, $currency_pos );
299 299
 }
300 300
 
301 301
 /**
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
  * @param mixed  $value Value.
391 391
  */
392 392
 function getpaid_maybe_define_constant( $name, $value ) {
393
-	if ( ! defined( $name ) ) {
394
-		define( $name, $value );
395
-	}
393
+    if ( ! defined( $name ) ) {
394
+        define( $name, $value );
395
+    }
396 396
 }
397 397
 
398 398
 function wpinv_get_php_arg_separator_output() {
399
-	return ini_get( 'arg_separator.output' );
399
+    return ini_get( 'arg_separator.output' );
400 400
 }
401 401
 
402 402
 function wpinv_rgb_from_hex( $color ) {
@@ -751,11 +751,11 @@  discard block
 block discarded – undo
751 751
         $list = array();
752 752
     }
753 753
 
754
-	if ( ! is_array( $list ) ) {
755
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
756
-	}
754
+    if ( ! is_array( $list ) ) {
755
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
756
+    }
757 757
 
758
-	return $list;
758
+    return $list;
759 759
 }
760 760
 
761 761
 /**
@@ -775,9 +775,9 @@  discard block
 block discarded – undo
775 775
     }
776 776
 
777 777
     $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
778
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
778
+    wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
779 779
 
780
-	return $data;
780
+    return $data;
781 781
 }
782 782
 
783 783
 /**
@@ -806,17 +806,17 @@  discard block
 block discarded – undo
806 806
  */
807 807
 function wpinv_clean( $var ) {
808 808
 
809
-	if ( is_array( $var ) ) {
810
-		return array_map( 'wpinv_clean', $var );
809
+    if ( is_array( $var ) ) {
810
+        return array_map( 'wpinv_clean', $var );
811 811
     }
812 812
 
813 813
     if ( is_object( $var ) ) {
814
-		$object_vars = get_object_vars( $var );
815
-		foreach ( $object_vars as $property_name => $property_value ) {
816
-			$var->$property_name = wpinv_clean( $property_value );
814
+        $object_vars = get_object_vars( $var );
815
+        foreach ( $object_vars as $property_name => $property_value ) {
816
+            $var->$property_name = wpinv_clean( $property_value );
817 817
         }
818 818
         return $var;
819
-	}
819
+    }
820 820
 
821 821
     return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
822 822
 }
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
  */
830 830
 function getpaid_convert_price_string_to_options( $str ) {
831 831
 
832
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
832
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
833 833
     $options     = array();
834 834
 
835 835
     foreach ( $raw_options as $option ) {
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
  * @return string
913 913
  */
914 914
 function getpaid_date_format() {
915
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
915
+    return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
916 916
 }
917 917
 
918 918
 /**
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
  * @return string
922 922
  */
923 923
 function getpaid_time_format() {
924
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
924
+    return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
925 925
 }
926 926
 
927 927
 /**
@@ -934,15 +934,15 @@  discard block
 block discarded – undo
934 934
 function getpaid_limit_length( $string, $limit ) {
935 935
     $str_limit = $limit - 3;
936 936
 
937
-	if ( function_exists( 'mb_strimwidth' ) ) {
938
-		if ( mb_strlen( $string ) > $limit ) {
939
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
940
-		}
941
-	} else {
942
-		if ( strlen( $string ) > $limit ) {
943
-			$string = substr( $string, 0, $str_limit ) . '...';
944
-		}
945
-	}
937
+    if ( function_exists( 'mb_strimwidth' ) ) {
938
+        if ( mb_strlen( $string ) > $limit ) {
939
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
940
+        }
941
+    } else {
942
+        if ( strlen( $string ) > $limit ) {
943
+            $string = substr( $string, 0, $str_limit ) . '...';
944
+        }
945
+    }
946 946
     return $string;
947 947
 
948 948
 }
@@ -1073,12 +1073,12 @@  discard block
 block discarded – undo
1073 1073
     $types = get_allowed_mime_types();
1074 1074
 
1075 1075
     if ( isset( $types['htm|html'] ) ) {
1076
-		unset( $types['htm|html'] );
1077
-	}
1076
+        unset( $types['htm|html'] );
1077
+    }
1078 1078
 
1079 1079
     if ( isset( $types['js'] ) ) {
1080
-		unset( $types['js'] );
1081
-	}
1080
+        unset( $types['js'] );
1081
+    }
1082 1082
 
1083 1083
     return $types;
1084 1084
 
Please login to merge, or discard this patch.
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param string $amount The amount to sanitize.
58 58
  * @return float
59 59
  */
60
-function getpaid_standardize_amount( $amount ) {
60
+function getpaid_standardize_amount($amount) {
61 61
 
62
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
63
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
64
-    if ( is_numeric( $amount ) ) {
65
-        return floatval( $amount );
62
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
63
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
64
+    if (is_numeric($amount)) {
65
+        return floatval($amount);
66 66
     }
67 67
 
68 68
     // Cast the remaining to a float.
69
-    return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) );
69
+    return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount));
70 70
 
71 71
 }
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @param string $amount The amount to sanitize.
77 77
  */
78
-function getpaid_unstandardize_amount( $amount ) {
79
-    return str_replace( '.', wpinv_decimal_separator(), $amount );
78
+function getpaid_unstandardize_amount($amount) {
79
+    return str_replace('.', wpinv_decimal_separator(), $amount);
80 80
 }
81 81
 
82 82
 /**
@@ -84,23 +84,23 @@  discard block
 block discarded – undo
84 84
  * 
85 85
  * @param string $amount The amount to sanitize.
86 86
  */
87
-function wpinv_sanitize_amount( $amount ) {
87
+function wpinv_sanitize_amount($amount) {
88 88
 
89
-    if ( is_numeric( $amount ) ) {
90
-        return floatval( $amount );
89
+    if (is_numeric($amount)) {
90
+        return floatval($amount);
91 91
     }
92 92
 
93 93
     // Separate the decimals and thousands.
94
-    $amount    = explode( wpinv_decimal_separator(), $amount );
94
+    $amount    = explode(wpinv_decimal_separator(), $amount);
95 95
 
96 96
     // Remove thousands.
97
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
97
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
98 98
 
99 99
     // Convert back to string.
100
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
100
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
101 101
 
102 102
     // Cast the remaining to a float.
103
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
103
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
104 104
 
105 105
 }
106 106
 
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
  * @param float $amount
111 111
  * @param float|string|int|null $decimals
112 112
  */
113
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
113
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
114 114
 
115
-    if ( $decimals === null ) {
115
+    if ($decimals === null) {
116 116
         $decimals = wpinv_decimals();
117 117
     }
118 118
 
119
-    if ( $use_sprintf ) {
120
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
119
+    if ($use_sprintf) {
120
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
121 121
     } else {
122
-        $amount = round( (float) $amount, absint( $decimals ) );
122
+        $amount = round((float) $amount, absint($decimals));
123 123
     }
124 124
 
125
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
125
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
126 126
 }
127 127
 
128 128
 /**
@@ -134,32 +134,32 @@  discard block
 block discarded – undo
134 134
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
135 135
  * @return array
136 136
  */
137
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
137
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
138 138
 
139 139
 	$invoice_statuses = array(
140
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
141
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
142
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
143
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
146
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
147
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
140
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
141
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
142
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
143
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
144
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
145
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
146
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
147
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
148 148
     );
149 149
 
150
-    if ( $draft ) {
151
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
150
+    if ($draft) {
151
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
152 152
     }
153 153
 
154
-    if ( $trashed ) {
155
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
154
+    if ($trashed) {
155
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
156 156
     }
157 157
 
158
-    if ( $invoice instanceof WPInv_Invoice ) {
158
+    if ($invoice instanceof WPInv_Invoice) {
159 159
         $invoice = $invoice->get_post_type();
160 160
     }
161 161
 
162
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
162
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
163 163
 }
164 164
 
165 165
 /**
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
  * @param string $status The raw status
169 169
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
170 170
  */
171
-function wpinv_status_nicename( $status, $invoice = false ) {
172
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
173
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : $status;
171
+function wpinv_status_nicename($status, $invoice = false) {
172
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
173
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
174 174
 
175
-    return sanitize_text_field( $status );
175
+    return sanitize_text_field($status);
176 176
 }
177 177
 
178 178
 /**
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
  * 
181 181
  * @param string $current
182 182
  */
183
-function wpinv_get_currency( $current = '' ) {
183
+function wpinv_get_currency($current = '') {
184 184
 
185
-    if ( empty( $current ) ) {
186
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
185
+    if (empty($current)) {
186
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
187 187
     }
188 188
 
189
-    return trim( strtoupper( $current ) );
189
+    return trim(strtoupper($current));
190 190
 }
191 191
 
192 192
 /**
@@ -194,25 +194,25 @@  discard block
 block discarded – undo
194 194
  * 
195 195
  * @param string|null $currency The currency code. Defaults to the default currency.
196 196
  */
197
-function wpinv_currency_symbol( $currency = null ) {
197
+function wpinv_currency_symbol($currency = null) {
198 198
 
199 199
     // Prepare the currency.
200
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
200
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
201 201
 
202 202
     // Fetch all symbols.
203 203
     $symbols = wpinv_get_currency_symbols();
204 204
 
205 205
     // Fetch this currencies symbol.
206
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
206
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
207 207
 
208 208
     // Filter the symbol.
209
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
209
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
210 210
 }
211 211
 
212 212
 function wpinv_currency_position() {
213
-    $position = wpinv_get_option( 'currency_position', 'left' );
213
+    $position = wpinv_get_option('currency_position', 'left');
214 214
     
215
-    return apply_filters( 'wpinv_currency_position', $position );
215
+    return apply_filters('wpinv_currency_position', $position);
216 216
 }
217 217
 
218 218
 /**
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
  * 
221 221
  * @param $string|null $current
222 222
  */
223
-function wpinv_thousands_separator( $current = null ) {
223
+function wpinv_thousands_separator($current = null) {
224 224
 
225
-    if ( null == $current ) {
226
-        $current = wpinv_get_option( 'thousands_separator', ',' );
225
+    if (null == $current) {
226
+        $current = wpinv_get_option('thousands_separator', ',');
227 227
     }
228 228
 
229
-    return trim( $current );
229
+    return trim($current);
230 230
 }
231 231
 
232 232
 /**
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
  * 
235 235
  * @param $string|null $current
236 236
  */
237
-function wpinv_decimal_separator( $current = null ) {
237
+function wpinv_decimal_separator($current = null) {
238 238
 
239
-    if ( null == $current ) {
240
-        $current = wpinv_get_option( 'decimal_separator', '.' );
239
+    if (null == $current) {
240
+        $current = wpinv_get_option('decimal_separator', '.');
241 241
     }
242 242
     
243
-    return trim( $current );
243
+    return trim($current);
244 244
 }
245 245
 
246 246
 /**
@@ -248,27 +248,27 @@  discard block
 block discarded – undo
248 248
  * 
249 249
  * @param $string|null $current
250 250
  */
251
-function wpinv_decimals( $current = null ) {
251
+function wpinv_decimals($current = null) {
252 252
 
253
-    if ( null == $current ) {
254
-        $current = wpinv_get_option( 'decimals', 2 );
253
+    if (null == $current) {
254
+        $current = wpinv_get_option('decimals', 2);
255 255
     }
256 256
     
257
-    return absint( $current );
257
+    return absint($current);
258 258
 }
259 259
 
260 260
 /**
261 261
  * Retrieves a list of all supported currencies.
262 262
  */
263 263
 function wpinv_get_currencies() {
264
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
264
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
265 265
 }
266 266
 
267 267
 /**
268 268
  * Retrieves a list of all currency symbols.
269 269
  */
270 270
 function wpinv_get_currency_symbols() {
271
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
271
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
272 272
 }
273 273
 
274 274
 /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	$currency_pos = wpinv_currency_position();
281 281
 	$format       = '%1$s%2$s';
282 282
 
283
-	switch ( $currency_pos ) {
283
+	switch ($currency_pos) {
284 284
 		case 'left':
285 285
 			$format = '%1$s%2$s';
286 286
 			break;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			break;
296 296
 	}
297 297
 
298
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
298
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
299 299
 }
300 300
 
301 301
 /**
@@ -305,25 +305,25 @@  discard block
 block discarded – undo
305 305
  * @param  string $currency Currency.
306 306
  * @return string
307 307
  */
308
-function wpinv_price( $amount = 0, $currency = '' ) {
308
+function wpinv_price($amount = 0, $currency = '') {
309 309
 
310 310
     // Backwards compatibility.
311
-    $amount             = wpinv_sanitize_amount( $amount );
311
+    $amount             = wpinv_sanitize_amount($amount);
312 312
 
313 313
     // Prepare variables.
314
-    $currency           = wpinv_get_currency( $currency );
314
+    $currency           = wpinv_get_currency($currency);
315 315
     $amount             = (float) $amount;
316 316
     $unformatted_amount = $amount;
317 317
     $negative           = $amount < 0;
318
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
319
-    $amount             = wpinv_format_amount( $amount );
318
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
319
+    $amount             = wpinv_format_amount($amount);
320 320
 
321 321
     // Format the amount.
322 322
     $format             = getpaid_get_price_format();
323
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
323
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
324 324
 
325 325
     // Filter the formatting.
326
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
326
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
327 327
 }
328 328
 
329 329
 /**
@@ -334,25 +334,25 @@  discard block
 block discarded – undo
334 334
  * @param  bool     $calculate Whether or not to apply separators.
335 335
  * @return string
336 336
  */
337
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
337
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
338 338
     $thousands_sep = wpinv_thousands_separator();
339 339
     $decimal_sep   = wpinv_decimal_separator();
340
-    $decimals      = wpinv_decimals( $decimals );
341
-    $amount        = wpinv_sanitize_amount( $amount );
340
+    $decimals      = wpinv_decimals($decimals);
341
+    $amount        = wpinv_sanitize_amount($amount);
342 342
 
343
-    if ( $calculate ) {
343
+    if ($calculate) {
344 344
         return $amount;
345 345
     }
346 346
 
347 347
     // Fomart the amount.
348
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
348
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
349 349
 }
350 350
 
351
-function wpinv_sanitize_key( $key ) {
351
+function wpinv_sanitize_key($key) {
352 352
     $raw_key = $key;
353
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
353
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
354 354
 
355
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
355
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
356 356
 }
357 357
 
358 358
 /**
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
  * 
361 361
  * @param $str the file whose extension should be retrieved.
362 362
  */
363
-function wpinv_get_file_extension( $str ) {
364
-    $filetype = wp_check_filetype( $str );
363
+function wpinv_get_file_extension($str) {
364
+    $filetype = wp_check_filetype($str);
365 365
     return $filetype['ext'];
366 366
 }
367 367
 
@@ -370,16 +370,16 @@  discard block
 block discarded – undo
370 370
  * 
371 371
  * @param string $string
372 372
  */
373
-function wpinv_string_is_image_url( $string ) {
374
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
375
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
373
+function wpinv_string_is_image_url($string) {
374
+    $extension = strtolower(wpinv_get_file_extension($string));
375
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
376 376
 }
377 377
 
378 378
 /**
379 379
  * Returns the current URL.
380 380
  */
381 381
 function wpinv_get_current_page_url() {
382
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
382
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
383 383
 }
384 384
 
385 385
 /**
@@ -389,46 +389,46 @@  discard block
 block discarded – undo
389 389
  * @param string $name  Constant name.
390 390
  * @param mixed  $value Value.
391 391
  */
392
-function getpaid_maybe_define_constant( $name, $value ) {
393
-	if ( ! defined( $name ) ) {
394
-		define( $name, $value );
392
+function getpaid_maybe_define_constant($name, $value) {
393
+	if (!defined($name)) {
394
+		define($name, $value);
395 395
 	}
396 396
 }
397 397
 
398 398
 function wpinv_get_php_arg_separator_output() {
399
-	return ini_get( 'arg_separator.output' );
399
+	return ini_get('arg_separator.output');
400 400
 }
401 401
 
402
-function wpinv_rgb_from_hex( $color ) {
403
-    $color = str_replace( '#', '', $color );
402
+function wpinv_rgb_from_hex($color) {
403
+    $color = str_replace('#', '', $color);
404 404
 
405 405
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
406
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
407
-    if ( empty( $color ) ) {
406
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
407
+    if (empty($color)) {
408 408
         return NULL;
409 409
     }
410 410
 
411
-    $color = str_split( $color );
411
+    $color = str_split($color);
412 412
 
413 413
     $rgb      = array();
414
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
415
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
416
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
414
+    $rgb['R'] = hexdec($color[0] . $color[1]);
415
+    $rgb['G'] = hexdec($color[2] . $color[3]);
416
+    $rgb['B'] = hexdec($color[4] . $color[5]);
417 417
 
418 418
     return $rgb;
419 419
 }
420 420
 
421
-function wpinv_hex_darker( $color, $factor = 30 ) {
422
-    $base  = wpinv_rgb_from_hex( $color );
421
+function wpinv_hex_darker($color, $factor = 30) {
422
+    $base  = wpinv_rgb_from_hex($color);
423 423
     $color = '#';
424 424
 
425
-    foreach ( $base as $k => $v ) {
425
+    foreach ($base as $k => $v) {
426 426
         $amount      = $v / 100;
427
-        $amount      = round( $amount * $factor );
427
+        $amount      = round($amount * $factor);
428 428
         $new_decimal = $v - $amount;
429 429
 
430
-        $new_hex_component = dechex( $new_decimal );
431
-        if ( strlen( $new_hex_component ) < 2 ) {
430
+        $new_hex_component = dechex($new_decimal);
431
+        if (strlen($new_hex_component) < 2) {
432 432
             $new_hex_component = "0" . $new_hex_component;
433 433
         }
434 434
         $color .= $new_hex_component;
@@ -437,18 +437,18 @@  discard block
 block discarded – undo
437 437
     return $color;
438 438
 }
439 439
 
440
-function wpinv_hex_lighter( $color, $factor = 30 ) {
441
-    $base  = wpinv_rgb_from_hex( $color );
440
+function wpinv_hex_lighter($color, $factor = 30) {
441
+    $base  = wpinv_rgb_from_hex($color);
442 442
     $color = '#';
443 443
 
444
-    foreach ( $base as $k => $v ) {
444
+    foreach ($base as $k => $v) {
445 445
         $amount      = 255 - $v;
446 446
         $amount      = $amount / 100;
447
-        $amount      = round( $amount * $factor );
447
+        $amount      = round($amount * $factor);
448 448
         $new_decimal = $v + $amount;
449 449
 
450
-        $new_hex_component = dechex( $new_decimal );
451
-        if ( strlen( $new_hex_component ) < 2 ) {
450
+        $new_hex_component = dechex($new_decimal);
451
+        if (strlen($new_hex_component) < 2) {
452 452
             $new_hex_component = "0" . $new_hex_component;
453 453
         }
454 454
         $color .= $new_hex_component;
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
     return $color;
458 458
 }
459 459
 
460
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
461
-    $hex = str_replace( '#', '', $color );
460
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
461
+    $hex = str_replace('#', '', $color);
462 462
 
463
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
464
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
465
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
463
+    $c_r = hexdec(substr($hex, 0, 2));
464
+    $c_g = hexdec(substr($hex, 2, 2));
465
+    $c_b = hexdec(substr($hex, 4, 2));
466 466
 
467
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
467
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
468 468
 
469 469
     return $brightness > 155 ? $dark : $light;
470 470
 }
471 471
 
472
-function wpinv_format_hex( $hex ) {
473
-    $hex = trim( str_replace( '#', '', $hex ) );
472
+function wpinv_format_hex($hex) {
473
+    $hex = trim(str_replace('#', '', $hex));
474 474
 
475
-    if ( strlen( $hex ) == 3 ) {
475
+    if (strlen($hex) == 3) {
476 476
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
477 477
     }
478 478
 
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
493 493
  * @return string
494 494
  */
495
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
496
-    if ( function_exists( 'mb_strimwidth' ) ) {
497
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
495
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
496
+    if (function_exists('mb_strimwidth')) {
497
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
498 498
     }
499 499
     
500
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
500
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
501 501
 }
502 502
 
503 503
 /**
@@ -509,28 +509,28 @@  discard block
 block discarded – undo
509 509
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
510 510
  * @return int Returns the number of characters in string.
511 511
  */
512
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
513
-    if ( function_exists( 'mb_strlen' ) ) {
514
-        return mb_strlen( $str, $encoding );
512
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
513
+    if (function_exists('mb_strlen')) {
514
+        return mb_strlen($str, $encoding);
515 515
     }
516 516
         
517
-    return strlen( $str );
517
+    return strlen($str);
518 518
 }
519 519
 
520
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
521
-    if ( function_exists( 'mb_strtolower' ) ) {
522
-        return mb_strtolower( $str, $encoding );
520
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
521
+    if (function_exists('mb_strtolower')) {
522
+        return mb_strtolower($str, $encoding);
523 523
     }
524 524
     
525
-    return strtolower( $str );
525
+    return strtolower($str);
526 526
 }
527 527
 
528
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
529
-    if ( function_exists( 'mb_strtoupper' ) ) {
530
-        return mb_strtoupper( $str, $encoding );
528
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
529
+    if (function_exists('mb_strtoupper')) {
530
+        return mb_strtoupper($str, $encoding);
531 531
     }
532 532
     
533
-    return strtoupper( $str );
533
+    return strtoupper($str);
534 534
 }
535 535
 
536 536
 /**
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
545 545
  * @return int Returns the position of the first occurrence of search in the string.
546 546
  */
547
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
548
-    if ( function_exists( 'mb_strpos' ) ) {
549
-        return mb_strpos( $str, $find, $offset, $encoding );
547
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
548
+    if (function_exists('mb_strpos')) {
549
+        return mb_strpos($str, $find, $offset, $encoding);
550 550
     }
551 551
         
552
-    return strpos( $str, $find, $offset );
552
+    return strpos($str, $find, $offset);
553 553
 }
554 554
 
555 555
 /**
@@ -563,12 +563,12 @@  discard block
 block discarded – undo
563 563
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
564 564
  * @return int Returns the position of the last occurrence of search.
565 565
  */
566
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
567
-    if ( function_exists( 'mb_strrpos' ) ) {
568
-        return mb_strrpos( $str, $find, $offset, $encoding );
566
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
567
+    if (function_exists('mb_strrpos')) {
568
+        return mb_strrpos($str, $find, $offset, $encoding);
569 569
     }
570 570
         
571
-    return strrpos( $str, $find, $offset );
571
+    return strrpos($str, $find, $offset);
572 572
 }
573 573
 
574 574
 /**
@@ -583,16 +583,16 @@  discard block
 block discarded – undo
583 583
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
584 584
  * @return string
585 585
  */
586
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
587
-    if ( function_exists( 'mb_substr' ) ) {
588
-        if ( $length === null ) {
589
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
586
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
587
+    if (function_exists('mb_substr')) {
588
+        if ($length === null) {
589
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
590 590
         } else {
591
-            return mb_substr( $str, $start, $length, $encoding );
591
+            return mb_substr($str, $start, $length, $encoding);
592 592
         }
593 593
     }
594 594
         
595
-    return substr( $str, $start, $length );
595
+    return substr($str, $start, $length);
596 596
 }
597 597
 
598 598
 /**
@@ -604,48 +604,48 @@  discard block
 block discarded – undo
604 604
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
605 605
  * @return string The width of string.
606 606
  */
607
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
608
-    if ( function_exists( 'mb_strwidth' ) ) {
609
-        return mb_strwidth( $str, $encoding );
607
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
608
+    if (function_exists('mb_strwidth')) {
609
+        return mb_strwidth($str, $encoding);
610 610
     }
611 611
     
612
-    return wpinv_utf8_strlen( $str, $encoding );
612
+    return wpinv_utf8_strlen($str, $encoding);
613 613
 }
614 614
 
615
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
616
-    if ( function_exists( 'mb_strlen' ) ) {
617
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
615
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
616
+    if (function_exists('mb_strlen')) {
617
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
618 618
         $str_end = "";
619 619
         
620
-        if ( $lower_str_end ) {
621
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
620
+        if ($lower_str_end) {
621
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
622 622
         } else {
623
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
623
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
624 624
         }
625 625
 
626 626
         return $first_letter . $str_end;
627 627
     }
628 628
     
629
-    return ucfirst( $str );
629
+    return ucfirst($str);
630 630
 }
631 631
 
632
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
633
-    if ( function_exists( 'mb_convert_case' ) ) {
634
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
632
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
633
+    if (function_exists('mb_convert_case')) {
634
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
635 635
     }
636 636
     
637
-    return ucwords( $str );
637
+    return ucwords($str);
638 638
 }
639 639
 
640
-function wpinv_period_in_days( $period, $unit ) {
641
-    $period = absint( $period );
640
+function wpinv_period_in_days($period, $unit) {
641
+    $period = absint($period);
642 642
     
643
-    if ( $period > 0 ) {
644
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
643
+    if ($period > 0) {
644
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
645 645
             $period = $period * 7;
646
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
646
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
647 647
             $period = $period * 30;
648
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
648
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
649 649
             $period = $period * 365;
650 650
         }
651 651
     }
@@ -653,14 +653,14 @@  discard block
 block discarded – undo
653 653
     return $period;
654 654
 }
655 655
 
656
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
657
-    if ( function_exists( 'cal_days_in_month' ) ) {
658
-        return cal_days_in_month( $calendar, $month, $year );
656
+function wpinv_cal_days_in_month($calendar, $month, $year) {
657
+    if (function_exists('cal_days_in_month')) {
658
+        return cal_days_in_month($calendar, $month, $year);
659 659
     }
660 660
 
661 661
     // Fallback in case the calendar extension is not loaded in PHP
662 662
     // Only supports Gregorian calendar
663
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
663
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
664 664
 }
665 665
 
666 666
 /**
@@ -671,15 +671,15 @@  discard block
 block discarded – undo
671 671
  *
672 672
  * @return string
673 673
  */
674
-function wpi_help_tip( $tip, $allow_html = false, $is_vue = false ) {
674
+function wpi_help_tip($tip, $allow_html = false, $is_vue = false) {
675 675
 
676
-    if ( $allow_html ) {
677
-        $tip = wpi_sanitize_tooltip( $tip );
676
+    if ($allow_html) {
677
+        $tip = wpi_sanitize_tooltip($tip);
678 678
     } else {
679
-        $tip = esc_attr( $tip );
679
+        $tip = esc_attr($tip);
680 680
     }
681 681
 
682
-    if ( $is_vue ) {
682
+    if ($is_vue) {
683 683
         return '<span class="dashicons dashicons-editor-help" title="' . $tip . '"></span>';
684 684
     }
685 685
 
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
  * @param string $var
695 695
  * @return string
696 696
  */
697
-function wpi_sanitize_tooltip( $var ) {
698
-    return wp_kses( html_entity_decode( $var ), array(
697
+function wpi_sanitize_tooltip($var) {
698
+    return wp_kses(html_entity_decode($var), array(
699 699
         'br'     => array(),
700 700
         'em'     => array(),
701 701
         'strong' => array(),
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
         'li'     => array(),
707 707
         'ol'     => array(),
708 708
         'p'      => array(),
709
-    ) );
709
+    ));
710 710
 }
711 711
 
712 712
 /**
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
  */
717 717
 function wpinv_get_screen_ids() {
718 718
 
719
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
719
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
720 720
 
721 721
     $screen_ids = array(
722 722
         'toplevel_page_' . $screen_id,
@@ -735,10 +735,10 @@  discard block
 block discarded – undo
735 735
         'getpaid_page_wpinv-reports',
736 736
         'getpaid_page_wpi-addons',
737 737
         'getpaid_page_wpinv-customers',
738
-        'gp-setup',// setup wizard
738
+        'gp-setup', // setup wizard
739 739
     );
740 740
 
741
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
741
+    return apply_filters('wpinv_screen_ids', $screen_ids);
742 742
 }
743 743
 
744 744
 /**
@@ -749,14 +749,14 @@  discard block
 block discarded – undo
749 749
  * @param array|string $list List of values.
750 750
  * @return array Sanitized array of values.
751 751
  */
752
-function wpinv_parse_list( $list ) {
752
+function wpinv_parse_list($list) {
753 753
 
754
-    if ( empty( $list ) ) {
754
+    if (empty($list)) {
755 755
         $list = array();
756 756
     }
757 757
 
758
-	if ( ! is_array( $list ) ) {
759
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
758
+	if (!is_array($list)) {
759
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
760 760
 	}
761 761
 
762 762
 	return $list;
@@ -770,16 +770,16 @@  discard block
 block discarded – undo
770 770
  * @param string $key Type of data to fetch.
771 771
  * @return mixed Fetched data.
772 772
  */
773
-function wpinv_get_data( $key ) {
773
+function wpinv_get_data($key) {
774 774
 
775 775
     // Try fetching it from the cache.
776
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
777
-    if( $data ) {
776
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
777
+    if ($data) {
778 778
         return $data;
779 779
     }
780 780
 
781
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
782
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
781
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
782
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
783 783
 
784 784
 	return $data;
785 785
 }
@@ -793,10 +793,10 @@  discard block
 block discarded – undo
793 793
  * @param bool $first_empty Whether or not the first item in the list should be empty
794 794
  * @return mixed Fetched data.
795 795
  */
796
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
796
+function wpinv_maybe_add_empty_option($options, $first_empty) {
797 797
 
798
-    if ( ! empty( $options ) && $first_empty ) {
799
-        return array_merge( array( '' => '' ), $options );
798
+    if (!empty($options) && $first_empty) {
799
+        return array_merge(array('' => ''), $options);
800 800
     }
801 801
     return $options;
802 802
 
@@ -808,21 +808,21 @@  discard block
 block discarded – undo
808 808
  * @param mixed $var Data to sanitize.
809 809
  * @return string|array
810 810
  */
811
-function wpinv_clean( $var ) {
811
+function wpinv_clean($var) {
812 812
 
813
-	if ( is_array( $var ) ) {
814
-		return array_map( 'wpinv_clean', $var );
813
+	if (is_array($var)) {
814
+		return array_map('wpinv_clean', $var);
815 815
     }
816 816
 
817
-    if ( is_object( $var ) ) {
818
-		$object_vars = get_object_vars( $var );
819
-		foreach ( $object_vars as $property_name => $property_value ) {
820
-			$var->$property_name = wpinv_clean( $property_value );
817
+    if (is_object($var)) {
818
+		$object_vars = get_object_vars($var);
819
+		foreach ($object_vars as $property_name => $property_value) {
820
+			$var->$property_name = wpinv_clean($property_value);
821 821
         }
822 822
         return $var;
823 823
 	}
824 824
 
825
-    return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
825
+    return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var;
826 826
 }
827 827
 
828 828
 /**
@@ -831,43 +831,43 @@  discard block
 block discarded – undo
831 831
  * @param string $str Data to convert.
832 832
  * @return string|array
833 833
  */
834
-function getpaid_convert_price_string_to_options( $str ) {
834
+function getpaid_convert_price_string_to_options($str) {
835 835
 
836
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
837
-    $options     = array();
836
+	$raw_options = array_map('trim', explode(',', $str));
837
+    $options = array();
838 838
 
839
-    foreach ( $raw_options as $option ) {
839
+    foreach ($raw_options as $option) {
840 840
 
841
-        if ( '' == $option ) {
841
+        if ('' == $option) {
842 842
             continue;
843 843
         }
844 844
 
845
-        $option = array_map( 'trim', explode( '|', $option ) );
845
+        $option = array_map('trim', explode('|', $option));
846 846
 
847 847
         $price = null;
848 848
         $label = null;
849 849
 
850
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
851
-            $label  = $option[0];
850
+        if (isset($option[0]) && '' != $option[0]) {
851
+            $label = $option[0];
852 852
         }
853 853
 
854
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
854
+        if (isset($option[1]) && '' != $option[1]) {
855 855
             $price = $option[1];
856 856
         }
857 857
 
858
-        if ( ! isset( $price ) ) {
858
+        if (!isset($price)) {
859 859
             $price = $label;
860 860
         }
861 861
 
862
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
862
+        if (!isset($price) || !is_numeric($price)) {
863 863
             continue;
864 864
         }
865 865
 
866
-        if ( ! isset( $label ) ) {
866
+        if (!isset($label)) {
867 867
             $label = $price;
868 868
         }
869 869
 
870
-        $options[ "$label|$price" ] = $label;
870
+        $options["$label|$price"] = $label;
871 871
     }
872 872
 
873 873
     return $options;
@@ -876,27 +876,27 @@  discard block
 block discarded – undo
876 876
 /**
877 877
  * Returns the help tip.
878 878
  */
879
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
880
-    $additional_classes = sanitize_html_class( $additional_classes );
881
-    $tip                = esc_attr__( $tip );
879
+function getpaid_get_help_tip($tip, $additional_classes = '') {
880
+    $additional_classes = sanitize_html_class($additional_classes);
881
+    $tip                = esc_attr__($tip);
882 882
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
883 883
 }
884 884
 
885 885
 /**
886 886
  * Formats a date
887 887
  */
888
-function getpaid_format_date( $date, $with_time = false ) {
888
+function getpaid_format_date($date, $with_time = false) {
889 889
 
890
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
890
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
891 891
         return '';
892 892
     }
893 893
 
894 894
     $format = getpaid_date_format();
895 895
 
896
-    if ( $with_time ) {
896
+    if ($with_time) {
897 897
         $format .= ' ' . getpaid_time_format();
898 898
     }
899
-    return date_i18n( $format, strtotime( $date ) );
899
+    return date_i18n($format, strtotime($date));
900 900
 
901 901
 }
902 902
 
@@ -905,9 +905,9 @@  discard block
 block discarded – undo
905 905
  *
906 906
  * @return string
907 907
  */
908
-function getpaid_format_date_value( $date, $default = "&mdash;", $with_time = false ) {
909
-    $date = getpaid_format_date( $date, $with_time );
910
-    return empty( $date ) ? $default : $date;
908
+function getpaid_format_date_value($date, $default = "&mdash;", $with_time = false) {
909
+    $date = getpaid_format_date($date, $with_time);
910
+    return empty($date) ? $default : $date;
911 911
 }
912 912
 
913 913
 /**
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
  * @return string
917 917
  */
918 918
 function getpaid_date_format() {
919
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
919
+	return apply_filters('getpaid_date_format', get_option('date_format'));
920 920
 }
921 921
 
922 922
 /**
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
  * @return string
926 926
  */
927 927
 function getpaid_time_format() {
928
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
928
+	return apply_filters('getpaid_time_format', get_option('time_format'));
929 929
 }
930 930
 
931 931
 /**
@@ -935,16 +935,16 @@  discard block
 block discarded – undo
935 935
  * @param  integer $limit Limit size in characters.
936 936
  * @return string
937 937
  */
938
-function getpaid_limit_length( $string, $limit ) {
938
+function getpaid_limit_length($string, $limit) {
939 939
     $str_limit = $limit - 3;
940 940
 
941
-	if ( function_exists( 'mb_strimwidth' ) ) {
942
-		if ( mb_strlen( $string ) > $limit ) {
943
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
941
+	if (function_exists('mb_strimwidth')) {
942
+		if (mb_strlen($string) > $limit) {
943
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
944 944
 		}
945 945
 	} else {
946
-		if ( strlen( $string ) > $limit ) {
947
-			$string = substr( $string, 0, $str_limit ) . '...';
946
+		if (strlen($string) > $limit) {
947
+			$string = substr($string, 0, $str_limit) . '...';
948 948
 		}
949 949
 	}
950 950
     return $string;
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
  * @since 1.0.19
959 959
  */
960 960
 function getpaid_api() {
961
-    return getpaid()->get( 'api' );
961
+    return getpaid()->get('api');
962 962
 }
963 963
 
964 964
 /**
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
  * @since 1.0.19
969 969
  */
970 970
 function getpaid_post_types() {
971
-    return getpaid()->get( 'post_types' );
971
+    return getpaid()->get('post_types');
972 972
 }
973 973
 
974 974
 /**
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
  * @since 1.0.19
979 979
  */
980 980
 function getpaid_session() {
981
-    return getpaid()->get( 'session' );
981
+    return getpaid()->get('session');
982 982
 }
983 983
 
984 984
 /**
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
  * @since 1.0.19
989 989
  */
990 990
 function getpaid_notes() {
991
-    return getpaid()->get( 'notes' );
991
+    return getpaid()->get('notes');
992 992
 }
993 993
 
994 994
 /**
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
  * @return GetPaid_Admin
998 998
  */
999 999
 function getpaid_admin() {
1000
-    return getpaid()->get( 'admin' );
1000
+    return getpaid()->get('admin');
1001 1001
 }
1002 1002
 
1003 1003
 /**
@@ -1007,8 +1007,8 @@  discard block
 block discarded – undo
1007 1007
  * @param string $base the base url
1008 1008
  * @return string
1009 1009
  */
1010
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
1011
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
1010
+function getpaid_get_authenticated_action_url($action, $base = false) {
1011
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
1012 1012
 }
1013 1013
 
1014 1014
 /**
@@ -1016,11 +1016,11 @@  discard block
 block discarded – undo
1016 1016
  *
1017 1017
  * @return string
1018 1018
  */
1019
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
1019
+function getpaid_get_post_type_label($post_type, $plural = true) {
1020 1020
 
1021
-    $post_type = get_post_type_object( $post_type );
1021
+    $post_type = get_post_type_object($post_type);
1022 1022
 
1023
-    if ( ! is_object( $post_type ) ) {
1023
+    if (!is_object($post_type)) {
1024 1024
         return null;
1025 1025
     }
1026 1026
 
@@ -1033,18 +1033,18 @@  discard block
 block discarded – undo
1033 1033
  *
1034 1034
  * @return mixed|null
1035 1035
  */
1036
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1036
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1037 1037
 
1038
-    if ( ! is_array( $array ) ) {
1038
+    if (!is_array($array)) {
1039 1039
         return null;
1040 1040
     }
1041 1041
 
1042
-    if ( ! empty( $secondary_key ) ) {
1043
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1044
-        return getpaid_get_array_field( $array, $key );
1042
+    if (!empty($secondary_key)) {
1043
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1044
+        return getpaid_get_array_field($array, $key);
1045 1045
     }
1046 1046
 
1047
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1047
+    return isset($array[$key]) ? $array[$key] : null;
1048 1048
 
1049 1049
 }
1050 1050
 
@@ -1053,12 +1053,12 @@  discard block
 block discarded – undo
1053 1053
  *
1054 1054
  * @return array
1055 1055
  */
1056
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1056
+function getpaid_array_merge_if_empty($args, $defaults) {
1057 1057
 
1058
-    foreach ( $defaults as $key => $value ) {
1058
+    foreach ($defaults as $key => $value) {
1059 1059
 
1060
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1061
-            $args[ $key ] = $value;
1060
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1061
+            $args[$key] = $value;
1062 1062
         }
1063 1063
 
1064 1064
     }
@@ -1076,12 +1076,12 @@  discard block
 block discarded – undo
1076 1076
 
1077 1077
     $types = get_allowed_mime_types();
1078 1078
 
1079
-    if ( isset( $types['htm|html'] ) ) {
1080
-		unset( $types['htm|html'] );
1079
+    if (isset($types['htm|html'])) {
1080
+		unset($types['htm|html']);
1081 1081
 	}
1082 1082
 
1083
-    if ( isset( $types['js'] ) ) {
1084
-		unset( $types['js'] );
1083
+    if (isset($types['js'])) {
1084
+		unset($types['js']);
1085 1085
 	}
1086 1086
 
1087 1087
     return $types;
@@ -1089,34 +1089,34 @@  discard block
 block discarded – undo
1089 1089
 }
1090 1090
 
1091 1091
 
1092
-function getpaid_user_delete_invoice( $data ) {
1092
+function getpaid_user_delete_invoice($data) {
1093 1093
 
1094 1094
     // Ensure there is an invoice to delete.
1095
-    if ( empty( $data['invoice_id'] ) ) {
1095
+    if (empty($data['invoice_id'])) {
1096 1096
         return;
1097 1097
     }
1098 1098
 
1099
-    $invoice = new WPInv_Invoice( (int) $data['invoice_id'] );
1099
+    $invoice = new WPInv_Invoice((int) $data['invoice_id']);
1100 1100
 
1101 1101
     // Ensure that it exists and that it belongs to the current user.
1102
-    if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) {
1103
-        wpinv_set_error( 'invalid_invoice', __( 'You do not have permission to delete this invoice', 'invoicing' ) );
1102
+    if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) {
1103
+        wpinv_set_error('invalid_invoice', __('You do not have permission to delete this invoice', 'invoicing'));
1104 1104
 
1105 1105
     // Can it be deleted?
1106
-    } else if ( ! $invoice->needs_payment() ) {
1107
-        wpinv_set_error( 'cannot_delete', __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ) );
1106
+    } else if (!$invoice->needs_payment()) {
1107
+        wpinv_set_error('cannot_delete', __('This invoice cannot be deleted as it has already been paid.', 'invoicing'));
1108 1108
 
1109 1109
     // Delete it.
1110 1110
     } else {
1111 1111
 
1112 1112
         $invoice->delete();
1113
-        wpinv_set_error( 'delete', __( 'The invoice has been deleted.', 'invoicing' ), 'info' );
1113
+        wpinv_set_error('delete', __('The invoice has been deleted.', 'invoicing'), 'info');
1114 1114
     }
1115 1115
 
1116
-    $redirect = remove_query_arg( array( 'getpaid-action', 'getpaid-nonce', 'invoice_id' ) );
1116
+    $redirect = remove_query_arg(array('getpaid-action', 'getpaid-nonce', 'invoice_id'));
1117 1117
 
1118
-    wp_safe_redirect( $redirect );
1118
+    wp_safe_redirect($redirect);
1119 1119
     exit;
1120 1120
 
1121 1121
 }
1122
-add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' );
1123 1122
\ No newline at end of file
1123
+add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice');
1124 1124
\ No newline at end of file
Please login to merge, or discard this patch.