Passed
Push — master ( df4a9d...6f31f4 )
by Brian
04:18
created
invoicing.php 2 patches
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.1.2' );
26
+    define( 'WPINV_VERSION', '2.1.2' );
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.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @package GetPaid
16 16
  */
17 17
 
18
-defined( 'ABSPATH' ) || exit;
18
+defined('ABSPATH') || exit;
19 19
 
20 20
 // Define constants.
21
-if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+	define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.1.2' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.1.2');
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30
-if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
30
+if (!class_exists('WPInv_Plugin', false)) {
31
+	require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function getpaid() {
41 41
 
42
-    if ( empty( $GLOBALS['invoicing'] ) ) {
42
+    if (empty($GLOBALS['invoicing'])) {
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
  * @since  2.0.8
53 53
  */
54 54
 function getpaid_deactivation_hook() {
55
-    update_option( 'wpinv_flush_permalinks', 1 );
55
+    update_option('wpinv_flush_permalinks', 1);
56 56
 }
57
-register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' );
57
+register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook');
58 58
 
59 59
 /**
60 60
  * @deprecated
@@ -64,4 +64,4 @@  discard block
 block discarded – undo
64 64
 }
65 65
 
66 66
 // Kickstart the plugin.
67
-add_action( 'plugins_loaded', 'getpaid', -100 );
67
+add_action('plugins_loaded', 'getpaid', -100);
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +494 added lines, -494 removed lines patch added patch discarded remove patch
@@ -14,536 +14,536 @@  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
-	 * @param 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
-
128
-		if ( class_exists( 'BuddyPress' ) ) {
129
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
130
-		}
131
-
132
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
133
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
134
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
135
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
136
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
137
-
138
-		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
141
-
142
-	}
143
-
144
-	public function plugins_loaded() {
145
-		/* Internationalize the text strings used. */
146
-		$this->load_textdomain();
147
-
148
-		do_action( 'wpinv_loaded' );
149
-
150
-		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
152
-			wpinv_oxygen_fix_conflict();
153
-		}
154
-	}
155
-
156
-	/**
157
-	 * Load the translation of the plugin.
158
-	 *
159
-	 * @since 1.0
160
-	 */
161
-	public function load_textdomain( $locale = NULL ) {
162
-		if ( empty( $locale ) ) {
163
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
164
-		}
165
-
166
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
167
-
168
-		unload_textdomain( 'invoicing' );
169
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
171
-
172
-		/**
173
-		 * Define language constants.
174
-		 */
175
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
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 . 'includes/admin/admin-pages.php' );
235
-
236
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
237
-			GetPaid_Post_Types_Admin::init();
238
-
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
245
-			// load the user class only on the users.php page
246
-			global $pagenow;
247
-			if($pagenow=='users.php'){
248
-				new WPInv_Admin_Users();
249
-			}
250
-		}
251
-
252
-		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
256
-		}
257
-
258
-	}
259
-
260
-	/**
261
-	 * Class autoloader
262
-	 *
263
-	 * @param       string $class_name The name of the class to load.
264
-	 * @access      public
265
-	 * @since       1.0.19
266
-	 * @return      void
267
-	 */
268
-	public function autoload( $class_name ) {
269
-
270
-		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
272
-
273
-		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
275
-			return;
276
-		}
277
-
278
-		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
280
-
281
-		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
283
-
284
-		// And an array of possible locations in order of importance.
285
-		$locations = array(
286
-			"$plugin_path/includes",
287
-			"$plugin_path/includes/data-stores",
288
-			"$plugin_path/includes/gateways",
289
-			"$plugin_path/includes/payments",
290
-			"$plugin_path/includes/geolocation",
291
-			"$plugin_path/includes/reports",
292
-			"$plugin_path/includes/api",
293
-			"$plugin_path/includes/admin",
294
-			"$plugin_path/includes/admin/meta-boxes",
295
-		);
296
-
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
298
-
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
301
-				break;
302
-			}
303
-
304
-		}
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
-		// Fires after getpaid inits.
336
-		do_action( 'getpaid_init', $this );
337
-
338
-	}
339
-
340
-	/**
341
-	 * Checks if this is an IPN request and processes it.
342
-	 */
343
-	public function maybe_process_ipn() {
344
-
345
-		// Ensure that this is an IPN request.
346
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
347
-			return;
348
-		}
349
-
350
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
351
-
352
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
353
-		do_action( "wpinv_verify_{$gateway}_ipn" );
354
-		exit;
355
-
356
-	}
357
-
358
-	public function enqueue_scripts() {
359
-
360
-		// Fires before adding scripts.
361
-		do_action( 'getpaid_enqueue_scripts' );
362
-
363
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
364
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
365
-		wp_enqueue_style( 'wpinv_front_style' );
366
-
367
-		$localize                         = array();
368
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
370
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
371
-		$localize['UseTaxes']             = wpinv_use_taxes();
372
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
373
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
374
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
375
-
376
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
377
-
378
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
379
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
380
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
381
-	}
382
-
383
-	public function wpinv_actions() {
384
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
385
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
386
-		}
387
-	}
388
-
389
-	/**
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
+     * @param 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
+
128
+        if ( class_exists( 'BuddyPress' ) ) {
129
+            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
130
+        }
131
+
132
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
133
+        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
134
+        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
135
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
136
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
137
+
138
+        // Fires after registering actions.
139
+        do_action( 'wpinv_actions', $this );
140
+        do_action( 'getpaid_actions', $this );
141
+
142
+    }
143
+
144
+    public function plugins_loaded() {
145
+        /* Internationalize the text strings used. */
146
+        $this->load_textdomain();
147
+
148
+        do_action( 'wpinv_loaded' );
149
+
150
+        // Fix oxygen page builder conflict
151
+        if ( function_exists( 'ct_css_output' ) ) {
152
+            wpinv_oxygen_fix_conflict();
153
+        }
154
+    }
155
+
156
+    /**
157
+     * Load the translation of the plugin.
158
+     *
159
+     * @since 1.0
160
+     */
161
+    public function load_textdomain( $locale = NULL ) {
162
+        if ( empty( $locale ) ) {
163
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
164
+        }
165
+
166
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
167
+
168
+        unload_textdomain( 'invoicing' );
169
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
171
+
172
+        /**
173
+         * Define language constants.
174
+         */
175
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
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 . 'includes/admin/admin-pages.php' );
235
+
236
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
237
+            GetPaid_Post_Types_Admin::init();
238
+
239
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
240
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
241
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
242
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
245
+            // load the user class only on the users.php page
246
+            global $pagenow;
247
+            if($pagenow=='users.php'){
248
+                new WPInv_Admin_Users();
249
+            }
250
+        }
251
+
252
+        // Register cli commands
253
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
256
+        }
257
+
258
+    }
259
+
260
+    /**
261
+     * Class autoloader
262
+     *
263
+     * @param       string $class_name The name of the class to load.
264
+     * @access      public
265
+     * @since       1.0.19
266
+     * @return      void
267
+     */
268
+    public function autoload( $class_name ) {
269
+
270
+        // Normalize the class name...
271
+        $class_name  = strtolower( $class_name );
272
+
273
+        // ... and make sure it is our class.
274
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
275
+            return;
276
+        }
277
+
278
+        // Next, prepare the file name from the class.
279
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
280
+
281
+        // Base path of the classes.
282
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
283
+
284
+        // And an array of possible locations in order of importance.
285
+        $locations = array(
286
+            "$plugin_path/includes",
287
+            "$plugin_path/includes/data-stores",
288
+            "$plugin_path/includes/gateways",
289
+            "$plugin_path/includes/payments",
290
+            "$plugin_path/includes/geolocation",
291
+            "$plugin_path/includes/reports",
292
+            "$plugin_path/includes/api",
293
+            "$plugin_path/includes/admin",
294
+            "$plugin_path/includes/admin/meta-boxes",
295
+        );
296
+
297
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
298
+
299
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
+                include trailingslashit( $location ) . $file_name;
301
+                break;
302
+            }
303
+
304
+        }
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
+        // Fires after getpaid inits.
336
+        do_action( 'getpaid_init', $this );
337
+
338
+    }
339
+
340
+    /**
341
+     * Checks if this is an IPN request and processes it.
342
+     */
343
+    public function maybe_process_ipn() {
344
+
345
+        // Ensure that this is an IPN request.
346
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
347
+            return;
348
+        }
349
+
350
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
351
+
352
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
353
+        do_action( "wpinv_verify_{$gateway}_ipn" );
354
+        exit;
355
+
356
+    }
357
+
358
+    public function enqueue_scripts() {
359
+
360
+        // Fires before adding scripts.
361
+        do_action( 'getpaid_enqueue_scripts' );
362
+
363
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
364
+        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
365
+        wp_enqueue_style( 'wpinv_front_style' );
366
+
367
+        $localize                         = array();
368
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
370
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
371
+        $localize['UseTaxes']             = wpinv_use_taxes();
372
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
373
+        $localize['loading']              = __( 'Loading...', 'invoicing' );
374
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
375
+
376
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
377
+
378
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
379
+        wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
380
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
381
+    }
382
+
383
+    public function wpinv_actions() {
384
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
385
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
386
+        }
387
+    }
388
+
389
+    /**
390 390
      * Fires an action after verifying that a user can fire them.
391
-	 *
392
-	 * Note: If the action is on an invoice, subscription etc, esure that the
393
-	 * current user owns the invoice/subscription.
391
+     *
392
+     * Note: If the action is on an invoice, subscription etc, esure that the
393
+     * current user owns the invoice/subscription.
394 394
      */
