Passed
Push — master ( 32accd...dc49db )
by Brian
05:22
created
includes/admin/class-getpaid-admin.php 1 patch
Spacing   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,33 +54,33 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect' ) );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9);
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form'));
65
+		add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice'));
66
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
67
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
68
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
69
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
70
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
71
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
72
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
73
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
74
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
75
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
76
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
77
+		do_action('getpaid_init_admin_hooks', $this);
78 78
 
79 79
 		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
80
+		if (!empty($_GET['page'])) {
81
+			switch (sanitize_text_field($_GET['page'])) {
82 82
 				case 'gp-setup':
83
-					include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
83
+					include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php';
84 84
 					break;
85 85
 			}
86 86
 		}
@@ -94,37 +94,37 @@  discard block
 block discarded – undo
94 94
 	public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
97
+		$page    = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
98 98
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100
-        if ( ! empty( $current_screen->post_type ) ) {
100
+        if (!empty($current_screen->post_type)) {
101 101
 			$page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
105
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) {
105
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) {
106 106
 
107 107
             // Styles.
108
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
109
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
110
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
108
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
109
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
110
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
111 111
 
112 112
             // Scripts.
113
-            wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
113
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
114 114
 
115
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
116
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version );
117
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
115
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
116
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
117
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
118 118
 
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+		if ('wpi_payment_form' == $page && $editing) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
126
+		if ($page == 'wpinv-subscriptions') {
127
+			wp_enqueue_script('postbox');
128 128
 		}
129 129
 
130 130
     }
@@ -137,31 +137,31 @@  discard block
 block discarded – undo
137 137
         global $post;
138 138
 
139 139
 		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
140
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days',
141 141
 		);
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+		if ($date_range['period'] == 'custom') {
144 144
 
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
145
+			if (isset($_GET['from'])) {
146
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
147 147
 			}
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
149
+			if (isset($_GET['to'])) {
150
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
151 151
 			}
152 152
 }
153 153
 
154 154
         $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,39 +170,39 @@  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' ),
192
-			'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
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
+			'graphs'                    => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())),
193 193
         );
194 194
 
195
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
196 196
 
197
-			$invoice              = new WPInv_Invoice( $post );
197
+			$invoice              = new WPInv_Invoice($post);
198 198
 			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
199
+				__('Save %s', 'invoicing'),
200
+				ucfirst($invoice->get_invoice_quote_type())
201 201
 			);
202 202
 
203 203
 			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
204
+				__('%s Description', 'invoicing'),
205
+				ucfirst($invoice->get_invoice_quote_type())
206 206
 			);
207 207
 
208 208
 		}
@@ -216,24 +216,24 @@  discard block
 block discarded – undo
216 216
 	 * @param  string $footer_text
217 217
 	 * @return string
218 218
 	 */
