Passed
Push — master ( b23fa6...8cf7d7 )
by Brian
15:03
created
vendor/ayecode/wp-ayecode-ui/includes/class-aui.php 1 patch
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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.
vendor/ayecode/wp-ayecode-ui/example-plugin.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -16,202 +16,202 @@
 block discarded – undo
16 16
 
17 17
 // If this file is called directly, abort.
18 18
 if ( ! defined( 'WPINC' ) ) {
19
-	die;
19
+    die;
20 20
 }
21 21
 
22 22
 class AyeCode_UI_Plugin {
23 23
 
24
-	/**
25
-	 * AUI Plugin constructor.
26
-	 *
27
-	 * @since 1.0.0
28
-	 */
29
-	public function __construct() {
30
-
31
-		// load AUI
32
-		require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' );
33
-
34
-		// Maybe show example page
35
-		add_action( 'template_redirect', array( $this,'maybe_show_examples' ) );
36
-	}
37
-
38
-	public function maybe_show_examples(){
39
-		if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
40
-			echo "<head>";
41
-			wp_head();
42
-			echo "</head>";
43
-			echo "<body class='bsui'>";
44
-			echo $this->get_examples();
45
-			wp_footer();
46
-			echo "</body>";
47
-			exit;
48
-		}
49
-	}
50
-
51
-	public function get_examples(){
52
-		$output = '';
53
-
54
-
55
-		// open form
56
-		$output .= "<form class='p-5 m-5 border rounded'>";
57
-
58
-		$output .= aui()->input(
59
-			array(
60
-				'type'             => 'datepicker',
61
-				'id'               => 'wpinv_discount_start',
62
-				'size'             => 'sm',
63
-				'name'             => 'wpinv_discount_start',
64
-				'label'            => __( 'Start Date', 'invoicing' ),
65
-				'placeholder'      => 'YYYY-MM-DD 00:00',
66
-				'value'            => '',
67
-				'extra_attributes' => array(
68
-					'data-enable-time' => 'true',
69
-					'data-time_24hr'   => 'true',
70
-					'data-allow-input' => 'true',
71
-				),
72
-			),
73
-		);
74
-
75
-		$output .= aui()->input(
76
-			array(
77
-				'type'             => 'datepicker',
78
-				'id'               => 'wpinv_discount_start',
79
-				//'size'             => 'smx',
80
-				'name'             => 'wpinv_discount_start',
81
-				'label'            => __( 'Start Date', 'invoicing' ),
82
-				'placeholder'      => 'YYYY-MM-DD 00:00',
83
-				'value'            => '',
84
-				'extra_attributes' => array(
85
-					'data-enable-time' => 'true',
86
-					'data-time_24hr'   => 'true',
87
-					'data-allow-input' => 'true',
88
-				),
89
-			),
90
-		);
91
-		$output .= aui()->input(
92
-			array(
93
-				'type'             => 'datepicker',
94
-				'id'               => 'wpinv_discount_start',
95
-				'size'             => 'lg',
96
-				'name'             => 'wpinv_discount_start',
97
-				'label'            => __( 'Start Date', 'invoicing' ),
98
-				'placeholder'      => 'YYYY-MM-DD 00:00',
99
-				'value'            => '',
100
-				'extra_attributes' => array(
101
-					'data-enable-time' => 'true',
102
-					'data-time_24hr'   => 'true',
103
-					//'data-allow-input' => 'true',
104
-				),
105
-			)
106
-		);
107
-
108
-
109
-		// input example
110
-		$output .= aui()->input(array(
111
-			'type'  =>  'text',
112
-			'id'    =>  'text-example',
113
-			'size'             => 'sm',
114
-			//'clear_icon'    => true,
115
-			'name'    =>  'text-example',
116
-			'placeholder'   => 'text placeholder',
117
-			'title'   => 'Text input example',
118
-			'value' =>  '',
119
-			'required'  => false,
120
-			'help_text' => 'help text',
121
-			'label' => 'Text input example label',
122
-			'label_type' => 'top'
123
-		));
124
-
125
-		$output .= aui()->input(array(
126
-			'type'  =>  'search',
127
-			'id'    =>  'text-example',
128
-			'size'             => 'sm',
129
-			//'clear_icon'    => true,
130
-			'name'    =>  'text-example',
131
-			'placeholder'   => 'text placeholder',
132
-			'title'   => 'Text input example',
133
-			'value' =>  '',
134
-			'required'  => false,
135
-			'help_text' => 'help text',
136
-			'label' => 'Text input example label',
137
-			'label_type' => 'top'
138
-		));
139
-
140
-		// input example
141
-		$output .= aui()->input(array(
142
-			'type'  =>  'url',
143
-			'id'    =>  'text-example2',
144
-			'name'    =>  'text-example',
145
-			'placeholder'   => 'url placeholder',
146
-			'title'   => 'Text input example',
147
-			'value' =>  '',
148
-			'required'  => false,
149
-			'help_text' => 'help text',
150
-			'label' => 'Text input example label'
151
-		));
152
-
153
-		// checkbox example
154
-		$output .= aui()->input(array(
155
-			'type'  =>  'checkbox',
156
-			'id'    =>  'checkbox-example',
157
-			'name'    =>  'checkbox-example',
158
-			'placeholder'   => 'checkbox-example',
159
-			'title'   => 'Checkbox example',
160
-			'value' =>  '1',
161
-			'checked'   => true,
162
-			'required'  => false,
163
-			'help_text' => 'help text',
164
-			'label' => 'Checkbox checked'
165
-		));
166
-
167
-		// checkbox example
168
-		$output .= aui()->input(array(
169
-			'type'  =>  'checkbox',
170
-			'id'    =>  'checkbox-example2',
171
-			'name'    =>  'checkbox-example2',
172
-			'placeholder'   => 'checkbox-example',
173
-			'title'   => 'Checkbox example',
174
-			'value' =>  '1',
175
-			'checked'   => false,
176
-			'required'  => false,
177
-			'help_text' => 'help text',
178
-			'label' => 'Checkbox un-checked'
179
-		));
180
-
181
-		// switch example
182
-		$output .= aui()->input(array(
183
-			'type'  =>  'checkbox',
184
-			'id'    =>  'switch-example',
185
-			'name'    =>  'switch-example',
186
-			'placeholder'   => 'checkbox-example',
187
-			'title'   => 'Switch example',
188
-			'value' =>  '1',
189
-			'checked'   => true,
190
-			'switch'    => true,
191
-			'required'  => false,
192
-			'help_text' => 'help text',
193
-			'label' => 'Switch on'
194
-		));
195
-
196
-		// switch example
197
-		$output .= aui()->input(array(
198
-			'type'  =>  'checkbox',
199
-			'id'    =>  'switch-example2',
200
-			'name'    =>  'switch-example2',
201
-			'placeholder'   => 'checkbox-example',
202
-			'title'   => 'Switch example',
203
-			'value' =>  '1',
204
-			'checked'   => false,
205
-			'switch'    => true,
206
-			'required'  => false,
207
-			'help_text' => 'help text',
208
-			'label' => 'Switch off'
209
-		));
210
-
211
-		// close form
212
-		$output .= "</form>";
213
-
214
-		return $output;
215
-	}
24
+    /**
25
+     * AUI Plugin constructor.
26
+     *
27
+     * @since 1.0.0
28
+     */
29
+    public function __construct() {
30
+
31
+        // load AUI
32
+        require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' );
33
+
34
+        // Maybe show example page
35
+        add_action( 'template_redirect', array( $this,'maybe_show_examples' ) );
36
+    }
37
+
38
+    public function maybe_show_examples(){
39
+        if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
40
+            echo "<head>";
41
+            wp_head();
42
+            echo "</head>";
43
+            echo "<body class='bsui'>";
44
+            echo $this->get_examples();
45
+            wp_footer();
46
+            echo "</body>";
47
+            exit;
48
+        }
49
+    }
50
+
51
+    public function get_examples(){
52
+        $output = '';
53
+
54
+
55
+        // open form
56
+        $output .= "<form class='p-5 m-5 border rounded'>";
57
+
58
+        $output .= aui()->input(
59
+            array(
60
+                'type'             => 'datepicker',
61
+                'id'               => 'wpinv_discount_start',
62
+                'size'             => 'sm',
63
+                'name'             => 'wpinv_discount_start',
64
+                'label'            => __( 'Start Date', 'invoicing' ),
65
+                'placeholder'      => 'YYYY-MM-DD 00:00',
66
+                'value'            => '',
67
+                'extra_attributes' => array(
68
+                    'data-enable-time' => 'true',
69
+                    'data-time_24hr'   => 'true',
70
+                    'data-allow-input' => 'true',
71
+                ),
72
+            ),
73
+        );
74
+
75
+        $output .= aui()->input(
76
+            array(
77
+                'type'             => 'datepicker',
78
+                'id'               => 'wpinv_discount_start',
79
+                //'size'             => 'smx',
80
+                'name'             => 'wpinv_discount_start',
81
+                'label'            => __( 'Start Date', 'invoicing' ),
82
+                'placeholder'      => 'YYYY-MM-DD 00:00',
83
+                'value'            => '',
84
+                'extra_attributes' => array(
85
+                    'data-enable-time' => 'true',
86
+                    'data-time_24hr'   => 'true',
87
+                    'data-allow-input' => 'true',
88
+                ),
89
+            ),
90
+        );
91
+        $output .= aui()->input(
92
+            array(
93
+                'type'             => 'datepicker',
94
+                'id'               => 'wpinv_discount_start',
95
+                'size'             => 'lg',
96
+                'name'             => 'wpinv_discount_start',
97
+                'label'            => __( 'Start Date', 'invoicing' ),
98
+                'placeholder'      => 'YYYY-MM-DD 00:00',
99
+                'value'            => '',
100
+                'extra_attributes' => array(
101
+                    'data-enable-time' => 'true',
102
+                    'data-time_24hr'   => 'true',
103
+                    //'data-allow-input' => 'true',
104
+                ),
105
+            )
106
+        );
107
+
108
+
109
+        // input example
110
+        $output .= aui()->input(array(
111
+            'type'  =>  'text',
112
+            'id'    =>  'text-example',
113
+            'size'             => 'sm',
114
+            //'clear_icon'    => true,
115
+            'name'    =>  'text-example',
116
+            'placeholder'   => 'text placeholder',
117
+            'title'   => 'Text input example',
118
+            'value' =>  '',
119
+            'required'  => false,
120
+            'help_text' => 'help text',
121
+            'label' => 'Text input example label',
122
+            'label_type' => 'top'
123
+        ));
124
+
125
+        $output .= aui()->input(array(
126
+            'type'  =>  'search',
127
+            'id'    =>  'text-example',
128
+            'size'             => 'sm',
129
+            //'clear_icon'    => true,
130
+            'name'    =>  'text-example',
131
+            'placeholder'   => 'text placeholder',
132
+            'title'   => 'Text input example',
133
+            'value' =>  '',
134
+            'required'  => false,
135
+            'help_text' => 'help text',
136
+            'label' => 'Text input example label',
137
+            'label_type' => 'top'
138
+        ));
139
+
140
+        // input example
141
+        $output .= aui()->input(array(
142
+            'type'  =>  'url',
143
+            'id'    =>  'text-example2',
144
+            'name'    =>  'text-example',
145
+            'placeholder'   => 'url placeholder',
146
+            'title'   => 'Text input example',
147
+            'value' =>  '',
148
+            'required'  => false,
149
+            'help_text' => 'help text',
150
+            'label' => 'Text input example label'
151
+        ));
152
+
153
+        // checkbox example
154
+        $output .= aui()->input(array(
155
+            'type'  =>  'checkbox',
156
+            'id'    =>  'checkbox-example',
157
+            'name'    =>  'checkbox-example',
158
+            'placeholder'   => 'checkbox-example',
159
+            'title'   => 'Checkbox example',
160
+            'value' =>  '1',
161
+            'checked'   => true,
162
+            'required'  => false,
163
+            'help_text' => 'help text',
164
+            'label' => 'Checkbox checked'
165
+        ));
166
+
167
+        // checkbox example
168
+        $output .= aui()->input(array(
169
+            'type'  =>  'checkbox',
170
+            'id'    =>  'checkbox-example2',
171
+            'name'    =>  'checkbox-example2',
172
+            'placeholder'   => 'checkbox-example',
173
+            'title'   => 'Checkbox example',
174
+            'value' =>  '1',
175
+            'checked'   => false,
176
+            'required'  => false,
177
+            'help_text' => 'help text',
178
+            'label' => 'Checkbox un-checked'
179
+        ));
180
+
181
+        // switch example
182
+        $output .= aui()->input(array(
183
+            'type'  =>  'checkbox',
184
+            'id'    =>  'switch-example',
185
+            'name'    =>  'switch-example',
186
+            'placeholder'   => 'checkbox-example',
187
+            'title'   => 'Switch example',
188
+            'value' =>  '1',
189
+            'checked'   => true,
190
+            'switch'    => true,
191
+            'required'  => false,
192
+            'help_text' => 'help text',
193
+            'label' => 'Switch on'
194
+        ));
195
+
196
+        // switch example
197
+        $output .= aui()->input(array(
198
+            'type'  =>  'checkbox',
199
+            'id'    =>  'switch-example2',
200
+            'name'    =>  'switch-example2',
201
+            'placeholder'   => 'checkbox-example',
202
+            'title'   => 'Switch example',
203
+            'value' =>  '1',
204
+            'checked'   => false,
205
+            'switch'    => true,
206
+            'required'  => false,
207
+            'help_text' => 'help text',
208
+            'label' => 'Switch off'
209
+        ));
210
+
211
+        // close form
212
+        $output .= "</form>";
213
+
214
+        return $output;
215
+    }
216 216
 }
217 217
 new AyeCode_UI_Plugin();