395 395
     public function maybe_do_authenticated_action() {
396 396
 
397
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
397
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
398
+
399
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
400
+            $data = wp_unslash( $_REQUEST );
401
+            if ( is_user_logged_in() ) {
402
+                do_action( "getpaid_authenticated_action_$key", $data );
403
+            }
398 404
 
399
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
400
-			$data = wp_unslash( $_REQUEST );
401
-			if ( is_user_logged_in() ) {
402
-				do_action( "getpaid_authenticated_action_$key", $data );
403
-			}
405
+            do_action( "getpaid_unauthenticated_action_$key", $data );
406
+
407
+        }
408
+
409
+    }
404 410
 
405
-			do_action( "getpaid_unauthenticated_action_$key", $data );
411
+    public function pre_get_posts( $wp_query ) {
406 412
 
407
-		}
413
+        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() ) {
414
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
415
+        }
408 416
 
417
+        return $wp_query;
409 418
     }
410 419
 
411
-	public function pre_get_posts( $wp_query ) {
412
-
413
-		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() ) {
414
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
415
-		}
416
-
417
-		return $wp_query;
418
-	}
419
-
420
-	public function bp_invoicing_init() {
421
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
422
-	}
423
-
424
-	/**
425
-	 * Register widgets
426
-	 *
427
-	 */
428
-	public function register_widgets() {
429
-
430
-		// Currently, UX Builder does not work particulaly well with SuperDuper.
431
-		// So we disable our widgets when editing a page with UX Builder.
432
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
433
-			return;
434
-		}
435
-
436
-		$widgets = apply_filters(
437
-			'getpaid_widget_classes',
438
-			array(
439
-				'WPInv_Checkout_Widget',
440
-				'WPInv_History_Widget',
441
-				'WPInv_Receipt_Widget',
442
-				'WPInv_Subscriptions_Widget',
443
-				'WPInv_Buy_Item_Widget',
444
-				'WPInv_Messages_Widget',
445
-				'WPInv_GetPaid_Widget'
446
-			)
447
-		);
448
-
449
-		foreach ( $widgets as $widget ) {
450
-			register_widget( $widget );
451
-		}
420
+    public function bp_invoicing_init() {
421
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
422
+    }
423
+
424
+    /**
425
+     * Register widgets
426
+     *
427
+     */
428
+    public function register_widgets() {
429
+
430
+        // Currently, UX Builder does not work particulaly well with SuperDuper.
431
+        // So we disable our widgets when editing a page with UX Builder.
432
+        if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
433
+            return;
434
+        }
435
+
436
+        $widgets = apply_filters(
437
+            'getpaid_widget_classes',
438
+            array(
439
+                'WPInv_Checkout_Widget',
440
+                'WPInv_History_Widget',
441
+                'WPInv_Receipt_Widget',
442
+                'WPInv_Subscriptions_Widget',
443
+                'WPInv_Buy_Item_Widget',
444
+                'WPInv_Messages_Widget',
445
+                'WPInv_GetPaid_Widget'
446
+            )
447
+        );
448
+
449
+        foreach ( $widgets as $widget ) {
450
+            register_widget( $widget );
451
+        }
452 452
 		
453
-	}
453
+    }
454 454
 
