Passed
Pull Request — master (#820)
by Kiran
05:18
created
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +619 added lines, -619 removed lines patch added patch discarded remove patch
@@ -14,94 +14,94 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
29
-
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29
+
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct() {
38
+     * Class constructor.
39
+     */
40
+    public function __construct() {
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect' ) );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
67
+        add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) );
68
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
69
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
70 70
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
76
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
77
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
78
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
79
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
80
-		do_action( 'getpaid_init_admin_hooks', $this );
81
-
82
-		// Setup/welcome
83
-		if ( ! empty( $_GET['page'] ) ) {
84
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
85
-				case 'gp-setup':
86
-					include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
87
-					break;
88
-			}
89
-		}
90
-
91
-    }
92
-
93
-    /**
94
-	 * Register admin scripts
95
-	 *
96
-	 */
97
-	public function enqeue_scripts() {
71
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
75
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
76
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
77
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
78
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
79
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
80
+        do_action( 'getpaid_init_admin_hooks', $this );
81
+
82
+        // Setup/welcome
83
+        if ( ! empty( $_GET['page'] ) ) {
84
+            switch ( sanitize_text_field( $_GET['page'] ) ) {
85
+                case 'gp-setup':
86
+                    include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
87
+                    break;
88
+            }
89
+        }
90
+
91
+    }
92
+
93
+    /**
94
+     * Register admin scripts
95
+     *
96
+     */
97
+    public function enqeue_scripts() {
98 98
         global $current_screen, $pagenow;
99 99
 
100
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
101
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
100
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
101
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
102 102
 
103 103
         if ( ! empty( $current_screen->post_type ) ) {
104
-			$page = $current_screen->post_type;
104
+            $page = $current_screen->post_type;
105 105
         }
106 106
 
107 107
         // General styles.
@@ -122,53 +122,53 @@  discard block
 block discarded – undo
122 122
         }
123 123
 
124 124
         // Payment form scripts.
125
-		if ( 'wpi_payment_form' == $page && $editing ) {
125
+        if ( 'wpi_payment_form' == $page && $editing ) {
126 126
             $this->load_payment_form_scripts();
127 127
         }
128 128
 
129
-		if ( $page == 'wpinv-subscriptions' ) {
130
-			wp_enqueue_script( 'postbox' );
131
-		}
129
+        if ( $page == 'wpinv-subscriptions' ) {
130
+            wp_enqueue_script( 'postbox' );
131
+        }
132 132
 
133 133
     }
134 134
 
135 135
     /**
136
-	 * Returns admin js translations.
137
-	 *
138
-	 */
139
-	protected function get_admin_i18() {
136
+     * Returns admin js translations.
137
+     *
138
+     */
139
+    protected function get_admin_i18() {
140 140
         global $post;
141 141
 
142
-		$date_range = array(
143
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
144
-		);
142
+        $date_range = array(
143
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
144
+        );
145 145
 
146
-		if ( $date_range['period'] == 'custom' ) {
146
+        if ( $date_range['period'] == 'custom' ) {
147 147
 
148
-			if ( isset( $_GET['from'] ) ) {
149
-				$date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
150
-			}
148
+            if ( isset( $_GET['from'] ) ) {
149
+                $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
150
+            }
151 151
 
152
-			if ( isset( $_GET['to'] ) ) {
153
-				$date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
154
-			}
152
+            if ( isset( $_GET['to'] ) ) {
153
+                $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
154
+            }
155 155
 }
156 156
 
157 157
         $i18n = array(
158 158
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
159 159
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
160
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
161
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
162
-			'rest_root'                 => esc_url_raw( rest_url() ),
163
-			'date_range'                => $date_range,
160
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
161
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
162
+            'rest_root'                 => esc_url_raw( rest_url() ),
163
+            'date_range'                => $date_range,
164 164
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
165 165
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
166 166
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
167 167
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
168 168
             'tax'                       => wpinv_tax_amount(),
169 169
             'discount'                  => 0,
170
-			'currency_symbol'           => wpinv_currency_symbol(),
171
-			'currency'                  => wpinv_get_currency(),
170
+            'currency_symbol'           => wpinv_currency_symbol(),
171
+            'currency'                  => wpinv_get_currency(),
172 172
             'currency_pos'              => wpinv_currency_position(),
173 173
             'thousand_sep'              => wpinv_thousands_separator(),
174 174
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -188,117 +188,117 @@  discard block
 block discarded – undo
188 188
             'item_description'          => __( 'Item Description', 'invoicing' ),
189 189
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
190 190
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
191
-			'searching'                 => __( 'Searching', 'invoicing' ),
192
-			'loading'                   => __( 'Loading...', 'invoicing' ),
193
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
194
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
195
-			'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
191
+            'searching'                 => __( 'Searching', 'invoicing' ),
192
+            'loading'                   => __( 'Loading...', 'invoicing' ),
193
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
194
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
195
+            'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
196 196
         );
197 197
 
198
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
198
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
199 199
 
200
-			$invoice              = new WPInv_Invoice( $post );
201
-			$i18n['save_invoice'] = sprintf(
202
-				__( 'Save %s', 'invoicing' ),
203
-				ucfirst( $invoice->get_invoice_quote_type() )
204
-			);
200
+            $invoice              = new WPInv_Invoice( $post );
201
+            $i18n['save_invoice'] = sprintf(
202
+                __( 'Save %s', 'invoicing' ),
203
+                ucfirst( $invoice->get_invoice_quote_type() )
204
+            );
205 205
 
206
-			$i18n['invoice_description'] = sprintf(
207
-				__( '%s Description', 'invoicing' ),
208
-				ucfirst( $invoice->get_invoice_quote_type() )
209
-			);
206
+            $i18n['invoice_description'] = sprintf(
207
+                __( '%s Description', 'invoicing' ),
208
+                ucfirst( $invoice->get_invoice_quote_type() )
209
+            );
210 210
 
211
-		}
212
-		return $i18n;
213
-	}
211
+        }
212
+        return $i18n;
213
+    }
214 214
 
215
-	/**
216
-	 * Change the admin footer text on GetPaid admin pages.
217
-	 *
218
-	 * @since  2.0.0
219
-	 * @param  string $footer_text
220
-	 * @return string
221
-	 */
222
-	public function admin_footer_text( $footer_text ) {
223
-		global $current_screen;
215
+    /**
216
+     * Change the admin footer text on GetPaid admin pages.
217
+     *
218
+     * @since  2.0.0
219
+     * @param  string $footer_text
220
+     * @return string
221
+     */
222
+    public function admin_footer_text( $footer_text ) {
223
+        global $current_screen;
224 224
 
225
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
225
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
226 226
 
227 227
         if ( ! empty( $current_screen->post_type ) ) {
228
-			$page = $current_screen->post_type;
228
+            $page = $current_screen->post_type;
229 229
         }
230 230
 
231 231
         // General styles.
232 232
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
233 233
 
234
-			// Change the footer text
235
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
234
+            // Change the footer text
235
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
236 236
 
237
-				$rating_url  = esc_url(
238
-					wp_nonce_url(
239
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
240
-						'getpaid-nonce',
241
-						'getpaid-nonce'
237
+                $rating_url  = esc_url(
238
+                    wp_nonce_url(
239
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
240
+                        'getpaid-nonce',
241
+                        'getpaid-nonce'
242 242
                     )
243
-				);
243
+                );
244 244
 
245
-				$footer_text = sprintf(
246
-					/* translators: %s: five stars */
247
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
248
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
249
-				);
245
+                $footer_text = sprintf(
246
+                    /* translators: %s: five stars */
247
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
248
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
249
+                );
250 250
 
251
-			} else {
251
+            } else {
252 252
 
253
-				$footer_text = sprintf(
254
-					/* translators: %s: GetPaid */
255
-					__( 'Thank you for using %s!', 'invoicing' ),
256
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
257
-				);
253
+                $footer_text = sprintf(
254
+                    /* translators: %s: GetPaid */
255
+                    __( 'Thank you for using %s!', 'invoicing' ),
256
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
257
+                );
258 258
 
259
-			}
259
+            }
260 260
 }
261 261
 
262
-		return $footer_text;
263
-	}
264
-
265
-	/**
266
-	 * Redirects to wp.org to rate the plugin.
267
-	 *
268
-	 * @since  2.0.0
269
-	 */
270
-	public function redirect_to_wordpress_rating_page() {
271
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
272
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
273
-		exit;
274
-	}
275
-
276
-    /**
277
-	 * Loads payment form js.
278
-	 *
279
-	 */
280
-	protected function load_payment_form_scripts() {
262
+        return $footer_text;
263
+    }
264
+
265
+    /**
266
+     * Redirects to wp.org to rate the plugin.
267
+     *
268
+     * @since  2.0.0
269
+     */
270
+    public function redirect_to_wordpress_rating_page() {
271
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
272
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
273
+        exit;
274
+    }
275
+
276
+    /**
277
+     * Loads payment form js.
278
+     *
279
+     */
280
+    protected function load_payment_form_scripts() {
281 281
         global $post;
282 282
 
283 283
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
284
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
285
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
284
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
285
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
286 286
 
287
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), WPINV_VERSION );
287
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), WPINV_VERSION );
288 288
 
289
-		wp_localize_script(
289
+        wp_localize_script(
290 290
             'wpinv-admin-payment-form-script',
291 291
             'wpinvPaymentFormAdmin',
292 292
             array(
293
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
294
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
295
-				'currency'      => wpinv_currency_symbol(),
296
-				'position'      => wpinv_currency_position(),
297
-				'decimals'      => (int) wpinv_decimals(),
298
-				'thousands_sep' => wpinv_thousands_separator(),
299
-				'decimals_sep'  => wpinv_decimal_separator(),
300
-				'form_items'    => gepaid_get_form_items( $post->ID ),
301
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
293
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
294
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
295
+                'currency'      => wpinv_currency_symbol(),
296
+                'position'      => wpinv_currency_position(),
297
+                'decimals'      => (int) wpinv_decimals(),
298
+                'thousands_sep' => wpinv_thousands_separator(),
299
+                'decimals_sep'  => wpinv_decimal_separator(),
300
+                'form_items'    => gepaid_get_form_items( $post->ID ),
301
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
302 302
             )
303 303
         );
304 304
 
@@ -307,19 +307,19 @@  discard block
 block discarded – undo
307 307
     }
308 308
 
309 309
     /**
310
-	 * Add our classes to admin pages.
310
+     * Add our classes to admin pages.
311 311
      *
312 312
      * @param string $classes
313 313
      * @return string
314
-	 *
315
-	 */
314
+     *
315
+     */
316 316
     public function admin_body_class( $classes ) {
317
-		global $pagenow, $post, $current_screen;
317
+        global $pagenow, $post, $current_screen;
318 318
 
319 319
         $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
320 320
 
321 321
         if ( ! empty( $current_screen->post_type ) ) {
322
-			$page = $current_screen->post_type;
322
+            $page = $current_screen->post_type;
323 323
         }
324 324
 
325 325
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -328,70 +328,70 @@  discard block
 block discarded – undo
328 328
 
329 329
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
330 330
             $classes .= ' wpinv-cpt wpinv';
331
-		}
331
+        }
332 332
 
333
-		if ( getpaid_is_invoice_post_type( $page ) ) {
333
+        if ( getpaid_is_invoice_post_type( $page ) ) {
334 334
             $classes .= ' getpaid-is-invoice-cpt';
335 335
         }
336 336
 
337
-		return $classes;
337
+        return $classes;
338 338
     }
339 339
 
340 340
     /**
341
-	 * Maybe show the AyeCode Connect Notice.
342
-	 */
343
-	public function init_ayecode_connect_helper() {
341
+     * Maybe show the AyeCode Connect Notice.
342
+     */
343
+    public function init_ayecode_connect_helper() {
344 344
 
345
-		// Register with the deactivation survey class.
346
-		AyeCode_Deactivation_Survey::instance(
345
+        // Register with the deactivation survey class.
346
+        AyeCode_Deactivation_Survey::instance(
347 347
             array(
348
-				'slug'              => 'invoicing',
349
-				'version'           => WPINV_VERSION,
350
-				'support_url'       => 'https://wpgetpaid.com/support/',
351
-				'documentation_url' => 'https://docs.wpgetpaid.com/',
352
-				'activated'         => (int) get_option( 'gepaid_installed_on' ),
348
+                'slug'              => 'invoicing',
349
+                'version'           => WPINV_VERSION,
350
+                'support_url'       => 'https://wpgetpaid.com/support/',
351
+                'documentation_url' => 'https://docs.wpgetpaid.com/',
352
+                'activated'         => (int) get_option( 'gepaid_installed_on' ),
353 353
             )
354 354
         );
355 355
 
356 356
         new AyeCode_Connect_Helper(
357 357
             array(
358
-				'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
359
-				'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
360
-				'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
361
-				'connect_button'    => __( 'Connect Site', 'invoicing' ),
362
-				'connecting_button' => __( 'Connecting...', 'invoicing' ),
363
-				'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
364
-				'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
358
+                'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
359
+                'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
360
+                'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
361
+                'connect_button'    => __( 'Connect Site', 'invoicing' ),
362
+                'connecting_button' => __( 'Connecting...', 'invoicing' ),
363
+                'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
364
+                'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
365 365
             ),
366 366
             array( 'wpi-addons' )
367 367
         );
368 368
 
369 369
     }
370 370
 
371
-	/**
372
-	 * Redirect users to settings on activation.
373
-	 *
374
-	 * @return void
375
-	 */
376
-	public function activation_redirect() {
371
+    /**
372
+     * Redirect users to settings on activation.
373
+     *
374
+     * @return void
375
+     */
376
+    public function activation_redirect() {
377 377
 
378
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
378
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
379 379
 
380
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
381
-			return;
382
-		}
380
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
381
+            return;
382
+        }
383 383
 
384
-		// Bail if activating from network, or bulk
385
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
386
-			return;
387
-		}
384
+        // Bail if activating from network, or bulk
385
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
386
+            return;
387
+        }
388 388
 
389
-	    update_option( 'wpinv_redirected_to_settings', 1 );
389
+        update_option( 'wpinv_redirected_to_settings', 1 );
390 390
 
391 391
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
392 392
         exit;
393 393
 
394
-	}
394
+    }
395 395
 
396 396
     /**
397 397
      * Fires an admin action after verifying that a user can fire them.
@@ -404,555 +404,555 @@  discard block
 block discarded – undo
404 404
         }
405 405
     }
406 406
 
407
-	/**
407
+    /**
408 408
      * Duplicate invoice.
409
-	 *
410
-	 * @param array $args
409
+     *
410
+     * @param array $args
411 411
      */
412 412
     public function duplicate_invoice( $args ) {
413 413
 
414
-		if ( empty( $args['invoice_id'] ) ) {
415
-			return;
416
-		}
414
+        if ( empty( $args['invoice_id'] ) ) {
415
+            return;
416
+        }
417 417
 
418
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
418
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
419 419
 
420
-		if ( ! $invoice->exists() ) {
421
-			return;
422
-		}
420
+        if ( ! $invoice->exists() ) {
421
+            return;
422
+        }
423 423
 
424
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
425
-		$new_invoice->save();
424
+        $new_invoice = getpaid_duplicate_invoice( $invoice );
425
+        $new_invoice->save();
426 426
 
427
-		if ( $new_invoice->exists() ) {
427
+        if ( $new_invoice->exists() ) {
428 428
 
429
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) );
429
+            getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) );
430 430
 
431
-			wp_safe_redirect(
432
-				add_query_arg(
433
-					array(
434
-						'action' => 'edit',
435
-						'post'   => $new_invoice->get_id(),
436
-					),
437
-					admin_url( 'post.php' )
438
-				)
439
-			);
440
-			exit;
431
+            wp_safe_redirect(
432
+                add_query_arg(
433
+                    array(
434
+                        'action' => 'edit',
435
+                        'post'   => $new_invoice->get_id(),
436
+                    ),
437
+                    admin_url( 'post.php' )
438
+                )
439
+            );
440
+            exit;
441 441
 
442
-		}
442
+        }
443 443
 
444
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) );
444
+        getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) );
445 445
 
446
-	}
446
+    }
447 447
 
448
-	/**
448
+    /**
449 449
      * Refund an invoice.
450
-	 *
451
-	 * @param array $args
450
+     *
451
+     * @param array $args
452 452
      */
453 453
     public function refund_invoice( $args ) {
454 454
 
455
-		if ( empty( $args['invoice_id'] ) ) {
456
-			return;
457
-		}
458
-
459
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
460
-
461
-		if ( ! $invoice->exists() || $invoice->is_refunded() ) {
462
-			return;
463
-		}
464
-
465
-		$invoice->refund();
466
-
467
-		// Refund remotely.
468
-		if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) {
469
-			do_action( 'getpaid_refund_invoice_remotely', $invoice );
470
-		}
471
-
472
-		// Cancel subscriptions.
473
-		if ( ! empty( $args['getpaid_cancel_subscription'] ) ) {
474
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
475
-
476
-			if ( ! empty( $subscriptions ) ) {
477
-				if ( ! is_array( $subscriptions ) ) {
478
-					$subscriptions = array( $subscriptions );
479
-				}
480
-
481
-				foreach ( $subscriptions as $subscription ) {
482
-					$subscription->cancel();
483
-					$invoice->add_system_note(
484
-						sprintf(
485
-							// translators: %s: subscription ID.
486
-							__( 'Subscription #%s cancelled', 'invoicing' ),
487
-							$subscription->get_id()
488
-						)
489
-					);
490
-				}
491
-			}
492
-		}
493
-
494
-		// Add notice.
495
-		$this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) );
496
-
497
-		// Redirect.
498
-		wp_safe_redirect(
499
-			remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) )
500
-		);
501
-	}
502
-
503
-	/**
455
+        if ( empty( $args['invoice_id'] ) ) {
456
+            return;
457
+        }
458
+
459
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
460
+
461
+        if ( ! $invoice->exists() || $invoice->is_refunded() ) {
462
+            return;
463
+        }
464
+
465
+        $invoice->refund();
466
+
467
+        // Refund remotely.
468
+        if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) {
469
+            do_action( 'getpaid_refund_invoice_remotely', $invoice );
470
+        }
471
+
472
+        // Cancel subscriptions.
473
+        if ( ! empty( $args['getpaid_cancel_subscription'] ) ) {
474
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
475
+
476
+            if ( ! empty( $subscriptions ) ) {
477
+                if ( ! is_array( $subscriptions ) ) {
478
+                    $subscriptions = array( $subscriptions );
479
+                }
480
+
481
+                foreach ( $subscriptions as $subscription ) {
482
+                    $subscription->cancel();
483
+                    $invoice->add_system_note(
484
+                        sprintf(
485
+                            // translators: %s: subscription ID.
486
+                            __( 'Subscription #%s cancelled', 'invoicing' ),
487
+                            $subscription->get_id()
488
+                        )
489
+                    );
490
+                }
491
+            }
492
+        }
493
+
494
+        // Add notice.
495
+        $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) );
496
+
497
+        // Redirect.
498
+        wp_safe_redirect(
499
+            remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) )
500
+        );
501
+    }
502
+
503
+    /**
504 504
      * Sends a payment reminder to a customer.
505
-	 *
506
-	 * @param array $args
505
+     *
506
+     * @param array $args
507 507
      */
