Passed
Push — master ( 330418...c4952f )
by Brian
05:45 queued 27s
created
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -14,91 +14,91 @@  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;
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 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
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_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		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_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68 68
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
78
-
79
-		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
82
-				case 'gp-setup' :
83
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
84
-					break;
85
-			}
86
-		}
87
-
88
-    }
89
-
90
-    /**
91
-	 * Register admin scripts
92
-	 *
93
-	 */
94
-	public function enqeue_scripts() {
69
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
+        do_action( 'getpaid_init_admin_hooks', $this );
78
+
79
+        // Setup/welcome
80
+        if ( ! empty( $_GET['page'] ) ) {
81
+            switch ( sanitize_text_field( $_GET['page'] ) ) {
82
+                case 'gp-setup' :
83
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
84
+                    break;
85
+            }
86
+        }
87
+
88
+    }
89
+
90
+    /**
91
+     * Register admin scripts
92
+     *
93
+     */
94
+    public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
98
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
97
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
98
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100 100
         if ( ! empty( $current_screen->post_type ) ) {
101
-			$page = $current_screen->post_type;
101
+            $page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
@@ -119,54 +119,54 @@  discard block
 block discarded – undo
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+        if ( 'wpi_payment_form' == $page && $editing ) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
128
-		}
126
+        if ( $page == 'wpinv-subscriptions' ) {
127
+            wp_enqueue_script( 'postbox' );
128
+        }
129 129
 
130 130
     }
131 131
 
132 132
     /**
133
-	 * Returns admin js translations.
134
-	 *
135
-	 */
136
-	protected function get_admin_i18() {
133
+     * Returns admin js translations.
134
+     *
135
+     */
136
+    protected function get_admin_i18() {
137 137
         global $post;
138 138
 
139
-		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
141
-		);
139
+        $date_range = array(
140
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
141
+        );
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+        if ( $date_range['period'] == 'custom' ) {
144 144
 			
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
-			}
145
+            if ( isset( $_GET['from'] ) ) {
146
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
+            }
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
-			}
149
+            if ( isset( $_GET['to'] ) ) {
150
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
+            }
152 152
 
153
-		}
153
+        }
154 154
 
155 155
         $i18n = array(
156 156
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
157 157
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
158
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
-			'rest_root'                 => esc_url_raw( rest_url() ),
161
-			'date_range'                => $date_range,
158
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
+            'rest_root'                 => esc_url_raw( rest_url() ),
161
+            'date_range'                => $date_range,
162 162
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
163 163
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
164 164
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
165 165
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
166 166
             'tax'                       => wpinv_tax_amount(),
167 167
             'discount'                  => 0,
168
-			'currency_symbol'           => wpinv_currency_symbol(),
169
-			'currency'                  => wpinv_get_currency(),
168
+            'currency_symbol'           => wpinv_currency_symbol(),
169
+            'currency'                  => wpinv_get_currency(),
170 170
             'currency_pos'              => wpinv_currency_position(),
171 171
             'thousand_sep'              => wpinv_thousands_separator(),
172 172
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -186,119 +186,119 @@  discard block
 block discarded – undo
186 186
             'item_description'          => __( 'Item Description', 'invoicing' ),
187 187
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
188 188
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
189
-			'searching'                 => __( 'Searching', 'invoicing' ),
190
-			'loading'                   => __( 'Loading...', 'invoicing' ),
191
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
193
-			'graphs' => array_merge( ['refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'], array_keys( wpinv_get_report_graphs() ) ),
189
+            'searching'                 => __( 'Searching', 'invoicing' ),
190
+            'loading'                   => __( 'Loading...', 'invoicing' ),
191
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
193
+            'graphs' => array_merge( ['refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'], array_keys( wpinv_get_report_graphs() ) ),
194 194
         );
195 195
 
196
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
196
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
197 197
 
198
-			$invoice              = new WPInv_Invoice( $post );
199
-			$i18n['save_invoice'] = sprintf(
200
-				__( 'Save %s', 'invoicing' ),
201
-				ucfirst( $invoice->get_invoice_quote_type() )
202
-			);
198
+            $invoice              = new WPInv_Invoice( $post );
199
+            $i18n['save_invoice'] = sprintf(
200
+                __( 'Save %s', 'invoicing' ),
201
+                ucfirst( $invoice->get_invoice_quote_type() )
202
+            );
203 203
 
204
-			$i18n['invoice_description'] = sprintf(
205
-				__( '%s Description', 'invoicing' ),
206
-				ucfirst( $invoice->get_invoice_quote_type() )
207
-			);
204
+            $i18n['invoice_description'] = sprintf(
205
+                __( '%s Description', 'invoicing' ),
206
+                ucfirst( $invoice->get_invoice_quote_type() )
207
+            );
208 208
 
209
-		}
210
-		return $i18n;
211
-	}
209
+        }
210
+        return $i18n;
211
+    }
212 212
 
213
-	/**
214
-	 * Change the admin footer text on GetPaid admin pages.
215
-	 *
216
-	 * @since  2.0.0
217
-	 * @param  string $footer_text
218
-	 * @return string
219
-	 */
220
-	public function admin_footer_text( $footer_text ) {
221
-		global $current_screen;
213
+    /**
214
+     * Change the admin footer text on GetPaid admin pages.
215
+     *
216
+     * @since  2.0.0
217
+     * @param  string $footer_text
218
+     * @return string
219
+     */
220
+    public function admin_footer_text( $footer_text ) {
221
+        global $current_screen;
222 222
 
223
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
223
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
224 224
 
225 225
         if ( ! empty( $current_screen->post_type ) ) {
226
-			$page = $current_screen->post_type;
226
+            $page = $current_screen->post_type;
227 227
         }
228 228
 
229 229
         // General styles.
230 230
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
231 231
 
232
-			// Change the footer text
233
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
234
-
235
-				$rating_url  = esc_url(
236
-					wp_nonce_url(
237
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
238
-						'getpaid-nonce',
239
-						'getpaid-nonce'
240
-						)
241
-				);
242
-
243
-				$footer_text = sprintf(
244
-					/* translators: %s: five stars */
245
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
246
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
247
-				);
248
-
249
-			} else {
250
-
251
-				$footer_text = sprintf(
252
-					/* translators: %s: GetPaid */
253
-					__( 'Thank you for using %s!', 'invoicing' ),
254
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
255
-				);
256
-
257
-			}
258
-
259
-		}
260
-
261
-		return $footer_text;
262
-	}
263
-
264
-	/**
265
-	 * Redirects to wp.org to rate the plugin.
266
-	 *
267
-	 * @since  2.0.0
268
-	 */
269
-	public function redirect_to_wordpress_rating_page() {
270
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
271
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
272
-		exit;
273
-	}
274
-
275
-    /**
276
-	 * Loads payment form js.
277
-	 *
278
-	 */
279
-	protected function load_payment_form_scripts() {
232
+            // Change the footer text
233
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
234
+
235
+                $rating_url  = esc_url(
236
+                    wp_nonce_url(
237
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
238
+                        'getpaid-nonce',
239
+                        'getpaid-nonce'
240
+                        )
241
+                );
242
+
243
+                $footer_text = sprintf(
244
+                    /* translators: %s: five stars */
245
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
246
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
247
+                );
248
+
249
+            } else {
250
+
251
+                $footer_text = sprintf(
252
+                    /* translators: %s: GetPaid */
253
+                    __( 'Thank you for using %s!', 'invoicing' ),
254
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
255
+                );
256
+
257
+            }
258
+
259
+        }
260
+
261
+        return $footer_text;
262
+    }
263
+
264
+    /**
265
+     * Redirects to wp.org to rate the plugin.
266
+     *
267
+     * @since  2.0.0
268
+     */
269
+    public function redirect_to_wordpress_rating_page() {
270
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
271
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
272
+        exit;
273
+    }
274
+
275
+    /**
276
+     * Loads payment form js.
277
+     *
278
+     */
279
+    protected function load_payment_form_scripts() {
280 280
         global $post;
281 281
 
282 282
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
283
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
284
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
283
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
284
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
285 285
 
286
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
287
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
286
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
287
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $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,20 +307,20 @@  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
 
320 320
         $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
321 321
 
322 322
         if ( ! empty( $current_screen->post_type ) ) {
323
-			$page = $current_screen->post_type;
323
+            $page = $current_screen->post_type;
324 324
         }
325 325
 
326 326
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -329,68 +329,68 @@  discard block
 block discarded – undo
329 329
 
330 330
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
331 331
             $classes .= ' wpinv-cpt wpinv';
332
-		}
332
+        }
333 333
 		
334
-		if ( getpaid_is_invoice_post_type( $page ) ) {
334
+        if ( getpaid_is_invoice_post_type( $page ) ) {
335 335
             $classes .= ' getpaid-is-invoice-cpt';
336 336
         }
337 337
 
338
-		return $classes;
338
+        return $classes;
339 339
     }
340 340
 
341 341
     /**
342
-	 * Maybe show the AyeCode Connect Notice.
343
-	 */
344
-	public function init_ayecode_connect_helper(){
342
+     * Maybe show the AyeCode Connect Notice.
343
+     */
344
+    public function init_ayecode_connect_helper(){
345 345
 
346
-		// Register with the deactivation survey class.
347
-		AyeCode_Deactivation_Survey::instance(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' ),
353
-		));
346
+        // Register with the deactivation survey class.
347
+        AyeCode_Deactivation_Survey::instance(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' ),
353
+        ));
354 354
 
355 355
         new AyeCode_Connect_Helper(
356 356
             array(
357
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
358
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
359
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
360
-				'connect_button'    => __("Connect Site","invoicing"),
361
-				'connecting_button'    => __("Connecting...","invoicing"),
362
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
363
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
357
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
358
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
359
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
360
+                'connect_button'    => __("Connect Site","invoicing"),
361
+                'connecting_button'    => __("Connecting...","invoicing"),
362
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
363
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
364 364
             ),
365 365
             array( 'wpi-addons' )
366 366
         );
367 367
 
368 368
     }
369 369
 
370
-	/**
371
-	 * Redirect users to settings on activation.
372
-	 *
373
-	 * @return void
374
-	 */
375
-	public function activation_redirect() {
370
+    /**
371
+     * Redirect users to settings on activation.
372
+     *
373
+     * @return void
374
+     */
375
+    public function activation_redirect() {
376 376
 
377
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
377
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
378 378
 
379
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
380
-			return;
381
-		}
379
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
380
+            return;
381
+        }
382 382
 
383
-		// Bail if activating from network, or bulk
384
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
385
-			return;
386
-		}
383
+        // Bail if activating from network, or bulk
384
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
385
+            return;
386
+        }
387 387
 
388
-	    update_option( 'wpinv_redirected_to_settings', 1 );
388
+        update_option( 'wpinv_redirected_to_settings', 1 );
389 389
 
390 390
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
391 391
         exit;
392 392
 
393
-	}
393
+    }
394 394
 
395 395
     /**
396 396
      * Fires an admin action after verifying that a user can fire them.
@@ -404,532 +404,532 @@  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.', 'newsletter-optin-box' ) );
429
+            getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
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.', 'newsletter-optin-box' ) );
444
+        getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
445 445
 
446
-	}
446
+    }
447 447
 
448
-	/**
448
+    /**
449 449
      * Sends a payment reminder to a customer.
450
-	 * 
451
-	 * @param array $args
450
+     * 
451
+     * @param array $args
452 452
      */
453 453
     public function duplicate_payment_form( $args ) {
454 454
 
455
-		if ( empty( $args['form_id'] ) ) {
456
-			return;
457
-		}
458
-
459
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
455
+        if ( empty( $args['form_id'] ) ) {
456
+            return;
457
+        }
460 458
 
461
-		if ( ! $form->exists() ) {
462
-			return;
463
-		}
459
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
464 460
 
465
-		$new_form = new GetPaid_Payment_Form();
466
-		$new_form->set_author( $form->get_author( 'edit' ) );
467
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
468
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
469
-		$new_form->set_items( $form->get_items( 'edit' ) );
470
-		$new_form->save();
461
+        if ( ! $form->exists() ) {
462
+            return;
463
+        }
471 464
 
472
-		if ( $new_form->exists() ) {
473
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
474
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
475
-		} else {
476
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
477
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
478
-		}
465
+        $new_form = new GetPaid_Payment_Form();
466
+        $new_form->set_author( $form->get_author( 'edit' ) );
467
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
468
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
469
+        $new_form->set_items( $form->get_items( 'edit' ) );
470
+        $new_form->save();
471
+
472
+        if ( $new_form->exists() ) {
473
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
474
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
475
+        } else {
476
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
477
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
478
+        }
479 479
 
480
-		wp_redirect( $url );
481
-		exit;
482
-	}
480
+        wp_redirect( $url );
481
+        exit;
482
+    }
483 483
 
484
-	/**
484
+    /**
485 485
      * Sends a payment reminder to a customer.
486
-	 * 
487
-	 * @param array $args
486
+     * 
487
+     * @param array $args
488 488
      */
489 489
     public function send_customer_invoice( $args ) {
490
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
491
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
492
-		exit;
493
-	}
490
+        getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
491
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
492
+        exit;
493
+    }
494 494
 
495
-	/**
495
+    /**
496 496
      * Sends a payment reminder to a customer.
497
-	 * 
498
-	 * @param array $args
497
+     * 
498
+     * @param array $args
499 499
      */
500 500
     public function send_customer_payment_reminder( $args ) {
501
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
501
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
502 502
 
503
-		if ( $sent ) {
504
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
505
-		} else {
506
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
507
-		}
503
+        if ( $sent ) {
504
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
505
+        } else {
506
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
507
+        }
508 508
 
509
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
510
-		exit;
511
-	}
509
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
510
+        exit;
511
+    }
512 512
 
513
-	/**
513
+    /**
514 514
      * Resets tax rates.
515
-	 * 
515
+     * 
516 516
      */
517 517
     public function admin_reset_tax_rates() {
518 518
 
519
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
520
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
521
-		exit;
519
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
520
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
521
+        exit;
522 522
 
523
-	}
523
+    }
524 524
 
525
-	/**
525
+    /**
526 526
      * Resets admin pages.
527
-	 * 
527
+     * 
528 528
      */
529 529
     public function admin_create_missing_pages() {
530
-		$installer = new GetPaid_Installer();
531
-		$installer->create_pages();
532
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
533
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
534
-		exit;
535
-	}
536
-
537
-	/**
530
+        $installer = new GetPaid_Installer();
531
+        $installer->create_pages();
532
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
533
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
534
+        exit;
535
+    }
536
+
537
+    /**
538 538
      * Creates an missing admin tables.
539
-	 * 
539
+     * 
540 540
      */
541 541
     public function admin_create_missing_tables() {
542
-		global $wpdb;
543
-		$installer = new GetPaid_Installer();
542
+        global $wpdb;
543
+        $installer = new GetPaid_Installer();
544 544
 
545
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
546
-			$installer->create_subscriptions_table();
545
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
546
+            $installer->create_subscriptions_table();
547 547
 
548
-			if ( $wpdb->last_error !== '' ) {
549
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
550
-			}
551
-		}
548
+            if ( $wpdb->last_error !== '' ) {
549
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
550
+            }
551
+        }
552 552
 
553
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
554
-			$installer->create_invoices_table();
553
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
554
+            $installer->create_invoices_table();
555 555
 
556
-			if ( $wpdb->last_error !== '' ) {
557
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
558
-			}
559
-		}
556
+            if ( $wpdb->last_error !== '' ) {
557
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
558
+            }
559
+        }
560 560
 
561
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
562
-			$installer->create_invoice_items_table();
561
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
562
+            $installer->create_invoice_items_table();
563 563
 
564
-			if ( $wpdb->last_error !== '' ) {
565
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
566
-			}
567
-		}
564
+            if ( $wpdb->last_error !== '' ) {
565
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
566
+            }
567
+        }
568 568
 
569
-		if ( ! $this->has_notices() ) {
570
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
571
-		}
569
+        if ( ! $this->has_notices() ) {
570
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
571
+        }
572 572
 
573
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
574
-		exit;
575
-	}
573
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
574
+        exit;
575
+    }
576 576
 
577
-	/**
577
+    /**
578 578
      * Migrates old invoices to the new database tables.
579
-	 * 
579
+     * 
580 580
      */
581 581
     public function admin_migrate_old_invoices() {
582 582
 
583
-		// Migrate the invoices.
584
-		$installer = new GetPaid_Installer();
585
-		$installer->migrate_old_invoices();
583
+        // Migrate the invoices.
584
+        $installer = new GetPaid_Installer();
585
+        $installer->migrate_old_invoices();
586 586
 
587
-		// Show an admin message.
588
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
587
+        // Show an admin message.
588
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
589 589
 
590
-		// Redirect the admin.
591
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
592
-		exit;
590
+        // Redirect the admin.
591
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
592
+        exit;
593 593
 
594
-	}
594
+    }
595 595
 
596
-	/**
596
+    /**
597 597
      * Download customers.
598
-	 * 
598
+     * 
599 599
      */
600 600
     public function admin_download_customers() {
601
-		global $wpdb;
601
+        global $wpdb;
602 602
 
603
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
603
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
604 604
 
605
-		header( "Content-Type:text/csv" );
606
-		header( "Content-Disposition:attachment;filename=customers.csv" );
605
+        header( "Content-Type:text/csv" );
606
+        header( "Content-Disposition:attachment;filename=customers.csv" );
607 607
 
608
-		$post_types = '';
608
+        $post_types = '';
609 609
 
610
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
611
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
612
-		}
610
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
611
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
612
+        }
613 613
 
614
-		$post_types = rtrim( $post_types, ' OR' );
614
+        $post_types = rtrim( $post_types, ' OR' );
615 615
 
616
-		$customers = $wpdb->get_col(
617
-			$wpdb->prepare(
618
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
619
-			)
620
-		);
616
+        $customers = $wpdb->get_col(
617
+            $wpdb->prepare(
618
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
619
+            )
620
+        );
621 621
 
622
-		$columns = array(
623
-			'name'     => __( 'Name', 'invoicing' ),
624
-			'email'    => __( 'Email', 'invoicing' ),
625
-			'country'  => __( 'Country', 'invoicing' ),
626
-			'state'    => __( 'State', 'invoicing' ),
627
-			'city'     => __( 'City', 'invoicing' ),
628
-			'zip'      => __( 'ZIP', 'invoicing' ),
629
-			'address'  => __( 'Address', 'invoicing' ),
630
-			'phone'    => __( 'Phone', 'invoicing' ),
631
-			'company'  => __( 'Company', 'invoicing' ),
632
-			'company_id'  => __( 'Company ID', 'invoicing' ),
633
-			'invoices' => __( 'Invoices', 'invoicing' ),
634
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
635
-			'signup'   => __( 'Date created', 'invoicing' ),
636
-		);
622
+        $columns = array(
623
+            'name'     => __( 'Name', 'invoicing' ),
624
+            'email'    => __( 'Email', 'invoicing' ),
625
+            'country'  => __( 'Country', 'invoicing' ),
626
+            'state'    => __( 'State', 'invoicing' ),
627
+            'city'     => __( 'City', 'invoicing' ),
628
+            'zip'      => __( 'ZIP', 'invoicing' ),
629
+            'address'  => __( 'Address', 'invoicing' ),
630
+            'phone'    => __( 'Phone', 'invoicing' ),
631
+            'company'  => __( 'Company', 'invoicing' ),
632
+            'company_id'  => __( 'Company ID', 'invoicing' ),
633
+            'invoices' => __( 'Invoices', 'invoicing' ),
634
+            'total_raw' => __( 'Total Spend', 'invoicing' ),
635
+            'signup'   => __( 'Date created', 'invoicing' ),
636
+        );
637 637
 
638
-		// Output the csv column headers.
639
-		fputcsv( $output, array_values( $columns ) );
638
+        // Output the csv column headers.
639
+        fputcsv( $output, array_values( $columns ) );
640 640
 
641
-		// Loop through
642
-		$table = new WPInv_Customers_Table();
643
-		foreach ( $customers as $customer_id ) {
641
+        // Loop through
642
+        $table = new WPInv_Customers_Table();
643
+        foreach ( $customers as $customer_id ) {
644 644
 
645
-			$user = get_user_by( 'id', $customer_id );
646
-			$row  = array();
647
-			if ( empty( $user ) ) {
648
-				continue;
649
-			}
645
+            $user = get_user_by( 'id', $customer_id );
646
+            $row  = array();
647
+            if ( empty( $user ) ) {
648
+                continue;
649
+            }
650 650
 
651
-			foreach ( array_keys( $columns ) as $column ) {
651
+            foreach ( array_keys( $columns ) as $column ) {
652 652
 
653
-				$method = 'column_' . $column;
653
+                $method = 'column_' . $column;
654 654
 
655
-				if ( 'name' == $column ) {
656
-					$value = esc_html( $user->display_name );
657
-				} else if( 'email' == $column ) {
658
-					$value = sanitize_email( $user->user_email );
659
-				} else if ( is_callable( array( $table, $method ) ) ) {
660
-					$value = strip_tags( $table->$method( $user ) );
661
-				}
655
+                if ( 'name' == $column ) {
656
+                    $value = esc_html( $user->display_name );
657
+                } else if( 'email' == $column ) {
658
+                    $value = sanitize_email( $user->user_email );
659
+                } else if ( is_callable( array( $table, $method ) ) ) {
660
+                    $value = strip_tags( $table->$method( $user ) );
661
+                }
662 662
 
663
-				if ( empty( $value ) ) {
664
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
665
-				}
663
+                if ( empty( $value ) ) {
664
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
665
+                }
666 666
 
667
-				$row[] = $value;
667
+                $row[] = $value;
668 668
 
669
-			}
669
+            }
670 670
 
671
-			fputcsv( $output, $row );
672
-		}
671
+            fputcsv( $output, $row );
672
+        }
673 673
 
674
-		fclose( $output );
675
-		exit;
674
+        fclose( $output );
675
+        exit;
676 676
 
677
-	}
677
+    }
678 678
 
679
-	/**
679
+    /**
680 680
      * Installs a plugin.
681
-	 *
682
-	 * @param array $data
681
+     *
682
+     * @param array $data
683 683
      */
684 684
     public function admin_install_plugin( $data ) {
685 685
 
686
-		if ( ! empty( $data['plugins'] ) ) {
687
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
688
-			wp_cache_flush();
686
+        if ( ! empty( $data['plugins'] ) ) {
687
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
688
+            wp_cache_flush();
689 689
 
690
-			foreach ( $data['plugins'] as $slug => $file ) {
691
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
692
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
693
-				$installed  = $upgrader->install( $plugin_zip );
690
+            foreach ( $data['plugins'] as $slug => $file ) {
691
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
692
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
693
+                $installed  = $upgrader->install( $plugin_zip );
694 694
 
695
-				if ( ! is_wp_error( $installed ) && $installed ) {
696
-					activate_plugin( $file, '', false, true );
697
-				} else {
698
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
699
-				}
695
+                if ( ! is_wp_error( $installed ) && $installed ) {
696
+                    activate_plugin( $file, '', false, true );
697
+                } else {
698
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
699
+                }
700 700
 
701
-			}
701
+            }
702 702
 
703
-		}
703
+        }
704 704
 
705
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
706
-		wp_safe_redirect( $redirect );
707
-		exit;
705
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
706
+        wp_safe_redirect( $redirect );
707
+        exit;
708 708
 
709
-	}
709
+    }
710 710
 
711
-	/**
711
+    /**
712 712
      * Connects a gateway.
713
-	 *
714
-	 * @param array $data
713
+     *
714
+     * @param array $data
715 715
      */
716 716
     public function admin_connect_gateway( $data ) {
717 717
 
718
-		if ( ! empty( $data['plugin'] ) ) {
718
+        if ( ! empty( $data['plugin'] ) ) {
719 719
 
720
-			$gateway     = sanitize_key( $data['plugin'] );
721
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
720
+            $gateway     = sanitize_key( $data['plugin'] );
721
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
722 722
 
723
-			if ( ! empty( $connect_url ) ) {
724
-				wp_redirect( $connect_url );
725
-				exit;
726
-			}
723
+            if ( ! empty( $connect_url ) ) {
724
+                wp_redirect( $connect_url );
725
+                exit;
726
+            }
727 727
 
728
-			if ( 'stripe' == $data['plugin'] ) {
729
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
730
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
731
-				wp_cache_flush();
728
+            if ( 'stripe' == $data['plugin'] ) {
729
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
730
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
731
+                wp_cache_flush();
732 732
 
733
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
734
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
735
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
736
-					$upgrader->install( $plugin_zip );
737
-				}
733
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
734
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
735
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
736
+                    $upgrader->install( $plugin_zip );
737
+                }
738 738
 
739
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
740
-			}
739
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
740
+            }
741 741
 
742
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
743
-			if ( ! empty( $connect_url ) ) {
744
-				wp_redirect( $connect_url );
745
-				exit;
746
-			}
742
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
743
+            if ( ! empty( $connect_url ) ) {
744
+                wp_redirect( $connect_url );
745
+                exit;
746
+            }
747 747
 
748
-		}
748
+        }
749 749
 
750
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
751
-		wp_safe_redirect( $redirect );
752
-		exit;
750
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
751
+        wp_safe_redirect( $redirect );
752
+        exit;
753 753
 
754
-	}
754
+    }
755 755
 
756
-	/**
756
+    /**
757 757
      * Recalculates discounts.
758
-	 * 
758
+     * 
759 759
      */
760 760
     public function admin_recalculate_discounts() {
761
-		global $wpdb;
761
+        global $wpdb;
762 762
 
763
-		// Fetch all invoices that have discount codes.
764
-		$table    = $wpdb->prefix . 'getpaid_invoices';
765
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
763
+        // Fetch all invoices that have discount codes.
764
+        $table    = $wpdb->prefix . 'getpaid_invoices';
765
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
766 766
 
767
-		foreach ( $invoices as $invoice ) {
767
+        foreach ( $invoices as $invoice ) {
768 768
 
769
-			$invoice = new WPInv_Invoice( $invoice );
769
+            $invoice = new WPInv_Invoice( $invoice );
770 770
 
771
-			if ( ! $invoice->exists() ) {
772
-				continue;
773
-			}
771
+            if ( ! $invoice->exists() ) {
772
+                continue;
773
+            }
774 774
 
775
-			// Abort if the discount does not exist or does not apply here.
776
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
777
-			if ( ! $discount->exists() ) {
778
-				continue;
779
-			}
775
+            // Abort if the discount does not exist or does not apply here.
776
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
777
+            if ( ! $discount->exists() ) {
778
+                continue;
779
+            }
780 780
 
781
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
782
-			$invoice->recalculate_total();
781
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
782
+            $invoice->recalculate_total();
783 783
 
784
-			if ( $invoice->get_total_discount() > 0 ) {
785
-				$invoice->save();
786
-			}
784
+            if ( $invoice->get_total_discount() > 0 ) {
785
+                $invoice->save();
786
+            }
787 787
 
788
-		}
788
+        }
789 789
 
790
-		// Show an admin message.
791
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
790
+        // Show an admin message.
791
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
792 792
 
793
-		// Redirect the admin.
794
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
795
-		exit;
793
+        // Redirect the admin.
794
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
795
+        exit;
796 796
 
797
-	}
797
+    }
798 798
 
799 799
     /**
800
-	 * Returns an array of admin notices.
801
-	 *
802
-	 * @since       1.0.19
800
+     * Returns an array of admin notices.
801
+     *
802
+     * @since       1.0.19
803 803
      * @return array
804
-	 */
805
-	public function get_notices() {
806
-		$notices = get_option( 'wpinv_admin_notices' );
804
+     */
805
+    public function get_notices() {
806
+        $notices = get_option( 'wpinv_admin_notices' );
807 807
         return is_array( $notices ) ? $notices : array();
808
-	}
808
+    }
809 809
 
