Passed
Push — master ( 5452c3...c16653 )
by Brian
04:51 queued 19s
created
includes/class-wpinv.php 2 patches
Indentation   +482 added lines, -482 removed lines patch added patch discarded remove patch
@@ -14,425 +14,425 @@  discard block
 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
-	 * Tax instance.
40
-	 *
41
-	 * @var WPInv_EUVat
42
-	 */
43
-	public $tax;
44
-
45
-	/**
46
-	 * @param array An array of payment gateways.
47
-	 */
48
-	public $gateways;
49
-
50
-	/**
51
-	 * Class constructor.
52
-	 */
53
-	public function __construct() {
54
-		$this->define_constants();
55
-		$this->includes();
56
-		$this->init_hooks();
57
-		$this->set_properties();
58
-	}
59
-
60
-	/**
61
-	 * Sets a custom data property.
62
-	 * 
63
-	 * @param string $prop The prop to set.
64
-	 * @param mixed $value The value to retrieve.
65
-	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
68
-	}
69
-
70
-	/**
71
-	 * Gets a custom data property.
72
-	 *
73
-	 * @param string $prop The prop to set.
74
-	 * @return mixed The value.
75
-	 */
76
-	public function get( $prop ) {
77
-
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
80
-		}
81
-
82
-		return null;
83
-	}
84
-
85
-	/**
86
-	 * Define class properties.
87
-	 */
88
-	public function set_properties() {
89
-
90
-		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
-		$this->form_elements = new WPInv_Payment_Form_Elements();
94
-		$this->tax           = new WPInv_EUVat();
95
-		$this->tax->init();
96
-		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97
-
98
-		// Init other objects.
99
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
-		$this->set( 'session', new WPInv_Session_Handler() );
101
-		$this->set( 'notes', new WPInv_Notes() );
102
-		$this->set( 'api', new WPInv_API() );
103
-		$this->set( 'post_types', new GetPaid_Post_Types() );
104
-		$this->set( 'template', new GetPaid_Template() );
105
-		$this->set( 'admin', new GetPaid_Admin() );
106
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
107
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
110
-
111
-	}
112
-
113
-	 /**
114
-	 * Define plugin constants.
115
-	 */
116
-	public function define_constants() {
117
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
118
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
119
-		$this->version = WPINV_VERSION;
120
-	}
121
-
122
-	/**
123
-	 * Hook into actions and filters.
124
-	 *
125
-	 * @since 1.0.19
126
-	 */
127
-	protected function init_hooks() {
128
-		/* Internationalize the text strings used. */
129
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
130
-
131
-		// Init the plugin after WordPress inits.
132
-		add_action( 'init', array( $this, 'init' ), 1 );
133
-		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
134
-		add_action( 'init', array( &$this, 'wpinv_actions' ) );
135
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
136
-
137
-		if ( class_exists( 'BuddyPress' ) ) {
138
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
139
-		}
140
-
141
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
142
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
143
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
144
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
145
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
146
-
147
-		// Fires after registering actions.
148
-		do_action( 'wpinv_actions', $this );
149
-		do_action( 'getpaid_actions', $this );
150
-
151
-	}
152
-
153
-	public function plugins_loaded() {
154
-		/* Internationalize the text strings used. */
155
-		$this->load_textdomain();
156
-
157
-		do_action( 'wpinv_loaded' );
158
-
159
-		// Fix oxygen page builder conflict
160
-		if ( function_exists( 'ct_css_output' ) ) {
161
-			wpinv_oxygen_fix_conflict();
162
-		}
163
-	}
164
-
165
-	/**
166
-	 * Load the translation of the plugin.
167
-	 *
168
-	 * @since 1.0
169
-	 */
170
-	public function load_textdomain( $locale = NULL ) {
171
-		if ( empty( $locale ) ) {
172
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
173
-		}
174
-
175
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
176
-
177
-		unload_textdomain( 'invoicing' );
178
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
179
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
180
-
181
-		/**
182
-		 * Define language constants.
183
-		 */
184
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
185
-	}
186
-
187
-	/**
188
-	 * Include required core files used in admin and on the frontend.
189
-	 */
190
-	public function includes() {
191
-
192
-		// Start with the settings.
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
194
-
195
-		// Packages/libraries.
196
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
199
-
200
-		// Load functions.
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
212
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
215
-
216
-		// Register autoloader.
217
-		try {
218
-			spl_autoload_register( array( $this, 'autoload' ), true );
219
-		} catch ( Exception $e ) {
220
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
221
-		}
222
-
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
242
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
243
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
244
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
245
-
246
-		/**
247
-		 * Load the tax class.
248
-		 */
249
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
250
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
251
-		}
252
-
253
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
254
-			GetPaid_Post_Types_Admin::init();
255
-
256
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
257
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
258
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
259
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
260
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
261
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
262
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
263
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
264
-			// load the user class only on the users.php page
265
-			global $pagenow;
266
-			if($pagenow=='users.php'){
267
-				new WPInv_Admin_Users();
268
-			}
269
-		}
270
-
271
-		// Register cli commands
272
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
273
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
274
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
275
-		}
276
-
277
-		// include css inliner
278
-		if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
279
-			include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
280
-		}
281
-
282
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
283
-	}
284
-
285
-	/**
286
-	 * Class autoloader
287
-	 *
288
-	 * @param       string $class_name The name of the class to load.
289
-	 * @access      public
290
-	 * @since       1.0.19
291
-	 * @return      void
292
-	 */
293
-	public function autoload( $class_name ) {
294
-
295
-		// Normalize the class name...
296
-		$class_name  = strtolower( $class_name );
297
-
298
-		// ... and make sure it is our class.
299
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
300
-			return;
301
-		}
302
-
303
-		// Next, prepare the file name from the class.
304
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
305
-
306
-		// Base path of the classes.
307
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
308
-
309
-		// And an array of possible locations in order of importance.
310
-		$locations = array(
311
-			"$plugin_path/includes",
312
-			"$plugin_path/includes/data-stores",
313
-			"$plugin_path/includes/gateways",
314
-			"$plugin_path/includes/api",
315
-			"$plugin_path/includes/admin",
316
-			"$plugin_path/includes/admin/meta-boxes",
317
-		);
318
-
319
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
320
-
321
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
322
-				include trailingslashit( $location ) . $file_name;
323
-				break;
324
-			}
325
-
326
-		}
327
-
328
-	}
329
-
330
-	/**
331
-	 * Inits hooks etc.
332
-	 */
333
-	public function init() {
334
-
335
-		// Fires before getpaid inits.
336
-		do_action( 'before_getpaid_init', $this );
337
-
338
-		// Load default gateways.
339
-		$gateways = apply_filters(
340
-			'getpaid_default_gateways',
341
-			array(
342
-				'manual'        => 'GetPaid_Manual_Gateway',
343
-				'paypal'        => 'GetPaid_Paypal_Gateway',
344
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
345
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
346
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
347
-			)
348
-		);
349
-
350
-		foreach ( $gateways as $id => $class ) {
351
-			$this->gateways[ $id ] = new $class();
352
-		}
353
-
354
-		// Fires after getpaid inits.
355
-		do_action( 'getpaid_init', $this );
356
-
357
-	}
358
-
359
-	/**
360
-	 * Checks if this is an IPN request and processes it.
361
-	 */
362
-	public function maybe_process_ipn() {
363
-
364
-		// Ensure that this is an IPN request.
365
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
366
-			return;
367
-		}
368
-
369
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
370
-
371
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
372
-		do_action( "wpinv_verify_{$gateway}_ipn" );
373
-		exit;
374
-
375
-	}
376
-
377
-	public function enqueue_scripts() {
378
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
379
-
380
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
381
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
382
-		wp_enqueue_style( 'wpinv_front_style' );
383
-
384
-		// Register scripts
385
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
386
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
387
-
388
-		$localize                         = array();
389
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
390
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
391
-		$localize['currency_symbol']      = wpinv_currency_symbol();
392
-		$localize['currency_pos']         = wpinv_currency_position();
393
-		$localize['thousand_sep']         = wpinv_thousands_separator();
394
-		$localize['decimal_sep']          = wpinv_decimal_separator();
395
-		$localize['decimals']             = wpinv_decimals();
396
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
397
-		$localize['UseTaxes']             = wpinv_use_taxes();
398
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
399
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
400
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
401
-
402
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
403
-
404
-		wp_enqueue_script( 'jquery-blockui' );
405
-		$autofill_api = wpinv_get_option('address_autofill_api');
406
-		$autofill_active = wpinv_get_option('address_autofill_active');
407
-		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
408
-			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
409
-				wp_dequeue_script( 'google-maps-api' );
410
-			}
411
-			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
412
-			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
413
-		}
414
-
415
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
416
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
417
-
418
-		wp_enqueue_script( 'wpinv-front-script' );
419
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
420
-
421
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
422
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
423
-	}
424
-
425
-	public function wpinv_actions() {
426
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
427
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
428
-		}
429
-	}
430
-
431
-	/**
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
+     * Tax instance.
40
+     *
41
+     * @var WPInv_EUVat
42
+     */
43
+    public $tax;
44
+
45
+    /**
46
+     * @param array An array of payment gateways.
47
+     */
48
+    public $gateways;
49
+
50
+    /**
51
+     * Class constructor.
52
+     */
53
+    public function __construct() {
54
+        $this->define_constants();
55
+        $this->includes();
56
+        $this->init_hooks();
57
+        $this->set_properties();
58
+    }
59
+
60
+    /**
61
+     * Sets a custom data property.
62
+     * 
63
+     * @param string $prop The prop to set.
64
+     * @param mixed $value The value to retrieve.
65
+     */
66
+    public function set( $prop, $value ) {
67
+        $this->data[ $prop ] = $value;
68
+    }
69
+
70
+    /**
71
+     * Gets a custom data property.
72
+     *
73
+     * @param string $prop The prop to set.
74
+     * @return mixed The value.
75
+     */
76
+    public function get( $prop ) {
77
+
78
+        if ( isset( $this->data[ $prop ] ) ) {
79
+            return $this->data[ $prop ];
80
+        }
81
+
82
+        return null;
83
+    }
84
+
85
+    /**
86
+     * Define class properties.
87
+     */
88
+    public function set_properties() {
89
+
90
+        // Sessions.
91
+        $this->set( 'session', new WPInv_Session_Handler() );
92
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
+        $this->form_elements = new WPInv_Payment_Form_Elements();
94
+        $this->tax           = new WPInv_EUVat();
95
+        $this->tax->init();
96
+        $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97
+
98
+        // Init other objects.
99
+        $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
+        $this->set( 'session', new WPInv_Session_Handler() );
101
+        $this->set( 'notes', new WPInv_Notes() );
102
+        $this->set( 'api', new WPInv_API() );
103
+        $this->set( 'post_types', new GetPaid_Post_Types() );
104
+        $this->set( 'template', new GetPaid_Template() );
105
+        $this->set( 'admin', new GetPaid_Admin() );
106
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
107
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
110
+
111
+    }
112
+
113
+        /**
114
+         * Define plugin constants.
115
+         */
116
+    public function define_constants() {
117
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
118
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
119
+        $this->version = WPINV_VERSION;
120
+    }
121
+
122
+    /**
123
+     * Hook into actions and filters.
124
+     *
125
+     * @since 1.0.19
126
+     */
127
+    protected function init_hooks() {
128
+        /* Internationalize the text strings used. */
129
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
130
+
131
+        // Init the plugin after WordPress inits.
132
+        add_action( 'init', array( $this, 'init' ), 1 );
133
+        add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
134
+        add_action( 'init', array( &$this, 'wpinv_actions' ) );
135
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
136
+
137
+        if ( class_exists( 'BuddyPress' ) ) {
138
+            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
139
+        }
140
+
141
+        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
142
+        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
143
+        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
144
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
145
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
146
+
147
+        // Fires after registering actions.
148
+        do_action( 'wpinv_actions', $this );
149
+        do_action( 'getpaid_actions', $this );
150
+
151
+    }
152
+
153
+    public function plugins_loaded() {
154
+        /* Internationalize the text strings used. */
155
+        $this->load_textdomain();
156
+
157
+        do_action( 'wpinv_loaded' );
158
+
159
+        // Fix oxygen page builder conflict
160
+        if ( function_exists( 'ct_css_output' ) ) {
161
+            wpinv_oxygen_fix_conflict();
162
+        }
163
+    }
164
+
165
+    /**
166
+     * Load the translation of the plugin.
167
+     *
168
+     * @since 1.0
169
+     */
170
+    public function load_textdomain( $locale = NULL ) {
171
+        if ( empty( $locale ) ) {
172
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
173
+        }
174
+
175
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
176
+
177
+        unload_textdomain( 'invoicing' );
178
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
179
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
180
+
181
+        /**
182
+         * Define language constants.
183
+         */
184
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
185
+    }
186
+
187
+    /**
188
+     * Include required core files used in admin and on the frontend.
189
+     */
190
+    public function includes() {
191
+
192
+        // Start with the settings.
193
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
194
+
195
+        // Packages/libraries.
196
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
197
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
198
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
199
+
200
+        // Load functions.
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
205
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
206
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
207
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
208
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
209
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
210
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
211
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
212
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
213
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
215
+
216
+        // Register autoloader.
217
+        try {
218
+            spl_autoload_register( array( $this, 'autoload' ), true );
219
+        } catch ( Exception $e ) {
220
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
221
+        }
222
+
223
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
234
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
235
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
236
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
237
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
238
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
239
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
240
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
241
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
242
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
243
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
244
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
245
+
246
+        /**
247
+         * Load the tax class.
248
+         */
249
+        if ( ! class_exists( 'WPInv_EUVat' ) ) {
250
+            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
251
+        }
252
+
253
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
254
+            GetPaid_Post_Types_Admin::init();
255
+
256
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
257
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
258
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
259
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
260
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
261
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
262
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
263
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
264
+            // load the user class only on the users.php page
265
+            global $pagenow;
266
+            if($pagenow=='users.php'){
267
+                new WPInv_Admin_Users();
268
+            }
269
+        }
270
+
271
+        // Register cli commands
272
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
273
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
274
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
275
+        }
276
+
277
+        // include css inliner
278
+        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
279
+            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
280
+        }
281
+
282
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
283
+    }
284
+
285
+    /**
286
+     * Class autoloader
287
+     *
288
+     * @param       string $class_name The name of the class to load.
289
+     * @access      public
290
+     * @since       1.0.19
291
+     * @return      void
292
+     */
293
+    public function autoload( $class_name ) {
294
+
295
+        // Normalize the class name...
296
+        $class_name  = strtolower( $class_name );
297
+
298
+        // ... and make sure it is our class.
299
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
300
+            return;
301
+        }
302
+
303
+        // Next, prepare the file name from the class.
304
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
305
+
306
+        // Base path of the classes.
307
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
308
+
309
+        // And an array of possible locations in order of importance.
310
+        $locations = array(
311
+            "$plugin_path/includes",
312
+            "$plugin_path/includes/data-stores",
313
+            "$plugin_path/includes/gateways",
314
+            "$plugin_path/includes/api",
315
+            "$plugin_path/includes/admin",
316
+            "$plugin_path/includes/admin/meta-boxes",
317
+        );
318
+
319
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
320
+
321
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
322
+                include trailingslashit( $location ) . $file_name;
323
+                break;
324
+            }
325
+
326
+        }
327
+
328
+    }
329
+
330
+    /**
331
+     * Inits hooks etc.
332
+     */
333
+    public function init() {
334
+
335
+        // Fires before getpaid inits.
336
+        do_action( 'before_getpaid_init', $this );
337
+
338
+        // Load default gateways.
339
+        $gateways = apply_filters(
340
+            'getpaid_default_gateways',
341
+            array(
342
+                'manual'        => 'GetPaid_Manual_Gateway',
343
+                'paypal'        => 'GetPaid_Paypal_Gateway',
344
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
345
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
346
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
347
+            )
348
+        );
349
+
350
+        foreach ( $gateways as $id => $class ) {
351
+            $this->gateways[ $id ] = new $class();
352
+        }
353
+
354
+        // Fires after getpaid inits.
355
+        do_action( 'getpaid_init', $this );
356
+
357
+    }
358
+
359
+    /**
360
+     * Checks if this is an IPN request and processes it.
361
+     */
362
+    public function maybe_process_ipn() {
363
+
364
+        // Ensure that this is an IPN request.
365
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
366
+            return;
367
+        }
368
+
369
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
370
+
371
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
372
+        do_action( "wpinv_verify_{$gateway}_ipn" );
373
+        exit;
374
+
375
+    }
376
+
377
+    public function enqueue_scripts() {
378
+        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
379
+
380
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
381
+        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
382
+        wp_enqueue_style( 'wpinv_front_style' );
383
+
384
+        // Register scripts
385
+        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
386
+        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
387
+
388
+        $localize                         = array();
389
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
390
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
391
+        $localize['currency_symbol']      = wpinv_currency_symbol();
392
+        $localize['currency_pos']         = wpinv_currency_position();
393
+        $localize['thousand_sep']         = wpinv_thousands_separator();
394
+        $localize['decimal_sep']          = wpinv_decimal_separator();
395
+        $localize['decimals']             = wpinv_decimals();
396
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
397
+        $localize['UseTaxes']             = wpinv_use_taxes();
398
+        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
399
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
400
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
401
+
402
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
403
+
404
+        wp_enqueue_script( 'jquery-blockui' );
405
+        $autofill_api = wpinv_get_option('address_autofill_api');
406
+        $autofill_active = wpinv_get_option('address_autofill_active');
407
+        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
408
+            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
409
+                wp_dequeue_script( 'google-maps-api' );
410
+            }
411
+            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
412
+            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
413
+        }
414
+
415
+        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
416
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
417
+
418
+        wp_enqueue_script( 'wpinv-front-script' );
419
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
420
+
421
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
422
+        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
423
+    }
424
+
425
+    public function wpinv_actions() {
426
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
427
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
428
+        }
429
+    }
430
+
431
+    /**
432 432
      * Fires an action after verifying that a user can fire them.
433
-	 *
434
-	 * Note: If the action is on an invoice, subscription etc, esure that the
435
-	 * current user owns the invoice/subscription.
433
+     *
434
+     * Note: If the action is on an invoice, subscription etc, esure that the
435
+     * current user owns the invoice/subscription.
436 436
      */