508 508
     public function duplicate_payment_form( $args ) {
509 509
 
510
-		if ( empty( $args['form_id'] ) ) {
511
-			return;
512
-		}
513
-
514
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
510
+        if ( empty( $args['form_id'] ) ) {
511
+            return;
512
+        }
515 513
 
516
-		if ( ! $form->exists() ) {
517
-			return;
518
-		}
514
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
519 515
 
520
-		$new_form = new GetPaid_Payment_Form();
521
-		$new_form->set_author( $form->get_author( 'edit' ) );
522
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
523
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
524
-		$new_form->set_items( $form->get_items( 'edit' ) );
525
-		$new_form->save();
516
+        if ( ! $form->exists() ) {
517
+            return;
518
+        }
526 519
 
527
-		if ( $new_form->exists() ) {
528
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
529
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
530
-		} else {
531
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
532
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
533
-		}
520
+        $new_form = new GetPaid_Payment_Form();
521
+        $new_form->set_author( $form->get_author( 'edit' ) );
522
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
523
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
524
+        $new_form->set_items( $form->get_items( 'edit' ) );
525
+        $new_form->save();
526
+
527
+        if ( $new_form->exists() ) {
528
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
529
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
530
+        } else {
531
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
532
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
533
+        }
534 534
 
535
-		wp_redirect( $url );
536
-		exit;
537
-	}
535
+        wp_redirect( $url );
536
+        exit;
537
+    }
538 538
 
539
-	/**
539
+    /**
540 540
      * Resets form stats.
541
-	 *
542
-	 * @param array $args
541
+     *
542
+     * @param array $args
543 543
      */
544 544
     public function reset_form_stats( $args ) {
545 545
 
546
-		if ( empty( $args['form_id'] ) ) {
547
-			return;
548
-		}
546
+        if ( empty( $args['form_id'] ) ) {
547
+            return;
548
+        }
549 549
 
550
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
550
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
551 551
 
552
-		if ( ! $form->exists() ) {
553
-			return;
554
-		}
552
+        if ( ! $form->exists() ) {
553
+            return;
554
+        }
555 555
 
556
-		$form->set_earned( 0 );
557
-		$form->set_refunded( 0 );
558
-		$form->set_cancelled( 0 );
559
-		$form->set_failed( 0 );
560
-		$form->save();
556
+        $form->set_earned( 0 );
557
+        $form->set_refunded( 0 );
558
+        $form->set_cancelled( 0 );
559
+        $form->set_failed( 0 );
560
+        $form->save();
561 561
 
562
-		$this->show_success( __( 'Form stats reset successfully', 'invoicing' ) );
562
+        $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) );
563 563
 
564
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) );
565
-		exit;
566
-	}
564
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) );
565
+        exit;
566
+    }
567 567
 
568
-	/**
568
+    /**
569 569
      * Sends a payment reminder to a customer.
570
-	 *
571
-	 * @param array $args
570
+     *
571
+     * @param array $args
572 572
      */
573 573
     public function send_customer_invoice( $args ) {
574
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
575
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
576
-		exit;
577
-	}
574
+        getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
575
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
576
+        exit;
577
+    }
578 578
 
579
-	/**
579
+    /**
580 580
      * Sends a payment reminder to a customer.
581
-	 *
582
-	 * @param array $args
581
+     *
582
+     * @param array $args
583 583
      */
584 584
     public function send_customer_payment_reminder( $args ) {
585
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
585
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
586 586
 
587
-		if ( $sent ) {
588
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
589
-		} else {
590
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
591
-		}
587
+        if ( $sent ) {
588
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
589
+        } else {
590
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
591
+        }
592 592
 
593
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
594
-		exit;
595
-	}
593
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
594
+        exit;
595
+    }
596 596
 
597
-	/**
597
+    /**
598 598
      * Resets tax rates.
599
-	 *
599
+     *
600 600
      */
601 601
     public function admin_reset_tax_rates() {
602 602
 
603
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
604
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
605
-		exit;
603
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
604
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
605
+        exit;
606 606
 
607
-	}
607
+    }
608 608
 
609
-	/**
609
+    /**
610 610
      * Resets admin pages.
611
-	 *
611
+     *
612 612
      */
613 613
     public function admin_create_missing_pages() {
614
-		$installer = new GetPaid_Installer();
615
-		$installer->create_pages();
616
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
617
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
618
-		exit;
619
-	}
620
-
621
-	/**
622
-	 * Refreshes the permalinks.
623
-	 */
624
-	public function admin_refresh_permalinks() {
625
-		flush_rewrite_rules();
626
-		$this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) );
627
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
628
-		exit;
629
-	}
630
-
631
-	/**
614
+        $installer = new GetPaid_Installer();
615
+        $installer->create_pages();
616
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
617
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
618
+        exit;
619
+    }
620
+
621
+    /**
622
+     * Refreshes the permalinks.
623
+     */
624
+    public function admin_refresh_permalinks() {
625
+        flush_rewrite_rules();
626
+        $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) );
627
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
628
+        exit;
629
+    }
630
+
631
+    /**
632 632
      * Creates missing admin tables.
633
-	 *
633
+     *
634 634
      */
635 635
     public function admin_create_missing_tables() {
636
-		global $wpdb;
636
+        global $wpdb;
637 637
 
638
-		GetPaid_Installer::create_db_tables();
639
-		GetPaid_Installer::migrate_old_customers();
638
+        GetPaid_Installer::create_db_tables();
639
+        GetPaid_Installer::migrate_old_customers();
640 640
 
641
-		if ( '' !== $wpdb->last_error ) {
642
-			$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
643
-		} else {
644
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
645
-		}
641
+        if ( '' !== $wpdb->last_error ) {
642
+            $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
643
+        } else {
644
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
645
+        }
646 646
 
647
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
648
-		exit;
649
-	}
647
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
648
+        exit;
649
+    }
650 650
 
651
-	/**
651
+    /**
652 652
      * Migrates old invoices to the new database tables.
653
-	 *
653
+     *
654 654
      */
655 655
     public function admin_migrate_old_invoices() {
656 656
 
657
-		// Migrate the invoices.
658
-		$installer = new GetPaid_Installer();
659
-		$installer->migrate_old_invoices();
657
+        // Migrate the invoices.
658
+        $installer = new GetPaid_Installer();
659
+        $installer->migrate_old_invoices();
660 660
 
661
-		// Show an admin message.
662
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
661
+        // Show an admin message.
662
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
663 663
 
664
-		// Redirect the admin.
665
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
666
-		exit;
664
+        // Redirect the admin.
665
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
666
+        exit;
667 667
 
668
-	}
668
+    }
669 669
 
670
-	/**
670
+    /**
671 671
      * Download customers.
672
-	 *
672
+     *
673 673
      */
674 674
     public function admin_download_customers() {
675 675
 
676
-		$output = fopen( 'php://output', 'w' );
676
+        $output = fopen( 'php://output', 'w' );
677 677
 
678
-		if ( false === $output ) {
679
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
680
-		}
678
+        if ( false === $output ) {
679
+            wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
680
+        }
681 681
 
682
-		header( 'Content-Type:text/csv' );
683
-		header( 'Content-Disposition:attachment;filename=customers.csv' );
682
+        header( 'Content-Type:text/csv' );
683
+        header( 'Content-Disposition:attachment;filename=customers.csv' );
684 684
 
685
-		/** @var GetPaid_Customer[] $customers */
686
-		$customers = getpaid_get_customers( array( 'number' => -1 ) );
687
-		$columns   = array_keys( GetPaid_Customer_Data_Store::get_database_fields() );
685
+        /** @var GetPaid_Customer[] $customers */
686
+        $customers = getpaid_get_customers( array( 'number' => -1 ) );
687
+        $columns   = array_keys( GetPaid_Customer_Data_Store::get_database_fields() );
688 688
 
689
-		// Output the csv column headers.
690
-		fputcsv( $output, $columns );
689
+        // Output the csv column headers.
690
+        fputcsv( $output, $columns );
691 691
 
692
-		// Loop through
693
-		foreach ( $customers as $customer ) {
692
+        // Loop through
693
+        foreach ( $customers as $customer ) {
694 694
 
695
-			$row  = array();
695
+            $row  = array();
696 696
 
697
-			foreach ( $columns as $column ) {
698
-				$row[]  = (string) maybe_serialize( $customer->get( $column, 'edit' ) );
699
-			}
697
+            foreach ( $columns as $column ) {
698
+                $row[]  = (string) maybe_serialize( $customer->get( $column, 'edit' ) );
699
+            }
700 700
 
701
-			fputcsv( $output, $row );
702
-		}
701
+            fputcsv( $output, $row );
702
+        }
703 703
 
704
-		fclose( $output );
705
-		exit;
704
+        fclose( $output );
705
+        exit;
706 706
 
707
-	}
707
+    }
708 708
 
709
-	/**
709
+    /**
710 710
      * Installs a plugin.
711
-	 *
712
-	 * @param array $data
711
+     *
712
+     * @param array $data
713 713
      */
714 714
     public function admin_install_plugin( $data ) {
715 715
 
716
-		if ( ! empty( $data['plugins'] ) ) {
717
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
718
-			wp_cache_flush();
716
+        if ( ! empty( $data['plugins'] ) ) {
717
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
718
+            wp_cache_flush();
719 719
 
720
-			foreach ( $data['plugins'] as $slug => $file ) {
721
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
722
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
723
-				$installed  = $upgrader->install( $plugin_zip );
720
+            foreach ( $data['plugins'] as $slug => $file ) {
721
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
722
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
723
+                $installed  = $upgrader->install( $plugin_zip );
724 724
 
725
-				if ( ! is_wp_error( $installed ) && $installed ) {
726
-					activate_plugin( $file, '', false, true );
727
-				} else {
728
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
729
-				}
725
+                if ( ! is_wp_error( $installed ) && $installed ) {
726
+                    activate_plugin( $file, '', false, true );
727
+                } else {
728
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
729
+                }
730 730
 }
731 731
 }
732 732
 
733
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
734
-		wp_safe_redirect( $redirect );
735
-		exit;
733
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
734
+        wp_safe_redirect( $redirect );
735
+        exit;
736 736
 
737
-	}
737
+    }
738 738
 
739
-	/**
739
+    /**
740 740
      * Connects a gateway.
741
-	 *
742
-	 * @param array $data
741
+     *
742
+     * @param array $data
743 743
      */
744 744
     public function admin_connect_gateway( $data ) {
745 745
 
746
-		if ( ! empty( $data['plugin'] ) ) {
746
+        if ( ! empty( $data['plugin'] ) ) {
747 747
 
748
-			$gateway     = sanitize_key( $data['plugin'] );
749
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
748
+            $gateway     = sanitize_key( $data['plugin'] );
749
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
750 750
 
751
-			if ( ! empty( $connect_url ) ) {
752
-				wp_redirect( $connect_url );
753
-				exit;
754
-			}
751
+            if ( ! empty( $connect_url ) ) {
752
+                wp_redirect( $connect_url );
753
+                exit;
754
+            }
755 755
 
756
-			if ( 'stripe' == $data['plugin'] ) {
757
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
758
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
759
-				wp_cache_flush();
756
+            if ( 'stripe' == $data['plugin'] ) {
757
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
758
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
759
+                wp_cache_flush();
760 760
 
761
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
762
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
763
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
764
-					$upgrader->install( $plugin_zip );
765
-				}
761
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
762
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
763
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
764
+                    $upgrader->install( $plugin_zip );
765
+                }
766 766
 
767
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
768
-			}
767
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
768
+            }
769 769
 
770
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
771
-			if ( ! empty( $connect_url ) ) {
772
-				wp_redirect( $connect_url );
773
-				exit;
774
-			}
770
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
771
+            if ( ! empty( $connect_url ) ) {
772
+                wp_redirect( $connect_url );
773
+                exit;
774
+            }
775 775
 }
776 776
 
777
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
778
-		wp_safe_redirect( $redirect );
779
-		exit;
777
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
778
+        wp_safe_redirect( $redirect );
779
+        exit;
780 780
 
781
-	}
781
+    }
782 782
 
783
-	/**
783
+    /**
784 784
      * Recalculates discounts.
785
-	 *
785
+     *
786 786
      */
787 787
     public function admin_recalculate_discounts() {
788
-		global $wpdb;
788
+        global $wpdb;
789 789
 
790
-		// Fetch all invoices that have discount codes.
791
-		$table    = $wpdb->prefix . 'getpaid_invoices';
792
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
790
+        // Fetch all invoices that have discount codes.
791
+        $table    = $wpdb->prefix . 'getpaid_invoices';
792
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
793 793
 
794
-		foreach ( $invoices as $invoice ) {
794
+        foreach ( $invoices as $invoice ) {
795 795
 
796
-			$invoice = new WPInv_Invoice( $invoice );
796
+            $invoice = new WPInv_Invoice( $invoice );
797 797
 
798
-			if ( ! $invoice->exists() ) {
799
-				continue;
800
-			}
798
+            if ( ! $invoice->exists() ) {
799
+                continue;
800
+            }
801 801
 
802
-			// Abort if the discount does not exist or does not apply here.
803
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
804
-			if ( ! $discount->exists() ) {
805
-				continue;
806
-			}
802
+            // Abort if the discount does not exist or does not apply here.
803
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
804
+            if ( ! $discount->exists() ) {
805
+                continue;
806
+            }
807 807
 
808
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
809
-			$invoice->recalculate_total();
808
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
809
+            $invoice->recalculate_total();
810 810
 
811
-			if ( $invoice->get_total_discount() > 0 ) {
812
-				$invoice->save();
813
-			}
811
+            if ( $invoice->get_total_discount() > 0 ) {
812
+                $invoice->save();
813
+            }
814 814
 }
815 815
 
816
-		// Show an admin message.
817
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
816
+        // Show an admin message.
817
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
818 818
 
819
-		// Redirect the admin.
820
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
821
-		exit;
819
+        // Redirect the admin.
820
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
821
+        exit;
822 822
 
823
-	}
823
+    }
824 824
 
825 825
     /**
826
-	 * Returns an array of admin notices.
827
-	 *
828
-	 * @since       1.0.19
826
+     * Returns an array of admin notices.
827
+     *
828
+     * @since       1.0.19
829 829
      * @return array
830
-	 */
831
-	public function get_notices() {
832
-		$notices = get_option( 'wpinv_admin_notices' );
830
+     */
831
+    public function get_notices() {
832
+        $notices = get_option( 'wpinv_admin_notices' );
833 833
         return is_array( $notices ) ? $notices : array();
834
-	}
834
+    }
835 835
 
