Passed
Push — master ( a32f68...20e602 )
by Brian
05:13
created
widgets/invoice.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
             'block-keywords'=> "['invoicing','invoice']",
23 23
             'class_name'     => __CLASS__,
24 24
             'base_id'       => 'getpaid_invoice',
25
-            'name'          => __( 'GetPaid > Single Invoice','invoicing' ),
25
+            'name'          => __('GetPaid > Single Invoice', 'invoicing'),
26 26
             'widget_ops'    => array(
27 27
                 'classname'   => 'wpinv-invoice-class bsui',
28
-                'description' => esc_html__('Displays a single invoice.','invoicing'),
28
+                'description' => esc_html__('Displays a single invoice.', 'invoicing'),
29 29
             ),
30 30
             'arguments'     => array(
31 31
                 'title'  => array(
32
-                    'title'       => __( 'Widget title', 'invoicing' ),
33
-                    'desc'        => __( 'Enter widget title.', 'invoicing' ),
32
+                    'title'       => __('Widget title', 'invoicing'),
33
+                    'desc'        => __('Enter widget title.', 'invoicing'),
34 34
                     'type'        => 'text',
35 35
                     'desc_tip'    => true,
36 36
                     'default'     => '',
37 37
                     'advanced'    => false
38 38
                 ),
39 39
                 'id'  => array(
40
-	                'title'       => __( 'Invoice', 'invoicing' ),
41
-	                'desc'        => __( 'Enter the invoice ID', 'invoicing' ),
40
+	                'title'       => __('Invoice', 'invoicing'),
41
+	                'desc'        => __('Enter the invoice ID', 'invoicing'),
42 42
 	                'type'        => 'text',
43 43
 	                'desc_tip'    => true,
44 44
 	                'default'     => '',
45
-	                'placeholder' => __('1','invoicing'),
45
+	                'placeholder' => __('1', 'invoicing'),
46 46
 	                'advanced'    => false
47 47
 				),
48 48
             )
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         );
51 51
 
52 52
 
53
-        parent::__construct( $options );
53
+        parent::__construct($options);
54 54
     }
55 55
 
56 56
 	/**
@@ -62,30 +62,30 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return mixed|string|bool
64 64
 	 */