455
-	/**
456
-	 * Upgrades the database.
457
-	 *
458
-	 * @since 2.0.2
459
-	 */
460
-	public function maybe_upgrade_database() {
455
+    /**
456
+     * Upgrades the database.
457
+     *
458
+     * @since 2.0.2
459
+     */
460
+    public function maybe_upgrade_database() {
461 461
 
462
-		$wpi_version = get_option( 'wpinv_version', 0 );
462
+        $wpi_version = get_option( 'wpinv_version', 0 );
463 463
 
464
-		if ( $wpi_version == WPINV_VERSION ) {
465
-			return;
466
-		}
464
+        if ( $wpi_version == WPINV_VERSION ) {
465
+            return;
466
+        }
467 467
 
468
-		$installer = new GetPaid_Installer();
468
+        $installer = new GetPaid_Installer();
469 469
 
470
-		if ( empty( $wpi_version ) ) {
471
-			return $installer->upgrade_db( 0 );
472
-		}
470
+        if ( empty( $wpi_version ) ) {
471
+            return $installer->upgrade_db( 0 );
472
+        }
473 473
 
474
-		$upgrades  = array(
475
-			'0.0.5' => '004',
476
-			'1.0.3' => '102',
477
-			'2.0.0' => '118',
478
-			'2.0.8' => '207',
479
-		);
474
+        $upgrades  = array(
475
+            '0.0.5' => '004',
476
+            '1.0.3' => '102',
477
+            '2.0.0' => '118',
478
+            '2.0.8' => '207',
479
+        );
480 480
 
481
-		foreach ( $upgrades as $key => $method ) {
481
+        foreach ( $upgrades as $key => $method ) {
482 482
 
483
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
484
-				return $installer->upgrade_db( $method );
485
-			}
483
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
484
+                return $installer->upgrade_db( $method );
485
+            }
486 486
 
487
-		}
487
+        }
488 488
 
489
-	}
489
+    }
490 490
 
491
-	/**
492
-	 * Flushes the permalinks if needed.
493
-	 *
494
-	 * @since 2.0.8
495
-	 */
496
-	public function maybe_flush_permalinks() {
491
+    /**
492
+     * Flushes the permalinks if needed.
493
+     *
494
+     * @since 2.0.8
495
+     */
496
+    public function maybe_flush_permalinks() {
497 497
 
498
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
498
+        $flush = get_option( 'wpinv_flush_permalinks', 0 );
499 499
 
500
-		if ( ! empty( $flush ) ) {
501
-			flush_rewrite_rules();
502
-			delete_option( 'wpinv_flush_permalinks' );
503
-		}
500
+        if ( ! empty( $flush ) ) {
501
+            flush_rewrite_rules();
502
+            delete_option( 'wpinv_flush_permalinks' );
503
+        }
504 504
 
505
-	}
505
+    }
506 506
 
507
-	/**
508
-	 * Remove our pages from yoast sitemaps.
509
-	 *
510
-	 * @since 1.0.19
511
-	 * @param int[] $excluded_posts_ids
512
-	 */
513
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
507
+    /**
508
+     * Remove our pages from yoast sitemaps.
509
+     *
510
+     * @since 1.0.19
511
+     * @param int[] $excluded_posts_ids
512
+     */
513
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
514 514
 
515
-		// Ensure that we have an array.
516
-		if ( ! is_array( $excluded_posts_ids ) ) {
517
-			$excluded_posts_ids = array();
518
-		}
515
+        // Ensure that we have an array.
516
+        if ( ! is_array( $excluded_posts_ids ) ) {
517
+            $excluded_posts_ids = array();
518
+        }
519 519
 
520
-		// Prepare our pages.
521
-		$our_pages = array();
520
+        // Prepare our pages.
521
+        $our_pages = array();
522 522
 
523
-		// Checkout page.
524
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
523
+        // Checkout page.
524
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
525 525
 
526
-		// Success page.
527
-		$our_pages[] = wpinv_get_option( 'success_page', false );
526
+        // Success page.
527
+        $our_pages[] = wpinv_get_option( 'success_page', false );
528 528
 
529
-		// Failure page.
530
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
529
+        // Failure page.
530
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
531 531
 
532
-		// History page.
533
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
532
+        // History page.
533
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
534 534
 
535
-		// Subscriptions page.
536
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
535
+        // Subscriptions page.
536
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
537 537
 
538
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
538
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
539 539
 
540
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
541
-		return array_unique( $excluded_posts_ids );
540
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
541
+        return array_unique( $excluded_posts_ids );
542 542
 
543
-	}
543
+    }
544 544
 
545
-	public function wp_footer() {
546
-		echo '
545
+    public function wp_footer() {
546
+        echo '
547 547
 			<div class="bsui">
548 548
 				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
549 549
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
@@ -559,6 +559,6 @@  discard block
 block discarded – undo
559 559
 				</div>
560 560
 			</div>
561 561
 		';
562
-	}
562
+    }
563 563
 
564 564
 }
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 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.
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param string $prop The prop to set.
57 57
 	 * @param mixed $value The value to retrieve.
58 58
 	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
59
+	public function set($prop, $value) {
60
+		$this->data[$prop] = $value;
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 * @param string $prop The prop to set.
67 67
 	 * @return mixed The value.
68 68
 	 */
69
-	public function get( $prop ) {
69
+	public function get($prop) {
70 70
 
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
71
+		if (isset($this->data[$prop])) {
72
+			return $this->data[$prop];
73 73
 		}
74 74
 
75 75
 		return null;
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	public function set_properties() {
82 82
 
83 83
 		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
+		$this->set('session', new WPInv_Session_Handler());
85
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
86 86
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87 87
 
88 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() );
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 101
 
102 102
 	}
103 103
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * Define plugin constants.
106 106
 	 */
107 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 ) );
108
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
109
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
110 110
 		$this->version = WPINV_VERSION;
111 111
 	}
112 112
 
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function init_hooks() {
119 119
 		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
120
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
121 121
 
122 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 );
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 127
 
128
-		if ( class_exists( 'BuddyPress' ) ) {
129
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
128
+		if (class_exists('BuddyPress')) {
129
+			add_action('bp_include', array(&$this, 'bp_invoicing_init'));
130 130
 		}
131 131
 
132
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
133
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
134
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
135
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
136
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
132
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
133
+		add_action('wp_footer', array(&$this, 'wp_footer'));
134
+		add_action('widgets_init', array(&$this, 'register_widgets'));
135
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
136
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
137 137
 
138 138
 		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
139
+		do_action('wpinv_actions', $this);
140
+		do_action('getpaid_actions', $this);
141 141
 
142 142
 	}
143 143
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 		/* Internationalize the text strings used. */
146 146
 		$this->load_textdomain();
147 147
 
148
-		do_action( 'wpinv_loaded' );
148
+		do_action('wpinv_loaded');
149 149
 
150 150
 		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