810
-	/**
811
-	 * Checks if we have any admin notices.
812
-	 *
813
-	 * @since       2.0.4
810
+    /**
811
+     * Checks if we have any admin notices.
812
+     *
813
+     * @since       2.0.4
814 814
      * @return array
815
-	 */
816
-	public function has_notices() {
817
-		return count( $this->get_notices() ) > 0;
818
-	}
819
-
820
-	/**
821
-	 * Clears all admin notices
822
-	 *
823
-	 * @access      public
824
-	 * @since       1.0.19
825
-	 */
826
-	public function clear_notices() {
827
-		delete_option( 'wpinv_admin_notices' );
828
-	}
829
-
830
-	/**
831
-	 * Saves a new admin notice
832
-	 *
833
-	 * @access      public
834
-	 * @since       1.0.19
835
-	 */
836
-	public function save_notice( $type, $message ) {
837
-		$notices = $this->get_notices();
838
-
839
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
840
-			$notices[ $type ] = array();
841
-		}
842
-
843
-		$notices[ $type ][] = $message;
844
-
845
-		update_option( 'wpinv_admin_notices', $notices );
846
-	}
847
-
848
-	/**
849
-	 * Displays a success notice
850
-	 *
851
-	 * @param       string $msg The message to qeue.
852
-	 * @access      public
853
-	 * @since       1.0.19
854
-	 */
855
-	public function show_success( $msg ) {
856
-		$this->save_notice( 'success', $msg );
857
-	}
858
-
859
-	/**
860
-	 * Displays a error notice
861
-	 *
862
-	 * @access      public
863
-	 * @param       string $msg The message to qeue.
864
-	 * @since       1.0.19
865
-	 */
866
-	public function show_error( $msg ) {
867
-		$this->save_notice( 'error', $msg );
868
-	}
869
-
870
-	/**
871
-	 * Displays a warning notice
872
-	 *
873
-	 * @access      public
874
-	 * @param       string $msg The message to qeue.
875
-	 * @since       1.0.19
876
-	 */
877
-	public function show_warning( $msg ) {
878
-		$this->save_notice( 'warning', $msg );
879
-	}
880
-
881
-	/**
882
-	 * Displays a info notice
883
-	 *
884
-	 * @access      public
885
-	 * @param       string $msg The message to qeue.
886
-	 * @since       1.0.19
887
-	 */
888
-	public function show_info( $msg ) {
889
-		$this->save_notice( 'info', $msg );
890
-	}
891
-
892
-	/**
893
-	 * Show notices
894
-	 *
895
-	 * @access      public
896
-	 * @since       1.0.19
897
-	 */
898
-	public function show_notices() {
815
+     */
816
+    public function has_notices() {
817
+        return count( $this->get_notices() ) > 0;
818
+    }
819
+
820
+    /**
821
+     * Clears all admin notices
822
+     *
823
+     * @access      public
824
+     * @since       1.0.19
825
+     */
826
+    public function clear_notices() {
827
+        delete_option( 'wpinv_admin_notices' );
828
+    }
829
+
830
+    /**
831
+     * Saves a new admin notice
832
+     *
833
+     * @access      public
834
+     * @since       1.0.19
835
+     */
836
+    public function save_notice( $type, $message ) {
837
+        $notices = $this->get_notices();
838
+
839
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
840
+            $notices[ $type ] = array();
841
+        }
842
+
843
+        $notices[ $type ][] = $message;
844
+
845
+        update_option( 'wpinv_admin_notices', $notices );
846
+    }
847
+
848
+    /**
849
+     * Displays a success notice
850
+     *
851
+     * @param       string $msg The message to qeue.
852
+     * @access      public
853
+     * @since       1.0.19
854
+     */
855
+    public function show_success( $msg ) {
856
+        $this->save_notice( 'success', $msg );
857
+    }
858
+
859
+    /**
860
+     * Displays a error notice
861
+     *
862
+     * @access      public
863
+     * @param       string $msg The message to qeue.
864
+     * @since       1.0.19
865
+     */
866
+    public function show_error( $msg ) {
867
+        $this->save_notice( 'error', $msg );
868
+    }
869
+
870
+    /**
871
+     * Displays a warning notice
872
+     *
873
+     * @access      public
874
+     * @param       string $msg The message to qeue.
875
+     * @since       1.0.19
876
+     */
877
+    public function show_warning( $msg ) {
878
+        $this->save_notice( 'warning', $msg );
879
+    }
880
+
881
+    /**
882
+     * Displays a info notice
883
+     *
884
+     * @access      public
885
+     * @param       string $msg The message to qeue.
886
+     * @since       1.0.19
887
+     */
888
+    public function show_info( $msg ) {
889
+        $this->save_notice( 'info', $msg );
890
+    }
891
+
892
+    /**
893
+     * Show notices
894
+     *
895
+     * @access      public
896
+     * @since       1.0.19
897
+     */
898
+    public function show_notices() {
899 899
 
900 900
         $notices = $this->get_notices();
901 901
         $this->clear_notices();
902 902
 
903
-		foreach ( $notices as $type => $messages ) {
903
+        foreach ( $notices as $type => $messages ) {
904 904
 
905
-			if ( ! is_array( $messages ) ) {
906
-				continue;
907
-			}
905
+            if ( ! is_array( $messages ) ) {
906
+                continue;
907
+            }
908 908
 
909 909
             $type  = esc_attr( $type );
910
-			foreach ( $messages as $message ) {
910
+            foreach ( $messages as $message ) {
911 911
                 $message = wp_kses_post( $message );
912
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
912
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
913 913
             }
914 914
 
915 915
         }
916 916
 
917
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
918
-
919
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
920
-				$url     = wp_nonce_url(
921
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
922
-					'getpaid-nonce',
923
-					'getpaid-nonce'
924
-				);
925
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
926
-				$message2 = __( 'Generate Pages', 'invoicing' );
927
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
928
-				break;
929
-			}
917
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
918
+
919
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
920
+                $url     = wp_nonce_url(
921
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
922
+                    'getpaid-nonce',
923
+                    'getpaid-nonce'
924
+                );
925
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
926
+                $message2 = __( 'Generate Pages', 'invoicing' );
927
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
928
+                break;
929
+            }
930 930
 
931
-		}
931
+        }
932 932
 
933
-	}
933
+    }
934 934
 
935 935
 }
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.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
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,33 +54,33 @@  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_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		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_duplicate_invoice', array($this, 'duplicate_invoice'));
66
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
67
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
68
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
69
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
70
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
71
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
72
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
73
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
74
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
75
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
76
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
77
+		do_action('getpaid_init_admin_hooks', $this);
78 78
 
79 79
 		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
80
+		if (!empty($_GET['page'])) {
81
+			switch (sanitize_text_field($_GET['page'])) {
82 82
 				case 'gp-setup' :
83
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
+					include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');
84 84
 					break;
85 85
 			}
86 86
 		}
@@ -94,37 +94,37 @@  discard block
 block discarded – undo
94 94
 	public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
97
+		$page    = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
98 98
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100
-        if ( ! empty( $current_screen->post_type ) ) {
100
+        if (!empty($current_screen->post_type)) {
101 101
 			$page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
105
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) {
105
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) {
106 106
 
107 107
             // Styles.
108
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
109
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
110
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
108
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
109
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
110
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
111 111
 
112 112
             // Scripts.
113
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
113
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
114 114
 
115
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
116
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ),  $version );
117
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
115
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
116
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
117
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
118 118
 
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+		if ('wpi_payment_form' == $page && $editing) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
126
+		if ($page == 'wpinv-subscriptions') {
127
+			wp_enqueue_script('postbox');
128 128
 		}
129 129
 
130 130
     }
@@ -137,32 +137,32 @@  discard block
 block discarded – undo
137 137
         global $post;
138 138
 
139 139
 		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
141 141
 		);
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+		if ($date_range['period'] == 'custom') {
144 144
 			
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
145
+			if (isset($_GET['from'])) {
146
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
147 147
 			}
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
149
+			if (isset($_GET['to'])) {
150
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
151 151
 			}
152 152
 
153 153
 		}
154 154
 
155 155
         $i18n = array(
156
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
157
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
158
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
-			'rest_root'                 => esc_url_raw( rest_url() ),
156
+            'ajax_url'                  => admin_url('admin-ajax.php'),
157
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
158
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
159
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
160
+			'rest_root'                 => esc_url_raw(rest_url()),
161 161
 			'date_range'                => $date_range,
162
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
163
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
164
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
165
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
162
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
163
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
164
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
165
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
166 166
             'tax'                       => wpinv_tax_amount(),
167 167
             'discount'                  => 0,
168 168
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -171,39 +171,39 @@  discard block
 block discarded – undo
171 171
             'thousand_sep'              => wpinv_thousands_separator(),
172 172
             'decimal_sep'               => wpinv_decimal_separator(),
173 173
             'decimals'                  => wpinv_decimals(),
174
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
175
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
176
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
177
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
178
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
179
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
180
-            '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' ),
181
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
182
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
183
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
184
-            'action_edit'               => __( 'Edit', 'invoicing' ),
185
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
186
-            'item_description'          => __( 'Item Description', 'invoicing' ),
187
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
188
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
189
-			'searching'                 => __( 'Searching', 'invoicing' ),
190
-			'loading'                   => __( 'Loading...', 'invoicing' ),
191
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
193
-			'graphs' => array_merge( ['refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'], array_keys( wpinv_get_report_graphs() ) ),
174
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
175
+            'status_publish'            => wpinv_status_nicename('publish'),
176
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
177
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
178
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
179
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
180
+            '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'),
181
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
182
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
183
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
184
+            'action_edit'               => __('Edit', 'invoicing'),
185
+            'action_cancel'             => __('Cancel', 'invoicing'),
186
+            'item_description'          => __('Item Description', 'invoicing'),
187
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
188
+            'discount_description'      => __('Discount Description', 'invoicing'),
189
+			'searching'                 => __('Searching', 'invoicing'),
190
+			'loading'                   => __('Loading...', 'invoicing'),
191
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
192
+			'search_items'              => __('Enter item name', 'invoicing'),
193
+			'graphs' => array_merge(['refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'], array_keys(wpinv_get_report_graphs())),
194 194
         );
195 195
 
196
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
196
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
197 197
 
198
-			$invoice              = new WPInv_Invoice( $post );
198
+			$invoice              = new WPInv_Invoice($post);
199 199
 			$i18n['save_invoice'] = sprintf(
200
-				__( 'Save %s', 'invoicing' ),
201
-				ucfirst( $invoice->get_invoice_quote_type() )
200
+				__('Save %s', 'invoicing'),
201
+				ucfirst($invoice->get_invoice_quote_type())
202 202
 			);
203 203
 
204 204
 			$i18n['invoice_description'] = sprintf(
205
-				__( '%s Description', 'invoicing' ),
206
-				ucfirst( $invoice->get_invoice_quote_type() )
205
+				__('%s Description', 'invoicing'),
206
+				ucfirst($invoice->get_invoice_quote_type())
207 207
 			);
208 208
 
209 209
 		}
@@ -217,24 +217,24 @@  discard block
 block discarded – undo
217 217
 	 * @param  string $footer_text
218 218
 	 * @return string
219 219
 	 */