65
-    public function output( $args = array(), $widget_args = array(), $content = '' ) {
65
+    public function output($args = array(), $widget_args = array(), $content = '') {
66 66
     
67 67
         // Is the shortcode set up correctly?
68
-		if ( empty( $args['id'] ) ) {
68
+		if (empty($args['id'])) {
69 69
 			return aui()->alert(
70 70
 				array(
71 71
 					'type'    => 'warning',
72
-					'content' => __( 'Missing invoice ID', 'invoicing' ),
72
+					'content' => __('Missing invoice ID', 'invoicing'),
73 73
 				)
74 74
 			);
75 75
 		}
76 76
 
77
-        $invoice = wpinv_get_invoice( (int) $args['id'] );
77
+        $invoice = wpinv_get_invoice((int) $args['id']);
78 78
 
79
-        if ( $invoice ) {
79
+        if ($invoice) {
80 80
             ob_start();
81
-            getpaid_invoice( $invoice );
81
+            getpaid_invoice($invoice);
82 82
             return ob_get_clean();
83 83
         }
84 84
 
85 85
         return aui()->alert(
86 86
             array(
87 87
                 'type'    => 'danger',
88
-                'content' => __( 'Invoice not found', 'invoicing' ),
88
+                'content' => __('Invoice not found', 'invoicing'),
89 89
             )
90 90
         );
91 91
 
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +179 added lines, -179 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 );
127
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
130
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
-
134
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
135
-        add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
136
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
123
+		add_action('init', array($this, 'init'), 1);
124
+		add_action('init', array($this, 'maybe_process_ipn'), 10);
125
+		add_action('init', array($this, 'wpinv_actions'));
126
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
127
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
128
+		add_action('wp_footer', array($this, 'wp_footer'));
129
+		add_action('wp_head', array($this, 'wp_head'));
130
+		add_action('widgets_init', array($this, 'register_widgets'));
131
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
132
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
133
+
134
+		add_filter('query_vars', array($this, 'custom_query_vars'));
135
+        add_action('init', array($this, 'add_rewrite_rule'), 10, 0);
136
+		add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1);
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
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		load_plugin_textdomain(
170 170
 			'invoicing',
171 171
 			false,
172
-			plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
172
+			plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/'
173 173
 		);
174 174
 
175 175
 	}
@@ -180,79 +180,79 @@  discard block
 block discarded – undo
180 180
 	public function includes() {
181 181
 
182 182
 		// Start with the settings.
183
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
183
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
184 184
 
185 185
 		// Packages/libraries.
186
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
186
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
187
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
188 188
 
189 189
 		// Load functions.
190
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
190
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
191
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
192
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
193
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
194
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
195
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
196
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
197
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
198
+		require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php');
199
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
200
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
201
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
205 205
 
206 206
 		// Register autoloader.
207 207
 		try {
208
-			spl_autoload_register( array( $this, 'autoload' ), true );
209
-		} catch ( Exception $e ) {
210
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
208
+			spl_autoload_register(array($this, 'autoload'), true);
209
+		} catch (Exception $e) {
210
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
211 211
 		}
212 212
 
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
235
-
236
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
213
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
214
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
215
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
216
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
217
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
218
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
219
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
220
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
221
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
222
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
223
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
224
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice.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,17 +328,17 @@  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
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+		if ('yes' != get_option('wpinv_renamed_gateways')) {
336 336
 			GetPaid_Installer::rename_gateways_label();
337
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
+			update_option('wpinv_renamed_gateways', 'yes');
338 338
 		}
339 339
 
340 340
 		// Fires after getpaid inits.
341
-		do_action( 'getpaid_init', $this );
341
+		do_action('getpaid_init', $this);
342 342
 
343 343
 	}
344 344
 
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 	public function maybe_process_ipn() {
349 349
 
350 350
 		// Ensure that this is an IPN request.
351
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
352 352
 			return;
353 353
 		}
354 354
 
355
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
355
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
356 356
 
357
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
358
-		do_action( "wpinv_verify_{$gateway}_ipn" );
357
+		do_action('wpinv_verify_payment_ipn', $gateway);
358
+		do_action("wpinv_verify_{$gateway}_ipn");
359 359
 		exit;
360 360
 
361 361
 	}
@@ -363,33 +363,33 @@  discard block
 block discarded – undo
363 363
 	public function enqueue_scripts() {
364 364
 
365 365
 		// Fires before adding scripts.
366
-		do_action( 'getpaid_enqueue_scripts' );
366
+		do_action('getpaid_enqueue_scripts');
367 367
 
368 368
 		$localize                         = array();
369
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
370 370
 		$localize['thousands']            = wpinv_thousands_separator();
371 371
 		$localize['decimals']             = wpinv_decimal_separator();
372
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
373
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
372
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
373
+		$localize['txtComplete']          = __('Continue', 'invoicing');
374 374
 		$localize['UseTaxes']             = wpinv_use_taxes();
375
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
377
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
375
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
376
+		$localize['loading']              = __('Loading...', 'invoicing');
377
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
378 378
 
379
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
380 380
 
381
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
382
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
383
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
381
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
382
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true);
383
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
384 384
 	}
385 385
 
386 386
 	public function wpinv_actions() {
387
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
388
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
387
+		if (isset($_REQUEST['wpi_action'])) {
388
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
389 389
 		}
390 390
 
391
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
392
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
391
+		if (defined('WP_ALL_IMPORT_ROOT_DIR')) {
392
+			include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
393 393
 		}
394 394
 	}
395 395
 
@@ -401,24 +401,24 @@  discard block
 block discarded – undo
401 401
      */