151
+		if (function_exists('ct_css_output')) {
152 152
 			wpinv_oxygen_fix_conflict();
153 153
 		}
154 154
 	}
@@ -158,21 +158,21 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @since 1.0
160 160
 	 */
161
-	public function load_textdomain( $locale = NULL ) {
162
-		if ( empty( $locale ) ) {
163
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
161
+	public function load_textdomain($locale = NULL) {
162
+		if (empty($locale)) {
163
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
164 164
 		}
165 165
 
166
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
166
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
167 167
 
168
-		unload_textdomain( 'invoicing' );
169
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
168
+		unload_textdomain('invoicing');
169
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
170
+		load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
171 171
 
172 172
 		/**
173 173
 		 * Define language constants.
174 174
 		 */
175
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
175
+		require_once(WPINV_PLUGIN_DIR . 'language.php');
176 176
 	}
177 177
 
178 178
 	/**
@@ -181,78 +181,78 @@  discard block
 block discarded – undo
181 181
 	public function includes() {
182 182
 
183 183
 		// Start with the settings.
184
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
184
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
185 185
 
186 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' );
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 189
 
190 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' );
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 206
 
207 207
 		// Register autoloader.
208 208
 		try {
209
-			spl_autoload_register( array( $this, 'autoload' ), true );
210
-		} catch ( Exception $e ) {
211
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
209
+			spl_autoload_register(array($this, 'autoload'), true);
210
+		} catch (Exception $e) {
211
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
212 212
 		}
213 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 . 'includes/admin/admin-pages.php' );
235
-
236
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
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 . 'includes/admin/admin-pages.php');
235
+
236
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
237 237
 			GetPaid_Post_Types_Admin::init();
238 238
 
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
239
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
240
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
241
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
242
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
243
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
244
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
245 245
 			// load the user class only on the users.php page
246 246
 			global $pagenow;
247
-			if($pagenow=='users.php'){
247
+			if ($pagenow == 'users.php') {
248 248
 				new WPInv_Admin_Users();
249 249
 			}
250 250
 		}
251 251
 
252 252
 		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
253
+		if (defined('WP_CLI') && WP_CLI) {
254
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
255
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
256 256
 		}
257 257
 
258 258
 	}
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	 * @since       1.0.19
266 266
 	 * @return      void
267 267
 	 */
268
-	public function autoload( $class_name ) {
268
+	public function autoload($class_name) {
269 269
 
270 270
 		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
271
+		$class_name = strtolower($class_name);
272 272
 
273 273
 		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
275 275
 			return;
276 276
 		}
277 277
 
278 278
 		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
280 280
 
281 281
 		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
283 283
 
284 284
 		// And an array of possible locations in order of importance.
285 285
 		$locations = array(
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 			"$plugin_path/includes/admin/meta-boxes",
295 295
 		);
296 296
 
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
298 298
 
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
299
+			if (file_exists(trailingslashit($location) . $file_name)) {
300
+				include trailingslashit($location) . $file_name;
301 301
 				break;
302 302
 			}
303 303
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	public function init() {
312 312
 
313 313
 		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
314
+		do_action('before_getpaid_init', $this);
315 315
 
316 316
 		// Maybe upgrade.
317 317
 		$this->maybe_upgrade_database();
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
 			)
329 329
 		);
330 330
 
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
331
+		foreach ($gateways as $id => $class) {
332
+			$this->gateways[$id] = new $class();
333 333
 		}
334 334
 
335 335
 		// Fires after getpaid inits.
336
-		do_action( 'getpaid_init', $this );
336
+		do_action('getpaid_init', $this);
337 337
 
338 338
 	}
339 339
 
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 	public function maybe_process_ipn() {
344 344
 
345 345
 		// Ensure that this is an IPN request.
346
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
346
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
347 347
 			return;
348 348
 		}
349 349
 
350
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
350
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
351 351
 
352
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
353
-		do_action( "wpinv_verify_{$gateway}_ipn" );
352
+		do_action('wpinv_verify_payment_ipn', $gateway);
353
+		do_action("wpinv_verify_{$gateway}_ipn");
354 354
 		exit;
355 355
 
356 356
 	}
@@ -358,31 +358,31 @@  discard block
 block discarded – undo
358 358
 	public function enqueue_scripts() {
359 359
 
360 360
 		// Fires before adding scripts.
361
-		do_action( 'getpaid_enqueue_scripts' );
361
+		do_action('getpaid_enqueue_scripts');
362 362
 
363
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
364
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
365
-		wp_enqueue_style( 'wpinv_front_style' );
363
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
364
+		wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
365
+		wp_enqueue_style('wpinv_front_style');
366 366
 
367 367
 		$localize                         = array();
368
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
370
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
368
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
369
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
370
+		$localize['txtComplete']          = __('Continue', 'invoicing');
371 371
 		$localize['UseTaxes']             = wpinv_use_taxes();
372
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
373
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
374
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
372
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
373
+		$localize['loading']              = __('Loading...', 'invoicing');
374
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
375 375
 
376
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
376
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
377 377
 
378
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
379
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
380
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
378
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
379
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true);
380
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
381 381
 	}
382 382
 
383 383
 	public function wpinv_actions() {
384
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
385
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
384
+		if (isset($_REQUEST['wpi_action'])) {
385
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
386 386
 		}
387 387
 	}
388 388
 
@@ -394,31 +394,31 @@  discard block
 block discarded – undo
394 394
      */
395 395
     public function maybe_do_authenticated_action() {
396 396
 
397
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
397
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
398 398
 
399
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
400
-			$data = wp_unslash( $_REQUEST );
401
-			if ( is_user_logged_in() ) {
402
-				do_action( "getpaid_authenticated_action_$key", $data );
399
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
400
+			$data = wp_unslash($_REQUEST);
401
+			if (is_user_logged_in()) {
402
+				do_action("getpaid_authenticated_action_$key", $data);
403 403
 			}
404 404
 
405
-			do_action( "getpaid_unauthenticated_action_$key", $data );
405
+			do_action("getpaid_unauthenticated_action_$key", $data);
406 406
 
407 407
 		}
408 408
 
409 409
     }
410 410
 
411
-	public function pre_get_posts( $wp_query ) {
411
+	public function pre_get_posts($wp_query) {
412 412
 
413
-		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() ) {
414
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
413
+		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()) {
414
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
415 415
 		}
416 416
 
417 417
 		return $wp_query;
418 418
 	}
419 419
 
420 420
 	public function bp_invoicing_init() {
421
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
421
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
422 422
 	}
423 423
 