437 437
     public function maybe_do_authenticated_action() {
438 438
 
@@ -443,82 +443,82 @@  discard block
 block discarded – undo
443 443
 
444 444
     }
445 445
 
446
-	public function pre_get_posts( $wp_query ) {
447
-		if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
448
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
449
-		}
450
-
451
-		return $wp_query;
452
-	}
453
-
454
-	public function bp_invoicing_init() {
455
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
456
-	}
457
-
458
-	/**
459
-	 * Register widgets
460
-	 *
461
-	 */
462
-	public function register_widgets() {
463
-		$widgets = apply_filters(
464
-			'getpaid_widget_classes',
465
-			array(
466
-				'WPInv_Checkout_Widget',
467
-				'WPInv_History_Widget',
468
-				'WPInv_Receipt_Widget',
469
-				'WPInv_Subscriptions_Widget',
470
-				'WPInv_Buy_Item_Widget',
471
-				'WPInv_Messages_Widget',
472
-				'WPInv_GetPaid_Widget'
473
-			)
474
-		);
475
-
476
-		foreach ( $widgets as $widget ) {
477
-			register_widget( $widget );
478
-		}
446
+    public function pre_get_posts( $wp_query ) {
447
+        if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
448
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
449
+        }
450
+
451
+        return $wp_query;
452
+    }
453
+
454
+    public function bp_invoicing_init() {
455
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
456
+    }
457
+
458
+    /**
459
+     * Register widgets
460
+     *
461
+     */
462
+    public function register_widgets() {
463
+        $widgets = apply_filters(
464
+            'getpaid_widget_classes',
465
+            array(
466
+                'WPInv_Checkout_Widget',
467
+                'WPInv_History_Widget',
468
+                'WPInv_Receipt_Widget',
469
+                'WPInv_Subscriptions_Widget',
470
+                'WPInv_Buy_Item_Widget',
471
+                'WPInv_Messages_Widget',
472
+                'WPInv_GetPaid_Widget'
473
+            )
474
+        );
475
+
476
+        foreach ( $widgets as $widget ) {
477
+            register_widget( $widget );
478
+        }
479 479
 		
480
-	}
480
+    }
481 481
 
