Passed
Push — master ( cc57e9...222a59 )
by Brian
09:42
created
vendor/composer/autoload_static.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,35 +6,35 @@  discard block
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5
8 8
 {
9
-    public static $files = array (
9
+    public static $files = array(
10 10
         'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php',
11 11
         '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php',
12 12
         '42671a413efb740d7040437ff2a982cd' => __DIR__ . '/..' . '/ayecode/wp-super-duper/sd-functions.php',
13 13
     );
14 14
 
15
-    public static $prefixLengthsPsr4 = array (
15
+    public static $prefixLengthsPsr4 = array(
16 16
         'M' => 
17
-        array (
17
+        array(
18 18
             'MaxMind\\Db\\' => 11,
19 19
         ),
20 20
         'C' => 
21
-        array (
21
+        array(
22 22
             'Composer\\Installers\\' => 20,
23 23
         ),
24 24
     );
25 25
 
26
-    public static $prefixDirsPsr4 = array (
26
+    public static $prefixDirsPsr4 = array(
27 27
         'MaxMind\\Db\\' => 
28
-        array (
28
+        array(
29 29
             0 => __DIR__ . '/..' . '/maxmind-db/reader/src/MaxMind/Db',
30 30
         ),
31 31
         'Composer\\Installers\\' => 
32
-        array (
32
+        array(
33 33
             0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
34 34
         ),
35 35
     );
36 36
 
37
-    public static $classMap = array (
37
+    public static $classMap = array(
38 38
         'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php',
39 39
         'AyeCode_Deactivation_Survey' => __DIR__ . '/..' . '/ayecode/wp-deactivation-survey/wp-deactivation-survey.php',
40 40
         'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
     public static function getInitializer(ClassLoader $loader)
45 45
     {
46
-        return \Closure::bind(function () use ($loader) {
46
+        return \Closure::bind(function() use ($loader) {
47 47
             $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4;
48 48
             $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4;
49 49
             $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap;
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +575 added lines, -575 removed lines patch added patch discarded remove patch
@@ -14,90 +14,90 @@  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_send_invoice', array( $this, 'send_customer_invoice' ) );
66
-		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_send_invoice', array( $this, 'send_customer_invoice' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
67 67
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
75
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
76
-		do_action( 'getpaid_init_admin_hooks', $this );
77
-
78
-		// Setup/welcome
79
-		if ( ! empty( $_GET['page'] ) ) {
80
-			switch ( $_GET['page'] ) {
81
-				case 'gp-setup' :
82
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
-					break;
84
-			}
85
-		}
68
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
69
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
75
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
76
+        do_action( 'getpaid_init_admin_hooks', $this );
77
+
78
+        // Setup/welcome
79
+        if ( ! empty( $_GET['page'] ) ) {
80
+            switch ( $_GET['page'] ) {
81
+                case 'gp-setup' :
82
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
+                    break;
84
+            }
85
+        }
86 86
 
87 87
     }
88 88
 
89 89
     /**
90
-	 * Register admin scripts
91
-	 *
92
-	 */
93
-	public function enqeue_scripts() {
90
+     * Register admin scripts
91
+     *
92
+     */
93
+    public function enqeue_scripts() {
94 94
         global $current_screen, $pagenow;
95 95
 
96
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
96
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
98 98
 
99 99
         if ( ! empty( $current_screen->post_type ) ) {
100
-			$page = $current_screen->post_type;
100
+            $page = $current_screen->post_type;
101 101
         }
102 102
 
103 103
         // General styles.
@@ -118,54 +118,54 @@  discard block
 block discarded – undo
118 118
         }
119 119
 
120 120
         // Payment form scripts.
121
-		if ( 'wpi_payment_form' == $page && $editing ) {
121
+        if ( 'wpi_payment_form' == $page && $editing ) {
122 122
             $this->load_payment_form_scripts();
123 123
         }
124 124
 
125
-		if ( $page == 'wpinv-subscriptions' ) {
126
-			wp_enqueue_script( 'postbox' );
127
-		}
125
+        if ( $page == 'wpinv-subscriptions' ) {
126
+            wp_enqueue_script( 'postbox' );
127
+        }
128 128
 
129 129
     }
130 130
 
131 131
     /**
132
-	 * Returns admin js translations.
133
-	 *
134
-	 */
135
-	protected function get_admin_i18() {
132
+     * Returns admin js translations.
133
+     *
134
+     */
135
+    protected function get_admin_i18() {
136 136
         global $post;
137 137
 
138
-		$date_range = array(
139
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
-		);
138
+        $date_range = array(
139
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
+        );
141 141
 
142
-		if ( $date_range['period'] == 'custom' ) {
142
+        if ( $date_range['period'] == 'custom' ) {
143 143
 			
144
-			if ( isset( $_GET['from'] ) ) {
145
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
146
-			}
144
+            if ( isset( $_GET['from'] ) ) {
145
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
146
+            }
147 147
 
148
-			if ( isset( $_GET['to'] ) ) {
149
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
150
-			}
148
+            if ( isset( $_GET['to'] ) ) {
149
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
150
+            }
151 151
 
152
-		}
152
+        }
153 153
 
154 154
         $i18n = array(
155 155
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
156 156
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
157
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
-			'rest_root'                 => esc_url_raw( rest_url() ),
160
-			'date_range'                => $date_range,
157
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
+            'rest_root'                 => esc_url_raw( rest_url() ),
160
+            'date_range'                => $date_range,
161 161
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
162 162
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
163 163
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
164 164
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
165 165
             'tax'                       => wpinv_tax_amount(),
166 166
             'discount'                  => 0,
167
-			'currency_symbol'           => wpinv_currency_symbol(),
168
-			'currency'                  => wpinv_get_currency(),
167
+            'currency_symbol'           => wpinv_currency_symbol(),
168
+            'currency'                  => wpinv_get_currency(),
169 169
             'currency_pos'              => wpinv_currency_position(),
170 170
             'thousand_sep'              => wpinv_thousands_separator(),
171 171
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -185,118 +185,118 @@  discard block
 block discarded – undo
185 185
             'item_description'          => __( 'Item Description', 'invoicing' ),
186 186
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
187 187
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
188
-			'searching'                 => __( 'Searching', 'invoicing' ),
189
-			'loading'                   => __( 'Loading...', 'invoicing' ),
190
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
188
+            'searching'                 => __( 'Searching', 'invoicing' ),
189
+            'loading'                   => __( 'Loading...', 'invoicing' ),
190
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
192 192
         );
193 193
 
194
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
194
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195 195
 
196
-			$invoice              = new WPInv_Invoice( $post );
197
-			$i18n['save_invoice'] = sprintf(
198
-				__( 'Save %s', 'invoicing' ),
199
-				ucfirst( $invoice->get_invoice_quote_type() )
200
-			);
196
+            $invoice              = new WPInv_Invoice( $post );
197
+            $i18n['save_invoice'] = sprintf(
198
+                __( 'Save %s', 'invoicing' ),
199
+                ucfirst( $invoice->get_invoice_quote_type() )
200
+            );
201 201
 
202
-			$i18n['invoice_description'] = sprintf(
203
-				__( '%s Description', 'invoicing' ),
204
-				ucfirst( $invoice->get_invoice_quote_type() )
205
-			);
202
+            $i18n['invoice_description'] = sprintf(
203
+                __( '%s Description', 'invoicing' ),
204
+                ucfirst( $invoice->get_invoice_quote_type() )
205
+            );
206 206
 
207
-		}
208
-		return $i18n;
209
-	}
207
+        }
208
+        return $i18n;
209
+    }
210 210
 
211
-	/**
212
-	 * Change the admin footer text on GetPaid admin pages.
213
-	 *
214
-	 * @since  2.0.0
215
-	 * @param  string $footer_text
216
-	 * @return string
217
-	 */
218
-	public function admin_footer_text( $footer_text ) {
219
-		global $current_screen;
211
+    /**
212
+     * Change the admin footer text on GetPaid admin pages.
213
+     *
214
+     * @since  2.0.0
215
+     * @param  string $footer_text
216
+     * @return string
217
+     */
218
+    public function admin_footer_text( $footer_text ) {
219
+        global $current_screen;
220 220
 
221
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
221
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222 222
 
223 223
         if ( ! empty( $current_screen->post_type ) ) {
224
-			$page = $current_screen->post_type;
224
+            $page = $current_screen->post_type;
225 225
         }
226 226
 
227 227
         // General styles.
228 228
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
229 229
 
230
-			// Change the footer text
231
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
-
233
-				$rating_url  = esc_url(
234
-					wp_nonce_url(
235
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
-						'getpaid-nonce',
237
-						'getpaid-nonce'
238
-						)
239
-				);
240
-
241
-				$footer_text = sprintf(
242
-					/* translators: %s: five stars */
243
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
245
-				);
246
-
247
-			} else {
248
-
249
-				$footer_text = sprintf(
250
-					/* translators: %s: GetPaid */
251
-					__( 'Thank you for using %s!', 'invoicing' ),
252
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
253
-				);
254
-
255
-			}
256
-
257
-		}
258
-
259
-		return $footer_text;
260
-	}
261
-
262
-	/**
263
-	 * Redirects to wp.org to rate the plugin.
264
-	 *
265
-	 * @since  2.0.0
266
-	 */
267
-	public function redirect_to_wordpress_rating_page() {
268
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
-		exit;
271
-	}
272
-
273
-    /**
274
-	 * Loads payment form js.
275
-	 *
276
-	 */
277
-	protected function load_payment_form_scripts() {
230
+            // Change the footer text
231
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
+
233
+                $rating_url  = esc_url(
234
+                    wp_nonce_url(
235
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
+                        'getpaid-nonce',
237
+                        'getpaid-nonce'
238
+                        )
239
+                );
240
+
241
+                $footer_text = sprintf(
242
+                    /* translators: %s: five stars */
243
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
245
+                );
246
+
247
+            } else {
248
+
249
+                $footer_text = sprintf(
250
+                    /* translators: %s: GetPaid */
251
+                    __( 'Thank you for using %s!', 'invoicing' ),
252
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
253
+                );
254
+
255
+            }
256
+
257
+        }
258
+
259
+        return $footer_text;
260
+    }
261
+
262
+    /**
263
+     * Redirects to wp.org to rate the plugin.
264
+     *
265
+     * @since  2.0.0
266
+     */
267
+    public function redirect_to_wordpress_rating_page() {
268
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
+        exit;
271
+    }
272
+
273
+    /**
274
+     * Loads payment form js.
275
+     *
276
+     */
277
+    protected function load_payment_form_scripts() {
278 278
         global $post;
279 279
 
280 280
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
281
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
283 283
 
284
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
-		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 );
284
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
+        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 286
 
287
-		wp_localize_script(
287
+        wp_localize_script(
288 288
             'wpinv-admin-payment-form-script',
289 289
             'wpinvPaymentFormAdmin',
290 290
             array(
291
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
-				'currency'      => wpinv_currency_symbol(),
294
-				'position'      => wpinv_currency_position(),
295
-				'decimals'      => (int) wpinv_decimals(),
296
-				'thousands_sep' => wpinv_thousands_separator(),
297
-				'decimals_sep'  => wpinv_decimal_separator(),
298
-				'form_items'    => gepaid_get_form_items( $post->ID ),
299
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
291
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
+                'currency'      => wpinv_currency_symbol(),
294
+                'position'      => wpinv_currency_position(),
295
+                'decimals'      => (int) wpinv_decimals(),
296
+                'thousands_sep' => wpinv_thousands_separator(),
297
+                'decimals_sep'  => wpinv_decimal_separator(),
298
+                'form_items'    => gepaid_get_form_items( $post->ID ),
299
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
300 300
             )
301 301
         );
302 302
 
@@ -305,20 +305,20 @@  discard block
 block discarded – undo
305 305
     }
306 306
 
307 307
     /**
308
-	 * Add our classes to admin pages.
308
+     * Add our classes to admin pages.
309 309
      *
310 310
      * @param string $classes
311 311
      * @return string
312
-	 *
313
-	 */
312
+     *
313
+     */
314 314
     public function admin_body_class( $classes ) {
315
-		global $pagenow, $post, $current_screen;
315
+        global $pagenow, $post, $current_screen;
316 316
 
317 317
 
318 318
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
319 319
 
320 320
         if ( ! empty( $current_screen->post_type ) ) {
321
-			$page = $current_screen->post_type;
321
+            $page = $current_screen->post_type;
322 322
         }
323 323
 
324 324
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -327,68 +327,68 @@  discard block
 block discarded – undo
327 327
 
328 328
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
329 329
             $classes .= ' wpinv-cpt wpinv';
330
-		}
330
+        }
331 331
 		
332
-		if ( getpaid_is_invoice_post_type( $page ) ) {
332
+        if ( getpaid_is_invoice_post_type( $page ) ) {
333 333
             $classes .= ' getpaid-is-invoice-cpt';
334 334
         }
335 335
 
336
-		return $classes;
336
+        return $classes;
337 337
     }
338 338
 
339 339
     /**
340
-	 * Maybe show the AyeCode Connect Notice.
341
-	 */
342
-	public function init_ayecode_connect_helper(){
340
+     * Maybe show the AyeCode Connect Notice.
341
+     */
342
+    public function init_ayecode_connect_helper(){
343 343
 
344
-		// Register with the deactivation survey class.
345
-		AyeCode_Deactivation_Survey::instance(array(
346
-			'slug'		        => 'invoicing',
347
-			'version'	        => WPINV_VERSION,
348
-			'support_url'       => 'https://wpgetpaid.com/support/',
349
-			'documentation_url' => 'https://docs.wpgetpaid.com/',
350
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
-		));
344
+        // Register with the deactivation survey class.
345
+        AyeCode_Deactivation_Survey::instance(array(
346
+            'slug'		        => 'invoicing',
347
+            'version'	        => WPINV_VERSION,
348
+            'support_url'       => 'https://wpgetpaid.com/support/',
349
+            'documentation_url' => 'https://docs.wpgetpaid.com/',
350
+            'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
+        ));
352 352
 
353 353
         new AyeCode_Connect_Helper(
354 354
             array(
355
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
356
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
357
-				'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>" ),
358
-				'connect_button'    => __("Connect Site","invoicing"),
359
-				'connecting_button'    => __("Connecting...","invoicing"),
360
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
361
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
355
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
356
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
357
+                '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>" ),
358
+                'connect_button'    => __("Connect Site","invoicing"),
359
+                'connecting_button'    => __("Connecting...","invoicing"),
360
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
361
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
362 362
             ),
363 363
             array( 'wpi-addons' )
364 364
         );
365 365
 
366 366
     }
367 367
 
368
-	/**
369
-	 * Redirect users to settings on activation.
370
-	 *
371
-	 * @return void
372
-	 */
373
-	public function activation_redirect() {
368
+    /**
369
+     * Redirect users to settings on activation.
370
+     *
371
+     * @return void
372
+     */
373
+    public function activation_redirect() {
374 374
 
375
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
375
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
376 376
 
377
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
-			return;
379
-		}
377
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
+            return;
379
+        }
380 380
 
381
-		// Bail if activating from network, or bulk
382
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
-			return;
384
-		}
381
+        // Bail if activating from network, or bulk
382
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
+            return;
384
+        }
385 385
 
386
-	    update_option( 'wpinv_redirected_to_settings', 1 );
386
+        update_option( 'wpinv_redirected_to_settings', 1 );
387 387
 
388 388
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
389 389
         exit;
390 390
 
391
-	}
391
+    }
392 392
 
393 393
     /**
394 394
      * Fires an admin action after verifying that a user can fire them.
@@ -402,498 +402,498 @@  discard block
 block discarded – undo
402 402
 
403 403
     }
404 404
 
405
-	/**
405
+    /**
406 406
      * Sends a payment reminder to a customer.
407
-	 * 
408
-	 * @param array $args
407
+     * 
408
+     * @param array $args
409 409
      */
410 410
     public function duplicate_payment_form( $args ) {
411 411
 
412
-		if ( empty( $args['form_id'] ) ) {
413
-			return;
414
-		}
415
-
416
-		$form = new GetPaid_Payment_Form( $args['form_id'] );
412
+        if ( empty( $args['form_id'] ) ) {
413
+            return;
414
+        }
417 415
 
418
-		if ( ! $form->exists() ) {
419
-			return;
420
-		}
416
+        $form = new GetPaid_Payment_Form( $args['form_id'] );
421 417
 
422
-		$new_form = new GetPaid_Payment_Form();
423
-		$new_form->set_author( $form->get_author( 'edit' ) );
424
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
425
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
426
-		$new_form->set_items( $form->get_items( 'edit' ) );
427
-		$new_form->save();
418
+        if ( ! $form->exists() ) {
419
+            return;
420
+        }
428 421
 
429
-		if ( $new_form->exists() ) {
430
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
431
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
432
-		} else {
433
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
434
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
435
-		}
422
+        $new_form = new GetPaid_Payment_Form();
423
+        $new_form->set_author( $form->get_author( 'edit' ) );
424
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
425
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
426
+        $new_form->set_items( $form->get_items( 'edit' ) );
427
+        $new_form->save();
428
+
429
+        if ( $new_form->exists() ) {
430
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
431
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
432
+        } else {
433
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
434
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
435
+        }
436 436
 
437
-		wp_redirect( $url );
438
-		exit;
439
-	}
437
+        wp_redirect( $url );
438
+        exit;
439
+    }
440 440
 
441
-	/**
441
+    /**
442 442
      * Sends a payment reminder to a customer.
443
-	 * 
444
-	 * @param array $args
443
+     * 
444
+     * @param array $args
445 445
      */
446 446
     public function send_customer_invoice( $args ) {
447
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
447
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
448 448
 
449
-		if ( $sent ) {
450
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
451
-		} else {
452
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
453
-		}
449
+        if ( $sent ) {
450
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
451
+        } else {
452
+            $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
453
+        }
454 454
 
455
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
456
-		exit;
457
-	}
455
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
456
+        exit;
457
+    }
458 458
 
459
-	/**
459
+    /**
460 460
      * Sends a payment reminder to a customer.
461
-	 * 
462
-	 * @param array $args
461
+     * 
462
+     * @param array $args
463 463
      */
464 464
     public function send_customer_payment_reminder( $args ) {
465
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
465
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
466 466
 
467
-		if ( $sent ) {
468
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
469
-		} else {
470
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
471
-		}
467
+        if ( $sent ) {
468
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
469
+        } else {
470
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
471
+        }
472 472
 
473
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
474
-		exit;
475
-	}
473
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
474
+        exit;
475
+    }
476 476
 
477
-	/**
477
+    /**
478 478
      * Resets tax rates.
479
-	 * 
479
+     * 
480 480
      */
481 481
     public function admin_reset_tax_rates() {
482 482
 
483
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
484
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
485
-		exit;
483
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
484
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
485
+        exit;
486 486
 
487
-	}
487
+    }
488 488
 
489
-	/**
489
+    /**
490 490
      * Resets admin pages.
491
-	 * 
491
+     * 
492 492
      */
493 493
     public function admin_create_missing_pages() {
494
-		$installer = new GetPaid_Installer();
495
-		$installer->create_pages();
496
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
497
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
498
-		exit;
499
-	}
500
-
501
-	/**
494
+        $installer = new GetPaid_Installer();
495
+        $installer->create_pages();
496
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
497
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
498
+        exit;
499
+    }
500
+
501
+    /**
502 502
      * Creates an missing admin tables.
503
-	 * 
503
+     * 
504 504
      */
505 505
     public function admin_create_missing_tables() {
506
-		global $wpdb;
507
-		$installer = new GetPaid_Installer();
506
+        global $wpdb;
507
+        $installer = new GetPaid_Installer();
508 508
 
509
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
510
-			$installer->create_subscriptions_table();
509
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
510
+            $installer->create_subscriptions_table();
511 511
 
512
-			if ( $wpdb->last_error !== '' ) {
513
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
514
-			}
515
-		}
512
+            if ( $wpdb->last_error !== '' ) {
513
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
514
+            }
515
+        }
516 516
 
517
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
518
-			$installer->create_invoices_table();
517
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
518
+            $installer->create_invoices_table();
519 519
 
520
-			if ( $wpdb->last_error !== '' ) {
521
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
522
-			}
523
-		}
520
+            if ( $wpdb->last_error !== '' ) {
521
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
522
+            }
523
+        }
524 524
 
525
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
526
-			$installer->create_invoice_items_table();
525
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
526
+            $installer->create_invoice_items_table();
527 527
 
528
-			if ( $wpdb->last_error !== '' ) {
529
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
530
-			}
531
-		}
528
+            if ( $wpdb->last_error !== '' ) {
529
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
530
+            }
531
+        }
532 532
 
533
-		if ( ! $this->has_notices() ) {
534
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
535
-		}
533
+        if ( ! $this->has_notices() ) {
534
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
535
+        }
536 536
 
537
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
538
-		exit;
539
-	}
537
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
538
+        exit;
539
+    }
540 540
 
541
-	/**
541
+    /**
542 542
      * Migrates old invoices to the new database tables.
543
-	 * 
543
+     * 
544 544
      */
545 545
     public function admin_migrate_old_invoices() {
546 546
 
547
-		// Migrate the invoices.
548
-		$installer = new GetPaid_Installer();
549
-		$installer->migrate_old_invoices();
547
+        // Migrate the invoices.
548
+        $installer = new GetPaid_Installer();
549
+        $installer->migrate_old_invoices();
550 550
 
551
-		// Show an admin message.
552
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
551
+        // Show an admin message.
552
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
553 553
 
554
-		// Redirect the admin.
555
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
556
-		exit;
554
+        // Redirect the admin.
555
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
556
+        exit;
557 557
 
558
-	}
558
+    }
559 559
 
