Passed
Push — master ( 8c59eb...c9008f )
by Brian
04:48
created
includes/admin/class-getpaid-admin.php 1 patch
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,21 +54,21 @@  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' ) );
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_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
71
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
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_send_invoice', array($this, 'send_customer_invoice'));
65
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
66
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
67
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
68
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
69
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
70
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
71
+		do_action('getpaid_init_admin_hooks', $this);
72 72
 
73 73
     }
74 74
 
@@ -79,37 +79,37 @@  discard block
 block discarded – undo
79 79
 	public function enqeue_scripts() {
80 80
         global $current_screen, $pagenow;
81 81
 
82
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
82
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
83 83
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
84 84
 
85
-        if ( ! empty( $current_screen->post_type ) ) {
85
+        if (!empty($current_screen->post_type)) {
86 86
 			$page = $current_screen->post_type;
87 87
         }
88 88
 
89 89
         // General styles.
90
-        if ( false !== stripos( $page, 'wpi' ) ) {
90
+        if (false !== stripos($page, 'wpi')) {
91 91
 
92 92
             // Styles.
93
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
94
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
95
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
93
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
94
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
95
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
96 96
 
97 97
             // Scripts.
98
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
98
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
99 99
 
100
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
101
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker' ),  $version );
102
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
100
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
101
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker'), $version);
102
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
103 103
 
104 104
         }
105 105
 
106 106
         // Payment form scripts.
107
-		if ( 'wpi_payment_form' == $page && $editing ) {
107
+		if ('wpi_payment_form' == $page && $editing) {
108 108
             $this->load_payment_form_scripts();
109 109
         }
110 110
 
111
-		if ( $page == 'wpinv-subscriptions' ) {
112
-			wp_enqueue_script( 'postbox' );
111
+		if ($page == 'wpinv-subscriptions') {
112
+			wp_enqueue_script('postbox');
113 113
 		}
114 114
 
115 115
     }
@@ -122,32 +122,32 @@  discard block
 block discarded – undo
122 122
         global $post;
123 123
 
124 124
 		$date_range = array(
125
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
125
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
126 126
 		);
127 127
 
128
-		if ( $date_range['period'] == 'custom' ) {
128
+		if ($date_range['period'] == 'custom') {
129 129
 			
130
-			if ( isset( $_GET['from'] ) ) {
131
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
130
+			if (isset($_GET['from'])) {
131
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
132 132
 			}
133 133
 
134
-			if ( isset( $_GET['to'] ) ) {
135
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
134
+			if (isset($_GET['to'])) {
135
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
136 136
 			}
137 137
 
138 138
 		}
139 139
 
140 140
         $i18n = array(
141
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
142
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
143
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
144
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
145
-			'rest_root'                 => esc_url_raw( rest_url() ),
141
+            'ajax_url'                  => admin_url('admin-ajax.php'),
142
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
143
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
144
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
145
+			'rest_root'                 => esc_url_raw(rest_url()),
146 146
 			'date_range'                => $date_range,
147
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
148
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
149
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
150
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
147
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
148
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
149
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
150
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
151 151
             'tax'                       => wpinv_tax_amount(),
152 152
             'discount'                  => 0,
153 153
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -156,36 +156,36 @@  discard block
 block discarded – undo
156 156
             'thousand_sep'              => wpinv_thousands_separator(),
157 157
             'decimal_sep'               => wpinv_decimal_separator(),
158 158
             'decimals'                  => wpinv_decimals(),
159
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
160
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
161
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
162
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
163
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
164
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
165
-            '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' ),
166
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
167
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
168
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
169
-            'action_edit'               => __( 'Edit', 'invoicing' ),
170
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
171
-            'item_description'          => __( 'Item Description', 'invoicing' ),
172
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
173
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
174
-			'searching'                 => __( 'Searching', 'invoicing' ),
175
-			'loading'                   => __( 'Loading...', 'invoicing' ),
159
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
160
+            'status_publish'            => wpinv_status_nicename('publish'),
161
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
162
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
163
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
164
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
165
+            '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'),
166
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
167
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
168
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
169
+            'action_edit'               => __('Edit', 'invoicing'),
170
+            'action_cancel'             => __('Cancel', 'invoicing'),
171
+            'item_description'          => __('Item Description', 'invoicing'),
172
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
173
+            'discount_description'      => __('Discount Description', 'invoicing'),
174
+			'searching'                 => __('Searching', 'invoicing'),
175
+			'loading'                   => __('Loading...', 'invoicing'),
176 176
         );
177 177
 
178
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
178
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
179 179
 
180
-			$invoice              = new WPInv_Invoice( $post );
180
+			$invoice              = new WPInv_Invoice($post);
181 181
 			$i18n['save_invoice'] = sprintf(
182
-				__( 'Save %s', 'invoicing' ),
183
-				ucfirst( $invoice->get_invoice_quote_type() )
182
+				__('Save %s', 'invoicing'),
183
+				ucfirst($invoice->get_invoice_quote_type())
184 184
 			);
185 185
 
186 186
 			$i18n['invoice_description'] = sprintf(
187
-				__( '%s Description', 'invoicing' ),
188
-				ucfirst( $invoice->get_invoice_quote_type() )
187
+				__('%s Description', 'invoicing'),
188
+				ucfirst($invoice->get_invoice_quote_type())
189 189
 			);
190 190
 
191 191
 		}
@@ -199,24 +199,24 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $footer_text
200 200
 	 * @return string
201 201
 	 */
202
-	public function admin_footer_text( $footer_text ) {
202
+	public function admin_footer_text($footer_text) {
203 203
 		global $current_screen;
204 204
 
205
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
205
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
206 206
 
207
-        if ( ! empty( $current_screen->post_type ) ) {
207
+        if (!empty($current_screen->post_type)) {
208 208
 			$page = $current_screen->post_type;
209 209
         }
210 210
 
211 211
         // General styles.
212
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
212
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
213 213
 
214 214
 			// Change the footer text
215
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
215
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
216 216
 
217
-				$rating_url  = esc_url(
217
+				$rating_url = esc_url(
218 218
 					wp_nonce_url(
219
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
219
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
220 220
 						'getpaid-nonce',
221 221
 						'getpaid-nonce'
222 222
 						)
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 				$footer_text = sprintf(
226 226
 					/* translators: %s: five stars */
227
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
227
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
228 228
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
229 229
 				);
230 230
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
 				$footer_text = sprintf(
234 234
 					/* translators: %s: GetPaid */
235
-					__( 'Thank you for using %s!', 'invoicing' ),
235
+					__('Thank you for using %s!', 'invoicing'),
236 236
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
237 237
 				);
238 238
 
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 	 * @since  2.0.0
250 250
 	 */
251 251
 	public function redirect_to_wordpress_rating_page() {
252
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
253
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
252
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
253
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
254 254
 		exit;
255 255
 	}
256 256
 
@@ -261,30 +261,30 @@  discard block
 block discarded – undo
261 261
 	protected function load_payment_form_scripts() {
262 262
         global $post;
263 263
 
264
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
265
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
266
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
264
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
265
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
266
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
267 267
 
268
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
269
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
268
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
269
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
270 270
 
271 271
 		wp_localize_script(
272 272
             'wpinv-admin-payment-form-script',
273 273
             'wpinvPaymentFormAdmin',
274 274
             array(
275
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
276
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
275
+				'elements'      => wpinv_get_data('payment-form-elements'),
276
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
277 277
 				'currency'      => wpinv_currency_symbol(),
278 278
 				'position'      => wpinv_currency_position(),
279 279
 				'decimals'      => (int) wpinv_decimals(),
280 280
 				'thousands_sep' => wpinv_thousands_separator(),
281 281
 				'decimals_sep'  => wpinv_decimal_separator(),
282
-				'form_items'    => gepaid_get_form_items( $post->ID ),
282
+				'form_items'    => gepaid_get_form_items($post->ID),
283 283
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
284 284
             )
285 285
         );
286 286
 
287
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
287
+        wp_enqueue_script('wpinv-admin-payment-form-script');
288 288
 
289 289
     }
290 290
 
@@ -295,25 +295,25 @@  discard block
 block discarded – undo
295 295
      * @return string
296 296
 	 *
297 297
 	 */
298
-    public function admin_body_class( $classes ) {
298
+    public function admin_body_class($classes) {
299 299
 		global $pagenow, $post, $current_screen;
300 300
 
301 301
 
302
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
302
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
303 303
 
304
-        if ( ! empty( $current_screen->post_type ) ) {
304
+        if (!empty($current_screen->post_type)) {
305 305
 			$page = $current_screen->post_type;
306 306
         }
307 307
 
308
-        if ( false !== stripos( $page, 'wpi' ) ) {
309
-            $classes .= ' wpi-' . sanitize_key( $page );
308
+        if (false !== stripos($page, 'wpi')) {
309
+            $classes .= ' wpi-' . sanitize_key($page);
310 310
         }
311 311
 
312
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
312
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
313 313
             $classes .= ' wpinv-cpt wpinv';
314 314
 		}
315 315
 		
316
-		if ( getpaid_is_invoice_post_type( $page ) ) {
316
+		if (getpaid_is_invoice_post_type($page)) {
317 317
             $classes .= ' getpaid-is-invoice-cpt';
318 318
         }
319 319
 
@@ -323,19 +323,19 @@  discard block
 block discarded – undo
323 323
     /**
324 324
 	 * Maybe show the AyeCode Connect Notice.
325 325
 	 */
326
-	public function init_ayecode_connect_helper(){
326
+	public function init_ayecode_connect_helper() {
327 327
 
328 328
         new AyeCode_Connect_Helper(
329 329
             array(
330
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
331
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
332
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
333
-				'connect_button'    => __("Connect Site","invoicing"),
334
-				'connecting_button'    => __("Connecting...","invoicing"),
335
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
336
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
330
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
331
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
332
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
333
+				'connect_button'    => __("Connect Site", "invoicing"),
334
+				'connecting_button'    => __("Connecting...", "invoicing"),
335
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
336
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
337 337
             ),
338
-            array( 'wpi-addons' )
338
+            array('wpi-addons')
339 339
         );
340 340
 
341 341
     }
@@ -347,20 +347,20 @@  discard block
 block discarded – undo
347 347
 	 */
348 348
 	public function activation_redirect() {
349 349
 
350
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
350
+		$redirected = get_option('wpinv_redirected_to_settings');
351 351
 
352
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
352
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
353 353
 			return;
354 354
 		}
355 355
 
356 356
 		// Bail if activating from network, or bulk
357
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
357
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
358 358
 			return;
359 359
 		}
360 360
 
361
-	    update_option( 'wpinv_redirected_to_settings', 1 );
361
+	    update_option('wpinv_redirected_to_settings', 1);
362 362
 
363
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
363
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
364 364
         exit;
365 365
 
366 366
 	}
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
      */
371 371
     public function maybe_do_admin_action() {
372 372
 
373
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
374
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
375
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
373
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
374
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
375
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
376 376
         }
377 377
 
378 378
     }
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
 	 * 
383 383
 	 * @param array $args
384 384
      */
385
-    public function send_customer_invoice( $args ) {
386
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
385
+    public function send_customer_invoice($args) {
386
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
387 387
 
388
-		if ( $sent ) {
389
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
388
+		if ($sent) {
389
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
390 390
 		} else {
391
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
391
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
392 392
 		}
393 393
 
394
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
394
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
395 395
 		exit;
396 396
 	}
397 397
 
@@ -400,16 +400,16 @@  discard block
 block discarded – undo
400 400
 	 * 
401 401
 	 * @param array $args
402 402
      */
403
-    public function send_customer_payment_reminder( $args ) {
404
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
403
+    public function send_customer_payment_reminder($args) {
404
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
405 405
 
406
-		if ( $sent ) {
407
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
406
+		if ($sent) {
407
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
408 408
 		} else {
409
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
409
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
410 410
 		}
411 411
 
412
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
412
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
413 413
 		exit;
414 414
 	}
415 415
 
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public function admin_reset_tax_rates() {
421 421
 
422
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
423
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
422
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
423
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
424 424
 		exit;
425 425
 
426 426
 	}
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
     public function admin_create_missing_pages() {
433 433
 		$installer = new GetPaid_Installer();
434 434
 		$installer->create_pages();
435
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
436
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
435
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
436
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
437 437
 		exit;
438 438
 	}
439 439
 
@@ -445,35 +445,35 @@  discard block
 block discarded – undo
445 445
 		global $wpdb;
446 446
 		$installer = new GetPaid_Installer();
447 447
 
448
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
448
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
449 449
 			$installer->create_subscriptions_table();
450 450
 
451
-			if ( $wpdb->last_error !== '' ) {
452
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
451
+			if ($wpdb->last_error !== '') {
452
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
453 453
 			}
454 454
 		}
455 455
 
456
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
456
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
457 457
 			$installer->create_invoices_table();
458 458
 
459
-			if ( $wpdb->last_error !== '' ) {
460
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
459
+			if ($wpdb->last_error !== '') {
460
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
461 461
 			}
462 462
 		}
463 463
 
464
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
464
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
465 465
 			$installer->create_invoice_items_table();
466 466
 
467
-			if ( $wpdb->last_error !== '' ) {
468
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
467
+			if ($wpdb->last_error !== '') {
468
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
469 469
 			}
470 470
 		}
471 471
 
472
-		if ( ! $this->has_notices() ) {
473
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
472
+		if (!$this->has_notices()) {
473
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
474 474
 		}
475 475
 
476
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
476
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
477 477
 		exit;
478 478
 	}
479 479
 
@@ -488,10 +488,10 @@  discard block
 block discarded – undo
488 488
 		$installer->migrate_old_invoices();
489 489
 
490 490
 		// Show an admin message.
491
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
491
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
492 492
 
493 493
 		// Redirect the admin.
494
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
494
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
495 495
 		exit;
496 496
 
497 497
 	}
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
      * @return array
504 504
 	 */
505 505
 	public function get_notices() {
506
-		$notices = get_option( 'wpinv_admin_notices' );
507
-        return is_array( $notices ) ? $notices : array();
506
+		$notices = get_option('wpinv_admin_notices');
507
+        return is_array($notices) ? $notices : array();
508 508
 	}
509 509
 
510 510
 	/**
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
      * @return array
515 515
 	 */
516 516
 	public function has_notices() {
517
-		return count( $this->get_notices() ) > 0;
517
+		return count($this->get_notices()) > 0;
518 518
 	}
519 519
 
520 520
 	/**
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	 * @since       1.0.19
525 525
 	 */
526 526
 	public function clear_notices() {
527
-		delete_option( 'wpinv_admin_notices' );
527
+		delete_option('wpinv_admin_notices');
528 528
 	}
529 529
 
530 530
 	/**
@@ -533,16 +533,16 @@  discard block
 block discarded – undo
533 533
 	 * @access      public
534 534
 	 * @since       1.0.19
535 535
 	 */
536
-	public function save_notice( $type, $message ) {
536
+	public function save_notice($type, $message) {
537 537
 		$notices = $this->get_notices();
538 538
 
539
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
540
-			$notices[ $type ] = array();
539
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
540
+			$notices[$type] = array();
541 541
 		}
542 542
 
543
-		$notices[ $type ][] = $message;
543
+		$notices[$type][] = $message;
544 544
 
545
-		update_option( 'wpinv_admin_notices', $notices );
545
+		update_option('wpinv_admin_notices', $notices);
546 546
 	}
547 547
 
548 548
 	/**
@@ -552,8 +552,8 @@  discard block
 block discarded – undo
552 552
 	 * @access      public
553 553
 	 * @since       1.0.19
554 554
 	 */
555
-	public function show_success( $msg ) {
556
-		$this->save_notice( 'success', $msg );
555
+	public function show_success($msg) {
556
+		$this->save_notice('success', $msg);
557 557
 	}
558 558
 
559 559
 	/**
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
 	 * @param       string $msg The message to qeue.
564 564
 	 * @since       1.0.19
565 565
 	 */
566
-	public function show_error( $msg ) {
567
-		$this->save_notice( 'error', $msg );
566
+	public function show_error($msg) {
567
+		$this->save_notice('error', $msg);
568 568
 	}
569 569
 
570 570
 	/**
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
 	 * @param       string $msg The message to qeue.
575 575
 	 * @since       1.0.19
576 576
 	 */
577
-	public function show_warning( $msg ) {
578
-		$this->save_notice( 'warning', $msg );
577
+	public function show_warning($msg) {
578
+		$this->save_notice('warning', $msg);
579 579
 	}
580 580
 
581 581
 	/**
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
 	 * @param       string $msg The message to qeue.
586 586
 	 * @since       1.0.19
587 587
 	 */
588
-	public function show_info( $msg ) {
589
-		$this->save_notice( 'info', $msg );
588
+	public function show_info($msg) {
589
+		$this->save_notice('info', $msg);
590 590
 	}
591 591
 
592 592
 	/**
@@ -600,32 +600,32 @@  discard block
 block discarded – undo
600 600
         $notices = $this->get_notices();
601 601
         $this->clear_notices();
602 602
 
603
-		foreach ( $notices as $type => $messages ) {
603
+		foreach ($notices as $type => $messages) {
604 604
 
605
-			if ( ! is_array( $messages ) ) {
605
+			if (!is_array($messages)) {
606 606
 				continue;
607 607
 			}
608 608
 
609
-            $type  = sanitize_key( $type );
610
-			foreach ( $messages as $message ) {
611
-                $message = wp_kses_post( $message );
609
+            $type = sanitize_key($type);
610
+			foreach ($messages as $message) {
611
+                $message = wp_kses_post($message);
612 612
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
613 613
             }
614 614
 
615 615
         }
616 616
 
617
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
617
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
618 618
 
619
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
620
-				$url     = esc_url(
619
+			if (!is_numeric(wpinv_get_option($page, false))) {
620
+				$url = esc_url(
621 621
 					wp_nonce_url(
622
-						add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
622
+						add_query_arg('getpaid-admin-action', 'create_missing_pages'),
623 623
 						'getpaid-nonce',
624 624
 						'getpaid-nonce'
625 625
 					)
626 626
 				);
627
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
628
-				$message2 = __( 'Generate Pages', 'invoicing' );
627
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
628
+				$message2 = __('Generate Pages', 'invoicing');
629 629
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
630 630
 				break;
631 631
 			}
Please login to merge, or discard this patch.