218 218
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 1 patch
Indentation   +391 added lines, -391 removed lines patch added patch discarded remove patch
@@ -12,473 +12,473 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Paypal_Gateway_IPN_Handler {
14 14
 
15
-	/**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
20
-	protected $id = 'paypal';
21
-
22
-	/**
23
-	 * Payment method object.
24
-	 *
25
-	 * @var GetPaid_Paypal_Gateway
26
-	 */
27
-	protected $gateway;
28
-
29
-	/**
30
-	 * Class constructor.
31
-	 *
32
-	 * @param GetPaid_Paypal_Gateway $gateway
33
-	 */
34
-	public function __construct( $gateway ) {
35
-		$this->gateway = $gateway;
36
-		$this->verify_ipn();
37
-	}
38
-
39
-	/**
40
-	 * Processes ipns and marks payments as complete.
41
-	 *
42
-	 * @return void
43
-	 */
44
-	public function verify_ipn() {
45
-
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
-
48
-		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
51
-		}
52
-
53
-		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
56
-
57
-		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
61
-		}
62
-
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
-
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
-
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
73
-		}
74
-
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
77
-
78
-	}
79
-
80
-	/**
81
-	 * Retrieves IPN Invoice.
82
-	 *
83
-	 * @param array $posted
84
-	 * @return WPInv_Invoice
85
-	 */
86
-	protected function get_ipn_invoice( $posted ) {
87
-
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
-
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
92
-
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
-				return $invoice;
96
-			}
97
-		}
98
-
99
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
101
-	}
102
-
103
-	/**
104
-	 * Check PayPal IPN validity.
105
-	 */
106
-	protected function validate_ipn() {
107
-
108
-		wpinv_error_log( 'Validating PayPal IPN response', false );
109
-
110
-		// Retrieve the associated invoice.
111
-		$posted  = wp_unslash( $_POST );
112
-		$invoice = $this->get_ipn_invoice( $posted );
113
-
114
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
115
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
116
-		}
117
-
118
-		// Validate the IPN.
119
-		$posted['cmd'] = '_notify-validate';
120
-
121
-		// Send back post vars to paypal.
122
-		$params = array(
123
-			'body'        => $posted,
124
-			'timeout'     => 60,
125
-			'httpversion' => '1.1',
126
-			'compress'    => false,
127
-			'decompress'  => false,
128
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
129
-		);
130
-
131
-		// Post back to get a response.
132
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
133
-
134
-		// Check to see if the request was valid.
135
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
136
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
137
-			return true;
138
-		}
139
-
140
-		if ( is_wp_error( $response ) ) {
141
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
142
-			return false;
143
-		}
144
-
145
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
146
-		return false;
147
-
148
-	}
149
-
150
-	/**
151
-	 * Check currency from IPN matches the invoice.
152
-	 *
153
-	 * @param WPInv_Invoice $invoice          Invoice object.
154
-	 * @param string   $currency currency to validate.
155
-	 */
156
-	protected function validate_ipn_currency( $invoice, $currency ) {
15
+    /**
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20
+    protected $id = 'paypal';
21
+
22
+    /**
23
+     * Payment method object.
24
+     *
25
+     * @var GetPaid_Paypal_Gateway
26
+     */
27
+    protected $gateway;
28
+
29
+    /**
30
+     * Class constructor.
31
+     *
32
+     * @param GetPaid_Paypal_Gateway $gateway
33
+     */
34
+    public function __construct( $gateway ) {
35
+        $this->gateway = $gateway;
36
+        $this->verify_ipn();
37
+    }
38
+
39
+    /**
40
+     * Processes ipns and marks payments as complete.
41
+     *
42
+     * @return void
43
+     */
44
+    public function verify_ipn() {
45
+
46
+        wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
+
48
+        // Validate the IPN.
49
+        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
+            wp_die( 'PayPal IPN Request Failure', 500 );
51
+        }
52
+
53
+        // Process the IPN.
54
+        $posted  = wp_unslash( $_POST );
55
+        $invoice = $this->get_ipn_invoice( $posted );
56
+
57
+        // Abort if it was not paid by our gateway.
58
+        if ( $this->id != $invoice->get_gateway() ) {
59
+            wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
+            wp_die( 'Invoice not paid via PayPal', 200 );
61
+        }
62
+
63
+        $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
+        $posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
+
66
+        wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
+        wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
+
69
+        if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
+            call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
+            wpinv_error_log( 'Done processing IPN', false );
72
+            wp_die( 'Processed', 200 );
73
+        }
74
+
75
+        wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
+        wp_die( 'Unsupported IPN type', 200 );
77
+
78
+    }
79
+
80
+    /**
81
+     * Retrieves IPN Invoice.
82
+     *
83
+     * @param array $posted
84
+     * @return WPInv_Invoice
85
+     */
86
+    protected function get_ipn_invoice( $posted ) {
87
+
88
+        wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
+
90
+        if ( ! empty( $posted['custom'] ) ) {
91
+            $invoice = new WPInv_Invoice( $posted['custom'] );
92
+
93
+            if ( $invoice->exists() ) {
94
+                wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
+                return $invoice;
96
+            }
97
+        }
98
+
99
+        wpinv_error_log( 'Could not retrieve the associated invoice.', false );
100
+        wp_die( 'Could not retrieve the associated invoice.', 200 );
101
+    }
102
+
103
+    /**
104
+     * Check PayPal IPN validity.
105
+     */
106
+    protected function validate_ipn() {
107
+
108
+        wpinv_error_log( 'Validating PayPal IPN response', false );
109
+
110
+        // Retrieve the associated invoice.
111
+        $posted  = wp_unslash( $_POST );
112
+        $invoice = $this->get_ipn_invoice( $posted );
113
+
114
+        if ( $this->gateway->is_sandbox( $invoice ) ) {
115
+            wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
116
+        }
117
+
118
+        // Validate the IPN.
119
+        $posted['cmd'] = '_notify-validate';
120
+
121
+        // Send back post vars to paypal.
122
+        $params = array(
123
+            'body'        => $posted,
124
+            'timeout'     => 60,
125
+            'httpversion' => '1.1',
126
+            'compress'    => false,
127
+            'decompress'  => false,
128
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
129
+        );
130
+
131
+        // Post back to get a response.
132
+        $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
133
+
134
+        // Check to see if the request was valid.
135
+        if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
136
+            wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
137
+            return true;
138
+        }
139
+
140
+        if ( is_wp_error( $response ) ) {
141
+            wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
142
+            return false;
143
+        }
144
+
145
+        wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
146
+        return false;
147
+
148
+    }
149
+
150
+    /**
151
+     * Check currency from IPN matches the invoice.
152
+     *
153
+     * @param WPInv_Invoice $invoice          Invoice object.
154
+     * @param string   $currency currency to validate.
155
+     */
156
+    protected function validate_ipn_currency( $invoice, $currency ) {
157 157
 
158
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
158
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159 159
 
160
-			/* translators: %s: currency code. */
161
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
160
+            /* translators: %s: currency code. */
161
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
162 162
 
163
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
164
-		}
163
+            wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
164
+        }
165 165
 
166
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
167
-	}
166
+        wpinv_error_log( $currency, 'Validated IPN Currency', false );
167
+    }
168 168
 
169
-	/**
170
-	 * Check payment amount from IPN matches the invoice.
171
-	 *
172
-	 * @param WPInv_Invoice $invoice          Invoice object.
173
-	 * @param float   $amount amount to validate.
174
-	 */
175
-	protected function validate_ipn_amount( $invoice, $amount ) {
176
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
169
+    /**
170
+     * Check payment amount from IPN matches the invoice.
171
+     *
172
+     * @param WPInv_Invoice $invoice          Invoice object.
173
+     * @param float   $amount amount to validate.
174
+     */
175
+    protected function validate_ipn_amount( $invoice, $amount ) {
176
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
177 177
 
178
-			/* translators: %s: Amount. */
179
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
178
+            /* translators: %s: Amount. */
179
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
180 180
 
181
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
182
-		}
181
+            wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
182
+        }
183 183
 
184
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
185
-	}
184
+        wpinv_error_log( $amount, 'Validated IPN Amount', false );
185
+    }
186 186
 
187
-	/**
188
-	 * Verify receiver email from PayPal.
189
-	 *
190
-	 * @param WPInv_Invoice $invoice          Invoice object.
191
-	 * @param string   $receiver_email Email to validate.
192
-	 */
193
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
194
-		$paypal_email = wpinv_get_option( 'paypal_email' );
187
+    /**
188
+     * Verify receiver email from PayPal.
189
+     *
190
+     * @param WPInv_Invoice $invoice          Invoice object.
191
+     * @param string   $receiver_email Email to validate.
192
+     */
193
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
194
+        $paypal_email = wpinv_get_option( 'paypal_email' );
195 195
 
196
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
197
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
196
+        if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
197
+            wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
198 198
 
199
-			/* translators: %s: email address . */
200
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
199
+            /* translators: %s: email address . */
200
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
201 201
 
202
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
203
-		}
202
+            return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
203
+        }
204 204
 
205
-		wpinv_error_log( 'Validated PayPal Email', false );
206
-	}
205
+        wpinv_error_log( 'Validated PayPal Email', false );
206
+    }
207 207
 
208
-	/**
209
-	 * Handles one time payments.
210
-	 *
211
-	 * @param WPInv_Invoice $invoice  Invoice object.
212
-	 * @param array    $posted Posted data.
213
-	 */
214
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
208
+    /**
209
+     * Handles one time payments.
210
+     *
211
+     * @param WPInv_Invoice $invoice  Invoice object.
212
+     * @param array    $posted Posted data.
213
+     */
214
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
215 215
 
216
-		// Collect payment details
217
-		$payment_status = strtolower( $posted['payment_status'] );
218
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
216
+        // Collect payment details
217
+        $payment_status = strtolower( $posted['payment_status'] );
218
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
219 219
 
220
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
221
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
220
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
221
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
222 222
 
223
-		// Update the transaction id.
224
-		if ( ! empty( $posted['txn_id'] ) ) {
225
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
226
-			$invoice->save();
227
-		}
223
+        // Update the transaction id.
224
+        if ( ! empty( $posted['txn_id'] ) ) {
225
+            $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
226
+            $invoice->save();
227
+        }
228 228
 
229
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
229
+        $invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
230 230
 
231
-		// Process a refund.
232
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
231
+        // Process a refund.
232
+        if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
233 233
 
234
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
234
+            update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
235 235
 
236
-			if ( ! $invoice->is_refunded() ) {
237
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
238
-			}
236
+            if ( ! $invoice->is_refunded() ) {
237
+                $invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
238
+            }
239 239
 
240
-			return wpinv_error_log( $posted['reason_code'], false );
241
-		}
240
+            return wpinv_error_log( $posted['reason_code'], false );
241
+        }
242 242
 
243
-		// Process payments.
244
-		if ( $payment_status == 'completed' ) {
243
+        // Process payments.
244
+        if ( $payment_status == 'completed' ) {
245 245
 
246
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
247
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
248
-			}
246
+            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
247
+                return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
248
+            }
249 249
 
250
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
250
+            $this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
251 251
 
252
-			$note = '';
252
+            $note = '';
253 253
 
254
-			if ( ! empty( $posted['mc_fee'] ) ) {
255
-				$note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
256
-			}
254
+            if ( ! empty( $posted['mc_fee'] ) ) {
255
+                $note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
256
+            }
257 257
 
258
-			if ( ! empty( $posted['payer_status'] ) ) {
259
-				$note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
260
-			}
258
+            if ( ! empty( $posted['payer_status'] ) ) {
259
+                $note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
260
+            }
261 261
 
262
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
263
-			return wpinv_error_log( 'Invoice marked as paid.', false );
262
+            $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
263
+            return wpinv_error_log( 'Invoice marked as paid.', false );
264 264
 
265
-		}
265
+        }
266 266
 
267
-		// Pending payments.
268
-		if ( $payment_status == 'pending' ) {
267
+        // Pending payments.
268
+        if ( $payment_status == 'pending' ) {
269 269
 
270
-			/* translators: %s: pending reason. */
271
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
270
+            /* translators: %s: pending reason. */
271
+            $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
272 272
 
273
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
274
-		}
273
+            return wpinv_error_log( 'Invoice marked as "payment held".', false );
274
+        }
275 275
 
276
-		/* translators: %s: payment status. */
277
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
276
+        /* translators: %s: payment status. */
277
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
278 278
 
279
-	}
279
+    }
280 280
 
281
-	/**
282
-	 * Handles one time payments.
283
-	 *
284
-	 * @param WPInv_Invoice $invoice  Invoice object.
285
-	 * @param array    $posted Posted data.
286
-	 */
287
-	protected function ipn_txn_cart( $invoice, $posted ) {
288
-		$this->ipn_txn_web_accept( $invoice, $posted );
289
-	}
281
+    /**
282
+     * Handles one time payments.
283
+     *
284
+     * @param WPInv_Invoice $invoice  Invoice object.
285
+     * @param array    $posted Posted data.
286
+     */
287
+    protected function ipn_txn_cart( $invoice, $posted ) {
288
+        $this->ipn_txn_web_accept( $invoice, $posted );
289
+    }
290 290
 
291
-	/**
292
-	 * Handles subscription sign ups.
293
-	 *
294
-	 * @param WPInv_Invoice $invoice  Invoice object.
295
-	 * @param array    $posted Posted data.
296
-	 */
297
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
291
+    /**
292
+     * Handles subscription sign ups.
293
+     *
294
+     * @param WPInv_Invoice $invoice  Invoice object.
295
+     * @param array    $posted Posted data.
296
+     */
297
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
298 298
 
299
-		wpinv_error_log( 'Processing subscription signup', false );
299
+        wpinv_error_log( 'Processing subscription signup', false );
300 300
 
301
-		// Make sure the invoice has a subscription.
302
-		$subscription = getpaid_get_invoice_subscription( $invoice );
301
+        // Make sure the invoice has a subscription.
302
+        $subscription = getpaid_get_invoice_subscription( $invoice );
303 303
 
304
-		if ( empty( $subscription ) ) {
305
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
306
-		}
304
+        if ( empty( $subscription ) ) {
305
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
306
+        }
307 307
 
308
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
308
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
309 309
 
310
-		// Validate the IPN.
311
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
312
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
313
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
310
+        // Validate the IPN.
311
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
312
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
313
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
314 314
 
315
-		// Activate the subscription.
316
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
317
-		$subscription->set_date_created( current_time( 'mysql' ) );
318
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
319
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
320
-		$subscription->activate();
315
+        // Activate the subscription.
316
+        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
317
+        $subscription->set_date_created( current_time( 'mysql' ) );
318
+        $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
319
+        $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
320
+        $subscription->activate();
321 321
 
322
-		// Set the transaction id.
323
-		if ( ! empty( $posted['txn_id'] ) ) {
324
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
325
-			$invoice->set_transaction_id( $posted['txn_id'] );
326
-		}
322
+        // Set the transaction id.
323
+        if ( ! empty( $posted['txn_id'] ) ) {
324
+            $invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
325
+            $invoice->set_transaction_id( $posted['txn_id'] );
326
+        }
327 327
 
328
-		// Update the payment status.
329
-		$invoice->mark_paid();
328
+        // Update the payment status.
329
+        $invoice->mark_paid();
330 330
 
331
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
331
+        $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
332 332
 
333
-		wpinv_error_log( 'Subscription started.', false );
334
-	}
333
+        wpinv_error_log( 'Subscription started.', false );
334
+    }
335 335
 
336
-	/**
337
-	 * Handles subscription renewals.
338
-	 *
339
-	 * @param WPInv_Invoice $invoice  Invoice object.
340
-	 * @param array    $posted Posted data.
341
-	 */
342
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
336
+    /**
337
+     * Handles subscription renewals.
338
+     *
339
+     * @param WPInv_Invoice $invoice  Invoice object.
340
+     * @param array    $posted Posted data.
341
+     */
342
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
343 343
 
344
-		// Make sure the invoice has a subscription.
345
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
344
+        // Make sure the invoice has a subscription.
345
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
346 346
 
347
-		if ( empty( $subscription ) ) {
348
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
349
-		}
347
+        if ( empty( $subscription ) ) {
348
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
349
+        }
350 350
 
351
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
351
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
352 352
 
353
-		// PayPal sends a subscr_payment for the first payment too.
354
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
355
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
356
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
357
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
358
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
359
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
353
+        // PayPal sends a subscr_payment for the first payment too.
354
+        $date_completed = getpaid_format_date( $invoice->get_date_completed() );
355
+        $date_created   = getpaid_format_date( $invoice->get_date_created() );
356
+        $today_date     = getpaid_format_date( current_time( 'mysql' ) );
357
+        $payment_date   = getpaid_format_date( $posted['payment_date'] );
358
+        $subscribe_date = getpaid_format_date( $subscription->get_date_created() );
359
+        $dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
360 360
 
361
-		foreach ( $dates as $date ) {
361
+        foreach ( $dates as $date ) {
362 362
 
363
-			if ( $date !== $today_date && $date !== $payment_date ) {
364
-				continue;
365
-			}
363
+            if ( $date !== $today_date && $date !== $payment_date ) {
364
+                continue;
365
+            }
366 366
 
367
-			if ( ! empty( $posted['txn_id'] ) ) {
368
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
369
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
370
-			}
367
+            if ( ! empty( $posted['txn_id'] ) ) {
368
+                $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );
369
+                $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
370
+            }
371 371
 
372
-			return $invoice->mark_paid();
373
-
374
-		}
372
+            return $invoice->mark_paid();
373
+
374
+        }
375 375
 
376
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
377
-
378
-		// Abort if the payment is already recorded.
379
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
380
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false );
381
-		}
382
-
383
-		$args = array(
384
-			'transaction_id' => $posted['txn_id'],
385
-			'gateway'        => $this->id,
386
-		);
387
-
388
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
376
+        wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
377
+
378
+        // Abort if the payment is already recorded.
379
+        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
380
+            return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false );
381
+        }
382
+
383
+        $args = array(
384
+            'transaction_id' => $posted['txn_id'],
385
+            'gateway'        => $this->id,
386
+        );
387
+
388
+        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
389 389
 
390
-		if ( empty( $invoice ) ) {
391
-			return;
392
-		}
390
+        if ( empty( $invoice ) ) {
391
+            return;
392
+        }
393 393
 
394
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
394
+        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ), $posted['txn_id'] ), false, false, true );
395
+        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ), $posted['subscr_id'] ), false, false, true );
396 396
 
397
-		$subscription->renew();
398
-		wpinv_error_log( 'Subscription renewed.', false );
397
+        $subscription->renew();
398
+        wpinv_error_log( 'Subscription renewed.', false );
399 399
 
400
-	}
400
+    }
401 401
 
402
-	/**
403
-	 * Handles subscription cancelations.
404
-	 *
405
-	 * @param WPInv_Invoice $invoice  Invoice object.
406
-	 */
407
-	protected function ipn_txn_subscr_cancel( $invoice ) {
402
+    /**
403
+     * Handles subscription cancelations.
404
+     *
405
+     * @param WPInv_Invoice $invoice  Invoice object.
406
+     */
407
+    protected function ipn_txn_subscr_cancel( $invoice ) {
408 408
 
409
-		// Make sure the invoice has a subscription.
410
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
411
-
412
-		if ( empty( $subscription ) ) {
413
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
414
-		}
415
-
416
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
417
-		$subscription->cancel();
418
-		wpinv_error_log( 'Subscription cancelled.', false );
409
+        // Make sure the invoice has a subscription.
410
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
411
+
412
+        if ( empty( $subscription ) ) {
413
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
414
+        }
415
+
416
+        wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
417
+        $subscription->cancel();
418
+        wpinv_error_log( 'Subscription cancelled.', false );
419 419
 
420
-	}
420
+    }
421 421
 