560
-	/**
560
+    /**
561 561
      * Download customers.
562
-	 * 
562
+     * 
563 563
      */
564 564
     public function admin_download_customers() {
565
-		global $wpdb;
565
+        global $wpdb;
566 566
 
567
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
567
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
568 568
 
569
-		header( "Content-Type:text/csv" );
570
-		header( "Content-Disposition:attachment;filename=customers.csv" );
569
+        header( "Content-Type:text/csv" );
570
+        header( "Content-Disposition:attachment;filename=customers.csv" );
571 571
 
572
-		$post_types = '';
572
+        $post_types = '';
573 573
 
574
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
575
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
576
-		}
574
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
575
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
576
+        }
577 577
 
578
-		$post_types = rtrim( $post_types, ' OR' );
578
+        $post_types = rtrim( $post_types, ' OR' );
579 579
 
580
-		$customers = $wpdb->get_col(
581
-			$wpdb->prepare(
582
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
583
-			)
584
-		);
580
+        $customers = $wpdb->get_col(
581
+            $wpdb->prepare(
582
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
583
+            )
584
+        );
585 585
 
586
-		$columns = array(
587
-			'name'     => __( 'Name', 'invoicing' ),
588
-			'email'    => __( 'Email', 'invoicing' ),
589
-			'country'  => __( 'Country', 'invoicing' ),
590
-			'state'    => __( 'State', 'invoicing' ),
591
-			'city'     => __( 'City', 'invoicing' ),
592
-			'zip'      => __( 'ZIP', 'invoicing' ),
593
-			'address'  => __( 'Address', 'invoicing' ),
594
-			'phone'    => __( 'Phone', 'invoicing' ),
595
-			'company'  => __( 'Company', 'invoicing' ),
596
-			'company_id'  => __( 'Company ID', 'invoicing' ),
597
-			'invoices' => __( 'Invoices', 'invoicing' ),
598
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
599
-			'signup'   => __( 'Date created', 'invoicing' ),
600
-		);
586
+        $columns = array(
587
+            'name'     => __( 'Name', 'invoicing' ),
588
+            'email'    => __( 'Email', 'invoicing' ),
589
+            'country'  => __( 'Country', 'invoicing' ),
590
+            'state'    => __( 'State', 'invoicing' ),
591
+            'city'     => __( 'City', 'invoicing' ),
592
+            'zip'      => __( 'ZIP', 'invoicing' ),
593
+            'address'  => __( 'Address', 'invoicing' ),
594
+            'phone'    => __( 'Phone', 'invoicing' ),
595
+            'company'  => __( 'Company', 'invoicing' ),
596
+            'company_id'  => __( 'Company ID', 'invoicing' ),
597
+            'invoices' => __( 'Invoices', 'invoicing' ),
598
+            'total_raw' => __( 'Total Spend', 'invoicing' ),
599
+            'signup'   => __( 'Date created', 'invoicing' ),
600
+        );
601 601
 
602
-		// Output the csv column headers.
603
-		fputcsv( $output, array_values( $columns ) );
602
+        // Output the csv column headers.
603
+        fputcsv( $output, array_values( $columns ) );
604 604
 
605
-		// Loop through
606
-		$table = new WPInv_Customers_Table();
607
-		foreach ( $customers as $customer_id ) {
605
+        // Loop through
606
+        $table = new WPInv_Customers_Table();
607
+        foreach ( $customers as $customer_id ) {
608 608
 
609
-			$user = get_user_by( 'id', $customer_id );
610
-			$row  = array();
611
-			if ( empty( $user ) ) {
612
-				continue;
613
-			}
609
+            $user = get_user_by( 'id', $customer_id );
610
+            $row  = array();
611
+            if ( empty( $user ) ) {
612
+                continue;
613
+            }
614 614
 
615
-			foreach ( array_keys( $columns ) as $column ) {
615
+            foreach ( array_keys( $columns ) as $column ) {
616 616
 
617
-				$method = 'column_' . $column;
617
+                $method = 'column_' . $column;
618 618
 
619
-				if ( 'name' == $column ) {
620
-					$value = esc_html( $user->display_name );
621
-				} else if( 'email' == $column ) {
622
-					$value = sanitize_email( $user->user_email );
623
-				} else if ( is_callable( array( $table, $method ) ) ) {
624
-					$value = strip_tags( $table->$method( $user ) );
625
-				}
619
+                if ( 'name' == $column ) {
620
+                    $value = esc_html( $user->display_name );
621
+                } else if( 'email' == $column ) {
622
+                    $value = sanitize_email( $user->user_email );
623
+                } else if ( is_callable( array( $table, $method ) ) ) {
624
+                    $value = strip_tags( $table->$method( $user ) );
625
+                }
626 626
 
627
-				if ( empty( $value ) ) {
628
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
629
-				}
627
+                if ( empty( $value ) ) {
628
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
629
+                }
630 630
 
631
-				$row[] = $value;
631
+                $row[] = $value;
632 632
 
633
-			}
633
+            }
634 634
 
635
-			fputcsv( $output, $row );
636
-		}
635
+            fputcsv( $output, $row );
636
+        }
637 637
 
638
-		fclose( $output );
639
-		exit;
638
+        fclose( $output );
639
+        exit;
640 640
 
641
-	}
641
+    }
642 642
 
643
-	/**
643
+    /**
644 644
      * Installs a plugin.
645
-	 *
646
-	 * @param array $data
645
+     *
646
+     * @param array $data
647 647
      */
648 648
     public function admin_install_plugin( $data ) {
649 649
 
650
-		if ( ! empty( $data['plugins'] ) ) {
651
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
652
-			wp_cache_flush();
650
+        if ( ! empty( $data['plugins'] ) ) {
651
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
652
+            wp_cache_flush();
653 653
 
654
-			foreach ( $data['plugins'] as $slug => $file ) {
655
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
656
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
657
-				$installed  = $upgrader->install( $plugin_zip );
654
+            foreach ( $data['plugins'] as $slug => $file ) {
655
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
656
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
657
+                $installed  = $upgrader->install( $plugin_zip );
658 658
 
659
-				if ( ! is_wp_error( $installed ) && $installed ) {
660
-					activate_plugin( $file, '', false, true );
661
-				} else {
662
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
663
-				}
659
+                if ( ! is_wp_error( $installed ) && $installed ) {
660
+                    activate_plugin( $file, '', false, true );
661
+                } else {
662
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
663
+                }
664 664
 
665
-			}
665
+            }
666 666
 
667
-		}
667
+        }
668 668
 
669
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
670
-		wp_safe_redirect( $redirect );
671
-		exit;
669
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
670
+        wp_safe_redirect( $redirect );
671
+        exit;
672 672
 
673
-	}
673
+    }
674 674
 
675
-	/**
675
+    /**
676 676
      * Connects a gateway.
677
-	 *
678
-	 * @param array $data
677
+     *
678
+     * @param array $data
679 679
      */
680 680
     public function admin_connect_gateway( $data ) {
681 681
 
682
-		if ( ! empty( $data['plugin'] ) ) {
682
+        if ( ! empty( $data['plugin'] ) ) {
683 683
 
684
-			$gateway     = sanitize_key( $data['plugin'] );
685
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
684
+            $gateway     = sanitize_key( $data['plugin'] );
685
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
686 686
 
687
-			if ( ! empty( $connect_url ) ) {
688
-				wp_redirect( $connect_url );
689
-				exit;
690
-			}
687
+            if ( ! empty( $connect_url ) ) {
688
+                wp_redirect( $connect_url );
689
+                exit;
690
+            }
691 691
 
692
-			if ( 'stripe' == $data['plugin'] ) {
693
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
694
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
695
-				wp_cache_flush();
692
+            if ( 'stripe' == $data['plugin'] ) {
693
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
694
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
695
+                wp_cache_flush();
696 696
 
697
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
698
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
699
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
700
-					$upgrader->install( $plugin_zip );
701
-				}
697
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
698
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
699
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
700
+                    $upgrader->install( $plugin_zip );
701
+                }
702 702
 
703
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
704
-			}
703
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
704
+            }
705 705
 
706
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
707
-			if ( ! empty( $connect_url ) ) {
708
-				wp_redirect( $connect_url );
709
-				exit;
710
-			}
706
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
707
+            if ( ! empty( $connect_url ) ) {
708
+                wp_redirect( $connect_url );
709
+                exit;
710
+            }
711 711
 
712
-		}
712
+        }
713 713
 
714
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
715
-		wp_safe_redirect( $redirect );
716
-		exit;
714
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
715
+        wp_safe_redirect( $redirect );
716
+        exit;
717 717
 
718
-	}
718
+    }
719 719
 
720
-	/**
720
+    /**
721 721
      * Recalculates discounts.
722
-	 * 
722
+     * 
723 723
      */
724 724
     public function admin_recalculate_discounts() {
725
-		global $wpdb;
725
+        global $wpdb;
726 726
 
727
-		// Fetch all invoices that have discount codes.
728
-		$table    = $wpdb->prefix . 'getpaid_invoices';
729
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
727
+        // Fetch all invoices that have discount codes.
728
+        $table    = $wpdb->prefix . 'getpaid_invoices';
729
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
730 730
 
731
-		foreach ( $invoices as $invoice ) {
731
+        foreach ( $invoices as $invoice ) {
732 732
 
733
-			$invoice = new WPInv_Invoice( $invoice );
733
+            $invoice = new WPInv_Invoice( $invoice );
734 734
 
735
-			if ( ! $invoice->exists() ) {
736
-				continue;
737
-			}
735
+            if ( ! $invoice->exists() ) {
736
+                continue;
737
+            }
738 738
 
739
-			// Abort if the discount does not exist or does not apply here.
740
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
741
-			if ( ! $discount->exists() ) {
742
-				continue;
743
-			}
739
+            // Abort if the discount does not exist or does not apply here.
740
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
741
+            if ( ! $discount->exists() ) {
742
+                continue;
743
+            }
744 744
 
745
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
746
-			$invoice->recalculate_total();
745
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
746
+            $invoice->recalculate_total();
747 747
 
748
-			if ( $invoice->get_total_discount() > 0 ) {
749
-				$invoice->save();
750
-			}
748
+            if ( $invoice->get_total_discount() > 0 ) {
749
+                $invoice->save();
750
+            }
751 751
 
752
-		}
752
+        }
753 753
 
754
-		// Show an admin message.
755
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
754
+        // Show an admin message.
755
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
756 756
 
757
-		// Redirect the admin.
758
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
759
-		exit;
757
+        // Redirect the admin.
758
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
759
+        exit;
760 760
 
761
-	}
761
+    }
762 762
 
763 763
     /**
764
-	 * Returns an array of admin notices.
765
-	 *
766
-	 * @since       1.0.19
764
+     * Returns an array of admin notices.
765
+     *
766
+     * @since       1.0.19
767 767
      * @return array
768
-	 */
769
-	public function get_notices() {
770
-		$notices = get_option( 'wpinv_admin_notices' );
768
+     */
769
+    public function get_notices() {
770
+        $notices = get_option( 'wpinv_admin_notices' );
771 771
         return is_array( $notices ) ? $notices : array();
772
-	}
772
+    }
773 773
 
774
-	/**
775
-	 * Checks if we have any admin notices.
776
-	 *
777
-	 * @since       2.0.4
774
+    /**
775
+     * Checks if we have any admin notices.
776
+     *
777
+     * @since       2.0.4
778 778
      * @return array
779
-	 */
780
-	public function has_notices() {
781
-		return count( $this->get_notices() ) > 0;
782
-	}
783
-
784
-	/**
785
-	 * Clears all admin notices
786
-	 *
787
-	 * @access      public
788
-	 * @since       1.0.19
789
-	 */
790
-	public function clear_notices() {
791
-		delete_option( 'wpinv_admin_notices' );
792
-	}
793
-
794
-	/**
795
-	 * Saves a new admin notice
796
-	 *
797
-	 * @access      public
798
-	 * @since       1.0.19
799
-	 */
800
-	public function save_notice( $type, $message ) {
801
-		$notices = $this->get_notices();
802
-
803
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
804
-			$notices[ $type ] = array();
805
-		}
806
-
807
-		$notices[ $type ][] = $message;
808
-
809
-		update_option( 'wpinv_admin_notices', $notices );
810
-	}
811
-
812
-	/**
813
-	 * Displays a success notice
814
-	 *
815
-	 * @param       string $msg The message to qeue.
816
-	 * @access      public
817
-	 * @since       1.0.19
818
-	 */
819
-	public function show_success( $msg ) {
820
-		$this->save_notice( 'success', $msg );
821
-	}
822
-
823
-	/**
824
-	 * Displays a error notice
825
-	 *
826
-	 * @access      public
827
-	 * @param       string $msg The message to qeue.
828
-	 * @since       1.0.19
829
-	 */
830
-	public function show_error( $msg ) {
831
-		$this->save_notice( 'error', $msg );
832
-	}
833
-
834
-	/**
835
-	 * Displays a warning notice
836
-	 *
837
-	 * @access      public
838
-	 * @param       string $msg The message to qeue.
839
-	 * @since       1.0.19
840
-	 */
841
-	public function show_warning( $msg ) {
842
-		$this->save_notice( 'warning', $msg );
843
-	}
844
-
845
-	/**
846
-	 * Displays a info notice
847
-	 *
848
-	 * @access      public
849
-	 * @param       string $msg The message to qeue.
850
-	 * @since       1.0.19
851
-	 */
852
-	public function show_info( $msg ) {
853
-		$this->save_notice( 'info', $msg );
854
-	}
855
-
856
-	/**
857
-	 * Show notices
858
-	 *
859
-	 * @access      public
860
-	 * @since       1.0.19
861
-	 */
862
-	public function show_notices() {
779
+     */
780
+    public function has_notices() {
781
+        return count( $this->get_notices() ) > 0;
782
+    }
783
+
784
+    /**
785
+     * Clears all admin notices
786
+     *
787
+     * @access      public
788
+     * @since       1.0.19
789
+     */
790
+    public function clear_notices() {
791
+        delete_option( 'wpinv_admin_notices' );
792
+    }
793
+
794
+    /**
795
+     * Saves a new admin notice
796
+     *
797
+     * @access      public
798
+     * @since       1.0.19
799
+     */
800
+    public function save_notice( $type, $message ) {
801
+        $notices = $this->get_notices();
802
+
803
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
804
+            $notices[ $type ] = array();
805
+        }
806
+
807
+        $notices[ $type ][] = $message;
808
+
809
+        update_option( 'wpinv_admin_notices', $notices );
810
+    }
811
+
812
+    /**
813
+     * Displays a success notice
814
+     *
815
+     * @param       string $msg The message to qeue.
816
+     * @access      public
817
+     * @since       1.0.19
818
+     */
819
+    public function show_success( $msg ) {
820
+        $this->save_notice( 'success', $msg );
821
+    }
822
+
823
+    /**
824
+     * Displays a error notice
825
+     *
826
+     * @access      public
827
+     * @param       string $msg The message to qeue.
828
+     * @since       1.0.19
829
+     */
830
+    public function show_error( $msg ) {
831
+        $this->save_notice( 'error', $msg );
832
+    }
833
+
834
+    /**
835
+     * Displays a warning notice
836
+     *
837
+     * @access      public
838
+     * @param       string $msg The message to qeue.
839
+     * @since       1.0.19
840
+     */
841
+    public function show_warning( $msg ) {
842
+        $this->save_notice( 'warning', $msg );
843
+    }
844
+
845
+    /**
846
+     * Displays a info notice
847
+     *
848
+     * @access      public
849
+     * @param       string $msg The message to qeue.
850
+     * @since       1.0.19
851
+     */
852
+    public function show_info( $msg ) {
853
+        $this->save_notice( 'info', $msg );
854
+    }
855
+
856
+    /**
857
+     * Show notices
858
+     *
859
+     * @access      public
860
+     * @since       1.0.19
861
+     */
862
+    public function show_notices() {
863 863
 
864 864
         $notices = $this->get_notices();
865 865
         $this->clear_notices();
866 866
 
867
-		foreach ( $notices as $type => $messages ) {
867
+        foreach ( $notices as $type => $messages ) {
868 868
 
869
-			if ( ! is_array( $messages ) ) {
870
-				continue;
871
-			}
869
+            if ( ! is_array( $messages ) ) {
870
+                continue;
871
+            }
872 872
 
873 873
             $type  = sanitize_key( $type );
874
-			foreach ( $messages as $message ) {
874
+            foreach ( $messages as $message ) {
875 875
                 $message = wp_kses_post( $message );
876
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
876
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
877 877
             }
878 878
 
879 879
         }
880 880
 
881
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
882
-
883
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
884
-				$url     = wp_nonce_url(
885
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
886
-					'getpaid-nonce',
887
-					'getpaid-nonce'
888
-				);
889
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
890
-				$message2 = __( 'Generate Pages', 'invoicing' );
891
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
892
-				break;
893
-			}
881
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
882
+
883
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
884
+                $url     = wp_nonce_url(
885
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
886
+                    'getpaid-nonce',
887
+                    'getpaid-nonce'
888
+                );
889
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
890
+                $message2 = __( 'Generate Pages', 'invoicing' );
891
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
892
+                break;
893
+            }
894 894
 
895
-		}
895
+        }
896 896
 
897
-	}
897
+    }
898 898
 
899 899
 }
Please login to merge, or discard this patch.
Spacing   +270 added lines, -270 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,32 +54,32 @@  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_send_invoice', array( $this, 'send_customer_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
67
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
75
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
76
-		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_send_invoice', array($this, 'send_customer_invoice'));
66
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
67
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
68
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
69
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
70
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
71
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
72
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
73
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
74
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
75
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
76
+		do_action('getpaid_init_admin_hooks', $this);
77 77
 
78 78
 		// Setup/welcome