482
-	/**
483
-	 * Remove our pages from yoast sitemaps.
484
-	 *
485
-	 * @since 1.0.19
486
-	 * @param int[] $excluded_posts_ids
487
-	 */
488
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
482
+    /**
483
+     * Remove our pages from yoast sitemaps.
484
+     *
485
+     * @since 1.0.19
486
+     * @param int[] $excluded_posts_ids
487
+     */
488
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
489 489
 
490
-		// Ensure that we have an array.
491
-		if ( ! is_array( $excluded_posts_ids ) ) {
492
-			$excluded_posts_ids = array();
493
-		}
490
+        // Ensure that we have an array.
491
+        if ( ! is_array( $excluded_posts_ids ) ) {
492
+            $excluded_posts_ids = array();
493
+        }
494 494
 
495
-		// Prepare our pages.
496
-		$our_pages = array();
495
+        // Prepare our pages.
496
+        $our_pages = array();
497 497
 
498
-		// Checkout page.
499
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
498
+        // Checkout page.
499
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
500 500
 
501
-		// Success page.
502
-		$our_pages[] = wpinv_get_option( 'success_page', false );
501
+        // Success page.
502
+        $our_pages[] = wpinv_get_option( 'success_page', false );
503 503
 
504
-		// Failure page.
505
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
504
+        // Failure page.
505
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
506 506
 