422
-	/**
423
-	 * Handles subscription completions.
424
-	 *
425
-	 * @param WPInv_Invoice $invoice  Invoice object.
426
-	 * @param array    $posted Posted data.
427
-	 */
428
-	protected function ipn_txn_subscr_eot( $invoice ) {
422
+    /**
423
+     * Handles subscription completions.
424
+     *
425
+     * @param WPInv_Invoice $invoice  Invoice object.
426
+     * @param array    $posted Posted data.
427
+     */
428
+    protected function ipn_txn_subscr_eot( $invoice ) {
429 429
 
430
-		// Make sure the invoice has a subscription.
431
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
430
+        // Make sure the invoice has a subscription.
431
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
432 432
 
433
-		if ( empty( $subscription ) ) {
434
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
435
-		}
433
+        if ( empty( $subscription ) ) {
434
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
435
+        }
436 436
 
437
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
438
-		$subscription->complete();
439
-		wpinv_error_log( 'Subscription completed.', false );
437
+        wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
438
+        $subscription->complete();
439
+        wpinv_error_log( 'Subscription completed.', false );
440 440
 
441
-	}
441
+    }
442 442
 
443
-	/**
444
-	 * Handles subscription fails.
445
-	 *
446
-	 * @param WPInv_Invoice $invoice  Invoice object.
447
-	 * @param array    $posted Posted data.
448
-	 */
449
-	protected function ipn_txn_subscr_failed( $invoice ) {
443
+    /**
444
+     * Handles subscription fails.
445
+     *
446
+     * @param WPInv_Invoice $invoice  Invoice object.
447
+     * @param array    $posted Posted data.
448
+     */
449
+    protected function ipn_txn_subscr_failed( $invoice ) {
450 450
 
451
-		// Make sure the invoice has a subscription.
452
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
451
+        // Make sure the invoice has a subscription.
452
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
453 453
 
454
-		if ( empty( $subscription ) ) {
455
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
456
-		}
454
+        if ( empty( $subscription ) ) {
455
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
456
+        }
457 457
 
458
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
459
-		$subscription->failing();
460
-		wpinv_error_log( 'Subscription marked as failing.', false );
458
+        wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
459
+        $subscription->failing();
460
+        wpinv_error_log( 'Subscription marked as failing.', false );
461 461
 
462
-	}
462
+    }
463 463
 
464
-	/**
465
-	 * Handles subscription suspensions.
466
-	 *
467
-	 * @param WPInv_Invoice $invoice  Invoice object.
468
-	 * @param array    $posted Posted data.
469
-	 */
470
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
464
+    /**
465
+     * Handles subscription suspensions.
466
+     *
467
+     * @param WPInv_Invoice $invoice  Invoice object.
468
+     * @param array    $posted Posted data.
469
+     */
470
+    protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
471 471
 
472
-		// Make sure the invoice has a subscription.
473
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
472
+        // Make sure the invoice has a subscription.
473
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
474 474
 
475
-		if ( empty( $subscription ) ) {
476
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
477
-		}
478
-
479
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
480
-		$subscription->cancel();
481
-		wpinv_error_log( 'Subscription cancelled.', false );
482
-	}
475
+        if ( empty( $subscription ) ) {
476
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
477
+        }
478
+
479
+        wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
480
+        $subscription->cancel();
481
+        wpinv_error_log( 'Subscription cancelled.', false );
482
+    }
483 483
 
484 484
 }
Please login to merge, or discard this patch.
invoicing.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.6.14' );
26
+    define( 'WPINV_VERSION', '2.6.14' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Indentation   +433 added lines, -433 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,308 +21,308 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 * @since 1.0.10 Now able to pass wp.org theme check.
29
-	 * @since 1.0.11 Font Awesome Pro now supported.
30
-	 * @since 1.0.11 Font Awesome Kits now supported.
31
-	 * @since 1.0.13 RTL language support added.
32
-	 * @since 1.0.14 Warning added for v6 pro requires kit and will now not work if official FA plugin installed.
33
-	 * @ver 1.0.14
34
-	 * @todo decide how to implement textdomain
35
-	 */
36
-	class WP_Font_Awesome_Settings {
37
-
38
-		/**
39
-		 * Class version version.
40
-		 *
41
-		 * @var string
42
-		 */
43
-		public $version = '1.0.14';
44
-
45
-		/**
46
-		 * Class textdomain.
47
-		 *
48
-		 * @var string
49
-		 */
50
-		public $textdomain = 'font-awesome-settings';
51
-
52
-		/**
53
-		 * Latest version of Font Awesome at time of publish published.
54
-		 *
55
-		 * @var string
56
-		 */
57
-		public $latest = "5.8.2";
58
-
59
-		/**
60
-		 * The title.
61
-		 *
62
-		 * @var string
63
-		 */
64
-		public $name = 'Font Awesome';
65
-
66
-		/**
67
-		 * Holds the settings values.
68
-		 *
69
-		 * @var array
70
-		 */
71
-		private $settings;
72
-
73
-		/**
74
-		 * WP_Font_Awesome_Settings instance.
75
-		 *
76
-		 * @access private
77
-		 * @since  1.0.0
78
-		 * @var    WP_Font_Awesome_Settings There can be only one!
79
-		 */
80
-		private static $instance = null;
81
-
82
-		/**
83
-		 * Main WP_Font_Awesome_Settings Instance.
84
-		 *
85
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
86
-		 *
87
-		 * @since 1.0.0
88
-		 * @static
89
-		 * @return WP_Font_Awesome_Settings - Main instance.
90
-		 */
91
-		public static function instance() {
92
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
93
-				self::$instance = new WP_Font_Awesome_Settings;
94
-
95
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
96
-
97
-				if ( is_admin() ) {
98
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
99
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
100
-					add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
101
-				}
102
-
103
-				do_action( 'wp_font_awesome_settings_loaded' );
104
-			}
105
-
106
-			return self::$instance;
107
-		}
108
-
109
-		/**
110
-		 * Initiate the settings and add the required action hooks.
111
-		 *
112
-		 * @since 1.0.8 Settings name wrong - FIXED
113
-		 */
114
-		public function init() {
115
-			$this->settings = $this->get_settings();
116
-
117
-			// check if the official plugin is active and use that instead if so.
118
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
119
-
120
-				if ( $this->settings['type'] == 'CSS' ) {
121
-
122
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
123
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
124
-					}
125
-
126
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
127
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
128
-					}
129
-
130
-				} else {
131
-
132
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
133
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
134
-					}
135
-
136
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
137
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
138
-					}
139
-				}
140
-
141
-				// remove font awesome if set to do so
142
-				if ( $this->settings['dequeue'] == '1' ) {
143
-					add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
144
-				}
145
-			}
146
-
147
-		}
148
-
149
-		/**
150
-		 * Adds the Font Awesome styles.
151
-		 */
152
-		public function enqueue_style() {
153
-			// build url
154
-			$url = $this->get_url();
155
-
156
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
157
-			wp_register_style( 'font-awesome', $url, array(), null );
158
-			wp_enqueue_style( 'font-awesome' );
159
-
160
-			// RTL language support CSS.
161
-			if ( is_rtl() ) {
162
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
163
-			}
164
-
165
-			if ( $this->settings['shims'] ) {
166
-				$url = $this->get_url( true );
167
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
168
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
169
-				wp_enqueue_style( 'font-awesome-shims' );
170
-			}
171
-		}
172
-
173
-		/**
174
-		 * Adds the Font Awesome JS.
175
-		 */
176
-		public function enqueue_scripts() {
177
-			// build url
178
-			$url = $this->get_url();
179
-
180
-			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
181
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
182
-			wp_register_script( 'font-awesome', $url, array(), null );
183
-			wp_enqueue_script( 'font-awesome' );
184
-
185
-			if ( $this->settings['shims'] ) {
186
-				$url = $this->get_url( true );
187
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
188
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
189
-				wp_enqueue_script( 'font-awesome-shims' );
190
-			}
191
-		}
192
-
193
-		/**
194
-		 * Get the url of the Font Awesome files.
195
-		 *
196
-		 * @param bool $shims If this is a shim file or not.
197
-		 *
198
-		 * @return string The url to the file.
199
-		 */
200
-		public function get_url( $shims = false ) {
201
-			$script  = $shims ? 'v4-shims' : 'all';
202
-			$sub     = $this->settings['pro'] ? 'pro' : 'use';
203
-			$type    = $this->settings['type'];
204
-			$version = $this->settings['version'];
205
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
206
-			$url     = '';
207
-
208
-			if ( $type == 'KIT' && $kit_url ) {
209
-				if ( $shims ) {
210
-					// if its a kit then we don't add shims here
211
-					return '';
212
-				}
213
-				$url .= $kit_url; // CDN
214
-				$url .= "?wpfas=true"; // set our var so our version is not removed
215
-			} else {
216
-				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
217
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
218
-				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
219
-				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
220
-				$url .= "?wpfas=true"; // set our var so our version is not removed
221
-			}
222
-
223
-			return $url;
224
-		}
225
-
226
-		/**
227
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
228
-		 *
229
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
230
-		 *
231
-		 * @param $url
232
-		 * @param $original_url
233
-		 * @param $_context
234
-		 *
235
-		 * @return string The filtered url.
236
-		 */
237
-		public function remove_font_awesome( $url, $original_url, $_context ) {
238
-
239
-			if ( $_context == 'display'
240
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
241
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
242
-			) {// it's a font-awesome-url (probably)
243
-
244
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
245
-					if ( $this->settings['type'] == 'JS' ) {
246
-						if ( $this->settings['js-pseudo'] ) {
247
-							$url .= "' data-search-pseudo-elements defer='defer";
248
-						} else {
249
-							$url .= "' defer='defer";
250
-						}
251
-					}
252
-				} else {
253
-					$url = ''; // removing the url removes the file
254
-				}
255
-
256
-			}
257
-
258
-			return $url;
259
-		}
260
-
261
-		/**
262
-		 * Register the database settings with WordPress.
263
-		 */
264
-		public function register_settings() {
265
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
266
-		}
267
-
268
-		/**
269
-		 * Add the WordPress settings menu item.
270
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
271
-		 */
272
-		public function menu_item() {
273
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
274
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
275
-				$this,
276
-				'settings_page'
277
-			) );
278
-		}
279
-
280
-		/**
281
-		 * Get the current Font Awesome output settings.
282
-		 *
283
-		 * @return array The array of settings.
284
-		 */
285
-		public function get_settings() {
286
-
287
-			$db_settings = get_option( 'wp-font-awesome-settings' );
288
-
289
-			$defaults = array(
290
-				'type'      => 'CSS', // type to use, CSS or JS or KIT
291
-				'version'   => '', // latest
292
-				'enqueue'   => '', // front and backend
293
-				'shims'     => '0', // default OFF now in 2020
294
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
295
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
296
-				'pro'       => '0', // if pro CDN url should be used
297
-				'kit-url'   => '', // the kit url
298
-			);
299
-
300
-			$settings = wp_parse_args( $db_settings, $defaults );
301
-
302
-			/**
303
-			 * Filter the Font Awesome settings.
304
-			 *
305
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
306
-			 */
307
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
308
-		}
309
-
310
-
311
-		/**
312
-		 * The settings page html output.
313
-		 */
314
-		public function settings_page() {
315
-			if ( ! current_user_can( 'manage_options' ) ) {
316
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
317
-			}
318
-
319
-			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
320
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
321
-				$this->get_latest_version( $force_api = true );
322
-			}
323
-
324
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
325
-				?>
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     * @since 1.0.10 Now able to pass wp.org theme check.
29
+     * @since 1.0.11 Font Awesome Pro now supported.
30
+     * @since 1.0.11 Font Awesome Kits now supported.
31
+     * @since 1.0.13 RTL language support added.
32
+     * @since 1.0.14 Warning added for v6 pro requires kit and will now not work if official FA plugin installed.
33
+     * @ver 1.0.14
34
+     * @todo decide how to implement textdomain
35
+     */
36
+    class WP_Font_Awesome_Settings {
37
+
38
+        /**
39
+         * Class version version.
40
+         *
41
+         * @var string
42
+         */
43
+        public $version = '1.0.14';
44
+
45
+        /**
46
+         * Class textdomain.
47
+         *
48
+         * @var string
49
+         */
50
+        public $textdomain = 'font-awesome-settings';
51
+
52
+        /**
53
+         * Latest version of Font Awesome at time of publish published.
54
+         *
55
+         * @var string
56
+         */
57
+        public $latest = "5.8.2";
58
+
59
+        /**
60
+         * The title.
61
+         *
62
+         * @var string
63
+         */
64
+        public $name = 'Font Awesome';
65
+
66
+        /**
67
+         * Holds the settings values.
68
+         *
69
+         * @var array
70
+         */
71
+        private $settings;
72
+
73
+        /**
74
+         * WP_Font_Awesome_Settings instance.
75
+         *
76
+         * @access private
77
+         * @since  1.0.0
78
+         * @var    WP_Font_Awesome_Settings There can be only one!
79
+         */
80
+        private static $instance = null;
81
+
82
+        /**
83
+         * Main WP_Font_Awesome_Settings Instance.
84
+         *
85
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
86
+         *
87
+         * @since 1.0.0
88
+         * @static
89
+         * @return WP_Font_Awesome_Settings - Main instance.
90
+         */
91
+        public static function instance() {
92
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
93
+                self::$instance = new WP_Font_Awesome_Settings;
94
+
95
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
96
+
97
+                if ( is_admin() ) {
98
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
99
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
100
+                    add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
101
+                }
102
+
103
+                do_action( 'wp_font_awesome_settings_loaded' );
104
+            }
105
+
106
+            return self::$instance;
107
+        }
108
+
109
+        /**
110
+         * Initiate the settings and add the required action hooks.
111
+         *
112
+         * @since 1.0.8 Settings name wrong - FIXED
113
+         */
114
+        public function init() {
115
+            $this->settings = $this->get_settings();
116
+
117
+            // check if the official plugin is active and use that instead if so.
118
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
119
+
120
+                if ( $this->settings['type'] == 'CSS' ) {
121
+
122
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
123
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
124
+                    }
125
+
126
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
127
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
128
+                    }
129
+
130
+                } else {
131
+
132
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
133
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
134
+                    }
135
+
136
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
137
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
138
+                    }
139
+                }
140
+
141
+                // remove font awesome if set to do so
142
+                if ( $this->settings['dequeue'] == '1' ) {
143
+                    add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
144
+                }
145
+            }
146
+
147
+        }
148
+
149
+        /**
150
+         * Adds the Font Awesome styles.
151
+         */
152
+        public function enqueue_style() {
153
+            // build url
154
+            $url = $this->get_url();
155
+
156
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
157
+            wp_register_style( 'font-awesome', $url, array(), null );
158
+            wp_enqueue_style( 'font-awesome' );
159
+
160
+            // RTL language support CSS.
161
+            if ( is_rtl() ) {
162
+                wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
163
+            }
164
+
165
+            if ( $this->settings['shims'] ) {
166
+                $url = $this->get_url( true );
167
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
168
+                wp_register_style( 'font-awesome-shims', $url, array(), null );
169
+                wp_enqueue_style( 'font-awesome-shims' );
170
+            }
171
+        }
172
+
173
+        /**
174
+         * Adds the Font Awesome JS.
175
+         */
176
+        public function enqueue_scripts() {
177
+            // build url
178
+            $url = $this->get_url();
179
+
180
+            $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
181
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
182
+            wp_register_script( 'font-awesome', $url, array(), null );
183
+            wp_enqueue_script( 'font-awesome' );
184
+
185
+            if ( $this->settings['shims'] ) {
186
+                $url = $this->get_url( true );
187
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
188
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
189
+                wp_enqueue_script( 'font-awesome-shims' );
190
+            }
191
+        }
192
+
193
+        /**
194
+         * Get the url of the Font Awesome files.
195
+         *
196
+         * @param bool $shims If this is a shim file or not.
197
+         *
198
+         * @return string The url to the file.
199
+         */
200
+        public function get_url( $shims = false ) {
201
+            $script  = $shims ? 'v4-shims' : 'all';
202
+            $sub     = $this->settings['pro'] ? 'pro' : 'use';
203
+            $type    = $this->settings['type'];
204
+            $version = $this->settings['version'];
205
+            $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
206
+            $url     = '';
207
+
208
+            if ( $type == 'KIT' && $kit_url ) {
209
+                if ( $shims ) {
210
+                    // if its a kit then we don't add shims here
211
+                    return '';
212
+                }
213
+                $url .= $kit_url; // CDN
214
+                $url .= "?wpfas=true"; // set our var so our version is not removed
215
+            } else {
216
+                $url .= "https://$sub.fontawesome.com/releases/"; // CDN
217
+                $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
218
+                $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
219
+                $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
220
+                $url .= "?wpfas=true"; // set our var so our version is not removed
221
+            }
222
+
223
+            return $url;
224
+        }
225
+
226
+        /**
227
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
228
+         *
229
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
230
+         *
231
+         * @param $url
232
+         * @param $original_url
233
+         * @param $_context
234
+         *
235
+         * @return string The filtered url.
236
+         */
237
+        public function remove_font_awesome( $url, $original_url, $_context ) {
238
+
239
+            if ( $_context == 'display'
240
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
241
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
242
+            ) {// it's a font-awesome-url (probably)
243
+
244
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
245
+                    if ( $this->settings['type'] == 'JS' ) {
246
+                        if ( $this->settings['js-pseudo'] ) {
247
+                            $url .= "' data-search-pseudo-elements defer='defer";
248
+                        } else {
249
+                            $url .= "' defer='defer";
250
+                        }
251
+                    }
252
+                } else {
253
+                    $url = ''; // removing the url removes the file
254
+                }
255
+
256
+            }
257
+
258
+            return $url;
259
+        }
260
+
261
+        /**
262
+         * Register the database settings with WordPress.
263
+         */
264
+        public function register_settings() {
265
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
266
+        }
267
+
268
+        /**
269
+         * Add the WordPress settings menu item.
270
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
271
+         */
272
+        public function menu_item() {
273
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
274
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
275
+                $this,
276
+                'settings_page'
277
+            ) );
278
+        }
279
+
280
+        /**
281
+         * Get the current Font Awesome output settings.
282
+         *
283
+         * @return array The array of settings.
284
+         */
285
+        public function get_settings() {
286
+
287
+            $db_settings = get_option( 'wp-font-awesome-settings' );
288
+
289
+            $defaults = array(
290
+                'type'      => 'CSS', // type to use, CSS or JS or KIT
291
+                'version'   => '', // latest
292
+                'enqueue'   => '', // front and backend
293
+                'shims'     => '0', // default OFF now in 2020
294
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
295
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
296
+                'pro'       => '0', // if pro CDN url should be used
297
+                'kit-url'   => '', // the kit url
298
+            );
299
+
300
+            $settings = wp_parse_args( $db_settings, $defaults );
301
+
302
+            /**
303
+             * Filter the Font Awesome settings.
304
+             *
305
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
306
+             */
307
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
308
+        }
309
+
310
+
311
+        /**
312
+         * The settings page html output.
313
+         */
314
+        public function settings_page() {
315
+            if ( ! current_user_can( 'manage_options' ) ) {
316
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
317
+            }
318
+
319
+            // a hidden way to force the update of the version number via api instead of waiting the 48 hours
320
+            if ( isset( $_REQUEST['force-version-check'] ) ) {
321
+                $this->get_latest_version( $force_api = true );
322
+            }
323
+
324
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
325
+                ?>
326 326
                 <style>
327 327
                     .wpfas-kit-show {
328 328
                         display: none;
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
                     <h1><?php echo $this->name; ?></h1>
341 341
                     <form method="post" action="options.php" class="fas-settings-form">
342 342
 						<?php
343
-						settings_fields( 'wp-font-awesome-settings' );
344
-						do_settings_sections( 'wp-font-awesome-settings' );
345
-						$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
346
-						?>
343
+                        settings_fields( 'wp-font-awesome-settings' );
344
+                        do_settings_sections( 'wp-font-awesome-settings' );
345
+                        $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
346
+                        ?>
347 347
                         <table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
348 348
                             <tr valign="top">
349 349
                                 <th scope="row"><label
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
                                            value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
370 370
                                            placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
371 371
                                     <span><?php
372
-										echo sprintf(
373
-											__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
374
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
375
-											'</a>'
376
-										);
377
-										?></span>
372
+                                        echo sprintf(
373
+                                            __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
374
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
375
+                                            '</a>'
376
+                                        );
377
+                                        ?></span>
378 378
                                 </td>
379 379
                             </tr>
380 380
 
@@ -443,14 +443,14 @@  discard block
 block discarded – undo
443 443
                                     <input type="checkbox" name="wp-font-awesome-settings[pro]"
444 444
                                            value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
445 445
                                     <span><?php
446
-										echo sprintf(
447
-											__( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'font-awesome-settings' ),
448
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
449
-											' <i class="fas fa-external-link-alt"></i></a>',
450
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
451
-											' <i class="fas fa-external-link-alt"></i></a>'
452
-										);
453
-										?></span>
446
+                                        echo sprintf(
447
+                                            __( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'font-awesome-settings' ),
448
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
449
+                                            ' <i class="fas fa-external-link-alt"></i></a>',
450
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
451
+                                            ' <i class="fas fa-external-link-alt"></i></a>'
452
+                                        );
453
+                                        ?></span>
454 454
                                 </td>
455 455
                             </tr>
456 456
 
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
                         </table>
495 495
                         <div class="fas-buttons">
496 496
 							<?php
497
-							submit_button();
498
-							?>
497
+                            submit_button();
498
+                            ?>
499 499
                             <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 14,000+ more icons with Font Awesome Pro','font-awesome-settings'); ?> <i class="fas fa-external-link-alt"></i></a></p>
500 500
 
501 501
                         </div>
@@ -519,126 +519,126 @@  discard block
 block discarded – undo
519 519
                     }
520 520
                 </style>
521 521
 				<?php
522
-			}
523
-		}
524
-
525
-		/**
526
-		 * Check a version number is valid and if so return it or else return an empty string.
527
-		 *
528
-		 * @param $version string The version number to check.
529
-		 *
530
-		 * @since 1.0.6
531
-		 *
532
-		 * @return string Either a valid version number or an empty string.
533
-		 */
534
-		public function validate_version_number( $version ) {
535
-
536
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
537
-				// valid
538
-			} else {
539
-				$version = '';// not validated
540
-			}
541
-
542
-			return $version;
543
-		}
544
-
545
-
546
-		/**
547
-		 * Get the latest version of Font Awesome.
548
-		 *
549
-		 * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
550
-		 *
551
-		 * @since 1.0.7
552
-		 * @return mixed|string The latest version number found.
553
-		 */
554
-		public function get_latest_version( $force_api = false ) {
555
-			$latest_version = $this->latest;
556
-
557
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
558
-
559
-			if ( $cache === false || $force_api ) { // its not set
560
-				$api_ver = $this->get_latest_version_from_api();
561
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
562
-					$latest_version = $api_ver;
563
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
564
-				}
565
-			} elseif ( $this->validate_version_number( $cache ) ) {
566
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
567
-					$latest_version = $cache;
568
-				}
569
-			}
570
-
571
-			return $latest_version;
572
-		}
573
-
574
-		/**
575
-		 * Get the latest Font Awesome version from the github API.
576
-		 *
577
-		 * @since 1.0.7
578
-		 * @return string The latest version number or `0` on API fail.
579
-		 */
580
-		public function get_latest_version_from_api() {
581
-			$version  = "0";
582
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
583
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
584
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
585
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
586
-					$version = $api_response['tag_name'];
587
-				}
588
-			}
589
-
590
-			return $version;
591
-		}
592
-
593
-		/**
594
-		 * Inline CSS for RTL language support.
595
-		 *
596
-		 * @since 1.0.13
597
-		 * @return string Inline CSS.
598
-		 */
599
-		public function rtl_inline_css() {
600
-			$inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
601
-
602
-			return $inline_css;
603
-		}
604
-
605
-		/**
606
-		 * Show any warnings as an admin notice.
607
-		 *
608
-		 * @return void
609
-		 */
610
-		public function admin_notices(){
611
-			$settings = $this->settings;
612
-
613
-			if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
614
-
615
-				if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
616
-					?>
522
+            }
523
+        }
524
+
525
+        /**
526
+         * Check a version number is valid and if so return it or else return an empty string.
527
+         *
528
+         * @param $version string The version number to check.
529
+         *
530
+         * @since 1.0.6
531
+         *
532
+         * @return string Either a valid version number or an empty string.
533
+         */
534
+        public function validate_version_number( $version ) {
535
+
536
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
537
+                // valid
538
+            } else {
539
+                $version = '';// not validated
540
+            }
541
+
542
+            return $version;
543
+        }
544
+
545
+
546
+        /**
547
+         * Get the latest version of Font Awesome.
548
+         *
549
+         * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
550
+         *
551
+         * @since 1.0.7
552
+         * @return mixed|string The latest version number found.
553
+         */
554
+        public function get_latest_version( $force_api = false ) {
555
+            $latest_version = $this->latest;
556
+
557
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
558
+
559
+            if ( $cache === false || $force_api ) { // its not set
560
+                $api_ver = $this->get_latest_version_from_api();
561
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
562
+                    $latest_version = $api_ver;
563
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
564
+                }
565
+            } elseif ( $this->validate_version_number( $cache ) ) {
566
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
567
+                    $latest_version = $cache;
568
+                }
569
+            }
570
+
571
+            return $latest_version;
572
+        }
573
+
574
+        /**
575
+         * Get the latest Font Awesome version from the github API.
576
+         *
577
+         * @since 1.0.7
578
+         * @return string The latest version number or `0` on API fail.
579
+         */
580
+        public function get_latest_version_from_api() {
581
+            $version  = "0";
582
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
583
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
584
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
585
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
586
+                    $version = $api_response['tag_name'];
587
+                }
588
+            }
589
+
590
+            return $version;
591
+        }
592
+
593
+        /**
594
+         * Inline CSS for RTL language support.
595
+         *
596
+         * @since 1.0.13
597
+         * @return string Inline CSS.
598
+         */
599
+        public function rtl_inline_css() {
600
+            $inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
601
+
602
+            return $inline_css;
603
+        }
604
+
605
+        /**
606
+         * Show any warnings as an admin notice.
607
+         *
608
+         * @return void
609
+         */
610
+        public function admin_notices(){
611
+            $settings = $this->settings;
612
+
613
+            if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
614
+
615
+                if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
616
+                    ?>
617 617
                     <div class="notice  notice-error is-dismissible">
618 618
                         <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'font-awesome-settings' ); ?></p>
