@@ -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,33 +54,33 @@ discard block |
||
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 ( $_GET['page'] ) { |
|
80 | + if (!empty($_GET['page'])) { |
|
81 | + switch ($_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 |
||
94 | 94 | public function enqeue_scripts() { |
95 | 95 | global $current_screen, $pagenow; |
96 | 96 | |
97 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
97 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
98 | 98 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
99 | 99 | |
100 | - if ( ! empty( $current_screen->post_type ) ) { |
|
100 | + if (!empty($current_screen->post_type)) { |
|
101 | 101 | $page = $current_screen->post_type; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // General styles. |
105 | - if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) { |
|
105 | + if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) { |
|
106 | 106 | |
107 | 107 | // Styles. |
108 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
109 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
110 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
108 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
109 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
110 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
111 | 111 | |
112 | 112 | // Scripts. |
113 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
113 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
114 | 114 | |
115 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
116 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version ); |
|
117 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
115 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
116 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); |
|
117 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Payment form scripts. |
122 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
122 | + if ('wpi_payment_form' == $page && $editing) { |
|
123 | 123 | $this->load_payment_form_scripts(); |
124 | 124 | } |
125 | 125 | |
126 | - if ( $page == 'wpinv-subscriptions' ) { |
|
127 | - wp_enqueue_script( 'postbox' ); |
|
126 | + if ($page == 'wpinv-subscriptions') { |
|
127 | + wp_enqueue_script('postbox'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | } |
@@ -137,32 +137,32 @@ discard block |
||
137 | 137 | global $post; |
138 | 138 | |
139 | 139 | $date_range = array( |
140 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days' |
|
140 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days' |
|
141 | 141 | ); |
142 | 142 | |
143 | - if ( $date_range['period'] == 'custom' ) { |
|
143 | + if ($date_range['period'] == 'custom') { |
|
144 | 144 | |
145 | - if ( isset( $_GET['from'] ) ) { |
|
146 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
145 | + if (isset($_GET['from'])) { |
|
146 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
147 | 147 | } |
148 | 148 | |
149 | - if ( isset( $_GET['to'] ) ) { |
|
150 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
149 | + if (isset($_GET['to'])) { |
|
150 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | } |
154 | 154 | |
155 | 155 | $i18n = array( |
156 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
157 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
158 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
159 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
160 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
156 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
157 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
158 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
159 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
160 | + 'rest_root' => esc_url_raw(rest_url()), |
|
161 | 161 | 'date_range' => $date_range, |
162 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
163 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
164 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
165 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
162 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
163 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
164 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
165 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
166 | 166 | 'tax' => wpinv_tax_amount(), |
167 | 167 | 'discount' => 0, |
168 | 168 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -171,39 +171,39 @@ discard block |
||
171 | 171 | 'thousand_sep' => wpinv_thousands_separator(), |
172 | 172 | 'decimal_sep' => wpinv_decimal_separator(), |
173 | 173 | 'decimals' => wpinv_decimals(), |
174 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
175 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
176 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
177 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
178 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
179 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
180 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
181 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
182 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
183 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
184 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
185 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
186 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
187 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
188 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
189 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
190 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
191 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
192 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
193 | - 'graphs' => array_merge( ['refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'], array_keys( wpinv_get_report_graphs() ) ), |
|
174 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
175 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
176 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
177 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
178 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
179 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
180 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
181 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
182 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
183 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
184 | + 'action_edit' => __('Edit', 'invoicing'), |
|
185 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
186 | + 'item_description' => __('Item Description', 'invoicing'), |
|
187 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
188 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
189 | + 'searching' => __('Searching', 'invoicing'), |
|
190 | + 'loading' => __('Loading...', 'invoicing'), |
|
191 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
192 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
193 | + 'graphs' => array_merge(['refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'], array_keys(wpinv_get_report_graphs())), |
|
194 | 194 | ); |
195 | 195 | |
196 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
196 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
197 | 197 | |
198 | - $invoice = new WPInv_Invoice( $post ); |
|
198 | + $invoice = new WPInv_Invoice($post); |
|
199 | 199 | $i18n['save_invoice'] = sprintf( |
200 | - __( 'Save %s', 'invoicing' ), |
|
201 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
200 | + __('Save %s', 'invoicing'), |
|
201 | + ucfirst($invoice->get_invoice_quote_type()) |
|
202 | 202 | ); |
203 | 203 | |
204 | 204 | $i18n['invoice_description'] = sprintf( |
205 | - __( '%s Description', 'invoicing' ), |
|
206 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
205 | + __('%s Description', 'invoicing'), |
|
206 | + ucfirst($invoice->get_invoice_quote_type()) |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | } |
@@ -217,24 +217,24 @@ discard block |
||
217 | 217 | * @param string $footer_text |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function admin_footer_text( $footer_text ) { |
|
220 | + public function admin_footer_text($footer_text) { |
|
221 | 221 | global $current_screen; |
222 | 222 | |
223 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
223 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
224 | 224 | |
225 | - if ( ! empty( $current_screen->post_type ) ) { |
|
225 | + if (!empty($current_screen->post_type)) { |
|
226 | 226 | $page = $current_screen->post_type; |
227 | 227 | } |
228 | 228 | |
229 | 229 | // General styles. |
230 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
230 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
231 | 231 | |
232 | 232 | // Change the footer text |
233 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
233 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
234 | 234 | |
235 | - $rating_url = esc_url( |
|
235 | + $rating_url = esc_url( |
|
236 | 236 | wp_nonce_url( |
237 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
237 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
238 | 238 | 'getpaid-nonce', |
239 | 239 | 'getpaid-nonce' |
240 | 240 | ) |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | $footer_text = sprintf( |
244 | 244 | /* translators: %s: five stars */ |
245 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
245 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
246 | 246 | "<a href='$rating_url'>★★★★★</a>" |
247 | 247 | ); |
248 | 248 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | $footer_text = sprintf( |
252 | 252 | /* translators: %s: GetPaid */ |
253 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
253 | + __('Thank you for using %s!', 'invoicing'), |
|
254 | 254 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
255 | 255 | ); |
256 | 256 | |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | * @since 2.0.0 |
268 | 268 | */ |
269 | 269 | public function redirect_to_wordpress_rating_page() { |
270 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
271 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
270 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
271 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
272 | 272 | exit; |
273 | 273 | } |
274 | 274 | |
@@ -279,30 +279,30 @@ discard block |
||
279 | 279 | protected function load_payment_form_scripts() { |
280 | 280 | global $post; |
281 | 281 | |
282 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
|
283 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
284 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
282 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION); |
|
283 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
284 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
285 | 285 | |
286 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
287 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version ); |
|
286 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
287 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version); |
|
288 | 288 | |
289 | 289 | wp_localize_script( |
290 | 290 | 'wpinv-admin-payment-form-script', |
291 | 291 | 'wpinvPaymentFormAdmin', |
292 | 292 | array( |
293 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
294 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
293 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
294 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
295 | 295 | 'currency' => wpinv_currency_symbol(), |
296 | 296 | 'position' => wpinv_currency_position(), |
297 | 297 | 'decimals' => (int) wpinv_decimals(), |
298 | 298 | 'thousands_sep' => wpinv_thousands_separator(), |
299 | 299 | 'decimals_sep' => wpinv_decimal_separator(), |
300 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
300 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
301 | 301 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
302 | 302 | ) |
303 | 303 | ); |
304 | 304 | |
305 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
305 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
306 | 306 | |
307 | 307 | } |
308 | 308 | |
@@ -313,25 +313,25 @@ discard block |
||
313 | 313 | * @return string |
314 | 314 | * |
315 | 315 | */ |
316 | - public function admin_body_class( $classes ) { |
|
316 | + public function admin_body_class($classes) { |
|
317 | 317 | global $pagenow, $post, $current_screen; |
318 | 318 | |
319 | 319 | |
320 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
320 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
321 | 321 | |
322 | - if ( ! empty( $current_screen->post_type ) ) { |
|
322 | + if (!empty($current_screen->post_type)) { |
|
323 | 323 | $page = $current_screen->post_type; |
324 | 324 | } |
325 | 325 | |
326 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
327 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
326 | + if (false !== stripos($page, 'wpi')) { |
|
327 | + $classes .= ' wpi-' . sanitize_key($page); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
330 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
331 | 331 | $classes .= ' wpinv-cpt wpinv'; |
332 | 332 | } |
333 | 333 | |
334 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
334 | + if (getpaid_is_invoice_post_type($page)) { |
|
335 | 335 | $classes .= ' getpaid-is-invoice-cpt'; |
336 | 336 | } |
337 | 337 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | /** |
342 | 342 | * Maybe show the AyeCode Connect Notice. |
343 | 343 | */ |
344 | - public function init_ayecode_connect_helper(){ |
|
344 | + public function init_ayecode_connect_helper() { |
|
345 | 345 | |
346 | 346 | // Register with the deactivation survey class. |
347 | 347 | AyeCode_Deactivation_Survey::instance(array( |
@@ -349,20 +349,20 @@ discard block |
||
349 | 349 | 'version' => WPINV_VERSION, |
350 | 350 | 'support_url' => 'https://wpgetpaid.com/support/', |
351 | 351 | 'documentation_url' => 'https://docs.wpgetpaid.com/', |
352 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
352 | + 'activated' => (int) get_option('gepaid_installed_on'), |
|
353 | 353 | )); |
354 | 354 | |
355 | 355 | new AyeCode_Connect_Helper( |
356 | 356 | array( |
357 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
358 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
359 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
360 | - 'connect_button' => __("Connect Site","invoicing"), |
|
361 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
362 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
363 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
357 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
358 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
359 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
360 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
361 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
362 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
363 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
364 | 364 | ), |
365 | - array( 'wpi-addons' ) |
|
365 | + array('wpi-addons') |
|
366 | 366 | ); |
367 | 367 | |
368 | 368 | } |
@@ -374,20 +374,20 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function activation_redirect() { |
376 | 376 | |
377 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
377 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
378 | 378 | |
379 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
379 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
380 | 380 | return; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // Bail if activating from network, or bulk |
384 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
384 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
385 | 385 | return; |
386 | 386 | } |
387 | 387 | |
388 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
388 | + update_option('wpinv_redirected_to_settings', 1); |
|
389 | 389 | |
390 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
|
390 | + wp_safe_redirect(admin_url('index.php?page=gp-setup')); |
|
391 | 391 | exit; |
392 | 392 | |
393 | 393 | } |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function maybe_do_admin_action() { |
399 | 399 | |
400 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
401 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
402 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
400 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
401 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
402 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | } |
@@ -409,24 +409,24 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @param array $args |
411 | 411 | */ |
412 | - public function duplicate_invoice( $args ) { |
|
412 | + public function duplicate_invoice($args) { |
|
413 | 413 | |
414 | - if ( empty( $args['invoice_id'] ) ) { |
|
414 | + if (empty($args['invoice_id'])) { |
|
415 | 415 | return; |
416 | 416 | } |
417 | 417 | |
418 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
418 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
419 | 419 | |
420 | - if ( ! $invoice->exists() ) { |
|
420 | + if (!$invoice->exists()) { |
|
421 | 421 | return; |
422 | 422 | } |
423 | 423 | |
424 | - $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
424 | + $new_invoice = getpaid_duplicate_invoice($invoice); |
|
425 | 425 | $new_invoice->save(); |
426 | 426 | |
427 | - if ( $new_invoice->exists() ) { |
|
427 | + if ($new_invoice->exists()) { |
|
428 | 428 | |
429 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) ); |
|
429 | + getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box')); |
|
430 | 430 | |
431 | 431 | wp_safe_redirect( |
432 | 432 | add_query_arg( |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | 'action' => 'edit', |
435 | 435 | 'post' => $new_invoice->get_id(), |
436 | 436 | ), |
437 | - admin_url( 'post.php' ) |
|
437 | + admin_url('post.php') |
|
438 | 438 | ) |
439 | 439 | ); |
440 | 440 | exit; |
441 | 441 | |
442 | 442 | } |
443 | 443 | |
444 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) ); |
|
444 | + getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box')); |
|
445 | 445 | |
446 | 446 | } |
447 | 447 | |
@@ -450,34 +450,34 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @param array $args |
452 | 452 | */ |
453 | - public function duplicate_payment_form( $args ) { |
|
453 | + public function duplicate_payment_form($args) { |
|
454 | 454 | |
455 | - if ( empty( $args['form_id'] ) ) { |
|
455 | + if (empty($args['form_id'])) { |
|
456 | 456 | return; |
457 | 457 | } |
458 | 458 | |
459 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
459 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
460 | 460 | |
461 | - if ( ! $form->exists() ) { |
|
461 | + if (!$form->exists()) { |
|
462 | 462 | return; |
463 | 463 | } |
464 | 464 | |
465 | 465 | $new_form = new GetPaid_Payment_Form(); |
466 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
467 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
468 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
469 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
466 | + $new_form->set_author($form->get_author('edit')); |
|
467 | + $new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing')); |
|
468 | + $new_form->set_elements($form->get_elements('edit')); |
|
469 | + $new_form->set_items($form->get_items('edit')); |
|
470 | 470 | $new_form->save(); |
471 | 471 | |
472 | - if ( $new_form->exists() ) { |
|
473 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
474 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
472 | + if ($new_form->exists()) { |
|
473 | + $this->show_success(__('Form duplicated successfully', 'invoicing')); |
|
474 | + $url = get_edit_post_link($new_form->get_id(), 'edit'); |
|
475 | 475 | } else { |
476 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
477 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
476 | + $this->show_error(__('Unable to duplicate form', 'invoicing')); |
|
477 | + $url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')); |
|
478 | 478 | } |
479 | 479 | |
480 | - wp_redirect( $url ); |
|
480 | + wp_redirect($url); |
|
481 | 481 | exit; |
482 | 482 | } |
483 | 483 | |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @param array $args |
488 | 488 | */ |
489 | - public function send_customer_invoice( $args ) { |
|
490 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
491 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
489 | + public function send_customer_invoice($args) { |
|
490 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); |
|
491 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
492 | 492 | exit; |
493 | 493 | } |
494 | 494 | |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @param array $args |
499 | 499 | */ |
500 | - public function send_customer_payment_reminder( $args ) { |
|
501 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
500 | + public function send_customer_payment_reminder($args) { |
|
501 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
502 | 502 | |
503 | - if ( $sent ) { |
|
504 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
503 | + if ($sent) { |
|
504 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
505 | 505 | } else { |
506 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
506 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
507 | 507 | } |
508 | 508 | |
509 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
509 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
510 | 510 | exit; |
511 | 511 | } |
512 | 512 | |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | */ |
517 | 517 | public function admin_reset_tax_rates() { |
518 | 518 | |
519 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
520 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
519 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
520 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
521 | 521 | exit; |
522 | 522 | |
523 | 523 | } |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | public function admin_create_missing_pages() { |
530 | 530 | $installer = new GetPaid_Installer(); |
531 | 531 | $installer->create_pages(); |
532 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
533 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
532 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
533 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
534 | 534 | exit; |
535 | 535 | } |
536 | 536 | |
@@ -542,35 +542,35 @@ discard block |
||
542 | 542 | global $wpdb; |
543 | 543 | $installer = new GetPaid_Installer(); |
544 | 544 | |
545 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
545 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') { |
|
546 | 546 | $installer->create_subscriptions_table(); |
547 | 547 | |
548 | - if ( $wpdb->last_error !== '' ) { |
|
549 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
548 | + if ($wpdb->last_error !== '') { |
|
549 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
553 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
553 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') { |
|
554 | 554 | $installer->create_invoices_table(); |
555 | 555 | |
556 | - if ( $wpdb->last_error !== '' ) { |
|
557 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
556 | + if ($wpdb->last_error !== '') { |
|
557 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
561 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') { |
|
562 | 562 | $installer->create_invoice_items_table(); |
563 | 563 | |
564 | - if ( $wpdb->last_error !== '' ) { |
|
565 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
564 | + if ($wpdb->last_error !== '') { |
|
565 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
566 | 566 | } |
567 | 567 | } |
568 | 568 | |
569 | - if ( ! $this->has_notices() ) { |
|
570 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
569 | + if (!$this->has_notices()) { |
|
570 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
571 | 571 | } |
572 | 572 | |
573 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
573 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
574 | 574 | exit; |
575 | 575 | } |
576 | 576 | |
@@ -585,10 +585,10 @@ discard block |
||
585 | 585 | $installer->migrate_old_invoices(); |
586 | 586 | |
587 | 587 | // Show an admin message. |
588 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
588 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
589 | 589 | |
590 | 590 | // Redirect the admin. |
591 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
591 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
592 | 592 | exit; |
593 | 593 | |
594 | 594 | } |
@@ -600,18 +600,18 @@ discard block |
||
600 | 600 | public function admin_download_customers() { |
601 | 601 | global $wpdb; |
602 | 602 | |
603 | - $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) ); |
|
603 | + $output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing')); |
|
604 | 604 | |
605 | - header( "Content-Type:text/csv" ); |
|
606 | - header( "Content-Disposition:attachment;filename=customers.csv" ); |
|
605 | + header("Content-Type:text/csv"); |
|
606 | + header("Content-Disposition:attachment;filename=customers.csv"); |
|
607 | 607 | |
608 | 608 | $post_types = ''; |
609 | 609 | |
610 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
611 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
610 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
611 | + $post_types .= $wpdb->prepare("post_type=%s OR ", $post_type); |
|
612 | 612 | } |
613 | 613 | |
614 | - $post_types = rtrim( $post_types, ' OR' ); |
|
614 | + $post_types = rtrim($post_types, ' OR'); |
|
615 | 615 | |
616 | 616 | $customers = $wpdb->get_col( |
617 | 617 | $wpdb->prepare( |
@@ -620,58 +620,58 @@ discard block |
||
620 | 620 | ); |
621 | 621 | |
622 | 622 | $columns = array( |
623 | - 'name' => __( 'Name', 'invoicing' ), |
|
624 | - 'email' => __( 'Email', 'invoicing' ), |
|
625 | - 'country' => __( 'Country', 'invoicing' ), |
|
626 | - 'state' => __( 'State', 'invoicing' ), |
|
627 | - 'city' => __( 'City', 'invoicing' ), |
|
628 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
629 | - 'address' => __( 'Address', 'invoicing' ), |
|
630 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
631 | - 'company' => __( 'Company', 'invoicing' ), |
|
632 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
633 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
634 | - 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
635 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
623 | + 'name' => __('Name', 'invoicing'), |
|
624 | + 'email' => __('Email', 'invoicing'), |
|
625 | + 'country' => __('Country', 'invoicing'), |
|
626 | + 'state' => __('State', 'invoicing'), |
|
627 | + 'city' => __('City', 'invoicing'), |
|
628 | + 'zip' => __('ZIP', 'invoicing'), |
|
629 | + 'address' => __('Address', 'invoicing'), |
|
630 | + 'phone' => __('Phone', 'invoicing'), |
|
631 | + 'company' => __('Company', 'invoicing'), |
|
632 | + 'company_id' => __('Company ID', 'invoicing'), |
|
633 | + 'invoices' => __('Invoices', 'invoicing'), |
|
634 | + 'total_raw' => __('Total Spend', 'invoicing'), |
|
635 | + 'signup' => __('Date created', 'invoicing'), |
|
636 | 636 | ); |
637 | 637 | |
638 | 638 | // Output the csv column headers. |
639 | - fputcsv( $output, array_values( $columns ) ); |
|
639 | + fputcsv($output, array_values($columns)); |
|
640 | 640 | |
641 | 641 | // Loop through |
642 | 642 | $table = new WPInv_Customers_Table(); |
643 | - foreach ( $customers as $customer_id ) { |
|
643 | + foreach ($customers as $customer_id) { |
|
644 | 644 | |
645 | - $user = get_user_by( 'id', $customer_id ); |
|
645 | + $user = get_user_by('id', $customer_id); |
|
646 | 646 | $row = array(); |
647 | - if ( empty( $user ) ) { |
|
647 | + if (empty($user)) { |
|
648 | 648 | continue; |
649 | 649 | } |
650 | 650 | |
651 | - foreach ( array_keys( $columns ) as $column ) { |
|
651 | + foreach (array_keys($columns) as $column) { |
|
652 | 652 | |
653 | 653 | $method = 'column_' . $column; |
654 | 654 | |
655 | - if ( 'name' == $column ) { |
|
656 | - $value = esc_html( $user->display_name ); |
|
657 | - } else if( 'email' == $column ) { |
|
658 | - $value = sanitize_email( $user->user_email ); |
|
659 | - } else if ( is_callable( array( $table, $method ) ) ) { |
|
660 | - $value = strip_tags( $table->$method( $user ) ); |
|
655 | + if ('name' == $column) { |
|
656 | + $value = esc_html($user->display_name); |
|
657 | + } else if ('email' == $column) { |
|
658 | + $value = sanitize_email($user->user_email); |
|
659 | + } else if (is_callable(array($table, $method))) { |
|
660 | + $value = strip_tags($table->$method($user)); |
|
661 | 661 | } |
662 | 662 | |
663 | - if ( empty( $value ) ) { |
|
664 | - $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
663 | + if (empty($value)) { |
|
664 | + $value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true)); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | $row[] = $value; |
668 | 668 | |
669 | 669 | } |
670 | 670 | |
671 | - fputcsv( $output, $row ); |
|
671 | + fputcsv($output, $row); |
|
672 | 672 | } |
673 | 673 | |
674 | - fclose( $output ); |
|
674 | + fclose($output); |
|
675 | 675 | exit; |
676 | 676 | |
677 | 677 | } |
@@ -681,29 +681,29 @@ discard block |
||
681 | 681 | * |
682 | 682 | * @param array $data |
683 | 683 | */ |
684 | - public function admin_install_plugin( $data ) { |
|
684 | + public function admin_install_plugin($data) { |
|
685 | 685 | |
686 | - if ( ! empty( $data['plugins'] ) ) { |
|
686 | + if (!empty($data['plugins'])) { |
|
687 | 687 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
688 | 688 | wp_cache_flush(); |
689 | 689 | |
690 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
691 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
692 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
693 | - $installed = $upgrader->install( $plugin_zip ); |
|
690 | + foreach ($data['plugins'] as $slug => $file) { |
|
691 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); |
|
692 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
693 | + $installed = $upgrader->install($plugin_zip); |
|
694 | 694 | |
695 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
696 | - activate_plugin( $file, '', false, true ); |
|
695 | + if (!is_wp_error($installed) && $installed) { |
|
696 | + activate_plugin($file, '', false, true); |
|
697 | 697 | } else { |
698 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
698 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | } |
702 | 702 | |
703 | 703 | } |
704 | 704 | |
705 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
706 | - wp_safe_redirect( $redirect ); |
|
705 | + $redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); |
|
706 | + wp_safe_redirect($redirect); |
|
707 | 707 | exit; |
708 | 708 | |
709 | 709 | } |
@@ -713,42 +713,42 @@ discard block |
||
713 | 713 | * |
714 | 714 | * @param array $data |
715 | 715 | */ |
716 | - public function admin_connect_gateway( $data ) { |
|
716 | + public function admin_connect_gateway($data) { |
|
717 | 717 | |
718 | - if ( ! empty( $data['plugin'] ) ) { |
|
718 | + if (!empty($data['plugin'])) { |
|
719 | 719 | |
720 | - $gateway = sanitize_key( $data['plugin'] ); |
|
721 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
720 | + $gateway = sanitize_key($data['plugin']); |
|
721 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
722 | 722 | |
723 | - if ( ! empty( $connect_url ) ) { |
|
724 | - wp_redirect( $connect_url ); |
|
723 | + if (!empty($connect_url)) { |
|
724 | + wp_redirect($connect_url); |
|
725 | 725 | exit; |
726 | 726 | } |
727 | 727 | |
728 | - if ( 'stripe' == $data['plugin'] ) { |
|
728 | + if ('stripe' == $data['plugin']) { |
|
729 | 729 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
730 | 730 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
731 | 731 | wp_cache_flush(); |
732 | 732 | |
733 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
734 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
735 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
736 | - $upgrader->install( $plugin_zip ); |
|
733 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
734 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
735 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
736 | + $upgrader->install($plugin_zip); |
|
737 | 737 | } |
738 | 738 | |
739 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
739 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
740 | 740 | } |
741 | 741 | |
742 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
743 | - if ( ! empty( $connect_url ) ) { |
|
744 | - wp_redirect( $connect_url ); |
|
742 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
743 | + if (!empty($connect_url)) { |
|
744 | + wp_redirect($connect_url); |
|
745 | 745 | exit; |
746 | 746 | } |
747 | 747 | |
748 | 748 | } |
749 | 749 | |
750 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
751 | - wp_safe_redirect( $redirect ); |
|
750 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
751 | + wp_safe_redirect($redirect); |
|
752 | 752 | exit; |
753 | 753 | |
754 | 754 | } |
@@ -762,36 +762,36 @@ discard block |
||
762 | 762 | |
763 | 763 | // Fetch all invoices that have discount codes. |
764 | 764 | $table = $wpdb->prefix . 'getpaid_invoices'; |
765 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
765 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
766 | 766 | |
767 | - foreach ( $invoices as $invoice ) { |
|
767 | + foreach ($invoices as $invoice) { |
|
768 | 768 | |
769 | - $invoice = new WPInv_Invoice( $invoice ); |
|
769 | + $invoice = new WPInv_Invoice($invoice); |
|
770 | 770 | |
771 | - if ( ! $invoice->exists() ) { |
|
771 | + if (!$invoice->exists()) { |
|
772 | 772 | continue; |
773 | 773 | } |
774 | 774 | |
775 | 775 | // Abort if the discount does not exist or does not apply here. |
776 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
777 | - if ( ! $discount->exists() ) { |
|
776 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
777 | + if (!$discount->exists()) { |
|
778 | 778 | continue; |
779 | 779 | } |
780 | 780 | |
781 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
781 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
782 | 782 | $invoice->recalculate_total(); |
783 | 783 | |
784 | - if ( $invoice->get_total_discount() > 0 ) { |
|
784 | + if ($invoice->get_total_discount() > 0) { |
|
785 | 785 | $invoice->save(); |
786 | 786 | } |
787 | 787 | |
788 | 788 | } |
789 | 789 | |
790 | 790 | // Show an admin message. |
791 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
791 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
792 | 792 | |
793 | 793 | // Redirect the admin. |
794 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
794 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
795 | 795 | exit; |
796 | 796 | |
797 | 797 | } |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | * @return array |
804 | 804 | */ |
805 | 805 | public function get_notices() { |
806 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
807 | - return is_array( $notices ) ? $notices : array(); |
|
806 | + $notices = get_option('wpinv_admin_notices'); |
|
807 | + return is_array($notices) ? $notices : array(); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | /** |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | * @return array |
815 | 815 | */ |
816 | 816 | public function has_notices() { |
817 | - return count( $this->get_notices() ) > 0; |
|
817 | + return count($this->get_notices()) > 0; |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | /** |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | * @since 1.0.19 |
825 | 825 | */ |
826 | 826 | public function clear_notices() { |
827 | - delete_option( 'wpinv_admin_notices' ); |
|
827 | + delete_option('wpinv_admin_notices'); |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | /** |
@@ -833,16 +833,16 @@ discard block |
||
833 | 833 | * @access public |
834 | 834 | * @since 1.0.19 |
835 | 835 | */ |
836 | - public function save_notice( $type, $message ) { |
|
836 | + public function save_notice($type, $message) { |
|
837 | 837 | $notices = $this->get_notices(); |
838 | 838 | |
839 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
840 | - $notices[ $type ] = array(); |
|
839 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
840 | + $notices[$type] = array(); |
|
841 | 841 | } |
842 | 842 | |
843 | - $notices[ $type ][] = $message; |
|
843 | + $notices[$type][] = $message; |
|
844 | 844 | |
845 | - update_option( 'wpinv_admin_notices', $notices ); |
|
845 | + update_option('wpinv_admin_notices', $notices); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | * @access public |
853 | 853 | * @since 1.0.19 |
854 | 854 | */ |
855 | - public function show_success( $msg ) { |
|
856 | - $this->save_notice( 'success', $msg ); |
|
855 | + public function show_success($msg) { |
|
856 | + $this->save_notice('success', $msg); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | * @param string $msg The message to qeue. |
864 | 864 | * @since 1.0.19 |
865 | 865 | */ |
866 | - public function show_error( $msg ) { |
|
867 | - $this->save_notice( 'error', $msg ); |
|
866 | + public function show_error($msg) { |
|
867 | + $this->save_notice('error', $msg); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -874,8 +874,8 @@ discard block |
||
874 | 874 | * @param string $msg The message to qeue. |
875 | 875 | * @since 1.0.19 |
876 | 876 | */ |
877 | - public function show_warning( $msg ) { |
|
878 | - $this->save_notice( 'warning', $msg ); |
|
877 | + public function show_warning($msg) { |
|
878 | + $this->save_notice('warning', $msg); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | /** |
@@ -885,8 +885,8 @@ discard block |
||
885 | 885 | * @param string $msg The message to qeue. |
886 | 886 | * @since 1.0.19 |
887 | 887 | */ |
888 | - public function show_info( $msg ) { |
|
889 | - $this->save_notice( 'info', $msg ); |
|
888 | + public function show_info($msg) { |
|
889 | + $this->save_notice('info', $msg); |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | /** |
@@ -900,30 +900,30 @@ discard block |
||
900 | 900 | $notices = $this->get_notices(); |
901 | 901 | $this->clear_notices(); |
902 | 902 | |
903 | - foreach ( $notices as $type => $messages ) { |
|
903 | + foreach ($notices as $type => $messages) { |
|
904 | 904 | |
905 | - if ( ! is_array( $messages ) ) { |
|
905 | + if (!is_array($messages)) { |
|
906 | 906 | continue; |
907 | 907 | } |
908 | 908 | |
909 | - $type = sanitize_key( $type ); |
|
910 | - foreach ( $messages as $message ) { |
|
911 | - $message = wp_kses_post( $message ); |
|
909 | + $type = sanitize_key($type); |
|
910 | + foreach ($messages as $message) { |
|
911 | + $message = wp_kses_post($message); |
|
912 | 912 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
913 | 913 | } |
914 | 914 | |
915 | 915 | } |
916 | 916 | |
917 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
917 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
918 | 918 | |
919 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
920 | - $url = wp_nonce_url( |
|
921 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
919 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
920 | + $url = wp_nonce_url( |
|
921 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
922 | 922 | 'getpaid-nonce', |
923 | 923 | 'getpaid-nonce' |
924 | 924 | ); |
925 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
926 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
925 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
926 | + $message2 = __('Generate Pages', 'invoicing'); |
|
927 | 927 | echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"; |
928 | 928 | break; |
929 | 929 | } |
@@ -12,88 +12,88 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports_Report { |
14 | 14 | |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - public $views; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + public $views; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Class constructor. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function __construct() { |
|
20 | + /** |
|
21 | + * Class constructor. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | 25 | |
26 | - $this->views = array( |
|
26 | + $this->views = array( |
|
27 | 27 | |
28 | 28 | 'items' => array( |
29 | - 'label' => __( 'Items', 'invoicing' ), |
|
30 | - 'class' => 'GetPaid_Reports_Report_Items', |
|
31 | - ), |
|
29 | + 'label' => __( 'Items', 'invoicing' ), |
|
30 | + 'class' => 'GetPaid_Reports_Report_Items', |
|
31 | + ), |
|
32 | 32 | |
33 | - 'gateways' => array( |
|
34 | - 'label' => __( 'Payment Methods', 'invoicing' ), |
|
35 | - 'class' => 'GetPaid_Reports_Report_Gateways', |
|
36 | - ), |
|
33 | + 'gateways' => array( |
|
34 | + 'label' => __( 'Payment Methods', 'invoicing' ), |
|
35 | + 'class' => 'GetPaid_Reports_Report_Gateways', |
|
36 | + ), |
|
37 | 37 | |
38 | - 'discounts' => array( |
|
39 | - 'label' => __( 'Discount Codes', 'invoicing' ), |
|
40 | - 'class' => 'GetPaid_Reports_Report_Discounts', |
|
41 | - ), |
|
38 | + 'discounts' => array( |
|
39 | + 'label' => __( 'Discount Codes', 'invoicing' ), |
|
40 | + 'class' => 'GetPaid_Reports_Report_Discounts', |
|
41 | + ), |
|
42 | 42 | |
43 | 43 | ); |
44 | 44 | |
45 | - $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
46 | - |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Retrieves the current range. |
|
51 | - * |
|
52 | - */ |
|
53 | - public function get_range() { |
|
54 | - $valid_ranges = $this->get_periods(); |
|
55 | - |
|
56 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
57 | - return sanitize_key( $_GET['date_range'] ); |
|
58 | - } |
|
59 | - |
|
60 | - return '7_days'; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Returns an array of date ranges. |
|
65 | - * |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function get_periods() { |
|
69 | - |
|
70 | - $periods = array( |
|
71 | - 'today' => __( 'Today', 'invoicing' ), |
|
72 | - 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
73 | - 'week' => __( 'This week', 'invoicing' ), |
|
74 | - 'last_week' => __( 'Last week', 'invoicing' ), |
|
75 | - '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
76 | - 'month' => __( 'This month', 'invoicing' ), |
|
77 | - 'last_month' => __( 'Last month', 'invoicing' ), |
|
78 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
79 | - 'quarter' => __( 'This Quarter', 'invoicing' ), |
|
80 | - 'last_quarter' => __( 'Last Quarter', 'invoicing' ), |
|
81 | - 'year' => __( 'This year', 'invoicing' ), |
|
82 | - 'last_year' => __( 'Last Year', 'invoicing' ), |
|
83 | - 'custom' => __( 'Custom Date Range', 'invoicing' ), |
|
84 | - ); |
|
85 | - |
|
86 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Displays the range selector. |
|
91 | - * |
|
92 | - */ |
|
93 | - public function display_range_selector() { |
|
94 | - |
|
95 | - $range = $this->get_range(); |
|
96 | - ?> |
|
45 | + $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
46 | + |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Retrieves the current range. |
|
51 | + * |
|
52 | + */ |
|
53 | + public function get_range() { |
|
54 | + $valid_ranges = $this->get_periods(); |
|
55 | + |
|
56 | + if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
57 | + return sanitize_key( $_GET['date_range'] ); |
|
58 | + } |
|
59 | + |
|
60 | + return '7_days'; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Returns an array of date ranges. |
|
65 | + * |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function get_periods() { |
|
69 | + |
|
70 | + $periods = array( |
|
71 | + 'today' => __( 'Today', 'invoicing' ), |
|
72 | + 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
73 | + 'week' => __( 'This week', 'invoicing' ), |
|
74 | + 'last_week' => __( 'Last week', 'invoicing' ), |
|
75 | + '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
76 | + 'month' => __( 'This month', 'invoicing' ), |
|
77 | + 'last_month' => __( 'Last month', 'invoicing' ), |
|
78 | + '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
79 | + 'quarter' => __( 'This Quarter', 'invoicing' ), |
|
80 | + 'last_quarter' => __( 'Last Quarter', 'invoicing' ), |
|
81 | + 'year' => __( 'This year', 'invoicing' ), |
|
82 | + 'last_year' => __( 'Last Year', 'invoicing' ), |
|
83 | + 'custom' => __( 'Custom Date Range', 'invoicing' ), |
|
84 | + ); |
|
85 | + |
|
86 | + return apply_filters( 'getpaid_earning_periods', $periods ); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Displays the range selector. |
|
91 | + * |
|
92 | + */ |
|
93 | + public function display_range_selector() { |
|
94 | + |
|
95 | + $range = $this->get_range(); |
|
96 | + ?> |
|
97 | 97 | |
98 | 98 | <form method="get" class="getpaid-filter-earnings float-right"> |
99 | 99 | <?php getpaid_hidden_field( 'page', isset( $_GET['page'] ) ? wpinv_clean( $_GET['page'] ) : 'wpinv-reports' ); ?> |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | </form> |
116 | 116 | |
117 | 117 | <?php |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Displays the reports tab. |
|
122 | - * |
|
123 | - */ |
|
124 | - public function display() { |
|
125 | - ?> |
|
120 | + /** |
|
121 | + * Displays the reports tab. |
|
122 | + * |
|
123 | + */ |
|
124 | + public function display() { |
|
125 | + ?> |
|
126 | 126 | |
127 | 127 | <div class="mt-4" style="max-width: 1200px;"> |
128 | 128 | |
@@ -202,16 +202,16 @@ discard block |
||
202 | 202 | |
203 | 203 | <?php |
204 | 204 | |
205 | - } |
|
205 | + } |
|
206 | 206 | |
207 | - /** |
|
208 | - * Displays the left side. |
|
209 | - * |
|
210 | - */ |
|
211 | - public function display_left() { |
|
212 | - $graphs = wpinv_get_report_graphs(); |
|
207 | + /** |
|
208 | + * Displays the left side. |
|
209 | + * |
|
210 | + */ |
|
211 | + public function display_left() { |
|
212 | + $graphs = wpinv_get_report_graphs(); |
|
213 | 213 | |
214 | - ?> |
|
214 | + ?> |
|
215 | 215 | |
216 | 216 | <?php foreach ( $graphs as $key => $graph ) : ?> |
217 | 217 | <div class="row mb-4"> |
@@ -230,35 +230,35 @@ discard block |
||
230 | 230 | |
231 | 231 | <?php |
232 | 232 | |
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Retrieves the download url. |
|
237 | - * |
|
238 | - */ |
|
239 | - public function get_download_url( $graph, $file_type ) { |
|
240 | - |
|
241 | - return wp_nonce_url( |
|
242 | - add_query_arg( |
|
243 | - array( |
|
244 | - 'getpaid-admin-action' => 'download_graph', |
|
245 | - 'file_type' => urlencode( $file_type ), |
|
246 | - 'graph' => urlencode( $graph ), |
|
247 | - ) |
|
248 | - ), |
|
249 | - 'getpaid-nonce', |
|
250 | - 'getpaid-nonce' |
|
251 | - ); |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Retrieves the download url. |
|
237 | + * |
|
238 | + */ |
|
239 | + public function get_download_url( $graph, $file_type ) { |
|
240 | + |
|
241 | + return wp_nonce_url( |
|
242 | + add_query_arg( |
|
243 | + array( |
|
244 | + 'getpaid-admin-action' => 'download_graph', |
|
245 | + 'file_type' => urlencode( $file_type ), |
|
246 | + 'graph' => urlencode( $graph ), |
|
247 | + ) |
|
248 | + ), |
|
249 | + 'getpaid-nonce', |
|
250 | + 'getpaid-nonce' |
|
251 | + ); |
|
252 | 252 | |
253 | - } |
|
253 | + } |
|
254 | 254 | |
255 | - /** |
|
256 | - * Displays the right side. |
|
257 | - * |
|
258 | - */ |
|
259 | - public function display_right() { |
|
255 | + /** |
|
256 | + * Displays the right side. |
|
257 | + * |
|
258 | + */ |
|
259 | + public function display_right() { |
|
260 | 260 | |
261 | - ?> |
|
261 | + ?> |
|
262 | 262 | |
263 | 263 | <?php foreach ( $this->views as $key => $view ) : ?> |
264 | 264 | <div class="row mb-4"> |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | </div> |
288 | 288 | <div class="card-body"> |
289 | 289 | <?php |
290 | - $class = $view['class']; |
|
291 | - $class = new $class(); |
|
292 | - $class->display_stats(); |
|
293 | - ?> |
|
290 | + $class = $view['class']; |
|
291 | + $class = new $class(); |
|
292 | + $class->display_stats(); |
|
293 | + ?> |
|
294 | 294 | </div> |
295 | 295 | </div> |
296 | 296 | </div> |
@@ -299,67 +299,67 @@ discard block |
||
299 | 299 | |
300 | 300 | <?php |
301 | 301 | |
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Returns a list of report cards. |
|
306 | - * |
|
307 | - */ |
|
308 | - public function get_cards() { |
|
309 | - |
|
310 | - $cards = array( |
|
311 | - 'total_sales' => array( |
|
312 | - 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
313 | - 'label' => __( 'Gross Revenue', 'invoicing' ), |
|
314 | - ), |
|
315 | - 'net_sales' => array( |
|
316 | - 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
317 | - 'label' => __( 'Net Revenue', 'invoicing' ), |
|
318 | - ), |
|
319 | - 'average_sales' => array( |
|
320 | - 'description' => __( 'Average net daily/monthly sales.', 'invoicing' ), |
|
321 | - 'label' => __( 'Avg. Net Sales', 'invoicing' ), |
|
322 | - ), |
|
323 | - 'average_total_sales' => array( |
|
324 | - 'description' => __( 'Average gross daily/monthly sales.', 'invoicing' ), |
|
325 | - 'label' => __( 'Avg. Gross Sales', 'invoicing' ), |
|
326 | - ), |
|
327 | - 'total_invoices' => array( |
|
328 | - 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
329 | - 'label' => __( 'Paid Invoices', 'invoicing' ), |
|
330 | - ), |
|
331 | - 'total_items' => array( |
|
332 | - 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
333 | - 'label' => __( 'Purchased Items', 'invoicing' ), |
|
334 | - ), |
|
335 | - 'refunded_items' => array( |
|
336 | - 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
337 | - 'label' => __( 'Refunded Items', 'invoicing' ), |
|
338 | - ), |
|
339 | - 'total_tax' => array( |
|
340 | - 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
341 | - 'label' => __( 'Tax', 'invoicing' ), |
|
342 | - ), |
|
343 | - 'total_refunded_tax' => array( |
|
344 | - 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
345 | - 'label' => __( 'Refunded Tax', 'invoicing' ), |
|
346 | - ), |
|
347 | - 'total_fees' => array( |
|
348 | - 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
349 | - 'label' => __( 'Fees', 'invoicing' ), |
|
350 | - ), |
|
351 | - 'total_refunds' => array( |
|
352 | - 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
353 | - 'label' => __( 'Refunded', 'invoicing' ), |
|
354 | - ), |
|
355 | - 'total_discount' => array( |
|
356 | - 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
357 | - 'label' => __( 'Discounted', 'invoicing' ), |
|
358 | - ), |
|
359 | - ); |
|
360 | - |
|
361 | - return apply_filters( 'wpinv_report_cards', $cards ); |
|
362 | - } |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * Returns a list of report cards. |
|
306 | + * |
|
307 | + */ |
|
308 | + public function get_cards() { |
|
309 | + |
|
310 | + $cards = array( |
|
311 | + 'total_sales' => array( |
|
312 | + 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
313 | + 'label' => __( 'Gross Revenue', 'invoicing' ), |
|
314 | + ), |
|
315 | + 'net_sales' => array( |
|
316 | + 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
317 | + 'label' => __( 'Net Revenue', 'invoicing' ), |
|
318 | + ), |
|
319 | + 'average_sales' => array( |
|
320 | + 'description' => __( 'Average net daily/monthly sales.', 'invoicing' ), |
|
321 | + 'label' => __( 'Avg. Net Sales', 'invoicing' ), |
|
322 | + ), |
|
323 | + 'average_total_sales' => array( |
|
324 | + 'description' => __( 'Average gross daily/monthly sales.', 'invoicing' ), |
|
325 | + 'label' => __( 'Avg. Gross Sales', 'invoicing' ), |
|
326 | + ), |
|
327 | + 'total_invoices' => array( |
|
328 | + 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
329 | + 'label' => __( 'Paid Invoices', 'invoicing' ), |
|
330 | + ), |
|
331 | + 'total_items' => array( |
|
332 | + 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
333 | + 'label' => __( 'Purchased Items', 'invoicing' ), |
|
334 | + ), |
|
335 | + 'refunded_items' => array( |
|
336 | + 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
337 | + 'label' => __( 'Refunded Items', 'invoicing' ), |
|
338 | + ), |
|
339 | + 'total_tax' => array( |
|
340 | + 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
341 | + 'label' => __( 'Tax', 'invoicing' ), |
|
342 | + ), |
|
343 | + 'total_refunded_tax' => array( |
|
344 | + 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
345 | + 'label' => __( 'Refunded Tax', 'invoicing' ), |
|
346 | + ), |
|
347 | + 'total_fees' => array( |
|
348 | + 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
349 | + 'label' => __( 'Fees', 'invoicing' ), |
|
350 | + ), |
|
351 | + 'total_refunds' => array( |
|
352 | + 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
353 | + 'label' => __( 'Refunded', 'invoicing' ), |
|
354 | + ), |
|
355 | + 'total_discount' => array( |
|
356 | + 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
357 | + 'label' => __( 'Discounted', 'invoicing' ), |
|
358 | + ), |
|
359 | + ); |
|
360 | + |
|
361 | + return apply_filters( 'wpinv_report_cards', $cards ); |
|
362 | + } |
|
363 | 363 | |
364 | 364 | |
365 | 365 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports_Report Class. |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | |
26 | - $this->views = array( |
|
26 | + $this->views = array( |
|
27 | 27 | |
28 | 28 | 'items' => array( |
29 | - 'label' => __( 'Items', 'invoicing' ), |
|
29 | + 'label' => __('Items', 'invoicing'), |
|
30 | 30 | 'class' => 'GetPaid_Reports_Report_Items', |
31 | 31 | ), |
32 | 32 | |
33 | 33 | 'gateways' => array( |
34 | - 'label' => __( 'Payment Methods', 'invoicing' ), |
|
34 | + 'label' => __('Payment Methods', 'invoicing'), |
|
35 | 35 | 'class' => 'GetPaid_Reports_Report_Gateways', |
36 | 36 | ), |
37 | 37 | |
38 | 38 | 'discounts' => array( |
39 | - 'label' => __( 'Discount Codes', 'invoicing' ), |
|
39 | + 'label' => __('Discount Codes', 'invoicing'), |
|
40 | 40 | 'class' => 'GetPaid_Reports_Report_Discounts', |
41 | 41 | ), |
42 | 42 | |
43 | 43 | ); |
44 | 44 | |
45 | - $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
45 | + $this->views = apply_filters('wpinv_report_views', $this->views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | public function get_range() { |
54 | 54 | $valid_ranges = $this->get_periods(); |
55 | 55 | |
56 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
57 | - return sanitize_key( $_GET['date_range'] ); |
|
56 | + if (isset($_GET['date_range']) && array_key_exists($_GET['date_range'], $valid_ranges)) { |
|
57 | + return sanitize_key($_GET['date_range']); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return '7_days'; |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | public function get_periods() { |
69 | 69 | |
70 | 70 | $periods = array( |
71 | - 'today' => __( 'Today', 'invoicing' ), |
|
72 | - 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
73 | - 'week' => __( 'This week', 'invoicing' ), |
|
74 | - 'last_week' => __( 'Last week', 'invoicing' ), |
|
75 | - '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
76 | - 'month' => __( 'This month', 'invoicing' ), |
|
77 | - 'last_month' => __( 'Last month', 'invoicing' ), |
|
78 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
79 | - 'quarter' => __( 'This Quarter', 'invoicing' ), |
|
80 | - 'last_quarter' => __( 'Last Quarter', 'invoicing' ), |
|
81 | - 'year' => __( 'This year', 'invoicing' ), |
|
82 | - 'last_year' => __( 'Last Year', 'invoicing' ), |
|
83 | - 'custom' => __( 'Custom Date Range', 'invoicing' ), |
|
71 | + 'today' => __('Today', 'invoicing'), |
|
72 | + 'yesterday' => __('Yesterday', 'invoicing'), |
|
73 | + 'week' => __('This week', 'invoicing'), |
|
74 | + 'last_week' => __('Last week', 'invoicing'), |
|
75 | + '7_days' => __('Last 7 days', 'invoicing'), |
|
76 | + 'month' => __('This month', 'invoicing'), |
|
77 | + 'last_month' => __('Last month', 'invoicing'), |
|
78 | + '30_days' => __('Last 30 days', 'invoicing'), |
|
79 | + 'quarter' => __('This Quarter', 'invoicing'), |
|
80 | + 'last_quarter' => __('Last Quarter', 'invoicing'), |
|
81 | + 'year' => __('This year', 'invoicing'), |
|
82 | + 'last_year' => __('Last Year', 'invoicing'), |
|
83 | + 'custom' => __('Custom Date Range', 'invoicing'), |
|
84 | 84 | ); |
85 | 85 | |
86 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
86 | + return apply_filters('getpaid_earning_periods', $periods); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -96,21 +96,21 @@ discard block |
||
96 | 96 | ?> |
97 | 97 | |
98 | 98 | <form method="get" class="getpaid-filter-earnings float-right"> |
99 | - <?php getpaid_hidden_field( 'page', isset( $_GET['page'] ) ? wpinv_clean( $_GET['page'] ) : 'wpinv-reports' ); ?> |
|
100 | - <?php getpaid_hidden_field( 'tab', 'reports' ); ?> |
|
99 | + <?php getpaid_hidden_field('page', isset($_GET['page']) ? wpinv_clean($_GET['page']) : 'wpinv-reports'); ?> |
|
100 | + <?php getpaid_hidden_field('tab', 'reports'); ?> |
|
101 | 101 | <select name='date_range'> |
102 | - <?php foreach( $this->get_periods() as $key => $label ) :?> |
|
103 | - <option value="<?php echo sanitize_key( $key ); ?>" <?php selected( $key, $range ); ?>><?php echo sanitize_text_field( $label ); ?></option> |
|
104 | - <?php endforeach;?> |
|
102 | + <?php foreach ($this->get_periods() as $key => $label) :?> |
|
103 | + <option value="<?php echo sanitize_key($key); ?>" <?php selected($key, $range); ?>><?php echo sanitize_text_field($label); ?></option> |
|
104 | + <?php endforeach; ?> |
|
105 | 105 | </select> |
106 | 106 | <span class="getpaid-date-range-picker <?php echo 'custom' == $range ? '' : 'd-none'; ?>"> |
107 | 107 | <input type="text" name="from" class="getpaid-from align-middle" /> |
108 | - <?php _e( 'to', 'invoicing' ); ?> |
|
108 | + <?php _e('to', 'invoicing'); ?> |
|
109 | 109 | <input type="text" name="to" class="getpaid-to align-middle" /> |
110 | 110 | </span> |
111 | 111 | <button type="submit" class="button button-primary"> |
112 | 112 | <i class="fa fa-chevron-right fa-lg"></i> |
113 | - <span class="screen-reader-text"><?php _e( 'View Reports', 'invoicing' ); ?></span> |
|
113 | + <span class="screen-reader-text"><?php _e('View Reports', 'invoicing'); ?></span> |
|
114 | 114 | </button> |
115 | 115 | </form> |
116 | 116 | |
@@ -159,17 +159,17 @@ discard block |
||
159 | 159 | |
160 | 160 | <div class="col-12 col-md-4"> |
161 | 161 | <div class="row getpaid-report-cards"> |
162 | - <?php foreach( $this->get_cards() as $key => $card ) : ?> |
|
162 | + <?php foreach ($this->get_cards() as $key => $card) : ?> |
|
163 | 163 | <div class="col-12 mb-4"> |
164 | 164 | |
165 | - <!-- <?php echo sanitize_text_field( $card['label'] ); ?> Card --> |
|
166 | - <div class="card p-0 m-0 shadow-none <?php echo sanitize_html_class( $key ); ?>"> |
|
165 | + <!-- <?php echo sanitize_text_field($card['label']); ?> Card --> |
|
166 | + <div class="card p-0 m-0 shadow-none <?php echo sanitize_html_class($key); ?>"> |
|
167 | 167 | |
168 | 168 | <div class="card-body"> |
169 | 169 | |
170 | 170 | <p class="getpaid-current text-uppercase small mb-2"> |
171 | - <strong><?php echo sanitize_text_field( $card['label'] ); ?></strong> |
|
172 | - <span title="<?php echo esc_attr( $card['description'] ); ?>" class="wpi-help-tip dashicons dashicons-editor-help text-muted" style="margin-top: -2px;"></span> |
|
171 | + <strong><?php echo sanitize_text_field($card['label']); ?></strong> |
|
172 | + <span title="<?php echo esc_attr($card['description']); ?>" class="wpi-help-tip dashicons dashicons-editor-help text-muted" style="margin-top: -2px;"></span> |
|
173 | 173 | </p> |
174 | 174 | <h5 class="font-weight-bold mb-0"> |
175 | 175 | <span class="getpaid-report-card-value"> |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | <hr> |
182 | 182 | |
183 | - <p class="getpaid-previous text-uppercase text-muted small mb-2"><strong><?php _e( 'Previous Period', 'invoicing' ); ?></strong></p> |
|
183 | + <p class="getpaid-previous text-uppercase text-muted small mb-2"><strong><?php _e('Previous Period', 'invoicing'); ?></strong></p> |
|
184 | 184 | <h5 class="getpaid-report-card-previous-value font-weight-bold text-muted mb-0"> |
185 | 185 | <span class="spinner is-active float-none"></span> |
186 | 186 | </h5> |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | </div> |
189 | 189 | |
190 | 190 | </div> |
191 | - <!-- <?php echo sanitize_text_field( $card['label'] ); ?> Card --> |
|
191 | + <!-- <?php echo sanitize_text_field($card['label']); ?> Card --> |
|
192 | 192 | |
193 | 193 | </div> |
194 | 194 | <?php endforeach; ?> |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | |
214 | 214 | ?> |
215 | 215 | |
216 | - <?php foreach ( $graphs as $key => $graph ) : ?> |
|
216 | + <?php foreach ($graphs as $key => $graph) : ?> |
|
217 | 217 | <div class="row mb-4"> |
218 | 218 | <div class="col-12"> |
219 | 219 | <div class="card m-0 p-0 single-report-card" style="max-width:100%"> |
220 | 220 | <div class="card-header"> |
221 | - <strong><?php echo wpinv_clean( $graph ); ?></strong> |
|
221 | + <strong><?php echo wpinv_clean($graph); ?></strong> |
|
222 | 222 | </div> |
223 | 223 | <div class="card-body"> |
224 | - <canvas id="getpaid-chartjs-<?php echo sanitize_key( $key ); ?>"></canvas> |
|
224 | + <canvas id="getpaid-chartjs-<?php echo sanitize_key($key); ?>"></canvas> |
|
225 | 225 | </div> |
226 | 226 | </div> |
227 | 227 | </div> |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | * Retrieves the download url. |
237 | 237 | * |
238 | 238 | */ |
239 | - public function get_download_url( $graph, $file_type ) { |
|
239 | + public function get_download_url($graph, $file_type) { |
|
240 | 240 | |
241 | 241 | return wp_nonce_url( |
242 | 242 | add_query_arg( |
243 | 243 | array( |
244 | 244 | 'getpaid-admin-action' => 'download_graph', |
245 | - 'file_type' => urlencode( $file_type ), |
|
246 | - 'graph' => urlencode( $graph ), |
|
245 | + 'file_type' => urlencode($file_type), |
|
246 | + 'graph' => urlencode($graph), |
|
247 | 247 | ) |
248 | 248 | ), |
249 | 249 | 'getpaid-nonce', |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | ?> |
262 | 262 | |
263 | - <?php foreach ( $this->views as $key => $view ) : ?> |
|
263 | + <?php foreach ($this->views as $key => $view) : ?> |
|
264 | 264 | <div class="row mb-4"> |
265 | 265 | <div class="col-12"> |
266 | 266 | <div class="card m-0 p-0" style="max-width:100%"> |
@@ -270,17 +270,17 @@ discard block |
||
270 | 270 | <strong><?php echo $view['label']; ?></strong> |
271 | 271 | </div> |
272 | 272 | <div class="col-3"> |
273 | - <a title="<?php esc_attr_e( 'Download JSON', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'json' ) ); ?>"> |
|
273 | + <a title="<?php esc_attr_e('Download JSON', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'json')); ?>"> |
|
274 | 274 | <i class="fa fa-download text-dark" style="font-size: 16px" aria-hidden="true"></i> |
275 | - <span class="screen-reader-text"><?php _e( 'Download JSON', 'invoicing' ); ?></span> |
|
275 | + <span class="screen-reader-text"><?php _e('Download JSON', 'invoicing'); ?></span> |
|
276 | 276 | </a> |
277 | - <a title="<?php esc_attr_e( 'Download CSV', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'csv' ) ); ?>"> |
|
277 | + <a title="<?php esc_attr_e('Download CSV', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'csv')); ?>"> |
|
278 | 278 | <i class="fa fa-file-csv text-dark" style="font-size: 16px" aria-hidden="true"></i> |
279 | - <span class="screen-reader-text"><?php _e( 'Download CSV', 'invoicing' ); ?></span> |
|
279 | + <span class="screen-reader-text"><?php _e('Download CSV', 'invoicing'); ?></span> |
|
280 | 280 | </a> |
281 | - <a title="<?php esc_attr_e( 'Download XML', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'xml' ) ); ?>"> |
|
281 | + <a title="<?php esc_attr_e('Download XML', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'xml')); ?>"> |
|
282 | 282 | <i class="fa fa-file-code text-dark" style="font-size: 16px" aria-hidden="true"></i> |
283 | - <span class="screen-reader-text"><?php _e( 'Download XML', 'invoicing' ); ?></span> |
|
283 | + <span class="screen-reader-text"><?php _e('Download XML', 'invoicing'); ?></span> |
|
284 | 284 | </a> |
285 | 285 | </div> |
286 | 286 | </div> |
@@ -309,56 +309,56 @@ discard block |
||
309 | 309 | |
310 | 310 | $cards = array( |
311 | 311 | 'total_sales' => array( |
312 | - 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
313 | - 'label' => __( 'Gross Revenue', 'invoicing' ), |
|
312 | + 'description' => __('Gross sales in the period.', 'invoicing'), |
|
313 | + 'label' => __('Gross Revenue', 'invoicing'), |
|
314 | 314 | ), |
315 | 315 | 'net_sales' => array( |
316 | - 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
317 | - 'label' => __( 'Net Revenue', 'invoicing' ), |
|
316 | + 'description' => __('Net sales in the period.', 'invoicing'), |
|
317 | + 'label' => __('Net Revenue', 'invoicing'), |
|
318 | 318 | ), |
319 | 319 | 'average_sales' => array( |
320 | - 'description' => __( 'Average net daily/monthly sales.', 'invoicing' ), |
|
321 | - 'label' => __( 'Avg. Net Sales', 'invoicing' ), |
|
320 | + 'description' => __('Average net daily/monthly sales.', 'invoicing'), |
|
321 | + 'label' => __('Avg. Net Sales', 'invoicing'), |
|
322 | 322 | ), |
323 | 323 | 'average_total_sales' => array( |
324 | - 'description' => __( 'Average gross daily/monthly sales.', 'invoicing' ), |
|
325 | - 'label' => __( 'Avg. Gross Sales', 'invoicing' ), |
|
324 | + 'description' => __('Average gross daily/monthly sales.', 'invoicing'), |
|
325 | + 'label' => __('Avg. Gross Sales', 'invoicing'), |
|
326 | 326 | ), |
327 | 327 | 'total_invoices' => array( |
328 | - 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
329 | - 'label' => __( 'Paid Invoices', 'invoicing' ), |
|
328 | + 'description' => __('Number of paid invoices.', 'invoicing'), |
|
329 | + 'label' => __('Paid Invoices', 'invoicing'), |
|
330 | 330 | ), |
331 | 331 | 'total_items' => array( |
332 | - 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
333 | - 'label' => __( 'Purchased Items', 'invoicing' ), |
|
332 | + 'description' => __('Number of items purchased.', 'invoicing'), |
|
333 | + 'label' => __('Purchased Items', 'invoicing'), |
|
334 | 334 | ), |
335 | 335 | 'refunded_items' => array( |
336 | - 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
337 | - 'label' => __( 'Refunded Items', 'invoicing' ), |
|
336 | + 'description' => __('Number of items refunded.', 'invoicing'), |
|
337 | + 'label' => __('Refunded Items', 'invoicing'), |
|
338 | 338 | ), |
339 | 339 | 'total_tax' => array( |
340 | - 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
341 | - 'label' => __( 'Tax', 'invoicing' ), |
|
340 | + 'description' => __('Total charged for taxes.', 'invoicing'), |
|
341 | + 'label' => __('Tax', 'invoicing'), |
|
342 | 342 | ), |
343 | 343 | 'total_refunded_tax' => array( |
344 | - 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
345 | - 'label' => __( 'Refunded Tax', 'invoicing' ), |
|
344 | + 'description' => __('Total refunded for taxes.', 'invoicing'), |
|
345 | + 'label' => __('Refunded Tax', 'invoicing'), |
|
346 | 346 | ), |
347 | 347 | 'total_fees' => array( |
348 | - 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
349 | - 'label' => __( 'Fees', 'invoicing' ), |
|
348 | + 'description' => __('Total fees charged.', 'invoicing'), |
|
349 | + 'label' => __('Fees', 'invoicing'), |
|
350 | 350 | ), |
351 | 351 | 'total_refunds' => array( |
352 | - 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
353 | - 'label' => __( 'Refunded', 'invoicing' ), |
|
352 | + 'description' => __('Total of refunded invoices.', 'invoicing'), |
|
353 | + 'label' => __('Refunded', 'invoicing'), |
|
354 | 354 | ), |
355 | 355 | 'total_discount' => array( |
356 | - 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
357 | - 'label' => __( 'Discounted', 'invoicing' ), |
|
356 | + 'description' => __('Total of discounts used.', 'invoicing'), |
|
357 | + 'label' => __('Discounted', 'invoicing'), |
|
358 | 358 | ), |
359 | 359 | ); |
360 | 360 | |
361 | - return apply_filters( 'wpinv_report_cards', $cards ); |
|
361 | + return apply_filters('wpinv_report_cards', $cards); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 |