836
-	/**
837
-	 * Checks if we have any admin notices.
838
-	 *
839
-	 * @since       2.0.4
836
+    /**
837
+     * Checks if we have any admin notices.
838
+     *
839
+     * @since       2.0.4
840 840
      * @return array
841
-	 */
842
-	public function has_notices() {
843
-		return count( $this->get_notices() ) > 0;
844
-	}
845
-
846
-	/**
847
-	 * Clears all admin notices
848
-	 *
849
-	 * @access      public
850
-	 * @since       1.0.19
851
-	 */
852
-	public function clear_notices() {
853
-		delete_option( 'wpinv_admin_notices' );
854
-	}
855
-
856
-	/**
857
-	 * Saves a new admin notice
858
-	 *
859
-	 * @access      public
860
-	 * @since       1.0.19
861
-	 */
862
-	public function save_notice( $type, $message ) {
863
-		$notices = $this->get_notices();
864
-
865
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
866
-			$notices[ $type ] = array();
867
-		}
868
-
869
-		$notices[ $type ][] = $message;
870
-
871
-		update_option( 'wpinv_admin_notices', $notices );
872
-	}
873
-
874
-	/**
875
-	 * Displays a success notice
876
-	 *
877
-	 * @param       string $msg The message to qeue.
878
-	 * @access      public
879
-	 * @since       1.0.19
880
-	 */
881
-	public function show_success( $msg ) {
882
-		$this->save_notice( 'success', $msg );
883
-	}
884
-
885
-	/**
886
-	 * Displays a error notice
887
-	 *
888
-	 * @access      public
889
-	 * @param       string $msg The message to qeue.
890
-	 * @since       1.0.19
891
-	 */
892
-	public function show_error( $msg ) {
893
-		$this->save_notice( 'error', $msg );
894
-	}
895
-
896
-	/**
897
-	 * Displays a warning notice
898
-	 *
899
-	 * @access      public
900
-	 * @param       string $msg The message to qeue.
901
-	 * @since       1.0.19
902
-	 */
903
-	public function show_warning( $msg ) {
904
-		$this->save_notice( 'warning', $msg );
905
-	}
906
-
907
-	/**
908
-	 * Displays a info notice
909
-	 *
910
-	 * @access      public
911
-	 * @param       string $msg The message to qeue.
912
-	 * @since       1.0.19
913
-	 */
914
-	public function show_info( $msg ) {
915
-		$this->save_notice( 'info', $msg );
916
-	}
917
-
918
-	/**
919
-	 * Show notices
920
-	 *
921
-	 * @access      public
922
-	 * @since       1.0.19
923
-	 */
924
-	public function show_notices() {
841
+     */
842
+    public function has_notices() {
843
+        return count( $this->get_notices() ) > 0;
844
+    }
845
+
846
+    /**
847
+     * Clears all admin notices
848
+     *
849
+     * @access      public
850
+     * @since       1.0.19
851
+     */
852
+    public function clear_notices() {
853
+        delete_option( 'wpinv_admin_notices' );
854
+    }
855
+
856
+    /**
857
+     * Saves a new admin notice
858
+     *
859
+     * @access      public
860
+     * @since       1.0.19
861
+     */
862
+    public function save_notice( $type, $message ) {
863
+        $notices = $this->get_notices();
864
+
865
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
866
+            $notices[ $type ] = array();
867
+        }
868
+
869
+        $notices[ $type ][] = $message;
870
+
871
+        update_option( 'wpinv_admin_notices', $notices );
872
+    }
873
+
874
+    /**
875
+     * Displays a success notice
876
+     *
877
+     * @param       string $msg The message to qeue.
878
+     * @access      public
879
+     * @since       1.0.19
880
+     */
881
+    public function show_success( $msg ) {
882
+        $this->save_notice( 'success', $msg );
883
+    }
884
+
885
+    /**
886
+     * Displays a error notice
887
+     *
888
+     * @access      public
889
+     * @param       string $msg The message to qeue.
890
+     * @since       1.0.19
891
+     */
892
+    public function show_error( $msg ) {
893
+        $this->save_notice( 'error', $msg );
894
+    }
895
+
896
+    /**
897
+     * Displays a warning notice
898
+     *
899
+     * @access      public
900
+     * @param       string $msg The message to qeue.
901
+     * @since       1.0.19
902
+     */
903
+    public function show_warning( $msg ) {
904
+        $this->save_notice( 'warning', $msg );
905
+    }
906
+
907
+    /**
908
+     * Displays a info notice
909
+     *
910
+     * @access      public
911
+     * @param       string $msg The message to qeue.
912
+     * @since       1.0.19
913
+     */
914
+    public function show_info( $msg ) {
915
+        $this->save_notice( 'info', $msg );
916
+    }
917
+
918
+    /**
919
+     * Show notices
920
+     *
921
+     * @access      public
922
+     * @since       1.0.19
923
+     */
924
+    public function show_notices() {
925 925
 
926 926
         $notices = $this->get_notices();
927 927
         $this->clear_notices();
928 928
 
929
-		foreach ( $notices as $type => $messages ) {
929
+        foreach ( $notices as $type => $messages ) {
930 930
 
931
-			if ( ! is_array( $messages ) ) {
932
-				continue;
933
-			}
931
+            if ( ! is_array( $messages ) ) {
932
+                continue;
933
+            }
934 934
 
935 935
             $type  = esc_attr( $type );
936
-			foreach ( $messages as $message ) {
937
-				echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
936
+            foreach ( $messages as $message ) {
937
+                echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
938 938
             }
939 939
 }
940 940
 
941
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
942
-
943
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
944
-				$url     = wp_nonce_url(
945
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
946
-					'getpaid-nonce',
947
-					'getpaid-nonce'
948
-				);
949
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
950
-				$message2 = __( 'Generate Pages', 'invoicing' );
951
-				echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
952
-				break;
953
-			}
941
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
942
+
943
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
944
+                $url     = wp_nonce_url(
945
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
946
+                    'getpaid-nonce',
947
+                    'getpaid-nonce'
948
+                );
949
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
950
+                $message2 = __( 'Generate Pages', 'invoicing' );
951
+                echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
952
+                break;
953
+            }
954 954
 }
955 955
 
956
-	}
956
+    }
957 957
 
958 958
 }
Please login to merge, or discard this patch.
Spacing   +278 added lines, -278 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,36 +54,36 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect' ) );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
70
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
76
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
77
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
78
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
79
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
80
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9);
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form'));
65
+		add_action('getpaid_authenticated_admin_action_reset_form_stats', array($this, 'reset_form_stats'));
66
+		add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice'));
67
+		add_action('getpaid_authenticated_admin_action_refund_invoice', array($this, 'refund_invoice'));
68
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
69
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
70
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
71
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
72
+		add_action('getpaid_authenticated_admin_action_refresh_permalinks', array($this, 'admin_refresh_permalinks'));
73
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
74
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
75
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
76
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
77
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
78
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
79
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
80
+		do_action('getpaid_init_admin_hooks', $this);
81 81
 
82 82
 		// Setup/welcome
83
-		if ( ! empty( $_GET['page'] ) ) {
84
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
83
+		if (!empty($_GET['page'])) {
84
+			switch (sanitize_text_field($_GET['page'])) {
85 85
 				case 'gp-setup':
86
-					include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
86
+					include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php';
87 87
 					break;
88 88
 			}
89 89
 		}
@@ -97,37 +97,37 @@  discard block
 block discarded – undo
97 97
 	public function enqeue_scripts() {
98 98
         global $current_screen, $pagenow;
99 99
 
100
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
100
+		$page    = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
101 101
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
102 102
 
103
-        if ( ! empty( $current_screen->post_type ) ) {
103
+        if (!empty($current_screen->post_type)) {
104 104
 			$page = $current_screen->post_type;
105 105
         }
106 106
 
107 107
         // General styles.
108
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) {
108
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) {
109 109
 
110 110
             // Styles.
111
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
112
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
113
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
111
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
112
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
113
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
114 114
 
115 115
             // Scripts.
116
-            wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
116
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
117 117
 
118
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
119
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version );
120
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
118
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
119
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
120
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
121 121
 
122 122
         }
123 123
 
124 124
         // Payment form scripts.
125
-		if ( 'wpi_payment_form' == $page && $editing ) {
125
+		if ('wpi_payment_form' == $page && $editing) {
126 126
             $this->load_payment_form_scripts();
127 127
         }
128 128
 
129
-		if ( $page == 'wpinv-subscriptions' ) {
130
-			wp_enqueue_script( 'postbox' );
129
+		if ($page == 'wpinv-subscriptions') {
130
+			wp_enqueue_script('postbox');
131 131
 		}
132 132
 
133 133
     }
@@ -140,31 +140,31 @@  discard block
 block discarded – undo
140 140
         global $post;
141 141
 
142 142
 		$date_range = array(
143
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
143
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days',
144 144
 		);
145 145
 
146
-		if ( $date_range['period'] == 'custom' ) {
146
+		if ($date_range['period'] == 'custom') {
147 147
 
148
-			if ( isset( $_GET['from'] ) ) {
149
-				$date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
148
+			if (isset($_GET['from'])) {
149
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
150 150
 			}
151 151
 
152
-			if ( isset( $_GET['to'] ) ) {
153
-				$date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
152
+			if (isset($_GET['to'])) {
153
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
154 154
 			}
155 155
 }
156 156
 
157 157
         $i18n = array(
158
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
159
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
160
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
161
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
162
-			'rest_root'                 => esc_url_raw( rest_url() ),
158
+            'ajax_url'                  => admin_url('admin-ajax.php'),
159
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
160
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
161
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
162
+			'rest_root'                 => esc_url_raw(rest_url()),
163 163
 			'date_range'                => $date_range,
164
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
165
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
166
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
167
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
164
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
165
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
166
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
167
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
168 168
             'tax'                       => wpinv_tax_amount(),
169 169
             'discount'                  => 0,
170 170
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -173,39 +173,39 @@  discard block
 block discarded – undo
173 173
             'thousand_sep'              => wpinv_thousands_separator(),
174 174
             'decimal_sep'               => wpinv_decimal_separator(),
175 175
             'decimals'                  => wpinv_decimals(),
176
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
177
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
178
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
179
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
180
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
181
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
182
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
183
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
184
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
185
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
186
-            'action_edit'               => __( 'Edit', 'invoicing' ),
187
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
188
-            'item_description'          => __( 'Item Description', 'invoicing' ),
189
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
190
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
191
-			'searching'                 => __( 'Searching', 'invoicing' ),
192
-			'loading'                   => __( 'Loading...', 'invoicing' ),
193
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
194
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
195
-			'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
176
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
177
+            'status_publish'            => wpinv_status_nicename('publish'),
178
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
179
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
180
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
181
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
182
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
183
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
184
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
185
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
186
+            'action_edit'               => __('Edit', 'invoicing'),
187
+            'action_cancel'             => __('Cancel', 'invoicing'),
188
+            'item_description'          => __('Item Description', 'invoicing'),
189
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
190
+            'discount_description'      => __('Discount Description', 'invoicing'),
191
+			'searching'                 => __('Searching', 'invoicing'),
192
+			'loading'                   => __('Loading...', 'invoicing'),
193
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
194
+			'search_items'              => __('Enter item name', 'invoicing'),
195
+			'graphs'                    => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())),
196 196
         );
197 197
 
198
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
198
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
199 199
 
200
-			$invoice              = new WPInv_Invoice( $post );
200
+			$invoice              = new WPInv_Invoice($post);
201 201
 			$i18n['save_invoice'] = sprintf(
202
-				__( 'Save %s', 'invoicing' ),
203
-				ucfirst( $invoice->get_invoice_quote_type() )
202
+				__('Save %s', 'invoicing'),
203
+				ucfirst($invoice->get_invoice_quote_type())
204 204
 			);
205 205
 
206 206
 			$i18n['invoice_description'] = sprintf(
207
-				__( '%s Description', 'invoicing' ),
208
-				ucfirst( $invoice->get_invoice_quote_type() )
207
+				__('%s Description', 'invoicing'),
208
+				ucfirst($invoice->get_invoice_quote_type())
209 209
 			);
210 210
 
211 211
 		}
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
 	 * @param  string $footer_text
220 220
 	 * @return string
221 221
 	 */
222
-	public function admin_footer_text( $footer_text ) {
222
+	public function admin_footer_text($footer_text) {
223 223
 		global $current_screen;
224 224
 
225
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
225
+		$page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
226 226
 
227
-        if ( ! empty( $current_screen->post_type ) ) {
227
+        if (!empty($current_screen->post_type)) {
228 228
 			$page = $current_screen->post_type;
229 229
         }
230 230
 
231 231
         // General styles.
232
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
232
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
233 233
 
234 234
 			// Change the footer text
235
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
235
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
236 236
 
237
-				$rating_url  = esc_url(
237
+				$rating_url = esc_url(
238 238
 					wp_nonce_url(
239
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
239
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
240 240
 						'getpaid-nonce',
241 241
 						'getpaid-nonce'
242 242
                     )
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 				$footer_text = sprintf(
246 246
 					/* translators: %s: five stars */
247
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
247
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
248 248
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
249 249
 				);
250 250
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 				$footer_text = sprintf(
254 254
 					/* translators: %s: GetPaid */
255
-					__( 'Thank you for using %s!', 'invoicing' ),
255
+					__('Thank you for using %s!', 'invoicing'),
256 256
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
257 257
 				);
258 258
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @since  2.0.0
269 269
 	 */
270 270
 	public function redirect_to_wordpress_rating_page() {
271
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
272
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
271
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
272
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
273 273
 		exit;
274 274
 	}
275 275
 
@@ -280,29 +280,29 @@  discard block
 block discarded – undo
280 280
 	protected function load_payment_form_scripts() {
281 281
         global $post;
282 282
 
283
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
284
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
285
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
283
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION);
284
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
285
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
286 286
 
287
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), WPINV_VERSION );
287
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), WPINV_VERSION);
288 288
 
289 289
 		wp_localize_script(
290 290
             'wpinv-admin-payment-form-script',
291 291
             'wpinvPaymentFormAdmin',
292 292
             array(
293
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
294
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
+				'elements'      => wpinv_get_data('payment-form-elements'),
294
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
295 295
 				'currency'      => wpinv_currency_symbol(),
296 296
 				'position'      => wpinv_currency_position(),
297 297
 				'decimals'      => (int) wpinv_decimals(),
298 298
 				'thousands_sep' => wpinv_thousands_separator(),
299 299
 				'decimals_sep'  => wpinv_decimal_separator(),
300
-				'form_items'    => gepaid_get_form_items( $post->ID ),
300
+				'form_items'    => gepaid_get_form_items($post->ID),
301 301
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
302 302
             )
303 303
         );
304 304
 
305
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
305
+        wp_enqueue_script('wpinv-admin-payment-form-script');
306 306
 
307 307
     }
308 308
 
@@ -313,24 +313,24 @@  discard block
 block discarded – undo
313 313
      * @return string
314 314
 	 *
315 315
 	 */
316
-    public function admin_body_class( $classes ) {
316
+    public function admin_body_class($classes) {
317 317
 		global $pagenow, $post, $current_screen;
318 318
 
319
-        $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
319
+        $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
320 320
 
321
-        if ( ! empty( $current_screen->post_type ) ) {
321
+        if (!empty($current_screen->post_type)) {
322 322
 			$page = $current_screen->post_type;
323 323
         }
324 324
 
325
-        if ( false !== stripos( $page, 'wpi' ) ) {
326
-            $classes .= ' wpi-' . sanitize_key( $page );
325
+        if (false !== stripos($page, 'wpi')) {
326
+            $classes .= ' wpi-' . sanitize_key($page);
327 327
         }
328 328
 
329
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
329
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
330 330
             $classes .= ' wpinv-cpt wpinv';
331 331
 		}
332 332
 
333
-		if ( getpaid_is_invoice_post_type( $page ) ) {
333
+		if (getpaid_is_invoice_post_type($page)) {
334 334
             $classes .= ' getpaid-is-invoice-cpt';
335 335
         }
336 336
 
@@ -349,21 +349,21 @@  discard block
 block discarded – undo
349 349
 				'version'           => WPINV_VERSION,
350 350
 				'support_url'       => 'https://wpgetpaid.com/support/',
351 351
 				'documentation_url' => 'https://docs.wpgetpaid.com/',
352
-				'activated'         => (int) get_option( 'gepaid_installed_on' ),
352
+				'activated'         => (int) get_option('gepaid_installed_on'),
353 353
             )
354 354
         );
355 355
 
356 356
         new AyeCode_Connect_Helper(
357 357
             array(
358
-				'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
359
-				'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
360
-				'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
361
-				'connect_button'    => __( 'Connect Site', 'invoicing' ),
362
-				'connecting_button' => __( 'Connecting...', 'invoicing' ),
363
-				'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
364
-				'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
358
+				'connect_title'     => __('WP Invoicing - an AyeCode product!', 'invoicing'),
359
+				'connect_external'  => __('Please confirm you wish to connect your site?', 'invoicing'),
360
+				'connect'           => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'),
361
+				'connect_button'    => __('Connect Site', 'invoicing'),
362
+				'connecting_button' => __('Connecting...', 'invoicing'),
363
+				'error_localhost'   => __('This service will only work with a live domain, not a localhost.', 'invoicing'),
364
+				'error'             => __('Something went wrong, please refresh and try again.', 'invoicing'),
365 365
             ),
366
-            array( 'wpi-addons' )
366
+            array('wpi-addons')
367 367
         );
368 368
 
369 369
     }
@@ -375,20 +375,20 @@  discard block
 block discarded – undo
375 375
 	 */
376 376
 	public function activation_redirect() {
377 377
 
378
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
378
+		$redirected = get_option('wpinv_redirected_to_settings');
379 379
 
380
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
380
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
381 381
 			return;
382 382
 		}
383 383
 
384 384
 		// Bail if activating from network, or bulk
385
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
385
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
386 386
 			return;
387 387
 		}
388 388
 
389
-	    update_option( 'wpinv_redirected_to_settings', 1 );
389
+	    update_option('wpinv_redirected_to_settings', 1);
390 390
 
391
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
391
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
392 392
         exit;
393 393
 
394 394
 	}
@@ -397,10 +397,10 @@  discard block
 block discarded – undo
397 397
      * Fires an admin action after verifying that a user can fire them.
398 398
      */
399 399
     public function maybe_do_admin_action() {
400
-        if ( isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) && wpinv_current_user_can( sanitize_text_field( $_REQUEST['getpaid-admin-action'] ), $_REQUEST ) ) {
401
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
400
+        if (isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce') && wpinv_current_user_can(sanitize_text_field($_REQUEST['getpaid-admin-action']), $_REQUEST)) {
401
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
402 402
 
403
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
403
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
404 404
         }
405 405
     }
406 406
 
@@ -409,24 +409,24 @@  discard block
 block discarded – undo
409 409
 	 *
410 410
 	 * @param array $args
411 411
      */
412
-    public function duplicate_invoice( $args ) {
412
+    public function duplicate_invoice($args) {
413 413
 
414
-		if ( empty( $args['invoice_id'] ) ) {
414
+		if (empty($args['invoice_id'])) {
415 415
 			return;
416 416
 		}
417 417
 
418
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
418
+		$invoice = new WPInv_Invoice((int) $args['invoice_id']);
419 419
 
420
-		if ( ! $invoice->exists() ) {
420
+		if (!$invoice->exists()) {
421 421
 			return;
422 422
 		}
423 423
 
424
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
424
+		$new_invoice = getpaid_duplicate_invoice($invoice);
425 425
 		$new_invoice->save();
426 426
 
427
-		if ( $new_invoice->exists() ) {
427
+		if ($new_invoice->exists()) {
428 428
 
429
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) );
429
+			getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'invoicing'));
430 430
 
431 431
 			wp_safe_redirect(
432 432
 				add_query_arg(
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
 						'action' => 'edit',
435 435
 						'post'   => $new_invoice->get_id(),
436 436
 					),
437
-					admin_url( 'post.php' )
437
+					admin_url('post.php')
438 438
 				)
439 439
 			);
440 440
 			exit;
441 441
 
442 442
 		}
443 443
 
444
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) );
444
+		getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'invoicing'));
445 445
 
446 446
 	}
447 447
 
@@ -450,40 +450,40 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @param array $args
452 452
      */