219
-	public function admin_footer_text( $footer_text ) {
219
+	public function admin_footer_text($footer_text) {
220 220
 		global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
222
+		$page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
223 223
 
224
-        if ( ! empty( $current_screen->post_type ) ) {
224
+        if (!empty($current_screen->post_type)) {
225 225
 			$page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
229
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
230 230
 
231 231
 			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
233 233
 
234
-				$rating_url  = esc_url(
234
+				$rating_url = esc_url(
235 235
 					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
237 237
 						'getpaid-nonce',
238 238
 						'getpaid-nonce'
239 239
                     )
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
 				$footer_text = sprintf(
243 243
 					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
245 245
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246 246
 				);
247 247
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 				$footer_text = sprintf(
251 251
 					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
252
+					__('Thank you for using %s!', 'invoicing'),
253 253
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254 254
 				);
255 255
 
@@ -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,24 +311,24 @@  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
-        $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
317
+        $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
318 318
 
319
-        if ( ! empty( $current_screen->post_type ) ) {
319
+        if (!empty($current_screen->post_type)) {
320 320
 			$page = $current_screen->post_type;
321 321
         }
322 322
 
323
-        if ( false !== stripos( $page, 'wpi' ) ) {
324
-            $classes .= ' wpi-' . sanitize_key( $page );
323
+        if (false !== stripos($page, 'wpi')) {
324
+            $classes .= ' wpi-' . sanitize_key($page);
325 325
         }
326 326
 
327
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
327
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
328 328
             $classes .= ' wpinv-cpt wpinv';
329 329
 		}
330 330
 
331
-		if ( getpaid_is_invoice_post_type( $page ) ) {
331
+		if (getpaid_is_invoice_post_type($page)) {
332 332
             $classes .= ' getpaid-is-invoice-cpt';
333 333
         }
334 334
 
@@ -347,21 +347,21 @@  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
 
354 354
         new AyeCode_Connect_Helper(
355 355
             array(
356
-				'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
357
-				'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
358
-				'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
359
-				'connect_button'    => __( 'Connect Site', 'invoicing' ),
360
-				'connecting_button' => __( 'Connecting...', 'invoicing' ),
361
-				'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
362
-				'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
356
+				'connect_title'     => __('WP Invoicing - an AyeCode product!', 'invoicing'),
357
+				'connect_external'  => __('Please confirm you wish to connect your site?', 'invoicing'),
358
+				'connect'           => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'),
359
+				'connect_button'    => __('Connect Site', 'invoicing'),
360
+				'connecting_button' => __('Connecting...', 'invoicing'),
361
+				'error_localhost'   => __('This service will only work with a live domain, not a localhost.', 'invoicing'),
362
+				'error'             => __('Something went wrong, please refresh and try again.', 'invoicing'),
363 363
             ),
364
-            array( 'wpi-addons' )
364
+            array('wpi-addons')
365 365
         );
366 366
 
367 367
     }
@@ -373,20 +373,20 @@  discard block
 block discarded – undo
373 373
 	 */
374 374
 	public function activation_redirect() {
375 375
 
376
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
376
+		$redirected = get_option('wpinv_redirected_to_settings');
377 377
 
378
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
379 379
 			return;
380 380
 		}
381 381
 
382 382
 		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
384 384
 			return;
385 385
 		}
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+	    update_option('wpinv_redirected_to_settings', 1);
388 388
 
389
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
389
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
390 390
         exit;
391 391
 
392 392
 	}
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
      */
397 397
     public function maybe_do_admin_action() {
398 398
 
399
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
400
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
401
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
399
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
400
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
401
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
402 402
         }
403 403
 
404 404
     }
@@ -408,24 +408,24 @@  discard block
 block discarded – undo
408 408
 	 *
409 409
 	 * @param array $args
410 410
      */
411
-    public function duplicate_invoice( $args ) {
411
+    public function duplicate_invoice($args) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
413
+		if (empty($args['invoice_id'])) {
414 414
 			return;
415 415
 		}
416 416
 
417
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
417
+		$invoice = new WPInv_Invoice((int) $args['invoice_id']);
418 418
 
419
-		if ( ! $invoice->exists() ) {
419
+		if (!$invoice->exists()) {
420 420
 			return;
421 421
 		}
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
423
+		$new_invoice = getpaid_duplicate_invoice($invoice);
424 424
 		$new_invoice->save();
425 425
 
426
-		if ( $new_invoice->exists() ) {
426
+		if ($new_invoice->exists()) {
427 427
 
428
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
428
+			getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box'));
429 429
 
430 430
 			wp_safe_redirect(
431 431
 				add_query_arg(
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 						'action' => 'edit',
434 434
 						'post'   => $new_invoice->get_id(),
435 435
 					),
436
-					admin_url( 'post.php' )
436
+					admin_url('post.php')
437 437
 				)
438 438
 			);
439 439
 			exit;
440 440
 
441 441
 		}
442 442
 
443
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
443
+		getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box'));
444 444
 
445 445
 	}
446 446
 
@@ -449,34 +449,34 @@  discard block
 block discarded – undo
449 449
 	 *
450 450
 	 * @param array $args
451 451
      */
452
-    public function duplicate_payment_form( $args ) {
452
+    public function duplicate_payment_form($args) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
454
+		if (empty($args['form_id'])) {
455 455
 			return;
456 456
 		}
457 457
 
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
458
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
459 459
 
460
-		if ( ! $form->exists() ) {
460
+		if (!$form->exists()) {
461 461
 			return;
462 462
 		}
463 463
 
464 464
 		$new_form = new GetPaid_Payment_Form();
465
-		$new_form->set_author( $form->get_author( 'edit' ) );
466
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
468
-		$new_form->set_items( $form->get_items( 'edit' ) );
465
+		$new_form->set_author($form->get_author('edit'));
466
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
467
+		$new_form->set_elements($form->get_elements('edit'));
468
+		$new_form->set_items($form->get_items('edit'));
469 469
 		$new_form->save();
470 470
 
471
-		if ( $new_form->exists() ) {
472
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
471
+		if ($new_form->exists()) {
472
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
473
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
474 474
 		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
475
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
476
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
477 477
 		}
478 478
 
479
-		wp_redirect( $url );
479
+		wp_redirect($url);
480 480
 		exit;
481 481
 	}
482 482
 
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 	 *
486 486
 	 * @param array $args
487 487
      */
488
-    public function send_customer_invoice( $args ) {
489
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
488
+    public function send_customer_invoice($args) {
489
+		getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
490
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
491 491
 		exit;
492 492
 	}
493 493
 
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 * @param array $args
498 498
      */
499
-    public function send_customer_payment_reminder( $args ) {
500
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
499
+    public function send_customer_payment_reminder($args) {
500
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
501 501
 
502
-		if ( $sent ) {
503
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
502
+		if ($sent) {
503
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
504 504
 		} else {
505
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
505
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
506 506
 		}
507 507
 
508
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
508
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
509 509
 		exit;
510 510
 	}
511 511
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
      */
516 516
     public function admin_reset_tax_rates() {
517 517
 
518
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
518
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
519
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
520 520
 		exit;
521 521
 
522 522
 	}
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
     public function admin_create_missing_pages() {
529 529
 		$installer = new GetPaid_Installer();
530 530
 		$installer->create_pages();
531
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
531
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
532
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
533 533
 		exit;
534 534
 	}
535 535
 
@@ -541,35 +541,35 @@  discard block
 block discarded – undo
541 541
 		global $wpdb;
542 542
 		$installer = new GetPaid_Installer();
543 543
 
544
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
544
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
545 545
 			$installer->create_subscriptions_table();
546 546
 
547
-			if ( $wpdb->last_error !== '' ) {
548
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
547
+			if ($wpdb->last_error !== '') {
548
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
549 549
 			}
550 550
 		}
551 551
 
552
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
552
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
553 553
 			$installer->create_invoices_table();
554 554
 
555
-			if ( $wpdb->last_error !== '' ) {
556
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
555
+			if ($wpdb->last_error !== '') {
556
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
557 557
 			}
558 558
 		}
559 559
 
560
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
560
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
561 561
 			$installer->create_invoice_items_table();
562 562
 
563
-			if ( $wpdb->last_error !== '' ) {
564
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
563
+			if ($wpdb->last_error !== '') {
564
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
565 565
 			}
566 566
 		}
567 567
 
568
-		if ( ! $this->has_notices() ) {
569
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
568
+		if (!$this->has_notices()) {
569
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
570 570
 		}
571 571
 
572
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
572
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
573 573
 		exit;
574 574
 	}
575 575
 
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 		$installer->migrate_old_invoices();
585 585
 
586 586
 		// Show an admin message.
587
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
587
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
588 588
 
589 589
 		// Redirect the admin.
590
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
590
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
591 591
 		exit;
592 592
 
593 593
 	}
@@ -599,18 +599,18 @@  discard block
 block discarded – undo
599 599
     public function admin_download_customers() {
600 600
 		global $wpdb;
601 601
 
602
-		$output = fopen( 'php://output', 'w' ) || die( esc_html__( 'Unsupported server', 'invoicing' ) );
602
+		$output = fopen('php://output', 'w') || die(esc_html__('Unsupported server', 'invoicing'));
603 603
 
604
-		header( 'Content-Type:text/csv' );
605
-		header( 'Content-Disposition:attachment;filename=customers.csv' );
604
+		header('Content-Type:text/csv');
605
+		header('Content-Disposition:attachment;filename=customers.csv');
606 606
 
607 607
 		$post_types = '';
608 608
 
609
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
610
-			$post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
609
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
610
+			$post_types .= $wpdb->prepare('post_type=%s OR ', $post_type);
611 611
 		}
612 612
 
613
-		$post_types = rtrim( $post_types, ' OR' );
613
+		$post_types = rtrim($post_types, ' OR');
614 614
 
615 615
 		$customers = $wpdb->get_col(
616 616
 			$wpdb->prepare(
@@ -619,58 +619,58 @@  discard block
 block discarded – undo
619 619
 		);
620 620
 
621 621
 		$columns = array(
622
-			'name'       => __( 'Name', 'invoicing' ),
623
-			'email'      => __( 'Email', 'invoicing' ),
624
-			'country'    => __( 'Country', 'invoicing' ),
625
-			'state'      => __( 'State', 'invoicing' ),
626
-			'city'       => __( 'City', 'invoicing' ),
627
-			'zip'        => __( 'ZIP', 'invoicing' ),
628
-			'address'    => __( 'Address', 'invoicing' ),
629
-			'phone'      => __( 'Phone', 'invoicing' ),
630
-			'company'    => __( 'Company', 'invoicing' ),
631
-			'company_id' => __( 'Company ID', 'invoicing' ),
632
-			'invoices'   => __( 'Invoices', 'invoicing' ),
633
-			'total_raw'  => __( 'Total Spend', 'invoicing' ),
634
-			'signup'     => __( 'Date created', 'invoicing' ),
622
+			'name'       => __('Name', 'invoicing'),
623
+			'email'      => __('Email', 'invoicing'),
624
+			'country'    => __('Country', 'invoicing'),
625
+			'state'      => __('State', 'invoicing'),
626
+			'city'       => __('City', 'invoicing'),
627
+			'zip'        => __('ZIP', 'invoicing'),
628
+			'address'    => __('Address', 'invoicing'),
629
+			'phone'      => __('Phone', 'invoicing'),
630
+			'company'    => __('Company', 'invoicing'),
631
+			'company_id' => __('Company ID', 'invoicing'),
632
+			'invoices'   => __('Invoices', 'invoicing'),
633
+			'total_raw'  => __('Total Spend', 'invoicing'),
634
+			'signup'     => __('Date created', 'invoicing'),
635 635
 		);
636 636
 
637 637
 		// Output the csv column headers.
638
-		fputcsv( $output, array_values( $columns ) );
638
+		fputcsv($output, array_values($columns));
639 639
 
640 640
 		// Loop through
641 641
 		$table = new WPInv_Customers_Table();
642
-		foreach ( $customers as $customer_id ) {
642
+		foreach ($customers as $customer_id) {
643 643
 
644
-			$user = get_user_by( 'id', $customer_id );
644
+			$user = get_user_by('id', $customer_id);
645 645
 			$row  = array();
646
-			if ( empty( $user ) ) {
646
+			if (empty($user)) {
647 647
 				continue;
648 648
 			}
649 649
 
650
-			foreach ( array_keys( $columns ) as $column ) {
650
+			foreach (array_keys($columns) as $column) {
651 651
 
652 652
 				$method = 'column_' . $column;
653 653
 
654
-				if ( 'name' == $column ) {
655
-					$value = esc_html( $user->display_name );
656
-				} elseif ( 'email' == $column ) {
657
-					$value = sanitize_email( $user->user_email );
658
-				} elseif ( is_callable( array( $table, $method ) ) ) {
659
-					$value = strip_tags( $table->$method( $user ) );
654
+				if ('name' == $column) {
655
+					$value = esc_html($user->display_name);
656
+				} elseif ('email' == $column) {
657
+					$value = sanitize_email($user->user_email);
658
+				} elseif (is_callable(array($table, $method))) {
659
+					$value = strip_tags($table->$method($user));
660 660
 				}
661 661
 
662
-				if ( empty( $value ) ) {
663
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
662
+				if (empty($value)) {
663
+					$value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));
664 664
 				}
665 665
 
666 666
 				$row[] = $value;
667 667
 
668 668
 			}
669 669
 
670
-			fputcsv( $output, $row );
670
+			fputcsv($output, $row);
671 671
 		}
672 672
 
673
-		fclose( $output );
673
+		fclose($output);
674 674
 		exit;
675 675
 
676 676
 	}
@@ -680,27 +680,27 @@  discard block
 block discarded – undo
680 680
 	 *
681 681
 	 * @param array $data
682 682
      */
683
-    public function admin_install_plugin( $data ) {
683
+    public function admin_install_plugin($data) {
684 684
 
685
-		if ( ! empty( $data['plugins'] ) ) {
685
+		if (!empty($data['plugins'])) {
686 686
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687 687
 			wp_cache_flush();
688 688
 
689
-			foreach ( $data['plugins'] as $slug => $file ) {
690
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
-				$installed  = $upgrader->install( $plugin_zip );
689
+			foreach ($data['plugins'] as $slug => $file) {
690
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
691
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
692
+				$installed  = $upgrader->install($plugin_zip);
693 693
 
694
-				if ( ! is_wp_error( $installed ) && $installed ) {
695
-					activate_plugin( $file, '', false, true );
694
+				if (!is_wp_error($installed) && $installed) {
695
+					activate_plugin($file, '', false, true);
696 696
 				} else {
697
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
697
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
698 698
 				}
699 699
 }
700 700
 }
701 701
 
702
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
703
-		wp_safe_redirect( $redirect );
702
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
703
+		wp_safe_redirect($redirect);
704 704
 		exit;
705 705
 
706 706
 	}
@@ -710,41 +710,41 @@  discard block
 block discarded – undo
710 710
 	 *
711 711
 	 * @param array $data
712 712
      */
713
-    public function admin_connect_gateway( $data ) {
713
+    public function admin_connect_gateway($data) {
714 714
 
715
-		if ( ! empty( $data['plugin'] ) ) {
715
+		if (!empty($data['plugin'])) {
716 716
 
717
-			$gateway     = sanitize_key( $data['plugin'] );
718
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
717
+			$gateway     = sanitize_key($data['plugin']);
718
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
719 719
 
720
-			if ( ! empty( $connect_url ) ) {
721
-				wp_redirect( $connect_url );
720
+			if (!empty($connect_url)) {
721
+				wp_redirect($connect_url);
722 722
 				exit;
723 723
 			}
724 724
 
725
-			if ( 'stripe' == $data['plugin'] ) {
725
+			if ('stripe' == $data['plugin']) {
726 726
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
727 727
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
728 728
 				wp_cache_flush();
729 729
 
730
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
731
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
732
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
733
-					$upgrader->install( $plugin_zip );
730
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
731
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
732
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
733
+					$upgrader->install($plugin_zip);
734 734
 				}
735 735
 
736
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
736
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
737 737
 			}
738 738
 
739
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
740
-			if ( ! empty( $connect_url ) ) {
741
-				wp_redirect( $connect_url );
739
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
740
+			if (!empty($connect_url)) {
741
+				wp_redirect($connect_url);
742 742
 				exit;
743 743
 			}
744 744
 }
745 745
 
746
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
747
-		wp_safe_redirect( $redirect );
746
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
747
+		wp_safe_redirect($redirect);
748 748
 		exit;
749 749
 
750 750
 	}
@@ -758,35 +758,35 @@  discard block
 block discarded – undo
758 758
 
759 759
 		// Fetch all invoices that have discount codes.
760 760
 		$table    = $wpdb->prefix . 'getpaid_invoices';
761
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
761
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
762 762
 
763
-		foreach ( $invoices as $invoice ) {
763
+		foreach ($invoices as $invoice) {
764 764
 
765
-			$invoice = new WPInv_Invoice( $invoice );
765
+			$invoice = new WPInv_Invoice($invoice);
766 766
 
767
-			if ( ! $invoice->exists() ) {
767
+			if (!$invoice->exists()) {
768 768
 				continue;
769 769
 			}
770 770
 
771 771
 			// Abort if the discount does not exist or does not apply here.
772
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
773
-			if ( ! $discount->exists() ) {
772
+			$discount = new WPInv_Discount($invoice->get_discount_code());
773
+			if (!$discount->exists()) {
774 774
 				continue;
775 775
 			}
776 776
 
777
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
777
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
778 778
 			$invoice->recalculate_total();
779 779
 
780
-			if ( $invoice->get_total_discount() > 0 ) {
780
+			if ($invoice->get_total_discount() > 0) {
781 781
 				$invoice->save();
782 782
 			}
783 783
 }
784 784
 
785 785
 		// Show an admin message.
786
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
786
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
787 787
 
788 788
 		// Redirect the admin.
789
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
789
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
790 790
 		exit;
791 791
 
792 792
 	}
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
      * @return array
799 799
 	 */
800 800
 	public function get_notices() {
801
-		$notices = get_option( 'wpinv_admin_notices' );
802
-        return is_array( $notices ) ? $notices : array();
801
+		$notices = get_option('wpinv_admin_notices');
802
+        return is_array($notices) ? $notices : array();
803 803
 	}
804 804
 
805 805
 	/**
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
      * @return array
810 810
 	 */
811 811
 	public function has_notices() {
812
-		return count( $this->get_notices() ) > 0;
812
+		return count($this->get_notices()) > 0;
813 813
 	}
814 814
 
815 815
 	/**
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 	 * @since       1.0.19
820 820
 	 */
821 821
 	public function clear_notices() {
822
-		delete_option( 'wpinv_admin_notices' );
822
+		delete_option('wpinv_admin_notices');
823 823
 	}
824 824
 
825 825
 	/**
@@ -828,16 +828,16 @@  discard block
 block discarded – undo
828 828
 	 * @access      public
829 829
 	 * @since       1.0.19
830 830
 	 */
831
-	public function save_notice( $type, $message ) {
831
+	public function save_notice($type, $message) {
832 832
 		$notices = $this->get_notices();
833 833
 
834
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
835
-			$notices[ $type ] = array();
834
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
835
+			$notices[$type] = array();
836 836
 		}
837 837
 
838
-		$notices[ $type ][] = $message;
838
+		$notices[$type][] = $message;
839 839
 
840
-		update_option( 'wpinv_admin_notices', $notices );
840
+		update_option('wpinv_admin_notices', $notices);
841 841
 	}
842 842
 
843 843
 	/**
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 * @access      public
848 848
 	 * @since       1.0.19
849 849
 	 */
850
-	public function show_success( $msg ) {
851
-		$this->save_notice( 'success', $msg );
850
+	public function show_success($msg) {
851
+		$this->save_notice('success', $msg);
852 852
 	}
853 853
 
854 854
 	/**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @param       string $msg The message to qeue.
859 859
 	 * @since       1.0.19
860 860
 	 */
861
-	public function show_error( $msg ) {
862
-		$this->save_notice( 'error', $msg );
861
+	public function show_error($msg) {
862
+		$this->save_notice('error', $msg);
863 863
 	}
864 864
 
865 865
 	/**
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 	 * @param       string $msg The message to qeue.
870 870
 	 * @since       1.0.19
871 871
 	 */
872
-	public function show_warning( $msg ) {
873
-		$this->save_notice( 'warning', $msg );
872
+	public function show_warning($msg) {
873
+		$this->save_notice('warning', $msg);
874 874
 	}
875 875
 
876 876
 	/**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 	 * @param       string $msg The message to qeue.
881 881
 	 * @since       1.0.19
882 882
 	 */
883
-	public function show_info( $msg ) {
884
-		$this->save_notice( 'info', $msg );
883
+	public function show_info($msg) {
884
+		$this->save_notice('info', $msg);
885 885
 	}
886 886
 
887 887
 	/**
@@ -895,29 +895,29 @@  discard block
 block discarded – undo
895 895
         $notices = $this->get_notices();
896 896
         $this->clear_notices();
897 897
 
898
-		foreach ( $notices as $type => $messages ) {
898
+		foreach ($notices as $type => $messages) {
899 899
 
900
-			if ( ! is_array( $messages ) ) {
900
+			if (!is_array($messages)) {
901 901
 				continue;
902 902
 			}
903 903
 
904
-            $type  = esc_attr( $type );
905
-			foreach ( $messages as $message ) {
906
-				echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
904
+            $type = esc_attr($type);
905
+			foreach ($messages as $message) {
906
+				echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>");
907 907
             }
908 908
 }
909 909
 
910
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
910
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
911 911
 
912
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
913
-				$url     = wp_nonce_url(
914
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
912
+			if (!is_numeric(wpinv_get_option($page, false))) {
913
+				$url = wp_nonce_url(
914
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
915 915
 					'getpaid-nonce',
916 916
 					'getpaid-nonce'
917 917
 				);
918
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
919
-				$message2 = __( 'Generate Pages', 'invoicing' );
920
-				echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
918
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
919
+				$message2 = __('Generate Pages', 'invoicing');
920
+				echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>");
921 921
 				break;
922 922
 			}
923 923
 }
Please login to merge, or discard this patch.
includes/admin/views/wizard-settings.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -4,15 +4,15 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 
11 11
 <div class="card shadow-sm my-5">
12 12
 
13 13
     <form method="post" class="text-left card-body" action="options.php">
14
-        <?php settings_fields( 'wpinv_settings' ); ?>
15
-        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>">
14
+        <?php settings_fields('wpinv_settings'); ?>
15
+        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>">
16 16
 
17 17
         <table class="gp-setup-maps w-100 " cellspacing="0">
18 18
             <tbody>
@@ -20,28 +20,28 @@  discard block
 block discarded – undo
20 20
 
21 21
                     global $wp_settings_fields;
22 22
 
23
-                    if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) {
24
-					$settings = $wp_settings_fields[ $page ][ $section ];
23
+                    if (isset($wp_settings_fields[$page][$section])) {
24
+					$settings = $wp_settings_fields[$page][$section];
25 25
 
26
-					foreach ( $settings as $field ) {
26
+					foreach ($settings as $field) {
27 27
 
28
-						$name      = esc_attr( $field['id'] );
29
-						$id        = sanitize_key( $name );
28
+						$name      = esc_attr($field['id']);
29
+						$id        = sanitize_key($name);
30 30
 						$class     = '';
31
-						$value     = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
32
-						$value     = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) );
33
-						$help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : '';
34
-						$type      = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) );
35
-						$label     = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : '';
36
-						$options   = isset( $field['args']['options'] ) ? $field['args']['options'] : array();
37
-
38
-						if ( false !== strpos( $name, 'logo' ) ) {
31
+						$value     = isset($field['args']['std']) ? $field['args']['std'] : '';
32
+						$value     = wpinv_clean(wpinv_get_option($field['args']['id'], $value));
33
+						$help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : '';
34
+						$type      = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback']));
35
+						$label     = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : '';
36
+						$options   = isset($field['args']['options']) ? $field['args']['options'] : array();
37
+
38
+						if (false !== strpos($name, 'logo')) {
39 39
 							$type = 'hidden';
40 40
                             }
41 41
 
42
-						if ( 'country_states' == $type ) {
42
+						if ('country_states' == $type) {
43 43
 
44
-							if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) {
44
+							if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) {
45 45
 								$type = 'text';
46 46
                                 } else {
47 47
 								$type = 'select';
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 							$class = 'getpaid_js_field-state';
51 51
                             }
52 52
 
53
-						if ( 'wpinv_settings[default_country]' == $name ) {
53
+						if ('wpinv_settings[default_country]' == $name) {
54 54
 							$class = 'getpaid_js_field-country';
55 55
                             }
56 56
 
57
-						switch ( $type ) {
57
+						switch ($type) {
58 58
 
59 59
 							case 'hidden':
60
-								echo "<input type='hidden' id='" . esc_attr( $id ) . "' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />";
60
+								echo "<input type='hidden' id='" . esc_attr($id) . "' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />";
61 61
 								break;
62 62
 							case 'text':
63 63
                             case 'number':
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 								'type'        => $type,
67 67
 								'id'          => $id,
68 68
 								'name'        => $name,
69
-								'value'       => is_scalar( $value ) ? esc_attr( $value ) : '',
69
+								'value'       => is_scalar($value) ? esc_attr($value) : '',
70 70
 								'required'    => false,
71 71
 								'help_text'   => $help_text,
72 72
 								'label'       => $label,
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 									array(
83 83
 										'id'          => $id,
84 84
 										'name'        => $name,
85
-										'value'       => is_scalar( $value ) ? esc_textarea( $value ) : '',
85
+										'value'       => is_scalar($value) ? esc_textarea($value) : '',
86 86
 										'required'    => false,
87 87
 										'help_text'   => $help_text,
88 88
 										'label'       => $label,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 										'id'          => $id,
102 102
 										'name'        => $name,
103 103
 										'placeholder' => '',
104
-										'value'       => is_scalar( $value ) ? esc_attr( $value ) : '',
104
+										'value'       => is_scalar($value) ? esc_attr($value) : '',
105 105
 										'required'    => false,
106 106
 										'help_text'   => $help_text,
107 107
 										'label'       => $label,
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 				<input
128 128
                     type="submit"
129 129
                     class="btn btn-primary button-next"
130
-				    value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
130
+				    value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/>
131 131
 			</p>
132 132
         </table>
133 133
     </form>
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin-setup-wizard.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @version     2.4.0
11 11
  * @info        GetPaid Setup Wizard.
12 12
  */
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15 15
 /**
16 16
  * GetPaid_Admin_Setup_Wizard class.
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public function __construct() {
46 46
 
47
-		if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) {
48
-			add_action( 'admin_menu', array( $this, 'add_menu' ) );
49
-			add_action( 'current_screen', array( $this, 'setup_wizard' ) );
47
+		if (apply_filters('getpaid_enable_setup_wizard', true) && wpinv_current_user_can_manage_invoicing()) {
48
+			add_action('admin_menu', array($this, 'add_menu'));
49
+			add_action('current_screen', array($this, 'setup_wizard'));
50 50
 		}
51 51
 
52 52
 	}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @since 2.4.0
58 58
 	 */
59 59
 	public function add_menu() {
60
-		add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' );
60
+		add_dashboard_page('', '', wpinv_get_capability(), 'gp-setup', '');
61 61
 	}
62 62
 
63 63
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function setup_wizard() {
69 69
 
70
-		if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) {
70
+		if (isset($_GET['page']) && 'gp-setup' === $_GET['page']) {
71 71
 			$this->setup_globals();
72 72
 			$this->maybe_save_current_step();
73 73
 			$this->display_wizard();
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 	 * @since 2.4.0
95 95
 	 */
96 96
 	protected function maybe_save_current_step() {
97
-		if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) {
98
-			call_user_func( $this->steps[ $this->step ]['handler'], $this );
97
+		if (!empty($_POST['save_step']) && is_callable($this->steps[$this->step]['handler'])) {
98
+			call_user_func($this->steps[$this->step]['handler'], $this);
99 99
 		}
100 100
 	}
101 101
 
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 		$steps = array(
111 111
 
112 112
 			'introduction'     => array(
113
-				'name'    => __( 'Introduction', 'invoicing' ),
114
-				'view'    => array( $this, 'setup_introduction' ),
113
+				'name'    => __('Introduction', 'invoicing'),
114
+				'view'    => array($this, 'setup_introduction'),
115 115
 				'handler' => '',
116 116
 			),
117 117
 
118 118
 			'business_details' => array(
119
-				'name'    => __( 'Business Details', 'invoicing' ),
120
-				'view'    => array( $this, 'setup_business' ),
119
+				'name'    => __('Business Details', 'invoicing'),
120
+				'view'    => array($this, 'setup_business'),
121 121
 				'handler' => '',
122 122
 			),
123 123
 
124 124
 			'currency'         => array(
125
-				'name'    => __( 'Currency', 'invoicing' ),
126
-				'view'    => array( $this, 'setup_currency' ),
125
+				'name'    => __('Currency', 'invoicing'),
126
+				'view'    => array($this, 'setup_currency'),
127 127
 				'handler' => '',
128 128
 			),
129 129
 
130 130
 			'payments'         => array(
131
-				'name'    => __( 'Payment Gateways', 'invoicing' ),
132
-				'view'    => array( $this, 'setup_payments' ),
133
-				'handler' => array( $this, 'setup_payments_save' ),
131
+				'name'    => __('Payment Gateways', 'invoicing'),
132
+				'view'    => array($this, 'setup_payments'),
133
+				'handler' => array($this, 'setup_payments_save'),
134 134
 			),
135 135
 
136 136
 			'recommend'        => array(
137
-				'name'    => __( 'Recommend', 'invoicing' ),
138
-				'view'    => array( $this, 'setup_recommend' ),
137
+				'name'    => __('Recommend', 'invoicing'),
138
+				'view'    => array($this, 'setup_recommend'),
139 139
 				'handler' => '',
140 140
 			),
141 141
 
142 142
 			'next_steps'       => array(
143
-				'name'    => __( 'Get Paid', 'invoicing' ),
144
-				'view'    => array( $this, 'setup_ready' ),
143
+				'name'    => __('Get Paid', 'invoicing'),
144
+				'view'    => array($this, 'setup_ready'),
145 145
 				'handler' => '',
146 146
 			),
147 147
 
148 148
 		);
149 149
 
150
-		return apply_filters( 'getpaid_setup_wizard_steps', $steps );
150
+		return apply_filters('getpaid_setup_wizard_steps', $steps);
151 151
 
152 152
 	}
153 153
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @return string
159 159
 	 */
160 160
 	protected function get_current_step() {
161
-		$step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : '';
162
-		return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) );
161
+		$step = isset($_GET['step']) ? sanitize_key($_GET['step']) : '';
162
+		return !empty($step) && in_array($step, array_keys($this->steps)) ? $step : current(array_keys($this->steps));
163 163
 	}
164 164
 
165 165
 	/**
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 
173 173
 		$previous = false;
174 174
 		$current  = $this->step;
175
-		foreach ( array_keys( $this->steps ) as $step ) {
176
-			if ( $current === $step ) {
175
+		foreach (array_keys($this->steps) as $step) {
176
+			if ($current === $step) {
177 177
 				return $previous;
178 178
 			}
179 179
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 
194 194
 		$on_current = false;
195 195
 		$current    = $this->step;
196
-		foreach ( array_keys( $this->steps ) as $step ) {
196
+		foreach (array_keys($this->steps) as $step) {
197 197
 
198
-			if ( $on_current ) {
198
+			if ($on_current) {
199 199
 				return $step;
200 200
 			}
201 201
 
202
-			if ( $current === $step ) {
202
+			if ($current === $step) {
203 203
 				return $on_current = true;
204 204
 			}
205 205
 }
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
 		$steps     = $this->steps;
228 228
 		$current   = $this->step;
229 229
 		$next_step = $this->next_step;
230
-		array_shift( $steps );
231
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php';
230
+		array_shift($steps);
231
+		include plugin_dir_path(__FILE__) . 'views/wizard-header.php';
232 232
 	}
233 233
 
234 234
 	/**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		?>
241 241
 			<div class="gp-setup-content rowx mw-100 text-center mb-3">
242 242
 				<div class="col-12 col-md-5 m-auto">
243
-					<?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?>
243
+					<?php call_user_func($this->steps[$this->step]['view'], $this); ?>
244 244
 				</div>
245 245
 			</div>
246 246
 		<?php
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 */
254 254
 	public function display_footer() {
255 255
 
256
-		if ( isset( $_GET['step'] ) ) {
257
-			$label    = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' );
256
+		if (isset($_GET['step'])) {
257
+			$label = $this->step == 'next_steps' ? __('Return to the WordPress Dashboard', 'invoicing') : __('Skip this step', 'invoicing');
258 258
 
259
-			echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . esc_url( $this->get_next_step_link() ) . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . esc_html( $label ) . '</a></p>';
259
+			echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . esc_url($this->get_next_step_link()) . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . esc_html($label) . '</a></p>';
260 260
 		}
261 261
 
262 262
 		echo '</body></html>';
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 */
270 270
 	public function setup_introduction() {
271 271
 		$next_url = $this->get_next_step_link();
272
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php';
272
+		include plugin_dir_path(__FILE__) . 'views/wizard-introduction.php';
273 273
 	}
274 274
 
275 275
 	/**
@@ -282,22 +282,22 @@  discard block
 block discarded – undo
282 282
 	 *                      Empty string on failure.
283 283
 	 * @since 3.0.0
284 284
 	 */
285
-	public function get_next_step_link( $step = '' ) {
286
-		if ( ! $step ) {
285
+	public function get_next_step_link($step = '') {
286
+		if (!$step) {
287 287
 			$step = $this->step;
288 288
 		}
289 289
 
290
-		$keys = array_keys( $this->steps );
291
-		if ( end( $keys ) === $step ) {
290
+		$keys = array_keys($this->steps);
291
+		if (end($keys) === $step) {
292 292
 			return admin_url();
293 293
 		}
294 294
 
295
-		$step_index = array_search( $step, $keys );
296
-		if ( false === $step_index ) {
295
+		$step_index = array_search($step, $keys);
296
+		if (false === $step_index) {
297 297
 			return '';
298 298
 		}
299 299
 
300
-		return remove_query_arg( 'settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ) );
300
+		return remove_query_arg('settings-updated', add_query_arg('step', $keys[$step_index + 1]));
301 301
 	}
302 302
 
303 303
 	/**
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		$wizard   = $this;
311 311
 		$page     = 'wpinv_settings_general_main';
312 312
 		$section  = 'wpinv_settings_general_main';
313
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
313
+		include plugin_dir_path(__FILE__) . 'views/wizard-settings.php';
314 314
 	}
315 315
 
316 316
 	/**
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		$wizard   = $this;
324 324
 		$page     = 'wpinv_settings_general_currency_section';
325 325
 		$section  = 'wpinv_settings_general_currency_section';
326
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
326
+		include plugin_dir_path(__FILE__) . 'views/wizard-settings.php';
327 327
 	}
328 328
 
329 329
 	/**
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	public function setup_recommend() {
335 335
 		$next_url            = $this->get_next_step_link();
336 336
 		$recommended_plugins = self::get_recommend_wp_plugins();
337
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php';
337
+		include plugin_dir_path(__FILE__) . 'views/wizard-plugins.php';
338 338
 	}
339 339
 
340 340
 	/**
@@ -348,21 +348,21 @@  discard block
 block discarded – undo
348 348
 				'url'  => 'https://wordpress.org/plugins/ayecode-connect/',
349 349
 				'slug' => 'ayecode-connect',
350 350
 				'name' => 'AyeCode Connect',
351
-				'desc' => __( 'Documentation and Support from within your WordPress admin.', 'invoicing' ),
351
+				'desc' => __('Documentation and Support from within your WordPress admin.', 'invoicing'),
352 352
 			),
353 353
 			'invoicing-quotes' => array(
354 354
 				'file' => 'invoicing-quotes/wpinv-quote.php',
355 355
 				'url'  => 'https://wordpress.org/plugins/invoicing-quotes/',
356 356
 				'slug' => 'invoicing-quotes',
357 357
 				'name' => 'Customer Quotes',
358
-				'desc' => __( 'Create & Send Quotes to Customers and have them accept and pay.', 'invoicing' ),
358
+				'desc' => __('Create & Send Quotes to Customers and have them accept and pay.', 'invoicing'),
359 359
 			),
360 360
 			'userswp'          => array(
361 361
 				'file' => 'userswp/userswp.php',
362 362
 				'url'  => 'https://wordpress.org/plugins/userswp/',
363 363
 				'slug' => 'userswp',
364 364
 				'name' => 'UsersWP',
365
-				'desc' => __( 'Frontend user login and registration as well as slick profile pages.', 'invoicing' ),
365
+				'desc' => __('Frontend user login and registration as well as slick profile pages.', 'invoicing'),
366 366
 			),
367 367
 		);
368 368
 	}
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 */
375 375
 	public function setup_payments() {
376 376
 		$next_url = $this->get_next_step_link();
377
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php';
377
+		include plugin_dir_path(__FILE__) . 'views/wizard-gateways.php';
378 378
 	}
379 379
 
380 380
 	/**
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 	 * @since 2.0.0
386 386
 	 */
387 387
 	public function setup_payments_save() {
388
-		check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' );
389
-		wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) );
388
+		check_admin_referer('getpaid-setup-wizard', 'getpaid-setup-wizard');
389
+		wpinv_update_option('manual_active', !empty($_POST['enable-manual-gateway']));
390 390
 
391
-		if ( ! empty( $_POST['paypal-email'] ) ) {
392
-			wpinv_update_option( 'paypal_email', sanitize_email( $_POST['paypal-email'] ) );
393
-			wpinv_update_option( 'paypal_active', 1 );
394
-			wpinv_update_option( 'paypal_sandbox', 0 );
391
+		if (!empty($_POST['paypal-email'])) {
392
+			wpinv_update_option('paypal_email', sanitize_email($_POST['paypal-email']));
393
+			wpinv_update_option('paypal_active', 1);
394
+			wpinv_update_option('paypal_sandbox', 0);
395 395
 		}
396 396
 
397
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
397
+		wp_redirect(esc_url_raw($this->get_next_step_link()));
398 398
 		exit;
399 399
 	}
400 400
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	 * @since 2.0.0
405 405
 	 */
406 406
 	public function setup_ready() {
407
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php';
407
+		include plugin_dir_path(__FILE__) . 'views/wizard-thank-you.php';
408 408
 	}
409 409
 
410 410
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-payment-meta.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         ?>
30 30
 
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
 
41 41
                     <?php
42 42
 
43
-                        if ( $invoice->is_draft() ) {
43
+                        if ($invoice->is_draft()) {
44 44
 
45 45
 						// Set gateway.
46 46
 						aui()->select(
47 47
                             array(
48 48
 						'id'               => 'wpinv_gateway',
49 49
 						'name'             => 'wpinv_gateway',
50
-						'label'            => __( 'Gateway:', 'invoicing' ),
50
+						'label'            => __('Gateway:', 'invoicing'),
51 51
 						'label_type'       => 'vertical',
52
-						'placeholder'      => __( 'Select Gateway', 'invoicing' ),
52
+						'placeholder'      => __('Select Gateway', 'invoicing'),
53 53
 						'value'            => wpinv_get_default_gateway(),
54 54
 						'select2'          => true,
55 55
 						'data-allow-clear' => 'false',
56
-						'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
56
+						'options'          => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'),
57 57
                             ),
58 58
                             true
59 59
                         );
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 						'id'               => 'wpinv_key',
67 67
 						'name'             => 'wpinv_key',
68 68
 						'label'            => sprintf(
69
-                            __( '%s Key:', 'invoicing' ),
70
-                            ucfirst( $invoice->get_invoice_quote_type() )
69
+                            __('%s Key:', 'invoicing'),
70
+                            ucfirst($invoice->get_invoice_quote_type())
71 71
 						),
72 72
 						'label_type'       => 'vertical',
73 73
 						'class'            => 'form-control-sm',
74
-						'value'            => $invoice->get_key( 'edit' ),
74
+						'value'            => $invoice->get_key('edit'),
75 75
 						'extra_attributes' => array(
76 76
                             'onclick'  => 'this.select();',
77 77
                             'readonly' => 'true',
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 						'id'               => 'wpinv_view_url',
88 88
 						'name'             => 'wpinv_view_url',
89 89
 						'label'            => sprintf(
90
-                            __( '%s URL:', 'invoicing' ),
91
-                            ucfirst( $invoice->get_invoice_quote_type() )
92
-						) . '&nbsp;<a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>',
90
+                            __('%s URL:', 'invoicing'),
91
+                            ucfirst($invoice->get_invoice_quote_type())
92
+						) . '&nbsp;<a href="' . esc_url_raw($invoice->get_view_url()) . '" title="' . __('View invoice', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>',
93 93
 						'label_type'       => 'vertical',
94 94
 						'class'            => 'form-control-sm',
95 95
 						'value'            => $invoice->get_view_url(),
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 						);
103 103
 
104 104
 						// If the invoice is paid...
105
-						if ( $invoice->is_paid() || $invoice->is_refunded() ) {
105
+						if ($invoice->is_paid() || $invoice->is_refunded()) {
106 106
 
107 107
 							// Gateway.
108 108
 							aui()->input(
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 									'type'             => 'text',
111 111
 									'id'               => 'wpinv_gateway',
112 112
 									'name'             => '',
113
-									'label'            => __( 'Gateway:', 'invoicing' ),
113
+									'label'            => __('Gateway:', 'invoicing'),
114 114
 									'label_type'       => 'vertical',
115 115
 									'class'            => 'form-control-sm',
116
-									'value'            => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
116
+									'value'            => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')),
117 117
 									'extra_attributes' => array(
118 118
 										'onclick'  => 'this.select();',
119 119
 										'readonly' => 'true',
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 									'type'             => 'text',
130 130
 									'id'               => 'wpinv_transaction_id',
131 131
 									'name'             => 'wpinv_transaction_id',
132
-									'label'            => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? '&nbsp;<a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ),
132
+									'label'            => __('Transaction ID:', 'invoicing') . ($transaction_url ? '&nbsp;<a href="' . esc_url($transaction_url) . '" title="' . __('View details', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : ''),
133 133
 									'label_type'       => 'vertical',
134 134
 									'class'            => 'form-control-sm',
135
-									'value'            => $invoice->get_transaction_id( 'edit' ),
136
-									'help_text'        => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ),
135
+									'value'            => $invoice->get_transaction_id('edit'),
136
+									'help_text'        => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice),
137 137
 									'extra_attributes' => array(
138 138
 										'onclick'  => 'this.select();',
139 139
 										'readonly' => 'true',
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 									'type'             => 'text',
149 149
 									'id'               => 'wpinv_currency',
150 150
 									'name'             => 'wpinv_currency',
151
-									'label'            => __( 'Currency:', 'invoicing' ),
151
+									'label'            => __('Currency:', 'invoicing'),
152 152
 									'label_type'       => 'vertical',
153 153
 									'class'            => 'form-control-sm',
154
-									'value'            => $invoice->get_currency( 'edit' ),
154
+									'value'            => $invoice->get_currency('edit'),
155 155
 									'extra_attributes' => array(
156 156
 										'onclick'  => 'this.select();',
157 157
 										'readonly' => 'true',
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
 						} else {
164 164
 
165
-							if ( 'wpi_invoice' == $invoice->get_post_type() ) {
165
+							if ('wpi_invoice' == $invoice->get_post_type()) {
166 166
 
167 167
 								// Payment URL.
168 168
 								aui()->input(
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 										'type'             => 'text',
171 171
 										'id'               => 'wpinv_payment_url',
172 172
 										'name'             => 'wpinv_payment_url',
173
-										'label'            => __( 'Payment URL:', 'invoicing' ),
173
+										'label'            => __('Payment URL:', 'invoicing'),
174 174
 										'label_type'       => 'vertical',
175 175
 										'class'            => 'form-control-sm',
176 176
 										'value'            => $invoice->get_checkout_payment_url(),
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 									array(
188 188
 										'id'               => 'wpinv_gateway',
189 189
 										'name'             => 'wpinv_gateway',
190
-										'label'            => __( 'Gateway:', 'invoicing' ),
190
+										'label'            => __('Gateway:', 'invoicing'),
191 191
 										'label_type'       => 'vertical',
192
-										'placeholder'      => __( 'Select Gateway', 'invoicing' ),
193
-										'value'            => $invoice->get_gateway( 'edit' ),
192
+										'placeholder'      => __('Select Gateway', 'invoicing'),
193
+										'value'            => $invoice->get_gateway('edit'),
194 194
 										'select2'          => true,
195 195
 										'data-allow-clear' => 'false',
196
-										'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
196
+										'options'          => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'),
197 197
 									),
198 198
 									true
199 199
 								);
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,51 +1,51 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( ! defined( 'WPINC' ) ) {
3
+if (!defined('WPINC')) {
4 4
     exit;
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code':
15
-            echo esc_html( $discount->get_code() );
15
+            echo esc_html($discount->get_code());
16 16
             break;
17 17
         case 'amount':
18
-            echo wp_kses_post( $discount->get_formatted_amount() );
18
+            echo wp_kses_post($discount->get_formatted_amount());
19 19
             break;
20 20
         case 'usage':
21
-            echo wp_kses_post( $discount->get_usage() );
21
+            echo wp_kses_post($discount->get_usage());
22 22
             break;
23 23
         case 'start_date':
24
-            echo wp_kses_post( getpaid_format_date_value( $discount->get_start_date() ) );
24
+            echo wp_kses_post(getpaid_format_date_value($discount->get_start_date()));
25 25
             break;
26 26
         case 'expiry_date':
27
-            echo wp_kses_post( getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ) );
27
+            echo wp_kses_post(getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')));
28 28
             break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = ! empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_discount' ) {
37
-        $actions = wpinv_discount_row_actions( $post, $actions );
36
+    if ($post_type == 'wpi_discount') {
37
+        $actions = wpinv_discount_row_actions($post, $actions);
38 38
     }
39 39
 
40 40
     return $actions;
41 41
 }
42 42
 
43
-function wpinv_discount_row_actions( $discount, $row_actions ) {
44
-    $row_actions  = array();
45
-    $edit_link = get_edit_post_link( $discount->ID );
46
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
43
+function wpinv_discount_row_actions($discount, $row_actions) {
44
+    $row_actions = array();
45
+    $edit_link = get_edit_post_link($discount->ID);
46
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
47 47
 
48
-    if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) {
48
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
49 49
 
50 50
         $url = wp_nonce_url(
51 51
             add_query_arg(
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
             'getpaid-nonce',
58 58
             'getpaid-nonce'
59 59
         );
60
-		$anchor = __( 'Deactivate', 'invoicing' );
61
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
60
+		$anchor = __('Deactivate', 'invoicing');
61
+		$title  = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing');
62 62
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
63 63
 
64
-    } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) {
64
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
65 65
 
66
-        $url    = wp_nonce_url(
66
+        $url = wp_nonce_url(
67 67
             add_query_arg(
68 68
                 array(
69 69
                     'getpaid-admin-action' => 'activate_discount',
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
             'getpaid-nonce',
74 74
             'getpaid-nonce'
75 75
         );
76
-		$anchor = __( 'Activate', 'invoicing' );
77
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
76
+		$anchor = __('Activate', 'invoicing');
77
+		$title  = esc_attr__('Are you sure you want to activate this discount?', 'invoicing');
78 78
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
79 79
 
80 80
     }
81 81
 
82
-    $url    = esc_url(
82
+    $url = esc_url(
83 83
         wp_nonce_url(
84 84
             add_query_arg(
85 85
                 array(
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
             'getpaid-nonce'
92 92
         )
93 93
     );
94
-	$anchor = __( 'Delete', 'invoicing' );
95
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
94
+	$anchor = __('Delete', 'invoicing');
95
+	$title  = esc_attr__('Are you sure you want to delete this discount?', 'invoicing');
96 96
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
97 97
 
98
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
98
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
99 99
 
100 100
     return $row_actions;
101 101
 }
@@ -103,68 +103,68 @@  discard block
 block discarded – undo
103 103
 function wpinv_restrict_manage_posts() {
104 104
     global $typenow;
105 105
 
106
-    if ( 'wpi_discount' == $typenow ) {
106
+    if ('wpi_discount' == $typenow) {
107 107
         wpinv_discount_filters();
108 108
     }
109 109
 }
110
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
110
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
111 111
 
112 112
 function wpinv_discount_filters() {
113 113
 
114 114
     ?>
115 115
     <select name="discount_type" id="dropdown_wpinv_discount_type">
116
-        <option value=""><?php esc_html_e( 'Show all types', 'invoicing' ); ?></option>
116
+        <option value=""><?php esc_html_e('Show all types', 'invoicing'); ?></option>
117 117
         <?php
118 118
             $types = wpinv_get_discount_types();
119 119
 
120
-            foreach ( $types as $name => $type ) {
121
-			echo '<option value="' . esc_attr( $name ) . '"';
120
+            foreach ($types as $name => $type) {
121
+			echo '<option value="' . esc_attr($name) . '"';
122 122
 
123
-			if ( isset( $_GET['discount_type'] ) ) {
124
-				selected( $name, sanitize_text_field( $_GET['discount_type'] ) );
123
+			if (isset($_GET['discount_type'])) {
124
+				selected($name, sanitize_text_field($_GET['discount_type']));
125 125
                 }
126 126
 
127
-			echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
127
+			echo '>' . esc_html__($type, 'invoicing') . '</option>';
128 128
             }
129 129
         ?>
130 130
     </select>
131 131
     <?php
132 132
 }
133 133
 
134
-function wpinv_request( $vars ) {
134
+function wpinv_request($vars) {
135 135
     global $typenow, $wp_post_statuses;
136 136
 
137
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
138
-        if ( ! isset( $vars['post_status'] ) ) {
139
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
137
+    if (getpaid_is_invoice_post_type($typenow)) {
138
+        if (!isset($vars['post_status'])) {
139
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
140 140
 
141
-            foreach ( $post_statuses as $status => $value ) {
142
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
143
-                    unset( $post_statuses[ $status ] );
141
+            foreach ($post_statuses as $status => $value) {
142
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
143
+                    unset($post_statuses[$status]);
144 144
                 }
145 145
             }
146 146
 
147
-            $vars['post_status'] = array_keys( $post_statuses );
147
+            $vars['post_status'] = array_keys($post_statuses);
148 148
         }
149
-} elseif ( 'wpi_discount' == $typenow ) {
150
-        $meta_query = ! empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
149
+} elseif ('wpi_discount' == $typenow) {
150
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
151 151
         // Filter vat rule type
152
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
152
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
153 153
             $meta_query[] = array(
154 154
 				'key'     => '_wpi_discount_type',
155
-				'value'   => sanitize_key( urldecode( $_GET['discount_type'] ) ),
155
+				'value'   => sanitize_key(urldecode($_GET['discount_type'])),
156 156
 				'compare' => '=',
157 157
 			);
158 158
 			}
159 159
 
160
-        if ( ! empty( $meta_query ) ) {
160
+        if (!empty($meta_query)) {
161 161
             $vars['meta_query'] = $meta_query;
162 162
 			}
163 163
     }
164 164
 
165 165
     return $vars;
166 166
 }
167
-add_filter( 'request', 'wpinv_request' );
167
+add_filter('request', 'wpinv_request');
168 168
 
169 169
 /**
170 170
  * Create a page and store the ID in an option.
@@ -176,61 +176,61 @@  discard block
 block discarded – undo
176 176
  * @param int $post_parent (default: 0) Parent for the new page
177 177
  * @return int page ID
178 178
  */
179
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
179
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
180 180
     global $wpdb;
181 181
 
182
-    $option_value = wpinv_get_option( $option );
182
+    $option_value = wpinv_get_option($option);
183 183
 
184
-    if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) {
185
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
184
+    if (!empty($option_value) && ($page_object = get_post($option_value))) {
185
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
186 186
             // Valid page is already in place
187 187
             return $page_object->ID;
188 188
         }
189 189
     }
190 190
 
191
-    if ( ! empty( $post_parent ) ) {
192
-        $page = get_page_by_path( $post_parent );
193
-        if ( $page ) {
191
+    if (!empty($post_parent)) {
192
+        $page = get_page_by_path($post_parent);
193
+        if ($page) {
194 194
             $post_parent = $page->ID;
195 195
         } else {
196 196
             $post_parent = '';
197 197
         }
198 198
     }
199 199
 
200
-    if ( strlen( $page_content ) > 0 ) {
200
+    if (strlen($page_content) > 0) {
201 201
         // Search for an existing page with the specified page content (typically a shortcode)
202
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
202
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
203 203
     } else {
204 204
         // Search for an existing page with the specified page slug
205
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
205
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
206 206
     }
207 207
 
208
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
208
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
209 209
 
210
-    if ( $valid_page_found ) {
211
-        if ( $option ) {
212
-            wpinv_update_option( $option, $valid_page_found );
210
+    if ($valid_page_found) {
211
+        if ($option) {
212
+            wpinv_update_option($option, $valid_page_found);
213 213
         }
214 214
         return $valid_page_found;
215 215
     }
216 216
 
217 217
     // Search for a matching valid trashed page
218
-    if ( strlen( $page_content ) > 0 ) {
218
+    if (strlen($page_content) > 0) {
219 219
         // Search for an existing page with the specified page content (typically a shortcode)
220
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
220
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
221 221
     } else {
222 222
         // Search for an existing page with the specified page slug
223
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
223
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
224 224
     }
225 225
 
226
-    if ( $trashed_page_found ) {
226
+    if ($trashed_page_found) {
227 227
         $page_id   = $trashed_page_found;
228 228
         $page_data = array(
229 229
             'ID'          => $page_id,
230 230
             'post_status' => 'publish',
231 231
             'post_parent' => $post_parent,
232 232
         );
233
-        wp_update_post( $page_data );
233
+        wp_update_post($page_data);
234 234
     } else {
235 235
         $page_data = array(
236 236
             'post_status'    => 'publish',
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
             'post_parent'    => $post_parent,
243 243
             'comment_status' => 'closed',
244 244
         );
245
-        $page_id = wp_insert_post( $page_data );
245
+        $page_id = wp_insert_post($page_data);
246 246
     }
247 247
 
248
-    if ( $option ) {
249
-        wpinv_update_option( $option, (int) $page_id );
248
+    if ($option) {
249
+        wpinv_update_option($option, (int) $page_id);
250 250
     }
251 251
 
252 252
     return $page_id;
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
  *
260 260
  * @return array
261 261
  */
262
-function wpinv_add_aui_screens( $screen_ids ) {
262
+function wpinv_add_aui_screens($screen_ids) {
263 263
 
264 264
     // load on these pages if set
265
-    $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() );
265
+    $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids());
266 266
 
267 267
     return $screen_ids;
268 268
 }
269
-add_filter( 'aui_screen_ids', 'wpinv_add_aui_screens' );
269
+add_filter('aui_screen_ids', 'wpinv_add_aui_screens');
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) );
17
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
18
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
19
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
20
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
21
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
22
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
23
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_head', array($this, 'set_admin_menu_class'));
17
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
18
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
19
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
20
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
21
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
22
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
23
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
24 24
     }
25 25
 
26 26
     /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	public function set_admin_menu_class() {
30 30
 		global $current_screen, $parent_file, $submenu_file;
31 31
 
32
-        if ( ! empty( $current_screen->id ) && in_array( $current_screen->id, array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) {
32
+        if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) {
33 33
 			$parent_file = 'wpinv';
34 34
 			$submenu_file = 'edit.php?post_type=' . $current_screen->id;
35 35
         }
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function admin_menu() {
40 40
 
41
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
41
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
42 42
         add_menu_page(
43
-            __( 'GetPaid', 'invoicing' ),
44
-            __( 'GetPaid', 'invoicing' ),
43
+            __('GetPaid', 'invoicing'),
44
+            __('GetPaid', 'invoicing'),
45 45
             $capability,
46 46
             'wpinv',
47 47
             null,
48
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
48
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
49 49
             '54.123460'
50 50
         );
51 51
 
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
     public function add_customers_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Customers', 'invoicing' ),
61
-            __( 'Customers', 'invoicing' ),
60
+            __('Customers', 'invoicing'),
61
+            __('Customers', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-customers',
64
-            array( $this, 'customers_page' )
64
+            array($this, 'customers_page')
65 65
         );
66 66
     }
67 67
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
     public function add_subscriptions_menu() {
72 72
         add_submenu_page(
73 73
             'wpinv',
74
-            __( 'Subscriptions', 'invoicing' ),
75
-            __( 'Subscriptions', 'invoicing' ),
74
+            __('Subscriptions', 'invoicing'),
75
+            __('Subscriptions', 'invoicing'),
76 76
             wpinv_get_capability(),
77 77
             'wpinv-subscriptions',
78 78
             'wpinv_subscriptions_page'
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
                     width: 30%;
92 92
                 }
93 93
             </style>
94
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?>&nbsp;<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export', 'invoicing' ); ?></a></h1>
94
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?>&nbsp;<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce')); ?>" class="page-title-action"><?php esc_html_e('Export', 'invoicing'); ?></a></h1>
95 95
             <form method="post">
96 96
             <?php
97 97
                 $table = new WPInv_Customers_Table();
98 98
                 $table->prepare_items();
99
-                $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
99
+                $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
100 100
                 $table->display();
101 101
             ?>
102 102
             </form>
@@ -110,26 +110,26 @@  discard block
 block discarded – undo
110 110
     public function add_settings_menu() {
111 111
         add_submenu_page(
112 112
             'wpinv',
113
-            __( 'Invoice Settings', 'invoicing' ),
114
-            __( 'Settings', 'invoicing' ),
115
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
113
+            __('Invoice Settings', 'invoicing'),
114
+            __('Settings', 'invoicing'),
115
+            apply_filters('invoicing_capability', wpinv_get_capability()),
116 116
             'wpinv-settings',
117
-            array( $this, 'options_page' )
117
+            array($this, 'options_page')
118 118
         );
119 119
     }
120 120
 
121 121
     public function add_addons_menu() {
122
-        if ( ! apply_filters( 'wpi_show_addons_page', true ) ) {
122
+        if (!apply_filters('wpi_show_addons_page', true)) {
123 123
             return;
124 124
         }
125 125
 
126 126
         add_submenu_page(
127 127
             'wpinv',
128
-            __( 'Invoicing extensions', 'invoicing' ),
129
-            __( 'Extensions', 'invoicing' ),
128
+            __('Invoicing extensions', 'invoicing'),
129
+            __('Extensions', 'invoicing'),
130 130
             'manage_options',
131 131
             'wpi-addons',
132
-            array( $this, 'addons_page' )
132
+            array($this, 'addons_page')
133 133
         );
134 134
     }
135 135
 
@@ -140,29 +140,29 @@  discard block
 block discarded – undo
140 140
 
141 141
     function options_page() {
142 142
 
143
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
143
+        if (!wpinv_current_user_can_manage_invoicing()) {
144 144
             return;
145 145
         }
146 146
 
147 147
         $settings_tabs = wpinv_get_settings_tabs();
148
-        $settings_tabs = empty( $settings_tabs ) ? array() : $settings_tabs;
149
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
150
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
148
+        $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
149
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
150
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
151 151
         $key           = 'main';
152 152
 
153
-        if ( is_array( $sections ) ) {
154
-            $key = key( $sections );
153
+        if (is_array($sections)) {
154
+            $key = key($sections);
155 155
         }
156 156
 
157 157
         add_thickbox();
158 158
 
159
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
160
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? sanitize_text_field( $_GET['section'] ) : $key;
159
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
160
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? sanitize_text_field($_GET['section']) : $key;
161 161
         ?>
162 162
         <div class="wrap">
163 163
             <h1 class="nav-tab-wrapper">
164 164
                 <?php
165
-                foreach ( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
165
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
166 166
                     $tab_url = add_query_arg(
167 167
                         array(
168 168
 							'settings-updated' => false,
@@ -172,23 +172,23 @@  discard block
 block discarded – undo
172 172
                     );
173 173
 
174 174
                     // Remove the section from the tabs so we always end up at the main section
175
-                    $tab_url = remove_query_arg( 'section', $tab_url );
176
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
175
+                    $tab_url = remove_query_arg('section', $tab_url);
176
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
177 177
 
178 178
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
179 179
 
180
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . esc_attr( $active ) . '">';
181
-                    echo esc_html( $tab_name );
180
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . esc_attr($active) . '">';
181
+                    echo esc_html($tab_name);
182 182
                     echo '</a>';
183 183
                 }
184 184
                 ?>
185 185
             </h1>
186 186
             <?php
187
-            $number_of_sections = count( $sections );
187
+            $number_of_sections = count($sections);
188 188
             $number = 0;
189
-            if ( $number_of_sections > 1 ) {
189
+            if ($number_of_sections > 1) {
190 190
                 echo '<div><ul class="subsubsub">';
191
-                foreach ( $sections as $section_id => $section_name ) {
191
+                foreach ($sections as $section_id => $section_name) {
192 192
                     echo '<li>';
193 193
                     $number++;
194 194
                     $tab_url = add_query_arg(
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
 							'tab'              => $active_tab,
198 198
 							'section'          => $section_id,
199 199
                         ),
200
-                        admin_url( 'admin.php?page=wpinv-settings' )
200
+                        admin_url('admin.php?page=wpinv-settings')
201 201
                     );
202
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
202
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
203 203
                     $class = '';
204
-                    if ( $section == $section_id ) {
204
+                    if ($section == $section_id) {
205 205
                         $class = 'current';
206 206
                     }
207
-                    echo '<a class="' . esc_attr( $class ) . '" href="' . esc_url( $tab_url ) . '">' . esc_html( $section_name ) . '</a>';
207
+                    echo '<a class="' . esc_attr($class) . '" href="' . esc_url($tab_url) . '">' . esc_html($section_name) . '</a>';
208 208
 
209
-                    if ( $number != $number_of_sections ) {
209
+                    if ($number != $number_of_sections) {
210 210
                         echo ' | ';
211 211
                     }
212 212
                     echo '</li>';
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
                 <form method="post" action="options.php">
219 219
                     <table class="form-table">
220 220
                         <?php
221
-                        settings_fields( 'wpinv_settings' );
221
+                        settings_fields('wpinv_settings');
222 222
 
223
-                        if ( 'main' === $section ) {
224
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
223
+                        if ('main' === $section) {
224
+                            do_action('wpinv_settings_tab_top', $active_tab);
225 225
                         }
226 226
 
227
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
228
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
229
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
230
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
227
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
228
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
229
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
230
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
231 231
 
232 232
                         // For backwards compatibility
233
-                        if ( 'main' === $section ) {
234
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
233
+                        if ('main' === $section) {
234
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
235 235
                         }
236 236
                         ?>
237 237
                     </table>
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     }
244 244
 
245 245
     public function remove_admin_submenus() {
246
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
246
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
247 247
     }
248 248
 
249 249
     /**
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 
254 254
         add_meta_box(
255 255
             'wpinv_endpoints_nav_link',
256
-            __( 'GetPaid endpoints', 'invoicing' ),
257
-            array( $this, 'nav_menu_links' ),
256
+            __('GetPaid endpoints', 'invoicing'),
257
+            array($this, 'nav_menu_links'),
258 258
             'nav-menus',
259 259
             'side',
260 260
             'low'
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
         $endpoints = $this->get_menu_items();
270 270
         ?>
271 271
         <div id="invoicing-endpoints" class="posttypediv">
272
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
272
+            <?php if (!empty($endpoints['pages'])) : ?>
273 273
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
274 274
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
275 275
                         <?php
276
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
277
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
276
+                            $walker = new Walker_Nav_Menu_Checklist(array());
277
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
278 278
                         ?>
279 279
                     </ul>
280 280
                 </div>
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
284 284
                 <span class="list-controls hide-if-no-js">
285 285
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
286
-                    <label for="invoicing-endpoints-tab"><?php esc_html_e( 'Select all', 'invoicing' ); ?></label>
286
+                    <label for="invoicing-endpoints-tab"><?php esc_html_e('Select all', 'invoicing'); ?></label>
287 287
                 </span>
288 288
 
289 289
                 <span class="add-to-menu">
290
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
290
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
291 291
                     <span class="spinner"></span>
292 292
                 </span>
293 293
             </p>
@@ -305,18 +305,18 @@  discard block
 block discarded – undo
305 305
 
306 306
         $pages = array(
307 307
             array(
308
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
309
-                'label' => __( 'My Invoices', 'invoicing' ),
308
+                'id'    => wpinv_get_option('invoice_history_page'),
309
+                'label' => __('My Invoices', 'invoicing'),
310 310
             ),
311 311
             array(
312
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
313
-                'label' => __( 'My Subscriptions', 'invoicing' ),
312
+                'id'    => wpinv_get_option('invoice_subscription_page'),
313
+                'label' => __('My Subscriptions', 'invoicing'),
314 314
             ),
315 315
         );
316 316
 
317
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
317
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
318 318
 
319
-            if ( (int) $page['id'] > 0 ) {
319
+            if ((int) $page['id'] > 0) {
320 320
 
321 321
                 $item                   = new stdClass();
322 322
                 $item->object_id        = (int) $page['id'];
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
                 $item->object           = 'page';
325 325
                 $item->menu_item_parent = 0;
326 326
                 $item->type             = 'post_type';
327
-                $item->title            = esc_html( $page['label'] );
328
-                $item->url              = get_permalink( (int) $page['id'] );
327
+                $item->title            = esc_html($page['label']);
328
+                $item->url              = get_permalink((int) $page['id']);
329 329
                 $item->target           = '';
330 330
                 $item->attr_title       = '';
331
-                $item->classes          = array( 'wpinv-menu-item' );
331
+                $item->classes          = array('wpinv-menu-item');
332 332
                 $item->xfn              = '';
333 333
 
334 334
                 $items['pages'][]       = $item;
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             }
337 337
 }
338 338
 
339
-        return apply_filters( 'wpinv_menu_items', $items );
339
+        return apply_filters('wpinv_menu_items', $items);
340 340
     }
341 341
 
342 342
 }
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( ! defined( 'WPINC' ) ) {
10
+if (!defined('WPINC')) {
11 11
     exit;
12 12
 }
13 13
 
14 14
 function wpinv_is_checkout() {
15 15
     global $wp_query;
16 16
 
17
-    $is_object_set    = isset( $wp_query->queried_object );
18
-    $is_object_id_set = isset( $wp_query->queried_object_id );
19
-    $checkout_page    = wpinv_get_option( 'checkout_page' );
20
-    $is_checkout      = ! empty( $checkout_page ) && is_page( $checkout_page );
17
+    $is_object_set    = isset($wp_query->queried_object);
18
+    $is_object_id_set = isset($wp_query->queried_object_id);
19
+    $checkout_page    = wpinv_get_option('checkout_page');
20
+    $is_checkout      = !empty($checkout_page) && is_page($checkout_page);
21 21
 
22
-    if ( ! $is_object_set ) {
23
-        unset( $wp_query->queried_object );
22
+    if (!$is_object_set) {
23
+        unset($wp_query->queried_object);
24 24
     }
25 25
 
26
-    if ( ! $is_object_id_set ) {
27
-        unset( $wp_query->queried_object_id );
26
+    if (!$is_object_id_set) {
27
+        unset($wp_query->queried_object_id);
28 28
     }
29 29
 
30
-    return apply_filters( 'wpinv_is_checkout', $is_checkout );
30
+    return apply_filters('wpinv_is_checkout', $is_checkout);
31 31
 }
32 32
 
33 33
 function wpinv_can_checkout() {
34 34
 	$can_checkout = true; // Always true for now
35 35
 
36
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
36
+	return (bool) apply_filters('wpinv_can_checkout', $can_checkout);
37 37
 }
38 38
 
39 39
 function wpinv_get_success_page_uri() {
40
-	$page_id = wpinv_get_option( 'success_page', 0 );
41
-	$page_id = absint( $page_id );
40
+	$page_id = wpinv_get_option('success_page', 0);
41
+	$page_id = absint($page_id);
42 42
 
43
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
43
+	return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id));
44 44
 }
45 45
 
46 46
 /**
@@ -49,143 +49,143 @@  discard block
 block discarded – undo
49 49
  * @param string $post_type The post type or invoice type.
50 50
  * @return string The history page URL.
51 51
  */
52
-function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) {
53
-    $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) );
54
-	$page_id   = wpinv_get_option( "{$post_type}_history_page", 0 );
55
-	$page_id   = absint( $page_id );
56
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type );
52
+function wpinv_get_history_page_uri($post_type = 'wpi_invoice') {
53
+    $post_type = sanitize_key(str_replace('wpi_', '', $post_type));
54
+	$page_id   = wpinv_get_option("{$post_type}_history_page", 0);
55
+	$page_id   = absint($page_id);
56
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type);
57 57
 }
58 58
 
59 59
 function wpinv_is_success_page() {
60
-	$is_success_page = wpinv_get_option( 'success_page', false );
61
-	$is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
60
+	$is_success_page = wpinv_get_option('success_page', false);
61
+	$is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false;
62 62
 
63
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
63
+	return apply_filters('wpinv_is_success_page', $is_success_page);
64 64
 }
65 65
 
66 66
 function wpinv_is_invoice_history_page() {
67
-	$ret = wpinv_get_option( 'invoice_history_page', false );
68
-	$ret = $ret ? is_page( $ret ) : false;
69
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
67
+	$ret = wpinv_get_option('invoice_history_page', false);
68
+	$ret = $ret ? is_page($ret) : false;
69
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
70 70
 }
71 71
 
72 72
 function wpinv_is_subscriptions_history_page() {
73
-    $ret = wpinv_get_option( 'invoice_subscription_page', false );
74
-    $ret = $ret ? is_page( $ret ) : false;
75
-    return apply_filters( 'wpinv_is_subscriptions_history_page', $ret );
73
+    $ret = wpinv_get_option('invoice_subscription_page', false);
74
+    $ret = $ret ? is_page($ret) : false;
75
+    return apply_filters('wpinv_is_subscriptions_history_page', $ret);
76 76
 }
77 77
 
78 78
 /**
79 79
  * Redirects a user the success page.
80 80
  */
81
-function wpinv_send_to_success_page( $args = array() ) {
81
+function wpinv_send_to_success_page($args = array()) {
82 82
 
83 83
     $redirect = add_query_arg(
84
-        wp_parse_args( $args ),
84
+        wp_parse_args($args),
85 85
         wpinv_get_success_page_uri()
86 86
     );
87 87
 
88
-    $redirect = apply_filters( 'wpinv_send_to_success_page_url', $redirect, $args );
88
+    $redirect = apply_filters('wpinv_send_to_success_page_url', $redirect, $args);
89 89
 
90
-    wp_redirect( $redirect );
90
+    wp_redirect($redirect);
91 91
     exit;
92 92
 }
93 93
 
94
-function wpinv_send_to_failed_page( $args = null ) {
94
+function wpinv_send_to_failed_page($args = null) {
95 95
 	$redirect = wpinv_get_failed_transaction_uri();
96 96
 
97
-    if ( ! empty( $args ) ) {
97
+    if (!empty($args)) {
98 98
         // Check for backward compatibility
99
-        if ( is_string( $args ) ) {
100
-            $args = str_replace( '?', '', $args );
99
+        if (is_string($args)) {
100
+            $args = str_replace('?', '', $args);
101 101
         }
102 102
 
103
-        $args = wp_parse_args( $args );
103
+        $args = wp_parse_args($args);
104 104
 
105
-        $redirect = add_query_arg( $args, $redirect );
105
+        $redirect = add_query_arg($args, $redirect);
106 106
     }
107 107
 
108
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
108
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
109 109
 
110
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
111
-    wp_redirect( $redirect );
110
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
111
+    wp_redirect($redirect);
112 112
     exit;
113 113
 }
114 114
 
115
-function wpinv_get_checkout_uri( $args = array() ) {
116
-	$uri = wpinv_get_option( 'checkout_page', false );
117
-	$uri = isset( $uri ) ? get_permalink( $uri ) : null;
115
+function wpinv_get_checkout_uri($args = array()) {
116
+	$uri = wpinv_get_option('checkout_page', false);
117
+	$uri = isset($uri) ? get_permalink($uri) : null;
118 118
 
119
-	if ( ! empty( $args ) ) {
119
+	if (!empty($args)) {
120 120
 		// Check for backward compatibility
121
-		if ( is_string( $args ) ) {
122
-			$args = str_replace( '?', '', $args );
121
+		if (is_string($args)) {
122
+			$args = str_replace('?', '', $args);
123 123
         }
124 124
 
125
-		$args = wp_parse_args( $args );
125
+		$args = wp_parse_args($args);
126 126
 
127
-		$uri = add_query_arg( $args, $uri );
127
+		$uri = add_query_arg($args, $uri);
128 128
 	}
129 129
 
130
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
130
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
131 131
 
132
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
132
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
133 133
 
134
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
135
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
134
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
135
+		$uri = preg_replace('/^http:/', 'https:', $uri);
136 136
 	}
137 137
 
138
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
138
+	return apply_filters('wpinv_get_checkout_uri', $uri);
139 139
 }
140 140
 
141
-function wpinv_get_success_page_url( $query_string = null ) {
142
-	$success_page = wpinv_get_option( 'success_page', 0 );
143
-	$success_page = get_permalink( $success_page );
141
+function wpinv_get_success_page_url($query_string = null) {
142
+	$success_page = wpinv_get_option('success_page', 0);
143
+	$success_page = get_permalink($success_page);
144 144
 
145
-	if ( $query_string ) {
145
+	if ($query_string) {
146 146
 		$success_page .= $query_string;
147 147
     }
148 148
 
149
-	return apply_filters( 'wpinv_success_page_url', $success_page );
149
+	return apply_filters('wpinv_success_page_url', $success_page);
150 150
 }
151 151
 
152
-function wpinv_get_failed_transaction_uri( $extras = false ) {
153
-	$uri = wpinv_get_option( 'failure_page', '' );
154
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
152
+function wpinv_get_failed_transaction_uri($extras = false) {
153
+	$uri = wpinv_get_option('failure_page', '');
154
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
155 155
 
156
-	if ( $extras ) {
156
+	if ($extras) {
157 157
 		$uri .= $extras;
158 158
     }
159 159
 
160
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
160
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
161 161
 }
162 162
 
163 163
 function wpinv_is_failed_transaction_page() {
164
-	$ret = wpinv_get_option( 'failure_page', false );
165
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
164
+	$ret = wpinv_get_option('failure_page', false);
165
+	$ret = isset($ret) ? is_page($ret) : false;
166 166
 
167
-	return apply_filters( 'wpinv_is_failure_page', $ret );
167
+	return apply_filters('wpinv_is_failure_page', $ret);
168 168
 }
169 169
 
170
-function wpinv_transaction_query( $type = 'start' ) {
170
+function wpinv_transaction_query($type = 'start') {
171 171
     global $wpdb;
172 172
 
173 173
     $wpdb->hide_errors();
174 174
 
175
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
176
-        define( 'WPINV_USE_TRANSACTIONS', true );
175
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
176
+        define('WPINV_USE_TRANSACTIONS', true);
177 177
     }
178 178
 
179
-    if ( WPINV_USE_TRANSACTIONS ) {
180
-        switch ( $type ) {
179
+    if (WPINV_USE_TRANSACTIONS) {
180
+        switch ($type) {
181 181
             case 'commit':
182
-                $wpdb->query( 'COMMIT' );
182
+                $wpdb->query('COMMIT');
183 183
                 break;
184 184
             case 'rollback':
185
-                $wpdb->query( 'ROLLBACK' );
185
+                $wpdb->query('ROLLBACK');
186 186
                 break;
187 187
             default:
188
-                $wpdb->query( 'START TRANSACTION' );
188
+                $wpdb->query('START TRANSACTION');
189 189
                 break;
190 190
         }
191 191
     }
@@ -194,146 +194,146 @@  discard block
 block discarded – undo
194 194
 function wpinv_get_prefix() {
195 195
     $invoice_prefix = 'INV-';
196 196
 
197
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
197
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
198 198
 }
199 199
 
200 200
 function wpinv_get_business_logo() {
201
-    $business_logo = wpinv_get_option( 'logo' );
202
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
201
+    $business_logo = wpinv_get_option('logo');
202
+    return apply_filters('wpinv_get_business_logo', $business_logo);
203 203
 }
204 204
 
205 205
 function wpinv_get_business_name() {
206
-    $name = wpinv_get_option( 'store_name', wpinv_get_blogname() );
206
+    $name = wpinv_get_option('store_name', wpinv_get_blogname());
207 207
 
208
-    if ( empty( $name ) ) {
208
+    if (empty($name)) {
209 209
         $name = wpinv_get_blogname();
210 210
     }
211 211
 
212
-    return apply_filters( 'wpinv_get_business_name', $name );
212
+    return apply_filters('wpinv_get_business_name', $name);
213 213
 }
214 214
 
215 215
 function wpinv_get_blogname() {
216
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
216
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
217 217
 }
218 218
 
219 219
 function wpinv_get_admin_email() {
220
-    $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) );
221
-    return apply_filters( 'wpinv_admin_email', $admin_email );
220
+    $admin_email = wpinv_get_option('admin_email', get_option('admin_email'));
221
+    return apply_filters('wpinv_admin_email', $admin_email);
222 222
 }
223 223
 
224 224
 function wpinv_get_business_website() {
225
-    $business_website = home_url( '/' );
226
-    return apply_filters( 'wpinv_get_business_website', $business_website );
225
+    $business_website = home_url('/');
226
+    return apply_filters('wpinv_get_business_website', $business_website);
227 227
 }
228 228
 
229
-function wpinv_get_terms_text( $invoice_id = 0 ) {
229
+function wpinv_get_terms_text($invoice_id = 0) {
230 230
     $terms_text = '';
231
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
231
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
232 232
 }
233 233
 
234 234
 function wpinv_get_business_footer() {
235
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
236
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
237
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
235
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
236
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
237
+    return apply_filters('wpinv_get_business_footer', $business_footer);
238 238
 }
239 239
 
240 240
 function wpinv_checkout_required_fields() {
241 241
     $required_fields = array();
242 242
 
243 243
     // Let payment gateways and other extensions determine if address fields should be required
244
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
244
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
245 245
 
246
-    if ( $require_billing_details ) {
247
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
246
+    if ($require_billing_details) {
247
+		if ((bool) wpinv_get_option('fname_mandatory')) {
248 248
 			$required_fields['first_name'] = array(
249 249
 				'error_id'      => 'invalid_first_name',
250
-				'error_message' => __( 'Please enter your first name', 'invoicing' ),
250
+				'error_message' => __('Please enter your first name', 'invoicing'),
251 251
 			);
252 252
 		}
253
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
253
+		if ((bool) wpinv_get_option('address_mandatory')) {
254 254
 			$required_fields['address'] = array(
255 255
 				'error_id'      => 'invalid_address',
256
-				'error_message' => __( 'Please enter your address', 'invoicing' ),
256
+				'error_message' => __('Please enter your address', 'invoicing'),
257 257
 			);
258 258
 		}
259
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
259
+		if ((bool) wpinv_get_option('city_mandatory')) {
260 260
 			$required_fields['city'] = array(
261 261
 				'error_id'      => 'invalid_city',
262
-				'error_message' => __( 'Please enter your billing city', 'invoicing' ),
262
+				'error_message' => __('Please enter your billing city', 'invoicing'),
263 263
 			);
264 264
 		}
265
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
265
+		if ((bool) wpinv_get_option('state_mandatory')) {
266 266
 			$required_fields['state'] = array(
267 267
 				'error_id'      => 'invalid_state',
268
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' ),
268
+				'error_message' => __('Please enter billing state / province', 'invoicing'),
269 269
 			);
270 270
 		}
271
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
271
+		if ((bool) wpinv_get_option('country_mandatory')) {
272 272
 			$required_fields['country'] = array(
273 273
 				'error_id'      => 'invalid_country',
274
-				'error_message' => __( 'Please select your billing country', 'invoicing' ),
274
+				'error_message' => __('Please select your billing country', 'invoicing'),
275 275
 			);
276 276
 		}
277 277
     }
278 278
 
279
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
279
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
280 280
 }
281 281
 
282 282
 function wpinv_is_ssl_enforced() {
283
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
284
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
283
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
284
+    return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
285 285
 }
286 286
 
287 287
 function wpinv_schedule_event_twicedaily() {
288 288
     wpinv_email_payment_reminders();
289 289
 }
290
-add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' );
290
+add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily');
291 291
 
292 292
 function wpinv_require_login_to_checkout() {
293
-    $return = wpinv_get_option( 'login_to_checkout', false );
294
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
293
+    $return = wpinv_get_option('login_to_checkout', false);
294
+    return (bool) apply_filters('wpinv_require_login_to_checkout', $return);
295 295
 }
296 296
 
297
-function wpinv_sequential_number_active( $type = '' ) {
298
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
299
-    if ( null !== $check ) {
297
+function wpinv_sequential_number_active($type = '') {
298
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
299
+    if (null !== $check) {
300 300
         return $check;
301 301
     }
302 302
 
303
-    return wpinv_get_option( 'sequential_invoice_number' );
303
+    return wpinv_get_option('sequential_invoice_number');
304 304
 }
305 305
 
306
-function wpinv_switch_to_locale( $locale = null ) {
306
+function wpinv_switch_to_locale($locale = null) {
307 307
     global $invoicing, $wpi_switch_locale;
308 308
 
309
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
310
-        $locale = empty( $locale ) ? get_locale() : $locale;
309
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
310
+        $locale = empty($locale) ? get_locale() : $locale;
311 311
 
312
-        switch_to_locale( $locale );
312
+        switch_to_locale($locale);
313 313
 
314 314
         $wpi_switch_locale = $locale;
315 315
 
316
-        add_filter( 'plugin_locale', 'get_locale' );
316
+        add_filter('plugin_locale', 'get_locale');
317 317
 
318 318
         $invoicing->load_textdomain();
319 319
 
320
-        do_action( 'wpinv_switch_to_locale', $locale );
320
+        do_action('wpinv_switch_to_locale', $locale);
321 321
     }
322 322
 }
323 323
 
324 324
 function wpinv_restore_locale() {
325 325
     global $invoicing, $wpi_switch_locale;
326 326
 
327
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
327
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
328 328
         restore_previous_locale();
329 329
 
330 330
         $wpi_switch_locale = null;
331 331
 
332
-        remove_filter( 'plugin_locale', 'get_locale' );
332
+        remove_filter('plugin_locale', 'get_locale');
333 333
 
334 334
         $invoicing->load_textdomain();
335 335
 
336
-        do_action( 'wpinv_restore_locale' );
336
+        do_action('wpinv_restore_locale');
337 337
     }
338 338
 }
339 339
 
@@ -341,26 +341,26 @@  discard block
 block discarded – undo
341 341
  * Returns the default form's id.
342 342
  */
343 343
 function wpinv_get_default_payment_form() {
344
-    $form = get_option( 'wpinv_default_payment_form' );
344
+    $form = get_option('wpinv_default_payment_form');
345 345
 
346
-    if ( empty( $form ) || 'publish' != get_post_status( $form ) ) {
346
+    if (empty($form) || 'publish' != get_post_status($form)) {
347 347
         $form = wp_insert_post(
348 348
             array(
349 349
                 'post_type'   => 'wpi_payment_form',
350
-                'post_title'  => __( 'Checkout (default)', 'invoicing' ),
350
+                'post_title'  => __('Checkout (default)', 'invoicing'),
351 351
                 'post_status' => 'publish',
352 352
                 'meta_input'  => array(
353
-                    'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ),
353
+                    'wpinv_form_elements' => wpinv_get_data('default-payment-form'),
354 354
                     'wpinv_form_items'    => array(),
355 355
                 ),
356 356
             )
357 357
         );
358 358
 
359
-        update_option( 'wpinv_default_payment_form', $form );
359
+        update_option('wpinv_default_payment_form', $form);
360 360
     }
361 361
 
362 362
     // WPML support.
363
-    $form = apply_filters( 'wpml_object_id', $form, 'wpi_payment_form', true );
363
+    $form = apply_filters('wpml_object_id', $form, 'wpi_payment_form', true);
364 364
     return $form;
365 365
 }
366 366
 
@@ -369,19 +369,19 @@  discard block
 block discarded – undo
369 369
  *
370 370
  * @param int $payment_form
371 371
  */
372
-function getpaid_get_payment_form_elements( $payment_form ) {
372
+function getpaid_get_payment_form_elements($payment_form) {
373 373
 
374
-    if ( empty( $payment_form ) ) {
375
-        return wpinv_get_data( 'sample-payment-form' );
374
+    if (empty($payment_form)) {
375
+        return wpinv_get_data('sample-payment-form');
376 376
     }
377 377
 
378
-    $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true );
378
+    $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true);
379 379
 
380
-    if ( is_array( $form_elements ) ) {
380
+    if (is_array($form_elements)) {
381 381
         return $form_elements;
382 382
     }
383 383
 
384
-    return wpinv_get_data( 'sample-payment-form' );
384
+    return wpinv_get_data('sample-payment-form');
385 385
 
386 386
 }
387 387
 
@@ -390,65 +390,65 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @param int $payment_form
392 392
  */
393
-function gepaid_get_form_items( $id ) {
394
-    $form = new GetPaid_Payment_Form( $id );
393
+function gepaid_get_form_items($id) {
394
+    $form = new GetPaid_Payment_Form($id);
395 395
 
396 396
     // Is this a default form?
397
-    if ( $form->is_default() ) {
397
+    if ($form->is_default()) {
398 398
         return array();
399 399
     }
400 400
 
401
-    return $form->get_items( 'view', 'arrays' );
401
+    return $form->get_items('view', 'arrays');
402 402
 }
403 403
 
404 404
 /**
405 405
  * Trims each line in a paragraph.
406 406
  *
407 407
  */
408
-function gepaid_trim_lines( $content ) {
409
-    return implode( "\n", array_map( 'trim', explode( "\n", $content ) ) );
408
+function gepaid_trim_lines($content) {
409
+    return implode("\n", array_map('trim', explode("\n", $content)));
410 410
 }
411 411
 
412 412
 
413
-function wpinv_add_elementor_widget_categories( $elements_manager ) {
413
+function wpinv_add_elementor_widget_categories($elements_manager) {
414 414
     $elements_manager->add_category(
415 415
         'getpaid',
416 416
         array(
417
-            'title' => esc_html__( 'GetPaid', 'invoicing' ),
417
+            'title' => esc_html__('GetPaid', 'invoicing'),
418 418
             'icon'  => 'fa fa-plug',
419 419
         )
420 420
     );
421 421
 }
422
-add_filter( 'elementor/elements/categories_registered', 'wpinv_add_elementor_widget_categories' );
422
+add_filter('elementor/elements/categories_registered', 'wpinv_add_elementor_widget_categories');
423 423
 
424
-function wpinv_alter_elementor_widget_config( $config ) {
424
+function wpinv_alter_elementor_widget_config($config) {
425 425
 
426
-    if ( ! empty( $config['initial_document']['widgets'] ) ) {
427
-        foreach ( $config['initial_document']['widgets'] as $key => $widget ) {
428
-            if ( substr( $key, 0, 16 ) === 'wp-widget-wpinv_' || $key === 'wp-widget-getpaid' ) {
429
-                $config['initial_document']['widgets'][ $key ]['categories'][] = 'getpaid';
430
-                $config['initial_document']['widgets'][ $key ]['hide_on_search'] = false;
431
-                $config['initial_document']['widgets'][ $key ]['icon'] = 'eicon-globe'; //@todo if no icons use on page then font-awesome is not loaded, wif we can fifure out how to force load we can use icons. <i class="fas fa-globe-americas"></i><i class="fa-solid fa-earth-americas"></i>
426
+    if (!empty($config['initial_document']['widgets'])) {
427
+        foreach ($config['initial_document']['widgets'] as $key => $widget) {
428
+            if (substr($key, 0, 16) === 'wp-widget-wpinv_' || $key === 'wp-widget-getpaid') {
429
+                $config['initial_document']['widgets'][$key]['categories'][] = 'getpaid';
430
+                $config['initial_document']['widgets'][$key]['hide_on_search'] = false;
431
+                $config['initial_document']['widgets'][$key]['icon'] = 'eicon-globe'; //@todo if no icons use on page then font-awesome is not loaded, wif we can fifure out how to force load we can use icons. <i class="fas fa-globe-americas"></i><i class="fa-solid fa-earth-americas"></i>
432 432
             }
433 433
         }
434 434
     }
435 435
 
436 436
     return $config;
437 437
 }
438
-add_filter( 'elementor/editor/localize_settings', 'wpinv_alter_elementor_widget_config' );
438
+add_filter('elementor/editor/localize_settings', 'wpinv_alter_elementor_widget_config');
439 439
 
440 440
 function wpinv_get_report_graphs() {
441 441
 
442 442
     return apply_filters(
443 443
         'getpaid_report_graphs',
444 444
         array(
445
-            'sales'    => __( 'Earnings', 'invoicing' ),
446
-            'refunds'  => __( 'Refunds', 'invoicing' ),
447
-            'tax'      => __( 'Taxes', 'invoicing' ),
448
-            'fees'     => __( 'Fees', 'invoicing' ),
449
-            'discount' => __( 'Discounts', 'invoicing' ),
450
-            'invoices' => __( 'Invoices', 'invoicing' ),
451
-            'items'    => __( 'Purchased Items', 'invoicing' ),
445
+            'sales'    => __('Earnings', 'invoicing'),
446
+            'refunds'  => __('Refunds', 'invoicing'),
447
+            'tax'      => __('Taxes', 'invoicing'),
448
+            'fees'     => __('Fees', 'invoicing'),
449
+            'discount' => __('Discounts', 'invoicing'),
450
+            'invoices' => __('Invoices', 'invoicing'),
451
+            'items'    => __('Purchased Items', 'invoicing'),
452 452
         )
453 453
     );
454 454
 
Please login to merge, or discard this patch.
includes/class-wpinv-legacy-invoice.php 1 patch
Spacing   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( ! defined( 'WPINC' ) ) {
10
+if (!defined('WPINC')) {
11 11
     exit;
12 12
 }
13 13
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * Invoice id.
21 21
      */
22
-    public $ID  = 0;
22
+    public $ID = 0;
23 23
 
24 24
     /**
25 25
      * The title of the invoice. Usually the invoice number.
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     /**
136 136
      * The invoice status.
137 137
      */
138
-    public $status      = 'wpi-pending';
138
+    public $status = 'wpi-pending';
139 139
 
140 140
     /**
141 141
      * Same as self::$status.
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public $parent_invoice = 0;
264 264
 
265
-    public function __construct( $invoice_id = false ) {
266
-        if ( empty( $invoice_id ) ) {
265
+    public function __construct($invoice_id = false) {
266
+        if (empty($invoice_id)) {
267 267
             return false;
268 268
         }
269 269
 
270
-        $this->setup_invoice( $invoice_id );
270
+        $this->setup_invoice($invoice_id);
271 271
     }
272 272
 
273
-    public function get( $key ) {
274
-        if ( method_exists( $this, 'get_' . $key ) ) {
275
-            $value = call_user_func( array( $this, 'get_' . $key ) );
273
+    public function get($key) {
274
+        if (method_exists($this, 'get_' . $key)) {
275
+            $value = call_user_func(array($this, 'get_' . $key));
276 276
         } else {
277 277
             $value = $this->$key;
278 278
         }
@@ -280,43 +280,43 @@  discard block
 block discarded – undo
280 280
         return $value;
281 281
     }
282 282
 
283
-    public function set( $key, $value ) {
284
-        $ignore = array( 'items', 'cart_details', 'fees', '_ID' );
283
+    public function set($key, $value) {
284
+        $ignore = array('items', 'cart_details', 'fees', '_ID');
285 285
 
286
-        if ( $key === 'status' ) {
286
+        if ($key === 'status') {
287 287
             $this->old_status = $this->status;
288 288
         }
289 289
 
290
-        if ( ! in_array( $key, $ignore ) ) {
291
-            $this->pending[ $key ] = $value;
290
+        if (!in_array($key, $ignore)) {
291
+            $this->pending[$key] = $value;
292 292
         }
293 293
 
294
-        if ( '_ID' !== $key ) {
294
+        if ('_ID' !== $key) {
295 295
             $this->$key = $value;
296 296
         }
297 297
     }
298 298
 
299
-    public function _isset( $name ) {
300
-        if ( property_exists( $this, $name ) ) {
301
-            return false === empty( $this->$name );
299
+    public function _isset($name) {
300
+        if (property_exists($this, $name)) {
301
+            return false === empty($this->$name);
302 302
         } else {
303 303
             return null;
304 304
         }
305 305
     }
306 306
 
307
-    private function setup_invoice( $invoice_id ) {
307
+    private function setup_invoice($invoice_id) {
308 308
         $this->pending = array();
309 309
 
310
-        $invoice = get_post( $invoice_id );
310
+        $invoice = get_post($invoice_id);
311 311
 
312
-        if ( ! $invoice || is_wp_error( $invoice ) ) {
312
+        if (!$invoice || is_wp_error($invoice)) {
313 313
             return false;
314 314
         }
315 315
 
316
-        do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id );
316
+        do_action('wpinv_pre_setup_invoice', $this, $invoice_id);
317 317
 
318 318
         // Primary Identifier
319
-        $this->ID              = absint( $invoice_id );
319
+        $this->ID              = absint($invoice_id);
320 320
         $this->post_type       = $invoice->post_type;
321 321
 
322 322
         // We have a payment, get the generic payment_meta item to reduce calls to it
@@ -326,15 +326,15 @@  discard block
 block discarded – undo
326 326
         $this->completed_date  = $this->setup_completed_date();
327 327
         $this->status          = $invoice->post_status;
328 328
 
329
-        if ( 'future' == $this->status ) {
329
+        if ('future' == $this->status) {
330 330
             $this->status = 'publish';
331 331
         }
332 332
 
333 333
         $this->post_status     = $this->status;
334 334
         $this->mode            = $this->setup_mode();
335 335
         $this->parent_invoice  = $invoice->post_parent;
336
-        $this->post_name       = $this->setup_post_name( $invoice );
337
-        $this->status_nicename = $this->setup_status_nicename( $invoice->post_status );
336
+        $this->post_name       = $this->setup_post_name($invoice);
337
+        $this->status_nicename = $this->setup_status_nicename($invoice->post_status);
338 338
 
339 339
         // Items
340 340
         $this->fees            = $this->setup_fees();
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 
357 357
         // User based
358 358
         $this->ip              = $this->setup_ip();
359
-        $this->user_id         = ! empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id();
360
-        $this->email           = get_the_author_meta( 'email', $this->user_id );
359
+        $this->user_id         = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id();
360
+        $this->email           = get_the_author_meta('email', $this->user_id);
361 361
 
362 362
         $this->user_info       = $this->setup_user_info();
363 363
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         $this->company         = $this->user_info['company'];
367 367
         $this->vat_number      = $this->user_info['vat_number'];
368 368
         $this->vat_rate        = $this->user_info['vat_rate'];
369
-        $this->adddress_confirmed  = $this->user_info['adddress_confirmed'];
369
+        $this->adddress_confirmed = $this->user_info['adddress_confirmed'];
370 370
         $this->address         = $this->user_info['address'];
371 371
         $this->city            = $this->user_info['city'];
372 372
         $this->country         = $this->user_info['country'];
@@ -381,31 +381,31 @@  discard block
 block discarded – undo
381 381
         // Other Identifiers
382 382
         $this->key             = $this->setup_invoice_key();
383 383
         $this->number          = $this->setup_invoice_number();
384
-        $this->title           = ! empty( $invoice->post_title ) ? $invoice->post_title : $this->number;
384
+        $this->title           = !empty($invoice->post_title) ? $invoice->post_title : $this->number;
385 385
 
386
-        $this->full_name       = trim( $this->first_name . ' ' . $this->last_name );
386
+        $this->full_name       = trim($this->first_name . ' ' . $this->last_name);
387 387
 
388 388
         // Allow extensions to add items to this object via hook
389
-        do_action( 'wpinv_setup_invoice', $this, $invoice_id );
389
+        do_action('wpinv_setup_invoice', $this, $invoice_id);
390 390
 
391 391
         return true;
392 392
     }
393 393
 
394
-    private function setup_status_nicename( $status ) {
394
+    private function setup_status_nicename($status) {
395 395
         return $status;
396 396
     }
397 397
 
398
-    private function setup_post_name( $post ) {
398
+    private function setup_post_name($post) {
399 399
         $this->post_name = $post->post_name;
400 400
     }
401 401
 
402 402
     private function setup_due_date() {
403
-        $due_date = $this->get_meta( '_wpinv_due_date' );
403
+        $due_date = $this->get_meta('_wpinv_due_date');
404 404
 
405
-        if ( empty( $due_date ) ) {
406
-            $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days', 0 ) ) );
407
-            $due_date = date_i18n( 'Y-m-d', $overdue_time );
408
-        } elseif ( $due_date == 'none' ) {
405
+        if (empty($due_date)) {
406
+            $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days', 0)));
407
+            $due_date = date_i18n('Y-m-d', $overdue_time);
408
+        } elseif ($due_date == 'none') {
409 409
             $due_date = '';
410 410
         }
411 411
 
@@ -413,67 +413,67 @@  discard block
 block discarded – undo
413 413
     }
414 414
 
415 415
     private function setup_completed_date() {
416
-        $invoice = get_post( $this->ID );
416
+        $invoice = get_post($this->ID);
417 417
 
418
-        if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) {
418
+        if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) {
419 419
             return false; // This invoice was never paid
420 420
         }
421 421
 
422
-        $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date;
422
+        $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date;
423 423
 
424 424
         return $date;
425 425
     }
426 426
 
427 427
     private function setup_cart_details() {
428
-        $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array();
428
+        $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array();
429 429
         return $cart_details;
430 430
     }
431 431
 
432 432
     public function array_convert() {
433
-        return get_object_vars( $this );
433
+        return get_object_vars($this);
434 434
     }
435 435
 
436 436
     private function setup_items() {
437
-        $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array();
437
+        $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array();
438 438
         return $items;
439 439
     }
440 440
 
441 441
     private function setup_fees() {
442
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
442
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
443 443
         return $payment_fees;
444 444
     }
445 445
 
446 446
     private function setup_currency() {
447
-        $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this );
447
+        $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this);
448 448
         return $currency;
449 449
     }
450 450
 
451 451
     private function setup_discount() {
452 452
         //$discount = $this->get_meta( '_wpinv_discount', true );
453
-        $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total );
454
-        if ( $discount < 0 ) {
453
+        $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total);
454
+        if ($discount < 0) {
455 455
             $discount = 0;
456 456
         }
457
-        $discount = wpinv_round_amount( $discount );
457
+        $discount = wpinv_round_amount($discount);
458 458
 
459 459
         return $discount;
460 460
     }
461 461
 
462 462
     private function setup_discount_code() {
463
-        $discount_code = ! empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true );
463
+        $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true);
464 464
         return $discount_code;
465 465
     }
466 466
 
467 467
     private function setup_tax() {
468 468
 
469
-        $tax = $this->get_meta( '_wpinv_tax', true );
469
+        $tax = $this->get_meta('_wpinv_tax', true);
470 470
 
471 471
         // We don't have tax as it's own meta and no meta was passed
472
-        if ( '' === $tax ) {
473
-            $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0;
472
+        if ('' === $tax) {
473
+            $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0;
474 474
         }
475 475
 
476
-        if ( $tax < 0 || ! $this->is_taxable() ) {
476
+        if ($tax < 0 || !$this->is_taxable()) {
477 477
             $tax = 0;
478 478
         }
479 479
 
@@ -484,16 +484,16 @@  discard block
 block discarded – undo
484 484
      * If taxes are enabled, allow users to enable/disable taxes per invoice.
485 485
      */
486 486
     private function setup_is_taxable() {
487
-        return (int) $this->get_meta( '_wpinv_disable_taxes', true );
487
+        return (int) $this->get_meta('_wpinv_disable_taxes', true);
488 488
     }
489 489
 
490 490
     private function setup_subtotal() {
491 491
         $subtotal     = 0;
492 492
         $cart_details = $this->cart_details;
493 493
 
494
-        if ( is_array( $cart_details ) ) {
495
-            foreach ( $cart_details as $item ) {
496
-                if ( isset( $item['subtotal'] ) ) {
494
+        if (is_array($cart_details)) {
495
+            foreach ($cart_details as $item) {
496
+                if (isset($item['subtotal'])) {
497 497
                     $subtotal += $item['subtotal'];
498 498
                 }
499 499
             }
@@ -507,23 +507,23 @@  discard block
 block discarded – undo
507 507
     }
508 508
 
509 509
     private function setup_discounts() {
510
-        $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array();
510
+        $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array();
511 511
         return $discounts;
512 512
     }
513 513
 
514 514
     private function setup_total() {
515
-        $amount = $this->get_meta( '_wpinv_total', true );
515
+        $amount = $this->get_meta('_wpinv_total', true);
516 516
 
517
-        if ( empty( $amount ) && '0.00' != $amount ) {
518
-            $meta   = $this->get_meta( '_wpinv_payment_meta', true );
519
-            $meta   = maybe_unserialize( $meta );
517
+        if (empty($amount) && '0.00' != $amount) {
518
+            $meta   = $this->get_meta('_wpinv_payment_meta', true);
519
+            $meta   = maybe_unserialize($meta);
520 520
 
521
-            if ( isset( $meta['amount'] ) ) {
521
+            if (isset($meta['amount'])) {
522 522
                 $amount = $meta['amount'];
523 523
             }
524 524
         }
525 525
 
526
-        if ( $amount < 0 ) {
526
+        if ($amount < 0) {
527 527
             $amount = 0;
528 528
         }
529 529
 
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
     }
532 532
 
533 533
     private function setup_mode() {
534
-        return $this->get_meta( '_wpinv_mode' );
534
+        return $this->get_meta('_wpinv_mode');
535 535
     }
536 536
 
537 537
     private function setup_gateway() {
538
-        $gateway = $this->get_meta( '_wpinv_gateway' );
538
+        $gateway = $this->get_meta('_wpinv_gateway');
539 539
 
540
-        if ( empty( $gateway ) && 'publish' === $this->status ) {
540
+        if (empty($gateway) && 'publish' === $this->status) {
541 541
             $gateway = 'manual';
542 542
         }
543 543
 
@@ -545,23 +545,23 @@  discard block
 block discarded – undo
545 545
     }
546 546
 
547 547
     private function setup_gateway_title() {
548
-        $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway );
548
+        $gateway_title = wpinv_get_gateway_checkout_label($this->gateway);
549 549
         return $gateway_title;
550 550
     }
551 551
 
552 552
     private function setup_transaction_id() {
553
-        $transaction_id = $this->get_meta( '_wpinv_transaction_id' );
553
+        $transaction_id = $this->get_meta('_wpinv_transaction_id');
554 554
 
555
-        if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
555
+        if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
556 556
             $gateway        = $this->gateway;
557
-            $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID );
557
+            $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID);
558 558
         }
559 559
 
560 560
         return $transaction_id;
561 561
     }
562 562
 
563 563
     private function setup_ip() {
564
-        $ip = $this->get_meta( '_wpinv_user_ip' );
564
+        $ip = $this->get_meta('_wpinv_user_ip');
565 565
         return $ip;
566 566
     }
567 567
 
@@ -571,62 +571,62 @@  discard block
 block discarded – undo
571 571
     ///}
572 572
 
573 573
     private function setup_first_name() {
574
-        $first_name = $this->get_meta( '_wpinv_first_name' );
574
+        $first_name = $this->get_meta('_wpinv_first_name');
575 575
         return $first_name;
576 576
     }
577 577
 
578 578
     private function setup_last_name() {
579
-        $last_name = $this->get_meta( '_wpinv_last_name' );
579
+        $last_name = $this->get_meta('_wpinv_last_name');
580 580
         return $last_name;
581 581
     }
582 582
 
583 583
     private function setup_company() {
584
-        $company = $this->get_meta( '_wpinv_company' );
584
+        $company = $this->get_meta('_wpinv_company');
585 585
         return $company;
586 586
     }
587 587
 
588 588
     private function setup_vat_number() {
589
-        $vat_number = $this->get_meta( '_wpinv_vat_number' );
589
+        $vat_number = $this->get_meta('_wpinv_vat_number');
590 590
         return $vat_number;
591 591
     }
592 592
 
593 593
     private function setup_vat_rate() {
594
-        $vat_rate = $this->get_meta( '_wpinv_vat_rate' );
594
+        $vat_rate = $this->get_meta('_wpinv_vat_rate');
595 595
         return $vat_rate;
596 596
     }
597 597
 
598 598
     private function setup_adddress_confirmed() {
599
-        $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' );
599
+        $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed');
600 600
         return $adddress_confirmed;
601 601
     }
602 602
 
603 603
     private function setup_phone() {
604
-        $phone = $this->get_meta( '_wpinv_phone' );
604
+        $phone = $this->get_meta('_wpinv_phone');
605 605
         return $phone;
606 606
     }
607 607
 
608 608
     private function setup_address() {
609
-        $address = $this->get_meta( '_wpinv_address', true );
609
+        $address = $this->get_meta('_wpinv_address', true);
610 610
         return $address;
611 611
     }
612 612
 
613 613
     private function setup_city() {
614
-        $city = $this->get_meta( '_wpinv_city', true );
614
+        $city = $this->get_meta('_wpinv_city', true);
615 615
         return $city;
616 616
     }
617 617
 
618 618
     private function setup_country() {
619
-        $country = $this->get_meta( '_wpinv_country', true );
619
+        $country = $this->get_meta('_wpinv_country', true);
620 620
         return $country;
621 621
     }
622 622
 
623 623
     private function setup_state() {
624
-        $state = $this->get_meta( '_wpinv_state', true );
624
+        $state = $this->get_meta('_wpinv_state', true);
625 625
         return $state;
626 626
     }
627 627
 
628 628
     private function setup_zip() {
629
-        $zip = $this->get_meta( '_wpinv_zip', true );
629
+        $zip = $this->get_meta('_wpinv_zip', true);
630 630
         return $zip;
631 631
     }
632 632
 
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
             'user_id'            => $this->user_id,
636 636
             'first_name'         => $this->first_name,
637 637
             'last_name'          => $this->last_name,
638
-            'email'              => get_the_author_meta( 'email', $this->user_id ),
638
+            'email'              => get_the_author_meta('email', $this->user_id),
639 639
             'phone'              => $this->phone,
640 640
             'address'            => $this->address,
641 641
             'city'               => $this->city,
@@ -650,12 +650,12 @@  discard block
 block discarded – undo
650 650
         );
651 651
 
652 652
         $user_info = array();
653
-        if ( isset( $this->payment_meta['user_info'] ) ) {
654
-            $user_info = maybe_unserialize( $this->payment_meta['user_info'] );
653
+        if (isset($this->payment_meta['user_info'])) {
654
+            $user_info = maybe_unserialize($this->payment_meta['user_info']);
655 655
 
656
-            if ( ! empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) {
656
+            if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) {
657 657
                 $this->user_id = $post->post_author;
658
-                $this->email = get_the_author_meta( 'email', $this->user_id );
658
+                $this->email = get_the_author_meta('email', $this->user_id);
659 659
 
660 660
                 $user_info['user_id'] = $this->user_id;
661 661
                 $user_info['email'] = $this->email;
@@ -664,13 +664,13 @@  discard block
 block discarded – undo
664 664
             }
665 665
         }
666 666
 
667
-        $user_info    = wp_parse_args( $user_info, $defaults );
667
+        $user_info = wp_parse_args($user_info, $defaults);
668 668
 
669 669
         // Get the user, but only if it's been created
670
-        $user = get_userdata( $this->user_id );
670
+        $user = get_userdata($this->user_id);
671 671
 
672
-        if ( ! empty( $user ) && $user->ID > 0 ) {
673
-            if ( empty( $user_info ) ) {
672
+        if (!empty($user) && $user->ID > 0) {
673
+            if (empty($user_info)) {
674 674
                 $user_info = array(
675 675
                     'user_id'    => $user->ID,
676 676
                     'first_name' => $user->first_name,
@@ -679,23 +679,23 @@  discard block
 block discarded – undo
679 679
                     'discount'   => '',
680 680
                 );
681 681
             } else {
682
-                foreach ( $user_info as $key => $value ) {
683
-                    if ( ! empty( $value ) ) {
682
+                foreach ($user_info as $key => $value) {
683
+                    if (!empty($value)) {
684 684
                         continue;
685 685
                     }
686 686
 
687
-                    switch ( $key ) {
687
+                    switch ($key) {
688 688
                         case 'user_id':
689
-                            $user_info[ $key ] = $user->ID;
689
+                            $user_info[$key] = $user->ID;
690 690
                             break;
691 691
                         case 'first_name':
692
-                            $user_info[ $key ] = $user->first_name;
692
+                            $user_info[$key] = $user->first_name;
693 693
                             break;
694 694
                         case 'last_name':
695
-                            $user_info[ $key ] = $user->last_name;
695
+                            $user_info[$key] = $user->last_name;
696 696
                             break;
697 697
                         case 'email':
698
-                            $user_info[ $key ] = $user->user_email;
698
+                            $user_info[$key] = $user->user_email;
699 699
                             break;
700 700
                     }
701 701
                 }
@@ -706,25 +706,25 @@  discard block
 block discarded – undo
706 706
     }
707 707
 
708 708
     private function setup_invoice_key() {
709
-        $key = $this->get_meta( '_wpinv_key', true );
709
+        $key = $this->get_meta('_wpinv_key', true);
710 710
 
711 711
         return $key;
712 712
     }
713 713
 
714 714
     private function setup_invoice_number() {
715
-        $number = $this->get_meta( '_wpinv_number', true );
715
+        $number = $this->get_meta('_wpinv_number', true);
716 716
 
717
-        if ( ! $number ) {
717
+        if (!$number) {
718 718
             $number = $this->ID;
719 719
 
720
-            if ( $this->status == 'auto-draft' ) {
721
-                if ( wpinv_sequential_number_active( $this->post_type ) ) {
722
-                    $next_number = wpinv_get_next_invoice_number( $this->post_type );
720
+            if ($this->status == 'auto-draft') {
721
+                if (wpinv_sequential_number_active($this->post_type)) {
722
+                    $next_number = wpinv_get_next_invoice_number($this->post_type);
723 723
                     $number      = $next_number;
724 724
                 }
725 725
             }
726 726
 
727
-            $number = wpinv_format_invoice_number( $number, $this->post_type );
727
+            $number = wpinv_format_invoice_number($number, $this->post_type);
728 728
         }
729 729
 
730 730
         return $number;
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
     public function save() {}
734 734
 
735
-    public function add_fee( $args ) {
735
+    public function add_fee($args) {
736 736
         $default_args = array(
737 737
             'label'   => '',
738 738
             'amount'  => 0,
@@ -742,36 +742,36 @@  discard block
 block discarded – undo
742 742
             'item_id' => 0,
743 743
         );
744 744
 
745
-        $fee = wp_parse_args( $args, $default_args );
745
+        $fee = wp_parse_args($args, $default_args);
746 746
 
747
-        if ( empty( $fee['label'] ) ) {
747
+        if (empty($fee['label'])) {
748 748
             return false;
749 749
         }
750 750
 
751
-        $fee['id']  = sanitize_title( $fee['label'] );
751
+        $fee['id'] = sanitize_title($fee['label']);
752 752
 
753
-        $this->fees[]               = $fee;
753
+        $this->fees[] = $fee;
754 754
 
755 755
         $added_fee               = $fee;
756 756
         $added_fee['action']     = 'add';
757 757
         $this->pending['fees'][] = $added_fee;
758
-        reset( $this->fees );
758
+        reset($this->fees);
759 759
 
760
-        $this->increase_fees( $fee['amount'] );
760
+        $this->increase_fees($fee['amount']);
761 761
         return true;
762 762
     }
763 763
 
764
-    public function remove_fee( $key ) {
764
+    public function remove_fee($key) {
765 765
         $removed = false;
766 766
 
767
-        if ( is_numeric( $key ) ) {
768
-            $removed = $this->remove_fee_by( 'index', $key );
767
+        if (is_numeric($key)) {
768
+            $removed = $this->remove_fee_by('index', $key);
769 769
         }
770 770
 
771 771
         return $removed;
772 772
     }
773 773
 
774
-    public function remove_fee_by( $key, $value, $global = false ) {
774
+    public function remove_fee_by($key, $value, $global = false) {
775 775
         $allowed_fee_keys = apply_filters(
776 776
             'wpinv_fee_keys',
777 777
             array(
@@ -782,41 +782,41 @@  discard block
 block discarded – undo
782 782
             )
783 783
         );
784 784
 
785
-        if ( ! in_array( $key, $allowed_fee_keys ) ) {
785
+        if (!in_array($key, $allowed_fee_keys)) {
786 786
             return false;
787 787
         }
788 788
 
789 789
         $removed = false;
790
-        if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
791
-            $removed_fee             = $this->fees[ $value ];
790
+        if ('index' === $key && array_key_exists($value, $this->fees)) {
791
+            $removed_fee             = $this->fees[$value];
792 792
             $removed_fee['action']   = 'remove';
793 793
             $this->pending['fees'][] = $removed_fee;
794 794
 
795
-            $this->decrease_fees( $removed_fee['amount'] );
795
+            $this->decrease_fees($removed_fee['amount']);
796 796
 
797
-            unset( $this->fees[ $value ] );
797
+            unset($this->fees[$value]);
798 798
             $removed = true;
799
-        } elseif ( 'index' !== $key ) {
800
-            foreach ( $this->fees as $index => $fee ) {
801
-                if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
799
+        } elseif ('index' !== $key) {
800
+            foreach ($this->fees as $index => $fee) {
801
+                if (isset($fee[$key]) && $fee[$key] == $value) {
802 802
                     $removed_fee             = $fee;
803 803
                     $removed_fee['action']   = 'remove';
804 804
                     $this->pending['fees'][] = $removed_fee;
805 805
 
806
-                    $this->decrease_fees( $removed_fee['amount'] );
806
+                    $this->decrease_fees($removed_fee['amount']);
807 807
 
808
-                    unset( $this->fees[ $index ] );
808
+                    unset($this->fees[$index]);
809 809
                     $removed = true;
810 810
 
811
-                    if ( false === $global ) {
811
+                    if (false === $global) {
812 812
                         break;
813 813
                     }
814 814
                 }
815 815
             }
816 816
         }
817 817
 
818
-        if ( true === $removed ) {
819
-            $this->fees = array_values( $this->fees );
818
+        if (true === $removed) {
819
+            $this->fees = array_values($this->fees);
820 820
         }
821 821
 
822 822
         return $removed;
@@ -824,28 +824,28 @@  discard block
 block discarded – undo
824 824
 
825 825
 
826 826
 
827
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
827
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
828 828
         // Bail if no note specified
829
-        if ( ! $note ) {
829
+        if (!$note) {
830 830
             return false;
831 831
         }
832 832
 
833
-        if ( empty( $this->ID ) ) {
833
+        if (empty($this->ID)) {
834 834
             return false;
835 835
         }
836 836
 
837
-        if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && ! $system ) {
838
-            $user                 = get_user_by( 'id', get_current_user_id() );
837
+        if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) {
838
+            $user                 = get_user_by('id', get_current_user_id());
839 839
             $comment_author       = $user->display_name;
840 840
             $comment_author_email = $user->user_email;
841 841
         } else {
842 842
             $comment_author       = 'System';
843 843
             $comment_author_email = 'system@';
844
-            $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com';
845
-            $comment_author_email = sanitize_email( $comment_author_email );
844
+            $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com';
845
+            $comment_author_email = sanitize_email($comment_author_email);
846 846
         }
847 847
 
848
-        do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type );
848
+        do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type);
849 849
 
850 850
         $note_id = wp_insert_comment(
851 851
             wp_filter_comment(
@@ -854,8 +854,8 @@  discard block
 block discarded – undo
854 854
 					'comment_content'      => $note,
855 855
 					'comment_agent'        => 'WPInvoicing',
856 856
 					'user_id'              => is_admin() ? get_current_user_id() : 0,
857
-					'comment_date'         => current_time( 'mysql' ),
858
-					'comment_date_gmt'     => current_time( 'mysql', 1 ),
857
+					'comment_date'         => current_time('mysql'),
858
+					'comment_date_gmt'     => current_time('mysql', 1),
859 859
 					'comment_approved'     => 1,
860 860
 					'comment_parent'       => 0,
861 861
 					'comment_author'       => $comment_author,
@@ -867,10 +867,10 @@  discard block
 block discarded – undo
867 867
             )
868 868
         );
869 869
 
870
-        do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note );
870
+        do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note);
871 871
 
872
-        if ( $customer_type ) {
873
-            add_comment_meta( $note_id, '_wpi_customer_note', 1 );
872
+        if ($customer_type) {
873
+            add_comment_meta($note_id, '_wpi_customer_note', 1);
874 874
 
875 875
             do_action(
876 876
                 'wpinv_new_customer_note',
@@ -884,40 +884,40 @@  discard block
 block discarded – undo
884 884
         return $note_id;
885 885
     }
886 886
 
887
-    private function increase_subtotal( $amount = 0.00 ) {
887
+    private function increase_subtotal($amount = 0.00) {
888 888
         $amount          = (float) $amount;
889 889
         $this->subtotal += $amount;
890
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
890
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
891 891
 
892 892
         $this->recalculate_total();
893 893
     }
894 894
 
895
-    private function decrease_subtotal( $amount = 0.00 ) {
895
+    private function decrease_subtotal($amount = 0.00) {
896 896
         $amount          = (float) $amount;
897 897
         $this->subtotal -= $amount;
898
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
898
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
899 899
 
900
-        if ( $this->subtotal < 0 ) {
900
+        if ($this->subtotal < 0) {
901 901
             $this->subtotal = 0;
902 902
         }
903 903
 
904 904
         $this->recalculate_total();
905 905
     }
906 906
 
907
-    private function increase_fees( $amount = 0.00 ) {
908
-        $amount            = (float)$amount;
907
+    private function increase_fees($amount = 0.00) {
908
+        $amount            = (float) $amount;
909 909
         $this->fees_total += $amount;
910
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
910
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
911 911
 
912 912
         $this->recalculate_total();
913 913
     }
914 914
 
915
-    private function decrease_fees( $amount = 0.00 ) {
915
+    private function decrease_fees($amount = 0.00) {
916 916
         $amount            = (float) $amount;
917 917
         $this->fees_total -= $amount;
918
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
918
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
919 919
 
920
-        if ( $this->fees_total < 0 ) {
920
+        if ($this->fees_total < 0) {
921 921
             $this->fees_total = 0;
922 922
         }
923 923
 
@@ -928,56 +928,56 @@  discard block
 block discarded – undo
928 928
         global $wpi_nosave;
929 929
 
930 930
         $this->total = $this->subtotal + $this->tax + $this->fees_total;
931
-        $this->total = wpinv_round_amount( $this->total );
931
+        $this->total = wpinv_round_amount($this->total);
932 932
 
933
-        do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave );
933
+        do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave);
934 934
     }
935 935
 
936
-    public function increase_tax( $amount = 0.00 ) {
936
+    public function increase_tax($amount = 0.00) {
937 937
         $amount       = (float) $amount;
938 938
         $this->tax   += $amount;
939 939
 
940 940
         $this->recalculate_total();
941 941
     }
942 942
 
943
-    public function decrease_tax( $amount = 0.00 ) {
943
+    public function decrease_tax($amount = 0.00) {
944 944
         $amount     = (float) $amount;
945 945
         $this->tax -= $amount;
946 946
 
947
-        if ( $this->tax < 0 ) {
947
+        if ($this->tax < 0) {
948 948
             $this->tax = 0;
949 949
         }
950 950
 
951 951
         $this->recalculate_total();
952 952
     }
953 953
 
954
-    public function update_status( $new_status = false, $note = '', $manual = false ) {
955
-        $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID );
954
+    public function update_status($new_status = false, $note = '', $manual = false) {
955
+        $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID);
956 956
 
957
-        if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) {
957
+        if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) {
958 958
             return false; // Don't permit status changes that aren't changes
959 959
         }
960 960
 
961
-        $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status );
961
+        $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status);
962 962
         $updated = false;
963 963
 
964
-        if ( $do_change ) {
965
-            do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status );
964
+        if ($do_change) {
965
+            do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status);
966 966
 
967 967
             $update_post_data                   = array();
968 968
             $update_post_data['ID']             = $this->ID;
969 969
             $update_post_data['post_status']    = $new_status;
970
-            $update_post_data['edit_date']      = current_time( 'mysql', 0 );
971
-            $update_post_data['edit_date_gmt']  = current_time( 'mysql', 1 );
970
+            $update_post_data['edit_date']      = current_time('mysql', 0);
971
+            $update_post_data['edit_date_gmt']  = current_time('mysql', 1);
972 972
 
973
-            $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID );
973
+            $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID);
974 974
 
975
-            $updated = wp_update_post( $update_post_data );
975
+            $updated = wp_update_post($update_post_data);
976 976
 
977 977
             // Status was changed.
978
-            do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status );
979
-            do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status );
980
-            do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status );
978
+            do_action('wpinv_status_' . $new_status, $this->ID, $old_status);
979
+            do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status);
980
+            do_action('wpinv_update_status', $this->ID, $new_status, $old_status);
981 981
         }
982 982
 
983 983
         return $updated;
@@ -994,114 +994,114 @@  discard block
 block discarded – undo
994 994
     public function update_meta() {}
995 995
 
996 996
     // get data
997
-    public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) {
998
-        $meta = get_post_meta( $this->ID, $meta_key, $single );
997
+    public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) {
998
+        $meta = get_post_meta($this->ID, $meta_key, $single);
999 999
 
1000
-        if ( $meta_key === '_wpinv_payment_meta' ) {
1000
+        if ($meta_key === '_wpinv_payment_meta') {
1001 1001
 
1002
-            if ( ! is_array( $meta ) ) {
1003
-$meta = array();} // we need this to be an array so make sure it is.
1002
+            if (!is_array($meta)) {
1003
+$meta = array(); } // we need this to be an array so make sure it is.
1004 1004
 
1005
-            if ( empty( $meta['key'] ) ) {
1005
+            if (empty($meta['key'])) {
1006 1006
                 $meta['key'] = $this->setup_invoice_key();
1007 1007
             }
1008 1008
 
1009
-            if ( empty( $meta['date'] ) ) {
1010
-                $meta['date'] = get_post_field( 'post_date', $this->ID );
1009
+            if (empty($meta['date'])) {
1010
+                $meta['date'] = get_post_field('post_date', $this->ID);
1011 1011
             }
1012 1012
         }
1013 1013
 
1014
-        $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID );
1014
+        $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID);
1015 1015
 
1016
-        return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key );
1016
+        return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key);
1017 1017
     }
1018 1018
 
1019 1019
     public function get_description() {
1020
-        $post = get_post( $this->ID );
1020
+        $post = get_post($this->ID);
1021 1021
 
1022
-        $description = ! empty( $post ) ? $post->post_content : '';
1023
-        return apply_filters( 'wpinv_get_description', $description, $this->ID, $this );
1022
+        $description = !empty($post) ? $post->post_content : '';
1023
+        return apply_filters('wpinv_get_description', $description, $this->ID, $this);
1024 1024
     }
1025 1025
 
1026
-    public function get_status( $nicename = false ) {
1027
-        if ( ! $nicename ) {
1026
+    public function get_status($nicename = false) {
1027
+        if (!$nicename) {
1028 1028
             $status = $this->status;
1029 1029
         } else {
1030 1030
             $status = $this->status_nicename;
1031 1031
         }
1032 1032
 
1033
-        return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this );
1033
+        return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this);
1034 1034
     }
1035 1035
 
1036 1036
     public function get_cart_details() {
1037
-        return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this );
1037
+        return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this);
1038 1038
     }
1039 1039
 
1040
-    public function get_subtotal( $currency = false ) {
1041
-        $subtotal = wpinv_round_amount( $this->subtotal );
1040
+    public function get_subtotal($currency = false) {
1041
+        $subtotal = wpinv_round_amount($this->subtotal);
1042 1042
 
1043
-        if ( $currency ) {
1044
-            $subtotal = wpinv_price( wpinv_format_amount( $subtotal, null, ! $currency ), $this->get_currency() );
1043
+        if ($currency) {
1044
+            $subtotal = wpinv_price(wpinv_format_amount($subtotal, null, !$currency), $this->get_currency());
1045 1045
         }
1046 1046
 
1047
-        return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency );
1047
+        return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency);
1048 1048
     }
1049 1049
 
1050
-    public function get_total( $currency = false ) {
1051
-        if ( $this->is_free_trial() ) {
1052
-            $total = wpinv_round_amount( 0 );
1050
+    public function get_total($currency = false) {
1051
+        if ($this->is_free_trial()) {
1052
+            $total = wpinv_round_amount(0);
1053 1053
         } else {
1054
-            $total = wpinv_round_amount( $this->total );
1054
+            $total = wpinv_round_amount($this->total);
1055 1055
         }
1056
-        if ( $currency ) {
1057
-            $total = wpinv_price( wpinv_format_amount( $total, null, ! $currency ), $this->get_currency() );
1056
+        if ($currency) {
1057
+            $total = wpinv_price(wpinv_format_amount($total, null, !$currency), $this->get_currency());
1058 1058
         }
1059 1059
 
1060
-        return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency );
1060
+        return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency);
1061 1061
     }
1062 1062
 
1063 1063
     public function get_recurring_details() {}
1064 1064
 
1065
-    public function get_final_tax( $currency = false ) {
1066
-        $final_total = wpinv_round_amount( $this->tax );
1067
-        if ( $currency ) {
1068
-            $final_total = wpinv_price( wpinv_format_amount( $final_total, null, ! $currency ), $this->get_currency() );
1065
+    public function get_final_tax($currency = false) {
1066
+        $final_total = wpinv_round_amount($this->tax);
1067
+        if ($currency) {
1068
+            $final_total = wpinv_price(wpinv_format_amount($final_total, null, !$currency), $this->get_currency());
1069 1069
         }
1070 1070
 
1071
-        return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency );
1071
+        return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency);
1072 1072
     }
1073 1073
 
1074
-    public function get_discounts( $array = false ) {
1074
+    public function get_discounts($array = false) {
1075 1075
         $discounts = $this->discounts;
1076
-        if ( $array && $discounts ) {
1077
-            $discounts = explode( ',', $discounts );
1076
+        if ($array && $discounts) {
1077
+            $discounts = explode(',', $discounts);
1078 1078
         }
1079
-        return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array );
1079
+        return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array);
1080 1080
     }
1081 1081
 
1082
-    public function get_discount( $currency = false, $dash = false ) {
1083
-        if ( ! empty( $this->discounts ) ) {
1082
+    public function get_discount($currency = false, $dash = false) {
1083
+        if (!empty($this->discounts)) {
1084 1084
             global $ajax_cart_details;
1085 1085
             $ajax_cart_details = $this->get_cart_details();
1086 1086
 
1087
-            if ( ! empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) {
1087
+            if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) {
1088 1088
                 $cart_items = $ajax_cart_details;
1089 1089
             } else {
1090 1090
                 $cart_items = $this->items;
1091 1091
             }
1092 1092
 
1093
-            $this->discount = wpinv_get_cart_items_discount_amount( $cart_items, $this->discounts );
1093
+            $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts);
1094 1094
         }
1095
-        $discount   = wpinv_round_amount( $this->discount );
1095
+        $discount   = wpinv_round_amount($this->discount);
1096 1096
         $dash       = $dash && $discount > 0 ? '&ndash;' : '';
1097 1097
 
1098
-        if ( $currency ) {
1099
-            $discount = wpinv_price( wpinv_format_amount( $discount, null, ! $currency ), $this->get_currency() );
1098
+        if ($currency) {
1099
+            $discount = wpinv_price(wpinv_format_amount($discount, null, !$currency), $this->get_currency());
1100 1100
         }
1101 1101
 
1102
-        $discount   = $dash . $discount;
1102
+        $discount = $dash . $discount;
1103 1103
 
1104
-        return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash );
1104
+        return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash);
1105 1105
     }
1106 1106
 
1107 1107
     public function get_discount_code() {
@@ -1113,150 +1113,150 @@  discard block
 block discarded – undo
1113 1113
         return (int) $this->disable_taxes === 0;
1114 1114
     }
1115 1115
 
1116
-    public function get_tax( $currency = false ) {
1117
-        $tax = wpinv_round_amount( $this->tax );
1116
+    public function get_tax($currency = false) {
1117
+        $tax = wpinv_round_amount($this->tax);
1118 1118
 
1119
-        if ( $currency ) {
1120
-            $tax = wpinv_price( wpinv_format_amount( $tax, null, ! $currency ), $this->get_currency() );
1119
+        if ($currency) {
1120
+            $tax = wpinv_price(wpinv_format_amount($tax, null, !$currency), $this->get_currency());
1121 1121
         }
1122 1122
 
1123
-        if ( ! $this->is_taxable() ) {
1124
-            $tax = wpinv_round_amount( 0.00 );
1123
+        if (!$this->is_taxable()) {
1124
+            $tax = wpinv_round_amount(0.00);
1125 1125
         }
1126 1126
 
1127
-        return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency );
1127
+        return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency);
1128 1128
     }
1129 1129
 
1130
-    public function get_fees( $type = 'all' ) {
1131
-        $fees    = array();
1130
+    public function get_fees($type = 'all') {
1131
+        $fees = array();
1132 1132
 
1133
-        if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1134
-            foreach ( $this->fees as $fee ) {
1135
-                if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1133
+        if (!empty($this->fees) && is_array($this->fees)) {
1134
+            foreach ($this->fees as $fee) {
1135
+                if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) {
1136 1136
                     continue;
1137 1137
                 }
1138 1138
 
1139
-                $fee['label'] = stripslashes( $fee['label'] );
1140
-                $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() );
1141
-                $fees[]    = $fee;
1139
+                $fee['label'] = stripslashes($fee['label']);
1140
+                $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency());
1141
+                $fees[] = $fee;
1142 1142
             }
1143 1143
         }
1144 1144
 
1145
-        return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this );
1145
+        return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this);
1146 1146
     }
1147 1147
 
1148 1148
     public function get_fees_total() {
1149 1149
         $fees_total = (float) 0.00;
1150 1150
 
1151
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1152
-        if ( ! empty( $payment_fees ) ) {
1153
-            foreach ( $payment_fees as $fee ) {
1151
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1152
+        if (!empty($payment_fees)) {
1153
+            foreach ($payment_fees as $fee) {
1154 1154
                 $fees_total += (float) $fee['amount'];
1155 1155
             }
1156 1156
         }
1157 1157
 
1158
-        return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this );
1158
+        return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this);
1159 1159
 
1160 1160
     }
1161 1161
 
1162 1162
     public function get_user_id() {
1163
-        return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this );
1163
+        return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this);
1164 1164
     }
1165 1165
 
1166 1166
     public function get_first_name() {
1167
-        return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this );
1167
+        return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this);
1168 1168
     }
1169 1169
 
1170 1170
     public function get_last_name() {
1171
-        return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this );
1171
+        return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this);
1172 1172
     }
1173 1173
 
1174 1174
     public function get_user_full_name() {
1175
-        return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this );
1175
+        return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this);
1176 1176
     }
1177 1177
 
1178 1178
     public function get_user_info() {
1179
-        return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this );
1179
+        return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this);
1180 1180
     }
1181 1181
 
1182 1182
     public function get_email() {
1183
-        return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this );
1183
+        return apply_filters('wpinv_user_email', $this->email, $this->ID, $this);
1184 1184
     }
1185 1185
 
1186 1186
     public function get_address() {
1187
-        return apply_filters( 'wpinv_address', $this->address, $this->ID, $this );
1187
+        return apply_filters('wpinv_address', $this->address, $this->ID, $this);
1188 1188
     }
1189 1189
 
1190 1190
     public function get_phone() {
1191
-        return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this );
1191
+        return apply_filters('wpinv_phone', $this->phone, $this->ID, $this);
1192 1192
     }
1193 1193
 
1194 1194
     public function get_number() {
1195
-        return apply_filters( 'wpinv_number', $this->number, $this->ID, $this );
1195
+        return apply_filters('wpinv_number', $this->number, $this->ID, $this);
1196 1196
     }
1197 1197
 
1198 1198
     public function get_items() {
1199
-        return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this );
1199
+        return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this);
1200 1200
     }
1201 1201
 
1202 1202
     public function get_key() {
1203
-        return apply_filters( 'wpinv_key', $this->key, $this->ID, $this );
1203
+        return apply_filters('wpinv_key', $this->key, $this->ID, $this);
1204 1204
     }
1205 1205
 
1206 1206
     public function get_transaction_id() {
1207
-        return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this );
1207
+        return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this);
1208 1208
     }
1209 1209
 
1210 1210
     public function get_gateway() {
1211
-        return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this );
1211
+        return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this);
1212 1212
     }
1213 1213
 
1214 1214
     public function get_gateway_title() {}
1215 1215
 
1216 1216
     public function get_currency() {
1217
-        return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this );
1217
+        return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this);
1218 1218
     }
1219 1219
 
1220 1220
     public function get_created_date() {
1221
-        return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this );
1221
+        return apply_filters('wpinv_created_date', $this->date, $this->ID, $this);
1222 1222
     }
1223 1223
 
1224
-    public function get_due_date( $display = false ) {
1225
-        $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this );
1224
+    public function get_due_date($display = false) {
1225
+        $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this);
1226 1226
 
1227
-        if ( ! $display ) {
1227
+        if (!$display) {
1228 1228
             return $due_date;
1229 1229
         }
1230 1230
 
1231
-        return getpaid_format_date( $this->due_date );
1231
+        return getpaid_format_date($this->due_date);
1232 1232
     }
1233 1233
 
1234 1234
     public function get_completed_date() {
1235
-        return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this );
1235
+        return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this);
1236 1236
     }
1237 1237
 
1238
-    public function get_invoice_date( $formatted = true ) {
1238
+    public function get_invoice_date($formatted = true) {
1239 1239
         $date_completed = $this->completed_date;
1240 1240
         $invoice_date   = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
1241 1241
 
1242
-        if ( $invoice_date == '' ) {
1242
+        if ($invoice_date == '') {
1243 1243
             $date_created   = $this->date;
1244 1244
             $invoice_date   = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : '';
1245 1245
         }
1246 1246
 
1247
-        if ( $formatted && $invoice_date ) {
1248
-            $invoice_date   = getpaid_format_date( $invoice_date );
1247
+        if ($formatted && $invoice_date) {
1248
+            $invoice_date = getpaid_format_date($invoice_date);
1249 1249
         }
1250 1250
 
1251
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this );
1251
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this);
1252 1252
     }
1253 1253
 
1254 1254
     public function get_ip() {
1255
-        return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this );
1255
+        return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this);
1256 1256
     }
1257 1257
 
1258
-    public function has_status( $status ) {
1259
-        return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status );
1258
+    public function has_status($status) {
1259
+        return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status);
1260 1260
     }
1261 1261
 
1262 1262
     public function add_item() {}
@@ -1273,66 +1273,66 @@  discard block
 block discarded – undo
1273 1273
 
1274 1274
     public function get_view_url() {}
1275 1275
 
1276
-    public function generate_key( $string = '' ) {
1277
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1278
-        return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) );  // Unique key
1276
+    public function generate_key($string = '') {
1277
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1278
+        return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key
1279 1279
     }
1280 1280
 
1281 1281
     public function is_recurring() {
1282
-        if ( empty( $this->cart_details ) ) {
1282
+        if (empty($this->cart_details)) {
1283 1283
             return false;
1284 1284
         }
1285 1285
 
1286 1286
         $has_subscription = false;
1287
-        foreach ( $this->cart_details as $cart_item ) {
1288
-            if ( ! empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) {
1287
+        foreach ($this->cart_details as $cart_item) {
1288
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
1289 1289
                 $has_subscription = true;
1290 1290
                 break;
1291 1291
             }
1292 1292
         }
1293 1293
 
1294
-        if ( count( $this->cart_details ) > 1 ) {
1294
+        if (count($this->cart_details) > 1) {
1295 1295
             $has_subscription = false;
1296 1296
         }
1297 1297
 
1298
-        return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details );
1298
+        return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details);
1299 1299
     }
1300 1300
 
1301 1301
     public function is_free_trial() {
1302 1302
         $is_free_trial = false;
1303 1303
 
1304
-        if ( $this->is_parent() && $item = $this->get_recurring( true ) ) {
1305
-            if ( ! empty( $item ) && $item->has_free_trial() ) {
1304
+        if ($this->is_parent() && $item = $this->get_recurring(true)) {
1305
+            if (!empty($item) && $item->has_free_trial()) {
1306 1306
                 $is_free_trial = true;
1307 1307
             }
1308 1308
         }
1309 1309
 
1310
-        return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this );
1310
+        return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this);
1311 1311
     }
1312 1312
 
1313 1313
     public function is_initial_free() {}
1314 1314
 
1315
-    public function get_recurring( $object = false ) {
1315
+    public function get_recurring($object = false) {
1316 1316
         $item = null;
1317 1317
 
1318
-        if ( empty( $this->cart_details ) ) {
1318
+        if (empty($this->cart_details)) {
1319 1319
             return $item;
1320 1320
         }
1321 1321
 
1322
-        foreach ( $this->cart_details as $cart_item ) {
1323
-            if ( ! empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) {
1322
+        foreach ($this->cart_details as $cart_item) {
1323
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
1324 1324
                 $item = $cart_item['id'];
1325 1325
                 break;
1326 1326
             }
1327 1327
         }
1328 1328
 
1329
-        if ( $object ) {
1330
-            $item = $item ? new WPInv_Item( $item ) : null;
1329
+        if ($object) {
1330
+            $item = $item ? new WPInv_Item($item) : null;
1331 1331
 
1332
-            apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this );
1332
+            apply_filters('wpinv_invoice_get_recurring_item', $item, $this);
1333 1333
         }
1334 1334
 
1335
-        return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this );
1335
+        return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this);
1336 1336
     }
1337 1337
 
1338 1338
     public function get_subscription_name() {}
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
     public function get_subscription_id() {}
1341 1341
 
1342 1342
     public function is_parent() {
1343
-        return ! empty( $this->parent_invoice );
1343
+        return !empty($this->parent_invoice);
1344 1344
     }
1345 1345
 
1346 1346
     public function is_renewal() {}
@@ -1354,8 +1354,8 @@  discard block
 block discarded – undo
1354 1354
     public function is_refunded() {}
1355 1355
 
1356 1356
     public function is_free() {
1357
-        $total = (float) wpinv_round_amount( $this->get_total() );
1358
-        return $total > 0 && ! $this->is_recurring();
1357
+        $total = (float) wpinv_round_amount($this->get_total());
1358
+        return $total > 0 && !$this->is_recurring();
1359 1359
     }
1360 1360
 
1361 1361
     public function has_vat() {}
Please login to merge, or discard this patch.
templates/invoice/billing-address.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  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
-$invoice     = new WPInv_Invoice( $invoice );
13
-$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() );
12
+$invoice     = new WPInv_Invoice($invoice);
13
+$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info());
14 14
 $phone       = $invoice->get_phone();
15 15
 $email       = $invoice->get_email();
16 16
 $vat_number  = $invoice->get_vat_number();
@@ -22,47 +22,47 @@  discard block
 block discarded – undo
22 22
 
23 23
 
24 24
             <div class="invoice-billing-address-label col-2">
25
-                <strong><?php esc_html_e( 'To:', 'invoicing' ); ?></strong>
25
+                <strong><?php esc_html_e('To:', 'invoicing'); ?></strong>
26 26
             </div>
27 27
 
28 28
 
29 29
             <div class="invoice-billing-address-value col-10">
30 30
 
31
-                <?php do_action( 'getpaid_billing_address_top' ); ?>
31
+                <?php do_action('getpaid_billing_address_top'); ?>
32 32
 
33
-                <?php if ( ! empty( $address_row ) ) : ?>
33
+                <?php if (!empty($address_row)) : ?>
34 34
                     <div class="billing-address">
35
-                        <?php echo wp_kses_post( $address_row ); ?>
35
+                        <?php echo wp_kses_post($address_row); ?>
36 36
                     </div>
37 37
                 <?php endif; ?>
38 38
 
39 39
 
40
-                <?php if ( ! empty( $phone ) ) : ?>
40
+                <?php if (!empty($phone)) : ?>
41 41
                     <div class="billing-phone">
42
-                        <?php echo wp_sprintf( esc_html__( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?>
42
+                        <?php echo wp_sprintf(esc_html__('Phone: %s', 'invoicing'), esc_html($phone)); ?>
43 43
                     </div>
44 44
                 <?php endif; ?>
45 45
 
46 46
 
47
-                <?php if ( ! empty( $email ) ) : ?>
47
+                <?php if (!empty($email)) : ?>
48 48
                     <div class="billing-email">
49
-                        <?php echo wp_sprintf( esc_html__( 'Email: %s', 'invoicing' ), esc_html( $email ) ); ?>
49
+                        <?php echo wp_sprintf(esc_html__('Email: %s', 'invoicing'), esc_html($email)); ?>
50 50
                     </div>
51 51
                 <?php endif; ?>
52 52
 
53
-                <?php if ( ! empty( $vat_number ) ) : ?>
53
+                <?php if (!empty($vat_number)) : ?>
54 54
                     <div class="vat-number">
55
-                        <?php echo wp_sprintf( esc_html__( 'Vat Number: %s', 'invoicing' ), esc_html( $vat_number ) ); ?>
55
+                        <?php echo wp_sprintf(esc_html__('Vat Number: %s', 'invoicing'), esc_html($vat_number)); ?>
56 56
                     </div>
57 57
                 <?php endif; ?>
58 58
 
59
-                <?php if ( ! empty( $company_id ) ) : ?>
59
+                <?php if (!empty($company_id)) : ?>
60 60
                     <div class="company-id">
61
-                        <?php echo wp_sprintf( esc_html__( 'Company ID: %s', 'invoicing' ), esc_html( $company_id ) ); ?>
61
+                        <?php echo wp_sprintf(esc_html__('Company ID: %s', 'invoicing'), esc_html($company_id)); ?>
62 62
                     </div>
63 63
                 <?php endif; ?>
64 64
 
65
-                <?php do_action( 'getpaid_billing_address_bottom' ); ?>
65
+                <?php do_action('getpaid_billing_address_bottom'); ?>
66 66
 
67 67
             </div>
68 68
 
Please login to merge, or discard this patch.