619 619
                     </div>
620 620
 					<?php
621
-				}
621
+                }
622 622
 
623
-			}else{
624
-				if ( ! empty( $settings ) ) {
625
-					if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
626
-						$link = admin_url('options-general.php?page=wp-font-awesome-settings');
627
-						?>
623
+            }else{
624
+                if ( ! empty( $settings ) ) {
625
+                    if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
626
+                        $link = admin_url('options-general.php?page=wp-font-awesome-settings');
627
+                        ?>
628 628
                         <div class="notice  notice-error is-dismissible">
629 629
                             <p><?php echo sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'font-awesome-settings' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p>
630 630
                         </div>
631 631
 						<?php
632
-					}
633
-				}
634
-			}
632
+                    }
633
+                }
634
+            }
635 635
 
636
-		}
636
+        }
637 637
 
638
-	}
638
+    }
639 639
 
640
-	/**
641
-	 * Run the class if found.
642
-	 */
643
-	WP_Font_Awesome_Settings::instance();
640
+    /**
641
+     * Run the class if found.
642
+     */
643
+    WP_Font_Awesome_Settings::instance();
644 644
 }
645 645
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Indentation   +586 added lines, -586 removed lines patch added patch discarded remove patch
@@ -14,635 +14,635 @@
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * @var array An array of payment gateways.
40
-	 */
41
-	public $gateways;
42
-
43
-	/**
44
-	 * Class constructor.
45
-	 */
46
-	public function __construct() {
47
-		$this->define_constants();
48
-		$this->includes();
49
-		$this->init_hooks();
50
-		$this->set_properties();
51
-	}
52
-
53
-	/**
54
-	 * Sets a custom data property.
55
-	 *
56
-	 * @param string $prop The prop to set.
57
-	 * @param mixed $value The value to retrieve.
58
-	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
61
-	}
62
-
63
-	/**
64
-	 * Gets a custom data property.
65
-	 *
66
-	 * @param string $prop The prop to set.
67
-	 * @return mixed The value.
68
-	 */
69
-	public function get( $prop ) {
70
-
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
73
-		}
74
-
75
-		return null;
76
-	}
77
-
78
-	/**
79
-	 * Define class properties.
80
-	 */
81
-	public function set_properties() {
82
-
83
-		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
-		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
-
88
-		// Init other objects.
89
-		$this->set( 'session', new WPInv_Session_Handler() );
90
-		$this->set( 'notes', new WPInv_Notes() );
91
-		$this->set( 'api', new WPInv_API() );
92
-		$this->set( 'post_types', new GetPaid_Post_Types() );
93
-		$this->set( 'template', new GetPaid_Template() );
94
-		$this->set( 'admin', new GetPaid_Admin() );
95
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
96
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
101
-
102
-	}
103
-
104
-	 /**
105
-	 * Define plugin constants.
106
-	 */
107
-	public function define_constants() {
108
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
110
-		$this->version = WPINV_VERSION;
111
-	}
112
-
113
-	/**
114
-	 * Hook into actions and filters.
115
-	 *
116
-	 * @since 1.0.19
117
-	 */
118
-	protected function init_hooks() {
119
-		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
121
-
122
-		// Init the plugin after WordPress inits.
123
-		add_action( 'init', array( $this, 'init' ), 1 );
124
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
126
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
130
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
-		add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
133
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
134
-
135
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * @var array An array of payment gateways.
40
+     */
41
+    public $gateways;
42
+
43
+    /**
44
+     * Class constructor.
45
+     */
46
+    public function __construct() {
47
+        $this->define_constants();
48
+        $this->includes();
49
+        $this->init_hooks();
50
+        $this->set_properties();
51
+    }
52
+
53
+    /**
54
+     * Sets a custom data property.
55
+     *
56
+     * @param string $prop The prop to set.
57
+     * @param mixed $value The value to retrieve.
58
+     */
59
+    public function set( $prop, $value ) {
60
+        $this->data[ $prop ] = $value;
61
+    }
62
+
63
+    /**
64
+     * Gets a custom data property.
65
+     *
66
+     * @param string $prop The prop to set.
67
+     * @return mixed The value.
68
+     */
69
+    public function get( $prop ) {
70
+
71
+        if ( isset( $this->data[ $prop ] ) ) {
72
+            return $this->data[ $prop ];
73
+        }
74
+
75
+        return null;
76
+    }
77
+
78
+    /**
79
+     * Define class properties.
80
+     */
81
+    public function set_properties() {
82
+
83
+        // Sessions.
84
+        $this->set( 'session', new WPInv_Session_Handler() );
85
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
+        $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
+
88
+        // Init other objects.
89
+        $this->set( 'session', new WPInv_Session_Handler() );
90
+        $this->set( 'notes', new WPInv_Notes() );
91
+        $this->set( 'api', new WPInv_API() );
92
+        $this->set( 'post_types', new GetPaid_Post_Types() );
93
+        $this->set( 'template', new GetPaid_Template() );
94
+        $this->set( 'admin', new GetPaid_Admin() );
95
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
96
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
+        $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
101
+
102
+    }
103
+
104
+        /**
105
+         * Define plugin constants.
106
+         */
107
+    public function define_constants() {
108
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
110
+        $this->version = WPINV_VERSION;
111
+    }
112
+
113
+    /**
114
+     * Hook into actions and filters.
115
+     *
116
+     * @since 1.0.19
117
+     */
118
+    protected function init_hooks() {
119
+        /* Internationalize the text strings used. */
120
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
121
+
122
+        // Init the plugin after WordPress inits.
123
+        add_action( 'init', array( $this, 'init' ), 1 );
124
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
126
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
+        add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
+        add_action( 'wp_head', array( $this, 'wp_head' ) );
130
+        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
+        add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
133
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
134
+
135
+        add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
136 136
         add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
137
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
138
-
139
-		// Fires after registering actions.
140
-		do_action( 'wpinv_actions', $this );
141
-		do_action( 'getpaid_actions', $this );
142
-
143
-	}
144
-
145
-	public function plugins_loaded() {
146
-		/* Internationalize the text strings used. */
147
-		$this->load_textdomain();
148
-
149
-		do_action( 'wpinv_loaded' );
150
-
151
-		// Fix oxygen page builder conflict
152
-		if ( function_exists( 'ct_css_output' ) ) {
153
-			wpinv_oxygen_fix_conflict();
154
-		}
155
-	}
156
-
157
-	/**
158
-	 * Load Localisation files.
159
-	 *
160
-	 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
161
-	 *
162
-	 * Locales found in:
163
-	 *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
164
-	 *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
165
-	 *
166
-	 * @since 1.0.0
167
-	 */
168
-	public function load_textdomain() {
169
-
170
-		load_plugin_textdomain(
171
-			'invoicing',
172
-			false,
173
-			plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
174
-		);
175
-
176
-	}
177
-
178
-	/**
179
-	 * Include required core files used in admin and on the frontend.
180
-	 */
181
-	public function includes() {
182
-
183
-		// Start with the settings.
184
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php';
185
-
186
-		// Packages/libraries.
187
-		require_once WPINV_PLUGIN_DIR . 'vendor/autoload.php';
188
-		require_once WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php';
189
-
190
-		// Load functions.
191
-		require_once WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php';
192
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php';
193
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php';
194
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php';
195
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php';
196
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php';
197
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php';
198
-		require_once WPINV_PLUGIN_DIR . 'includes/invoice-functions.php';
199
-		require_once WPINV_PLUGIN_DIR . 'includes/subscription-functions.php';
200
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php';
201
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php';
202
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php';
203
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php';
204
-		require_once WPINV_PLUGIN_DIR . 'includes/user-functions.php';
205
-		require_once WPINV_PLUGIN_DIR . 'includes/error-functions.php';
206
-
207
-		// Register autoloader.
208
-		try {
209
-			spl_autoload_register( array( $this, 'autoload' ), true );
210
-		} catch ( Exception $e ) {
211
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
212
-		}
213
-
214
-		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
215
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php';
216
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php';
217
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php';
218
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php';
219
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php';
220
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php';
221
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php';
222
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php';
223
-		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php';
224
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php';
225
-		require_once WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php';
226
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php';
227
-		require_once WPINV_PLUGIN_DIR . 'widgets/checkout.php';
228
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-history.php';
229
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php';
230
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php';
231
-		require_once WPINV_PLUGIN_DIR . 'widgets/subscriptions.php';
232
-		require_once WPINV_PLUGIN_DIR . 'widgets/buy-item.php';
233
-		require_once WPINV_PLUGIN_DIR . 'widgets/getpaid.php';
234
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
235
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
236
-
237
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
238
-			GetPaid_Post_Types_Admin::init();
239
-
240
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
241
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php';
242
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php';
243
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php';
244
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php';
245
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
246
-			// load the user class only on the users.php page
247
-			global $pagenow;
248
-			if ( $pagenow == 'users.php' ) {
249
-				new WPInv_Admin_Users();
250
-			}
251
-		}
252
-
253
-		// Register cli commands
254
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
255
-			require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
256
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
257
-		}
258
-
259
-	}
260
-
261
-	/**
262
-	 * Class autoloader
263
-	 *
264
-	 * @param       string $class_name The name of the class to load.
265
-	 * @access      public
266
-	 * @since       1.0.19
267
-	 * @return      void
268
-	 */
269
-	public function autoload( $class_name ) {
270
-
271
-		// Normalize the class name...
272
-		$class_name  = strtolower( $class_name );
273
-
274
-		// ... and make sure it is our class.
275
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
276
-			return;
277
-		}
278
-
279
-		// Next, prepare the file name from the class.
280
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
281
-
282
-		// Base path of the classes.
283
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
284
-
285
-		// And an array of possible locations in order of importance.
286
-		$locations = array(
287
-			"$plugin_path/includes",
288
-			"$plugin_path/includes/data-stores",
289
-			"$plugin_path/includes/gateways",
290
-			"$plugin_path/includes/payments",
291
-			"$plugin_path/includes/geolocation",
292
-			"$plugin_path/includes/reports",
293
-			"$plugin_path/includes/api",
294
-			"$plugin_path/includes/admin",
295
-			"$plugin_path/includes/admin/meta-boxes",
296
-		);
297
-
298
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
299
-
300
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
301
-				include trailingslashit( $location ) . $file_name;
302
-				break;
303
-			}
137
+        add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
138
+
139
+        // Fires after registering actions.
140
+        do_action( 'wpinv_actions', $this );
141
+        do_action( 'getpaid_actions', $this );
142
+
143
+    }
144
+
145
+    public function plugins_loaded() {
146
+        /* Internationalize the text strings used. */
147
+        $this->load_textdomain();
148
+
149
+        do_action( 'wpinv_loaded' );
150
+
151
+        // Fix oxygen page builder conflict
152
+        if ( function_exists( 'ct_css_output' ) ) {
153
+            wpinv_oxygen_fix_conflict();
154
+        }
155
+    }
156
+
157
+    /**
158
+     * Load Localisation files.
159
+     *
160
+     * Note: the first-loaded translation file overrides any following ones if the same translation is present.
161
+     *
162
+     * Locales found in:
163
+     *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
164
+     *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
165
+     *
166
+     * @since 1.0.0
167
+     */
168
+    public function load_textdomain() {
169
+
170
+        load_plugin_textdomain(
171
+            'invoicing',
172
+            false,
173
+            plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
174
+        );
175
+
176
+    }
177
+
178
+    /**
179
+     * Include required core files used in admin and on the frontend.
180
+     */
181
+    public function includes() {
182
+
183
+        // Start with the settings.
184
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php';
185
+
186
+        // Packages/libraries.
187
+        require_once WPINV_PLUGIN_DIR . 'vendor/autoload.php';
188
+        require_once WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php';
189
+
190
+        // Load functions.
191
+        require_once WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php';
192
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php';
193
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php';
194
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php';
195
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php';
196
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php';
197
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php';
198
+        require_once WPINV_PLUGIN_DIR . 'includes/invoice-functions.php';
199
+        require_once WPINV_PLUGIN_DIR . 'includes/subscription-functions.php';
200
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php';
201
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php';
202
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php';
203
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php';
204
+        require_once WPINV_PLUGIN_DIR . 'includes/user-functions.php';
205
+        require_once WPINV_PLUGIN_DIR . 'includes/error-functions.php';
206
+
207
+        // Register autoloader.
208
+        try {
209
+            spl_autoload_register( array( $this, 'autoload' ), true );
210
+        } catch ( Exception $e ) {
211
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
212
+        }
213
+
214
+        require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
215
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php';
216
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php';
217
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php';
218
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php';
219
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php';
220
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php';
221
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php';
222
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php';
223
+        require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php';
224
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php';
225
+        require_once WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php';
226
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php';
227
+        require_once WPINV_PLUGIN_DIR . 'widgets/checkout.php';
228
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-history.php';
229
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php';
230
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php';
231
+        require_once WPINV_PLUGIN_DIR . 'widgets/subscriptions.php';
232
+        require_once WPINV_PLUGIN_DIR . 'widgets/buy-item.php';
233
+        require_once WPINV_PLUGIN_DIR . 'widgets/getpaid.php';
234
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
235
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
236
+
237
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
238
+            GetPaid_Post_Types_Admin::init();
239
+
240
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
241
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php';
242
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php';
243
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php';
244
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php';
245
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
246
+            // load the user class only on the users.php page
247
+            global $pagenow;
248
+            if ( $pagenow == 'users.php' ) {
249
+                new WPInv_Admin_Users();
250
+            }
251
+        }
252
+
253
+        // Register cli commands
254
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
255
+            require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
256
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
257
+        }
258
+
259
+    }
260
+
261
+    /**
262
+     * Class autoloader
263
+     *
264
+     * @param       string $class_name The name of the class to load.
265
+     * @access      public
266
+     * @since       1.0.19
267
+     * @return      void
268
+     */
269
+    public function autoload( $class_name ) {
270
+
271
+        // Normalize the class name...
272
+        $class_name  = strtolower( $class_name );
273
+
274
+        // ... and make sure it is our class.
275
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
276
+            return;
277
+        }
278
+
279
+        // Next, prepare the file name from the class.
280
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
281
+
282
+        // Base path of the classes.
283
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
284
+
285
+        // And an array of possible locations in order of importance.
286
+        $locations = array(
287
+            "$plugin_path/includes",
288
+            "$plugin_path/includes/data-stores",
289
+            "$plugin_path/includes/gateways",
290
+            "$plugin_path/includes/payments",
291
+            "$plugin_path/includes/geolocation",
292
+            "$plugin_path/includes/reports",
293
+            "$plugin_path/includes/api",
294
+            "$plugin_path/includes/admin",
295
+            "$plugin_path/includes/admin/meta-boxes",
296
+        );
297
+
298
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
299
+
300
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
301
+                include trailingslashit( $location ) . $file_name;
302
+                break;
303
+            }
304 304
 }