453
-    public function refund_invoice( $args ) {
453
+    public function refund_invoice($args) {
454 454
 
455
-		if ( empty( $args['invoice_id'] ) ) {
455
+		if (empty($args['invoice_id'])) {
456 456
 			return;
457 457
 		}
458 458
 
459
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
459
+		$invoice = new WPInv_Invoice((int) $args['invoice_id']);
460 460
 
461
-		if ( ! $invoice->exists() || $invoice->is_refunded() ) {
461
+		if (!$invoice->exists() || $invoice->is_refunded()) {
462 462
 			return;
463 463
 		}
464 464
 
465 465
 		$invoice->refund();
466 466
 
467 467
 		// Refund remotely.
468
-		if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) {
469
-			do_action( 'getpaid_refund_invoice_remotely', $invoice );
468
+		if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds') && !empty($args['getpaid_refund_remote'])) {
469
+			do_action('getpaid_refund_invoice_remotely', $invoice);
470 470
 		}
471 471
 
472 472
 		// Cancel subscriptions.
473
-		if ( ! empty( $args['getpaid_cancel_subscription'] ) ) {
474
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
473
+		if (!empty($args['getpaid_cancel_subscription'])) {
474
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
475 475
 
476
-			if ( ! empty( $subscriptions ) ) {
477
-				if ( ! is_array( $subscriptions ) ) {
478
-					$subscriptions = array( $subscriptions );
476
+			if (!empty($subscriptions)) {
477
+				if (!is_array($subscriptions)) {
478
+					$subscriptions = array($subscriptions);
479 479
 				}
480 480
 
481
-				foreach ( $subscriptions as $subscription ) {
481
+				foreach ($subscriptions as $subscription) {
482 482
 					$subscription->cancel();
483 483
 					$invoice->add_system_note(
484 484
 						sprintf(
485 485
 							// translators: %s: subscription ID.
486
-							__( 'Subscription #%s cancelled', 'invoicing' ),
486
+							__('Subscription #%s cancelled', 'invoicing'),
487 487
 							$subscription->get_id()
488 488
 						)
489 489
 					);
@@ -492,11 +492,11 @@  discard block
 block discarded – undo
492 492
 		}
493 493
 
494 494
 		// Add notice.
495
-		$this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) );
495
+		$this->show_success(__('Invoice refunded successfully.', 'invoicing'));
496 496
 
497 497
 		// Redirect.
498 498
 		wp_safe_redirect(
499
-			remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) )
499
+			remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote'))
500 500
 		);
501 501
 	}
502 502
 
@@ -505,34 +505,34 @@  discard block
 block discarded – undo
505 505
 	 *
506 506
 	 * @param array $args
507 507
      */
508
-    public function duplicate_payment_form( $args ) {
508
+    public function duplicate_payment_form($args) {
509 509
 
510
-		if ( empty( $args['form_id'] ) ) {
510
+		if (empty($args['form_id'])) {
511 511
 			return;
512 512
 		}
513 513
 
514
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
514
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
515 515
 
516
-		if ( ! $form->exists() ) {
516
+		if (!$form->exists()) {
517 517
 			return;
518 518
 		}
519 519
 
520 520
 		$new_form = new GetPaid_Payment_Form();
521
-		$new_form->set_author( $form->get_author( 'edit' ) );
522
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
523
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
524
-		$new_form->set_items( $form->get_items( 'edit' ) );
521
+		$new_form->set_author($form->get_author('edit'));
522
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
523
+		$new_form->set_elements($form->get_elements('edit'));
524
+		$new_form->set_items($form->get_items('edit'));
525 525
 		$new_form->save();
526 526
 
527
-		if ( $new_form->exists() ) {
528
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
529
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
527
+		if ($new_form->exists()) {
528
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
529
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
530 530
 		} else {
531
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
532
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
531
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
532
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
533 533
 		}
534 534
 
535
-		wp_redirect( $url );
535
+		wp_redirect($url);
536 536
 		exit;
537 537
 	}
538 538
 
@@ -541,27 +541,27 @@  discard block
 block discarded – undo
541 541
 	 *
542 542
 	 * @param array $args
543 543
      */
544
-    public function reset_form_stats( $args ) {
544
+    public function reset_form_stats($args) {
545 545
 
546
-		if ( empty( $args['form_id'] ) ) {
546
+		if (empty($args['form_id'])) {
547 547
 			return;
548 548
 		}
549 549
 
550
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
550
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
551 551
 
552
-		if ( ! $form->exists() ) {
552
+		if (!$form->exists()) {
553 553
 			return;
554 554
 		}
555 555
 
556
-		$form->set_earned( 0 );
557
-		$form->set_refunded( 0 );
558
-		$form->set_cancelled( 0 );
559
-		$form->set_failed( 0 );
556
+		$form->set_earned(0);
557
+		$form->set_refunded(0);
558
+		$form->set_cancelled(0);
559
+		$form->set_failed(0);
560 560
 		$form->save();
561 561
 
562
-		$this->show_success( __( 'Form stats reset successfully', 'invoicing' ) );
562
+		$this->show_success(__('Form stats reset successfully', 'invoicing'));
563 563
 
564
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) );
564
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')));
565 565
 		exit;
566 566
 	}
567 567
 
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
 	 *
571 571
 	 * @param array $args
572 572
      */
573
-    public function send_customer_invoice( $args ) {
574
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
575
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
573
+    public function send_customer_invoice($args) {
574
+		getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
575
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
576 576
 		exit;
577 577
 	}
578 578
 
@@ -581,16 +581,16 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @param array $args
583 583
      */
584
-    public function send_customer_payment_reminder( $args ) {
585
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
584
+    public function send_customer_payment_reminder($args) {
585
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
586 586
 
587
-		if ( $sent ) {
588
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
587
+		if ($sent) {
588
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
589 589
 		} else {
590
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
590
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
591 591
 		}
592 592
 
593
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
593
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
594 594
 		exit;
595 595
 	}
596 596
 
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
      */
601 601
     public function admin_reset_tax_rates() {
602 602
 
603
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
604
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
603
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
604
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
605 605
 		exit;
606 606
 
607 607
 	}
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
     public function admin_create_missing_pages() {
614 614
 		$installer = new GetPaid_Installer();
615 615
 		$installer->create_pages();
616
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
617
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
616
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
617
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
618 618
 		exit;
619 619
 	}
620 620
 
@@ -623,8 +623,8 @@  discard block
 block discarded – undo
623 623
 	 */
624 624
 	public function admin_refresh_permalinks() {
625 625
 		flush_rewrite_rules();
626
-		$this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) );
627
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
626
+		$this->show_success(__('Permalinks refreshed.', 'invoicing'));
627
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
628 628
 		exit;
629 629
 	}
630 630
 
@@ -638,13 +638,13 @@  discard block
 block discarded – undo
638 638
 		GetPaid_Installer::create_db_tables();
639 639
 		GetPaid_Installer::migrate_old_customers();
640 640
 
641
-		if ( '' !== $wpdb->last_error ) {
642
-			$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
641
+		if ('' !== $wpdb->last_error) {
642
+			$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
643 643
 		} else {
644
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
644
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
645 645
 		}
646 646
 
647
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
647
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
648 648
 		exit;
649 649
 	}
650 650
 
@@ -659,10 +659,10 @@  discard block
 block discarded – undo
659 659
 		$installer->migrate_old_invoices();
660 660
 
661 661
 		// Show an admin message.
662
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
662
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
663 663
 
664 664
 		// Redirect the admin.
665
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
665
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
666 666
 		exit;
667 667
 
668 668
 	}
@@ -673,35 +673,35 @@  discard block
 block discarded – undo
673 673
      */
674 674
     public function admin_download_customers() {
675 675
 
676
-		$output = fopen( 'php://output', 'w' );
676
+		$output = fopen('php://output', 'w');
677 677
 
678
-		if ( false === $output ) {
679
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
678
+		if (false === $output) {
679
+			wp_die(esc_html__('Unsupported server', 'invoicing'), 500);
680 680
 		}
681 681
 
682
-		header( 'Content-Type:text/csv' );
683
-		header( 'Content-Disposition:attachment;filename=customers.csv' );
682
+		header('Content-Type:text/csv');
683
+		header('Content-Disposition:attachment;filename=customers.csv');
684 684
 
685 685
 		/** @var GetPaid_Customer[] $customers */
686
-		$customers = getpaid_get_customers( array( 'number' => -1 ) );
687
-		$columns   = array_keys( GetPaid_Customer_Data_Store::get_database_fields() );
686
+		$customers = getpaid_get_customers(array('number' => -1));
687
+		$columns   = array_keys(GetPaid_Customer_Data_Store::get_database_fields());
688 688
 
689 689
 		// Output the csv column headers.
690
-		fputcsv( $output, $columns );
690
+		fputcsv($output, $columns);
691 691
 
692 692
 		// Loop through
693
-		foreach ( $customers as $customer ) {
693
+		foreach ($customers as $customer) {
694 694
 
695
-			$row  = array();
695
+			$row = array();
696 696
 
697
-			foreach ( $columns as $column ) {
698
-				$row[]  = (string) maybe_serialize( $customer->get( $column, 'edit' ) );
697
+			foreach ($columns as $column) {
698
+				$row[] = (string) maybe_serialize($customer->get($column, 'edit'));
699 699
 			}
700 700
 
701
-			fputcsv( $output, $row );
701
+			fputcsv($output, $row);
702 702
 		}
703 703
 
704
-		fclose( $output );
704
+		fclose($output);
705 705
 		exit;
706 706
 
707 707
 	}
@@ -711,27 +711,27 @@  discard block
 block discarded – undo
711 711
 	 *
712 712
 	 * @param array $data
713 713
      */
714
-    public function admin_install_plugin( $data ) {
714
+    public function admin_install_plugin($data) {
715 715
 
716
-		if ( ! empty( $data['plugins'] ) ) {
716
+		if (!empty($data['plugins'])) {
717 717
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
718 718
 			wp_cache_flush();
719 719
 
720
-			foreach ( $data['plugins'] as $slug => $file ) {
721
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
722
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
723
-				$installed  = $upgrader->install( $plugin_zip );
720
+			foreach ($data['plugins'] as $slug => $file) {
721
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
722
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
723
+				$installed  = $upgrader->install($plugin_zip);
724 724
 
725
-				if ( ! is_wp_error( $installed ) && $installed ) {
726
-					activate_plugin( $file, '', false, true );
725
+				if (!is_wp_error($installed) && $installed) {
726
+					activate_plugin($file, '', false, true);
727 727
 				} else {
728
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
728
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
729 729
 				}
730 730
 }
731 731
 }
732 732
 
733
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
734
-		wp_safe_redirect( $redirect );
733
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
734
+		wp_safe_redirect($redirect);
735 735
 		exit;
736 736
 
737 737
 	}
@@ -741,41 +741,41 @@  discard block
 block discarded – undo
741 741
 	 *
742 742
 	 * @param array $data
743 743
      */
744
-    public function admin_connect_gateway( $data ) {
744
+    public function admin_connect_gateway($data) {
745 745
 
746
-		if ( ! empty( $data['plugin'] ) ) {
746
+		if (!empty($data['plugin'])) {
747 747
 
748
-			$gateway     = sanitize_key( $data['plugin'] );
749
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
748
+			$gateway     = sanitize_key($data['plugin']);
749
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
750 750
 
751
-			if ( ! empty( $connect_url ) ) {
752
-				wp_redirect( $connect_url );
751
+			if (!empty($connect_url)) {
752
+				wp_redirect($connect_url);
753 753
 				exit;
754 754
 			}
755 755
 
756
-			if ( 'stripe' == $data['plugin'] ) {
756
+			if ('stripe' == $data['plugin']) {
757 757
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
758 758
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
759 759
 				wp_cache_flush();
760 760
 
761
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
762
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
763
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
764
-					$upgrader->install( $plugin_zip );
761
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
762
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
763
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
764
+					$upgrader->install($plugin_zip);
765 765
 				}
766 766
 
767
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
767
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
768 768
 			}
769 769
 
770
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
771
-			if ( ! empty( $connect_url ) ) {
772
-				wp_redirect( $connect_url );
770
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
771
+			if (!empty($connect_url)) {
772
+				wp_redirect($connect_url);
773 773
 				exit;
774 774
 			}
775 775
 }
776 776
 
777
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
778
-		wp_safe_redirect( $redirect );
777
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
778
+		wp_safe_redirect($redirect);
779 779
 		exit;
780 780
 
781 781
 	}
@@ -789,35 +789,35 @@  discard block
 block discarded – undo
789 789
 
790 790
 		// Fetch all invoices that have discount codes.
791 791
 		$table    = $wpdb->prefix . 'getpaid_invoices';
792
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
792
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
793 793
 
794
-		foreach ( $invoices as $invoice ) {
794
+		foreach ($invoices as $invoice) {
795 795
 
796
-			$invoice = new WPInv_Invoice( $invoice );
796
+			$invoice = new WPInv_Invoice($invoice);
797 797
 
798
-			if ( ! $invoice->exists() ) {
798
+			if (!$invoice->exists()) {
799 799
 				continue;
800 800
 			}
801 801
 
802 802
 			// Abort if the discount does not exist or does not apply here.
803
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
804
-			if ( ! $discount->exists() ) {
803
+			$discount = new WPInv_Discount($invoice->get_discount_code());
804
+			if (!$discount->exists()) {
805 805
 				continue;
806 806
 			}
807 807
 
808
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
808
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
809 809
 			$invoice->recalculate_total();
810 810
 
811
-			if ( $invoice->get_total_discount() > 0 ) {
811
+			if ($invoice->get_total_discount() > 0) {
812 812
 				$invoice->save();
813 813
 			}
814 814
 }
815 815
 
816 816
 		// Show an admin message.
817
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
817
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
818 818
 
819 819
 		// Redirect the admin.
820
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
820
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
821 821
 		exit;
822 822
 
823 823
 	}
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
      * @return array
830 830
 	 */
831 831
 	public function get_notices() {
832
-		$notices = get_option( 'wpinv_admin_notices' );
833
-        return is_array( $notices ) ? $notices : array();
832
+		$notices = get_option('wpinv_admin_notices');
833
+        return is_array($notices) ? $notices : array();
834 834
 	}
835 835
 
836 836
 	/**
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
      * @return array
841 841
 	 */
842 842
 	public function has_notices() {
843
-		return count( $this->get_notices() ) > 0;
843
+		return count($this->get_notices()) > 0;
844 844
 	}
845 845
 
846 846
 	/**
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 * @since       1.0.19
851 851
 	 */
852 852
 	public function clear_notices() {
853
-		delete_option( 'wpinv_admin_notices' );
853
+		delete_option('wpinv_admin_notices');
854 854
 	}
855 855
 
856 856
 	/**
@@ -859,16 +859,16 @@  discard block
 block discarded – undo
859 859
 	 * @access      public
860 860
 	 * @since       1.0.19
861 861
 	 */
862
-	public function save_notice( $type, $message ) {
862
+	public function save_notice($type, $message) {
863 863
 		$notices = $this->get_notices();
864 864
 
865
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
866
-			$notices[ $type ] = array();
865
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
866
+			$notices[$type] = array();
867 867
 		}
868 868
 
869
-		$notices[ $type ][] = $message;
869
+		$notices[$type][] = $message;
870 870
 
871
-		update_option( 'wpinv_admin_notices', $notices );
871
+		update_option('wpinv_admin_notices', $notices);
872 872
 	}
873 873
 
874 874
 	/**
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	 * @access      public
879 879
 	 * @since       1.0.19
880 880
 	 */
881
-	public function show_success( $msg ) {
882
-		$this->save_notice( 'success', $msg );
881
+	public function show_success($msg) {
882
+		$this->save_notice('success', $msg);
883 883
 	}
884 884
 
885 885
 	/**
@@ -889,8 +889,8 @@  discard block
 block discarded – undo
889 889
 	 * @param       string $msg The message to qeue.
890 890
 	 * @since       1.0.19
891 891
 	 */
892
-	public function show_error( $msg ) {
893
-		$this->save_notice( 'error', $msg );
892
+	public function show_error($msg) {
893
+		$this->save_notice('error', $msg);
894 894
 	}
895 895
 
896 896
 	/**
@@ -900,8 +900,8 @@  discard block
 block discarded – undo
900 900
 	 * @param       string $msg The message to qeue.
901 901
 	 * @since       1.0.19
902 902
 	 */
903
-	public function show_warning( $msg ) {
904
-		$this->save_notice( 'warning', $msg );
903
+	public function show_warning($msg) {
904
+		$this->save_notice('warning', $msg);
905 905
 	}
906 906
 
907 907
 	/**
@@ -911,8 +911,8 @@  discard block
 block discarded – undo
911 911
 	 * @param       string $msg The message to qeue.
912 912
 	 * @since       1.0.19
913 913
 	 */
914
-	public function show_info( $msg ) {
915
-		$this->save_notice( 'info', $msg );
914
+	public function show_info($msg) {
915
+		$this->save_notice('info', $msg);
916 916
 	}
917 917
 
918 918
 	/**
@@ -926,29 +926,29 @@  discard block
 block discarded – undo
926 926
         $notices = $this->get_notices();
927 927
         $this->clear_notices();
928 928
 
929
-		foreach ( $notices as $type => $messages ) {
929
+		foreach ($notices as $type => $messages) {
930 930
 
931
-			if ( ! is_array( $messages ) ) {
931
+			if (!is_array($messages)) {
932 932
 				continue;
933 933
 			}
934 934
 
935
-            $type  = esc_attr( $type );
936
-			foreach ( $messages as $message ) {
937
-				echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
935
+            $type = esc_attr($type);
936
+			foreach ($messages as $message) {
937
+				echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>");
938 938
             }
939 939
 }
940 940
 
941
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
941
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
942 942
 
943
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
944
-				$url     = wp_nonce_url(
945
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
943
+			if (!is_numeric(wpinv_get_option($page, false))) {
944
+				$url = wp_nonce_url(
945
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
946 946
 					'getpaid-nonce',
947 947
 					'getpaid-nonce'
948 948
 				);
949
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
950
-				$message2 = __( 'Generate Pages', 'invoicing' );
951
-				echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
949
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
950
+				$message2 = __('Generate Pages', 'invoicing');
951
+				echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>");
952 952
 				break;
953 953
 			}
954 954
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +615 added lines, -615 removed lines patch added patch discarded remove patch
@@ -14,619 +14,619 @@
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * @var array An array of payment gateways.
40
-	 */
41
-	public $gateways;
42
-
43
-	/**
44
-	 * Class constructor.
45
-	 */
46
-	public function __construct() {
47
-		$this->define_constants();
48
-		$this->includes();
49
-		$this->init_hooks();
50
-		$this->set_properties();
51
-	}
52
-
53
-	/**
54
-	 * Sets a custom data property.
55
-	 *
56
-	 * @param string $prop The prop to set.
57
-	 * @param mixed $value The value to retrieve.
58
-	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
61
-	}
62
-
63
-	/**
64
-	 * Gets a custom data property.
65
-	 *
66
-	 * @param string $prop The prop to set.
67
-	 * @return mixed The value.
68
-	 */
69
-	public function get( $prop ) {
70
-		if ( isset( $this->data[ $prop ] ) ) {
71
-			return $this->data[ $prop ];
72
-		}
73
-
74
-		return null;
75
-	}
76
-
77
-	/**
78
-	 * Define class properties.
79
-	 */
80
-	public function set_properties() {
81
-		// Sessions.
82
-		$this->set( 'session', new WPInv_Session_Handler() );
83
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
-		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
85
-
86
-		// Init other objects.
87
-		$this->set( 'notes', new WPInv_Notes() );
88
-		$this->set( 'api', new WPInv_API() );
89
-		$this->set( 'post_types', new GetPaid_Post_Types() );
90
-		$this->set( 'template', new GetPaid_Template() );
91
-		$this->set( 'admin', new GetPaid_Admin() );
92
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
93
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
94
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
95
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
96
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
97
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
98
-	}
99
-
100
-	 /**
101
-	 * Define plugin constants.
102
-	 */
103
-	public function define_constants() {
104
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
105
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
106
-		$this->version = WPINV_VERSION;
107
-	}
108
-
109
-	/**
110
-	 * Hook into actions and filters.
111
-	 *
112
-	 * @since 1.0.19
113
-	 */
114
-	protected function init_hooks() {
115
-		/* Internationalize the text strings used. */
116
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
117
-
118
-		// Init the plugin after WordPress inits.
119
-		add_action( 'init', array( $this, 'init' ), 1 );
120
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
121
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
122
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
123
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
124
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
125
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
126
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
127
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
128
-		add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
129
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
130
-
131
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
132
-		add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
133
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
134
-
135
-		// Fires after registering actions.
136
-		do_action( 'wpinv_actions', $this );
137
-		do_action( 'getpaid_actions', $this );
138
-	}
139
-
140
-	public function plugins_loaded() {
141
-		/* Internationalize the text strings used. */
142
-		$this->load_textdomain();
143
-
144
-		do_action( 'wpinv_loaded' );
145
-
146
-		// Fix oxygen page builder conflict
147
-		if ( function_exists( 'ct_css_output' ) ) {
148
-			wpinv_oxygen_fix_conflict();
149
-		}
150
-	}
151
-
152
-	/**
153
-	 * Load Localisation files.
154
-	 *
155
-	 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
156
-	 *
157
-	 * Locales found in:
158
-	 *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
159
-	 *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
160
-	 *
161
-	 * @since 1.0.0
162
-	 */
163
-	public function load_textdomain() {
164
-		// Determines the current locale.
165
-		if ( function_exists( 'determine_locale' ) ) {
166
-			$locale = determine_locale();
167
-		} else if ( function_exists( 'get_user_locale' ) ) {
168
-			$locale = get_user_locale();
169
-		} else {
170
-			$locale = get_locale();
171
-		}
172
-
173
-		/**
174
-		 * Filter the locale to use for translations.
175
-		 */
176
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
-
178
-		unload_textdomain( 'invoicing', true );
179
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
-		load_plugin_textdomain( 'invoicing', false, plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' );
181
-	}
182
-
183
-	/**
184
-	 * Include required core files used in admin and on the frontend.
185
-	 */
186
-	public function includes() {
187
-		// Start with the settings.
188
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php';
189
-
190
-		// Packages/libraries.
191
-		require_once WPINV_PLUGIN_DIR . 'vendor/autoload.php';
192
-		require_once WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php';
193
-
194
-		// Load functions.
195
-		require_once WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php';
196
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php';
197
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php';
198
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php';
199
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php';
200
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php';
201
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php';
202
-		require_once WPINV_PLUGIN_DIR . 'includes/invoice-functions.php';
203
-		require_once WPINV_PLUGIN_DIR . 'includes/subscription-functions.php';
204
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php';
205
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php';
206
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php';
207
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php';
208
-		require_once WPINV_PLUGIN_DIR . 'includes/user-functions.php';
209
-		require_once WPINV_PLUGIN_DIR . 'includes/error-functions.php';
210
-
211
-		// Register autoloader.
212
-		try {
213
-			spl_autoload_register( array( $this, 'autoload' ), true );
214
-		} catch ( Exception $e ) {
215
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
216
-		}
217
-
218
-		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
219
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php';
220
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php';
221
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php';
222
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php';
223
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php';
224
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php';
225
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php';
226
-		require_once WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php';
227
-		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php';
228
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php';
229
-		require_once WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php';
230
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php';
231
-		require_once WPINV_PLUGIN_DIR . 'widgets/checkout.php';
232
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-history.php';
233
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php';
234
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php';
235
-		require_once WPINV_PLUGIN_DIR . 'widgets/subscriptions.php';
236
-		require_once WPINV_PLUGIN_DIR . 'widgets/buy-item.php';
237
-		require_once WPINV_PLUGIN_DIR . 'widgets/getpaid.php';
238
-		require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
239
-		require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
240
-
241
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
242
-			GetPaid_Post_Types_Admin::init();
243
-
244
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
245
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php';
246
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php';
247
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php';
248
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php';
249
-			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
250
-			// load the user class only on the users.php page
251
-			global $pagenow;
252
-			if ( $pagenow == 'users.php' ) {
253
-				new WPInv_Admin_Users();
254
-			}
255
-		}
256
-
257
-		// Register cli commands
258
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
259
-			require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
260
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
261
-		}
262
-	}
263
-
264
-	/**
265
-	 * Class autoloader
266
-	 *
267
-	 * @param       string $class_name The name of the class to load.
268
-	 * @access      public
269
-	 * @since       1.0.19
270
-	 * @return      void
271
-	 */
272
-	public function autoload( $class_name ) {
273
-		// Normalize the class name...
274
-		$class_name  = strtolower( $class_name );
275
-
276
-		// ... and make sure it is our class.
277
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
278
-			return;
279
-		}
280
-
281
-		// Next, prepare the file name from the class.
282
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
283
-
284
-		// Base path of the classes.
285
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
286
-
287
-		// And an array of possible locations in order of importance.
288
-		$locations = array(
289
-			"$plugin_path/includes",
290
-			"$plugin_path/includes/data-stores",
291
-			"$plugin_path/includes/gateways",
292
-			"$plugin_path/includes/payments",
293
-			"$plugin_path/includes/geolocation",
294
-			"$plugin_path/includes/reports",
295
-			"$plugin_path/includes/api",
296
-			"$plugin_path/includes/admin",
297
-			"$plugin_path/includes/admin/meta-boxes",
298
-		);
299
-
300
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
301
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
302
-				include trailingslashit( $location ) . $file_name;
303
-				break;
304
-			}
305
-		}
306
-	}
307
-
308
-	/**
309
-	 * Inits hooks etc.
310
-	 */
311
-	public function init() {
312
-		// Fires before getpaid inits.
313
-		do_action( 'before_getpaid_init', $this );
314
-
315
-		// Maybe upgrade.
316
-		$this->maybe_upgrade_database();
317
-
318
-		// Load default gateways.
319
-		$gateways = apply_filters(
320
-			'getpaid_default_gateways',
321
-			array(
322
-				'manual'        => 'GetPaid_Manual_Gateway',
323
-				'paypal'        => 'GetPaid_Paypal_Gateway',
324
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
325
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
326
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
327
-			)
328
-		);
329
-
330
-		foreach ( $gateways as $id => $class ) {
331
-			$this->gateways[ $id ] = new $class();
332
-		}
333
-
334
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
-			GetPaid_Installer::rename_gateways_label();
336
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
-		}
338
-
339
-		// Fires after getpaid inits.
340
-		do_action( 'getpaid_init', $this );
341
-	}
342
-
343
-	/**
344
-	 * Checks if this is an IPN request and processes it.
345
-	 */
346
-	public function maybe_process_ipn() {
347
-		// Ensure that this is an IPN request.
348
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
349
-			return;
350
-		}
351
-
352
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
353
-
354
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
355
-		do_action( "wpinv_verify_{$gateway}_ipn" );
356
-		exit;
357
-	}
358
-
359
-	public function enqueue_scripts() {
360
-		// Fires before adding scripts.
361
-		do_action( 'getpaid_enqueue_scripts' );
362
-
363
-		$localize                         = array();
364
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
365
-		$localize['thousands']            = wpinv_thousands_separator();
366
-		$localize['decimals']             = wpinv_decimal_separator();
367
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
368
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
369
-		$localize['UseTaxes']             = wpinv_use_taxes();
370
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
371
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
372
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
373
-		$localize['recaptchaSettings']    = getpaid_get_recaptcha_settings();
374
-
375
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
376
-
377
-		// reCaptcha.
378
-		if ( getpaid_is_recaptcha_enabled() && ( $recaptcha_js = getpaid_recaptcha_api_url() ) ) {
379
-			wp_enqueue_script( 'recaptcha', $recaptcha_js, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
380
-		}
381
-
382
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array( 'jquery' ), WPINV_VERSION, true );
383
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
384
-	}
385
-
386
-	public function wpinv_actions() {
387
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
388
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
389
-		}
390
-
391
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
392
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
393
-		}
394
-	}
395
-
396
-	/**
397
-	 * Fires an action after verifying that a user can fire them.
398
-	 *
399
-	 * Note: If the action is on an invoice, subscription etc, esure that the
400
-	 * current user owns the invoice/subscription.
401
-	 */
402
-	public function maybe_do_authenticated_action() {
403
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
404
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
405
-			$data = wp_unslash( $_REQUEST );
406
-
407
-			if ( is_user_logged_in() ) {
408
-				do_action( "getpaid_authenticated_action_$key", $data );
409
-			}
410
-
411
-			do_action( "getpaid_unauthenticated_action_$key", $data );
412
-		}
413
-	}
414
-
415
-	public function pre_get_posts( $wp_query ) {
416
-		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() ) {
417
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
418
-		}
419
-
420
-		return $wp_query;
421
-	}
422
-
423
-	/**
424
-	 * Register widgets
425
-	 *
426
-	 */
427
-	public function register_widgets() {
428
-		global $pagenow;
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
-		$block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
437
-
438
-		if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
439
-			// don't initiate in these conditions.
440
-		} else {
441
-			// Only load allowed widgets.
442
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
443
-			$widgets = apply_filters(
444
-				'getpaid_widget_classes',
445
-				array(
446
-					'WPInv_Checkout_Widget',
447
-					'WPInv_History_Widget',
448
-					'WPInv_Receipt_Widget',
449
-					'WPInv_Subscriptions_Widget',
450
-					'WPInv_Buy_Item_Widget',
451
-					'WPInv_Messages_Widget',
452
-					'WPInv_GetPaid_Widget',
453
-					'WPInv_Invoice_Widget',
454
-				)
455
-			);
456
-
457
-			// For each widget...
458
-			foreach ( $widgets as $widget ) {
459
-				// Abort early if it is excluded for this page.
460
-				if ( in_array( $widget, $exclude ) ) {
461
-					continue;
462
-				}
463
-
464
-				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
465
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
466
-					register_widget( $widget );
467
-				} else {
468
-					new $widget();
469
-				}
470
-			}
471
-		}
472
-	}
473
-
474
-	/**
475
-	 * Upgrades the database.
476
-	 *
477
-	 * @since 2.0.2
478
-	 */
479
-	public function maybe_upgrade_database() {
480
-		// Ensure the database tables are up to date.
481
-		GetPaid_Installer::maybe_create_db_tables();
482
-
483
-		$wpi_version = get_option( 'wpinv_version', 0 );
484
-
485
-		if ( $wpi_version == WPINV_VERSION ) {
486
-			return;
487
-		}
488
-
489
-		$installer = new GetPaid_Installer();
490
-
491
-		if ( empty( $wpi_version ) ) {
492
-			return $installer->upgrade_db( 0 );
493
-		}
494
-
495
-		$upgrades  = array(
496
-			'0.0.5' => '004',
497
-			'1.0.3' => '102',
498
-			'2.0.0' => '118',
499
-			'2.8.0' => '279',
500
-		);
501
-
502
-		foreach ( $upgrades as $key => $method ) {
503
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
504
-				return $installer->upgrade_db( $method );
505
-			}
506
-		}
507
-	}
508
-
509
-	/**
510
-	 * Flushes the permalinks if needed.
511
-	 *
512
-	 * @since 2.0.8
513
-	 */
514
-	public function maybe_flush_permalinks() {
515
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
516
-
517
-		if ( ! empty( $flush ) ) {
518
-			flush_rewrite_rules();
519
-			delete_option( 'wpinv_flush_permalinks' );
520
-		}
521
-	}
522
-
523
-	/**
524
-	 * Remove our pages from yoast sitemaps.
525
-	 *
526
-	 * @since 1.0.19
527
-	 * @param int[] $excluded_posts_ids
528
-	 */
529
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
530
-		// Ensure that we have an array.
531
-		if ( ! is_array( $excluded_posts_ids ) ) {
532
-			$excluded_posts_ids = array();
533
-		}
534
-
535
-		// Prepare our pages.
536
-		$our_pages = array();
537
-
538
-		// Checkout page.
539
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
540
-
541
-		// Success page.
542
-		$our_pages[] = wpinv_get_option( 'success_page', false );
543
-
544
-		// Failure page.
545
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
546
-
547
-		// History page.
548
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
549
-
550
-		// Subscriptions page.
551
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
552
-
553
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
554
-
555
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
556
-
557
-		return array_unique( $excluded_posts_ids );
558
-	}
559
-
560
-	/**
561
-	 * Remove our pages from yoast sitemaps.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @param string[] $post_types
565
-	 */
566
-	public function exclude_invoicing_post_types( $post_types ) {
567
-		// Ensure that we have an array.
568
-		if ( ! is_array( $post_types ) ) {
569
-			$post_types = array();
570
-		}
571
-
572
-		// Remove our post types.
573
-		return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
574
-	}
575
-
576
-	/**
577
-	 * Displays additional footer code.
578
-	 *
579
-	 * @since 2.0.0
580
-	 */
581
-	public function wp_footer() {
582
-		wpinv_get_template( 'frontend-footer.php' );
583
-	}
584
-
585
-	/**
586
-	 * Displays additional header code.
587
-	 *
588
-	 * @since 2.0.0
589
-	 */
590
-	public function wp_head() {
591
-		wpinv_get_template( 'frontend-head.php' );
592
-	}
593
-
594
-	/**
595
-	 * Custom query vars.
596
-	 *
597
-	 */
598
-	public function custom_query_vars( $vars ) {
599
-		$vars[] = 'getpaid-ipn';
600
-		return $vars;
601
-	}
602
-
603
-	/**
604
-	 * Add rewrite tags and rules.
605
-	 *
606
-	 */
607
-	public function add_rewrite_rule() {
608
-		$tag = 'getpaid-ipn';
609
-		add_rewrite_tag( "%$tag%", '([^&]+)' );
610
-		add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
611
-	}
612
-
613
-	/**
614
-	 * Processes non-query string ipns.
615
-	 *
616
-	 */
617
-	public function maybe_process_new_ipn( $query ) {
618
-		if ( is_admin() || ! $query->is_main_query() ) {
619
-			return;
620
-		}
621
-
622
-		$gateway = get_query_var( 'getpaid-ipn' );
623
-
624
-		if ( ! empty( $gateway ) ) {
625
-			$gateway = sanitize_text_field( $gateway );
626
-			nocache_headers();
627
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
628
-			do_action( "wpinv_verify_{$gateway}_ipn" );
629
-			exit;
630
-		}
631
-	}
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * @var array An array of payment gateways.
40
+     */
41
+    public $gateways;
42
+
43
+    /**
44
+     * Class constructor.
45
+     */
46
+    public function __construct() {
47
+        $this->define_constants();
48
+        $this->includes();
49
+        $this->init_hooks();
50
+        $this->set_properties();
51
+    }
52
+
53
+    /**
54
+     * Sets a custom data property.
55
+     *
56
+     * @param string $prop The prop to set.
57
+     * @param mixed $value The value to retrieve.
58
+     */
59
+    public function set( $prop, $value ) {
60
+        $this->data[ $prop ] = $value;
61
+    }
62
+
63
+    /**
64
+     * Gets a custom data property.
65
+     *
66
+     * @param string $prop The prop to set.
67
+     * @return mixed The value.
68
+     */
69
+    public function get( $prop ) {
70
+        if ( isset( $this->data[ $prop ] ) ) {
71
+            return $this->data[ $prop ];
72
+        }
73
+
74
+        return null;
75
+    }
76
+
77
+    /**
78
+     * Define class properties.
79
+     */
80
+    public function set_properties() {
81
+        // Sessions.
82
+        $this->set( 'session', new WPInv_Session_Handler() );
83
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
+        $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
85
+
86
+        // Init other objects.
87
+        $this->set( 'notes', new WPInv_Notes() );
88
+        $this->set( 'api', new WPInv_API() );
89
+        $this->set( 'post_types', new GetPaid_Post_Types() );
90
+        $this->set( 'template', new GetPaid_Template() );
91
+        $this->set( 'admin', new GetPaid_Admin() );
92
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
93
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
94
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
95
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
96
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
97
+        $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
98
+    }
99
+
100
+        /**
101
+         * Define plugin constants.
102
+         */
103
+    public function define_constants() {
104
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
105
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
106
+        $this->version = WPINV_VERSION;
107
+    }
108
+
109
+    /**
110
+     * Hook into actions and filters.
111
+     *
112
+     * @since 1.0.19
113
+     */
114
+    protected function init_hooks() {
115
+        /* Internationalize the text strings used. */
116
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
117
+
118
+        // Init the plugin after WordPress inits.
119
+        add_action( 'init', array( $this, 'init' ), 1 );
120
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
121
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
122
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
123
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
124
+        add_action( 'wp_footer', array( $this, 'wp_footer' ) );
125
+        add_action( 'wp_head', array( $this, 'wp_head' ) );
126
+        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
127
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
128
+        add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
129
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
130
+
131
+        add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
132
+        add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
133
+        add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
134
+
135
+        // Fires after registering actions.
136
+        do_action( 'wpinv_actions', $this );
137
+        do_action( 'getpaid_actions', $this );
138
+    }
139
+
140
+    public function plugins_loaded() {
141
+        /* Internationalize the text strings used. */
142
+        $this->load_textdomain();
143
+
144
+        do_action( 'wpinv_loaded' );
145
+
146
+        // Fix oxygen page builder conflict
147
+        if ( function_exists( 'ct_css_output' ) ) {
148
+            wpinv_oxygen_fix_conflict();
149
+        }
150
+    }
151
+
152
+    /**
153
+     * Load Localisation files.
154
+     *
155
+     * Note: the first-loaded translation file overrides any following ones if the same translation is present.
156
+     *
157
+     * Locales found in:
158
+     *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
159
+     *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
160
+     *
161
+     * @since 1.0.0
162
+     */
163
+    public function load_textdomain() {
164
+        // Determines the current locale.
165
+        if ( function_exists( 'determine_locale' ) ) {
166
+            $locale = determine_locale();
167
+        } else if ( function_exists( 'get_user_locale' ) ) {
168
+            $locale = get_user_locale();
169
+        } else {
170
+            $locale = get_locale();
171
+        }
172
+
173
+        /**
174
+         * Filter the locale to use for translations.
175
+         */
176
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
+
178
+        unload_textdomain( 'invoicing', true );
179
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
+        load_plugin_textdomain( 'invoicing', false, plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' );
181
+    }
182
+
183
+    /**
184
+     * Include required core files used in admin and on the frontend.
185
+     */
186
+    public function includes() {
187
+        // Start with the settings.
188
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php';
189
+
190
+        // Packages/libraries.
191
+        require_once WPINV_PLUGIN_DIR . 'vendor/autoload.php';
192
+        require_once WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php';
193
+
194
+        // Load functions.
195
+        require_once WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php';
196
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php';
197
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php';
198
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php';
199
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php';
200
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php';
201
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php';
202
+        require_once WPINV_PLUGIN_DIR . 'includes/invoice-functions.php';
203
+        require_once WPINV_PLUGIN_DIR . 'includes/subscription-functions.php';
204
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php';
205
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php';
206
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php';
207
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php';
208
+        require_once WPINV_PLUGIN_DIR . 'includes/user-functions.php';
209
+        require_once WPINV_PLUGIN_DIR . 'includes/error-functions.php';
210
+
211
+        // Register autoloader.
212
+        try {
213
+            spl_autoload_register( array( $this, 'autoload' ), true );
214
+        } catch ( Exception $e ) {
215
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
216
+        }
217
+
218
+        require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
219
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php';
220
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php';
221
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php';
222
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php';
223
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php';
224
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php';
225
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php';
226
+        require_once WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php';
227
+        require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php';
228
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php';
229
+        require_once WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php';
230
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php';
231
+        require_once WPINV_PLUGIN_DIR . 'widgets/checkout.php';
232
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-history.php';
233
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php';
234
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php';
235
+        require_once WPINV_PLUGIN_DIR . 'widgets/subscriptions.php';
236
+        require_once WPINV_PLUGIN_DIR . 'widgets/buy-item.php';
237
+        require_once WPINV_PLUGIN_DIR . 'widgets/getpaid.php';
238
+        require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
239
+        require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
240
+
241
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
242
+            GetPaid_Post_Types_Admin::init();
243
+
244
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
245
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php';
246
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php';
247
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php';
248
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php';
249
+            require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
250
+            // load the user class only on the users.php page
251
+            global $pagenow;
252
+            if ( $pagenow == 'users.php' ) {
253
+                new WPInv_Admin_Users();
254
+            }
255
+        }
256
+
257
+        // Register cli commands
258
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
259
+            require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
260
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
261
+        }
262
+    }
263
+
264
+    /**
265
+     * Class autoloader
266
+     *
267
+     * @param       string $class_name The name of the class to load.
268
+     * @access      public
269
+     * @since       1.0.19
270
+     * @return      void
271
+     */
272
+    public function autoload( $class_name ) {
273
+        // Normalize the class name...
274
+        $class_name  = strtolower( $class_name );
275
+
276
+        // ... and make sure it is our class.
277
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
278
+            return;
279
+        }
280
+
281
+        // Next, prepare the file name from the class.
282
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
283
+
284
+        // Base path of the classes.
285
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
286
+
287
+        // And an array of possible locations in order of importance.
288
+        $locations = array(
289
+            "$plugin_path/includes",
290
+            "$plugin_path/includes/data-stores",
291
+            "$plugin_path/includes/gateways",
292
+            "$plugin_path/includes/payments",
293
+            "$plugin_path/includes/geolocation",
294
+            "$plugin_path/includes/reports",
295
+            "$plugin_path/includes/api",
296
+            "$plugin_path/includes/admin",
297
+            "$plugin_path/includes/admin/meta-boxes",
298
+        );
299
+
300
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
301
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
302
+                include trailingslashit( $location ) . $file_name;
303
+                break;
304
+            }
305
+        }
306
+    }
307
+
308
+    /**
309
+     * Inits hooks etc.
310
+     */
311
+    public function init() {
312
+        // Fires before getpaid inits.
313
+        do_action( 'before_getpaid_init', $this );
314
+
315
+        // Maybe upgrade.
316
+        $this->maybe_upgrade_database();
317
+
318
+        // Load default gateways.
319
+        $gateways = apply_filters(
320
+            'getpaid_default_gateways',
321
+            array(
322
+                'manual'        => 'GetPaid_Manual_Gateway',
323
+                'paypal'        => 'GetPaid_Paypal_Gateway',
324
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
325
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
326
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
327
+            )
328
+        );
329
+
330
+        foreach ( $gateways as $id => $class ) {
331
+            $this->gateways[ $id ] = new $class();
332
+        }
333
+
334
+        if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+            GetPaid_Installer::rename_gateways_label();
336
+            update_option( 'wpinv_renamed_gateways', 'yes' );
337
+        }
338
+
339
+        // Fires after getpaid inits.
340
+        do_action( 'getpaid_init', $this );
341
+    }
342
+
343
+    /**
344
+     * Checks if this is an IPN request and processes it.
345
+     */
346
+    public function maybe_process_ipn() {
347
+        // Ensure that this is an IPN request.
348
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
349
+            return;
350
+        }
351
+
352
+        $gateway = sanitize_text_field( $_GET['wpi-gateway'] );
353
+
354
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
355
+        do_action( "wpinv_verify_{$gateway}_ipn" );
356
+        exit;
357
+    }
358
+
359
+    public function enqueue_scripts() {
360
+        // Fires before adding scripts.
361
+        do_action( 'getpaid_enqueue_scripts' );
362
+
363
+        $localize                         = array();
364
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
365
+        $localize['thousands']            = wpinv_thousands_separator();
366
+        $localize['decimals']             = wpinv_decimal_separator();
367
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
368
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
369
+        $localize['UseTaxes']             = wpinv_use_taxes();
370
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
371
+        $localize['loading']              = __( 'Loading...', 'invoicing' );
372
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
373
+        $localize['recaptchaSettings']    = getpaid_get_recaptcha_settings();
374
+
375
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
376
+
377
+        // reCaptcha.
378
+        if ( getpaid_is_recaptcha_enabled() && ( $recaptcha_js = getpaid_recaptcha_api_url() ) ) {
379
+            wp_enqueue_script( 'recaptcha', $recaptcha_js, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
380
+        }
381
+
382
+        wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array( 'jquery' ), WPINV_VERSION, true );
383
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
384
+    }
385
+
386
+    public function wpinv_actions() {
387
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
388
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
389
+        }
390
+
391
+        if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
392
+            include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
393
+        }
394
+    }
395
+
396
+    /**
397
+     * Fires an action after verifying that a user can fire them.
398
+     *
399
+     * Note: If the action is on an invoice, subscription etc, esure that the
400
+     * current user owns the invoice/subscription.
401
+     */
402
+    public function maybe_do_authenticated_action() {
403
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
404
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
405
+            $data = wp_unslash( $_REQUEST );
406
+
407
+            if ( is_user_logged_in() ) {
408
+                do_action( "getpaid_authenticated_action_$key", $data );
409
+            }
410
+
411
+            do_action( "getpaid_unauthenticated_action_$key", $data );
412
+        }
413
+    }
414
+
415
+    public function pre_get_posts( $wp_query ) {
416
+        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() ) {
417
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
418
+        }
419
+
420
+        return $wp_query;
421
+    }
422
+
423
+    /**
424
+     * Register widgets
425
+     *
426
+     */
427
+    public function register_widgets() {
428
+        global $pagenow;
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
+        $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
437
+
438
+        if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
439
+            // don't initiate in these conditions.
440
+        } else {
441
+            // Only load allowed widgets.
442
+            $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
443
+            $widgets = apply_filters(
444
+                'getpaid_widget_classes',
445
+                array(
446
+                    'WPInv_Checkout_Widget',
447
+                    'WPInv_History_Widget',
448
+                    'WPInv_Receipt_Widget',
449
+                    'WPInv_Subscriptions_Widget',
450
+                    'WPInv_Buy_Item_Widget',
451
+                    'WPInv_Messages_Widget',
452
+                    'WPInv_GetPaid_Widget',
453
+                    'WPInv_Invoice_Widget',
454
+                )
455
+            );
456
+
457
+            // For each widget...
458
+            foreach ( $widgets as $widget ) {
459
+                // Abort early if it is excluded for this page.
460
+                if ( in_array( $widget, $exclude ) ) {
461
+                    continue;
462
+                }
463
+
464
+                // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
465
+                if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
466
+                    register_widget( $widget );
467
+                } else {
468
+                    new $widget();
469
+                }
470
+            }
471
+        }
472
+    }
473
+
474
+    /**
475
+     * Upgrades the database.
476
+     *
477
+     * @since 2.0.2
478
+     */
479
+    public function maybe_upgrade_database() {
480
+        // Ensure the database tables are up to date.
481
+        GetPaid_Installer::maybe_create_db_tables();
482
+
483
+        $wpi_version = get_option( 'wpinv_version', 0 );
484
+
485
+        if ( $wpi_version == WPINV_VERSION ) {
486
+            return;
487
+        }
488
+
489
+        $installer = new GetPaid_Installer();
490
+
491
+        if ( empty( $wpi_version ) ) {
492
+            return $installer->upgrade_db( 0 );
493
+        }
494
+
495
+        $upgrades  = array(
496
+            '0.0.5' => '004',
497
+            '1.0.3' => '102',
498
+            '2.0.0' => '118',
499
+            '2.8.0' => '279',
500
+        );
501
+
502
+        foreach ( $upgrades as $key => $method ) {
503
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
504
+                return $installer->upgrade_db( $method );
505
+            }
506
+        }
507
+    }
508
+
509
+    /**
510
+     * Flushes the permalinks if needed.
511
+     *
512
+     * @since 2.0.8
513
+     */
514
+    public function maybe_flush_permalinks() {
515
+        $flush = get_option( 'wpinv_flush_permalinks', 0 );
516
+
517
+        if ( ! empty( $flush ) ) {
518
+            flush_rewrite_rules();
519
+            delete_option( 'wpinv_flush_permalinks' );
520
+        }
521
+    }
522
+
523
+    /**
524
+     * Remove our pages from yoast sitemaps.
525
+     *
526
+     * @since 1.0.19
527
+     * @param int[] $excluded_posts_ids
528
+     */
529
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
530
+        // Ensure that we have an array.
531
+        if ( ! is_array( $excluded_posts_ids ) ) {
532
+            $excluded_posts_ids = array();
533
+        }
534
+
535
+        // Prepare our pages.
536
+        $our_pages = array();
537
+
538
+        // Checkout page.
539
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
540
+
541
+        // Success page.
542
+        $our_pages[] = wpinv_get_option( 'success_page', false );
543
+
544
+        // Failure page.
545
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
546
+
547
+        // History page.
548
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
549
+
550
+        // Subscriptions page.
551
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
552
+
553
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
554
+
555
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
556
+
557
+        return array_unique( $excluded_posts_ids );
558
+    }
559
+
560
+    /**
561
+     * Remove our pages from yoast sitemaps.
562
+     *
563
+     * @since 1.0.19
564
+     * @param string[] $post_types
565
+     */
566
+    public function exclude_invoicing_post_types( $post_types ) {
567
+        // Ensure that we have an array.
568
+        if ( ! is_array( $post_types ) ) {
569
+            $post_types = array();
570
+        }
571
+
572
+        // Remove our post types.
573
+        return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
574
+    }
575
+
576
+    /**
577
+     * Displays additional footer code.
578
+     *
579
+     * @since 2.0.0
580
+     */
581
+    public function wp_footer() {
582
+        wpinv_get_template( 'frontend-footer.php' );
583
+    }
584
+
585
+    /**
586
+     * Displays additional header code.
587
+     *
588
+     * @since 2.0.0
589
+     */
590
+    public function wp_head() {
591
+        wpinv_get_template( 'frontend-head.php' );
592
+    }
593
+
594
+    /**
595
+     * Custom query vars.
596
+     *
597
+     */
598
+    public function custom_query_vars( $vars ) {
599
+        $vars[] = 'getpaid-ipn';
600
+        return $vars;
601
+    }
602
+
603
+    /**
604
+     * Add rewrite tags and rules.
605
+     *
606
+     */
607
+    public function add_rewrite_rule() {
608
+        $tag = 'getpaid-ipn';
609
+        add_rewrite_tag( "%$tag%", '([^&]+)' );
610
+        add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
611
+    }
612
+
613
+    /**
614
+     * Processes non-query string ipns.
615
+     *
616
+     */
617
+    public function maybe_process_new_ipn( $query ) {
618
+        if ( is_admin() || ! $query->is_main_query() ) {
619
+            return;
620
+        }
621
+
622
+        $gateway = get_query_var( 'getpaid-ipn' );
623
+
624
+        if ( ! empty( $gateway ) ) {
625
+            $gateway = sanitize_text_field( $gateway );
626
+            nocache_headers();
627
+            do_action( 'wpinv_verify_payment_ipn', $gateway );
628
+            do_action( "wpinv_verify_{$gateway}_ipn" );
629
+            exit;
630
+        }
631
+    }
632 632
 }
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 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,9 +66,9 @@  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 ) {
70
-		if ( isset( $this->data[ $prop ] ) ) {
71
-			return $this->data[ $prop ];
69
+	public function get($prop) {
70
+		if (isset($this->data[$prop])) {
71
+			return $this->data[$prop];
72 72
 		}
73 73
 
74 74
 		return null;
@@ -79,30 +79,30 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function set_properties() {
81 81
 		// Sessions.
82
-		$this->set( 'session', new WPInv_Session_Handler() );
83
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
82
+		$this->set('session', new WPInv_Session_Handler());
83
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
84 84
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
85 85
 
86 86
 		// Init other objects.
87
-		$this->set( 'notes', new WPInv_Notes() );
88
-		$this->set( 'api', new WPInv_API() );
89
-		$this->set( 'post_types', new GetPaid_Post_Types() );
90
-		$this->set( 'template', new GetPaid_Template() );
91
-		$this->set( 'admin', new GetPaid_Admin() );
92
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
93
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
94
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
95
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
96
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
97
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
87
+		$this->set('notes', new WPInv_Notes());
88
+		$this->set('api', new WPInv_API());
89
+		$this->set('post_types', new GetPaid_Post_Types());
90
+		$this->set('template', new GetPaid_Template());
91
+		$this->set('admin', new GetPaid_Admin());
92
+		$this->set('subscriptions', new WPInv_Subscriptions());
93
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
94
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
95
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
96
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
97
+		$this->set('maxmind', new GetPaid_MaxMind_Geolocation());
98 98
 	}
99 99
 
100 100
 	 /**
101 101
 	 * Define plugin constants.
102 102
 	 */
103 103
 	public function define_constants() {
104
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
105
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
104
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
105
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
106 106
 		$this->version = WPINV_VERSION;
107 107
 	}
108 108
 
@@ -113,38 +113,38 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	protected function init_hooks() {
115 115
 		/* Internationalize the text strings used. */
116
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
116
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
117 117
 
118 118
 		// Init the plugin after WordPress inits.
119
-		add_action( 'init', array( $this, 'init' ), 1 );
120
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
121
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
122
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
123
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
124
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
125
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
126
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
127
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
128
-		add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
129
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
130
-
131
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
132
-		add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
133
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
119
+		add_action('init', array($this, 'init'), 1);
120
+		add_action('init', array($this, 'maybe_process_ipn'), 10);
121
+		add_action('init', array($this, 'wpinv_actions'));
122
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
123
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
124
+		add_action('wp_footer', array($this, 'wp_footer'));
125
+		add_action('wp_head', array($this, 'wp_head'));
126
+		add_action('widgets_init', array($this, 'register_widgets'));
127
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
128
+		add_filter('the_seo_framework_sitemap_supported_post_types', array($this, 'exclude_invoicing_post_types'));
129
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
130
+
131
+		add_filter('query_vars', array($this, 'custom_query_vars'));
132
+		add_action('init', array($this, 'add_rewrite_rule'), 10, 0);
133
+		add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1);
134 134
 
135 135
 		// Fires after registering actions.
136
-		do_action( 'wpinv_actions', $this );
137
-		do_action( 'getpaid_actions', $this );
136
+		do_action('wpinv_actions', $this);
137
+		do_action('getpaid_actions', $this);
138 138
 	}
139 139
 
140 140
 	public function plugins_loaded() {
141 141
 		/* Internationalize the text strings used. */
142 142
 		$this->load_textdomain();
143 143
 
144
-		do_action( 'wpinv_loaded' );
144
+		do_action('wpinv_loaded');
145 145
 
146 146
 		// Fix oxygen page builder conflict
147
-		if ( function_exists( 'ct_css_output' ) ) {
147
+		if (function_exists('ct_css_output')) {
148 148
 			wpinv_oxygen_fix_conflict();
149 149
 		}
150 150
 	}
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public function load_textdomain() {
164 164
 		// Determines the current locale.
165
-		if ( function_exists( 'determine_locale' ) ) {
165
+		if (function_exists('determine_locale')) {
166 166
 			$locale = determine_locale();
167
-		} else if ( function_exists( 'get_user_locale' ) ) {
167
+		} else if (function_exists('get_user_locale')) {
168 168
 			$locale = get_user_locale();
169 169
 		} else {
170 170
 			$locale = get_locale();
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 		/**
174 174
 		 * Filter the locale to use for translations.
175 175
 		 */
176
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
176
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
177 177
 
178
-		unload_textdomain( 'invoicing', true );
179
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
180
-		load_plugin_textdomain( 'invoicing', false, plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' );
178
+		unload_textdomain('invoicing', true);
179
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
180
+		load_plugin_textdomain('invoicing', false, plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/');
181 181
 	}
182 182
 
183 183
 	/**
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 
211 211
 		// Register autoloader.
212 212
 		try {
213
-			spl_autoload_register( array( $this, 'autoload' ), true );
214
-		} catch ( Exception $e ) {
215
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
213
+			spl_autoload_register(array($this, 'autoload'), true);
214
+		} catch (Exception $e) {
215
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
216 216
 		}
217 217
 
218 218
 		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
239 239
 		require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
240 240
 
241
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
241
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
242 242
 			GetPaid_Post_Types_Admin::init();
243 243
 
244 244
 			require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
 			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
250 250
 			// load the user class only on the users.php page
251 251
 			global $pagenow;
252
-			if ( $pagenow == 'users.php' ) {
252
+			if ($pagenow == 'users.php') {
253 253
 				new WPInv_Admin_Users();
254 254
 			}
255 255
 		}
256 256
 
257 257
 		// Register cli commands
258
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
258
+		if (defined('WP_CLI') && WP_CLI) {
259 259
 			require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
260
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
260
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
261 261
 		}
262 262
 	}
263 263
 
@@ -269,20 +269,20 @@  discard block
 block discarded – undo
269 269
 	 * @since       1.0.19
270 270
 	 * @return      void
271 271
 	 */
272
-	public function autoload( $class_name ) {
272
+	public function autoload($class_name) {
273 273
 		// Normalize the class name...
274
-		$class_name  = strtolower( $class_name );
274
+		$class_name = strtolower($class_name);
275 275
 
276 276
 		// ... and make sure it is our class.
277
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
277
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
278 278
 			return;
279 279
 		}
280 280
 
281 281
 		// Next, prepare the file name from the class.
282
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
282
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
283 283
 
284 284
 		// Base path of the classes.
285
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
285
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
286 286
 
287 287
 		// And an array of possible locations in order of importance.
288 288
 		$locations = array(
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 			"$plugin_path/includes/admin/meta-boxes",
298 298
 		);
299 299
 
300
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
301
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
302
-				include trailingslashit( $location ) . $file_name;
300
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
301
+			if (file_exists(trailingslashit($location) . $file_name)) {
302
+				include trailingslashit($location) . $file_name;
303 303
 				break;
304 304
 			}
305 305
 		}
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 */
311 311
 	public function init() {
312 312
 		// Fires before getpaid inits.
313
-		do_action( 'before_getpaid_init', $this );
313
+		do_action('before_getpaid_init', $this);
314 314
 
315 315
 		// Maybe upgrade.
316 316
 		$this->maybe_upgrade_database();
@@ -327,17 +327,17 @@  discard block
 block discarded – undo
327 327
 			)
328 328
 		);
329 329
 
330
-		foreach ( $gateways as $id => $class ) {
331
-			$this->gateways[ $id ] = new $class();
330
+		foreach ($gateways as $id => $class) {
331
+			$this->gateways[$id] = new $class();
332 332
 		}
333 333
 
334
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
334
+		if ('yes' != get_option('wpinv_renamed_gateways')) {
335 335
 			GetPaid_Installer::rename_gateways_label();
336
-			update_option( 'wpinv_renamed_gateways', 'yes' );
336
+			update_option('wpinv_renamed_gateways', 'yes');
337 337
 		}
338 338
 
339 339
 		// Fires after getpaid inits.
340
-		do_action( 'getpaid_init', $this );
340
+		do_action('getpaid_init', $this);
341 341
 	}
342 342
 
343 343
 	/**
@@ -345,51 +345,51 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	public function maybe_process_ipn() {
347 347
 		// Ensure that this is an IPN request.
348
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
348
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
349 349
 			return;
350 350
 		}
351 351
 
352
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
352
+		$gateway = sanitize_text_field($_GET['wpi-gateway']);
353 353
 
354
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
355
-		do_action( "wpinv_verify_{$gateway}_ipn" );
354
+		do_action('wpinv_verify_payment_ipn', $gateway);
355
+		do_action("wpinv_verify_{$gateway}_ipn");
356 356
 		exit;
357 357
 	}
358 358
 
359 359
 	public function enqueue_scripts() {
360 360
 		// Fires before adding scripts.
361
-		do_action( 'getpaid_enqueue_scripts' );
361
+		do_action('getpaid_enqueue_scripts');
362 362
 
363 363
 		$localize                         = array();
364
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
364
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
365 365
 		$localize['thousands']            = wpinv_thousands_separator();
366 366
 		$localize['decimals']             = wpinv_decimal_separator();
367
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
368
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
367
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
368
+		$localize['txtComplete']          = __('Continue', 'invoicing');
369 369
 		$localize['UseTaxes']             = wpinv_use_taxes();
370
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
371
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
372
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
370
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
371
+		$localize['loading']              = __('Loading...', 'invoicing');
372
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
373 373
 		$localize['recaptchaSettings']    = getpaid_get_recaptcha_settings();
374 374
 
375
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
375
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
376 376
 
377 377
 		// reCaptcha.
378
-		if ( getpaid_is_recaptcha_enabled() && ( $recaptcha_js = getpaid_recaptcha_api_url() ) ) {
379
-			wp_enqueue_script( 'recaptcha', $recaptcha_js, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
378
+		if (getpaid_is_recaptcha_enabled() && ($recaptcha_js = getpaid_recaptcha_api_url())) {
379
+			wp_enqueue_script('recaptcha', $recaptcha_js, array(), null, true); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
380 380
 		}
381 381
 
382
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array( 'jquery' ), WPINV_VERSION, true );
383
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
382
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array('jquery'), WPINV_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
 
@@ -400,21 +400,21 @@  discard block
 block discarded – undo
400 400
 	 * current user owns the invoice/subscription.
401 401
 	 */
402 402
 	public function maybe_do_authenticated_action() {
403
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
404
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
405
-			$data = wp_unslash( $_REQUEST );
403
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
404
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
405
+			$data = wp_unslash($_REQUEST);
406 406
 
407
-			if ( is_user_logged_in() ) {
408
-				do_action( "getpaid_authenticated_action_$key", $data );
407
+			if (is_user_logged_in()) {
408
+				do_action("getpaid_authenticated_action_$key", $data);
409 409
 			}
410 410
 
411
-			do_action( "getpaid_unauthenticated_action_$key", $data );
411
+			do_action("getpaid_unauthenticated_action_$key", $data);
412 412
 		}
413 413
 	}
414 414
 
415
-	public function pre_get_posts( $wp_query ) {
416
-		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() ) {
417
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
415
+	public function pre_get_posts($wp_query) {
416
+		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()) {
417
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
418 418
 		}
419 419
 
420 420
 		return $wp_query;
@@ -429,17 +429,17 @@  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
 
436
-		$block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
436
+		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
437 437
 
438
-		if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
438
+		if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
439 439
 			// don't initiate in these conditions.
440 440
 		} else {
441 441
 			// Only load allowed widgets.
442
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
442
+			$exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
443 443
 			$widgets = apply_filters(
444 444
 				'getpaid_widget_classes',
445 445
 				array(
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
 			);
456 456
 
457 457
 			// For each widget...
458
-			foreach ( $widgets as $widget ) {
458
+			foreach ($widgets as $widget) {
459 459
 				// Abort early if it is excluded for this page.
460
-				if ( in_array( $widget, $exclude ) ) {
460
+				if (in_array($widget, $exclude)) {
461 461
 					continue;
462 462
 				}
463 463
 
464 464
 				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
465
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
466
-					register_widget( $widget );
465
+				if (is_subclass_of($widget, 'WP_Widget')) {
466
+					register_widget($widget);
467 467
 				} else {
468 468
 					new $widget();
469 469
 				}
@@ -480,28 +480,28 @@  discard block
 block discarded – undo
480 480
 		// Ensure the database tables are up to date.
481 481
 		GetPaid_Installer::maybe_create_db_tables();
482 482
 
483
-		$wpi_version = get_option( 'wpinv_version', 0 );
483
+		$wpi_version = get_option('wpinv_version', 0);
484 484
 
485
-		if ( $wpi_version == WPINV_VERSION ) {
485
+		if ($wpi_version == WPINV_VERSION) {
486 486
 			return;
487 487
 		}
488 488
 
489 489
 		$installer = new GetPaid_Installer();
490 490
 
491
-		if ( empty( $wpi_version ) ) {
492
-			return $installer->upgrade_db( 0 );
491
+		if (empty($wpi_version)) {
492
+			return $installer->upgrade_db(0);
493 493
 		}
494 494
 
495
-		$upgrades  = array(
495
+		$upgrades = array(
496 496
 			'0.0.5' => '004',
497 497
 			'1.0.3' => '102',
498 498
 			'2.0.0' => '118',
499 499
 			'2.8.0' => '279',
500 500
 		);
501 501
 
502
-		foreach ( $upgrades as $key => $method ) {
503
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
504
-				return $installer->upgrade_db( $method );
502
+		foreach ($upgrades as $key => $method) {
503
+			if (version_compare($wpi_version, $key, '<')) {
504
+				return $installer->upgrade_db($method);
505 505
 			}
506 506
 		}
507 507
 	}
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	 * @since 2.0.8
513 513
 	 */
514 514
 	public function maybe_flush_permalinks() {
515
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
515
+		$flush = get_option('wpinv_flush_permalinks', 0);
516 516
 
517
-		if ( ! empty( $flush ) ) {
517
+		if (!empty($flush)) {
518 518
 			flush_rewrite_rules();
519
-			delete_option( 'wpinv_flush_permalinks' );
519
+			delete_option('wpinv_flush_permalinks');
520 520
 		}
521 521
 	}
522 522
 
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 	 * @since 1.0.19
527 527
 	 * @param int[] $excluded_posts_ids
528 528
 	 */
529
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
529
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
530 530
 		// Ensure that we have an array.
531
-		if ( ! is_array( $excluded_posts_ids ) ) {
531
+		if (!is_array($excluded_posts_ids)) {
532 532
 			$excluded_posts_ids = array();
533 533
 		}
534 534
 
@@ -536,25 +536,25 @@  discard block
 block discarded – undo
536 536
 		$our_pages = array();
537 537
 
538 538
 		// Checkout page.
539
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
539
+		$our_pages[] = wpinv_get_option('checkout_page', false);
540 540
 
541 541
 		// Success page.
542
-		$our_pages[] = wpinv_get_option( 'success_page', false );
542
+		$our_pages[] = wpinv_get_option('success_page', false);
543 543
 
544 544
 		// Failure page.
545
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
545
+		$our_pages[] = wpinv_get_option('failure_page', false);
546 546
 
547 547
 		// History page.
548
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
548
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
549 549
 
550 550
 		// Subscriptions page.
551
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
551
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
552 552
 
553
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
553
+		$our_pages   = array_map('intval', array_filter($our_pages));
554 554
 
555 555
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
556 556
 
557
-		return array_unique( $excluded_posts_ids );
557
+		return array_unique($excluded_posts_ids);
558 558
 	}
559 559
 
560 560
 	/**
@@ -563,14 +563,14 @@  discard block
 block discarded – undo
563 563
 	 * @since 1.0.19
564 564
 	 * @param string[] $post_types
565 565
 	 */
566
-	public function exclude_invoicing_post_types( $post_types ) {
566
+	public function exclude_invoicing_post_types($post_types) {
567 567
 		// Ensure that we have an array.
568
-		if ( ! is_array( $post_types ) ) {
568
+		if (!is_array($post_types)) {
569 569
 			$post_types = array();
570 570
 		}
571 571
 
572 572
 		// Remove our post types.
573
-		return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
573
+		return array_diff($post_types, array_keys(getpaid_get_invoice_post_types()));
574 574
 	}
575 575
 
576 576
 	/**
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	 * @since 2.0.0
580 580
 	 */
581 581
 	public function wp_footer() {
582
-		wpinv_get_template( 'frontend-footer.php' );
582
+		wpinv_get_template('frontend-footer.php');
583 583
 	}
584 584
 
585 585
 	/**
@@ -588,14 +588,14 @@  discard block
 block discarded – undo
588 588
 	 * @since 2.0.0
589 589
 	 */
590 590
 	public function wp_head() {
591
-		wpinv_get_template( 'frontend-head.php' );
591
+		wpinv_get_template('frontend-head.php');
592 592
 	}
593 593
 
594 594
 	/**
595 595
 	 * Custom query vars.
596 596
 	 *
597 597
 	 */
598
-	public function custom_query_vars( $vars ) {
598
+	public function custom_query_vars($vars) {
599 599
 		$vars[] = 'getpaid-ipn';
600 600
 		return $vars;
601 601
 	}
@@ -606,26 +606,26 @@  discard block
 block discarded – undo
606 606
 	 */
607 607
 	public function add_rewrite_rule() {
608 608
 		$tag = 'getpaid-ipn';
609
-		add_rewrite_tag( "%$tag%", '([^&]+)' );
610
-		add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
609
+		add_rewrite_tag("%$tag%", '([^&]+)');
610
+		add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top');
611 611
 	}
612 612
 
613 613
 	/**
614 614
 	 * Processes non-query string ipns.
615 615
 	 *
616 616
 	 */
617
-	public function maybe_process_new_ipn( $query ) {
618
-		if ( is_admin() || ! $query->is_main_query() ) {
617
+	public function maybe_process_new_ipn($query) {
618
+		if (is_admin() || !$query->is_main_query()) {
619 619
 			return;
620 620
 		}
621 621
 
622
-		$gateway = get_query_var( 'getpaid-ipn' );
622
+		$gateway = get_query_var('getpaid-ipn');
623 623
 
624
-		if ( ! empty( $gateway ) ) {
625
-			$gateway = sanitize_text_field( $gateway );
624
+		if (!empty($gateway)) {
625
+			$gateway = sanitize_text_field($gateway);
626 626
 			nocache_headers();
627
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
628
-			do_action( "wpinv_verify_{$gateway}_ipn" );
627
+			do_action('wpinv_verify_payment_ipn', $gateway);
628
+			do_action("wpinv_verify_{$gateway}_ipn");
629 629
 			exit;
630 630
 		}
631 631
 	}
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.2.30";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.2.30";
19
+    if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.2.30";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
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.8.20' );
26
+    define( 'WPINV_VERSION', '2.8.20' );
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.8.20' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.8.20');
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', 0 );
67
+add_action('plugins_loaded', 'getpaid', 0);
Please login to merge, or discard this patch.
includes/class-wpinv-privacy-exporters.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Personal data exporters.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy_Exporters Class.
@@ -17,39 +17,39 @@  discard block
 block discarded – undo
17 17
      * @param int    $page  Page.
18 18
      * @return array An array of invoice data in name value pairs
19 19
      */
20
-    public static function customer_invoice_data_exporter( $email_address, $page ) {
20
+    public static function customer_invoice_data_exporter($email_address, $page) {
21 21
         $done           = false;
22 22
         $page           = (int) $page;
23 23
         $data_to_export = array();
24 24
 
25
-        $user           = get_user_by( 'email', $email_address );
26
-        if ( ! $user instanceof WP_User ) {
25
+        $user           = get_user_by('email', $email_address);
26
+        if (!$user instanceof WP_User) {
27 27
             return array(
28 28
                 'data' => $data_to_export,
29 29
                 'done' => true,
30 30
             );
31 31
         }
32 32
 
33
-        $args    = array(
34
-            'limit'    => get_option( 'posts_per_page' ),
33
+        $args = array(
34
+            'limit'    => get_option('posts_per_page'),
35 35
             'page'     => $page,
36 36
             'user'     => $user->ID,
37 37
             'paginate' => false,
38 38
         );
39 39
 
40
-        $invoices = wpinv_get_invoices( $args );
40
+        $invoices = wpinv_get_invoices($args);
41 41
 
42
-        if ( 0 < count( $invoices ) ) {
43
-            foreach ( $invoices as $invoice ) {
42
+        if (0 < count($invoices)) {
43
+            foreach ($invoices as $invoice) {
44 44
                 $data_to_export[] = array(
45 45
                     'group_id'          => 'customer_invoices',
46
-                    'group_label'       => __( 'GetPaid: Invoices', 'invoicing' ),
47
-                    'group_description' => __( 'Customer invoices.', 'invoicing' ),
46
+                    'group_label'       => __('GetPaid: Invoices', 'invoicing'),
47
+                    'group_description' => __('Customer invoices.', 'invoicing'),
48 48
                     'item_id'           => "wpinv-{$invoice->get_id()}",
49
-                    'data'              => self::get_customer_invoice_data( $invoice ),
49
+                    'data'              => self::get_customer_invoice_data($invoice),
50 50
                 );
51 51
             }
52
-            $done = get_option( 'posts_per_page' ) > count( $invoices );
52
+            $done = get_option('posts_per_page') > count($invoices);
53 53
         } else {
54 54
             $done = true;
55 55
         }
@@ -67,122 +67,122 @@  discard block
 block discarded – undo
67 67
      * @param WPInv_Invoice $invoice invoice object.
68 68
      * @return array
69 69
      */
70
-    public static function get_customer_invoice_data( $invoice ) {
70
+    public static function get_customer_invoice_data($invoice) {
71 71
 
72 72
         // Prepare basic properties.
73 73
         $props_to_export = array(
74 74
             'number'       => array(
75
-                'name'  => __( 'Invoice Number', 'invoicing' ),
75
+                'name'  => __('Invoice Number', 'invoicing'),
76 76
                 'value' => $invoice->get_number(),
77 77
             ),
78 78
             'created_date' => array(
79
-                'name'  => __( 'Created Date', 'invoicing' ),
79
+                'name'  => __('Created Date', 'invoicing'),
80 80
                 'value' => $invoice->get_date_created(),
81 81
             ),
82 82
             'due_date'     => array(
83
-                'name'  => __( 'Due Date', 'invoicing' ),
83
+                'name'  => __('Due Date', 'invoicing'),
84 84
                 'value' => $invoice->get_due_date(),
85 85
             ),
86 86
             'items'        => array(
87
-                'name'  => __( 'Invoice Items', 'invoicing' ),
88
-                'value' => self::process_invoice_items( $invoice ),
87
+                'name'  => __('Invoice Items', 'invoicing'),
88
+                'value' => self::process_invoice_items($invoice),
89 89
             ),
90 90
             'discount'     => array(
91
-                'name'  => __( 'Invoice Discount', 'invoicing' ),
92
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
91
+                'name'  => __('Invoice Discount', 'invoicing'),
92
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
93 93
             ),
94 94
             'total'        => array(
95
-                'name'  => __( 'Invoice Total', 'invoicing' ),
96
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
95
+                'name'  => __('Invoice Total', 'invoicing'),
96
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
97 97
             ),
98 98
             'status'       => array(
99
-                'name'  => __( 'Invoice Status', 'invoicing' ),
99
+                'name'  => __('Invoice Status', 'invoicing'),
100 100
                 'value' => $invoice->get_status_nicename(),
101 101
             ),
102 102
             'first_name'   => array(
103
-                'name'  => __( 'First Name', 'invoicing' ),
103
+                'name'  => __('First Name', 'invoicing'),
104 104
                 'value' => $invoice->get_first_name(),
105 105
             ),
106 106
             'last_name'    => array(
107
-                'name'  => __( 'Last Name', 'invoicing' ),
107
+                'name'  => __('Last Name', 'invoicing'),
108 108
                 'value' => $invoice->get_last_name(),
109 109
             ),
110 110
             'email'        => array(
111
-                'name'  => __( 'Email Address', 'invoicing' ),
111
+                'name'  => __('Email Address', 'invoicing'),
112 112
                 'value' => $invoice->get_email(),
113 113
             ),
114 114
             'company'      => array(
115
-                'name'  => __( 'Company', 'invoicing' ),
115
+                'name'  => __('Company', 'invoicing'),
116 116
                 'value' => $invoice->get_company(),
117 117
             ),
118 118
             'phone'        => array(
119
-                'name'  => __( 'Phone Number', 'invoicing' ),
119
+                'name'  => __('Phone Number', 'invoicing'),
120 120
                 'value' => $invoice->get_phone(),
121 121
             ),
122 122
             'address'      => array(
123
-                'name'  => __( 'Address', 'invoicing' ),
123
+                'name'  => __('Address', 'invoicing'),
124 124
                 'value' => $invoice->get_address(),
125 125
             ),
126 126
             'city'         => array(
127
-                'name'  => __( 'City', 'invoicing' ),
127
+                'name'  => __('City', 'invoicing'),
128 128
                 'value' => $invoice->get_city(),
129 129
             ),
130 130
             'state'        => array(
131
-                'name'  => __( 'State', 'invoicing' ),
131
+                'name'  => __('State', 'invoicing'),
132 132
                 'value' => $invoice->get_state(),
133 133
             ),
134 134
             'zip'          => array(
135
-                'name'  => __( 'Zip', 'invoicing' ),
135
+                'name'  => __('Zip', 'invoicing'),
136 136
                 'value' => $invoice->get_zip(),
137 137
             ),
138 138
             'vat_number'   => array(
139
-                'name'  => __( 'VAT Number', 'invoicing' ),
139
+                'name'  => __('VAT Number', 'invoicing'),
140 140
                 'value' => $invoice->get_vat_number(),
141 141
             ),
142 142
             'description'  => array(
143
-                'name'  => __( 'Description', 'invoicing' ),
143
+                'name'  => __('Description', 'invoicing'),
144 144
                 'value' => $invoice->get_description(),
145 145
             ),
146 146
         );
147 147
 
148 148
         // In case the invoice is paid, add the payment date and gateway.
149
-        if ( $invoice->is_paid() ) {
149
+        if ($invoice->is_paid()) {
150 150
 
151 151
             $props_to_export['completed_date'] = array(
152
-                'name'  => __( 'Completed Date', 'invoicing' ),
152
+                'name'  => __('Completed Date', 'invoicing'),
153 153
                 'value' => $invoice->get_completed_date(),
154 154
             );
155 155
 
156 156
             $props_to_export['gateway'] = array(
157
-                'name'  => __( 'Paid Via', 'invoicing' ),
157
+                'name'  => __('Paid Via', 'invoicing'),
158 158
                 'value' => $invoice->get_gateway(),
159 159
             );
160 160
 
161 161
         }
162 162
 
163 163
         // Maybe add subscription details.
164
-        $props_to_export = self::process_subscription( $invoice, $props_to_export );
164
+        $props_to_export = self::process_subscription($invoice, $props_to_export);
165 165
 
166 166
         // Add the ip address.
167 167
         $props_to_export['ip'] = array(
168
-            'name'  => __( 'IP Address', 'invoicing' ),
168
+            'name'  => __('IP Address', 'invoicing'),
169 169
             'value' => $invoice->get_ip(),
170 170
         );
171 171
 
172 172
         // Add the invoice url.
173 173
         $props_to_export['view_url'] = array(
174
-            'name'  => __( 'Invoice URL', 'invoicing' ),
174
+            'name'  => __('Invoice URL', 'invoicing'),
175 175
             'value' => $invoice->get_view_url(),
176 176
         );
177 177
 
178 178
         // Return the values.
179
-        $items = apply_filters( 'getpaid_privacy_export_invoice_personal_data', array_values( $props_to_export ), $invoice );
179
+        $items = apply_filters('getpaid_privacy_export_invoice_personal_data', array_values($props_to_export), $invoice);
180 180
 
181 181
         $data = array();
182 182
 
183 183
         // Unset null values to prevent PHP deprecated notice.
184
-        foreach ( $items as $item ) {
185
-            if ( isset( $item['value'] ) && ! is_null( $item['value'] ) ) {
184
+        foreach ($items as $item) {
185
+            if (isset($item['value']) && !is_null($item['value'])) {
186 186
                 $data[] = $item;
187 187
             }
188 188
         }
@@ -198,40 +198,40 @@  discard block
 block discarded – undo
198 198
      * @param array $props invoice props.
199 199
      * @return array
200 200
      */
201
-    public static function process_subscription( $invoice, $props ) {
201
+    public static function process_subscription($invoice, $props) {
202 202
 
203
-        $subscription = wpinv_get_subscription( $invoice );
204
-        if ( ! empty( $subscription ) ) {
203
+        $subscription = wpinv_get_subscription($invoice);
204
+        if (!empty($subscription)) {
205 205
 
206
-            $frequency    = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency() );
207
-            $period       = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ) . ' / ' . $frequency;
208
-            $initial_amt  = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
209
-            $bill_times   = $subscription->get_times_billed() . ' / ' . ( ( $subscription->get_bill_times() == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->get_bill_times() );
210
-            $renewal_date = getpaid_format_date_value( $subscription->get_expiration() );
206
+            $frequency    = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency());
207
+            $period       = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()) . ' / ' . $frequency;
208
+            $initial_amt  = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency());
209
+            $bill_times   = $subscription->get_times_billed() . ' / ' . (($subscription->get_bill_times() == 0) ? __('Until Cancelled', 'invoicing') : $subscription->get_bill_times());
210
+            $renewal_date = getpaid_format_date_value($subscription->get_expiration());
211 211
 
212 212
             // Billing cycle.
213 213
             $props['period'] = array(
214
-                'name'  => __( 'Billing Cycle', 'invoicing' ),
214
+                'name'  => __('Billing Cycle', 'invoicing'),
215 215
                 'value' => $period,
216 216
             );
217 217
 
218 218
             // Initial amount.
219 219
             $props['initial_amount'] = array(
220
-                'name'  => __( 'Initial Amount', 'invoicing' ),
220
+                'name'  => __('Initial Amount', 'invoicing'),
221 221
                 'value' => $initial_amt,
222 222
             );
223 223
 
224 224
             // Bill times.
225 225
             $props['bill_times'] = array(
226
-                'name'  => __( 'Times Billed', 'invoicing' ),
226
+                'name'  => __('Times Billed', 'invoicing'),
227 227
                 'value' => $bill_times,
228 228
             );
229 229
 
230 230
             // Add expiry date.
231
-            if ( $subscription->is_active() ) {
231
+            if ($subscription->is_active()) {
232 232
 
233 233
                 $props['renewal_date'] = array(
234
-                    'name'  => __( 'Expires', 'invoicing' ),
234
+                    'name'  => __('Expires', 'invoicing'),
235 235
                     'value' => $renewal_date,
236 236
                 );
237 237
 
@@ -249,19 +249,19 @@  discard block
 block discarded – undo
249 249
      * @param WPInv_Invoice $invoice invoice object.
250 250
      * @return array
251 251
      */
252
-    public static function process_invoice_items( $invoice ) {
252
+    public static function process_invoice_items($invoice) {
253 253
 
254 254
         $item_names = array();
255
-        foreach ( $invoice->get_items() as $cart_item ) {
255
+        foreach ($invoice->get_items() as $cart_item) {
256 256
             $item_names[] = sprintf(
257 257
                 '%s x %s - %s',
258 258
                 $cart_item->get_name(),
259 259
                 $cart_item->get_quantity(),
260
-                wpinv_price( $invoice->is_renewal() ? $cart_item->get_recurring_sub_total() : $cart_item->get_sub_total(), $invoice->get_currency() )
260
+                wpinv_price($invoice->is_renewal() ? $cart_item->get_recurring_sub_total() : $cart_item->get_sub_total(), $invoice->get_currency())
261 261
             );
262 262
         }
263 263
 
264
-        return implode( ', ', $item_names );
264
+        return implode(', ', $item_names);
265 265
 
266 266
     }
267 267
 
Please login to merge, or discard this patch.
includes/class-wpinv-privacy.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         add_action( 'init', array( $this, 'register_erasers_exporters' ) );
30 30
     }
31 31
 
32
-   /**
32
+    /**
33 33
      * Initial registration of privacy erasers and exporters.
34 34
      *
35 35
      * Due to the use of translation functions, this should run only after plugins loaded.
@@ -49,25 +49,25 @@  discard block
 block discarded – undo
49 49
     public function get_privacy_message() {
50 50
 
51 51
         $content = '<div class="wp-suggested-text">' .
52
-                   '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
53
-                   '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
54
-                   '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
55
-                   '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
56
-                   '<ul>' .
57
-                   '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' .
58
-                   '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
59
-                   '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
60
-                   '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
61
-                   '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
62
-                   '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
63
-                   '</ul>' .
64
-                   '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
65
-                   '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
66
-                   '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
67
-                   '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
68
-                   '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
69
-                   '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' .
70
-                   '</div>';
52
+                    '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
53
+                    '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
54
+                    '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
55
+                    '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
56
+                    '<ul>' .
57
+                    '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' .
58
+                    '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
59
+                    '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
60
+                    '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
61
+                    '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
62
+                    '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
63
+                    '</ul>' .
64
+                    '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
65
+                    '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
66
+                    '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
67
+                    '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
68
+                    '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
69
+                    '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' .
70
+                    '</div>';
71 71
 
72 72
         return apply_filters( 'wpinv_privacy_policy_content', $content );
73 73
     }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Privacy/GDPR related functionality which ties into WordPress functionality.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy Class.
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         $this->init();
27 27
 
28 28
         // Initialize data exporters and erasers.
29
-        add_action( 'init', array( $this, 'register_erasers_exporters' ) );
29
+        add_action('init', array($this, 'register_erasers_exporters'));
30 30
     }
31 31
 
32 32
    /**
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
      * Due to the use of translation functions, this should run only after plugins loaded.
36 36
      */
37 37
     public function register_erasers_exporters() {
38
-        $this->name = __( 'GetPaid', 'invoicing' );
38
+        $this->name = __('GetPaid', 'invoicing');
39 39
 
40 40
         // This hook registers Invoicing data exporters.
41
-        $this->add_exporter( 'wpinv-customer-invoices', __( 'Customer Invoices', 'invoicing' ), array( 'WPInv_Privacy_Exporters', 'customer_invoice_data_exporter' ) );
41
+        $this->add_exporter('wpinv-customer-invoices', __('Customer Invoices', 'invoicing'), array('WPInv_Privacy_Exporters', 'customer_invoice_data_exporter'));
42 42
     }
43 43
 
44 44
     /**
@@ -49,27 +49,27 @@  discard block
 block discarded – undo
49 49
     public function get_privacy_message() {
50 50
 
51 51
         $content = '<div class="wp-suggested-text">' .
52
-                   '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' .
53
-                   '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' .
54
-                   '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' .
55
-                   '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' .
52
+                   '<h2>' . __('Invoices and checkout', 'invoicing') . '</h2>' .
53
+                   '<p class="privacy-policy-tutorial">' . __('Example privacy texts.', 'invoicing') . '</p>' .
54
+                   '<p>' . __('We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing') . '</p>' .
55
+                   '<p>' . __('Handling this data also allows us to:', 'invoicing') . '</p>' .
56 56
                    '<ul>' .
57
-                   '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' .
58
-                   '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' .
59
-                   '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' .
60
-                   '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
61
-                   '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' .
62
-                   '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' .
57
+                   '<li>' . __('- Send you important account/invoice/service information.', 'invoicing') . '</li>' .
58
+                   '<li>' . __('- Estimate taxes based on your location.', 'invoicing') . '</li>' .
59
+                   '<li>' . __('- Respond to your queries or complaints.', 'invoicing') . '</li>' .
60
+                   '<li>' . __('- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing') . '</li>' .
61
+                   '<li>' . __('- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing') . '</li>' .
62
+                   '<li>' . __('- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing') . '</li>' .
63 63
                    '</ul>' .
64
-                   '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' .
65
-                   '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' .
66
-                   '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' .
67
-                   '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' .
68
-                   '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' .
69
-                   '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' .
64
+                   '<p>' . __('In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing') . '</p>' .
65
+                   '<h2>' . __('What we share with others', 'invoicing') . '</h2>' .
66
+                   '<p>' . __('We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing') . '</p>' .
67
+                   '<p class="privacy-policy-tutorial">' . __('In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing') . '</p>' .
68
+                   '<p>' . __('We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing') . '</p>' .
69
+                   '<p>' . __('Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing') . '</p>' .
70 70
                    '</div>';
71 71
 
72
-        return apply_filters( 'wpinv_privacy_policy_content', $content );
72
+        return apply_filters('wpinv_privacy_policy_content', $content);
73 73
     }
74 74
 
75 75
 }
Please login to merge, or discard this patch.
includes/abstracts/abstract-wpinv-privacy.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Abstract privacy class.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Abstract class that is intended to be extended by
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @param string $name Plugin identifier.
40 40
      */
41
-    public function __construct( $name = '' ) {
41
+    public function __construct($name = '') {
42 42
         $this->name = $name;
43 43
         $this->init();
44 44
     }
@@ -47,26 +47,26 @@  discard block
 block discarded – undo
47 47
      * Hook in events.
48 48
      */
49 49
     protected function init() {
50
-        add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
50
+        add_action('admin_init', array($this, 'add_privacy_message'));
51 51
         // Register data exporters
52
-        add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 );
52
+        add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), 10);
53 53
         // Register data erasers
54
-        add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) );
54
+        add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers'));
55 55
     }
56 56
 
57 57
     /**
58 58
      * Adds the privacy message on invoicing privacy page.
59 59
      */
60 60
     public function add_privacy_message() {
61
-        if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
61
+        if (function_exists('wp_add_privacy_policy_content')) {
62 62
             $content = $this->get_privacy_message();
63 63
 
64
-            if ( $content ) {
65
-                if ( empty( $this->name ) ) {
66
-                    $this->name = __( 'GetPaid', 'invoicing' );
64
+            if ($content) {
65
+                if (empty($this->name)) {
66
+                    $this->name = __('GetPaid', 'invoicing');
67 67
                 }
68 68
 
69
-                wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() );
69
+                wp_add_privacy_policy_content($this->name, $this->get_privacy_message());
70 70
             }
71 71
         }
72 72
     }
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
      * @param array $exporters List of exporter callbacks.
88 88
      * @return array
89 89
      */
90
-    public function register_exporters( $exporters = array() ) {
91
-        foreach ( $this->exporters as $id => $exporter ) {
92
-            $exporters[ $id ] = $exporter;
90
+    public function register_exporters($exporters = array()) {
91
+        foreach ($this->exporters as $id => $exporter) {
92
+            $exporters[$id] = $exporter;
93 93
         }
94 94
         return $exporters;
95 95
     }
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
      * @param array $erasers List of eraser callbacks.
101 101
      * @return array
102 102
      */
103
-    public function register_erasers( $erasers = array() ) {
104
-        foreach ( $this->erasers as $id => $eraser ) {
105
-            $erasers[ $id ] = $eraser;
103
+    public function register_erasers($erasers = array()) {
104
+        foreach ($this->erasers as $id => $eraser) {
105
+            $erasers[$id] = $eraser;
106 106
         }
107 107
         return $erasers;
108 108
     }
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return array
118 118
      */
119
-    public function add_exporter( $id, $name, $callback ) {
120
-        $this->exporters[ $id ] = array(
119
+    public function add_exporter($id, $name, $callback) {
120
+        $this->exporters[$id] = array(
121 121
             'exporter_friendly_name' => $name,
122 122
             'callback'               => $callback,
123 123
         );
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
      *
134 134
      * @return array
135 135
      */
136
-    public function add_eraser( $id, $name, $callback ) {
137
-        $this->erasers[ $id ] = array(
136
+    public function add_eraser($id, $name, $callback) {
137
+        $this->erasers[$id] = array(
138 138
             'eraser_friendly_name' => $name,
139 139
             'callback'             => $callback,
140 140
         );
Please login to merge, or discard this patch.