79
-		if ( ! empty( $_GET['page'] ) ) {
80
-			switch ( $_GET['page'] ) {
79
+		if (!empty($_GET['page'])) {
80
+			switch ($_GET['page']) {
81 81
 				case 'gp-setup' :
82
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
82
+					include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');
83 83
 					break;
84 84
 			}
85 85
 		}
@@ -93,37 +93,37 @@  discard block
 block discarded – undo
93 93
 	public function enqeue_scripts() {
94 94
         global $current_screen, $pagenow;
95 95
 
96
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
96
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
97 97
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
98 98
 
99
-        if ( ! empty( $current_screen->post_type ) ) {
99
+        if (!empty($current_screen->post_type)) {
100 100
 			$page = $current_screen->post_type;
101 101
         }
102 102
 
103 103
         // General styles.
104
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page ) {
104
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page) {
105 105
 
106 106
             // Styles.
107
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
108
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
109
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
107
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
108
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
109
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
110 110
 
111 111
             // Scripts.
112
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
112
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
113 113
 
114
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
115
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ),  $version );
116
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
114
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
115
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
116
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
117 117
 
118 118
         }
119 119
 
120 120
         // Payment form scripts.
121
-		if ( 'wpi_payment_form' == $page && $editing ) {
121
+		if ('wpi_payment_form' == $page && $editing) {
122 122
             $this->load_payment_form_scripts();
123 123
         }
124 124
 
125
-		if ( $page == 'wpinv-subscriptions' ) {
126
-			wp_enqueue_script( 'postbox' );
125
+		if ($page == 'wpinv-subscriptions') {
126
+			wp_enqueue_script('postbox');
127 127
 		}
128 128
 
129 129
     }
@@ -136,32 +136,32 @@  discard block
 block discarded – undo
136 136
         global $post;
137 137
 
138 138
 		$date_range = array(
139
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
139
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
140 140
 		);
141 141
 
142
-		if ( $date_range['period'] == 'custom' ) {
142
+		if ($date_range['period'] == 'custom') {
143 143
 			
144
-			if ( isset( $_GET['from'] ) ) {
145
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
144
+			if (isset($_GET['from'])) {
145
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
146 146
 			}
147 147
 
148
-			if ( isset( $_GET['to'] ) ) {
149
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
148
+			if (isset($_GET['to'])) {
149
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
150 150
 			}
151 151
 
152 152
 		}
153 153
 
154 154
         $i18n = array(
155
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
156
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
157
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
-			'rest_root'                 => esc_url_raw( rest_url() ),
155
+            'ajax_url'                  => admin_url('admin-ajax.php'),
156
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
157
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
158
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
159
+			'rest_root'                 => esc_url_raw(rest_url()),
160 160
 			'date_range'                => $date_range,
161
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
162
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
163
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
164
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
161
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
162
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
163
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
164
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
165 165
             'tax'                       => wpinv_tax_amount(),
166 166
             'discount'                  => 0,
167 167
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -170,38 +170,38 @@  discard block
 block discarded – undo
170 170
             'thousand_sep'              => wpinv_thousands_separator(),
171 171
             'decimal_sep'               => wpinv_decimal_separator(),
172 172
             'decimals'                  => wpinv_decimals(),
173
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
174
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
175
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
176
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
177
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
178
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
179
-            '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' ),
180
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
181
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
182
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
183
-            'action_edit'               => __( 'Edit', 'invoicing' ),
184
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
185
-            'item_description'          => __( 'Item Description', 'invoicing' ),
186
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
187
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
188
-			'searching'                 => __( 'Searching', 'invoicing' ),
189
-			'loading'                   => __( 'Loading...', 'invoicing' ),
190
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
173
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
174
+            'status_publish'            => wpinv_status_nicename('publish'),
175
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
176
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
177
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
178
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
179
+            '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'),
180
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
181
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
182
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
183
+            'action_edit'               => __('Edit', 'invoicing'),
184
+            'action_cancel'             => __('Cancel', 'invoicing'),
185
+            'item_description'          => __('Item Description', 'invoicing'),
186
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
187
+            'discount_description'      => __('Discount Description', 'invoicing'),
188
+			'searching'                 => __('Searching', 'invoicing'),
189
+			'loading'                   => __('Loading...', 'invoicing'),
190
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
191
+			'search_items'              => __('Enter item name', 'invoicing'),
192 192
         );
193 193
 
194
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
194
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
195 195
 
196
-			$invoice              = new WPInv_Invoice( $post );
196
+			$invoice              = new WPInv_Invoice($post);
197 197
 			$i18n['save_invoice'] = sprintf(
198
-				__( 'Save %s', 'invoicing' ),
199
-				ucfirst( $invoice->get_invoice_quote_type() )
198
+				__('Save %s', 'invoicing'),
199
+				ucfirst($invoice->get_invoice_quote_type())
200 200
 			);
201 201
 
202 202
 			$i18n['invoice_description'] = sprintf(
203
-				__( '%s Description', 'invoicing' ),
204
-				ucfirst( $invoice->get_invoice_quote_type() )
203
+				__('%s Description', 'invoicing'),
204
+				ucfirst($invoice->get_invoice_quote_type())
205 205
 			);
206 206
 
207 207
 		}
@@ -215,24 +215,24 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $footer_text
216 216
 	 * @return string
217 217
 	 */
218
-	public function admin_footer_text( $footer_text ) {
218
+	public function admin_footer_text($footer_text) {
219 219
 		global $current_screen;
220 220
 
221
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
221
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
222 222
 
223
-        if ( ! empty( $current_screen->post_type ) ) {
223
+        if (!empty($current_screen->post_type)) {
224 224
 			$page = $current_screen->post_type;
225 225
         }
226 226
 
227 227
         // General styles.
228
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
228
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
229 229
 
230 230
 			// Change the footer text
231
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
231
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
232 232
 
233
-				$rating_url  = esc_url(
233
+				$rating_url = esc_url(
234 234
 					wp_nonce_url(
235
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
235
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
236 236
 						'getpaid-nonce',
237 237
 						'getpaid-nonce'
238 238
 						)
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
 				$footer_text = sprintf(
242 242
 					/* translators: %s: five stars */
243
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
243
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
244 244
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
245 245
 				);
246 246
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 				$footer_text = sprintf(
250 250
 					/* translators: %s: GetPaid */
251
-					__( 'Thank you for using %s!', 'invoicing' ),
251
+					__('Thank you for using %s!', 'invoicing'),
252 252
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
253 253
 				);
254 254
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 * @since  2.0.0
266 266
 	 */
267 267
 	public function redirect_to_wordpress_rating_page() {
268
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
268
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
269
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
270 270
 		exit;
271 271
 	}
272 272
 
@@ -277,30 +277,30 @@  discard block
 block discarded – undo
277 277
 	protected function load_payment_form_scripts() {
278 278
         global $post;
279 279
 
280
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
280
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION);
281
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
282
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
283 283
 
284
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
-		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 );
284
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
285
+		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 286
 
287 287
 		wp_localize_script(
288 288
             'wpinv-admin-payment-form-script',
289 289
             'wpinvPaymentFormAdmin',
290 290
             array(
291
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
291
+				'elements'      => wpinv_get_data('payment-form-elements'),
292
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
293 293
 				'currency'      => wpinv_currency_symbol(),
294 294
 				'position'      => wpinv_currency_position(),
295 295
 				'decimals'      => (int) wpinv_decimals(),
296 296
 				'thousands_sep' => wpinv_thousands_separator(),
297 297
 				'decimals_sep'  => wpinv_decimal_separator(),
298
-				'form_items'    => gepaid_get_form_items( $post->ID ),
298
+				'form_items'    => gepaid_get_form_items($post->ID),
299 299
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
300 300
             )
301 301
         );
302 302
 
303
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
303
+        wp_enqueue_script('wpinv-admin-payment-form-script');
304 304
 
305 305
     }
306 306
 
@@ -311,25 +311,25 @@  discard block
 block discarded – undo
311 311
      * @return string
312 312
 	 *
313 313
 	 */
314
-    public function admin_body_class( $classes ) {
314
+    public function admin_body_class($classes) {
315 315
 		global $pagenow, $post, $current_screen;
316 316
 
317 317
 
318
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
318
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
319 319
 
320
-        if ( ! empty( $current_screen->post_type ) ) {
320
+        if (!empty($current_screen->post_type)) {
321 321
 			$page = $current_screen->post_type;
322 322
         }
323 323
 
324
-        if ( false !== stripos( $page, 'wpi' ) ) {
325
-            $classes .= ' wpi-' . sanitize_key( $page );
324
+        if (false !== stripos($page, 'wpi')) {
325
+            $classes .= ' wpi-' . sanitize_key($page);
326 326
         }
327 327
 
328
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
328
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
329 329
             $classes .= ' wpinv-cpt wpinv';
330 330
 		}
331 331
 		
332
-		if ( getpaid_is_invoice_post_type( $page ) ) {
332
+		if (getpaid_is_invoice_post_type($page)) {
333 333
             $classes .= ' getpaid-is-invoice-cpt';
334 334
         }
335 335
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
     /**
340 340
 	 * Maybe show the AyeCode Connect Notice.
341 341
 	 */
342
-	public function init_ayecode_connect_helper(){
342
+	public function init_ayecode_connect_helper() {
343 343
 
344 344
 		// Register with the deactivation survey class.
345 345
 		AyeCode_Deactivation_Survey::instance(array(
@@ -347,20 +347,20 @@  discard block
 block discarded – undo
347 347
 			'version'	        => WPINV_VERSION,
348 348
 			'support_url'       => 'https://wpgetpaid.com/support/',
349 349
 			'documentation_url' => 'https://docs.wpgetpaid.com/',
350
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
350
+			'activated'         => (int) get_option('gepaid_installed_on'),
351 351
 		));
352 352
 
353 353
         new AyeCode_Connect_Helper(
354 354
             array(
355
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
356
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
357
-				'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>" ),
358
-				'connect_button'    => __("Connect Site","invoicing"),
359
-				'connecting_button'    => __("Connecting...","invoicing"),
360
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
361
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
355
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
356
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
357
+				'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>"),
358
+				'connect_button'    => __("Connect Site", "invoicing"),
359
+				'connecting_button'    => __("Connecting...", "invoicing"),
360
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
361
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
362 362
             ),
363
-            array( 'wpi-addons' )
363
+            array('wpi-addons')
364 364
         );
365 365
 
366 366
     }
@@ -372,20 +372,20 @@  discard block
 block discarded – undo
372 372
 	 */
373 373
 	public function activation_redirect() {
374 374
 
375
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
375
+		$redirected = get_option('wpinv_redirected_to_settings');
376 376
 
377
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
377
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
378 378
 			return;
379 379
 		}
380 380
 
381 381
 		// Bail if activating from network, or bulk
382
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
382
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
383 383
 			return;
384 384
 		}
385 385
 
386
-	    update_option( 'wpinv_redirected_to_settings', 1 );
386
+	    update_option('wpinv_redirected_to_settings', 1);
387 387
 
388
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
388
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
389 389
         exit;
390 390
 
391 391
 	}
@@ -395,9 +395,9 @@  discard block
 block discarded – undo
395 395
      */
396 396
     public function maybe_do_admin_action() {
397 397
 
398
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
399
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
400
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
398
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
399
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
400
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
401 401
         }
402 402
 
403 403
     }
@@ -407,34 +407,34 @@  discard block
 block discarded – undo
407 407
 	 * 
408 408
 	 * @param array $args
409 409
      */
410
-    public function duplicate_payment_form( $args ) {
410
+    public function duplicate_payment_form($args) {
411 411
 
412
-		if ( empty( $args['form_id'] ) ) {
412
+		if (empty($args['form_id'])) {
413 413
 			return;
414 414
 		}
415 415
 
416
-		$form = new GetPaid_Payment_Form( $args['form_id'] );
416
+		$form = new GetPaid_Payment_Form($args['form_id']);
417 417
 
418
-		if ( ! $form->exists() ) {
418
+		if (!$form->exists()) {
419 419
 			return;
420 420
 		}
421 421
 
422 422
 		$new_form = new GetPaid_Payment_Form();
423
-		$new_form->set_author( $form->get_author( 'edit' ) );
424
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
425
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
426
-		$new_form->set_items( $form->get_items( 'edit' ) );
423
+		$new_form->set_author($form->get_author('edit'));
424
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
425
+		$new_form->set_elements($form->get_elements('edit'));
426
+		$new_form->set_items($form->get_items('edit'));
427 427
 		$new_form->save();
428 428
 
429
-		if ( $new_form->exists() ) {
430
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
431
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
429
+		if ($new_form->exists()) {
430
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
431
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
432 432
 		} else {
433
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
434
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
433
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
434
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
435 435
 		}
436 436
 
437
-		wp_redirect( $url );
437
+		wp_redirect($url);
438 438
 		exit;
439 439
 	}
440 440
 
@@ -443,16 +443,16 @@  discard block
 block discarded – undo
443 443
 	 * 
444 444
 	 * @param array $args
445 445
      */
446
-    public function send_customer_invoice( $args ) {
447
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
446
+    public function send_customer_invoice($args) {
447
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
448 448
 
449
-		if ( $sent ) {
450
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
449
+		if ($sent) {
450
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
451 451
 		} else {
452
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
452
+			$this->show_error(__('Could not send the invoice to the customer', 'invoicing'));
453 453
 		}
454 454
 
455
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
455
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
456 456
 		exit;
457 457
 	}
458 458
 
@@ -461,16 +461,16 @@  discard block
 block discarded – undo
461 461
 	 * 
462 462
 	 * @param array $args
463 463
      */
464
-    public function send_customer_payment_reminder( $args ) {
465
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
464
+    public function send_customer_payment_reminder($args) {
465
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
466 466
 
467
-		if ( $sent ) {
468
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
467
+		if ($sent) {
468
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
469 469
 		} else {
470
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
470
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
471 471
 		}
472 472
 
473
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
473
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
474 474
 		exit;
475 475
 	}
476 476
 
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
      */
481 481
     public function admin_reset_tax_rates() {
482 482
 
483
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
484
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
483
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
484
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
485 485
 		exit;
486 486
 
487 487
 	}
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
     public function admin_create_missing_pages() {
494 494
 		$installer = new GetPaid_Installer();
495 495
 		$installer->create_pages();
496
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
497
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
496
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
497
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
498 498
 		exit;
499 499
 	}
500 500
 
@@ -506,35 +506,35 @@  discard block
 block discarded – undo
506 506
 		global $wpdb;
507 507
 		$installer = new GetPaid_Installer();
508 508
 
509
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
509
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
510 510
 			$installer->create_subscriptions_table();
511 511
 
512
-			if ( $wpdb->last_error !== '' ) {
513
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
512
+			if ($wpdb->last_error !== '') {
513
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
514 514
 			}
515 515
 		}
516 516
 
517
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
517
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
518 518
 			$installer->create_invoices_table();
519 519
 
520
-			if ( $wpdb->last_error !== '' ) {
521
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
520
+			if ($wpdb->last_error !== '') {
521
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
522 522
 			}
523 523
 		}
524 524
 
525
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
525
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
526 526
 			$installer->create_invoice_items_table();
527 527
 
528
-			if ( $wpdb->last_error !== '' ) {
529
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
528
+			if ($wpdb->last_error !== '') {
529
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
530 530
 			}
531 531
 		}
532 532
 
533
-		if ( ! $this->has_notices() ) {
534
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
533
+		if (!$this->has_notices()) {
534
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
535 535
 		}
536 536
 
537
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
537
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
538 538
 		exit;
539 539
 	}
540 540
 
@@ -549,10 +549,10 @@  discard block
 block discarded – undo
549 549
 		$installer->migrate_old_invoices();
550 550
 
551 551
 		// Show an admin message.
552
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
552
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
553 553
 
554 554
 		// Redirect the admin.
555
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
555
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
556 556
 		exit;
557 557
 
558 558
 	}
@@ -564,18 +564,18 @@  discard block
 block discarded – undo
564 564
     public function admin_download_customers() {
565 565
 		global $wpdb;
566 566
 
567
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
567
+		$output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing'));
568 568
 
569
-		header( "Content-Type:text/csv" );
570
-		header( "Content-Disposition:attachment;filename=customers.csv" );
569
+		header("Content-Type:text/csv");
570
+		header("Content-Disposition:attachment;filename=customers.csv");
571 571
 
572 572
 		$post_types = '';
573 573
 
574
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
575
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
574
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
575
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
576 576
 		}
577 577
 
578
-		$post_types = rtrim( $post_types, ' OR' );
578
+		$post_types = rtrim($post_types, ' OR');
579 579
 
580 580
 		$customers = $wpdb->get_col(
581 581
 			$wpdb->prepare(
@@ -584,58 +584,58 @@  discard block
 block discarded – undo
584 584
 		);
585 585
 
586 586
 		$columns = array(
587
-			'name'     => __( 'Name', 'invoicing' ),
588
-			'email'    => __( 'Email', 'invoicing' ),
589
-			'country'  => __( 'Country', 'invoicing' ),
590
-			'state'    => __( 'State', 'invoicing' ),
591
-			'city'     => __( 'City', 'invoicing' ),
592
-			'zip'      => __( 'ZIP', 'invoicing' ),
593
-			'address'  => __( 'Address', 'invoicing' ),
594
-			'phone'    => __( 'Phone', 'invoicing' ),
595
-			'company'  => __( 'Company', 'invoicing' ),
596
-			'company_id'  => __( 'Company ID', 'invoicing' ),
597
-			'invoices' => __( 'Invoices', 'invoicing' ),
598
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
599
-			'signup'   => __( 'Date created', 'invoicing' ),
587
+			'name'     => __('Name', 'invoicing'),
588
+			'email'    => __('Email', 'invoicing'),
589
+			'country'  => __('Country', 'invoicing'),
590
+			'state'    => __('State', 'invoicing'),
591
+			'city'     => __('City', 'invoicing'),
592
+			'zip'      => __('ZIP', 'invoicing'),
593
+			'address'  => __('Address', 'invoicing'),
594
+			'phone'    => __('Phone', 'invoicing'),
595
+			'company'  => __('Company', 'invoicing'),
596
+			'company_id'  => __('Company ID', 'invoicing'),
597
+			'invoices' => __('Invoices', 'invoicing'),
598
+			'total_raw' => __('Total Spend', 'invoicing'),
599
+			'signup'   => __('Date created', 'invoicing'),
600 600
 		);
601 601
 
602 602
 		// Output the csv column headers.
603
-		fputcsv( $output, array_values( $columns ) );
603
+		fputcsv($output, array_values($columns));
604 604
 
605 605
 		// Loop through
606 606
 		$table = new WPInv_Customers_Table();
607
-		foreach ( $customers as $customer_id ) {
607
+		foreach ($customers as $customer_id) {
608 608
 
609
-			$user = get_user_by( 'id', $customer_id );
609
+			$user = get_user_by('id', $customer_id);
610 610
 			$row  = array();
611
-			if ( empty( $user ) ) {
611
+			if (empty($user)) {
612 612
 				continue;
613 613
 			}
614 614
 
615
-			foreach ( array_keys( $columns ) as $column ) {
615
+			foreach (array_keys($columns) as $column) {
616 616
 
617 617
 				$method = 'column_' . $column;
618 618
 
619
-				if ( 'name' == $column ) {
620
-					$value = esc_html( $user->display_name );
621
-				} else if( 'email' == $column ) {
622
-					$value = sanitize_email( $user->user_email );
623
-				} else if ( is_callable( array( $table, $method ) ) ) {
624
-					$value = strip_tags( $table->$method( $user ) );
619
+				if ('name' == $column) {
620
+					$value = esc_html($user->display_name);
621
+				} else if ('email' == $column) {
622
+					$value = sanitize_email($user->user_email);
623
+				} else if (is_callable(array($table, $method))) {
624
+					$value = strip_tags($table->$method($user));
625 625
 				}
626 626
 
627
-				if ( empty( $value ) ) {
628
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
627
+				if (empty($value)) {
628
+					$value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));
629 629
 				}
630 630
 
631 631
 				$row[] = $value;
632 632
 
633 633
 			}
634 634
 
635
-			fputcsv( $output, $row );
635
+			fputcsv($output, $row);
636 636
 		}
637 637
 
638
-		fclose( $output );
638
+		fclose($output);
639 639
 		exit;
640 640
 
641 641
 	}
@@ -645,29 +645,29 @@  discard block
 block discarded – undo
645 645
 	 *
646 646
 	 * @param array $data
647 647
      */
648
-    public function admin_install_plugin( $data ) {
648
+    public function admin_install_plugin($data) {
649 649
 
650
-		if ( ! empty( $data['plugins'] ) ) {
650
+		if (!empty($data['plugins'])) {
651 651
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
652 652
 			wp_cache_flush();
653 653
 
654
-			foreach ( $data['plugins'] as $slug => $file ) {
655
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
656
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
657
-				$installed  = $upgrader->install( $plugin_zip );
654
+			foreach ($data['plugins'] as $slug => $file) {
655
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
656
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
657
+				$installed  = $upgrader->install($plugin_zip);
658 658
 
659
-				if ( ! is_wp_error( $installed ) && $installed ) {
660
-					activate_plugin( $file, '', false, true );
659
+				if (!is_wp_error($installed) && $installed) {
660
+					activate_plugin($file, '', false, true);
661 661
 				} else {
662
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
662
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
663 663
 				}
664 664
 
665 665
 			}
666 666
 
667 667
 		}
668 668
 
669
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
670
-		wp_safe_redirect( $redirect );
669
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
670
+		wp_safe_redirect($redirect);
671 671
 		exit;
672 672
 
673 673
 	}
@@ -677,42 +677,42 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @param array $data
679 679
      */
680
-    public function admin_connect_gateway( $data ) {
680
+    public function admin_connect_gateway($data) {
681 681
 
682
-		if ( ! empty( $data['plugin'] ) ) {
682
+		if (!empty($data['plugin'])) {
683 683
 
684
-			$gateway     = sanitize_key( $data['plugin'] );
685
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
684
+			$gateway     = sanitize_key($data['plugin']);
685
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
686 686
 
687
-			if ( ! empty( $connect_url ) ) {
688
-				wp_redirect( $connect_url );
687
+			if (!empty($connect_url)) {
688
+				wp_redirect($connect_url);
689 689
 				exit;
690 690
 			}
691 691
 
692
-			if ( 'stripe' == $data['plugin'] ) {
692
+			if ('stripe' == $data['plugin']) {
693 693
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
694 694
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
695 695
 				wp_cache_flush();
696 696
 
697
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
698
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
699
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
700
-					$upgrader->install( $plugin_zip );
697
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
698
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
699
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
700
+					$upgrader->install($plugin_zip);
701 701
 				}
702 702
 
703
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
703
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
704 704
 			}
705 705
 
706
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
707
-			if ( ! empty( $connect_url ) ) {
708
-				wp_redirect( $connect_url );
706
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
707
+			if (!empty($connect_url)) {
708
+				wp_redirect($connect_url);
709 709
 				exit;
710 710
 			}
711 711
 
712 712
 		}
713 713
 
714
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
715
-		wp_safe_redirect( $redirect );
714
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
715
+		wp_safe_redirect($redirect);
716 716
 		exit;
717 717
 
718 718
 	}
@@ -726,36 +726,36 @@  discard block
 block discarded – undo
726 726
 
727 727
 		// Fetch all invoices that have discount codes.
728 728
 		$table    = $wpdb->prefix . 'getpaid_invoices';
729
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
729
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
730 730
 
731
-		foreach ( $invoices as $invoice ) {
731
+		foreach ($invoices as $invoice) {
732 732
 
733
-			$invoice = new WPInv_Invoice( $invoice );
733
+			$invoice = new WPInv_Invoice($invoice);
734 734
 
735
-			if ( ! $invoice->exists() ) {
735
+			if (!$invoice->exists()) {
736 736
 				continue;
737 737
 			}
738 738
 
739 739
 			// Abort if the discount does not exist or does not apply here.
740
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
741
-			if ( ! $discount->exists() ) {
740
+			$discount = new WPInv_Discount($invoice->get_discount_code());
741
+			if (!$discount->exists()) {
742 742
 				continue;
743 743
 			}
744 744
 
745
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
745
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
746 746
 			$invoice->recalculate_total();
747 747
 
748
-			if ( $invoice->get_total_discount() > 0 ) {
748
+			if ($invoice->get_total_discount() > 0) {
749 749
 				$invoice->save();
750 750
 			}
751 751
 
752 752
 		}
753 753
 
754 754
 		// Show an admin message.
755
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
755
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
756 756
 
757 757
 		// Redirect the admin.
758
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
758
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
759 759
 		exit;
760 760
 
761 761
 	}
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
      * @return array
768 768
 	 */
769 769
 	public function get_notices() {
770
-		$notices = get_option( 'wpinv_admin_notices' );
771
-        return is_array( $notices ) ? $notices : array();
770
+		$notices = get_option('wpinv_admin_notices');
771
+        return is_array($notices) ? $notices : array();
772 772
 	}
773 773
 
774 774
 	/**
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
      * @return array
779 779
 	 */
780 780
 	public function has_notices() {
781
-		return count( $this->get_notices() ) > 0;
781
+		return count($this->get_notices()) > 0;
782 782
 	}
783 783
 
784 784
 	/**
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	 * @since       1.0.19
789 789
 	 */
790 790
 	public function clear_notices() {
791
-		delete_option( 'wpinv_admin_notices' );
791
+		delete_option('wpinv_admin_notices');
792 792
 	}
793 793
 
794 794
 	/**
@@ -797,16 +797,16 @@  discard block
 block discarded – undo
797 797
 	 * @access      public
798 798
 	 * @since       1.0.19
799 799
 	 */
800
-	public function save_notice( $type, $message ) {
800
+	public function save_notice($type, $message) {
801 801
 		$notices = $this->get_notices();
802 802
 
803
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
804
-			$notices[ $type ] = array();
803
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
804
+			$notices[$type] = array();
805 805
 		}
806 806
 
807
-		$notices[ $type ][] = $message;
807
+		$notices[$type][] = $message;
808 808
 
809
-		update_option( 'wpinv_admin_notices', $notices );
809
+		update_option('wpinv_admin_notices', $notices);
810 810
 	}
811 811
 
812 812
 	/**
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
 	 * @access      public
817 817
 	 * @since       1.0.19
818 818
 	 */
819
-	public function show_success( $msg ) {
820
-		$this->save_notice( 'success', $msg );
819
+	public function show_success($msg) {
820
+		$this->save_notice('success', $msg);
821 821
 	}
822 822
 
823 823
 	/**
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 	 * @param       string $msg The message to qeue.
828 828
 	 * @since       1.0.19
829 829
 	 */
830
-	public function show_error( $msg ) {
831
-		$this->save_notice( 'error', $msg );
830
+	public function show_error($msg) {
831
+		$this->save_notice('error', $msg);
832 832
 	}
833 833
 
834 834
 	/**
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 	 * @param       string $msg The message to qeue.
839 839
 	 * @since       1.0.19
840 840
 	 */
841
-	public function show_warning( $msg ) {
842
-		$this->save_notice( 'warning', $msg );
841
+	public function show_warning($msg) {
842
+		$this->save_notice('warning', $msg);
843 843
 	}
844 844
 
845 845
 	/**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 * @param       string $msg The message to qeue.
850 850
 	 * @since       1.0.19
851 851
 	 */
852
-	public function show_info( $msg ) {
853
-		$this->save_notice( 'info', $msg );
852
+	public function show_info($msg) {
853
+		$this->save_notice('info', $msg);
854 854
 	}
855 855
 
856 856
 	/**
@@ -864,30 +864,30 @@  discard block
 block discarded – undo
864 864
         $notices = $this->get_notices();
865 865
         $this->clear_notices();
866 866
 
867
-		foreach ( $notices as $type => $messages ) {
867
+		foreach ($notices as $type => $messages) {
868 868
 
869
-			if ( ! is_array( $messages ) ) {
869
+			if (!is_array($messages)) {
870 870
 				continue;
871 871
 			}
872 872
 
873
-            $type  = sanitize_key( $type );
874
-			foreach ( $messages as $message ) {
875
-                $message = wp_kses_post( $message );
873
+            $type = sanitize_key($type);
874
+			foreach ($messages as $message) {
875
+                $message = wp_kses_post($message);
876 876
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
877 877
             }
878 878
 
879 879
         }
880 880
 
881
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
881
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
882 882
 
883
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
884
-				$url     = wp_nonce_url(
885
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
883
+			if (!is_numeric(wpinv_get_option($page, false))) {
884
+				$url = wp_nonce_url(
885
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
886 886
 					'getpaid-nonce',
887 887
 					'getpaid-nonce'
888 888
 				);
889
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
890
-				$message2 = __( 'Generate Pages', 'invoicing' );
889
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
890
+				$message2 = __('Generate Pages', 'invoicing');
891 891
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
892 892
 				break;
893 893
 			}
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/wp-deactivation-survey.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,103 +1,103 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
8 8
 
9
-	class AyeCode_Deactivation_Survey {
9
+    class AyeCode_Deactivation_Survey {
10 10
 
11
-		/**
12
-		 * AyeCode_Deactivation_Survey instance.
13
-		 *
14
-		 * @access private
15
-		 * @since  1.0.0
16
-		 * @var    AyeCode_Deactivation_Survey There can be only one!
17
-		 */
18
-		private static $instance = null;
11
+        /**
12
+         * AyeCode_Deactivation_Survey instance.
13
+         *
14
+         * @access private
15
+         * @since  1.0.0
16
+         * @var    AyeCode_Deactivation_Survey There can be only one!
17
+         */
18
+        private static $instance = null;
19 19
 
20
-		public static $plugins;
20
+        public static $plugins;
21 21
 
22
-		public $version = "1.0.4";
22
+        public $version = "1.0.4";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
-				self::$instance = new AyeCode_Deactivation_Survey;
27
-				self::$plugins = array();
24
+        public static function instance( $plugin = array() ) {
25
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
+                self::$instance = new AyeCode_Deactivation_Survey;
27
+                self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+                add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
32
-			}
31
+                do_action( 'ayecode_deactivation_survey_loaded' );
32
+            }
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
36
-			}
34
+            if(!empty($plugin)){
35
+                self::$plugins[] = (object)$plugin;
36
+            }
37 37
 
38
-			return self::$instance;
39
-		}
38
+            return self::$instance;
39
+        }
40 40
 
41
-		public function scripts() {
42
-			global $pagenow;
41
+        public function scripts() {
42
+            global $pagenow;
43 43
 
44
-			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
46
-				return;
47
-			}
44
+            // Bail if we are not on the plugins page
45
+            if ( $pagenow != "plugins.php" ) {
46
+                return;
47
+            }
48 48
 
49
-			// Enqueue scripts
50
-			add_thickbox();
51
-			wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
49
+            // Enqueue scripts
50
+            add_thickbox();
51
+            wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
52 52
 
53
-			/*
53
+            /*
54 54
 			 * Localized strings. Strings can be localised by plugins using this class.
55 55
 			 * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review.
56 56
 			 */
57
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
-				'quick_feedback'			=> 'Quick Feedback',
59
-				'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
-				'better_plugins_name'		=> 'Please tell us which plugin?',
61
-				'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
-				'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
-				'brief_description'			=> 'Please give us any feedback that could help us improve',
64
-				'cancel'					=> 'Cancel',
65
-				'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
-				'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
-				'please_wait'				=> 'Please wait',
68
-				'get_support'				=> 'Get Support',
69
-				'documentation'				=> 'Documentation',
70
-				'thank_you'					=> 'Thank you!',
71
-			));
72
-
73
-			// Plugins
74
-			$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
-
76
-			// Reasons
77
-			$defaultReasons = array(
78
-				'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
-				'plugin-broke-site'			=> 'The plugin broke my site',
80
-				'plugin-setup-difficult'	=> 'Too difficult to setup',
81
-				'plugin-design-difficult'	=> 'Too difficult to get the design i want',
82
-				'no-longer-needed'			=> 'I don\'t need this plugin any more',
83
-				'found-better-plugin'		=> 'I found a better plugin',
84
-				'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
85
-				'other'						=> 'Other',
86
-			);
87
-
88
-			foreach($plugins as $plugin)
89
-			{
90
-				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91
-				$plugin->url = home_url();
92
-				$plugin->activated = 0;
93
-			}
94
-
95
-			// Send plugin data
96
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
97
-
98
-		}
57
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
+                'quick_feedback'			=> 'Quick Feedback',
59
+                'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
+                'better_plugins_name'		=> 'Please tell us which plugin?',
61
+                'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
+                'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
+                'brief_description'			=> 'Please give us any feedback that could help us improve',
64
+                'cancel'					=> 'Cancel',
65
+                'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
+                'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
+                'please_wait'				=> 'Please wait',
68
+                'get_support'				=> 'Get Support',
69
+                'documentation'				=> 'Documentation',
70
+                'thank_you'					=> 'Thank you!',
71
+            ));
72
+
73
+            // Plugins
74
+            $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
+
76
+            // Reasons
77
+            $defaultReasons = array(
78
+                'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
+                'plugin-broke-site'			=> 'The plugin broke my site',
80
+                'plugin-setup-difficult'	=> 'Too difficult to setup',
81
+                'plugin-design-difficult'	=> 'Too difficult to get the design i want',
82
+                'no-longer-needed'			=> 'I don\'t need this plugin any more',
83
+                'found-better-plugin'		=> 'I found a better plugin',
84
+                'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
85
+                'other'						=> 'Other',
86
+            );
87
+
88
+            foreach($plugins as $plugin)
89
+            {
90
+                $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91
+                $plugin->url = home_url();
92
+                $plugin->activated = 0;
93
+            }
94
+
95
+            // Send plugin data
96
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
97
+
98
+        }
99 99
 		
100 100
 
101
-	}
101
+    }
102 102
 
103 103
 }
104 104
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
7
+if (!class_exists('AyeCode_Deactivation_Survey')) {
8 8
 
9 9
 	class AyeCode_Deactivation_Survey {
10 10
 
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
 
22 22
 		public $version = "1.0.4";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
24
+		public static function instance($plugin = array()) {
25
+			if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_Deactivation_Survey)) {
26 26
 				self::$instance = new AyeCode_Deactivation_Survey;
27 27
 				self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+				add_action('admin_enqueue_scripts', array(self::$instance, 'scripts'));
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
31
+				do_action('ayecode_deactivation_survey_loaded');
32 32
 			}
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
34
+			if (!empty($plugin)) {
35
+				self::$plugins[] = (object) $plugin;
36 36
 			}
37 37
 
38 38
 			return self::$instance;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			global $pagenow;
43 43
 
44 44
 			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
45
+			if ($pagenow != "plugins.php") {
46 46
 				return;
47 47
 			}
48 48
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				'other'						=> 'Other',
86 86
 			);
87 87
 
88
-			foreach($plugins as $plugin)
88
+			foreach ($plugins as $plugin)
89 89
 			{
90 90
 				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91 91
 				$plugin->url = home_url();
Please login to merge, or discard this patch.
includes/payments/class-getpaid-form-item.php 2 patches
Indentation   +359 added lines, -359 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,67 +10,67 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Form_Item  extends WPInv_Item {
11 11
 
12 12
     /**
13
-	 * Stores a custom description for the item.
14
-	 *
15
-	 * @var string
16
-	 */
17
-	protected $custom_description = null;
18
-
19
-	/**
20
-	 * Stores the item quantity.
21
-	 *
22
-	 * @var float
23
-	 */
24
-	protected $quantity = 1;
25
-
26
-	/**
27
-	 * Stores the item meta.
28
-	 *
29
-	 * @var array
30
-	 */
31
-	protected $meta = array();
32
-
33
-	/**
34
-	 * Is this item required?
35
-	 *
36
-	 * @var int
37
-	 */
38
-	protected $is_required = true;
39
-
40
-	/**
41
-	 * Are quantities allowed?
42
-	 *
43
-	 * @var int
44
-	 */
45
-	protected $allow_quantities = false;
46
-
47
-	/**
48
-	 * Associated invoice.
49
-	 *
50
-	 * @var int
51
-	 */
52
-	public $invoice_id = 0;
53
-
54
-	/**
55
-	 * Item discount.
56
-	 *
57
-	 * @var float
58
-	 */
59
-	public $item_discount = 0;
60
-
61
-	/**
62
-	 * Recurring item discount.
63
-	 *
64
-	 * @var float
65
-	 */
66
-	public $recurring_item_discount = 0;
67
-
68
-	/**
69
-	 * Item tax.
70
-	 *
71
-	 * @var float
72
-	 */
73
-	public $item_tax = 0;
13
+     * Stores a custom description for the item.
14
+     *
15
+     * @var string
16
+     */
17
+    protected $custom_description = null;
18
+
19
+    /**
20
+     * Stores the item quantity.
21
+     *
22
+     * @var float
23
+     */
24
+    protected $quantity = 1;
25
+
26
+    /**
27
+     * Stores the item meta.
28
+     *
29
+     * @var array
30
+     */
31
+    protected $meta = array();
32
+
33
+    /**
34
+     * Is this item required?
35
+     *
36
+     * @var int
37
+     */
38
+    protected $is_required = true;
39
+
40
+    /**
41
+     * Are quantities allowed?
42
+     *
43
+     * @var int
44
+     */
45
+    protected $allow_quantities = false;
46
+
47
+    /**
48
+     * Associated invoice.
49
+     *
50
+     * @var int
51
+     */
52
+    public $invoice_id = 0;
53
+
54
+    /**
55
+     * Item discount.
56
+     *
57
+     * @var float
58
+     */
59
+    public $item_discount = 0;
60
+
61
+    /**
62
+     * Recurring item discount.
63
+     *
64
+     * @var float
65
+     */
66
+    public $recurring_item_discount = 0;
67
+
68
+    /**
69
+     * Item tax.
70
+     *
71
+     * @var float
72
+     */
73
+    public $item_tax = 0;
74 74
 
75 75
     /*
76 76
 	|--------------------------------------------------------------------------
@@ -88,230 +88,230 @@  discard block
 block discarded – undo
88 88
     */
89 89
 
90 90
     /**
91
-	 * Get the item name.
92
-	 *
93
-	 * @since 1.0.19
94
-	 * @param  string $context View or edit context.
95
-	 * @return string
96
-	 */
97
-	public function get_name( $context = 'view' ) {
98
-		$name = parent::get_name( $context );
99
-		return $name . wpinv_get_item_suffix( $this );
100
-	}
101
-
102
-	/**
103
-	 * Get the item name without a suffix.
104
-	 *
105
-	 * @since 1.0.19
106
-	 * @param  string $context View or edit context.
107
-	 * @return string
108
-	 */
109
-	public function get_raw_name( $context = 'view' ) {
110
-		return parent::get_name( $context );
111
-	}
112
-
113
-	/**
114
-	 * Get the item description.
115
-	 *
116
-	 * @since 1.0.19
117
-	 * @param  string $context View or edit context.
118
-	 * @return string
119
-	 */
120
-	public function get_description( $context = 'view' ) {
121
-
122
-		if ( isset( $this->custom_description ) ) {
123
-			return $this->custom_description;
124
-		}
125
-
126
-		return parent::get_description( $context );
127
-	}
128
-
129
-	/**
130
-	 * Returns the sub total.
131
-	 *
132
-	 * @since 1.0.19
133
-	 * @param  string $context View or edit context.
134
-	 * @return float
135
-	 */
136
-	public function get_sub_total( $context = 'view' ) {
137
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context );
138
-	}
139
-
140
-	/**
141
-	 * Returns the recurring sub total.
142
-	 *
143
-	 * @since 1.0.19
144
-	 * @param  string $context View or edit context.
145
-	 * @return float
146
-	 */
147
-	public function get_recurring_sub_total( $context = 'view' ) {
148
-
149
-		if ( $this->is_recurring() ) {
150
-			return $this->get_quantity( $context ) * $this->get_price( $context );
151
-		}
152
-
153
-		return 0;
154
-	}
155
-
156
-	/**
157
-	 * @deprecated
158
-	 */
159
-	public function get_qantity( $context = 'view' ) {
160
-		return $this->get_quantity( $context );
161
-	}
162
-
163
-	/**
164
-	 * Get the item quantity.
165
-	 *
166
-	 * @since 1.0.19
167
-	 * @param  string $context View or edit context.
168
-	 * @return float
169
-	 */
170
-	public function get_quantity( $context = 'view' ) {
171
-		$quantity = (float) $this->quantity;
172
-
173
-		if ( 'view' == $context ) {
174
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
175
-		}
176
-
177
-		return $quantity;
178
-
179
-	}
180
-
181
-	/**
182
-	 * Get the item meta data.
183
-	 *
184
-	 * @since 1.0.19
185
-	 * @param  string $context View or edit context.
186
-	 * @return meta
187
-	 */
188
-	public function get_item_meta( $context = 'view' ) {
189
-		$meta = $this->meta;
190
-
191
-		if ( 'view' == $context ) {
192
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
193
-		}
194
-
195
-		return $meta;
196
-
197
-	}
198
-
199
-	/**
200
-	 * Returns whether or not customers can update the item quantity.
201
-	 *
202
-	 * @since 1.0.19
203
-	 * @param  string $context View or edit context.
204
-	 * @return bool
205
-	 */
206
-	public function get_allow_quantities( $context = 'view' ) {
207
-		$allow_quantities = (bool) $this->allow_quantities;
208
-
209
-		if ( 'view' == $context ) {
210
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
211
-		}
212
-
213
-		return $allow_quantities;
214
-
215
-	}
216
-
217
-	/**
218
-	 * Returns whether or not the item is required.
219
-	 *
220
-	 * @since 1.0.19
221
-	 * @param  string $context View or edit context.
222
-	 * @return bool
223
-	 */
224
-	public function get_is_required( $context = 'view' ) {
225
-		$is_required = (bool) $this->is_required;
226
-
227
-		if ( 'view' == $context ) {
228
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
229
-		}
230
-
231
-		return $is_required;
232
-
233
-	}
234
-
235
-	/**
236
-	 * Prepares form data for use.
237
-	 *
238
-	 * @since 1.0.19
239
-	 * @return array
240
-	 */
241
-	public function prepare_data_for_use( $required = null ) {
242
-
243
-		$required = is_null( $required ) ? $this->is_required() : $required;
244
-		return array(
245
-			'title'            => strip_tags( $this->get_name() ),
246
-			'id'               => $this->get_id(),
247
-			'price'            => $this->get_price(),
248
-			'recurring'        => $this->is_recurring(),
249
-			'description'      => $this->get_description(),
250
-			'allow_quantities' => $this->allows_quantities(),
251
-			'required'         => $required,
252
-		);
253
-
254
-	}
255
-
256
-	/**
257
-	 * Prepares form data for ajax use.
258
-	 *
259
-	 * @since 1.0.19
260
-	 * @return array
261
-	 */
262
-	public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
263
-
264
-		$description = getpaid_item_recurring_price_help_text( $this, $currency );
265
-
266
-		if ( $description ) {
267
-			$description = "<div class='getpaid-subscription-help-text'>$description</div>";
268
-		}
269
-
270
-		$price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
271
-		$subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
272
-		return array(
273
-			'id'     => $this->get_id(),
274
-			'texts'  => array(
275
-				'item-name'        => sanitize_text_field( $this->get_name() ),
276
-				'item-description' => wp_kses_post( $this->get_description() ) . $description,
277
-				'item-quantity'    => floatval( $this->get_quantity() ),
278
-				'item-price'       => wpinv_price( $price, $currency ),
279
-				'item-total'       => wpinv_price( $subtotal, $currency ),
280
-			),
281
-			'inputs' => array(
282
-				'item-id'          => $this->get_id(),
283
-				'item-name'        => sanitize_text_field( $this->get_name() ),
284
-				'item-description' => wp_kses_post( $this->get_description() ),
285
-				'item-quantity'    => floatval( $this->get_quantity() ),
286
-				'item-price'       => $price,
287
-			)
288
-		);
289
-
290
-	}
291
-
292
-	/**
293
-	 * Prepares form data for saving (cart_details).
294
-	 *
295
-	 * @since 1.0.19
296
-	 * @return array
297
-	 */
298
-	public function prepare_data_for_saving() {
299
-
300
-		return array(
301
-			'post_id'           => $this->invoice_id,
302
-			'item_id'           => $this->get_id(),
303
-			'item_name'         => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
304
-			'item_description'  => $this->get_description( 'edit' ),
305
-			'tax'               => $this->item_tax,
306
-			'item_price'        => $this->get_price( 'edit' ),
307
-			'quantity'          => (float) $this->get_quantity( 'edit' ),
308
-			'discount'          => $this->item_discount,
309
-			'subtotal'          => $this->get_sub_total( 'edit' ),
310
-			'price'             => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
311
-			'meta'              => $this->get_item_meta( 'edit' ),
312
-		);
313
-
314
-	}
91
+     * Get the item name.
92
+     *
93
+     * @since 1.0.19
94
+     * @param  string $context View or edit context.
95
+     * @return string
96
+     */
97
+    public function get_name( $context = 'view' ) {
98
+        $name = parent::get_name( $context );
99
+        return $name . wpinv_get_item_suffix( $this );
100
+    }
101
+
102
+    /**
103
+     * Get the item name without a suffix.
104
+     *
105
+     * @since 1.0.19
106
+     * @param  string $context View or edit context.
107
+     * @return string
108
+     */
109
+    public function get_raw_name( $context = 'view' ) {
110
+        return parent::get_name( $context );
111
+    }
112
+
113
+    /**
114
+     * Get the item description.
115
+     *
116
+     * @since 1.0.19
117
+     * @param  string $context View or edit context.
118
+     * @return string
119
+     */
120
+    public function get_description( $context = 'view' ) {
121
+
122
+        if ( isset( $this->custom_description ) ) {
123
+            return $this->custom_description;
124
+        }
125
+
126
+        return parent::get_description( $context );
127
+    }
128
+
129
+    /**
130
+     * Returns the sub total.
131
+     *
132
+     * @since 1.0.19
133
+     * @param  string $context View or edit context.
134
+     * @return float
135
+     */
136
+    public function get_sub_total( $context = 'view' ) {
137
+        return $this->get_quantity( $context ) * $this->get_initial_price( $context );
138
+    }
139
+
140
+    /**
141
+     * Returns the recurring sub total.
142
+     *
143
+     * @since 1.0.19
144
+     * @param  string $context View or edit context.
145
+     * @return float
146
+     */
147
+    public function get_recurring_sub_total( $context = 'view' ) {
148
+
149
+        if ( $this->is_recurring() ) {
150
+            return $this->get_quantity( $context ) * $this->get_price( $context );
151
+        }
152
+
153
+        return 0;
154
+    }
155
+
156
+    /**
157
+     * @deprecated
158
+     */
159
+    public function get_qantity( $context = 'view' ) {
160
+        return $this->get_quantity( $context );
161
+    }
162
+
163
+    /**
164
+     * Get the item quantity.
165
+     *
166
+     * @since 1.0.19
167
+     * @param  string $context View or edit context.
168
+     * @return float
169
+     */
170
+    public function get_quantity( $context = 'view' ) {
171
+        $quantity = (float) $this->quantity;
172
+
173
+        if ( 'view' == $context ) {
174
+            return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
175
+        }
176
+
177
+        return $quantity;
178
+
179
+    }
180
+
181
+    /**
182
+     * Get the item meta data.
183
+     *
184
+     * @since 1.0.19
185
+     * @param  string $context View or edit context.
186
+     * @return meta
187
+     */
188
+    public function get_item_meta( $context = 'view' ) {
189
+        $meta = $this->meta;
190
+
191
+        if ( 'view' == $context ) {
192
+            return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
193
+        }
194
+
195
+        return $meta;
196
+
197
+    }
198
+
199
+    /**
200
+     * Returns whether or not customers can update the item quantity.
201
+     *
202
+     * @since 1.0.19
203
+     * @param  string $context View or edit context.
204
+     * @return bool
205
+     */
206
+    public function get_allow_quantities( $context = 'view' ) {
207
+        $allow_quantities = (bool) $this->allow_quantities;
208
+
209
+        if ( 'view' == $context ) {
210
+            return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
211
+        }
212
+
213
+        return $allow_quantities;
214
+
215
+    }
216
+
217
+    /**
218
+     * Returns whether or not the item is required.
219
+     *
220
+     * @since 1.0.19
221
+     * @param  string $context View or edit context.
222
+     * @return bool
223
+     */
224
+    public function get_is_required( $context = 'view' ) {
225
+        $is_required = (bool) $this->is_required;
226
+
227
+        if ( 'view' == $context ) {
228
+            return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
229
+        }
230
+
231
+        return $is_required;
232
+
233
+    }
234
+
235
+    /**
236
+     * Prepares form data for use.
237
+     *
238
+     * @since 1.0.19
239
+     * @return array
240
+     */
241
+    public function prepare_data_for_use( $required = null ) {
242
+
243
+        $required = is_null( $required ) ? $this->is_required() : $required;
244
+        return array(
245
+            'title'            => strip_tags( $this->get_name() ),
246
+            'id'               => $this->get_id(),
247
+            'price'            => $this->get_price(),
248
+            'recurring'        => $this->is_recurring(),
249
+            'description'      => $this->get_description(),
250
+            'allow_quantities' => $this->allows_quantities(),
251
+            'required'         => $required,
252
+        );
253
+
254
+    }
255
+
256
+    /**
257
+     * Prepares form data for ajax use.
258
+     *
259
+     * @since 1.0.19
260
+     * @return array
261
+     */
262
+    public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
263
+
264
+        $description = getpaid_item_recurring_price_help_text( $this, $currency );
265
+
266
+        if ( $description ) {
267
+            $description = "<div class='getpaid-subscription-help-text'>$description</div>";
268
+        }
269
+
270
+        $price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
271
+        $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
272
+        return array(
273
+            'id'     => $this->get_id(),
274
+            'texts'  => array(
275
+                'item-name'        => sanitize_text_field( $this->get_name() ),
276
+                'item-description' => wp_kses_post( $this->get_description() ) . $description,
277
+                'item-quantity'    => floatval( $this->get_quantity() ),
278
+                'item-price'       => wpinv_price( $price, $currency ),
279
+                'item-total'       => wpinv_price( $subtotal, $currency ),
280
+            ),
281
+            'inputs' => array(
282
+                'item-id'          => $this->get_id(),
283
+                'item-name'        => sanitize_text_field( $this->get_name() ),
284
+                'item-description' => wp_kses_post( $this->get_description() ),
285
+                'item-quantity'    => floatval( $this->get_quantity() ),
286
+                'item-price'       => $price,
287
+            )
288
+        );
289
+
290
+    }
291
+
292
+    /**
293
+     * Prepares form data for saving (cart_details).
294
+     *
295
+     * @since 1.0.19
296
+     * @return array
297
+     */
298
+    public function prepare_data_for_saving() {
299
+
300
+        return array(
301
+            'post_id'           => $this->invoice_id,
302
+            'item_id'           => $this->get_id(),
303
+            'item_name'         => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
304
+            'item_description'  => $this->get_description( 'edit' ),
305
+            'tax'               => $this->item_tax,
306
+            'item_price'        => $this->get_price( 'edit' ),
307
+            'quantity'          => (float) $this->get_quantity( 'edit' ),
308
+            'discount'          => $this->item_discount,
309
+            'subtotal'          => $this->get_sub_total( 'edit' ),
310
+            'price'             => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
311
+            'meta'              => $this->get_item_meta( 'edit' ),
312
+        );
313
+
314
+    }
315 315
 
316 316
     /*
317 317
 	|--------------------------------------------------------------------------
@@ -323,70 +323,70 @@  discard block
 block discarded – undo
323 323
 	| object.
324 324
     */
325 325
 
326
-	/**
327
-	 * Set the item qantity.
328
-	 *
329
-	 * @since 1.0.19
330
-	 * @param  float $quantity The item quantity.
331
-	 */
332
-	public function set_quantity( $quantity ) {
333
-
334
-		if ( ! is_numeric( $quantity ) ) {
335
-			$quantity = 1;
336
-		}
337
-
338
-		$this->quantity = (float) $quantity;
339
-
340
-	}
341
-
342
-	/**
343
-	 * Set the item meta data.
344
-	 *
345
-	 * @since 1.0.19
346
-	 * @param  array $meta The item meta data.
347
-	 */
348
-	public function set_item_meta( $meta ) {
349
-		$this->meta = maybe_unserialize( $meta );
350
-	}
351
-
352
-	/**
353
-	 * Set whether or not the quantities are allowed.
354
-	 *
355
-	 * @since 1.0.19
356
-	 * @param  bool $allow_quantities
357
-	 */
358
-	public function set_allow_quantities( $allow_quantities ) {
359
-		$this->allow_quantities = (bool) $allow_quantities;
360
-	}
361
-
362
-	/**
363
-	 * Set whether or not the item is required.
364
-	 *
365
-	 * @since 1.0.19
366
-	 * @param  bool $is_required
367
-	 */
368
-	public function set_is_required( $is_required ) {
369
-		$this->is_required = (bool) $is_required;
370
-	}
371
-
372
-	/**
373
-	 * Sets the custom item description.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $description
377
-	 */
378
-	public function set_custom_description( $description ) {
379
-		$this->custom_description = $description;
380
-	}
326
+    /**
327
+     * Set the item qantity.
328
+     *
329
+     * @since 1.0.19
330
+     * @param  float $quantity The item quantity.
331
+     */
332
+    public function set_quantity( $quantity ) {
333
+
334
+        if ( ! is_numeric( $quantity ) ) {
335
+            $quantity = 1;
336
+        }
337
+
338
+        $this->quantity = (float) $quantity;
339
+
340
+    }
341
+
342
+    /**
343
+     * Set the item meta data.
344
+     *
345
+     * @since 1.0.19
346
+     * @param  array $meta The item meta data.
347
+     */
348
+    public function set_item_meta( $meta ) {
349
+        $this->meta = maybe_unserialize( $meta );
350
+    }
351
+
352
+    /**
353
+     * Set whether or not the quantities are allowed.
354
+     *
355
+     * @since 1.0.19
356
+     * @param  bool $allow_quantities
357
+     */
358
+    public function set_allow_quantities( $allow_quantities ) {
359
+        $this->allow_quantities = (bool) $allow_quantities;
360
+    }
361
+
362
+    /**
363
+     * Set whether or not the item is required.
364
+     *
365
+     * @since 1.0.19
366
+     * @param  bool $is_required
367
+     */
368
+    public function set_is_required( $is_required ) {
369
+        $this->is_required = (bool) $is_required;
370
+    }
371
+
372
+    /**
373
+     * Sets the custom item description.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $description
377
+     */
378
+    public function set_custom_description( $description ) {
379
+        $this->custom_description = $description;
380
+    }
381 381
 
382 382
     /**
383 383
      * We do not want to save items to the database.
384 384
      * 
385
-	 * @return int item id
385
+     * @return int item id
386 386
      */
387 387
     public function save( $data = array() ) {
388 388
         return $this->get_id();
389
-	}
389
+    }
390 390
 
391 391
     /*
392 392
 	|--------------------------------------------------------------------------
@@ -398,23 +398,23 @@  discard block
 block discarded – undo
398 398
 	*/
399 399
 
400 400
     /**
401
-	 * Checks whether the item has enabled dynamic pricing.
402
-	 *
403
-	 * @since 1.0.19
404
-	 * @return bool
405
-	 */
406
-	public function is_required() {
401
+     * Checks whether the item has enabled dynamic pricing.
402
+     *
403
+     * @since 1.0.19
404
+     * @return bool
405
+     */
406
+    public function is_required() {
407 407
         return (bool) $this->get_is_required();
408
-	}
409
-
410
-	/**
411
-	 * Checks whether users can edit the quantities.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @return bool
415
-	 */
416
-	public function allows_quantities() {
408
+    }
409
+
410
+    /**
411
+     * Checks whether users can edit the quantities.
412
+     *
413
+     * @since 1.0.19
414
+     * @return bool
415
+     */
416
+    public function allows_quantities() {
417 417
         return (bool) $this->get_allow_quantities();
418
-	}
418
+    }
419 419
 
420 420
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @param  string $context View or edit context.
95 95
 	 * @return string
96 96
 	 */
97
-	public function get_name( $context = 'view' ) {
98
-		$name = parent::get_name( $context );
99
-		return $name . wpinv_get_item_suffix( $this );
97
+	public function get_name($context = 'view') {
98
+		$name = parent::get_name($context);
99
+		return $name . wpinv_get_item_suffix($this);
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	 * @param  string $context View or edit context.
107 107
 	 * @return string
108 108
 	 */
109
-	public function get_raw_name( $context = 'view' ) {
110
-		return parent::get_name( $context );
109
+	public function get_raw_name($context = 'view') {
110
+		return parent::get_name($context);
111 111
 	}
112 112
 
113 113
 	/**
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
 	 * @param  string $context View or edit context.
118 118
 	 * @return string
119 119
 	 */
120
-	public function get_description( $context = 'view' ) {
120
+	public function get_description($context = 'view') {
121 121
 
122
-		if ( isset( $this->custom_description ) ) {
122
+		if (isset($this->custom_description)) {
123 123
 			return $this->custom_description;
124 124
 		}
125 125
 
126
-		return parent::get_description( $context );
126
+		return parent::get_description($context);
127 127
 	}
128 128
 
129 129
 	/**
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @param  string $context View or edit context.
134 134
 	 * @return float
135 135
 	 */
136
-	public function get_sub_total( $context = 'view' ) {
137
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context );
136
+	public function get_sub_total($context = 'view') {
137
+		return $this->get_quantity($context) * $this->get_initial_price($context);
138 138
 	}
139 139
 
140 140
 	/**
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	 * @param  string $context View or edit context.
145 145
 	 * @return float
146 146
 	 */
147
-	public function get_recurring_sub_total( $context = 'view' ) {
147
+	public function get_recurring_sub_total($context = 'view') {
148 148
 
149
-		if ( $this->is_recurring() ) {
150
-			return $this->get_quantity( $context ) * $this->get_price( $context );
149
+		if ($this->is_recurring()) {
150
+			return $this->get_quantity($context) * $this->get_price($context);
151 151
 		}
152 152
 
153 153
 		return 0;
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	/**
157 157
 	 * @deprecated
158 158
 	 */
159
-	public function get_qantity( $context = 'view' ) {
160
-		return $this->get_quantity( $context );
159
+	public function get_qantity($context = 'view') {
160
+		return $this->get_quantity($context);
161 161
 	}
162 162
 
163 163
 	/**
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 * @param  string $context View or edit context.
168 168
 	 * @return float
169 169
 	 */
170
-	public function get_quantity( $context = 'view' ) {
170
+	public function get_quantity($context = 'view') {
171 171
 		$quantity = (float) $this->quantity;
172 172
 
173
-		if ( 'view' == $context ) {
174
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
173
+		if ('view' == $context) {
174
+			return apply_filters('getpaid_payment_form_item_quantity', $quantity, $this);
175 175
 		}
176 176
 
177 177
 		return $quantity;
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 	 * @param  string $context View or edit context.
186 186
 	 * @return meta
187 187
 	 */
188
-	public function get_item_meta( $context = 'view' ) {
188
+	public function get_item_meta($context = 'view') {
189 189
 		$meta = $this->meta;
190 190
 
191
-		if ( 'view' == $context ) {
192
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
191
+		if ('view' == $context) {
192
+			return apply_filters('getpaid_payment_form_item_meta', $meta, $this);
193 193
 		}
194 194
 
195 195
 		return $meta;
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 	 * @param  string $context View or edit context.
204 204
 	 * @return bool
205 205
 	 */
206
-	public function get_allow_quantities( $context = 'view' ) {
206
+	public function get_allow_quantities($context = 'view') {
207 207
 		$allow_quantities = (bool) $this->allow_quantities;
208 208
 
209
-		if ( 'view' == $context ) {
210
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
209
+		if ('view' == $context) {
210
+			return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this);
211 211
 		}
212 212
 
213 213
 		return $allow_quantities;
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 	 * @param  string $context View or edit context.
222 222
 	 * @return bool
223 223
 	 */
224
-	public function get_is_required( $context = 'view' ) {
224
+	public function get_is_required($context = 'view') {
225 225
 		$is_required = (bool) $this->is_required;
226 226
 
227
-		if ( 'view' == $context ) {
228
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
227
+		if ('view' == $context) {
228
+			return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this);
229 229
 		}
230 230
 
231 231
 		return $is_required;
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 	 * @since 1.0.19
239 239
 	 * @return array
240 240
 	 */
241
-	public function prepare_data_for_use( $required = null ) {
241
+	public function prepare_data_for_use($required = null) {
242 242
 
243
-		$required = is_null( $required ) ? $this->is_required() : $required;
243
+		$required = is_null($required) ? $this->is_required() : $required;
244 244
 		return array(
245
-			'title'            => strip_tags( $this->get_name() ),
245
+			'title'            => strip_tags($this->get_name()),
246 246
 			'id'               => $this->get_id(),
247 247
 			'price'            => $this->get_price(),
248 248
 			'recurring'        => $this->is_recurring(),
@@ -259,30 +259,30 @@  discard block
 block discarded – undo
259 259
 	 * @since 1.0.19
260 260
 	 * @return array
261 261
 	 */
262
-	public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
262
+	public function prepare_data_for_invoice_edit_ajax($currency = '', $is_renewal = false) {
263 263
 
264
-		$description = getpaid_item_recurring_price_help_text( $this, $currency );
264
+		$description = getpaid_item_recurring_price_help_text($this, $currency);
265 265
 
266
-		if ( $description ) {
266
+		if ($description) {
267 267
 			$description = "<div class='getpaid-subscription-help-text'>$description</div>";
268 268
 		}
269 269
 
270
-		$price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
271
-		$subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
270
+		$price    = !$is_renewal ? $this->get_price() : $this->get_recurring_price();
271
+		$subtotal = !$is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
272 272
 		return array(
273 273
 			'id'     => $this->get_id(),
274 274
 			'texts'  => array(
275
-				'item-name'        => sanitize_text_field( $this->get_name() ),
276
-				'item-description' => wp_kses_post( $this->get_description() ) . $description,
277
-				'item-quantity'    => floatval( $this->get_quantity() ),
278
-				'item-price'       => wpinv_price( $price, $currency ),
279
-				'item-total'       => wpinv_price( $subtotal, $currency ),
275
+				'item-name'        => sanitize_text_field($this->get_name()),
276
+				'item-description' => wp_kses_post($this->get_description()) . $description,
277
+				'item-quantity'    => floatval($this->get_quantity()),
278
+				'item-price'       => wpinv_price($price, $currency),
279
+				'item-total'       => wpinv_price($subtotal, $currency),
280 280
 			),
281 281
 			'inputs' => array(
282 282
 				'item-id'          => $this->get_id(),
283
-				'item-name'        => sanitize_text_field( $this->get_name() ),
284
-				'item-description' => wp_kses_post( $this->get_description() ),
285
-				'item-quantity'    => floatval( $this->get_quantity() ),
283
+				'item-name'        => sanitize_text_field($this->get_name()),
284
+				'item-description' => wp_kses_post($this->get_description()),
285
+				'item-quantity'    => floatval($this->get_quantity()),
286 286
 				'item-price'       => $price,
287 287
 			)
288 288
 		);
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
 		return array(
301 301
 			'post_id'           => $this->invoice_id,
302 302
 			'item_id'           => $this->get_id(),
303
-			'item_name'         => sanitize_text_field( $this->get_raw_name( 'edit' ) ),
304
-			'item_description'  => $this->get_description( 'edit' ),
303
+			'item_name'         => sanitize_text_field($this->get_raw_name('edit')),
304
+			'item_description'  => $this->get_description('edit'),
305 305
 			'tax'               => $this->item_tax,
306
-			'item_price'        => $this->get_price( 'edit' ),
307
-			'quantity'          => (float) $this->get_quantity( 'edit' ),
306
+			'item_price'        => $this->get_price('edit'),
307
+			'quantity'          => (float) $this->get_quantity('edit'),
308 308
 			'discount'          => $this->item_discount,
309
-			'subtotal'          => $this->get_sub_total( 'edit' ),
310
-			'price'             => $this->get_sub_total( 'edit' ) + $this->item_tax - $this->item_discount,
311
-			'meta'              => $this->get_item_meta( 'edit' ),
309
+			'subtotal'          => $this->get_sub_total('edit'),
310
+			'price'             => $this->get_sub_total('edit') + $this->item_tax - $this->item_discount,
311
+			'meta'              => $this->get_item_meta('edit'),
312 312
 		);
313 313
 
314 314
 	}
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 	 * @since 1.0.19
330 330
 	 * @param  float $quantity The item quantity.
331 331
 	 */
332
-	public function set_quantity( $quantity ) {
332
+	public function set_quantity($quantity) {
333 333
 
334
-		if ( ! is_numeric( $quantity ) ) {
334
+		if (!is_numeric($quantity)) {
335 335
 			$quantity = 1;
336 336
 		}
337 337
 
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	 * @since 1.0.19
346 346
 	 * @param  array $meta The item meta data.
347 347
 	 */
348
-	public function set_item_meta( $meta ) {
349
-		$this->meta = maybe_unserialize( $meta );
348
+	public function set_item_meta($meta) {
349
+		$this->meta = maybe_unserialize($meta);
350 350
 	}
351 351
 
352 352
 	/**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @since 1.0.19
356 356
 	 * @param  bool $allow_quantities
357 357
 	 */
358
-	public function set_allow_quantities( $allow_quantities ) {
358
+	public function set_allow_quantities($allow_quantities) {
359 359
 		$this->allow_quantities = (bool) $allow_quantities;
360 360
 	}
361 361
 
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 * @since 1.0.19
366 366
 	 * @param  bool $is_required
367 367
 	 */
368
-	public function set_is_required( $is_required ) {
368
+	public function set_is_required($is_required) {
369 369
 		$this->is_required = (bool) $is_required;
370 370
 	}
371 371
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 * @since 1.0.19
376 376
 	 * @param  string $description
377 377
 	 */
378
-	public function set_custom_description( $description ) {
378
+	public function set_custom_description($description) {
379 379
 		$this->custom_description = $description;
380 380
 	}
381 381
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
      * 
385 385
 	 * @return int item id
386 386
      */
387
-    public function save( $data = array() ) {
387
+    public function save($data = array()) {
388 388
         return $this->get_id();
389 389
 	}
390 390
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/file_upload.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,31 +7,31 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='form-group'>
15 15
     <label class="d-block">
16
-        <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span>
16
+        <span><?php esc_html_e('Field Label', 'invoicing'); ?></span>
17 17
         <input v-model="active_form_element.label" class="form-control" type="text"/>
18 18
     </label>
19 19
 </div>
20 20
 
21 21
 <div class='form-group'>
22 22
     <label class="d-block">
23
-        <span><?php esc_html_e( 'Max File Number', 'invoicing' ); ?></span>
23
+        <span><?php esc_html_e('Max File Number', 'invoicing'); ?></span>
24 24
         <input v-model="active_form_element.max_file_num" class="form-control" min="1" type="number" />
25
-        <small class="form-text text-muted"><?php _e( 'How many files can be uploaded?', 'invoicing' ); ?></small>
25
+        <small class="form-text text-muted"><?php _e('How many files can be uploaded?', 'invoicing'); ?></small>
26 26
     </label>
27 27
 </div>
28 28
 
29 29
 <div class='form-group'>
30 30
     <label class="d-block">
31
-        <span><?php esc_html_e( 'Allowed File types', 'invoicing' ); ?></span>
31
+        <span><?php esc_html_e('Allowed File types', 'invoicing'); ?></span>
32 32
         <gpselect2 class='form-control custom-select' v-model='active_form_element.file_types' multiple>
33
-            <?php foreach ( getpaid_get_allowed_mime_types() as $ext_regex => $mime_type ) : ?>
34
-                <option value="<?php echo esc_attr( $ext_regex ); ?>"><?php echo esc_html( "$mime_type" ) ?></option>
33
+            <?php foreach (getpaid_get_allowed_mime_types() as $ext_regex => $mime_type) : ?>
34
+                <option value="<?php echo esc_attr($ext_regex); ?>"><?php echo esc_html("$mime_type") ?></option>
35 35
             <?php endforeach; ?>
36 36
         </gpselect2>
37 37
     </label>
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
 <div class='form-group'>
41 41
     <label class="d-block">
42
-        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
43
-        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
44
-        <small class="form-text text-muted"><?php _e( 'HTML is allowed', 'invoicing' ); ?></small>
42
+        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
43
+        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
44
+        <small class="form-text text-muted"><?php _e('HTML is allowed', 'invoicing'); ?></small>
45 45
     </label>
46 46
 </div>
47 47
 
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 
50 50
 <div class='form-group form-check'>
51 51
     <input :id="active_form_element.id + '_edit'" v-model='active_form_element.required' type='checkbox' class='form-check-input' />
52
-    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Is this field required?', 'invoicing' ); ?></label>
52
+    <label class='form-check-label' :for="active_form_element.id + '_edit'"><?php esc_html_e('Is this field required?', 'invoicing'); ?></label>
53 53
 </div>
54 54
 
55 55
 <div class='form-group form-check'>
56 56
     <input :id="active_form_element.id + '_add_meta'" v-model='active_form_element.add_meta' type='checkbox' class='form-check-input' />
57
-    <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e( 'Show this field in receipts and emails?', 'invoicing' ); ?></label>
57
+    <label class='form-check-label' :for="active_form_element.id + '_add_meta'"><?php esc_html_e('Show this field in receipts and emails?', 'invoicing'); ?></label>
58 58
 </div>
59 59
 
60 60
 <hr class='featurette-divider mt-4'>
61 61
 
62 62
 <div class='form-group'>
63 63
     <label class="d-block">
64
-        <span><?php esc_html_e( 'Email Merge Tag', 'invoicing' ); ?></span>
64
+        <span><?php esc_html_e('Email Merge Tag', 'invoicing'); ?></span>
65 65
         <input :value='active_form_element.label | formatMergeTag' class='form-control bg-white' type="text" readonly onclick="this.select()" />
66
-        <span class="form-text text-muted"><?php esc_html_e( 'You can use this merge tag in notification emails', 'invoicing' ); ?></span>
66
+        <span class="form-text text-muted"><?php esc_html_e('You can use this merge tag in notification emails', 'invoicing'); ?></span>
67 67
     </label>
68 68
 </div>
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/file_upload.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <label><span v-html="form_element.label"></span></label>
15 15
 <div class="d-flex w-100 flex-column align-items-center justify-content-center p-2" style="height: 200px; border: 3px dashed rgb(136, 136, 136); cursor: pointer;">
16 16
     <div class="h5 text-dark">
17
-        <span v-if="form_element.max_file_num > 1"><?php _e( 'Drag files to this area or click to upload', 'invoicing' ); ?></span>
18
-        <span v-if="form_element.max_file_num < 2"><?php _e( 'Drag your file to this area or click to upload', 'invoicing' ); ?></span>
17
+        <span v-if="form_element.max_file_num > 1"><?php _e('Drag files to this area or click to upload', 'invoicing'); ?></span>
18
+        <span v-if="form_element.max_file_num < 2"><?php _e('Drag your file to this area or click to upload', 'invoicing'); ?></span>
19 19
     </div>
20 20
     <small v-if='form_element.description' class='form-text text-muted' v-html='form_element.description'></small>
21 21
 </div>
Please login to merge, or discard this patch.
templates/payment-forms/elements/file_upload.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,22 +21,22 @@
 block discarded – undo
21 21
 
22 22
 foreach ( $file_types as $file_type ) {
23 23
 
24
-	if ( isset( $all_types[ $file_type ] ) ) {
25
-		$types[]   = $all_types[ $file_type ];
26
-		$file_type = explode( '|', $file_type );
24
+    if ( isset( $all_types[ $file_type ] ) ) {
25
+        $types[]   = $all_types[ $file_type ];
26
+        $file_type = explode( '|', $file_type );
27 27
 
28
-		foreach ( $file_type as $type ) {
29
-			$type     = trim( $type );
30
-			$types[]  = ".$type";
31
-			$_types[] = $type;
32
-		}
28
+        foreach ( $file_type as $type ) {
29
+            $type     = trim( $type );
30
+            $types[]  = ".$type";
31
+            $_types[] = $type;
32
+        }
33 33
 
34
-	}
34
+    }
35 35
 
36 36
 }
37 37
 
38 38
 if ( ! empty( $required ) ) {
39
-	$label .= "<span class='text-danger'> *</span>";
39
+    $label .= "<span class='text-danger'> *</span>";
40 40
 }
41 41
 
42 42
 ?>
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
11
-
12
-$label        = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class  = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14
-$id           = esc_attr( $id );
15
-$_id          = $id . uniqid( '_' );
16
-$max_file_num = empty( $max_file_num ) ? 1 : absint( $max_file_num );
17
-$file_types   = empty( $file_types ) ? array( 'jpg|jpeg|jpe', 'gif', 'png' ) : $file_types;
10
+defined('ABSPATH') || exit;
11
+
12
+$label        = empty($label) ? '' : wp_kses_post($label);
13
+$label_class  = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14
+$id           = esc_attr($id);
15
+$_id          = $id . uniqid('_');
16
+$max_file_num = empty($max_file_num) ? 1 : absint($max_file_num);
17
+$file_types   = empty($file_types) ? array('jpg|jpeg|jpe', 'gif', 'png') : $file_types;
18 18
 $all_types    = getpaid_get_allowed_mime_types();
19 19
 $types        = array();
20 20
 $_types       = array();
21 21
 
22
-foreach ( $file_types as $file_type ) {
22
+foreach ($file_types as $file_type) {
23 23
 
24
-	if ( isset( $all_types[ $file_type ] ) ) {
25
-		$types[]   = $all_types[ $file_type ];
26
-		$file_type = explode( '|', $file_type );
24
+	if (isset($all_types[$file_type])) {
25
+		$types[]   = $all_types[$file_type];
26
+		$file_type = explode('|', $file_type);
27 27
 
28
-		foreach ( $file_type as $type ) {
29
-			$type     = trim( $type );
28
+		foreach ($file_type as $type) {
29
+			$type     = trim($type);
30 30
 			$types[]  = ".$type";
31 31
 			$_types[] = $type;
32 32
 		}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 }
37 37
 
38
-if ( ! empty( $required ) ) {
38
+if (!empty($required)) {
39 39
 	$label .= "<span class='text-danger'> *</span>";
40 40
 }
41 41
 
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 
44 44
 <label><span v-html="form_element.label"></span></label>
45 45
 
46
-<div class="form-group <?php echo sanitize_html_class( $label_class ); ?>" data-name="<?php echo esc_attr( $id ); ?>" data-max="<?php echo esc_attr( $max_file_num ); ?>">
47
-	<label for="<?php echo esc_attr( $id ); ?>"><?php echo wp_kses_post( $label ); ?></label>
48
-	<input type="file" class="sr-only getpaid-files-input" id="<?php echo esc_attr( $id ); ?>" accept="<?php echo esc_attr( implode( ', ', $types ) ); ?>" data-extensions="<?php echo esc_attr( wp_json_encode( $_types ) ); ?>" <?php echo $max_file_num == 1 ? '' : 'multiple="multiple"'; ?>>
46
+<div class="form-group <?php echo sanitize_html_class($label_class); ?>" data-name="<?php echo esc_attr($id); ?>" data-max="<?php echo esc_attr($max_file_num); ?>">
47
+	<label for="<?php echo esc_attr($id); ?>"><?php echo wp_kses_post($label); ?></label>
48
+	<input type="file" class="sr-only getpaid-files-input" id="<?php echo esc_attr($id); ?>" accept="<?php echo esc_attr(implode(', ', $types)); ?>" data-extensions="<?php echo esc_attr(wp_json_encode($_types)); ?>" <?php echo $max_file_num == 1 ? '' : 'multiple="multiple"'; ?>>
49 49
 
50
-	<label for="<?php echo esc_attr( $id ); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2">
50
+	<label for="<?php echo esc_attr($id); ?>" class="getpaid-file-upload-element d-flex w-100 flex-column align-items-center justify-content-center p-2 mb-2">
51 51
 		<div class="h5 text-dark">
52
-			<?php echo _n( 'Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing' ); ?>
52
+			<?php echo _n('Drag your file to this area or click to upload', 'Drag files to this area or click to upload', $max_file_num, 'invoicing'); ?>
53 53
 		</div>
54
-		<?php if ( ! empty( $description ) ) : ?>
55
-			<small class="form-text text-muted"><?php echo wp_kses_post( $description ); ?></small>
54
+		<?php if (!empty($description)) : ?>
55
+			<small class="form-text text-muted"><?php echo wp_kses_post($description); ?></small>
56 56
 		<?php endif; ?>
57 57
 	</label>
58 58
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	<div class="form-row mb-3 d-none getpaid-progress-template">
62 62
 
63 63
 		<div class="overflow-hidden text-nowrap col-7 col-sm-4">
64
-			<a href="" class="close float-none" title="<?php esc_attr_e( 'Remove File', 'invoicing' ); ?>">&times;<span class="sr-only"><?php _e( 'Close', 'invoicing' ); ?></span></a>&nbsp;
64
+			<a href="" class="close float-none" title="<?php esc_attr_e('Remove File', 'invoicing'); ?>">&times;<span class="sr-only"><?php _e('Close', 'invoicing'); ?></span></a>&nbsp;
65 65
 			<i class="fa fa-file" aria-hidden="true"></i>&nbsp; <span class="getpaid-progress-file-name"></span>&nbsp;
66 66
 		</div>
67 67
 
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@  discard block
 block discarded – undo
14 14
 class WPInv_Ajax {
15 15
 
16 16
     /**
17
-	 * Hook in ajax handlers.
18
-	 */
19
-	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
-		self::add_ajax_events();
17
+     * Hook in ajax handlers.
18
+     */
19
+    public static function init() {
20
+        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
+        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
+        self::add_ajax_events();
23 23
     }
24 24
 
25 25
     /**
26
-	 * Set GetPaid AJAX constant and headers.
27
-	 */
28
-	public static function define_ajax() {
29
-
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
-			}
36
-			$GLOBALS['wpdb']->hide_errors();
37
-		}
26
+     * Set GetPaid AJAX constant and headers.
27
+     */
28
+    public static function define_ajax() {
29
+
30
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
+            getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
+            getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
+            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
+                /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
+            }
36
+            $GLOBALS['wpdb']->hide_errors();
37
+        }
38 38
 
39 39
     }
40 40
     
41 41
     /**
42
-	 * Send headers for GetPaid Ajax Requests.
43
-	 *
44
-	 * @since 1.0.18
45
-	 */
46
-	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
48
-			send_origin_headers();
49
-			send_nosniff_header();
50
-			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
54
-		}
42
+     * Send headers for GetPaid Ajax Requests.
43
+     *
44
+     * @since 1.0.18
45
+     */
46
+    private static function wpinv_ajax_headers() {
47
+        if ( ! headers_sent() ) {
48
+            send_origin_headers();
49
+            send_nosniff_header();
50
+            nocache_headers();
51
+            header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
+            header( 'X-Robots-Tag: noindex' );
53
+            status_header( 200 );
54
+        }
55 55
     }
56 56
     
57 57
     /**
58
-	 * Check for GetPaid Ajax request and fire action.
59
-	 */
60
-	public static function do_wpinv_ajax() {
61
-		global $wp_query;
58
+     * Check for GetPaid Ajax request and fire action.
59
+     */
60
+    public static function do_wpinv_ajax() {
61
+        global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
-		}
63
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
+            $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
+        }
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+        $action = $wp_query->get( 'wpinv-ajax' );
68 68
 
69
-		if ( $action ) {
70
-			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
73
-			wp_die();
74
-		}
69
+        if ( $action ) {
70
+            self::wpinv_ajax_headers();
71
+            $action = sanitize_text_field( $action );
72
+            do_action( 'wpinv_ajax_' . $action );
73
+            wp_die();
74
+        }
75 75
 
76 76
     }
77 77
 
78 78
     /**
79
-	 * Hook in ajax methods.
80
-	 */
79
+     * Hook in ajax methods.
80
+     */
81 81
     public static function add_ajax_events() {
82 82
 
83 83
         // array( 'event' => is_frontend )
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
         check_ajax_referer( 'getpaid_form_nonce' );
262 262
 
263 263
         // Is the request set up correctly?
264
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
265
-			echo aui()->alert(
266
-				array(
267
-					'type'    => 'warning',
268
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
269
-				)
264
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
265
+            echo aui()->alert(
266
+                array(
267
+                    'type'    => 'warning',
268
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
269
+                )
270 270
             );
271 271
             exit;
272 272
         }
273 273
 
274 274
         // Payment form or button?
275
-		if ( ! empty( $_GET['form'] ) ) {
275
+        if ( ! empty( $_GET['form'] ) ) {
276 276
             $form = urldecode( $_GET['form'] );
277 277
 
278 278
             if ( false !== strpos( $form, '|' ) ) {
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
                 getpaid_display_payment_form( $form );
327 327
             }
328 328
 
329
-		} else if( ! empty( $_GET['invoice'] ) ) {
330
-		    getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
329
+        } else if( ! empty( $_GET['invoice'] ) ) {
330
+            getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
331 331
         } else {
332
-			$items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
333
-		    getpaid_display_item_payment_form( $items );
332
+            $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
333
+            getpaid_display_item_payment_form( $items );
334 334
         }
335 335
 
336 336
         exit;
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
         if ( is_wp_error( $error ) ) {
652 652
             $alert = $error->get_error_message();
653 653
             wp_send_json_success( compact( 'alert' ) );
654
-         }
654
+            }
655 655
 
656 656
         // Update totals.
657 657
         $invoice->recalculate_total();
@@ -1085,12 +1085,12 @@  discard block
 block discarded – undo
1085 1085
     }
1086 1086
 
1087 1087
     /**
1088
-	 * Handles file uploads.
1089
-	 *
1090
-	 * @since       1.0.0
1091
-	 * @return      void
1092
-	 */
1093
-	public static function file_upload() {
1088
+     * Handles file uploads.
1089
+     *
1090
+     * @since       1.0.0
1091
+     * @return      void
1092
+     */
1093
+    public static function file_upload() {
1094 1094
 
1095 1095
         // Check nonce.
1096 1096
         check_ajax_referer( 'getpaid_form_nonce' );
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 
1152 1152
         wp_send_json_success( $response );
1153 1153
 
1154
-	}
1154
+    }
1155 1155
 
1156 1156
 }
1157 1157
 
Please login to merge, or discard this patch.
Spacing   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -106,36 +106,36 @@  discard block
 block discarded – undo
106 106
             'file_upload'                 => true,
107 107
         );
108 108
 
109
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
110
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
111
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
109
+        foreach ($ajax_events as $ajax_event => $nopriv) {
110
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
111
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
112 112
 
113
-            if ( $nopriv ) {
114
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
115
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
116
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
113
+            if ($nopriv) {
114
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
115
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
116
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
117 117
             }
118 118
         }
119 119
     }
120 120
     
121 121
     public static function add_note() {
122
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
122
+        check_ajax_referer('add-invoice-note', '_nonce');
123 123
 
124
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
124
+        if (!wpinv_current_user_can_manage_invoicing()) {
125 125
             die(-1);
126 126
         }
127 127
 
128
-        $post_id   = absint( $_POST['post_id'] );
129
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
130
-        $note_type = sanitize_text_field( $_POST['note_type'] );
128
+        $post_id   = absint($_POST['post_id']);
129
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
130
+        $note_type = sanitize_text_field($_POST['note_type']);
131 131
 
132 132
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
133 133
 
134
-        if ( $post_id > 0 ) {
135
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
134
+        if ($post_id > 0) {
135
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
136 136
 
137
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
138
-                wpinv_get_invoice_note_line_item( $note_id );
137
+            if ($note_id > 0 && !is_wp_error($note_id)) {
138
+                wpinv_get_invoice_note_line_item($note_id);
139 139
             }
140 140
         }
141 141
 
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
     }
144 144
 
145 145
     public static function delete_note() {
146
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
146
+        check_ajax_referer('delete-invoice-note', '_nonce');
147 147
 
148
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
148
+        if (!wpinv_current_user_can_manage_invoicing()) {
149 149
             die(-1);
150 150
         }
151 151
 
152
-        $note_id = (int)$_POST['note_id'];
152
+        $note_id = (int) $_POST['note_id'];
153 153
 
154
-        if ( $note_id > 0 ) {
155
-            wp_delete_comment( $note_id, true );
154
+        if ($note_id > 0) {
155
+            wp_delete_comment($note_id, true);
156 156
         }
157 157
 
158 158
         die();
@@ -170,34 +170,34 @@  discard block
 block discarded – undo
170 170
     public static function get_billing_details() {
171 171
 
172 172
         // Verify nonce.
173
-        check_ajax_referer( 'wpinv-nonce' );
173
+        check_ajax_referer('wpinv-nonce');
174 174
 
175 175
         // Can the user manage the plugin?
176
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
176
+        if (!wpinv_current_user_can_manage_invoicing()) {
177 177
             die(-1);
178 178
         }
179 179
 
180 180
         // Do we have a user id?
181 181
         $user_id = $_GET['user_id'];
182 182
 
183
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
183
+        if (empty($user_id) || !is_numeric($user_id)) {
184 184
             die(-1);
185 185
         }
186 186
 
187 187
         // Fetch the billing details.
188
-        $billing_details    = wpinv_get_user_address( $user_id );
189
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
188
+        $billing_details    = wpinv_get_user_address($user_id);
189
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
190 190
 
191 191
         // unset the user id and email.
192
-        $to_ignore = array( 'user_id', 'email' );
192
+        $to_ignore = array('user_id', 'email');
193 193
 
194
-        foreach ( $to_ignore as $key ) {
195
-            if ( isset( $billing_details[ $key ] ) ) {
196
-                unset( $billing_details[ $key ] );
194
+        foreach ($to_ignore as $key) {
195
+            if (isset($billing_details[$key])) {
196
+                unset($billing_details[$key]);
197 197
             }
198 198
         }
199 199
 
200
-        wp_send_json_success( $billing_details );
200
+        wp_send_json_success($billing_details);
201 201
 
202 202
     }
203 203
 
@@ -207,47 +207,47 @@  discard block
 block discarded – undo
207 207
     public static function check_new_user_email() {
208 208
 
209 209
         // Verify nonce.
210
-        check_ajax_referer( 'wpinv-nonce' );
210
+        check_ajax_referer('wpinv-nonce');
211 211
 
212 212
         // Can the user manage the plugin?
213
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
213
+        if (!wpinv_current_user_can_manage_invoicing()) {
214 214
             die(-1);
215 215
         }
216 216
 
217 217
         // We need an email address.
218
-        if ( empty( $_GET['email'] ) ) {
219
-            _e( "Provide the new user's email address", 'invoicing' );
218
+        if (empty($_GET['email'])) {
219
+            _e("Provide the new user's email address", 'invoicing');
220 220
             exit;
221 221
         }
222 222
 
223 223
         // Ensure the email is valid.
224
-        $email = sanitize_text_field( $_GET['email'] );
225
-        if ( ! is_email( $email ) ) {
226
-            _e( 'Invalid email address', 'invoicing' );
224
+        $email = sanitize_text_field($_GET['email']);
225
+        if (!is_email($email)) {
226
+            _e('Invalid email address', 'invoicing');
227 227
             exit;
228 228
         }
229 229
 
230 230
         // And it does not exist.
231
-        $id = email_exists( $email );
232
-        if ( $id ) {
233
-            wp_send_json_success( compact( 'id' ) );
231
+        $id = email_exists($email);
232
+        if ($id) {
233
+            wp_send_json_success(compact('id'));
234 234
         }
235 235
 
236
-        wp_send_json_success( true );
236
+        wp_send_json_success(true);
237 237
     }
238 238
     
239 239
     public static function run_tool() {
240
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
241
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
240
+        check_ajax_referer('wpinv-nonce', '_nonce');
241
+        if (!wpinv_current_user_can_manage_invoicing()) {
242 242
             die(-1);
243 243
         }
244 244
         
245
-        $tool = sanitize_text_field( $_POST['tool'] );
245
+        $tool = sanitize_text_field($_POST['tool']);
246 246
         
247
-        do_action( 'wpinv_run_tool' );
247
+        do_action('wpinv_run_tool');
248 248
         
249
-        if ( !empty( $tool ) ) {
250
-            do_action( 'wpinv_tool_' . $tool );
249
+        if (!empty($tool)) {
250
+            do_action('wpinv_tool_' . $tool);
251 251
         }
252 252
     }
253 253
 
@@ -258,43 +258,43 @@  discard block
 block discarded – undo
258 258
         global $getpaid_force_checkbox;
259 259
 
260 260
         // Check nonce.
261
-        check_ajax_referer( 'getpaid_form_nonce' );
261
+        check_ajax_referer('getpaid_form_nonce');
262 262
 
263 263
         // Is the request set up correctly?
264
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
264
+		if (empty($_GET['form']) && empty($_GET['item']) && empty($_GET['invoice'])) {
265 265
 			echo aui()->alert(
266 266
 				array(
267 267
 					'type'    => 'warning',
268
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
268
+					'content' => __('No payment form or item provided', 'invoicing'),
269 269
 				)
270 270
             );
271 271
             exit;
272 272
         }
273 273
 
274 274
         // Payment form or button?
275
-		if ( ! empty( $_GET['form'] ) ) {
276
-            $form = urldecode( $_GET['form'] );
275
+		if (!empty($_GET['form'])) {
276
+            $form = urldecode($_GET['form']);
277 277
 
278
-            if ( false !== strpos( $form, '|' ) ) {
279
-                $form_pos = strpos( $form, '|' );
280
-                $_items   = getpaid_convert_items_to_array( substr( $form, $form_pos + 1 ) );
281
-                $form     = substr( $form, 0, $form_pos );
278
+            if (false !== strpos($form, '|')) {
279
+                $form_pos = strpos($form, '|');
280
+                $_items   = getpaid_convert_items_to_array(substr($form, $form_pos + 1));
281
+                $form     = substr($form, 0, $form_pos);
282 282
 
283 283
                 // Retrieve appropriate payment form.
284
-                $payment_form = new GetPaid_Payment_Form( $form );
285
-                $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
284
+                $payment_form = new GetPaid_Payment_Form($form);
285
+                $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form());
286 286
 
287 287
                 $items    = array();
288 288
                 $item_ids = array();
289 289
 
290
-                foreach ( $_items as $item_id => $qty ) {
291
-                    if ( ! in_array( $item_id, $item_ids ) ) {
292
-                        $item = new GetPaid_Form_Item( $item_id );
293
-                        $item->set_quantity( $qty );
290
+                foreach ($_items as $item_id => $qty) {
291
+                    if (!in_array($item_id, $item_ids)) {
292
+                        $item = new GetPaid_Form_Item($item_id);
293
+                        $item->set_quantity($qty);
294 294
 
295
-                        if ( 0 == $qty ) {
296
-                            $item->set_allow_quantities( true );
297
-                            $item->set_is_required( false );
295
+                        if (0 == $qty) {
296
+                            $item->set_allow_quantities(true);
297
+                            $item->set_is_required(false);
298 298
                             $getpaid_force_checkbox = true;
299 299
                         }
300 300
 
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
                     }
304 304
                 }
305 305
 
306
-                if ( ! $payment_form->is_default() ) {
306
+                if (!$payment_form->is_default()) {
307 307
 
308
-                    foreach ( $payment_form->get_items() as $item ) {
309
-                        if ( ! in_array( $item->get_id(), $item_ids ) ) {
308
+                    foreach ($payment_form->get_items() as $item) {
309
+                        if (!in_array($item->get_id(), $item_ids)) {
310 310
                             $item_ids[] = $item->get_id();
311 311
                             $items[]    = $item;
312 312
                         }
@@ -314,23 +314,23 @@  discard block
 block discarded – undo
314 314
 
315 315
                 }
316 316
 
317
-                $payment_form->set_items( $items );
318
-                $extra_items     = esc_attr( getpaid_convert_items_to_string( $_items ) );
319
-                $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items );
317
+                $payment_form->set_items($items);
318
+                $extra_items     = esc_attr(getpaid_convert_items_to_string($_items));
319
+                $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items);
320 320
                 $extra_items     = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />";
321 321
                 $extra_items    .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />";
322
-                $payment_form->display( $extra_items );
322
+                $payment_form->display($extra_items);
323 323
                 $getpaid_force_checkbox = false;
324 324
 
325 325
             } else {
326
-                getpaid_display_payment_form( $form );
326
+                getpaid_display_payment_form($form);
327 327
             }
328 328
 
329
-		} else if( ! empty( $_GET['invoice'] ) ) {
330
-		    getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
329
+		} else if (!empty($_GET['invoice'])) {
330
+		    getpaid_display_invoice_payment_form(urldecode($_GET['invoice']));
331 331
         } else {
332
-			$items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
333
-		    getpaid_display_item_payment_form( $items );
332
+			$items = getpaid_convert_items_to_array(urldecode($_GET['item']));
333
+		    getpaid_display_item_payment_form($items);
334 334
         }
335 335
 
336 336
         exit;
@@ -345,17 +345,17 @@  discard block
 block discarded – undo
345 345
     public static function payment_form() {
346 346
 
347 347
         // Check nonce.
348
-        check_ajax_referer( 'getpaid_form_nonce' );
348
+        check_ajax_referer('getpaid_form_nonce');
349 349
 
350 350
         // ... form fields...
351
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
352
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
351
+        if (empty($_POST['getpaid_payment_form_submission'])) {
352
+            _e('Error: Reload the page and try again.', 'invoicing');
353 353
             exit;
354 354
         }
355 355
 
356 356
         // Process the payment form.
357
-        $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' );
358
-        $checkout       = new $checkout_class( new GetPaid_Payment_Form_Submission() );
357
+        $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout');
358
+        $checkout       = new $checkout_class(new GetPaid_Payment_Form_Submission());
359 359
         $checkout->process_checkout();
360 360
 
361 361
         exit;
@@ -368,55 +368,55 @@  discard block
 block discarded – undo
368 368
      */
369 369
     public static function get_payment_form_states_field() {
370 370
 
371
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
371
+        if (empty($_GET['country']) || empty($_GET['form'])) {
372 372
             exit;
373 373
         }
374 374
 
375
-        $elements = getpaid_get_payment_form_elements( $_GET['form'] );
375
+        $elements = getpaid_get_payment_form_elements($_GET['form']);
376 376
 
377
-        if ( empty( $elements ) ) {
377
+        if (empty($elements)) {
378 378
             exit;
379 379
         }
380 380
 
381 381
         $address_fields = array();
382
-        foreach ( $elements as $element ) {
383
-            if ( 'address' === $element['type'] ) {
382
+        foreach ($elements as $element) {
383
+            if ('address' === $element['type']) {
384 384
                 $address_fields = $element;
385 385
                 break;
386 386
             }
387 387
         }
388 388
 
389
-        if ( empty( $address_fields ) ) {
389
+        if (empty($address_fields)) {
390 390
             exit;
391 391
         }
392 392
 
393
-        foreach ( $address_fields['fields'] as $address_field ) {
393
+        foreach ($address_fields['fields'] as $address_field) {
394 394
 
395
-            if ( 'wpinv_state' == $address_field['name'] ) {
395
+            if ('wpinv_state' == $address_field['name']) {
396 396
 
397
-                $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
398
-                $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
399
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
400
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
401
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
402
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
397
+                $wrap_class  = getpaid_get_form_element_grid_class($address_field);
398
+                $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
399
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
400
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
401
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
402
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
403 403
 
404
-                if ( ! empty( $address_field['required'] ) ) {
404
+                if (!empty($address_field['required'])) {
405 405
                     $label .= "<span class='text-danger'> *</span>";
406 406
                 }
407 407
 
408
-                $html = getpaid_get_states_select_markup (
409
-                    sanitize_text_field( $_GET['country'] ),
408
+                $html = getpaid_get_states_select_markup(
409
+                    sanitize_text_field($_GET['country']),
410 410
                     $value,
411 411
                     $placeholder,
412 412
                     $label,
413 413
                     $description,
414
-                    ! empty( $address_field['required'] ),
414
+                    !empty($address_field['required']),
415 415
                     $wrap_class,
416
-                    wpinv_clean( $_GET['name'] )
416
+                    wpinv_clean($_GET['name'])
417 417
                 );
418 418
 
419
-                wp_send_json_success( $html );
419
+                wp_send_json_success($html);
420 420
                 exit;
421 421
 
422 422
             }
@@ -432,66 +432,66 @@  discard block
 block discarded – undo
432 432
     public static function recalculate_invoice_totals() {
433 433
 
434 434
         // Verify nonce.
435
-        check_ajax_referer( 'wpinv-nonce' );
435
+        check_ajax_referer('wpinv-nonce');
436 436
 
437
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
437
+        if (!wpinv_current_user_can_manage_invoicing()) {
438 438
             exit;
439 439
         }
440 440
 
441 441
         // We need an invoice.
442
-        if ( empty( $_POST['post_id'] ) ) {
442
+        if (empty($_POST['post_id'])) {
443 443
             exit;
444 444
         }
445 445
 
446 446
         // Fetch the invoice.
447
-        $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) );
447
+        $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id']));
448 448
 
449 449
         // Ensure it exists.
450
-        if ( ! $invoice->get_id() ) {
450
+        if (!$invoice->get_id()) {
451 451
             exit;
452 452
         }
453 453
 
454 454
         // Maybe set the country, state, currency.
455
-        foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) {
456
-            if ( isset( $_POST[ $key ] ) ) {
455
+        foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) {
456
+            if (isset($_POST[$key])) {
457 457
                 $method = "set_$key";
458
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
458
+                $invoice->$method(sanitize_text_field($_POST[$key]));
459 459
             }
460 460
         }
461 461
 
462 462
         // Maybe disable taxes.
463
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
463
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
464 464
 
465 465
         // Discount code.
466
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
467
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
468
-            if ( $discount->exists() ) {
469
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
466
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
467
+            $discount = new WPInv_Discount($invoice->get_discount_code());
468
+            if ($discount->exists()) {
469
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
470 470
             } else {
471
-                $invoice->remove_discount( 'discount_code' );
471
+                $invoice->remove_discount('discount_code');
472 472
             }
473 473
         }
474 474
 
475 475
         // Recalculate totals.
476 476
         $invoice->recalculate_total();
477 477
 
478
-        $total        = wpinv_price( $invoice->get_total(), $invoice->get_currency() );
479
-        $suscriptions = getpaid_get_invoice_subscriptions( $invoice );
480
-        if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
481
-            $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() );
482
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
478
+        $total        = wpinv_price($invoice->get_total(), $invoice->get_currency());
479
+        $suscriptions = getpaid_get_invoice_subscriptions($invoice);
480
+        if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
481
+            $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency());
482
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
483 483
         }
484 484
 
485 485
         $totals = array(
486
-            'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
487
-            'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
488
-            'tax'      => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
486
+            'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
487
+            'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
488
+            'tax'      => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
489 489
             'total'    => $total,
490 490
         );
491 491
 
492
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
492
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
493 493
 
494
-        wp_send_json_success( compact( 'totals' ) );
494
+        wp_send_json_success(compact('totals'));
495 495
     }
496 496
 
497 497
     /**
@@ -500,33 +500,33 @@  discard block
 block discarded – undo
500 500
     public static function get_invoice_items() {
501 501
 
502 502
         // Verify nonce.
503
-        check_ajax_referer( 'wpinv-nonce' );
503
+        check_ajax_referer('wpinv-nonce');
504 504
 
505
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
505
+        if (!wpinv_current_user_can_manage_invoicing()) {
506 506
             exit;
507 507
         }
508 508
 
509 509
         // We need an invoice and items.
510
-        if ( empty( $_POST['post_id'] ) ) {
510
+        if (empty($_POST['post_id'])) {
511 511
             exit;
512 512
         }
513 513
 
514 514
         // Fetch the invoice.
515
-        $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) );
515
+        $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id']));
516 516
 
517 517
         // Ensure it exists.
518
-        if ( ! $invoice->get_id() ) {
518
+        if (!$invoice->get_id()) {
519 519
             exit;
520 520
         }
521 521
 
522 522
         // Return an array of invoice items.
523 523
         $items = array();
524 524
 
525
-        foreach ( $invoice->get_items() as $item ) {
526
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency(), $invoice->is_renewal()  );
525
+        foreach ($invoice->get_items() as $item) {
526
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal());
527 527
         }
528 528
 
529
-        wp_send_json_success( compact( 'items' ) );
529
+        wp_send_json_success(compact('items'));
530 530
     }
531 531
 
532 532
     /**
@@ -535,50 +535,50 @@  discard block
 block discarded – undo
535 535
     public static function edit_invoice_item() {
536 536
 
537 537
         // Verify nonce.
538
-        check_ajax_referer( 'wpinv-nonce' );
538
+        check_ajax_referer('wpinv-nonce');
539 539
 
540
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
540
+        if (!wpinv_current_user_can_manage_invoicing()) {
541 541
             exit;
542 542
         }
543 543
 
544 544
         // We need an invoice and item details.
545
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
545
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
546 546
             exit;
547 547
         }
548 548
 
549 549
         // Fetch the invoice.
550
-        $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) );
550
+        $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id']));
551 551
 
552 552
         // Ensure it exists and its not been paid for.
553
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
553
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
554 554
             exit;
555 555
         }
556 556
 
557 557
         // Format the data.
558
-        $data = wp_kses_post_deep( wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ) );
558
+        $data = wp_kses_post_deep(wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field')));
559 559
 
560 560
         // Ensure that we have an item id.
561
-        if ( empty( $data['id'] ) ) {
561
+        if (empty($data['id'])) {
562 562
             exit;
563 563
         }
564 564
 
565 565
         // Abort if the invoice does not have the specified item.
566
-        $item = $invoice->get_item( (int) $data['id'] );
566
+        $item = $invoice->get_item((int) $data['id']);
567 567
 
568
-        if ( empty( $item ) ) {
568
+        if (empty($item)) {
569 569
             exit;
570 570
         }
571 571
 
572 572
         // Update the item.
573
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
574
-        $item->set_name( sanitize_text_field( $data['name'] ) );
575
-        $item->set_description( wp_kses_post( $data['description'] ) );
576
-        $item->set_quantity( floatval( $data['quantity'] ) );
573
+        $item->set_price(getpaid_standardize_amount($data['price']));
574
+        $item->set_name(sanitize_text_field($data['name']));
575
+        $item->set_description(wp_kses_post($data['description']));
576
+        $item->set_quantity(floatval($data['quantity']));
577 577
 
578 578
         // Add it to the invoice.
579
-        $error = $invoice->add_item( $item );
579
+        $error = $invoice->add_item($item);
580 580
         $alert = false;
581
-        if ( is_wp_error( $error ) ) {
581
+        if (is_wp_error($error)) {
582 582
             $alert = $error->get_error_message();
583 583
         }
584 584
 
@@ -591,11 +591,11 @@  discard block
 block discarded – undo
591 591
         // Return an array of invoice items.
592 592
         $items = array();
593 593
 
594
-        foreach ( $invoice->get_items() as $item ) {
595
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
594
+        foreach ($invoice->get_items() as $item) {
595
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
596 596
         }
597 597
 
598
-        wp_send_json_success( compact( 'items', 'alert' ) );
598
+        wp_send_json_success(compact('items', 'alert'));
599 599
     }
600 600
 
601 601
     /**
@@ -604,53 +604,53 @@  discard block
 block discarded – undo
604 604
     public static function create_invoice_item() {
605 605
 
606 606
         // Verify nonce.
607
-        check_ajax_referer( 'wpinv-nonce' );
607
+        check_ajax_referer('wpinv-nonce');
608 608
 
609
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
609
+        if (!wpinv_current_user_can_manage_invoicing()) {
610 610
             exit;
611 611
         }
612 612
 
613 613
         // We need an invoice and item details.
614
-        if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) {
614
+        if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) {
615 615
             exit;
616 616
         }
617 617
 
618 618
         // Fetch the invoice.
619
-        $invoice = new WPInv_Invoice( wpinv_clean( $_POST['invoice_id'] ) );
619
+        $invoice = new WPInv_Invoice(wpinv_clean($_POST['invoice_id']));
620 620
 
621 621
         // Ensure it exists and its not been paid for.
622
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
622
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
623 623
             exit;
624 624
         }
625 625
 
626 626
         // Format the data.
627
-        $data = wp_unslash( $_POST['_wpinv_quick'] );
627
+        $data = wp_unslash($_POST['_wpinv_quick']);
628 628
 
629 629
         $item = new WPInv_Item();
630
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
631
-        $item->set_name( sanitize_text_field( $data['name'] ) );
632
-        $item->set_description( wp_kses_post( $data['description'] ) );
633
-        $item->set_type( sanitize_text_field( $data['type'] ) );
634
-        $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) );
635
-        $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) );
636
-        $item->set_status( 'publish' );
630
+        $item->set_price(getpaid_standardize_amount($data['price']));
631
+        $item->set_name(sanitize_text_field($data['name']));
632
+        $item->set_description(wp_kses_post($data['description']));
633
+        $item->set_type(sanitize_text_field($data['type']));
634
+        $item->set_vat_rule(sanitize_text_field($data['vat_rule']));
635
+        $item->set_vat_class(sanitize_text_field($data['vat_class']));
636
+        $item->set_status('publish');
637 637
         $item->save();
638 638
 
639
-        if ( ! $item->exists() ) {
640
-            $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' );
641
-            wp_send_json_success( compact( 'alert' ) );
639
+        if (!$item->exists()) {
640
+            $alert = __('Could not create invoice item. Please try again.', 'invoicing');
641
+            wp_send_json_success(compact('alert'));
642 642
         }
643 643
 
644
-        $item = new GetPaid_Form_Item( $item->get_id() );
645
-        $item->set_quantity( floatval( $data['qty'] ) );
644
+        $item = new GetPaid_Form_Item($item->get_id());
645
+        $item->set_quantity(floatval($data['qty']));
646 646
 
647 647
         // Add it to the invoice.
648
-        $error = $invoice->add_item( $item );
648
+        $error = $invoice->add_item($item);
649 649
         $alert = false;
650 650
 
651
-        if ( is_wp_error( $error ) ) {
651
+        if (is_wp_error($error)) {
652 652
             $alert = $error->get_error_message();
653
-            wp_send_json_success( compact( 'alert' ) );
653
+            wp_send_json_success(compact('alert'));
654 654
          }
655 655
 
656 656
         // Update totals.
@@ -663,9 +663,9 @@  discard block
 block discarded – undo
663 663
         $invoice->recalculate_total();
664 664
         $invoice->save();
665 665
         ob_start();
666
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
666
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
667 667
         $row = ob_get_clean();
668
-        wp_send_json_success( compact( 'row' ) );
668
+        wp_send_json_success(compact('row'));
669 669
     }
670 670
 
671 671
     /**
@@ -674,33 +674,33 @@  discard block
 block discarded – undo
674 674
     public static function remove_invoice_item() {
675 675
 
676 676
         // Verify nonce.
677
-        check_ajax_referer( 'wpinv-nonce' );
677
+        check_ajax_referer('wpinv-nonce');
678 678
 
679
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
679
+        if (!wpinv_current_user_can_manage_invoicing()) {
680 680
             exit;
681 681
         }
682 682
 
683 683
         // We need an invoice and an item.
684
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
684
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
685 685
             exit;
686 686
         }
687 687
 
688 688
         // Fetch the invoice.
689
-        $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) );
689
+        $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id']));
690 690
 
691 691
         // Ensure it exists and its not been paid for.
692
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
692
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
693 693
             exit;
694 694
         }
695 695
 
696 696
         // Abort if the invoice does not have the specified item.
697
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
697
+        $item = $invoice->get_item((int) $_POST['item_id']);
698 698
 
699
-        if ( empty( $item ) ) {
699
+        if (empty($item)) {
700 700
             exit;
701 701
         }
702 702
 
703
-        $invoice->remove_item( (int) $_POST['item_id'] );
703
+        $invoice->remove_item((int) $_POST['item_id']);
704 704
 
705 705
         // Update totals.
706 706
         $invoice->recalculate_total();
@@ -711,11 +711,11 @@  discard block
 block discarded – undo
711 711
         // Return an array of invoice items.
712 712
         $items = array();
713 713
 
714
-        foreach ( $invoice->get_items() as $item ) {
715
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
714
+        foreach ($invoice->get_items() as $item) {
715
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
716 716
         }
717 717
 
718
-        wp_send_json_success( compact( 'items' ) );
718
+        wp_send_json_success(compact('items'));
719 719
     }
720 720
 
721 721
     /**
@@ -724,69 +724,69 @@  discard block
 block discarded – undo
724 724
     public static function recalculate_full_prices() {
725 725
 
726 726
         // Verify nonce.
727
-        check_ajax_referer( 'wpinv-nonce' );
727
+        check_ajax_referer('wpinv-nonce');
728 728
 
729
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
729
+        if (!wpinv_current_user_can_manage_invoicing()) {
730 730
             exit;
731 731
         }
732 732
 
733 733
         // We need an invoice and item.
734
-        if ( empty( $_POST['post_id'] ) ) {
734
+        if (empty($_POST['post_id'])) {
735 735
             exit;
736 736
         }
737 737
 
738 738
         // Fetch the invoice.
739
-        $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) );
739
+        $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id']));
740 740
         $alert   = false;
741 741
 
742 742
         // Ensure it exists and its not been paid for.
743
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
743
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
744 744
             exit;
745 745
         }
746 746
 
747
-        $invoice->set_items( array() );
747
+        $invoice->set_items(array());
748 748
 
749
-        if ( ! empty( $_POST['getpaid_items'] ) ) {
749
+        if (!empty($_POST['getpaid_items'])) {
750 750
 
751
-            foreach ( $_POST['getpaid_items'] as $item_id => $args ) {
752
-                $item = new GetPaid_Form_Item( $item_id );
751
+            foreach ($_POST['getpaid_items'] as $item_id => $args) {
752
+                $item = new GetPaid_Form_Item($item_id);
753 753
 
754
-                if ( $item->exists() ) {
755
-                    $item->set_price( getpaid_standardize_amount( $args['price'] ) );
756
-                    $item->set_quantity( floatval( $args['quantity'] ) );
757
-                    $item->set_name( sanitize_text_field( $args['name'] ) );
758
-                    $item->set_description( wp_kses_post( $args['description'] ) );
759
-                    $invoice->add_item( $item );
754
+                if ($item->exists()) {
755
+                    $item->set_price(getpaid_standardize_amount($args['price']));
756
+                    $item->set_quantity(floatval($args['quantity']));
757
+                    $item->set_name(sanitize_text_field($args['name']));
758
+                    $item->set_description(wp_kses_post($args['description']));
759
+                    $invoice->add_item($item);
760 760
                 }
761 761
             }
762 762
 
763 763
         }
764 764
 
765
-        $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) );
765
+        $invoice->set_disable_taxes(!empty($_POST['disable_taxes']));
766 766
 
767 767
         // Maybe set the country, state, currency.
768
-        foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) {
769
-            if ( isset( $_POST[ $key ] ) ) {
770
-                $_key   = str_replace( 'wpinv_', '', $key );
768
+        foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) {
769
+            if (isset($_POST[$key])) {
770
+                $_key   = str_replace('wpinv_', '', $key);
771 771
                 $method = "set_$_key";
772
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
772
+                $invoice->$method(sanitize_text_field($_POST[$key]));
773 773
             }
774 774
         }
775 775
 
776
-        $discount = new WPInv_Discount( $invoice->get_discount_code() );
777
-        if ( $discount->exists() ) {
778
-            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
776
+        $discount = new WPInv_Discount($invoice->get_discount_code());
777
+        if ($discount->exists()) {
778
+            $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
779 779
         } else {
780
-            $invoice->remove_discount( 'discount_code' );
780
+            $invoice->remove_discount('discount_code');
781 781
         }
782 782
 
783 783
         // Save the invoice.
784 784
         $invoice->recalculate_total();
785 785
         $invoice->save();
786 786
         ob_start();
787
-        GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice );
787
+        GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice);
788 788
         $table = ob_get_clean();
789
-        wp_send_json_success( compact( 'table' ) );
789
+        wp_send_json_success(compact('table'));
790 790
     }
791 791
 
792 792
     /**
@@ -795,42 +795,42 @@  discard block
 block discarded – undo
795 795
     public static function admin_add_invoice_item() {
796 796
 
797 797
         // Verify nonce.
798
-        check_ajax_referer( 'wpinv-nonce' );
798
+        check_ajax_referer('wpinv-nonce');
799 799
 
800
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
800
+        if (!wpinv_current_user_can_manage_invoicing()) {
801 801
             exit;
802 802
         }
803 803
 
804 804
         // We need an invoice and item.
805
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
805
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
806 806
             exit;
807 807
         }
808 808
 
809 809
         // Fetch the invoice.
810
-        $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) );
810
+        $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id']));
811 811
         $alert   = false;
812 812
 
813 813
         // Ensure it exists and its not been paid for.
814
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
814
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
815 815
             exit;
816 816
         }
817 817
 
818 818
         // Add the item.
819
-        $item  = new GetPaid_Form_Item( (int) $_POST['item_id'] );
820
-        $error = $invoice->add_item( $item );
819
+        $item  = new GetPaid_Form_Item((int) $_POST['item_id']);
820
+        $error = $invoice->add_item($item);
821 821
 
822
-        if ( is_wp_error( $error ) ) {
822
+        if (is_wp_error($error)) {
823 823
             $alert = $error->get_error_message();
824
-            wp_send_json_success( compact( 'alert' ) );
824
+            wp_send_json_success(compact('alert'));
825 825
         }
826 826
 
827 827
         // Save the invoice.
828 828
         $invoice->recalculate_total();
829 829
         $invoice->save();
830 830
         ob_start();
831
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
831
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
832 832
         $row = ob_get_clean();
833
-        wp_send_json_success( compact( 'row' ) );
833
+        wp_send_json_success(compact('row'));
834 834
     }
835 835
 
836 836
     /**
@@ -839,39 +839,39 @@  discard block
 block discarded – undo
839 839
     public static function add_invoice_items() {
840 840
 
841 841
         // Verify nonce.
842
-        check_ajax_referer( 'wpinv-nonce' );
842
+        check_ajax_referer('wpinv-nonce');
843 843
 
844
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
844
+        if (!wpinv_current_user_can_manage_invoicing()) {
845 845
             exit;
846 846
         }
847 847
 
848 848
         // We need an invoice and items.
849
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
849
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
850 850
             exit;
851 851
         }
852 852
 
853 853
         // Fetch the invoice.
854
-        $invoice = new WPInv_Invoice( wpinv_clean( $_POST['post_id'] ) );
854
+        $invoice = new WPInv_Invoice(wpinv_clean($_POST['post_id']));
855 855
         $alert   = false;
856 856
 
857 857
         // Ensure it exists and its not been paid for.
858
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
858
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
859 859
             exit;
860 860
         }
861 861
 
862 862
         // Add the items.
863
-        foreach ( $_POST['items'] as $data ) {
863
+        foreach ($_POST['items'] as $data) {
864 864
 
865
-            $item = new GetPaid_Form_Item( (int) $data[ 'id' ] );
865
+            $item = new GetPaid_Form_Item((int) $data['id']);
866 866
 
867
-            if ( is_numeric( $data[ 'qty' ] ) && (float) $data[ 'qty' ] > 0 ) {
868
-                $item->set_quantity( floatval( $data[ 'qty' ] ) );
867
+            if (is_numeric($data['qty']) && (float) $data['qty'] > 0) {
868
+                $item->set_quantity(floatval($data['qty']));
869 869
             }
870 870
 
871
-            if ( $item->get_id() > 0 ) {
872
-                $error = $invoice->add_item( $item );
871
+            if ($item->get_id() > 0) {
872
+                $error = $invoice->add_item($item);
873 873
 
874
-                if ( is_wp_error( $error ) ) {
874
+                if (is_wp_error($error)) {
875 875
                     $alert = $error->get_error_message();
876 876
                 }
877 877
 
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
         // Return an array of invoice items.
887 887
         $items = array();
888 888
 
889
-        foreach ( $invoice->get_items() as $item ) {
890
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
889
+        foreach ($invoice->get_items() as $item) {
890
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
891 891
         }
892 892
 
893
-        wp_send_json_success( compact( 'items', 'alert' ) );
893
+        wp_send_json_success(compact('items', 'alert'));
894 894
     }
895 895
 
896 896
     /**
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
     public static function get_invoicing_items() {
900 900
 
901 901
         // Verify nonce.
902
-        check_ajax_referer( 'wpinv-nonce' );
902
+        check_ajax_referer('wpinv-nonce');
903 903
 
904
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
904
+        if (!wpinv_current_user_can_manage_invoicing()) {
905 905
             exit;
906 906
         }
907 907
 
908 908
         // We need a search term.
909
-        if ( empty( $_GET['search'] ) ) {
910
-            wp_send_json_success( array() );
909
+        if (empty($_GET['search'])) {
910
+            wp_send_json_success(array());
911 911
         }
912 912
 
913 913
         // Retrieve items.
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
             'orderby'        => 'title',
917 917
             'order'          => 'ASC',
918 918
             'posts_per_page' => -1,
919
-            'post_status'    => array( 'publish' ),
920
-            's'              => trim( $_GET['search'] ),
919
+            'post_status'    => array('publish'),
920
+            's'              => trim($_GET['search']),
921 921
             'meta_query'     => array(
922 922
                 array(
923 923
                     'key'       => '_wpinv_type',
@@ -927,21 +927,21 @@  discard block
 block discarded – undo
927 927
             )
928 928
         );
929 929
 
930
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
930
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
931 931
         $data  = array();
932 932
 
933
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) );
933
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id']));
934 934
 
935
-        foreach ( $items as $item ) {
936
-            $item      = new GetPaid_Form_Item( $item );
935
+        foreach ($items as $item) {
936
+            $item = new GetPaid_Form_Item($item);
937 937
             $data[] = array(
938 938
                 'id'        => (int) $item->get_id(),
939
-                'text'      => strip_tags( $item->get_name() ),
940
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
939
+                'text'      => strip_tags($item->get_name()),
940
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
941 941
             );
942 942
         }
943 943
 
944
-        wp_send_json_success( $data );
944
+        wp_send_json_success($data);
945 945
 
946 946
     }
947 947
 
@@ -951,37 +951,37 @@  discard block
 block discarded – undo
951 951
     public static function get_customers() {
952 952
 
953 953
         // Verify nonce.
954
-        check_ajax_referer( 'wpinv-nonce' );
954
+        check_ajax_referer('wpinv-nonce');
955 955
 
956
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
956
+        if (!wpinv_current_user_can_manage_invoicing()) {
957 957
             exit;
958 958
         }
959 959
 
960 960
         // We need a search term.
961
-        if ( empty( $_GET['search'] ) ) {
962
-            wp_send_json_success( array() );
961
+        if (empty($_GET['search'])) {
962
+            wp_send_json_success(array());
963 963
         }
964 964
 
965 965
         // Retrieve customers.
966 966
     
967 967
         $customer_args = array(
968
-            'fields'         => array( 'ID', 'user_email', 'display_name' ),
968
+            'fields'         => array('ID', 'user_email', 'display_name'),
969 969
             'orderby'        => 'display_name',
970
-            'search'         => '*' . sanitize_text_field( $_GET['search'] ) . '*',
971
-            'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
970
+            'search'         => '*' . sanitize_text_field($_GET['search']) . '*',
971
+            'search_columns' => array('user_login', 'user_email', 'display_name'),
972 972
         );
973 973
 
974
-        $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) );
974
+        $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args));
975 975
         $data      = array();
976 976
 
977
-        foreach ( $customers as $customer ) {
977
+        foreach ($customers as $customer) {
978 978
             $data[] = array(
979 979
                 'id'        => (int) $customer->ID,
980
-                'text'      => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ),
980
+                'text'      => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)),
981 981
             );
982 982
         }
983 983
 
984
-        wp_send_json_success( $data );
984
+        wp_send_json_success($data);
985 985
 
986 986
     }
987 987
 
@@ -991,28 +991,28 @@  discard block
 block discarded – undo
991 991
     public static function get_aui_states_field() {
992 992
 
993 993
         // Verify nonce.
994
-        check_ajax_referer( 'wpinv-nonce' );
994
+        check_ajax_referer('wpinv-nonce');
995 995
 
996 996
         // We need a country.
997
-        if ( empty( $_GET['country'] ) ) {
997
+        if (empty($_GET['country'])) {
998 998
             exit;
999 999
         }
1000 1000
 
1001
-        $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) );
1002
-        $state  = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state();
1003
-        $name   = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state';
1004
-        $class  = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm';
1001
+        $states = wpinv_get_country_states(sanitize_text_field($_GET['country']));
1002
+        $state  = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state();
1003
+        $name   = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state';
1004
+        $class  = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm';
1005 1005
 
1006
-        if ( empty( $states ) ) {
1006
+        if (empty($states)) {
1007 1007
 
1008 1008
             $html = aui()->input(
1009 1009
                 array(
1010 1010
                     'type'        => 'text',
1011 1011
                     'id'          => 'wpinv_state',
1012 1012
                     'name'        => $name,
1013
-                    'label'       => __( 'State', 'invoicing' ),
1013
+                    'label'       => __('State', 'invoicing'),
1014 1014
                     'label_type'  => 'vertical',
1015
-                    'placeholder' => __( 'State', 'invoicing' ),
1015
+                    'placeholder' => __('State', 'invoicing'),
1016 1016
                     'class'       => $class,
1017 1017
                     'value'       => $state,
1018 1018
                 )
@@ -1024,9 +1024,9 @@  discard block
 block discarded – undo
1024 1024
                 array(
1025 1025
                     'id'          => 'wpinv_state',
1026 1026
                     'name'        => $name,
1027
-                    'label'       => __( 'State', 'invoicing' ),
1027
+                    'label'       => __('State', 'invoicing'),
1028 1028
                     'label_type'  => 'vertical',
1029
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
1029
+                    'placeholder' => __('Select a state', 'invoicing'),
1030 1030
                     'class'       => $class,
1031 1031
                     'value'       => $state,
1032 1032
                     'options'     => $states,
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
         wp_send_json_success(
1041 1041
             array(
1042 1042
                 'html'   => $html,
1043
-                'select' => ! empty ( $states )
1043
+                'select' => !empty ($states)
1044 1044
             )
1045 1045
         );
1046 1046
 
@@ -1054,11 +1054,11 @@  discard block
 block discarded – undo
1054 1054
     public static function payment_form_refresh_prices() {
1055 1055
 
1056 1056
         // Check nonce.
1057
-        check_ajax_referer( 'getpaid_form_nonce' );
1057
+        check_ajax_referer('getpaid_form_nonce');
1058 1058
 
1059 1059
         // ... form fields...
1060
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
1061
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
1060
+        if (empty($_POST['getpaid_payment_form_submission'])) {
1061
+            _e('Error: Reload the page and try again.', 'invoicing');
1062 1062
             exit;
1063 1063
         }
1064 1064
 
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
         $submission = new GetPaid_Payment_Form_Submission();
1067 1067
 
1068 1068
         // Do we have an error?
1069
-        if ( ! empty( $submission->last_error ) ) {
1069
+        if (!empty($submission->last_error)) {
1070 1070
             wp_send_json_error(
1071 1071
                 array(
1072 1072
                     'code'  => $submission->last_error_code,
@@ -1076,12 +1076,12 @@  discard block
 block discarded – undo
1076 1076
         }
1077 1077
 
1078 1078
         // Prepare the response.
1079
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
1079
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
1080 1080
 
1081 1081
         // Filter the response.
1082
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
1082
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
1083 1083
 
1084
-        wp_send_json_success( $response );
1084
+        wp_send_json_success($response);
1085 1085
     }
1086 1086
 
1087 1087
     /**
@@ -1093,63 +1093,63 @@  discard block
 block discarded – undo
1093 1093
 	public static function file_upload() {
1094 1094
 
1095 1095
         // Check nonce.
1096
-        check_ajax_referer( 'getpaid_form_nonce' );
1096
+        check_ajax_referer('getpaid_form_nonce');
1097 1097
 
1098
-        if ( empty( $_POST['form_id'] ) || empty( $_POST['field_name'] ) || empty( $_FILES['file'] ) ) {
1099
-            wp_die( __( 'Bad Request', 'invoicing' ), 400 );
1098
+        if (empty($_POST['form_id']) || empty($_POST['field_name']) || empty($_FILES['file'])) {
1099
+            wp_die(__('Bad Request', 'invoicing'), 400);
1100 1100
         }
1101 1101
 
1102 1102
         // Fetch form.
1103
-        $form = new GetPaid_Payment_Form( intval( $_POST['form_id'] ) );
1103
+        $form = new GetPaid_Payment_Form(intval($_POST['form_id']));
1104 1104
 
1105
-        if ( ! $form->is_active() ) {
1106
-            wp_send_json_error( __( 'Payment form not active', 'invoicing' ) );
1105
+        if (!$form->is_active()) {
1106
+            wp_send_json_error(__('Payment form not active', 'invoicing'));
1107 1107
         }
1108 1108
 
1109 1109
         // Fetch appropriate field.
1110
-        $upload_field = current( wp_list_filter( $form->get_elements(), array( 'id' => sanitize_text_field( $_POST['field_name'] ) ) ) );
1111
-        if ( empty( $upload_field ) ) {
1112
-            wp_send_json_error( __( 'Invalid upload field.', 'invoicing' ) );
1110
+        $upload_field = current(wp_list_filter($form->get_elements(), array('id' => sanitize_text_field($_POST['field_name']))));
1111
+        if (empty($upload_field)) {
1112
+            wp_send_json_error(__('Invalid upload field.', 'invoicing'));
1113 1113
         }
1114 1114
 
1115 1115
         // Prepare allowed file types.
1116
-        $file_types = isset( $upload_field['file_types'] ) ? $upload_field['file_types'] : array( 'jpg|jpeg|jpe', 'gif', 'png' );
1116
+        $file_types = isset($upload_field['file_types']) ? $upload_field['file_types'] : array('jpg|jpeg|jpe', 'gif', 'png');
1117 1117
         $all_types  = getpaid_get_allowed_mime_types();
1118 1118
         $mime_types = array();
1119 1119
 
1120
-        foreach ( $file_types as $file_type ) {
1121
-            if ( isset( $all_types[ $file_type ] ) ) {
1122
-                $mime_types[] = $all_types[ $file_type ];
1120
+        foreach ($file_types as $file_type) {
1121
+            if (isset($all_types[$file_type])) {
1122
+                $mime_types[] = $all_types[$file_type];
1123 1123
             }
1124 1124
         }
1125 1125
 
1126
-        if ( ! in_array( $_FILES['file']['type'], $mime_types ) ) {
1127
-            wp_send_json_error( __( 'Unsupported file type.', 'invoicing' ) );
1126
+        if (!in_array($_FILES['file']['type'], $mime_types)) {
1127
+            wp_send_json_error(__('Unsupported file type.', 'invoicing'));
1128 1128
         }
1129 1129
 
1130 1130
         // Upload file.
1131
-        $file_name = explode( '.', strtolower( $_FILES['file']['name'] ) );
1132
-        $file_name = uniqid( 'getpaid-' ) . '.' . array_pop( $file_name );
1131
+        $file_name = explode('.', strtolower($_FILES['file']['name']));
1132
+        $file_name = uniqid('getpaid-') . '.' . array_pop($file_name);
1133 1133
 
1134 1134
         $uploaded = wp_upload_bits(
1135 1135
             $file_name,
1136 1136
             null,
1137
-            file_get_contents( $_FILES["file"]["tmp_name"] )
1137
+            file_get_contents($_FILES["file"]["tmp_name"])
1138 1138
         );
1139 1139
 
1140
-        if ( ! empty( $uploaded['error'] ) ) {
1141
-            wp_send_json_error( $uploaded['error'] );
1140
+        if (!empty($uploaded['error'])) {
1141
+            wp_send_json_error($uploaded['error']);
1142 1142
         }
1143 1143
 
1144 1144
         // Retrieve response.
1145 1145
         $response = sprintf(
1146 1146
             '<input type="hidden" name="%s[%s]" value="%s" />',
1147
-            esc_attr( $_POST['field_name'] ),
1148
-            esc_attr( $uploaded['url'] ),
1149
-            esc_attr( strtolower( $_FILES['file']['name'] ) )
1147
+            esc_attr($_POST['field_name']),
1148
+            esc_attr($uploaded['url']),
1149
+            esc_attr(strtolower($_FILES['file']['name']))
1150 1150
         );
1151 1151
 
1152
-        wp_send_json_success( $response );
1152
+        wp_send_json_success($response);
1153 1153
 
1154 1154
 	}
1155 1155
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-payment-form.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Payment_Form {
@@ -11,23 +11,23 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @param WP_Post $post
13 13
      */
14
-    public static function output_details( $post ) {
15
-        $details = get_post_meta( $post->ID, 'payment_form_data', true );
14
+    public static function output_details($post) {
15
+        $details = get_post_meta($post->ID, 'payment_form_data', true);
16 16
 
17
-        if ( ! is_array( $details ) ) {
17
+        if (!is_array($details)) {
18 18
             return;
19 19
         }
20 20
 
21 21
         echo '<div class="bsui"> <div class="form-row">';
22 22
 
23
-        foreach ( $details as $key => $value ) {
24
-            $key = esc_html( $key );
23
+        foreach ($details as $key => $value) {
24
+            $key = esc_html($key);
25 25
 
26
-            if ( is_array( $value ) ) {
27
-                $value = implode( ',', $value );
26
+            if (is_array($value)) {
27
+                $value = implode(',', $value);
28 28
             }
29 29
 
30
-            $value = wp_kses_post( $value );
30
+            $value = wp_kses_post($value);
31 31
             echo "<div class='col-12'><strong>$key:</strong></div><div class='col-12 form-group'>$value</div>";
32 32
         }
33 33
 
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @param WP_Post $post
42 42
      */
43
-    public static function output_shortcode( $post ) {
43
+    public static function output_shortcode($post) {
44 44
 
45
-        if ( ! is_numeric( $post ) ) {
45
+        if (!is_numeric($post)) {
46 46
             $post = $post->ID;
47 47
         }
48 48
 
49
-        if ( $post == wpinv_get_default_payment_form() ) {
49
+        if ($post == wpinv_get_default_payment_form()) {
50 50
             echo '&mdash;';
51 51
             return;
52 52
         }
Please login to merge, or discard this patch.