220
-	public function admin_footer_text( $footer_text ) {
220
+	public function admin_footer_text($footer_text) {
221 221
 		global $current_screen;
222 222
 
223
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
223
+		$page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
224 224
 
225
-        if ( ! empty( $current_screen->post_type ) ) {
225
+        if (!empty($current_screen->post_type)) {
226 226
 			$page = $current_screen->post_type;
227 227
         }
228 228
 
229 229
         // General styles.
230
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
230
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
231 231
 
232 232
 			// Change the footer text
233
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
234 234
 
235
-				$rating_url  = esc_url(
235
+				$rating_url = esc_url(
236 236
 					wp_nonce_url(
237
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
238 238
 						'getpaid-nonce',
239 239
 						'getpaid-nonce'
240 240
 						)
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 				$footer_text = sprintf(
244 244
 					/* translators: %s: five stars */
245
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
246 246
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
247 247
 				);
248 248
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 
251 251
 				$footer_text = sprintf(
252 252
 					/* translators: %s: GetPaid */
253
-					__( 'Thank you for using %s!', 'invoicing' ),
253
+					__('Thank you for using %s!', 'invoicing'),
254 254
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
255 255
 				);
256 256
 
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 	 * @since  2.0.0
268 268
 	 */
269 269
 	public function redirect_to_wordpress_rating_page() {
270
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
271
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
271
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
272 272
 		exit;
273 273
 	}
274 274
 
@@ -279,30 +279,30 @@  discard block
 block discarded – undo
279 279
 	protected function load_payment_form_scripts() {
280 280
         global $post;
281 281
 
282
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
283
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
284
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
282
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION);
283
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
284
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
285 285
 
286
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
287
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
286
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
287
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $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,25 +313,25 @@  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 319
 
320
-        $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
320
+        $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
321 321
 
322
-        if ( ! empty( $current_screen->post_type ) ) {
322
+        if (!empty($current_screen->post_type)) {
323 323
 			$page = $current_screen->post_type;
324 324
         }
325 325
 
326
-        if ( false !== stripos( $page, 'wpi' ) ) {
327
-            $classes .= ' wpi-' . sanitize_key( $page );
326
+        if (false !== stripos($page, 'wpi')) {
327
+            $classes .= ' wpi-' . sanitize_key($page);
328 328
         }
329 329
 
330
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
330
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
331 331
             $classes .= ' wpinv-cpt wpinv';
332 332
 		}
333 333
 		
334
-		if ( getpaid_is_invoice_post_type( $page ) ) {
334
+		if (getpaid_is_invoice_post_type($page)) {
335 335
             $classes .= ' getpaid-is-invoice-cpt';
336 336
         }
337 337
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
     /**
342 342
 	 * Maybe show the AyeCode Connect Notice.
343 343
 	 */
344
-	public function init_ayecode_connect_helper(){
344
+	public function init_ayecode_connect_helper() {
345 345
 
346 346
 		// Register with the deactivation survey class.
347 347
 		AyeCode_Deactivation_Survey::instance(array(
@@ -349,20 +349,20 @@  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
         new AyeCode_Connect_Helper(
356 356
             array(
357
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
358
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
359
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
360
-				'connect_button'    => __("Connect Site","invoicing"),
361
-				'connecting_button'    => __("Connecting...","invoicing"),
362
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
363
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
357
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
358
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
359
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
360
+				'connect_button'    => __("Connect Site", "invoicing"),
361
+				'connecting_button'    => __("Connecting...", "invoicing"),
362
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
363
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
364 364
             ),
365
-            array( 'wpi-addons' )
365
+            array('wpi-addons')
366 366
         );
367 367
 
368 368
     }
@@ -374,20 +374,20 @@  discard block
 block discarded – undo
374 374
 	 */
375 375
 	public function activation_redirect() {
376 376
 
377
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
377
+		$redirected = get_option('wpinv_redirected_to_settings');
378 378
 
379
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
380 380
 			return;
381 381
 		}
382 382
 
383 383
 		// Bail if activating from network, or bulk
384
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
385 385
 			return;
386 386
 		}
387 387
 
388
-	    update_option( 'wpinv_redirected_to_settings', 1 );
388
+	    update_option('wpinv_redirected_to_settings', 1);
389 389
 
390
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
390
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
391 391
         exit;
392 392
 
393 393
 	}
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
      */
398 398
     public function maybe_do_admin_action() {
399 399
 
400
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
401
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
402
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
400
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
401
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
402
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
403 403
         }
404 404
 
405 405
     }
@@ -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.', 'newsletter-optin-box' ) );
429
+			getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box'));
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.', 'newsletter-optin-box' ) );
444
+		getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box'));
445 445
 
446 446
 	}
447 447
 
@@ -450,34 +450,34 @@  discard block
 block discarded – undo
450 450
 	 * 
451 451
 	 * @param array $args
452 452
      */
453
-    public function duplicate_payment_form( $args ) {
453
+    public function duplicate_payment_form($args) {
454 454
 
455
-		if ( empty( $args['form_id'] ) ) {
455
+		if (empty($args['form_id'])) {
456 456
 			return;
457 457
 		}
458 458
 
459
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
459
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
460 460
 
461
-		if ( ! $form->exists() ) {
461
+		if (!$form->exists()) {
462 462
 			return;
463 463
 		}
464 464
 
465 465
 		$new_form = new GetPaid_Payment_Form();
466
-		$new_form->set_author( $form->get_author( 'edit' ) );
467
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
468
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
469
-		$new_form->set_items( $form->get_items( 'edit' ) );
466
+		$new_form->set_author($form->get_author('edit'));
467
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
468
+		$new_form->set_elements($form->get_elements('edit'));
469
+		$new_form->set_items($form->get_items('edit'));
470 470
 		$new_form->save();
471 471
 
472
-		if ( $new_form->exists() ) {
473
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
474
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
472
+		if ($new_form->exists()) {
473
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
474
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
475 475
 		} else {
476
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
477
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
476
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
477
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
478 478
 		}
479 479
 
480
-		wp_redirect( $url );
480
+		wp_redirect($url);
481 481
 		exit;
482 482
 	}
483 483
 
@@ -486,9 +486,9 @@  discard block
 block discarded – undo
486 486
 	 * 
487 487
 	 * @param array $args
488 488
      */
489
-    public function send_customer_invoice( $args ) {
490
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
491
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
489
+    public function send_customer_invoice($args) {
490
+		getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
491
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
492 492
 		exit;
493 493
 	}
494 494
 
@@ -497,16 +497,16 @@  discard block
 block discarded – undo
497 497
 	 * 
498 498
 	 * @param array $args
499 499
      */
500
-    public function send_customer_payment_reminder( $args ) {
501
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
500
+    public function send_customer_payment_reminder($args) {
501
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
502 502
 
503
-		if ( $sent ) {
504
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
503
+		if ($sent) {
504
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
505 505
 		} else {
506
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
506
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
507 507
 		}
508 508
 
509
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
509
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
510 510
 		exit;
511 511
 	}
512 512
 
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
      */
517 517
     public function admin_reset_tax_rates() {
518 518
 
519
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
520
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
519
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
520
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
521 521
 		exit;
522 522
 
523 523
 	}
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
     public function admin_create_missing_pages() {
530 530
 		$installer = new GetPaid_Installer();
531 531
 		$installer->create_pages();
532
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
533
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
532
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
533
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
534 534
 		exit;
535 535
 	}
536 536
 
@@ -542,35 +542,35 @@  discard block
 block discarded – undo
542 542
 		global $wpdb;
543 543
 		$installer = new GetPaid_Installer();
544 544
 
545
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
545
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
546 546
 			$installer->create_subscriptions_table();
547 547
 
548
-			if ( $wpdb->last_error !== '' ) {
549
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
548
+			if ($wpdb->last_error !== '') {
549
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
550 550
 			}
551 551
 		}
552 552
 
553
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
553
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
554 554
 			$installer->create_invoices_table();
555 555
 
556
-			if ( $wpdb->last_error !== '' ) {
557
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
556
+			if ($wpdb->last_error !== '') {
557
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
558 558
 			}
559 559
 		}
560 560
 
561
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
561
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
562 562
 			$installer->create_invoice_items_table();
563 563
 
564
-			if ( $wpdb->last_error !== '' ) {
565
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
564
+			if ($wpdb->last_error !== '') {
565
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
566 566
 			}
567 567
 		}
568 568
 
569
-		if ( ! $this->has_notices() ) {
570
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
569
+		if (!$this->has_notices()) {
570
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
571 571
 		}
572 572
 
573
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
573
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
574 574
 		exit;
575 575
 	}
576 576
 
@@ -585,10 +585,10 @@  discard block
 block discarded – undo
585 585
 		$installer->migrate_old_invoices();
586 586
 
587 587
 		// Show an admin message.
588
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
588
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
589 589
 
590 590
 		// Redirect the admin.
591
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
591
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
592 592
 		exit;
593 593
 
594 594
 	}
@@ -600,18 +600,18 @@  discard block
 block discarded – undo
600 600
     public function admin_download_customers() {
601 601
 		global $wpdb;
602 602
 
603
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
603
+		$output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing'));
604 604
 
605
-		header( "Content-Type:text/csv" );
606
-		header( "Content-Disposition:attachment;filename=customers.csv" );
605
+		header("Content-Type:text/csv");
606
+		header("Content-Disposition:attachment;filename=customers.csv");
607 607
 
608 608
 		$post_types = '';
609 609
 
610
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
611
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
610
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
611
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
612 612
 		}
613 613
 
614
-		$post_types = rtrim( $post_types, ' OR' );
614
+		$post_types = rtrim($post_types, ' OR');
615 615
 
616 616
 		$customers = $wpdb->get_col(
617 617
 			$wpdb->prepare(
@@ -620,58 +620,58 @@  discard block
 block discarded – undo
620 620
 		);
621 621
 
622 622
 		$columns = array(
623
-			'name'     => __( 'Name', 'invoicing' ),
624
-			'email'    => __( 'Email', 'invoicing' ),
625
-			'country'  => __( 'Country', 'invoicing' ),
626
-			'state'    => __( 'State', 'invoicing' ),
627
-			'city'     => __( 'City', 'invoicing' ),
628
-			'zip'      => __( 'ZIP', 'invoicing' ),
629
-			'address'  => __( 'Address', 'invoicing' ),
630
-			'phone'    => __( 'Phone', 'invoicing' ),
631
-			'company'  => __( 'Company', 'invoicing' ),
632
-			'company_id'  => __( 'Company ID', 'invoicing' ),
633
-			'invoices' => __( 'Invoices', 'invoicing' ),
634
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
635
-			'signup'   => __( 'Date created', 'invoicing' ),
623
+			'name'     => __('Name', 'invoicing'),
624
+			'email'    => __('Email', 'invoicing'),
625
+			'country'  => __('Country', 'invoicing'),
626
+			'state'    => __('State', 'invoicing'),
627
+			'city'     => __('City', 'invoicing'),
628
+			'zip'      => __('ZIP', 'invoicing'),
629
+			'address'  => __('Address', 'invoicing'),
630
+			'phone'    => __('Phone', 'invoicing'),
631
+			'company'  => __('Company', 'invoicing'),
632
+			'company_id'  => __('Company ID', 'invoicing'),
633
+			'invoices' => __('Invoices', 'invoicing'),
634
+			'total_raw' => __('Total Spend', 'invoicing'),
635
+			'signup'   => __('Date created', 'invoicing'),
636 636
 		);
637 637
 
638 638
 		// Output the csv column headers.
639
-		fputcsv( $output, array_values( $columns ) );
639
+		fputcsv($output, array_values($columns));
640 640
 
641 641
 		// Loop through
642 642
 		$table = new WPInv_Customers_Table();
643
-		foreach ( $customers as $customer_id ) {
643
+		foreach ($customers as $customer_id) {
644 644
 
645
-			$user = get_user_by( 'id', $customer_id );
645
+			$user = get_user_by('id', $customer_id);
646 646
 			$row  = array();
647
-			if ( empty( $user ) ) {
647
+			if (empty($user)) {
648 648
 				continue;
649 649
 			}
650 650
 
651
-			foreach ( array_keys( $columns ) as $column ) {
651
+			foreach (array_keys($columns) as $column) {
652 652
 
653 653
 				$method = 'column_' . $column;
654 654
 
655
-				if ( 'name' == $column ) {
656
-					$value = esc_html( $user->display_name );
657
-				} else if( 'email' == $column ) {
658
-					$value = sanitize_email( $user->user_email );
659
-				} else if ( is_callable( array( $table, $method ) ) ) {
660
-					$value = strip_tags( $table->$method( $user ) );
655
+				if ('name' == $column) {
656
+					$value = esc_html($user->display_name);
657
+				} else if ('email' == $column) {
658
+					$value = sanitize_email($user->user_email);
659
+				} else if (is_callable(array($table, $method))) {
660
+					$value = strip_tags($table->$method($user));
661 661
 				}
662 662
 
663
-				if ( empty( $value ) ) {
664
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
663
+				if (empty($value)) {
664
+					$value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));
665 665
 				}
666 666
 
667 667
 				$row[] = $value;
668 668
 
669 669
 			}
670 670
 
671
-			fputcsv( $output, $row );
671
+			fputcsv($output, $row);
672 672
 		}
673 673
 
674
-		fclose( $output );
674
+		fclose($output);
675 675
 		exit;
676 676
 
677 677
 	}
@@ -681,29 +681,29 @@  discard block
 block discarded – undo
681 681
 	 *
682 682
 	 * @param array $data
683 683
      */
684
-    public function admin_install_plugin( $data ) {
684
+    public function admin_install_plugin($data) {
685 685
 
686
-		if ( ! empty( $data['plugins'] ) ) {
686
+		if (!empty($data['plugins'])) {
687 687
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
688 688
 			wp_cache_flush();
689 689
 
690
-			foreach ( $data['plugins'] as $slug => $file ) {
691
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
692
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
693
-				$installed  = $upgrader->install( $plugin_zip );
690
+			foreach ($data['plugins'] as $slug => $file) {
691
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
692
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
693
+				$installed  = $upgrader->install($plugin_zip);
694 694
 
695
-				if ( ! is_wp_error( $installed ) && $installed ) {
696
-					activate_plugin( $file, '', false, true );
695
+				if (!is_wp_error($installed) && $installed) {
696
+					activate_plugin($file, '', false, true);
697 697
 				} else {
698
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
698
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
699 699
 				}
700 700
 
701 701
 			}
702 702
 
703 703
 		}
704 704
 
705
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
706
-		wp_safe_redirect( $redirect );
705
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
706
+		wp_safe_redirect($redirect);
707 707
 		exit;
708 708
 
709 709
 	}
@@ -713,42 +713,42 @@  discard block
 block discarded – undo
713 713
 	 *
714 714
 	 * @param array $data
715 715
      */
716
-    public function admin_connect_gateway( $data ) {
716
+    public function admin_connect_gateway($data) {
717 717
 
718
-		if ( ! empty( $data['plugin'] ) ) {
718
+		if (!empty($data['plugin'])) {
719 719
 
720
-			$gateway     = sanitize_key( $data['plugin'] );
721
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
720
+			$gateway     = sanitize_key($data['plugin']);
721
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
722 722
 
723
-			if ( ! empty( $connect_url ) ) {
724
-				wp_redirect( $connect_url );
723
+			if (!empty($connect_url)) {
724
+				wp_redirect($connect_url);
725 725
 				exit;
726 726
 			}
727 727
 
728
-			if ( 'stripe' == $data['plugin'] ) {
728
+			if ('stripe' == $data['plugin']) {
729 729
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
730 730
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
731 731
 				wp_cache_flush();
732 732
 
733
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
734
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
735
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
736
-					$upgrader->install( $plugin_zip );
733
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
734
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
735
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
736
+					$upgrader->install($plugin_zip);
737 737
 				}
738 738
 
739
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
739
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
740 740
 			}
741 741
 
742
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
743
-			if ( ! empty( $connect_url ) ) {
744
-				wp_redirect( $connect_url );
742
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
743
+			if (!empty($connect_url)) {
744
+				wp_redirect($connect_url);
745 745
 				exit;
746 746
 			}
747 747
 
748 748
 		}
749 749
 
750
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
751
-		wp_safe_redirect( $redirect );
750
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
751
+		wp_safe_redirect($redirect);
752 752
 		exit;
753 753
 
754 754
 	}
@@ -762,36 +762,36 @@  discard block
 block discarded – undo
762 762
 
763 763
 		// Fetch all invoices that have discount codes.
764 764
 		$table    = $wpdb->prefix . 'getpaid_invoices';
765
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
765
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
766 766
 
767
-		foreach ( $invoices as $invoice ) {
767
+		foreach ($invoices as $invoice) {
768 768
 
769
-			$invoice = new WPInv_Invoice( $invoice );
769
+			$invoice = new WPInv_Invoice($invoice);
770 770
 
771
-			if ( ! $invoice->exists() ) {
771
+			if (!$invoice->exists()) {
772 772
 				continue;
773 773
 			}
774 774
 
775 775
 			// Abort if the discount does not exist or does not apply here.
776
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
777
-			if ( ! $discount->exists() ) {
776
+			$discount = new WPInv_Discount($invoice->get_discount_code());
777
+			if (!$discount->exists()) {
778 778
 				continue;
779 779
 			}
780 780
 
781
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
781
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
782 782
 			$invoice->recalculate_total();
783 783
 
784
-			if ( $invoice->get_total_discount() > 0 ) {
784
+			if ($invoice->get_total_discount() > 0) {
785 785
 				$invoice->save();
786 786
 			}
787 787
 
788 788
 		}
789 789
 
790 790
 		// Show an admin message.
791
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
791
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
792 792
 
793 793
 		// Redirect the admin.
794
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
794
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
795 795
 		exit;
796 796
 
797 797
 	}
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
      * @return array
804 804
 	 */
805 805
 	public function get_notices() {
806
-		$notices = get_option( 'wpinv_admin_notices' );
807
-        return is_array( $notices ) ? $notices : array();
806
+		$notices = get_option('wpinv_admin_notices');
807
+        return is_array($notices) ? $notices : array();
808 808
 	}
809 809
 
810 810
 	/**
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
      * @return array
815 815
 	 */
816 816
 	public function has_notices() {
817
-		return count( $this->get_notices() ) > 0;
817
+		return count($this->get_notices()) > 0;
818 818
 	}
819 819
 
820 820
 	/**
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 	 * @since       1.0.19
825 825
 	 */
826 826
 	public function clear_notices() {
827
-		delete_option( 'wpinv_admin_notices' );
827
+		delete_option('wpinv_admin_notices');
828 828
 	}
829 829
 
830 830
 	/**
@@ -833,16 +833,16 @@  discard block
 block discarded – undo
833 833
 	 * @access      public
834 834
 	 * @since       1.0.19
835 835
 	 */
836
-	public function save_notice( $type, $message ) {
836
+	public function save_notice($type, $message) {
837 837
 		$notices = $this->get_notices();
838 838
 
839
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
840
-			$notices[ $type ] = array();
839
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
840
+			$notices[$type] = array();
841 841
 		}
842 842
 
843
-		$notices[ $type ][] = $message;
843
+		$notices[$type][] = $message;
844 844
 
845
-		update_option( 'wpinv_admin_notices', $notices );
845
+		update_option('wpinv_admin_notices', $notices);
846 846
 	}
847 847
 
848 848
 	/**
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 	 * @access      public
853 853
 	 * @since       1.0.19
854 854
 	 */
855
-	public function show_success( $msg ) {
856
-		$this->save_notice( 'success', $msg );
855
+	public function show_success($msg) {
856
+		$this->save_notice('success', $msg);
857 857
 	}
858 858
 
859 859
 	/**
@@ -863,8 +863,8 @@  discard block
 block discarded – undo
863 863
 	 * @param       string $msg The message to qeue.
864 864
 	 * @since       1.0.19
865 865
 	 */
866
-	public function show_error( $msg ) {
867
-		$this->save_notice( 'error', $msg );
866
+	public function show_error($msg) {
867
+		$this->save_notice('error', $msg);
868 868
 	}
869 869
 
870 870
 	/**
@@ -874,8 +874,8 @@  discard block
 block discarded – undo
874 874
 	 * @param       string $msg The message to qeue.
875 875
 	 * @since       1.0.19
876 876
 	 */
877
-	public function show_warning( $msg ) {
878
-		$this->save_notice( 'warning', $msg );
877
+	public function show_warning($msg) {
878
+		$this->save_notice('warning', $msg);
879 879
 	}
880 880
 
881 881
 	/**
@@ -885,8 +885,8 @@  discard block
 block discarded – undo
885 885
 	 * @param       string $msg The message to qeue.
886 886
 	 * @since       1.0.19
887 887
 	 */
888
-	public function show_info( $msg ) {
889
-		$this->save_notice( 'info', $msg );
888
+	public function show_info($msg) {
889
+		$this->save_notice('info', $msg);
890 890
 	}
891 891
 
892 892
 	/**
@@ -900,30 +900,30 @@  discard block
 block discarded – undo
900 900
         $notices = $this->get_notices();
901 901
         $this->clear_notices();
902 902
 
903
-		foreach ( $notices as $type => $messages ) {
903
+		foreach ($notices as $type => $messages) {
904 904
 
905
-			if ( ! is_array( $messages ) ) {
905
+			if (!is_array($messages)) {
906 906
 				continue;
907 907
 			}
908 908
 
909
-            $type  = esc_attr( $type );
910
-			foreach ( $messages as $message ) {
911
-                $message = wp_kses_post( $message );
909
+            $type = esc_attr($type);
910
+			foreach ($messages as $message) {
911
+                $message = wp_kses_post($message);
912 912
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
913 913
             }
914 914
 
915 915
         }
916 916
 
917
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
917
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
918 918
 
919
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
920
-				$url     = wp_nonce_url(
921
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
919
+			if (!is_numeric(wpinv_get_option($page, false))) {
920
+				$url = wp_nonce_url(
921
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
922 922
 					'getpaid-nonce',
923 923
 					'getpaid-nonce'
924 924
 				);
925
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
926
-				$message2 = __( 'Generate Pages', 'invoicing' );
925
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
926
+				$message2 = __('Generate Pages', 'invoicing');
927 927
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
928 928
 				break;
929 929
 			}
Please login to merge, or discard this patch.
includes/admin/views/wizard-introduction.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -4,78 +4,78 @@  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
 
11 11
 <div class="card shadow-sm my-5">
12 12
 
13 13
     <h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1">
14
-        <?php esc_html_e( 'Welcome to the GetPaid Setup Wizard!', 'invoicing' ); ?>
14
+        <?php esc_html_e('Welcome to the GetPaid Setup Wizard!', 'invoicing'); ?>
15 15
     </h1>
16 16
 
17 17
     <div class="card-body text-muted ">
18
-        <p><?php _e( 'Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing' ); ?></p>
18
+        <p><?php _e('Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing'); ?></p>
19 19
         <hr class="mt-4 pt-3 pb-0" />
20
-        <p class="small"><?php _e( 'This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes</b>.', 'invoicing' ); ?></p>
20
+        <p class="small"><?php _e('This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes</b>.', 'invoicing'); ?></p>
21 21
     </div>
22 22
 
23 23
     <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0">
24 24
         <a
25
-            href="<?php echo esc_url( $next_url ); ?>"
26
-            class="btn btn-primary button-next"><?php esc_html_e( "Let's go!", 'invoicing' ); ?></a>
25
+            href="<?php echo esc_url($next_url); ?>"
26
+            class="btn btn-primary button-next"><?php esc_html_e("Let's go!", 'invoicing'); ?></a>
27 27
         <a
28
-            href="<?php echo esc_url( admin_url() ); ?>"
29
-            class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
28
+            href="<?php echo esc_url(admin_url()); ?>"
29
+            class="btn btn-link d-block mt-2 "><?php esc_html_e('Not right now', 'invoicing'); ?></a>
30 30
     </div>
31 31
 </div>
32 32
 
33 33
 <div class="card shadow-sm my-5 overflow-hidden">
34 34
     <h1 class="h4 card-header bg-white border-bottom-0  pt-4 pb-1">
35
-        <?php esc_html_e( 'GetPaid Features & Addons!', 'invoicing' ); ?>
35
+        <?php esc_html_e('GetPaid Features & Addons!', 'invoicing'); ?>
36 36
     </h1>
37 37
 
38 38
     <div class="card-body text-muted overflow-hidden">
39
-		<p><?php _e( 'Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing' ); ?></p>
39
+		<p><?php _e('Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing'); ?></p>
40 40
 		<hr>
41 41
 
42 42
 		<div class="row row-cols-2 text-left">
43 43
 			<div class="col mt-3">
44 44
 				<div class="media">
45
-                    <img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/buy.svg' );?>" class="mr-3" alt="...">
45
+                    <img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/buy.svg'); ?>" class="mr-3" alt="...">
46 46
                     <div class="media-body">
47
-                        <h6 class="mt-0 font-weight-bold"><?php _e( 'GetPaid via Buy Now Buttons', 'invoicing' );?></h6>
48
-                        <small><?php _e( 'Sell via buy now buttons anywhere on your site', 'invoicing' );?></small>
47
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Buy Now Buttons', 'invoicing'); ?></h6>
48
+                        <small><?php _e('Sell via buy now buttons anywhere on your site', 'invoicing'); ?></small>
49 49
                     </div>
50 50
                 </div>
51 51
 			</div>
52 52
 
53 53
             <div class="col mt-3">
54 54
                 <div class="media">
55
-                    <img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/report.svg' );?>" class="mr-3" alt="...">
55
+                    <img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/report.svg'); ?>" class="mr-3" alt="...">
56 56
                         <div class="media-body">
57
-                        <h6 class="mt-0 font-weight-bold"><?php _e( 'GetPaid via payment form', 'invoicing' );?></h6>
58
-                        <small><?php _e( 'Payment forms are conversion-optimized checkout forms', 'invoicing' );?></small>
57
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via payment form', 'invoicing'); ?></h6>
58
+                        <small><?php _e('Payment forms are conversion-optimized checkout forms', 'invoicing'); ?></small>
59 59
                     </div>
60 60
                 </div>
61 61
 		    </div>
62 62
 
63 63
             <div class="col mt-3">
64 64
                 <div class="media">
65
-                    <img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/invoices.svg' );?>" class="mr-3" alt="...">
65
+                    <img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/invoices.svg'); ?>" class="mr-3" alt="...">
66 66
                     <div class="media-body">
67
-                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice','invoicing');?></h6>
68
-                        <small><?php _e('Create and send invoices for just about anything from the WordPress dashboard','invoicing');?></small>
67
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice', 'invoicing'); ?></h6>
68
+                        <small><?php _e('Create and send invoices for just about anything from the WordPress dashboard', 'invoicing'); ?></small>
69 69
                     </div>
70 70
                 </div>
71 71
 		    </div>
72 72
 
73 73
             <div class="col mt-3">
74 74
                 <div class="media">
75
-                    <img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/payment.svg' );?>" class="mr-3" alt="...">
75
+                    <img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/payment.svg'); ?>" class="mr-3" alt="...">
76 76
                     <div class="media-body">
77
-                        <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways','invoicing');?></h6>
78
-                        <small><?php _e('On average our gateways are over 66% cheaper than our competition','invoicing');?></small>
77
+                        <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways', 'invoicing'); ?></h6>
78
+                        <small><?php _e('On average our gateways are over 66% cheaper than our competition', 'invoicing'); ?></small>
79 79
                     </div>
80 80
                 </div>
81 81
 		    </div>
@@ -86,51 +86,51 @@  discard block
 block discarded – undo
86 86
 	<div class="mt-5">
87 87
 		<a
88 88
             href="https://wpgetpaid.com/features-list/"
89
-			class="btn btn-primary"><?php esc_html_e( 'View All Features!', 'invoicing' ); ?></a>
89
+			class="btn btn-primary"><?php esc_html_e('View All Features!', 'invoicing'); ?></a>
90 90
 	</div>
91 91
 
92 92
 	<div class="mt-5 mx-n4 py-4" style="background:#eafaf6;">
93
-		<h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e( 'More with Membership!' , 'invoicing' );?></h4>
93
+		<h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e('More with Membership!', 'invoicing'); ?></h4>
94 94
 		<div class="row row-cols-2 text-left px-5">
95 95
 
96 96
 			<div class="col">
97 97
 				<ul class="list-unstyled">
98
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'PDF Invoices' , 'invoicing' );?></li>
99
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Gravity Forms' , 'invoicing' );?></li>
100
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Contact form 7' , 'invoicing' );?></li>
101
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'AffiliateWP Integration' , 'invoicing' );?></li>
98
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('PDF Invoices', 'invoicing'); ?></li>
99
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Gravity Forms', 'invoicing'); ?></li>
100
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Contact form 7', 'invoicing'); ?></li>
101
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('AffiliateWP Integration', 'invoicing'); ?></li>
102 102
 				</ul>
103 103
 			</div>
104 104
 
105 105
 			<div class="col">
106 106
 				<ul class="list-unstyled">
107
-			    	<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Ninja forms' , 'invoicing' );?></li>
108
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Digital Downloads' , 'invoicing' );?></li>
109
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Wallet' , 'invoicing' );?></li>
107
+			    	<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Ninja forms', 'invoicing'); ?></li>
108
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Digital Downloads', 'invoicing'); ?></li>
109
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Wallet', 'invoicing'); ?></li>
110 110
 				</ul>
111 111
 			</div>
112 112
 		</div>
113 113
 
114
-		<h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From','invoicing');?></h5>
115
-		<h1 class="mt-0 font-weight-bold text-dark mb-4 display-3"><?php esc_html_e( '$49', 'invoicing' ); ?></h1>
114
+		<h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From', 'invoicing'); ?></h5>
115
+		<h1 class="mt-0 font-weight-bold text-dark mb-4 display-3"><?php esc_html_e('$49', 'invoicing'); ?></h1>
116 116
 
117 117
 		<div class="mt-2">
118 118
 			<a
119 119
                 href="https://wpgetpaid.com/downloads/membership/"
120
-				class="btn btn-primary"><?php esc_html_e( 'Buy Membership Now!', 'invoicing' ); ?></a>
120
+				class="btn btn-primary"><?php esc_html_e('Buy Membership Now!', 'invoicing'); ?></a>
121 121
 		</div>
122 122
 
123 123
 	</div>
124 124
 
125 125
     <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0">
126 126
         <a
127
-            href="<?php echo esc_url( $next_url ); ?>"
128
-            class="btn btn-outline-primary button-next"><?php esc_html_e( 'Launch the Setup Wizard!', 'invoicing' ); ?></a>
127
+            href="<?php echo esc_url($next_url); ?>"
128
+            class="btn btn-outline-primary button-next"><?php esc_html_e('Launch the Setup Wizard!', 'invoicing'); ?></a>
129 129
         <a
130 130
             href="https://docs.wpgetpaid.com/"
131
-            class="btn btn-outline-primary ml-4"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a>
131
+            class="btn btn-outline-primary ml-4"><?php esc_html_e('Documentation', 'invoicing'); ?></a>
132 132
         <a
133
-            href="<?php echo esc_url( admin_url() ); ?>"
134
-            class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
133
+            href="<?php echo esc_url(admin_url()); ?>"
134
+            class="btn btn-link d-block mt-2 "><?php esc_html_e('Not right now', 'invoicing'); ?></a>
135 135
     </div>
136 136
 </div>
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rates-edit.php 1 patch
Spacing   +20 added lines, -20 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
 $tax_rates  = GetPaid_Tax::get_all_tax_rates();
10 10
 $dummy_rate = array(
@@ -13,11 +13,11 @@  discard block
 block discarded – undo
13 13
     'global'       => true,
14 14
     'rate'         => wpinv_get_default_tax_rate(),
15 15
     'reduced_rate' => 5,
16
-    'name'         => __( 'VAT', 'invoicing' ),
16
+    'name'         => __('VAT', 'invoicing'),
17 17
 );
18 18
 
19 19
 $reset_url = wp_nonce_url(
20
-    add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ),
20
+    add_query_arg('getpaid-admin-action', 'reset_tax_rates'),
21 21
     'getpaid-nonce',
22 22
     'getpaid-nonce'
23 23
 );
@@ -25,34 +25,34 @@  discard block
 block discarded – undo
25 25
 ?>
26 26
 <div class="table-responsive">
27 27
     <table id="wpinv_tax_rates" class="widefat fixed table">
28
-        <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption>
28
+        <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption>
29 29
 
30 30
         <thead>
31 31
             <tr class="table-light">
32 32
 
33 33
                 <th scope="col" class="border-bottom border-top">
34
-                    <?php _e( 'Country', 'invoicing' ); ?>
35
-                    <?php echo getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static' ); ?>
34
+                    <?php _e('Country', 'invoicing'); ?>
35
+                    <?php echo getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static'); ?>
36 36
                 </th>
37 37
 
38 38
                 <th scope="col" class="border-bottom border-top">
39
-                    <?php _e( 'State', 'invoicing' ); ?>
40
-                    <?php echo getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static' ); ?>
39
+                    <?php _e('State', 'invoicing'); ?>
40
+                    <?php echo getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static'); ?>
41 41
                 </th>
42 42
 
43 43
                 <th scope="col" class="border-bottom border-top">
44
-                    <?php _e( 'Standard Rate %', 'invoicing' ); ?>
45
-                    <?php echo getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static' ); ?>
44
+                    <?php _e('Standard Rate %', 'invoicing'); ?>
45
+                    <?php echo getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static'); ?>
46 46
                 </th>
47 47
 
48 48
                 <th scope="col" class="border-bottom border-top">
49
-                    <?php _e( 'Reduced Rate %', 'invoicing' ); ?>
50
-                    <?php echo getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static' ); ?>
49
+                    <?php _e('Reduced Rate %', 'invoicing'); ?>
50
+                    <?php echo getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static'); ?>
51 51
                 </th>
52 52
 
53 53
                 <th scope="col" class="border-bottom border-top">
54
-                    <?php _e( 'Tax Name', 'invoicing' ); ?>
55
-                    <?php echo getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static' ); ?>
54
+                    <?php _e('Tax Name', 'invoicing'); ?>
55
+                    <?php echo getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static'); ?>
56 56
                 </th>
57 57
 
58 58
                 <th scope="col" class="border-bottom border-top" style="width:32px">&nbsp;</th>
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
         </thead>
62 62
 
63 63
         <tbody>
64
-            <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?>
64
+            <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?>
65 65
         </tbody>
66 66
 
67 67
         <tfoot>
68 68
             <tr class="table-light">
69 69
                 <td colspan="6" class="border-top">
70 70
 
71
-                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>">
72
-                        <span><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span>
71
+                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>">
72
+                        <span><?php _e('Add Tax Rate', 'invoicing'); ?></span>
73 73
                     </button>
74 74
 
75
-                    <a href="<?php echo esc_url( $reset_url ); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>">
76
-                        <span><?php _e( 'Reset Tax Rates', 'invoicing' ); ?></span>
75
+                    <a href="<?php echo esc_url($reset_url); ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>">
76
+                        <span><?php _e('Reset Tax Rates', 'invoicing'); ?></span>
77 77
                     </a>
78 78
                 </td>
79 79
             </tr>
@@ -82,6 +82,6 @@  discard block
 block discarded – undo
82 82
 </div>
83 83
 
84 84
 <script type="text/html" id="tmpl-wpinv-tax-rate-row">
85
-    <?php echo wpinv_tax_rate_callback( $dummy_rate, 0, false ); ?>
85
+    <?php echo wpinv_tax_rate_callback($dummy_rate, 0, false); ?>
86 86
 </script>
87 87
 
Please login to merge, or discard this patch.
includes/admin/register-settings.php 2 patches
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
     $name       = isset( $option['name'] ) ? $option['name'] : '';
196 196
     $cb         = "wpinv_{$option['type']}_callback";
197 197
     $section    = "wpinv_settings_{$tab}_$section";
198
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
198
+    $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
199 199
 
200
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
201
-		$tip   = wpinv_clean( $option['desc'] );
202
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
203
-		unset( $option['desc'] );
204
-	}
200
+    if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
201
+        $tip   = wpinv_clean( $option['desc'] );
202
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
203
+        unset( $option['desc'] );
204
+    }
205 205
 
206 206
     // Loop through all tabs.
207 207
     add_settings_field(
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
229 229
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
230 230
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
231
-			'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
232
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
233
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
231
+            'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
232
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
233
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
234 234
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
235 235
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
236 236
         )
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
  * @return array
245 245
  */
246 246
 function wpinv_get_registered_settings() {
247
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
247
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
248 248
 }
249 249
 
250 250
 /**
@@ -263,18 +263,18 @@  discard block
 block discarded – undo
263 263
  */
264 264
 function wpinv_settings_sanitize( $input = array() ) {
265 265
 
266
-	$wpinv_options = wpinv_get_options();
267
-	$raw_referrer  = wp_get_raw_referer();
266
+    $wpinv_options = wpinv_get_options();
267
+    $raw_referrer  = wp_get_raw_referer();
268 268
 
269 269
     if ( empty( $raw_referrer ) ) {
270
-		return array_merge( $wpinv_options, $input );
270
+        return array_merge( $wpinv_options, $input );
271 271
     }
272 272
 
273 273
     wp_parse_str( $raw_referrer, $referrer );
274 274
 
275
-	if ( in_array( 'gp-setup', $referrer ) ) {
276
-		return array_merge( $wpinv_options, $input );
277
-	}
275
+    if ( in_array( 'gp-setup', $referrer ) ) {
276
+        return array_merge( $wpinv_options, $input );
277
+    }
278 278
 
279 279
     $settings = wpinv_get_registered_settings();
280 280
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
         }
297 297
 
298 298
         // General filter
299
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
299
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
300 300
 
301
-		// Key specific filter.
302
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
301
+        // Key specific filter.
302
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
303 303
     }
304 304
 
305 305
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 
343 343
     foreach ( $new_rates as $rate ) {
344 344
 
345
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
346
-		$rate['name']    = sanitize_text_field( $rate['name'] );
347
-		$rate['state']   = sanitize_text_field( $rate['state'] );
348
-		$rate['country'] = sanitize_text_field( $rate['country'] );
349
-		$rate['global']  = empty( $rate['state'] );
350
-		$tax_rates[]     = $rate;
345
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
346
+        $rate['name']    = sanitize_text_field( $rate['name'] );
347
+        $rate['state']   = sanitize_text_field( $rate['state'] );
348
+        $rate['country'] = sanitize_text_field( $rate['country'] );
349
+        $rate['global']  = empty( $rate['state'] );
350
+        $tax_rates[]     = $rate;
351 351
 
352
-	}
352
+    }
353 353
 
354 354
     update_option( 'wpinv_tax_rates', $tax_rates );
355 355
 
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
     $tabs['general']  = __( 'General', 'invoicing' );
363 363
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
364 364
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
365
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
365
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
366 366
 
367
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
368
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
369
-	}
367
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
368
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
369
+    }
370 370
 
371 371
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
372 372
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
         ) ),
406 406
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
407 407
             'main'  => __( 'Tax Settings', 'invoicing' ),
408
-			'rates' => __( 'Tax Rates', 'invoicing' ),
409
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
408
+            'rates' => __( 'Tax Rates', 'invoicing' ),
409
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
410 410
         ) ),
411 411
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
412 412
             'main' => __( 'Email Settings', 'invoicing' ),
413
-		) ),
413
+        ) ),
414 414
 
415
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
415
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
416 416
 
417 417
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
418 418
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -432,48 +432,48 @@  discard block
 block discarded – undo
432 432
 }
433 433
 
434 434
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
435
-	$pages_options = array();
435
+    $pages_options = array();
436 436
 
437
-	if( $default_label !== NULL && $default_label !== false ) {
438
-		$pages_options = array( '' => $default_label ); // Blank option
439
-	}
437
+    if( $default_label !== NULL && $default_label !== false ) {
438
+        $pages_options = array( '' => $default_label ); // Blank option
439
+    }
440 440
 
441
-	$pages = get_pages();
442
-	if ( $pages ) {
443
-		foreach ( $pages as $page ) {
444
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
441
+    $pages = get_pages();
442
+    if ( $pages ) {
443
+        foreach ( $pages as $page ) {
444
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
445 445
             $pages_options[ $page->ID ] = $title;
446
-		}
447
-	}
446
+        }
447
+    }
448 448
 
449
-	return $pages_options;
449
+    return $pages_options;
450 450
 }
451 451
 
452 452
 function wpinv_header_callback( $args ) {
453
-	if ( !empty( $args['desc'] ) ) {
453
+    if ( !empty( $args['desc'] ) ) {
454 454
         echo wp_kses_post( $args['desc'] );
455 455
     }
456 456
 }
457 457
 
458 458
 function wpinv_hidden_callback( $args ) {
459 459
 
460
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
461
-	$value   = wpinv_get_option( $args['id'], $std );
460
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
461
+    $value   = wpinv_get_option( $args['id'], $std );
462 462
 
463
-	if ( isset( $args['set_value'] ) ) {
464
-		$value = $args['set_value'];
465
-	}
463
+    if ( isset( $args['set_value'] ) ) {
464
+        $value = $args['set_value'];
465
+    }
466 466
 
467
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
468
-		$args['readonly'] = true;
469
-		$name  = '';
470
-	} else {
471
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
472
-	}
467
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
468
+        $args['readonly'] = true;
469
+        $name  = '';
470
+    } else {
471
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
472
+    }
473 473
 
474
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
474
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
475 475
     
476
-	echo $html;
476
+    echo $html;
477 477
 }
478 478
 
479 479
 /**
@@ -481,12 +481,12 @@  discard block
 block discarded – undo
481 481
  */
482 482
 function wpinv_checkbox_callback( $args ) {
483 483
 
484
-	$std = isset( $args['std'] ) ? $args['std'] : '';
485
-	$std = wpinv_get_option( $args['id'], $std );
486
-	$id  = esc_attr( $args['id'] );
484
+    $std = isset( $args['std'] ) ? $args['std'] : '';
485
+    $std = wpinv_get_option( $args['id'], $std );
486
+    $id  = esc_attr( $args['id'] );
487 487
 
488
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
489
-	?>
488
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
489
+    ?>
490 490
 		<fieldset>
491 491
 			<label>
492 492
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -498,75 +498,75 @@  discard block
 block discarded – undo
498 498
 
499 499
 function wpinv_multicheck_callback( $args ) {
500 500
 
501
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
502
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
501
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
502
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
503 503
 
504
-	if ( ! empty( $args['options'] ) ) {
504
+    if ( ! empty( $args['options'] ) ) {
505 505
 
506
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
507
-		$value   = wpinv_get_option( $args['id'], $std );
506
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
507
+        $value   = wpinv_get_option( $args['id'], $std );
508 508
 
509
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
509
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
510 510
         foreach( $args['options'] as $key => $option ):
511
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
512
-			if ( in_array( $sanitize_key, $value ) ) { 
513
-				$enabled = $sanitize_key;
514
-			} else { 
515
-				$enabled = NULL; 
516
-			}
517
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
518
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
519
-		endforeach;
520
-		echo '</div>';
521
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
522
-	}
511
+            $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
512
+            if ( in_array( $sanitize_key, $value ) ) { 
513
+                $enabled = $sanitize_key;
514
+            } else { 
515
+                $enabled = NULL; 
516
+            }
517
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
518
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
519
+        endforeach;
520
+        echo '</div>';
521
+        echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
522
+    }
523 523
 }
524 524
 
525 525
 function wpinv_payment_icons_callback( $args ) {
526 526
     
527 527
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
528
-	$value   = wpinv_get_option( $args['id'], false);
528
+    $value   = wpinv_get_option( $args['id'], false);
529 529
 
530
-	if ( ! empty( $args['options'] ) ) {
531
-		foreach( $args['options'] as $key => $option ) {
530
+    if ( ! empty( $args['options'] ) ) {
531
+        foreach( $args['options'] as $key => $option ) {
532 532
             $sanitize_key = wpinv_sanitize_key( $key );
533 533
             
534
-			if( empty( $value ) ) {
535
-				$enabled = $option;
536
-			} else {
537
-				$enabled = NULL;
538
-			}
539
-
540
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
541
-
542
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
543
-
544
-				if ( wpinv_string_is_image_url( $key ) ) {
545
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
546
-				} else {
547
-					$card = strtolower( str_replace( ' ', '', $option ) );
548
-
549
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
550
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
551
-					} else {
552
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
553
-						$content_dir = WP_CONTENT_DIR;
554
-
555
-						if ( function_exists( 'wp_normalize_path' ) ) {
556
-							// Replaces backslashes with forward slashes for Windows systems
557
-							$image = wp_normalize_path( $image );
558
-							$content_dir = wp_normalize_path( $content_dir );
559
-						}
560
-
561
-						$image = str_replace( $content_dir, content_url(), $image );
562
-					}
563
-
564
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565
-				}
566
-			echo $option . '</label>';
567
-		}
568
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
569
-	}
534
+            if( empty( $value ) ) {
535
+                $enabled = $option;
536
+            } else {
537
+                $enabled = NULL;
538
+            }
539
+
540
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
541
+
542
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
543
+
544
+                if ( wpinv_string_is_image_url( $key ) ) {
545
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
546
+                } else {
547
+                    $card = strtolower( str_replace( ' ', '', $option ) );
548
+
549
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
550
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
551
+                    } else {
552
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
553
+                        $content_dir = WP_CONTENT_DIR;
554
+
555
+                        if ( function_exists( 'wp_normalize_path' ) ) {
556
+                            // Replaces backslashes with forward slashes for Windows systems
557
+                            $image = wp_normalize_path( $image );
558
+                            $content_dir = wp_normalize_path( $content_dir );
559
+                        }
560
+
561
+                        $image = str_replace( $content_dir, content_url(), $image );
562
+                    }
563
+
564
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565
+                }
566
+            echo $option . '</label>';
567
+        }
568
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
569
+    }
570 570
 }
571 571
 
572 572
 /**
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
  */
575 575
 function wpinv_radio_callback( $args ) {
576 576
 
577
-	$std = isset( $args['std'] ) ? $args['std'] : '';
578
-	$std = wpinv_get_option( $args['id'], $std );
579
-	?>
577
+    $std = isset( $args['std'] ) ? $args['std'] : '';
578
+    $std = wpinv_get_option( $args['id'], $std );
579
+    ?>
580 580
 		<fieldset>
581 581
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
582 582
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			</ul>
591 591
 		</fieldset>
592 592
 	<?php
593
-	getpaid_settings_description_callback( $args );
593
+    getpaid_settings_description_callback( $args );
594 594
 }
595 595
 
596 596
 /**
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
  */
599 599
 function getpaid_settings_description_callback( $args ) {
600 600
 
601
-	if ( ! empty( $args['desc'] ) ) {
602
-		$description = wp_kses_post( $args['desc'] );
603
-		echo "<p class='description'>$description</p>";
604
-	}
601
+    if ( ! empty( $args['desc'] ) ) {
602
+        $description = wp_kses_post( $args['desc'] );
603
+        echo "<p class='description'>$description</p>";
604
+    }
605 605
 
606 606
 }
607 607
 
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
  */
611 611
 function wpinv_gateways_callback() {
612 612
 
613
-	?>
613
+    ?>
614 614
 		</td>
615 615
 	</tr>
616 616
 	<tr class="bsui">
@@ -624,22 +624,22 @@  discard block
 block discarded – undo
624 624
 
625 625
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
626 626
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
627
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
628
-	$value   = wpinv_get_option( $args['id'], $std );
627
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
628
+    $value   = wpinv_get_option( $args['id'], $std );
629 629
 
630
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
630
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
631 631
 
632
-	foreach ( $args['options'] as $key => $option ) :
633
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
632
+    foreach ( $args['options'] as $key => $option ) :
633
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
634 634
             $selected = selected( $key, $args['selected'], false );
635 635
         } else {
636 636
             $selected = selected( $key, $value, false );
637 637
         }
638
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
639
-	endforeach;
638
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
639
+    endforeach;
640 640
 
641
-	echo '</select>';
642
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
641
+    echo '</select>';
642
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
643 643
 }
644 644
 
645 645
 /**
@@ -650,29 +650,29 @@  discard block
 block discarded – undo
650 650
  */
651 651
 function wpinv_settings_attrs_helper( $args ) {
652 652
 
653
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
654
-	$id           = esc_attr( $args['id'] );
655
-	$placeholder  = esc_attr( $args['placeholder'] );
653
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
654
+    $id           = esc_attr( $args['id'] );
655
+    $placeholder  = esc_attr( $args['placeholder'] );
656 656
 
657
-	if ( ! empty( $args['faux'] ) ) {
658
-		$args['readonly'] = true;
659
-		$name             = '';
660
-	} else {
661
-		$value  = wpinv_get_option( $args['id'], $value );
662
-		$name   = "wpinv_settings[$id]";
663
-	}
657
+    if ( ! empty( $args['faux'] ) ) {
658
+        $args['readonly'] = true;
659
+        $name             = '';
660
+    } else {
661
+        $value  = wpinv_get_option( $args['id'], $value );
662
+        $name   = "wpinv_settings[$id]";
663
+    }
664 664
 
665
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
666
-	$class    = esc_attr( $args['class'] );
667
-	$style    = esc_attr( $args['style'] );
668
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
665
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
666
+    $class    = esc_attr( $args['class'] );
667
+    $style    = esc_attr( $args['style'] );
668
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
669 669
 
670
-	$onchange = '';
670
+    $onchange = '';
671 671
     if ( ! empty( $args['onchange'] ) ) {
672 672
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
673
-	}
673
+    }
674 674
 
675
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
675
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
676 676
 }
677 677
 
678 678
 /**
@@ -680,11 +680,11 @@  discard block
 block discarded – undo
680 680
  */
681 681
 function wpinv_text_callback( $args ) {
682 682
 
683
-	$desc = wp_kses_post( $args['desc'] );
684
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
685
-	$attr = wpinv_settings_attrs_helper( $args );
683
+    $desc = wp_kses_post( $args['desc'] );
684
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
685
+    $attr = wpinv_settings_attrs_helper( $args );
686 686
 
687
-	?>
687
+    ?>
688 688
 		<label style="width: 100%;">
689 689
 			<input type="text" <?php echo $attr; ?>>
690 690
 			<?php echo $desc; ?>
@@ -698,14 +698,14 @@  discard block
 block discarded – undo
698 698
  */
699 699
 function wpinv_number_callback( $args ) {
700 700
 
701
-	$desc = wp_kses_post( $args['desc'] );
702
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
703
-	$attr = wpinv_settings_attrs_helper( $args );
704
-	$max  = intval( $args['max'] );
705
-	$min  = intval( $args['min'] );
706
-	$step = floatval( $args['step'] );
701
+    $desc = wp_kses_post( $args['desc'] );
702
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
703
+    $attr = wpinv_settings_attrs_helper( $args );
704
+    $max  = intval( $args['max'] );
705
+    $min  = intval( $args['min'] );
706
+    $step = floatval( $args['step'] );
707 707
 
708
-	?>
708
+    ?>
709 709
 		<label style="width: 100%;">
710 710
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
711 711
 			<?php echo $desc; ?>
@@ -717,36 +717,36 @@  discard block
 block discarded – undo
717 717
 function wpinv_textarea_callback( $args ) {
718 718
     
719 719
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
720
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
721
-	$value   = wpinv_get_option( $args['id'], $std );
720
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
721
+    $value   = wpinv_get_option( $args['id'], $std );
722 722
 
723 723
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
724 724
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
725 725
 
726
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
727
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
726
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
727
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
728 728
 
729
-	echo $html;
729
+    echo $html;
730 730
 }
731 731
 
732 732
 function wpinv_password_callback( $args ) {
733 733
     
734 734
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
735
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
736
-	$value   = wpinv_get_option( $args['id'], $std );
735
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
736
+    $value   = wpinv_get_option( $args['id'], $std );
737 737
 
738
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
739
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
740
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
738
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
739
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
740
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
741 741
 
742
-	echo $html;
742
+    echo $html;
743 743
 }
744 744
 
745 745
 function wpinv_missing_callback($args) {
746
-	printf(
747
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
748
-		'<strong>' . $args['id'] . '</strong>'
749
-	);
746
+    printf(
747
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
748
+        '<strong>' . $args['id'] . '</strong>'
749
+    );
750 750
 }
751 751
 
752 752
 /**
@@ -754,14 +754,14 @@  discard block
 block discarded – undo
754 754
  */
755 755
 function wpinv_select_callback( $args ) {
756 756
 
757
-	$desc   = wp_kses_post( $args['desc'] );
758
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
759
-	$attr   = wpinv_settings_attrs_helper( $args );
760
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
761
-	$value  = wpinv_get_option( $args['id'], $value );
762
-	$rand   = uniqid( 'random_id' );
757
+    $desc   = wp_kses_post( $args['desc'] );
758
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
759
+    $attr   = wpinv_settings_attrs_helper( $args );
760
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
761
+    $value  = wpinv_get_option( $args['id'], $value );
762
+    $rand   = uniqid( 'random_id' );
763 763
 
764
-	?>
764
+    ?>
765 765
 		<label style="width: 100%;">
766 766
 			<select <?php echo $attr; ?> data-allow-clear="true">
767 767
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -794,104 +794,104 @@  discard block
 block discarded – undo
794 794
 function wpinv_color_select_callback( $args ) {
795 795
     
796 796
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
797
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
798
-	$value   = wpinv_get_option( $args['id'], $std );
797
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
798
+    $value   = wpinv_get_option( $args['id'], $std );
799 799
 
800
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
800
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
801 801
 
802
-	foreach ( $args['options'] as $option => $color ) {
803
-		$selected = selected( $option, $value, false );
804
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
805
-	}
802
+    foreach ( $args['options'] as $option => $color ) {
803
+        $selected = selected( $option, $value, false );
804
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
805
+    }
806 806
 
807
-	$html .= '</select>';
808
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
807
+    $html .= '</select>';
808
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
809 809
 
810
-	echo $html;
810
+    echo $html;
811 811
 }
812 812
 
813 813
 function wpinv_rich_editor_callback( $args ) {
814
-	global $wp_version;
814
+    global $wp_version;
815 815
     
816 816
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
817 817
 
818
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
819
-	$value   = wpinv_get_option( $args['id'], $std );
818
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
819
+    $value   = wpinv_get_option( $args['id'], $std );
820 820
 	
821
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
822
-		$value = $std;
823
-	}
821
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
822
+        $value = $std;
823
+    }
824 824
 
825
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
825
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
826 826
 
827
-	$html = '<div class="getpaid-settings-editor-input">';
828
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
829
-		ob_start();
830
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
831
-		$html .= ob_get_clean();
832
-	} else {
833
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
834
-	}
827
+    $html = '<div class="getpaid-settings-editor-input">';
828
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
829
+        ob_start();
830
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
831
+        $html .= ob_get_clean();
832
+    } else {
833
+        $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
834
+    }
835 835
 
836
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
836
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
837 837
 
838
-	echo $html;
838
+    echo $html;
839 839
 }
840 840
 
841 841
 function wpinv_upload_callback( $args ) {
842 842
     
843 843
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
844 844
 
845
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
846
-	$value   = wpinv_get_option( $args['id'], $std );
845
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
846
+    $value   = wpinv_get_option( $args['id'], $std );
847 847
 
848
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
849
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
850
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
851
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
848
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
849
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
850
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
851
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
852 852
 
853
-	echo $html;
853
+    echo $html;
854 854
 }
855 855
 
856 856
 function wpinv_color_callback( $args ) {
857 857
 
858
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
859
-	$value       = wpinv_get_option( $args['id'], $std );
858
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
859
+    $value       = wpinv_get_option( $args['id'], $std );
860 860
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
861 861
 
862
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
863
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
862
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
863
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
864 864
 
865
-	echo $html;
865
+    echo $html;
866 866
 }
867 867
 
868 868
 function wpinv_country_states_callback($args) {
869 869
 
870
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
871
-	$value   = wpinv_get_option( $args['id'], $std );
870
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
871
+    $value   = wpinv_get_option( $args['id'], $std );
872 872
 
873 873
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
874 874
 
875
-	if ( isset( $args['placeholder'] ) ) {
876
-		$placeholder = $args['placeholder'];
877
-	} else {
878
-		$placeholder = '';
879
-	}
875
+    if ( isset( $args['placeholder'] ) ) {
876
+        $placeholder = $args['placeholder'];
877
+    } else {
878
+        $placeholder = '';
879
+    }
880 880
 
881
-	$states = wpinv_get_country_states();
881
+    $states = wpinv_get_country_states();
882 882
 
883
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
883
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
885 885
 
886
-	foreach ( $states as $option => $name ) {
887
-		$selected = selected( $option, $value, false );
888
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
889
-	}
886
+    foreach ( $states as $option => $name ) {
887
+        $selected = selected( $option, $value, false );
888
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
889
+    }
890 890
 
891
-	$html .= '</select>';
892
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
891
+    $html .= '</select>';
892
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
893 893
 
894
-	echo $html;
894
+    echo $html;
895 895
 }
896 896
 
897 897
 /**
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
  */
900 900
 function wpinv_tax_rates_callback() {
901 901
 	
902
-	?>
902
+    ?>
903 903
 		</td>
904 904
 	</tr>
905 905
 	<tr class="bsui">
@@ -914,17 +914,17 @@  discard block
 block discarded – undo
914 914
  * Displays a tax rate' edit row.
915 915
  */
916 916
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
917
-	ob_start();
917
+    ob_start();
918 918
 
919
-	$key                      = sanitize_key( $key );
920
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
921
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
919
+    $key                      = sanitize_key( $key );
920
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
921
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
922 922
 
923
-	if ( $echo ) {
924
-		echo ob_get_clean();
925
-	} else {
926
-		return ob_get_clean(); 
927
-	}
923
+    if ( $echo ) {
924
+        echo ob_get_clean();
925
+    } else {
926
+        return ob_get_clean(); 
927
+    }
928 928
 
929 929
 }
930 930
 
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
                 </td>
953 953
                 <td>
954 954
 					<a href="<?php
955
-						echo esc_url(
956
-							wp_nonce_url(
957
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
958
-								'getpaid-nonce',
959
-								'getpaid-nonce'
960
-							)
961
-						);
962
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
955
+                        echo esc_url(
956
+                            wp_nonce_url(
957
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
958
+                                'getpaid-nonce',
959
+                                'getpaid-nonce'
960
+                            )
961
+                        );
962
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
963 963
                 </td>
964 964
             </tr>
965 965
 			<tr>
@@ -969,14 +969,14 @@  discard block
 block discarded – undo
969 969
                 </td>
970 970
                 <td>
971 971
 					<a href="<?php
972
-						echo esc_url(
973
-							wp_nonce_url(
974
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
975
-								'getpaid-nonce',
976
-								'getpaid-nonce'
977
-							)
978
-						);
979
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
972
+                        echo esc_url(
973
+                            wp_nonce_url(
974
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
975
+                                'getpaid-nonce',
976
+                                'getpaid-nonce'
977
+                            )
978
+                        );
979
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
980 980
                 </td>
981 981
             </tr>
982 982
 			<tr>
@@ -986,14 +986,14 @@  discard block
 block discarded – undo
986 986
                 </td>
987 987
                 <td>
988 988
 					<a href="<?php
989
-						echo esc_url(
990
-							wp_nonce_url(
991
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
992
-								'getpaid-nonce',
993
-								'getpaid-nonce'
994
-							)
995
-						);
996
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
989
+                        echo esc_url(
990
+                            wp_nonce_url(
991
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
992
+                                'getpaid-nonce',
993
+                                'getpaid-nonce'
994
+                            )
995
+                        );
996
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
997 997
                 </td>
998 998
             </tr>
999 999
 
@@ -1004,14 +1004,14 @@  discard block
 block discarded – undo
1004 1004
                 </td>
1005 1005
                 <td>
1006 1006
 					<a href="<?php
1007
-						echo esc_url(
1008
-							wp_nonce_url(
1009
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1010
-								'getpaid-nonce',
1011
-								'getpaid-nonce'
1012
-							)
1013
-						);
1014
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1007
+                        echo esc_url(
1008
+                            wp_nonce_url(
1009
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1010
+                                'getpaid-nonce',
1011
+                                'getpaid-nonce'
1012
+                            )
1013
+                        );
1014
+                    ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1015 1015
                 </td>
1016 1016
             </tr>
1017 1017
 
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
                 </td>
1023 1023
                 <td>
1024 1024
 					<a href="<?php
1025
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1026
-					?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a>
1025
+                        echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1026
+                    ?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a>
1027 1027
                 </td>
1028 1028
             </tr>
1029 1029
 
@@ -1037,19 +1037,19 @@  discard block
 block discarded – undo
1037 1037
 
1038 1038
 
1039 1039
 function wpinv_descriptive_text_callback( $args ) {
1040
-	echo wp_kses_post( $args['desc'] );
1040
+    echo wp_kses_post( $args['desc'] );
1041 1041
 }
1042 1042
 
1043 1043
 function wpinv_raw_html_callback( $args ) {
1044
-	echo $args['desc'];
1044
+    echo $args['desc'];
1045 1045
 }
1046 1046
 
1047 1047
 function wpinv_hook_callback( $args ) {
1048
-	do_action( 'wpinv_' . $args['id'], $args );
1048
+    do_action( 'wpinv_' . $args['id'], $args );
1049 1049
 }
1050 1050
 
1051 1051
 function wpinv_set_settings_cap() {
1052
-	return wpinv_get_capability();
1052
+    return wpinv_get_capability();
1053 1053
 }
1054 1054
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1055 1055
 
@@ -1073,15 +1073,15 @@  discard block
 block discarded – undo
1073 1073
  */
1074 1074
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1075 1075
 
1076
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1077
-	$link = sprintf(
1078
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1079
-		$url,
1080
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1081
-	);
1076
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1077
+    $link = sprintf(
1078
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1079
+        $url,
1080
+        esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1081
+    );
1082 1082
 
1083
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1083
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1084 1084
 
1085
-	return "$description $link";
1085
+    return "$description $link";
1086 1086
 
1087 1087
 }
Please login to merge, or discard this patch.
Spacing   +375 added lines, -375 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
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( empty( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (empty($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,49 +190,49 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name       = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name       = isset($option['name']) ? $option['name'] : '';
196 196
     $cb         = "wpinv_{$option['type']}_callback";
197 197
     $section    = "wpinv_settings_{$tab}_$section";
198
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
198
+	$is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page'];
199 199
 
200
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
201
-		$tip   = wpinv_clean( $option['desc'] );
200
+	if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) {
201
+		$tip   = wpinv_clean($option['desc']);
202 202
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
203
-		unset( $option['desc'] );
203
+		unset($option['desc']);
204 204
 	}
205 205
 
206 206
     // Loop through all tabs.
207 207
     add_settings_field(
208 208
         'wpinv_settings[' . $option['id'] . ']',
209 209
         $name,
210
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
210
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
211 211
         $section,
212 212
         $section,
213 213
         array(
214 214
             'section'     => $section,
215
-            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
216
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
215
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
216
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
217 217
             'name'        => $name,
218
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
219
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
220
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
221
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
222
-            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
223
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
224
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
225
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
226
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
227
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
228
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
229
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
230
-            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
231
-			'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
232
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
233
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
234
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
235
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
218
+            'size'        => isset($option['size']) ? $option['size'] : null,
219
+            'options'     => isset($option['options']) ? $option['options'] : '',
220
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
221
+            'std'         => isset($option['std']) ? $option['std'] : '',
222
+            'min'         => isset($option['min']) ? $option['min'] : 0,
223
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
224
+            'step'        => isset($option['step']) ? $option['step'] : 1,
225
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
226
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
227
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
228
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
229
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
230
+            'custom'      => isset($option['custom']) ? $option['custom'] : '',
231
+			'default_content' => isset($option['default_content']) ? $option['default_content'] : '',
232
+			'class'       => isset($option['class']) ? $option['class'] : '',
233
+			'style'       => isset($option['style']) ? $option['style'] : '',
234
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
235
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
236 236
         )
237 237
     );
238 238
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
  * @return array
245 245
  */
246 246
 function wpinv_get_registered_settings() {
247
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
247
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
248 248
 }
249 249
 
250 250
 /**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
  * @return array
254 254
  */
255 255
 function getpaid_get_integration_settings() {
256
-    return apply_filters( 'getpaid_integration_settings', array() );
256
+    return apply_filters('getpaid_integration_settings', array());
257 257
 }
258 258
 
259 259
 /**
@@ -261,126 +261,126 @@  discard block
 block discarded – undo
261 261
  * 
262 262
  * @return array
263 263
  */
264
-function wpinv_settings_sanitize( $input = array() ) {
264
+function wpinv_settings_sanitize($input = array()) {
265 265
 
266 266
 	$wpinv_options = wpinv_get_options();
267 267
 	$raw_referrer  = wp_get_raw_referer();
268 268
 
269
-    if ( empty( $raw_referrer ) ) {
270
-		return array_merge( $wpinv_options, $input );
269
+    if (empty($raw_referrer)) {
270
+		return array_merge($wpinv_options, $input);
271 271
     }
272 272
 
273
-    wp_parse_str( $raw_referrer, $referrer );
273
+    wp_parse_str($raw_referrer, $referrer);
274 274
 
275
-	if ( in_array( 'gp-setup', $referrer ) ) {
276
-		return array_merge( $wpinv_options, $input );
275
+	if (in_array('gp-setup', $referrer)) {
276
+		return array_merge($wpinv_options, $input);
277 277
 	}
278 278
 
279 279
     $settings = wpinv_get_registered_settings();
280
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
281
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
280
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
281
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
282 282
 
283 283
     $input = $input ? $input : array();
284
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
285
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
284
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
285
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
286 286
 
287 287
     // Loop through each setting being saved and pass it through a sanitization filter
288
-    foreach ( $input as $key => $value ) {
288
+    foreach ($input as $key => $value) {
289 289
 
290 290
         // Get the setting type (checkbox, select, etc)
291
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
291
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
292 292
 
293
-        if ( $type ) {
293
+        if ($type) {
294 294
             // Field type specific filter
295
-            $input[$key] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key );
295
+            $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key);
296 296
         }
297 297
 
298 298
         // General filter
299
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
299
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
300 300
 
301 301
 		// Key specific filter.
302
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
302
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
303 303
     }
304 304
 
305 305
     // Loop through the whitelist and unset any that are empty for the tab being saved
306
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
307
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
306
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
307
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
308 308
 
309
-    $found_settings   = array_merge( $main_settings, $section_settings );
309
+    $found_settings   = array_merge($main_settings, $section_settings);
310 310
 
311
-    if ( ! empty( $found_settings ) ) {
312
-        foreach ( $found_settings as $key => $value ) {
311
+    if (!empty($found_settings)) {
312
+        foreach ($found_settings as $key => $value) {
313 313
 
314 314
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
315
-            if ( is_numeric( $key ) ) {
315
+            if (is_numeric($key)) {
316 316
                 $key = $value['id'];
317 317
             }
318 318
 
319
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
320
-                unset( $wpinv_options[ $key ] );
319
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
320
+                unset($wpinv_options[$key]);
321 321
             }
322 322
         }
323 323
     }
324 324
 
325 325
     // Merge our new settings with the existing
326
-    $output = array_merge( $wpinv_options, $input );
326
+    $output = array_merge($wpinv_options, $input);
327 327
 
328
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
328
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
329 329
 
330 330
     return $output;
331 331
 }
332
-add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 );
333
-add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' );
332
+add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1);
333
+add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount');
334 334
 
335
-function wpinv_settings_sanitize_tax_rates( $input ) {
336
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
335
+function wpinv_settings_sanitize_tax_rates($input) {
336
+    if (!wpinv_current_user_can_manage_invoicing()) {
337 337
         return $input;
338 338
     }
339 339
 
340
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array();
340
+    $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array();
341 341
     $tax_rates = array();
342 342
 
343
-    foreach ( $new_rates as $rate ) {
343
+    foreach ($new_rates as $rate) {
344 344
 
345
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
346
-		$rate['name']    = sanitize_text_field( $rate['name'] );
347
-		$rate['state']   = sanitize_text_field( $rate['state'] );
348
-		$rate['country'] = sanitize_text_field( $rate['country'] );
349
-		$rate['global']  = empty( $rate['state'] );
345
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
346
+		$rate['name']    = sanitize_text_field($rate['name']);
347
+		$rate['state']   = sanitize_text_field($rate['state']);
348
+		$rate['country'] = sanitize_text_field($rate['country']);
349
+		$rate['global']  = empty($rate['state']);
350 350
 		$tax_rates[]     = $rate;
351 351
 
352 352
 	}
353 353
 
354
-    update_option( 'wpinv_tax_rates', $tax_rates );
354
+    update_option('wpinv_tax_rates', $tax_rates);
355 355
 
356 356
     return $input;
357 357
 }
358
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
358
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
359 359
 
360 360
 function wpinv_get_settings_tabs() {
361 361
     $tabs             = array();
362
-    $tabs['general']  = __( 'General', 'invoicing' );
363
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
364
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
365
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
362
+    $tabs['general']  = __('General', 'invoicing');
363
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
364
+    $tabs['taxes']    = __('Taxes', 'invoicing');
365
+	$tabs['emails'] = __('Emails', 'invoicing');
366 366
 
367
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
368
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
367
+	if (count(getpaid_get_integration_settings()) > 0) {
368
+		$tabs['integrations'] = __('Integrations', 'invoicing');
369 369
 	}
370 370
 
371
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
372
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
373
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
371
+    $tabs['privacy']  = __('Privacy', 'invoicing');
372
+    $tabs['misc']     = __('Misc', 'invoicing');
373
+    $tabs['tools']    = __('Tools', 'invoicing');
374 374
 
375
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
375
+    return apply_filters('wpinv_settings_tabs', $tabs);
376 376
 }
377 377
 
378
-function wpinv_get_settings_tab_sections( $tab = false ) {
378
+function wpinv_get_settings_tab_sections($tab = false) {
379 379
     $tabs     = false;
380 380
     $sections = wpinv_get_registered_settings_sections();
381 381
 
382
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
383
-        $tabs = $sections[ $tab ];
382
+    if ($tab && !empty($sections[$tab])) {
383
+        $tabs = $sections[$tab];
384 384
     }
385 385
 
386 386
     return $tabs;
@@ -389,89 +389,89 @@  discard block
 block discarded – undo
389 389
 function wpinv_get_registered_settings_sections() {
390 390
     static $sections = false;
391 391
 
392
-    if ( false !== $sections ) {
392
+    if (false !== $sections) {
393 393
         return $sections;
394 394
     }
395 395
 
396 396
     $sections = array(
397
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
398
-            'main' => __( 'General Settings', 'invoicing' ),
399
-            'page_section' => __( 'Page Settings', 'invoicing' ),
400
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
401
-            'labels' => __( 'Label Texts', 'invoicing' ),
402
-        ) ),
403
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
404
-            'main' => __( 'Gateway Settings', 'invoicing' ),
405
-        ) ),
406
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
407
-            'main'  => __( 'Tax Settings', 'invoicing' ),
408
-			'rates' => __( 'Tax Rates', 'invoicing' ),
409
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
410
-        ) ),
411
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
412
-            'main' => __( 'Email Settings', 'invoicing' ),
413
-		) ),
414
-
415
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
416
-
417
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
418
-            'main' => __( 'Privacy policy', 'invoicing' ),
419
-        ) ),
420
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
421
-            'main' => __( 'Miscellaneous', 'invoicing' ),
422
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
423
-        ) ),
424
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
425
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
426
-        ) ),
397
+        'general' => apply_filters('wpinv_settings_sections_general', array(
398
+            'main' => __('General Settings', 'invoicing'),
399
+            'page_section' => __('Page Settings', 'invoicing'),
400
+            'currency_section' => __('Currency Settings', 'invoicing'),
401
+            'labels' => __('Label Texts', 'invoicing'),
402
+        )),
403
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
404
+            'main' => __('Gateway Settings', 'invoicing'),
405
+        )),
406
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
407
+            'main'  => __('Tax Settings', 'invoicing'),
408
+			'rates' => __('Tax Rates', 'invoicing'),
409
+			'vat'   => __('EU VAT Settings', 'invoicing')
410
+        )),
411
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
412
+            'main' => __('Email Settings', 'invoicing'),
413
+		)),
414
+
415
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
416
+
417
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
418
+            'main' => __('Privacy policy', 'invoicing'),
419
+        )),
420
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
421
+            'main' => __('Miscellaneous', 'invoicing'),
422
+            'custom-css' => __('Custom CSS', 'invoicing'),
423
+        )),
424
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
425
+            'main' => __('Diagnostic Tools', 'invoicing'),
426
+        )),
427 427
     );