305 305
 
306
-	}
307
-
308
-	/**
309
-	 * Inits hooks etc.
310
-	 */
311
-	public function init() {
312
-
313
-		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
315
-
316
-		// Maybe upgrade.
317
-		$this->maybe_upgrade_database();
318
-
319
-		// Load default gateways.
320
-		$gateways = apply_filters(
321
-			'getpaid_default_gateways',
322
-			array(
323
-				'manual'        => 'GetPaid_Manual_Gateway',
324
-				'paypal'        => 'GetPaid_Paypal_Gateway',
325
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
326
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
327
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
328
-			)
329
-		);
330
-
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
333
-		}
334
-
335
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
336
-			GetPaid_Installer::rename_gateways_label();
337
-			update_option( 'wpinv_renamed_gateways', 'yes' );
338
-		}
339
-
340
-		// Fires after getpaid inits.
341
-		do_action( 'getpaid_init', $this );
342
-
343
-	}
344
-
345
-	/**
346
-	 * Checks if this is an IPN request and processes it.
347
-	 */
348
-	public function maybe_process_ipn() {
349
-
350
-		// Ensure that this is an IPN request.
351
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
352
-			return;
353
-		}
354
-
355
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
356
-
357
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
358
-		do_action( "wpinv_verify_{$gateway}_ipn" );
359
-		exit;
360
-
361
-	}
362
-
363
-	public function enqueue_scripts() {
364
-
365
-		// Fires before adding scripts.
366
-		do_action( 'getpaid_enqueue_scripts' );
367
-
368
-		$localize                         = array();
369
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
370
-		$localize['thousands']            = wpinv_thousands_separator();
371
-		$localize['decimals']             = wpinv_decimal_separator();
372
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
373
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
374
-		$localize['UseTaxes']             = wpinv_use_taxes();
375
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
377
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
378
-
379
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
380
-
381
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
382
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true );
383
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
384
-	}
385
-
386
-	public function wpinv_actions() {
387
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
388
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
389
-		}
390
-
391
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
392
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
393
-		}
394
-	}
395
-
396
-	/**
306
+    }
307
+
308
+    /**
309
+     * Inits hooks etc.
310
+     */
311
+    public function init() {
312
+
313
+        // Fires before getpaid inits.
314
+        do_action( 'before_getpaid_init', $this );
315
+
316
+        // Maybe upgrade.
317
+        $this->maybe_upgrade_database();
318
+
319
+        // Load default gateways.
320
+        $gateways = apply_filters(
321
+            'getpaid_default_gateways',
322
+            array(
323
+                'manual'        => 'GetPaid_Manual_Gateway',
324
+                'paypal'        => 'GetPaid_Paypal_Gateway',
325
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
326
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
327
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
328
+            )
329
+        );
330
+
331
+        foreach ( $gateways as $id => $class ) {
332
+            $this->gateways[ $id ] = new $class();
333
+        }
334
+
335
+        if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
336
+            GetPaid_Installer::rename_gateways_label();
337
+            update_option( 'wpinv_renamed_gateways', 'yes' );
338
+        }
339
+
340
+        // Fires after getpaid inits.
341
+        do_action( 'getpaid_init', $this );
342
+
343
+    }
344
+
345
+    /**
346
+     * Checks if this is an IPN request and processes it.
347
+     */
348
+    public function maybe_process_ipn() {
349
+
350
+        // Ensure that this is an IPN request.
351
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
352
+            return;
353
+        }
354
+
355
+        $gateway = sanitize_text_field( $_GET['wpi-gateway'] );
356
+
357
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
358
+        do_action( "wpinv_verify_{$gateway}_ipn" );
359
+        exit;
360
+
361
+    }
362
+
363
+    public function enqueue_scripts() {
364
+
365
+        // Fires before adding scripts.
366
+        do_action( 'getpaid_enqueue_scripts' );
367
+
368
+        $localize                         = array();
369
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
370
+        $localize['thousands']            = wpinv_thousands_separator();
371
+        $localize['decimals']             = wpinv_decimal_separator();
372
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
373
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
374
+        $localize['UseTaxes']             = wpinv_use_taxes();
375
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
+        $localize['loading']              = __( 'Loading...', 'invoicing' );
377
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
378
+
379
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
380
+
381
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
382
+        wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true );
383
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
384
+    }
385
+
386
+    public function wpinv_actions() {
387
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
388
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
389
+        }
390
+
391
+        if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
392
+            include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
393
+        }
394
+    }
395
+
396
+    /**
397 397
      * Fires an action after verifying that a user can fire them.
398
-	 *
399
-	 * Note: If the action is on an invoice, subscription etc, esure that the
400
-	 * current user owns the invoice/subscription.
398
+     *
399
+     * Note: If the action is on an invoice, subscription etc, esure that the
400
+     * current user owns the invoice/subscription.
401 401
      */
402 402
     public function maybe_do_authenticated_action() {
403 403
 
404
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
404
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
405
+
406
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
407
+            $data = wp_unslash( $_REQUEST );
408
+            if ( is_user_logged_in() ) {
409
+                do_action( "getpaid_authenticated_action_$key", $data );
410
+            }
411
+
412
+            do_action( "getpaid_unauthenticated_action_$key", $data );
413
+
414
+        }
405 415
 
406
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
407
-			$data = wp_unslash( $_REQUEST );
408
-			if ( is_user_logged_in() ) {
409
-				do_action( "getpaid_authenticated_action_$key", $data );
410
-			}
416
+    }
411 417
 
412
-			do_action( "getpaid_unauthenticated_action_$key", $data );
418
+    public function pre_get_posts( $wp_query ) {
413 419
 
414
-		}
420
+        if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
421
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
422
+        }
415 423
 
424
+        return $wp_query;
416 425
     }
417 426
 
418
-	public function pre_get_posts( $wp_query ) {
419
-
420
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
421
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
422
-		}
423
-
424
-		return $wp_query;
425
-	}
426
-
427
-	/**
428
-	 * Register widgets
429
-	 *
430
-	 */
431
-	public function register_widgets() {
432
-		global $pagenow;
433
-
434
-		// Currently, UX Builder does not work particulaly well with SuperDuper.
435
-		// So we disable our widgets when editing a page with UX Builder.
436
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
437
-			return;
438
-		}
439
-
440
-		$block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
441
-
442
-		if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
443
-			// don't initiate in these conditions.
444
-		} else {
445
-
446
-			// Only load allowed widgets.
447
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
448
-			$widgets = apply_filters(
449
-				'getpaid_widget_classes',
450
-				array(
451
-					'WPInv_Checkout_Widget',
452
-					'WPInv_History_Widget',
453
-					'WPInv_Receipt_Widget',
454
-					'WPInv_Subscriptions_Widget',
455
-					'WPInv_Buy_Item_Widget',
456
-					'WPInv_Messages_Widget',
457
-					'WPInv_GetPaid_Widget',
458
-					'WPInv_Invoice_Widget',
459
-				)
460
-			);
461
-
462
-			// For each widget...
463
-			foreach ( $widgets as $widget ) {
464
-
465
-				// Abort early if it is excluded for this page.
466
-				if ( in_array( $widget, $exclude ) ) {
467
-					continue;
468
-				}
469
-
470
-				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
471
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
472
-					register_widget( $widget );
473
-				} else {
474
-					new $widget();
475
-				}
427
+    /**
428
+     * Register widgets
429
+     *
430
+     */
431
+    public function register_widgets() {
432
+        global $pagenow;
433
+
434
+        // Currently, UX Builder does not work particulaly well with SuperDuper.
435
+        // So we disable our widgets when editing a page with UX Builder.
436
+        if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
437
+            return;
438
+        }
439
+
440
+        $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
441
+
442
+        if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
443
+            // don't initiate in these conditions.
444
+        } else {
445
+
446
+            // Only load allowed widgets.
447
+            $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
448
+            $widgets = apply_filters(
449
+                'getpaid_widget_classes',
450
+                array(
451
+                    'WPInv_Checkout_Widget',
452
+                    'WPInv_History_Widget',
453
+                    'WPInv_Receipt_Widget',
454
+                    'WPInv_Subscriptions_Widget',
455
+                    'WPInv_Buy_Item_Widget',
456
+                    'WPInv_Messages_Widget',
457
+                    'WPInv_GetPaid_Widget',
458
+                    'WPInv_Invoice_Widget',
459
+                )
460
+            );
461
+
462
+            // For each widget...
463
+            foreach ( $widgets as $widget ) {
464
+
465
+                // Abort early if it is excluded for this page.
466
+                if ( in_array( $widget, $exclude ) ) {
467
+                    continue;
468
+                }
469
+
470
+                // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
471
+                if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
472
+                    register_widget( $widget );
473
+                } else {
474
+                    new $widget();
475
+                }
476 476
 }
477 477
 }
478 478
 
479
-	}
479
+    }
480 480
 
