@@ -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. |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct() { |
41 | 41 | |
42 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
42 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
43 | + $this->admin_url = plugins_url('/', __FILE__); |
|
44 | 44 | $this->reports = new GetPaid_Reports(); |
45 | 45 | |
46 | - if ( is_admin() ) { |
|
46 | + if (is_admin()) { |
|
47 | 47 | $this->init_admin_hooks(); |
48 | 48 | } |
49 | 49 | |
@@ -54,33 +54,33 @@ discard block |
||
54 | 54 | * |
55 | 55 | */ |
56 | 56 | private function init_admin_hooks() { |
57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 ); |
|
58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
60 | - add_action( 'admin_init', array( $this, 'activation_redirect' ) ); |
|
61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) ); |
|
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
67 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
71 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
75 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
76 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
77 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9); |
|
58 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
59 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
60 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
61 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
62 | + add_action('admin_notices', array($this, 'show_notices')); |
|
63 | + add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page')); |
|
64 | + add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form')); |
|
65 | + add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice')); |
|
66 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
67 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
68 | + add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates')); |
|
69 | + add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); |
|
70 | + add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); |
|
71 | + add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); |
|
72 | + add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers')); |
|
73 | + add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); |
|
74 | + add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin')); |
|
75 | + add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway')); |
|
76 | + add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
77 | + do_action('getpaid_init_admin_hooks', $this); |
|
78 | 78 | |
79 | 79 | // Setup/welcome |
80 | - if ( ! empty( $_GET['page'] ) ) { |
|
81 | - switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
80 | + if (!empty($_GET['page'])) { |
|
81 | + switch (sanitize_text_field($_GET['page'])) { |
|
82 | 82 | case 'gp-setup': |
83 | - include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
83 | + include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php'; |
|
84 | 84 | break; |
85 | 85 | } |
86 | 86 | } |
@@ -94,37 +94,37 @@ discard block |
||
94 | 94 | public function enqeue_scripts() { |
95 | 95 | global $current_screen, $pagenow; |
96 | 96 | |
97 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
97 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
98 | 98 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
99 | 99 | |
100 | - if ( ! empty( $current_screen->post_type ) ) { |
|
100 | + if (!empty($current_screen->post_type)) { |
|
101 | 101 | $page = $current_screen->post_type; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // General styles. |
105 | - if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) { |
|
105 | + if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) { |
|
106 | 106 | |
107 | 107 | // Styles. |
108 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
109 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
110 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
108 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
109 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
110 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
111 | 111 | |
112 | 112 | // Scripts. |
113 | - wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
113 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
114 | 114 | |
115 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
116 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version ); |
|
117 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
115 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
116 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); |
|
117 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Payment form scripts. |
122 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
122 | + if ('wpi_payment_form' == $page && $editing) { |
|
123 | 123 | $this->load_payment_form_scripts(); |
124 | 124 | } |
125 | 125 | |
126 | - if ( $page == 'wpinv-subscriptions' ) { |
|
127 | - wp_enqueue_script( 'postbox' ); |
|
126 | + if ($page == 'wpinv-subscriptions') { |
|
127 | + wp_enqueue_script('postbox'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | } |
@@ -137,31 +137,31 @@ discard block |
||
137 | 137 | global $post; |
138 | 138 | |
139 | 139 | $date_range = array( |
140 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
140 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days', |
|
141 | 141 | ); |
142 | 142 | |
143 | - if ( $date_range['period'] == 'custom' ) { |
|
143 | + if ($date_range['period'] == 'custom') { |
|
144 | 144 | |
145 | - if ( isset( $_GET['from'] ) ) { |
|
146 | - $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
145 | + if (isset($_GET['from'])) { |
|
146 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
147 | 147 | } |
148 | 148 | |
149 | - if ( isset( $_GET['to'] ) ) { |
|
150 | - $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
149 | + if (isset($_GET['to'])) { |
|
150 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | 154 | $i18n = array( |
155 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
156 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
157 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
158 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
159 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
155 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
156 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
157 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
158 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
159 | + 'rest_root' => esc_url_raw(rest_url()), |
|
160 | 160 | 'date_range' => $date_range, |
161 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
162 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
163 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
164 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
161 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
162 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
163 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
164 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
165 | 165 | 'tax' => wpinv_tax_amount(), |
166 | 166 | 'discount' => 0, |
167 | 167 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -170,39 +170,39 @@ discard block |
||
170 | 170 | 'thousand_sep' => wpinv_thousands_separator(), |
171 | 171 | 'decimal_sep' => wpinv_decimal_separator(), |
172 | 172 | 'decimals' => wpinv_decimals(), |
173 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
174 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
175 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
176 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
177 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
178 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
179 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
180 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
181 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
182 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
183 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
184 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
185 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
186 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
187 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
188 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
189 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
190 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
191 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
192 | - 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
173 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
174 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
175 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
176 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
177 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
178 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
179 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
180 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
181 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
182 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
183 | + 'action_edit' => __('Edit', 'invoicing'), |
|
184 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
185 | + 'item_description' => __('Item Description', 'invoicing'), |
|
186 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
187 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
188 | + 'searching' => __('Searching', 'invoicing'), |
|
189 | + 'loading' => __('Loading...', 'invoicing'), |
|
190 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
191 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
192 | + 'graphs' => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())), |
|
193 | 193 | ); |
194 | 194 | |
195 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
195 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
196 | 196 | |
197 | - $invoice = new WPInv_Invoice( $post ); |
|
197 | + $invoice = new WPInv_Invoice($post); |
|
198 | 198 | $i18n['save_invoice'] = sprintf( |
199 | - __( 'Save %s', 'invoicing' ), |
|
200 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
199 | + __('Save %s', 'invoicing'), |
|
200 | + ucfirst($invoice->get_invoice_quote_type()) |
|
201 | 201 | ); |
202 | 202 | |
203 | 203 | $i18n['invoice_description'] = sprintf( |
204 | - __( '%s Description', 'invoicing' ), |
|
205 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
204 | + __('%s Description', 'invoicing'), |
|
205 | + ucfirst($invoice->get_invoice_quote_type()) |
|
206 | 206 | ); |
207 | 207 | |
208 | 208 | } |
@@ -216,24 +216,24 @@ discard block |
||
216 | 216 | * @param string $footer_text |
217 | 217 | * @return string |
218 | 218 | */ |
219 | - public function admin_footer_text( $footer_text ) { |
|
219 | + public function admin_footer_text($footer_text) { |
|
220 | 220 | global $current_screen; |
221 | 221 | |
222 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
222 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
223 | 223 | |
224 | - if ( ! empty( $current_screen->post_type ) ) { |
|
224 | + if (!empty($current_screen->post_type)) { |
|
225 | 225 | $page = $current_screen->post_type; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // General styles. |
229 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
229 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
230 | 230 | |
231 | 231 | // Change the footer text |
232 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
232 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
233 | 233 | |
234 | - $rating_url = esc_url( |
|
234 | + $rating_url = esc_url( |
|
235 | 235 | wp_nonce_url( |
236 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
236 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
237 | 237 | 'getpaid-nonce', |
238 | 238 | 'getpaid-nonce' |
239 | 239 | ) |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | $footer_text = sprintf( |
243 | 243 | /* translators: %s: five stars */ |
244 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
244 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
245 | 245 | "<a href='$rating_url'>★★★★★</a>" |
246 | 246 | ); |
247 | 247 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | $footer_text = sprintf( |
251 | 251 | /* translators: %s: GetPaid */ |
252 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
252 | + __('Thank you for using %s!', 'invoicing'), |
|
253 | 253 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
254 | 254 | ); |
255 | 255 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * @since 2.0.0 |
266 | 266 | */ |
267 | 267 | public function redirect_to_wordpress_rating_page() { |
268 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
269 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
268 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
269 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
270 | 270 | exit; |
271 | 271 | } |
272 | 272 | |
@@ -277,30 +277,30 @@ discard block |
||
277 | 277 | protected function load_payment_form_scripts() { |
278 | 278 | global $post; |
279 | 279 | |
280 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
|
281 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
282 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
280 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION); |
|
281 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
282 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
283 | 283 | |
284 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
285 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version ); |
|
284 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
285 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version); |
|
286 | 286 | |
287 | 287 | wp_localize_script( |
288 | 288 | 'wpinv-admin-payment-form-script', |
289 | 289 | 'wpinvPaymentFormAdmin', |
290 | 290 | array( |
291 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
292 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
291 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
292 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
293 | 293 | 'currency' => wpinv_currency_symbol(), |
294 | 294 | 'position' => wpinv_currency_position(), |
295 | 295 | 'decimals' => (int) wpinv_decimals(), |
296 | 296 | 'thousands_sep' => wpinv_thousands_separator(), |
297 | 297 | 'decimals_sep' => wpinv_decimal_separator(), |
298 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
298 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
299 | 299 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
300 | 300 | ) |
301 | 301 | ); |
302 | 302 | |
303 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
303 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | |
@@ -311,24 +311,24 @@ discard block |
||
311 | 311 | * @return string |
312 | 312 | * |
313 | 313 | */ |
314 | - public function admin_body_class( $classes ) { |
|
314 | + public function admin_body_class($classes) { |
|
315 | 315 | global $pagenow, $post, $current_screen; |
316 | 316 | |
317 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
317 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
318 | 318 | |
319 | - if ( ! empty( $current_screen->post_type ) ) { |
|
319 | + if (!empty($current_screen->post_type)) { |
|
320 | 320 | $page = $current_screen->post_type; |
321 | 321 | } |
322 | 322 | |
323 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
324 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
323 | + if (false !== stripos($page, 'wpi')) { |
|
324 | + $classes .= ' wpi-' . sanitize_key($page); |
|
325 | 325 | } |
326 | 326 | |
327 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
327 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
328 | 328 | $classes .= ' wpinv-cpt wpinv'; |
329 | 329 | } |
330 | 330 | |
331 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
331 | + if (getpaid_is_invoice_post_type($page)) { |
|
332 | 332 | $classes .= ' getpaid-is-invoice-cpt'; |
333 | 333 | } |
334 | 334 | |
@@ -347,21 +347,21 @@ discard block |
||
347 | 347 | 'version' => WPINV_VERSION, |
348 | 348 | 'support_url' => 'https://wpgetpaid.com/support/', |
349 | 349 | 'documentation_url' => 'https://docs.wpgetpaid.com/', |
350 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
350 | + 'activated' => (int) get_option('gepaid_installed_on'), |
|
351 | 351 | ) |
352 | 352 | ); |
353 | 353 | |
354 | 354 | new AyeCode_Connect_Helper( |
355 | 355 | array( |
356 | - 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
357 | - 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
358 | - 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
359 | - 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
360 | - 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
361 | - 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
362 | - 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
356 | + 'connect_title' => __('WP Invoicing - an AyeCode product!', 'invoicing'), |
|
357 | + 'connect_external' => __('Please confirm you wish to connect your site?', 'invoicing'), |
|
358 | + 'connect' => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'), |
|
359 | + 'connect_button' => __('Connect Site', 'invoicing'), |
|
360 | + 'connecting_button' => __('Connecting...', 'invoicing'), |
|
361 | + 'error_localhost' => __('This service will only work with a live domain, not a localhost.', 'invoicing'), |
|
362 | + 'error' => __('Something went wrong, please refresh and try again.', 'invoicing'), |
|
363 | 363 | ), |
364 | - array( 'wpi-addons' ) |
|
364 | + array('wpi-addons') |
|
365 | 365 | ); |
366 | 366 | |
367 | 367 | } |
@@ -373,20 +373,20 @@ discard block |
||
373 | 373 | */ |
374 | 374 | public function activation_redirect() { |
375 | 375 | |
376 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
376 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
377 | 377 | |
378 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
378 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Bail if activating from network, or bulk |
383 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
383 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
384 | 384 | return; |
385 | 385 | } |
386 | 386 | |
387 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
387 | + update_option('wpinv_redirected_to_settings', 1); |
|
388 | 388 | |
389 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
|
389 | + wp_safe_redirect(admin_url('index.php?page=gp-setup')); |
|
390 | 390 | exit; |
391 | 391 | |
392 | 392 | } |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function maybe_do_admin_action() { |
398 | 398 | |
399 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
400 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
401 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
399 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
400 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
401 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | } |
@@ -408,24 +408,24 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param array $args |
410 | 410 | */ |
411 | - public function duplicate_invoice( $args ) { |
|
411 | + public function duplicate_invoice($args) { |
|
412 | 412 | |
413 | - if ( empty( $args['invoice_id'] ) ) { |
|
413 | + if (empty($args['invoice_id'])) { |
|
414 | 414 | return; |
415 | 415 | } |
416 | 416 | |
417 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
417 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
418 | 418 | |
419 | - if ( ! $invoice->exists() ) { |
|
419 | + if (!$invoice->exists()) { |
|
420 | 420 | return; |
421 | 421 | } |
422 | 422 | |
423 | - $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
423 | + $new_invoice = getpaid_duplicate_invoice($invoice); |
|
424 | 424 | $new_invoice->save(); |
425 | 425 | |
426 | - if ( $new_invoice->exists() ) { |
|
426 | + if ($new_invoice->exists()) { |
|
427 | 427 | |
428 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) ); |
|
428 | + getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box')); |
|
429 | 429 | |
430 | 430 | wp_safe_redirect( |
431 | 431 | add_query_arg( |
@@ -433,14 +433,14 @@ discard block |
||
433 | 433 | 'action' => 'edit', |
434 | 434 | 'post' => $new_invoice->get_id(), |
435 | 435 | ), |
436 | - admin_url( 'post.php' ) |
|
436 | + admin_url('post.php') |
|
437 | 437 | ) |
438 | 438 | ); |
439 | 439 | exit; |
440 | 440 | |
441 | 441 | } |
442 | 442 | |
443 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) ); |
|
443 | + getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box')); |
|
444 | 444 | |
445 | 445 | } |
446 | 446 | |
@@ -449,34 +449,34 @@ discard block |
||
449 | 449 | * |
450 | 450 | * @param array $args |
451 | 451 | */ |
452 | - public function duplicate_payment_form( $args ) { |
|
452 | + public function duplicate_payment_form($args) { |
|
453 | 453 | |
454 | - if ( empty( $args['form_id'] ) ) { |
|
454 | + if (empty($args['form_id'])) { |
|
455 | 455 | return; |
456 | 456 | } |
457 | 457 | |
458 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
458 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
459 | 459 | |
460 | - if ( ! $form->exists() ) { |
|
460 | + if (!$form->exists()) { |
|
461 | 461 | return; |
462 | 462 | } |
463 | 463 | |
464 | 464 | $new_form = new GetPaid_Payment_Form(); |
465 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
466 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
467 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
468 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
465 | + $new_form->set_author($form->get_author('edit')); |
|
466 | + $new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing')); |
|
467 | + $new_form->set_elements($form->get_elements('edit')); |
|
468 | + $new_form->set_items($form->get_items('edit')); |
|
469 | 469 | $new_form->save(); |
470 | 470 | |
471 | - if ( $new_form->exists() ) { |
|
472 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
473 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
471 | + if ($new_form->exists()) { |
|
472 | + $this->show_success(__('Form duplicated successfully', 'invoicing')); |
|
473 | + $url = get_edit_post_link($new_form->get_id(), 'edit'); |
|
474 | 474 | } else { |
475 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
476 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
475 | + $this->show_error(__('Unable to duplicate form', 'invoicing')); |
|
476 | + $url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')); |
|
477 | 477 | } |
478 | 478 | |
479 | - wp_redirect( $url ); |
|
479 | + wp_redirect($url); |
|
480 | 480 | exit; |
481 | 481 | } |
482 | 482 | |
@@ -485,9 +485,9 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @param array $args |
487 | 487 | */ |
488 | - public function send_customer_invoice( $args ) { |
|
489 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
490 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
488 | + public function send_customer_invoice($args) { |
|
489 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); |
|
490 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
491 | 491 | exit; |
492 | 492 | } |
493 | 493 | |
@@ -496,16 +496,16 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @param array $args |
498 | 498 | */ |
499 | - public function send_customer_payment_reminder( $args ) { |
|
500 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
499 | + public function send_customer_payment_reminder($args) { |
|
500 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
501 | 501 | |
502 | - if ( $sent ) { |
|
503 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
502 | + if ($sent) { |
|
503 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
504 | 504 | } else { |
505 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
505 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
506 | 506 | } |
507 | 507 | |
508 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
508 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
509 | 509 | exit; |
510 | 510 | } |
511 | 511 | |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | */ |
516 | 516 | public function admin_reset_tax_rates() { |
517 | 517 | |
518 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
519 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
518 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
519 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
520 | 520 | exit; |
521 | 521 | |
522 | 522 | } |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | public function admin_create_missing_pages() { |
529 | 529 | $installer = new GetPaid_Installer(); |
530 | 530 | $installer->create_pages(); |
531 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
532 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
531 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
532 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
533 | 533 | exit; |
534 | 534 | } |
535 | 535 | |
@@ -541,35 +541,35 @@ discard block |
||
541 | 541 | global $wpdb; |
542 | 542 | $installer = new GetPaid_Installer(); |
543 | 543 | |
544 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { |
|
544 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') { |
|
545 | 545 | $installer->create_subscriptions_table(); |
546 | 546 | |
547 | - if ( $wpdb->last_error !== '' ) { |
|
548 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
547 | + if ($wpdb->last_error !== '') { |
|
548 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { |
|
552 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') { |
|
553 | 553 | $installer->create_invoices_table(); |
554 | 554 | |
555 | - if ( $wpdb->last_error !== '' ) { |
|
556 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
555 | + if ($wpdb->last_error !== '') { |
|
556 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
560 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { |
|
560 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') { |
|
561 | 561 | $installer->create_invoice_items_table(); |
562 | 562 | |
563 | - if ( $wpdb->last_error !== '' ) { |
|
564 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
563 | + if ($wpdb->last_error !== '') { |
|
564 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
568 | - if ( ! $this->has_notices() ) { |
|
569 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
568 | + if (!$this->has_notices()) { |
|
569 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
570 | 570 | } |
571 | 571 | |
572 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
572 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
573 | 573 | exit; |
574 | 574 | } |
575 | 575 | |
@@ -584,10 +584,10 @@ discard block |
||
584 | 584 | $installer->migrate_old_invoices(); |
585 | 585 | |
586 | 586 | // Show an admin message. |
587 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
587 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
588 | 588 | |
589 | 589 | // Redirect the admin. |
590 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
590 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
591 | 591 | exit; |
592 | 592 | |
593 | 593 | } |
@@ -599,18 +599,18 @@ discard block |
||
599 | 599 | public function admin_download_customers() { |
600 | 600 | global $wpdb; |
601 | 601 | |
602 | - $output = fopen( 'php://output', 'w' ) || die( esc_html__( 'Unsupported server', 'invoicing' ) ); |
|
602 | + $output = fopen('php://output', 'w') || die(esc_html__('Unsupported server', 'invoicing')); |
|
603 | 603 | |
604 | - header( 'Content-Type:text/csv' ); |
|
605 | - header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
604 | + header('Content-Type:text/csv'); |
|
605 | + header('Content-Disposition:attachment;filename=customers.csv'); |
|
606 | 606 | |
607 | 607 | $post_types = ''; |
608 | 608 | |
609 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
610 | - $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type ); |
|
609 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
610 | + $post_types .= $wpdb->prepare('post_type=%s OR ', $post_type); |
|
611 | 611 | } |
612 | 612 | |
613 | - $post_types = rtrim( $post_types, ' OR' ); |
|
613 | + $post_types = rtrim($post_types, ' OR'); |
|
614 | 614 | |
615 | 615 | $customers = $wpdb->get_col( |
616 | 616 | $wpdb->prepare( |
@@ -619,58 +619,58 @@ discard block |
||
619 | 619 | ); |
620 | 620 | |
621 | 621 | $columns = array( |
622 | - 'name' => __( 'Name', 'invoicing' ), |
|
623 | - 'email' => __( 'Email', 'invoicing' ), |
|
624 | - 'country' => __( 'Country', 'invoicing' ), |
|
625 | - 'state' => __( 'State', 'invoicing' ), |
|
626 | - 'city' => __( 'City', 'invoicing' ), |
|
627 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
628 | - 'address' => __( 'Address', 'invoicing' ), |
|
629 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
630 | - 'company' => __( 'Company', 'invoicing' ), |
|
631 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
632 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
633 | - 'total_raw' => __( 'Total Spend', 'invoicing' ), |
|
634 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
622 | + 'name' => __('Name', 'invoicing'), |
|
623 | + 'email' => __('Email', 'invoicing'), |
|
624 | + 'country' => __('Country', 'invoicing'), |
|
625 | + 'state' => __('State', 'invoicing'), |
|
626 | + 'city' => __('City', 'invoicing'), |
|
627 | + 'zip' => __('ZIP', 'invoicing'), |
|
628 | + 'address' => __('Address', 'invoicing'), |
|
629 | + 'phone' => __('Phone', 'invoicing'), |
|
630 | + 'company' => __('Company', 'invoicing'), |
|
631 | + 'company_id' => __('Company ID', 'invoicing'), |
|
632 | + 'invoices' => __('Invoices', 'invoicing'), |
|
633 | + 'total_raw' => __('Total Spend', 'invoicing'), |
|
634 | + 'signup' => __('Date created', 'invoicing'), |
|
635 | 635 | ); |
636 | 636 | |
637 | 637 | // Output the csv column headers. |
638 | - fputcsv( $output, array_values( $columns ) ); |
|
638 | + fputcsv($output, array_values($columns)); |
|
639 | 639 | |
640 | 640 | // Loop through |
641 | 641 | $table = new WPInv_Customers_Table(); |
642 | - foreach ( $customers as $customer_id ) { |
|
642 | + foreach ($customers as $customer_id) { |
|
643 | 643 | |
644 | - $user = get_user_by( 'id', $customer_id ); |
|
644 | + $user = get_user_by('id', $customer_id); |
|
645 | 645 | $row = array(); |
646 | - if ( empty( $user ) ) { |
|
646 | + if (empty($user)) { |
|
647 | 647 | continue; |
648 | 648 | } |
649 | 649 | |
650 | - foreach ( array_keys( $columns ) as $column ) { |
|
650 | + foreach (array_keys($columns) as $column) { |
|
651 | 651 | |
652 | 652 | $method = 'column_' . $column; |
653 | 653 | |
654 | - if ( 'name' == $column ) { |
|
655 | - $value = esc_html( $user->display_name ); |
|
656 | - } elseif ( 'email' == $column ) { |
|
657 | - $value = sanitize_email( $user->user_email ); |
|
658 | - } elseif ( is_callable( array( $table, $method ) ) ) { |
|
659 | - $value = strip_tags( $table->$method( $user ) ); |
|
654 | + if ('name' == $column) { |
|
655 | + $value = esc_html($user->display_name); |
|
656 | + } elseif ('email' == $column) { |
|
657 | + $value = sanitize_email($user->user_email); |
|
658 | + } elseif (is_callable(array($table, $method))) { |
|
659 | + $value = strip_tags($table->$method($user)); |
|
660 | 660 | } |
661 | 661 | |
662 | - if ( empty( $value ) ) { |
|
663 | - $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) ); |
|
662 | + if (empty($value)) { |
|
663 | + $value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true)); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | $row[] = $value; |
667 | 667 | |
668 | 668 | } |
669 | 669 | |
670 | - fputcsv( $output, $row ); |
|
670 | + fputcsv($output, $row); |
|
671 | 671 | } |
672 | 672 | |
673 | - fclose( $output ); |
|
673 | + fclose($output); |
|
674 | 674 | exit; |
675 | 675 | |
676 | 676 | } |
@@ -680,27 +680,27 @@ discard block |
||
680 | 680 | * |
681 | 681 | * @param array $data |
682 | 682 | */ |
683 | - public function admin_install_plugin( $data ) { |
|
683 | + public function admin_install_plugin($data) { |
|
684 | 684 | |
685 | - if ( ! empty( $data['plugins'] ) ) { |
|
685 | + if (!empty($data['plugins'])) { |
|
686 | 686 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
687 | 687 | wp_cache_flush(); |
688 | 688 | |
689 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
690 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
691 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
692 | - $installed = $upgrader->install( $plugin_zip ); |
|
689 | + foreach ($data['plugins'] as $slug => $file) { |
|
690 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); |
|
691 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
692 | + $installed = $upgrader->install($plugin_zip); |
|
693 | 693 | |
694 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
695 | - activate_plugin( $file, '', false, true ); |
|
694 | + if (!is_wp_error($installed) && $installed) { |
|
695 | + activate_plugin($file, '', false, true); |
|
696 | 696 | } else { |
697 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
697 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
702 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
703 | - wp_safe_redirect( $redirect ); |
|
702 | + $redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); |
|
703 | + wp_safe_redirect($redirect); |
|
704 | 704 | exit; |
705 | 705 | |
706 | 706 | } |
@@ -710,41 +710,41 @@ discard block |
||
710 | 710 | * |
711 | 711 | * @param array $data |
712 | 712 | */ |
713 | - public function admin_connect_gateway( $data ) { |
|
713 | + public function admin_connect_gateway($data) { |
|
714 | 714 | |
715 | - if ( ! empty( $data['plugin'] ) ) { |
|
715 | + if (!empty($data['plugin'])) { |
|
716 | 716 | |
717 | - $gateway = sanitize_key( $data['plugin'] ); |
|
718 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
717 | + $gateway = sanitize_key($data['plugin']); |
|
718 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
719 | 719 | |
720 | - if ( ! empty( $connect_url ) ) { |
|
721 | - wp_redirect( $connect_url ); |
|
720 | + if (!empty($connect_url)) { |
|
721 | + wp_redirect($connect_url); |
|
722 | 722 | exit; |
723 | 723 | } |
724 | 724 | |
725 | - if ( 'stripe' == $data['plugin'] ) { |
|
725 | + if ('stripe' == $data['plugin']) { |
|
726 | 726 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
727 | 727 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
728 | 728 | wp_cache_flush(); |
729 | 729 | |
730 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
731 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
732 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
733 | - $upgrader->install( $plugin_zip ); |
|
730 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
731 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
732 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
733 | + $upgrader->install($plugin_zip); |
|
734 | 734 | } |
735 | 735 | |
736 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
736 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
737 | 737 | } |
738 | 738 | |
739 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
740 | - if ( ! empty( $connect_url ) ) { |
|
741 | - wp_redirect( $connect_url ); |
|
739 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
740 | + if (!empty($connect_url)) { |
|
741 | + wp_redirect($connect_url); |
|
742 | 742 | exit; |
743 | 743 | } |
744 | 744 | } |
745 | 745 | |
746 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
747 | - wp_safe_redirect( $redirect ); |
|
746 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
747 | + wp_safe_redirect($redirect); |
|
748 | 748 | exit; |
749 | 749 | |
750 | 750 | } |
@@ -758,35 +758,35 @@ discard block |
||
758 | 758 | |
759 | 759 | // Fetch all invoices that have discount codes. |
760 | 760 | $table = $wpdb->prefix . 'getpaid_invoices'; |
761 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
761 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
762 | 762 | |
763 | - foreach ( $invoices as $invoice ) { |
|
763 | + foreach ($invoices as $invoice) { |
|
764 | 764 | |
765 | - $invoice = new WPInv_Invoice( $invoice ); |
|
765 | + $invoice = new WPInv_Invoice($invoice); |
|
766 | 766 | |
767 | - if ( ! $invoice->exists() ) { |
|
767 | + if (!$invoice->exists()) { |
|
768 | 768 | continue; |
769 | 769 | } |
770 | 770 | |
771 | 771 | // Abort if the discount does not exist or does not apply here. |
772 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
773 | - if ( ! $discount->exists() ) { |
|
772 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
773 | + if (!$discount->exists()) { |
|
774 | 774 | continue; |
775 | 775 | } |
776 | 776 | |
777 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
777 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
778 | 778 | $invoice->recalculate_total(); |
779 | 779 | |
780 | - if ( $invoice->get_total_discount() > 0 ) { |
|
780 | + if ($invoice->get_total_discount() > 0) { |
|
781 | 781 | $invoice->save(); |
782 | 782 | } |
783 | 783 | } |
784 | 784 | |
785 | 785 | // Show an admin message. |
786 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
786 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
787 | 787 | |
788 | 788 | // Redirect the admin. |
789 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
789 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
790 | 790 | exit; |
791 | 791 | |
792 | 792 | } |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | * @return array |
799 | 799 | */ |
800 | 800 | public function get_notices() { |
801 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
802 | - return is_array( $notices ) ? $notices : array(); |
|
801 | + $notices = get_option('wpinv_admin_notices'); |
|
802 | + return is_array($notices) ? $notices : array(); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | /** |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | * @return array |
810 | 810 | */ |
811 | 811 | public function has_notices() { |
812 | - return count( $this->get_notices() ) > 0; |
|
812 | + return count($this->get_notices()) > 0; |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | * @since 1.0.19 |
820 | 820 | */ |
821 | 821 | public function clear_notices() { |
822 | - delete_option( 'wpinv_admin_notices' ); |
|
822 | + delete_option('wpinv_admin_notices'); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
@@ -828,16 +828,16 @@ discard block |
||
828 | 828 | * @access public |
829 | 829 | * @since 1.0.19 |
830 | 830 | */ |
831 | - public function save_notice( $type, $message ) { |
|
831 | + public function save_notice($type, $message) { |
|
832 | 832 | $notices = $this->get_notices(); |
833 | 833 | |
834 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
835 | - $notices[ $type ] = array(); |
|
834 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
835 | + $notices[$type] = array(); |
|
836 | 836 | } |
837 | 837 | |
838 | - $notices[ $type ][] = $message; |
|
838 | + $notices[$type][] = $message; |
|
839 | 839 | |
840 | - update_option( 'wpinv_admin_notices', $notices ); |
|
840 | + update_option('wpinv_admin_notices', $notices); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | /** |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | * @access public |
848 | 848 | * @since 1.0.19 |
849 | 849 | */ |
850 | - public function show_success( $msg ) { |
|
851 | - $this->save_notice( 'success', $msg ); |
|
850 | + public function show_success($msg) { |
|
851 | + $this->save_notice('success', $msg); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -858,8 +858,8 @@ discard block |
||
858 | 858 | * @param string $msg The message to qeue. |
859 | 859 | * @since 1.0.19 |
860 | 860 | */ |
861 | - public function show_error( $msg ) { |
|
862 | - $this->save_notice( 'error', $msg ); |
|
861 | + public function show_error($msg) { |
|
862 | + $this->save_notice('error', $msg); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /** |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | * @param string $msg The message to qeue. |
870 | 870 | * @since 1.0.19 |
871 | 871 | */ |
872 | - public function show_warning( $msg ) { |
|
873 | - $this->save_notice( 'warning', $msg ); |
|
872 | + public function show_warning($msg) { |
|
873 | + $this->save_notice('warning', $msg); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | /** |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @param string $msg The message to qeue. |
881 | 881 | * @since 1.0.19 |
882 | 882 | */ |
883 | - public function show_info( $msg ) { |
|
884 | - $this->save_notice( 'info', $msg ); |
|
883 | + public function show_info($msg) { |
|
884 | + $this->save_notice('info', $msg); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | /** |
@@ -895,29 +895,29 @@ discard block |
||
895 | 895 | $notices = $this->get_notices(); |
896 | 896 | $this->clear_notices(); |
897 | 897 | |
898 | - foreach ( $notices as $type => $messages ) { |
|
898 | + foreach ($notices as $type => $messages) { |
|
899 | 899 | |
900 | - if ( ! is_array( $messages ) ) { |
|
900 | + if (!is_array($messages)) { |
|
901 | 901 | continue; |
902 | 902 | } |
903 | 903 | |
904 | - $type = esc_attr( $type ); |
|
905 | - foreach ( $messages as $message ) { |
|
906 | - echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
904 | + $type = esc_attr($type); |
|
905 | + foreach ($messages as $message) { |
|
906 | + echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>"); |
|
907 | 907 | } |
908 | 908 | } |
909 | 909 | |
910 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
910 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
911 | 911 | |
912 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
913 | - $url = wp_nonce_url( |
|
914 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
912 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
913 | + $url = wp_nonce_url( |
|
914 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
915 | 915 | 'getpaid-nonce', |
916 | 916 | 'getpaid-nonce' |
917 | 917 | ); |
918 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
919 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
920 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
918 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
919 | + $message2 = __('Generate Pages', 'invoicing'); |
|
920 | + echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"); |
|
921 | 921 | break; |
922 | 922 | } |
923 | 923 | } |
@@ -4,15 +4,15 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | |
11 | 11 | <div class="card shadow-sm my-5"> |
12 | 12 | |
13 | 13 | <form method="post" class="text-left card-body" action="options.php"> |
14 | - <?php settings_fields( 'wpinv_settings' ); ?> |
|
15 | - <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>"> |
|
14 | + <?php settings_fields('wpinv_settings'); ?> |
|
15 | + <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>"> |
|
16 | 16 | |
17 | 17 | <table class="gp-setup-maps w-100 " cellspacing="0"> |
18 | 18 | <tbody> |
@@ -20,28 +20,28 @@ discard block |
||
20 | 20 | |
21 | 21 | global $wp_settings_fields; |
22 | 22 | |
23 | - if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) { |
|
24 | - $settings = $wp_settings_fields[ $page ][ $section ]; |
|
23 | + if (isset($wp_settings_fields[$page][$section])) { |
|
24 | + $settings = $wp_settings_fields[$page][$section]; |
|
25 | 25 | |
26 | - foreach ( $settings as $field ) { |
|
26 | + foreach ($settings as $field) { |
|
27 | 27 | |
28 | - $name = esc_attr( $field['id'] ); |
|
29 | - $id = sanitize_key( $name ); |
|
28 | + $name = esc_attr($field['id']); |
|
29 | + $id = sanitize_key($name); |
|
30 | 30 | $class = ''; |
31 | - $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
|
32 | - $value = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) ); |
|
33 | - $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : ''; |
|
34 | - $type = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) ); |
|
35 | - $label = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : ''; |
|
36 | - $options = isset( $field['args']['options'] ) ? $field['args']['options'] : array(); |
|
37 | - |
|
38 | - if ( false !== strpos( $name, 'logo' ) ) { |
|
31 | + $value = isset($field['args']['std']) ? $field['args']['std'] : ''; |
|
32 | + $value = wpinv_clean(wpinv_get_option($field['args']['id'], $value)); |
|
33 | + $help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : ''; |
|
34 | + $type = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback'])); |
|
35 | + $label = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : ''; |
|
36 | + $options = isset($field['args']['options']) ? $field['args']['options'] : array(); |
|
37 | + |
|
38 | + if (false !== strpos($name, 'logo')) { |
|
39 | 39 | $type = 'hidden'; |
40 | 40 | } |
41 | 41 | |
42 | - if ( 'country_states' == $type ) { |
|
42 | + if ('country_states' == $type) { |
|
43 | 43 | |
44 | - if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) { |
|
44 | + if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) { |
|
45 | 45 | $type = 'text'; |
46 | 46 | } else { |
47 | 47 | $type = 'select'; |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | $class = 'getpaid_js_field-state'; |
51 | 51 | } |
52 | 52 | |
53 | - if ( 'wpinv_settings[default_country]' == $name ) { |
|
53 | + if ('wpinv_settings[default_country]' == $name) { |
|
54 | 54 | $class = 'getpaid_js_field-country'; |
55 | 55 | } |
56 | 56 | |
57 | - switch ( $type ) { |
|
57 | + switch ($type) { |
|
58 | 58 | |
59 | 59 | case 'hidden': |
60 | - echo "<input type='hidden' id='" . esc_attr( $id ) . "' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
60 | + echo "<input type='hidden' id='" . esc_attr($id) . "' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
61 | 61 | break; |
62 | 62 | case 'text': |
63 | 63 | case 'number': |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'type' => $type, |
67 | 67 | 'id' => $id, |
68 | 68 | 'name' => $name, |
69 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
69 | + 'value' => is_scalar($value) ? esc_attr($value) : '', |
|
70 | 70 | 'required' => false, |
71 | 71 | 'help_text' => $help_text, |
72 | 72 | 'label' => $label, |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | array( |
83 | 83 | 'id' => $id, |
84 | 84 | 'name' => $name, |
85 | - 'value' => is_scalar( $value ) ? esc_textarea( $value ) : '', |
|
85 | + 'value' => is_scalar($value) ? esc_textarea($value) : '', |
|
86 | 86 | 'required' => false, |
87 | 87 | 'help_text' => $help_text, |
88 | 88 | 'label' => $label, |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | 'id' => $id, |
102 | 102 | 'name' => $name, |
103 | 103 | 'placeholder' => '', |
104 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
104 | + 'value' => is_scalar($value) ? esc_attr($value) : '', |
|
105 | 105 | 'required' => false, |
106 | 106 | 'help_text' => $help_text, |
107 | 107 | 'label' => $label, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | <input |
128 | 128 | type="submit" |
129 | 129 | class="btn btn-primary button-next" |
130 | - value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/> |
|
130 | + value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/> |
|
131 | 131 | </p> |
132 | 132 | </table> |
133 | 133 | </form> |
@@ -3,27 +3,27 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
10 | 10 | ?> |
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
12 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
13 | 13 | |
14 | - <?php if ( $tabs ) { ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . esc_url(admin_url('admin.php?page=wpi-addons&tab=' . $name)) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . esc_html($label) . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { ?> |
|
36 | - <h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2> |
|
35 | + <?php if (defined('WP_EASY_UPDATES_ACTIVE')) { ?> |
|
36 | + <h2><?php esc_html_e('Have a membership key?', 'invoicing'); ?></h2> |
|
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo wp_kses_post( $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ) ); |
|
39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1'); |
|
40 | + echo wp_kses_post($wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351))); |
|
41 | 41 | ?> |
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
45 | 45 | <div class="membership-cta-contet"> |
46 | 46 | <div class="main-cta"> |
47 | - <h2><?php esc_html_e( 'Membership benefits Include:', 'invoicing' ); ?></h2> |
|
47 | + <h2><?php esc_html_e('Membership benefits Include:', 'invoicing'); ?></h2> |
|
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | 51 | $addon_obj = new WPInv_Admin_Addons(); |
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
52 | + if ($addons = $addon_obj->get_section_data('addons')) { |
|
53 | + foreach ($addons as $addon) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
61 | - <h3><?php esc_html_e( 'Membership Starts from', 'invoicing' ); ?></h3> |
|
61 | + <h3><?php esc_html_e('Membership Starts from', 'invoicing'); ?></h3> |
|
62 | 62 | <h4>$99</h4> |
63 | - <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
63 | + <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e('Buy Membership', 'invoicing'); ?></a> |
|
64 | 64 | </div> |
65 | - <h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3> |
|
65 | + <h3><?php esc_html_e('Included Gateways:', 'invoicing'); ?></h3> |
|
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
68 | + if ($addons = $addon_obj->get_section_data('gateways')) { |
|
69 | + foreach ($addons as $addon) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > '; |
|
84 | + echo '<img src="' . esc_url(plugins_url('images/t-image2.png', dirname(__FILE__))) . '" > '; |
|
85 | 85 | ?> |
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > '; |
|
104 | + echo '<img src="' . esc_url(plugins_url('images/t-image1.png', dirname(__FILE__))) . '" > '; |
|
105 | 105 | ?> |
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | </div> |
118 | 118 | </div> |
119 | 119 | <div class="member-footer"> |
120 | - <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
121 | - <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e( 'Create Invoice', 'invoicing' ); ?></a> |
|
120 | + <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e('Buy Membership', 'invoicing'); ?></a> |
|
121 | + <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e('Create Invoice', 'invoicing'); ?></a> |
|
122 | 122 | </div> |
123 | 123 | </div> |
124 | 124 | |
@@ -129,55 +129,55 @@ discard block |
||
129 | 129 | } else { |
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
132 | + if ($addons = $addon_obj->get_section_data($current_tab)) : |
|
133 | 133 | //print_r($addons); |
134 | 134 | ?> |
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | - foreach ( $addons as $addon ) : |
|
138 | - if ( 965 == $addon->info->id ) { |
|
139 | -continue;}// don't show quote add on |
|
137 | + foreach ($addons as $addon) : |
|
138 | + if (965 == $addon->info->id) { |
|
139 | +continue; }// don't show quote add on |
|
140 | 140 | ?> |
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - wpi_help_tip( $addon->info->excerpt, false, false, true ); |
|
145 | + if (!empty($addon->info->excerpt)) { |
|
146 | + wpi_help_tip($addon->info->excerpt, false, false, true); |
|
147 | 147 | } |
148 | - echo esc_html( $addon->info->title ); |
|
148 | + echo esc_html($addon->info->title); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
152 | 152 | |
153 | 153 | <span class="wpi-product-image"> |
154 | - <?php if ( ! empty( $addon->info->thumbnail ) ) : ?> |
|
155 | - <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
|
154 | + <?php if (!empty($addon->info->thumbnail)) : ?> |
|
155 | + <img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/> |
|
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
159 | + if ('stripe-payment-gateway' == $addon->info->slug) { |
|
160 | 160 | $addon->info->slug = 'getpaid-stripe-payments'; |
161 | 161 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
162 | 162 | } |
163 | 163 | |
164 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
165 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
164 | + if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === 'https://wordpress.org') { |
|
165 | + echo '<a href="' . esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug)) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
166 | + echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>'; |
|
167 | 167 | echo '</a>'; |
168 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
169 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
170 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
168 | + } elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === 'https://wpinvoicing.com' || substr($addon->info->link, 0, 21) === 'https://wpgetpaid.com')) { |
|
169 | + if (defined('WP_EASY_UPDATES_ACTIVE')) { |
|
170 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
171 | 171 | } else { |
172 | 172 | // if installed show activation link |
173 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
173 | + if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) { |
|
174 | 174 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
175 | 175 | } else { |
176 | 176 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
177 | 177 | } |
178 | 178 | } |
179 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
180 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
179 | + echo '<a href="' . esc_url($url) . '" class="thickbox">'; |
|
180 | + echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>'; |
|
181 | 181 | echo '</a>'; |
182 | 182 | } |
183 | 183 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | <span class="wpi-product-button"> |
190 | 190 | <?php |
191 | - $addon_obj->output_button( $addon ); |
|
191 | + $addon_obj->output_button($addon); |
|
192 | 192 | ?> |
193 | 193 | </span> |
194 | 194 | |
@@ -202,21 +202,21 @@ discard block |
||
202 | 202 | |
203 | 203 | <div class="clearfix" ></div> |
204 | 204 | |
205 | - <?php if ( $current_tab == 'addons' ) { ?> |
|
206 | - <p><?php printf( wp_kses_post( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ) ); ?></p> |
|
207 | - <?php } if ( $current_tab == 'gateways' ) { ?> |
|
208 | - <p><?php printf( wp_kses_post( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ) ); ?></p> |
|
205 | + <?php if ($current_tab == 'addons') { ?> |
|
206 | + <p><?php printf(wp_kses_post(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/')); ?></p> |
|
207 | + <?php } if ($current_tab == 'gateways') { ?> |
|
208 | + <p><?php printf(wp_kses_post(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/')); ?></p> |
|
209 | 209 | <?php } ?> |
210 | 210 | |
211 | - <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( wp_kses_post( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing' ), wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php' ), 'activate-plugin_wp-easy-updates/external-updates.php' ) ) ); ?></span></div> |
|
212 | - <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf( wp_kses_post( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing' ), admin_url( 'plugin-install.php?tab=upload&wpeu-install=true' ) ) ); ?></span></div> |
|
211 | + <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(wp_kses_post(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'))); ?></span></div> |
|
212 | + <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(wp_kses_post(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url('plugin-install.php?tab=upload&wpeu-install=true'))); ?></span></div> |
|
213 | 213 | <div id="wpeu-licence-popup" style="display:none;"> |
214 | 214 | <span class="wpi-notification noti-white"> |
215 | - <h3 class="wpeu-licence-title"><?php esc_html_e( 'Licence key', 'invoicing' ); ?></h3> |
|
216 | - <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button> |
|
215 | + <h3 class="wpeu-licence-title"><?php esc_html_e('Licence key', 'invoicing'); ?></h3> |
|
216 | + <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e('Enter your licence key', 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e('Install', 'invoicing'); ?></button> |
|
217 | 217 | <br> |
218 | 218 | <?php |
219 | - echo sprintf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
219 | + echo sprintf(esc_html__('%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>'); |
|
220 | 220 | ?> |
221 | 221 | </span> |
222 | 222 | </div> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @version 2.4.0 |
11 | 11 | * @info GetPaid Setup Wizard. |
12 | 12 | */ |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * GetPaid_Admin_Setup_Wizard class. |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | |
47 | - if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) { |
|
48 | - add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
49 | - add_action( 'current_screen', array( $this, 'setup_wizard' ) ); |
|
47 | + if (apply_filters('getpaid_enable_setup_wizard', true) && wpinv_current_user_can_manage_invoicing()) { |
|
48 | + add_action('admin_menu', array($this, 'add_menu')); |
|
49 | + add_action('current_screen', array($this, 'setup_wizard')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @since 2.4.0 |
58 | 58 | */ |
59 | 59 | public function add_menu() { |
60 | - add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' ); |
|
60 | + add_dashboard_page('', '', wpinv_get_capability(), 'gp-setup', ''); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function setup_wizard() { |
69 | 69 | |
70 | - if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) { |
|
70 | + if (isset($_GET['page']) && 'gp-setup' === $_GET['page']) { |
|
71 | 71 | $this->setup_globals(); |
72 | 72 | $this->maybe_save_current_step(); |
73 | 73 | $this->display_wizard(); |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @since 2.4.0 |
95 | 95 | */ |
96 | 96 | protected function maybe_save_current_step() { |
97 | - if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) { |
|
98 | - call_user_func( $this->steps[ $this->step ]['handler'], $this ); |
|
97 | + if (!empty($_POST['save_step']) && is_callable($this->steps[$this->step]['handler'])) { |
|
98 | + call_user_func($this->steps[$this->step]['handler'], $this); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | $steps = array( |
111 | 111 | |
112 | 112 | 'introduction' => array( |
113 | - 'name' => __( 'Introduction', 'invoicing' ), |
|
114 | - 'view' => array( $this, 'setup_introduction' ), |
|
113 | + 'name' => __('Introduction', 'invoicing'), |
|
114 | + 'view' => array($this, 'setup_introduction'), |
|
115 | 115 | 'handler' => '', |
116 | 116 | ), |
117 | 117 | |
118 | 118 | 'business_details' => array( |
119 | - 'name' => __( 'Business Details', 'invoicing' ), |
|
120 | - 'view' => array( $this, 'setup_business' ), |
|
119 | + 'name' => __('Business Details', 'invoicing'), |
|
120 | + 'view' => array($this, 'setup_business'), |
|
121 | 121 | 'handler' => '', |
122 | 122 | ), |
123 | 123 | |
124 | 124 | 'currency' => array( |
125 | - 'name' => __( 'Currency', 'invoicing' ), |
|
126 | - 'view' => array( $this, 'setup_currency' ), |
|
125 | + 'name' => __('Currency', 'invoicing'), |
|
126 | + 'view' => array($this, 'setup_currency'), |
|
127 | 127 | 'handler' => '', |
128 | 128 | ), |
129 | 129 | |
130 | 130 | 'payments' => array( |
131 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
132 | - 'view' => array( $this, 'setup_payments' ), |
|
133 | - 'handler' => array( $this, 'setup_payments_save' ), |
|
131 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
132 | + 'view' => array($this, 'setup_payments'), |
|
133 | + 'handler' => array($this, 'setup_payments_save'), |
|
134 | 134 | ), |
135 | 135 | |
136 | 136 | 'recommend' => array( |
137 | - 'name' => __( 'Recommend', 'invoicing' ), |
|
138 | - 'view' => array( $this, 'setup_recommend' ), |
|
137 | + 'name' => __('Recommend', 'invoicing'), |
|
138 | + 'view' => array($this, 'setup_recommend'), |
|
139 | 139 | 'handler' => '', |
140 | 140 | ), |
141 | 141 | |
142 | 142 | 'next_steps' => array( |
143 | - 'name' => __( 'Get Paid', 'invoicing' ), |
|
144 | - 'view' => array( $this, 'setup_ready' ), |
|
143 | + 'name' => __('Get Paid', 'invoicing'), |
|
144 | + 'view' => array($this, 'setup_ready'), |
|
145 | 145 | 'handler' => '', |
146 | 146 | ), |
147 | 147 | |
148 | 148 | ); |
149 | 149 | |
150 | - return apply_filters( 'getpaid_setup_wizard_steps', $steps ); |
|
150 | + return apply_filters('getpaid_setup_wizard_steps', $steps); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | protected function get_current_step() { |
161 | - $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; |
|
162 | - return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) ); |
|
161 | + $step = isset($_GET['step']) ? sanitize_key($_GET['step']) : ''; |
|
162 | + return !empty($step) && in_array($step, array_keys($this->steps)) ? $step : current(array_keys($this->steps)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | |
173 | 173 | $previous = false; |
174 | 174 | $current = $this->step; |
175 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
176 | - if ( $current === $step ) { |
|
175 | + foreach (array_keys($this->steps) as $step) { |
|
176 | + if ($current === $step) { |
|
177 | 177 | return $previous; |
178 | 178 | } |
179 | 179 | |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | |
194 | 194 | $on_current = false; |
195 | 195 | $current = $this->step; |
196 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
196 | + foreach (array_keys($this->steps) as $step) { |
|
197 | 197 | |
198 | - if ( $on_current ) { |
|
198 | + if ($on_current) { |
|
199 | 199 | return $step; |
200 | 200 | } |
201 | 201 | |
202 | - if ( $current === $step ) { |
|
202 | + if ($current === $step) { |
|
203 | 203 | return $on_current = true; |
204 | 204 | } |
205 | 205 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | $steps = $this->steps; |
228 | 228 | $current = $this->step; |
229 | 229 | $next_step = $this->next_step; |
230 | - array_shift( $steps ); |
|
231 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php'; |
|
230 | + array_shift($steps); |
|
231 | + include plugin_dir_path(__FILE__) . 'views/wizard-header.php'; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | ?> |
241 | 241 | <div class="gp-setup-content rowx mw-100 text-center mb-3"> |
242 | 242 | <div class="col-12 col-md-5 m-auto"> |
243 | - <?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?> |
|
243 | + <?php call_user_func($this->steps[$this->step]['view'], $this); ?> |
|
244 | 244 | </div> |
245 | 245 | </div> |
246 | 246 | <?php |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function display_footer() { |
255 | 255 | |
256 | - if ( isset( $_GET['step'] ) ) { |
|
257 | - $label = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' ); |
|
256 | + if (isset($_GET['step'])) { |
|
257 | + $label = $this->step == 'next_steps' ? __('Return to the WordPress Dashboard', 'invoicing') : __('Skip this step', 'invoicing'); |
|
258 | 258 | |
259 | - echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . esc_url( $this->get_next_step_link() ) . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . esc_html( $label ) . '</a></p>'; |
|
259 | + echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . esc_url($this->get_next_step_link()) . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . esc_html($label) . '</a></p>'; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | echo '</body></html>'; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | public function setup_introduction() { |
271 | 271 | $next_url = $this->get_next_step_link(); |
272 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php'; |
|
272 | + include plugin_dir_path(__FILE__) . 'views/wizard-introduction.php'; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -282,22 +282,22 @@ discard block |
||
282 | 282 | * Empty string on failure. |
283 | 283 | * @since 3.0.0 |
284 | 284 | */ |
285 | - public function get_next_step_link( $step = '' ) { |
|
286 | - if ( ! $step ) { |
|
285 | + public function get_next_step_link($step = '') { |
|
286 | + if (!$step) { |
|
287 | 287 | $step = $this->step; |
288 | 288 | } |
289 | 289 | |
290 | - $keys = array_keys( $this->steps ); |
|
291 | - if ( end( $keys ) === $step ) { |
|
290 | + $keys = array_keys($this->steps); |
|
291 | + if (end($keys) === $step) { |
|
292 | 292 | return admin_url(); |
293 | 293 | } |
294 | 294 | |
295 | - $step_index = array_search( $step, $keys ); |
|
296 | - if ( false === $step_index ) { |
|
295 | + $step_index = array_search($step, $keys); |
|
296 | + if (false === $step_index) { |
|
297 | 297 | return ''; |
298 | 298 | } |
299 | 299 | |
300 | - return remove_query_arg( 'settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ) ); |
|
300 | + return remove_query_arg('settings-updated', add_query_arg('step', $keys[$step_index + 1])); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $wizard = $this; |
311 | 311 | $page = 'wpinv_settings_general_main'; |
312 | 312 | $section = 'wpinv_settings_general_main'; |
313 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
313 | + include plugin_dir_path(__FILE__) . 'views/wizard-settings.php'; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $wizard = $this; |
324 | 324 | $page = 'wpinv_settings_general_currency_section'; |
325 | 325 | $section = 'wpinv_settings_general_currency_section'; |
326 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
326 | + include plugin_dir_path(__FILE__) . 'views/wizard-settings.php'; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | public function setup_recommend() { |
335 | 335 | $next_url = $this->get_next_step_link(); |
336 | 336 | $recommended_plugins = self::get_recommend_wp_plugins(); |
337 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php'; |
|
337 | + include plugin_dir_path(__FILE__) . 'views/wizard-plugins.php'; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -348,21 +348,21 @@ discard block |
||
348 | 348 | 'url' => 'https://wordpress.org/plugins/ayecode-connect/', |
349 | 349 | 'slug' => 'ayecode-connect', |
350 | 350 | 'name' => 'AyeCode Connect', |
351 | - 'desc' => __( 'Documentation and Support from within your WordPress admin.', 'invoicing' ), |
|
351 | + 'desc' => __('Documentation and Support from within your WordPress admin.', 'invoicing'), |
|
352 | 352 | ), |
353 | 353 | 'invoicing-quotes' => array( |
354 | 354 | 'file' => 'invoicing-quotes/wpinv-quote.php', |
355 | 355 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
356 | 356 | 'slug' => 'invoicing-quotes', |
357 | 357 | 'name' => 'Customer Quotes', |
358 | - 'desc' => __( 'Create & Send Quotes to Customers and have them accept and pay.', 'invoicing' ), |
|
358 | + 'desc' => __('Create & Send Quotes to Customers and have them accept and pay.', 'invoicing'), |
|
359 | 359 | ), |
360 | 360 | 'userswp' => array( |
361 | 361 | 'file' => 'userswp/userswp.php', |
362 | 362 | 'url' => 'https://wordpress.org/plugins/userswp/', |
363 | 363 | 'slug' => 'userswp', |
364 | 364 | 'name' => 'UsersWP', |
365 | - 'desc' => __( 'Frontend user login and registration as well as slick profile pages.', 'invoicing' ), |
|
365 | + 'desc' => __('Frontend user login and registration as well as slick profile pages.', 'invoicing'), |
|
366 | 366 | ), |
367 | 367 | ); |
368 | 368 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function setup_payments() { |
376 | 376 | $next_url = $this->get_next_step_link(); |
377 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php'; |
|
377 | + include plugin_dir_path(__FILE__) . 'views/wizard-gateways.php'; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @since 2.0.0 |
386 | 386 | */ |
387 | 387 | public function setup_payments_save() { |
388 | - check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); |
|
389 | - wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) ); |
|
388 | + check_admin_referer('getpaid-setup-wizard', 'getpaid-setup-wizard'); |
|
389 | + wpinv_update_option('manual_active', !empty($_POST['enable-manual-gateway'])); |
|
390 | 390 | |
391 | - if ( ! empty( $_POST['paypal-email'] ) ) { |
|
392 | - wpinv_update_option( 'paypal_email', sanitize_email( $_POST['paypal-email'] ) ); |
|
393 | - wpinv_update_option( 'paypal_active', 1 ); |
|
394 | - wpinv_update_option( 'paypal_sandbox', 0 ); |
|
391 | + if (!empty($_POST['paypal-email'])) { |
|
392 | + wpinv_update_option('paypal_email', sanitize_email($_POST['paypal-email'])); |
|
393 | + wpinv_update_option('paypal_active', 1); |
|
394 | + wpinv_update_option('paypal_sandbox', 0); |
|
395 | 395 | } |
396 | 396 | |
397 | - wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
|
397 | + wp_redirect(esc_url_raw($this->get_next_step_link())); |
|
398 | 398 | exit; |
399 | 399 | } |
400 | 400 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @since 2.0.0 |
405 | 405 | */ |
406 | 406 | public function setup_ready() { |
407 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php'; |
|
407 | + include plugin_dir_path(__FILE__) . 'views/wizard-thank-you.php'; |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | } |
@@ -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 | * Post types Admin Class |
@@ -21,74 +21,74 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | + add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions')); |
|
34 | + add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3); |
|
35 | 35 | |
36 | 36 | // Items table columns. |
37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
37 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
38 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
39 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
40 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
41 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
42 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
43 | 43 | |
44 | 44 | // Payment forms columns. |
45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
45 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
46 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
47 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
48 | 48 | |
49 | 49 | // Discount table columns. |
50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
51 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
52 | 52 | |
53 | 53 | // Deleting posts. |
54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
55 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
56 | 56 | |
57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
57 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Post updated messages. |
62 | 62 | */ |
63 | - public static function post_updated_messages( $messages ) { |
|
63 | + public static function post_updated_messages($messages) { |
|
64 | 64 | global $post; |
65 | 65 | |
66 | 66 | $messages['wpi_discount'] = array( |
67 | 67 | 0 => '', |
68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
68 | + 1 => __('Discount updated.', 'invoicing'), |
|
69 | + 2 => __('Custom field updated.', 'invoicing'), |
|
70 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
71 | + 4 => __('Discount updated.', 'invoicing'), |
|
72 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
73 | + 6 => __('Discount updated.', 'invoicing'), |
|
74 | + 7 => __('Discount saved.', 'invoicing'), |
|
75 | + 8 => __('Discount submitted.', 'invoicing'), |
|
76 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
77 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | $messages['wpi_payment_form'] = array( |
81 | 81 | 0 => '', |
82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
82 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
83 | + 2 => __('Custom field updated.', 'invoicing'), |
|
84 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
85 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
86 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
87 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
88 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
89 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
90 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
91 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | return $messages; |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Post row actions. |
100 | 100 | */ |
101 | - public static function post_row_actions( $actions, $post ) { |
|
101 | + public static function post_row_actions($actions, $post) { |
|
102 | 102 | |
103 | - $post = get_post( $post ); |
|
103 | + $post = get_post($post); |
|
104 | 104 | |
105 | 105 | // We do not want to edit the default payment form. |
106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
106 | + if ('wpi_payment_form' == $post->post_type) { |
|
107 | 107 | |
108 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
109 | - unset( $actions['trash'] ); |
|
110 | - unset( $actions['inline hide-if-no-js'] ); |
|
108 | + if ($post->ID == wpinv_get_default_payment_form()) { |
|
109 | + unset($actions['trash']); |
|
110 | + unset($actions['inline hide-if-no-js']); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $actions['duplicate'] = sprintf( |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | 'getpaid-nonce' |
125 | 125 | ) |
126 | 126 | ), |
127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
127 | + esc_html(__('Duplicate', 'invoicing')) |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Link to item payment form. |
133 | - if ( 'wpi_item' == $post->post_type ) { |
|
133 | + if ('wpi_item' == $post->post_type) { |
|
134 | 134 | |
135 | - if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
135 | + if (in_array(get_post_meta($post->ID, '_wpinv_type', true), array('', 'fee', 'custom'))) { |
|
136 | 136 | |
137 | 137 | $actions['buy'] = sprintf( |
138 | 138 | '<a href="%1$s">%2$s</a>', |
139 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
140 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
139 | + esc_url(getpaid_embed_url(false, $post->ID . '|0')), |
|
140 | + esc_html(__('Buy', 'invoicing')) |
|
141 | 141 | ); |
142 | 142 | |
143 | 143 | } |
@@ -154,27 +154,27 @@ discard block |
||
154 | 154 | * @param WP_Post $post |
155 | 155 | * @return array $actions actions without edit option |
156 | 156 | */ |
157 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
157 | + public static function filter_invoice_row_actions($actions, $post) { |
|
158 | 158 | |
159 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
159 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
160 | 160 | |
161 | 161 | $actions = array(); |
162 | - $invoice = new WPInv_Invoice( $post ); |
|
162 | + $invoice = new WPInv_Invoice($post); |
|
163 | 163 | |
164 | 164 | $actions['edit'] = sprintf( |
165 | 165 | '<a href="%1$s">%2$s</a>', |
166 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
167 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
166 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
167 | + esc_html(__('Edit', 'invoicing')) |
|
168 | 168 | ); |
169 | 169 | |
170 | - if ( ! $invoice->is_draft() ) { |
|
170 | + if (!$invoice->is_draft()) { |
|
171 | 171 | |
172 | 172 | $actions['view'] = sprintf( |
173 | 173 | '<a href="%1$s">%2$s</a>', |
174 | - esc_url( $invoice->get_view_url() ), |
|
174 | + esc_url($invoice->get_view_url()), |
|
175 | 175 | sprintf( |
176 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
177 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
176 | + esc_html(__('View %s', 'invoicing')), |
|
177 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
178 | 178 | ) |
179 | 179 | ); |
180 | 180 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | 'getpaid-nonce' |
193 | 193 | ) |
194 | 194 | ), |
195 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
195 | + esc_html(__('Send to Customer', 'invoicing')) |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | 'getpaid-nonce' |
212 | 212 | ) |
213 | 213 | ), |
214 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
214 | + esc_html(__('Duplicate', 'invoicing')) |
|
215 | 215 | ); |
216 | 216 | |
217 | 217 | } |
@@ -222,42 +222,42 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * Returns an array of invoice table columns. |
224 | 224 | */ |
225 | - public static function invoice_columns( $columns ) { |
|
225 | + public static function invoice_columns($columns) { |
|
226 | 226 | |
227 | 227 | $columns = array( |
228 | 228 | 'cb' => $columns['cb'], |
229 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
230 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
231 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
232 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
233 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
234 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
235 | - 'status' => __( 'Status', 'invoicing' ), |
|
229 | + 'number' => __('Invoice', 'invoicing'), |
|
230 | + 'customer' => __('Customer', 'invoicing'), |
|
231 | + 'invoice_date' => __('Created', 'invoicing'), |
|
232 | + 'payment_date' => __('Completed', 'invoicing'), |
|
233 | + 'amount' => __('Amount', 'invoicing'), |
|
234 | + 'recurring' => __('Recurring', 'invoicing'), |
|
235 | + 'status' => __('Status', 'invoicing'), |
|
236 | 236 | ); |
237 | 237 | |
238 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
238 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | 242 | * Displays invoice table columns. |
243 | 243 | */ |
244 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
244 | + public static function display_invoice_columns($column_name, $post_id) { |
|
245 | 245 | |
246 | - $invoice = new WPInv_Invoice( $post_id ); |
|
246 | + $invoice = new WPInv_Invoice($post_id); |
|
247 | 247 | |
248 | - switch ( $column_name ) { |
|
248 | + switch ($column_name) { |
|
249 | 249 | |
250 | 250 | case 'invoice_date': |
251 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
252 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
253 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
251 | + $date_time = esc_attr($invoice->get_created_date()); |
|
252 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
253 | + echo wp_kses_post("<span title='$date_time'>$date</span>"); |
|
254 | 254 | break; |
255 | 255 | |
256 | 256 | case 'payment_date': |
257 | - if ( $invoice->is_paid() ) { |
|
258 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
259 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
260 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
257 | + if ($invoice->is_paid()) { |
|
258 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
259 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
260 | + echo wp_kses_post("<span title='$date_time'>$date</span>"); |
|
261 | 261 | } else { |
262 | 262 | echo '—'; |
263 | 263 | } |
@@ -266,57 +266,57 @@ discard block |
||
266 | 266 | |
267 | 267 | case 'amount': |
268 | 268 | $amount = $invoice->get_total(); |
269 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
269 | + $formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency())); |
|
270 | 270 | |
271 | - if ( $invoice->is_refunded() ) { |
|
272 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
273 | - echo wp_kses_post( "<del>$formated_amount</del> <ins>$refunded_amount</ins>" ); |
|
271 | + if ($invoice->is_refunded()) { |
|
272 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
273 | + echo wp_kses_post("<del>$formated_amount</del> <ins>$refunded_amount</ins>"); |
|
274 | 274 | } else { |
275 | 275 | |
276 | 276 | $discount = $invoice->get_total_discount(); |
277 | 277 | |
278 | - if ( ! empty( $discount ) ) { |
|
279 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
280 | - echo wp_kses_post( "<del>$new_amount</del> <ins>$formated_amount</ins>" ); |
|
278 | + if (!empty($discount)) { |
|
279 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
280 | + echo wp_kses_post("<del>$new_amount</del> <ins>$formated_amount</ins>"); |
|
281 | 281 | } else { |
282 | - echo wp_kses_post( $formated_amount ); |
|
282 | + echo wp_kses_post($formated_amount); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | 286 | break; |
287 | 287 | |
288 | 288 | case 'status': |
289 | - $status = esc_html( $invoice->get_status() ); |
|
290 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
289 | + $status = esc_html($invoice->get_status()); |
|
290 | + $status_label = esc_html($invoice->get_status_nicename()); |
|
291 | 291 | |
292 | 292 | // If it is paid, show the gateway title. |
293 | - if ( $invoice->is_paid() ) { |
|
294 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
295 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
293 | + if ($invoice->is_paid()) { |
|
294 | + $gateway = esc_html($invoice->get_gateway_title()); |
|
295 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway)); |
|
296 | 296 | |
297 | - echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" ); |
|
297 | + echo wp_kses_post("<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"); |
|
298 | 298 | } else { |
299 | - echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" ); |
|
299 | + echo wp_kses_post("<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | // If it is not paid, display the overdue and view status. |
303 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
303 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
304 | 304 | |
305 | 305 | // Invoice view status. |
306 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
307 | - echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
306 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
307 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
308 | 308 | } else { |
309 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
309 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | // Display the overview status. |
313 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
313 | + if (wpinv_get_option('overdue_active')) { |
|
314 | 314 | $due_date = $invoice->get_due_date(); |
315 | - $fomatted = getpaid_format_date( $due_date ); |
|
315 | + $fomatted = getpaid_format_date($due_date); |
|
316 | 316 | |
317 | - if ( ! empty( $fomatted ) ) { |
|
318 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
319 | - echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" ); |
|
317 | + if (!empty($fomatted)) { |
|
318 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
319 | + echo wp_kses_post("<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | break; |
325 | 325 | |
326 | 326 | case 'recurring': |
327 | - if ( $invoice->is_recurring() ) { |
|
327 | + if ($invoice->is_recurring()) { |
|
328 | 328 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
329 | 329 | } else { |
330 | 330 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -332,25 +332,25 @@ discard block |
||
332 | 332 | break; |
333 | 333 | |
334 | 334 | case 'number': |
335 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
336 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
337 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
335 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
336 | + $invoice_number = esc_html($invoice->get_number()); |
|
337 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
338 | 338 | |
339 | - echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" ); |
|
339 | + echo wp_kses_post("<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"); |
|
340 | 340 | |
341 | 341 | break; |
342 | 342 | |
343 | 343 | case 'customer': |
344 | 344 | $customer_name = $invoice->get_user_full_name(); |
345 | 345 | |
346 | - if ( empty( $customer_name ) ) { |
|
346 | + if (empty($customer_name)) { |
|
347 | 347 | $customer_name = $invoice->get_email(); |
348 | 348 | } |
349 | 349 | |
350 | - if ( ! empty( $customer_name ) ) { |
|
351 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
352 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
353 | - echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" ); |
|
350 | + if (!empty($customer_name)) { |
|
351 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
352 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
353 | + echo wp_kses_post("<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"); |
|
354 | 354 | } else { |
355 | 355 | echo '<div>—</div>'; |
356 | 356 | } |
@@ -364,19 +364,19 @@ discard block |
||
364 | 364 | /** |
365 | 365 | * Displays invoice bulk actions. |
366 | 366 | */ |
367 | - public static function invoice_bulk_actions( $actions ) { |
|
368 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
367 | + public static function invoice_bulk_actions($actions) { |
|
368 | + $actions['resend-invoice'] = __('Send to Customer', 'invoicing'); |
|
369 | 369 | return $actions; |
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
373 | 373 | * Processes invoice bulk actions. |
374 | 374 | */ |
375 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
375 | + public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) { |
|
376 | 376 | |
377 | - if ( $action == 'resend-invoice' ) { |
|
378 | - foreach ( $post_ids as $post_id ) { |
|
379 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
377 | + if ($action == 'resend-invoice') { |
|
378 | + foreach ($post_ids as $post_id) { |
|
379 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
@@ -387,49 +387,49 @@ discard block |
||
387 | 387 | /** |
388 | 388 | * Returns an array of payment forms table columns. |
389 | 389 | */ |
390 | - public static function payment_form_columns( $columns ) { |
|
390 | + public static function payment_form_columns($columns) { |
|
391 | 391 | |
392 | 392 | $columns = array( |
393 | 393 | 'cb' => $columns['cb'], |
394 | - 'title' => __( 'Name', 'invoicing' ), |
|
395 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
396 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
397 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
398 | - 'items' => __( 'Items', 'invoicing' ), |
|
399 | - 'date' => __( 'Date', 'invoicing' ), |
|
394 | + 'title' => __('Name', 'invoicing'), |
|
395 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
396 | + 'earnings' => __('Revenue', 'invoicing'), |
|
397 | + 'refunds' => __('Refunded', 'invoicing'), |
|
398 | + 'items' => __('Items', 'invoicing'), |
|
399 | + 'date' => __('Date', 'invoicing'), |
|
400 | 400 | ); |
401 | 401 | |
402 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
402 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
407 | 407 | * Displays payment form table columns. |
408 | 408 | */ |
409 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
409 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
410 | 410 | |
411 | 411 | // Retrieve the payment form. |
412 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
412 | + $form = new GetPaid_Payment_Form($post_id); |
|
413 | 413 | |
414 | - switch ( $column_name ) { |
|
414 | + switch ($column_name) { |
|
415 | 415 | |
416 | 416 | case 'earnings': |
417 | - echo wp_kses_post( wpinv_price( $form->get_earned() ) ); |
|
417 | + echo wp_kses_post(wpinv_price($form->get_earned())); |
|
418 | 418 | break; |
419 | 419 | |
420 | 420 | case 'refunds': |
421 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
421 | + echo wp_kses_post(wpinv_price($form->get_refunded())); |
|
422 | 422 | break; |
423 | 423 | |
424 | 424 | case 'refunds': |
425 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
425 | + echo wp_kses_post(wpinv_price($form->get_refunded())); |
|
426 | 426 | break; |
427 | 427 | |
428 | 428 | case 'shortcode': |
429 | - if ( $form->is_default() ) { |
|
429 | + if ($form->is_default()) { |
|
430 | 430 | echo '—'; |
431 | 431 | } else { |
432 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
432 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | break; |
@@ -437,28 +437,28 @@ discard block |
||
437 | 437 | case 'items': |
438 | 438 | $items = $form->get_items(); |
439 | 439 | |
440 | - if ( $form->is_default() || empty( $items ) ) { |
|
440 | + if ($form->is_default() || empty($items)) { |
|
441 | 441 | echo '—'; |
442 | 442 | return; |
443 | 443 | } |
444 | 444 | |
445 | 445 | $_items = array(); |
446 | 446 | |
447 | - foreach ( $items as $item ) { |
|
447 | + foreach ($items as $item) { |
|
448 | 448 | $url = $item->get_edit_url(); |
449 | 449 | |
450 | - if ( empty( $url ) ) { |
|
451 | - $_items[] = esc_html( $item->get_name() ); |
|
450 | + if (empty($url)) { |
|
451 | + $_items[] = esc_html($item->get_name()); |
|
452 | 452 | } else { |
453 | 453 | $_items[] = sprintf( |
454 | 454 | '<a href="%s">%s</a>', |
455 | - esc_url( $url ), |
|
456 | - esc_html( $item->get_name() ) |
|
455 | + esc_url($url), |
|
456 | + esc_html($item->get_name()) |
|
457 | 457 | ); |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | - echo wp_kses_post( implode( '<br>', $_items ) ); |
|
461 | + echo wp_kses_post(implode('<br>', $_items)); |
|
462 | 462 | |
463 | 463 | break; |
464 | 464 | |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | /** |
470 | 470 | * Filters post states. |
471 | 471 | */ |
472 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
472 | + public static function filter_payment_form_state($post_states, $post) { |
|
473 | 473 | |
474 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
475 | - $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
474 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
475 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | return $post_states; |
@@ -482,35 +482,35 @@ discard block |
||
482 | 482 | /** |
483 | 483 | * Returns an array of coupon table columns. |
484 | 484 | */ |
485 | - public static function discount_columns( $columns ) { |
|
485 | + public static function discount_columns($columns) { |
|
486 | 486 | |
487 | 487 | $columns = array( |
488 | 488 | 'cb' => $columns['cb'], |
489 | - 'title' => __( 'Name', 'invoicing' ), |
|
490 | - 'code' => __( 'Code', 'invoicing' ), |
|
491 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
492 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
493 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
494 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
489 | + 'title' => __('Name', 'invoicing'), |
|
490 | + 'code' => __('Code', 'invoicing'), |
|
491 | + 'amount' => __('Amount', 'invoicing'), |
|
492 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
493 | + 'start_date' => __('Start Date', 'invoicing'), |
|
494 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
495 | 495 | ); |
496 | 496 | |
497 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
497 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |
501 | 501 | * Filters post states. |
502 | 502 | */ |
503 | - public static function filter_discount_state( $post_states, $post ) { |
|
503 | + public static function filter_discount_state($post_states, $post) { |
|
504 | 504 | |
505 | - if ( 'wpi_discount' == $post->post_type ) { |
|
505 | + if ('wpi_discount' == $post->post_type) { |
|
506 | 506 | |
507 | - $discount = new WPInv_Discount( $post ); |
|
507 | + $discount = new WPInv_Discount($post); |
|
508 | 508 | |
509 | 509 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
510 | 510 | |
511 | - if ( $status != 'publish' ) { |
|
511 | + if ($status != 'publish') { |
|
512 | 512 | return array( |
513 | - 'discount_status' => wpinv_discount_status( $status ), |
|
513 | + 'discount_status' => wpinv_discount_status($status), |
|
514 | 514 | ); |
515 | 515 | } |
516 | 516 | |
@@ -525,30 +525,30 @@ discard block |
||
525 | 525 | /** |
526 | 526 | * Returns an array of items table columns. |
527 | 527 | */ |
528 | - public static function item_columns( $columns ) { |
|
528 | + public static function item_columns($columns) { |
|
529 | 529 | |
530 | 530 | $columns = array( |
531 | 531 | 'cb' => $columns['cb'], |
532 | - 'title' => __( 'Name', 'invoicing' ), |
|
533 | - 'price' => __( 'Price', 'invoicing' ), |
|
534 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
535 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
536 | - 'type' => __( 'Type', 'invoicing' ), |
|
537 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
532 | + 'title' => __('Name', 'invoicing'), |
|
533 | + 'price' => __('Price', 'invoicing'), |
|
534 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
535 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
536 | + 'type' => __('Type', 'invoicing'), |
|
537 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
538 | 538 | ); |
539 | 539 | |
540 | - if ( ! wpinv_use_taxes() ) { |
|
541 | - unset( $columns['vat_rule'] ); |
|
542 | - unset( $columns['vat_class'] ); |
|
540 | + if (!wpinv_use_taxes()) { |
|
541 | + unset($columns['vat_rule']); |
|
542 | + unset($columns['vat_class']); |
|
543 | 543 | } |
544 | 544 | |
545 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
545 | + return apply_filters('wpi_item_table_columns', $columns); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
549 | 549 | * Returns an array of sortable items table columns. |
550 | 550 | */ |
551 | - public static function sortable_item_columns( $columns ) { |
|
551 | + public static function sortable_item_columns($columns) { |
|
552 | 552 | |
553 | 553 | return array_merge( |
554 | 554 | $columns, |
@@ -565,45 +565,45 @@ discard block |
||
565 | 565 | /** |
566 | 566 | * Displays items table columns. |
567 | 567 | */ |
568 | - public static function display_item_columns( $column_name, $post_id ) { |
|
568 | + public static function display_item_columns($column_name, $post_id) { |
|
569 | 569 | |
570 | - $item = new WPInv_Item( $post_id ); |
|
570 | + $item = new WPInv_Item($post_id); |
|
571 | 571 | |
572 | - switch ( $column_name ) { |
|
572 | + switch ($column_name) { |
|
573 | 573 | |
574 | 574 | case 'price': |
575 | - if ( ! $item->is_recurring() ) { |
|
576 | - echo wp_kses_post( $item->get_the_price() ); |
|
575 | + if (!$item->is_recurring()) { |
|
576 | + echo wp_kses_post($item->get_the_price()); |
|
577 | 577 | break; |
578 | 578 | } |
579 | 579 | |
580 | 580 | $price = wp_sprintf( |
581 | - __( '%1$s / %2$s', 'invoicing' ), |
|
581 | + __('%1$s / %2$s', 'invoicing'), |
|
582 | 582 | $item->get_the_price(), |
583 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
583 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
584 | 584 | ); |
585 | 585 | |
586 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
587 | - echo wp_kses_post( $price ); |
|
586 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
587 | + echo wp_kses_post($price); |
|
588 | 588 | break; |
589 | 589 | } |
590 | 590 | |
591 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
591 | + echo wp_kses_post($item->get_the_initial_price()); |
|
592 | 592 | |
593 | - echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
593 | + echo '<span class="meta">' . wp_sprintf(esc_html__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>'; |
|
594 | 594 | break; |
595 | 595 | |
596 | 596 | case 'vat_rule': |
597 | - echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) ); |
|
597 | + echo wp_kses_post(getpaid_get_tax_rule_label($item->get_vat_rule())); |
|
598 | 598 | break; |
599 | 599 | |
600 | 600 | case 'vat_class': |
601 | - echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) ); |
|
601 | + echo wp_kses_post(getpaid_get_tax_class_label($item->get_vat_class())); |
|
602 | 602 | break; |
603 | 603 | |
604 | 604 | case 'shortcode': |
605 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
606 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
605 | + if ($item->is_type(array('', 'fee', 'custom'))) { |
|
606 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
607 | 607 | } else { |
608 | 608 | echo '—'; |
609 | 609 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'type': |
614 | - echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' ); |
|
614 | + echo wp_kses_post(wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'); |
|
615 | 615 | break; |
616 | 616 | |
617 | 617 | } |
@@ -621,21 +621,21 @@ discard block |
||
621 | 621 | /** |
622 | 622 | * Lets users filter items using taxes. |
623 | 623 | */ |
624 | - public static function add_item_filters( $post_type ) { |
|
624 | + public static function add_item_filters($post_type) { |
|
625 | 625 | |
626 | 626 | // Abort if we're not dealing with items. |
627 | - if ( $post_type != 'wpi_item' ) { |
|
627 | + if ($post_type != 'wpi_item') { |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // Filter by vat rules. |
632 | - if ( wpinv_use_taxes() ) { |
|
632 | + if (wpinv_use_taxes()) { |
|
633 | 633 | |
634 | 634 | // Sanitize selected vat rule. |
635 | 635 | $vat_rule = ''; |
636 | 636 | $vat_rules = getpaid_get_tax_rules(); |
637 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
638 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); |
|
637 | + if (isset($_GET['vat_rule'])) { |
|
638 | + $vat_rule = sanitize_text_field($_GET['vat_rule']); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | // Filter by VAT rule. |
@@ -643,13 +643,13 @@ discard block |
||
643 | 643 | array( |
644 | 644 | 'options' => array_merge( |
645 | 645 | array( |
646 | - '' => __( 'All VAT rules', 'invoicing' ), |
|
646 | + '' => __('All VAT rules', 'invoicing'), |
|
647 | 647 | ), |
648 | 648 | $vat_rules |
649 | 649 | ), |
650 | 650 | 'name' => 'vat_rule', |
651 | 651 | 'id' => 'vat_rule', |
652 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
652 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
653 | 653 | 'show_option_all' => false, |
654 | 654 | 'show_option_none' => false, |
655 | 655 | ) |
@@ -660,21 +660,21 @@ discard block |
||
660 | 660 | // Sanitize selected vat rule. |
661 | 661 | $vat_class = ''; |
662 | 662 | $vat_classes = getpaid_get_tax_classes(); |
663 | - if ( isset( $_GET['vat_class'] ) ) { |
|
664 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); |
|
663 | + if (isset($_GET['vat_class'])) { |
|
664 | + $vat_class = sanitize_text_field($_GET['vat_class']); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | echo wpinv_html_select( |
668 | 668 | array( |
669 | 669 | 'options' => array_merge( |
670 | 670 | array( |
671 | - '' => __( 'All VAT classes', 'invoicing' ), |
|
671 | + '' => __('All VAT classes', 'invoicing'), |
|
672 | 672 | ), |
673 | 673 | $vat_classes |
674 | 674 | ), |
675 | 675 | 'name' => 'vat_class', |
676 | 676 | 'id' => 'vat_class', |
677 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
677 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
678 | 678 | 'show_option_all' => false, |
679 | 679 | 'show_option_none' => false, |
680 | 680 | ) |
@@ -683,22 +683,22 @@ discard block |
||
683 | 683 | } |
684 | 684 | |
685 | 685 | // Filter by item type. |
686 | - $type = ''; |
|
687 | - if ( isset( $_GET['type'] ) ) { |
|
688 | - $type = sanitize_text_field( $_GET['type'] ); |
|
686 | + $type = ''; |
|
687 | + if (isset($_GET['type'])) { |
|
688 | + $type = sanitize_text_field($_GET['type']); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | echo wpinv_html_select( |
692 | 692 | array( |
693 | 693 | 'options' => array_merge( |
694 | 694 | array( |
695 | - '' => __( 'All item types', 'invoicing' ), |
|
695 | + '' => __('All item types', 'invoicing'), |
|
696 | 696 | ), |
697 | 697 | wpinv_get_item_types() |
698 | 698 | ), |
699 | 699 | 'name' => 'type', |
700 | 700 | 'id' => 'type', |
701 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
701 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
702 | 702 | 'show_option_all' => false, |
703 | 703 | 'show_option_none' => false, |
704 | 704 | ) |
@@ -709,45 +709,45 @@ discard block |
||
709 | 709 | /** |
710 | 710 | * Filters the item query. |
711 | 711 | */ |
712 | - public static function filter_item_query( $query ) { |
|
712 | + public static function filter_item_query($query) { |
|
713 | 713 | |
714 | 714 | // modify the query only if it admin and main query. |
715 | - if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
715 | + if (!(is_admin() && $query->is_main_query())) { |
|
716 | 716 | return $query; |
717 | 717 | } |
718 | 718 | |
719 | 719 | // we want to modify the query for our items. |
720 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) { |
|
720 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
721 | 721 | return $query; |
722 | 722 | } |
723 | 723 | |
724 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
724 | + if (empty($query->query_vars['meta_query'])) { |
|
725 | 725 | $query->query_vars['meta_query'] = array(); |
726 | 726 | } |
727 | 727 | |
728 | 728 | // Filter vat rule type |
729 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
729 | + if (!empty($_GET['vat_rule'])) { |
|
730 | 730 | $query->query_vars['meta_query'][] = array( |
731 | 731 | 'key' => '_wpinv_vat_rule', |
732 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
732 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
733 | 733 | 'compare' => '=', |
734 | 734 | ); |
735 | 735 | } |
736 | 736 | |
737 | 737 | // Filter vat class |
738 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
738 | + if (!empty($_GET['vat_class'])) { |
|
739 | 739 | $query->query_vars['meta_query'][] = array( |
740 | 740 | 'key' => '_wpinv_vat_class', |
741 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
741 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
742 | 742 | 'compare' => '=', |
743 | 743 | ); |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Filter item type |
747 | - if ( ! empty( $_GET['type'] ) ) { |
|
747 | + if (!empty($_GET['type'])) { |
|
748 | 748 | $query->query_vars['meta_query'][] = array( |
749 | 749 | 'key' => '_wpinv_type', |
750 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
750 | + 'value' => sanitize_text_field($_GET['type']), |
|
751 | 751 | 'compare' => '=', |
752 | 752 | ); |
753 | 753 | } |
@@ -757,15 +757,15 @@ discard block |
||
757 | 757 | /** |
758 | 758 | * Reorders items. |
759 | 759 | */ |
760 | - public static function reorder_items( $vars ) { |
|
760 | + public static function reorder_items($vars) { |
|
761 | 761 | global $typenow; |
762 | 762 | |
763 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
763 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
764 | 764 | return $vars; |
765 | 765 | } |
766 | 766 | |
767 | 767 | // By item type. |
768 | - if ( 'type' == $vars['orderby'] ) { |
|
768 | + if ('type' == $vars['orderby']) { |
|
769 | 769 | return array_merge( |
770 | 770 | $vars, |
771 | 771 | array( |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | } |
777 | 777 | |
778 | 778 | // By vat class. |
779 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
779 | + if ('vat_class' == $vars['orderby']) { |
|
780 | 780 | return array_merge( |
781 | 781 | $vars, |
782 | 782 | array( |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | } |
788 | 788 | |
789 | 789 | // By vat rule. |
790 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
790 | + if ('vat_rule' == $vars['orderby']) { |
|
791 | 791 | return array_merge( |
792 | 792 | $vars, |
793 | 793 | array( |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | } |
799 | 799 | |
800 | 800 | // By price. |
801 | - if ( 'price' == $vars['orderby'] ) { |
|
801 | + if ('price' == $vars['orderby']) { |
|
802 | 802 | return array_merge( |
803 | 803 | $vars, |
804 | 804 | array( |
@@ -815,27 +815,27 @@ discard block |
||
815 | 815 | /** |
816 | 816 | * Fired when deleting a post. |
817 | 817 | */ |
818 | - public static function delete_post( $post_id ) { |
|
818 | + public static function delete_post($post_id) { |
|
819 | 819 | |
820 | - switch ( get_post_type( $post_id ) ) { |
|
820 | + switch (get_post_type($post_id)) { |
|
821 | 821 | |
822 | 822 | case 'wpi_item': |
823 | - do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
823 | + do_action('getpaid_before_delete_item', new WPInv_Item($post_id)); |
|
824 | 824 | break; |
825 | 825 | |
826 | 826 | case 'wpi_payment_form': |
827 | - do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
827 | + do_action('getpaid_before_delete_payment_form', new GetPaid_Payment_Form($post_id)); |
|
828 | 828 | break; |
829 | 829 | |
830 | 830 | case 'wpi_discount': |
831 | - do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
831 | + do_action('getpaid_before_delete_discount', new WPInv_Discount($post_id)); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'wpi_invoice': |
835 | - $invoice = new WPInv_Invoice( $post_id ); |
|
836 | - do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
837 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
838 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
835 | + $invoice = new WPInv_Invoice($post_id); |
|
836 | + do_action('getpaid_before_delete_invoice', $invoice); |
|
837 | + $invoice->get_data_store()->delete_items($invoice); |
|
838 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
839 | 839 | break; |
840 | 840 | } |
841 | 841 | } |
@@ -848,28 +848,28 @@ discard block |
||
848 | 848 | * |
849 | 849 | * @return mixed |
850 | 850 | */ |
851 | - public static function add_display_post_states( $post_states, $post ) { |
|
851 | + public static function add_display_post_states($post_states, $post) { |
|
852 | 852 | |
853 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
854 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
853 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
854 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
855 | 855 | } |
856 | 856 | |
857 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
857 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
858 | 858 | |
859 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
860 | - $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
861 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
859 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
860 | + $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
861 | + __('GetPaid %s History Page', 'invoicing'), |
|
862 | 862 | $label |
863 | 863 | ); |
864 | 864 | } |
865 | 865 | } |
866 | 866 | |
867 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
868 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
867 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
868 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
869 | 869 | } |
870 | 870 | |
871 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
872 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
871 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
872 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | return $post_states; |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
28 | - $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
29 | - $customer = new WP_User( $customer ); |
|
30 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
31 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | + $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id(); |
|
29 | + $customer = new WP_User($customer); |
|
30 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email); |
|
31 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
32 | 32 | |
33 | 33 | ?> |
34 | 34 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | <div class="col-12 col-sm-6"> |
44 | 44 | <div id="getpaid-invoice-user-id-wrapper" class="form-group"> |
45 | 45 | <div> |
46 | - <label for="post_author_override"><?php esc_html_e( 'Customer', 'invoicing' );?></label> |
|
46 | + <label for="post_author_override"><?php esc_html_e('Customer', 'invoicing'); ?></label> |
|
47 | 47 | </div> |
48 | 48 | <div> |
49 | - <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>"> |
|
50 | - <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>) |
|
49 | + <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>"> |
|
50 | + <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>) |
|
51 | 51 | </select> |
52 | 52 | </div> |
53 | 53 | </div> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'type' => 'text', |
61 | 61 | 'id' => 'getpaid-invoice-new-user-email', |
62 | 62 | 'name' => 'wpinv_email', |
63 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
63 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
64 | 64 | 'label_type' => 'vertical', |
65 | 65 | 'placeholder' => '[email protected]', |
66 | 66 | 'class' => 'form-control-sm', |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | <div class="col-12 col-sm-6 form-group mt-sm-4"> |
74 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
74 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
75 | 75 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
76 | 76 | <i aria-hidden="true" class="fa fa-refresh"></i> |
77 | - <?php esc_html_e( 'Fill User Details', 'invoicing' );?> |
|
77 | + <?php esc_html_e('Fill User Details', 'invoicing'); ?> |
|
78 | 78 | </a> |
79 | 79 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
80 | 80 | <i aria-hidden="true" class="fa fa-plus"></i> |
81 | - <?php esc_html_e( 'Add New User', 'invoicing' );?> |
|
81 | + <?php esc_html_e('Add New User', 'invoicing'); ?> |
|
82 | 82 | </a> |
83 | 83 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
84 | 84 | <i aria-hidden="true" class="fa fa-close"></i> |
85 | - <?php esc_html_e( 'Cancel', 'invoicing' );?> |
|
85 | + <?php esc_html_e('Cancel', 'invoicing'); ?> |
|
86 | 86 | </a> |
87 | 87 | <?php endif; ?> |
88 | 88 | </div> |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | 'type' => 'text', |
96 | 96 | 'id' => 'wpinv_first_name', |
97 | 97 | 'name' => 'wpinv_first_name', |
98 | - 'label' => __( 'First Name', 'invoicing' ), |
|
98 | + 'label' => __('First Name', 'invoicing'), |
|
99 | 99 | 'label_type' => 'vertical', |
100 | 100 | 'placeholder' => '', |
101 | 101 | 'class' => 'form-control-sm', |
102 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
102 | + 'value' => $invoice->get_first_name('edit'), |
|
103 | 103 | ), |
104 | 104 | true |
105 | 105 | ); |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | 'type' => 'text', |
113 | 113 | 'id' => 'wpinv_last_name', |
114 | 114 | 'name' => 'wpinv_last_name', |
115 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
115 | + 'label' => __('Last Name', 'invoicing'), |
|
116 | 116 | 'label_type' => 'vertical', |
117 | 117 | 'placeholder' => '', |
118 | 118 | 'class' => 'form-control-sm', |
119 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
119 | + 'value' => $invoice->get_last_name('edit'), |
|
120 | 120 | ), |
121 | 121 | true |
122 | 122 | ); |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | 'type' => 'text', |
133 | 133 | 'id' => 'wpinv_company', |
134 | 134 | 'name' => 'wpinv_company', |
135 | - 'label' => __( 'Company', 'invoicing' ), |
|
135 | + 'label' => __('Company', 'invoicing'), |
|
136 | 136 | 'label_type' => 'vertical', |
137 | 137 | 'placeholder' => '', |
138 | 138 | 'class' => 'form-control-sm', |
139 | - 'value' => $invoice->get_company( 'edit' ), |
|
139 | + 'value' => $invoice->get_company('edit'), |
|
140 | 140 | ), |
141 | 141 | true |
142 | 142 | ); |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | 'type' => 'text', |
150 | 150 | 'id' => 'wpinv_vat_number', |
151 | 151 | 'name' => 'wpinv_vat_number', |
152 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
152 | + 'label' => __('Vat Number', 'invoicing'), |
|
153 | 153 | 'label_type' => 'vertical', |
154 | 154 | 'placeholder' => '', |
155 | 155 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
156 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
156 | + 'value' => $invoice->get_vat_number('edit'), |
|
157 | 157 | ), |
158 | 158 | true |
159 | 159 | ); |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | 'type' => 'text', |
170 | 170 | 'id' => 'wpinv_address', |
171 | 171 | 'name' => 'wpinv_address', |
172 | - 'label' => __( 'Address', 'invoicing' ), |
|
172 | + 'label' => __('Address', 'invoicing'), |
|
173 | 173 | 'label_type' => 'vertical', |
174 | 174 | 'placeholder' => '', |
175 | 175 | 'class' => 'form-control-sm', |
176 | - 'value' => $invoice->get_address( 'edit' ), |
|
176 | + 'value' => $invoice->get_address('edit'), |
|
177 | 177 | ), |
178 | 178 | true |
179 | 179 | ); |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | 'type' => 'text', |
187 | 187 | 'id' => 'wpinv_city', |
188 | 188 | 'name' => 'wpinv_city', |
189 | - 'label' => __( 'City', 'invoicing' ), |
|
189 | + 'label' => __('City', 'invoicing'), |
|
190 | 190 | 'label_type' => 'vertical', |
191 | 191 | 'placeholder' => '', |
192 | 192 | 'class' => 'form-control-sm', |
193 | - 'value' => $invoice->get_city( 'edit' ), |
|
193 | + 'value' => $invoice->get_city('edit'), |
|
194 | 194 | ), |
195 | 195 | true |
196 | 196 | ); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | array( |
206 | 206 | 'id' => 'wpinv_country', |
207 | 207 | 'name' => 'wpinv_country', |
208 | - 'label' => __( 'Country', 'invoicing' ), |
|
208 | + 'label' => __('Country', 'invoicing'), |
|
209 | 209 | 'label_type' => 'vertical', |
210 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
210 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
211 | 211 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
212 | - 'value' => $invoice->get_country( 'edit' ), |
|
212 | + 'value' => $invoice->get_country('edit'), |
|
213 | 213 | 'options' => wpinv_get_country_list(), |
214 | 214 | 'data-allow-clear' => 'false', |
215 | 215 | 'select2' => true, |
@@ -221,20 +221,20 @@ discard block |
||
221 | 221 | <div class="col-12 col-sm-6"> |
222 | 222 | <?php |
223 | 223 | |
224 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
224 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
225 | 225 | |
226 | - if ( empty( $states ) ) { |
|
226 | + if (empty($states)) { |
|
227 | 227 | |
228 | 228 | aui()->input( |
229 | 229 | array( |
230 | 230 | 'type' => 'text', |
231 | 231 | 'id' => 'wpinv_state', |
232 | 232 | 'name' => 'wpinv_state', |
233 | - 'label' => __( 'State', 'invoicing' ), |
|
233 | + 'label' => __('State', 'invoicing'), |
|
234 | 234 | 'label_type' => 'vertical', |
235 | 235 | 'placeholder' => '', |
236 | 236 | 'class' => 'form-control-sm', |
237 | - 'value' => $invoice->get_state( 'edit' ), |
|
237 | + 'value' => $invoice->get_state('edit'), |
|
238 | 238 | ), |
239 | 239 | true |
240 | 240 | ); |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | array( |
246 | 246 | 'id' => 'wpinv_state', |
247 | 247 | 'name' => 'wpinv_state', |
248 | - 'label' => __( 'State', 'invoicing' ), |
|
248 | + 'label' => __('State', 'invoicing'), |
|
249 | 249 | 'label_type' => 'vertical', |
250 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
250 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
251 | 251 | 'class' => 'form-control-sm', |
252 | - 'value' => $invoice->get_state( 'edit' ), |
|
252 | + 'value' => $invoice->get_state('edit'), |
|
253 | 253 | 'options' => $states, |
254 | 254 | 'data-allow-clear' => 'false', |
255 | 255 | 'select2' => true, |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | 'type' => 'text', |
272 | 272 | 'id' => 'wpinv_zip', |
273 | 273 | 'name' => 'wpinv_zip', |
274 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
274 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
275 | 275 | 'label_type' => 'vertical', |
276 | 276 | 'placeholder' => '', |
277 | 277 | 'class' => 'form-control-sm', |
278 | - 'value' => $invoice->get_zip( 'edit' ), |
|
278 | + 'value' => $invoice->get_zip('edit'), |
|
279 | 279 | ), |
280 | 280 | true |
281 | 281 | ); |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | 'type' => 'text', |
289 | 289 | 'id' => 'wpinv_phone', |
290 | 290 | 'name' => 'wpinv_phone', |
291 | - 'label' => __( 'Phone', 'invoicing' ), |
|
291 | + 'label' => __('Phone', 'invoicing'), |
|
292 | 292 | 'label_type' => 'vertical', |
293 | 293 | 'placeholder' => '', |
294 | 294 | 'class' => 'form-control-sm', |
295 | - 'value' => $invoice->get_phone( 'edit' ), |
|
295 | + 'value' => $invoice->get_phone('edit'), |
|
296 | 296 | ), |
297 | 297 | true |
298 | 298 | ); |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | </div> |
301 | 301 | </div> |
302 | 302 | |
303 | - <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?> |
|
304 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
303 | + <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?> |
|
304 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
305 | 305 | |
306 | 306 | <div class="row"> |
307 | 307 | <div class="col-12 col-sm-6"> |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | array( |
311 | 311 | 'id' => 'wpinv_template', |
312 | 312 | 'name' => 'wpinv_template', |
313 | - 'label' => __( 'Template', 'invoicing' ), |
|
313 | + 'label' => __('Template', 'invoicing'), |
|
314 | 314 | 'label_type' => 'vertical', |
315 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
315 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
316 | 316 | 'class' => 'form-control-sm', |
317 | - 'value' => $invoice->get_template( 'edit' ), |
|
317 | + 'value' => $invoice->get_template('edit'), |
|
318 | 318 | 'options' => array( |
319 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
320 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
319 | + 'quantity' => __('Quantity', 'invoicing'), |
|
320 | + 'hours' => __('Hours', 'invoicing'), |
|
321 | 321 | //'amount' => __( 'Amount Only', 'invoicing' ), |
322 | 322 | ), |
323 | 323 | 'data-allow-clear' => 'false', |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | array( |
336 | 336 | 'id' => 'wpinv_currency', |
337 | 337 | 'name' => 'wpinv_currency', |
338 | - 'label' => __( 'Currency', 'invoicing' ), |
|
338 | + 'label' => __('Currency', 'invoicing'), |
|
339 | 339 | 'label_type' => 'vertical', |
340 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
340 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
341 | 341 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
342 | - 'value' => $invoice->get_currency( 'edit' ), |
|
342 | + 'value' => $invoice->get_currency('edit'), |
|
343 | 343 | 'required' => false, |
344 | 344 | 'data-allow-clear' => 'false', |
345 | 345 | 'select2' => true, |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | </div> |
353 | 353 | </div> |
354 | 354 | |
355 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
355 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
356 | 356 | <?php endif; ?> |
357 | 357 | |
358 | 358 | <div class="row"> |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | 'type' => 'text', |
364 | 364 | 'id' => 'wpinv_company_id', |
365 | 365 | 'name' => 'wpinv_company_id', |
366 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
366 | + 'label' => __('Company ID', 'invoicing'), |
|
367 | 367 | 'label_type' => 'vertical', |
368 | 368 | 'placeholder' => '', |
369 | 369 | 'class' => 'form-control-sm', |
370 | - 'value' => $invoice->get_company_id( 'edit' ), |
|
370 | + 'value' => $invoice->get_company_id('edit'), |
|
371 | 371 | ), |
372 | 372 | true |
373 | 373 | ); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | </div> |
376 | 376 | </div> |
377 | 377 | |
378 | - <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?> |
|
378 | + <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?> |
|
379 | 379 | </div> |
380 | 380 | <?php |
381 | 381 | } |
@@ -385,51 +385,51 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @param int $post_id |
387 | 387 | */ |
388 | - public static function save( $post_id ) { |
|
388 | + public static function save($post_id) { |
|
389 | 389 | |
390 | 390 | // Prepare the invoice. |
391 | - $invoice = new WPInv_Invoice( $post_id ); |
|
391 | + $invoice = new WPInv_Invoice($post_id); |
|
392 | 392 | |
393 | 393 | // Load new data. |
394 | 394 | $invoice->set_props( |
395 | 395 | array( |
396 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
397 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
398 | - 'disable_taxes' => ! empty( $_POST['disable_taxes'] ), |
|
399 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
400 | - 'gateway' => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
401 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
402 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
403 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
404 | - 'company_id' => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null, |
|
405 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
406 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
407 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
408 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
409 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
410 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
411 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
412 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
413 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
414 | - 'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null, |
|
415 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
416 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
417 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
396 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
397 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
398 | + 'disable_taxes' => !empty($_POST['disable_taxes']), |
|
399 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
400 | + 'gateway' => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
401 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
402 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
403 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
404 | + 'company_id' => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null, |
|
405 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
406 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
407 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
408 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
409 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
410 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
411 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
412 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
413 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
414 | + 'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null, |
|
415 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
416 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
417 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
418 | 418 | ) |
419 | 419 | ); |
420 | 420 | |
421 | 421 | // Discount code. |
422 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
422 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
423 | 423 | |
424 | - if ( isset( $_POST['wpinv_discount_code'] ) ) { |
|
425 | - $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) ); |
|
424 | + if (isset($_POST['wpinv_discount_code'])) { |
|
425 | + $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code'])); |
|
426 | 426 | } |
427 | 427 | |
428 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
429 | - if ( $discount->exists() ) { |
|
430 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
428 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
429 | + if ($discount->exists()) { |
|
430 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
431 | 431 | } else { |
432 | - $invoice->remove_discount( 'discount_code' ); |
|
432 | + $invoice->remove_discount('discount_code'); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | // Recalculate totals. |
@@ -438,17 +438,17 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | // If we're creating a new user... |
441 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) { |
|
441 | + if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) { |
|
442 | 442 | |
443 | 443 | // Attempt to create the user. |
444 | - $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) ); |
|
444 | + $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email']))); |
|
445 | 445 | |
446 | 446 | |
447 | 447 | // If successful, update the invoice author. |
448 | - if ( is_numeric( $user ) ) { |
|
449 | - $invoice->set_author( $user ); |
|
448 | + if (is_numeric($user)) { |
|
449 | + $invoice->set_author($user); |
|
450 | 450 | } else { |
451 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
451 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
@@ -462,16 +462,16 @@ discard block |
||
462 | 462 | $GLOBALS['wpinv_skip_invoice_notification'] = false; |
463 | 463 | |
464 | 464 | // (Maybe) send new user notification. |
465 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
466 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
467 | - wp_send_new_user_notifications( $user, 'user' ); |
|
465 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
466 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) { |
|
467 | + wp_send_new_user_notifications($user, 'user'); |
|
468 | 468 | } |
469 | 469 | |
470 | - if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
471 | - getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
470 | + if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) { |
|
471 | + getpaid()->get('invoice_emails')->user_invoice($invoice, true); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | // Fires after an invoice is saved. |
475 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
475 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
476 | 476 | } |
477 | 477 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ; |
|
30 | + wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | ?> |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | |
47 | 47 | <div class="bsui" style="margin-top: 1.5rem"> |
48 | 48 | |
49 | - <?php do_action( 'getpaid_invoice_edit_before_viewed_by_customer', $invoice ); ?> |
|
50 | - <?php if ( ! $invoice->is_draft() ) : ?> |
|
49 | + <?php do_action('getpaid_invoice_edit_before_viewed_by_customer', $invoice); ?> |
|
50 | + <?php if (!$invoice->is_draft()) : ?> |
|
51 | 51 | <div class="form-group"> |
52 | - <strong><?php esc_html_e( 'Viewed by Customer:', 'invoicing' );?></strong> |
|
53 | - <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?> |
|
52 | + <strong><?php esc_html_e('Viewed by Customer:', 'invoicing'); ?></strong> |
|
53 | + <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?> |
|
54 | 54 | </div> |
55 | 55 | <?php endif; ?> |
56 | 56 | |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | |
59 | 59 | // Date created. |
60 | 60 | $label = sprintf( |
61 | - __( '%s Date:', 'invoicing' ), |
|
62 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
61 | + __('%s Date:', 'invoicing'), |
|
62 | + ucfirst($invoice->get_invoice_quote_type()) |
|
63 | 63 | ); |
64 | 64 | |
65 | - $info = sprintf( |
|
66 | - __( 'The date this %s was created.', 'invoicing' ), |
|
67 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
65 | + $info = sprintf( |
|
66 | + __('The date this %s was created.', 'invoicing'), |
|
67 | + strtolower($invoice->get_invoice_quote_type()) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | aui()->input( |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | 'type' => 'datepicker', |
73 | 73 | 'id' => 'wpinv_date_created', |
74 | 74 | 'name' => 'date_created', |
75 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
75 | + 'label' => $label . getpaid_get_help_tip($info), |
|
76 | 76 | 'label_type' => 'vertical', |
77 | 77 | 'placeholder' => 'YYYY-MM-DD 00:00', |
78 | 78 | 'class' => 'form-control-sm', |
79 | - 'value' => $invoice->get_date_created( 'edit' ), |
|
79 | + 'value' => $invoice->get_date_created('edit'), |
|
80 | 80 | 'extra_attributes' => array( |
81 | 81 | 'data-enable-time' => 'true', |
82 | 82 | 'data-time_24hr' => 'true', |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | ); |
89 | 89 | |
90 | 90 | // Date paid. |
91 | - $date_paid = $invoice->get_date_completed( 'edit' ); |
|
92 | - if ( ! empty( $date_paid ) && $invoice->is_paid() ) { |
|
91 | + $date_paid = $invoice->get_date_completed('edit'); |
|
92 | + if (!empty($date_paid) && $invoice->is_paid()) { |
|
93 | 93 | |
94 | 94 | aui()->input( |
95 | 95 | array( |
96 | 96 | 'type' => 'text', |
97 | 97 | 'id' => 'wpinv_date_completed', |
98 | 98 | 'name' => 'wpinv_date_completed', |
99 | - 'label' => __( 'Date Completed:', 'invoicing' ), |
|
99 | + 'label' => __('Date Completed:', 'invoicing'), |
|
100 | 100 | 'label_type' => 'vertical', |
101 | 101 | 'class' => 'form-control-sm', |
102 | 102 | 'value' => $date_paid, |
@@ -107,18 +107,18 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | // Due date. |
110 | - if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( ! $invoice->is_paid() || $invoice->is_draft() ) ) { |
|
110 | + if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && (!$invoice->is_paid() || $invoice->is_draft())) { |
|
111 | 111 | |
112 | 112 | aui()->input( |
113 | 113 | array( |
114 | 114 | 'type' => 'datepicker', |
115 | 115 | 'id' => 'wpinv_due_date', |
116 | 116 | 'name' => 'wpinv_due_date', |
117 | - 'label' => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ), |
|
117 | + 'label' => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')), |
|
118 | 118 | 'label_type' => 'vertical', |
119 | - 'placeholder' => __( 'No due date', 'invoicing' ), |
|
119 | + 'placeholder' => __('No due date', 'invoicing'), |
|
120 | 120 | 'class' => 'form-control-sm', |
121 | - 'value' => $invoice->get_due_date( 'edit' ), |
|
121 | + 'value' => $invoice->get_due_date('edit'), |
|
122 | 122 | 'extra_attributes' => array( |
123 | 123 | 'data-enable-time' => 'true', |
124 | 124 | 'data-time_24hr' => 'true', |
@@ -131,40 +131,40 @@ discard block |
||
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | - do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() ); |
|
135 | - do_action( 'getpaid_metabox_after_due_date', $invoice ); |
|
134 | + do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id()); |
|
135 | + do_action('getpaid_metabox_after_due_date', $invoice); |
|
136 | 136 | |
137 | 137 | // Status. |
138 | 138 | $label = sprintf( |
139 | - __( '%s Status:', 'invoicing' ), |
|
140 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
139 | + __('%s Status:', 'invoicing'), |
|
140 | + ucfirst($invoice->get_invoice_quote_type()) |
|
141 | 141 | ); |
142 | 142 | |
143 | - $status = $invoice->get_status( 'edit' ); |
|
143 | + $status = $invoice->get_status('edit'); |
|
144 | 144 | aui()->select( |
145 | 145 | array( |
146 | 146 | 'id' => 'wpinv_status', |
147 | 147 | 'name' => 'wpinv_status', |
148 | 148 | 'label' => $label, |
149 | 149 | 'label_type' => 'vertical', |
150 | - 'placeholder' => __( 'Select Status', 'invoicing' ), |
|
151 | - 'value' => array_key_exists( $status, $invoice->get_all_statuses() ) ? $status : $invoice->get_default_status(), |
|
150 | + 'placeholder' => __('Select Status', 'invoicing'), |
|
151 | + 'value' => array_key_exists($status, $invoice->get_all_statuses()) ? $status : $invoice->get_default_status(), |
|
152 | 152 | 'select2' => true, |
153 | 153 | 'data-allow-clear' => 'false', |
154 | - 'options' => wpinv_get_invoice_statuses( true, false, $invoice ) |
|
154 | + 'options' => wpinv_get_invoice_statuses(true, false, $invoice) |
|
155 | 155 | ), |
156 | 156 | true |
157 | 157 | ); |
158 | 158 | |
159 | 159 | // Invoice number. |
160 | 160 | $label = sprintf( |
161 | - __( '%s Number:', 'invoicing' ), |
|
162 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
161 | + __('%s Number:', 'invoicing'), |
|
162 | + ucfirst($invoice->get_invoice_quote_type()) |
|
163 | 163 | ); |
164 | 164 | |
165 | - $info = sprintf( |
|
166 | - __( 'Each %s number must be unique.', 'invoicing' ), |
|
167 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
165 | + $info = sprintf( |
|
166 | + __('Each %s number must be unique.', 'invoicing'), |
|
167 | + strtolower($invoice->get_invoice_quote_type()) |
|
168 | 168 | ); |
169 | 169 | |
170 | 170 | aui()->input( |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | 'type' => 'text', |
173 | 173 | 'id' => 'wpinv_number', |
174 | 174 | 'name' => 'wpinv_number', |
175 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
175 | + 'label' => $label . getpaid_get_help_tip($info), |
|
176 | 176 | 'label_type' => 'vertical', |
177 | - 'placeholder' => __( 'Autogenerate', 'invoicing' ), |
|
177 | + 'placeholder' => __('Autogenerate', 'invoicing'), |
|
178 | 178 | 'class' => 'form-control-sm', |
179 | - 'value' => $invoice->get_number( 'edit' ), |
|
179 | + 'value' => $invoice->get_number('edit'), |
|
180 | 180 | ), |
181 | 181 | true |
182 | 182 | ); |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | 'type' => 'text', |
188 | 188 | 'id' => 'wpinv_cc', |
189 | 189 | 'name' => 'wpinv_cc', |
190 | - 'label' => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ), |
|
190 | + 'label' => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')), |
|
191 | 191 | 'label_type' => 'vertical', |
192 | - 'placeholder' => __( '[email protected], [email protected]', 'invoicing' ), |
|
192 | + 'placeholder' => __('[email protected], [email protected]', 'invoicing'), |
|
193 | 193 | 'class' => 'form-control-sm', |
194 | - 'value' => $invoice->get_email_cc( 'edit' ), |
|
194 | + 'value' => $invoice->get_email_cc('edit'), |
|
195 | 195 | ), |
196 | 196 | true |
197 | 197 | ); |
198 | 198 | |
199 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
199 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
200 | 200 | |
201 | 201 | // Apply a discount. |
202 | 202 | aui()->input( |
@@ -204,26 +204,26 @@ discard block |
||
204 | 204 | 'type' => 'text', |
205 | 205 | 'id' => 'wpinv_discount_code', |
206 | 206 | 'name' => 'wpinv_discount_code', |
207 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
208 | - 'placeholder' => __( 'Apply Discount', 'invoicing' ), |
|
207 | + 'label' => __('Discount Code:', 'invoicing'), |
|
208 | + 'placeholder' => __('Apply Discount', 'invoicing'), |
|
209 | 209 | 'label_type' => 'vertical', |
210 | 210 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
211 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
211 | + 'value' => $invoice->get_discount_code('edit'), |
|
212 | 212 | ), |
213 | 213 | true |
214 | 214 | ); |
215 | 215 | |
216 | - } else if ( $invoice->get_discount_code( 'edit' ) ) { |
|
216 | + } else if ($invoice->get_discount_code('edit')) { |
|
217 | 217 | |
218 | 218 | aui()->input( |
219 | 219 | array( |
220 | 220 | 'type' => 'text', |
221 | 221 | 'id' => 'wpinv_discount_code', |
222 | 222 | 'name' => 'wpinv_discount_code', |
223 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
223 | + 'label' => __('Discount Code:', 'invoicing'), |
|
224 | 224 | 'label_type' => 'vertical', |
225 | 225 | 'class' => 'form-control-sm', |
226 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
226 | + 'value' => $invoice->get_discount_code('edit'), |
|
227 | 227 | 'extra_attributes' => array( |
228 | 228 | 'onclick' => 'this.select();', |
229 | 229 | 'readonly' => 'true', |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | |
235 | 235 | } |
236 | 236 | |
237 | - do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() ); |
|
237 | + do_action('wpinv_meta_box_details_inner', $invoice->get_id()); |
|
238 | 238 | |
239 | 239 | // Disable taxes. |
240 | - if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { |
|
240 | + if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) { |
|
241 | 241 | |
242 | 242 | aui()->input( |
243 | 243 | array( |
244 | 244 | 'id' => 'wpinv_taxable', |
245 | 245 | 'name' => 'disable_taxes', |
246 | 246 | 'type' => 'checkbox', |
247 | - 'label' => __( 'Disable taxes', 'invoicing' ), |
|
247 | + 'label' => __('Disable taxes', 'invoicing'), |
|
248 | 248 | 'value' => '1', |
249 | 249 | 'checked' => (bool) $invoice->get_disable_taxes(), |
250 | 250 | 'class' => 'getpaid-recalculate-prices-on-change', |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | |
255 | 255 | } |
256 | 256 | |
257 | - if ( $invoice->is_type( 'invoice' ) ) { |
|
257 | + if ($invoice->is_type('invoice')) { |
|
258 | 258 | |
259 | 259 | // Send to customer. |
260 | 260 | aui()->input( |
@@ -262,16 +262,16 @@ discard block |
||
262 | 262 | 'id' => 'wpinv_send_to_customer', |
263 | 263 | 'name' => 'send_to_customer', |
264 | 264 | 'type' => 'checkbox', |
265 | - 'label' => __( 'Send invoice to customer after saving', 'invoicing' ), |
|
265 | + 'label' => __('Send invoice to customer after saving', 'invoicing'), |
|
266 | 266 | 'value' => '1', |
267 | - 'checked' => $invoice->is_draft() && (bool) wpinv_get_option( 'email_user_invoice_active', true ), |
|
267 | + 'checked' => $invoice->is_draft() && (bool) wpinv_get_option('email_user_invoice_active', true), |
|
268 | 268 | ), |
269 | 269 | true |
270 | 270 | ); |
271 | 271 | |
272 | 272 | } |
273 | 273 | |
274 | - do_action( 'getpaid_metabox_after_invoice_details', $invoice ); |
|
274 | + do_action('getpaid_metabox_after_invoice_details', $invoice); |
|
275 | 275 | |
276 | 276 | ?> |
277 | 277 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
@@ -40,20 +40,20 @@ discard block |
||
40 | 40 | |
41 | 41 | <?php |
42 | 42 | |
43 | - if ( $invoice->is_draft() ) { |
|
43 | + if ($invoice->is_draft()) { |
|
44 | 44 | |
45 | 45 | // Set gateway. |
46 | 46 | aui()->select( |
47 | 47 | array( |
48 | 48 | 'id' => 'wpinv_gateway', |
49 | 49 | 'name' => 'wpinv_gateway', |
50 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
50 | + 'label' => __('Gateway:', 'invoicing'), |
|
51 | 51 | 'label_type' => 'vertical', |
52 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
52 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
53 | 53 | 'value' => wpinv_get_default_gateway(), |
54 | 54 | 'select2' => true, |
55 | 55 | 'data-allow-clear' => 'false', |
56 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
56 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
57 | 57 | ), |
58 | 58 | true |
59 | 59 | ); |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | 'id' => 'wpinv_key', |
67 | 67 | 'name' => 'wpinv_key', |
68 | 68 | 'label' => sprintf( |
69 | - __( '%s Key:', 'invoicing' ), |
|
70 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
69 | + __('%s Key:', 'invoicing'), |
|
70 | + ucfirst($invoice->get_invoice_quote_type()) |
|
71 | 71 | ), |
72 | 72 | 'label_type' => 'vertical', |
73 | 73 | 'class' => 'form-control-sm', |
74 | - 'value' => $invoice->get_key( 'edit' ), |
|
74 | + 'value' => $invoice->get_key('edit'), |
|
75 | 75 | 'extra_attributes' => array( |
76 | 76 | 'onclick' => 'this.select();', |
77 | 77 | 'readonly' => 'true', |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | 'id' => 'wpinv_view_url', |
88 | 88 | 'name' => 'wpinv_view_url', |
89 | 89 | 'label' => sprintf( |
90 | - __( '%s URL:', 'invoicing' ), |
|
91 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
92 | - ) . ' <a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
90 | + __('%s URL:', 'invoicing'), |
|
91 | + ucfirst($invoice->get_invoice_quote_type()) |
|
92 | + ) . ' <a href="' . esc_url_raw($invoice->get_view_url()) . '" title="' . __('View invoice', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>', |
|
93 | 93 | 'label_type' => 'vertical', |
94 | 94 | 'class' => 'form-control-sm', |
95 | 95 | 'value' => $invoice->get_view_url(), |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | ); |
103 | 103 | |
104 | 104 | // If the invoice is paid... |
105 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
105 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
106 | 106 | |
107 | 107 | // Gateway. |
108 | 108 | aui()->input( |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | 'type' => 'text', |
111 | 111 | 'id' => 'wpinv_gateway', |
112 | 112 | 'name' => '', |
113 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
113 | + 'label' => __('Gateway:', 'invoicing'), |
|
114 | 114 | 'label_type' => 'vertical', |
115 | 115 | 'class' => 'form-control-sm', |
116 | - 'value' => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ), |
|
116 | + 'value' => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')), |
|
117 | 117 | 'extra_attributes' => array( |
118 | 118 | 'onclick' => 'this.select();', |
119 | 119 | 'readonly' => 'true', |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | 'type' => 'text', |
130 | 130 | 'id' => 'wpinv_transaction_id', |
131 | 131 | 'name' => 'wpinv_transaction_id', |
132 | - 'label' => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? ' <a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ), |
|
132 | + 'label' => __('Transaction ID:', 'invoicing') . ($transaction_url ? ' <a href="' . esc_url($transaction_url) . '" title="' . __('View details', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : ''), |
|
133 | 133 | 'label_type' => 'vertical', |
134 | 134 | 'class' => 'form-control-sm', |
135 | - 'value' => $invoice->get_transaction_id( 'edit' ), |
|
136 | - 'help_text' => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ), |
|
135 | + 'value' => $invoice->get_transaction_id('edit'), |
|
136 | + 'help_text' => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice), |
|
137 | 137 | 'extra_attributes' => array( |
138 | 138 | 'onclick' => 'this.select();', |
139 | 139 | 'readonly' => 'true', |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | 'type' => 'text', |
149 | 149 | 'id' => 'wpinv_currency', |
150 | 150 | 'name' => 'wpinv_currency', |
151 | - 'label' => __( 'Currency:', 'invoicing' ), |
|
151 | + 'label' => __('Currency:', 'invoicing'), |
|
152 | 152 | 'label_type' => 'vertical', |
153 | 153 | 'class' => 'form-control-sm', |
154 | - 'value' => $invoice->get_currency( 'edit' ), |
|
154 | + 'value' => $invoice->get_currency('edit'), |
|
155 | 155 | 'extra_attributes' => array( |
156 | 156 | 'onclick' => 'this.select();', |
157 | 157 | 'readonly' => 'true', |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | } else { |
164 | 164 | |
165 | - if ( 'wpi_invoice' == $invoice->get_post_type() ) { |
|
165 | + if ('wpi_invoice' == $invoice->get_post_type()) { |
|
166 | 166 | |
167 | 167 | // Payment URL. |
168 | 168 | aui()->input( |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | 'type' => 'text', |
171 | 171 | 'id' => 'wpinv_payment_url', |
172 | 172 | 'name' => 'wpinv_payment_url', |
173 | - 'label' => __( 'Payment URL:', 'invoicing' ), |
|
173 | + 'label' => __('Payment URL:', 'invoicing'), |
|
174 | 174 | 'label_type' => 'vertical', |
175 | 175 | 'class' => 'form-control-sm', |
176 | 176 | 'value' => $invoice->get_checkout_payment_url(), |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | array( |
188 | 188 | 'id' => 'wpinv_gateway', |
189 | 189 | 'name' => 'wpinv_gateway', |
190 | - 'label' => __( 'Gateway:', 'invoicing' ), |
|
190 | + 'label' => __('Gateway:', 'invoicing'), |
|
191 | 191 | 'label_type' => 'vertical', |
192 | - 'placeholder' => __( 'Select Gateway', 'invoicing' ), |
|
193 | - 'value' => $invoice->get_gateway( 'edit' ), |
|
192 | + 'placeholder' => __('Select Gateway', 'invoicing'), |
|
193 | + 'value' => $invoice->get_gateway('edit'), |
|
194 | 194 | 'select2' => true, |
195 | 195 | 'data-allow-clear' => 'false', |
196 | - 'options' => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ), |
|
196 | + 'options' => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'), |
|
197 | 197 | ), |
198 | 198 | true |
199 | 199 | ); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,24 +21,24 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the discount. |
27 | - $discount = new WPInv_Discount( $post ); |
|
27 | + $discount = new WPInv_Discount($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
31 | 31 | |
32 | - do_action( 'wpinv_discount_form_top', $discount ); |
|
32 | + do_action('wpinv_discount_form_top', $discount); |
|
33 | 33 | |
34 | 34 | // Set the currency position. |
35 | 35 | $position = wpinv_currency_position(); |
36 | 36 | |
37 | - if ( $position == 'left_space' ) { |
|
37 | + if ($position == 'left_space') { |
|
38 | 38 | $position = 'left'; |
39 | 39 | } |
40 | 40 | |
41 | - if ( $position == 'right_space' ) { |
|
41 | + if ($position == 'right_space') { |
|
42 | 42 | $position = 'right'; |
43 | 43 | } |
44 | 44 | |
@@ -52,68 +52,68 @@ discard block |
||
52 | 52 | </style> |
53 | 53 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
54 | 54 | |
55 | - <?php do_action( 'wpinv_discount_form_first', $discount ); ?> |
|
55 | + <?php do_action('wpinv_discount_form_first', $discount); ?> |
|
56 | 56 | |
57 | - <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?> |
|
57 | + <?php do_action('wpinv_discount_form_before_code', $discount); ?> |
|
58 | 58 | <div class="form-group row"> |
59 | 59 | <label for="wpinv_discount_code" class="col-sm-3 col-form-label"> |
60 | - <?php esc_html_e( 'Discount Code', 'invoicing' ); ?> |
|
60 | + <?php esc_html_e('Discount Code', 'invoicing'); ?> |
|
61 | 61 | </label> |
62 | 62 | <div class="col-sm-8"> |
63 | 63 | <div class="row"> |
64 | 64 | <div class="col-sm-12 form-group"> |
65 | - <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> |
|
65 | + <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> |
|
66 | 66 | </div> |
67 | 67 | <div class="col-sm-12"> |
68 | 68 | <?php |
69 | - do_action( 'wpinv_discount_form_before_single_use', $discount ); |
|
69 | + do_action('wpinv_discount_form_before_single_use', $discount); |
|
70 | 70 | |
71 | 71 | aui()->input( |
72 | 72 | array( |
73 | 73 | 'id' => 'wpinv_discount_single_use', |
74 | 74 | 'name' => 'wpinv_discount_single_use', |
75 | 75 | 'type' => 'checkbox', |
76 | - 'label' => __( 'Each customer can only use this discount once', 'invoicing' ), |
|
76 | + 'label' => __('Each customer can only use this discount once', 'invoicing'), |
|
77 | 77 | 'value' => '1', |
78 | 78 | 'checked' => $discount->is_single_use(), |
79 | 79 | ), |
80 | 80 | true |
81 | 81 | ); |
82 | 82 | |
83 | - do_action( 'wpinv_discount_form_single_use', $discount ); |
|
83 | + do_action('wpinv_discount_form_single_use', $discount); |
|
84 | 84 | ?> |
85 | 85 | </div> |
86 | 86 | <div class="col-sm-12"> |
87 | 87 | <?php |
88 | - do_action( 'wpinv_discount_form_before_recurring', $discount ); |
|
88 | + do_action('wpinv_discount_form_before_recurring', $discount); |
|
89 | 89 | |
90 | 90 | aui()->input( |
91 | 91 | array( |
92 | 92 | 'id' => 'wpinv_discount_recurring', |
93 | 93 | 'name' => 'wpinv_discount_recurring', |
94 | 94 | 'type' => 'checkbox', |
95 | - 'label' => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ), |
|
95 | + 'label' => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'), |
|
96 | 96 | 'value' => '1', |
97 | 97 | 'checked' => $discount->is_recurring(), |
98 | 98 | ), |
99 | 99 | true |
100 | 100 | ); |
101 | 101 | |
102 | - do_action( 'wpinv_discount_form_recurring', $discount ); |
|
102 | + do_action('wpinv_discount_form_recurring', $discount); |
|
103 | 103 | ?> |
104 | 104 | </div> |
105 | 105 | </div> |
106 | 106 | </div> |
107 | 107 | <div class="col-sm-1 pt-2 pl-0"> |
108 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span> |
|
108 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span> |
|
109 | 109 | </div> |
110 | 110 | </div> |
111 | - <?php do_action( 'wpinv_discount_form_code', $discount ); ?> |
|
111 | + <?php do_action('wpinv_discount_form_code', $discount); ?> |
|
112 | 112 | |
113 | - <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?> |
|
113 | + <?php do_action('wpinv_discount_form_before_type', $discount); ?> |
|
114 | 114 | <div class="form-group row"> |
115 | 115 | <label for="wpinv_discount_type" class="col-sm-3 col-form-label"> |
116 | - <?php esc_html_e( 'Discount Type', 'invoicing' ); ?> |
|
116 | + <?php esc_html_e('Discount Type', 'invoicing'); ?> |
|
117 | 117 | </label> |
118 | 118 | <div class="col-sm-8"> |
119 | 119 | <?php |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | array( |
122 | 122 | 'id' => 'wpinv_discount_type', |
123 | 123 | 'name' => 'wpinv_discount_type', |
124 | - 'label' => __( 'Discount Type', 'invoicing' ), |
|
125 | - 'placeholder' => __( 'Select Discount Type', 'invoicing' ), |
|
126 | - 'value' => $discount->get_type( 'edit' ), |
|
124 | + 'label' => __('Discount Type', 'invoicing'), |
|
125 | + 'placeholder' => __('Select Discount Type', 'invoicing'), |
|
126 | + 'value' => $discount->get_type('edit'), |
|
127 | 127 | 'select2' => true, |
128 | 128 | 'data-allow-clear' => 'false', |
129 | 129 | 'options' => wpinv_get_discount_types(), |
@@ -133,19 +133,19 @@ discard block |
||
133 | 133 | ?> |
134 | 134 | </div> |
135 | 135 | <div class="col-sm-1 pt-2 pl-0"> |
136 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span> |
|
136 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span> |
|
137 | 137 | </div> |
138 | 138 | </div> |
139 | - <?php do_action( 'wpinv_discount_form_type', $discount ); ?> |
|
139 | + <?php do_action('wpinv_discount_form_type', $discount); ?> |
|
140 | 140 | |
141 | - <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?> |
|
142 | - <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap"> |
|
141 | + <?php do_action('wpinv_discount_form_before_amount', $discount); ?> |
|
142 | + <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap"> |
|
143 | 143 | <label for="wpinv_discount_amount" class="col-sm-3 col-form-label"> |
144 | - <?php esc_html_e( 'Discount Amount', 'invoicing' ); ?> |
|
144 | + <?php esc_html_e('Discount Amount', 'invoicing'); ?> |
|
145 | 145 | </label> |
146 | 146 | <div class="col-sm-8"> |
147 | 147 | <div class="input-group input-group-sm"> |
148 | - <?php if ( 'left' == $position ) : ?> |
|
148 | + <?php if ('left' == $position) : ?> |
|
149 | 149 | <div class="input-group-prepend left wpinv-if-flat"> |
150 | 150 | <span class="input-group-text"> |
151 | 151 | <?php echo wpinv_currency_symbol(); ?> |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | </div> |
154 | 154 | <?php endif; ?> |
155 | 155 | |
156 | - <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control"> |
|
156 | + <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control"> |
|
157 | 157 | |
158 | - <?php if ( 'right' == $position ) : ?> |
|
158 | + <?php if ('right' == $position) : ?> |
|
159 | 159 | <div class="input-group-prepend left wpinv-if-flat"> |
160 | 160 | <span class="input-group-text"> |
161 | 161 | <?php echo wpinv_currency_symbol(); ?> |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | </div> |
169 | 169 | </div> |
170 | 170 | <div class="col-sm-1 pt-2 pl-0"> |
171 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span> |
|
171 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span> |
|
172 | 172 | </div> |
173 | 173 | </div> |
174 | - <?php do_action( 'wpinv_discount_form_amount', $discount ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_amount', $discount); ?> |
|
175 | 175 | |
176 | - <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?> |
|
176 | + <?php do_action('wpinv_discount_form_before_items', $discount); ?> |
|
177 | 177 | <div class="form-group row"> |
178 | 178 | <label for="wpinv_discount_items" class="col-sm-3 col-form-label"> |
179 | - <?php esc_html_e( 'Items', 'invoicing' ); ?> |
|
179 | + <?php esc_html_e('Items', 'invoicing'); ?> |
|
180 | 180 | </label> |
181 | 181 | <div class="col-sm-8"> |
182 | 182 | <?php |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | array( |
185 | 185 | 'id' => 'wpinv_discount_items', |
186 | 186 | 'name' => 'wpinv_discount_items[]', |
187 | - 'label' => __( 'Items', 'invoicing' ), |
|
188 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
189 | - 'value' => $discount->get_items( 'edit' ), |
|
187 | + 'label' => __('Items', 'invoicing'), |
|
188 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
189 | + 'value' => $discount->get_items('edit'), |
|
190 | 190 | 'select2' => true, |
191 | 191 | 'multiple' => true, |
192 | 192 | 'data-allow-clear' => 'false', |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | ?> |
198 | 198 | </div> |
199 | 199 | <div class="col-sm-1 pt-2 pl-0"> |
200 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span> |
|
200 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span> |
|
201 | 201 | </div> |
202 | 202 | </div> |
203 | - <?php do_action( 'wpinv_discount_form_items', $discount ); ?> |
|
203 | + <?php do_action('wpinv_discount_form_items', $discount); ?> |
|
204 | 204 | |
205 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?> |
|
205 | + <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?> |
|
206 | 206 | <div class="form-group row"> |
207 | 207 | <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label"> |
208 | - <?php esc_html_e( 'Excluded Items', 'invoicing' ); ?> |
|
208 | + <?php esc_html_e('Excluded Items', 'invoicing'); ?> |
|
209 | 209 | </label> |
210 | 210 | <div class="col-sm-8"> |
211 | 211 | <?php |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | array( |
214 | 214 | 'id' => 'wpinv_discount_excluded_items', |
215 | 215 | 'name' => 'wpinv_discount_excluded_items[]', |
216 | - 'label' => __( 'Excluded Items', 'invoicing' ), |
|
217 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
218 | - 'value' => $discount->get_excluded_items( 'edit' ), |
|
216 | + 'label' => __('Excluded Items', 'invoicing'), |
|
217 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
218 | + 'value' => $discount->get_excluded_items('edit'), |
|
219 | 219 | 'select2' => true, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'data-allow-clear' => 'false', |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | ?> |
227 | 227 | </div> |
228 | 228 | <div class="col-sm-1 pt-2 pl-0"> |
229 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span> |
|
229 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span> |
|
230 | 230 | </div> |
231 | 231 | </div> |
232 | - <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?> |
|
232 | + <?php do_action('wpinv_discount_form_excluded_items', $discount); ?> |
|
233 | 233 | |
234 | - <?php do_action( 'wpinv_discount_form_before_required_items', $discount ); ?> |
|
234 | + <?php do_action('wpinv_discount_form_before_required_items', $discount); ?> |
|
235 | 235 | <div class="form-group row"> |
236 | 236 | <label for="wpinv_discount_required_items" class="col-sm-3 col-form-label"> |
237 | - <?php esc_html_e( 'Required Items', 'invoicing' ); ?> |
|
237 | + <?php esc_html_e('Required Items', 'invoicing'); ?> |
|
238 | 238 | </label> |
239 | 239 | <div class="col-sm-8"> |
240 | 240 | <?php |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | array( |
243 | 243 | 'id' => 'wpinv_discount_required_items', |
244 | 244 | 'name' => 'wpinv_discount_required_items[]', |
245 | - 'label' => __( 'Required Items', 'invoicing' ), |
|
246 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
247 | - 'value' => $discount->get_required_items( 'edit' ), |
|
245 | + 'label' => __('Required Items', 'invoicing'), |
|
246 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
247 | + 'value' => $discount->get_required_items('edit'), |
|
248 | 248 | 'select2' => true, |
249 | 249 | 'multiple' => true, |
250 | 250 | 'data-allow-clear' => 'false', |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | ?> |
256 | 256 | </div> |
257 | 257 | <div class="col-sm-1 pt-2 pl-0"> |
258 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are required to be in the cart before using this discount.', 'invoicing' ); ?>"></span> |
|
258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are required to be in the cart before using this discount.', 'invoicing'); ?>"></span> |
|
259 | 259 | </div> |
260 | 260 | </div> |
261 | - <?php do_action( 'wpinv_discount_form_required_items', $discount ); ?> |
|
261 | + <?php do_action('wpinv_discount_form_required_items', $discount); ?> |
|
262 | 262 | |
263 | - <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?> |
|
263 | + <?php do_action('wpinv_discount_form_before_start', $discount); ?> |
|
264 | 264 | <div class="form-group row"> |
265 | 265 | <label for="wpinv_discount_start" class="col-sm-3 col-form-label"> |
266 | - <?php esc_html_e( 'Start Date', 'invoicing' ); ?> |
|
266 | + <?php esc_html_e('Start Date', 'invoicing'); ?> |
|
267 | 267 | </label> |
268 | 268 | <div class="col-sm-8"> |
269 | 269 | <?php |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | 'type' => 'datepicker', |
273 | 273 | 'id' => 'wpinv_discount_start', |
274 | 274 | 'name' => 'wpinv_discount_start', |
275 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
275 | + 'label' => __('Start Date', 'invoicing'), |
|
276 | 276 | 'placeholder' => 'YYYY-MM-DD 00:00', |
277 | 277 | 'class' => 'form-control-sm', |
278 | - 'value' => $discount->get_start_date( 'edit' ), |
|
278 | + 'value' => $discount->get_start_date('edit'), |
|
279 | 279 | 'extra_attributes' => array( |
280 | 280 | 'data-enable-time' => 'true', |
281 | 281 | 'data-time_24hr' => 'true', |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | ?> |
288 | 288 | </div> |
289 | 289 | <div class="col-sm-1 pt-2 pl-0"> |
290 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span> |
|
290 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span> |
|
291 | 291 | </div> |
292 | 292 | </div> |
293 | - <?php do_action( 'wpinv_discount_form_start', $discount ); ?> |
|
293 | + <?php do_action('wpinv_discount_form_start', $discount); ?> |
|
294 | 294 | |
295 | - <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?> |
|
295 | + <?php do_action('wpinv_discount_form_before_expiration', $discount); ?> |
|
296 | 296 | <div class="form-group row"> |
297 | 297 | <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label"> |
298 | - <?php esc_html_e( 'Expiration Date', 'invoicing' ); ?> |
|
298 | + <?php esc_html_e('Expiration Date', 'invoicing'); ?> |
|
299 | 299 | </label> |
300 | 300 | <div class="col-sm-8"> |
301 | 301 | <?php |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | 'type' => 'datepicker', |
305 | 305 | 'id' => 'wpinv_discount_expiration', |
306 | 306 | 'name' => 'wpinv_discount_expiration', |
307 | - 'label' => __( 'Expiration Date', 'invoicing' ), |
|
307 | + 'label' => __('Expiration Date', 'invoicing'), |
|
308 | 308 | 'placeholder' => 'YYYY-MM-DD 00:00', |
309 | 309 | 'class' => 'form-control-sm', |
310 | - 'value' => $discount->get_end_date( 'edit' ), |
|
310 | + 'value' => $discount->get_end_date('edit'), |
|
311 | 311 | 'extra_attributes' => array( |
312 | 312 | 'data-enable-time' => 'true', |
313 | 313 | 'data-time_24hr' => 'true', |
@@ -321,27 +321,27 @@ discard block |
||
321 | 321 | ?> |
322 | 322 | </div> |
323 | 323 | <div class="col-sm-1 pt-2 pl-0"> |
324 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span> |
|
324 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span> |
|
325 | 325 | </div> |
326 | 326 | </div> |
327 | - <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_expiration', $discount); ?> |
|
328 | 328 | |
329 | - <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?> |
|
329 | + <?php do_action('wpinv_discount_form_before_min_total', $discount); ?> |
|
330 | 330 | <div class="form-group row"> |
331 | 331 | <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label"> |
332 | - <?php esc_html_e( 'Minimum Amount', 'invoicing' ); ?> |
|
332 | + <?php esc_html_e('Minimum Amount', 'invoicing'); ?> |
|
333 | 333 | </label> |
334 | 334 | <div class="col-sm-8"> |
335 | 335 | <div class="input-group input-group-sm"> |
336 | - <?php if ( 'left' == $position ) : ?> |
|
336 | + <?php if ('left' == $position) : ?> |
|
337 | 337 | <div class="input-group-prepend"> |
338 | 338 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> |
339 | 339 | </div> |
340 | 340 | <?php endif; ?> |
341 | 341 | |
342 | - <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control"> |
|
342 | + <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control"> |
|
343 | 343 | |
344 | - <?php if ( 'left' != $position ) : ?> |
|
344 | + <?php if ('left' != $position) : ?> |
|
345 | 345 | <div class="input-group-append"> |
346 | 346 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> |
347 | 347 | </div> |
@@ -349,27 +349,27 @@ discard block |
||
349 | 349 | </div> |
350 | 350 | </div> |
351 | 351 | <div class="col-sm-1 pt-2 pl-0"> |
352 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span> |
|
352 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span> |
|
353 | 353 | </div> |
354 | 354 | </div> |
355 | - <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?> |
|
355 | + <?php do_action('wpinv_discount_form_min_total', $discount); ?> |
|
356 | 356 | |
357 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> |
|
357 | + <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> |
|
358 | 358 | <div class="form-group row"> |
359 | 359 | <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label"> |
360 | - <?php esc_html_e( 'Maximum Amount', 'invoicing' ); ?> |
|
360 | + <?php esc_html_e('Maximum Amount', 'invoicing'); ?> |
|
361 | 361 | </label> |
362 | 362 | <div class="col-sm-8"> |
363 | 363 | <div class="input-group input-group-sm"> |
364 | - <?php if ( 'left' == $position ) : ?> |
|
364 | + <?php if ('left' == $position) : ?> |
|
365 | 365 | <div class="input-group-prepend"> |
366 | 366 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> |
367 | 367 | </div> |
368 | 368 | <?php endif; ?> |
369 | 369 | |
370 | - <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control"> |
|
370 | + <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control"> |
|
371 | 371 | |
372 | - <?php if ( 'left' != $position ) : ?> |
|
372 | + <?php if ('left' != $position) : ?> |
|
373 | 373 | <div class="input-group-append"> |
374 | 374 | <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span> |
375 | 375 | </div> |
@@ -377,30 +377,30 @@ discard block |
||
377 | 377 | </div> |
378 | 378 | </div> |
379 | 379 | <div class="col-sm-1 pt-2 pl-0"> |
380 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span> |
|
380 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span> |
|
381 | 381 | </div> |
382 | 382 | </div> |
383 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> |
|
383 | + <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> |
|
384 | 384 | |
385 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?> |
|
385 | + <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?> |
|
386 | 386 | <div class="form-group row"> |
387 | 387 | <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label"> |
388 | - <?php esc_html_e( 'Maximum Uses', 'invoicing' ); ?> |
|
388 | + <?php esc_html_e('Maximum Uses', 'invoicing'); ?> |
|
389 | 389 | </label> |
390 | 390 | <div class="col-sm-8"> |
391 | - <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> |
|
391 | + <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> |
|
392 | 392 | </div> |
393 | 393 | <div class="col-sm-1 pt-2 pl-0"> |
394 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span> |
|
394 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span> |
|
395 | 395 | </div> |
396 | 396 | </div> |
397 | - <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?> |
|
397 | + <?php do_action('wpinv_discount_form_max_uses', $discount); ?> |
|
398 | 398 | |
399 | - <?php do_action( 'wpinv_discount_form_last', $discount ); ?> |
|
399 | + <?php do_action('wpinv_discount_form_last', $discount); ?> |
|
400 | 400 | |
401 | 401 | </div> |
402 | 402 | <?php |
403 | - do_action( 'wpinv_discount_form_bottom', $post ); |
|
403 | + do_action('wpinv_discount_form_bottom', $post); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -408,31 +408,31 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param int $post_id |
410 | 410 | */ |
411 | - public static function save( $post_id ) { |
|
411 | + public static function save($post_id) { |
|
412 | 412 | |
413 | 413 | // Prepare the discount. |
414 | - $discount = new WPInv_Discount( $post_id ); |
|
414 | + $discount = new WPInv_Discount($post_id); |
|
415 | 415 | |
416 | 416 | // Load new data. |
417 | 417 | $discount->set_props( |
418 | 418 | array( |
419 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null, |
|
420 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null, |
|
421 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
422 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
423 | - 'is_single_use' => ! empty( $_POST['wpinv_discount_single_use'] ), |
|
424 | - 'type' => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null, |
|
425 | - 'is_recurring' => ! empty( $_POST['wpinv_discount_recurring'] ), |
|
426 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(), |
|
427 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(), |
|
428 | - 'required_items' => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(), |
|
429 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null, |
|
430 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null, |
|
431 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null, |
|
419 | + 'code' => isset($_POST['wpinv_discount_code']) ? wpinv_clean($_POST['wpinv_discount_code']) : null, |
|
420 | + 'amount' => isset($_POST['wpinv_discount_amount']) ? floatval($_POST['wpinv_discount_amount']) : null, |
|
421 | + 'start' => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null, |
|
422 | + 'expiration' => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null, |
|
423 | + 'is_single_use' => !empty($_POST['wpinv_discount_single_use']), |
|
424 | + 'type' => isset($_POST['wpinv_discount_type']) ? wpinv_clean($_POST['wpinv_discount_type']) : null, |
|
425 | + 'is_recurring' => !empty($_POST['wpinv_discount_recurring']), |
|
426 | + 'items' => isset($_POST['wpinv_discount_items']) ? wpinv_clean($_POST['wpinv_discount_items']) : array(), |
|
427 | + 'excluded_items' => isset($_POST['wpinv_discount_excluded_items']) ? wpinv_clean($_POST['wpinv_discount_excluded_items']) : array(), |
|
428 | + 'required_items' => isset($_POST['wpinv_discount_required_items']) ? wpinv_clean($_POST['wpinv_discount_required_items']) : array(), |
|
429 | + 'max_uses' => isset($_POST['wpinv_discount_max_uses']) ? intval($_POST['wpinv_discount_max_uses']) : null, |
|
430 | + 'min_total' => isset($_POST['wpinv_discount_min_total']) ? floatval($_POST['wpinv_discount_min_total']) : null, |
|
431 | + 'max_total' => isset($_POST['wpinv_discount_max_total']) ? floatval($_POST['wpinv_discount_max_total']) : null, |
|
432 | 432 | ) |
433 | 433 | ); |
434 | 434 | |
435 | 435 | $discount->save(); |
436 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
436 | + do_action('getpaid_discount_metabox_save', $post_id, $discount); |
|
437 | 437 | } |
438 | 438 | } |