428 428
 
429
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
429
+    $sections = apply_filters('wpinv_settings_sections', $sections);
430 430
 
431 431
     return $sections;
432 432
 }
433 433
 
434
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
434
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
435 435
 	$pages_options = array();
436 436
 
437
-	if( $default_label !== NULL && $default_label !== false ) {
438
-		$pages_options = array( '' => $default_label ); // Blank option
437
+	if ($default_label !== NULL && $default_label !== false) {
438
+		$pages_options = array('' => $default_label); // Blank option
439 439
 	}
440 440
 
441 441
 	$pages = get_pages();
442
-	if ( $pages ) {
443
-		foreach ( $pages as $page ) {
442
+	if ($pages) {
443
+		foreach ($pages as $page) {
444 444
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
445
-            $pages_options[ $page->ID ] = $title;
445
+            $pages_options[$page->ID] = $title;
446 446
 		}
447 447
 	}
448 448
 
449 449
 	return $pages_options;
450 450
 }
451 451
 
452
-function wpinv_header_callback( $args ) {
453
-	if ( !empty( $args['desc'] ) ) {
454
-        echo wp_kses_post( $args['desc'] );
452
+function wpinv_header_callback($args) {
453
+	if (!empty($args['desc'])) {
454
+        echo wp_kses_post($args['desc']);
455 455
     }
456 456
 }
457 457
 
458
-function wpinv_hidden_callback( $args ) {
458
+function wpinv_hidden_callback($args) {
459 459
 
460
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
461
-	$value   = wpinv_get_option( $args['id'], $std );
460
+	$std     = isset($args['std']) ? $args['std'] : '';
461
+	$value   = wpinv_get_option($args['id'], $std);
462 462
 
463
-	if ( isset( $args['set_value'] ) ) {
463
+	if (isset($args['set_value'])) {
464 464
 		$value = $args['set_value'];
465 465
 	}
466 466
 
467
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
467
+	if (isset($args['faux']) && true === $args['faux']) {
468 468
 		$args['readonly'] = true;
469
-		$name  = '';
469
+		$name = '';
470 470
 	} else {
471
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
471
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
472 472
 	}
473 473
 
474
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
474
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
475 475
     
476 476
 	echo $html;
477 477
 }
@@ -479,59 +479,59 @@  discard block
 block discarded – undo
479 479
 /**
480 480
  * Displays a checkbox settings callback.
481 481
  */
482
-function wpinv_checkbox_callback( $args ) {
482
+function wpinv_checkbox_callback($args) {
483 483
 
484
-	$std = isset( $args['std'] ) ? $args['std'] : '';
485
-	$std = wpinv_get_option( $args['id'], $std );
486
-	$id  = esc_attr( $args['id'] );
484
+	$std = isset($args['std']) ? $args['std'] : '';
485
+	$std = wpinv_get_option($args['id'], $std);
486
+	$id  = esc_attr($args['id']);
487 487
 
488
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
488
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
489 489
 	?>
490 490
 		<fieldset>
491 491
 			<label>
492
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
493
-				<?php echo wp_kses_post( $args['desc'] ); ?>
492
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
493
+				<?php echo wp_kses_post($args['desc']); ?>
494 494
 			</label>
495 495
 		</fieldset>
496 496
 	<?php
497 497
 }
498 498
 
499
-function wpinv_multicheck_callback( $args ) {
499
+function wpinv_multicheck_callback($args) {
500 500
 
501
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
502
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
501
+	$sanitize_id = wpinv_sanitize_key($args['id']);
502
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
503 503
 
504
-	if ( ! empty( $args['options'] ) ) {
504
+	if (!empty($args['options'])) {
505 505
 
506
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
507
-		$value   = wpinv_get_option( $args['id'], $std );
506
+		$std     = isset($args['std']) ? $args['std'] : array();
507
+		$value   = wpinv_get_option($args['id'], $std);
508 508
 
509 509
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
510
-        foreach( $args['options'] as $key => $option ):
511
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
512
-			if ( in_array( $sanitize_key, $value ) ) { 
510
+        foreach ($args['options'] as $key => $option):
511
+			$sanitize_key = esc_attr(wpinv_sanitize_key($key));
512
+			if (in_array($sanitize_key, $value)) { 
513 513
 				$enabled = $sanitize_key;
514 514
 			} else { 
515 515
 				$enabled = NULL; 
516 516
 			}
517
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
518
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
517
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
518
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
519 519
 		endforeach;
520 520
 		echo '</div>';
521
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
521
+		echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
522 522
 	}
523 523
 }
524 524
 
525
-function wpinv_payment_icons_callback( $args ) {
525
+function wpinv_payment_icons_callback($args) {
526 526
     
527
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
528
-	$value   = wpinv_get_option( $args['id'], false);
527
+    $sanitize_id = wpinv_sanitize_key($args['id']);
528
+	$value = wpinv_get_option($args['id'], false);
529 529
 
530
-	if ( ! empty( $args['options'] ) ) {
531
-		foreach( $args['options'] as $key => $option ) {
532
-            $sanitize_key = wpinv_sanitize_key( $key );
530
+	if (!empty($args['options'])) {
531
+		foreach ($args['options'] as $key => $option) {
532
+            $sanitize_key = wpinv_sanitize_key($key);
533 533
             
534
-			if( empty( $value ) ) {
534
+			if (empty($value)) {
535 535
 				$enabled = $option;
536 536
 			} else {
537 537
 				$enabled = NULL;
@@ -539,67 +539,67 @@  discard block
 block discarded – undo
539 539
 
540 540
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
541 541
 
542
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
542
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
543 543
 
544
-				if ( wpinv_string_is_image_url( $key ) ) {
545
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
544
+				if (wpinv_string_is_image_url($key)) {
545
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
546 546
 				} else {
547
-					$card = strtolower( str_replace( ' ', '', $option ) );
547
+					$card = strtolower(str_replace(' ', '', $option));
548 548
 
549
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
550
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
549
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
550
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
551 551
 					} else {
552
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
552
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
553 553
 						$content_dir = WP_CONTENT_DIR;
554 554
 
555
-						if ( function_exists( 'wp_normalize_path' ) ) {
555
+						if (function_exists('wp_normalize_path')) {
556 556
 							// Replaces backslashes with forward slashes for Windows systems
557
-							$image = wp_normalize_path( $image );
558
-							$content_dir = wp_normalize_path( $content_dir );
557
+							$image = wp_normalize_path($image);
558
+							$content_dir = wp_normalize_path($content_dir);
559 559
 						}
560 560
 
561
-						$image = str_replace( $content_dir, content_url(), $image );
561
+						$image = str_replace($content_dir, content_url(), $image);
562 562
 					}
563 563
 
564
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
564
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565 565
 				}
566 566
 			echo $option . '</label>';
567 567
 		}
568
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
568
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
569 569
 	}
570 570
 }
571 571
 
572 572
 /**
573 573
  * Displays a radio settings field.
574 574
  */
575
-function wpinv_radio_callback( $args ) {
575
+function wpinv_radio_callback($args) {
576 576
 
577
-	$std = isset( $args['std'] ) ? $args['std'] : '';
578
-	$std = wpinv_get_option( $args['id'], $std );
577
+	$std = isset($args['std']) ? $args['std'] : '';
578
+	$std = wpinv_get_option($args['id'], $std);
579 579
 	?>
580 580
 		<fieldset>
581
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
582
-				<?php foreach( $args['options'] as $key => $option ) : ?>
581
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
582
+				<?php foreach ($args['options'] as $key => $option) : ?>
583 583
 					<li>
584 584
 						<label>
585
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
586
-							<?php echo wp_kses_post( $option ); ?>
585
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
586
+							<?php echo wp_kses_post($option); ?>
587 587
 						</label>
588 588
 					</li>
589 589
 				<?php endforeach; ?>
590 590
 			</ul>
591 591
 		</fieldset>
592 592
 	<?php
593
-	getpaid_settings_description_callback( $args );
593
+	getpaid_settings_description_callback($args);
594 594
 }
595 595
 
596 596
 /**
597 597
  * Displays a description if available.
598 598
  */
599
-function getpaid_settings_description_callback( $args ) {
599
+function getpaid_settings_description_callback($args) {
600 600
 
601
-	if ( ! empty( $args['desc'] ) ) {
602
-		$description = wp_kses_post( $args['desc'] );
601
+	if (!empty($args['desc'])) {
602
+		$description = wp_kses_post($args['desc']);
603 603
 		echo "<p class='description'>$description</p>";
604 604
 	}
605 605
 
@@ -615,31 +615,31 @@  discard block
 block discarded – undo
615 615
 	</tr>
616 616
 	<tr class="bsui">
617 617
     	<td colspan="2" class="p-0">
618
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
618
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
619 619
 
620 620
 	<?php
621 621
 }
622 622
 
623 623
 function wpinv_gateway_select_callback($args) {
624 624
 
625
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
626
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
627
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
628
-	$value   = wpinv_get_option( $args['id'], $std );
625
+    $sanitize_id = wpinv_sanitize_key($args['id']);
626
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
627
+	$std     = isset($args['std']) ? $args['std'] : '';
628
+	$value   = wpinv_get_option($args['id'], $std);
629 629
 
630
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
630
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
631 631
 
632
-	foreach ( $args['options'] as $key => $option ) :
633
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
634
-            $selected = selected( $key, $args['selected'], false );
632
+	foreach ($args['options'] as $key => $option) :
633
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
634
+            $selected = selected($key, $args['selected'], false);
635 635
         } else {
636
-            $selected = selected( $key, $value, false );
636
+            $selected = selected($key, $value, false);
637 637
         }
638
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
638
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
639 639
 	endforeach;
640 640
 
641 641
 	echo '</select>';
642
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
642
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
643 643
 }
644 644
 
645 645
 /**
@@ -648,28 +648,28 @@  discard block
 block discarded – undo
648 648
  * @param array $args
649 649
  * @return string
650 650
  */
651
-function wpinv_settings_attrs_helper( $args ) {
651
+function wpinv_settings_attrs_helper($args) {
652 652
 
653
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
654
-	$id           = esc_attr( $args['id'] );
655
-	$placeholder  = esc_attr( $args['placeholder'] );
653
+	$value        = isset($args['std']) ? $args['std'] : '';
654
+	$id           = esc_attr($args['id']);
655
+	$placeholder  = esc_attr($args['placeholder']);
656 656
 
657
-	if ( ! empty( $args['faux'] ) ) {
657
+	if (!empty($args['faux'])) {
658 658
 		$args['readonly'] = true;
659 659
 		$name             = '';
660 660
 	} else {
661
-		$value  = wpinv_get_option( $args['id'], $value );
661
+		$value  = wpinv_get_option($args['id'], $value);
662 662
 		$name   = "wpinv_settings[$id]";
663 663
 	}
664 664
 
665
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
666
-	$class    = esc_attr( $args['class'] );
667
-	$style    = esc_attr( $args['style'] );
668
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
665
+	$value    = is_scalar($value) ? esc_attr($value) : '';
666
+	$class    = esc_attr($args['class']);
667
+	$style    = esc_attr($args['style']);
668
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
669 669
 
670 670
 	$onchange = '';
671
-    if ( ! empty( $args['onchange'] ) ) {
672
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
671
+    if (!empty($args['onchange'])) {
672
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
673 673
 	}
674 674
 
675 675
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -678,11 +678,11 @@  discard block
 block discarded – undo
678 678
 /**
679 679
  * Displays a text input settings callback.
680 680
  */
681
-function wpinv_text_callback( $args ) {
681
+function wpinv_text_callback($args) {
682 682
 
683
-	$desc = wp_kses_post( $args['desc'] );
684
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
685
-	$attr = wpinv_settings_attrs_helper( $args );
683
+	$desc = wp_kses_post($args['desc']);
684
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
685
+	$attr = wpinv_settings_attrs_helper($args);
686 686
 
687 687
 	?>
688 688
 		<label style="width: 100%;">
@@ -696,14 +696,14 @@  discard block
 block discarded – undo
696 696
 /**
697 697
  * Displays a number input settings callback.
698 698
  */
699
-function wpinv_number_callback( $args ) {
699
+function wpinv_number_callback($args) {
700 700
 
701
-	$desc = wp_kses_post( $args['desc'] );
702
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
703
-	$attr = wpinv_settings_attrs_helper( $args );
704
-	$max  = intval( $args['max'] );
705
-	$min  = intval( $args['min'] );
706
-	$step = floatval( $args['step'] );
701
+	$desc = wp_kses_post($args['desc']);
702
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
703
+	$attr = wpinv_settings_attrs_helper($args);
704
+	$max  = intval($args['max']);
705
+	$min  = intval($args['min']);
706
+	$step = floatval($args['step']);
707 707
 
708 708
 	?>
709 709
 		<label style="width: 100%;">
@@ -714,37 +714,37 @@  discard block
 block discarded – undo
714 714
 
715 715
 }
716 716
 
717
-function wpinv_textarea_callback( $args ) {
717
+function wpinv_textarea_callback($args) {
718 718
     
719
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
720
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
721
-	$value   = wpinv_get_option( $args['id'], $std );
719
+    $sanitize_id = wpinv_sanitize_key($args['id']);
720
+	$std     = isset($args['std']) ? $args['std'] : '';
721
+	$value   = wpinv_get_option($args['id'], $std);
722 722
 
723
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
724
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
723
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
724
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
725 725
 
726
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
727
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
726
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
727
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
728 728
 
729 729
 	echo $html;
730 730
 }
731 731
 
732
-function wpinv_password_callback( $args ) {
732
+function wpinv_password_callback($args) {
733 733
     
734
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
735
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
736
-	$value   = wpinv_get_option( $args['id'], $std );
734
+    $sanitize_id = wpinv_sanitize_key($args['id']);
735
+	$std     = isset($args['std']) ? $args['std'] : '';
736
+	$value   = wpinv_get_option($args['id'], $std);
737 737
 
738
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
739
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
740
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
738
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
739
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
740
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
741 741
 
742 742
 	echo $html;
743 743
 }
744 744
 
745 745
 function wpinv_missing_callback($args) {
746 746
 	printf(
747
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
747
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
748 748
 		'<strong>' . $args['id'] . '</strong>'
749 749
 	);
750 750
 }
@@ -752,35 +752,35 @@  discard block
 block discarded – undo
752 752
 /**
753 753
  * Displays a number input settings callback.
754 754
  */
755
-function wpinv_select_callback( $args ) {
755
+function wpinv_select_callback($args) {
756 756
 
757
-	$desc   = wp_kses_post( $args['desc'] );
758
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
759
-	$attr   = wpinv_settings_attrs_helper( $args );
760
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
761
-	$value  = wpinv_get_option( $args['id'], $value );
762
-	$rand   = uniqid( 'random_id' );
757
+	$desc   = wp_kses_post($args['desc']);
758
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
759
+	$attr   = wpinv_settings_attrs_helper($args);
760
+	$value  = isset($args['std']) ? $args['std'] : '';
761
+	$value  = wpinv_get_option($args['id'], $value);
762
+	$rand   = uniqid('random_id');
763 763
 
764 764
 	?>
765 765
 		<label style="width: 100%;">
766 766
 			<select <?php echo $attr; ?> data-allow-clear="true">
767
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
768
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
769
-				<?php endforeach;?>
767
+				<?php foreach ($args['options'] as $option => $name) : ?>
768
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option>
769
+				<?php endforeach; ?>
770 770
 			</select>
771 771
 
772
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
773
-				<a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a>
772
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
773
+				<a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing') ?></a>
774 774
 			<?php endif; ?>
775 775
 
776
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
777
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ) ?></a>
776
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
777
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing') ?></a>
778 778
 				<div id='<?php echo $rand; ?>' style='display:none;'>
779 779
 					<div>
780
-						<h3><?php _e( 'Original Content', 'invoicing' ) ?></h3>
781
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea>
782
-						<h3><?php _e( 'Current Content', 'invoicing' ) ?></h3>
783
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea>
780
+						<h3><?php _e('Original Content', 'invoicing') ?></h3>
781
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea>
782
+						<h3><?php _e('Current Content', 'invoicing') ?></h3>
783
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea>
784 784
 					</div>
785 785
 				</div>
786 786
 			<?php endif; ?>
@@ -791,88 +791,88 @@  discard block
 block discarded – undo
791 791
 
792 792
 }
793 793
 
794
-function wpinv_color_select_callback( $args ) {
794
+function wpinv_color_select_callback($args) {
795 795
     
796
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
797
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
798
-	$value   = wpinv_get_option( $args['id'], $std );
796
+    $sanitize_id = wpinv_sanitize_key($args['id']);
797
+	$std     = isset($args['std']) ? $args['std'] : '';
798
+	$value   = wpinv_get_option($args['id'], $std);
799 799
 
800
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
800
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
801 801
 
802
-	foreach ( $args['options'] as $option => $color ) {
803
-		$selected = selected( $option, $value, false );
804
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
802
+	foreach ($args['options'] as $option => $color) {
803
+		$selected = selected($option, $value, false);
804
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
805 805
 	}
806 806
 
807 807
 	$html .= '</select>';
808
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
808
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
809 809
 
810 810
 	echo $html;
811 811
 }
812 812
 
813
-function wpinv_rich_editor_callback( $args ) {
813
+function wpinv_rich_editor_callback($args) {
814 814
 	global $wp_version;
815 815
     
816
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
816
+    $sanitize_id = wpinv_sanitize_key($args['id']);
817 817
 
818
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
819
-	$value   = wpinv_get_option( $args['id'], $std );
818
+	$std     = isset($args['std']) ? $args['std'] : '';
819
+	$value   = wpinv_get_option($args['id'], $std);
820 820
 	
821
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
821
+	if (!empty($args['allow_blank']) && empty($value)) {
822 822
 		$value = $std;
823 823
 	}
824 824
 
825
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
825
+	$rows = isset($args['size']) ? $args['size'] : 20;
826 826
 
827 827
 	$html = '<div class="getpaid-settings-editor-input">';
828
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
828
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
829 829
 		ob_start();
830
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
830
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
831 831
 		$html .= ob_get_clean();
832 832
 	} else {
833
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
833
+		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
834 834
 	}
835 835
 
836
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
836
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
837 837
 
838 838
 	echo $html;
839 839
 }
840 840
 
841
-function wpinv_upload_callback( $args ) {
841
+function wpinv_upload_callback($args) {
842 842
     
843
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
843
+    $sanitize_id = wpinv_sanitize_key($args['id']);
844 844
 
845
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
846
-	$value   = wpinv_get_option( $args['id'], $std );
845
+	$std     = isset($args['std']) ? $args['std'] : '';
846
+	$value   = wpinv_get_option($args['id'], $std);
847 847
 
848
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
849
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
850
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
851
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
848
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
849
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
850
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
851
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
852 852
 
853 853
 	echo $html;
854 854
 }
855 855
 
856
-function wpinv_color_callback( $args ) {
856
+function wpinv_color_callback($args) {
857 857
 
858
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
859
-	$value       = wpinv_get_option( $args['id'], $std );
860
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
858
+	$std         = isset($args['std']) ? $args['std'] : '';
859
+	$value       = wpinv_get_option($args['id'], $std);
860
+    $sanitize_id = wpinv_sanitize_key($args['id']);
861 861
 
862
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
863
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
862
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />';
863
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
864 864
 
865 865
 	echo $html;
866 866
 }
867 867
 
868 868
 function wpinv_country_states_callback($args) {
869 869
 
870
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
871
-	$value   = wpinv_get_option( $args['id'], $std );
870
+	$std     = isset($args['std']) ? $args['std'] : '';
871
+	$value   = wpinv_get_option($args['id'], $std);
872 872
 
873
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
873
+    $sanitize_id = wpinv_sanitize_key($args['id']);
874 874
 
875
-	if ( isset( $args['placeholder'] ) ) {
875
+	if (isset($args['placeholder'])) {
876 876
 		$placeholder = $args['placeholder'];
877 877
 	} else {
878 878
 		$placeholder = '';
@@ -880,16 +880,16 @@  discard block
 block discarded – undo
880 880
 
881 881
 	$states = wpinv_get_country_states();
882 882
 
883
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
883
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
885 885
 
886
-	foreach ( $states as $option => $name ) {
887
-		$selected = selected( $option, $value, false );
888
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
886
+	foreach ($states as $option => $name) {
887
+		$selected = selected($option, $value, false);
888
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
889 889
 	}
890 890
 
891 891
 	$html .= '</select>';
892
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
893 893
 
894 894
 	echo $html;
895 895
 }
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 	</tr>
905 905
 	<tr class="bsui">
906 906
     	<td colspan="2" class="p-0">
907
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
907
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
908 908
 
909 909
 	<?php
910 910
 
@@ -913,14 +913,14 @@  discard block
 block discarded – undo
913 913
 /**
914 914
  * Displays a tax rate' edit row.
915 915
  */
916
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
916
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
917 917
 	ob_start();
918 918
 
919
-	$key                      = sanitize_key( $key );
920
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
921
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
919
+	$key                      = sanitize_key($key);
920
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
921
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
922 922
 
923
-	if ( $echo ) {
923
+	if ($echo) {
924 924
 		echo ob_get_clean();
925 925
 	} else {
926 926
 		return ob_get_clean(); 
@@ -933,136 +933,136 @@  discard block
 block discarded – undo
933 933
     ob_start(); ?>
934 934
     </td><tr>
935 935
     <td colspan="2" class="wpinv_tools_tdbox">
936
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
937
-    <?php do_action( 'wpinv_tools_before' ); ?>
936
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
937
+    <?php do_action('wpinv_tools_before'); ?>
938 938
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
939 939
         <thead>
940 940
             <tr>
941
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
942
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
943
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
941
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
942
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
943
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
944 944
             </tr>
945 945
         </thead>
946 946
 
947 947
         <tbody>
948 948
 			<tr>
949
-                <td><?php _e( 'Check Pages', 'invoicing' );?></td>
949
+                <td><?php _e('Check Pages', 'invoicing'); ?></td>
950 950
                 <td>
951
-                    <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
951
+                    <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
952 952
                 </td>
953 953
                 <td>
954 954
 					<a href="<?php
955 955
 						echo esc_url(
956 956
 							wp_nonce_url(
957
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
957
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
958 958
 								'getpaid-nonce',
959 959
 								'getpaid-nonce'
960 960
 							)
961 961
 						);
962
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
962
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
963 963
                 </td>
964 964
             </tr>
965 965
 			<tr>
966
-                <td><?php _e( 'Create Database Tables', 'invoicing' );?></td>
966
+                <td><?php _e('Create Database Tables', 'invoicing'); ?></td>
967 967
                 <td>
968
-                    <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
968
+                    <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
969 969
                 </td>
970 970
                 <td>
971 971
 					<a href="<?php
972 972
 						echo esc_url(
973 973
 							wp_nonce_url(
974
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
974
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
975 975
 								'getpaid-nonce',
976 976
 								'getpaid-nonce'
977 977
 							)
978 978
 						);
979
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
979
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
980 980
                 </td>
981 981
             </tr>
982 982
 			<tr>
983
-                <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td>
983
+                <td><?php _e('Migrate old invoices', 'invoicing'); ?></td>
984 984
                 <td>
985
-                    <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
985
+                    <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
986 986
                 </td>
987 987
                 <td>
988 988
 					<a href="<?php
989 989
 						echo esc_url(
990 990
 							wp_nonce_url(
991
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
991
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
992 992
 								'getpaid-nonce',
993 993
 								'getpaid-nonce'
994 994
 							)
995 995
 						);
996
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
996
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
997 997
                 </td>
998 998
             </tr>
999 999
 
1000 1000
 			<tr>
1001
-                <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td>
1001
+                <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td>
1002 1002
                 <td>
1003
-                    <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1003
+                    <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1004 1004
                 </td>
1005 1005
                 <td>
1006 1006
 					<a href="<?php
1007 1007
 						echo esc_url(
1008 1008
 							wp_nonce_url(
1009
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1009
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1010 1010
 								'getpaid-nonce',
1011 1011
 								'getpaid-nonce'
1012 1012
 							)
1013 1013
 						);
1014
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1014
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1015 1015
                 </td>
1016 1016
             </tr>
1017 1017
 
1018 1018
 			<tr>
1019
-                <td><?php _e( 'Set-up Wizard', 'invoicing' );?></td>
1019
+                <td><?php _e('Set-up Wizard', 'invoicing'); ?></td>
1020 1020
                 <td>
1021
-                    <small><?php _e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small>
1021
+                    <small><?php _e('Launch the quick set-up wizard.', 'invoicing'); ?></small>
1022 1022
                 </td>
1023 1023
                 <td>
1024 1024
 					<a href="<?php
1025
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1026
-					?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a>
1025
+						echo esc_url(admin_url('index.php?page=gp-setup'));
1026
+					?>" class="button button-primary"><?php _e('Launch', 'invoicing'); ?></a>
1027 1027
                 </td>
1028 1028
             </tr>
1029 1029
 
1030
-			<?php do_action( 'wpinv_tools_row' ); ?>
1030
+			<?php do_action('wpinv_tools_row'); ?>
1031 1031
         </tbody>
1032 1032
     </table>
1033
-    <?php do_action( 'wpinv_tools_after' ); ?>
1033
+    <?php do_action('wpinv_tools_after'); ?>
1034 1034
     <?php
1035 1035
     echo ob_get_clean();
1036 1036
 }
1037 1037
 
1038 1038
 
1039
-function wpinv_descriptive_text_callback( $args ) {
1040
-	echo wp_kses_post( $args['desc'] );
1039
+function wpinv_descriptive_text_callback($args) {
1040
+	echo wp_kses_post($args['desc']);
1041 1041
 }
1042 1042
 
1043
-function wpinv_raw_html_callback( $args ) {
1043
+function wpinv_raw_html_callback($args) {
1044 1044
 	echo $args['desc'];
1045 1045
 }
1046 1046
 
1047
-function wpinv_hook_callback( $args ) {
1048
-	do_action( 'wpinv_' . $args['id'], $args );
1047
+function wpinv_hook_callback($args) {
1048
+	do_action('wpinv_' . $args['id'], $args);
1049 1049
 }
1050 1050
 
1051 1051
 function wpinv_set_settings_cap() {
1052 1052
 	return wpinv_get_capability();
1053 1053
 }
1054
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1054
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1055 1055
 
1056 1056
 
1057
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1058
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1059
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1057
+function wpinv_on_update_settings($old_value, $value, $option) {
1058
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1059
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1060 1060
     
1061
-    if ( $old != $new ) {
1062
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1061
+    if ($old != $new) {
1062
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1063 1063
     }
1064 1064
 }
1065
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1065
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1066 1066
 
1067 1067
 /**
1068 1068
  * Returns the merge tags help text.
@@ -1071,16 +1071,16 @@  discard block
 block discarded – undo
1071 1071
  * 
1072 1072
  * @return string
1073 1073
  */
1074
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1074
+function wpinv_get_merge_tags_help_text($subscription = false) {
1075 1075
 
1076 1076
 	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1077 1077
 	$link = sprintf(
1078 1078
 		'<strong><a href="%s" target="_blank">%s</a></strong>',
1079 1079
 		$url,
1080
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1080
+		esc_html__('View available merge tags.', 'wpinv-quotes')
1081 1081
 	);
1082 1082
 
1083
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1083
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1084 1084
 
1085 1085
 	return "$description $link";
1086 1086
 
Please login to merge, or discard this patch.
includes/admin/html-admin-page-addons.php 3 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 add_ThickBox();
10 10
 ?>
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 	<?php if ( $tabs ){ ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
19
-			}
20
-			do_action( 'wpi_addons_tabs' );
21
-			?>
17
+            foreach ( $tabs as $name => $label ) {
18
+                echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
19
+            }
20
+            do_action( 'wpi_addons_tabs' );
21
+            ?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+        if($current_tab == 'membership'){
27 27
 
28
-			?>
28
+            ?>
29 29
 
30 30
 			<div class="wpi-membership-tab-conatiner">
31 31
 				<div class="membership-content">
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 					<h2><?php _e("Have a membership key?","invoicing");?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
-						?>
39
+                        $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
+                        echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
+                        ?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51
-									$addon_obj = new WPInv_Admin_Addons();
52
-									if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
-										}
56
-									}
57
-									?>
51
+                                    $addon_obj = new WPInv_Admin_Addons();
52
+                                    if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
+                                        foreach ( $addons as $addon ) {
54
+                                            echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
+                                        }
56
+                                    }
57
+                                    ?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 									<h3><?php _e("Included Gateways:","invoicing");?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
-											}
72
-										}
73
-										?>
68
+                                        if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
+                                            foreach ( $addons as $addon ) {
70
+                                                echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
+                                            }
72
+                                        }
73
+                                        ?>
74 74
 								</ul>
75 75
 							</div>
76 76
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
-								?>
84
+                                    echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
+                                ?>
86 86
 							</div>
87 87
 							<div class="t-content">
88 88
 								<p>
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
-								?>
104
+                                    echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
+                                ?>
106 106
 							</div>
107 107
 							<div class="t-content">
108 108
 								<p>
@@ -126,21 +126,21 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
130
-			$installed_plugins = get_plugins();
129
+        }else{
130
+            $installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
-				//print_r($addons);
134
-				?>
132
+            if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
+                //print_r($addons);
134
+                ?>
135 135
 				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
136 136
                         if(965==$addon->info->id){continue;}// don't show quote add on
137
-						?><li class="wpi-product">
137
+                        ?><li class="wpi-product">
138 138
 								<div class="wpi-product-title">
139 139
 									<h3><?php
140
-										if ( ! empty( $addon->info->excerpt) ){
141
-											echo wpi_help_tip( $addon->info->excerpt );
142
-										}
143
-										echo esc_html( $addon->info->title ); ?></h3>
140
+                                        if ( ! empty( $addon->info->excerpt) ){
141
+                                            echo wpi_help_tip( $addon->info->excerpt );
142
+                                        }
143
+                                        echo esc_html( $addon->info->title ); ?></h3>
144 144
 								</div>
145 145
 
146 146
 								<span class="wpi-product-image">
@@ -148,32 +148,32 @@  discard block
 block discarded – undo
148 148
 										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
149 149
 									<?php endif;
150 150
 
151
-									if ( 'stripe-payment-gateway' == $addon->info->slug ) {
152
-										$addon->info->slug = 'getpaid-stripe-payments';
153
-										$addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154
-									}
155
-
156
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
-										echo '<a href="'.esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug)).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159
-										echo '</a>';
160
-									}elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
162
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
-										}else{
164
-											// if installed show activation link
165
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
-											}else{
168
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169
-											}
170
-										}
171
-										echo '<a href="'.esc_url($url).'" class="thickbox">';
172
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
-										echo '</a>';
174
-									}
175
-
176
-									?>
151
+                                    if ( 'stripe-payment-gateway' == $addon->info->slug ) {
152
+                                        $addon->info->slug = 'getpaid-stripe-payments';
153
+                                        $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154
+                                    }
155
+
156
+                                    if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
+                                        echo '<a href="'.esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug)).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159
+                                        echo '</a>';
160
+                                    }elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
+                                        if(defined('WP_EASY_UPDATES_ACTIVE')){
162
+                                            $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
+                                        }else{
164
+                                            // if installed show activation link
165
+                                            if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
+                                            }else{
168
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169
+                                            }
170
+                                        }
171
+                                        echo '<a href="'.esc_url($url).'" class="thickbox">';
172
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
+                                        echo '</a>';
174
+                                    }
175
+
176
+                                    ?>
177 177
 
178 178
 								</span>
179 179
 
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 								<span class="wpi-product-button">
182 182
 									<?php
183 183
                                     $addon_obj->output_button( $addon );
184
-									?>
184
+                                    ?>
185 185
 								</span>
186 186
 
187 187
 								<span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul>
188 188
 			<?php endif;
189
-		}
189
+        }
190 190
 
191
-	}
192
-	?>
191
+    }
192
+    ?>
193 193
 
194 194
 
195 195
 	<div class="clearfix" ></div>
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
209 209
 			<br>
210 210
 			<?php
211
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
212
-			?>
211
+            echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
212
+            ?>
213 213
 		</span>
214 214
 	</div>
215 215
 
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Admin View: Page - Addons
4 4
  *
5 5
  */
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 add_ThickBox();
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 <div class="wrap wpi_addons_wrap">
12 12
 	<h1><?php echo get_admin_page_title(); ?></h1>
13 13
 
14
-	<?php if ( $tabs ){ ?>
14
+	<?php if ($tabs) { ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>';
17
+			foreach ($tabs as $name => $label) {
18
+				echo '<a href="' . esc_url(admin_url('admin.php?page=wpi-addons&tab=' . $name)) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . esc_html($label) . '</a>';
19 19
 			}
20
-			do_action( 'wpi_addons_tabs' );
20
+			do_action('wpi_addons_tabs');
21 21
 			?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+		if ($current_tab == 'membership') {
27 27
 
28 28
 			?>
29 29
 
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 <!--
33 33
 				<h2>With our WPInvoicing Membership you get access to all our products!</h2>
34 34
 				<p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>-->
35
-				<?php if(defined('WP_EASY_UPDATES_ACTIVE')){?>
36
-					<h2><?php _e("Have a membership key?","invoicing");?></h2>
35
+				<?php if (defined('WP_EASY_UPDATES_ACTIVE')) {?>
36
+					<h2><?php _e("Have a membership key?", "invoicing"); ?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
39
+						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1');
40
+						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351));
41 41
 						?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
45 45
 				<div class="membership-cta-contet">
46 46
 					<div class="main-cta">
47
-							<h2><?php _e("Membership benefits Include:","invoicing");?></h2>
47
+							<h2><?php _e("Membership benefits Include:", "invoicing"); ?></h2>
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51 51
 									$addon_obj = new WPInv_Admin_Addons();
52
-									if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
52
+									if ($addons = $addon_obj->get_section_data('addons')) {
53
+										foreach ($addons as $addon) {
54
+											echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>';
55 55
 										}
56 56
 									}
57 57
 									?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
61
-										<h3><?php _e("Membership Starts from","invoicing");?></h3>
61
+										<h3><?php _e("Membership Starts from", "invoicing"); ?></h3>
62 62
 										<h4>$99</h4>
63
-										<a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a>
63
+										<a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a>
64 64
 									</div>
65
-									<h3><?php _e("Included Gateways:","invoicing");?></h3>
65
+									<h3><?php _e("Included Gateways:", "invoicing"); ?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
68
+										if ($addons = $addon_obj->get_section_data('gateways')) {
69
+											foreach ($addons as $addon) {
70
+												echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>';
71 71
 											}
72 72
 										}
73 73
 										?>
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
84
+									echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > ';
85 85
 								?>
86 86
 							</div>
87 87
 							<div class="t-content">
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
104
+									echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > ';
105 105
 								?>
106 106
 							</div>
107 107
 							<div class="t-content">
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 						</div>
118 118
 					</div>
119 119
 					<div class="member-footer">
120
-						<a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a>
121
-						<a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice","invoicing");?></a>
120
+						<a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a>
121
+						<a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice", "invoicing"); ?></a>
122 122
 					</div>
123 123
 				</div>
124 124
 
@@ -126,50 +126,50 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
129
+		} else {
130 130
 			$installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
132
+			if ($addons = $addon_obj->get_section_data($current_tab)) :
133 133
 				//print_r($addons);
134 134
 				?>
135
-				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
136
-                        if(965==$addon->info->id){continue;}// don't show quote add on
135
+				<ul class="wpi-products"><?php foreach ($addons as $addon) :
136
+                        if (965 == $addon->info->id) {continue; }// don't show quote add on
137 137
 						?><li class="wpi-product">
138 138
 								<div class="wpi-product-title">
139 139
 									<h3><?php
140
-										if ( ! empty( $addon->info->excerpt) ){
141
-											echo wpi_help_tip( $addon->info->excerpt );
140
+										if (!empty($addon->info->excerpt)) {
141
+											echo wpi_help_tip($addon->info->excerpt);
142 142
 										}
143
-										echo esc_html( $addon->info->title ); ?></h3>
143
+										echo esc_html($addon->info->title); ?></h3>
144 144
 								</div>
145 145
 
146 146
 								<span class="wpi-product-image">
147
-									<?php if ( ! empty( $addon->info->thumbnail) ) : ?>
148
-										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
147
+									<?php if (!empty($addon->info->thumbnail)) : ?>
148
+										<img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/>
149 149
 									<?php endif;
150 150
 
151
-									if ( 'stripe-payment-gateway' == $addon->info->slug ) {
151
+									if ('stripe-payment-gateway' == $addon->info->slug) {
152 152
 										$addon->info->slug = 'getpaid-stripe-payments';
153 153
 										$addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154 154
 									}
155 155
 
156
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
-										echo '<a href="'.esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug)).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
156
+									if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === "https://wordpress.org") {
157
+										echo '<a href="' . esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug)) . '&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
159 159
 										echo '</a>';
160
-									}elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
162
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
-										}else{
160
+									}elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === "https://wpinvoicing.com" || substr($addon->info->link, 0, 21) === "https://wpgetpaid.com")) {
161
+										if (defined('WP_EASY_UPDATES_ACTIVE')) {
162
+											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true');
163
+										} else {
164 164
 											// if installed show activation link
165
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
165
+											if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) {
166 166
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
-											}else{
167
+											} else {
168 168
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169 169
 											}
170 170
 										}
171
-										echo '<a href="'.esc_url($url).'" class="thickbox">';
172
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
171
+										echo '<a href="' . esc_url($url) . '" class="thickbox">';
172
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
173 173
 										echo '</a>';
174 174
 									}
175 175
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 								<span class="wpi-product-button">
182 182
 									<?php
183
-                                    $addon_obj->output_button( $addon );
183
+                                    $addon_obj->output_button($addon);
184 184
 									?>
185 185
 								</span>
186 186
 
@@ -194,21 +194,21 @@  discard block
 block discarded – undo
194 194
 
195 195
 	<div class="clearfix" ></div>
196 196
 
197
-	<?php if($current_tab =='addons'){ ?>
198
-	<p><?php printf( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ); ?></p>
199
-	<?php } if($current_tab =='gateways'){  ?>
200
-    <p><?php printf( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ); ?></p>
197
+	<?php if ($current_tab == 'addons') { ?>
198
+	<p><?php printf(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/'); ?></p>
199
+	<?php } if ($current_tab == 'gateways') {  ?>
200
+    <p><?php printf(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/'); ?></p>
201 201
     <?php } ?>
202 202
 
203
-	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.",'invoicing'),wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'));?></span></div>
204
-	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(  __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.",'invoicing'),admin_url("plugin-install.php?tab=upload&wpeu-install=true"));?></span></div>
203
+	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php')); ?></span></div>
204
+	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url("plugin-install.php?tab=upload&wpeu-install=true")); ?></span></div>
205 205
 	<div id="wpeu-licence-popup" style="display:none;">
206 206
 		<span class="wpi-notification noti-white">
207
-			<h3 class="wpeu-licence-title"><?php _e("Licence key",'invoicing');?></h3>
208
-			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
207
+			<h3 class="wpeu-licence-title"><?php _e("Licence key", 'invoicing'); ?></h3>
208
+			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key", 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install", 'invoicing'); ?></button>
209 209
 			<br>
210 210
 			<?php
211
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
211
+			echo sprintf(__('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>');
212 212
 			?>
213 213
 		</span>
214 214
 	</div>
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
129
+		} else{
130 130
 			$installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132 132
 			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 										echo '<a href="'.esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug)).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158 158
 										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159 159
 										echo '</a>';
160
-									}elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
160
+									} elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161 161
 										if(defined('WP_EASY_UPDATES_ACTIVE')){
162 162
 											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
-										}else{
163
+										} else{
164 164
 											// if installed show activation link
165 165
 											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166 166
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
-											}else{
167
+											} else{
168 168
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169 169
 											}
170 170
 										}
Please login to merge, or discard this patch.
includes/class-bp-getpaid-component.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -17,45 +17,45 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class BP_GetPaid_Component extends BP_Component {
19 19
 
20
-	/**
21
-	 * Start the component setup process.
22
-	 *
23
-	 * @since 2.1.5
24
-	 */
25
-	public function __construct() {
26
-		parent::start(
27
-			'getpaid',
28
-			'GetPaid',
29
-			buddypress()->plugin_dir,
30
-			array(
31
-				'adminbar_myaccount_order' => 30,
32
-			)
33
-		);
34
-	}
20
+    /**
21
+     * Start the component setup process.
22
+     *
23
+     * @since 2.1.5
24
+     */
25
+    public function __construct() {
26
+        parent::start(
27
+            'getpaid',
28
+            'GetPaid',
29
+            buddypress()->plugin_dir,
30
+            array(
31
+                'adminbar_myaccount_order' => 30,
32
+            )
33
+        );
34
+    }
35 35
 
36 36
     /**
37
-	 * Set up component global variables.
38
-	 *
39
-	 * @since 2.1.5
40
-	 *
41
-	 *
42
-	 * @param array $args {
43
-	 *     All values are optional.
44
-	 *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
45
-	 *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
46
-	 *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
47
-	 *                                           component has a root directory (the slug will be overridden by the
48
-	 *                                           post_name of the directory page). Default: the slug of the directory page
49
-	 *                                           if one is found, otherwise an empty string.
50
-	 *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
51
-	 *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
52
-	 *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
53
-	 *                                           'Search Groups...'.
54
-	 *     @type array    $global_tables         Optional. An array of database table names.
55
-	 *     @type array    $meta_tables           Optional. An array of metadata table names.
56
-	 * }
57
-	 */
58
-	public function setup_globals( $args = array() ) {
37
+     * Set up component global variables.
38
+     *
39
+     * @since 2.1.5
40
+     *
41
+     *
42
+     * @param array $args {
43
+     *     All values are optional.
44
+     *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
45
+     *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
46
+     *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
47
+     *                                           component has a root directory (the slug will be overridden by the
48
+     *                                           post_name of the directory page). Default: the slug of the directory page
49
+     *                                           if one is found, otherwise an empty string.
50
+     *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
51
+     *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
52
+     *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
53
+     *                                           'Search Groups...'.
54
+     *     @type array    $global_tables         Optional. An array of database table names.
55
+     *     @type array    $meta_tables           Optional. An array of metadata table names.
56
+     * }
57
+     */
58
+    public function setup_globals( $args = array() ) {
59 59
         parent::setup_globals(
60 60
             array(
61 61
                 'id'            => 'getpaid',
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
                 'has_directory' => false
65 65
             )
66 66
         );
67
-	}
68
-
69
-	/**
70
-	 * Set up component navigation.
71
-	 *
72
-	 * @since 2.1.5
73
-	 *
74
-	 * @see BP_Component::setup_nav() for a description of arguments.
75
-	 *
76
-	 * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77
-	 * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78
-	 */
79
-	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
80
-
81
-		// Abort if the integration is inactive.
67
+    }
68
+
69
+    /**
70
+     * Set up component navigation.
71
+     *
72
+     * @since 2.1.5
73
+     *
74
+     * @see BP_Component::setup_nav() for a description of arguments.
75
+     *
76
+     * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77
+     * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78
+     */
79
+    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
80
+
81
+        // Abort if the integration is inactive.
82 82
         if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) {
83 83
             return;
84 84
         }
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
             return;
89 89
         }
90 90
 
91
-		// Determine user to use.
92
-		$user_domain   = bp_loggedin_user_domain();
93
-		$slug          = 'getpaid';
94
-		$payments_link = trailingslashit( $user_domain . $slug );
95
-
96
-		// Add 'Payments' to the main navigation.
97
-		$main_nav = array(
98
-			'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
99
-			'slug'                => $slug,
100
-			'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
-			'screen_function'     => array( $this, 'display_current_tab' ),
102
-			'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
91
+        // Determine user to use.
92
+        $user_domain   = bp_loggedin_user_domain();
93
+        $slug          = 'getpaid';
94
+        $payments_link = trailingslashit( $user_domain . $slug );
95
+
96
+        // Add 'Payments' to the main navigation.
97
+        $main_nav = array(
98
+            'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
99
+            'slug'                => $slug,
100
+            'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
+            'screen_function'     => array( $this, 'display_current_tab' ),
102
+            'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
103 103
             'show_for_displayed_user' => false,
104
-			'item_css_id'         => $this->id,
105
-			'parent_url'          => $user_domain,
106
-			'parent_slug'         => buddypress()->slug,
107
-		);
104
+            'item_css_id'         => $this->id,
105
+            'parent_url'          => $user_domain,
106
+            'parent_slug'         => buddypress()->slug,
107
+        );
108 108
 
109
-		// Add the subnav items to the payments nav item if we are using a theme that supports this.
109
+        // Add the subnav items to the payments nav item if we are using a theme that supports this.
110 110
         foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) {
111 111
 
112 112
             $sub_nav[] = array(
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                 'parent_slug'     => $slug,
117 117
                 'position' => 10,
118 118
                 'screen_function'        => function() use ( $tab ) {
119
-					$GLOBALS['getpaid_bp_current_tab'] = $tab;
120
-					$this->display_current_tab();
119
+                    $GLOBALS['getpaid_bp_current_tab'] = $tab;
120
+                    $this->display_current_tab();
121 121
                 },
122 122
                 'show_for_displayed_user' => false,
123 123
                 'item_css_id'             => "getpaid-bp-$_slug",
@@ -125,27 +125,27 @@  discard block
 block discarded – undo
125 125
 
126 126
         }
127 127
 
128
-		parent::setup_nav( $main_nav, $sub_nav );
129
-	}
130
-
131
-	/**
132
-	 * Set up the component entries in the WordPress Admin Bar.
133
-	 *
134
-	 * @since 2.1.5
135
-	 *
136
-	 * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
137
-	 *      parameter array.
138
-	 *
139
-	 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140
-	 *                            description.
141
-	 */
142
-	public function setup_admin_bar( $wp_admin_nav = array() ) {
143
-
144
-		// Menus for logged in user.
145
-		if ( is_user_logged_in() ) {
128
+        parent::setup_nav( $main_nav, $sub_nav );
129
+    }
146 130
 
147
-			// Setup the logged in user variables.
148
-			$payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
131
+    /**
132
+     * Set up the component entries in the WordPress Admin Bar.
133
+     *
134
+     * @since 2.1.5
135
+     *
136
+     * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
137
+     *      parameter array.
138
+     *
139
+     * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140
+     *                            description.
141
+     */
142
+    public function setup_admin_bar( $wp_admin_nav = array() ) {
143
+
144
+        // Menus for logged in user.
145
+        if ( is_user_logged_in() ) {
146
+
147
+            // Setup the logged in user variables.
148
+            $payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
149 149
 
150 150
             // Add the "Payments" sub menu.
151 151
             $wp_admin_nav[] = array(
@@ -167,50 +167,50 @@  discard block
 block discarded – undo
167 167
 
168 168
             }
169 169
 
170
-		}
171
-
172
-		parent::setup_admin_bar( $wp_admin_nav );
173
-	}
170
+        }
174 171
 
175
-	/**
176
-	 * Retrieves the current tab.
177
-	 *
178
-	 * @since 2.1.5
179
-	 */
180
-	public function get_current_tab() {
181
-		global $getpaid_bp_current_tab;
172
+        parent::setup_admin_bar( $wp_admin_nav );
173
+    }
182 174
 
183
-		if ( empty( $getpaid_bp_current_tab ) ) {
184
-			return array(
185
-				'label'     => __( 'Invoices', 'invoicing' ),
186
-				'content'   => '[wpinv_history]',
187
-				'icon'      => 'fas fa-file-invoice',
188
-			);
189
-		}
175
+    /**
176
+     * Retrieves the current tab.
177
+     *
178
+     * @since 2.1.5
179
+     */
180
+    public function get_current_tab() {
181
+        global $getpaid_bp_current_tab;
182
+
183
+        if ( empty( $getpaid_bp_current_tab ) ) {
184
+            return array(
185
+                'label'     => __( 'Invoices', 'invoicing' ),
186
+                'content'   => '[wpinv_history]',
187
+                'icon'      => 'fas fa-file-invoice',
188
+            );
189
+        }
190 190
 
191
-		return $getpaid_bp_current_tab;
192
-	}
191
+        return $getpaid_bp_current_tab;
192
+    }
193 193
 
194
-	/**
195
-	 * Displays the current tab.
196
-	 *
197
-	 * @since 2.1.5
198
-	 */
199
-	public function display_current_tab() {
194
+    /**
195
+     * Displays the current tab.
196
+     *
197
+     * @since 2.1.5
198
+     */
199
+    public function display_current_tab() {
200 200
 
201
-		add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
-		$template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
201
+        add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
+        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
203 203
 
204 204
         bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
205
-	}
206
-
207
-	/**
208
-	 * Handles the actual display of the current tab.
209
-	 *
210
-	 * @since 2.1.5
211
-	 */
212
-	public function handle_display_current_tab() {
213
-		 getpaid_prepare_user_content_tab( $this->get_current_tab() );
214
-	}
205
+    }
206
+
207
+    /**
208
+     * Handles the actual display of the current tab.
209
+     *
210
+     * @since 2.1.5
211
+     */
212
+    public function handle_display_current_tab() {
213
+            getpaid_prepare_user_content_tab( $this->get_current_tab() );
214
+    }
215 215
 
216 216
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly.
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * Main GetPaid Class.
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *     @type array    $meta_tables           Optional. An array of metadata table names.
56 56
 	 * }
57 57
 	 */
58
-	public function setup_globals( $args = array() ) {
58
+	public function setup_globals($args = array()) {
59 59
         parent::setup_globals(
60 60
             array(
61 61
                 'id'            => 'getpaid',
@@ -76,30 +76,30 @@  discard block
 block discarded – undo
76 76
 	 * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77 77
 	 * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78 78
 	 */
79
-	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
79
+	public function setup_nav($main_nav = array(), $sub_nav = array()) {
80 80
 
81 81
 		// Abort if the integration is inactive.
82
-        if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) {
82
+        if (!getpaid_is_buddypress_integration_active() || !is_user_logged_in()) {
83 83
             return;
84 84
         }
85 85
     
86 86
         // Or a user is not viewing their profile.
87
-        if ( bp_displayed_user_id() != bp_loggedin_user_id() ) {
87
+        if (bp_displayed_user_id() != bp_loggedin_user_id()) {
88 88
             return;
89 89
         }
90 90
 
91 91
 		// Determine user to use.
92 92
 		$user_domain   = bp_loggedin_user_domain();
93 93
 		$slug          = 'getpaid';
94
-		$payments_link = trailingslashit( $user_domain . $slug );
94
+		$payments_link = trailingslashit($user_domain . $slug);
95 95
 
96 96
 		// Add 'Payments' to the main navigation.
97 97
 		$main_nav = array(
98
-			'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
98
+			'name'                => _x('Billing', 'BuddyPress profile payments screen nav', 'invoicing'),
99 99
 			'slug'                => $slug,
100
-			'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
-			'screen_function'     => array( $this, 'display_current_tab' ),
102
-			'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
100
+			'position'            => apply_filters('wpinv_bp_nav_position', wpinv_get_option('wpinv_menu_position', 91), $slug),
101
+			'screen_function'     => array($this, 'display_current_tab'),
102
+			'default_subnav_slug' => apply_filters('getpaid_default_tab', 'gp-edit-address'),
103 103
             'show_for_displayed_user' => false,
104 104
 			'item_css_id'         => $this->id,
105 105
 			'parent_url'          => $user_domain,
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 
109 109
 		// Add the subnav items to the payments nav item if we are using a theme that supports this.
110
-        foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) {
110
+        foreach (getpaid_get_user_content_tabs() as $_slug => $tab) {
111 111
 
112 112
             $sub_nav[] = array(
113
-                'name'            => $tab[ 'label'],
113
+                'name'            => $tab['label'],
114 114
                 'slug'            => $_slug,
115 115
                 'parent_url'      => $payments_link,
116 116
                 'parent_slug'     => $slug,
117 117
                 'position' => 10,
118
-                'screen_function'        => function() use ( $tab ) {
118
+                'screen_function'        => function() use ($tab) {
119 119
 					$GLOBALS['getpaid_bp_current_tab'] = $tab;
120 120
 					$this->display_current_tab();
121 121
                 },
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         }
127 127
 
128
-		parent::setup_nav( $main_nav, $sub_nav );
128
+		parent::setup_nav($main_nav, $sub_nav);
129 129
 	}
130 130
 
131 131
 	/**
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
 	 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140 140
 	 *                            description.
141 141
 	 */
142
-	public function setup_admin_bar( $wp_admin_nav = array() ) {
142
+	public function setup_admin_bar($wp_admin_nav = array()) {
143 143
 
144 144
 		// Menus for logged in user.
145
-		if ( is_user_logged_in() ) {
145
+		if (is_user_logged_in()) {
146 146
 
147 147
 			// Setup the logged in user variables.
148
-			$payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
148
+			$payments_link = trailingslashit(bp_loggedin_user_domain() . 'getpaid/');
149 149
 
150 150
             // Add the "Payments" sub menu.
151 151
             $wp_admin_nav[] = array(
152 152
                 'parent' => buddypress()->my_account_menu_id,
153 153
                 'id'     => 'my-account-getpaid',
154
-                'title'  => _x( 'Billing', 'BuddyPress my account payments sub nav', 'invoicing' ),
155
-                'href'   => $payments_link . apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
154
+                'title'  => _x('Billing', 'BuddyPress my account payments sub nav', 'invoicing'),
155
+                'href'   => $payments_link . apply_filters('getpaid_default_tab', 'gp-edit-address'),
156 156
             );
157 157
 
158
-            foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) {
158
+            foreach (getpaid_get_user_content_tabs() as $slug => $tab) {
159 159
 
160 160
                 $wp_admin_nav[] = array(
161 161
                     'parent'   => 'my-account-getpaid',
162 162
                     'id'       => 'my-account-getpaid' . $slug,
163
-                    'title'    => $tab[ 'label'],
164
-                    'href'     => trailingslashit( $payments_link . $slug ),
163
+                    'title'    => $tab['label'],
164
+                    'href'     => trailingslashit($payments_link . $slug),
165 165
                     'position' => 20
166 166
                 );
167 167
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 		}
171 171
 
172
-		parent::setup_admin_bar( $wp_admin_nav );
172
+		parent::setup_admin_bar($wp_admin_nav);
173 173
 	}
174 174
 
175 175
 	/**
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	public function get_current_tab() {
181 181
 		global $getpaid_bp_current_tab;
182 182
 
183
-		if ( empty( $getpaid_bp_current_tab ) ) {
183
+		if (empty($getpaid_bp_current_tab)) {
184 184
 			return array(
185
-				'label'     => __( 'Invoices', 'invoicing' ),
185
+				'label'     => __('Invoices', 'invoicing'),
186 186
 				'content'   => '[wpinv_history]',
187 187
 				'icon'      => 'fas fa-file-invoice',
188 188
 			);
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function display_current_tab() {
200 200
 
201
-		add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
-		$template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
201
+		add_action('bp_template_content', array($this, 'handle_display_current_tab'));
202
+		$template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
203 203
 
204
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
204
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
205 205
 	}
206 206
 
207 207
 	/**
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @since 2.1.5
211 211
 	 */
212 212
 	public function handle_display_current_tab() {
213
-		 getpaid_prepare_user_content_tab( $this->get_current_tab() );
213
+		 getpaid_prepare_user_content_tab($this->get_current_tab());
214 214
 	}
215 215
 
216 216
 }
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-report-earnings.php 2 patches
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -12,43 +12,43 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports_Report_Earnings extends GetPaid_Reports_Abstract_Report {
14 14
 
15
-	/**
16
-	 * Retrieves the earning graphs.
17
-	 *
18
-	 */
19
-	public function get_graphs() {
15
+    /**
16
+     * Retrieves the earning graphs.
17
+     *
18
+     */
19
+    public function get_graphs() {
20 20
 
21
-		$graphs = array(
21
+        $graphs = array(
22 22
 
23 23
             'total'      => __( 'Earnings', 'invoicing' ),
24 24
             'discount'   => __( 'Discount', 'invoicing' ),
25
-			'fees_total' => __( 'Fees', 'invoicing' ),
26
-			'tax'        => __( 'Tax', 'invoicing' ),
25
+            'fees_total' => __( 'Fees', 'invoicing' ),
26
+            'tax'        => __( 'Tax', 'invoicing' ),
27 27
 
28
-		);
28
+        );
29 29
 
30
-		return apply_filters( 'getpaid_earning_graphs', $graphs );
30
+        return apply_filters( 'getpaid_earning_graphs', $graphs );
31 31
 
32
-	}
32
+    }
33 33
 
34
-	/**
35
-	 * Retrieves the earning sql.
36
-	 *
37
-	 */
38
-	public function get_sql( $range ) {
39
-		global $wpdb;
34
+    /**
35
+     * Retrieves the earning sql.
36
+     *
37
+     */
38
+    public function get_sql( $range ) {
39
+        global $wpdb;
40 40
 
41
-		$table      = $wpdb->prefix . 'getpaid_invoices';
42
-		$clauses    = $this->get_range_sql( $range );
43
-		$graphs     = array_keys( $this->get_graphs() );
44
-		$graphs_sql = array();
41
+        $table      = $wpdb->prefix . 'getpaid_invoices';
42
+        $clauses    = $this->get_range_sql( $range );
43
+        $graphs     = array_keys( $this->get_graphs() );
44
+        $graphs_sql = array();
45 45
 
46
-		foreach ( $graphs as $graph ) {
47
-			$graphs_sql[] = "SUM( meta.$graph ) AS $graph";
48
-		}
46
+        foreach ( $graphs as $graph ) {
47
+            $graphs_sql[] = "SUM( meta.$graph ) AS $graph";
48
+        }
49 49
 
50
-		$graphs_sql = implode( ', ', $graphs_sql );
51
-		$sql        = "SELECT {$clauses[0]} AS completed_date, $graphs_sql
50
+        $graphs_sql = implode( ', ', $graphs_sql );
51
+        $sql        = "SELECT {$clauses[0]} AS completed_date, $graphs_sql
52 52
             FROM $wpdb->posts
53 53
             LEFT JOIN $table as meta ON meta.post_id = $wpdb->posts.ID
54 54
             WHERE meta.post_id IS NOT NULL
@@ -58,94 +58,94 @@  discard block
 block discarded – undo
58 58
             GROUP BY {$clauses[0]}
59 59
         ";
60 60
 
61
-		return apply_filters( 'getpaid_earning_graphs_get_sql', $sql, $range );
62
-
63
-	}
64
-
65
-	/**
66
-	 * Prepares the report stats.
67
-	 *
68
-	 */
69
-	public function prepare_stats() {
70
-		global $wpdb;
71
-		$this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) );
72
-	}
73
-
74
-	/**
75
-	 * Retrieves report labels.
76
-	 *
77
-	 */
78
-	public function get_labels( $range ) {
79
-
80
-		$labels = array(
81
-			'today'     => $this->get_hours_in_a_day(),
82
-			'yesterday' => $this->get_hours_in_a_day(),
83
-			'7_days'    => $this->get_days_in_period( 7 ),
84
-			'30_days'   => $this->get_days_in_period( 30 ),
85
-			'60_days'   => $this->get_days_in_period( 60 ),
86
-			'90_days'   => $this->get_weeks_in_period( 90 ),
87
-			'180_days'  => $this->get_weeks_in_period( 180 ),
88
-			'360_days'  => $this->get_weeks_in_period( 360 ),
89
-		);
90
-
91
-		$label = isset( $labels[ $range ] ) ? $labels[ $range ] : $labels[ '7_days' ];
92
-		return apply_filters( 'getpaid_earning_graphs_get_labels', $label, $range );
93
-	}
94
-
95
-	/**
96
-	 * Retrieves report datasets.
97
-	 *
98
-	 */
99
-	public function get_datasets( $labels ) {
100
-
101
-		$datasets = array();
102
-
103
-		foreach ( $this->get_graphs() as $key => $label ) {
104
-			$datasets[ $key ] = array(
105
-				'label' => $label,
106
-				'data'  => $this->get_data( $key, $labels )
107
-			);
108
-		}
109
-
110
-		return apply_filters( 'getpaid_earning_graphs_get_datasets', $datasets, $labels );
111
-	}
112
-
113
-	/**
114
-	 * Retrieves report data.
115
-	 *
116
-	 */
117
-	public function get_data( $key, $labels ) {
118
-
119
-		$data     = wp_list_pluck( $this->stats, $key, 'completed_date' );
120
-		$prepared = array();
121
-
122
-		foreach ( $labels as $label ) {
123
-
124
-			$value = 0;
125
-			if ( isset( $data[ $label ] ) ) {
126
-				$value = wpinv_round_amount( wpinv_sanitize_amount( $data[ $label ] ) );
127
-			}
128
-
129
-			$prepared[] = $value;
130
-		}
131
-
132
-		return apply_filters( 'getpaid_earning_graphs_get_data', $prepared, $key, $labels );
133
-
134
-	}
135
-
136
-	/**
137
-	 * Displays the report card.
138
-	 *
139
-	 */
140
-	public function display() {
141
-
142
-		$labels     = $this->get_labels( $this->get_range() );
143
-		$chart_data = array(
144
-			'labels'   => array_values( $labels ),
145
-			'datasets' => $this->get_datasets( array_keys( $labels ) ),
146
-		);
147
-
148
-		?>
61
+        return apply_filters( 'getpaid_earning_graphs_get_sql', $sql, $range );
62
+
63
+    }
64
+
65
+    /**
66
+     * Prepares the report stats.
67
+     *
68
+     */
69
+    public function prepare_stats() {
70
+        global $wpdb;
71
+        $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) );
72
+    }
73
+
74
+    /**
75
+     * Retrieves report labels.
76
+     *
77
+     */
78
+    public function get_labels( $range ) {
79
+
80
+        $labels = array(
81
+            'today'     => $this->get_hours_in_a_day(),
82
+            'yesterday' => $this->get_hours_in_a_day(),
83
+            '7_days'    => $this->get_days_in_period( 7 ),
84
+            '30_days'   => $this->get_days_in_period( 30 ),
85
+            '60_days'   => $this->get_days_in_period( 60 ),
86
+            '90_days'   => $this->get_weeks_in_period( 90 ),
87
+            '180_days'  => $this->get_weeks_in_period( 180 ),
88
+            '360_days'  => $this->get_weeks_in_period( 360 ),
89
+        );
90
+
91
+        $label = isset( $labels[ $range ] ) ? $labels[ $range ] : $labels[ '7_days' ];
92
+        return apply_filters( 'getpaid_earning_graphs_get_labels', $label, $range );
93
+    }
94
+
95
+    /**
96
+     * Retrieves report datasets.
97
+     *
98
+     */
99
+    public function get_datasets( $labels ) {
100
+
101
+        $datasets = array();
102
+
103
+        foreach ( $this->get_graphs() as $key => $label ) {
104
+            $datasets[ $key ] = array(
105
+                'label' => $label,
106
+                'data'  => $this->get_data( $key, $labels )
107
+            );
108
+        }
109
+
110
+        return apply_filters( 'getpaid_earning_graphs_get_datasets', $datasets, $labels );
111
+    }
112
+
113
+    /**
114
+     * Retrieves report data.
115
+     *
116
+     */
117
+    public function get_data( $key, $labels ) {
118
+
119
+        $data     = wp_list_pluck( $this->stats, $key, 'completed_date' );
120
+        $prepared = array();
121
+
122
+        foreach ( $labels as $label ) {
123
+
124
+            $value = 0;
125
+            if ( isset( $data[ $label ] ) ) {
126
+                $value = wpinv_round_amount( wpinv_sanitize_amount( $data[ $label ] ) );
127
+            }
128
+
129
+            $prepared[] = $value;
130
+        }
131
+
132
+        return apply_filters( 'getpaid_earning_graphs_get_data', $prepared, $key, $labels );
133
+
134
+    }
135
+
136
+    /**
137
+     * Displays the report card.
138
+     *
139
+     */
140
+    public function display() {
141
+
142
+        $labels     = $this->get_labels( $this->get_range() );
143
+        $chart_data = array(
144
+            'labels'   => array_values( $labels ),
145
+            'datasets' => $this->get_datasets( array_keys( $labels ) ),
146
+        );
147
+
148
+        ?>
149 149
 
150 150
 			<?php foreach ( $chart_data['datasets'] as $key => $dataset ) : ?>
151 151
 				<div class="row mb-4">
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
 
166 166
 		<?php
167 167
 
168
-	}
168
+    }
169 169
 
170
-	/**
171
-	 * Displays the actual report.
172
-	 *
173
-	 */
174
-	public function display_graph( $key, $dataset, $labels ) {
170
+    /**
171
+     * Displays the actual report.
172
+     *
173
+     */
174
+    public function display_graph( $key, $dataset, $labels ) {
175 175
 
176
-		?>
176
+        ?>
177 177
 
178 178
 		<canvas id="getpaid-chartjs-earnings-<?php echo esc_attr( $key ); ?>"></canvas>
179 179
 
@@ -223,20 +223,20 @@  discard block
 block discarded – undo
223 223
 		</script>
224 224
 
225 225
 		<?php
226
-	}
226
+    }
227 227
 
228
-	/**
229
-	 * Displays the actual report.
230
-	 *
231
-	 */
232
-	public function display_stats() {}
228
+    /**
229
+     * Displays the actual report.
230
+     *
231
+     */
232
+    public function display_stats() {}
233 233
 
234
-	/**
235
-	 * Displays the range selector.
236
-	 *
237
-	 */
238
-	public function display_range_selector() {
234
+    /**
235
+     * Displays the range selector.
236
+     *
237
+     */
238
+    public function display_range_selector() {
239 239
 
240
-	}
240
+    }
241 241
 
242 242
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Report_Earnings Class.
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 
21 21
 		$graphs = array(
22 22
 
23
-            'total'      => __( 'Earnings', 'invoicing' ),
24
-            'discount'   => __( 'Discount', 'invoicing' ),
25
-			'fees_total' => __( 'Fees', 'invoicing' ),
26
-			'tax'        => __( 'Tax', 'invoicing' ),
23
+            'total'      => __('Earnings', 'invoicing'),
24
+            'discount'   => __('Discount', 'invoicing'),
25
+			'fees_total' => __('Fees', 'invoicing'),
26
+			'tax'        => __('Tax', 'invoicing'),
27 27
 
28 28
 		);
29 29
 
30
-		return apply_filters( 'getpaid_earning_graphs', $graphs );
30
+		return apply_filters('getpaid_earning_graphs', $graphs);
31 31
 
32 32
 	}
33 33
 
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
 	 * Retrieves the earning sql.
36 36
 	 *
37 37
 	 */
38
-	public function get_sql( $range ) {
38
+	public function get_sql($range) {
39 39
 		global $wpdb;
40 40
 
41 41
 		$table      = $wpdb->prefix . 'getpaid_invoices';
42
-		$clauses    = $this->get_range_sql( $range );
43
-		$graphs     = array_keys( $this->get_graphs() );
42
+		$clauses    = $this->get_range_sql($range);
43
+		$graphs     = array_keys($this->get_graphs());
44 44
 		$graphs_sql = array();
45 45
 
46
-		foreach ( $graphs as $graph ) {
46
+		foreach ($graphs as $graph) {
47 47
 			$graphs_sql[] = "SUM( meta.$graph ) AS $graph";
48 48
 		}
49 49
 
50
-		$graphs_sql = implode( ', ', $graphs_sql );
50
+		$graphs_sql = implode(', ', $graphs_sql);
51 51
 		$sql        = "SELECT {$clauses[0]} AS completed_date, $graphs_sql
52 52
             FROM $wpdb->posts
53 53
             LEFT JOIN $table as meta ON meta.post_id = $wpdb->posts.ID
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             GROUP BY {$clauses[0]}
59 59
         ";
60 60
 
61
-		return apply_filters( 'getpaid_earning_graphs_get_sql', $sql, $range );
61
+		return apply_filters('getpaid_earning_graphs_get_sql', $sql, $range);
62 62
 
63 63
 	}
64 64
 
@@ -68,68 +68,68 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function prepare_stats() {
70 70
 		global $wpdb;
71
-		$this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) );
71
+		$this->stats = $wpdb->get_results($this->get_sql($this->get_range()));
72 72
 	}
73 73
 
74 74
 	/**
75 75
 	 * Retrieves report labels.
76 76
 	 *
77 77
 	 */
78
-	public function get_labels( $range ) {
78
+	public function get_labels($range) {
79 79
 
80 80
 		$labels = array(
81 81
 			'today'     => $this->get_hours_in_a_day(),
82 82
 			'yesterday' => $this->get_hours_in_a_day(),
83
-			'7_days'    => $this->get_days_in_period( 7 ),
84
-			'30_days'   => $this->get_days_in_period( 30 ),
85
-			'60_days'   => $this->get_days_in_period( 60 ),
86
-			'90_days'   => $this->get_weeks_in_period( 90 ),
87
-			'180_days'  => $this->get_weeks_in_period( 180 ),
88
-			'360_days'  => $this->get_weeks_in_period( 360 ),
83
+			'7_days'    => $this->get_days_in_period(7),
84
+			'30_days'   => $this->get_days_in_period(30),
85
+			'60_days'   => $this->get_days_in_period(60),
86
+			'90_days'   => $this->get_weeks_in_period(90),
87
+			'180_days'  => $this->get_weeks_in_period(180),
88
+			'360_days'  => $this->get_weeks_in_period(360),
89 89
 		);
90 90
 
91
-		$label = isset( $labels[ $range ] ) ? $labels[ $range ] : $labels[ '7_days' ];
92
-		return apply_filters( 'getpaid_earning_graphs_get_labels', $label, $range );
91
+		$label = isset($labels[$range]) ? $labels[$range] : $labels['7_days'];
92
+		return apply_filters('getpaid_earning_graphs_get_labels', $label, $range);
93 93
 	}
94 94
 
95 95
 	/**
96 96
 	 * Retrieves report datasets.
97 97
 	 *
98 98
 	 */
99
-	public function get_datasets( $labels ) {
99
+	public function get_datasets($labels) {
100 100
 
101 101
 		$datasets = array();
102 102
 
103
-		foreach ( $this->get_graphs() as $key => $label ) {
104
-			$datasets[ $key ] = array(
103
+		foreach ($this->get_graphs() as $key => $label) {
104
+			$datasets[$key] = array(
105 105
 				'label' => $label,
106
-				'data'  => $this->get_data( $key, $labels )
106
+				'data'  => $this->get_data($key, $labels)
107 107
 			);
108 108
 		}
109 109
 
110
-		return apply_filters( 'getpaid_earning_graphs_get_datasets', $datasets, $labels );
110
+		return apply_filters('getpaid_earning_graphs_get_datasets', $datasets, $labels);
111 111
 	}
112 112
 
113 113
 	/**
114 114
 	 * Retrieves report data.
115 115
 	 *
116 116
 	 */
117
-	public function get_data( $key, $labels ) {
117
+	public function get_data($key, $labels) {
118 118
 
119
-		$data     = wp_list_pluck( $this->stats, $key, 'completed_date' );
119
+		$data     = wp_list_pluck($this->stats, $key, 'completed_date');
120 120
 		$prepared = array();
121 121
 
122
-		foreach ( $labels as $label ) {
122
+		foreach ($labels as $label) {
123 123
 
124 124
 			$value = 0;
125
-			if ( isset( $data[ $label ] ) ) {
126
-				$value = wpinv_round_amount( wpinv_sanitize_amount( $data[ $label ] ) );
125
+			if (isset($data[$label])) {
126
+				$value = wpinv_round_amount(wpinv_sanitize_amount($data[$label]));
127 127
 			}
128 128
 
129 129
 			$prepared[] = $value;
130 130
 		}
131 131
 
132
-		return apply_filters( 'getpaid_earning_graphs_get_data', $prepared, $key, $labels );
132
+		return apply_filters('getpaid_earning_graphs_get_data', $prepared, $key, $labels);
133 133
 
134 134
 	}
135 135
 
@@ -139,24 +139,24 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public function display() {
141 141
 
142
-		$labels     = $this->get_labels( $this->get_range() );
142
+		$labels     = $this->get_labels($this->get_range());
143 143
 		$chart_data = array(
144
-			'labels'   => array_values( $labels ),
145
-			'datasets' => $this->get_datasets( array_keys( $labels ) ),
144
+			'labels'   => array_values($labels),
145
+			'datasets' => $this->get_datasets(array_keys($labels)),
146 146
 		);
147 147
 
148 148
 		?>
149 149
 
150
-			<?php foreach ( $chart_data['datasets'] as $key => $dataset ) : ?>
150
+			<?php foreach ($chart_data['datasets'] as $key => $dataset) : ?>
151 151
 				<div class="row mb-4">
152 152
 					<div class="col-12">
153 153
 						<div class="card m-0 p-0" style="max-width:100%">
154 154
 							<div class="card-header d-flex align-items-center">
155
-								<strong class="flex-grow-1"><?php echo esc_html( $dataset['label'] ); ?></strong>
155
+								<strong class="flex-grow-1"><?php echo esc_html($dataset['label']); ?></strong>
156 156
 								<?php $this->display_range_selector(); ?>
157 157
 							</div>
158 158
 							<div class="card-body">
159
-								<?php $this->display_graph( $key, $dataset, $chart_data['labels'] ); ?>
159
+								<?php $this->display_graph($key, $dataset, $chart_data['labels']); ?>
160 160
 							</div>
161 161
 						</div>
162 162
 					</div>
@@ -171,26 +171,26 @@  discard block
 block discarded – undo
171 171
 	 * Displays the actual report.
172 172
 	 *
173 173
 	 */
174
-	public function display_graph( $key, $dataset, $labels ) {
174
+	public function display_graph($key, $dataset, $labels) {
175 175
 
176 176
 		?>
177 177
 
178
-		<canvas id="getpaid-chartjs-earnings-<?php echo esc_attr( $key ); ?>"></canvas>
178
+		<canvas id="getpaid-chartjs-earnings-<?php echo esc_attr($key); ?>"></canvas>
179 179
 
180 180
 		<script>
181 181
 			window.addEventListener( 'DOMContentLoaded', function() {
182 182
 
183
-				var ctx = document.getElementById( 'getpaid-chartjs-earnings-<?php echo esc_attr( $key ); ?>' ).getContext('2d');
183
+				var ctx = document.getElementById( 'getpaid-chartjs-earnings-<?php echo esc_attr($key); ?>' ).getContext('2d');
184 184
 				new Chart(
185 185
 					ctx,
186 186
 					{
187 187
 						type: 'line',
188 188
 						data: {
189
-							'labels': <?php echo wp_json_encode( wpinv_clean( $labels ) ); ?>,
189
+							'labels': <?php echo wp_json_encode(wpinv_clean($labels)); ?>,
190 190
 							'datasets': [
191 191
 								{
192
-									label: '<?php echo esc_attr( $dataset['label'] ); ?>',
193
-									data: <?php echo wp_json_encode( wpinv_clean( $dataset['data'] ) ); ?>,
192
+									label: '<?php echo esc_attr($dataset['label']); ?>',
193
+									data: <?php echo wp_json_encode(wpinv_clean($dataset['data'])); ?>,
194 194
 									backgroundColor: 'rgba(54, 162, 235, 0.1)',
195 195
 									borderColor: 'rgb(54, 162, 235)',
196 196
 									borderWidth: 4,
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+                    foreach( $tabs as $key => $label ) {
67 67
 
68
-						$key   = sanitize_key( $key );
69
-						$label = esc_html( $label );
70
-						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
-						);
68
+                        $key   = sanitize_key( $key );
69
+                        $label = esc_html( $label );
70
+                        $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                        $url   = esc_url(
72
+                            add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
+                        );
74 74
 
75
-						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
75
+                        echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	/**
97
-	 * Retrieves reports page tabs.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	public function get_tabs() {
96
+    /**
97
+     * Retrieves reports page tabs.
98
+     *
99
+     * @return array
100
+     */
101
+    public function get_tabs() {
102 102
 
103
-		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
106
-		);
103
+        $tabs = array(
104
+            'reports' => __( 'Reports', 'invoicing' ),
105
+            'export'  => __( 'Export', 'invoicing' ),
106
+        );
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
-	}
108
+        return apply_filters( 'getpaid_report_tabs', $tabs );
109
+    }
110 110
 
111
-	/**
112
-	 * Displays the reports tab.
113
-	 *
114
-	 */
115
-	public function display_reports_tab() {
111
+    /**
112
+     * Displays the reports tab.
113
+     *
114
+     */
115
+    public function display_reports_tab() {
116 116
 
117
-		$reports = new GetPaid_Reports_Report();
118
-		$reports->display();
117
+        $reports = new GetPaid_Reports_Report();
118
+        $reports->display();
119 119
 
120
-	}
120
+    }
121 121
 
122
-	/**
123
-	 * Displays the exports tab.
124
-	 *
125
-	 */
126
-	public function display_exports_tab() {
122
+    /**
123
+     * Displays the exports tab.
124
+     *
125
+     */
126
+    public function display_exports_tab() {
127 127
 
128
-		$exports = new GetPaid_Reports_Export();
129
-		$exports->display();
128
+        $exports = new GetPaid_Reports_Export();
129
+        $exports->display();
130 130
 
131
-	}
131
+    }
132 132
 
133
-	/**
134
-	 * Donwnloads a graph.
135
-	 *
136
-	 * @param array $args
137
-	 */
138
-	public function download_graph( $args ) {
133
+    /**
134
+     * Donwnloads a graph.
135
+     *
136
+     * @param array $args
137
+     */
138
+    public function download_graph( $args ) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
141
-			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
143
-		}
140
+        if ( ! empty( $args['graph'] ) ) {
141
+            $downloader = new GetPaid_Graph_Downloader();
142
+            $downloader->download( $args['graph'] );
143
+        }
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Exports invoices.
149
-	 *
150
-	 * @param array $args
151
-	 */
152
-	public function export_invoices( $args ) {
147
+    /**
148
+     * Exports invoices.
149
+     *
150
+     * @param array $args
151
+     */
152
+    public function export_invoices( $args ) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+        if ( ! empty( $args['post_type'] ) ) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
157
-				$downloader = new GetPaid_Subscription_Exporter();
158
-			} else {
159
-				$downloader = new GetPaid_Invoice_Exporter();
160
-			}
156
+            if ( 'subscriptions' === $args['post_type'] ) {
157
+                $downloader = new GetPaid_Subscription_Exporter();
158
+            } else {
159
+                $downloader = new GetPaid_Invoice_Exporter();
160
+            }
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
163
-		}
162
+            $downloader->export( $args['post_type'], $args );
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo esc_html($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-						$key   = sanitize_key( $key );
69
-						$label = esc_html( $label );
68
+						$key   = sanitize_key($key);
69
+						$label = esc_html($label);
70 70
 						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+							add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
 						);
74 74
 
75 75
 						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true);
93 93
 
94 94
 	}
95 95
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	public function get_tabs() {
102 102
 
103 103
 		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
104
+			'reports' => __('Reports', 'invoicing'),
105
+			'export'  => __('Export', 'invoicing'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
108
+		return apply_filters('getpaid_report_tabs', $tabs);
109 109
 	}
110 110
 
111 111
 	/**
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $args
137 137
 	 */
138
-	public function download_graph( $args ) {
138
+	public function download_graph($args) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
140
+		if (!empty($args['graph'])) {
141 141
 			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
142
+			$downloader->download($args['graph']);
143 143
 		}
144 144
 
145 145
 	}
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $args
151 151
 	 */
152
-	public function export_invoices( $args ) {
152
+	public function export_invoices($args) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+		if (!empty($args['post_type'])) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
156
+			if ('subscriptions' === $args['post_type']) {
157 157
 				$downloader = new GetPaid_Subscription_Exporter();
158 158
 			} else {
159 159
 				$downloader = new GetPaid_Invoice_Exporter();
160 160
 			}
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
162
+			$downloader->export($args['post_type'], $args);
163 163
 		}
164 164
 
165 165
 	}
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 2 patches
Indentation   +403 added lines, -403 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,300 +21,300 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 * @since 1.0.10 Now able to pass wp.org theme check.
29
-	 * @since 1.0.11 Font Awesome Pro now supported.
30
-	 * @since 1.0.11 Font Awesome Kits now supported.
31
-	 * @since 1.0.13 RTL language support added.
32
-	 * @ver 1.0.13
33
-	 * @todo decide how to implement textdomain
34
-	 */
35
-	class WP_Font_Awesome_Settings {
36
-
37
-		/**
38
-		 * Class version version.
39
-		 *
40
-		 * @var string
41
-		 */
42
-		public $version = '1.0.13';
43
-
44
-		/**
45
-		 * Class textdomain.
46
-		 *
47
-		 * @var string
48
-		 */
49
-		public $textdomain = 'font-awesome-settings';
50
-
51
-		/**
52
-		 * Latest version of Font Awesome at time of publish published.
53
-		 *
54
-		 * @var string
55
-		 */
56
-		public $latest = "5.8.2";
57
-
58
-		/**
59
-		 * The title.
60
-		 *
61
-		 * @var string
62
-		 */
63
-		public $name = 'Font Awesome';
64
-
65
-		/**
66
-		 * Holds the settings values.
67
-		 *
68
-		 * @var array
69
-		 */
70
-		private $settings;
71
-
72
-		/**
73
-		 * WP_Font_Awesome_Settings instance.
74
-		 *
75
-		 * @access private
76
-		 * @since  1.0.0
77
-		 * @var    WP_Font_Awesome_Settings There can be only one!
78
-		 */
79
-		private static $instance = null;
80
-
81
-		/**
82
-		 * Main WP_Font_Awesome_Settings Instance.
83
-		 *
84
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
85
-		 *
86
-		 * @since 1.0.0
87
-		 * @static
88
-		 * @return WP_Font_Awesome_Settings - Main instance.
89
-		 */
90
-		public static function instance() {
91
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
92
-				self::$instance = new WP_Font_Awesome_Settings;
93
-
94
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
95
-
96
-				if ( is_admin() ) {
97
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
98
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
99
-				}
100
-
101
-				do_action( 'wp_font_awesome_settings_loaded' );
102
-			}
103
-
104
-			return self::$instance;
105
-		}
106
-
107
-		/**
108
-		 * Initiate the settings and add the required action hooks.
109
-		 *
110
-		 * @since 1.0.8 Settings name wrong - FIXED
111
-		 */
112
-		public function init() {
113
-			$this->settings = $this->get_settings();
114
-
115
-			if ( $this->settings['type'] == 'CSS' ) {
116
-
117
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
118
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
119
-				}
120
-
121
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
122
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
123
-				}
124
-
125
-			} else {
126
-
127
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
128
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
129
-				}
130
-
131
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
132
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
133
-				}
134
-			}
135
-
136
-			// remove font awesome if set to do so
137
-			if ( $this->settings['dequeue'] == '1' ) {
138
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
139
-			}
140
-
141
-		}
142
-
143
-		/**
144
-		 * Adds the Font Awesome styles.
145
-		 */
146
-		public function enqueue_style() {
147
-			// build url
148
-			$url = $this->get_url();
149
-
150
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
151
-			wp_register_style( 'font-awesome', $url, array(), null );
152
-			wp_enqueue_style( 'font-awesome' );
153
-
154
-			// RTL language support CSS.
155
-			if ( is_rtl() ) {
156
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
157
-			}
158
-
159
-			if ( $this->settings['shims'] ) {
160
-				$url = $this->get_url( true );
161
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
162
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
163
-				wp_enqueue_style( 'font-awesome-shims' );
164
-			}
165
-		}
166
-
167
-		/**
168
-		 * Adds the Font Awesome JS.
169
-		 */
170
-		public function enqueue_scripts() {
171
-			// build url
172
-			$url = $this->get_url();
173
-
174
-			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
175
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
176
-			wp_register_script( 'font-awesome', $url, array(), null );
177
-			wp_enqueue_script( 'font-awesome' );
178
-
179
-			if ( $this->settings['shims'] ) {
180
-				$url = $this->get_url( true );
181
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
182
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
183
-				wp_enqueue_script( 'font-awesome-shims' );
184
-			}
185
-		}
186
-
187
-		/**
188
-		 * Get the url of the Font Awesome files.
189
-		 *
190
-		 * @param bool $shims If this is a shim file or not.
191
-		 *
192
-		 * @return string The url to the file.
193
-		 */
194
-		public function get_url( $shims = false ) {
195
-			$script  = $shims ? 'v4-shims' : 'all';
196
-			$sub     = $this->settings['pro'] ? 'pro' : 'use';
197
-			$type    = $this->settings['type'];
198
-			$version = $this->settings['version'];
199
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
200
-			$url     = '';
201
-
202
-			if ( $type == 'KIT' && $kit_url ) {
203
-				if ( $shims ) {
204
-					// if its a kit then we don't add shims here
205
-					return '';
206
-				}
207
-				$url .= $kit_url; // CDN
208
-				$url .= "?wpfas=true"; // set our var so our version is not removed
209
-			} else {
210
-				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
211
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
212
-				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
213
-				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
214
-				$url .= "?wpfas=true"; // set our var so our version is not removed
215
-			}
216
-
217
-			return $url;
218
-		}
219
-
220
-		/**
221
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
222
-		 *
223
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
224
-		 *
225
-		 * @param $url
226
-		 * @param $original_url
227
-		 * @param $_context
228
-		 *
229
-		 * @return string The filtered url.
230
-		 */
231
-		public function remove_font_awesome( $url, $original_url, $_context ) {
232
-
233
-			if ( $_context == 'display'
234
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
235
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
236
-			) {// it's a font-awesome-url (probably)
237
-
238
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
239
-					if ( $this->settings['type'] == 'JS' ) {
240
-						if ( $this->settings['js-pseudo'] ) {
241
-							$url .= "' data-search-pseudo-elements defer='defer";
242
-						} else {
243
-							$url .= "' defer='defer";
244
-						}
245
-					}
246
-				} else {
247
-					$url = ''; // removing the url removes the file
248
-				}
249
-
250
-			}
251
-
252
-			return $url;
253
-		}
254
-
255
-		/**
256
-		 * Register the database settings with WordPress.
257
-		 */
258
-		public function register_settings() {
259
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
260
-		}
261
-
262
-		/**
263
-		 * Add the WordPress settings menu item.
264
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
265
-		 */
266
-		public function menu_item() {
267
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
268
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
269
-				$this,
270
-				'settings_page'
271
-			) );
272
-		}
273
-
274
-		/**
275
-		 * Get the current Font Awesome output settings.
276
-		 *
277
-		 * @return array The array of settings.
278
-		 */
279
-		public function get_settings() {
280
-
281
-			$db_settings = get_option( 'wp-font-awesome-settings' );
282
-
283
-			$defaults = array(
284
-				'type'      => 'CSS', // type to use, CSS or JS or KIT
285
-				'version'   => '', // latest
286
-				'enqueue'   => '', // front and backend
287
-				'shims'     => '0', // default OFF now in 2020
288
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
289
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
290
-				'pro'       => '0', // if pro CDN url should be used
291
-				'kit-url'   => '', // the kit url
292
-			);
293
-
294
-			$settings = wp_parse_args( $db_settings, $defaults );
295
-
296
-			/**
297
-			 * Filter the Font Awesome settings.
298
-			 *
299
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
300
-			 */
301
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
302
-		}
303
-
304
-
305
-		/**
306
-		 * The settings page html output.
307
-		 */
308
-		public function settings_page() {
309
-			if ( ! current_user_can( 'manage_options' ) ) {
310
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
311
-			}
312
-
313
-			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
314
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
315
-				$this->get_latest_version( $force_api = true );
316
-			}
317
-			?>
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     * @since 1.0.10 Now able to pass wp.org theme check.
29
+     * @since 1.0.11 Font Awesome Pro now supported.
30
+     * @since 1.0.11 Font Awesome Kits now supported.
31
+     * @since 1.0.13 RTL language support added.
32
+     * @ver 1.0.13
33
+     * @todo decide how to implement textdomain
34
+     */
35
+    class WP_Font_Awesome_Settings {
36
+
37
+        /**
38
+         * Class version version.
39
+         *
40
+         * @var string
41
+         */
42
+        public $version = '1.0.13';
43
+
44
+        /**
45
+         * Class textdomain.
46
+         *
47
+         * @var string
48
+         */
49
+        public $textdomain = 'font-awesome-settings';
50
+
51
+        /**
52
+         * Latest version of Font Awesome at time of publish published.
53
+         *
54
+         * @var string
55
+         */
56
+        public $latest = "5.8.2";
57
+
58
+        /**
59
+         * The title.
60
+         *
61
+         * @var string
62
+         */
63
+        public $name = 'Font Awesome';
64
+
65
+        /**
66
+         * Holds the settings values.
67
+         *
68
+         * @var array
69
+         */
70
+        private $settings;
71
+
72
+        /**
73
+         * WP_Font_Awesome_Settings instance.
74
+         *
75
+         * @access private
76
+         * @since  1.0.0
77
+         * @var    WP_Font_Awesome_Settings There can be only one!
78
+         */
79
+        private static $instance = null;
80
+
81
+        /**
82
+         * Main WP_Font_Awesome_Settings Instance.
83
+         *
84
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
85
+         *
86
+         * @since 1.0.0
87
+         * @static
88
+         * @return WP_Font_Awesome_Settings - Main instance.
89
+         */
90
+        public static function instance() {
91
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
92
+                self::$instance = new WP_Font_Awesome_Settings;
93
+
94
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
95
+
96
+                if ( is_admin() ) {
97
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
98
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
99
+                }
100
+
101
+                do_action( 'wp_font_awesome_settings_loaded' );
102
+            }
103
+
104
+            return self::$instance;
105
+        }
106
+
107
+        /**
108
+         * Initiate the settings and add the required action hooks.
109
+         *
110
+         * @since 1.0.8 Settings name wrong - FIXED
111
+         */
112
+        public function init() {
113
+            $this->settings = $this->get_settings();
114
+
115
+            if ( $this->settings['type'] == 'CSS' ) {
116
+
117
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
118
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
119
+                }
120
+
121
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
122
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
123
+                }
124
+
125
+            } else {
126
+
127
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
128
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
129
+                }
130
+
131
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
132
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
133
+                }
134
+            }
135
+
136
+            // remove font awesome if set to do so
137
+            if ( $this->settings['dequeue'] == '1' ) {
138
+                add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
139
+            }
140
+
141
+        }
142
+
143
+        /**
144
+         * Adds the Font Awesome styles.
145
+         */
146
+        public function enqueue_style() {
147
+            // build url
148
+            $url = $this->get_url();
149
+
150
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
151
+            wp_register_style( 'font-awesome', $url, array(), null );
152
+            wp_enqueue_style( 'font-awesome' );
153
+
154
+            // RTL language support CSS.
155
+            if ( is_rtl() ) {
156
+                wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
157
+            }
158
+
159
+            if ( $this->settings['shims'] ) {
160
+                $url = $this->get_url( true );
161
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
162
+                wp_register_style( 'font-awesome-shims', $url, array(), null );
163
+                wp_enqueue_style( 'font-awesome-shims' );
164
+            }
165
+        }
166
+
167
+        /**
168
+         * Adds the Font Awesome JS.
169
+         */
170
+        public function enqueue_scripts() {
171
+            // build url
172
+            $url = $this->get_url();
173
+
174
+            $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
175
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
176
+            wp_register_script( 'font-awesome', $url, array(), null );
177
+            wp_enqueue_script( 'font-awesome' );
178
+
179
+            if ( $this->settings['shims'] ) {
180
+                $url = $this->get_url( true );
181
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
182
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
183
+                wp_enqueue_script( 'font-awesome-shims' );
184
+            }
185
+        }
186
+
187
+        /**
188
+         * Get the url of the Font Awesome files.
189
+         *
190
+         * @param bool $shims If this is a shim file or not.
191
+         *
192
+         * @return string The url to the file.
193
+         */
194
+        public function get_url( $shims = false ) {
195
+            $script  = $shims ? 'v4-shims' : 'all';
196
+            $sub     = $this->settings['pro'] ? 'pro' : 'use';
197
+            $type    = $this->settings['type'];
198
+            $version = $this->settings['version'];
199
+            $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
200
+            $url     = '';
201
+
202
+            if ( $type == 'KIT' && $kit_url ) {
203
+                if ( $shims ) {
204
+                    // if its a kit then we don't add shims here
205
+                    return '';
206
+                }
207
+                $url .= $kit_url; // CDN
208
+                $url .= "?wpfas=true"; // set our var so our version is not removed
209
+            } else {
210
+                $url .= "https://$sub.fontawesome.com/releases/"; // CDN
211
+                $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
212
+                $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
213
+                $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
214
+                $url .= "?wpfas=true"; // set our var so our version is not removed
215
+            }
216
+
217
+            return $url;
218
+        }
219
+
220
+        /**
221
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
222
+         *
223
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
224
+         *
225
+         * @param $url
226
+         * @param $original_url
227
+         * @param $_context
228
+         *
229
+         * @return string The filtered url.
230
+         */
231
+        public function remove_font_awesome( $url, $original_url, $_context ) {
232
+
233
+            if ( $_context == 'display'
234
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
235
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
236
+            ) {// it's a font-awesome-url (probably)
237
+
238
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
239
+                    if ( $this->settings['type'] == 'JS' ) {
240
+                        if ( $this->settings['js-pseudo'] ) {
241
+                            $url .= "' data-search-pseudo-elements defer='defer";
242
+                        } else {
243
+                            $url .= "' defer='defer";
244
+                        }
245
+                    }
246
+                } else {
247
+                    $url = ''; // removing the url removes the file
248
+                }
249
+
250
+            }
251
+
252
+            return $url;
253
+        }
254
+
255
+        /**
256
+         * Register the database settings with WordPress.
257
+         */
258
+        public function register_settings() {
259
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
260
+        }
261
+
262
+        /**
263
+         * Add the WordPress settings menu item.
264
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
265
+         */
266
+        public function menu_item() {
267
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
268
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
269
+                $this,
270
+                'settings_page'
271
+            ) );
272
+        }
273
+
274
+        /**
275
+         * Get the current Font Awesome output settings.
276
+         *
277
+         * @return array The array of settings.
278
+         */
279
+        public function get_settings() {
280
+
281
+            $db_settings = get_option( 'wp-font-awesome-settings' );
282
+
283
+            $defaults = array(
284
+                'type'      => 'CSS', // type to use, CSS or JS or KIT
285
+                'version'   => '', // latest
286
+                'enqueue'   => '', // front and backend
287
+                'shims'     => '0', // default OFF now in 2020
288
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
289
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
290
+                'pro'       => '0', // if pro CDN url should be used
291
+                'kit-url'   => '', // the kit url
292
+            );
293
+
294
+            $settings = wp_parse_args( $db_settings, $defaults );
295
+
296
+            /**
297
+             * Filter the Font Awesome settings.
298
+             *
299
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
300
+             */
301
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
302
+        }
303
+
304
+
305
+        /**
306
+         * The settings page html output.
307
+         */
308
+        public function settings_page() {
309
+            if ( ! current_user_can( 'manage_options' ) ) {
310
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
311
+            }
312
+
313
+            // a hidden way to force the update of the version number via api instead of waiting the 48 hours
314
+            if ( isset( $_REQUEST['force-version-check'] ) ) {
315
+                $this->get_latest_version( $force_api = true );
316
+            }
317
+            ?>
318 318
 			<style>
319 319
 				.wpfas-kit-show {
320 320
 					display: none;
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
 				<h1><?php echo esc_html( $this->name ); ?></h1>
333 333
 				<form method="post" action="options.php">
334 334
 					<?php
335
-					settings_fields( 'wp-font-awesome-settings' );
336
-					do_settings_sections( 'wp-font-awesome-settings' );
337
-					$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
338
-					?>
335
+                    settings_fields( 'wp-font-awesome-settings' );
336
+                    do_settings_sections( 'wp-font-awesome-settings' );
337
+                    $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
338
+                    ?>
339 339
 					<table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
340 340
 						<tr valign="top">
341 341
 							<th scope="row"><label
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 								       value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
362 362
 								       placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
363 363
 								<span><?php
364
-									echo sprintf(
365
-										__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
366
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
367
-										'</a>'
368
-									);
369
-									?></span>
364
+                                    echo sprintf(
365
+                                        __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
366
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
367
+                                        '</a>'
368
+                                    );
369
+                                    ?></span>
370 370
 							</td>
371 371
 						</tr>
372 372
 
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
 								<input type="checkbox" name="wp-font-awesome-settings[pro]"
427 427
 								       value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
428 428
 								<span><?php
429
-									echo sprintf(
430
-										__( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
431
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
432
-										'</a>',
433
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
434
-										'</a>'
435
-									);
436
-									?></span>
429
+                                    echo sprintf(
430
+                                        __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
431
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
432
+                                        '</a>',
433
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
434
+                                        '</a>'
435
+                                    );
436
+                                    ?></span>
437 437
 							</td>
438 438
 						</tr>
439 439
 
@@ -476,100 +476,100 @@  discard block
 block discarded – undo
476 476
 
477 477
 					</table>
478 478
 					<?php
479
-					submit_button();
480
-					?>
479
+                    submit_button();
480
+                    ?>
481 481
 				</form>
482 482
 
483 483
 				<div id="wpfas-version"><?php echo esc_html( $this->version ); ?></div>
484 484
 			</div>
485 485
 
486 486
 			<?php
487
-		}
488
-
489
-		/**
490
-		 * Check a version number is valid and if so return it or else return an empty string.
491
-		 *
492
-		 * @param $version string The version number to check.
493
-		 *
494
-		 * @since 1.0.6
495
-		 *
496
-		 * @return string Either a valid version number or an empty string.
497
-		 */
498
-		public function validate_version_number( $version ) {
499
-
500
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
501
-				// valid
502
-			} else {
503
-				$version = '';// not validated
504
-			}
505
-
506
-			return $version;
507
-		}
508
-
509
-
510
-		/**
511
-		 * Get the latest version of Font Awesome.
512
-		 *
513
-		 * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
514
-		 *
515
-		 * @since 1.0.7
516
-		 * @return mixed|string The latest version number found.
517
-		 */
518
-		public function get_latest_version( $force_api = false ) {
519
-			$latest_version = $this->latest;
520
-
521
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
522
-
523
-			if ( $cache === false || $force_api ) { // its not set
524
-				$api_ver = $this->get_latest_version_from_api();
525
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
526
-					$latest_version = $api_ver;
527
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
528
-				}
529
-			} elseif ( $this->validate_version_number( $cache ) ) {
530
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
531
-					$latest_version = $cache;
532
-				}
533
-			}
534
-
535
-			return $latest_version;
536
-		}
537
-
538
-		/**
539
-		 * Get the latest Font Awesome version from the github API.
540
-		 *
541
-		 * @since 1.0.7
542
-		 * @return string The latest version number or `0` on API fail.
543
-		 */
544
-		public function get_latest_version_from_api() {
545
-			$version  = "0";
546
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
547
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
548
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
549
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
550
-					$version = $api_response['tag_name'];
551
-				}
552
-			}
553
-
554
-			return $version;
555
-		}
556
-
557
-		/**
558
-		 * Inline CSS for RTL language support.
559
-		 *
560
-		 * @since 1.0.13
561
-		 * @return string Inline CSS.
562
-		 */
563
-		public function rtl_inline_css() {
564
-			$inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
565
-
566
-			return $inline_css;
567
-		}
568
-
569
-	}
570
-
571
-	/**
572
-	 * Run the class if found.
573
-	 */
574
-	WP_Font_Awesome_Settings::instance();
487
+        }
488
+
489
+        /**
490
+         * Check a version number is valid and if so return it or else return an empty string.
491
+         *
492
+         * @param $version string The version number to check.
493
+         *
494
+         * @since 1.0.6
495
+         *
496
+         * @return string Either a valid version number or an empty string.
497
+         */
498
+        public function validate_version_number( $version ) {
499
+
500
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
501
+                // valid
502
+            } else {
503
+                $version = '';// not validated
504
+            }
505
+
506
+            return $version;
507
+        }
508
+
509
+
510
+        /**
511
+         * Get the latest version of Font Awesome.
512
+         *
513
+         * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
514
+         *
515
+         * @since 1.0.7
516
+         * @return mixed|string The latest version number found.
517
+         */
518
+        public function get_latest_version( $force_api = false ) {
519
+            $latest_version = $this->latest;
520
+
521
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
522
+
523
+            if ( $cache === false || $force_api ) { // its not set
524
+                $api_ver = $this->get_latest_version_from_api();
525
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
526
+                    $latest_version = $api_ver;
527
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
528
+                }
529
+            } elseif ( $this->validate_version_number( $cache ) ) {
530
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
531
+                    $latest_version = $cache;
532
+                }
533
+            }
534
+
535
+            return $latest_version;
536
+        }
537
+
538
+        /**
539
+         * Get the latest Font Awesome version from the github API.
540
+         *
541
+         * @since 1.0.7
542
+         * @return string The latest version number or `0` on API fail.
543
+         */
544
+        public function get_latest_version_from_api() {
545
+            $version  = "0";
546
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
547
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
548
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
549
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
550
+                    $version = $api_response['tag_name'];
551
+                }
552
+            }
553
+
554
+            return $version;
555
+        }
556
+
557
+        /**
558
+         * Inline CSS for RTL language support.
559
+         *
560
+         * @since 1.0.13
561
+         * @return string Inline CSS.
562
+         */
563
+        public function rtl_inline_css() {
564
+            $inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
565
+
566
+            return $inline_css;
567
+        }
568
+
569
+    }
570
+
571
+    /**
572
+     * Run the class if found.
573
+     */
574
+    WP_Font_Awesome_Settings::instance();
575 575
 }
576 576
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -88,17 +88,17 @@  discard block
 block discarded – undo
88 88
 		 * @return WP_Font_Awesome_Settings - Main instance.
89 89
 		 */
90 90
 		public static function instance() {
91
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
91
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
92 92
 				self::$instance = new WP_Font_Awesome_Settings;
93 93
 
94
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
94
+				add_action('init', array(self::$instance, 'init')); // set settings
95 95
 
96
-				if ( is_admin() ) {
97
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
98
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
96
+				if (is_admin()) {
97
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
98
+					add_action('admin_init', array(self::$instance, 'register_settings'));
99 99
 				}
100 100
 
101
-				do_action( 'wp_font_awesome_settings_loaded' );
101
+				do_action('wp_font_awesome_settings_loaded');
102 102
 			}
103 103
 
104 104
 			return self::$instance;
@@ -112,30 +112,30 @@  discard block
 block discarded – undo
112 112
 		public function init() {
113 113
 			$this->settings = $this->get_settings();
114 114
 
115
-			if ( $this->settings['type'] == 'CSS' ) {
115
+			if ($this->settings['type'] == 'CSS') {
116 116
 
117
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
118
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
117
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
118
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000);
119 119
 				}
120 120
 
121
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
122
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
121
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
122
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
123 123
 				}
124 124
 
125 125
 			} else {
126 126
 
127
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
128
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
127
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
128
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
129 129
 				}
130 130
 
131
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
132
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
131
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
132
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
133 133
 				}
134 134
 			}