481
-	/**
482
-	 * Upgrades the database.
483
-	 *
484
-	 * @since 2.0.2
485
-	 */
486
-	public function maybe_upgrade_database() {
481
+    /**
482
+     * Upgrades the database.
483
+     *
484
+     * @since 2.0.2
485
+     */
486
+    public function maybe_upgrade_database() {
487 487
 
488
-		$wpi_version = get_option( 'wpinv_version', 0 );
488
+        $wpi_version = get_option( 'wpinv_version', 0 );
489 489
 
490
-		if ( $wpi_version == WPINV_VERSION ) {
491
-			return;
492
-		}
490
+        if ( $wpi_version == WPINV_VERSION ) {
491
+            return;
492
+        }
493 493
 
494
-		$installer = new GetPaid_Installer();
494
+        $installer = new GetPaid_Installer();
495 495
 
496
-		if ( empty( $wpi_version ) ) {
497
-			return $installer->upgrade_db( 0 );
498
-		}
496
+        if ( empty( $wpi_version ) ) {
497
+            return $installer->upgrade_db( 0 );
498
+        }
499 499
 
500
-		$upgrades  = array(
501
-			'0.0.5' => '004',
502
-			'1.0.3' => '102',
503
-			'2.0.0' => '118',
504
-			'2.0.8' => '207',
505
-		);
500
+        $upgrades  = array(
501
+            '0.0.5' => '004',
502
+            '1.0.3' => '102',
503
+            '2.0.0' => '118',
504
+            '2.0.8' => '207',
505
+        );
506 506
 
507
-		foreach ( $upgrades as $key => $method ) {
507
+        foreach ( $upgrades as $key => $method ) {
508 508
 
509
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
510
-				return $installer->upgrade_db( $method );
511
-			}
509
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
510
+                return $installer->upgrade_db( $method );
511
+            }
512 512
 }
513 513
 
514
-	}
515
-
516
-	/**
517
-	 * Flushes the permalinks if needed.
518
-	 *
519
-	 * @since 2.0.8
520
-	 */
521
-	public function maybe_flush_permalinks() {
522
-
523
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
524
-
525
-		if ( ! empty( $flush ) ) {
526
-			flush_rewrite_rules();
527
-			delete_option( 'wpinv_flush_permalinks' );
528
-		}
529
-
530
-	}
531
-
532
-	/**
533
-	 * Remove our pages from yoast sitemaps.
534
-	 *
535
-	 * @since 1.0.19
536
-	 * @param int[] $excluded_posts_ids
537
-	 */
538
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
539
-
540
-		// Ensure that we have an array.
541
-		if ( ! is_array( $excluded_posts_ids ) ) {
542
-			$excluded_posts_ids = array();
543
-		}
544
-
545
-		// Prepare our pages.
546
-		$our_pages = array();
547
-
548
-		// Checkout page.
549
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
550
-
551
-		// Success page.
552
-		$our_pages[] = wpinv_get_option( 'success_page', false );
553
-
554
-		// Failure page.
555
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
556
-
557
-		// History page.
558
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
559
-
560
-		// Subscriptions page.
561
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
562
-
563
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
564
-
565
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
566
-		return array_unique( $excluded_posts_ids );
567
-
568
-	}
569
-
570
-	/**
571
-	 * Remove our pages from yoast sitemaps.
572
-	 *
573
-	 * @since 1.0.19
574
-	 * @param string[] $post_types
575
-	 */
576
-	public function exclude_invoicing_post_types( $post_types ) {
577
-
578
-		// Ensure that we have an array.
579
-		if ( ! is_array( $post_types ) ) {
580
-			$post_types = array();
581
-		}
582
-
583
-		// Remove our post types.
584
-		return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
585
-	}
586
-
587
-	/**
588
-	 * Displays additional footer code.
589
-	 *
590
-	 * @since 2.0.0
591
-	 */
592
-	public function wp_footer() {
593
-		wpinv_get_template( 'frontend-footer.php' );
594
-	}
595
-
596
-	/**
597
-	 * Displays additional header code.
598
-	 *
599
-	 * @since 2.0.0
600
-	 */
601
-	public function wp_head() {
602
-		wpinv_get_template( 'frontend-head.php' );
603
-	}
604
-
605
-	/**
606
-	 * Custom query vars.
607
-	 *
608
-	 */
609
-	public function custom_query_vars( $vars ) {
514
+    }
515
+
516
+    /**
517
+     * Flushes the permalinks if needed.
518
+     *
519
+     * @since 2.0.8
520
+     */
521
+    public function maybe_flush_permalinks() {
522
+
523
+        $flush = get_option( 'wpinv_flush_permalinks', 0 );
524
+
525
+        if ( ! empty( $flush ) ) {
526
+            flush_rewrite_rules();
527
+            delete_option( 'wpinv_flush_permalinks' );
528
+        }
529
+
530
+    }
531
+
532
+    /**
533
+     * Remove our pages from yoast sitemaps.
534
+     *
535
+     * @since 1.0.19
536
+     * @param int[] $excluded_posts_ids
537
+     */
538
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
539
+
540
+        // Ensure that we have an array.
541
+        if ( ! is_array( $excluded_posts_ids ) ) {
542
+            $excluded_posts_ids = array();
543
+        }
544
+
545
+        // Prepare our pages.
546
+        $our_pages = array();
547
+
548
+        // Checkout page.
549
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
550
+
551
+        // Success page.
552
+        $our_pages[] = wpinv_get_option( 'success_page', false );
553
+
554
+        // Failure page.
555
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
556
+
557
+        // History page.
558
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
559
+
560
+        // Subscriptions page.
561
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
562
+
563
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
564
+
565
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
566
+        return array_unique( $excluded_posts_ids );
567
+
568
+    }
569
+
570
+    /**
571
+     * Remove our pages from yoast sitemaps.
572
+     *
573
+     * @since 1.0.19
574
+     * @param string[] $post_types
575
+     */
576
+    public function exclude_invoicing_post_types( $post_types ) {
577
+
578
+        // Ensure that we have an array.
579
+        if ( ! is_array( $post_types ) ) {
580
+            $post_types = array();
581
+        }
582
+
583
+        // Remove our post types.
584
+        return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
585
+    }
586
+
587
+    /**
588
+     * Displays additional footer code.
589
+     *
590
+     * @since 2.0.0
591
+     */
592
+    public function wp_footer() {
593
+        wpinv_get_template( 'frontend-footer.php' );
594
+    }
595
+
596
+    /**
597
+     * Displays additional header code.
598
+     *
599
+     * @since 2.0.0
600
+     */
601
+    public function wp_head() {
602
+        wpinv_get_template( 'frontend-head.php' );
603
+    }
604
+
605
+    /**
606
+     * Custom query vars.
607
+     *
608
+     */
609
+    public function custom_query_vars( $vars ) {
610 610
         $vars[] = 'getpaid-ipn';
611 611
         return $vars;
612
-	}
612
+    }
613 613
 
614
-	/**
615
-	 * Add rewrite tags and rules.
616
-	 *
617
-	 */
618
-	public function add_rewrite_rule() {
614
+    /**
615
+     * Add rewrite tags and rules.
616
+     *
617
+     */
618
+    public function add_rewrite_rule() {
619 619
         $tag = 'getpaid-ipn';
620 620
         add_rewrite_tag( "%$tag%", '([^&]+)' );
621 621
         add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
622
-	}
622
+    }
623 623
 
624
-	/**
625
-	 * Processes non-query string ipns.
626
-	 *
627
-	 */
628
-	public function maybe_process_new_ipn( $query ) {
624
+    /**
625
+     * Processes non-query string ipns.
626
+     *
627
+     */
628
+    public function maybe_process_new_ipn( $query ) {
629 629
 
630 630
         if ( is_admin() || ! $query->is_main_query() ) {
631 631
             return;
632 632
         }
633 633
 
634
-		$gateway = get_query_var( 'getpaid-ipn' );
634
+        $gateway = get_query_var( 'getpaid-ipn' );
635 635
 
636 636
         if ( ! empty( $gateway ) ) {
637 637
 
638
-			$gateway = sanitize_text_field( $gateway );
639
-			nocache_headers();
640
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
641
-			do_action( "wpinv_verify_{$gateway}_ipn" );
642
-			exit;
638
+            $gateway = sanitize_text_field( $gateway );
639
+            nocache_headers();
640
+            do_action( 'wpinv_verify_payment_ipn', $gateway );
641
+            do_action( "wpinv_verify_{$gateway}_ipn" );
642
+            exit;
643 643
 
644 644
         }
645 645
 
646
-	}
646
+    }
647 647
 
648 648
 }
Please login to merge, or discard this patch.
includes/data/currency-symbols.php 1 patch
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -11,166 +11,166 @@
 block discarded – undo
11 11
 defined( 'ABSPATH' ) || exit;
12 12
 
13 13
 return array(
14
-	'AED' => '&#x62f;.&#x625;',
15
-	'AFN' => '&#x60b;',
16
-	'ALL' => 'L',
17
-	'AMD' => 'AMD',
18
-	'ANG' => '&fnof;',
19
-	'AOA' => 'Kz',
20
-	'ARS' => '&#36;',
21
-	'AUD' => '&#36;',
22
-	'AWG' => '&fnof;',
23
-	'AZN' => 'AZN',
24
-	'BAM' => 'KM',
25
-	'BBD' => '&#36;',
26
-	'BDT' => '&#2547;',
27
-	'BGN' => '&#1083;&#1074;.',
28
-	'BHD' => '.&#x62f;.&#x628;',
29
-	'BIF' => 'Fr',
30
-	'BMD' => '&#36;',
31
-	'BND' => '&#36;',
32
-	'BOB' => 'Bs.',
33
-	'BRL' => '&#82;&#36;',
34
-	'BSD' => '&#36;',
35
-	'BTC' => '&#3647;',
36
-	'BTN' => 'Nu.',
37
-	'BWP' => 'P',
38
-	'BYN' => 'Br',
39
-	'BZD' => '&#36;',
40
-	'CAD' => '&#36;',
41
-	'CDF' => 'Fr',
42
-	'CHF' => '&#67;&#72;&#70;',
43
-	'CLP' => '&#36;',
44
-	'CNY' => '&yen;',
45
-	'COP' => '&#36;',
46
-	'CRC' => '&#x20a1;',
47
-	'CUC' => '&#36;',
48
-	'CUP' => '&#36;',
49
-	'CVE' => '&#36;',
50
-	'CZK' => '&#75;&#269;',
51
-	'DJF' => 'Fr',
52
-	'DKK' => 'DKK',
53
-	'DOP' => 'RD&#36;',
54
-	'DZD' => '&#x62f;.&#x62c;',
55
-	'EGP' => 'EGP',
56
-	'ERN' => 'Nfk',
57
-	'ETB' => 'Br',
58
-	'EUR' => '&euro;',
59
-	'FJD' => '&#36;',
60
-	'FKP' => '&pound;',
61
-	'GBP' => '&pound;',
62
-	'GEL' => '&#x10da;',
63
-	'GGP' => '&pound;',
64
-	'GHS' => '&#x20b5;',
65
-	'GIP' => '&pound;',
66
-	'GMD' => 'D',
67
-	'GNF' => 'Fr',
68
-	'GTQ' => 'Q',
69
-	'GYD' => '&#36;',
70
-	'HKD' => '&#36;',
71
-	'HNL' => 'L',
72
-	'HRK' => 'Kn',
73
-	'HTG' => 'G',
74
-	'HUF' => '&#70;&#116;',
75
-	'IDR' => 'Rp',
76
-	'ILS' => '&#8362;',
77
-	'IMP' => '&pound;',
78
-	'INR' => '&#8377;',
79
-	'IQD' => '&#x639;.&#x62f;',
80
-	'IRR' => '&#xfdfc;',
81
-	'IRT' => '&#x062A;&#x0648;&#x0645;&#x0627;&#x0646;',
82
-	'ISK' => 'kr.',
83
-	'JEP' => '&pound;',
84
-	'JMD' => '&#36;',
85
-	'JOD' => '&#x62f;.&#x627;',
86
-	'JPY' => '&yen;',
87
-	'KES' => 'KSh',
88
-	'KGS' => '&#x441;&#x43e;&#x43c;',
89
-	'KHR' => '&#x17db;',
90
-	'KMF' => 'Fr',
91
-	'KPW' => '&#x20a9;',
92
-	'KRW' => '&#8361;',
93
-	'KWD' => '&#x62f;.&#x643;',
94
-	'KYD' => '&#36;',
95
-	'KZT' => 'KZT',
96
-	'LAK' => '&#8365;',
97
-	'LBP' => '&#x644;.&#x644;',
98
-	'LKR' => '&#xdbb;&#xdd4;',
99
-	'LRD' => '&#36;',
100
-	'LSL' => 'L',
101
-	'LYD' => '&#x644;.&#x62f;',
102
-	'MAD' => '&#x62f;.&#x645;.',
103
-	'MDL' => 'MDL',
104
-	'MGA' => 'Ar',
105
-	'MKD' => '&#x434;&#x435;&#x43d;',
106
-	'MMK' => 'Ks',
107
-	'MNT' => '&#x20ae;',
108
-	'MOP' => 'P',
109
-	'MRO' => 'UM',
110
-	'MUR' => '&#x20a8;',
111
-	'MVR' => '.&#x783;',
112
-	'MWK' => 'MK',
113
-	'MXN' => '&#36;',
114
-	'MYR' => '&#82;&#77;',
115
-	'MZN' => 'MT',
116
-	'NAD' => 'N&#36;',
117
-	'NGN' => '&#8358;',
118
-	'NIO' => 'C&#36;',
119
-	'NOK' => '&#107;&#114;',
120
-	'NPR' => '&#8360;',
121
-	'NZD' => '&#36;',
122
-	'OMR' => '&#x631;.&#x639;.',
123
-	'PAB' => 'B/.',
124
-	'PEN' => 'S/.',
125
-	'PGK' => 'K',
126
-	'PHP' => '&#8369;',
127
-	'PKR' => '&#8360;',
128
-	'PLN' => '&#122;&#322;',
129
-	'PRB' => '&#x440;.',
130
-	'PYG' => '&#8370;',
131
-	'QAR' => '&#x631;.&#x642;',
132
-	'RMB' => '&yen;',
133
-	'RON' => 'lei',
134
-	'RSD' => '&#x434;&#x438;&#x43d;.',
135
-	'RUB' => '&#8381;',
136
-	'RWF' => 'Fr',
137
-	'SAR' => '&#x631;.&#x633;',
138
-	'SBD' => '&#36;',
139
-	'SCR' => '&#x20a8;',
140
-	'SDG' => '&#x62c;.&#x633;.',
141
-	'SEK' => '&#107;&#114;',
142
-	'SGD' => '&#36;',
143
-	'SHP' => '&pound;',
144
-	'SLL' => 'Le',
145
-	'SOS' => 'Sh',
146
-	'SRD' => '&#36;',
147
-	'SSP' => '&pound;',
148
-	'STD' => 'Db',
149
-	'SYP' => '&#x644;.&#x633;',
150
-	'SZL' => 'L',
151
-	'THB' => '&#3647;',
152
-	'TJS' => '&#x405;&#x41c;',
153
-	'TMT' => 'm',
154
-	'TND' => '&#x62f;.&#x62a;',
155
-	'TOP' => 'T&#36;',
156
-	'TRY' => '&#8378;',
157
-	'TTD' => '&#36;',
158
-	'TWD' => '&#78;&#84;&#36;',
159
-	'TZS' => 'Sh',
160
-	'UAH' => '&#8372;',
161
-	'UGX' => 'UGX',
162
-	'USD' => '&#36;',
163
-	'UYU' => '&#36;',
164
-	'UZS' => 'UZS',
165
-	'VEF' => 'Bs.',
166
-	'VND' => '&#8363;',
167
-	'VUV' => 'Vt',
168
-	'WST' => 'T',
169
-	'XAF' => 'Fr',
170
-	'XCD' => '&#36;',
171
-	'XOF' => 'Fr',
172
-	'XPF' => 'Fr',
173
-	'YER' => '&#xfdfc;',
174
-	'ZAR' => '&#82;',
175
-	'ZMW' => 'ZK',
14
+    'AED' => '&#x62f;.&#x625;',
15
+    'AFN' => '&#x60b;',
16
+    'ALL' => 'L',
17
+    'AMD' => 'AMD',
18
+    'ANG' => '&fnof;',
19
+    'AOA' => 'Kz',
20
+    'ARS' => '&#36;',
21
+    'AUD' => '&#36;',
22
+    'AWG' => '&fnof;',
23
+    'AZN' => 'AZN',
24
+    'BAM' => 'KM',
25
+    'BBD' => '&#36;',
26
+    'BDT' => '&#2547;',
27
+    'BGN' => '&#1083;&#1074;.',
28
+    'BHD' => '.&#x62f;.&#x628;',
29
+    'BIF' => 'Fr',
30
+    'BMD' => '&#36;',
31
+    'BND' => '&#36;',
32
+    'BOB' => 'Bs.',
33
+    'BRL' => '&#82;&#36;',
34
+    'BSD' => '&#36;',
35
+    'BTC' => '&#3647;',
36
+    'BTN' => 'Nu.',
37
+    'BWP' => 'P',
38
+    'BYN' => 'Br',
39
+    'BZD' => '&#36;',
40
+    'CAD' => '&#36;',
41
+    'CDF' => 'Fr',
42
+    'CHF' => '&#67;&#72;&#70;',
43
+    'CLP' => '&#36;',
44
+    'CNY' => '&yen;',
45
+    'COP' => '&#36;',
46
+    'CRC' => '&#x20a1;',
47
+    'CUC' => '&#36;',
48
+    'CUP' => '&#36;',
49
+    'CVE' => '&#36;',
50
+    'CZK' => '&#75;&#269;',
51
+    'DJF' => 'Fr',
52
+    'DKK' => 'DKK',
53
+    'DOP' => 'RD&#36;',
54
+    'DZD' => '&#x62f;.&#x62c;',
55
+    'EGP' => 'EGP',
56
+    'ERN' => 'Nfk',
57
+    'ETB' => 'Br',
58
+    'EUR' => '&euro;',
59
+    'FJD' => '&#36;',
60
+    'FKP' => '&pound;',
61
+    'GBP' => '&pound;',
62
+    'GEL' => '&#x10da;',
63
+    'GGP' => '&pound;',
64
+    'GHS' => '&#x20b5;',
65
+    'GIP' => '&pound;',
66
+    'GMD' => 'D',
67
+    'GNF' => 'Fr',
68
+    'GTQ' => 'Q',
69
+    'GYD' => '&#36;',
70
+    'HKD' => '&#36;',
71
+    'HNL' => 'L',
72
+    'HRK' => 'Kn',
73
+    'HTG' => 'G',
74
+    'HUF' => '&#70;&#116;',
75
+    'IDR' => 'Rp',
76
+    'ILS' => '&#8362;',
77
+    'IMP' => '&pound;',
78
+    'INR' => '&#8377;',
79
+    'IQD' => '&#x639;.&#x62f;',
80
+    'IRR' => '&#xfdfc;',
81
+    'IRT' => '&#x062A;&#x0648;&#x0645;&#x0627;&#x0646;',
82
+    'ISK' => 'kr.',
83
+    'JEP' => '&pound;',
84
+    'JMD' => '&#36;',
85
+    'JOD' => '&#x62f;.&#x627;',
86
+    'JPY' => '&yen;',
87
+    'KES' => 'KSh',
88
+    'KGS' => '&#x441;&#x43e;&#x43c;',
89
+    'KHR' => '&#x17db;',
90
+    'KMF' => 'Fr',
91
+    'KPW' => '&#x20a9;',
92
+    'KRW' => '&#8361;',
93
+    'KWD' => '&#x62f;.&#x643;',
94
+    'KYD' => '&#36;',
95
+    'KZT' => 'KZT',
96
+    'LAK' => '&#8365;',
97
+    'LBP' => '&#x644;.&#x644;',
98
+    'LKR' => '&#xdbb;&#xdd4;',
99
+    'LRD' => '&#36;',
100
+    'LSL' => 'L',
101
+    'LYD' => '&#x644;.&#x62f;',
102
+    'MAD' => '&#x62f;.&#x645;.',
103
+    'MDL' => 'MDL',
104
+    'MGA' => 'Ar',
105
+    'MKD' => '&#x434;&#x435;&#x43d;',
106
+    'MMK' => 'Ks',
107
+    'MNT' => '&#x20ae;',
108
+    'MOP' => 'P',
109
+    'MRO' => 'UM',
110
+    'MUR' => '&#x20a8;',
111
+    'MVR' => '.&#x783;',
112
+    'MWK' => 'MK',
113
+    'MXN' => '&#36;',
114
+    'MYR' => '&#82;&#77;',
115
+    'MZN' => 'MT',
116
+    'NAD' => 'N&#36;',
117
+    'NGN' => '&#8358;',
118
+    'NIO' => 'C&#36;',
119
+    'NOK' => '&#107;&#114;',
120
+    'NPR' => '&#8360;',
121
+    'NZD' => '&#36;',
122
+    'OMR' => '&#x631;.&#x639;.',
123
+    'PAB' => 'B/.',
124
+    'PEN' => 'S/.',
125
+    'PGK' => 'K',
126
+    'PHP' => '&#8369;',
127
+    'PKR' => '&#8360;',
128
+    'PLN' => '&#122;&#322;',
129
+    'PRB' => '&#x440;.',
130
+    'PYG' => '&#8370;',
131
+    'QAR' => '&#x631;.&#x642;',
132
+    'RMB' => '&yen;',
133
+    'RON' => 'lei',
134
+    'RSD' => '&#x434;&#x438;&#x43d;.',
135
+    'RUB' => '&#8381;',
136
+    'RWF' => 'Fr',
137
+    'SAR' => '&#x631;.&#x633;',
138
+    'SBD' => '&#36;',
139
+    'SCR' => '&#x20a8;',
140
+    'SDG' => '&#x62c;.&#x633;.',
141
+    'SEK' => '&#107;&#114;',
142
+    'SGD' => '&#36;',
143
+    'SHP' => '&pound;',
144
+    'SLL' => 'Le',
145
+    'SOS' => 'Sh',
146
+    'SRD' => '&#36;',
147
+    'SSP' => '&pound;',
148
+    'STD' => 'Db',
149
+    'SYP' => '&#x644;.&#x633;',
150
+    'SZL' => 'L',
151
+    'THB' => '&#3647;',
152
+    'TJS' => '&#x405;&#x41c;',
153
+    'TMT' => 'm',
154
+    'TND' => '&#x62f;.&#x62a;',
155
+    'TOP' => 'T&#36;',
156
+    'TRY' => '&#8378;',
157
+    'TTD' => '&#36;',
158
+    'TWD' => '&#78;&#84;&#36;',
159
+    'TZS' => 'Sh',
160
+    'UAH' => '&#8372;',
161
+    'UGX' => 'UGX',
162
+    'USD' => '&#36;',
163
+    'UYU' => '&#36;',
164
+    'UZS' => 'UZS',
165
+    'VEF' => 'Bs.',
166
+    'VND' => '&#8363;',
167
+    'VUV' => 'Vt',
168
+    'WST' => 'T',
169
+    'XAF' => 'Fr',
170
+    'XCD' => '&#36;',
171
+    'XOF' => 'Fr',
172
+    'XPF' => 'Fr',
173
+    'YER' => '&#xfdfc;',
174
+    'ZAR' => '&#82;',
175
+    'ZMW' => 'ZK',
176 176
 );
