Passed
Pull Request — master (#785)
by
unknown
14:17
created
vendor/ayecode/wp-ayecode-ui/includes/class-aui.php 3 patches
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,299 +11,299 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI {
13 13
 
14
-	/**
15
-	 * Holds the class instance.
16
-	 *
17
-	 * @since 1.0.0
18
-	 * @var null
19
-	 */
20
-	private static $instance = null;
21
-
22
-	/**
23
-	 * Holds the current AUI version number.
24
-	 *
25
-	 * @var string $ver The current version number.
26
-	 */
27
-	public static $ver = '0.1.72';
28
-
29
-	public static $options = null;
30
-
31
-	/**
32
-	 * There can be only one.
33
-	 *
34
-	 * @since 1.0.0
35
-	 * @return AUI|null
36
-	 */
37
-	public static function instance() {
38
-		if ( self::$instance == null ) {
39
-			self::$instance = new AUI();
40
-		}
41
-
42
-		return self::$instance;
43
-	}
44
-
45
-	/**
46
-	 * AUI constructor.
47
-	 *
48
-	 * @since 1.0.0
49
-	 */
50
-	private function __construct() {
51
-		if ( function_exists( "__autoload" ) ) {
52
-			spl_autoload_register( "__autoload" );
53
-		}
54
-		spl_autoload_register( array( $this, 'autoload' ) );
55
-
56
-		// load options
57
-		self::$options = get_option('aui_options');
58
-	}
59
-
60
-	/**
61
-	 * Autoload any components on the fly.
62
-	 *
63
-	 * @since 1.0.0
64
-	 *
65
-	 * @param $classname
66
-	 */
67
-	private function autoload( $classname ) {
68
-		$class     = str_replace( '_', '-', strtolower( $classname ) );
69
-		$file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
70
-		if ( $file_path && is_readable( $file_path ) ) {
71
-			include_once( $file_path );
72
-		}
73
-	}
74
-
75
-	/**
76
-	 * Get the AUI options.
77
-	 *
78
-	 * @param $option
79
-	 *
80
-	 * @return string|void
81
-	 */
82
-	public function get_option( $option ){
83
-		$result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : '';
84
-
85
-		if ( ! $result && $option) {
86
-			if( $option == 'color_primary' ){
87
-				$result = AUI_PRIMARY_COLOR;
88
-			}elseif( $option == 'color_secondary' ){
89
-				$result = AUI_SECONDARY_COLOR;
90
-			}
91
-		}
92
-		return $result;
93
-	}
94
-
95
-	public function render( $items = array(), $echo = false ) {
96
-		$output = '';
97
-
98
-		if ( ! empty( $items ) ) {
99
-			foreach ( $items as $args ) {
100
-				$render = isset( $args['render'] ) ? $args['render'] : '';
101
-				if ( $render && method_exists( __CLASS__, $render ) ) {
102
-					$output .= $this->$render( $args );
103
-				}
104
-			}
105
-		}
106
-
107
-		if ( $echo ) {
108
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
109
-		}else{
110
-			return $output;
111
-		}
112
-
113
-	}
114
-
115
-	/**
116
-	 * Render and return a bootstrap alert component.
117
-	 *
118
-	 * @since 1.0.0
119
-	 *
120
-	 * @param array $args The function arguments.
121
-	 * @param bool  $echo If we should return or echo.
122
-	 *
123
-	 * @return string The rendered component.
124
-	 */
125
-	public function alert( $args = array(), $echo = false ) {
126
-		$output = AUI_Component_Alert::get( $args );
127
-
128
-		if ( $echo ) {
129
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
130
-		}else{
131
-			return $output;
132
-		}
133
-	}
134
-
135
-	/**
136
-	 * Render and return a bootstrap input component.
137
-	 *
138
-	 * @since 1.0.0
139
-	 *
140
-	 * @param array $args The function arguments.
141
-	 * @param bool  $echo If we should return or echo.
142
-	 *
143
-	 * @return string The rendered component.
144
-	 */
145
-	public function input( $args = array(), $echo = false ) {
146
-		$output = AUI_Component_Input::input( $args );
147
-
148
-		if ( $echo ) {
149
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
150
-		}else{
151
-			return $output;
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * Render and return a bootstrap textarea component.
157
-	 *
158
-	 * @since 1.0.0
159
-	 *
160
-	 * @param array $args The function arguments.
161
-	 * @param bool  $echo If we should return or echo.
162
-	 *
163
-	 * @return string The rendered component.
164
-	 */
165
-	public function textarea( $args = array(), $echo = false ) {
166
-		$output = AUI_Component_Input::textarea( $args );
167
-
168
-		if ( $echo ) {
169
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
170
-		}else{
171
-			return $output;
172
-		}
173
-	}
174
-
175
-	/**
176
-	 * Render and return a bootstrap button component.
177
-	 *
178
-	 * @since 1.0.0
179
-	 *
180
-	 * @param array $args The function arguments.
181
-	 * @param bool  $echo If we should return or echo.
182
-	 *
183
-	 * @return string The rendered component.
184
-	 */
185
-	public function button( $args = array(), $echo = false ) {
186
-		$output = AUI_Component_Button::get( $args );
187
-
188
-		if ( $echo ) {
189
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
190
-		}else{
191
-			return $output;
192
-		}
193
-	}
194
-
195
-	/**
196
-	 * Render and return a bootstrap button component.
197
-	 *
198
-	 * @since 1.0.0
199
-	 *
200
-	 * @param array $args The function arguments.
201
-	 * @param bool  $echo If we should return or echo.
202
-	 *
203
-	 * @return string The rendered component.
204
-	 */
205
-	public function badge( $args = array(), $echo = false ) {
206
-		$defaults = array(
207
-			'class' => 'badge badge-primary align-middle',
208
-		);
209
-
210
-		// maybe set type.
211
-		if ( empty( $args['href'] ) ) {
212
-			$defaults['type'] = 'badge';
213
-		}
214
-
215
-		/**
216
-		 * Parse incoming $args into an array and merge it with $defaults
217
-		 */
218
-		$args = wp_parse_args( $args, $defaults );
219
-
220
-		$output = AUI_Component_Button::get( $args );
221
-
222
-		if ( $echo ) {
223
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
224
-		}else{
225
-			return $output;
226
-		}
227
-	}
228
-
229
-	/**
230
-	 * Render and return a bootstrap dropdown component.
231
-	 *
232
-	 * @since 1.0.0
233
-	 *
234
-	 * @param array $args The function arguments.
235
-	 * @param bool  $echo If we should return or echo.
236
-	 *
237
-	 * @return string The rendered component.
238
-	 */
239
-	public function dropdown( $args = array(), $echo = false ) {
240
-		$output = AUI_Component_Dropdown::get( $args );
241
-
242
-		if ( $echo ) {
243
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
244
-		}else{
245
-			return $output;
246
-		}
247
-	}
248
-
249
-	/**
250
-	 * Render and return a bootstrap select component.
251
-	 *
252
-	 * @since 1.0.0
253
-	 *
254
-	 * @param array $args The function arguments.
255
-	 * @param bool  $echo If we should return or echo.
256
-	 *
257
-	 * @return string The rendered component.
258
-	 */
259
-	public function select( $args = array(), $echo = false ) {
260
-		$output = AUI_Component_Input::select( $args );
261
-
262
-		if ( $echo ) {
263
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
264
-		}else{
265
-			return $output;
266
-		}
267
-	}
268
-
269
-	/**
270
-	 * Render and return a bootstrap radio component.
271
-	 *
272
-	 * @since 1.0.0
273
-	 *
274
-	 * @param array $args The function arguments.
275
-	 * @param bool  $echo If we should return or echo.
276
-	 *
277
-	 * @return string The rendered component.
278
-	 */
279
-	public function radio( $args = array(), $echo = false ) {
280
-		$output = AUI_Component_Input::radio( $args );
281
-
282
-		if ( $echo ) {
283
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
284
-		}else{
285
-			return $output;
286
-		}
287
-	}
288
-
289
-	/**
290
-	 * Render and return a bootstrap pagination component.
291
-	 *
292
-	 * @since 1.0.0
293
-	 *
294
-	 * @param array $args The function arguments.
295
-	 * @param bool  $echo If we should return or echo.
296
-	 *
297
-	 * @return string The rendered component.
298
-	 */
299
-	public function pagination( $args = array(), $echo = false ) {
300
-		$output = AUI_Component_Pagination::get( $args );
301
-
302
-		if ( $echo ) {
303
-			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
304
-		}else{
305
-			return $output;
306
-		}
307
-	}
14
+    /**
15
+     * Holds the class instance.
16
+     *
17
+     * @since 1.0.0
18
+     * @var null
19
+     */
20
+    private static $instance = null;
21
+
22
+    /**
23
+     * Holds the current AUI version number.
24
+     *
25
+     * @var string $ver The current version number.
26
+     */
27
+    public static $ver = '0.1.72';
28
+
29
+    public static $options = null;
30
+
31
+    /**
32
+     * There can be only one.
33
+     *
34
+     * @since 1.0.0
35
+     * @return AUI|null
36
+     */
37
+    public static function instance() {
38
+        if ( self::$instance == null ) {
39
+            self::$instance = new AUI();
40
+        }
41
+
42
+        return self::$instance;
43
+    }
44
+
45
+    /**
46
+     * AUI constructor.
47
+     *
48
+     * @since 1.0.0
49
+     */
50
+    private function __construct() {
51
+        if ( function_exists( "__autoload" ) ) {
52
+            spl_autoload_register( "__autoload" );
53
+        }
54
+        spl_autoload_register( array( $this, 'autoload' ) );
55
+
56
+        // load options
57
+        self::$options = get_option('aui_options');
58
+    }
59
+
60
+    /**
61
+     * Autoload any components on the fly.
62
+     *
63
+     * @since 1.0.0
64
+     *
65
+     * @param $classname
66
+     */
67
+    private function autoload( $classname ) {
68
+        $class     = str_replace( '_', '-', strtolower( $classname ) );
69
+        $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
70
+        if ( $file_path && is_readable( $file_path ) ) {
71
+            include_once( $file_path );
72
+        }
73
+    }
74
+
75
+    /**
76
+     * Get the AUI options.
77
+     *
78
+     * @param $option
79
+     *
80
+     * @return string|void
81
+     */
82
+    public function get_option( $option ){
83
+        $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : '';
84
+
85
+        if ( ! $result && $option) {
86
+            if( $option == 'color_primary' ){
87
+                $result = AUI_PRIMARY_COLOR;
88
+            }elseif( $option == 'color_secondary' ){
89
+                $result = AUI_SECONDARY_COLOR;
90
+            }
91
+        }
92
+        return $result;
93
+    }
94
+
95
+    public function render( $items = array(), $echo = false ) {
96
+        $output = '';
97
+
98
+        if ( ! empty( $items ) ) {
99
+            foreach ( $items as $args ) {
100
+                $render = isset( $args['render'] ) ? $args['render'] : '';
101
+                if ( $render && method_exists( __CLASS__, $render ) ) {
102
+                    $output .= $this->$render( $args );
103
+                }
104
+            }
105
+        }
106
+
107
+        if ( $echo ) {
108
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
109
+        }else{
110
+            return $output;
111
+        }
112
+
113
+    }
114
+
115
+    /**
116
+     * Render and return a bootstrap alert component.
117
+     *
118
+     * @since 1.0.0
119
+     *
120
+     * @param array $args The function arguments.
121
+     * @param bool  $echo If we should return or echo.
122
+     *
123
+     * @return string The rendered component.
124
+     */
125
+    public function alert( $args = array(), $echo = false ) {
126
+        $output = AUI_Component_Alert::get( $args );
127
+
128
+        if ( $echo ) {
129
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
130
+        }else{
131
+            return $output;
132
+        }
133
+    }
134
+
135
+    /**
136
+     * Render and return a bootstrap input component.
137
+     *
138
+     * @since 1.0.0
139
+     *
140
+     * @param array $args The function arguments.
141
+     * @param bool  $echo If we should return or echo.
142
+     *
143
+     * @return string The rendered component.
144
+     */
145
+    public function input( $args = array(), $echo = false ) {
146
+        $output = AUI_Component_Input::input( $args );
147
+
148
+        if ( $echo ) {
149
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
150
+        }else{
151
+            return $output;
152
+        }
153
+    }
154
+
155
+    /**
156
+     * Render and return a bootstrap textarea component.
157
+     *
158
+     * @since 1.0.0
159
+     *
160
+     * @param array $args The function arguments.
161
+     * @param bool  $echo If we should return or echo.
162
+     *
163
+     * @return string The rendered component.
164
+     */
165
+    public function textarea( $args = array(), $echo = false ) {
166
+        $output = AUI_Component_Input::textarea( $args );
167
+
168
+        if ( $echo ) {
169
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
170
+        }else{
171
+            return $output;
172
+        }
173
+    }
174
+
175
+    /**
176
+     * Render and return a bootstrap button component.
177
+     *
178
+     * @since 1.0.0
179
+     *
180
+     * @param array $args The function arguments.
181
+     * @param bool  $echo If we should return or echo.
182
+     *
183
+     * @return string The rendered component.
184
+     */
185
+    public function button( $args = array(), $echo = false ) {
186
+        $output = AUI_Component_Button::get( $args );
187
+
188
+        if ( $echo ) {
189
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
190
+        }else{
191
+            return $output;
192
+        }
193
+    }
194
+
195
+    /**
196
+     * Render and return a bootstrap button component.
197
+     *
198
+     * @since 1.0.0
199
+     *
200
+     * @param array $args The function arguments.
201
+     * @param bool  $echo If we should return or echo.
202
+     *
203
+     * @return string The rendered component.
204
+     */
205
+    public function badge( $args = array(), $echo = false ) {
206
+        $defaults = array(
207
+            'class' => 'badge badge-primary align-middle',
208
+        );
209
+
210
+        // maybe set type.
211
+        if ( empty( $args['href'] ) ) {
212
+            $defaults['type'] = 'badge';
213
+        }
214
+
215
+        /**
216
+         * Parse incoming $args into an array and merge it with $defaults
217
+         */
218
+        $args = wp_parse_args( $args, $defaults );
219
+
220
+        $output = AUI_Component_Button::get( $args );
221
+
222
+        if ( $echo ) {
223
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
224
+        }else{
225
+            return $output;
226
+        }
227
+    }
228
+
229
+    /**
230
+     * Render and return a bootstrap dropdown component.
231
+     *
232
+     * @since 1.0.0
233
+     *
234
+     * @param array $args The function arguments.
235
+     * @param bool  $echo If we should return or echo.
236
+     *
237
+     * @return string The rendered component.
238
+     */
239
+    public function dropdown( $args = array(), $echo = false ) {
240
+        $output = AUI_Component_Dropdown::get( $args );
241
+
242
+        if ( $echo ) {
243
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
244
+        }else{
245
+            return $output;
246
+        }
247
+    }
248
+
249
+    /**
250
+     * Render and return a bootstrap select component.
251
+     *
252
+     * @since 1.0.0
253
+     *
254
+     * @param array $args The function arguments.
255
+     * @param bool  $echo If we should return or echo.
256
+     *
257
+     * @return string The rendered component.
258
+     */
259
+    public function select( $args = array(), $echo = false ) {
260
+        $output = AUI_Component_Input::select( $args );
261
+
262
+        if ( $echo ) {
263
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
264
+        }else{
265
+            return $output;
266
+        }
267
+    }
268
+
269
+    /**
270
+     * Render and return a bootstrap radio component.
271
+     *
272
+     * @since 1.0.0
273
+     *
274
+     * @param array $args The function arguments.
275
+     * @param bool  $echo If we should return or echo.
276
+     *
277
+     * @return string The rendered component.
278
+     */
279
+    public function radio( $args = array(), $echo = false ) {
280
+        $output = AUI_Component_Input::radio( $args );
281
+
282
+        if ( $echo ) {
283
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
284
+        }else{
285
+            return $output;
286
+        }
287
+    }
288
+
289
+    /**
290
+     * Render and return a bootstrap pagination component.
291
+     *
292
+     * @since 1.0.0
293
+     *
294
+     * @param array $args The function arguments.
295
+     * @param bool  $echo If we should return or echo.
296
+     *
297
+     * @return string The rendered component.
298
+     */
299
+    public function pagination( $args = array(), $echo = false ) {
300
+        $output = AUI_Component_Pagination::get( $args );
301
+
302
+        if ( $echo ) {
303
+            echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
304
+        }else{
305
+            return $output;
306
+        }
307
+    }
308 308
 
309 309
 }
310 310
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @return AUI|null
36 36
 	 */
37 37
 	public static function instance() {
38
-		if ( self::$instance == null ) {
38
+		if (self::$instance == null) {
39 39
 			self::$instance = new AUI();
40 40
 		}
41 41
 
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 	 * @since 1.0.0
49 49
 	 */
50 50
 	private function __construct() {
51
-		if ( function_exists( "__autoload" ) ) {
52
-			spl_autoload_register( "__autoload" );
51
+		if (function_exists("__autoload")) {
52
+			spl_autoload_register("__autoload");
53 53
 		}
54
-		spl_autoload_register( array( $this, 'autoload' ) );
54
+		spl_autoload_register(array($this, 'autoload'));
55 55
 
56 56
 		// load options
57 57
 		self::$options = get_option('aui_options');
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @param $classname
66 66
 	 */
67
-	private function autoload( $classname ) {
68
-		$class     = str_replace( '_', '-', strtolower( $classname ) );
69
-		$file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
70
-		if ( $file_path && is_readable( $file_path ) ) {
71
-			include_once( $file_path );
67
+	private function autoload($classname) {
68
+		$class     = str_replace('_', '-', strtolower($classname));
69
+		$file_path = trailingslashit(dirname(__FILE__)) . "components/class-" . $class . '.php';
70
+		if ($file_path && is_readable($file_path)) {
71
+			include_once($file_path);
72 72
 		}
73 73
 	}
74 74
 
@@ -79,34 +79,34 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @return string|void
81 81
 	 */
82
-	public function get_option( $option ){
82
+	public function get_option($option) {
83 83
 		$result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : '';
84 84
 
85
-		if ( ! $result && $option) {
86
-			if( $option == 'color_primary' ){
85
+		if (!$result && $option) {
86
+			if ($option == 'color_primary') {
87 87
 				$result = AUI_PRIMARY_COLOR;
88
-			}elseif( $option == 'color_secondary' ){
88
+			}elseif ($option == 'color_secondary') {
89 89
 				$result = AUI_SECONDARY_COLOR;
90 90
 			}
91 91
 		}
92 92
 		return $result;
93 93
 	}
94 94
 
95
-	public function render( $items = array(), $echo = false ) {
95
+	public function render($items = array(), $echo = false) {
96 96
 		$output = '';
97 97
 
98
-		if ( ! empty( $items ) ) {
99
-			foreach ( $items as $args ) {
100
-				$render = isset( $args['render'] ) ? $args['render'] : '';
101
-				if ( $render && method_exists( __CLASS__, $render ) ) {
102
-					$output .= $this->$render( $args );
98
+		if (!empty($items)) {
99
+			foreach ($items as $args) {
100
+				$render = isset($args['render']) ? $args['render'] : '';
101
+				if ($render && method_exists(__CLASS__, $render)) {
102
+					$output .= $this->$render($args);
103 103
 				}
104 104
 			}
105 105
 		}
106 106
 
107
-		if ( $echo ) {
107
+		if ($echo) {
108 108
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
109
-		}else{
109
+		} else {
110 110
 			return $output;
111 111
 		}
112 112
 
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return string The rendered component.
124 124
 	 */
125
-	public function alert( $args = array(), $echo = false ) {
126
-		$output = AUI_Component_Alert::get( $args );
125
+	public function alert($args = array(), $echo = false) {
126
+		$output = AUI_Component_Alert::get($args);
127 127
 
128
-		if ( $echo ) {
128
+		if ($echo) {
129 129
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
130
-		}else{
130
+		} else {
131 131
 			return $output;
132 132
 		}
133 133
 	}
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return string The rendered component.
144 144
 	 */
145
-	public function input( $args = array(), $echo = false ) {
146
-		$output = AUI_Component_Input::input( $args );
145
+	public function input($args = array(), $echo = false) {
146
+		$output = AUI_Component_Input::input($args);
147 147
 
148
-		if ( $echo ) {
148
+		if ($echo) {
149 149
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
150
-		}else{
150
+		} else {
151 151
 			return $output;
152 152
 		}
153 153
 	}
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @return string The rendered component.
164 164
 	 */
165
-	public function textarea( $args = array(), $echo = false ) {
166
-		$output = AUI_Component_Input::textarea( $args );
165
+	public function textarea($args = array(), $echo = false) {
166
+		$output = AUI_Component_Input::textarea($args);
167 167
 
168
-		if ( $echo ) {
168
+		if ($echo) {
169 169
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
170
-		}else{
170
+		} else {
171 171
 			return $output;
172 172
 		}
173 173
 	}
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return string The rendered component.
184 184
 	 */
185
-	public function button( $args = array(), $echo = false ) {
186
-		$output = AUI_Component_Button::get( $args );
185
+	public function button($args = array(), $echo = false) {
186
+		$output = AUI_Component_Button::get($args);
187 187
 
188
-		if ( $echo ) {
188
+		if ($echo) {
189 189
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
190
-		}else{
190
+		} else {
191 191
 			return $output;
192 192
 		}
193 193
 	}
@@ -202,26 +202,26 @@  discard block
 block discarded – undo
202 202
 	 *
203 203
 	 * @return string The rendered component.
204 204
 	 */
205
-	public function badge( $args = array(), $echo = false ) {
205
+	public function badge($args = array(), $echo = false) {
206 206
 		$defaults = array(
207 207
 			'class' => 'badge badge-primary align-middle',
208 208
 		);
209 209
 
210 210
 		// maybe set type.
211
-		if ( empty( $args['href'] ) ) {
211
+		if (empty($args['href'])) {
212 212
 			$defaults['type'] = 'badge';
213 213
 		}
214 214
 
215 215
 		/**
216 216
 		 * Parse incoming $args into an array and merge it with $defaults
217 217
 		 */
218
-		$args = wp_parse_args( $args, $defaults );
218
+		$args = wp_parse_args($args, $defaults);
219 219
 
220
-		$output = AUI_Component_Button::get( $args );
220
+		$output = AUI_Component_Button::get($args);
221 221
 
222
-		if ( $echo ) {
222
+		if ($echo) {
223 223
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
224
-		}else{
224
+		} else {
225 225
 			return $output;
226 226
 		}
227 227
 	}
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 	 *
237 237
 	 * @return string The rendered component.
238 238
 	 */
239
-	public function dropdown( $args = array(), $echo = false ) {
240
-		$output = AUI_Component_Dropdown::get( $args );
239
+	public function dropdown($args = array(), $echo = false) {
240
+		$output = AUI_Component_Dropdown::get($args);
241 241
 
242
-		if ( $echo ) {
242
+		if ($echo) {
243 243
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
244
-		}else{
244
+		} else {
245 245
 			return $output;
246 246
 		}
247 247
 	}
@@ -256,12 +256,12 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return string The rendered component.
258 258
 	 */
259
-	public function select( $args = array(), $echo = false ) {
260
-		$output = AUI_Component_Input::select( $args );
259
+	public function select($args = array(), $echo = false) {
260
+		$output = AUI_Component_Input::select($args);
261 261
 
262
-		if ( $echo ) {
262
+		if ($echo) {
263 263
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
264
-		}else{
264
+		} else {
265 265
 			return $output;
266 266
 		}
267 267
 	}
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return string The rendered component.
278 278
 	 */
279
-	public function radio( $args = array(), $echo = false ) {
280
-		$output = AUI_Component_Input::radio( $args );
279
+	public function radio($args = array(), $echo = false) {
280
+		$output = AUI_Component_Input::radio($args);
281 281
 
282
-		if ( $echo ) {
282
+		if ($echo) {
283 283
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
284
-		}else{
284
+		} else {
285 285
 			return $output;
286 286
 		}
287 287
 	}
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
 	 *
297 297
 	 * @return string The rendered component.
298 298
 	 */
299
-	public function pagination( $args = array(), $echo = false ) {
300
-		$output = AUI_Component_Pagination::get( $args );
299
+	public function pagination($args = array(), $echo = false) {
300
+		$output = AUI_Component_Pagination::get($args);
301 301
 
302
-		if ( $echo ) {
302
+		if ($echo) {
303 303
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
304
-		}else{
304
+		} else {
305 305
 			return $output;
306 306
 		}
307 307
 	}
Please login to merge, or discard this patch.
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		if ( ! $result && $option) {
86 86
 			if( $option == 'color_primary' ){
87 87
 				$result = AUI_PRIMARY_COLOR;
88
-			}elseif( $option == 'color_secondary' ){
88
+			} elseif( $option == 'color_secondary' ){
89 89
 				$result = AUI_SECONDARY_COLOR;
90 90
 			}
91 91
 		}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 		if ( $echo ) {
108 108
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
109
-		}else{
109
+		} else{
110 110
 			return $output;
111 111
 		}
112 112
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 
128 128
 		if ( $echo ) {
129 129
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
130
-		}else{
130
+		} else{
131 131
 			return $output;
132 132
 		}
133 133
 	}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
 		if ( $echo ) {
149 149
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
150
-		}else{
150
+		} else{
151 151
 			return $output;
152 152
 		}
153 153
 	}
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 		if ( $echo ) {
169 169
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
170
-		}else{
170
+		} else{
171 171
 			return $output;
172 172
 		}
173 173
 	}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
 		if ( $echo ) {
189 189
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
190
-		}else{
190
+		} else{
191 191
 			return $output;
192 192
 		}
193 193
 	}
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
 		if ( $echo ) {
223 223
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
224
-		}else{
224
+		} else{
225 225
 			return $output;
226 226
 		}
227 227
 	}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
 		if ( $echo ) {
243 243
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
244
-		}else{
244
+		} else{
245 245
 			return $output;
246 246
 		}
247 247
 	}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
 		if ( $echo ) {
263 263
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
264
-		}else{
264
+		} else{
265 265
 			return $output;
266 266
 		}
267 267
 	}
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 		if ( $echo ) {
283 283
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
284
-		}else{
284
+		} else{
285 285
 			return $output;
286 286
 		}
287 287
 	}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
 		if ( $echo ) {
303 303
 			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
304
-		}else{
304
+		} else{
305 305
 			return $output;
306 306
 		}
307 307
 	}
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.2.9";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.2.9";
19
+    if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.2.9";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin-profile.php 3 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -5,126 +5,126 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit; // Exit if accessed directly
8
+    exit; // Exit if accessed directly
9 9
 }
10 10
 
11 11
 if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) :
12 12
 
13
-	/**
14
-	 * GetPaid_Admin_Profile Class.
15
-	 */
16
-	class GetPaid_Admin_Profile {
17
-
18
-		/**
19
-		 * Hook in tabs.
20
-		 */
21
-		public function __construct() {
22
-			add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
-			add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
24
-
25
-			add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
-			add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
27
-		}
28
-
29
-		/**
30
-		 * Get Address Fields for the edit user pages.
31
-		 *
32
-		 * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned
33
-		 */
34
-		public function get_customer_meta_fields() {
35
-
36
-			$show_fields = apply_filters(
37
-				'getpaid_customer_meta_fields',
38
-				array(
39
-					'billing' => array(
40
-						'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
41
-						'fields' => array(
42
-							'_wpinv_first_name' => array(
43
-								'label'       => __( 'First name', 'invoicing' ),
44
-								'description' => '',
45
-							),
46
-							'_wpinv_last_name'  => array(
47
-								'label'       => __( 'Last name', 'invoicing' ),
48
-								'description' => '',
49
-							),
50
-							'_wpinv_company'    => array(
51
-								'label'       => __( 'Company', 'invoicing' ),
52
-								'description' => '',
53
-							),
54
-							'_wpinv_company_id' => array(
55
-								'label'       => __( 'Company ID', 'invoicing' ),
56
-								'description' => '',
57
-							),
58
-							'_wpinv_address'    => array(
59
-								'label'       => __( 'Address', 'invoicing' ),
60
-								'description' => '',
61
-							),
62
-							'_wpinv_city'       => array(
63
-								'label'       => __( 'City', 'invoicing' ),
64
-								'description' => '',
65
-							),
66
-							'_wpinv_zip'        => array(
67
-								'label'       => __( 'Postcode / ZIP', 'invoicing' ),
68
-								'description' => '',
69
-							),
70
-							'_wpinv_country'    => array(
71
-								'label'       => __( 'Country / Region', 'invoicing' ),
72
-								'description' => '',
73
-								'class'       => 'getpaid_js_field-country',
74
-								'type'        => 'select',
75
-								'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
76
-							),
77
-							'_wpinv_state'      => array(
78
-								'label'       => __( 'State / County', 'invoicing' ),
79
-								'description' => __( 'State / County or state code', 'invoicing' ),
80
-								'class'       => 'getpaid_js_field-state regular-text',
81
-							),
82
-							'_wpinv_phone'      => array(
83
-								'label'       => __( 'Phone', 'invoicing' ),
84
-								'description' => '',
85
-							),
86
-							'_wpinv_vat_number' => array(
87
-								'label'       => __( 'VAT Number', 'invoicing' ),
88
-								'description' => '',
89
-							),
90
-						),
91
-					),
92
-				)
93
-			);
94
-			return $show_fields;
95
-		}
96
-
97
-		/**
98
-		 * Show Address Fields on edit user pages.
99
-		 *
100
-		 * @param WP_User $user
101
-		 */
102
-		public function add_customer_meta_fields( $user ) {
103
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
104
-				return;
105
-			}
106
-
107
-			$show_fields = $this->get_customer_meta_fields();
108
-
109
-			$customer = getpaid_get_customer_by_user_id( (int) $user->ID );
110
-
111
-			foreach ( $show_fields as $fieldset_key => $fieldset ) :
112
-				?>
13
+    /**
14
+     * GetPaid_Admin_Profile Class.
15
+     */
16
+    class GetPaid_Admin_Profile {
17
+
18
+        /**
19
+         * Hook in tabs.
20
+         */
21
+        public function __construct() {
22
+            add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
+            add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
24
+
25
+            add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
+            add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
27
+        }
28
+
29
+        /**
30
+         * Get Address Fields for the edit user pages.
31
+         *
32
+         * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned
33
+         */
34
+        public function get_customer_meta_fields() {
35
+
36
+            $show_fields = apply_filters(
37
+                'getpaid_customer_meta_fields',
38
+                array(
39
+                    'billing' => array(
40
+                        'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
41
+                        'fields' => array(
42
+                            '_wpinv_first_name' => array(
43
+                                'label'       => __( 'First name', 'invoicing' ),
44
+                                'description' => '',
45
+                            ),
46
+                            '_wpinv_last_name'  => array(
47
+                                'label'       => __( 'Last name', 'invoicing' ),
48
+                                'description' => '',
49
+                            ),
50
+                            '_wpinv_company'    => array(
51
+                                'label'       => __( 'Company', 'invoicing' ),
52
+                                'description' => '',
53
+                            ),
54
+                            '_wpinv_company_id' => array(
55
+                                'label'       => __( 'Company ID', 'invoicing' ),
56
+                                'description' => '',
57
+                            ),
58
+                            '_wpinv_address'    => array(
59
+                                'label'       => __( 'Address', 'invoicing' ),
60
+                                'description' => '',
61
+                            ),
62
+                            '_wpinv_city'       => array(
63
+                                'label'       => __( 'City', 'invoicing' ),
64
+                                'description' => '',
65
+                            ),
66
+                            '_wpinv_zip'        => array(
67
+                                'label'       => __( 'Postcode / ZIP', 'invoicing' ),
68
+                                'description' => '',
69
+                            ),
70
+                            '_wpinv_country'    => array(
71
+                                'label'       => __( 'Country / Region', 'invoicing' ),
72
+                                'description' => '',
73
+                                'class'       => 'getpaid_js_field-country',
74
+                                'type'        => 'select',
75
+                                'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
76
+                            ),
77
+                            '_wpinv_state'      => array(
78
+                                'label'       => __( 'State / County', 'invoicing' ),
79
+                                'description' => __( 'State / County or state code', 'invoicing' ),
80
+                                'class'       => 'getpaid_js_field-state regular-text',
81
+                            ),
82
+                            '_wpinv_phone'      => array(
83
+                                'label'       => __( 'Phone', 'invoicing' ),
84
+                                'description' => '',
85
+                            ),
86
+                            '_wpinv_vat_number' => array(
87
+                                'label'       => __( 'VAT Number', 'invoicing' ),
88
+                                'description' => '',
89
+                            ),
90
+                        ),
91
+                    ),
92
+                )
93
+            );
94
+            return $show_fields;
95
+        }
96
+
97
+        /**
98
+         * Show Address Fields on edit user pages.
99
+         *
100
+         * @param WP_User $user
101
+         */
102
+        public function add_customer_meta_fields( $user ) {
103
+            if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
104
+                return;
105
+            }
106
+
107
+            $show_fields = $this->get_customer_meta_fields();
108
+
109
+            $customer = getpaid_get_customer_by_user_id( (int) $user->ID );
110
+
111
+            foreach ( $show_fields as $fieldset_key => $fieldset ) :
112
+                ?>
113 113
 				<h2><?php echo esc_html( $fieldset['title'] ); ?></h2>
114 114
 				<table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>">
115 115
 					<?php foreach ( $fieldset['fields'] as $key => $field ) :
116
-						if ( ! empty( $customer ) ) {
117
-							if ( strpos( $key, '_wpinv_' ) === 0 ) {
118
-								$save_key = substr( $key , 7 );
119
-							} else {
120
-								$save_key = $key;
121
-							}
122
-
123
-							$value = $customer->get( $save_key );
124
-						} else {
125
-							$value = $this->get_user_meta( $user->ID, $key );
126
-						}
127
-						?>
116
+                        if ( ! empty( $customer ) ) {
117
+                            if ( strpos( $key, '_wpinv_' ) === 0 ) {
118
+                                $save_key = substr( $key , 7 );
119
+                            } else {
120
+                                $save_key = $key;
121
+                            }
122
+
123
+                            $value = $customer->get( $save_key );
124
+                        } else {
125
+                            $value = $this->get_user_meta( $user->ID, $key );
126
+                        }
127
+                        ?>
128 128
 						<tr>
129 129
 							<th>
130 130
 								<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
@@ -147,75 +147,75 @@  discard block
 block discarded – undo
147 147
 					<?php endforeach; ?>
148 148
 				</table>
149 149
 				<?php
150
-			endforeach;
151
-		}
152
-
153
-		/**
154
-		 * Save Address Fields on edit user pages.
155
-		 *
156
-		 * @param int $user_id User ID of the user being saved
157
-		 */
158
-		public function save_customer_meta_fields( $user_id ) {
159
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
160
-				return;
161
-			}
162
-
163
-			$save_fields = $this->get_customer_meta_fields();
164
-			$save_data = array();
165
-
166
-			foreach ( $save_fields as $fieldset ) {
167
-				foreach ( $fieldset['fields'] as $key => $field ) {
168
-					if ( strpos( $key, '_wpinv_' ) === 0 ) {
169
-						$save_key = substr( $key , 7 );
170
-					} else {
171
-						$save_key = $key;
172
-					}
173
-
174
-					if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
175
-						$save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false;
176
-					} else if ( $save_key && isset( $_POST[ $key ] ) ) {
177
-						$save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] );
178
-					}
179
-				}
180
-			}
181
-
182
-			if ( empty( $save_data ) ) {
183
-				return;
184
-			}
185
-
186
-			$customer = getpaid_get_customer_by_user_id( (int) $user_id );
187
-
188
-			if ( empty( $customer ) ) {
189
-				$customer = new GetPaid_Customer( 0 );
190
-				$customer->clone_user( (int) $user_id );
191
-			}
192
-
193
-			foreach ( $save_data as $key => $value ) {
194
-				$customer->set( $key, $value );
195
-			}
196
-
197
-			$customer->save();
198
-		}
199
-
200
-		/**
201
-		 * Get user meta for a given key, with fallbacks to core user info for pre-existing fields.
202
-		 *
203
-		 * @since 3.1.0
204
-		 * @param int    $user_id User ID of the user being edited
205
-		 * @param string $key     Key for user meta field
206
-		 * @return string
207
-		 */
208
-		protected function get_user_meta( $user_id, $key ) {
209
-			$value           = get_user_meta( $user_id, $key, true );
210
-			$existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
211
-
212
-			if ( ! $value && in_array( $key, $existing_fields ) ) {
213
-				$value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
214
-			}
215
-
216
-			return $value;
217
-		}
218
-	}
150
+            endforeach;
151
+        }
152
+
153
+        /**
154
+         * Save Address Fields on edit user pages.
155
+         *
156
+         * @param int $user_id User ID of the user being saved
157
+         */
158
+        public function save_customer_meta_fields( $user_id ) {
159
+            if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
160
+                return;
161
+            }
162
+
163
+            $save_fields = $this->get_customer_meta_fields();
164
+            $save_data = array();
165
+
166
+            foreach ( $save_fields as $fieldset ) {
167
+                foreach ( $fieldset['fields'] as $key => $field ) {
168
+                    if ( strpos( $key, '_wpinv_' ) === 0 ) {
169
+                        $save_key = substr( $key , 7 );
170
+                    } else {
171
+                        $save_key = $key;
172
+                    }
173
+
174
+                    if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
175
+                        $save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false;
176
+                    } else if ( $save_key && isset( $_POST[ $key ] ) ) {
177
+                        $save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] );
178
+                    }
179
+                }
180
+            }
181
+
182
+            if ( empty( $save_data ) ) {
183
+                return;
184
+            }
185
+
186
+            $customer = getpaid_get_customer_by_user_id( (int) $user_id );
187
+
188
+            if ( empty( $customer ) ) {
189
+                $customer = new GetPaid_Customer( 0 );
190
+                $customer->clone_user( (int) $user_id );
191
+            }
192
+
193
+            foreach ( $save_data as $key => $value ) {
194
+                $customer->set( $key, $value );
195
+            }
196
+
197
+            $customer->save();
198
+        }
199
+
200
+        /**
201
+         * Get user meta for a given key, with fallbacks to core user info for pre-existing fields.
202
+         *
203
+         * @since 3.1.0
204
+         * @param int    $user_id User ID of the user being edited
205
+         * @param string $key     Key for user meta field
206
+         * @return string
207
+         */
208
+        protected function get_user_meta( $user_id, $key ) {
209
+            $value           = get_user_meta( $user_id, $key, true );
210
+            $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
211
+
212
+            if ( ! $value && in_array( $key, $existing_fields ) ) {
213
+                $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
214
+            }
215
+
216
+            return $value;
217
+        }
218
+    }
219 219
 
220 220
 endif;
221 221
 
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit; // Exit if accessed directly
9 9
 }
10 10
 
11
-if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) :
11
+if (!class_exists('GetPaid_Admin_Profile', false)) :
12 12
 
13 13
 	/**
14 14
 	 * GetPaid_Admin_Profile Class.
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 		 * Hook in tabs.
20 20
 		 */
21 21
 		public function __construct() {
22
-			add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
-			add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
22
+			add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100);
23
+			add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100);
24 24
 
25
-			add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
-			add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
25
+			add_action('personal_options_update', array($this, 'save_customer_meta_fields'));
26
+			add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields'));
27 27
 		}
28 28
 
29 29
 		/**
@@ -37,54 +37,54 @@  discard block
 block discarded – undo
37 37
 				'getpaid_customer_meta_fields',
38 38
 				array(
39 39
 					'billing' => array(
40
-						'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
40
+						'title'  => __('Billing Details (GetPaid)', 'invoicing'),
41 41
 						'fields' => array(
42 42
 							'_wpinv_first_name' => array(
43
-								'label'       => __( 'First name', 'invoicing' ),
43
+								'label'       => __('First name', 'invoicing'),
44 44
 								'description' => '',
45 45
 							),
46 46
 							'_wpinv_last_name'  => array(
47
-								'label'       => __( 'Last name', 'invoicing' ),
47
+								'label'       => __('Last name', 'invoicing'),
48 48
 								'description' => '',
49 49
 							),
50 50
 							'_wpinv_company'    => array(
51
-								'label'       => __( 'Company', 'invoicing' ),
51
+								'label'       => __('Company', 'invoicing'),
52 52
 								'description' => '',
53 53
 							),
54 54
 							'_wpinv_company_id' => array(
55
-								'label'       => __( 'Company ID', 'invoicing' ),
55
+								'label'       => __('Company ID', 'invoicing'),
56 56
 								'description' => '',
57 57
 							),
58 58
 							'_wpinv_address'    => array(
59
-								'label'       => __( 'Address', 'invoicing' ),
59
+								'label'       => __('Address', 'invoicing'),
60 60
 								'description' => '',
61 61
 							),
62 62
 							'_wpinv_city'       => array(
63
-								'label'       => __( 'City', 'invoicing' ),
63
+								'label'       => __('City', 'invoicing'),
64 64
 								'description' => '',
65 65
 							),
66 66
 							'_wpinv_zip'        => array(
67
-								'label'       => __( 'Postcode / ZIP', 'invoicing' ),
67
+								'label'       => __('Postcode / ZIP', 'invoicing'),
68 68
 								'description' => '',
69 69
 							),
70 70
 							'_wpinv_country'    => array(
71
-								'label'       => __( 'Country / Region', 'invoicing' ),
71
+								'label'       => __('Country / Region', 'invoicing'),
72 72
 								'description' => '',
73 73
 								'class'       => 'getpaid_js_field-country',
74 74
 								'type'        => 'select',
75
-								'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
75
+								'options'     => array('' => __('Select a country / region&hellip;', 'invoicing')) + wpinv_get_country_list(),
76 76
 							),
77 77
 							'_wpinv_state'      => array(
78
-								'label'       => __( 'State / County', 'invoicing' ),
79
-								'description' => __( 'State / County or state code', 'invoicing' ),
78
+								'label'       => __('State / County', 'invoicing'),
79
+								'description' => __('State / County or state code', 'invoicing'),
80 80
 								'class'       => 'getpaid_js_field-state regular-text',
81 81
 							),
82 82
 							'_wpinv_phone'      => array(
83
-								'label'       => __( 'Phone', 'invoicing' ),
83
+								'label'       => __('Phone', 'invoicing'),
84 84
 								'description' => '',
85 85
 							),
86 86
 							'_wpinv_vat_number' => array(
87
-								'label'       => __( 'VAT Number', 'invoicing' ),
87
+								'label'       => __('VAT Number', 'invoicing'),
88 88
 								'description' => '',
89 89
 							),
90 90
 						),
@@ -99,49 +99,49 @@  discard block
 block discarded – undo
99 99
 		 *
100 100
 		 * @param WP_User $user
101 101
 		 */
102
-		public function add_customer_meta_fields( $user ) {
103
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
102
+		public function add_customer_meta_fields($user) {
103
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) {
104 104
 				return;
105 105
 			}
106 106
 
107 107
 			$show_fields = $this->get_customer_meta_fields();
108 108
 
109
-			$customer = getpaid_get_customer_by_user_id( (int) $user->ID );
109
+			$customer = getpaid_get_customer_by_user_id((int) $user->ID);
110 110
 
111
-			foreach ( $show_fields as $fieldset_key => $fieldset ) :
111
+			foreach ($show_fields as $fieldset_key => $fieldset) :
112 112
 				?>
113
-				<h2><?php echo esc_html( $fieldset['title'] ); ?></h2>
114
-				<table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>">
115
-					<?php foreach ( $fieldset['fields'] as $key => $field ) :
116
-						if ( ! empty( $customer ) ) {
117
-							if ( strpos( $key, '_wpinv_' ) === 0 ) {
118
-								$save_key = substr( $key , 7 );
113
+				<h2><?php echo esc_html($fieldset['title']); ?></h2>
114
+				<table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>">
115
+					<?php foreach ($fieldset['fields'] as $key => $field) :
116
+						if (!empty($customer)) {
117
+							if (strpos($key, '_wpinv_') === 0) {
118
+								$save_key = substr($key, 7);
119 119
 							} else {
120 120
 								$save_key = $key;
121 121
 							}
122 122
 
123
-							$value = $customer->get( $save_key );
123
+							$value = $customer->get($save_key);
124 124
 						} else {
125
-							$value = $this->get_user_meta( $user->ID, $key );
125
+							$value = $this->get_user_meta($user->ID, $key);
126 126
 						}
127 127
 						?>
128 128
 						<tr>
129 129
 							<th>
130
-								<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
130
+								<label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label>
131 131
 							</th>
132 132
 							<td>
133
-								<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?>
134
-									<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;">
135
-										<?php foreach ( $field['options'] as $option_key => $option_value ) : ?>
136
-											<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $value, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option>
133
+								<?php if (!empty($field['type']) && 'select' === $field['type']) : ?>
134
+									<select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;">
135
+										<?php foreach ($field['options'] as $option_key => $option_value) : ?>
136
+											<option value="<?php echo esc_attr($option_key); ?>" <?php selected($value, $option_key, true); ?>><?php echo esc_html($option_value); ?></option>
137 137
 										<?php endforeach; ?>
138 138
 									</select>
139
-								<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
140
-									<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) $value, 1, true ); ?> />
139
+								<?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?>
140
+									<input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) $value, 1, true); ?> />
141 141
 								<?php else : ?>
142
-									<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
142
+									<input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($value); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" />
143 143
 								<?php endif; ?>
144
-								<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
144
+								<p class="description"><?php echo wp_kses_post($field['description']); ?></p>
145 145
 							</td>
146 146
 						</tr>
147 147
 					<?php endforeach; ?>
@@ -155,43 +155,43 @@  discard block
 block discarded – undo
155 155
 		 *
156 156
 		 * @param int $user_id User ID of the user being saved
157 157
 		 */
158
-		public function save_customer_meta_fields( $user_id ) {
159
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
158
+		public function save_customer_meta_fields($user_id) {
159
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) {
160 160
 				return;
161 161
 			}
162 162
 
163 163
 			$save_fields = $this->get_customer_meta_fields();
164 164
 			$save_data = array();
165 165
 
166
-			foreach ( $save_fields as $fieldset ) {
167
-				foreach ( $fieldset['fields'] as $key => $field ) {
168
-					if ( strpos( $key, '_wpinv_' ) === 0 ) {
169
-						$save_key = substr( $key , 7 );
166
+			foreach ($save_fields as $fieldset) {
167
+				foreach ($fieldset['fields'] as $key => $field) {
168
+					if (strpos($key, '_wpinv_') === 0) {
169
+						$save_key = substr($key, 7);
170 170
 					} else {
171 171
 						$save_key = $key;
172 172
 					}
173 173
 
174
-					if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
175
-						$save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false;
176
-					} else if ( $save_key && isset( $_POST[ $key ] ) ) {
177
-						$save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] );
174
+					if ($save_key && isset($field['type']) && 'checkbox' === $field['type']) {
175
+						$save_data[$save_key] = !empty($_POST[$key]) ? true : false;
176
+					} else if ($save_key && isset($_POST[$key])) {
177
+						$save_data[$save_key] = wpinv_clean($_POST[$key]);
178 178
 					}
179 179
 				}
180 180
 			}
181 181
 
182
-			if ( empty( $save_data ) ) {
182
+			if (empty($save_data)) {
183 183
 				return;
184 184
 			}
185 185
 
186
-			$customer = getpaid_get_customer_by_user_id( (int) $user_id );
186
+			$customer = getpaid_get_customer_by_user_id((int) $user_id);
187 187
 
188
-			if ( empty( $customer ) ) {
189
-				$customer = new GetPaid_Customer( 0 );
190
-				$customer->clone_user( (int) $user_id );
188
+			if (empty($customer)) {
189
+				$customer = new GetPaid_Customer(0);
190
+				$customer->clone_user((int) $user_id);
191 191
 			}
192 192
 
193
-			foreach ( $save_data as $key => $value ) {
194
-				$customer->set( $key, $value );
193
+			foreach ($save_data as $key => $value) {
194
+				$customer->set($key, $value);
195 195
 			}
196 196
 
197 197
 			$customer->save();
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 		 * @param string $key     Key for user meta field
206 206
 		 * @return string
207 207
 		 */
208
-		protected function get_user_meta( $user_id, $key ) {
209
-			$value           = get_user_meta( $user_id, $key, true );
210
-			$existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
208
+		protected function get_user_meta($user_id, $key) {
209
+			$value           = get_user_meta($user_id, $key, true);
210
+			$existing_fields = array('_wpinv_first_name', '_wpinv_last_name');
211 211
 
212
-			if ( ! $value && in_array( $key, $existing_fields ) ) {
213
-				$value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
212
+			if (!$value && in_array($key, $existing_fields)) {
213
+				$value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true);
214 214
 			}
215 215
 
216 216
 			return $value;
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -138,8 +138,11 @@
 block discarded – undo
138 138
 									</select>
139 139
 								<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
140 140
 									<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) $value, 1, true ); ?> />
141
-								<?php else : ?>
142
-									<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
141
+								<?php else {
142
+    : ?>
143
+									<input type="text" name="<?php echo esc_attr( $key );
144
+}
145
+?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
143 146
 								<?php endif; ?>
144 147
 								<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
145 148
 							</td>
Please login to merge, or discard this patch.
includes/user-functions.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -19,28 +19,28 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function getpaid_get_customers( $args = array(), $return = 'results' ) {
21 21
 
22
-	// Do not retrieve all fields if we just want the count.
23
-	if ( 'count' === $return ) {
24
-		$args['fields'] = 'id';
25
-		$args['number'] = 1;
26
-	}
22
+    // Do not retrieve all fields if we just want the count.
23
+    if ( 'count' === $return ) {
24
+        $args['fields'] = 'id';
25
+        $args['number'] = 1;
26
+    }
27 27
 
28
-	// Do not count all matches if we just want the results.
29
-	if ( 'results' === $return ) {
30
-		$args['count_total'] = false;
31
-	}
28
+    // Do not count all matches if we just want the results.
29
+    if ( 'results' === $return ) {
30
+        $args['count_total'] = false;
31
+    }
32 32
 
33
-	$query = new GetPaid_Customers_Query( $args );
33
+    $query = new GetPaid_Customers_Query( $args );
34 34
 
35
-	if ( 'results' === $return ) {
36
-		return $query->get_results();
37
-	}
35
+    if ( 'results' === $return ) {
36
+        return $query->get_results();
37
+    }
38 38
 
39
-	if ( 'count' === $return ) {
40
-		return $query->get_total();
41
-	}
39
+    if ( 'count' === $return ) {
40
+        return $query->get_total();
41
+    }
42 42
 
43
-	return $query;
43
+    return $query;
44 44
 }
45 45
 
46 46
 /**
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
  */
107 107
 function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
108 108
 
109
-	if ( current_user_can( 'manage_options' ) ) {
110
-		return 'manage_options';
111
-	};
109
+    if ( current_user_can( 'manage_options' ) ) {
110
+        return 'manage_options';
111
+    };
112 112
 
113
-	return $capalibilty;
113
+    return $capalibilty;
114 114
 }
115 115
 
116 116
 /**
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
  * @return bool Whether the current user has the given capability.
134 134
  */
135 135
 function wpinv_current_user_can( $capability, $args = array() ) {
136
-	$can = wpinv_current_user_can_manage_invoicing();
136
+    $can = wpinv_current_user_can_manage_invoicing();
137 137
 
138
-	return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
138
+    return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
139 139
 }
140 140
 
141 141
 /**
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
     // Prepare user values.
150 150
     $prefix = preg_replace( '/\s+/', '', $prefix );
151 151
     $prefix = empty( $prefix ) ? $email : $prefix;
152
-	$args   = array(
153
-		'user_login' => wpinv_generate_user_name( $prefix ),
154
-		'user_pass'  => wp_generate_password(),
155
-		'user_email' => $email,
152
+    $args   = array(
153
+        'user_login' => wpinv_generate_user_name( $prefix ),
154
+        'user_pass'  => wp_generate_password(),
155
+        'user_email' => $email,
156 156
         'role'       => 'subscriber',
157 157
     );
158 158
 
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 function wpinv_generate_user_name( $prefix = '' ) {
170 170
 
171 171
     // If prefix is an email, retrieve the part before the email.
172
-	$prefix = strtok( $prefix, '@' );
172
+    $prefix = strtok( $prefix, '@' );
173 173
     $prefix = trim( $prefix, '.' );
174 174
 
175
-	// Sanitize the username.
176
-	$prefix = sanitize_user( $prefix, true );
175
+    // Sanitize the username.
176
+    $prefix = sanitize_user( $prefix, true );
177 177
 
178
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
179
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
180
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
181
-	}
178
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
179
+    if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
180
+        $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
181
+    }
182 182
 
183 183
     $username = $prefix;
184 184
     $postfix  = 2;
@@ -317,43 +317,43 @@  discard block
 block discarded – undo
317 317
 
318 318
                         $value = $customer->get( $key );
319 319
 
320
-					// Display the country.
321
-					if ( 'country' == $key ) {
322
-
323
-						aui()->select(
324
-							array(
325
-								'options'     => wpinv_get_country_list(),
326
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
327
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
328
-								'value'       => sanitize_text_field( $value ),
329
-								'placeholder' => $label,
330
-								'label'       => wp_kses_post( $label ),
331
-								'label_type'  => 'vertical',
332
-								'class'       => 'getpaid-address-field',
320
+                    // Display the country.
321
+                    if ( 'country' == $key ) {
322
+
323
+                        aui()->select(
324
+                            array(
325
+                                'options'     => wpinv_get_country_list(),
326
+                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
327
+                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
328
+                                'value'       => sanitize_text_field( $value ),
329
+                                'placeholder' => $label,
330
+                                'label'       => wp_kses_post( $label ),
331
+                                'label_type'  => 'vertical',
332
+                                'class'       => 'getpaid-address-field',
333 333
                             ),
334 334
                             true
335
-						);
335
+                        );
336 336
 
337
-					}
337
+                    }
338 338
 
339
-					// Display the state.
340
-					elseif ( 'state' == $key ) {
339
+                    // Display the state.
340
+                    elseif ( 'state' == $key ) {
341 341
 
342
-						getpaid_get_states_select_markup(
342
+                        getpaid_get_states_select_markup(
343 343
                             $customer->get( 'country' ),
344
-							$value,
345
-							$label,
346
-							$label,
347
-							'',
348
-							false,
349
-							'',
350
-							'getpaid_address[' . esc_attr( $key ) . ']',
344
+                            $value,
345
+                            $label,
346
+                            $label,
347
+                            '',
348
+                            false,
349
+                            '',
350
+                            'getpaid_address[' . esc_attr( $key ) . ']',
351 351
                             true
352
-						);
352
+                        );
353 353
 
354 354
                         } else {
355 355
 
356
-						aui()->input(
356
+                        aui()->input(
357 357
                             array(
358 358
                                 'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
359 359
                                 'id'          => 'wpinv-' . sanitize_html_class( $key ),
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                                 'class'       => 'getpaid-address-field',
366 366
                             ),
367 367
                             true
368
-						);
368
+                        );
369 369
 
370 370
                         }
371 371
                     }
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 function getpaid_allowed_html() {
510 510
     $allowed_html = wp_kses_allowed_html( 'post' );
511 511
 
512
-	// form fields
512
+    // form fields
513 513
     $allowed_html['form'] = array(
514 514
         'action'         => true,
515 515
         'accept'         => true,
@@ -521,12 +521,12 @@  discard block
 block discarded – undo
521 521
     );
522 522
 
523 523
     // - input
524
-	$allowed_html['input'] = array(
525
-		'class'        => array(),
526
-		'id'           => array(),
527
-		'name'         => array(),
528
-		'value'        => array(),
529
-		'type'         => array(),
524
+    $allowed_html['input'] = array(
525
+        'class'        => array(),
526
+        'id'           => array(),
527
+        'name'         => array(),
528
+        'value'        => array(),
529
+        'type'         => array(),
530 530
         'placeholder'  => array(),
531 531
         'autocomplete' => array(),
532 532
         'autofocus'    => array(),
@@ -540,33 +540,33 @@  discard block
 block discarded – undo
540 540
         'max'          => array(),
541 541
         'step'         => array(),
542 542
         'size'         => array(),
543
-	);
543
+    );
544 544
 
545 545
     // - input
546
-	$allowed_html['textarea'] = array(
547
-		'class' => array(),
548
-		'id'    => array(),
549
-		'name'  => array(),
550
-		'value' => array(),
551
-	);
552
-
553
-	// select
554
-	$allowed_html['select'] = array(
555
-		'class'        => array(),
556
-		'id'           => array(),
557
-		'name'         => array(),
546
+    $allowed_html['textarea'] = array(
547
+        'class' => array(),
548
+        'id'    => array(),
549
+        'name'  => array(),
550
+        'value' => array(),
551
+    );
552
+
553
+    // select
554
+    $allowed_html['select'] = array(
555
+        'class'        => array(),
556
+        'id'           => array(),
557
+        'name'         => array(),
558 558
         'autocomplete' => array(),
559 559
         'multiple'     => array(),
560
-	);
560
+    );
561 561
 
562
-	// select options
563
-	$allowed_html['option'] = array(
564
-		'selected' => array(),
562
+    // select options
563
+    $allowed_html['option'] = array(
564
+        'selected' => array(),
565 565
         'disabled' => array(),
566 566
         'value'    => array(),
567
-	);
567
+    );
568 568
 
569
-	return $allowed_html;
569
+    return $allowed_html;
570 570
 
571 571
 }
572 572
 
@@ -870,14 +870,14 @@  discard block
 block discarded – undo
870 870
  * @param WP_User  $user     WP_User object of the user to delete.
871 871
  */
872 872
 function getpaid_delete_user_data( $user_id, $reassign, $user ) {
873
-	global $wpdb;
874
-
875
-	// Delete customer data.
876
-	$wpdb->delete(
877
-		$wpdb->prefix . 'getpaid_customers',
878
-		array(
879
-			'user_id' => (int) $user_id,
880
-		)
881
-	);
873
+    global $wpdb;
874
+
875
+    // Delete customer data.
876
+    $wpdb->delete(
877
+        $wpdb->prefix . 'getpaid_customers',
878
+        array(
879
+            'user_id' => (int) $user_id,
880
+        )
881
+    );
882 882
 }
883 883
 add_action( 'delete_user', 'getpaid_delete_user_data', 10, 3 );
884 884
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package GetPaid
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Queries the customers database.
@@ -17,26 +17,26 @@  discard block
 block discarded – undo
17 17
  *
18 18
  * @return int|array|GetPaid_Customer[]|GetPaid_Customers_Query
19 19
  */
20
-function getpaid_get_customers( $args = array(), $return = 'results' ) {
20
+function getpaid_get_customers($args = array(), $return = 'results') {
21 21
 
22 22
 	// Do not retrieve all fields if we just want the count.
23
-	if ( 'count' === $return ) {
23
+	if ('count' === $return) {
24 24
 		$args['fields'] = 'id';
25 25
 		$args['number'] = 1;
26 26
 	}
27 27
 
28 28
 	// Do not count all matches if we just want the results.
29
-	if ( 'results' === $return ) {
29
+	if ('results' === $return) {
30 30
 		$args['count_total'] = false;
31 31
 	}
32 32
 
33
-	$query = new GetPaid_Customers_Query( $args );
33
+	$query = new GetPaid_Customers_Query($args);
34 34
 
35
-	if ( 'results' === $return ) {
35
+	if ('results' === $return) {
36 36
 		return $query->get_results();
37 37
 	}
38 38
 
39
-	if ( 'count' === $return ) {
39
+	if ('count' === $return) {
40 40
 		return $query->get_total();
41 41
 	}
42 42
 
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
  * @param int|string|object|GetPaid_Customer $customer customer id, email or object.
50 50
  * @return GetPaid_Customer|null
51 51
  */
52
-function getpaid_get_customer( $customer ) {
52
+function getpaid_get_customer($customer) {
53 53
 
54
-    if ( empty( $customer ) ) {
54
+    if (empty($customer)) {
55 55
         return null;
56 56
     }
57 57
 
58 58
     // Retrieve the customer.
59
-    if ( ! is_a( $customer, 'GetPaid_Customer' ) ) {
60
-        $customer = new GetPaid_Customer( $customer );
59
+    if (!is_a($customer, 'GetPaid_Customer')) {
60
+        $customer = new GetPaid_Customer($customer);
61 61
     }
62 62
 
63 63
     // Check if it exists.
64
-    if ( $customer->exists() ) {
64
+    if ($customer->exists()) {
65 65
         return $customer;
66 66
     }
67 67
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
  * @return GetPaid_Customer|null
75 75
  * @since 1.0.0
76 76
  */
77
-function getpaid_get_customer_by_user_id( $user_id ) {
77
+function getpaid_get_customer_by_user_id($user_id) {
78 78
     return getpaid_get_customer(
79
-        GetPaid_Customer::get_customer_id_by( $user_id, 'user_id' )
79
+        GetPaid_Customer::get_customer_id_by($user_id, 'user_id')
80 80
     );
81 81
 }
82 82
 
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
  * @param array $args
89 89
  * @see wp_dropdown_users
90 90
  */
91
-function wpinv_dropdown_users( $args = '' ) {
91
+function wpinv_dropdown_users($args = '') {
92 92
 
93
-    if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) {
93
+    if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) {
94 94
         $args['show'] = 'display_name_with_login';
95 95
     }
96 96
 
97
-    return wp_dropdown_users( $args );
97
+    return wp_dropdown_users($args);
98 98
 }
99 99
 
100 100
 /**
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
  * @return string capability to check against
105 105
  * @param string $capalibilty Optional. The alternative capability to check against.
106 106
  */
107
-function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
107
+function wpinv_get_capability($capalibilty = 'manage_invoicing') {
108 108
 
109
-	if ( current_user_can( 'manage_options' ) ) {
109
+	if (current_user_can('manage_options')) {
110 110
 		return 'manage_options';
111 111
 	};
112 112
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
  * @return bool
121 121
  */
122 122
 function wpinv_current_user_can_manage_invoicing() {
123
-    return current_user_can( wpinv_get_capability() );
123
+    return current_user_can(wpinv_get_capability());
124 124
 }
125 125
 
126 126
 /**
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
  * @param mixed  $args    Optional further parameters, typically starting with an object.
133 133
  * @return bool Whether the current user has the given capability.
134 134
  */
135
-function wpinv_current_user_can( $capability, $args = array() ) {
135
+function wpinv_current_user_can($capability, $args = array()) {
136 136
 	$can = wpinv_current_user_can_manage_invoicing();
137 137
 
138
-	return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
138
+	return apply_filters('getpaid_current_user_can', $can, $capability, $args);
139 139
 }
140 140
 
141 141
 /**
@@ -144,19 +144,19 @@  discard block
 block discarded – undo
144 144
  * @since 1.0.19
145 145
  * @return int|WP_Error
146 146
  */
147
-function wpinv_create_user( $email, $prefix = '' ) {
147
+function wpinv_create_user($email, $prefix = '') {
148 148
 
149 149
     // Prepare user values.
150
-    $prefix = preg_replace( '/\s+/', '', $prefix );
151
-    $prefix = empty( $prefix ) ? $email : $prefix;
152
-	$args   = array(
153
-		'user_login' => wpinv_generate_user_name( $prefix ),
150
+    $prefix = preg_replace('/\s+/', '', $prefix);
151
+    $prefix = empty($prefix) ? $email : $prefix;
152
+	$args = array(
153
+		'user_login' => wpinv_generate_user_name($prefix),
154 154
 		'user_pass'  => wp_generate_password(),
155 155
 		'user_email' => $email,
156 156
         'role'       => 'subscriber',
157 157
     );
158 158
 
159
-    return wp_insert_user( $args );
159
+    return wp_insert_user($args);
160 160
 
161 161
 }
162 162
 
@@ -166,26 +166,26 @@  discard block
 block discarded – undo
166 166
  * @since 1.0.19
167 167
  * @return bool|WP_User
168 168
  */
169
-function wpinv_generate_user_name( $prefix = '' ) {
169
+function wpinv_generate_user_name($prefix = '') {
170 170
 
171 171
     // If prefix is an email, retrieve the part before the email.
172
-	$prefix = strtok( $prefix, '@' );
173
-    $prefix = trim( $prefix, '.' );
172
+	$prefix = strtok($prefix, '@');
173
+    $prefix = trim($prefix, '.');
174 174
 
175 175
 	// Sanitize the username.
176
-	$prefix = sanitize_user( $prefix, true );
176
+	$prefix = sanitize_user($prefix, true);
177 177
 
178
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
179
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
180
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
178
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
179
+	if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) {
180
+		$prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4);
181 181
 	}
182 182
 
183 183
     $username = $prefix;
184 184
     $postfix  = 2;
185 185
 
186
-    while ( username_exists( $username ) ) {
186
+    while (username_exists($username)) {
187 187
         $username = "{$prefix}{$postfix}";
188
-        $postfix ++;
188
+        $postfix++;
189 189
     }
190 190
 
191 191
     return $username;
@@ -202,31 +202,31 @@  discard block
 block discarded – undo
202 202
     $tabs = array(
203 203
 
204 204
         'gp-invoices'      => array(
205
-            'label'   => __( 'Invoices', 'invoicing' ), // Name of the tab.
205
+            'label'   => __('Invoices', 'invoicing'), // Name of the tab.
206 206
             'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead.
207 207
             'icon'    => 'fas fa-file-invoice', // Shown on some profile plugins.
208 208
         ),
209 209
 
210 210
         'gp-subscriptions' => array(
211
-            'label'   => __( 'Subscriptions', 'invoicing' ),
211
+            'label'   => __('Subscriptions', 'invoicing'),
212 212
             'content' => '[wpinv_subscriptions]',
213 213
             'icon'    => 'fas fa-redo',
214 214
         ),
215 215
 
216 216
         'gp-edit-address'  => array(
217
-            'label'    => __( 'Billing Address', 'invoicing' ),
217
+            'label'    => __('Billing Address', 'invoicing'),
218 218
             'callback' => 'getpaid_display_address_edit_tab',
219 219
             'icon'     => 'fas fa-credit-card',
220 220
         ),
221 221
 
222 222
     );
223 223
 
224
-    $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs );
224
+    $tabs = apply_filters('getpaid_user_content_tabs', $tabs);
225 225
 
226 226
     // Make sure address editing is last on the list.
227
-    if ( isset( $tabs['gp-edit-address'] ) ) {
227
+    if (isset($tabs['gp-edit-address'])) {
228 228
         $address = $tabs['gp-edit-address'];
229
-        unset( $tabs['gp-edit-address'] );
229
+        unset($tabs['gp-edit-address']);
230 230
         $tabs['gp-edit-address'] = $address;
231 231
     }
232 232
 
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
  * @param array $tab
241 241
  * @return array
242 242
  */
243
-function getpaid_prepare_user_content_tab( $tab ) {
243
+function getpaid_prepare_user_content_tab($tab) {
244 244
 
245
-    if ( ! empty( $tab['callback'] ) ) {
246
-        return call_user_func( $tab['callback'] );
245
+    if (!empty($tab['callback'])) {
246
+        return call_user_func($tab['callback']);
247 247
     }
248 248
 
249
-    if ( ! empty( $tab['content'] ) ) {
250
-        return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) );
249
+    if (!empty($tab['content'])) {
250
+        return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content']))))))));
251 251
     }
252 252
 
253 253
     $notice = aui()->alert(
254 254
         array(
255
-            'content' => __( 'This tab has no content or content callback.', 'invoicing' ),
255
+            'content' => __('This tab has no content or content callback.', 'invoicing'),
256 256
             'type'    => 'error',
257 257
         )
258 258
     );
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
  * @param string $default
269 269
  * @return array
270 270
  */
271
-function getpaid_get_tab_url( $tab, $default ) {
271
+function getpaid_get_tab_url($tab, $default) {
272 272
     global $getpaid_tab_url;
273 273
 
274
-    if ( empty( $getpaid_tab_url ) ) {
274
+    if (empty($getpaid_tab_url)) {
275 275
         return $default;
276 276
     }
277 277
 
278
-    return sprintf( $getpaid_tab_url, $tab );
278
+    return sprintf($getpaid_tab_url, $tab);
279 279
 
280 280
 }
281 281
 
@@ -287,21 +287,21 @@  discard block
 block discarded – undo
287 287
  */
288 288
 function getpaid_display_address_edit_tab() {
289 289
 
290
-    if ( 0 === get_current_user_id() ) {
290
+    if (0 === get_current_user_id()) {
291 291
         return '<div class="bsui">' . aui()->alert(
292 292
             array(
293 293
                 'type'        => 'error',
294
-                'content'     => __( 'Your must be logged in to view this section', 'invoicing' ),
294
+                'content'     => __('Your must be logged in to view this section', 'invoicing'),
295 295
                 'dismissible' => false,
296 296
             )
297 297
         ) . '</div>';
298 298
     }
299 299
 
300
-    $customer = getpaid_get_customer_by_user_id( get_current_user_id() );
300
+    $customer = getpaid_get_customer_by_user_id(get_current_user_id());
301 301
 
302
-    if ( empty( $customer ) ) {
303
-        $customer = new GetPaid_Customer( 0 );
304
-        $customer->clone_user( get_current_user_id() );
302
+    if (empty($customer)) {
303
+        $customer = new GetPaid_Customer(0);
304
+        $customer->clone_user(get_current_user_id());
305 305
         $customer->save();
306 306
     }
307 307
 
@@ -313,21 +313,21 @@  discard block
 block discarded – undo
313 313
 
314 314
                 <?php
315 315
 
316
-                    foreach ( getpaid_user_address_fields() as $key => $label ) {
316
+                    foreach (getpaid_user_address_fields() as $key => $label) {
317 317
 
318
-                        $value = $customer->get( $key );
318
+                        $value = $customer->get($key);
319 319
 
320 320
 					// Display the country.
321
-					if ( 'country' == $key ) {
321
+					if ('country' == $key) {
322 322
 
323 323
 						aui()->select(
324 324
 							array(
325 325
 								'options'     => wpinv_get_country_list(),
326
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
327
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
328
-								'value'       => sanitize_text_field( $value ),
326
+								'name'        => 'getpaid_address[' . esc_attr($key) . ']',
327
+								'id'          => 'wpinv-' . sanitize_html_class($key),
328
+								'value'       => sanitize_text_field($value),
329 329
 								'placeholder' => $label,
330
-								'label'       => wp_kses_post( $label ),
330
+								'label'       => wp_kses_post($label),
331 331
 								'label_type'  => 'vertical',
332 332
 								'class'       => 'getpaid-address-field',
333 333
                             ),
@@ -337,17 +337,17 @@  discard block
 block discarded – undo
337 337
 					}
338 338
 
339 339
 					// Display the state.
340
-					elseif ( 'state' == $key ) {
340
+					elseif ('state' == $key) {
341 341
 
342 342
 						getpaid_get_states_select_markup(
343
-                            $customer->get( 'country' ),
343
+                            $customer->get('country'),
344 344
 							$value,
345 345
 							$label,
346 346
 							$label,
347 347
 							'',
348 348
 							false,
349 349
 							'',
350
-							'getpaid_address[' . esc_attr( $key ) . ']',
350
+							'getpaid_address[' . esc_attr($key) . ']',
351 351
                             true
352 352
 						);
353 353
 
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 
356 356
 						aui()->input(
357 357
                             array(
358
-                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
359
-                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
358
+                                'name'        => 'getpaid_address[' . esc_attr($key) . ']',
359
+                                'id'          => 'wpinv-' . sanitize_html_class($key),
360 360
                                 'placeholder' => $label,
361
-                                'label'       => wp_kses_post( $label ),
361
+                                'label'       => wp_kses_post($label),
362 362
                                 'label_type'  => 'vertical',
363 363
                                 'type'        => 'text',
364
-                                'value'       => sanitize_text_field( $value ),
364
+                                'value'       => sanitize_text_field($value),
365 365
                                 'class'       => 'getpaid-address-field',
366 366
                             ),
367 367
                             true
@@ -375,32 +375,32 @@  discard block
 block discarded – undo
375 375
                             'name'        => 'getpaid_address[email_cc]',
376 376
                             'id'          => 'wpinv-email_cc',
377 377
                             'placeholder' => '[email protected], [email protected]',
378
-                            'label'       => __( 'Other email addresses', 'invoicing' ),
378
+                            'label'       => __('Other email addresses', 'invoicing'),
379 379
                             'label_type'  => 'vertical',
380 380
                             'type'        => 'text',
381
-                            'value'       => sanitize_text_field( $customer->get( 'email_cc' ) ),
381
+                            'value'       => sanitize_text_field($customer->get('email_cc')),
382 382
                             'class'       => 'getpaid-address-field',
383
-                            'help_text'   => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ),
383
+                            'help_text'   => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'),
384 384
                         ),
385 385
                         true
386 386
                     );
387 387
 
388
-                    do_action( 'getpaid_display_address_edit_tab' );
388
+                    do_action('getpaid_display_address_edit_tab');
389 389
 
390 390
                     aui()->input(
391 391
                         array(
392 392
                             'name'      => 'getpaid_profile_edit_submit_button',
393 393
                             'id'        => 'getpaid_profile_edit_submit_button',
394
-                            'value'     => __( 'Save Address', 'invoicing' ),
395
-                            'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ),
394
+                            'value'     => __('Save Address', 'invoicing'),
395
+                            'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'),
396 396
                             'type'      => 'submit',
397 397
                             'class'     => 'btn btn-primary btn-block submit-button',
398 398
                         ),
399 399
                         true
400 400
                     );
401 401
 
402
-                    wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' );
403
-                    getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' );
402
+                    wp_nonce_field('getpaid-nonce', 'getpaid-nonce');
403
+                    getpaid_hidden_field('getpaid-action', 'edit_billing_details');
404 404
                 ?>
405 405
 
406 406
             </form>
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 
411 411
     return ob_get_clean();
412 412
 }
413
-add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' );
413
+add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab');
414 414
 
415 415
 /**
416 416
  * Saves the billing address edit tab.
@@ -418,35 +418,35 @@  discard block
 block discarded – undo
418 418
  * @since 2.1.4
419 419
  * @param array $data
420 420
  */
421
-function getpaid_save_address_edit_tab( $data ) {
421
+function getpaid_save_address_edit_tab($data) {
422 422
 
423
-    if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) {
423
+    if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) {
424 424
         return;
425 425
     }
426 426
 
427 427
     $data     = $data['getpaid_address'];
428
-    $customer = getpaid_get_customer_by_user_id( get_current_user_id() );
428
+    $customer = getpaid_get_customer_by_user_id(get_current_user_id());
429 429
 
430
-    if ( empty( $customer ) ) {
431
-        $customer = new GetPaid_Customer( 0 );
432
-        $customer->clone_user( get_current_user_id() );
430
+    if (empty($customer)) {
431
+        $customer = new GetPaid_Customer(0);
432
+        $customer->clone_user(get_current_user_id());
433 433
     }
434 434
 
435
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
435
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
436 436
 
437
-        if ( isset( $data[ $field ] ) ) {
438
-            $customer->set( $field, sanitize_text_field( $data[ $field ] ) );
437
+        if (isset($data[$field])) {
438
+            $customer->set($field, sanitize_text_field($data[$field]));
439 439
         }
440 440
     }
441 441
 
442
-    if ( isset( $data['email_cc'] ) ) {
443
-        $customer->set( 'email_cc', sanitize_text_field( $data['email_cc'] ) );
442
+    if (isset($data['email_cc'])) {
443
+        $customer->set('email_cc', sanitize_text_field($data['email_cc']));
444 444
     }
445 445
 
446 446
     $customer->save();
447
-    wpinv_set_error( 'address_updated' );
447
+    wpinv_set_error('address_updated');
448 448
 }
449
-add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' );
449
+add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab');
450 450
 
451 451
 
452 452
 /*
@@ -464,27 +464,27 @@  discard block
 block discarded – undo
464 464
  * @param  array $tabs
465 465
  * @return array
466 466
  */
467
-function getpaid_filter_userswp_account_tabs( $tabs ) {
467
+function getpaid_filter_userswp_account_tabs($tabs) {
468 468
 
469 469
     // Abort if the integration is inactive.
470
-    if ( ! getpaid_is_userswp_integration_active() ) {
470
+    if (!getpaid_is_userswp_integration_active()) {
471 471
         return $tabs;
472 472
     }
473 473
 
474
-    $new_tabs   = array();
474
+    $new_tabs = array();
475 475
 
476
-    foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) {
476
+    foreach (getpaid_get_user_content_tabs() as $slug => $tab) {
477 477
 
478
-        $new_tabs[ $slug ] = array(
478
+        $new_tabs[$slug] = array(
479 479
             'title' => $tab['label'],
480 480
             'icon'  => $tab['icon'],
481 481
         );
482 482
 
483 483
     }
484 484
 
485
-    return array_merge( $tabs, $new_tabs );
485
+    return array_merge($tabs, $new_tabs);
486 486
 }
487
-add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' );
487
+add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs');
488 488
 
489 489
 /**
490 490
  * Display our UsersWP account tabs.
@@ -493,21 +493,21 @@  discard block
 block discarded – undo
493 493
  * @param  array $tabs
494 494
  * @return array
495 495
  */
496
-function getpaid_display_userswp_account_tabs( $tab ) {
496
+function getpaid_display_userswp_account_tabs($tab) {
497 497
     global $getpaid_tab_url;
498 498
 
499 499
     $our_tabs = getpaid_get_user_content_tabs();
500 500
 
501
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
502
-        $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() );
503
-        echo wp_kses( getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ), getpaid_allowed_html() );
501
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
502
+        $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url());
503
+        echo wp_kses(getpaid_prepare_user_content_tab($our_tabs[$tab]), getpaid_allowed_html());
504 504
     }
505 505
 
506 506
 }
507
-add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' );
507
+add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs');
508 508
 
509 509
 function getpaid_allowed_html() {
510
-    $allowed_html = wp_kses_allowed_html( 'post' );
510
+    $allowed_html = wp_kses_allowed_html('post');
511 511
 
512 512
 	// form fields
513 513
     $allowed_html['form'] = array(
@@ -578,17 +578,17 @@  discard block
 block discarded – undo
578 578
  * @param  string $tab   Current tab.
579 579
  * @return string Title.
580 580
  */
581
-function getpaid_filter_userswp_account_title( $title, $tab ) {
581
+function getpaid_filter_userswp_account_title($title, $tab) {
582 582
 
583
-    $our_tabs   = getpaid_get_user_content_tabs();
583
+    $our_tabs = getpaid_get_user_content_tabs();
584 584
 
585
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
586
-        return $our_tabs[ $tab ]['label'];
585
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
586
+        return $our_tabs[$tab]['label'];
587 587
     }
588 588
 
589 589
     return $title;
590 590
 }
591
-add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 );
591
+add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2);
592 592
 
593 593
 /**
594 594
  * Registers the UsersWP integration settings.
@@ -597,26 +597,26 @@  discard block
 block discarded – undo
597 597
  * @param  array $settings An array of integration settings.
598 598
  * @return array
599 599
  */
600
-function getpaid_register_userswp_settings( $settings ) {
600
+function getpaid_register_userswp_settings($settings) {
601 601
 
602
-    if ( defined( 'USERSWP_PLUGIN_FILE' ) ) {
602
+    if (defined('USERSWP_PLUGIN_FILE')) {
603 603
 
604 604
         $settings[] = array(
605 605
 
606 606
             'id'       => 'userswp',
607
-            'label'    => __( 'UsersWP', 'invoicing' ),
607
+            'label'    => __('UsersWP', 'invoicing'),
608 608
             'settings' => array(
609 609
 
610 610
                 'userswp_settings' => array(
611 611
                     'id'   => 'userswp_settings',
612
-                    'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>',
612
+                    'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>',
613 613
                     'type' => 'header',
614 614
                 ),
615 615
 
616 616
                 'enable_userswp'   => array(
617 617
                     'id'   => 'enable_userswp',
618
-                    'name' => __( 'Enable Integration', 'invoicing' ),
619
-                    'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ),
618
+                    'name' => __('Enable Integration', 'invoicing'),
619
+                    'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'),
620 620
                     'type' => 'checkbox',
621 621
                     'std'  => 1,
622 622
                 ),
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 
630 630
     return $settings;
631 631
 }
632
-add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' );
632
+add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings');
633 633
 
634 634
 /**
635 635
  * Ovewrites the invoices history page to UsersWP.
@@ -637,18 +637,18 @@  discard block
 block discarded – undo
637 637
  * @since  2.3.1
638 638
  * @return bool
639 639
  */
640
-function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) {
640
+function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) {
641 641
 
642 642
     $our_tabs = getpaid_get_user_content_tabs();
643 643
     $tab      = "gp-{$post_type}s";
644
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
645
-        return add_query_arg( 'type', $tab, uwp_get_account_page_url() );
644
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
645
+        return add_query_arg('type', $tab, uwp_get_account_page_url());
646 646
     }
647 647
 
648 648
     return $url;
649 649
 
650 650
 }
651
-add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 );
651
+add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2);
652 652
 
653 653
 /**
654 654
  * Checks if the integration is enabled.
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
  * @return bool
658 658
  */
659 659
 function getpaid_is_userswp_integration_active() {
660
-    $enabled = wpinv_get_option( 'enable_userswp', 1 );
661
-    return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled );
660
+    $enabled = wpinv_get_option('enable_userswp', 1);
661
+    return defined('USERSWP_PLUGIN_FILE') && !empty($enabled);
662 662
 }
663 663
 
664 664
 /*
@@ -676,26 +676,26 @@  discard block
 block discarded – undo
676 676
  * @param  array $settings An array of integration settings.
677 677
  * @return array
678 678
  */
679
-function getpaid_register_buddypress_settings( $settings ) {
679
+function getpaid_register_buddypress_settings($settings) {
680 680
 
681
-    if ( class_exists( 'BuddyPress' ) ) {
681
+    if (class_exists('BuddyPress')) {
682 682
 
683 683
         $settings[] = array(
684 684
 
685 685
             'id'       => 'buddypress',
686
-            'label'    => __( 'BuddyPress', 'invoicing' ),
686
+            'label'    => __('BuddyPress', 'invoicing'),
687 687
             'settings' => array(
688 688
 
689 689
                 'buddypress_settings' => array(
690 690
                     'id'   => 'buddypress_settings',
691
-                    'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>',
691
+                    'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>',
692 692
                     'type' => 'header',
693 693
                 ),
694 694
 
695 695
                 'enable_buddypress'   => array(
696 696
                     'id'   => 'enable_buddypress',
697
-                    'name' => __( 'Enable Integration', 'invoicing' ),
698
-                    'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ),
697
+                    'name' => __('Enable Integration', 'invoicing'),
698
+                    'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'),
699 699
                     'type' => 'checkbox',
700 700
                     'std'  => 1,
701 701
                 ),
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 
709 709
     return $settings;
710 710
 }
711
-add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' );
711
+add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings');
712 712
 
713 713
 /**
714 714
  * Checks if the integration is enabled.
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
  * @return bool
718 718
  */
719 719
 function getpaid_is_buddypress_integration_active() {
720
-    $enabled = wpinv_get_option( 'enable_buddypress', 1 );
721
-    return class_exists( 'BuddyPress' ) && ! empty( $enabled );
720
+    $enabled = wpinv_get_option('enable_buddypress', 1);
721
+    return class_exists('BuddyPress') && !empty($enabled);
722 722
 }
723 723
 
724 724
 /**
@@ -729,13 +729,13 @@  discard block
 block discarded – undo
729 729
  */
730 730
 function getpaid_setup_buddypress_integration() {
731 731
 
732
-    if ( getpaid_is_buddypress_integration_active() ) {
732
+    if (getpaid_is_buddypress_integration_active()) {
733 733
         require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php';
734 734
         buddypress()->getpaid = new BP_GetPaid_Component();
735 735
     }
736 736
 
737 737
 }
738
-add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' );
738
+add_action('bp_setup_components', 'getpaid_setup_buddypress_integration');
739 739
 
740 740
 /**
741 741
  * Checks if a given user has purchased a given item.
@@ -744,10 +744,10 @@  discard block
 block discarded – undo
744 744
  * @param int $item_id The item id.
745 745
  * @return int The IDs of users who purchased the item.
746 746
  */
747
-function getpaid_user_ids_who_purchased_item( $item_id ) {
747
+function getpaid_user_ids_who_purchased_item($item_id) {
748 748
     global $wpdb;
749 749
 
750
-    if ( empty( $item_id ) ) {
750
+    if (empty($item_id)) {
751 751
         return false;
752 752
     }
753 753
 
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
         )
761 761
     );
762 762
 
763
-    return wp_parse_id_list( $ids );
763
+    return wp_parse_id_list($ids);
764 764
 }
765 765
 
766 766
 /**
@@ -769,10 +769,10 @@  discard block
 block discarded – undo
769 769
  * @since 2.6.17
770 770
  * @param int $user_id The user id.
771 771
  */
772
-function getpaid_has_user_purchased_item( $user_id, $item_id ) {
772
+function getpaid_has_user_purchased_item($user_id, $item_id) {
773 773
     global $wpdb;
774 774
 
775
-    if ( empty( $user_id ) ) {
775
+    if (empty($user_id)) {
776 776
         return false;
777 777
     }
778 778
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
         )
788 788
     );
789 789
 
790
-    return ! empty( $count );
790
+    return !empty($count);
791 791
 }
792 792
 
793 793
 /**
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
  * @since 2.6.17
797 797
  * @param int $user_id The user id.
798 798
  */
799
-function getpaid_get_user_total_spend( $user_id ) {
799
+function getpaid_get_user_total_spend($user_id) {
800 800
     $args = array(
801 801
         'data'           => array(
802 802
 
@@ -811,17 +811,17 @@  discard block
 block discarded – undo
811 811
 
812 812
             'author' => array(
813 813
                 'type'     => 'post_data',
814
-                'value'    => absint( $user_id ),
814
+                'value'    => absint($user_id),
815 815
                 'key'      => 'posts.post_author',
816 816
                 'operator' => '=',
817 817
             ),
818 818
 
819 819
         ),
820 820
         'query_type'     => 'get_var',
821
-        'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
821
+        'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'),
822 822
     );
823 823
 
824
-    return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
824
+    return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args));
825 825
 }
826 826
 
827 827
 /**
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
  * @since 2.6.17
831 831
  * @param int $user_id The user id.
832 832
  */
833
-function getpaid_count_user_invoices( $user_id ) {
833
+function getpaid_count_user_invoices($user_id) {
834 834
     $args = array(
835 835
         'data'           => array(
836 836
 
@@ -846,17 +846,17 @@  discard block
 block discarded – undo
846 846
 
847 847
             'author' => array(
848 848
                 'type'     => 'post_data',
849
-                'value'    => absint( $user_id ),
849
+                'value'    => absint($user_id),
850 850
                 'key'      => 'posts.post_author',
851 851
                 'operator' => '=',
852 852
             ),
853 853
 
854 854
         ),
855 855
         'query_type'     => 'get_var',
856
-        'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
856
+        'invoice_status' => array_keys(wpinv_get_invoice_statuses()),
857 857
     );
858 858
 
859
-    return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
859
+    return absint(GetPaid_Reports_Helper::get_invoice_report_data($args));
860 860
 }
861 861
 
862 862
 /**
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
  *                           Default null, for no reassignment.
870 870
  * @param WP_User  $user     WP_User object of the user to delete.
871 871
  */
872
-function getpaid_delete_user_data( $user_id, $reassign, $user ) {
872
+function getpaid_delete_user_data($user_id, $reassign, $user) {
873 873
 	global $wpdb;
874 874
 
875 875
 	// Delete customer data.
@@ -880,4 +880,4 @@  discard block
 block discarded – undo
880 880
 		)
881 881
 	);
882 882
 }
883
-add_action( 'delete_user', 'getpaid_delete_user_data', 10, 3 );
884 883
\ No newline at end of file
884
+add_action('delete_user', 'getpaid_delete_user_data', 10, 3);
885 885
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 2 patches
Indentation   +751 added lines, -751 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,30 +10,30 @@  discard block
 block discarded – undo
10 10
 class WPInv_Item extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'item';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'item';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'item';
25 25
 
26 26
     /**
27
-	 * Item Data array. This is the core item data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'parent_id'            => 0,
34
-		'status'               => 'draft',
35
-		'version'              => '',
36
-		'date_created'         => null,
27
+     * Item Data array. This is the core item data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'parent_id'            => 0,
34
+        'status'               => 'draft',
35
+        'version'              => '',
36
+        'date_created'         => null,
37 37
         'date_modified'        => null,
38 38
         'name'                 => '',
39 39
         'description'          => '',
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
     );
63 63
 
64 64
     /**
65
-	 * Stores meta in cache for future reads.
66
-	 *
67
-	 * A group must be set to to enable caching.
68
-	 *
69
-	 * @var string
70
-	 */
71
-	protected $cache_group = 'getpaid_items';
65
+     * Stores meta in cache for future reads.
66
+     *
67
+     * A group must be set to to enable caching.
68
+     *
69
+     * @var string
70
+     */
71
+    protected $cache_group = 'getpaid_items';
72 72
 
73 73
     /**
74 74
      * Stores a reference to the original WP_Post object
@@ -78,36 +78,36 @@  discard block
 block discarded – undo
78 78
     protected $post = null;
79 79
 
80 80
     /**
81
-	 * Get the item if ID is passed, otherwise the item is new and empty.
82
-	 *
83
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
84
-	 */
85
-	public function __construct( $item = 0 ) {
86
-		parent::__construct( $item );
87
-
88
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
89
-			$this->set_id( $item );
90
-		} elseif ( $item instanceof self ) {
91
-			$this->set_id( $item->get_id() );
92
-		} elseif ( ! empty( $item->ID ) ) {
93
-			$this->set_id( $item->ID );
94
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
95
-			$this->set_id( $item_id );
96
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
97
-			$this->set_id( $item_id );
98
-		} else {
99
-			$this->set_object_read( true );
100
-		}
81
+     * Get the item if ID is passed, otherwise the item is new and empty.
82
+     *
83
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
84
+     */
85
+    public function __construct( $item = 0 ) {
86
+        parent::__construct( $item );
87
+
88
+        if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
89
+            $this->set_id( $item );
90
+        } elseif ( $item instanceof self ) {
91
+            $this->set_id( $item->get_id() );
92
+        } elseif ( ! empty( $item->ID ) ) {
93
+            $this->set_id( $item->ID );
94
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
95
+            $this->set_id( $item_id );
96
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
97
+            $this->set_id( $item_id );
98
+        } else {
99
+            $this->set_object_read( true );
100
+        }
101 101
 
102 102
         // Load the datastore.
103
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
103
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
104 104
 
105
-		if ( $this->get_id() > 0 ) {
105
+        if ( $this->get_id() > 0 ) {
106 106
             $this->post = get_post( $this->get_id() );
107 107
             $this->ID   = $this->get_id();
108
-			$this->data_store->read( $this );
108
+            $this->data_store->read( $this );
109 109
         }
110
-	}
110
+    }
111 111
 
112 112
     /*
113 113
 	|--------------------------------------------------------------------------
@@ -125,188 +125,188 @@  discard block
 block discarded – undo
125 125
     */
126 126
 
127 127
     /**
128
-	 * Get parent item ID.
129
-	 *
130
-	 * @since 1.0.19
131
-	 * @param  string $context View or edit context.
132
-	 * @return int
133
-	 */
134
-	public function get_parent_id( $context = 'view' ) {
135
-		return (int) $this->get_prop( 'parent_id', $context );
128
+     * Get parent item ID.
129
+     *
130
+     * @since 1.0.19
131
+     * @param  string $context View or edit context.
132
+     * @return int
133
+     */
134
+    public function get_parent_id( $context = 'view' ) {
135
+        return (int) $this->get_prop( 'parent_id', $context );
136 136
     }
137 137
 
138 138
     /**
139
-	 * Get item status.
140
-	 *
141
-	 * @since 1.0.19
142
-	 * @param  string $context View or edit context.
143
-	 * @return string
144
-	 */
145
-	public function get_status( $context = 'view' ) {
146
-		return $this->get_prop( 'status', $context );
139
+     * Get item status.
140
+     *
141
+     * @since 1.0.19
142
+     * @param  string $context View or edit context.
143
+     * @return string
144
+     */
145
+    public function get_status( $context = 'view' ) {
146
+        return $this->get_prop( 'status', $context );
147 147
     }
148 148
 
149 149
     /**
150
-	 * Get plugin version when the item was created.
151
-	 *
152
-	 * @since 1.0.19
153
-	 * @param  string $context View or edit context.
154
-	 * @return string
155
-	 */
156
-	public function get_version( $context = 'view' ) {
157
-		return $this->get_prop( 'version', $context );
150
+     * Get plugin version when the item was created.
151
+     *
152
+     * @since 1.0.19
153
+     * @param  string $context View or edit context.
154
+     * @return string
155
+     */
156
+    public function get_version( $context = 'view' ) {
157
+        return $this->get_prop( 'version', $context );
158 158
     }
159 159
 
160 160
     /**
161
-	 * Get date when the item was created.
162
-	 *
163
-	 * @since 1.0.19
164
-	 * @param  string $context View or edit context.
165
-	 * @return string
166
-	 */
167
-	public function get_date_created( $context = 'view' ) {
168
-		return $this->get_prop( 'date_created', $context );
161
+     * Get date when the item was created.
162
+     *
163
+     * @since 1.0.19
164
+     * @param  string $context View or edit context.
165
+     * @return string
166
+     */
167
+    public function get_date_created( $context = 'view' ) {
168
+        return $this->get_prop( 'date_created', $context );
169 169
     }
170 170
 
171 171
     /**
172
-	 * Get GMT date when the item was created.
173
-	 *
174
-	 * @since 1.0.19
175
-	 * @param  string $context View or edit context.
176
-	 * @return string
177
-	 */
178
-	public function get_date_created_gmt( $context = 'view' ) {
172
+     * Get GMT date when the item was created.
173
+     *
174
+     * @since 1.0.19
175
+     * @param  string $context View or edit context.
176
+     * @return string
177
+     */
178
+    public function get_date_created_gmt( $context = 'view' ) {
179 179
         $date = $this->get_date_created( $context );
180 180
 
181 181
         if ( $date ) {
182 182
             $date = get_gmt_from_date( $date );
183 183
         }
184
-		return $date;
184
+        return $date;
185 185
     }
186 186
 
187 187
     /**
188
-	 * Get date when the item was last modified.
189
-	 *
190
-	 * @since 1.0.19
191
-	 * @param  string $context View or edit context.
192
-	 * @return string
193
-	 */
194
-	public function get_date_modified( $context = 'view' ) {
195
-		return $this->get_prop( 'date_modified', $context );
188
+     * Get date when the item was last modified.
189
+     *
190
+     * @since 1.0.19
191
+     * @param  string $context View or edit context.
192
+     * @return string
193
+     */
194
+    public function get_date_modified( $context = 'view' ) {
195
+        return $this->get_prop( 'date_modified', $context );
196 196
     }
197 197
 
198 198
     /**
199
-	 * Get GMT date when the item was last modified.
200
-	 *
201
-	 * @since 1.0.19
202
-	 * @param  string $context View or edit context.
203
-	 * @return string
204
-	 */
205
-	public function get_date_modified_gmt( $context = 'view' ) {
199
+     * Get GMT date when the item was last modified.
200
+     *
201
+     * @since 1.0.19
202
+     * @param  string $context View or edit context.
203
+     * @return string
204
+     */
205
+    public function get_date_modified_gmt( $context = 'view' ) {
206 206
         $date = $this->get_date_modified( $context );
207 207
 
208 208
         if ( $date ) {
209 209
             $date = get_gmt_from_date( $date );
210 210
         }
211
-		return $date;
211
+        return $date;
212 212
     }
213 213
 
214 214
     /**
215
-	 * Get the item name.
216
-	 *
217
-	 * @since 1.0.19
218
-	 * @param  string $context View or edit context.
219
-	 * @return string
220
-	 */
221
-	public function get_name( $context = 'view' ) {
222
-		return $this->get_prop( 'name', $context );
215
+     * Get the item name.
216
+     *
217
+     * @since 1.0.19
218
+     * @param  string $context View or edit context.
219
+     * @return string
220
+     */
221
+    public function get_name( $context = 'view' ) {
222
+        return $this->get_prop( 'name', $context );
223 223
     }
224 224
 
225 225
     /**
226
-	 * Alias of self::get_name().
227
-	 *
228
-	 * @since 1.0.19
229
-	 * @param  string $context View or edit context.
230
-	 * @return string
231
-	 */
232
-	public function get_title( $context = 'view' ) {
233
-		return $this->get_name( $context );
226
+     * Alias of self::get_name().
227
+     *
228
+     * @since 1.0.19
229
+     * @param  string $context View or edit context.
230
+     * @return string
231
+     */
232
+    public function get_title( $context = 'view' ) {
233
+        return $this->get_name( $context );
234 234
     }
235 235
 
236 236
     /**
237
-	 * Get the item description.
238
-	 *
239
-	 * @since 1.0.19
240
-	 * @param  string $context View or edit context.
241
-	 * @return string
242
-	 */
243
-	public function get_description( $context = 'view' ) {
244
-		return $this->get_prop( 'description', $context );
237
+     * Get the item description.
238
+     *
239
+     * @since 1.0.19
240
+     * @param  string $context View or edit context.
241
+     * @return string
242
+     */
243
+    public function get_description( $context = 'view' ) {
244
+        return $this->get_prop( 'description', $context );
245 245
     }
246 246
 
247 247
     /**
248
-	 * Alias of self::get_description().
249
-	 *
250
-	 * @since 1.0.19
251
-	 * @param  string $context View or edit context.
252
-	 * @return string
253
-	 */
254
-	public function get_excerpt( $context = 'view' ) {
255
-		return $this->get_description( $context );
248
+     * Alias of self::get_description().
249
+     *
250
+     * @since 1.0.19
251
+     * @param  string $context View or edit context.
252
+     * @return string
253
+     */
254
+    public function get_excerpt( $context = 'view' ) {
255
+        return $this->get_description( $context );
256 256
     }
257 257
 
258 258
     /**
259
-	 * Alias of self::get_description().
260
-	 *
261
-	 * @since 1.0.19
262
-	 * @param  string $context View or edit context.
263
-	 * @return string
264
-	 */
265
-	public function get_summary( $context = 'view' ) {
266
-		return $this->get_description( $context );
259
+     * Alias of self::get_description().
260
+     *
261
+     * @since 1.0.19
262
+     * @param  string $context View or edit context.
263
+     * @return string
264
+     */
265
+    public function get_summary( $context = 'view' ) {
266
+        return $this->get_description( $context );
267 267
     }
268 268
 
269 269
     /**
270
-	 * Get the owner of the item.
271
-	 *
272
-	 * @since 1.0.19
273
-	 * @param  string $context View or edit context.
274
-	 * @return int
275
-	 */
276
-	public function get_author( $context = 'view' ) {
277
-		return (int) $this->get_prop( 'author', $context );
278
-	}
270
+     * Get the owner of the item.
271
+     *
272
+     * @since 1.0.19
273
+     * @param  string $context View or edit context.
274
+     * @return int
275
+     */
276
+    public function get_author( $context = 'view' ) {
277
+        return (int) $this->get_prop( 'author', $context );
278
+    }
279 279
 
280
-	/**
281
-	 * Alias of self::get_author().
282
-	 *
283
-	 * @since 1.0.19
284
-	 * @param  string $context View or edit context.
285
-	 * @return int
286
-	 */
287
-	public function get_owner( $context = 'view' ) {
288
-		return $this->get_author( $context );
280
+    /**
281
+     * Alias of self::get_author().
282
+     *
283
+     * @since 1.0.19
284
+     * @param  string $context View or edit context.
285
+     * @return int
286
+     */
287
+    public function get_owner( $context = 'view' ) {
288
+        return $this->get_author( $context );
289 289
     }
290 290
 
291 291
     /**
292
-	 * Get the price of the item.
293
-	 *
294
-	 * @since 1.0.19
295
-	 * @param  string $context View or edit context.
296
-	 * @return float
297
-	 */
298
-	public function get_price( $context = 'view' ) {
292
+     * Get the price of the item.
293
+     *
294
+     * @since 1.0.19
295
+     * @param  string $context View or edit context.
296
+     * @return float
297
+     */
298
+    public function get_price( $context = 'view' ) {
299 299
         return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
300
-	}
301
-
302
-	/**
303
-	 * Get the inital price of the item.
304
-	 *
305
-	 * @since 1.0.19
306
-	 * @param  string $context View or edit context.
307
-	 * @return float
308
-	 */
309
-	public function get_initial_price( $context = 'view', $price_id = null ) {
300
+    }
301
+
302
+    /**
303
+     * Get the inital price of the item.
304
+     *
305
+     * @since 1.0.19
306
+     * @param  string $context View or edit context.
307
+     * @return float
308
+     */
309
+    public function get_initial_price( $context = 'view', $price_id = null ) {
310 310
         $price = 0;
311 311
 
312 312
         if ( null === $price_id ) {
@@ -327,134 +327,134 @@  discard block
 block discarded – undo
327 327
     }
328 328
 
329 329
     /**
330
-	 * Returns a formated price.
331
-	 *
332
-	 * @since 1.0.19
333
-	 * @param  string $context View or edit context.
334
-	 * @return string
335
-	 */
330
+     * Returns a formated price.
331
+     *
332
+     * @since 1.0.19
333
+     * @param  string $context View or edit context.
334
+     * @return string
335
+     */
336 336
     public function get_the_price() {
337 337
         return wpinv_price( $this->get_price() );
338
-	}
339
-
340
-	/**
341
-	 * Returns the formated initial price.
342
-	 *
343
-	 * @since 1.0.19
344
-	 * @param  string $context View or edit context.
345
-	 * @return string
346
-	 */
338
+    }
339
+
340
+    /**
341
+     * Returns the formated initial price.
342
+     *
343
+     * @since 1.0.19
344
+     * @param  string $context View or edit context.
345
+     * @return string
346
+     */
347 347
     public function get_the_initial_price() {
348 348
         return wpinv_price( $this->get_initial_price() );
349 349
     }
350 350
 
351 351
     /**
352
-	 * Get the VAT rule of the item.
353
-	 *
354
-	 * @since 1.0.19
355
-	 * @param  string $context View or edit context.
356
-	 * @return string
357
-	 */
358
-	public function get_vat_rule( $context = 'view' ) {
352
+     * Get the VAT rule of the item.
353
+     *
354
+     * @since 1.0.19
355
+     * @param  string $context View or edit context.
356
+     * @return string
357
+     */
358
+    public function get_vat_rule( $context = 'view' ) {
359 359
         return $this->get_prop( 'vat_rule', $context );
360 360
     }
361 361
 
362 362
     /**
363
-	 * Get the VAT class of the item.
364
-	 *
365
-	 * @since 1.0.19
366
-	 * @param  string $context View or edit context.
367
-	 * @return string
368
-	 */
369
-	public function get_vat_class( $context = 'view' ) {
363
+     * Get the VAT class of the item.
364
+     *
365
+     * @since 1.0.19
366
+     * @param  string $context View or edit context.
367
+     * @return string
368
+     */
369
+    public function get_vat_class( $context = 'view' ) {
370 370
         return $this->get_prop( 'vat_class', $context );
371 371
     }
372 372
 
373 373
     /**
374
-	 * Get the type of the item.
375
-	 *
376
-	 * @since 1.0.19
377
-	 * @param  string $context View or edit context.
378
-	 * @return string
379
-	 */
380
-	public function get_type( $context = 'view' ) {
374
+     * Get the type of the item.
375
+     *
376
+     * @since 1.0.19
377
+     * @param  string $context View or edit context.
378
+     * @return string
379
+     */
380
+    public function get_type( $context = 'view' ) {
381 381
         return $this->get_prop( 'type', $context );
382 382
     }
383 383
 
384 384
     /**
385
-	 * Get the custom id of the item.
386
-	 *
387
-	 * @since 1.0.19
388
-	 * @param  string $context View or edit context.
389
-	 * @return string
390
-	 */
391
-	public function get_custom_id( $context = 'view' ) {
385
+     * Get the custom id of the item.
386
+     *
387
+     * @since 1.0.19
388
+     * @param  string $context View or edit context.
389
+     * @return string
390
+     */
391
+    public function get_custom_id( $context = 'view' ) {
392 392
         return $this->get_prop( 'custom_id', $context );
393 393
     }
394 394
 
395 395
     /**
396
-	 * Get the custom name of the item.
397
-	 *
398
-	 * @since 1.0.19
399
-	 * @param  string $context View or edit context.
400
-	 * @return string
401
-	 */
402
-	public function get_custom_name( $context = 'view' ) {
396
+     * Get the custom name of the item.
397
+     *
398
+     * @since 1.0.19
399
+     * @param  string $context View or edit context.
400
+     * @return string
401
+     */
402
+    public function get_custom_name( $context = 'view' ) {
403 403
         return $this->get_prop( 'custom_name', $context );
404 404
     }
405 405
 
406 406
     /**
407
-	 * Get the custom singular name of the item.
408
-	 *
409
-	 * @since 1.0.19
410
-	 * @param  string $context View or edit context.
411
-	 * @return string
412
-	 */
413
-	public function get_custom_singular_name( $context = 'view' ) {
407
+     * Get the custom singular name of the item.
408
+     *
409
+     * @since 1.0.19
410
+     * @param  string $context View or edit context.
411
+     * @return string
412
+     */
413
+    public function get_custom_singular_name( $context = 'view' ) {
414 414
         return $this->get_prop( 'custom_singular_name', $context );
415 415
     }
416 416
 
417 417
     /**
418
-	 * Checks if an item is editable..
419
-	 *
420
-	 * @since 1.0.19
421
-	 * @param  string $context View or edit context.
422
-	 * @return int
423
-	 */
424
-	public function get_is_editable( $context = 'view' ) {
418
+     * Checks if an item is editable..
419
+     *
420
+     * @since 1.0.19
421
+     * @param  string $context View or edit context.
422
+     * @return int
423
+     */
424
+    public function get_is_editable( $context = 'view' ) {
425 425
         return (int) $this->get_prop( 'is_editable', $context );
426 426
     }
427 427
 
428 428
     /**
429
-	 * Alias of self::get_is_editable().
430
-	 *
431
-	 * @since 1.0.19
432
-	 * @param  string $context View or edit context.
433
-	 * @return int
434
-	 */
435
-	public function get_editable( $context = 'view' ) {
436
-		return $this->get_is_editable( $context );
429
+     * Alias of self::get_is_editable().
430
+     *
431
+     * @since 1.0.19
432
+     * @param  string $context View or edit context.
433
+     * @return int
434
+     */
435
+    public function get_editable( $context = 'view' ) {
436
+        return $this->get_is_editable( $context );
437 437
     }
438 438
 
439 439
     /**
440
-	 * Checks if dynamic pricing is enabled.
441
-	 *
442
-	 * @since 1.0.19
443
-	 * @param  string $context View or edit context.
444
-	 * @return int
445
-	 */
446
-	public function get_is_dynamic_pricing( $context = 'view' ) {
440
+     * Checks if dynamic pricing is enabled.
441
+     *
442
+     * @since 1.0.19
443
+     * @param  string $context View or edit context.
444
+     * @return int
445
+     */
446
+    public function get_is_dynamic_pricing( $context = 'view' ) {
447 447
         return (int) $this->get_prop( 'is_dynamic_pricing', $context );
448 448
     }
449 449
 
450 450
     /**
451
-	 * Returns the minimum price if dynamic pricing is enabled.
452
-	 *
453
-	 * @since 1.0.19
454
-	 * @param  string $context View or edit context.
455
-	 * @return float
456
-	 */
457
-	public function get_minimum_price( $context = 'view' ) {
451
+     * Returns the minimum price if dynamic pricing is enabled.
452
+     *
453
+     * @since 1.0.19
454
+     * @param  string $context View or edit context.
455
+     * @return float
456
+     */
457
+    public function get_minimum_price( $context = 'view' ) {
458 458
         return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
459 459
     }
460 460
 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
     /**
529 529
      * Retrieve the variable prices
530 530
      *
531
-    * @since 2.8.9
531
+     * @since 2.8.9
532 532
      * @return array List of the variable prices
533 533
      */
534 534
     public function get_variable_prices() {
@@ -542,76 +542,76 @@  discard block
 block discarded – undo
542 542
     }
543 543
 
544 544
     /**
545
-	 * Checks if this is a recurring item.
546
-	 *
547
-	 * @since 1.0.19
548
-	 * @param  string $context View or edit context.
549
-	 * @return int
550
-	 */
551
-	public function get_is_recurring( $context = 'view' ) {
545
+     * Checks if this is a recurring item.
546
+     *
547
+     * @since 1.0.19
548
+     * @param  string $context View or edit context.
549
+     * @return int
550
+     */
551
+    public function get_is_recurring( $context = 'view' ) {
552 552
         return (int) $this->get_prop( 'is_recurring', $context );
553
-	}
554
-
555
-	/**
556
-	 * Get the recurring price of the item.
557
-	 *
558
-	 * @since 1.0.19
559
-	 * @param  string $context View or edit context.
560
-	 * @return float
561
-	 */
562
-	public function get_recurring_price( $context = 'view' ) {
563
-		$price = $this->get_price( $context );
553
+    }
554
+
555
+    /**
556
+     * Get the recurring price of the item.
557
+     *
558
+     * @since 1.0.19
559
+     * @param  string $context View or edit context.
560
+     * @return float
561
+     */
562
+    public function get_recurring_price( $context = 'view' ) {
563
+        $price = $this->get_price( $context );
564 564
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
565
-	}
566
-
567
-	/**
568
-	 * Get the formatted recurring price of the item.
569
-	 *
570
-	 * @since 1.0.19
571
-	 * @param  string $context View or edit context.
572
-	 * @return string
573
-	 */
565
+    }
566
+
567
+    /**
568
+     * Get the formatted recurring price of the item.
569
+     *
570
+     * @since 1.0.19
571
+     * @param  string $context View or edit context.
572
+     * @return string
573
+     */
574 574
     public function get_the_recurring_price() {
575 575
         return wpinv_price( $this->get_recurring_price() );
576
-	}
577
-
578
-	/**
579
-	 * Get the first renewal date (in timestamps) of the item.
580
-	 *
581
-	 * @since 1.0.19
582
-	 * @return int
583
-	 */
584
-	public function get_first_renewal_date() {
585
-
586
-		$periods = array(
587
-			'D' => 'days',
588
-			'W' => 'weeks',
589
-			'M' => 'months',
590
-			'Y' => 'years',
591
-		);
592
-
593
-		$period   = $this->get_recurring_period();
594
-		$interval = $this->get_recurring_interval();
595
-
596
-		if ( $this->has_free_trial() ) {
597
-			$period   = $this->get_trial_period();
598
-			$interval = $this->get_trial_interval();
599
-		}
600
-
601
-		$period       = $periods[ $period ];
602
-		$interval     = empty( $interval ) ? 1 : $interval;
603
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
576
+    }
577
+
578
+    /**
579
+     * Get the first renewal date (in timestamps) of the item.
580
+     *
581
+     * @since 1.0.19
582
+     * @return int
583
+     */
584
+    public function get_first_renewal_date() {
585
+
586
+        $periods = array(
587
+            'D' => 'days',
588
+            'W' => 'weeks',
589
+            'M' => 'months',
590
+            'Y' => 'years',
591
+        );
592
+
593
+        $period   = $this->get_recurring_period();
594
+        $interval = $this->get_recurring_interval();
595
+
596
+        if ( $this->has_free_trial() ) {
597
+            $period   = $this->get_trial_period();
598
+            $interval = $this->get_trial_interval();
599
+        }
600
+
601
+        $period       = $periods[ $period ];
602
+        $interval     = empty( $interval ) ? 1 : $interval;
603
+        $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
604 604
         return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
605 605
     }
606 606
 
607 607
     /**
608
-	 * Get the recurring period.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @param  bool $full Return abbreviation or in full.
612
-	 * @return string
613
-	 */
614
-	public function get_recurring_period( $full = false ) {
608
+     * Get the recurring period.
609
+     *
610
+     * @since 1.0.19
611
+     * @param  bool $full Return abbreviation or in full.
612
+     * @return string
613
+     */
614
+    public function get_recurring_period( $full = false ) {
615 615
         $period = $this->get_prop( 'recurring_period', 'view' );
616 616
 
617 617
         if ( $full && ! is_bool( $full ) ) {
@@ -622,58 +622,58 @@  discard block
 block discarded – undo
622 622
     }
623 623
 
624 624
     /**
625
-	 * Get the recurring interval.
626
-	 *
627
-	 * @since 1.0.19
628
-	 * @param  string $context View or edit context.
629
-	 * @return int
630
-	 */
631
-	public function get_recurring_interval( $context = 'view' ) {
632
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
633
-		return max( 1, $interval );
625
+     * Get the recurring interval.
626
+     *
627
+     * @since 1.0.19
628
+     * @param  string $context View or edit context.
629
+     * @return int
630
+     */
631
+    public function get_recurring_interval( $context = 'view' ) {
632
+        $interval = absint( $this->get_prop( 'recurring_interval', $context ) );
633
+        return max( 1, $interval );
634 634
     }
635 635
 
636 636
     /**
637
-	 * Get the recurring limit.
638
-	 *
639
-	 * @since 1.0.19
640
-	 * @param  string $context View or edit context.
641
-	 * @return int
642
-	 */
643
-	public function get_recurring_limit( $context = 'view' ) {
637
+     * Get the recurring limit.
638
+     *
639
+     * @since 1.0.19
640
+     * @param  string $context View or edit context.
641
+     * @return int
642
+     */
643
+    public function get_recurring_limit( $context = 'view' ) {
644 644
         return (int) $this->get_prop( 'recurring_limit', $context );
645 645
     }
646 646
 
647 647
     /**
648
-	 * Checks if we have a free trial.
649
-	 *
650
-	 * @since 1.0.19
651
-	 * @param  string $context View or edit context.
652
-	 * @return int
653
-	 */
654
-	public function get_is_free_trial( $context = 'view' ) {
648
+     * Checks if we have a free trial.
649
+     *
650
+     * @since 1.0.19
651
+     * @param  string $context View or edit context.
652
+     * @return int
653
+     */
654
+    public function get_is_free_trial( $context = 'view' ) {
655 655
         return (int) $this->get_prop( 'is_free_trial', $context );
656 656
     }
657 657
 
658 658
     /**
659
-	 * Alias for self::get_is_free_trial().
660
-	 *
661
-	 * @since 1.0.19
662
-	 * @param  string $context View or edit context.
663
-	 * @return int
664
-	 */
665
-	public function get_free_trial( $context = 'view' ) {
659
+     * Alias for self::get_is_free_trial().
660
+     *
661
+     * @since 1.0.19
662
+     * @param  string $context View or edit context.
663
+     * @return int
664
+     */
665
+    public function get_free_trial( $context = 'view' ) {
666 666
         return $this->get_is_free_trial( $context );
667 667
     }
668 668
 
669 669
     /**
670
-	 * Get the trial period.
671
-	 *
672
-	 * @since 1.0.19
673
-	 * @param  bool $full Return abbreviation or in full.
674
-	 * @return string
675
-	 */
676
-	public function get_trial_period( $full = false ) {
670
+     * Get the trial period.
671
+     *
672
+     * @since 1.0.19
673
+     * @param  bool $full Return abbreviation or in full.
674
+     * @return string
675
+     */
676
+    public function get_trial_period( $full = false ) {
677 677
         $period = $this->get_prop( 'trial_period', 'view' );
678 678
 
679 679
         if ( $full && ! is_bool( $full ) ) {
@@ -684,104 +684,104 @@  discard block
 block discarded – undo
684 684
     }
685 685
 
686 686
     /**
687
-	 * Get the trial interval.
688
-	 *
689
-	 * @since 1.0.19
690
-	 * @param  string $context View or edit context.
691
-	 * @return int
692
-	 */
693
-	public function get_trial_interval( $context = 'view' ) {
687
+     * Get the trial interval.
688
+     *
689
+     * @since 1.0.19
690
+     * @param  string $context View or edit context.
691
+     * @return int
692
+     */
693
+    public function get_trial_interval( $context = 'view' ) {
694 694
         return (int) $this->get_prop( 'trial_interval', $context );
695
-	}
696
-
697
-	/**
698
-	 * Get the item's edit url.
699
-	 *
700
-	 * @since 1.0.19
701
-	 * @return string
702
-	 */
703
-	public function get_edit_url() {
695
+    }
696
+
697
+    /**
698
+     * Get the item's edit url.
699
+     *
700
+     * @since 1.0.19
701
+     * @return string
702
+     */
703
+    public function get_edit_url() {
704 704
         return get_edit_post_link( $this->get_id(), 'edit' );
705
-	}
706
-
707
-	/**
708
-	 * Given an item's name/custom id, it returns its id.
709
-	 *
710
-	 *
711
-	 * @static
712
-	 * @param string $value The item name or custom id.
713
-	 * @param string $field Either name or custom_id.
714
-	 * @param string $type in case you need to search for a given type.
715
-	 * @since 1.0.15
716
-	 * @return int
717
-	 */
718
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
719
-
720
-		// Trim the value.
721
-		$value = sanitize_text_field( $value );
722
-		if ( empty( $value ) ) {
723
-			return 0;
724
-		}
705
+    }
706
+
707
+    /**
708
+     * Given an item's name/custom id, it returns its id.
709
+     *
710
+     *
711
+     * @static
712
+     * @param string $value The item name or custom id.
713
+     * @param string $field Either name or custom_id.
714
+     * @param string $type in case you need to search for a given type.
715
+     * @since 1.0.15
716
+     * @return int
717
+     */
718
+    public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
719
+
720
+        // Trim the value.
721
+        $value = sanitize_text_field( $value );
722
+        if ( empty( $value ) ) {
723
+            return 0;
724
+        }
725 725
 
726 726
         // Valid fields.
727 727
         $fields = array( 'custom_id', 'name', 'slug' );
728 728
 
729
-		// Ensure a field has been passed.
730
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
731
-			return 0;
732
-		}
733
-
734
-		if ( $field == 'name' ) {
735
-			$field = 'slug';
736
-		}
737
-
738
-		// Maybe retrieve from the cache.
739
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
740
-		if ( ! empty( $item_id ) ) {
741
-			return $item_id;
742
-		}
743
-
744
-		// Fetch from the db.
745
-		$items = array();
746
-		if ( $field == 'slug' ) {
747
-			$items = get_posts(
748
-				array(
749
-					'post_type'      => 'wpi_item',
750
-					'name'           => $value,
751
-					'posts_per_page' => 1,
752
-					'post_status'    => 'any',
753
-				)
754
-			);
755
-		}
756
-
757
-		if ( $field == 'custom_id' ) {
758
-			$items = get_posts(
759
-				array(
760
-					'post_type'      => 'wpi_item',
761
-					'posts_per_page' => 1,
762
-					'post_status'    => 'any',
763
-					'meta_query'     => array(
764
-						array(
765
-							'key'   => '_wpinv_type',
766
-                			'value' => $type,
767
-						),
768
-						array(
769
-							'key'   => '_wpinv_custom_id',
770
-                			'value' => $value,
771
-						),
772
-					),
773
-				)
774
-			);
775
-		}
776
-
777
-		if ( empty( $items ) ) {
778
-			return 0;
779
-		}
780
-
781
-		// Update the cache with our data
782
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
783
-
784
-		return $items[0]->ID;
729
+        // Ensure a field has been passed.
730
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
731
+            return 0;
732
+        }
733
+
734
+        if ( $field == 'name' ) {
735
+            $field = 'slug';
736
+        }
737
+
738
+        // Maybe retrieve from the cache.
739
+        $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
740
+        if ( ! empty( $item_id ) ) {
741
+            return $item_id;
742
+        }
743
+
744
+        // Fetch from the db.
745
+        $items = array();
746
+        if ( $field == 'slug' ) {
747
+            $items = get_posts(
748
+                array(
749
+                    'post_type'      => 'wpi_item',
750
+                    'name'           => $value,
751
+                    'posts_per_page' => 1,
752
+                    'post_status'    => 'any',
753
+                )
754
+            );
755
+        }
756
+
757
+        if ( $field == 'custom_id' ) {
758
+            $items = get_posts(
759
+                array(
760
+                    'post_type'      => 'wpi_item',
761
+                    'posts_per_page' => 1,
762
+                    'post_status'    => 'any',
763
+                    'meta_query'     => array(
764
+                        array(
765
+                            'key'   => '_wpinv_type',
766
+                            'value' => $type,
767
+                        ),
768
+                        array(
769
+                            'key'   => '_wpinv_custom_id',
770
+                            'value' => $value,
771
+                        ),
772
+                    ),
773
+                )
774
+            );
775
+        }
776
+
777
+        if ( empty( $items ) ) {
778
+            return 0;
779
+        }
780
+
781
+        // Update the cache with our data
782
+        wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
783
+
784
+        return $items[0]->ID;
785 785
     }
786 786
 
787 787
     /**
@@ -813,52 +813,52 @@  discard block
 block discarded – undo
813 813
     */
814 814
 
815 815
     /**
816
-	 * Set parent order ID.
817
-	 *
818
-	 * @since 1.0.19
819
-	 */
820
-	public function set_parent_id( $value ) {
821
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
822
-			return;
823
-		}
824
-		$this->set_prop( 'parent_id', absint( $value ) );
825
-	}
826
-
827
-    /**
828
-	 * Sets item status.
829
-	 *
830
-	 * @since 1.0.19
831
-	 * @param  string $status New status.
832
-	 * @return array details of change.
833
-	 */
834
-	public function set_status( $status ) {
816
+     * Set parent order ID.
817
+     *
818
+     * @since 1.0.19
819
+     */
820
+    public function set_parent_id( $value ) {
821
+        if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
822
+            return;
823
+        }
824
+        $this->set_prop( 'parent_id', absint( $value ) );
825
+    }
826
+
827
+    /**
828
+     * Sets item status.
829
+     *
830
+     * @since 1.0.19
831
+     * @param  string $status New status.
832
+     * @return array details of change.
833
+     */
834
+    public function set_status( $status ) {
835 835
         $old_status = $this->get_status();
836 836
 
837 837
         $this->set_prop( 'status', $status );
838 838
 
839
-		return array(
840
-			'from' => $old_status,
841
-			'to'   => $status,
842
-		);
839
+        return array(
840
+            'from' => $old_status,
841
+            'to'   => $status,
842
+        );
843 843
     }
844 844
 
845 845
     /**
846
-	 * Set plugin version when the item was created.
847
-	 *
848
-	 * @since 1.0.19
849
-	 */
850
-	public function set_version( $value ) {
851
-		$this->set_prop( 'version', $value );
846
+     * Set plugin version when the item was created.
847
+     *
848
+     * @since 1.0.19
849
+     */
850
+    public function set_version( $value ) {
851
+        $this->set_prop( 'version', $value );
852 852
     }
853 853
 
854 854
     /**
855
-	 * Set date when the item was created.
856
-	 *
857
-	 * @since 1.0.19
858
-	 * @param string $value Value to set.
855
+     * Set date when the item was created.
856
+     *
857
+     * @since 1.0.19
858
+     * @param string $value Value to set.
859 859
      * @return bool Whether or not the date was set.
860
-	 */
861
-	public function set_date_created( $value ) {
860
+     */
861
+    public function set_date_created( $value ) {
862 862
         $date = strtotime( $value );
863 863
 
864 864
         if ( $date ) {
@@ -870,13 +870,13 @@  discard block
 block discarded – undo
870 870
     }
871 871
 
872 872
     /**
873
-	 * Set date when the item was last modified.
874
-	 *
875
-	 * @since 1.0.19
876
-	 * @param string $value Value to set.
873
+     * Set date when the item was last modified.
874
+     *
875
+     * @since 1.0.19
876
+     * @param string $value Value to set.
877 877
      * @return bool Whether or not the date was set.
878
-	 */
879
-	public function set_date_modified( $value ) {
878
+     */
879
+    public function set_date_modified( $value ) {
880 880
         $date = strtotime( $value );
881 881
 
882 882
         if ( $date ) {
@@ -888,115 +888,115 @@  discard block
 block discarded – undo
888 888
     }
889 889
 
890 890
     /**
891
-	 * Set the item name.
892
-	 *
893
-	 * @since 1.0.19
894
-	 * @param  string $value New name.
895
-	 */
896
-	public function set_name( $value ) {
891
+     * Set the item name.
892
+     *
893
+     * @since 1.0.19
894
+     * @param  string $value New name.
895
+     */
896
+    public function set_name( $value ) {
897 897
         $name = sanitize_text_field( $value );
898
-		$this->set_prop( 'name', $name );
898
+        $this->set_prop( 'name', $name );
899 899
     }
900 900
 
901 901
     /**
902
-	 * Alias of self::set_name().
903
-	 *
904
-	 * @since 1.0.19
905
-	 * @param  string $value New name.
906
-	 */
907
-	public function set_title( $value ) {
908
-		$this->set_name( $value );
902
+     * Alias of self::set_name().
903
+     *
904
+     * @since 1.0.19
905
+     * @param  string $value New name.
906
+     */
907
+    public function set_title( $value ) {
908
+        $this->set_name( $value );
909 909
     }
910 910
 
911 911
     /**
912
-	 * Set the item description.
913
-	 *
914
-	 * @since 1.0.19
915
-	 * @param  string $value New description.
916
-	 */
917
-	public function set_description( $value ) {
918
-		$description = wp_kses_post( wp_unslash( $value ) );
919
-		return $this->set_prop( 'description', $description );
912
+     * Set the item description.
913
+     *
914
+     * @since 1.0.19
915
+     * @param  string $value New description.
916
+     */
917
+    public function set_description( $value ) {
918
+        $description = wp_kses_post( wp_unslash( $value ) );
919
+        return $this->set_prop( 'description', $description );
920 920
     }
921 921
 
922 922
     /**
923
-	 * Alias of self::set_description().
924
-	 *
925
-	 * @since 1.0.19
926
-	 * @param  string $value New description.
927
-	 */
928
-	public function set_excerpt( $value ) {
929
-		$this->set_description( $value );
923
+     * Alias of self::set_description().
924
+     *
925
+     * @since 1.0.19
926
+     * @param  string $value New description.
927
+     */
928
+    public function set_excerpt( $value ) {
929
+        $this->set_description( $value );
930 930
     }
931 931
 
932 932
     /**
933
-	 * Alias of self::set_description().
934
-	 *
935
-	 * @since 1.0.19
936
-	 * @param  string $value New description.
937
-	 */
938
-	public function set_summary( $value ) {
939
-		$this->set_description( $value );
933
+     * Alias of self::set_description().
934
+     *
935
+     * @since 1.0.19
936
+     * @param  string $value New description.
937
+     */
938
+    public function set_summary( $value ) {
939
+        $this->set_description( $value );
940 940
     }
941 941
 
942 942
     /**
943
-	 * Set the owner of the item.
944
-	 *
945
-	 * @since 1.0.19
946
-	 * @param  int $value New author.
947
-	 */
948
-	public function set_author( $value ) {
949
-		$this->set_prop( 'author', (int) $value );
950
-	}
943
+     * Set the owner of the item.
944
+     *
945
+     * @since 1.0.19
946
+     * @param  int $value New author.
947
+     */
948
+    public function set_author( $value ) {
949
+        $this->set_prop( 'author', (int) $value );
950
+    }
951 951
 
952
-	/**
953
-	 * Alias of self::set_author().
954
-	 *
955
-	 * @since 1.0.19
956
-	 * @param  int $value New author.
957
-	 */
958
-	public function set_owner( $value ) {
959
-		$this->set_author( $value );
952
+    /**
953
+     * Alias of self::set_author().
954
+     *
955
+     * @since 1.0.19
956
+     * @param  int $value New author.
957
+     */
958
+    public function set_owner( $value ) {
959
+        $this->set_author( $value );
960 960
     }
961 961
 
962 962
     /**
963
-	 * Set the price of the item.
964
-	 *
965
-	 * @since 1.0.19
966
-	 * @param  float $value New price.
967
-	 */
968
-	public function set_price( $value ) {
963
+     * Set the price of the item.
964
+     *
965
+     * @since 1.0.19
966
+     * @param  float $value New price.
967
+     */
968
+    public function set_price( $value ) {
969 969
         $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
970 970
     }
971 971
 
972 972
     /**
973
-	 * Set the VAT rule of the item.
974
-	 *
975
-	 * @since 1.0.19
976
-	 * @param  string $value new rule.
977
-	 */
978
-	public function set_vat_rule( $value ) {
973
+     * Set the VAT rule of the item.
974
+     *
975
+     * @since 1.0.19
976
+     * @param  string $value new rule.
977
+     */
978
+    public function set_vat_rule( $value ) {
979 979
         $this->set_prop( 'vat_rule', $value );
980 980
     }
981 981
 
982 982
     /**
983
-	 * Set the VAT class of the item.
984
-	 *
985
-	 * @since 1.0.19
986
-	 * @param  string $value new class.
987
-	 */
988
-	public function set_vat_class( $value ) {
983
+     * Set the VAT class of the item.
984
+     *
985
+     * @since 1.0.19
986
+     * @param  string $value new class.
987
+     */
988
+    public function set_vat_class( $value ) {
989 989
         $this->set_prop( 'vat_class', $value );
990 990
     }
991 991
 
992 992
     /**
993
-	 * Set the type of the item.
994
-	 *
995
-	 * @since 1.0.19
996
-	 * @param  string $value new item type.
997
-	 * @return string
998
-	 */
999
-	public function set_type( $value ) {
993
+     * Set the type of the item.
994
+     *
995
+     * @since 1.0.19
996
+     * @param  string $value new item type.
997
+     * @return string
998
+     */
999
+    public function set_type( $value ) {
1000 1000
 
1001 1001
         if ( empty( $value ) ) {
1002 1002
             $value = 'custom';
@@ -1006,102 +1006,102 @@  discard block
 block discarded – undo
1006 1006
     }
1007 1007
 
1008 1008
     /**
1009
-	 * Set the custom id of the item.
1010
-	 *
1011
-	 * @since 1.0.19
1012
-	 * @param  string $value new custom id.
1013
-	 */
1014
-	public function set_custom_id( $value ) {
1009
+     * Set the custom id of the item.
1010
+     *
1011
+     * @since 1.0.19
1012
+     * @param  string $value new custom id.
1013
+     */
1014
+    public function set_custom_id( $value ) {
1015 1015
         $this->set_prop( 'custom_id', $value );
1016 1016
     }
1017 1017
 
1018 1018
     /**
1019
-	 * Set the custom name of the item.
1020
-	 *
1021
-	 * @since 1.0.19
1022
-	 * @param  string $value new custom name.
1023
-	 */
1024
-	public function set_custom_name( $value ) {
1019
+     * Set the custom name of the item.
1020
+     *
1021
+     * @since 1.0.19
1022
+     * @param  string $value new custom name.
1023
+     */
1024
+    public function set_custom_name( $value ) {
1025 1025
         $this->set_prop( 'custom_name', $value );
1026 1026
     }
1027 1027
 
1028 1028
     /**
1029
-	 * Set the custom singular name of the item.
1030
-	 *
1031
-	 * @since 1.0.19
1032
-	 * @param  string $value new custom singular name.
1033
-	 */
1034
-	public function set_custom_singular_name( $value ) {
1029
+     * Set the custom singular name of the item.
1030
+     *
1031
+     * @since 1.0.19
1032
+     * @param  string $value new custom singular name.
1033
+     */
1034
+    public function set_custom_singular_name( $value ) {
1035 1035
         $this->set_prop( 'custom_singular_name', $value );
1036 1036
     }
1037 1037
 
1038 1038
     /**
1039
-	 * Sets if an item is editable..
1040
-	 *
1041
-	 * @since 1.0.19
1042
-	 * @param  int|bool $value whether or not the item is editable.
1043
-	 */
1044
-	public function set_is_editable( $value ) {
1045
-		$this->set_prop( 'is_editable', (int) $value );
1039
+     * Sets if an item is editable..
1040
+     *
1041
+     * @since 1.0.19
1042
+     * @param  int|bool $value whether or not the item is editable.
1043
+     */
1044
+    public function set_is_editable( $value ) {
1045
+        $this->set_prop( 'is_editable', (int) $value );
1046 1046
     }
1047 1047
 
1048 1048
     /**
1049
-	 * Sets if dynamic pricing is enabled.
1050
-	 *
1051
-	 * @since 1.0.19
1052
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
1053
-	 */
1054
-	public function set_is_dynamic_pricing( $value ) {
1049
+     * Sets if dynamic pricing is enabled.
1050
+     *
1051
+     * @since 1.0.19
1052
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
1053
+     */
1054
+    public function set_is_dynamic_pricing( $value ) {
1055 1055
         $this->set_prop( 'is_dynamic_pricing', (int) $value );
1056 1056
     }
1057 1057
 
1058 1058
     /**
1059
-	 * Sets the minimum price if dynamic pricing is enabled.
1060
-	 *
1061
-	 * @since 1.0.19
1062
-	 * @param  float $value minimum price.
1063
-	 */
1064
-	public function set_minimum_price( $value ) {
1059
+     * Sets the minimum price if dynamic pricing is enabled.
1060
+     *
1061
+     * @since 1.0.19
1062
+     * @param  float $value minimum price.
1063
+     */
1064
+    public function set_minimum_price( $value ) {
1065 1065
         $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) );
1066 1066
     }
1067 1067
 
1068 1068
     /**
1069
-	 * Sets if this item has multi price mode.
1070
-	 *
1071
-	 * @since 1.0.19
1072
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
1073
-	 */
1074
-	public function set_is_multi_price_mode( $value ) {
1069
+     * Sets if this item has multi price mode.
1070
+     *
1071
+     * @since 1.0.19
1072
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
1073
+     */
1074
+    public function set_is_multi_price_mode( $value ) {
1075 1075
         $this->set_prop( 'is_multi_price_mode', (int) $value );
1076 1076
     }
1077 1077
 
1078 1078
     /**
1079
-	 * Sets if this item has variable pricing.
1080
-	 *
1081
-	 * @since 1.0.19
1082
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
1083
-	 */
1084
-	public function set_has_variable_pricing( $value ) {
1079
+     * Sets if this item has variable pricing.
1080
+     *
1081
+     * @since 1.0.19
1082
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
1083
+     */
1084
+    public function set_has_variable_pricing( $value ) {
1085 1085
         $this->set_prop( 'has_variable_pricing', (int) $value );
1086 1086
     }
1087 1087
 
1088 1088
     /**
1089
-	 * Set the default price ID.
1090
-	 *
1091
-	 * @since 1.0.19
1092
-	 * @param  int $value default price ID.
1093
-	 */
1094
-	public function set_default_price_id( $value ) {
1089
+     * Set the default price ID.
1090
+     *
1091
+     * @since 1.0.19
1092
+     * @param  int $value default price ID.
1093
+     */
1094
+    public function set_default_price_id( $value ) {
1095 1095
         return $this->set_prop( 'default_price_id', (int) $value );
1096 1096
     }
1097 1097
 
1098 1098
     /**
1099
-	 * Set the variable prices.
1100
-	 *
1101
-	 * @since 1.0.19
1102
-	 * @param  int $prices variable prices.
1103
-	 */
1104
-	public function set_variable_prices( $prices ) {
1099
+     * Set the variable prices.
1100
+     *
1101
+     * @since 1.0.19
1102
+     * @param  int $prices variable prices.
1103
+     */
1104
+    public function set_variable_prices( $prices ) {
1105 1105
         if ( ! is_array( $prices ) ) {
1106 1106
             $prices = array();
1107 1107
         }
@@ -1121,72 +1121,72 @@  discard block
 block discarded – undo
1121 1121
     }
1122 1122
 
1123 1123
     /**
1124
-	 * Sets if this is a recurring item.
1125
-	 *
1126
-	 * @since 1.0.19
1127
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
1128
-	 */
1129
-	public function set_is_recurring( $value ) {
1124
+     * Sets if this is a recurring item.
1125
+     *
1126
+     * @since 1.0.19
1127
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
1128
+     */
1129
+    public function set_is_recurring( $value ) {
1130 1130
         $this->set_prop( 'is_recurring', (int) $value );
1131 1131
     }
1132 1132
 
1133 1133
     /**
1134
-	 * Set the recurring period.
1135
-	 *
1136
-	 * @since 1.0.19
1137
-	 * @param  string $value new period.
1138
-	 */
1139
-	public function set_recurring_period( $value ) {
1134
+     * Set the recurring period.
1135
+     *
1136
+     * @since 1.0.19
1137
+     * @param  string $value new period.
1138
+     */
1139
+    public function set_recurring_period( $value ) {
1140 1140
         $this->set_prop( 'recurring_period', $value );
1141 1141
     }
1142 1142
 
1143 1143
     /**
1144
-	 * Set the recurring interval.
1145
-	 *
1146
-	 * @since 1.0.19
1147
-	 * @param  int $value recurring interval.
1148
-	 */
1149
-	public function set_recurring_interval( $value ) {
1144
+     * Set the recurring interval.
1145
+     *
1146
+     * @since 1.0.19
1147
+     * @param  int $value recurring interval.
1148
+     */
1149
+    public function set_recurring_interval( $value ) {
1150 1150
         return $this->set_prop( 'recurring_interval', (int) $value );
1151 1151
     }
1152 1152
 
1153 1153
     /**
1154
-	 * Get the recurring limit.
1155
-	 * @since 1.0.19
1156
-	 * @param  int $value The recurring limit.
1157
-	 * @return int
1158
-	 */
1159
-	public function set_recurring_limit( $value ) {
1154
+     * Get the recurring limit.
1155
+     * @since 1.0.19
1156
+     * @param  int $value The recurring limit.
1157
+     * @return int
1158
+     */
1159
+    public function set_recurring_limit( $value ) {
1160 1160
         $this->set_prop( 'recurring_limit', (int) $value );
1161 1161
     }
1162 1162
 
1163 1163
     /**
1164
-	 * Checks if we have a free trial.
1165
-	 *
1166
-	 * @since 1.0.19
1167
-	 * @param  int|bool $value whether or not it has a free trial.
1168
-	 */
1169
-	public function set_is_free_trial( $value ) {
1164
+     * Checks if we have a free trial.
1165
+     *
1166
+     * @since 1.0.19
1167
+     * @param  int|bool $value whether or not it has a free trial.
1168
+     */
1169
+    public function set_is_free_trial( $value ) {
1170 1170
         $this->set_prop( 'is_free_trial', (int) $value );
1171 1171
     }
1172 1172
 
1173 1173
     /**
1174
-	 * Set the trial period.
1175
-	 *
1176
-	 * @since 1.0.19
1177
-	 * @param  string $value trial period.
1178
-	 */
1179
-	public function set_trial_period( $value ) {
1174
+     * Set the trial period.
1175
+     *
1176
+     * @since 1.0.19
1177
+     * @param  string $value trial period.
1178
+     */
1179
+    public function set_trial_period( $value ) {
1180 1180
         $this->set_prop( 'trial_period', $value );
1181 1181
     }
1182 1182
 
1183 1183
     /**
1184
-	 * Set the trial interval.
1185
-	 *
1186
-	 * @since 1.0.19
1187
-	 * @param  int $value trial interval.
1188
-	 */
1189
-	public function set_trial_interval( $value ) {
1184
+     * Set the trial interval.
1185
+     *
1186
+     * @since 1.0.19
1187
+     * @param  int $value trial interval.
1188
+     */
1189
+    public function set_trial_interval( $value ) {
1190 1190
         $this->set_prop( 'trial_interval', $value );
1191 1191
     }
1192 1192
 
@@ -1194,24 +1194,24 @@  discard block
 block discarded – undo
1194 1194
      * Create an item. For backwards compatibilty.
1195 1195
      *
1196 1196
      * @deprecated
1197
-	 * @return int item id
1197
+     * @return int item id
1198 1198
      */
1199 1199
     public function create( $data = array() ) {
1200 1200
 
1201
-		// Set the properties.
1202
-		if ( is_array( $data ) ) {
1203
-			$this->set_props( $data );
1204
-		}
1201
+        // Set the properties.
1202
+        if ( is_array( $data ) ) {
1203
+            $this->set_props( $data );
1204
+        }
1205 1205
 
1206
-		// Save the item.
1207
-		return $this->save();
1206
+        // Save the item.
1207
+        return $this->save();
1208 1208
     }
1209 1209
 
1210 1210
     /**
1211 1211
      * Updates an item. For backwards compatibilty.
1212 1212
      *
1213 1213
      * @deprecated
1214
-	 * @return int item id
1214
+     * @return int item id
1215 1215
      */
1216 1216
     public function update( $data = array() ) {
1217 1217
         return $this->create( $data );
@@ -1227,93 +1227,93 @@  discard block
 block discarded – undo
1227 1227
 	*/
1228 1228
 
1229 1229
     /**
1230
-	 * Checks whether the item has enabled dynamic pricing.
1231
-	 *
1232
-	 * @since 1.0.19
1233
-	 * @return bool
1234
-	 */
1235
-	public function user_can_set_their_price() {
1230
+     * Checks whether the item has enabled dynamic pricing.
1231
+     *
1232
+     * @since 1.0.19
1233
+     * @return bool
1234
+     */
1235
+    public function user_can_set_their_price() {
1236 1236
         return (bool) $this->get_is_dynamic_pricing();
1237
-	}
1238
-
1239
-	/**
1240
-	 * Checks whether the item is recurring.
1241
-	 *
1242
-	 * @since 1.0.19
1243
-	 * @return bool
1244
-	 */
1245
-	public function is_recurring() {
1237
+    }
1238
+
1239
+    /**
1240
+     * Checks whether the item is recurring.
1241
+     *
1242
+     * @since 1.0.19
1243
+     * @return bool
1244
+     */
1245
+    public function is_recurring() {
1246 1246
         return (bool) $this->get_is_recurring();
1247 1247
     }
1248 1248
 
1249 1249
     /**
1250
-	 * Checks whether the item has a free trial.
1251
-	 *
1252
-	 * @since 1.0.19
1253
-	 * @return bool
1254
-	 */
1250
+     * Checks whether the item has a free trial.
1251
+     *
1252
+     * @since 1.0.19
1253
+     * @return bool
1254
+     */
1255 1255
     public function has_free_trial() {
1256 1256
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1257 1257
         return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1258 1258
     }
1259 1259
 
1260 1260
     /**
1261
-	 * Checks whether the item is free.
1262
-	 *
1263
-	 * @since 1.0.19
1264
-	 * @return bool
1265
-	 */
1261
+     * Checks whether the item is free.
1262
+     *
1263
+     * @since 1.0.19
1264
+     * @return bool
1265
+     */
1266 1266
     public function is_free() {
1267 1267
         $is_free   = $this->get_price() == 0;
1268 1268
         return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1269 1269
     }
1270 1270
 
1271 1271
     /**
1272
-	 * Checks the item status against a passed in status.
1273
-	 *
1274
-	 * @param array|string $status Status to check.
1275
-	 * @return bool
1276
-	 */
1277
-	public function has_status( $status ) {
1278
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1279
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1272
+     * Checks the item status against a passed in status.
1273
+     *
1274
+     * @param array|string $status Status to check.
1275
+     * @return bool
1276
+     */
1277
+    public function has_status( $status ) {
1278
+        $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1279
+        return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1280 1280
     }
1281 1281
 
1282 1282
     /**
1283
-	 * Checks the item type against a passed in types.
1284
-	 *
1285
-	 * @param array|string $type Type to check.
1286
-	 * @return bool
1287
-	 */
1288
-	public function is_type( $type ) {
1289
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1290
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1291
-	}
1283
+     * Checks the item type against a passed in types.
1284
+     *
1285
+     * @param array|string $type Type to check.
1286
+     * @return bool
1287
+     */
1288
+    public function is_type( $type ) {
1289
+        $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1290
+        return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1291
+    }
1292 1292
 
1293 1293
     /**
1294
-	 * Checks whether the item is editable.
1295
-	 *
1296
-	 * @since 1.0.19
1297
-	 * @return bool
1298
-	 */
1294
+     * Checks whether the item is editable.
1295
+     *
1296
+     * @since 1.0.19
1297
+     * @return bool
1298
+     */
1299 1299
     public function is_editable() {
1300 1300
         $is_editable = $this->get_is_editable();
1301 1301
         return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1302
-	}
1302
+    }
1303 1303
 
1304
-	/**
1305
-	 * Returns an array of cart fees.
1306
-	 */
1307
-	public function get_fees() {
1304
+    /**
1305
+     * Returns an array of cart fees.
1306
+     */
1307
+    public function get_fees() {
1308 1308
         return array();
1309 1309
     }
1310 1310
 
1311 1311
     /**
1312
-	 * Checks whether the item is purchasable.
1313
-	 *
1314
-	 * @since 1.0.19
1315
-	 * @return bool
1316
-	 */
1312
+     * Checks whether the item is purchasable.
1313
+     *
1314
+     * @since 1.0.19
1315
+     * @return bool
1316
+     */
1317 1317
     public function can_purchase() {
1318 1318
         $can_purchase = $this->exists();
1319 1319
 
@@ -1325,11 +1325,11 @@  discard block
 block discarded – undo
1325 1325
     }
1326 1326
 
1327 1327
     /**
1328
-	 * Checks whether the item supports dynamic pricing.
1329
-	 *
1330
-	 * @since 1.0.19
1331
-	 * @return bool
1332
-	 */
1328
+     * Checks whether the item supports dynamic pricing.
1329
+     *
1330
+     * @since 1.0.19
1331
+     * @return bool
1332
+     */
1333 1333
     public function supports_dynamic_pricing() {
1334 1334
         return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1335 1335
     }
Please login to merge, or discard this patch.
Spacing   +241 added lines, -241 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
 
@@ -82,30 +82,30 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
84 84
 	 */
85
-	public function __construct( $item = 0 ) {
86
-		parent::__construct( $item );
87
-
88
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
89
-			$this->set_id( $item );
90
-		} elseif ( $item instanceof self ) {
91
-			$this->set_id( $item->get_id() );
92
-		} elseif ( ! empty( $item->ID ) ) {
93
-			$this->set_id( $item->ID );
94
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
95
-			$this->set_id( $item_id );
96
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
97
-			$this->set_id( $item_id );
85
+	public function __construct($item = 0) {
86
+		parent::__construct($item);
87
+
88
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
89
+			$this->set_id($item);
90
+		} elseif ($item instanceof self) {
91
+			$this->set_id($item->get_id());
92
+		} elseif (!empty($item->ID)) {
93
+			$this->set_id($item->ID);
94
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
95
+			$this->set_id($item_id);
96
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
97
+			$this->set_id($item_id);
98 98
 		} else {
99
-			$this->set_object_read( true );
99
+			$this->set_object_read(true);
100 100
 		}
101 101
 
102 102
         // Load the datastore.
103
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
103
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
104 104
 
105
-		if ( $this->get_id() > 0 ) {
106
-            $this->post = get_post( $this->get_id() );
105
+		if ($this->get_id() > 0) {
106
+            $this->post = get_post($this->get_id());
107 107
             $this->ID   = $this->get_id();
108
-			$this->data_store->read( $this );
108
+			$this->data_store->read($this);
109 109
         }
110 110
 	}
111 111
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param  string $context View or edit context.
132 132
 	 * @return int
133 133
 	 */
134
-	public function get_parent_id( $context = 'view' ) {
135
-		return (int) $this->get_prop( 'parent_id', $context );
134
+	public function get_parent_id($context = 'view') {
135
+		return (int) $this->get_prop('parent_id', $context);
136 136
     }
137 137
 
138 138
     /**
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 	 * @param  string $context View or edit context.
143 143
 	 * @return string
144 144
 	 */
145
-	public function get_status( $context = 'view' ) {
146
-		return $this->get_prop( 'status', $context );
145
+	public function get_status($context = 'view') {
146
+		return $this->get_prop('status', $context);
147 147
     }
148 148
 
149 149
     /**
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 	 * @param  string $context View or edit context.
154 154
 	 * @return string
155 155
 	 */
156
-	public function get_version( $context = 'view' ) {
157
-		return $this->get_prop( 'version', $context );
156
+	public function get_version($context = 'view') {
157
+		return $this->get_prop('version', $context);
158 158
     }
159 159
 
160 160
     /**
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param  string $context View or edit context.
165 165
 	 * @return string
166 166
 	 */
167
-	public function get_date_created( $context = 'view' ) {
168
-		return $this->get_prop( 'date_created', $context );
167
+	public function get_date_created($context = 'view') {
168
+		return $this->get_prop('date_created', $context);
169 169
     }
170 170
 
171 171
     /**
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 	 * @param  string $context View or edit context.
176 176
 	 * @return string
177 177
 	 */
178
-	public function get_date_created_gmt( $context = 'view' ) {
179
-        $date = $this->get_date_created( $context );
178
+	public function get_date_created_gmt($context = 'view') {
179
+        $date = $this->get_date_created($context);
180 180
 
181
-        if ( $date ) {
182
-            $date = get_gmt_from_date( $date );
181
+        if ($date) {
182
+            $date = get_gmt_from_date($date);
183 183
         }
184 184
 		return $date;
185 185
     }
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 	 * @param  string $context View or edit context.
192 192
 	 * @return string
193 193
 	 */
194
-	public function get_date_modified( $context = 'view' ) {
195
-		return $this->get_prop( 'date_modified', $context );
194
+	public function get_date_modified($context = 'view') {
195
+		return $this->get_prop('date_modified', $context);
196 196
     }
197 197
 
198 198
     /**
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 	 * @param  string $context View or edit context.
203 203
 	 * @return string
204 204
 	 */
205
-	public function get_date_modified_gmt( $context = 'view' ) {
206
-        $date = $this->get_date_modified( $context );
205
+	public function get_date_modified_gmt($context = 'view') {
206
+        $date = $this->get_date_modified($context);
207 207
 
208
-        if ( $date ) {
209
-            $date = get_gmt_from_date( $date );
208
+        if ($date) {
209
+            $date = get_gmt_from_date($date);
210 210
         }
211 211
 		return $date;
212 212
     }
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 	 * @param  string $context View or edit context.
219 219
 	 * @return string
220 220
 	 */
221
-	public function get_name( $context = 'view' ) {
222
-		return $this->get_prop( 'name', $context );
221
+	public function get_name($context = 'view') {
222
+		return $this->get_prop('name', $context);
223 223
     }
224 224
 
225 225
     /**
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 	 * @param  string $context View or edit context.
230 230
 	 * @return string
231 231
 	 */
232
-	public function get_title( $context = 'view' ) {
233
-		return $this->get_name( $context );
232
+	public function get_title($context = 'view') {
233
+		return $this->get_name($context);
234 234
     }
235 235
 
236 236
     /**
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 * @param  string $context View or edit context.
241 241
 	 * @return string
242 242
 	 */
243
-	public function get_description( $context = 'view' ) {
244
-		return $this->get_prop( 'description', $context );
243
+	public function get_description($context = 'view') {
244
+		return $this->get_prop('description', $context);
245 245
     }
246 246
 
247 247
     /**
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 	 * @param  string $context View or edit context.
252 252
 	 * @return string
253 253
 	 */
254
-	public function get_excerpt( $context = 'view' ) {
255
-		return $this->get_description( $context );
254
+	public function get_excerpt($context = 'view') {
255
+		return $this->get_description($context);
256 256
     }
257 257
 
258 258
     /**
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 	 * @param  string $context View or edit context.
263 263
 	 * @return string
264 264
 	 */
265
-	public function get_summary( $context = 'view' ) {
266
-		return $this->get_description( $context );
265
+	public function get_summary($context = 'view') {
266
+		return $this->get_description($context);
267 267
     }
268 268
 
269 269
     /**
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	 * @param  string $context View or edit context.
274 274
 	 * @return int
275 275
 	 */
276
-	public function get_author( $context = 'view' ) {
277
-		return (int) $this->get_prop( 'author', $context );
276
+	public function get_author($context = 'view') {
277
+		return (int) $this->get_prop('author', $context);
278 278
 	}
279 279
 
280 280
 	/**
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 	 * @param  string $context View or edit context.
285 285
 	 * @return int
286 286
 	 */
287
-	public function get_owner( $context = 'view' ) {
288
-		return $this->get_author( $context );
287
+	public function get_owner($context = 'view') {
288
+		return $this->get_author($context);
289 289
     }
290 290
 
291 291
     /**
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 	 * @param  string $context View or edit context.
296 296
 	 * @return float
297 297
 	 */
298
-	public function get_price( $context = 'view' ) {
299
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
298
+	public function get_price($context = 'view') {
299
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
300 300
 	}
301 301
 
302 302
 	/**
@@ -306,24 +306,24 @@  discard block
 block discarded – undo
306 306
 	 * @param  string $context View or edit context.
307 307
 	 * @return float
308 308
 	 */
309
-	public function get_initial_price( $context = 'view', $price_id = null ) {
309
+	public function get_initial_price($context = 'view', $price_id = null) {
310 310
         $price = 0;
311 311
 
312
-        if ( null === $price_id ) {
313
-            $price = (float) $this->get_price( $context );
312
+        if (null === $price_id) {
313
+            $price = (float) $this->get_price($context);
314 314
 
315
-            if ( $this->has_free_trial() ) {
315
+            if ($this->has_free_trial()) {
316 316
                 $price = 0;
317 317
             }
318 318
         } else {
319 319
             $prices = $this->get_variable_prices();
320 320
 
321
-            if ( isset( $prices[ $price_id ] ) ) {
322
-                $price = (float) $prices[ $price_id ]['amount'];
321
+            if (isset($prices[$price_id])) {
322
+                $price = (float) $prices[$price_id]['amount'];
323 323
             }
324 324
         }
325 325
 
326
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
326
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
327 327
     }
328 328
 
329 329
     /**
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	 * @return string
335 335
 	 */
336 336
     public function get_the_price() {
337
-        return wpinv_price( $this->get_price() );
337
+        return wpinv_price($this->get_price());
338 338
 	}
339 339
 
340 340
 	/**
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 * @return string
346 346
 	 */
347 347
     public function get_the_initial_price() {
348
-        return wpinv_price( $this->get_initial_price() );
348
+        return wpinv_price($this->get_initial_price());
349 349
     }
350 350
 
351 351
     /**
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	 * @param  string $context View or edit context.
356 356
 	 * @return string
357 357
 	 */
358
-	public function get_vat_rule( $context = 'view' ) {
359
-        return $this->get_prop( 'vat_rule', $context );
358
+	public function get_vat_rule($context = 'view') {
359
+        return $this->get_prop('vat_rule', $context);
360 360
     }
361 361
 
362 362
     /**
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 * @param  string $context View or edit context.
367 367
 	 * @return string
368 368
 	 */
369
-	public function get_vat_class( $context = 'view' ) {
370
-        return $this->get_prop( 'vat_class', $context );
369
+	public function get_vat_class($context = 'view') {
370
+        return $this->get_prop('vat_class', $context);
371 371
     }
372 372
 
373 373
     /**
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	 * @param  string $context View or edit context.
378 378
 	 * @return string
379 379
 	 */
380
-	public function get_type( $context = 'view' ) {
381
-        return $this->get_prop( 'type', $context );
380
+	public function get_type($context = 'view') {
381
+        return $this->get_prop('type', $context);
382 382
     }
383 383
 
384 384
     /**
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 	 * @param  string $context View or edit context.
389 389
 	 * @return string
390 390
 	 */
391
-	public function get_custom_id( $context = 'view' ) {
392
-        return $this->get_prop( 'custom_id', $context );
391
+	public function get_custom_id($context = 'view') {
392
+        return $this->get_prop('custom_id', $context);
393 393
     }
394 394
 
395 395
     /**
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
 	 * @param  string $context View or edit context.
400 400
 	 * @return string
401 401
 	 */
402
-	public function get_custom_name( $context = 'view' ) {
403
-        return $this->get_prop( 'custom_name', $context );
402
+	public function get_custom_name($context = 'view') {
403
+        return $this->get_prop('custom_name', $context);
404 404
     }
405 405
 
406 406
     /**
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
 	 * @param  string $context View or edit context.
411 411
 	 * @return string
412 412
 	 */
413
-	public function get_custom_singular_name( $context = 'view' ) {
414
-        return $this->get_prop( 'custom_singular_name', $context );
413
+	public function get_custom_singular_name($context = 'view') {
414
+        return $this->get_prop('custom_singular_name', $context);
415 415
     }
416 416
 
417 417
     /**
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
 	 * @param  string $context View or edit context.
422 422
 	 * @return int
423 423
 	 */
424
-	public function get_is_editable( $context = 'view' ) {
425
-        return (int) $this->get_prop( 'is_editable', $context );
424
+	public function get_is_editable($context = 'view') {
425
+        return (int) $this->get_prop('is_editable', $context);
426 426
     }
427 427
 
428 428
     /**
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
 	 * @param  string $context View or edit context.
433 433
 	 * @return int
434 434
 	 */
435
-	public function get_editable( $context = 'view' ) {
436
-		return $this->get_is_editable( $context );
435
+	public function get_editable($context = 'view') {
436
+		return $this->get_is_editable($context);
437 437
     }
438 438
 
439 439
     /**
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 * @param  string $context View or edit context.
444 444
 	 * @return int
445 445
 	 */
446
-	public function get_is_dynamic_pricing( $context = 'view' ) {
447
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
446
+	public function get_is_dynamic_pricing($context = 'view') {
447
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
448 448
     }
449 449
 
450 450
     /**
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @param  string $context View or edit context.
455 455
 	 * @return float
456 456
 	 */
457
-	public function get_minimum_price( $context = 'view' ) {
458
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
457
+	public function get_minimum_price($context = 'view') {
458
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
459 459
     }
460 460
 
461 461
     /**
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
      * @param  string $context View or edit context.
466 466
      * @return int
467 467
      */
468
-    public function get_is_multi_price_mode( $context = 'view' ) {
469
-        return (bool) $this->get_prop( 'is_multi_price_mode', $context );
468
+    public function get_is_multi_price_mode($context = 'view') {
469
+        return (bool) $this->get_prop('is_multi_price_mode', $context);
470 470
     }
471 471
 
472 472
     /**
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
      * @param  string $context View or edit context.
488 488
      * @return int
489 489
      */
490
-    public function get_has_variable_pricing( $context = 'view' ) {
491
-        return (bool) $this->get_prop( 'has_variable_pricing', $context );
490
+    public function get_has_variable_pricing($context = 'view') {
491
+        return (bool) $this->get_prop('has_variable_pricing', $context);
492 492
     }
493 493
 
494 494
     /**
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      * @return int
500 500
      */
501 501
     public function has_variable_pricing() {
502
-        return $this->get_has_variable_pricing( 'view' );
502
+        return $this->get_has_variable_pricing('view');
503 503
     }
504 504
 
505 505
     /**
@@ -509,20 +509,20 @@  discard block
 block discarded – undo
509 509
      * @since 2.8.9
510 510
      * @return int              The Price ID to select by default
511 511
      */
512
-    public function get_default_price_id( $context = 'view' ) {
513
-        if ( ! $this->has_variable_pricing() ) {
512
+    public function get_default_price_id($context = 'view') {
513
+        if (!$this->has_variable_pricing()) {
514 514
             return false;
515 515
         }
516 516
 
517 517
         $prices = $this->get_variable_prices();
518 518
 
519
-        $default_price_id = (int) $this->get_prop( 'default_price_id', $context );
519
+        $default_price_id = (int) $this->get_prop('default_price_id', $context);
520 520
 
521
-        if ( '' === $default_price_id || ! isset( $prices[ $default_price_id ] ) ) {
522
-            $default_price_id = current( array_keys( $prices ) );
521
+        if ('' === $default_price_id || !isset($prices[$default_price_id])) {
522
+            $default_price_id = current(array_keys($prices));
523 523
         }
524 524
 
525
-        return  absint( $default_price_id );
525
+        return  absint($default_price_id);
526 526
     }
527 527
 
528 528
     /**
@@ -534,8 +534,8 @@  discard block
 block discarded – undo
534 534
     public function get_variable_prices() {
535 535
         $prices = array();
536 536
 
537
-        if ( true === $this->has_variable_pricing() ) {
538
-            $prices = $this->get_prop( 'variable_prices', 'view' );
537
+        if (true === $this->has_variable_pricing()) {
538
+            $prices = $this->get_prop('variable_prices', 'view');
539 539
         }
540 540
 
541 541
         return $prices;
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 	 * @param  string $context View or edit context.
549 549
 	 * @return int
550 550
 	 */
551
-	public function get_is_recurring( $context = 'view' ) {
552
-        return (int) $this->get_prop( 'is_recurring', $context );
551
+	public function get_is_recurring($context = 'view') {
552
+        return (int) $this->get_prop('is_recurring', $context);
553 553
 	}
554 554
 
555 555
 	/**
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 	 * @param  string $context View or edit context.
560 560
 	 * @return float
561 561
 	 */
562
-	public function get_recurring_price( $context = 'view' ) {
563
-		$price = $this->get_price( $context );
564
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
562
+	public function get_recurring_price($context = 'view') {
563
+		$price = $this->get_price($context);
564
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
565 565
 	}
566 566
 
567 567
 	/**
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	 * @return string
573 573
 	 */
574 574
     public function get_the_recurring_price() {
575
-        return wpinv_price( $this->get_recurring_price() );
575
+        return wpinv_price($this->get_recurring_price());
576 576
 	}
577 577
 
578 578
 	/**
@@ -593,15 +593,15 @@  discard block
 block discarded – undo
593 593
 		$period   = $this->get_recurring_period();
594 594
 		$interval = $this->get_recurring_interval();
595 595
 
596
-		if ( $this->has_free_trial() ) {
596
+		if ($this->has_free_trial()) {
597 597
 			$period   = $this->get_trial_period();
598 598
 			$interval = $this->get_trial_interval();
599 599
 		}
600 600
 
601
-		$period       = $periods[ $period ];
602
-		$interval     = empty( $interval ) ? 1 : $interval;
603
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
604
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
601
+		$period       = $periods[$period];
602
+		$interval     = empty($interval) ? 1 : $interval;
603
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
604
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
605 605
     }
606 606
 
607 607
     /**
@@ -611,14 +611,14 @@  discard block
 block discarded – undo
611 611
 	 * @param  bool $full Return abbreviation or in full.
612 612
 	 * @return string
613 613
 	 */
614
-	public function get_recurring_period( $full = false ) {
615
-        $period = $this->get_prop( 'recurring_period', 'view' );
614
+	public function get_recurring_period($full = false) {
615
+        $period = $this->get_prop('recurring_period', 'view');
616 616
 
617
-        if ( $full && ! is_bool( $full ) ) {
617
+        if ($full && !is_bool($full)) {
618 618
             $full = false;
619 619
         }
620 620
 
621
-        return getpaid_sanitize_recurring_period( $period, $full );
621
+        return getpaid_sanitize_recurring_period($period, $full);
622 622
     }
623 623
 
624 624
     /**
@@ -628,9 +628,9 @@  discard block
 block discarded – undo
628 628
 	 * @param  string $context View or edit context.
629 629
 	 * @return int
630 630
 	 */
631
-	public function get_recurring_interval( $context = 'view' ) {
632
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
633
-		return max( 1, $interval );
631
+	public function get_recurring_interval($context = 'view') {
632
+		$interval = absint($this->get_prop('recurring_interval', $context));
633
+		return max(1, $interval);
634 634
     }
635 635
 
636 636
     /**
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 * @param  string $context View or edit context.
641 641
 	 * @return int
642 642
 	 */
643
-	public function get_recurring_limit( $context = 'view' ) {
644
-        return (int) $this->get_prop( 'recurring_limit', $context );
643
+	public function get_recurring_limit($context = 'view') {
644
+        return (int) $this->get_prop('recurring_limit', $context);
645 645
     }
646 646
 
647 647
     /**
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 	 * @param  string $context View or edit context.
652 652
 	 * @return int
653 653
 	 */
654
-	public function get_is_free_trial( $context = 'view' ) {
655
-        return (int) $this->get_prop( 'is_free_trial', $context );
654
+	public function get_is_free_trial($context = 'view') {
655
+        return (int) $this->get_prop('is_free_trial', $context);
656 656
     }
657 657
 
658 658
     /**
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
 	 * @param  string $context View or edit context.
663 663
 	 * @return int
664 664
 	 */
665
-	public function get_free_trial( $context = 'view' ) {
666
-        return $this->get_is_free_trial( $context );
665
+	public function get_free_trial($context = 'view') {
666
+        return $this->get_is_free_trial($context);
667 667
     }
668 668
 
669 669
     /**
@@ -673,14 +673,14 @@  discard block
 block discarded – undo
673 673
 	 * @param  bool $full Return abbreviation or in full.
674 674
 	 * @return string
675 675
 	 */
676
-	public function get_trial_period( $full = false ) {
677
-        $period = $this->get_prop( 'trial_period', 'view' );
676
+	public function get_trial_period($full = false) {
677
+        $period = $this->get_prop('trial_period', 'view');
678 678
 
679
-        if ( $full && ! is_bool( $full ) ) {
679
+        if ($full && !is_bool($full)) {
680 680
             $full = false;
681 681
         }
682 682
 
683
-        return getpaid_sanitize_recurring_period( $period, $full );
683
+        return getpaid_sanitize_recurring_period($period, $full);
684 684
     }
685 685
 
686 686
     /**
@@ -690,8 +690,8 @@  discard block
 block discarded – undo
690 690
 	 * @param  string $context View or edit context.
691 691
 	 * @return int
692 692
 	 */
693
-	public function get_trial_interval( $context = 'view' ) {
694
-        return (int) $this->get_prop( 'trial_interval', $context );
693
+	public function get_trial_interval($context = 'view') {
694
+        return (int) $this->get_prop('trial_interval', $context);
695 695
 	}
696 696
 
697 697
 	/**
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 	 * @return string
702 702
 	 */
703 703
 	public function get_edit_url() {
704
-        return get_edit_post_link( $this->get_id(), 'edit' );
704
+        return get_edit_post_link($this->get_id(), 'edit');
705 705
 	}
706 706
 
707 707
 	/**
@@ -715,35 +715,35 @@  discard block
 block discarded – undo
715 715
 	 * @since 1.0.15
716 716
 	 * @return int
717 717
 	 */
718
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
718
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
719 719
 
720 720
 		// Trim the value.
721
-		$value = sanitize_text_field( $value );
722
-		if ( empty( $value ) ) {
721
+		$value = sanitize_text_field($value);
722
+		if (empty($value)) {
723 723
 			return 0;
724 724
 		}
725 725
 
726 726
         // Valid fields.
727
-        $fields = array( 'custom_id', 'name', 'slug' );
727
+        $fields = array('custom_id', 'name', 'slug');
728 728
 
729 729
 		// Ensure a field has been passed.
730
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
730
+		if (empty($field) || !in_array($field, $fields)) {
731 731
 			return 0;
732 732
 		}
733 733
 
734
-		if ( $field == 'name' ) {
734
+		if ($field == 'name') {
735 735
 			$field = 'slug';
736 736
 		}
737 737
 
738 738
 		// Maybe retrieve from the cache.
739
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
740
-		if ( ! empty( $item_id ) ) {
739
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
740
+		if (!empty($item_id)) {
741 741
 			return $item_id;
742 742
 		}
743 743
 
744 744
 		// Fetch from the db.
745 745
 		$items = array();
746
-		if ( $field == 'slug' ) {
746
+		if ($field == 'slug') {
747 747
 			$items = get_posts(
748 748
 				array(
749 749
 					'post_type'      => 'wpi_item',
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 			);
755 755
 		}
756 756
 
757
-		if ( $field == 'custom_id' ) {
757
+		if ($field == 'custom_id') {
758 758
 			$items = get_posts(
759 759
 				array(
760 760
 					'post_type'      => 'wpi_item',
@@ -774,12 +774,12 @@  discard block
 block discarded – undo
774 774
 			);
775 775
 		}
776 776
 
777
-		if ( empty( $items ) ) {
777
+		if (empty($items)) {
778 778
 			return 0;
779 779
 		}
780 780
 
781 781
 		// Update the cache with our data
782
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
782
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
783 783
 
784 784
 		return $items[0]->ID;
785 785
     }
@@ -787,19 +787,19 @@  discard block
 block discarded – undo
787 787
     /**
788 788
      * Margic method for retrieving a property.
789 789
      */
790
-    public function __get( $key ) {
790
+    public function __get($key) {
791 791
 
792 792
         // Check if we have a helper method for that.
793
-        if ( method_exists( $this, 'get_' . $key ) ) {
794
-            return call_user_func( array( $this, 'get_' . $key ) );
793
+        if (method_exists($this, 'get_' . $key)) {
794
+            return call_user_func(array($this, 'get_' . $key));
795 795
         }
796 796
 
797 797
         // Check if the key is in the associated $post object.
798
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
798
+        if (!empty($this->post) && isset($this->post->$key)) {
799 799
             return $this->post->$key;
800 800
         }
801 801
 
802
-        return $this->get_prop( $key );
802
+        return $this->get_prop($key);
803 803
     }
804 804
 
805 805
     /*
@@ -817,11 +817,11 @@  discard block
 block discarded – undo
817 817
 	 *
818 818
 	 * @since 1.0.19
819 819
 	 */
820
-	public function set_parent_id( $value ) {
821
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
820
+	public function set_parent_id($value) {
821
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
822 822
 			return;
823 823
 		}
824
-		$this->set_prop( 'parent_id', absint( $value ) );
824
+		$this->set_prop('parent_id', absint($value));
825 825
 	}
826 826
 
827 827
     /**
@@ -831,10 +831,10 @@  discard block
 block discarded – undo
831 831
 	 * @param  string $status New status.
832 832
 	 * @return array details of change.
833 833
 	 */
834
-	public function set_status( $status ) {
834
+	public function set_status($status) {
835 835
         $old_status = $this->get_status();
836 836
 
837
-        $this->set_prop( 'status', $status );
837
+        $this->set_prop('status', $status);
838 838
 
839 839
 		return array(
840 840
 			'from' => $old_status,
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 *
848 848
 	 * @since 1.0.19
849 849
 	 */
850
-	public function set_version( $value ) {
851
-		$this->set_prop( 'version', $value );
850
+	public function set_version($value) {
851
+		$this->set_prop('version', $value);
852 852
     }
853 853
 
854 854
     /**
@@ -858,11 +858,11 @@  discard block
 block discarded – undo
858 858
 	 * @param string $value Value to set.
859 859
      * @return bool Whether or not the date was set.
860 860
 	 */
861
-	public function set_date_created( $value ) {
862
-        $date = strtotime( $value );
861
+	public function set_date_created($value) {
862
+        $date = strtotime($value);
863 863
 
864
-        if ( $date ) {
865
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
864
+        if ($date) {
865
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
866 866
             return true;
867 867
         }
868 868
 
@@ -876,11 +876,11 @@  discard block
 block discarded – undo
876 876
 	 * @param string $value Value to set.
877 877
      * @return bool Whether or not the date was set.
878 878
 	 */
879
-	public function set_date_modified( $value ) {
880
-        $date = strtotime( $value );
879
+	public function set_date_modified($value) {
880
+        $date = strtotime($value);
881 881
 
882
-        if ( $date ) {
883
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
882
+        if ($date) {
883
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
884 884
             return true;
885 885
         }
886 886
 
@@ -893,9 +893,9 @@  discard block
 block discarded – undo
893 893
 	 * @since 1.0.19
894 894
 	 * @param  string $value New name.
895 895
 	 */
896
-	public function set_name( $value ) {
897
-        $name = sanitize_text_field( $value );
898
-		$this->set_prop( 'name', $name );
896
+	public function set_name($value) {
897
+        $name = sanitize_text_field($value);
898
+		$this->set_prop('name', $name);
899 899
     }
900 900
 
901 901
     /**
@@ -904,8 +904,8 @@  discard block
 block discarded – undo
904 904
 	 * @since 1.0.19
905 905
 	 * @param  string $value New name.
906 906
 	 */
907
-	public function set_title( $value ) {
908
-		$this->set_name( $value );
907
+	public function set_title($value) {
908
+		$this->set_name($value);
909 909
     }
910 910
 
911 911
     /**
@@ -914,9 +914,9 @@  discard block
 block discarded – undo
914 914
 	 * @since 1.0.19
915 915
 	 * @param  string $value New description.
916 916
 	 */
917
-	public function set_description( $value ) {
918
-		$description = wp_kses_post( wp_unslash( $value ) );
919
-		return $this->set_prop( 'description', $description );
917
+	public function set_description($value) {
918
+		$description = wp_kses_post(wp_unslash($value));
919
+		return $this->set_prop('description', $description);
920 920
     }
921 921
 
922 922
     /**
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	 * @since 1.0.19
926 926
 	 * @param  string $value New description.
927 927
 	 */
928
-	public function set_excerpt( $value ) {
929
-		$this->set_description( $value );
928
+	public function set_excerpt($value) {
929
+		$this->set_description($value);
930 930
     }
931 931
 
932 932
     /**
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 	 * @since 1.0.19
936 936
 	 * @param  string $value New description.
937 937
 	 */
938
-	public function set_summary( $value ) {
939
-		$this->set_description( $value );
938
+	public function set_summary($value) {
939
+		$this->set_description($value);
940 940
     }
941 941
 
942 942
     /**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 	 * @since 1.0.19
946 946
 	 * @param  int $value New author.
947 947
 	 */
948
-	public function set_author( $value ) {
949
-		$this->set_prop( 'author', (int) $value );
948
+	public function set_author($value) {
949
+		$this->set_prop('author', (int) $value);
950 950
 	}
951 951
 
952 952
 	/**
@@ -955,8 +955,8 @@  discard block
 block discarded – undo
955 955
 	 * @since 1.0.19
956 956
 	 * @param  int $value New author.
957 957
 	 */
958
-	public function set_owner( $value ) {
959
-		$this->set_author( $value );
958
+	public function set_owner($value) {
959
+		$this->set_author($value);
960 960
     }
961 961
 
962 962
     /**
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 	 * @since 1.0.19
966 966
 	 * @param  float $value New price.
967 967
 	 */
968
-	public function set_price( $value ) {
969
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
968
+	public function set_price($value) {
969
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
970 970
     }
971 971
 
972 972
     /**
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
 	 * @since 1.0.19
976 976
 	 * @param  string $value new rule.
977 977
 	 */
978
-	public function set_vat_rule( $value ) {
979
-        $this->set_prop( 'vat_rule', $value );
978
+	public function set_vat_rule($value) {
979
+        $this->set_prop('vat_rule', $value);
980 980
     }
981 981
 
982 982
     /**
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
 	 * @since 1.0.19
986 986
 	 * @param  string $value new class.
987 987
 	 */
988
-	public function set_vat_class( $value ) {
989
-        $this->set_prop( 'vat_class', $value );
988
+	public function set_vat_class($value) {
989
+        $this->set_prop('vat_class', $value);
990 990
     }
991 991
 
992 992
     /**
@@ -996,13 +996,13 @@  discard block
 block discarded – undo
996 996
 	 * @param  string $value new item type.
997 997
 	 * @return string
998 998
 	 */
999
-	public function set_type( $value ) {
999
+	public function set_type($value) {
1000 1000
 
1001
-        if ( empty( $value ) ) {
1001
+        if (empty($value)) {
1002 1002
             $value = 'custom';
1003 1003
         }
1004 1004
 
1005
-        $this->set_prop( 'type', $value );
1005
+        $this->set_prop('type', $value);
1006 1006
     }
1007 1007
 
1008 1008
     /**
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 	 * @since 1.0.19
1012 1012
 	 * @param  string $value new custom id.
1013 1013
 	 */
1014
-	public function set_custom_id( $value ) {
1015
-        $this->set_prop( 'custom_id', $value );
1014
+	public function set_custom_id($value) {
1015
+        $this->set_prop('custom_id', $value);
1016 1016
     }
1017 1017
 
1018 1018
     /**
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
 	 * @since 1.0.19
1022 1022
 	 * @param  string $value new custom name.
1023 1023
 	 */
1024
-	public function set_custom_name( $value ) {
1025
-        $this->set_prop( 'custom_name', $value );
1024
+	public function set_custom_name($value) {
1025
+        $this->set_prop('custom_name', $value);
1026 1026
     }
1027 1027
 
1028 1028
     /**
@@ -1031,8 +1031,8 @@  discard block
 block discarded – undo
1031 1031
 	 * @since 1.0.19
1032 1032
 	 * @param  string $value new custom singular name.
1033 1033
 	 */
1034
-	public function set_custom_singular_name( $value ) {
1035
-        $this->set_prop( 'custom_singular_name', $value );
1034
+	public function set_custom_singular_name($value) {
1035
+        $this->set_prop('custom_singular_name', $value);
1036 1036
     }
1037 1037
 
1038 1038
     /**
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
 	 * @since 1.0.19
1042 1042
 	 * @param  int|bool $value whether or not the item is editable.
1043 1043
 	 */
1044
-	public function set_is_editable( $value ) {
1045
-		$this->set_prop( 'is_editable', (int) $value );
1044
+	public function set_is_editable($value) {
1045
+		$this->set_prop('is_editable', (int) $value);
1046 1046
     }
1047 1047
 
1048 1048
     /**
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 	 * @since 1.0.19
1052 1052
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
1053 1053
 	 */
1054
-	public function set_is_dynamic_pricing( $value ) {
1055
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
1054
+	public function set_is_dynamic_pricing($value) {
1055
+        $this->set_prop('is_dynamic_pricing', (int) $value);
1056 1056
     }
1057 1057
 
1058 1058
     /**
@@ -1061,8 +1061,8 @@  discard block
 block discarded – undo
1061 1061
 	 * @since 1.0.19
1062 1062
 	 * @param  float $value minimum price.
1063 1063
 	 */
1064
-	public function set_minimum_price( $value ) {
1065
-        $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) );
1064
+	public function set_minimum_price($value) {
1065
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
1066 1066
     }
1067 1067
 
1068 1068
     /**
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
 	 * @since 1.0.19
1072 1072
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
1073 1073
 	 */
1074
-	public function set_is_multi_price_mode( $value ) {
1075
-        $this->set_prop( 'is_multi_price_mode', (int) $value );
1074
+	public function set_is_multi_price_mode($value) {
1075
+        $this->set_prop('is_multi_price_mode', (int) $value);
1076 1076
     }
1077 1077
 
1078 1078
     /**
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
 	 * @since 1.0.19
1082 1082
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
1083 1083
 	 */
1084
-	public function set_has_variable_pricing( $value ) {
1085
-        $this->set_prop( 'has_variable_pricing', (int) $value );
1084
+	public function set_has_variable_pricing($value) {
1085
+        $this->set_prop('has_variable_pricing', (int) $value);
1086 1086
     }
1087 1087
 
1088 1088
     /**
@@ -1091,8 +1091,8 @@  discard block
 block discarded – undo
1091 1091
 	 * @since 1.0.19
1092 1092
 	 * @param  int $value default price ID.
1093 1093
 	 */
1094
-	public function set_default_price_id( $value ) {
1095
-        return $this->set_prop( 'default_price_id', (int) $value );
1094
+	public function set_default_price_id($value) {
1095
+        return $this->set_prop('default_price_id', (int) $value);
1096 1096
     }
1097 1097
 
1098 1098
     /**
@@ -1101,23 +1101,23 @@  discard block
 block discarded – undo
1101 1101
 	 * @since 1.0.19
1102 1102
 	 * @param  int $prices variable prices.
1103 1103
 	 */
1104
-	public function set_variable_prices( $prices ) {
1105
-        if ( ! is_array( $prices ) ) {
1104
+	public function set_variable_prices($prices) {
1105
+        if (!is_array($prices)) {
1106 1106
             $prices = array();
1107 1107
         }
1108 1108
 
1109
-        foreach ( $prices as $id => $price ) {
1110
-            if ( empty( $price['amount'] ) && empty( $price['name'] ) ) {
1111
-                unset( $prices[ $id ] );
1109
+        foreach ($prices as $id => $price) {
1110
+            if (empty($price['amount']) && empty($price['name'])) {
1111
+                unset($prices[$id]);
1112 1112
                 continue;
1113
-            } elseif ( empty( $price['amount'] ) ) {
1113
+            } elseif (empty($price['amount'])) {
1114 1114
                 $price['amount'] = 0;
1115 1115
             }
1116 1116
 
1117
-            $prices[ $id ]['amount'] = getpaid_standardize_amount( $price['amount'] );
1117
+            $prices[$id]['amount'] = getpaid_standardize_amount($price['amount']);
1118 1118
         }
1119 1119
 
1120
-        return $this->set_prop( 'variable_prices', $prices );
1120
+        return $this->set_prop('variable_prices', $prices);
1121 1121
     }
1122 1122
 
1123 1123
     /**
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
 	 * @since 1.0.19
1127 1127
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
1128 1128
 	 */
1129
-	public function set_is_recurring( $value ) {
1130
-        $this->set_prop( 'is_recurring', (int) $value );
1129
+	public function set_is_recurring($value) {
1130
+        $this->set_prop('is_recurring', (int) $value);
1131 1131
     }
1132 1132
 
1133 1133
     /**
@@ -1136,8 +1136,8 @@  discard block
 block discarded – undo
1136 1136
 	 * @since 1.0.19
1137 1137
 	 * @param  string $value new period.
1138 1138
 	 */
1139
-	public function set_recurring_period( $value ) {
1140
-        $this->set_prop( 'recurring_period', $value );
1139
+	public function set_recurring_period($value) {
1140
+        $this->set_prop('recurring_period', $value);
1141 1141
     }
1142 1142
 
1143 1143
     /**
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 	 * @since 1.0.19
1147 1147
 	 * @param  int $value recurring interval.
1148 1148
 	 */
1149
-	public function set_recurring_interval( $value ) {
1150
-        return $this->set_prop( 'recurring_interval', (int) $value );
1149
+	public function set_recurring_interval($value) {
1150
+        return $this->set_prop('recurring_interval', (int) $value);
1151 1151
     }
1152 1152
 
1153 1153
     /**
@@ -1156,8 +1156,8 @@  discard block
 block discarded – undo
1156 1156
 	 * @param  int $value The recurring limit.
1157 1157
 	 * @return int
1158 1158
 	 */
1159
-	public function set_recurring_limit( $value ) {
1160
-        $this->set_prop( 'recurring_limit', (int) $value );
1159
+	public function set_recurring_limit($value) {
1160
+        $this->set_prop('recurring_limit', (int) $value);
1161 1161
     }
1162 1162
 
1163 1163
     /**
@@ -1166,8 +1166,8 @@  discard block
 block discarded – undo
1166 1166
 	 * @since 1.0.19
1167 1167
 	 * @param  int|bool $value whether or not it has a free trial.
1168 1168
 	 */
1169
-	public function set_is_free_trial( $value ) {
1170
-        $this->set_prop( 'is_free_trial', (int) $value );
1169
+	public function set_is_free_trial($value) {
1170
+        $this->set_prop('is_free_trial', (int) $value);
1171 1171
     }
1172 1172
 
1173 1173
     /**
@@ -1176,8 +1176,8 @@  discard block
 block discarded – undo
1176 1176
 	 * @since 1.0.19
1177 1177
 	 * @param  string $value trial period.
1178 1178
 	 */
1179
-	public function set_trial_period( $value ) {
1180
-        $this->set_prop( 'trial_period', $value );
1179
+	public function set_trial_period($value) {
1180
+        $this->set_prop('trial_period', $value);
1181 1181
     }
1182 1182
 
1183 1183
     /**
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 	 * @since 1.0.19
1187 1187
 	 * @param  int $value trial interval.
1188 1188
 	 */
1189
-	public function set_trial_interval( $value ) {
1190
-        $this->set_prop( 'trial_interval', $value );
1189
+	public function set_trial_interval($value) {
1190
+        $this->set_prop('trial_interval', $value);
1191 1191
     }
1192 1192
 
1193 1193
     /**
@@ -1196,11 +1196,11 @@  discard block
 block discarded – undo
1196 1196
      * @deprecated
1197 1197
 	 * @return int item id
1198 1198
      */
1199
-    public function create( $data = array() ) {
1199
+    public function create($data = array()) {
1200 1200
 
1201 1201
 		// Set the properties.
1202
-		if ( is_array( $data ) ) {
1203
-			$this->set_props( $data );
1202
+		if (is_array($data)) {
1203
+			$this->set_props($data);
1204 1204
 		}
1205 1205
 
1206 1206
 		// Save the item.
@@ -1213,8 +1213,8 @@  discard block
 block discarded – undo
1213 1213
      * @deprecated
1214 1214
 	 * @return int item id
1215 1215
      */
1216
-    public function update( $data = array() ) {
1217
-        return $this->create( $data );
1216
+    public function update($data = array()) {
1217
+        return $this->create($data);
1218 1218
     }
1219 1219
 
1220 1220
     /*
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 	 */
1255 1255
     public function has_free_trial() {
1256 1256
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1257
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1257
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1258 1258
     }
1259 1259
 
1260 1260
     /**
@@ -1264,8 +1264,8 @@  discard block
 block discarded – undo
1264 1264
 	 * @return bool
1265 1265
 	 */
1266 1266
     public function is_free() {
1267
-        $is_free   = $this->get_price() == 0;
1268
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1267
+        $is_free = $this->get_price() == 0;
1268
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1269 1269
     }
1270 1270
 
1271 1271
     /**
@@ -1274,9 +1274,9 @@  discard block
 block discarded – undo
1274 1274
 	 * @param array|string $status Status to check.
1275 1275
 	 * @return bool
1276 1276
 	 */
1277
-	public function has_status( $status ) {
1278
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1279
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1277
+	public function has_status($status) {
1278
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1279
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1280 1280
     }
1281 1281
 
1282 1282
     /**
@@ -1285,9 +1285,9 @@  discard block
 block discarded – undo
1285 1285
 	 * @param array|string $type Type to check.
1286 1286
 	 * @return bool
1287 1287
 	 */
1288
-	public function is_type( $type ) {
1289
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1290
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1288
+	public function is_type($type) {
1289
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1290
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1291 1291
 	}
1292 1292
 
1293 1293
     /**
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
 	 */
1299 1299
     public function is_editable() {
1300 1300
         $is_editable = $this->get_is_editable();
1301
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1301
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1302 1302
 	}
1303 1303
 
1304 1304
 	/**
@@ -1317,11 +1317,11 @@  discard block
 block discarded – undo
1317 1317
     public function can_purchase() {
1318 1318
         $can_purchase = $this->exists();
1319 1319
 
1320
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1320
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1321 1321
             $can_purchase = false;
1322 1322
         }
1323 1323
 
1324
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1324
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1325 1325
     }
1326 1326
 
1327 1327
     /**
@@ -1331,6 +1331,6 @@  discard block
 block discarded – undo
1331 1331
 	 * @return bool
1332 1332
 	 */
1333 1333
     public function supports_dynamic_pricing() {
1334
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1334
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1335 1335
     }
1336 1336
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -696,7 +696,7 @@
 block discarded – undo
696 696
                                     $extra_attributes,
697 697
                                     array( 'size' => 4 )
698 698
                                 ),
699
-							),
699
+                            ),
700 700
                             true
701 701
                         );
702 702
                         ?>
Please login to merge, or discard this patch.
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
     exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @param WP_Post $post
23 23
      */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
         // Prepare the item.
26
-        $item = new WPInv_Item( $post );
26
+        $item = new WPInv_Item($post);
27 27
 
28 28
         // Nonce field.
29
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
29
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
30 30
 
31 31
         // Variable prices.
32 32
         $variable_prices = $item->get_variable_prices();
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
         // Set the currency position.
35 35
         $position = wpinv_currency_position();
36 36
 
37
-        if ( $position == 'left_space' ) {
37
+        if ($position == 'left_space') {
38 38
             $position = 'left';
39 39
         }
40 40
 
41
-        if ( $position == 'right_space' ) {
41
+        if ($position == 'right_space') {
42 42
             $position = 'right';
43 43
         }
44 44
 
45 45
         ?>
46
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
46
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
47 47
         <style>
48 48
             #poststuff .input-group-text,
49 49
             #poststuff .form-control {
@@ -56,37 +56,37 @@  discard block
 block discarded – undo
56 56
         </style>
57 57
         <div class="bsui" style="max-width: 600px;padding-top: 10px;">
58 58
 
59
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
59
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
60 60
 
61 61
             <div class="form-group mb-3 row">
62
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php esc_html_e( 'Item Price', 'invoicing' ); ?></span></label>
62
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php esc_html_e('Item Price', 'invoicing'); ?></span></label>
63 63
                 <div class="col-sm-8">
64 64
                     <div class="row wpinv_hide_if_variable_pricing">
65 65
                         <div class="col-sm-4 getpaid-price-input mb-3">
66 66
                             <div class="input-group input-group-sm">
67 67
 
68
-                                <?php if ( 'left' == $position ) : ?>
69
-                                    <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
68
+                                <?php if ('left' == $position) : ?>
69
+                                    <?php if (empty($GLOBALS['aui_bs5'])) : ?>
70 70
                                         <div class="input-group-prepend">
71
-                                            <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
71
+                                            <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
72 72
                                         </div>
73 73
                                     <?php else : ?>
74 74
                                         <span class="input-group-text">
75
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
75
+                                            <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
76 76
                                         </span>
77 77
                                     <?php endif; ?>
78 78
                                 <?php endif; ?>
79 79
 
80
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control wpinv-force-integer" autocomplete="off">
80
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control wpinv-force-integer" autocomplete="off">
81 81
 
82
-                                <?php if ( 'left' != $position ) : ?>
83
-                                    <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
82
+                                <?php if ('left' != $position) : ?>
83
+                                    <?php if (empty($GLOBALS['aui_bs5'])) : ?>
84 84
                                         <div class="input-group-append">
85
-                                            <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
85
+                                            <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
86 86
                                         </div>
87 87
                                     <?php else : ?>
88 88
                                         <span class="input-group-text">
89
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
89
+                                            <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
90 90
                                         </span>
91 91
                                     <?php endif; ?>
92 92
                                 <?php endif; ?>
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
                         </div>
95 95
                         <div class="col-sm-4 wpinv_show_if_recurring">
96 96
                             <?php
97
-                            esc_html_e( 'Every' );
97
+                            esc_html_e('Every');
98 98
                             echo '&nbsp;';
99 99
                             ?>
100
-                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
100
+                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
101 101
                         </div>
102 102
                         <div class="col-sm-4 wpinv_show_if_recurring">
103 103
                             <?php
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
                                 array(
106 106
                                     'id'               => 'wpinv_recurring_period',
107 107
                                     'name'             => 'wpinv_recurring_period',
108
-                                    'label'            => __( 'Period', 'invoicing' ),
109
-                                    'placeholder'      => __( 'Select Period', 'invoicing' ),
110
-                                    'value'            => $item->get_recurring_period( 'edit' ),
108
+                                    'label'            => __('Period', 'invoicing'),
109
+                                    'placeholder'      => __('Select Period', 'invoicing'),
110
+                                    'value'            => $item->get_recurring_period('edit'),
111 111
                                     'select2'          => true,
112 112
                                     'data-allow-clear' => 'false',
113 113
                                     'options'          => array(
114
-                                        'D' => __( 'day(s)', 'invoicing' ),
115
-                                        'W' => __( 'week(s)', 'invoicing' ),
116
-                                        'M' => __( 'month(s)', 'invoicing' ),
117
-                                        'Y' => __( 'year(s)', 'invoicing' ),
114
+                                        'D' => __('day(s)', 'invoicing'),
115
+                                        'W' => __('week(s)', 'invoicing'),
116
+                                        'M' => __('month(s)', 'invoicing'),
117
+                                        'Y' => __('year(s)', 'invoicing'),
118 118
                                     ),
119 119
                                 ),
120 120
                                 true
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
                         <div class="col-sm-12">
128 128
                             <?php
129 129
                             // Variable pricing.
130
-                            do_action( 'wpinv_item_details_metabox_before_variable_pricing_checkbox', $item );
130
+                            do_action('wpinv_item_details_metabox_before_variable_pricing_checkbox', $item);
131 131
 
132 132
                             aui()->input(
133 133
                                 array(
134 134
                                     'id'      => 'wpinv_variable_pricing',
135 135
                                     'name'    => 'wpinv_variable_pricing',
136 136
                                     'type'    => 'checkbox',
137
-                                    'label'   => apply_filters( 'wpinv_variable_pricing_toggle_text', __( 'Enable variable pricing', 'invoicing' ) ),
137
+                                    'label'   => apply_filters('wpinv_variable_pricing_toggle_text', __('Enable variable pricing', 'invoicing')),
138 138
                                     'value'   => '1',
139 139
                                     'checked' => $item->has_variable_pricing(),
140 140
                                     'no_wrap' => true,
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                                 true
143 143
                             );
144 144
 
145
-                            do_action( 'wpinv_item_details_metabox_variable_pricing_checkbox', $item );
145
+                            do_action('wpinv_item_details_metabox_variable_pricing_checkbox', $item);
146 146
                             ?>
147 147
                         </div>
148 148
                     </div>
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
                             <?php
153 153
 
154 154
                             // Dynamic pricing.
155
-                            if ( $item->supports_dynamic_pricing() ) {
155
+                            if ($item->supports_dynamic_pricing()) {
156 156
 
157
-                                do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
157
+                                do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
158 158
 
159 159
                                 // NYP toggle.
160 160
                                 aui()->input(
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
                                         'id'      => 'wpinv_name_your_price',
163 163
                                         'name'    => 'wpinv_name_your_price',
164 164
                                         'type'    => 'checkbox',
165
-                                        'label'   => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
165
+                                        'label'   => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
166 166
                                         'value'   => '1',
167 167
                                         'checked' => $item->user_can_set_their_price(),
168 168
                                         'no_wrap' => true,
@@ -170,72 +170,72 @@  discard block
 block discarded – undo
170 170
                                     true
171 171
                                 );
172 172
 
173
-                                do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
173
+                                do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
174 174
                             }
175 175
 
176 176
                             // Subscriptions.
177
-                            do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
177
+                            do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
178 178
 
179 179
                             aui()->input(
180 180
                                 array(
181 181
                                     'id'      => 'wpinv_is_recurring',
182 182
                                     'name'    => 'wpinv_is_recurring',
183 183
                                     'type'    => 'checkbox',
184
-                                    'label'   => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
184
+                                    'label'   => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
185 185
                                     'value'   => '1',
186 186
                                     'checked' => $item->is_recurring(),
187 187
                                     'no_wrap' => true,
188 188
                                 ),
189 189
                                 true
190 190
                             );
191
-                            do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
191
+                            do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
192 192
 
193 193
                             ?>
194 194
                             <div class="wpinv_show_if_recurring">
195
-                                <em><?php echo wp_kses_post( wpinv_get_recurring_gateways_text() ); ?></em>
195
+                                <em><?php echo wp_kses_post(wpinv_get_recurring_gateways_text()); ?></em>
196 196
                             </div>
197 197
                         </div>
198 198
                     </div>
199 199
                 </div>
200 200
                 <div class="col-sm-1 pt-2 pl-0 wpinv_hide_if_variable_pricing">
201
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
201
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
202 202
                 </div>
203 203
             </div>
204 204
 
205
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
205
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
206 206
 
207
-            <?php if ( $item->supports_dynamic_pricing() ) : ?>
208
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
207
+            <?php if ($item->supports_dynamic_pricing()) : ?>
208
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
209 209
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price wpinv_hide_if_variable_pricing">
210 210
 
211 211
                     <div class="form-group mb-3 row">
212 212
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
213
-                            <?php esc_html_e( 'Minimum Price', 'invoicing' ); ?>
213
+                            <?php esc_html_e('Minimum Price', 'invoicing'); ?>
214 214
                         </label>
215 215
                         <div class="col-sm-8">
216 216
                             <div class="input-group input-group-sm">
217
-                                <?php if ( 'left' == $position ) : ?>
218
-                                    <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
217
+                                <?php if ('left' == $position) : ?>
218
+                                    <?php if (empty($GLOBALS['aui_bs5'])) : ?>
219 219
                                         <div class="input-group-prepend">
220
-                                            <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
220
+                                            <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
221 221
                                         </div>
222 222
                                     <?php else : ?>
223 223
                                         <span class="input-group-text">
224
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
224
+                                            <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
225 225
                                         </span>
226 226
                                     <?php endif; ?>
227 227
                                 <?php endif; ?>
228 228
 
229
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control wpinv-force-integer">
229
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control wpinv-force-integer">
230 230
 
231
-                                <?php if ( 'left' != $position ) : ?>
232
-                                    <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
231
+                                <?php if ('left' != $position) : ?>
232
+                                    <?php if (empty($GLOBALS['aui_bs5'])) : ?>
233 233
                                         <div class="input-group-append">
234
-                                            <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
234
+                                            <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
235 235
                                         </div>
236 236
                                     <?php else : ?>
237 237
                                         <span class="input-group-text">
238
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
238
+                                            <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
239 239
                                         </span>
240 240
                                     <?php endif; ?>
241 241
                                 <?php endif; ?>
@@ -243,45 +243,45 @@  discard block
 block discarded – undo
243 243
                         </div>
244 244
 
245 245
                         <div class="col-sm-1 pt-2 pl-0">
246
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
246
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
247 247
                         </div>
248 248
                     </div>
249 249
 
250 250
                 </div>
251
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
251
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
252 252
             <?php endif; ?>
253 253
 
254
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
254
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
255 255
             <div class="wpinv_show_if_recurring wpinv_hide_if_variable_pricing wpinv_maximum_renewals">
256 256
 
257 257
                 <div class="form-group mb-3 row">
258 258
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
259
-                        <?php esc_html_e( 'Maximum Renewals', 'invoicing' ); ?>
259
+                        <?php esc_html_e('Maximum Renewals', 'invoicing'); ?>
260 260
                     </label>
261 261
                     <div class="col-sm-8">
262
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
262
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
263 263
                     </div>
264 264
                     <div class="col-sm-1 pt-2 pl-0">
265
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
265
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
266 266
                     </div>
267 267
                 </div>
268 268
 
269 269
             </div>
270
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
270
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
271 271
 
272
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
272
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
273 273
             <div class="wpinv_show_if_recurring wpinv_hide_if_variable_pricing wpinv_free_trial">
274 274
 
275 275
                 <div class="form-group mb-3 row">
276
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? esc_html_e( 'Free/Paid Trial', 'invoicing' ) : esc_html_e( 'Free Trial', 'invoicing' ); ?></label>
276
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? esc_html_e('Free/Paid Trial', 'invoicing') : esc_html_e('Free Trial', 'invoicing'); ?></label>
277 277
 
278 278
                     <div class="col-sm-8">
279 279
                         <div class="row">
280 280
                             <div class="col-sm-6">
281
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0; ?>
281
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
282 282
 
283 283
                                 <div>
284
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>">
284
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>">
285 285
                                 </div>
286 286
                             </div>
287 287
                             <div class="col-sm-6">
@@ -290,17 +290,17 @@  discard block
 block discarded – undo
290 290
                                     array(
291 291
                                         'id'               => 'wpinv_trial_period',
292 292
                                         'name'             => 'wpinv_trial_period',
293
-                                        'label'            => __( 'Trial Period', 'invoicing' ),
294
-                                        'placeholder'      => __( 'Trial Period', 'invoicing' ),
295
-                                        'value'            => $item->get_trial_period( 'edit' ),
293
+                                        'label'            => __('Trial Period', 'invoicing'),
294
+                                        'placeholder'      => __('Trial Period', 'invoicing'),
295
+                                        'value'            => $item->get_trial_period('edit'),
296 296
                                         'select2'          => true,
297 297
                                         'data-allow-clear' => 'false',
298 298
                                         'no_wrap'          => true,
299 299
                                         'options'          => array(
300
-                                            'D' => __( 'day(s)', 'invoicing' ),
301
-                                            'W' => __( 'week(s)', 'invoicing' ),
302
-                                            'M' => __( 'month(s)', 'invoicing' ),
303
-                                            'Y' => __( 'year(s)', 'invoicing' ),
300
+                                            'D' => __('day(s)', 'invoicing'),
301
+                                            'W' => __('week(s)', 'invoicing'),
302
+                                            'M' => __('month(s)', 'invoicing'),
303
+                                            'Y' => __('year(s)', 'invoicing'),
304 304
                                         ),
305 305
                                     ),
306 306
                                     true
@@ -312,17 +312,17 @@  discard block
 block discarded – undo
312 312
                     </div>
313 313
 
314 314
                     <div class="col-sm-1 pt-2 pl-0">
315
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
315
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
316 316
                     </div>
317 317
 
318 318
                 </div>
319 319
 
320 320
             </div>
321
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
321
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
322 322
         </div>
323 323
 
324 324
         <div class="bsui">
325
-            <?php do_action( 'wpinv_item_details_metabox_before_variable_pricing', $item ); ?>
325
+            <?php do_action('wpinv_item_details_metabox_before_variable_pricing', $item); ?>
326 326
 
327 327
             <div class="wpinv_show_if_variable_pricing wpinv_variable_pricing">
328 328
                 
@@ -331,47 +331,47 @@  discard block
 block discarded – undo
331 331
 
332 332
                         <div class="wpinv-price-option-fields getpaid-repeatables-wrap">
333 333
                             <?php
334
-                            if ( ! empty( $variable_prices ) ) :
334
+                            if (!empty($variable_prices)) :
335 335
 
336
-                                foreach ( $variable_prices as $key => $value ) :
337
-                                    $name   = (isset( $value['name'] ) && ! empty( $value['name'] )) ? $value['name'] : '';
338
-                                    $index  = (isset( $value['index'] ) && $value['index'] !== '') ? $value['index'] : $key;
339
-                                    $amount = isset( $value['amount'] ) ? $value['amount'] : '';
336
+                                foreach ($variable_prices as $key => $value) :
337
+                                    $name   = (isset($value['name']) && !empty($value['name'])) ? $value['name'] : '';
338
+                                    $index  = (isset($value['index']) && $value['index'] !== '') ? $value['index'] : $key;
339
+                                    $amount = isset($value['amount']) ? $value['amount'] : '';
340 340
 
341
-                                    $args   = apply_filters( 'wpinv_price_row_args', compact( 'name', 'amount' ), $value );
342
-                                    $args = wp_parse_args( $args, $value );
341
+                                    $args   = apply_filters('wpinv_price_row_args', compact('name', 'amount'), $value);
342
+                                    $args = wp_parse_args($args, $value);
343 343
                                     ?>
344
-                                    <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="<?php echo esc_attr( $key ); ?>">
345
-                                        <?php self::render_price_row( $key, $args, $item, $index ); ?>
344
+                                    <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="<?php echo esc_attr($key); ?>">
345
+                                        <?php self::render_price_row($key, $args, $item, $index); ?>
346 346
                                     </div>
347 347
                                 <?php
348 348
                                 endforeach;
349 349
                             else :
350 350
                                 ?>
351 351
                                 <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="1">
352
-                                    <?php self::render_price_row( 1, array(), $item, 1 ); ?>
352
+                                    <?php self::render_price_row(1, array(), $item, 1); ?>
353 353
                                 </div>
354 354
                             <?php endif; ?>
355 355
 
356 356
                             <div class="wpinv-add-repeatable-row">
357 357
                                 <div class="float-none pt-2 clear">
358
-                                    <button type="button" class="button-secondary getpaid-add-variable-price-row"><?php _e( 'Add New Price', 'invoicing' ); ?></button>
358
+                                    <button type="button" class="button-secondary getpaid-add-variable-price-row"><?php _e('Add New Price', 'invoicing'); ?></button>
359 359
                                 </div>
360 360
                             </div>
361 361
                         </div>
362 362
                     </div>
363 363
                 </div>
364 364
             </div>
365
-            <?php do_action( 'wpinv_item_details_metabox_variable_pricing', $item ); ?>
365
+            <?php do_action('wpinv_item_details_metabox_variable_pricing', $item); ?>
366 366
         </div>
367 367
 
368 368
         <div class="bsui" style="max-width: 600px;">
369
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
369
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
370 370
         </div>
371 371
 
372 372
         <script type="text/html" id="tmpl-getpaid-variable-price-row">
373 373
             <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="1">
374
-                <?php self::render_price_row( 1, array(), $item, 1 ); ?>
374
+                <?php self::render_price_row(1, array(), $item, 1); ?>
375 375
             </div>
376 376
         </script>
377 377
 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
      * @param WP_Post $item  WPINV Itemm object.
474 474
      * @param int    $index The index of the price row.
475 475
      */
476
-    public static function render_price_row( $key, $args = array(), $item, $index ) {
476
+    public static function render_price_row($key, $args = array(), $item, $index) {
477 477
         $defaults = array(
478 478
             'name'               => null,
479 479
             'amount'             => null,
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
             'recurring-limit'    => 0,
486 486
         );
487 487
 
488
-        $args = wp_parse_args( $args, $defaults );
488
+        $args = wp_parse_args($args, $defaults);
489 489
 
490 490
         $default_price_id = $item->get_default_price_id();
491 491
         $is_recurring = ('yes' === $args['is-recurring']) ? true : false;
@@ -498,22 +498,22 @@  discard block
 block discarded – undo
498 498
             'style' => 'width: 70px',
499 499
         );
500 500
 
501
-        if ( ! $is_recurring ) {
501
+        if (!$is_recurring) {
502 502
             $extra_attributes['disabled'] = true;
503 503
         }
504 504
         ?>
505 505
         <div class="getpaid-repeatable-row-header getpaid-draghandle-cursor">
506 506
 
507
-            <span class="getpaid-repeatable-row-title" title="<?php _e( 'Click and drag to re-order price options', 'invoicing' ); ?>">
508
-                <?php printf( __( 'Price ID: %s', 'invoicing' ), '<span class="getpaid_price_id">' . $key . '</span>' ); ?>
507
+            <span class="getpaid-repeatable-row-title" title="<?php _e('Click and drag to re-order price options', 'invoicing'); ?>">
508
+                <?php printf(__('Price ID: %s', 'invoicing'), '<span class="getpaid_price_id">' . $key . '</span>'); ?>
509 509
                 <input type="hidden" name="wpinv_variable_prices[<?php echo $key; ?>][index]" class="getpaid_repeatable_index" value="<?php echo $index; ?>"/>
510 510
             </span>
511 511
 
512 512
             <span class="getpaid-repeatable-row-actions">
513
-                <a href="#" class="wpinv-toggle-custom-price-option-settings" data-show="<?php _e( 'Show advanced settings', 'invoicing' ); ?>" data-hide="<?php _e( 'Hide advanced settings', 'invoicing' ); ?>"><?php _e( 'Show advanced settings', 'invoicing' ); ?></a> 
513
+                <a href="#" class="wpinv-toggle-custom-price-option-settings" data-show="<?php _e('Show advanced settings', 'invoicing'); ?>" data-hide="<?php _e('Hide advanced settings', 'invoicing'); ?>"><?php _e('Show advanced settings', 'invoicing'); ?></a> 
514 514
                 &nbsp;&#124;&nbsp;
515 515
                 <a class="getpaid-remove-price-option-row text-danger">
516
-                    <?php _e( 'Remove', 'invoicing' ); ?> <span class="screen-reader-text"><?php printf( __( 'Remove price option %s', 'invoicing' ), esc_attr( $key ) ); ?></span>
516
+                    <?php _e('Remove', 'invoicing'); ?> <span class="screen-reader-text"><?php printf(__('Remove price option %s', 'invoicing'), esc_attr($key)); ?></span>
517 517
                 </a>
518 518
             </span>
519 519
         </div>
@@ -521,13 +521,13 @@  discard block
 block discarded – undo
521 521
         <div class="getpaid-repeatable-row-standard-fields">
522 522
 
523 523
             <div class="getpaid-option-name">
524
-                <label class="form-label"><?php _e( 'Option Name', 'invoicing' ); ?></label>
524
+                <label class="form-label"><?php _e('Option Name', 'invoicing'); ?></label>
525 525
                 <?php
526 526
                 aui()->input(
527 527
                     array(
528 528
                         'name'        => 'wpinv_variable_prices[' . $key . '][name]',
529
-                        'placeholder' => __( 'Option Name', 'invoicing' ),
530
-                        'value'       => esc_attr( $args['name'] ),
529
+                        'placeholder' => __('Option Name', 'invoicing'),
530
+                        'value'       => esc_attr($args['name']),
531 531
                         'class'       => 'wpinv_variable_price_name form-control-sm',
532 532
                         'no_wrap'     => true,
533 533
                     ),
@@ -537,30 +537,30 @@  discard block
 block discarded – undo
537 537
             </div>
538 538
 
539 539
             <div class="getpaid-option-price">
540
-                <label class="form-label"><?php _e( 'Price', 'invoicing' ); ?></label>
540
+                <label class="form-label"><?php _e('Price', 'invoicing'); ?></label>
541 541
                 <div class="input-group input-group-sm">
542
-                    <?php if ( 'left' == $position ) : ?>
543
-                        <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
542
+                    <?php if ('left' == $position) : ?>
543
+                        <?php if (empty($GLOBALS['aui_bs5'])) : ?>
544 544
                             <div class="input-group-prepend">
545
-                                <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
545
+                                <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
546 546
                             </div>
547 547
                         <?php else : ?>
548 548
                             <span class="input-group-text">
549
-                                <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
549
+                                <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
550 550
                             </span>
551 551
                         <?php endif; ?>
552 552
                     <?php endif; ?>
553 553
 
554
-                    <input type="text" name="wpinv_variable_prices[<?php echo $key; ?>][amount]" id="wpinv_variable_prices[<?php echo $key; ?>][amount]" value="<?php echo esc_attr( getpaid_unstandardize_amount( $args['amount'] ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 9.99 ) ); ?>" class="form-control form-control-sm wpinv-force-integer getpaid-price-field" autocomplete="off">
554
+                    <input type="text" name="wpinv_variable_prices[<?php echo $key; ?>][amount]" id="wpinv_variable_prices[<?php echo $key; ?>][amount]" value="<?php echo esc_attr(getpaid_unstandardize_amount($args['amount'])); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(9.99)); ?>" class="form-control form-control-sm wpinv-force-integer getpaid-price-field" autocomplete="off">
555 555
 
556
-                    <?php if ( 'left' != $position ) : ?>
557
-                        <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
556
+                    <?php if ('left' != $position) : ?>
557
+                        <?php if (empty($GLOBALS['aui_bs5'])) : ?>
558 558
                             <div class="input-group-append">
559
-                                <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
559
+                                <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
560 560
                             </div>
561 561
                         <?php else : ?>
562 562
                             <span class="input-group-text">
563
-                                <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
563
+                                <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
564 564
                             </span>
565 565
                         <?php endif; ?>
566 566
                     <?php endif; ?>
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
             </div>
569 569
 
570 570
             <div class="getpaid_repeatable_default getpaid_repeatable_default_wrapper">
571
-                <label class="form-label d-block"><?php _e( 'Default', 'invoicing' ); ?></label>
571
+                <label class="form-label d-block"><?php _e('Default', 'invoicing'); ?></label>
572 572
                 <label class="getpaid-default-price">
573
-                    <input type="radio" <?php checked( $default_price_id, $key, true ); ?> class="getpaid_repeatable_default_input" name="_wpinv_default_price_id" value="<?php echo $key; ?>" />
574
-                    <span class="screen-reader-text"><?php printf( __( 'Set ID %s as default price', 'invoicing' ), $key ); ?></span>
573
+                    <input type="radio" <?php checked($default_price_id, $key, true); ?> class="getpaid_repeatable_default_input" name="_wpinv_default_price_id" value="<?php echo $key; ?>" />
574
+                    <span class="screen-reader-text"><?php printf(__('Set ID %s as default price', 'invoicing'), $key); ?></span>
575 575
                 </label>
576 576
             </div>
577 577
 
@@ -581,20 +581,20 @@  discard block
 block discarded – undo
581 581
             <div class="wpinv-custom-price-option-settings">
582 582
                 <div class="wpinv-custom-price-option-setting">
583 583
 
584
-                    <div class="wpinv-custom-price-option-setting-title"><?php _e( 'Recurring Payments Settings', 'invoicing' ); ?></div>
584
+                    <div class="wpinv-custom-price-option-setting-title"><?php _e('Recurring Payments Settings', 'invoicing'); ?></div>
585 585
                     
586 586
                     <div class="wpinv-recurring-enabled">
587
-                        <label class="form-label"><?php _e( 'Recurring', 'invoicing' ); ?></label>
587
+                        <label class="form-label"><?php _e('Recurring', 'invoicing'); ?></label>
588 588
                         <?php
589 589
                         aui()->select(
590 590
                             array(
591 591
                                 'name'    => 'wpinv_variable_prices[' . $key . '][is-recurring]',
592
-                                'value'   => esc_attr( $args['is-recurring'] ),
592
+                                'value'   => esc_attr($args['is-recurring']),
593 593
                                 'class'   => 'custom-select-sm',
594 594
                                 'no_wrap' => true,
595 595
                                 'options' => array(
596
-                                    'no'  => __( 'No', 'invoicing' ),
597
-                                    'yes' => __( 'Yes', 'invoicing' ),
596
+                                    'no'  => __('No', 'invoicing'),
597
+                                    'yes' => __('Yes', 'invoicing'),
598 598
                                 ),
599 599
                             ),
600 600
                             true
@@ -603,14 +603,14 @@  discard block
 block discarded – undo
603 603
                     </div>
604 604
 
605 605
                     <div class="wpinv-recurring-free-trial">
606
-                        <label class="form-label"><?php _e( 'Free Trial', 'invoicing' ); ?></label>
606
+                        <label class="form-label"><?php _e('Free Trial', 'invoicing'); ?></label>
607 607
                         <?php
608 608
                         aui()->input(
609 609
                             array(
610 610
                                 'type'             => 'number',
611 611
                                 'id'               => 'wpinv_variable_prices[' . $key . '][trial-interval]',
612 612
                                 'name'             => 'wpinv_variable_prices[' . $key . '][trial-interval]',
613
-                                'value'            => absint( $args['trial-interval'] ),
613
+                                'value'            => absint($args['trial-interval']),
614 614
                                 'class'            => 'form-control-sm d-inline-block',
615 615
                                 'no_wrap'          => true,
616 616
                                 'extra_attributes' => $extra_attributes,
@@ -624,15 +624,15 @@  discard block
 block discarded – undo
624 624
                             array(
625 625
                                 'id'               => 'wpinv_variable_prices[' . $key . '][trial-period]',
626 626
                                 'name'             => 'wpinv_variable_prices[' . $key . '][trial-period]',
627
-                                'value'            => esc_attr( $args['trial-period'] ),
627
+                                'value'            => esc_attr($args['trial-period']),
628 628
                                 'class'            => 'custom-select-sm w-auto d-inline-block',
629 629
                                 'no_wrap'          => true,
630
-                                'extra_attributes' => ( ! $is_recurring ? array( 'disabled' => true ) : array()),
630
+                                'extra_attributes' => (!$is_recurring ? array('disabled' => true) : array()),
631 631
                                 'options'          => array(
632
-                                    'D' => __( 'Day(s)', 'invoicing' ),
633
-                                    'W' => __( 'Week(s)', 'invoicing' ),
634
-                                    'M' => __( 'Month(s)', 'invoicing' ),
635
-                                    'Y' => __( 'Year(s)', 'invoicing' ),
632
+                                    'D' => __('Day(s)', 'invoicing'),
633
+                                    'W' => __('Week(s)', 'invoicing'),
634
+                                    'M' => __('Month(s)', 'invoicing'),
635
+                                    'Y' => __('Year(s)', 'invoicing'),
636 636
                                 ),
637 637
                             ),
638 638
                             true
@@ -641,14 +641,14 @@  discard block
 block discarded – undo
641 641
                     </div>
642 642
 
643 643
                     <div class="wpinv-recurring-interval">
644
-                        <label class="form-label"><?php _e( 'Every', 'invoicing' ); ?></label>
644
+                        <label class="form-label"><?php _e('Every', 'invoicing'); ?></label>
645 645
                         <?php
646 646
                         aui()->input(
647 647
                             array(
648 648
                                 'type'             => 'number',
649 649
                                 'id'               => 'wpinv_variable_prices[' . $key . '][recurring-interval]',
650 650
                                 'name'             => 'wpinv_variable_prices[' . $key . '][recurring-interval]',
651
-                                'value'            => absint( $args['recurring-interval'] ),
651
+                                'value'            => absint($args['recurring-interval']),
652 652
                                 'class'            => 'form-control-sm',
653 653
                                 'no_wrap'          => true,
654 654
                                 'extra_attributes' => $extra_attributes,
@@ -659,21 +659,21 @@  discard block
 block discarded – undo
659 659
                     </div>
660 660
 
661 661
                     <div class="wpinv-recurring-period">
662
-                        <label class="form-label"><?php _e( 'Period', 'invoicing' ); ?></label>
662
+                        <label class="form-label"><?php _e('Period', 'invoicing'); ?></label>
663 663
                         <?php
664 664
                         aui()->select(
665 665
                             array(
666 666
                                 'id'               => 'wpinv_variable_prices[' . $key . '][recurring-period]',
667 667
                                 'name'             => 'wpinv_variable_prices[' . $key . '][recurring-period]',
668
-                                'value'            => esc_attr( $args['recurring-period'] ),
668
+                                'value'            => esc_attr($args['recurring-period']),
669 669
                                 'class'            => 'custom-select-sm',
670
-                                'extra_attributes' => ( ! $is_recurring ? array( 'disabled' => true ) : array()),
670
+                                'extra_attributes' => (!$is_recurring ? array('disabled' => true) : array()),
671 671
                                 'no_wrap'          => true,
672 672
                                 'options'          => array(
673
-                                    'D' => __( 'Day(s)', 'invoicing' ),
674
-                                    'W' => __( 'Week(s)', 'invoicing' ),
675
-                                    'M' => __( 'Month(s)', 'invoicing' ),
676
-                                    'Y' => __( 'Year(s)', 'invoicing' ),
673
+                                    'D' => __('Day(s)', 'invoicing'),
674
+                                    'W' => __('Week(s)', 'invoicing'),
675
+                                    'M' => __('Month(s)', 'invoicing'),
676
+                                    'Y' => __('Year(s)', 'invoicing'),
677 677
                                 ),
678 678
                             ),
679 679
                             true
@@ -682,19 +682,19 @@  discard block
 block discarded – undo
682 682
                     </div>
683 683
 
684 684
                     <div class="wpinv-recurring-limit">
685
-                        <label class="form-label"><?php _e( 'Maximum Renewals', 'invoicing' ); ?></label>
685
+                        <label class="form-label"><?php _e('Maximum Renewals', 'invoicing'); ?></label>
686 686
                         <?php
687 687
                         aui()->input(
688 688
                             array(
689 689
                                 'type'             => 'number',
690 690
                                 'id'               => 'wpinv_variable_prices[' . $key . '][recurring-limit]',
691 691
                                 'name'             => 'wpinv_variable_prices[' . $key . '][recurring-limit]',
692
-                                'value'            => esc_attr( $args['recurring-limit'] ),
692
+                                'value'            => esc_attr($args['recurring-limit']),
693 693
                                 'class'            => 'form-control-sm',
694 694
                                 'no_wrap'          => true,
695 695
                                 'extra_attributes' => array_merge(
696 696
                                     $extra_attributes,
697
-                                    array( 'size' => 4 )
697
+                                    array('size' => 4)
698 698
                                 ),
699 699
 							),
700 700
                             true
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
                     </div>
704 704
                 </div>
705 705
 
706
-                <?php do_action( 'wpinv_download_price_option_row', $item->ID, $key, $args ); ?>
706
+                <?php do_action('wpinv_download_price_option_row', $item->ID, $key, $args); ?>
707 707
             </div>
708 708
         </div>
709 709
     <?php
@@ -714,43 +714,43 @@  discard block
 block discarded – undo
714 714
      *
715 715
      * @param int $post_id
716 716
      */
717
-    public static function save( $post_id ) {
717
+    public static function save($post_id) {
718 718
 
719 719
         // Prepare the item.
720
-        $item = new WPInv_Item( $post_id );
720
+        $item = new WPInv_Item($post_id);
721 721
 
722
-        $is_dynamic_pricing = ! empty( $_POST['wpinv_name_your_price'] );
723
-        $is_recurring = ! empty( $_POST['wpinv_is_recurring'] );
724
-        $is_free_trial = isset( $_POST['wpinv_trial_interval'] ) ? (0 != (int) $_POST['wpinv_trial_interval']) : null;
722
+        $is_dynamic_pricing = !empty($_POST['wpinv_name_your_price']);
723
+        $is_recurring = !empty($_POST['wpinv_is_recurring']);
724
+        $is_free_trial = isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null;
725 725
 
726
-        $has_variable_pricing = ! empty( $_POST['wpinv_variable_pricing'] );
727
-        if ( true === $has_variable_pricing ) {
726
+        $has_variable_pricing = !empty($_POST['wpinv_variable_pricing']);
727
+        if (true === $has_variable_pricing) {
728 728
             $is_dynamic_pricing = $is_recurring = $is_free_trial = false;
729 729
         }
730 730
 
731 731
         // Load new data.
732 732
         $item->set_props(
733 733
             array(
734
-                'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
735
-                'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
736
-                'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
737
-                'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
734
+                'price'                => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null,
735
+                'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
736
+                'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
737
+                'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
738 738
                 'is_dynamic_pricing'   => $is_dynamic_pricing,
739
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
739
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null,
740 740
                 'has_variable_pricing' => $has_variable_pricing,
741
-                'default_price_id'     => isset( $_POST['_wpinv_default_price_id'] ) ? absint( $_POST['_wpinv_default_price_id'] ) : null,
742
-                'variable_prices'      => isset( $_POST['wpinv_variable_prices'] ) ? wpinv_clean( $_POST['wpinv_variable_prices'] ) : array(),
741
+                'default_price_id'     => isset($_POST['_wpinv_default_price_id']) ? absint($_POST['_wpinv_default_price_id']) : null,
742
+                'variable_prices'      => isset($_POST['wpinv_variable_prices']) ? wpinv_clean($_POST['wpinv_variable_prices']) : array(),
743 743
                 'is_recurring'         => $is_recurring,
744
-                'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
745
-                'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
746
-                'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
744
+                'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
745
+                'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1,
746
+                'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
747 747
                 'is_free_trial'        => $is_free_trial,
748
-                'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
749
-                'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
748
+                'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
749
+                'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
750 750
             )
751 751
         );
752 752
 
753 753
         $item->save();
754
-        do_action( 'getpaid_item_metabox_save', $post_id, $item );
754
+        do_action('getpaid_item_metabox_save', $post_id, $item);
755 755
     }
756 756
 }
Please login to merge, or discard this patch.
Braces   +35 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,9 +70,12 @@  discard block
 block discarded – undo
70 70
                                         <div class="input-group-prepend">
71 71
                                             <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
72 72
                                         </div>
73
-                                    <?php else : ?>
73
+                                    <?php else {
74
+    : ?>
74 75
                                         <span class="input-group-text">
75
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
76
+                                            <?php echo wp_kses_post( wpinv_currency_symbol() );
77
+}
78
+?>
76 79
                                         </span>
77 80
                                     <?php endif; ?>
78 81
                                 <?php endif; ?>
@@ -84,9 +87,12 @@  discard block
 block discarded – undo
84 87
                                         <div class="input-group-append">
85 88
                                             <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
86 89
                                         </div>
87
-                                    <?php else : ?>
90
+                                    <?php else {
91
+    : ?>
88 92
                                         <span class="input-group-text">
89
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
93
+                                            <?php echo wp_kses_post( wpinv_currency_symbol() );
94
+}
95
+?>
90 96
                                         </span>
91 97
                                     <?php endif; ?>
92 98
                                 <?php endif; ?>
@@ -219,9 +225,12 @@  discard block
 block discarded – undo
219 225
                                         <div class="input-group-prepend">
220 226
                                             <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
221 227
                                         </div>
222
-                                    <?php else : ?>
228
+                                    <?php else {
229
+    : ?>
223 230
                                         <span class="input-group-text">
224
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
231
+                                            <?php echo wp_kses_post( wpinv_currency_symbol() );
232
+}
233
+?>
225 234
                                         </span>
226 235
                                     <?php endif; ?>
227 236
                                 <?php endif; ?>
@@ -233,9 +242,12 @@  discard block
 block discarded – undo
233 242
                                         <div class="input-group-append">
234 243
                                             <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
235 244
                                         </div>
236
-                                    <?php else : ?>
245
+                                    <?php else {
246
+    : ?>
237 247
                                         <span class="input-group-text">
238
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
248
+                                            <?php echo wp_kses_post( wpinv_currency_symbol() );
249
+}
250
+?>
239 251
                                         </span>
240 252
                                     <?php endif; ?>
241 253
                                 <?php endif; ?>
@@ -346,10 +358,13 @@  discard block
 block discarded – undo
346 358
                                     </div>
347 359
                                 <?php
348 360
                                 endforeach;
349
-                            else :
361
+                            else {
362
+                                :
350 363
                                 ?>
351 364
                                 <div class="wpinv_variable_prices_wrapper getpaid_repeatable_row" data-key="1">
352
-                                    <?php self::render_price_row( 1, array(), $item, 1 ); ?>
365
+                                    <?php self::render_price_row( 1, array(), $item, 1 );
366
+                            }
367
+                            ?>
353 368
                                 </div>
354 369
                             <?php endif; ?>
355 370
 
@@ -544,9 +559,12 @@  discard block
 block discarded – undo
544 559
                             <div class="input-group-prepend">
545 560
                                 <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
546 561
                             </div>
547
-                        <?php else : ?>
562
+                        <?php else {
563
+    : ?>
548 564
                             <span class="input-group-text">
549
-                                <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
565
+                                <?php echo wp_kses_post( wpinv_currency_symbol() );
566
+}
567
+?>
550 568
                             </span>
551 569
                         <?php endif; ?>
552 570
                     <?php endif; ?>
@@ -558,9 +576,12 @@  discard block
 block discarded – undo
558 576
                             <div class="input-group-append">
559 577
                                 <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
560 578
                             </div>
561
-                        <?php else : ?>
579
+                        <?php else {
580
+    : ?>
562 581
                             <span class="input-group-text">
563
-                                <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
582
+                                <?php echo wp_kses_post( wpinv_currency_symbol() );
583
+}
584
+?>
564 585
                             </span>
565 586
                         <?php endif; ?>
566 587
                     <?php endif; ?>
Please login to merge, or discard this patch.
includes/payments/class-getpaid-form-item.php 2 patches
Indentation   +388 added lines, -388 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,75 +10,75 @@  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;
74
-
75
-
76
-    /**
77
-	 * Item price ID.
78
-	 *
79
-	 * @var int
80
-	 */
81
-	public $price_id = 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
+
75
+
76
+    /**
77
+     * Item price ID.
78
+     *
79
+     * @var int
80
+     */
81
+    public $price_id = 0;
82 82
 
83 83
     /*
84 84
 	|--------------------------------------------------------------------------
@@ -96,242 +96,242 @@  discard block
 block discarded – undo
96 96
     */
97 97
 
98 98
     /**
99
-	 * Get the item name.
100
-	 *
101
-	 * @since 1.0.19
102
-	 * @param  string $context View or edit context.
103
-	 * @return string
104
-	 */
105
-	public function get_name( $context = 'view' ) {
106
-		$name = parent::get_name( $context );
107
-		return $name . wpinv_get_item_suffix( $this );
108
-	}
109
-
110
-	/**
111
-	 * Get the item name without a suffix.
112
-	 *
113
-	 * @since 1.0.19
114
-	 * @param  string $context View or edit context.
115
-	 * @return string
116
-	 */
117
-	public function get_raw_name( $context = 'view' ) {
118
-		return parent::get_name( $context );
119
-	}
120
-
121
-	/**
122
-	 * Get the item description.
123
-	 *
124
-	 * @since 1.0.19
125
-	 * @param  string $context View or edit context.
126
-	 * @return string
127
-	 */
128
-	public function get_description( $context = 'view' ) {
129
-
130
-		if ( isset( $this->custom_description ) ) {
131
-			return $this->custom_description;
132
-		}
133
-
134
-		return parent::get_description( $context );
135
-	}
136
-
137
-	/**
138
-	 * Returns the sub total.
139
-	 *
140
-	 * @since 1.0.19
141
-	 * @param  string $context View or edit context.
142
-	 * @return float
143
-	 */
144
-	public function get_sub_total( $context = 'view', $price_id = null ) {
145
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context, $price_id );
146
-	}
147
-
148
-	/**
149
-	 * Returns the recurring sub total.
150
-	 *
151
-	 * @since 1.0.19
152
-	 * @param  string $context View or edit context.
153
-	 * @return float
154
-	 */
155
-	public function get_recurring_sub_total( $context = 'view' ) {
156
-
157
-		if ( $this->is_recurring() ) {
158
-			return $this->get_quantity( $context ) * $this->get_price( $context );
159
-		}
160
-
161
-		return 0;
162
-	}
163
-
164
-	/**
165
-	 * @deprecated
166
-	 */
167
-	public function get_qantity( $context = 'view' ) {
168
-		return $this->get_quantity( $context );
169
-	}
170
-
171
-	/**
172
-	 * Get the item quantity.
173
-	 *
174
-	 * @since 1.0.19
175
-	 * @param  string $context View or edit context.
176
-	 * @return float
177
-	 */
178
-	public function get_quantity( $context = 'view' ) {
179
-		$quantity = (float) $this->quantity;
180
-
181
-		if ( 'view' === $context ) {
182
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
183
-		}
184
-
185
-		return $quantity;
186
-	}
187
-
188
-	/**
189
-	 * Get the item meta data.
190
-	 *
191
-	 * @since 1.0.19
192
-	 * @param  string $context View or edit context.
193
-	 * @return meta
194
-	 */
195
-	public function get_item_meta( $context = 'view' ) {
196
-		$meta = $this->meta;
197
-
198
-		if ( 'view' === $context ) {
199
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
200
-		}
201
-
202
-		return $meta;
203
-	}
204
-
205
-	/**
206
-	 * Returns whether or not customers can update the item quantity.
207
-	 *
208
-	 * @since 1.0.19
209
-	 * @param  string $context View or edit context.
210
-	 * @return bool
211
-	 */
212
-	public function get_allow_quantities( $context = 'view' ) {
213
-		$allow_quantities = (bool) $this->allow_quantities;
214
-
215
-		if ( 'view' === $context ) {
216
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
217
-		}
218
-
219
-		return $allow_quantities;
220
-	}
221
-
222
-	/**
223
-	 * Returns whether or not the item is required.
224
-	 *
225
-	 * @since 1.0.19
226
-	 * @param  string $context View or edit context.
227
-	 * @return bool
228
-	 */
229
-	public function get_is_required( $context = 'view' ) {
230
-		$is_required = (bool) $this->is_required;
231
-
232
-		if ( 'view' === $context ) {
233
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
234
-		}
235
-
236
-		return $is_required;
237
-	}
238
-
239
-    /**
240
-	 * Returns whether or not customers can update the item quantity.
241
-	 *
242
-	 * @since 1.0.19
243
-	 * @param  string $context View or edit context.
244
-	 * @return int
245
-	 */
246
-	public function get_price_id( $context = 'view' ) {
247
-		$price_id = (int) $this->price_id;
248
-
249
-		if ( 'view' === $context ) {
250
-			return apply_filters( 'getpaid_payment_form_item_price_id', $price_id, $this );
251
-		}
252
-
253
-		return $price_id;
254
-	}
255
-
256
-	/**
257
-	 * Prepares form data for use.
258
-	 *
259
-	 * @since 1.0.19
260
-	 * @return array
261
-	 */
262
-	public function prepare_data_for_use( $required = null ) {
263
-
264
-		$required = is_null( $required ) ? $this->is_required() : $required;
265
-		return array(
266
-			'title'            => wp_strip_all_tags( $this->get_name() ),
267
-			'id'               => $this->get_id(),
268
-			'price'            => $this->get_price(),
269
-			'recurring'        => $this->is_recurring(),
270
-			'description'      => $this->get_description(),
271
-			'allow_quantities' => $this->allows_quantities(),
272
-			'price_id'         => $this->get_price_id(),
273
-			'required'         => $required,
274
-		);
275
-	}
276
-
277
-	/**
278
-	 * Prepares form data for ajax use.
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @return array
282
-	 */
283
-	public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
284
-
285
-		$description = getpaid_item_recurring_price_help_text( $this, $currency );
286
-
287
-		if ( $description ) {
288
-			$description = "<div class='getpaid-subscription-help-text'>$description</div>";
289
-		}
290
-
291
-		$price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
292
-		$subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
293
-		return array(
294
-			'id'     => $this->get_id(),
295
-			'texts'  => array(
296
-				'item-name'        => sanitize_text_field( $this->get_name() ),
297
-				'item-description' => wp_kses_post( $this->get_description() ) . $description,
298
-				'item-quantity'    => floatval( $this->get_quantity() ),
299
-				'item-price'       => wpinv_price( $price, $currency ),
300
-				'item-total'       => wpinv_price( $subtotal, $currency ),
301
-			),
302
-			'inputs' => array(
303
-				'item-id'          => $this->get_id(),
304
-				'item-name'        => sanitize_text_field( $this->get_name() ),
305
-				'item-description' => wp_kses_post( $this->get_description() ),
306
-				'item-quantity'    => floatval( $this->get_quantity() ),
307
-				'item-price'       => $price,
308
-			),
309
-		);
310
-	}
311
-
312
-	/**
313
-	 * Prepares form data for saving (cart_details).
314
-	 *
315
-	 * @since 1.0.19
316
-	 * @return array
317
-	 */
318
-	public function prepare_data_for_saving() {
319
-
320
-		return array(
321
-			'post_id'          => $this->invoice_id,
322
-			'item_id'          => $this->get_id(),
323
-			'item_name'        => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
324
-			'item_description' => $this->get_description( 'edit' ),
325
-			'tax'              => $this->item_tax,
326
-			'item_price'       => $this->get_price( 'edit' ),
327
-			'quantity'         => (float) $this->get_quantity( 'edit' ),
328
-			'discount'         => $this->item_discount,
329
-			'subtotal'         => $this->get_sub_total( 'edit' ),
330
-			'price'            => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
331
-			'price_id'         => (int) $this->get_price_id( 'edit' ),
332
-			'meta'             => $this->get_item_meta( 'edit' ),
333
-		);
334
-	}
99
+     * Get the item name.
100
+     *
101
+     * @since 1.0.19
102
+     * @param  string $context View or edit context.
103
+     * @return string
104
+     */
105
+    public function get_name( $context = 'view' ) {
106
+        $name = parent::get_name( $context );
107
+        return $name . wpinv_get_item_suffix( $this );
108
+    }
109
+
110
+    /**
111
+     * Get the item name without a suffix.
112
+     *
113
+     * @since 1.0.19
114
+     * @param  string $context View or edit context.
115
+     * @return string
116
+     */
117
+    public function get_raw_name( $context = 'view' ) {
118
+        return parent::get_name( $context );
119
+    }
120
+
121
+    /**
122
+     * Get the item description.
123
+     *
124
+     * @since 1.0.19
125
+     * @param  string $context View or edit context.
126
+     * @return string
127
+     */
128
+    public function get_description( $context = 'view' ) {
129
+
130
+        if ( isset( $this->custom_description ) ) {
131
+            return $this->custom_description;
132
+        }
133
+
134
+        return parent::get_description( $context );
135
+    }
136
+
137
+    /**
138
+     * Returns the sub total.
139
+     *
140
+     * @since 1.0.19
141
+     * @param  string $context View or edit context.
142
+     * @return float
143
+     */
144
+    public function get_sub_total( $context = 'view', $price_id = null ) {
145
+        return $this->get_quantity( $context ) * $this->get_initial_price( $context, $price_id );
146
+    }
147
+
148
+    /**
149
+     * Returns the recurring sub total.
150
+     *
151
+     * @since 1.0.19
152
+     * @param  string $context View or edit context.
153
+     * @return float
154
+     */
155
+    public function get_recurring_sub_total( $context = 'view' ) {
156
+
157
+        if ( $this->is_recurring() ) {
158
+            return $this->get_quantity( $context ) * $this->get_price( $context );
159
+        }
160
+
161
+        return 0;
162
+    }
163
+
164
+    /**
165
+     * @deprecated
166
+     */
167
+    public function get_qantity( $context = 'view' ) {
168
+        return $this->get_quantity( $context );
169
+    }
170
+
171
+    /**
172
+     * Get the item quantity.
173
+     *
174
+     * @since 1.0.19
175
+     * @param  string $context View or edit context.
176
+     * @return float
177
+     */
178
+    public function get_quantity( $context = 'view' ) {
179
+        $quantity = (float) $this->quantity;
180
+
181
+        if ( 'view' === $context ) {
182
+            return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
183
+        }
184
+
185
+        return $quantity;
186
+    }
187
+
188
+    /**
189
+     * Get the item meta data.
190
+     *
191
+     * @since 1.0.19
192
+     * @param  string $context View or edit context.
193
+     * @return meta
194
+     */
195
+    public function get_item_meta( $context = 'view' ) {
196
+        $meta = $this->meta;
197
+
198
+        if ( 'view' === $context ) {
199
+            return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
200
+        }
201
+
202
+        return $meta;
203
+    }
204
+
205
+    /**
206
+     * Returns whether or not customers can update the item quantity.
207
+     *
208
+     * @since 1.0.19
209
+     * @param  string $context View or edit context.
210
+     * @return bool
211
+     */
212
+    public function get_allow_quantities( $context = 'view' ) {
213
+        $allow_quantities = (bool) $this->allow_quantities;
214
+
215
+        if ( 'view' === $context ) {
216
+            return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
217
+        }
218
+
219
+        return $allow_quantities;
220
+    }
221
+
222
+    /**
223
+     * Returns whether or not the item is required.
224
+     *
225
+     * @since 1.0.19
226
+     * @param  string $context View or edit context.
227
+     * @return bool
228
+     */
229
+    public function get_is_required( $context = 'view' ) {
230
+        $is_required = (bool) $this->is_required;
231
+
232
+        if ( 'view' === $context ) {
233
+            return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
234
+        }
235
+
236
+        return $is_required;
237
+    }
238
+
239
+    /**
240
+     * Returns whether or not customers can update the item quantity.
241
+     *
242
+     * @since 1.0.19
243
+     * @param  string $context View or edit context.
244
+     * @return int
245
+     */
246
+    public function get_price_id( $context = 'view' ) {
247
+        $price_id = (int) $this->price_id;
248
+
249
+        if ( 'view' === $context ) {
250
+            return apply_filters( 'getpaid_payment_form_item_price_id', $price_id, $this );
251
+        }
252
+
253
+        return $price_id;
254
+    }
255
+
256
+    /**
257
+     * Prepares form data for use.
258
+     *
259
+     * @since 1.0.19
260
+     * @return array
261
+     */
262
+    public function prepare_data_for_use( $required = null ) {
263
+
264
+        $required = is_null( $required ) ? $this->is_required() : $required;
265
+        return array(
266
+            'title'            => wp_strip_all_tags( $this->get_name() ),
267
+            'id'               => $this->get_id(),
268
+            'price'            => $this->get_price(),
269
+            'recurring'        => $this->is_recurring(),
270
+            'description'      => $this->get_description(),
271
+            'allow_quantities' => $this->allows_quantities(),
272
+            'price_id'         => $this->get_price_id(),
273
+            'required'         => $required,
274
+        );
275
+    }
276
+
277
+    /**
278
+     * Prepares form data for ajax use.
279
+     *
280
+     * @since 1.0.19
281
+     * @return array
282
+     */
283
+    public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
284
+
285
+        $description = getpaid_item_recurring_price_help_text( $this, $currency );
286
+
287
+        if ( $description ) {
288
+            $description = "<div class='getpaid-subscription-help-text'>$description</div>";
289
+        }
290
+
291
+        $price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
292
+        $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
293
+        return array(
294
+            'id'     => $this->get_id(),
295
+            'texts'  => array(
296
+                'item-name'        => sanitize_text_field( $this->get_name() ),
297
+                'item-description' => wp_kses_post( $this->get_description() ) . $description,
298
+                'item-quantity'    => floatval( $this->get_quantity() ),
299
+                'item-price'       => wpinv_price( $price, $currency ),
300
+                'item-total'       => wpinv_price( $subtotal, $currency ),
301
+            ),
302
+            'inputs' => array(
303
+                'item-id'          => $this->get_id(),
304
+                'item-name'        => sanitize_text_field( $this->get_name() ),
305
+                'item-description' => wp_kses_post( $this->get_description() ),
306
+                'item-quantity'    => floatval( $this->get_quantity() ),
307
+                'item-price'       => $price,
308
+            ),
309
+        );
310
+    }
311
+
312
+    /**
313
+     * Prepares form data for saving (cart_details).
314
+     *
315
+     * @since 1.0.19
316
+     * @return array
317
+     */
318
+    public function prepare_data_for_saving() {
319
+
320
+        return array(
321
+            'post_id'          => $this->invoice_id,
322
+            'item_id'          => $this->get_id(),
323
+            'item_name'        => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
324
+            'item_description' => $this->get_description( 'edit' ),
325
+            'tax'              => $this->item_tax,
326
+            'item_price'       => $this->get_price( 'edit' ),
327
+            'quantity'         => (float) $this->get_quantity( 'edit' ),
328
+            'discount'         => $this->item_discount,
329
+            'subtotal'         => $this->get_sub_total( 'edit' ),
330
+            'price'            => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
331
+            'price_id'         => (int) $this->get_price_id( 'edit' ),
332
+            'meta'             => $this->get_item_meta( 'edit' ),
333
+        );
334
+    }
335 335
 
336 336
     /*
337 337
 	|--------------------------------------------------------------------------
@@ -343,84 +343,84 @@  discard block
 block discarded – undo
343 343
 	| object.
344 344
     */
345 345
 
346
-	/**
347
-	 * Set the item qantity.
348
-	 *
349
-	 * @since 1.0.19
350
-	 * @param  float $quantity The item quantity.
351
-	 */
352
-	public function set_quantity( $quantity ) {
346
+    /**
347
+     * Set the item qantity.
348
+     *
349
+     * @since 1.0.19
350
+     * @param  float $quantity The item quantity.
351
+     */
352
+    public function set_quantity( $quantity ) {
353
+
354
+        if ( ! is_numeric( $quantity ) ) {
355
+            $quantity = 1;
356
+        }
357
+
358
+        $this->quantity = (float) $quantity;
359
+    }
360
+
361
+    /**
362
+     * Set the item price ID.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  float $price_id The item price ID.
366
+     */
367
+    public function set_price_id( $price_id ) {
368
+
369
+        if ( ! is_numeric( $price_id ) ) {
370
+            $price_id = $this->get_default_price_id();
371
+        }
353 372
 
354
-		if ( ! is_numeric( $quantity ) ) {
355
-			$quantity = 1;
356
-		}
373
+        $this->price_id = (int) $price_id;
374
+    }
357 375
 
358
-		$this->quantity = (float) $quantity;
376
+    /**
377
+     * Set the item meta data.
378
+     *
379
+     * @since 1.0.19
380
+     * @param  array $meta The item meta data.
381
+     */
382
+    public function set_item_meta( $meta ) {
383
+        $this->meta = maybe_unserialize( $meta );
359 384
     }
360 385
 
361 386
     /**
362
-	 * Set the item price ID.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  float $price_id The item price ID.
366
-	 */
367
-	public function set_price_id( $price_id ) {
368
-
369
-		if ( ! is_numeric( $price_id ) ) {
370
-			$price_id = $this->get_default_price_id();
371
-		}
372
-
373
-		$this->price_id = (int) $price_id;
374
-	}
375
-
376
-	/**
377
-	 * Set the item meta data.
378
-	 *
379
-	 * @since 1.0.19
380
-	 * @param  array $meta The item meta data.
381
-	 */
382
-	public function set_item_meta( $meta ) {
383
-		$this->meta = maybe_unserialize( $meta );
384
-	}
385
-
386
-	/**
387
-	 * Set whether or not the quantities are allowed.
388
-	 *
389
-	 * @since 1.0.19
390
-	 * @param  bool $allow_quantities
391
-	 */
392
-	public function set_allow_quantities( $allow_quantities ) {
393
-		$this->allow_quantities = (bool) $allow_quantities;
394
-	}
395
-
396
-	/**
397
-	 * Set whether or not the item is required.
398
-	 *
399
-	 * @since 1.0.19
400
-	 * @param  bool $is_required
401
-	 */
402
-	public function set_is_required( $is_required ) {
403
-		$this->is_required = (bool) $is_required;
404
-	}
405
-
406
-	/**
407
-	 * Sets the custom item description.
408
-	 *
409
-	 * @since 1.0.19
410
-	 * @param  string $description
411
-	 */
412
-	public function set_custom_description( $description ) {
413
-		$this->custom_description = $description;
414
-	}
387
+     * Set whether or not the quantities are allowed.
388
+     *
389
+     * @since 1.0.19
390
+     * @param  bool $allow_quantities
391
+     */
392
+    public function set_allow_quantities( $allow_quantities ) {
393
+        $this->allow_quantities = (bool) $allow_quantities;
394
+    }
395
+
396
+    /**
397
+     * Set whether or not the item is required.
398
+     *
399
+     * @since 1.0.19
400
+     * @param  bool $is_required
401
+     */
402
+    public function set_is_required( $is_required ) {
403
+        $this->is_required = (bool) $is_required;
404
+    }
405
+
406
+    /**
407
+     * Sets the custom item description.
408
+     *
409
+     * @since 1.0.19
410
+     * @param  string $description
411
+     */
412
+    public function set_custom_description( $description ) {
413
+        $this->custom_description = $description;
414
+    }
415 415
 
416 416
     /**
417 417
      * We do not want to save items to the database.
418 418
      *
419
-	 * @return int item id
419
+     * @return int item id
420 420
      */
421 421
     public function save( $data = array() ) {
422 422
         return $this->get_id();
423
-	}
423
+    }
424 424
 
425 425
     /*
426 426
 	|--------------------------------------------------------------------------
@@ -432,22 +432,22 @@  discard block
 block discarded – undo
432 432
 	*/
433 433
 
434 434
     /**
435
-	 * Checks whether the item has enabled dynamic pricing.
436
-	 *
437
-	 * @since 1.0.19
438
-	 * @return bool
439
-	 */
440
-	public function is_required() {
435
+     * Checks whether the item has enabled dynamic pricing.
436
+     *
437
+     * @since 1.0.19
438
+     * @return bool
439
+     */
440
+    public function is_required() {
441 441
         return (bool) $this->get_is_required();
442
-	}
443
-
444
-	/**
445
-	 * Checks whether users can edit the quantities.
446
-	 *
447
-	 * @since 1.0.19
448
-	 * @return bool
449
-	 */
450
-	public function allows_quantities() {
442
+    }
443
+
444
+    /**
445
+     * Checks whether users can edit the quantities.
446
+     *
447
+     * @since 1.0.19
448
+     * @return bool
449
+     */
450
+    public function allows_quantities() {
451 451
         return (bool) $this->get_allow_quantities();
452
-	}
452
+    }
453 453
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 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
 
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	 * @param  string $context View or edit context.
103 103
 	 * @return string
104 104
 	 */
105
-	public function get_name( $context = 'view' ) {
106
-		$name = parent::get_name( $context );
107
-		return $name . wpinv_get_item_suffix( $this );
105
+	public function get_name($context = 'view') {
106
+		$name = parent::get_name($context);
107
+		return $name . wpinv_get_item_suffix($this);
108 108
 	}
109 109
 
110 110
 	/**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @param  string $context View or edit context.
115 115
 	 * @return string
116 116
 	 */
117
-	public function get_raw_name( $context = 'view' ) {
118
-		return parent::get_name( $context );
117
+	public function get_raw_name($context = 'view') {
118
+		return parent::get_name($context);
119 119
 	}
120 120
 
121 121
 	/**
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 	 * @param  string $context View or edit context.
126 126
 	 * @return string
127 127
 	 */
128
-	public function get_description( $context = 'view' ) {
128
+	public function get_description($context = 'view') {
129 129
 
130
-		if ( isset( $this->custom_description ) ) {
130
+		if (isset($this->custom_description)) {
131 131
 			return $this->custom_description;
132 132
 		}
133 133
 
134
-		return parent::get_description( $context );
134
+		return parent::get_description($context);
135 135
 	}
136 136
 
137 137
 	/**
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 	 * @param  string $context View or edit context.
142 142
 	 * @return float
143 143
 	 */
144
-	public function get_sub_total( $context = 'view', $price_id = null ) {
145
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context, $price_id );
144
+	public function get_sub_total($context = 'view', $price_id = null) {
145
+		return $this->get_quantity($context) * $this->get_initial_price($context, $price_id);
146 146
 	}
147 147
 
148 148
 	/**
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 * @param  string $context View or edit context.
153 153
 	 * @return float
154 154
 	 */
155
-	public function get_recurring_sub_total( $context = 'view' ) {
155
+	public function get_recurring_sub_total($context = 'view') {
156 156
 
157
-		if ( $this->is_recurring() ) {
158
-			return $this->get_quantity( $context ) * $this->get_price( $context );
157
+		if ($this->is_recurring()) {
158
+			return $this->get_quantity($context) * $this->get_price($context);
159 159
 		}
160 160
 
161 161
 		return 0;
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	/**
165 165
 	 * @deprecated
166 166
 	 */
167
-	public function get_qantity( $context = 'view' ) {
168
-		return $this->get_quantity( $context );
167
+	public function get_qantity($context = 'view') {
168
+		return $this->get_quantity($context);
169 169
 	}
170 170
 
171 171
 	/**
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 	 * @param  string $context View or edit context.
176 176
 	 * @return float
177 177
 	 */
178
-	public function get_quantity( $context = 'view' ) {
178
+	public function get_quantity($context = 'view') {
179 179
 		$quantity = (float) $this->quantity;
180 180
 
181
-		if ( 'view' === $context ) {
182
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
181
+		if ('view' === $context) {
182
+			return apply_filters('getpaid_payment_form_item_quantity', $quantity, $this);
183 183
 		}
184 184
 
185 185
 		return $quantity;
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 	 * @param  string $context View or edit context.
193 193
 	 * @return meta
194 194
 	 */
195
-	public function get_item_meta( $context = 'view' ) {
195
+	public function get_item_meta($context = 'view') {
196 196
 		$meta = $this->meta;
197 197
 
198
-		if ( 'view' === $context ) {
199
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
198
+		if ('view' === $context) {
199
+			return apply_filters('getpaid_payment_form_item_meta', $meta, $this);
200 200
 		}
201 201
 
202 202
 		return $meta;
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
 	 * @param  string $context View or edit context.
210 210
 	 * @return bool
211 211
 	 */
212
-	public function get_allow_quantities( $context = 'view' ) {
212
+	public function get_allow_quantities($context = 'view') {
213 213
 		$allow_quantities = (bool) $this->allow_quantities;
214 214
 
215
-		if ( 'view' === $context ) {
216
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
215
+		if ('view' === $context) {
216
+			return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this);
217 217
 		}
218 218
 
219 219
 		return $allow_quantities;
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return bool
228 228
 	 */
229
-	public function get_is_required( $context = 'view' ) {
229
+	public function get_is_required($context = 'view') {
230 230
 		$is_required = (bool) $this->is_required;
231 231
 
232
-		if ( 'view' === $context ) {
233
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
232
+		if ('view' === $context) {
233
+			return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this);
234 234
 		}
235 235
 
236 236
 		return $is_required;
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 	 * @param  string $context View or edit context.
244 244
 	 * @return int
245 245
 	 */
246
-	public function get_price_id( $context = 'view' ) {
246
+	public function get_price_id($context = 'view') {
247 247
 		$price_id = (int) $this->price_id;
248 248
 
249
-		if ( 'view' === $context ) {
250
-			return apply_filters( 'getpaid_payment_form_item_price_id', $price_id, $this );
249
+		if ('view' === $context) {
250
+			return apply_filters('getpaid_payment_form_item_price_id', $price_id, $this);
251 251
 		}
252 252
 
253 253
 		return $price_id;
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 	 * @since 1.0.19
260 260
 	 * @return array
261 261
 	 */
262
-	public function prepare_data_for_use( $required = null ) {
262
+	public function prepare_data_for_use($required = null) {
263 263
 
264
-		$required = is_null( $required ) ? $this->is_required() : $required;
264
+		$required = is_null($required) ? $this->is_required() : $required;
265 265
 		return array(
266
-			'title'            => wp_strip_all_tags( $this->get_name() ),
266
+			'title'            => wp_strip_all_tags($this->get_name()),
267 267
 			'id'               => $this->get_id(),
268 268
 			'price'            => $this->get_price(),
269 269
 			'recurring'        => $this->is_recurring(),
@@ -280,30 +280,30 @@  discard block
 block discarded – undo
280 280
 	 * @since 1.0.19
281 281
 	 * @return array
282 282
 	 */
283
-	public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
283
+	public function prepare_data_for_invoice_edit_ajax($currency = '', $is_renewal = false) {
284 284
 
285
-		$description = getpaid_item_recurring_price_help_text( $this, $currency );
285
+		$description = getpaid_item_recurring_price_help_text($this, $currency);
286 286
 
287
-		if ( $description ) {
287
+		if ($description) {
288 288
 			$description = "<div class='getpaid-subscription-help-text'>$description</div>";
289 289
 		}
290 290
 
291
-		$price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
292
-		$subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
291
+		$price    = !$is_renewal ? $this->get_price() : $this->get_recurring_price();
292
+		$subtotal = !$is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
293 293
 		return array(
294 294
 			'id'     => $this->get_id(),
295 295
 			'texts'  => array(
296
-				'item-name'        => sanitize_text_field( $this->get_name() ),
297
-				'item-description' => wp_kses_post( $this->get_description() ) . $description,
298
-				'item-quantity'    => floatval( $this->get_quantity() ),
299
-				'item-price'       => wpinv_price( $price, $currency ),
300
-				'item-total'       => wpinv_price( $subtotal, $currency ),
296
+				'item-name'        => sanitize_text_field($this->get_name()),
297
+				'item-description' => wp_kses_post($this->get_description()) . $description,
298
+				'item-quantity'    => floatval($this->get_quantity()),
299
+				'item-price'       => wpinv_price($price, $currency),
300
+				'item-total'       => wpinv_price($subtotal, $currency),
301 301
 			),
302 302
 			'inputs' => array(
303 303
 				'item-id'          => $this->get_id(),
304
-				'item-name'        => sanitize_text_field( $this->get_name() ),
305
-				'item-description' => wp_kses_post( $this->get_description() ),
306
-				'item-quantity'    => floatval( $this->get_quantity() ),
304
+				'item-name'        => sanitize_text_field($this->get_name()),
305
+				'item-description' => wp_kses_post($this->get_description()),
306
+				'item-quantity'    => floatval($this->get_quantity()),
307 307
 				'item-price'       => $price,
308 308
 			),
309 309
 		);
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
 		return array(
321 321
 			'post_id'          => $this->invoice_id,
322 322
 			'item_id'          => $this->get_id(),
323
-			'item_name'        => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
324
-			'item_description' => $this->get_description( 'edit' ),
323
+			'item_name'        => sanitize_text_field($this->get_raw_name('edit')),
324
+			'item_description' => $this->get_description('edit'),
325 325
 			'tax'              => $this->item_tax,
326
-			'item_price'       => $this->get_price( 'edit' ),
327
-			'quantity'         => (float) $this->get_quantity( 'edit' ),
326
+			'item_price'       => $this->get_price('edit'),
327
+			'quantity'         => (float) $this->get_quantity('edit'),
328 328
 			'discount'         => $this->item_discount,
329
-			'subtotal'         => $this->get_sub_total( 'edit' ),
330
-			'price'            => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
331
-			'price_id'         => (int) $this->get_price_id( 'edit' ),
332
-			'meta'             => $this->get_item_meta( 'edit' ),
329
+			'subtotal'         => $this->get_sub_total('edit'),
330
+			'price'            => $this->get_sub_total('edit') + $this->item_tax - $this->item_discount,
331
+			'price_id'         => (int) $this->get_price_id('edit'),
332
+			'meta'             => $this->get_item_meta('edit'),
333 333
 		);
334 334
 	}
335 335
 
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 	 * @since 1.0.19
350 350
 	 * @param  float $quantity The item quantity.
351 351
 	 */
352
-	public function set_quantity( $quantity ) {
352
+	public function set_quantity($quantity) {
353 353
 
354
-		if ( ! is_numeric( $quantity ) ) {
354
+		if (!is_numeric($quantity)) {
355 355
 			$quantity = 1;
356 356
 		}
357 357
 
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 	 * @since 1.0.19
365 365
 	 * @param  float $price_id The item price ID.
366 366
 	 */
367
-	public function set_price_id( $price_id ) {
367
+	public function set_price_id($price_id) {
368 368
 
369
-		if ( ! is_numeric( $price_id ) ) {
369
+		if (!is_numeric($price_id)) {
370 370
 			$price_id = $this->get_default_price_id();
371 371
 		}
372 372
 
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 	 * @since 1.0.19
380 380
 	 * @param  array $meta The item meta data.
381 381
 	 */
382
-	public function set_item_meta( $meta ) {
383
-		$this->meta = maybe_unserialize( $meta );
382
+	public function set_item_meta($meta) {
383
+		$this->meta = maybe_unserialize($meta);
384 384
 	}
385 385
 
386 386
 	/**
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 * @since 1.0.19
390 390
 	 * @param  bool $allow_quantities
391 391
 	 */
392
-	public function set_allow_quantities( $allow_quantities ) {
392
+	public function set_allow_quantities($allow_quantities) {
393 393
 		$this->allow_quantities = (bool) $allow_quantities;
394 394
 	}
395 395
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	 * @since 1.0.19
400 400
 	 * @param  bool $is_required
401 401
 	 */
402
-	public function set_is_required( $is_required ) {
402
+	public function set_is_required($is_required) {
403 403
 		$this->is_required = (bool) $is_required;
404 404
 	}
405 405
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 	 * @since 1.0.19
410 410
 	 * @param  string $description
411 411
 	 */
412
-	public function set_custom_description( $description ) {
412
+	public function set_custom_description($description) {
413 413
 		$this->custom_description = $description;
414 414
 	}
415 415
 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
      *
419 419
 	 * @return int item id
420 420
      */
421
-    public function save( $data = array() ) {
421
+    public function save($data = array()) {
422 422
         return $this->get_id();
423 423
 	}
424 424
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-checkout.php 2 patches
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -12,185 +12,185 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Checkout {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Payment_Form_Submission
17
-	 */
18
-	protected $payment_form_submission;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 *
23
-	 * @param GetPaid_Payment_Form_Submission $submission
24
-	 */
25
-	public function __construct( $submission ) {
26
-		$this->payment_form_submission = $submission;
27
-	}
28
-
29
-	/**
30
-	 * Processes the checkout.
31
-	 *
32
-	 */
33
-	public function process_checkout() {
34
-
35
-		// Validate the submission.
36
-		$this->validate_submission();
37
-
38
-		// Prepare the invoice.
39
-		$items    = $this->get_submission_items();
40
-		$invoice  = $this->get_submission_invoice();
41
-		$invoice  = $this->process_submission_invoice( $invoice, $items );
42
-		$prepared = $this->prepare_submission_data_for_saving();
43
-
44
-		$this->prepare_billing_info( $invoice );
45
-
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
47
-
48
-		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
50
-		$invoice->recalculate_total();
15
+    /**
16
+     * @var GetPaid_Payment_Form_Submission
17
+     */
18
+    protected $payment_form_submission;
19
+
20
+    /**
21
+     * Class constructor.
22
+     *
23
+     * @param GetPaid_Payment_Form_Submission $submission
24
+     */
25
+    public function __construct( $submission ) {
26
+        $this->payment_form_submission = $submission;
27
+    }
28
+
29
+    /**
30
+     * Processes the checkout.
31
+     *
32
+     */
33
+    public function process_checkout() {
34
+
35
+        // Validate the submission.
36
+        $this->validate_submission();
37
+
38
+        // Prepare the invoice.
39
+        $items    = $this->get_submission_items();
40
+        $invoice  = $this->get_submission_invoice();
41
+        $invoice  = $this->process_submission_invoice( $invoice, $items );
42
+        $prepared = $this->prepare_submission_data_for_saving();
43
+
44
+        $this->prepare_billing_info( $invoice );
45
+
46
+        $shipping   = $this->prepare_shipping_info( $invoice );
47
+
48
+        // Save the invoice.
49
+        $invoice->set_is_viewed( true );
50
+        $invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+        do_action( 'getpaid_checkout_invoice_updated', $invoice );
54 54
 
55
-		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
57
-	}
55
+        // Send to the gateway.
56
+        $this->post_process_submission( $invoice, $prepared, $shipping );
57
+    }
58 58
 
59
-	/**
60
-	 * Validates the submission.
61
-	 *
62
-	 */
63
-	protected function validate_submission() {
59
+    /**
60
+     * Validates the submission.
61
+     *
62
+     */
63
+    protected function validate_submission() {
64 64
 
65
-		$submission = $this->payment_form_submission;
66
-		$data       = $submission->get_data();
65
+        $submission = $this->payment_form_submission;
66
+        $data       = $submission->get_data();
67 67
 
68
-		// Do we have an error?
68
+        // Do we have an error?
69 69
         if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
70
+            wp_send_json_error( $submission->last_error );
71 71
         }
72 72
 
73
-		// We need a billing email.
73
+        // We need a billing email.
74 74
         if ( ! $submission->has_billing_email() ) {
75 75
             wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
76
-		}
76
+        }
77 77
 
78
-		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
-		}
78
+        // Non-recurring gateways should not be allowed to process recurring invoices.
79
+        if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
+            wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
+        }
82 82
 
83
-		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) );
86
-		}
83
+        // Ensure the gateway is active.
84
+        if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
+            wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) );
86
+        }
87 87
 
88
-		// Clear any existing errors.
89
-		wpinv_clear_errors();
88
+        // Clear any existing errors.
89
+        wpinv_clear_errors();
90 90
 
91
-		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
91
+        // Allow themes and plugins to hook to errors
92
+        do_action( 'getpaid_checkout_error_checks', $submission );
93 93
 
94
-		// Do we have any errors?
94
+        // Do we have any errors?
95 95
         if ( wpinv_get_errors() ) {
96 96
             wp_send_json_error( getpaid_get_errors_html() );
97
-		}
97
+        }
98 98
 
99
-	} 
99
+    } 
100 100
 
101
-	/**
102
-	 * Retrieves submission items.
103
-	 *
104
-	 * @return GetPaid_Form_Item[]
105
-	 */
106
-	protected function get_submission_items() {
101
+    /**
102
+     * Retrieves submission items.
103
+     *
104
+     * @return GetPaid_Form_Item[]
105
+     */
106
+    protected function get_submission_items() {
107 107
 
108
-		$items = $this->payment_form_submission->get_items();
108
+        $items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111 111
         if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112 112
             wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
113
-		}
114
-
115
-		return $items;
116
-	}
117
-
118
-	/**
119
-	 * Retrieves submission invoice.
120
-	 *
121
-	 * @return WPInv_Invoice
122
-	 */
123
-	protected function get_submission_invoice() {
124
-		$submission = $this->payment_form_submission;
125
-
126
-		if ( ! $submission->has_invoice() ) {
127
-			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
129
-			return $invoice;
130 113
         }
131 114
 
132
-		$invoice = $submission->get_invoice();
115
+        return $items;
116
+    }
117
+
118
+    /**
119
+     * Retrieves submission invoice.
120
+     *
121
+     * @return WPInv_Invoice
122
+     */
123
+    protected function get_submission_invoice() {
124
+        $submission = $this->payment_form_submission;
133 125
 
134
-		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
-		}
126
+        if ( ! $submission->has_invoice() ) {
127
+            $invoice = new WPInv_Invoice();
128
+            $invoice->set_created_via( 'payment_form' );
129
+            return $invoice;
130
+        }
138 131
 
139
-		return $invoice;
140
-	}
132
+        $invoice = $submission->get_invoice();
141 133
 
142
-	/**
143
-	 * Processes the submission invoice.
144
-	 *
145
-	 * @param WPInv_Invoice $invoice
146
-	 * @param GetPaid_Form_Item[] $items
147
-	 * @return WPInv_Invoice
148
-	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
134
+        // Make sure that it is neither paid or refunded.
135
+        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
+            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
+        }
150 138
 
151
-		$submission = $this->payment_form_submission;
139
+        return $invoice;
140
+    }
152 141
 
153
-		// Set-up the invoice details.
154
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
155
-		$invoice->set_user_id( $this->get_submission_customer() );
156
-		$invoice->set_submission_id( $submission->id );
157
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
142
+    /**
143
+     * Processes the submission invoice.
144
+     *
145
+     * @param WPInv_Invoice $invoice
146
+     * @param GetPaid_Form_Item[] $items
147
+     * @return WPInv_Invoice
148
+     */
149
+    protected function process_submission_invoice( $invoice, $items ) {
150
+
151
+        $submission = $this->payment_form_submission;
152
+
153
+        // Set-up the invoice details.
154
+        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
155
+        $invoice->set_user_id( $this->get_submission_customer() );
156
+        $invoice->set_submission_id( $submission->id );
157
+        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
158 158
         $invoice->set_items( $items );
159 159
         $invoice->set_fees( $submission->get_fees() );
160 160
         $invoice->set_taxes( $submission->get_taxes() );
161
-		$invoice->set_discounts( $submission->get_discounts() );
162
-		$invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
163
-		$invoice->set_currency( $submission->get_currency() );
161
+        $invoice->set_discounts( $submission->get_discounts() );
162
+        $invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
163
+        $invoice->set_currency( $submission->get_currency() );
164 164
 
165
-		if ( $submission->has_shipping() ) {
166
-			$invoice->set_shipping( $submission->get_shipping() );
167
-		}
165
+        if ( $submission->has_shipping() ) {
166
+            $invoice->set_shipping( $submission->get_shipping() );
167
+        }
168 168
 
169
-		$address_confirmed = $submission->get_field( 'confirm-address' );
170
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
169
+        $address_confirmed = $submission->get_field( 'confirm-address' );
170
+        $invoice->set_address_confirmed( ! empty( $address_confirmed ) );
171 171
 
172
-		if ( $submission->has_discount_code() ) {
172
+        if ( $submission->has_discount_code() ) {
173 173
             $invoice->set_discount_code( $submission->get_discount_code() );
174
-		}
175
-
176
-		getpaid_maybe_add_default_address( $invoice );
177
-		return $invoice;
178
-	}
179
-
180
-	/**
181
-	 * Retrieves the submission's customer.
182
-	 *
183
-	 * @return int The customer id.
184
-	 */
185
-	protected function get_submission_customer() {
186
-		$submission = $this->payment_form_submission;
187
-
188
-		// If this is an existing invoice...
189
-		if ( $submission->has_invoice() ) {
190
-			return $submission->get_invoice()->get_user_id();
191
-		}
192
-
193
-		// (Maybe) create the user.
174
+        }
175
+
176
+        getpaid_maybe_add_default_address( $invoice );
177
+        return $invoice;
178
+    }
179
+
180
+    /**
181
+     * Retrieves the submission's customer.
182
+     *
183
+     * @return int The customer id.
184
+     */
185
+    protected function get_submission_customer() {
186
+        $submission = $this->payment_form_submission;
187
+
188
+        // If this is an existing invoice...
189
+        if ( $submission->has_invoice() ) {
190
+            return $submission->get_invoice()->get_user_id();
191
+        }
192
+
193
+        // (Maybe) create the user.
194 194
         $user = get_current_user_id();
195 195
 
196 196
         if ( empty( $user ) ) {
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
         }
199 199
 
200 200
         if ( empty( $user ) ) {
201
-			$name = array( $submission->get_field( 'wpinv_first_name', 'billing' ), $submission->get_field( 'wpinv_last_name', 'billing' ) );
202
-			$name = implode( '', array_filter( $name ) );
201
+            $name = array( $submission->get_field( 'wpinv_first_name', 'billing' ), $submission->get_field( 'wpinv_last_name', 'billing' ) );
202
+            $name = implode( '', array_filter( $name ) );
203 203
             $user = wpinv_create_user( $submission->get_billing_email(), $name );
204 204
 
205
-			// (Maybe) send new user notification.
206
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
207
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
208
-				wp_send_new_user_notifications( $user, 'user' );
209
-			}
210
-		}
205
+            // (Maybe) send new user notification.
206
+            $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
207
+            if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
208
+                wp_send_new_user_notifications( $user, 'user' );
209
+            }
210
+        }
211 211
 
212 212
         if ( is_wp_error( $user ) ) {
213 213
             wp_send_json_error( $user->get_error_message() );
@@ -215,47 +215,47 @@  discard block
 block discarded – undo
215 215
 
216 216
         if ( is_numeric( $user ) ) {
217 217
             return $user;
218
-		}
218
+        }
219 219
 
220
-		return $user->ID;
220
+        return $user->ID;
221 221
 
222
-	}
222
+    }
223 223
 
224
-	/**
224
+    /**
225 225
      * Prepares submission data for saving to the database.
226 226
      *
227
-	 * @return array
227
+     * @return array
228 228
      */
229 229
     public function prepare_submission_data_for_saving() {
230 230
 
231
-		$submission = $this->payment_form_submission;
231
+        $submission = $this->payment_form_submission;
232 232
 
233
-		// Prepared submission details.
233
+        // Prepared submission details.
234 234
         $prepared = array(
235
-			'all'  => array(),
236
-			'meta' => array(),
237
-		);
235
+            'all'  => array(),
236
+            'meta' => array(),
237
+        );
238 238
 
239 239
         // Raw submission details.
240
-		$data     = $submission->get_data();
240
+        $data     = $submission->get_data();
241 241
 
242
-		// Loop through the submitted details.
242
+        // Loop through the submitted details.
243 243
         foreach ( $submission->get_payment_form()->get_elements() as $field ) {
244 244
 
245
-			// Skip premade fields.
245
+            // Skip premade fields.
246 246
             if ( ! empty( $field['premade'] ) ) {
247 247
                 continue;
248 248
             }
249 249
 
250
-			// Ensure address is provided.
251
-			if ( 'address' === $field['type'] ) {
250
+            // Ensure address is provided.
251
+            if ( 'address' === $field['type'] ) {
252 252
                 $address_type = isset( $field['address_type'] ) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing';
253 253
 
254
-				foreach ( $field['fields'] as $address_field ) {
254
+                foreach ( $field['fields'] as $address_field ) {
255 255
 
256
-					if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
257
-						wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
258
-					}
256
+                    if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
257
+                        wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
258
+                    }
259 259
                 }
260 260
             }
261 261
 
@@ -267,31 +267,31 @@  discard block
 block discarded – undo
267 267
             // Handle misc fields.
268 268
             if ( isset( $data[ $field['id'] ] ) ) {
269 269
 
270
-				// Uploads.
271
-				if ( 'file_upload' === $field['type'] ) {
272
-					$max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
270
+                // Uploads.
271
+                if ( 'file_upload' === $field['type'] ) {
272
+                    $max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
273 273
 
274
-					if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
275
-						wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
276
-					}
274
+                    if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
275
+                        wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
276
+                    }
277 277
 
278
-					$value = array();
278
+                    $value = array();
279 279
 
280
-					foreach ( $data[ $field['id'] ] as $url => $name ) {
281
-						$value[] = sprintf(
282
-							'<a href="%s" target="_blank">%s</a>',
283
-							esc_url_raw( $url ),
284
-							esc_html( $name )
285
-						);
286
-					}
280
+                    foreach ( $data[ $field['id'] ] as $url => $name ) {
281
+                        $value[] = sprintf(
282
+                            '<a href="%s" target="_blank">%s</a>',
283
+                            esc_url_raw( $url ),
284
+                            esc_html( $name )
285
+                        );
286
+                    }
287 287
 
288
-					$value = implode( ' | ', $value );
288
+                    $value = implode( ' | ', $value );
289 289
 
290
-				} elseif ( 'checkbox' === $field['type'] ) {
291
-					$value = ! empty( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
292
-				} else {
293
-					$value = wp_kses_post( $data[ $field['id'] ] );
294
-				}
290
+                } elseif ( 'checkbox' === $field['type'] ) {
291
+                    $value = ! empty( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
292
+                } else {
293
+                    $value = wp_kses_post( $data[ $field['id'] ] );
294
+                }
295 295
 
296 296
                 $label = $field['id'];
297 297
 
@@ -299,192 +299,192 @@  discard block
 block discarded – undo
299 299
                     $label = $field['label'];
300 300
                 }
301 301
 
302
-				if ( ! empty( $field['add_meta'] ) ) {
303
-					$prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
304
-				}
305
-				$prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
302
+                if ( ! empty( $field['add_meta'] ) ) {
303
+                    $prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
304
+                }
305
+                $prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
306 306
 
307 307
             }
308
-		}
308
+        }
309 309
 
310
-		return $prepared;
310
+        return $prepared;
311 311
 
312
-	}
312
+    }
313 313
 
314
-	/**
314
+    /**
315 315
      * Retrieves address details.
316 316
      *
317
-	 * @return array
318
-	 * @param WPInv_Invoice $invoice
319
-	 * @param string $type
317
+     * @return array
318
+     * @param WPInv_Invoice $invoice
319
+     * @param string $type
320 320
      */
321 321
     public function prepare_address_details( $invoice, $type = 'billing' ) {
322 322
 
323
-		$data     = $this->payment_form_submission->get_data();
324
-		$type     = sanitize_key( $type );
325
-		$address  = array();
326
-		$prepared = array();
323
+        $data     = $this->payment_form_submission->get_data();
324
+        $type     = sanitize_key( $type );
325
+        $address  = array();
326
+        $prepared = array();
327 327
 
328
-		if ( ! empty( $data[ $type ] ) ) {
329
-			$address = $data[ $type ];
330
-		}
328
+        if ( ! empty( $data[ $type ] ) ) {
329
+            $address = $data[ $type ];
330
+        }
331 331
 
332
-		// Clean address details.
333
-		foreach ( $address as $key => $value ) {
334
-			$key             = sanitize_key( $key );
335
-			$key             = str_replace( 'wpinv_', '', $key );
336
-			$value           = wpinv_clean( $value );
337
-			$prepared[ $key ] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
338
-		}
332
+        // Clean address details.
333
+        foreach ( $address as $key => $value ) {
334
+            $key             = sanitize_key( $key );
335
+            $key             = str_replace( 'wpinv_', '', $key );
336
+            $value           = wpinv_clean( $value );
337
+            $prepared[ $key ] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
338
+        }
339 339
 
340
-		// Filter address details.
341
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
340
+        // Filter address details.
341
+        $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
342 342
 
343
-		// Remove non-whitelisted values.
344
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
343
+        // Remove non-whitelisted values.
344
+        return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
345 345
 
346
-	}
346
+    }
347 347
 
348
-	/**
348
+    /**
349 349
      * Prepares the billing details.
350 350
      *
351
-	 * @return array
352
-	 * @param WPInv_Invoice $invoice
351
+     * @return array
352
+     * @param WPInv_Invoice $invoice
353 353
      */
354 354
     protected function prepare_billing_info( &$invoice ) {
355 355
 
356
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
356
+        $billing_address = $this->prepare_address_details( $invoice, 'billing' );
357 357
 
358
-		// Update the invoice with the billing details.
359
-		$invoice->set_props( $billing_address );
358
+        // Update the invoice with the billing details.
359
+        $invoice->set_props( $billing_address );
360 360
 
361
-	}
361
+    }
362 362
 
363
-	/**
363
+    /**
364 364
      * Prepares the shipping details.
365 365
      *
366
-	 * @return array
367
-	 * @param WPInv_Invoice $invoice
366
+     * @return array
367
+     * @param WPInv_Invoice $invoice
368 368
      */
369 369
     protected function prepare_shipping_info( $invoice ) {
370 370
 
371
-		$data = $this->payment_form_submission->get_data();
371
+        $data = $this->payment_form_submission->get_data();
372 372
 
373
-		if ( empty( $data['same-shipping-address'] ) ) {
374
-			return $this->prepare_address_details( $invoice, 'shipping' );
375
-		}
373
+        if ( empty( $data['same-shipping-address'] ) ) {
374
+            return $this->prepare_address_details( $invoice, 'shipping' );
375
+        }
376 376
 
377
-		return $this->prepare_address_details( $invoice, 'billing' );
377
+        return $this->prepare_address_details( $invoice, 'billing' );
378 378
 
379
-	}
379
+    }
380 380
 
381
-	/**
382
-	 * Confirms the submission is valid and send users to the gateway.
383
-	 *
384
-	 * @param WPInv_Invoice $invoice
385
-	 * @param array $prepared_payment_form_data
386
-	 * @param array $shipping
387
-	 */
388
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
381
+    /**
382
+     * Confirms the submission is valid and send users to the gateway.
383
+     *
384
+     * @param WPInv_Invoice $invoice
385
+     * @param array $prepared_payment_form_data
386
+     * @param array $shipping
387
+     */
388
+    protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
389 389
 
390
-		// Ensure the invoice exists.
390
+        // Ensure the invoice exists.
391 391
         if ( ! $invoice->exists() ) {
392 392
             wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
393 393
         }
394 394
 
395
-		// Save payment form data.
396
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
395
+        // Save payment form data.
396
+        $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
397 397
         delete_post_meta( $invoice->get_id(), 'payment_form_data' );
398
-		delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
399
-		if ( ! empty( $prepared_payment_form_data ) ) {
398
+        delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
399
+        if ( ! empty( $prepared_payment_form_data ) ) {
400 400
 
401
-			if ( ! empty( $prepared_payment_form_data['all'] ) ) {
402
-				update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
403
-			}
401
+            if ( ! empty( $prepared_payment_form_data['all'] ) ) {
402
+                update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
403
+            }
404 404
 
405
-			if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
406
-				update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
407
-			}
408
-		}
405
+            if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
406
+                update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
407
+            }
408
+        }
409 409
 
410
-		// Save payment form data.
411
-		$shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission );
410
+        // Save payment form data.
411
+        $shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission );
412 412
         if ( ! empty( $shipping ) ) {
413 413
             update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
414
-		}
414
+        }
415 415
 
416
-		// Backwards compatibility.
416
+        // Backwards compatibility.
417 417
         add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
418 418
 
419
-		try {
420
-			$this->process_payment( $invoice );
421
-		} catch ( Exception $e ) {
422
-			wpinv_set_error( 'payment_error', $e->getMessage() );
423
-		}
419
+        try {
420
+            $this->process_payment( $invoice );
421
+        } catch ( Exception $e ) {
422
+            wpinv_set_error( 'payment_error', $e->getMessage() );
423
+        }
424 424
 
425 425
         // If we are here, there was an error.
426
-		wpinv_send_back_to_checkout( $invoice );
426
+        wpinv_send_back_to_checkout( $invoice );
427 427
 
428
-	}
428
+    }
429 429
 
430
-	/**
431
-	 * Processes the actual payment.
432
-	 *
433
-	 * @param WPInv_Invoice $invoice
434
-	 */
435
-	protected function process_payment( $invoice ) {
430
+    /**
431
+     * Processes the actual payment.
432
+     *
433
+     * @param WPInv_Invoice $invoice
434
+     */
435
+    protected function process_payment( $invoice ) {
436 436
 
437
-		// Clear any checkout errors.
438
-		wpinv_clear_errors();
437
+        // Clear any checkout errors.
438
+        wpinv_clear_errors();
439 439
 
440
-		// No need to send free invoices to the gateway.
441
-		if ( $invoice->is_free() ) {
442
-			$this->process_free_payment( $invoice );
443
-		}
440
+        // No need to send free invoices to the gateway.
441
+        if ( $invoice->is_free() ) {
442
+            $this->process_free_payment( $invoice );
443
+        }
444 444
 
445
-		$submission = $this->payment_form_submission;
445
+        $submission = $this->payment_form_submission;
446 446
 
447
-		// Fires before sending to the gateway.
448
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
447
+        // Fires before sending to the gateway.
448
+        do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
449 449
 
450
-		// Allow the sumission data to be modified before it is sent to the gateway.
451
-		$submission_data    = $submission->get_data();
452
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
453
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
450
+        // Allow the sumission data to be modified before it is sent to the gateway.
451
+        $submission_data    = $submission->get_data();
452
+        $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
453
+        $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
454 454
 
455
-		// Validate the currency.
456
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
457
-			wpinv_set_error( 'invalid_currency' );
458
-		}
455
+        // Validate the currency.
456
+        if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
457
+            wpinv_set_error( 'invalid_currency' );
458
+        }
459 459
 
460
-		// Check to see if we have any errors.
461
-		if ( wpinv_get_errors() ) {
462
-			wpinv_send_back_to_checkout( $invoice );
463
-		}
460
+        // Check to see if we have any errors.
461
+        if ( wpinv_get_errors() ) {
462
+            wpinv_send_back_to_checkout( $invoice );
463
+        }
464 464
 
465
-		// Send info to the gateway for payment processing
466
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
465
+        // Send info to the gateway for payment processing
466
+        do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
467 467
 
468
-		// Backwards compatibility.
469
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
468
+        // Backwards compatibility.
469
+        wpinv_send_to_gateway( $submission_gateway, $invoice );
470 470
 
471
-	}
471
+    }
472 472
 
473
-	/**
474
-	 * Marks the invoice as paid in case the checkout is free.
475
-	 *
476
-	 * @param WPInv_Invoice $invoice
477
-	 */
478
-	protected function process_free_payment( $invoice ) {
473
+    /**
474
+     * Marks the invoice as paid in case the checkout is free.
475
+     *
476
+     * @param WPInv_Invoice $invoice
477
+     */
478
+    protected function process_free_payment( $invoice ) {
479 479
 
480
-		$invoice->set_gateway( 'none' );
481
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
482
-		$invoice->mark_paid();
483
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
480
+        $invoice->set_gateway( 'none' );
481
+        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
482
+        $invoice->mark_paid();
483
+        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
484 484
 
485
-	}
485
+    }
486 486
 
487
-	/**
487
+    /**
488 488
      * Sends a redrect response to payment details.
489 489
      *
490 490
      */
Please login to merge, or discard this patch.
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Main Checkout Class.
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param GetPaid_Payment_Form_Submission $submission
24 24
 	 */
25
-	public function __construct( $submission ) {
25
+	public function __construct($submission) {
26 26
 		$this->payment_form_submission = $submission;
27 27
 	}
28 28
 
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
 		// Prepare the invoice.
39 39
 		$items    = $this->get_submission_items();
40 40
 		$invoice  = $this->get_submission_invoice();
41
-		$invoice  = $this->process_submission_invoice( $invoice, $items );
41
+		$invoice  = $this->process_submission_invoice($invoice, $items);
42 42
 		$prepared = $this->prepare_submission_data_for_saving();
43 43
 
44
-		$this->prepare_billing_info( $invoice );
44
+		$this->prepare_billing_info($invoice);
45 45
 
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
46
+		$shipping = $this->prepare_shipping_info($invoice);
47 47
 
48 48
 		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
49
+		$invoice->set_is_viewed(true);
50 50
 		$invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+		do_action('getpaid_checkout_invoice_updated', $invoice);
54 54
 
55 55
 		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
56
+		$this->post_process_submission($invoice, $prepared, $shipping);
57 57
 	}
58 58
 
59 59
 	/**
@@ -66,34 +66,34 @@  discard block
 block discarded – undo
66 66
 		$data       = $submission->get_data();
67 67
 
68 68
 		// Do we have an error?
69
-        if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
69
+        if (!empty($submission->last_error)) {
70
+			wp_send_json_error($submission->last_error);
71 71
         }
72 72
 
73 73
 		// We need a billing email.
74
-        if ( ! $submission->has_billing_email() ) {
75
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
74
+        if (!$submission->has_billing_email()) {
75
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
76 76
 		}
77 77
 
78 78
 		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
79
+		if ($submission->should_collect_payment_details() && $submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) {
80
+			wp_send_json_error(__('The selected payment gateway does not support subscription payments.', 'invoicing'));
81 81
 		}
82 82
 
83 83
 		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) );
84
+		if ($submission->should_collect_payment_details() && !wpinv_is_gateway_active($data['wpi-gateway'])) {
85
+			wp_send_json_error(__('The selected payment gateway is not active', 'invoicing'));
86 86
 		}
87 87
 
88 88
 		// Clear any existing errors.
89 89
 		wpinv_clear_errors();
90 90
 
91 91
 		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
92
+		do_action('getpaid_checkout_error_checks', $submission);
93 93
 
94 94
 		// Do we have any errors?
95
-        if ( wpinv_get_errors() ) {
96
-            wp_send_json_error( getpaid_get_errors_html() );
95
+        if (wpinv_get_errors()) {
96
+            wp_send_json_error(getpaid_get_errors_html());
97 97
 		}
98 98
 
99 99
 	} 
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 		$items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111
-        if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112
-            wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
111
+        if (empty($items) && !$this->payment_form_submission->has_fees()) {
112
+            wp_send_json_error(__('Please provide at least one item or amount.', 'invoicing'));
113 113
 		}
114 114
 
115 115
 		return $items;
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 	protected function get_submission_invoice() {
124 124
 		$submission = $this->payment_form_submission;
125 125
 
126
-		if ( ! $submission->has_invoice() ) {
126
+		if (!$submission->has_invoice()) {
127 127
 			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
128
+			$invoice->set_created_via('payment_form');
129 129
 			return $invoice;
130 130
         }
131 131
 
132 132
 		$invoice = $submission->get_invoice();
133 133
 
134 134
 		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
135
+		if ($invoice->is_paid() || $invoice->is_refunded()) {
136
+			wp_send_json_error(__('This invoice has already been paid for.', 'invoicing'));
137 137
 		}
138 138
 
139 139
 		return $invoice;
@@ -146,34 +146,34 @@  discard block
 block discarded – undo
146 146
 	 * @param GetPaid_Form_Item[] $items
147 147
 	 * @return WPInv_Invoice
148 148
 	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
149
+	protected function process_submission_invoice($invoice, $items) {
150 150
 
151 151
 		$submission = $this->payment_form_submission;
152 152
 
153 153
 		// Set-up the invoice details.
154
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
155
-		$invoice->set_user_id( $this->get_submission_customer() );
156
-		$invoice->set_submission_id( $submission->id );
157
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
158
-        $invoice->set_items( $items );
159
-        $invoice->set_fees( $submission->get_fees() );
160
-        $invoice->set_taxes( $submission->get_taxes() );
161
-		$invoice->set_discounts( $submission->get_discounts() );
162
-		$invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
163
-		$invoice->set_currency( $submission->get_currency() );
164
-
165
-		if ( $submission->has_shipping() ) {
166
-			$invoice->set_shipping( $submission->get_shipping() );
154
+		$invoice->set_email(sanitize_email($submission->get_billing_email()));
155
+		$invoice->set_user_id($this->get_submission_customer());
156
+		$invoice->set_submission_id($submission->id);
157
+		$invoice->set_payment_form(absint($submission->get_payment_form()->get_id()));
158
+        $invoice->set_items($items);
159
+        $invoice->set_fees($submission->get_fees());
160
+        $invoice->set_taxes($submission->get_taxes());
161
+		$invoice->set_discounts($submission->get_discounts());
162
+		$invoice->set_gateway($submission->get_field('wpi-gateway'));
163
+		$invoice->set_currency($submission->get_currency());
164
+
165
+		if ($submission->has_shipping()) {
166
+			$invoice->set_shipping($submission->get_shipping());
167 167
 		}
168 168
 
169
-		$address_confirmed = $submission->get_field( 'confirm-address' );
170
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
169
+		$address_confirmed = $submission->get_field('confirm-address');
170
+		$invoice->set_address_confirmed(!empty($address_confirmed));
171 171
 
172
-		if ( $submission->has_discount_code() ) {
173
-            $invoice->set_discount_code( $submission->get_discount_code() );
172
+		if ($submission->has_discount_code()) {
173
+            $invoice->set_discount_code($submission->get_discount_code());
174 174
 		}
175 175
 
176
-		getpaid_maybe_add_default_address( $invoice );
176
+		getpaid_maybe_add_default_address($invoice);
177 177
 		return $invoice;
178 178
 	}
179 179
 
@@ -186,34 +186,34 @@  discard block
 block discarded – undo
186 186
 		$submission = $this->payment_form_submission;
187 187
 
188 188
 		// If this is an existing invoice...
189
-		if ( $submission->has_invoice() ) {
189
+		if ($submission->has_invoice()) {
190 190
 			return $submission->get_invoice()->get_user_id();
191 191
 		}
192 192
 
193 193
 		// (Maybe) create the user.
194 194
         $user = get_current_user_id();
195 195
 
196
-        if ( empty( $user ) ) {
197
-            $user = get_user_by( 'email', $submission->get_billing_email() );
196
+        if (empty($user)) {
197
+            $user = get_user_by('email', $submission->get_billing_email());
198 198
         }
199 199
 
200
-        if ( empty( $user ) ) {
201
-			$name = array( $submission->get_field( 'wpinv_first_name', 'billing' ), $submission->get_field( 'wpinv_last_name', 'billing' ) );
202
-			$name = implode( '', array_filter( $name ) );
203
-            $user = wpinv_create_user( $submission->get_billing_email(), $name );
200
+        if (empty($user)) {
201
+			$name = array($submission->get_field('wpinv_first_name', 'billing'), $submission->get_field('wpinv_last_name', 'billing'));
202
+			$name = implode('', array_filter($name));
203
+            $user = wpinv_create_user($submission->get_billing_email(), $name);
204 204
 
205 205
 			// (Maybe) send new user notification.
206
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
207
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
208
-				wp_send_new_user_notifications( $user, 'user' );
206
+			$should_send_notification = wpinv_get_option('disable_new_user_emails');
207
+			if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification), $user)) {
208
+				wp_send_new_user_notifications($user, 'user');
209 209
 			}
210 210
 		}
211 211
 
212
-        if ( is_wp_error( $user ) ) {
213
-            wp_send_json_error( $user->get_error_message() );
212
+        if (is_wp_error($user)) {
213
+            wp_send_json_error($user->get_error_message());
214 214
         }
215 215
 
216
-        if ( is_numeric( $user ) ) {
216
+        if (is_numeric($user)) {
217 217
             return $user;
218 218
 		}
219 219
 
@@ -237,72 +237,72 @@  discard block
 block discarded – undo
237 237
 		);
238 238
 
239 239
         // Raw submission details.
240
-		$data     = $submission->get_data();
240
+		$data = $submission->get_data();
241 241
 
242 242
 		// Loop through the submitted details.
243
-        foreach ( $submission->get_payment_form()->get_elements() as $field ) {
243
+        foreach ($submission->get_payment_form()->get_elements() as $field) {
244 244
 
245 245
 			// Skip premade fields.
246
-            if ( ! empty( $field['premade'] ) ) {
246
+            if (!empty($field['premade'])) {
247 247
                 continue;
248 248
             }
249 249
 
250 250
 			// Ensure address is provided.
251
-			if ( 'address' === $field['type'] ) {
252
-                $address_type = isset( $field['address_type'] ) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing';
251
+			if ('address' === $field['type']) {
252
+                $address_type = isset($field['address_type']) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing';
253 253
 
254
-				foreach ( $field['fields'] as $address_field ) {
254
+				foreach ($field['fields'] as $address_field) {
255 255
 
256
-					if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
257
-						wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
256
+					if (!empty($address_field['visible']) && !empty($address_field['required']) && '' === trim($_POST[$address_type][$address_field['name']])) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
257
+						wp_send_json_error(__('Please fill all required fields.', 'invoicing'));
258 258
 					}
259 259
                 }
260 260
             }
261 261
 
262 262
             // If it is required and not set, abort.
263
-            if ( ! $submission->is_required_field_set( $field ) ) {
264
-                wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
263
+            if (!$submission->is_required_field_set($field)) {
264
+                wp_send_json_error(__('Please fill all required fields.', 'invoicing'));
265 265
             }
266 266
 
267 267
             // Handle misc fields.
268
-            if ( isset( $data[ $field['id'] ] ) ) {
268
+            if (isset($data[$field['id']])) {
269 269
 
270 270
 				// Uploads.
271
-				if ( 'file_upload' === $field['type'] ) {
272
-					$max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
271
+				if ('file_upload' === $field['type']) {
272
+					$max_file_num = empty($field['max_file_num']) ? 1 : absint($field['max_file_num']);
273 273
 
274
-					if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
275
-						wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
274
+					if (count($data[$field['id']]) > $max_file_num) {
275
+						wp_send_json_error(__('Maximum number of allowed files exceeded.', 'invoicing'));
276 276
 					}
277 277
 
278 278
 					$value = array();
279 279
 
280
-					foreach ( $data[ $field['id'] ] as $url => $name ) {
280
+					foreach ($data[$field['id']] as $url => $name) {
281 281
 						$value[] = sprintf(
282 282
 							'<a href="%s" target="_blank">%s</a>',
283
-							esc_url_raw( $url ),
284
-							esc_html( $name )
283
+							esc_url_raw($url),
284
+							esc_html($name)
285 285
 						);
286 286
 					}
287 287
 
288
-					$value = implode( ' | ', $value );
288
+					$value = implode(' | ', $value);
289 289
 
290
-				} elseif ( 'checkbox' === $field['type'] ) {
291
-					$value = ! empty( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
290
+				} elseif ('checkbox' === $field['type']) {
291
+					$value = !empty($data[$field['id']]) ? __('Yes', 'invoicing') : __('No', 'invoicing');
292 292
 				} else {
293
-					$value = wp_kses_post( $data[ $field['id'] ] );
293
+					$value = wp_kses_post($data[$field['id']]);
294 294
 				}
295 295
 
296 296
                 $label = $field['id'];
297 297
 
298
-                if ( isset( $field['label'] ) ) {
298
+                if (isset($field['label'])) {
299 299
                     $label = $field['label'];
300 300
                 }
301 301
 
302
-				if ( ! empty( $field['add_meta'] ) ) {
303
-					$prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
302
+				if (!empty($field['add_meta'])) {
303
+					$prepared['meta'][wpinv_clean($label)] = wp_kses_post_deep($value);
304 304
 				}
305
-				$prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
305
+				$prepared['all'][wpinv_clean($label)] = wp_kses_post_deep($value);
306 306
 
307 307
             }
308 308
 		}
@@ -318,30 +318,30 @@  discard block
 block discarded – undo
318 318
 	 * @param WPInv_Invoice $invoice
319 319
 	 * @param string $type
320 320
      */
321
-    public function prepare_address_details( $invoice, $type = 'billing' ) {
321
+    public function prepare_address_details($invoice, $type = 'billing') {
322 322
 
323 323
 		$data     = $this->payment_form_submission->get_data();
324
-		$type     = sanitize_key( $type );
324
+		$type     = sanitize_key($type);
325 325
 		$address  = array();
326 326
 		$prepared = array();
327 327
 
328
-		if ( ! empty( $data[ $type ] ) ) {
329
-			$address = $data[ $type ];
328
+		if (!empty($data[$type])) {
329
+			$address = $data[$type];
330 330
 		}
331 331
 
332 332
 		// Clean address details.
333
-		foreach ( $address as $key => $value ) {
334
-			$key             = sanitize_key( $key );
335
-			$key             = str_replace( 'wpinv_', '', $key );
336
-			$value           = wpinv_clean( $value );
337
-			$prepared[ $key ] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
333
+		foreach ($address as $key => $value) {
334
+			$key             = sanitize_key($key);
335
+			$key             = str_replace('wpinv_', '', $key);
336
+			$value           = wpinv_clean($value);
337
+			$prepared[$key] = apply_filters("getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice);
338 338
 		}
339 339
 
340 340
 		// Filter address details.
341
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
341
+		$prepared = apply_filters("getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice);
342 342
 
343 343
 		// Remove non-whitelisted values.
344
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
344
+		return array_filter($prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY);
345 345
 
346 346
 	}
347 347
 
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 	 * @return array
352 352
 	 * @param WPInv_Invoice $invoice
353 353
      */
354
-    protected function prepare_billing_info( &$invoice ) {
354
+    protected function prepare_billing_info(&$invoice) {
355 355
 
356
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
356
+		$billing_address = $this->prepare_address_details($invoice, 'billing');
357 357
 
358 358
 		// Update the invoice with the billing details.
359
-		$invoice->set_props( $billing_address );
359
+		$invoice->set_props($billing_address);
360 360
 
361 361
 	}
362 362
 
@@ -366,15 +366,15 @@  discard block
 block discarded – undo
366 366
 	 * @return array
367 367
 	 * @param WPInv_Invoice $invoice
368 368
      */
369
-    protected function prepare_shipping_info( $invoice ) {
369
+    protected function prepare_shipping_info($invoice) {
370 370
 
371 371
 		$data = $this->payment_form_submission->get_data();
372 372
 
373
-		if ( empty( $data['same-shipping-address'] ) ) {
374
-			return $this->prepare_address_details( $invoice, 'shipping' );
373
+		if (empty($data['same-shipping-address'])) {
374
+			return $this->prepare_address_details($invoice, 'shipping');
375 375
 		}
376 376
 
377
-		return $this->prepare_address_details( $invoice, 'billing' );
377
+		return $this->prepare_address_details($invoice, 'billing');
378 378
 
379 379
 	}
380 380
 
@@ -385,45 +385,45 @@  discard block
 block discarded – undo
385 385
 	 * @param array $prepared_payment_form_data
386 386
 	 * @param array $shipping
387 387
 	 */
388
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
388
+	protected function post_process_submission($invoice, $prepared_payment_form_data, $shipping) {
389 389
 
390 390
 		// Ensure the invoice exists.
391
-        if ( ! $invoice->exists() ) {
392
-            wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
391
+        if (!$invoice->exists()) {
392
+            wp_send_json_error(__('An error occured while saving your invoice. Please try again.', 'invoicing'));
393 393
         }
394 394
 
395 395
 		// Save payment form data.
396
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
397
-        delete_post_meta( $invoice->get_id(), 'payment_form_data' );
398
-		delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
399
-		if ( ! empty( $prepared_payment_form_data ) ) {
396
+		$prepared_payment_form_data = apply_filters('getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice);
397
+        delete_post_meta($invoice->get_id(), 'payment_form_data');
398
+		delete_post_meta($invoice->get_id(), 'additional_meta_data');
399
+		if (!empty($prepared_payment_form_data)) {
400 400
 
401
-			if ( ! empty( $prepared_payment_form_data['all'] ) ) {
402
-				update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
401
+			if (!empty($prepared_payment_form_data['all'])) {
402
+				update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all']);
403 403
 			}
404 404
 
405
-			if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
406
-				update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
405
+			if (!empty($prepared_payment_form_data['meta'])) {
406
+				update_post_meta($invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta']);
407 407
 			}
408 408
 		}
409 409
 
410 410
 		// Save payment form data.
411
-		$shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission );
412
-        if ( ! empty( $shipping ) ) {
413
-            update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
411
+		$shipping = apply_filters('getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission);
412
+        if (!empty($shipping)) {
413
+            update_post_meta($invoice->get_id(), 'shipping_address', $shipping);
414 414
 		}
415 415
 
416 416
 		// Backwards compatibility.
417
-        add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
417
+        add_filter('wp_redirect', array($this, 'send_redirect_response'));
418 418
 
419 419
 		try {
420
-			$this->process_payment( $invoice );
421
-		} catch ( Exception $e ) {
422
-			wpinv_set_error( 'payment_error', $e->getMessage() );
420
+			$this->process_payment($invoice);
421
+		} catch (Exception $e) {
422
+			wpinv_set_error('payment_error', $e->getMessage());
423 423
 		}
424 424
 
425 425
         // If we are here, there was an error.
426
-		wpinv_send_back_to_checkout( $invoice );
426
+		wpinv_send_back_to_checkout($invoice);
427 427
 
428 428
 	}
429 429
 
@@ -432,41 +432,41 @@  discard block
 block discarded – undo
432 432
 	 *
433 433
 	 * @param WPInv_Invoice $invoice
434 434
 	 */
435
-	protected function process_payment( $invoice ) {
435
+	protected function process_payment($invoice) {
436 436
 
437 437
 		// Clear any checkout errors.
438 438
 		wpinv_clear_errors();
439 439
 
440 440
 		// No need to send free invoices to the gateway.
441
-		if ( $invoice->is_free() ) {
442
-			$this->process_free_payment( $invoice );
441
+		if ($invoice->is_free()) {
442
+			$this->process_free_payment($invoice);
443 443
 		}
444 444
 
445 445
 		$submission = $this->payment_form_submission;
446 446
 
447 447
 		// Fires before sending to the gateway.
448
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
448
+		do_action('getpaid_checkout_before_gateway', $invoice, $submission);
449 449
 
450 450
 		// Allow the sumission data to be modified before it is sent to the gateway.
451 451
 		$submission_data    = $submission->get_data();
452
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
453
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
452
+		$submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice);
453
+		$submission_data    = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice);
454 454
 
455 455
 		// Validate the currency.
456
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
457
-			wpinv_set_error( 'invalid_currency' );
456
+		if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) {
457
+			wpinv_set_error('invalid_currency');
458 458
 		}
459 459
 
460 460
 		// Check to see if we have any errors.
461
-		if ( wpinv_get_errors() ) {
462
-			wpinv_send_back_to_checkout( $invoice );
461
+		if (wpinv_get_errors()) {
462
+			wpinv_send_back_to_checkout($invoice);
463 463
 		}
464 464
 
465 465
 		// Send info to the gateway for payment processing
466
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
466
+		do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission);
467 467
 
468 468
 		// Backwards compatibility.
469
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
469
+		wpinv_send_to_gateway($submission_gateway, $invoice);
470 470
 
471 471
 	}
472 472
 
@@ -475,12 +475,12 @@  discard block
 block discarded – undo
475 475
 	 *
476 476
 	 * @param WPInv_Invoice $invoice
477 477
 	 */
478
-	protected function process_free_payment( $invoice ) {
478
+	protected function process_free_payment($invoice) {
479 479
 
480
-		$invoice->set_gateway( 'none' );
481
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
480
+		$invoice->set_gateway('none');
481
+		$invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true);
482 482
 		$invoice->mark_paid();
483
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
483
+		wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
484 484
 
485 485
 	}
486 486
 
@@ -488,9 +488,9 @@  discard block
 block discarded – undo
488 488
      * Sends a redrect response to payment details.
489 489
      *
490 490
      */
491
-    public function send_redirect_response( $url ) {
492
-        $url = rawurlencode( $url );
493
-        wp_send_json_success( $url );
491
+    public function send_redirect_response($url) {
492
+        $url = rawurlencode($url);
493
+        wp_send_json_success($url);
494 494
     }
495 495
 
496 496
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-items.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -12,28 +12,28 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Items {
14 14
 
15
-	/**
16
-	 * Submission items.
17
-	 * @var GetPaid_Form_Item[]
18
-	 */
19
-	public $items = array();
15
+    /**
16
+     * Submission items.
17
+     * @var GetPaid_Form_Item[]
18
+     */
19
+    public $items = array();
20 20
 
21 21
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$data         = $submission->get_data();
29
-		$payment_form = $submission->get_payment_form();
30
-		$invoice      = $submission->get_invoice();
31
-		$force_prices = array();
32
-
33
-		// Prepare the selected items.
34
-		$selected_items = array();
35
-		if ( ! empty( $data['getpaid-items'] ) ) {
36
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $data         = $submission->get_data();
29
+        $payment_form = $submission->get_payment_form();
30
+        $invoice      = $submission->get_invoice();
31
+        $force_prices = array();
32
+
33
+        // Prepare the selected items.
34
+        $selected_items = array();
35
+        if ( ! empty( $data['getpaid-items'] ) ) {
36
+            $selected_items = wpinv_clean( $data['getpaid-items'] );
37 37
 
38 38
             if ( is_array( $submission->get_field( 'getpaid-variable-items' ) ) ) {
39 39
                 $selected_prices = $submission->get_field( 'getpaid-variable-items' );
@@ -46,28 +46,28 @@  discard block
 block discarded – undo
46 46
                 );
47 47
             }
48 48
 
49
-			if ( ! empty( $invoice ) && $submission->is_initial_fetch() ) {
50
-				foreach ( $invoice->get_items() as $invoice_item ) {
49
+            if ( ! empty( $invoice ) && $submission->is_initial_fetch() ) {
50
+                foreach ( $invoice->get_items() as $invoice_item ) {
51 51
                     if ( ! $invoice_item->has_variable_pricing() && isset( $selected_items[ $invoice_item->get_id() ] ) ) {
52 52
                         $selected_items[ $invoice_item->get_id() ]['quantity'] = $invoice_item->get_quantity();
53 53
                         $selected_items[ $invoice_item->get_id() ]['price']    = $invoice_item->get_price();
54 54
 
55 55
                         $force_prices[ $invoice_item->get_id() ] = $invoice_item->get_price();
56 56
                     }
57
-				}
58
-			}
59
-		}
57
+                }
58
+            }
59
+        }
60 60
 
61
-		// (Maybe) set form items.
62
-		if ( isset( $data['getpaid-form-items'] ) ) {
61
+        // (Maybe) set form items.
62
+        if ( isset( $data['getpaid-form-items'] ) ) {
63 63
 
64
-			// Confirm items key.
65
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
66
-			if ( ! isset( $data['getpaid-form-items-key'] ) || md5( NONCE_KEY . AUTH_KEY . $form_items ) !== $data['getpaid-form-items-key'] ) {
67
-				throw new Exception( __( 'We could not validate the form items. Please reload the page and try again.', 'invoicing' ) );
68
-			}
64
+            // Confirm items key.
65
+            $form_items = wpinv_clean( $data['getpaid-form-items'] );
66
+            if ( ! isset( $data['getpaid-form-items-key'] ) || md5( NONCE_KEY . AUTH_KEY . $form_items ) !== $data['getpaid-form-items-key'] ) {
67
+                throw new Exception( __( 'We could not validate the form items. Please reload the page and try again.', 'invoicing' ) );
68
+            }
69 69
 
70
-			$items    = array();
70
+            $items    = array();
71 71
             $item_ids = array();
72 72
 
73 73
             foreach ( getpaid_convert_items_to_array( $form_items ) as $item_id => $qty ) {
@@ -101,25 +101,25 @@  discard block
 block discarded – undo
101 101
                         $items[]    = $item;
102 102
                     }
103 103
                 }
104
-			}
104
+            }
105 105
 
106 106
             $payment_form->set_items( $items );
107
-		}
108
-
109
-		// Process each individual item.
110
-		foreach ( $payment_form->get_items() as $item ) {
111
-			$this->process_item( $item, $selected_items, $submission );
112
-		}
113
-	}
114
-
115
-	/**
116
-	 * Process a single item.
117
-	 *
118
-	 * @param GetPaid_Form_Item $item
119
-	 * @param array $selected_items
120
-	 * @param GetPaid_Payment_Form_Submission $submission
121
-	 */
122
-	public function process_item( $item, $selected_items, $submission ) {
107
+        }
108
+
109
+        // Process each individual item.
110
+        foreach ( $payment_form->get_items() as $item ) {
111
+            $this->process_item( $item, $selected_items, $submission );
112
+        }
113
+    }
114
+
115
+    /**
116
+     * Process a single item.
117
+     *
118
+     * @param GetPaid_Form_Item $item
119
+     * @param array $selected_items
120
+     * @param GetPaid_Payment_Form_Submission $submission
121
+     */
122
+    public function process_item( $item, $selected_items, $submission ) {
123 123
 
124 124
         if ( $item->has_variable_pricing() ) {
125 125
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                 }
166 166
             }
167 167
         } else {
168
-		    // Abort if this is an optional item and it has not been selected.
168
+            // Abort if this is an optional item and it has not been selected.
169 169
             if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
170 170
                 return;
171 171
             }
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
             }
192 192
         }
193 193
 
194
-		if ( 0 == $item->get_quantity() ) {
195
-			return;
196
-		}
194
+        if ( 0 == $item->get_quantity() ) {
195
+            return;
196
+        }
197 197
 
198
-		// Save the item.
199
-		$this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item', $item, $submission );
200
-	}
198
+        // Save the item.
199
+        $this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item', $item, $submission );
200
+    }
201 201
 }
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission itemss class
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$data         = $submission->get_data();
29 29
 		$payment_form = $submission->get_payment_form();
@@ -32,59 +32,59 @@  discard block
 block discarded – undo
32 32
 
33 33
 		// Prepare the selected items.
34 34
 		$selected_items = array();
35
-		if ( ! empty( $data['getpaid-items'] ) ) {
36
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
35
+		if (!empty($data['getpaid-items'])) {
36
+			$selected_items = wpinv_clean($data['getpaid-items']);
37 37
 
38
-            if ( is_array( $submission->get_field( 'getpaid-variable-items' ) ) ) {
39
-                $selected_prices = $submission->get_field( 'getpaid-variable-items' );
38
+            if (is_array($submission->get_field('getpaid-variable-items'))) {
39
+                $selected_prices = $submission->get_field('getpaid-variable-items');
40 40
 
41 41
                 $selected_items = array_filter(
42 42
                     $selected_items,
43
-                    function ( $item ) use ( $selected_prices ) {
44
-                        return isset( $item['price_id'] ) && in_array( (int) $item['price_id'], $selected_prices );
43
+                    function($item) use ($selected_prices) {
44
+                        return isset($item['price_id']) && in_array((int) $item['price_id'], $selected_prices);
45 45
                     }
46 46
                 );
47 47
             }
48 48
 
49
-			if ( ! empty( $invoice ) && $submission->is_initial_fetch() ) {
50
-				foreach ( $invoice->get_items() as $invoice_item ) {
51
-                    if ( ! $invoice_item->has_variable_pricing() && isset( $selected_items[ $invoice_item->get_id() ] ) ) {
52
-                        $selected_items[ $invoice_item->get_id() ]['quantity'] = $invoice_item->get_quantity();
53
-                        $selected_items[ $invoice_item->get_id() ]['price']    = $invoice_item->get_price();
49
+			if (!empty($invoice) && $submission->is_initial_fetch()) {
50
+				foreach ($invoice->get_items() as $invoice_item) {
51
+                    if (!$invoice_item->has_variable_pricing() && isset($selected_items[$invoice_item->get_id()])) {
52
+                        $selected_items[$invoice_item->get_id()]['quantity'] = $invoice_item->get_quantity();
53
+                        $selected_items[$invoice_item->get_id()]['price']    = $invoice_item->get_price();
54 54
 
55
-                        $force_prices[ $invoice_item->get_id() ] = $invoice_item->get_price();
55
+                        $force_prices[$invoice_item->get_id()] = $invoice_item->get_price();
56 56
                     }
57 57
 				}
58 58
 			}
59 59
 		}
60 60
 
61 61
 		// (Maybe) set form items.
62
-		if ( isset( $data['getpaid-form-items'] ) ) {
62
+		if (isset($data['getpaid-form-items'])) {
63 63
 
64 64
 			// Confirm items key.
65
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
66
-			if ( ! isset( $data['getpaid-form-items-key'] ) || md5( NONCE_KEY . AUTH_KEY . $form_items ) !== $data['getpaid-form-items-key'] ) {
67
-				throw new Exception( __( 'We could not validate the form items. Please reload the page and try again.', 'invoicing' ) );
65
+			$form_items = wpinv_clean($data['getpaid-form-items']);
66
+			if (!isset($data['getpaid-form-items-key']) || md5(NONCE_KEY . AUTH_KEY . $form_items) !== $data['getpaid-form-items-key']) {
67
+				throw new Exception(__('We could not validate the form items. Please reload the page and try again.', 'invoicing'));
68 68
 			}
69 69
 
70
-			$items    = array();
70
+			$items = array();
71 71
             $item_ids = array();
72 72
 
73
-            foreach ( getpaid_convert_items_to_array( $form_items ) as $item_id => $qty ) {
74
-                if ( ! in_array( $item_id, $item_ids ) ) {
75
-                    $item = new GetPaid_Form_Item( $item_id );
73
+            foreach (getpaid_convert_items_to_array($form_items) as $item_id => $qty) {
74
+                if (!in_array($item_id, $item_ids)) {
75
+                    $item = new GetPaid_Form_Item($item_id);
76 76
 
77
-                    if ( ! $item->has_variable_pricing() ) {
78
-                        $item->set_quantity( $qty );
77
+                    if (!$item->has_variable_pricing()) {
78
+                        $item->set_quantity($qty);
79 79
 
80
-                        if ( empty( $qty ) ) {
81
-                            $item->set_allow_quantities( true );
82
-                            $item->set_is_required( false );
80
+                        if (empty($qty)) {
81
+                            $item->set_allow_quantities(true);
82
+                            $item->set_is_required(false);
83 83
                         }
84 84
 
85
-                        if ( ! $item->user_can_set_their_price() && isset( $force_prices[ $item_id ] ) ) {
86
-                            $item->set_is_dynamic_pricing( true );
87
-                            $item->set_minimum_price( 0 );
85
+                        if (!$item->user_can_set_their_price() && isset($force_prices[$item_id])) {
86
+                            $item->set_is_dynamic_pricing(true);
87
+                            $item->set_minimum_price(0);
88 88
                         }
89 89
                     }
90 90
 
@@ -93,22 +93,22 @@  discard block
 block discarded – undo
93 93
                 }
94 94
             }
95 95
 
96
-            if ( ! $payment_form->is_default() ) {
96
+            if (!$payment_form->is_default()) {
97 97
 
98
-                foreach ( $payment_form->get_items() as $item ) {
99
-                    if ( ! in_array( $item->get_id(), $item_ids ) ) {
98
+                foreach ($payment_form->get_items() as $item) {
99
+                    if (!in_array($item->get_id(), $item_ids)) {
100 100
                         $item_ids[] = $item->get_id();
101 101
                         $items[]    = $item;
102 102
                     }
103 103
                 }
104 104
 			}
105 105
 
106
-            $payment_form->set_items( $items );
106
+            $payment_form->set_items($items);
107 107
 		}
108 108
 
109 109
 		// Process each individual item.
110
-		foreach ( $payment_form->get_items() as $item ) {
111
-			$this->process_item( $item, $selected_items, $submission );
110
+		foreach ($payment_form->get_items() as $item) {
111
+			$this->process_item($item, $selected_items, $submission);
112 112
 		}
113 113
 	}
114 114
 
@@ -119,83 +119,83 @@  discard block
 block discarded – undo
119 119
 	 * @param array $selected_items
120 120
 	 * @param GetPaid_Payment_Form_Submission $submission
121 121
 	 */
122
-	public function process_item( $item, $selected_items, $submission ) {
122
+	public function process_item($item, $selected_items, $submission) {
123 123
 
124
-        if ( $item->has_variable_pricing() ) {
124
+        if ($item->has_variable_pricing()) {
125 125
 
126 126
             $selected_items = array_filter(
127 127
                 $selected_items,
128
-                function ( $selected_item ) use ( $item ) {
128
+                function($selected_item) use ($item) {
129 129
                     return (int) $selected_item['item_id'] === (int) $item->get_id();
130 130
                 }
131 131
             );
132 132
 
133
-            if ( ! $item->is_required() && ! count( $selected_items ) ) {
133
+            if (!$item->is_required() && !count($selected_items)) {
134 134
                 return;
135 135
             }
136 136
 
137 137
             $price_options = $item->get_variable_prices();
138
-            $price = current( $selected_items );
138
+            $price = current($selected_items);
139 139
 
140
-            $item->set_price_id( $price['price_id'] );
141
-            $item->set_quantity( $price['quantity'] );
140
+            $item->set_price_id($price['price_id']);
141
+            $item->set_quantity($price['quantity']);
142 142
 
143
-            $price = isset( $price_options[ $price['price_id'] ] ) ? $price_options[ $price['price_id'] ] : $price;
144
-            $item->set_price( (float) $price['amount'] );
143
+            $price = isset($price_options[$price['price_id']]) ? $price_options[$price['price_id']] : $price;
144
+            $item->set_price((float) $price['amount']);
145 145
 
146
-            if ( isset( $price['is-recurring'] ) && 'yes' === $price['is-recurring'] ) {
147
-                if ( isset( $price['trial-interval'], $price['trial-period'] ) && $price['trial-interval'] > 0 ) {
146
+            if (isset($price['is-recurring']) && 'yes' === $price['is-recurring']) {
147
+                if (isset($price['trial-interval'], $price['trial-period']) && $price['trial-interval'] > 0) {
148 148
                     $trial_interval = (int) $price['trial-interval'];
149 149
                     $trial_period = $price['trial-period'];
150 150
 
151
-                    $item->set_is_free_trial( 1 );
152
-                    $item->set_trial_interval( $trial_interval );
153
-                    $item->set_trial_period( $trial_period );
151
+                    $item->set_is_free_trial(1);
152
+                    $item->set_trial_interval($trial_interval);
153
+                    $item->set_trial_period($trial_period);
154 154
                 }
155 155
 
156
-                if ( isset( $price['recurring-interval'], $price['recurring-period'] ) && $price['recurring-interval'] > 0 ) {
156
+                if (isset($price['recurring-interval'], $price['recurring-period']) && $price['recurring-interval'] > 0) {
157 157
                     $recurring_interval = (int) $price['recurring-interval'];
158 158
                     $recurring_period = $price['recurring-period'];
159
-                    $recurring_limit = isset( $price['recurring-limit'] ) ? (int) $price['recurring-limit'] : 0;
159
+                    $recurring_limit = isset($price['recurring-limit']) ? (int) $price['recurring-limit'] : 0;
160 160
 
161
-                    $item->set_is_recurring( 1 );
162
-                    $item->set_recurring_interval( $recurring_interval );
163
-                    $item->set_recurring_period( $recurring_period );
164
-                    $item->set_recurring_limit( $recurring_limit );
161
+                    $item->set_is_recurring(1);
162
+                    $item->set_recurring_interval($recurring_interval);
163
+                    $item->set_recurring_period($recurring_period);
164
+                    $item->set_recurring_limit($recurring_limit);
165 165
                 }
166 166
             }
167 167
         } else {
168 168
 		    // Abort if this is an optional item and it has not been selected.
169
-            if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
169
+            if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
170 170
                 return;
171 171
             }
172 172
 
173 173
             // (maybe) let customers change the quantities and prices.
174
-            if ( isset( $selected_items[ $item->get_id() ] ) ) {
174
+            if (isset($selected_items[$item->get_id()])) {
175 175
 
176 176
                 // Maybe change the quantities.
177
-                if ( $item->allows_quantities() ) {
178
-                    $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] );
177
+                if ($item->allows_quantities()) {
178
+                    $item->set_quantity((float) $selected_items[$item->get_id()]['quantity']);
179 179
                 }
180 180
 
181 181
                 // Maybe change the price.
182
-                if ( $item->user_can_set_their_price() ) {
183
-                    $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
182
+                if ($item->user_can_set_their_price()) {
183
+                    $price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
184 184
 
185
-                    if ( $item->get_minimum_price() > $price ) {
186
-                        throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $item->get_minimum_price() ) ) );
185
+                    if ($item->get_minimum_price() > $price) {
186
+                        throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), getpaid_unstandardize_amount($item->get_minimum_price())));
187 187
                     }
188 188
 
189
-                    $item->set_price( $price );
189
+                    $item->set_price($price);
190 190
                 }
191 191
             }
192 192
         }
193 193
 
194
-		if ( 0 == $item->get_quantity() ) {
194
+		if (0 == $item->get_quantity()) {
195 195
 			return;
196 196
 		}
197 197
 
198 198
 		// Save the item.
199
-		$this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item', $item, $submission );
199
+		$this->items[] = apply_filters('getpaid_payment_form_submission_processed_item', $item, $submission);
200 200
 	}
201 201
 }
Please login to merge, or discard this patch.