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