507
-		// History page.
508
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
507
+        // History page.
508
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
509 509
 
510
-		// Subscriptions page.
511
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
510
+        // Subscriptions page.
511
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
512 512
 
513
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
513
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
514 514
 
515
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
516
-		return array_unique( $excluded_posts_ids );
515
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
516
+        return array_unique( $excluded_posts_ids );
517 517
 
518
-	}
518
+    }
519 519
 
520
-	public function wp_footer() {
521
-		echo '
520
+    public function wp_footer() {
521
+        echo '
522 522
 			<div class="bsui">
523 523
 				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
524 524
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
@@ -529,6 +529,6 @@  discard block
 block discarded – undo
529 529
 				</div>
530 530
 			</div>
531 531
 		';
532
-	}
532
+    }
533 533
 
534 534
 }
Please login to merge, or discard this patch.
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 * @param string $prop The prop to set.
64 64
 	 * @param mixed $value The value to retrieve.
65 65
 	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
66
+	public function set($prop, $value) {
67
+		$this->data[$prop] = $value;
68 68
 	}
69 69
 
70 70
 	/**
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 * @param string $prop The prop to set.
74 74
 	 * @return mixed The value.
75 75
 	 */
76
-	public function get( $prop ) {
76
+	public function get($prop) {
77 77
 
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
78
+		if (isset($this->data[$prop])) {
79
+			return $this->data[$prop];
80 80
 		}
81 81
 
82 82
 		return null;
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
 	public function set_properties() {
89 89
 
90 90
 		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
91
+		$this->set('session', new WPInv_Session_Handler());
92
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
93 93
 		$this->form_elements = new WPInv_Payment_Form_Elements();
94 94
 		$this->tax           = new WPInv_EUVat();
95 95
 		$this->tax->init();
96 96
 		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97 97
 
98 98
 		// Init other objects.
99
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
-		$this->set( 'session', new WPInv_Session_Handler() );
101
-		$this->set( 'notes', new WPInv_Notes() );
102
-		$this->set( 'api', new WPInv_API() );
103
-		$this->set( 'post_types', new GetPaid_Post_Types() );
104
-		$this->set( 'template', new GetPaid_Template() );
105
-		$this->set( 'admin', new GetPaid_Admin() );
106
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
107
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
108
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
109
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
+		$this->set('reports', new WPInv_Reports()); // TODO: Refactor.
100
+		$this->set('session', new WPInv_Session_Handler());
101
+		$this->set('notes', new WPInv_Notes());
102
+		$this->set('api', new WPInv_API());
103
+		$this->set('post_types', new GetPaid_Post_Types());
104
+		$this->set('template', new GetPaid_Template());
105
+		$this->set('admin', new GetPaid_Admin());
106
+		$this->set('subscriptions', new WPInv_Subscriptions());
107
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
108
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
109
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
110 110
 
111 111
 	}
112 112
 
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * Define plugin constants.
115 115
 	 */
116 116
 	public function define_constants() {
117
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
118
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
117
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
118
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
119 119
 		$this->version = WPINV_VERSION;
120 120
 	}
121 121
 
@@ -126,27 +126,27 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	protected function init_hooks() {
128 128
 		/* Internationalize the text strings used. */
129
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
129
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
130 130
 
131 131
 		// Init the plugin after WordPress inits.
132
-		add_action( 'init', array( $this, 'init' ), 1 );
133
-		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
134
-		add_action( 'init', array( &$this, 'wpinv_actions' ) );
135
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
132
+		add_action('init', array($this, 'init'), 1);
133
+		add_action('getpaid_init', array($this, 'maybe_process_ipn'), 5);
134
+		add_action('init', array(&$this, 'wpinv_actions'));
135
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
136 136
 
137
-		if ( class_exists( 'BuddyPress' ) ) {
138
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
137
+		if (class_exists('BuddyPress')) {
138
+			add_action('bp_include', array(&$this, 'bp_invoicing_init'));
139 139
 		}
140 140
 
141
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
142
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
143
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
144
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
145
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
141
+		add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
142
+		add_action('wp_footer', array(&$this, 'wp_footer'));
143
+		add_action('widgets_init', array(&$this, 'register_widgets'));
144
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
145
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
146 146
 
147 147
 		// Fires after registering actions.
148
-		do_action( 'wpinv_actions', $this );
149
-		do_action( 'getpaid_actions', $this );
148
+		do_action('wpinv_actions', $this);
149
+		do_action('getpaid_actions', $this);
150 150
 
151 151
 	}
152 152
 
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 		/* Internationalize the text strings used. */
155 155
 		$this->load_textdomain();
156 156
 
157
-		do_action( 'wpinv_loaded' );
157
+		do_action('wpinv_loaded');
158 158
 
159 159
 		// Fix oxygen page builder conflict
160
-		if ( function_exists( 'ct_css_output' ) ) {
160
+		if (function_exists('ct_css_output')) {
161 161
 			wpinv_oxygen_fix_conflict();
162 162
 		}
163 163
 	}
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @since 1.0
169 169
 	 */
170
-	public function load_textdomain( $locale = NULL ) {
171
-		if ( empty( $locale ) ) {
172
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
170
+	public function load_textdomain($locale = NULL) {
171
+		if (empty($locale)) {
172
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
173 173
 		}
174 174
 
175
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
175
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
176 176
 
177
-		unload_textdomain( 'invoicing' );
178
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
179
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
177
+		unload_textdomain('invoicing');
178
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
179
+		load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
180 180
 
181 181
 		/**
182 182
 		 * Define language constants.
183 183
 		 */
184
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
184
+		require_once(WPINV_PLUGIN_DIR . 'language.php');
185 185
 	}
186 186
 
187 187
 	/**
@@ -190,96 +190,96 @@  discard block
 block discarded – undo
190 190
 	public function includes() {
191 191
 
192 192
 		// Start with the settings.
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
193
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
194 194
 
195 195
 		// Packages/libraries.
196
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
196
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
197
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
198
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
199 199
 
200 200
 		// Load functions.
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
212
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
201
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
205
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
206
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
207
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
208
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
209
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
210
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
211
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
212
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
213
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
214
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
215 215
 
216 216
 		// Register autoloader.
217 217
 		try {
218
-			spl_autoload_register( array( $this, 'autoload' ), true );
219
-		} catch ( Exception $e ) {
220
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
218
+			spl_autoload_register(array($this, 'autoload'), true);
219
+		} catch (Exception $e) {
220
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
221 221
 		}
222 222
 
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
242
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
243
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
244
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
223
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
224
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
234
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
235
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
236
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
237
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
238
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
239
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
240
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
241
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
242
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
243
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
244
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
245 245
 
246 246
 		/**
247 247
 		 * Load the tax class.
248 248
 		 */
249
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
250
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
249
+		if (!class_exists('WPInv_EUVat')) {
250
+			require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
251 251
 		}
252 252
 
253
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
253
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
254 254
 			GetPaid_Post_Types_Admin::init();
255 255
 
256
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
257
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
258
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
259
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
260
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
261
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
262
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
263
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
256
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
257
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
258
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
259
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
260
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
261
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
262
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
263
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
264 264
 			// load the user class only on the users.php page
265 265
 			global $pagenow;
266
-			if($pagenow=='users.php'){
266
+			if ($pagenow == 'users.php') {
267 267
 				new WPInv_Admin_Users();
268 268
 			}
269 269
 		}
270 270
 
271 271
 		// Register cli commands
272
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
273
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
274
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
272
+		if (defined('WP_CLI') && WP_CLI) {
273
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
274
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
275 275
 		}
276 276
 
277 277
 		// include css inliner
278
-		if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
279
-			include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
278
+		if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
279
+			include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
280 280
 		}
281 281
 
282
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
282
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
283 283
 	}
284 284
 
285 285
 	/**
@@ -290,21 +290,21 @@  discard block
 block discarded – undo
290 290
 	 * @since       1.0.19
291 291
 	 * @return      void
292 292
 	 */
293
-	public function autoload( $class_name ) {
293
+	public function autoload($class_name) {
294 294
 
295 295
 		// Normalize the class name...
296
-		$class_name  = strtolower( $class_name );
296
+		$class_name = strtolower($class_name);
297 297
 
298 298
 		// ... and make sure it is our class.
299
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
299
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
300 300
 			return;
301 301
 		}
302 302
 
303 303
 		// Next, prepare the file name from the class.
304
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
304
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
305 305
 
306 306
 		// Base path of the classes.
307
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
307
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
308 308
 
309 309
 		// And an array of possible locations in order of importance.
310 310
 		$locations = array(
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 			"$plugin_path/includes/admin/meta-boxes",
317 317
 		);
318 318
 
319
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
319
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
320 320
 
321
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
322
-				include trailingslashit( $location ) . $file_name;
321
+			if (file_exists(trailingslashit($location) . $file_name)) {
322
+				include trailingslashit($location) . $file_name;
323 323
 				break;
324 324
 			}
325 325
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	public function init() {
334 334
 
335 335
 		// Fires before getpaid inits.
336
-		do_action( 'before_getpaid_init', $this );
336
+		do_action('before_getpaid_init', $this);
337 337
 
338 338
 		// Load default gateways.
339 339
 		$gateways = apply_filters(
@@ -347,12 +347,12 @@  discard block
 block discarded – undo
347 347
 			)
348 348
 		);
349 349
 
350
-		foreach ( $gateways as $id => $class ) {
351
-			$this->gateways[ $id ] = new $class();
350
+		foreach ($gateways as $id => $class) {
351
+			$this->gateways[$id] = new $class();
352 352
 		}
353 353
 
354 354
 		// Fires after getpaid inits.
355
-		do_action( 'getpaid_init', $this );
355
+		do_action('getpaid_init', $this);
356 356
 
357 357
 	}
358 358
 
@@ -362,69 +362,69 @@  discard block
 block discarded – undo
362 362
 	public function maybe_process_ipn() {
363 363
 
364 364
 		// Ensure that this is an IPN request.
365
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
365
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
366 366
 			return;
367 367
 		}
368 368
 
369
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
369
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
370 370
 
371
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
372
-		do_action( "wpinv_verify_{$gateway}_ipn" );
371
+		do_action('wpinv_verify_payment_ipn', $gateway);
372
+		do_action("wpinv_verify_{$gateway}_ipn");
373 373
 		exit;
374 374
 
375 375
 	}
376 376
 
377 377
 	public function enqueue_scripts() {
378
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
378
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
379 379
 
380
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
381
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
382
-		wp_enqueue_style( 'wpinv_front_style' );
380
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
381
+		wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
382
+		wp_enqueue_style('wpinv_front_style');
383 383
 
384 384
 		// Register scripts
385
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
386
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
385
+		wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
386
+		wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
387 387
 
388 388
 		$localize                         = array();
389
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
390
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
389
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
390
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
391 391
 		$localize['currency_symbol']      = wpinv_currency_symbol();
392 392
 		$localize['currency_pos']         = wpinv_currency_position();
393 393
 		$localize['thousand_sep']         = wpinv_thousands_separator();
394 394
 		$localize['decimal_sep']          = wpinv_decimal_separator();
395 395
 		$localize['decimals']             = wpinv_decimals();
396
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
396
+		$localize['txtComplete']          = __('Continue', 'invoicing');
397 397
 		$localize['UseTaxes']             = wpinv_use_taxes();
398
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
399
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
400
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
398
+		$localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
399
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
400
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
401 401
 
402
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
402
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
403 403
 
404
-		wp_enqueue_script( 'jquery-blockui' );
404
+		wp_enqueue_script('jquery-blockui');
405 405
 		$autofill_api = wpinv_get_option('address_autofill_api');
406 406
 		$autofill_active = wpinv_get_option('address_autofill_active');
407
-		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
408
-			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
409
-				wp_dequeue_script( 'google-maps-api' );
407
+		if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
408
+			if (wp_script_is('google-maps-api', 'enqueued')) {
409
+				wp_dequeue_script('google-maps-api');
410 410
 			}
411
-			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
412
-			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
411
+			wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
412
+			wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
413 413
 		}
414 414
 
415
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
416
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
415
+		wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
416
+		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
417 417
 
418
-		wp_enqueue_script( 'wpinv-front-script' );
419
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
418
+		wp_enqueue_script('wpinv-front-script');
419
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
420 420
 
421
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
422
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
421
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
422
+		wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
423 423
 	}
424 424
 
425 425
 	public function wpinv_actions() {
426
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
427
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
426
+		if (isset($_REQUEST['wpi_action'])) {
427
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
428 428
 		}
429 429
 	}
430 430
 
@@ -436,23 +436,23 @@  discard block
 block discarded – undo
436 436
      */
437 437
     public function maybe_do_authenticated_action() {
438 438
 
439
-        if ( is_user_logged_in() && isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
440
-            $key = sanitize_key( $_REQUEST['getpaid-action'] );
441
-            do_action( "getpaid_authenticated_action_$key", $_REQUEST );
439
+        if (is_user_logged_in() && isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
440
+            $key = sanitize_key($_REQUEST['getpaid-action']);
441
+            do_action("getpaid_authenticated_action_$key", $_REQUEST);
442 442
         }
443 443
 
444 444
     }
445 445
 
446
-	public function pre_get_posts( $wp_query ) {
447
-		if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
448
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
446
+	public function pre_get_posts($wp_query) {
447
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
448
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
449 449
 		}
450 450
 
451 451
 		return $wp_query;
452 452
 	}
453 453
 
454 454
 	public function bp_invoicing_init() {
455
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
455
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
456 456
 	}
457 457
 
458 458
 	/**
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 			)
474 474
 		);
475 475
 
476
-		foreach ( $widgets as $widget ) {
477
-			register_widget( $widget );
476
+		foreach ($widgets as $widget) {
477
+			register_widget($widget);
478 478
 		}
479 479
 		
480 480
 	}
@@ -485,10 +485,10 @@  discard block
 block discarded – undo
485 485
 	 * @since 1.0.19
486 486
 	 * @param int[] $excluded_posts_ids
487 487
 	 */
488
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
488
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
489 489
 
490 490
 		// Ensure that we have an array.
491
-		if ( ! is_array( $excluded_posts_ids ) ) {
491
+		if (!is_array($excluded_posts_ids)) {
492 492
 			$excluded_posts_ids = array();
493 493
 		}
494 494
 
@@ -496,24 +496,24 @@  discard block
 block discarded – undo
496 496
 		$our_pages = array();
497 497
 
498 498
 		// Checkout page.
499
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
499
+		$our_pages[] = wpinv_get_option('checkout_page', false);
500 500
 
501 501
 		// Success page.
502
-		$our_pages[] = wpinv_get_option( 'success_page', false );
502
+		$our_pages[] = wpinv_get_option('success_page', false);
503 503
 
504 504
 		// Failure page.
505
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
505
+		$our_pages[] = wpinv_get_option('failure_page', false);
506 506
 
507 507
 		// History page.
508
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
508
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
509 509
 
510 510
 		// Subscriptions page.
511
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
511
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
512 512
 
513
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
513
+		$our_pages   = array_map('intval', array_filter($our_pages));
514 514
 
515 515
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
516
-		return array_unique( $excluded_posts_ids );
516
+		return array_unique($excluded_posts_ids);
517 517
 
518 518
 	}
519 519
 
Please login to merge, or discard this patch.