424 424
 	/**
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 
430 430
 		// Currently, UX Builder does not work particulaly well with SuperDuper.
431 431
 		// So we disable our widgets when editing a page with UX Builder.
432
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
432
+		if (function_exists('ux_builder_is_active') && ux_builder_is_active()) {
433 433
 			return;
434 434
 		}
435 435
 
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
 			)
447 447
 		);
448 448
 
449
-		foreach ( $widgets as $widget ) {
450
-			register_widget( $widget );
449
+		foreach ($widgets as $widget) {
450
+			register_widget($widget);
451 451
 		}
452 452
 		
453 453
 	}
@@ -459,29 +459,29 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public function maybe_upgrade_database() {
461 461
 
462
-		$wpi_version = get_option( 'wpinv_version', 0 );
462
+		$wpi_version = get_option('wpinv_version', 0);
463 463
 
464
-		if ( $wpi_version == WPINV_VERSION ) {
464
+		if ($wpi_version == WPINV_VERSION) {
465 465
 			return;
466 466
 		}
467 467
 
468 468
 		$installer = new GetPaid_Installer();
469 469
 
470
-		if ( empty( $wpi_version ) ) {
471
-			return $installer->upgrade_db( 0 );
470
+		if (empty($wpi_version)) {
471
+			return $installer->upgrade_db(0);
472 472
 		}
473 473
 
474
-		$upgrades  = array(
474
+		$upgrades = array(
475 475
 			'0.0.5' => '004',
476 476
 			'1.0.3' => '102',
477 477
 			'2.0.0' => '118',
478 478
 			'2.0.8' => '207',
479 479
 		);
480 480
 
481
-		foreach ( $upgrades as $key => $method ) {
481
+		foreach ($upgrades as $key => $method) {
482 482
 
483
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
484
-				return $installer->upgrade_db( $method );
483
+			if (version_compare($wpi_version, $key, '<')) {
484
+				return $installer->upgrade_db($method);
485 485
 			}
486 486
 
487 487
 		}
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 	 */
496 496
 	public function maybe_flush_permalinks() {
497 497
 
498
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
498
+		$flush = get_option('wpinv_flush_permalinks', 0);
499 499
 
500
-		if ( ! empty( $flush ) ) {
500
+		if (!empty($flush)) {
501 501
 			flush_rewrite_rules();
502
-			delete_option( 'wpinv_flush_permalinks' );
502
+			delete_option('wpinv_flush_permalinks');
503 503
 		}
504 504
 
505 505
 	}
@@ -510,10 +510,10 @@  discard block
 block discarded – undo
510 510
 	 * @since 1.0.19
511 511
 	 * @param int[] $excluded_posts_ids
512 512
 	 */
513
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
513
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
514 514
 
515 515
 		// Ensure that we have an array.
516
-		if ( ! is_array( $excluded_posts_ids ) ) {
516
+		if (!is_array($excluded_posts_ids)) {
517 517
 			$excluded_posts_ids = array();
518 518
 		}
519 519
 
@@ -521,24 +521,24 @@  discard block
 block discarded – undo
521 521
 		$our_pages = array();
522 522
 
523 523
 		// Checkout page.
524
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
524
+		$our_pages[] = wpinv_get_option('checkout_page', false);
525 525
 
526 526
 		// Success page.
527
-		$our_pages[] = wpinv_get_option( 'success_page', false );
527
+		$our_pages[] = wpinv_get_option('success_page', false);
528 528
 
529 529
 		// Failure page.
530
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
530
+		$our_pages[] = wpinv_get_option('failure_page', false);
531 531
 
532 532
 		// History page.
533
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
533
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
534 534
 
535 535
 		// Subscriptions page.
536
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
536
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
537 537
 
538
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
538
+		$our_pages   = array_map('intval', array_filter($our_pages));
539 539
 
540 540
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
541
-		return array_unique( $excluded_posts_ids );
541
+		return array_unique($excluded_posts_ids);
542 542
 
543 543
 	}
544 544
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
550 550
 						<div class="modal-content">
551 551
 							<div class="modal-body">
552
-								<button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="' . esc_attr__( 'Close', 'invoicing' ) . '">
552
+								<button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="' . esc_attr__('Close', 'invoicing') . '">
553 553
 									<i class="fa fa-times" aria-hidden="true"></i>
554 554
 								</button>
555 555
 								<div class="modal-body-wrapper"></div>
Please login to merge, or discard this patch.
includes/admin/views/html-gateways-edit.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,26 +4,26 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 <div class="table-responsive">
11 11
     <table id="wpinv_gateways_select" class="table border bg-white form-table">
12
-        <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption>
12
+        <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption>
13 13
 
14 14
         <thead>
15 15
             <tr class="table-light">
16 16
 
17 17
                 <th scope="col" class="border-bottom border-top text-left">
18
-                    <?php _e( 'Payment Method', 'invoicing' ); ?>
18
+                    <?php _e('Payment Method', 'invoicing'); ?>
19 19
                 </th>
20 20
 
21 21
                 <th scope="col" class="border-bottom border-top text-center">
22
-                    <?php _e( 'Enabled', 'invoicing' ); ?>
22
+                    <?php _e('Enabled', 'invoicing'); ?>
23 23
                 </th>
24 24
 
25 25
                 <th scope="col" class="border-bottom border-top text-center">
26
-                    <?php _e( 'Supports Subscriptions', 'invoicing' ); ?>
26
+                    <?php _e('Supports Subscriptions', 'invoicing'); ?>
27 27
                 </th>
28 28
 
29 29
                 <th scope="col" class="border-bottom border-top text-right" style="width:32px">&nbsp;</th>
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
         </thead>
33 33
 
34 34
         <tbody>
35
-            <?php foreach ( wpinv_get_payment_gateways() as $id => $gateway ) : ?>
35
+            <?php foreach (wpinv_get_payment_gateways() as $id => $gateway) : ?>
36 36
                 <tr>
37 37
                     <td class="getpaid-payment-method text-left">
38
-                        <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo sanitize_text_field( $gateway['admin_label'] ); ?></a>
38
+                        <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo sanitize_text_field($gateway['admin_label']); ?></a>
39 39
                     </td>
40 40
                     <td class="getpaid-payment-method-enabled text-center">
41 41
                         <?php
42 42
 
43
-                            $id = esc_attr( $id );
43
+                            $id = esc_attr($id);
44 44
                             echo aui()->input(
45 45
                                 array(
46 46
                                     'type'    => 'checkbox',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                                     'value'   => 1,
50 50
                                     'switch'  => true,
51 51
                                     'label'   => '&nbsp;',
52
-                                    'checked' => wpinv_is_gateway_active( $id ),
52
+                                    'checked' => wpinv_is_gateway_active($id),
53 53
                                     'no_wrap' => true,
54 54
                                 )
55 55
                             );
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
                     <td class="getpaid-payment-method-subscription text-center">
60 60
                         <?php
61 61
 
62
-                            $supports = apply_filters( "wpinv_{$id}_support_subscription", false );
63
-                            $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id );
62
+                            $supports = apply_filters("wpinv_{$id}_support_subscription", false);
63
+                            $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id);
64 64
 