Please login to merge, or discard this patch.
includes/subscription-functions.php 1 patch
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
  */
51 51
 function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) {
52 52
     $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id );
53
-	$matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
53
+    $matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
54 54
     return reset( $matching_group );
55 55
 }
56 56
 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
  */
64 64
 function getpaid_get_subscription( $subscription ) {
65 65
 
66
-	if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
-		$subscription = new WPInv_Subscription( $subscription );
68
-	}
66
+    if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
+        $subscription = new WPInv_Subscription( $subscription );
68
+    }
69 69
 
70
-	return $subscription->exists() ? $subscription : false;
70
+    return $subscription->exists() ? $subscription : false;
71 71
 }
72 72
 
73 73
 /**
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
83 83
 
84
-	// Do not retrieve all fields if we just want the count.
85
-	if ( 'count' == $return ) {
86
-		$args['fields'] = 'id';
87
-		$args['number'] = 1;
88
-	}
84
+    // Do not retrieve all fields if we just want the count.
85
+    if ( 'count' == $return ) {
86
+        $args['fields'] = 'id';
87
+        $args['number'] = 1;
88
+    }
89 89
 
90
-	// Do not count all matches if we just want the results.
91
-	if ( 'results' == $return ) {
92
-		$args['count_total'] = false;
93
-	}
90
+    // Do not count all matches if we just want the results.
91
+    if ( 'results' == $return ) {
92
+        $args['count_total'] = false;
93
+    }
94 94
 
95
-	$query = new GetPaid_Subscriptions_Query( $args );
95
+    $query = new GetPaid_Subscriptions_Query( $args );
96 96
 
97
-	if ( 'results' == $return ) {
98
-		return $query->get_results();
99
-	}
97
+    if ( 'results' == $return ) {
98
+        return $query->get_results();
99
+    }
100 100
 
101
-	if ( 'count' == $return ) {
102
-		return $query->get_total();
103
-	}
101
+    if ( 'count' == $return ) {
102
+        return $query->get_total();
103
+    }
104 104
 
105
-	return $query;
105
+    return $query;
106 106
 }
107 107
 
108 108
 /**
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function getpaid_get_subscription_statuses() {
114 114
 
115
-	return apply_filters(
116
-		'getpaid_get_subscription_statuses',
117
-		array(
118
-			'pending'   => __( 'Pending', 'invoicing' ),
119
-			'trialling' => __( 'Trialing', 'invoicing' ),
120
-			'active'    => __( 'Active', 'invoicing' ),
121
-			'failing'   => __( 'Failing', 'invoicing' ),
122
-			'expired'   => __( 'Expired', 'invoicing' ),
123
-			'completed' => __( 'Complete', 'invoicing' ),
124
-			'cancelled' => __( 'Cancelled', 'invoicing' ),
125
-		)
126
-	);
115
+    return apply_filters(
116
+        'getpaid_get_subscription_statuses',
117
+        array(
118
+            'pending'   => __( 'Pending', 'invoicing' ),
119
+            'trialling' => __( 'Trialing', 'invoicing' ),
120
+            'active'    => __( 'Active', 'invoicing' ),
121
+            'failing'   => __( 'Failing', 'invoicing' ),
122
+            'expired'   => __( 'Expired', 'invoicing' ),
123
+            'completed' => __( 'Complete', 'invoicing' ),
124
+            'cancelled' => __( 'Cancelled', 'invoicing' ),
125
+        )
126
+    );
127 127
 
128 128
 }
129 129
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
  * @return string
134 134
  */
135 135
 function getpaid_get_subscription_status_label( $status ) {
136
-	$statuses = getpaid_get_subscription_statuses();
137
-	return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
136
+    $statuses = getpaid_get_subscription_statuses();
137
+    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
138 138
 }
139 139
 
140 140
 /**
@@ -144,18 +144,18 @@  discard block
 block discarded – undo
144 144
  */
145 145
 function getpaid_get_subscription_status_classes() {
146 146
 
147
-	return apply_filters(
148
-		'getpaid_get_subscription_status_classes',
149
-		array(
150
-			'pending'   => 'badge-dark',
151
-			'trialling' => 'badge-info',
152
-			'active'    => 'badge-success',
153
-			'failing'   => 'badge-warning',
154
-			'expired'   => 'badge-danger',
155
-			'completed' => 'badge-primary',
156
-			'cancelled' => 'badge-secondary',
157
-		)
158
-	);
147
+    return apply_filters(
148
+        'getpaid_get_subscription_status_classes',
149
+        array(
150
+            'pending'   => 'badge-dark',
151
+            'trialling' => 'badge-info',
152
+            'active'    => 'badge-success',
153
+            'failing'   => 'badge-warning',
154
+            'expired'   => 'badge-danger',
155
+            'completed' => 'badge-primary',
156
+            'cancelled' => 'badge-secondary',
157
+        )
158
+    );
159 159
 
160 160
 }
161 161
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
  */
167 167
 function getpaid_get_subscription_status_counts( $args = array() ) {
168 168
 
169
-	$statuses = array_keys( getpaid_get_subscription_statuses() );
170
-	$counts   = array();
169
+    $statuses = array_keys( getpaid_get_subscription_statuses() );
170
+    $counts   = array();
171 171
 
172
-	foreach ( $statuses as $status ) {
173
-		$_args             = wp_parse_args( "status=$status", $args );
174
-		$counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
175
-	}
172
+    foreach ( $statuses as $status ) {
173
+        $_args             = wp_parse_args( "status=$status", $args );
174
+        $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
175
+    }
176 176
 
177
-	return $counts;
177
+    return $counts;
178 178
 
179 179
 }
180 180
 
@@ -185,32 +185,32 @@  discard block
 block discarded – undo
185 185
  */
186 186
 function getpaid_get_subscription_periods() {
187 187
 
188
-	return apply_filters(
189
-		'getpaid_get_subscription_periods',
190
-		array(
188
+    return apply_filters(
189
+        'getpaid_get_subscription_periods',
190
+        array(
191 191
 
192
-			'day'   => array(
193
-				'singular' => __( '%s day', 'invoicing' ),
194
-				'plural'   => __( '%d days', 'invoicing' ),
195
-			),
192
+            'day'   => array(
193
+                'singular' => __( '%s day', 'invoicing' ),
194
+                'plural'   => __( '%d days', 'invoicing' ),
195
+            ),
196 196
 
197
-			'week'  => array(
198
-				'singular' => __( '%s week', 'invoicing' ),
199
-				'plural'   => __( '%d weeks', 'invoicing' ),
200
-			),
197
+            'week'  => array(
198
+                'singular' => __( '%s week', 'invoicing' ),
199
+                'plural'   => __( '%d weeks', 'invoicing' ),
200
+            ),
201 201
 
202
-			'month' => array(
203
-				'singular' => __( '%s month', 'invoicing' ),
204
-				'plural'   => __( '%d months', 'invoicing' ),
205
-			),
202
+            'month' => array(
203
+                'singular' => __( '%s month', 'invoicing' ),
204
+                'plural'   => __( '%d months', 'invoicing' ),
205
+            ),
206 206
 
207
-			'year'  => array(
208
-				'singular' => __( '%s year', 'invoicing' ),
209
-				'plural'   => __( '%d years', 'invoicing' ),
210
-			),
207
+            'year'  => array(
208
+                'singular' => __( '%s year', 'invoicing' ),
209
+                'plural'   => __( '%d years', 'invoicing' ),
210
+            ),
211 211
 
212
-		)
213
-	);
212
+        )
213
+    );
214 214
 
215 215
 }
216 216
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  * @return int
222 222
  */
223 223
 function getpaid_get_subscription_trial_period_interval( $trial_period ) {
224
-	return (int) preg_replace( '/[^0-9]/', '', $trial_period );
224
+    return (int) preg_replace( '/[^0-9]/', '', $trial_period );
225 225
 }
226 226
 
227 227
 /**
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  * @return string
232 232
  */
233 233
 function getpaid_get_subscription_trial_period_period( $trial_period ) {
234
-	return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
234
+    return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
235 235
 }
236 236
 
237 237
 /**
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
  * @return string
243 243
  */
244 244
 function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) {
245
-	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
-	return strtolower( sanitize_text_field( $label ) );
245
+    $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
+    return strtolower( sanitize_text_field( $label ) );
247 247
 }
248 248
 
249 249
 /**
@@ -254,22 +254,22 @@  discard block
 block discarded – undo
254 254
  */
255 255
 function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) {
256 256
 
257
-	$periods = getpaid_get_subscription_periods();
258
-	$period  = strtolower( $period );
257
+    $periods = getpaid_get_subscription_periods();
258
+    $period  = strtolower( $period );
259 259
 
260
-	if ( isset( $periods[ $period ] ) ) {
261
-		return sprintf( $periods[ $period ]['singular'], $singular_prefix );
262
-	}
260
+    if ( isset( $periods[ $period ] ) ) {
261
+        return sprintf( $periods[ $period ]['singular'], $singular_prefix );
262
+    }
263 263
 
264
-	// Backwards compatibility.
265
-	foreach ( $periods as $key => $data ) {
266
-		if ( strpos( $key, $period ) === 0 ) {
267
-			return sprintf( $data['singular'], $singular_prefix );
268
-		}
269
-	}
264
+    // Backwards compatibility.
265
+    foreach ( $periods as $key => $data ) {
266
+        if ( strpos( $key, $period ) === 0 ) {
267
+            return sprintf( $data['singular'], $singular_prefix );
268
+        }
269
+    }
270 270
 
271
-	// Invalid string.
272
-	return '';
271
+    // Invalid string.
272
+    return '';
273 273
 }
274 274
 
275 275
 /**
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
  */
282 282
 function getpaid_get_plural_subscription_period_label( $period, $interval ) {
283 283
 
284
-	$periods = getpaid_get_subscription_periods();
285
-	$period  = strtolower( $period );
284
+    $periods = getpaid_get_subscription_periods();
285
+    $period  = strtolower( $period );
286 286
 
287
-	if ( isset( $periods[ $period ] ) ) {
288
-		return sprintf( $periods[ $period ]['plural'], $interval );
289
-	}
287
+    if ( isset( $periods[ $period ] ) ) {
288
+        return sprintf( $periods[ $period ]['plural'], $interval );
289
+    }
290 290
 
291
-	// Backwards compatibility.
292
-	foreach ( $periods as $key => $data ) {
293
-		if ( strpos( $key, $period ) === 0 ) {
294
-			return sprintf( $data['plural'], $interval );
295
-		}
296
-	}
291
+    // Backwards compatibility.
292
+    foreach ( $periods as $key => $data ) {
293
+        if ( strpos( $key, $period ) === 0 ) {
294
+            return sprintf( $data['plural'], $interval );
295
+        }
296
+    }
297 297
 
298
-	// Invalid string.
299
-	return '';
298
+    // Invalid string.
299
+    return '';
300 300
 }
301 301
 
302 302
 /**
@@ -307,92 +307,92 @@  discard block
 block discarded – undo
307 307
  */