402 402
     public function maybe_do_authenticated_action() {
403 403
 
404
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
404
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
405 405
 
406
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
407
-			$data = wp_unslash( $_REQUEST );
408
-			if ( is_user_logged_in() ) {
409
-				do_action( "getpaid_authenticated_action_$key", $data );
406
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
407
+			$data = wp_unslash($_REQUEST);
408
+			if (is_user_logged_in()) {
409
+				do_action("getpaid_authenticated_action_$key", $data);
410 410
 			}
411 411
 
412
-			do_action( "getpaid_unauthenticated_action_$key", $data );
412
+			do_action("getpaid_unauthenticated_action_$key", $data);
413 413
 
414 414
 		}
415 415
 
416 416
     }
417 417
 
418
-	public function pre_get_posts( $wp_query ) {
418
+	public function pre_get_posts($wp_query) {
419 419
 
420
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
421
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
420
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
421
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
422 422
 		}
423 423
 
424 424
 		return $wp_query;
@@ -433,18 +433,18 @@  discard block
 block discarded – undo
433 433
 
434 434
 		// Currently, UX Builder does not work particulaly well with SuperDuper.
435 435
 		// So we disable our widgets when editing a page with UX Builder.
436
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
436
+		if (function_exists('ux_builder_is_active') && ux_builder_is_active()) {
437 437
 			return;
438 438
 		}
439 439
 
440 440
 		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
441 441
 
442
-		if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
442
+		if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
443 443
 			// don't initiate in these conditions.
444
-		}else{
444
+		} else {
445 445
 
446 446
 			// Only load allowed widgets.
447
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
447
+			$exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
448 448
 			$widgets = apply_filters(
449 449
 				'getpaid_widget_classes',
450 450
 				array(
@@ -460,16 +460,16 @@  discard block
 block discarded – undo
460 460
 			);
461 461
 
462 462
 			// For each widget...
463
-			foreach ( $widgets as $widget ) {
463
+			foreach ($widgets as $widget) {
464 464
 
465 465
 				// Abort early if it is excluded for this page.
466
-				if ( in_array( $widget, $exclude ) ) {
466
+				if (in_array($widget, $exclude)) {
467 467
 					continue;
468 468
 				}
469 469
 
470 470
 				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
471
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
472
-					register_widget( $widget );
471
+				if (is_subclass_of($widget, 'WP_Widget')) {
472
+					register_widget($widget);
473 473
 				} else {
474 474
 					new $widget();
475 475
 				}
@@ -487,29 +487,29 @@  discard block
 block discarded – undo
487 487
 	 */
488 488
 	public function maybe_upgrade_database() {
489 489
 
490
-		$wpi_version = get_option( 'wpinv_version', 0 );
490
+		$wpi_version = get_option('wpinv_version', 0);
491 491
 
492
-		if ( $wpi_version == WPINV_VERSION ) {
492
+		if ($wpi_version == WPINV_VERSION) {
493 493
 			return;
494 494
 		}
495 495
 
496 496
 		$installer = new GetPaid_Installer();
497 497
 
498
-		if ( empty( $wpi_version ) ) {
499
-			return $installer->upgrade_db( 0 );
498
+		if (empty($wpi_version)) {
499
+			return $installer->upgrade_db(0);
500 500
 		}
501 501
 
502
-		$upgrades  = array(
502
+		$upgrades = array(
503 503
 			'0.0.5' => '004',
504 504
 			'1.0.3' => '102',
505 505
 			'2.0.0' => '118',
506 506
 			'2.0.8' => '207',
507 507
 		);
508 508
 
509
-		foreach ( $upgrades as $key => $method ) {
509
+		foreach ($upgrades as $key => $method) {
510 510
 
511
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
512
-				return $installer->upgrade_db( $method );
511
+			if (version_compare($wpi_version, $key, '<')) {
512
+				return $installer->upgrade_db($method);
513 513
 			}
514 514
 
515 515
 		}
@@ -523,11 +523,11 @@  discard block
 block discarded – undo
523 523
 	 */
524 524
 	public function maybe_flush_permalinks() {
525 525
 
526
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
526
+		$flush = get_option('wpinv_flush_permalinks', 0);
527 527
 
528
-		if ( ! empty( $flush ) ) {
528
+		if (!empty($flush)) {
529 529
 			flush_rewrite_rules();
530
-			delete_option( 'wpinv_flush_permalinks' );
530
+			delete_option('wpinv_flush_permalinks');
531 531
 		}
532 532
 
533 533
 	}
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
 	 * @since 1.0.19
539 539
 	 * @param int[] $excluded_posts_ids
540 540
 	 */
541
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
541
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
542 542
 
543 543
 		// Ensure that we have an array.
544
-		if ( ! is_array( $excluded_posts_ids ) ) {
544
+		if (!is_array($excluded_posts_ids)) {
545 545
 			$excluded_posts_ids = array();
546 546
 		}
547 547
 
@@ -549,24 +549,24 @@  discard block
 block discarded – undo
549 549
 		$our_pages = array();
550 550
 
551 551
 		// Checkout page.
552
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
552
+		$our_pages[] = wpinv_get_option('checkout_page', false);
553 553
 
554 554
 		// Success page.
555
-		$our_pages[] = wpinv_get_option( 'success_page', false );
555
+		$our_pages[] = wpinv_get_option('success_page', false);
556 556
 
557 557
 		// Failure page.
558
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
558
+		$our_pages[] = wpinv_get_option('failure_page', false);
559 559
 
560 560
 		// History page.
561
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
561
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
562 562
 
563 563
 		// Subscriptions page.
564
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
564
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
565 565
 
566
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
566
+		$our_pages   = array_map('intval', array_filter($our_pages));
567 567
 
568 568
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
569
-		return array_unique( $excluded_posts_ids );
569
+		return array_unique($excluded_posts_ids);
570 570
 
571 571
 	}
572 572
 
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	 * @since 2.0.0
577 577
 	 */
578 578
 	public function wp_footer() {
579
-		wpinv_get_template( 'frontend-footer.php' );
579
+		wpinv_get_template('frontend-footer.php');
580 580
 	}
581 581
 
582 582
 	/**
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
 	 * @since 2.0.0
586 586
 	 */
587 587
 	public function wp_head() {
588
-		wpinv_get_template( 'frontend-head.php' );
588
+		wpinv_get_template('frontend-head.php');
589 589
 	}
590 590
 
591 591
 	/**
592 592
 	 * Custom query vars.
593 593
 	 *
594 594
 	 */
595
-	public function custom_query_vars( $vars ) {
595
+	public function custom_query_vars($vars) {
596 596
         $vars[] = 'getpaid-ipn';
597 597
         return $vars;
598 598
 	}
@@ -603,28 +603,28 @@  discard block
 block discarded – undo
603 603
 	 */
604 604
 	public function add_rewrite_rule() {
605 605
         $tag = 'getpaid-ipn';
606
-        add_rewrite_tag( "%$tag%", '([^&]+)' );
607
-        add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' );
606
+        add_rewrite_tag("%$tag%", '([^&]+)');
607
+        add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top');
608 608
 	}
609 609
 
610 610
 	/**
611 611
 	 * Processes non-query string ipns.
612 612
 	 *
613 613
 	 */
614
-	public function maybe_process_new_ipn( $query ) {
614
+	public function maybe_process_new_ipn($query) {
615 615
 
616
-        if ( is_admin() || ! $query->is_main_query() ) {
616
+        if (is_admin() || !$query->is_main_query()) {
617 617
             return;
618 618
         }
619 619
 
620
-		$gateway = get_query_var( 'getpaid-ipn' );
620
+		$gateway = get_query_var('getpaid-ipn');
621 621
 
622
-        if ( ! empty( $gateway ) ){
622
+        if (!empty($gateway)) {
623 623
 
624
-			$gateway = sanitize_text_field( $gateway );
624
+			$gateway = sanitize_text_field($gateway);
625 625
 			nocache_headers();
626
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
627
-			do_action( "wpinv_verify_{$gateway}_ipn" );
626
+			do_action('wpinv_verify_payment_ipn', $gateway);
627
+			do_action("wpinv_verify_{$gateway}_ipn");
628 628
 			exit;
629 629
 
630 630
         }
Please login to merge, or discard this patch.