65
-                            if ( $supports ) {
65
+                            if ($supports) {
66 66
                                 echo "<i class='text-success fa fa-check'></i>";
67 67
                             } else {
68 68
                                 echo "<i class='text-dark fa fa-times'></i>";
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                     </td>
73 73
 
74 74
                     <td class="getpaid-payment-method-action text-right">
75
-                        <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a>
75
+                        <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a>
76 76
                     </td>
77 77
 
78 78
                 </tr>
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             <tr class="table-light">
84 84
                 <td colspan="4" class="border-top">
85 85
                     <a class="button button-secondary getpaid-install-gateways" href="https://wpgetpaid.com/downloads/category/gateways/">
86
-                        <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span>
86
+                        <span><?php _e('Add Payment Methods', 'invoicing'); ?></span>
87 87
                     </a>
88 88
                 </td>
89 89
             </tr>
Please login to merge, or discard this patch.
includes/user-functions.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
36 36
 
37
-	if ( current_user_can( 'manage_options' ) ) {
38
-		return 'manage_options';
39
-	};
37
+    if ( current_user_can( 'manage_options' ) ) {
38
+        return 'manage_options';
39
+    };
40 40
 
41
-	return $capalibilty;
41
+    return $capalibilty;
42 42
 }
43 43
 
44 44
 /**
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     // Prepare user values.
63 63
     $prefix = preg_replace( '/\s+/', '', $prefix );
64 64
     $prefix = empty( $prefix ) ? $email : $prefix;
65
-	$args   = array(
66
-		'user_login' => wpinv_generate_user_name( $prefix ),
67
-		'user_pass'  => wp_generate_password(),
68
-		'user_email' => $email,
65
+    $args   = array(
66
+        'user_login' => wpinv_generate_user_name( $prefix ),
67
+        'user_pass'  => wp_generate_password(),
68
+        'user_email' => $email,
69 69
         'role'       => 'subscriber',
70 70
     );
71 71
 
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 function wpinv_generate_user_name( $prefix = '' ) {
83 83
 
84 84
     // If prefix is an email, retrieve the part before the email.
85
-	$prefix = strtok( $prefix, '@' );
85
+    $prefix = strtok( $prefix, '@' );
86 86
 
87
-	// Sanitize the username.
88
-	$prefix = sanitize_user( $prefix, true );
87
+    // Sanitize the username.
88
+    $prefix = sanitize_user( $prefix, true );
89 89
 
90
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
91
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
92
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
93
-	}
90
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
91
+    if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
92
+        $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
93
+    }
94 94
 
95 95
     $username = $prefix;
96 96
     $postfix  = 2;
Please login to merge, or discard this patch.
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package GetPaid
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  *  Generates a users select dropdown.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  * @param array $args
17 17
  * @see wp_dropdown_users
18 18
  */
19
-function wpinv_dropdown_users( $args = '' ) {
19
+function wpinv_dropdown_users($args = '') {
20 20
 
21
-    if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) {
21
+    if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) {
22 22
         $args['show'] = 'display_name_with_login';
23 23
     }
24 24
 
25
-    return wp_dropdown_users( $args );
25
+    return wp_dropdown_users($args);
26 26
 }
27 27
 
28 28
 /**
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
  * @return string capability to check against
33 33
  * @param string $capalibilty Optional. The alternative capability to check against.
34 34
  */
35
-function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
35
+function wpinv_get_capability($capalibilty = 'manage_invoicing') {
36 36
 
37
-	if ( current_user_can( 'manage_options' ) ) {
37
+	if (current_user_can('manage_options')) {
38 38
 		return 'manage_options';
39 39
 	};
40 40
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  * @return bool
49 49
  */
50 50
 function wpinv_current_user_can_manage_invoicing() {
51
-    return current_user_can( wpinv_get_capability() );
51
+    return current_user_can(wpinv_get_capability());
52 52
 }
53 53
 
54 54
 /**
@@ -57,19 +57,19 @@  discard block
 block discarded – undo
57 57
  * @since 1.0.19
58 58
  * @return int|WP_Error
59 59
  */
60
-function wpinv_create_user( $email, $prefix = '' ) {
60
+function wpinv_create_user($email, $prefix = '') {
61 61
 
62 62
     // Prepare user values.
63
-    $prefix = preg_replace( '/\s+/', '', $prefix );
64
-    $prefix = empty( $prefix ) ? $email : $prefix;
65
-	$args   = array(
66
-		'user_login' => wpinv_generate_user_name( $prefix ),
63
+    $prefix = preg_replace('/\s+/', '', $prefix);
64
+    $prefix = empty($prefix) ? $email : $prefix;
65
+	$args = array(
66
+		'user_login' => wpinv_generate_user_name($prefix),
67 67
 		'user_pass'  => wp_generate_password(),
68 68
 		'user_email' => $email,
69 69
         'role'       => 'subscriber',
70 70
     );
71 71
 
72
-    return wp_insert_user( $args );
72
+    return wp_insert_user($args);
73 73
 
74 74
 }
75 75
 
@@ -79,25 +79,25 @@  discard block
 block discarded – undo
79 79
  * @since 1.0.19
80 80
  * @return bool|WP_User
81 81
  */
82
-function wpinv_generate_user_name( $prefix = '' ) {
82
+function wpinv_generate_user_name($prefix = '') {
83 83
 
84 84
     // If prefix is an email, retrieve the part before the email.
85
-	$prefix = strtok( $prefix, '@' );
85
+	$prefix = strtok($prefix, '@');
86 86
 
87 87
 	// Sanitize the username.
88
-	$prefix = sanitize_user( $prefix, true );
88
+	$prefix = sanitize_user($prefix, true);
89 89
 
90
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
91
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
92
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
90
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
91
+	if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) {
92
+		$prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4);
93 93
 	}
94 94
 
95 95
     $username = $prefix;
96 96
     $postfix  = 2;
97 97
 
98
-    while ( username_exists( $username ) ) {
98
+    while (username_exists($username)) {
99 99
         $username = $prefix + $postfix;
100
-        $postfix ++;
100
+        $postfix++;
101 101
     }
102 102
 
103 103
     return $username;
@@ -114,26 +114,26 @@  discard block
 block discarded – undo
114 114
     $tabs = array(
115 115
 
116 116
         'gp-edit-address'  => array(
117
-            'label'        => __( 'Billing Address', 'invoicing' ),
117
+            'label'        => __('Billing Address', 'invoicing'),
118 118
             'callback'     => 'getpaid_display_address_edit_tab',
119 119
             'icon'         => 'fas fa-credit-card',
120 120
         ),
121 121
 
122 122
         'gp-invoices'   => array(
123
-            'label'     => __( 'Invoices', 'invoicing' ), // Name of the tab.
123
+            'label'     => __('Invoices', 'invoicing'), // Name of the tab.
124 124
             'content'   => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead.
125 125
             'icon'      => 'fas fa-file-invoice', // Shown on some profile plugins.
126 126
         ),
127 127
 
128 128
         'gp-subscriptions' => array(
129
-            'label'        => __( 'Subscriptions', 'invoicing' ),
129
+            'label'        => __('Subscriptions', 'invoicing'),
130 130
             'content'      => '[wpinv_subscriptions]',
131 131
             'icon'         => 'fas fa-redo',
132 132
         ),
133 133
 
134 134
     );
135 135
 
136
-    return apply_filters( 'getpaid_user_content_tabs', $tabs );
136
+    return apply_filters('getpaid_user_content_tabs', $tabs);
137 137
 }
138 138
 
139 139
 /**
@@ -143,19 +143,19 @@  discard block
 block discarded – undo
143 143
  * @param array $tab
144 144
  * @return array
145 145
  */
146
-function getpaid_prepare_user_content_tab( $tab ) {
146
+function getpaid_prepare_user_content_tab($tab) {
147 147
 
148
-    if ( ! empty( $tab['callback'] ) ) {
149
-        return call_user_func( $tab['callback'] );
148
+    if (!empty($tab['callback'])) {
149
+        return call_user_func($tab['callback']);
150 150
     }
151 151
 
152
-    if ( ! empty( $tab['content'] ) ) {
153
-        return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) );
152
+    if (!empty($tab['content'])) {
153
+        return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content']))))))));
154 154
     }
155 155
 
156 156
     $notice = aui()->alert(
157 157
         array(
158
-            'content'     => __( 'This tab has no content or content callback.', 'invoicing' ),
158
+            'content'     => __('This tab has no content or content callback.', 'invoicing'),
159 159
             'type'        => 'error',
160 160
         )
161 161
     );
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
  * @param string $default
172 172
  * @return array
173 173
  */
174
-function getpaid_get_tab_url( $tab, $default ) {
174
+function getpaid_get_tab_url($tab, $default) {
175 175
     global $getpaid_tab_url;
176 176
 
177
-    if ( empty( $getpaid_tab_url ) ) {
177
+    if (empty($getpaid_tab_url)) {
178 178
         return $default;
179 179
     }
180 180
 
181
-    return sprintf( $getpaid_tab_url, $tab );
181
+    return sprintf($getpaid_tab_url, $tab);
182 182
 
183 183
 }
184 184
 
@@ -198,19 +198,19 @@  discard block
 block discarded – undo
198 198
 
199 199
                 <?php
200 200
 
201
-                    foreach ( getpaid_user_address_fields() as $key => $label ) {
201
+                    foreach (getpaid_user_address_fields() as $key => $label) {
202 202
 
203 203
                         // Display the country.
204
-                        if ( 'country' == $key ) {
204
+                        if ('country' == $key) {
205 205
 
206 206
                             echo aui()->select(
207 207
                                 array(
208 208
                                     'options'     => wpinv_get_country_list(),
209
-                                    'name'        => esc_attr( $key ),
210
-                                    'id'          => 'wpinv-' . sanitize_html_class( $key ),
211
-                                    'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
209
+                                    'name'        => esc_attr($key),
210
+                                    'id'          => 'wpinv-' . sanitize_html_class($key),
211
+                                    'value'       => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)),
212 212
                                     'placeholder' => $label,
213
-                                    'label'       => wp_kses_post( $label ),
213
+                                    'label'       => wp_kses_post($label),
214 214
                                     'label_type'  => 'vertical',
215 215
                                     'class'       => 'getpaid-address-field',
216 216
                                 )
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
                         }
220 220
 
221 221
                         // Display the state.
222
-                        else if ( 'state' == $key ) {
222
+                        else if ('state' == $key) {
223 223
 
224
-                            echo getpaid_get_states_select_markup (
225
-                                getpaid_get_user_address_field( get_current_user_id(), 'country' ),
226
-                                getpaid_get_user_address_field( get_current_user_id(), 'state' ),
224
+                            echo getpaid_get_states_select_markup(
225
+                                getpaid_get_user_address_field(get_current_user_id(), 'country'),
226
+                                getpaid_get_user_address_field(get_current_user_id(), 'state'),
227 227
                                 $label,
228 228
                                 $label,
229 229
                                 '',
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 
237 237
                             echo aui()->input(
238 238
                                 array(
239
-                                    'name'        => esc_attr( $key ),
240
-                                    'id'          => 'wpinv-' . sanitize_html_class( $key ),
239
+                                    'name'        => esc_attr($key),
240
+                                    'id'          => 'wpinv-' . sanitize_html_class($key),
241 241
                                     'placeholder' => $label,
242
-                                    'label'       => wp_kses_post( $label ),
242
+                                    'label'       => wp_kses_post($label),
243 243
                                     'label_type'  => 'vertical',
244 244
                                     'type'        => 'text',
245
-                                    'value'       => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ),
245
+                                    'value'       => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)),
246 246
                                     'class'       => 'getpaid-address-field',
247 247
                                 )
248 248
                             );
@@ -251,21 +251,21 @@  discard block
 block discarded – undo
251 251
 
252 252
                     }
253 253
 
254
-                    do_action( 'getpaid_display_address_edit_tab' );
254
+                    do_action('getpaid_display_address_edit_tab');
255 255
 
256 256
                     echo aui()->input(
257 257
                         array(
258 258
                             'name'             => 'getpaid_profile_edit_submit_button',
259 259
                             'id'               => 'getpaid_profile_edit_submit_button',
260
-                            'value'            => __( 'Save Address', 'invoicing' ),
261
-                            'help_text'        => __( 'New invoices will use this address as the billing address.', 'invoicing' ),
260
+                            'value'            => __('Save Address', 'invoicing'),
261
+                            'help_text'        => __('New invoices will use this address as the billing address.', 'invoicing'),
262 262
                             'type'             => 'submit',
263 263
                             'class'            => 'btn btn-primary btn-block submit-button',
264 264
                         )
265 265
                     );
266 266
 
267
-                    wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' );
268
-                    getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' );
267
+                    wp_nonce_field('getpaid-nonce', 'getpaid-nonce');
268
+                    getpaid_hidden_field('getpaid-action', 'edit_billing_details');
269 269
                 ?>
270 270
 
271 271
             </form>
@@ -282,20 +282,20 @@  discard block
 block discarded – undo
282 282
  * @since 2.1.4
283 283
  * @param array $data
284 284
  */
285
-function getpaid_save_address_edit_tab( $data ) {
285
+function getpaid_save_address_edit_tab($data) {
286 286
 
287
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
287
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
288 288
 
289
-        if ( isset( $data[ $field ] ) ) {
290
-            $value = sanitize_text_field( $data[ $field ] );
291
-            update_user_meta( get_current_user_id(), '_wpinv_' . $field, $value );
289
+        if (isset($data[$field])) {
290
+            $value = sanitize_text_field($data[$field]);
291
+            update_user_meta(get_current_user_id(), '_wpinv_' . $field, $value);
292 292
         }
293 293
 
294
-        wpinv_set_error( 'address_updated', __( 'You billing address has been updated', 'invoicing' ), 'success');
294
+        wpinv_set_error('address_updated', __('You billing address has been updated', 'invoicing'), 'success');
295 295
     }
296 296
 
297 297
 }
298
-add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' );
298
+add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab');
299 299
 
300 300
 
301 301
 /*
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
  * @param  array $tabs
314 314
  * @return array
315 315
  */
316
-function getpaid_filter_userswp_account_tabs( $tabs ) {
316
+function getpaid_filter_userswp_account_tabs($tabs) {
317 317
 
318 318
     // Abort if the integration is inactive.
319
-    if ( ! getpaid_is_userswp_integration_active() ) {
319
+    if (!getpaid_is_userswp_integration_active()) {
320 320
         return $tabs;
321 321
     }
322 322
 
323
-    $new_tabs   = array();
323
+    $new_tabs = array();
324 324
 
325
-    foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) {
325
+    foreach (getpaid_get_user_content_tabs() as $slug => $tab) {
326 326
 
327
-        $new_tabs[ $slug ] = array(
328
-            'title' => $tab[ 'label'],
329
-            'icon'  =>  $tab[ 'icon'],
327
+        $new_tabs[$slug] = array(
328
+            'title' => $tab['label'],
329
+            'icon'  =>  $tab['icon'],
330 330
         );
331 331
 
332 332
     }
333 333
 
334
-    return array_merge( $tabs, $new_tabs );
334
+    return array_merge($tabs, $new_tabs);
335 335
 }
336
-add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' );
336
+add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs');
337 337
 
338 338
 /**
339 339
  * Display our UsersWP account tabs.
@@ -342,18 +342,18 @@  discard block
 block discarded – undo
342 342
  * @param  array $tabs
343 343
  * @return array
344 344
  */
345
-function getpaid_display_userswp_account_tabs( $tab ) {
345
+function getpaid_display_userswp_account_tabs($tab) {
346 346
     global $getpaid_tab_url;
347 347
 
348 348
     $our_tabs = getpaid_get_user_content_tabs();
349 349
 
350
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
351
-        $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() );
352
-        echo getpaid_prepare_user_content_tab( $our_tabs[ $tab ] );
350
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
351
+        $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url());
352
+        echo getpaid_prepare_user_content_tab($our_tabs[$tab]);
353 353
     }
354 354
 
355 355
 }
356
-add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' );
356
+add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs');
357 357
 
358 358
 
359 359
 /**
@@ -364,17 +364,17 @@  discard block
 block discarded – undo
364 364
  * @param  string $tab   Current tab.
365 365
  * @return string Title.
366 366
  */
367
-function getpaid_filter_userswp_account_title( $title, $tab ) {
367
+function getpaid_filter_userswp_account_title($title, $tab) {
368 368
 
369
-    $our_tabs   = getpaid_get_user_content_tabs();
369
+    $our_tabs = getpaid_get_user_content_tabs();
370 370
 
371
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
372
-        return $our_tabs[ $tab ]['label'];
371
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
372
+        return $our_tabs[$tab]['label'];
373 373
     }
374 374
 
375 375
     return $title;
376 376
 }
377
-add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 );
377
+add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2);
378 378
 
379 379
 /**
380 380
  * Registers the UsersWP integration settings.
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
  * @param  array $settings An array of integration settings.
384 384
  * @return array
385 385
  */
386
-function getpaid_register_userswp_settings( $settings ) {
386
+function getpaid_register_userswp_settings($settings) {
387 387
 
388
-    if ( defined( 'USERSWP_PLUGIN_FILE' ) ) {
388
+    if (defined('USERSWP_PLUGIN_FILE')) {
389 389
 
390 390
         $settings[] = array(
391 391
 
392 392
             'id'       => 'userswp',
393
-            'label'    => __( 'UsersWP', 'invoicing' ),
393
+            'label'    => __('UsersWP', 'invoicing'),
394 394
             'settings' => array(
395 395
 
396 396
                 'userswp_settings' => array(
397 397
                     'id'   => 'userswp_settings',
398
-                    'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>',
398
+                    'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>',
399 399
                     'type' => 'header',
400 400
                 ),
401 401
 
402 402
                 'enable_userswp' => array(
403 403
                     'id'         => 'enable_userswp',
404
-                    'name'       => __( 'Enable Integration', 'invoicing' ),
405
-                    'desc'       => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ),
404
+                    'name'       => __('Enable Integration', 'invoicing'),
405
+                    'desc'       => __('Display GetPaid items on UsersWP account page.', 'invoicing'),
406 406
                     'type'       => 'checkbox',
407 407
                     'std'        => 1,
408 408
                 )
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 
416 416
     return $settings;
417 417
 }
418
-add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' );
418
+add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings');
419 419
 
420 420
 /**
421 421
  * Checks if the integration is enabled.
@@ -424,6 +424,6 @@  discard block
 block discarded – undo
424 424
  * @return bool
425 425
  */
426 426
 function getpaid_is_userswp_integration_active() {
427
-    $enabled = wpinv_get_option( 'enable_userswp', 1 );
428
-    return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled );
427
+    $enabled = wpinv_get_option('enable_userswp', 1);
428
+    return defined('USERSWP_PLUGIN_FILE') && !empty($enabled);
429 429
 }
Please login to merge, or discard this patch.