308 308
 function getpaid_get_formatted_subscription_amount( $subscription ) {
309 309
 
310
-	$initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
-	$recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
-	$period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
313
-	$bill_times = $subscription->get_bill_times();
314
-	$bill_times_less = $bill_times - 1;
315
-
316
-	if ( ! empty( $bill_times ) ) {
317
-		$bill_times = $subscription->get_frequency() * $bill_times;
318
-		$bill_times_less = getpaid_get_subscription_period_label( $subscription->get_frequency(), $bill_times - $subscription->get_frequency() );
319
-		$bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
320
-	}
321
-
322
-	// Trial periods.
323
-	if ( $subscription->has_trial_period() ) {
324
-
325
-		$trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
-		$trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
327
-
328
-		if ( empty( $bill_times ) ) {
329
-
330
-			return sprintf(
331
-				// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
-				_x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
333
-				$initial,
334
-				getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
335
-				$recurring,
336
-				$period
337
-			);
338
-
339
-		}
340
-
341
-		return sprintf(
342
-			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
-			_x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
344
-			$initial,
345
-			getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
346
-			$recurring,
347
-			$period,
348
-			$bill_times
349
-		);
350
-
351
-	}
352
-
353
-	if ( $initial != $recurring ) {
354
-
355
-		if ( empty( $bill_times ) ) {
356
-
357
-			return sprintf(
358
-				// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
-				_x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
360
-				$initial,
361
-				$recurring,
362
-				$period
363
-			);
364
-
365
-		}
366
-
367
-		return sprintf(
368
-			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
-			_x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
370
-			$initial,
371
-			$recurring,
372
-			$period,
373
-			$bill_times_less
374
-		);
375
-
376
-	}
377
-
378
-	if ( empty( $bill_times ) ) {
379
-
380
-		return sprintf(
381
-			// translators: $1: is the recurring amount, $2: is the recurring period
382
-			_x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
383
-			$initial,
384
-			$period
385
-		);
386
-
387
-	}
388
-
389
-	return sprintf(
390
-		// translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
-		_x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
392
-		$bill_times,
393
-		$initial,
394
-		$period
395
-	);
310
+    $initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
+    $recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
+    $period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
313
+    $bill_times = $subscription->get_bill_times();
314
+    $bill_times_less = $bill_times - 1;
315
+
316
+    if ( ! empty( $bill_times ) ) {
317
+        $bill_times = $subscription->get_frequency() * $bill_times;
318
+        $bill_times_less = getpaid_get_subscription_period_label( $subscription->get_frequency(), $bill_times - $subscription->get_frequency() );
319
+        $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
320
+    }
321
+
322
+    // Trial periods.
323
+    if ( $subscription->has_trial_period() ) {
324
+
325
+        $trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
+        $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
327
+
328
+        if ( empty( $bill_times ) ) {
329
+
330
+            return sprintf(
331
+                // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
+                _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
333
+                $initial,
334
+                getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
335
+                $recurring,
336
+                $period
337
+            );
338
+
339
+        }
340
+
341
+        return sprintf(
342
+            // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
+            _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
344
+            $initial,
345
+            getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
346
+            $recurring,
347
+            $period,
348
+            $bill_times
349
+        );
350
+
351
+    }
352
+
353
+    if ( $initial != $recurring ) {
354
+
355
+        if ( empty( $bill_times ) ) {
356
+
357
+            return sprintf(
358
+                // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
+                _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
360
+                $initial,
361
+                $recurring,
362
+                $period
363
+            );
364
+
365
+        }
366
+
367
+        return sprintf(
368
+            // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
+            _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
370
+            $initial,
371
+            $recurring,
372
+            $period,
373
+            $bill_times_less
374
+        );
375
+
376
+    }
377
+
378
+    if ( empty( $bill_times ) ) {
379
+
380
+        return sprintf(
381
+            // translators: $1: is the recurring amount, $2: is the recurring period
382
+            _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
383
+            $initial,
384
+            $period
385
+        );
386
+
387
+    }
388
+
389
+    return sprintf(
390
+        // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
+        _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
392
+        $bill_times,
393
+        $initial,
394
+        $period
395
+    );
396 396
 
397 397
 }
398 398
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
  * @return WPInv_Subscription|false
404 404
  */
405 405
 function getpaid_get_invoice_subscription( $invoice ) {
406
-	return getpaid_subscriptions()->get_invoice_subscription( $invoice );
406
+    return getpaid_subscriptions()->get_invoice_subscription( $invoice );
407 407
 }
408 408
 
409 409
 /**
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
  * @param WPInv_Invoice $invoice
413 413
  */
414 414
 function getpaid_activate_invoice_subscription( $invoice ) {
415
-	$subscription = getpaid_get_invoice_subscription( $invoice );
416
-	if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
417
-		$subscription->activate();
418
-	}
415
+    $subscription = getpaid_get_invoice_subscription( $invoice );
416
+    if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
417
+        $subscription->activate();
418
+    }
419 419
 }
420 420
 
421 421
 /**
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @return WPInv_Subscriptions
425 425
  */
426 426
 function getpaid_subscriptions() {
427
-	return getpaid()->get( 'subscriptions' );
427
+    return getpaid()->get( 'subscriptions' );
428 428
 }
429 429
 
430 430
 /**
@@ -443,15 +443,15 @@  discard block
 block discarded – undo
443 443
         return false;
444 444
     }
445 445
 
446
-	// Fetch the invoice subscription.
447
-	$subscription = getpaid_get_subscriptions(
448
-		array(
449
-			'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(),
450
-			'number'     => 1,
451
-		)
452
-	);
446
+    // Fetch the invoice subscription.
447
+    $subscription = getpaid_get_subscriptions(
448
+        array(
449
+            'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(),
450
+            'number'     => 1,
451
+        )
452
+    );
453 453
 
454
-	return empty( $subscription ) ? false : $subscription[0];
454
+    return empty( $subscription ) ? false : $subscription[0];
455 455
 
456 456
 }
457 457
 
@@ -468,48 +468,48 @@  discard block
 block discarded – undo
468 468
  */
469 469
 function getpaid_get_recurring_item_key( $cart_item ) {
470 470
 
471
-	$cart_key     = 'renews_';
472
-	$interval     = $cart_item->get_recurring_interval();
473
-	$period       = $cart_item->get_recurring_period( true );
474
-	$length       = $cart_item->get_recurring_limit() * $interval;
475
-	$trial_period = $cart_item->get_trial_period( true );
476
-	$trial_length = $cart_item->get_trial_interval();
477
-
478
-	// First start with the billing interval and period
479
-	switch ( $interval ) {
480
-		case 1:
481
-			if ( 'day' == $period ) {
482
-				$cart_key .= 'daily';
483
-			} else {
484
-				$cart_key .= sprintf( '%sly', $period );
485
-			}
486
-			break;
487
-		case 2:
488
-			$cart_key .= sprintf( 'every_2nd_%s', $period );
489
-			break;
490
-		case 3:
491
-			$cart_key .= sprintf( 'every_3rd_%s', $period );
492
-		    break;
493
-		default:
494
-			$cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
495
-			break;
496
-	}
497
-
498
-	// Maybe add the optional maximum billing periods...
499
-	if ( $length > 0 ) {
500
-		$cart_key .= '_for_';
501
-		$cart_key .= sprintf( '%d_%s', $length, $period );
502
-		if ( $length > 1 ) {
503
-			$cart_key .= 's';
504
-		}
505
-	}
506
-
507
-	// And an optional free trial.
508
-	if ( $cart_item->has_free_trial() ) {
509
-		$cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
510
-	}
511
-
512
-	return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
471
+    $cart_key     = 'renews_';
472
+    $interval     = $cart_item->get_recurring_interval();
473
+    $period       = $cart_item->get_recurring_period( true );
474
+    $length       = $cart_item->get_recurring_limit() * $interval;
475
+    $trial_period = $cart_item->get_trial_period( true );
476
+    $trial_length = $cart_item->get_trial_interval();
477
+
478
+    // First start with the billing interval and period
479
+    switch ( $interval ) {
480
+        case 1:
481
+            if ( 'day' == $period ) {
482
+                $cart_key .= 'daily';
483
+            } else {
484
+                $cart_key .= sprintf( '%sly', $period );
485
+            }
486
+            break;
487
+        case 2:
488
+            $cart_key .= sprintf( 'every_2nd_%s', $period );
489
+            break;
490
+        case 3:
491
+            $cart_key .= sprintf( 'every_3rd_%s', $period );
492
+            break;
493
+        default:
494
+            $cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
495
+            break;
496
+    }
497
+
498
+    // Maybe add the optional maximum billing periods...
499
+    if ( $length > 0 ) {
500
+        $cart_key .= '_for_';
501
+        $cart_key .= sprintf( '%d_%s', $length, $period );
502
+        if ( $length > 1 ) {
503
+            $cart_key .= 's';
504
+        }
505
+    }
506
+
507
+    // And an optional free trial.
508
+    if ( $cart_item->has_free_trial() ) {
509
+        $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
510
+    }
511
+
512
+    return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
513 513
 }
514 514
 
515 515
 /**
@@ -520,16 +520,16 @@  discard block
 block discarded – undo
520 520
  */
521 521
 function getpaid_get_subscription_groups( $invoice ) {
522 522
 
523
-	// Generate subscription groups.
524
-	$subscription_groups = array();
525
-	foreach ( $invoice->get_items() as $item ) {
523
+    // Generate subscription groups.
524
+    $subscription_groups = array();
525
+    foreach ( $invoice->get_items() as $item ) {
526 526
 
527
-		if ( $item->is_recurring() ) {
528
-			$subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
529
-		}
527
+        if ( $item->is_recurring() ) {
528
+            $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
529
+        }
530 530
 }
531 531
 
532
-	return $subscription_groups;
532
+    return $subscription_groups;
533 533
 }
534 534
 
535 535
 /**
@@ -543,56 +543,56 @@  discard block
 block discarded – undo
543 543
  */
544 544
 function getpaid_calculate_subscription_totals( $invoice ) {
545 545
 
546
-	// Generate subscription groups.
547
-	$subscription_groups = getpaid_get_subscription_groups( $invoice );
546
+    // Generate subscription groups.
547
+    $subscription_groups = getpaid_get_subscription_groups( $invoice );
548 548
 
549
-	// Now let's calculate the totals for each group of subscriptions
550
-	$subscription_totals = array();
549
+    // Now let's calculate the totals for each group of subscriptions
550
+    $subscription_totals = array();
551 551
 
552
-	foreach ( $subscription_groups as $subscription_key => $items ) {
552
+    foreach ( $subscription_groups as $subscription_key => $items ) {
553 553
 
554
-		if ( empty( $subscription_totals[ $subscription_key ] ) ) {
554
+        if ( empty( $subscription_totals[ $subscription_key ] ) ) {
555 555
 
556
-			$subscription_totals[ $subscription_key ] = array(
557
-				'initial_total'   => 0,
558
-				'recurring_total' => 0,
559
-				'items'           => array(),
560
-				'trialling'       => false,
561
-			);
556
+            $subscription_totals[ $subscription_key ] = array(
557
+                'initial_total'   => 0,
558
+                'recurring_total' => 0,
559
+                'items'           => array(),
560
+                'trialling'       => false,
561
+            );
562 562
 
563
-		}
563
+        }
564 564
 
565
-		/**
566
-		 * Get the totals of the group.
567
-		 * @var GetPaid_Form_Item $item
568
-		 */
569
-		foreach ( $items as $item ) {
565
+        /**
566
+         * Get the totals of the group.
567
+         * @var GetPaid_Form_Item $item
568
+         */
569
+        foreach ( $items as $item ) {
570 570
 
571
-			$subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
-			$subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
-			$subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
-			$subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
-			$subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
-			$subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
-			$subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
571
+            $subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
+            $subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
+            $subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
+            $subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
+            $subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
+            $subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
+            $subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
578 578
 
579
-			// Calculate the next renewal date.
580
-			$period       = $item->get_recurring_period( true );
581
-			$interval     = $item->get_recurring_interval();
579
+            // Calculate the next renewal date.
580
+            $period       = $item->get_recurring_period( true );
581
+            $interval     = $item->get_recurring_interval();
582 582
 
583
-			// If the subscription item has a trial period...
584
-			if ( $item->has_free_trial() ) {
585
-				$period   = $item->get_trial_period( true );
586
-				$interval = $item->get_trial_interval();
587
-				$subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
588
-			}
583
+            // If the subscription item has a trial period...
584
+            if ( $item->has_free_trial() ) {
585
+                $period   = $item->get_trial_period( true );
586
+                $interval = $item->get_trial_interval();
587
+                $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
588
+            }
589 589
 
590
-			$subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
590
+            $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
591 591
 
592
-		}
592
+        }
593 593
 }
594 594
 
595
-	return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
595
+    return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
596 596
 }
597 597
 
598 598
 /**
@@ -603,16 +603,16 @@  discard block
 block discarded – undo
603 603
  */
604 604
 function getpaid_should_group_subscriptions( $invoice ) {
605 605
 
606
-	$recurring_items = 0;
606
+    $recurring_items = 0;
607 607
 
608
-	foreach ( $invoice->get_items() as $item ) {
608
+    foreach ( $invoice->get_items() as $item ) {
609 609
 
610
-		if ( $item->is_recurring() ) {
611
-			$recurring_items ++;
612
-		}
610
+        if ( $item->is_recurring() ) {
611
+            $recurring_items ++;
612
+        }
613 613
 }
614 614
 
615
-	return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
615
+    return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
616 616
 }
617 617
 
618 618
 /**
@@ -623,39 +623,39 @@  discard block
 block discarded – undo
623 623
  * @return int
624 624
  */
625 625
 function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) {
626
-	global $wpdb;
626
+    global $wpdb;
627 627
 
628
-	$parent_invoice_id = (int) $parent_invoice_id;
628
+    $parent_invoice_id = (int) $parent_invoice_id;
629 629
 
630
-	if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
630
+    if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
631 631
 
632
-		return (int) $wpdb->get_var(
633
-			$wpdb->prepare(
634
-				"SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
635
-				$parent_invoice_id,
636
-				$parent_invoice_id
637
-			)
638
-		);
632
+        return (int) $wpdb->get_var(
633
+            $wpdb->prepare(
634
+                "SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
635
+                $parent_invoice_id,
636
+                $parent_invoice_id
637
+            )
638
+        );
639 639
 
640
-	}
640
+    }
641 641
 
642
-	$invoice_ids = $wpdb->get_col(
643
-		$wpdb->prepare(
644
-			"SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
645
-			$parent_invoice_id,
646
-			$parent_invoice_id
647
-		)
648
-	);
642
+    $invoice_ids = $wpdb->get_col(
643
+        $wpdb->prepare(
644
+            "SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
645
+            $parent_invoice_id,
646
+            $parent_invoice_id
647
+        )
648
+    );
649 649
 
650
-	$count = 0;
650
+    $count = 0;
651 651
 
652
-	foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
652
+    foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
653 653
 
654
-		if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
-			$count ++;
656
-			continue;
657
-		}
654
+        if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
+            $count ++;
656
+            continue;
657
+        }
658 658
 }
659 659
 
660
-	return $count;
660
+    return $count;
661 661
 }
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
     $args = wp_parse_args(
58 58
         $args,
59 59
         array(
60
-			'status'     => array( 'publish' ),
61
-			'limit'      => get_option( 'posts_per_page' ),
62
-			'page'       => 1,
63
-			'exclude'    => array(),
64
-			'orderby'    => 'date',
65
-			'order'      => 'DESC',
66
-			'type'       => wpinv_item_types(),
67
-			'meta_query' => array(),
68
-			'return'     => 'objects',
69
-			'paginate'   => false,
60
+            'status'     => array( 'publish' ),
61
+            'limit'      => get_option( 'posts_per_page' ),
62
+            'page'       => 1,
63
+            'exclude'    => array(),
64
+            'orderby'    => 'date',
65
+            'order'      => 'DESC',
66
+            'type'       => wpinv_item_types(),
67
+            'meta_query' => array(),
68
+            'return'     => 'objects',
69
+            'paginate'   => false,
70 70
         )
71 71
     );
72 72
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 
207 207
 function wpinv_get_item_types() {
208 208
     $item_types = array(
209
-		'custom' => __( 'Standard', 'invoicing' ),
210
-		'fee'    => __( 'Fee', 'invoicing' ),
211
-	);
209
+        'custom' => __( 'Standard', 'invoicing' ),
210
+        'fee'    => __( 'Fee', 'invoicing' ),
211
+    );
212 212
     return apply_filters( 'wpinv_get_item_types', $item_types );
213 213
 }
214 214
 
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
 function wpinv_get_random_items( $num = 3, $post_ids = true ) {
250 250
     if ( $post_ids ) {
251 251
         $args = array(
252
-			'post_type'  => 'wpi_item',
253
-			'orderby'    => 'rand',
254
-			'post_count' => $num,
255
-			'fields'     => 'ids',
256
-		);
252
+            'post_type'  => 'wpi_item',
253
+            'orderby'    => 'rand',
254
+            'post_count' => $num,
255
+            'fields'     => 'ids',
256
+        );
257 257
     } else {
258 258
         $args = array(
259
-			'post_type'  => 'wpi_item',
260
-			'orderby'    => 'rand',
261
-			'post_count' => $num,
262
-		);
259
+            'post_type'  => 'wpi_item',
260
+            'orderby'    => 'rand',
261
+            'post_count' => $num,
262
+        );
263 263
     }
264 264
 
265 265
     $args  = apply_filters( 'wpinv_get_random_items', $args );
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
     $bill_times_less = $bill_times - 1;
428 428
 
429 429
     if ( ! empty( $bill_times ) ) {
430
-		$bill_times = $item->get_recurring_interval() * $bill_times;
430
+        $bill_times = $item->get_recurring_interval() * $bill_times;
431 431
         $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() );
432
-		$bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
433
-	}
432
+        $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
433
+    }
434 434
 
435 435
     if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) {
436 436
         $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
Please login to merge, or discard this patch.