135 135
 
136 136
 			// remove font awesome if set to do so
137
-			if ( $this->settings['dequeue'] == '1' ) {
138
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
137
+			if ($this->settings['dequeue'] == '1') {
138
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
139 139
 			}
140 140
 
141 141
 		}
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 			// build url
148 148
 			$url = $this->get_url();
149 149
 
150
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
151
-			wp_register_style( 'font-awesome', $url, array(), null );
152
-			wp_enqueue_style( 'font-awesome' );
150
+			wp_deregister_style('font-awesome'); // deregister in case its already there
151
+			wp_register_style('font-awesome', $url, array(), null);
152
+			wp_enqueue_style('font-awesome');
153 153
 
154 154
 			// RTL language support CSS.
155
-			if ( is_rtl() ) {
156
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
155
+			if (is_rtl()) {
156
+				wp_add_inline_style('font-awesome', $this->rtl_inline_css());
157 157
 			}
158 158
 
159
-			if ( $this->settings['shims'] ) {
160
-				$url = $this->get_url( true );
161
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
162
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
163
-				wp_enqueue_style( 'font-awesome-shims' );
159
+			if ($this->settings['shims']) {
160
+				$url = $this->get_url(true);
161
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
162
+				wp_register_style('font-awesome-shims', $url, array(), null);
163
+				wp_enqueue_style('font-awesome-shims');
164 164
 			}
165 165
 		}
166 166
 
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
 			$url = $this->get_url();
173 173
 
174 174
 			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
175
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
176
-			wp_register_script( 'font-awesome', $url, array(), null );
177
-			wp_enqueue_script( 'font-awesome' );
178
-
179
-			if ( $this->settings['shims'] ) {
180
-				$url = $this->get_url( true );
181
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
182
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
183
-				wp_enqueue_script( 'font-awesome-shims' );
175
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
176
+			wp_register_script('font-awesome', $url, array(), null);
177
+			wp_enqueue_script('font-awesome');
178
+
179
+			if ($this->settings['shims']) {
180
+				$url = $this->get_url(true);
181
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
182
+				wp_register_script('font-awesome-shims', $url, array(), null);
183
+				wp_enqueue_script('font-awesome-shims');
184 184
 			}
185 185
 		}
186 186
 
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
 		 *
192 192
 		 * @return string The url to the file.
193 193
 		 */
194
-		public function get_url( $shims = false ) {
194
+		public function get_url($shims = false) {
195 195
 			$script  = $shims ? 'v4-shims' : 'all';
196 196
 			$sub     = $this->settings['pro'] ? 'pro' : 'use';
197 197
 			$type    = $this->settings['type'];
198 198
 			$version = $this->settings['version'];
199
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
199
+			$kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : '';
200 200
 			$url     = '';
201 201
 
202
-			if ( $type == 'KIT' && $kit_url ) {
203
-				if ( $shims ) {
202
+			if ($type == 'KIT' && $kit_url) {
203
+				if ($shims) {
204 204
 					// if its a kit then we don't add shims here
205 205
 					return '';
206 206
 				}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 				$url .= "?wpfas=true"; // set our var so our version is not removed
209 209
 			} else {
210 210
 				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
211
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
211
+				$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
212 212
 				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
213 213
 				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
214 214
 				$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
 		 *
229 229
 		 * @return string The filtered url.
230 230
 		 */
231
-		public function remove_font_awesome( $url, $original_url, $_context ) {
231
+		public function remove_font_awesome($url, $original_url, $_context) {
232 232
 
233
-			if ( $_context == 'display'
234
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
235
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
233
+			if ($_context == 'display'
234
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
235
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
236 236
 			) {// it's a font-awesome-url (probably)
237 237
 
238
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
239
-					if ( $this->settings['type'] == 'JS' ) {
240
-						if ( $this->settings['js-pseudo'] ) {
238
+				if (strstr($url, "wpfas=true") !== false) {
239
+					if ($this->settings['type'] == 'JS') {
240
+						if ($this->settings['js-pseudo']) {
241 241
 							$url .= "' data-search-pseudo-elements defer='defer";
242 242
 						} else {
243 243
 							$url .= "' defer='defer";
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		 * Register the database settings with WordPress.
257 257
 		 */
258 258
 		public function register_settings() {
259
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
259
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
260 260
 		}
261 261
 
262 262
 		/**
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 		 */
266 266
 		public function menu_item() {
267 267
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
268
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
268
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
269 269
 				$this,
270 270
 				'settings_page'
271
-			) );
271
+			));
272 272
 		}
273 273
 
274 274
 		/**
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		 */
279 279
 		public function get_settings() {
280 280
 
281
-			$db_settings = get_option( 'wp-font-awesome-settings' );
281
+			$db_settings = get_option('wp-font-awesome-settings');
282 282
 
283 283
 			$defaults = array(
284 284
 				'type'      => 'CSS', // type to use, CSS or JS or KIT
@@ -291,14 +291,14 @@  discard block
 block discarded – undo
291 291
 				'kit-url'   => '', // the kit url
292 292
 			);
293 293
 
294
-			$settings = wp_parse_args( $db_settings, $defaults );
294
+			$settings = wp_parse_args($db_settings, $defaults);
295 295
 
296 296
 			/**
297 297
 			 * Filter the Font Awesome settings.
298 298
 			 *
299 299
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
300 300
 			 */
301
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
301
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
302 302
 		}
303 303
 
304 304
 
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 		 * The settings page html output.
307 307
 		 */
308 308
 		public function settings_page() {
309
-			if ( ! current_user_can( 'manage_options' ) ) {
310
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
309
+			if (!current_user_can('manage_options')) {
310
+				wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings'));
311 311
 			}
312 312
 
313 313
 			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
314
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
315
-				$this->get_latest_version( $force_api = true );
314
+			if (isset($_REQUEST['force-version-check'])) {
315
+				$this->get_latest_version($force_api = true);
316 316
 			}
317 317
 			?>
318 318
 			<style>
@@ -329,40 +329,40 @@  discard block
 block discarded – undo
329 329
 				}
330 330
 			</style>
331 331
 			<div class="wrap">
332
-				<h1><?php echo esc_html( $this->name ); ?></h1>
332
+				<h1><?php echo esc_html($this->name); ?></h1>
333 333
 				<form method="post" action="options.php">
334 334
 					<?php
335
-					settings_fields( 'wp-font-awesome-settings' );
336
-					do_settings_sections( 'wp-font-awesome-settings' );
335
+					settings_fields('wp-font-awesome-settings');
336
+					do_settings_sections('wp-font-awesome-settings');
337 337
 					$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
338 338
 					?>
339
-					<table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
339
+					<table class="form-table wpfas-table-settings <?php echo esc_attr($kit_set); ?>">
340 340
 						<tr valign="top">
341 341
 							<th scope="row"><label
342
-									for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
342
+									for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th>
343 343
 							<td>
344 344
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type"
345 345
 								        onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}">
346 346
 									<option
347
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option>
348
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
347
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option>
348
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
349 349
 									<option
350
-										value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option>
350
+										value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option>
351 351
 								</select>
352 352
 							</td>
353 353
 						</tr>
354 354
 
355 355
 						<tr valign="top" class="wpfas-kit-show">
356 356
 							<th scope="row"><label
357
-									for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th>
357
+									for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th>
358 358
 							<td>
359 359
 								<input class="regular-text" id="wpfas-kit-url" type="url"
360 360
 								       name="wp-font-awesome-settings[kit-url]"
361
-								       value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
362
-								       placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
361
+								       value="<?php echo esc_attr($this->settings['kit-url']); ?>"
362
+								       placeholder="<?php echo 'https://kit.font'; echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
363 363
 								<span><?php
364 364
 									echo sprintf(
365
-										__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
365
+										__('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'),
366 366
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
367 367
 										'</a>'
368 368
 									);
@@ -372,31 +372,31 @@  discard block
 block discarded – undo
372 372
 
373 373
 						<tr valign="top" class="wpfas-kit-hide">
374 374
 							<th scope="row"><label
375
-									for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th>
375
+									for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th>
376 376
 							<td>
377 377
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
378 378
 									<option
379
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), esc_html( $this->get_latest_version() ) ); ?>
379
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), esc_html($this->get_latest_version())); ?>
380 380
 									</option>
381
-									<option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>
381
+									<option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>
382 382
 										5.6.0
383 383
 									</option>
384
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
384
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
385 385
 										5.5.0
386 386
 									</option>
387
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
387
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
388 388
 										5.4.0
389 389
 									</option>
390
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
390
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
391 391
 										5.3.0
392 392
 									</option>
393
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
393
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
394 394
 										5.2.0
395 395
 									</option>
396
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
396
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
397 397
 										5.1.0
398 398
 									</option>
399
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
399
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
400 400
 										4.7.1 (CSS only)
401 401
 									</option>
402 402
 								</select>
@@ -405,29 +405,29 @@  discard block
 block discarded – undo
405 405
 
406 406
 						<tr valign="top">
407 407
 							<th scope="row"><label
408
-									for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th>
408
+									for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th>
409 409
 							<td>
410 410
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
411 411
 									<option
412
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option>
412
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option>
413 413
 									<option
414
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option>
414
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option>
415 415
 									<option
416
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option>
416
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option>
417 417
 								</select>
418 418
 							</td>
419 419
 						</tr>
420 420
 
421 421
 						<tr valign="top" class="wpfas-kit-hide">
422 422
 							<th scope="row"><label
423
-									for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th>
423
+									for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th>
424 424
 							<td>
425 425
 								<input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
426 426
 								<input type="checkbox" name="wp-font-awesome-settings[pro]"
427
-								       value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
427
+								       value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro"/>
428 428
 								<span><?php
429 429
 									echo sprintf(
430
-										__( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
430
+										__('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'),
431 431
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
432 432
 										'</a>',
433 433
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
@@ -439,38 +439,38 @@  discard block
 block discarded – undo
439 439
 
440 440
 						<tr valign="top" class="wpfas-kit-hide">
441 441
 							<th scope="row"><label
442
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label>
442
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label>
443 443
 							</th>
444 444
 							<td>
445 445
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
446 446
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
447
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
448
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span>
447
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
448
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span>
449 449
 							</td>
450 450
 						</tr>
451 451
 
452 452
 						<tr valign="top" class="wpfas-kit-hide">
453 453
 							<th scope="row"><label
454
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label>
454
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label>
455 455
 							</th>
456 456
 							<td>
457 457
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
458 458
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
459
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
459
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
460 460
 								       id="wpfas-js-pseudo"/>
461
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span>
461
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span>
462 462
 							</td>
463 463
 						</tr>
464 464
 
465 465
 						<tr valign="top">
466 466
 							<th scope="row"><label
467
-									for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th>
467
+									for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th>
468 468
 							<td>
469 469
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
470 470
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
471
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
471
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
472 472
 								       id="wpfas-dequeue"/>
473
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span>
473
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span>
474 474
 							</td>
475 475
 						</tr>
476 476
 
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 					?>
481 481
 				</form>
482 482
 
483
-				<div id="wpfas-version"><?php echo esc_html( $this->version ); ?></div>
483
+				<div id="wpfas-version"><?php echo esc_html($this->version); ?></div>
484 484
 			</div>
485 485
 
486 486
 			<?php
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 		 *
496 496
 		 * @return string Either a valid version number or an empty string.
497 497
 		 */
498
-		public function validate_version_number( $version ) {
498
+		public function validate_version_number($version) {
499 499
 
500
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
500
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
501 501
 				// valid
502 502
 			} else {
503
-				$version = '';// not validated
503
+				$version = ''; // not validated
504 504
 			}
505 505
 
506 506
 			return $version;
@@ -515,19 +515,19 @@  discard block
 block discarded – undo
515 515
 		 * @since 1.0.7
516 516
 		 * @return mixed|string The latest version number found.
517 517
 		 */
518
-		public function get_latest_version( $force_api = false ) {
518
+		public function get_latest_version($force_api = false) {
519 519
 			$latest_version = $this->latest;
520 520
 
521
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
521
+			$cache = get_transient('wp-font-awesome-settings-version');
522 522
 
523
-			if ( $cache === false || $force_api ) { // its not set
523
+			if ($cache === false || $force_api) { // its not set
524 524
 				$api_ver = $this->get_latest_version_from_api();
525
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
525
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
526 526
 					$latest_version = $api_ver;
527
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
527
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
528 528
 				}
529
-			} elseif ( $this->validate_version_number( $cache ) ) {
530
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
529
+			} elseif ($this->validate_version_number($cache)) {
530
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
531 531
 					$latest_version = $cache;
532 532
 				}
533 533
 			}
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
 		 */
544 544
 		public function get_latest_version_from_api() {
545 545
 			$version  = "0";
546
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
547
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
548
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
549
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
546
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
547
+			if (!is_wp_error($response) && is_array($response)) {
548
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
549
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
550 550
 					$version = $api_response['tag_name'];
551 551
 				}
552 552
 			}
Please login to merge, or discard this patch.