@@ -4,17 +4,17 @@ discard block |
||
4 | 4 | */ |
5 | 5 | global $wpinv_receipt_args; |
6 | 6 | |
7 | -$invoice = get_post( $wpinv_receipt_args['id'] ); |
|
7 | +$invoice = get_post($wpinv_receipt_args['id']); |
|
8 | 8 | |
9 | -if( empty( $invoice ) ) { |
|
9 | +if (empty($invoice)) { |
|
10 | 10 | ?> |
11 | 11 | <div class="wpinv_errors alert wpi-alert-error"> |
12 | - <?php _e( 'The specified receipt ID appears to be invalid', 'invoicing' ); ?> |
|
12 | + <?php _e('The specified receipt ID appears to be invalid', 'invoicing'); ?> |
|
13 | 13 | </div> |
14 | 14 | <?php |
15 | 15 | return; |
16 | 16 | } |
17 | -$invoice = wpinv_get_invoice( $invoice->ID ); |
|
17 | +$invoice = wpinv_get_invoice($invoice->ID); |
|
18 | 18 | |
19 | 19 | global $ajax_cart_details; |
20 | 20 | $ajax_cart_details = $invoice->get_cart_details(); |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | $quantities_enabled = wpinv_item_quantities_enabled(); |
25 | 25 | $use_taxes = wpinv_use_taxes(); |
26 | 26 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
27 | -$tax_label = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? __( '(Tax Incl.)', 'invoicing' ) : __( '(Tax Excl.)', 'invoicing' ) ) : ''; |
|
27 | +$tax_label = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? __('(Tax Incl.)', 'invoicing') : __('(Tax Excl.)', 'invoicing')) : ''; |
|
28 | 28 | ?> |
29 | -<?php do_action( 'wpinv_before_receipt', $invoice ); ?> |
|
29 | +<?php do_action('wpinv_before_receipt', $invoice); ?> |
|
30 | 30 | <div class="wpinv-receipt"> |
31 | - <?php do_action( 'wpinv_receipt_start', $invoice ); ?> |
|
32 | - <div class="wpinv-receipt-message"><?php _e( 'Thank you for your payment!', 'invoicing' ); ?></div> |
|
33 | - <?php do_action( 'wpinv_before_receipt_details', $invoice ); ?> |
|
31 | + <?php do_action('wpinv_receipt_start', $invoice); ?> |
|
32 | + <div class="wpinv-receipt-message"><?php _e('Thank you for your payment!', 'invoicing'); ?></div> |
|
33 | + <?php do_action('wpinv_before_receipt_details', $invoice); ?> |
|
34 | 34 | <div class="wpinv-receipt-details"> |
35 | - <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ) ); ?></h3> |
|
36 | - <?php wpinv_display_invoice_details( $invoice ); ?> |
|
35 | + <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing')); ?></h3> |
|
36 | + <?php wpinv_display_invoice_details($invoice); ?> |
|
37 | 37 | </div> |
38 | - <?php do_action( 'wpinv_after_receipt_details', $invoice ); ?> |
|
39 | - <?php do_action( 'wpinv_receipt_end', $invoice ); ?> |
|
38 | + <?php do_action('wpinv_after_receipt_details', $invoice); ?> |
|
39 | + <?php do_action('wpinv_receipt_end', $invoice); ?> |
|
40 | 40 | </div> |
41 | -<?php do_action( 'wpinv_after_receipt', $invoice ); ?> |
|
42 | 41 | \ No newline at end of file |
42 | +<?php do_action('wpinv_after_receipt', $invoice); ?> |
|
43 | 43 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -11,60 +11,60 @@ discard block |
||
11 | 11 | public function __construct() { |
12 | 12 | global $bp; |
13 | 13 | |
14 | - if ( !defined( 'WPINV_BP_SLUG' ) ) { |
|
15 | - define( 'WPINV_BP_SLUG', 'invoices' ); |
|
14 | + if (!defined('WPINV_BP_SLUG')) { |
|
15 | + define('WPINV_BP_SLUG', 'invoices'); |
|
16 | 16 | } |
17 | 17 | |
18 | - $position = wpinv_get_option( 'wpinv_menu_position' ); |
|
18 | + $position = wpinv_get_option('wpinv_menu_position'); |
|
19 | 19 | $position = $position !== '' && $position !== false ? $position : 91; |
20 | - $this->position = apply_filters( 'wpinv_bp_nav_position', $position ); |
|
20 | + $this->position = apply_filters('wpinv_bp_nav_position', $position); |
|
21 | 21 | $this->slug = WPINV_BP_SLUG; |
22 | 22 | |
23 | 23 | parent::start( |
24 | 24 | 'invoicing', |
25 | - _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ), |
|
26 | - trailingslashit( dirname( __FILE__ ) ), |
|
25 | + _x('Invoices', 'Invoices screen page <title>', 'invoicing'), |
|
26 | + trailingslashit(dirname(__FILE__)), |
|
27 | 27 | array( |
28 | 28 | 'adminbar_myaccount_order' => $this->position |
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - public function includes( $includes = array() ) { |
|
34 | - parent::includes( $includes ); |
|
33 | + public function includes($includes = array()) { |
|
34 | + parent::includes($includes); |
|
35 | 35 | } |
36 | 36 | |
37 | - public function setup_globals( $args = array() ) { |
|
37 | + public function setup_globals($args = array()) { |
|
38 | 38 | global $bp; |
39 | 39 | |
40 | 40 | $args = array( |
41 | 41 | 'slug' => $this->slug, |
42 | 42 | ); |
43 | 43 | |
44 | - parent::setup_globals( $args ); |
|
44 | + parent::setup_globals($args); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
48 | - if ( !bp_is_my_profile() ) { |
|
47 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
48 | + if (!bp_is_my_profile()) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
52 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $this->setup_invoice_count(); |
57 | 57 | |
58 | 58 | $user_domain = bp_loggedin_user_domain(); |
59 | - $invoices_link = trailingslashit( $user_domain . $this->slug ); |
|
60 | - $class = ( 0 === $this->count ) ? 'no-count' : 'count'; |
|
59 | + $invoices_link = trailingslashit($user_domain . $this->slug); |
|
60 | + $class = (0 === $this->count) ? 'no-count' : 'count'; |
|
61 | 61 | |
62 | 62 | $main_nav_name = sprintf( |
63 | - __( 'My Invoices %s', 'invoicing' ), |
|
63 | + __('My Invoices %s', 'invoicing'), |
|
64 | 64 | sprintf( |
65 | 65 | '<span class="%s">%s</span>', |
66 | - esc_attr( $class ), |
|
67 | - bp_core_number_format( $this->count ) |
|
66 | + esc_attr($class), |
|
67 | + bp_core_number_format($this->count) |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | |
@@ -72,54 +72,54 @@ discard block |
||
72 | 72 | 'name' => $main_nav_name, |
73 | 73 | 'slug' => $this->slug, |
74 | 74 | 'position' => $this->position, |
75 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
75 | + 'screen_function' => array($this, 'invoices_screen'), |
|
76 | 76 | 'default_subnav_slug' => 'invoices', |
77 | 77 | 'item_css_id' => $this->id |
78 | 78 | ); |
79 | 79 | |
80 | 80 | $sub_nav[] = array( |
81 | - 'name' => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ), |
|
81 | + 'name' => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'), |
|
82 | 82 | 'slug' => 'invoices', |
83 | 83 | 'parent_url' => $invoices_link, |
84 | 84 | 'parent_slug' => $this->slug, |
85 | - 'screen_function' => array( $this, 'invoices_screen' ), |
|
85 | + 'screen_function' => array($this, 'invoices_screen'), |
|
86 | 86 | 'position' => 10, |
87 | 87 | 'item_css_id' => 'invoices-my-invoices' |
88 | 88 | ); |
89 | 89 | |
90 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
90 | + parent::setup_nav($main_nav, $sub_nav); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public function setup_title() { |
94 | 94 | // Adjust title. |
95 | - if ( (bool)bp_is_current_component( 'invoicing' ) ) { |
|
95 | + if ((bool)bp_is_current_component('invoicing')) { |
|
96 | 96 | global $bp; |
97 | 97 | |
98 | - $bp->bp_options_title = __( 'My Invoices', 'invoicing' ); |
|
98 | + $bp->bp_options_title = __('My Invoices', 'invoicing'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | parent::setup_title(); |
102 | 102 | } |
103 | 103 | |
104 | 104 | public function invoices_screen() { |
105 | - if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) { |
|
105 | + if (wpinv_get_option('wpinv_bp_hide_menu')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | global $bp; |
110 | 110 | |
111 | - add_action( 'bp_template_content', array( $this, 'invoices_content' ) ); |
|
111 | + add_action('bp_template_content', array($this, 'invoices_content')); |
|
112 | 112 | |
113 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
113 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
114 | 114 | |
115 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
115 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | public function invoices_content() { |
119 | - if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) { |
|
119 | + if ($this->has_invoices(bp_ajax_querystring('invoices'))) { |
|
120 | 120 | global $invoices_template; |
121 | 121 | |
122 | - do_action( 'wpinv_bp_invoices_before_content' ); |
|
122 | + do_action('wpinv_bp_invoices_before_content'); |
|
123 | 123 | ?> |
124 | 124 | <div class="wpi-bp-invoices invoices invoicing" style="position:relative"> |
125 | 125 | <div id="pag-top" class="pagination"> |
@@ -133,58 +133,58 @@ discard block |
||
133 | 133 | <table class="table table-bordered table-hover wpi-user-invoices" style="margin:0"> |
134 | 134 | <thead> |
135 | 135 | <tr> |
136 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
137 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
136 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
137 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
138 | 138 | <?php endforeach; ?> |
139 | 139 | </tr> |
140 | 140 | </thead> |
141 | 141 | <tbody> |
142 | - <?php foreach ( $invoices_template->invoices as $invoice ) { |
|
142 | + <?php foreach ($invoices_template->invoices as $invoice) { |
|
143 | 143 | ?> |
144 | 144 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
145 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
146 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
147 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
148 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
149 | - |
|
150 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
151 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
152 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
145 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
146 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
147 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
148 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
149 | + |
|
150 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
151 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
152 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
153 | 153 | </a> |
154 | 154 | |
155 | - <?php elseif ( 'invoice-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
156 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
155 | + <?php elseif ('invoice-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
156 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
157 | 157 | |
158 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
159 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
158 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
159 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
160 | 160 | |
161 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
162 | - <?php echo $invoice->get_total( true ); ?> |
|
161 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
162 | + <?php echo $invoice->get_total(true); ?> |
|
163 | 163 | |
164 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
164 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
165 | 165 | <?php |
166 | 166 | $actions = array( |
167 | 167 | 'pay' => array( |
168 | 168 | 'url' => $invoice->get_checkout_payment_url(), |
169 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
169 | + 'name' => __('Pay Now', 'invoicing'), |
|
170 | 170 | 'class' => 'btn-success' |
171 | 171 | ), |
172 | 172 | 'print' => array( |
173 | 173 | 'url' => $invoice->get_view_url(), |
174 | - 'name' => __( 'Print', 'invoicing' ), |
|
174 | + 'name' => __('Print', 'invoicing'), |
|
175 | 175 | 'class' => 'btn-primary', |
176 | 176 | 'attrs' => 'target="_blank"' |
177 | 177 | ) |
178 | 178 | ); |
179 | 179 | |
180 | - if ( ! $invoice->needs_payment() ) { |
|
181 | - unset( $actions['pay'] ); |
|
180 | + if (!$invoice->needs_payment()) { |
|
181 | + unset($actions['pay']); |
|
182 | 182 | } |
183 | 183 | |
184 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
185 | - foreach ( $actions as $key => $action ) { |
|
184 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
185 | + foreach ($actions as $key => $action) { |
|
186 | 186 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
187 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
187 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | ?> |
@@ -212,64 +212,64 @@ discard block |
||
212 | 212 | </div> |
213 | 213 | <?php |
214 | 214 | |
215 | - do_action( 'wpinv_bp_invoices_after_content' ); |
|
215 | + do_action('wpinv_bp_invoices_after_content'); |
|
216 | 216 | } else { |
217 | 217 | ?> |
218 | 218 | <div id="message" class="info"> |
219 | - <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p> |
|
219 | + <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p> |
|
220 | 220 | </div> |
221 | 221 | <?php |
222 | 222 | } |
223 | 223 | |
224 | - if ( defined( 'DOING_AJAX' ) ) { |
|
224 | + if (defined('DOING_AJAX')) { |
|
225 | 225 | exit; |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - public function has_invoices( $args = '' ) { |
|
229 | + public function has_invoices($args = '') { |
|
230 | 230 | global $invoices_template; |
231 | 231 | |
232 | - $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) ); |
|
232 | + $per_page = absint(wpinv_get_option('wpinv_bp_per_page')); |
|
233 | 233 | // Parse arguments. |
234 | - $r = bp_parse_args( $args, array( |
|
234 | + $r = bp_parse_args($args, array( |
|
235 | 235 | 'status' => 'all', |
236 | 236 | 'page_arg' => 'bpage', |
237 | 237 | 'page' => 1, |
238 | 238 | 'per_page' => $per_page > 0 ? $per_page : 20, |
239 | 239 | 'max' => false, |
240 | 240 | 'user_id' => bp_loggedin_user_id(), |
241 | - ), 'has_invoices' ); |
|
241 | + ), 'has_invoices'); |
|
242 | 242 | |
243 | 243 | |
244 | - if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) { |
|
244 | + if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) { |
|
245 | 245 | $r['per_page'] = (int)$r['max']; |
246 | 246 | } |
247 | 247 | |
248 | 248 | // Get the invoices. |
249 | - $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] ); |
|
249 | + $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']); |
|
250 | 250 | |
251 | - return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r ); |
|
251 | + return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | public function setup_invoice_count() { |
255 | - $query = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) ); |
|
256 | - $invoices = wpinv_get_invoices( $query ); |
|
255 | + $query = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false)); |
|
256 | + $invoices = wpinv_get_invoices($query); |
|
257 | 257 | |
258 | - $this->count = !empty( $invoices ) ? count( $invoices ) : 0; |
|
258 | + $this->count = !empty($invoices) ? count($invoices) : 0; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | public function pagination_count() { |
262 | 262 | global $invoices_template; |
263 | 263 | |
264 | - $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1; |
|
265 | - $from_num = bp_core_number_format( $start_num ); |
|
266 | - $to_num = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) ); |
|
267 | - $total = bp_core_number_format( $invoices_template->total_invoice_count ); |
|
264 | + $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1; |
|
265 | + $from_num = bp_core_number_format($start_num); |
|
266 | + $to_num = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1)); |
|
267 | + $total = bp_core_number_format($invoices_template->total_invoice_count); |
|
268 | 268 | |
269 | - if ( 1 == $invoices_template->total_invoice_count ) { |
|
270 | - $message = __( 'Viewing 1 invoice', 'invoicing' ); |
|
269 | + if (1 == $invoices_template->total_invoice_count) { |
|
270 | + $message = __('Viewing 1 invoice', 'invoicing'); |
|
271 | 271 | } else { |
272 | - $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total ); |
|
272 | + $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $message; |
@@ -278,32 +278,32 @@ discard block |
||
278 | 278 | function pagination_links() { |
279 | 279 | global $invoices_template; |
280 | 280 | |
281 | - return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links ); |
|
281 | + return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links); |
|
282 | 282 | } |
283 | 283 | |
284 | - public function bp_section( $settings = array() ) { |
|
285 | - $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' ); |
|
284 | + public function bp_section($settings = array()) { |
|
285 | + $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing'); |
|
286 | 286 | return $settings; |
287 | 287 | } |
288 | 288 | |
289 | - public function bp_settings( $settings = array() ) { |
|
289 | + public function bp_settings($settings = array()) { |
|
290 | 290 | $settings['wpinv_bp'] = array( |
291 | 291 | 'wpinv_bp_labels' => array( |
292 | 292 | 'id' => 'wpinv_bp_settings', |
293 | - 'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>', |
|
293 | + 'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>', |
|
294 | 294 | 'desc' => '', |
295 | 295 | 'type' => 'header', |
296 | 296 | ), |
297 | 297 | 'wpinv_bp_hide_menu' => array( |
298 | 298 | 'id' => 'wpinv_bp_hide_menu', |
299 | - 'name' => __( 'Hide Invoices link', 'invoicing' ), |
|
300 | - 'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ), |
|
299 | + 'name' => __('Hide Invoices link', 'invoicing'), |
|
300 | + 'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'), |
|
301 | 301 | 'type' => 'checkbox', |
302 | 302 | ), |
303 | 303 | 'wpinv_menu_position' => array( |
304 | 304 | 'id' => 'wpinv_menu_position', |
305 | - 'name' => __( 'Menu position', 'invoicing' ), |
|
306 | - 'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ), |
|
305 | + 'name' => __('Menu position', 'invoicing'), |
|
306 | + 'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'), |
|
307 | 307 | 'type' => 'number', |
308 | 308 | 'size' => 'small', |
309 | 309 | 'min' => '1', |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | ), |
314 | 314 | 'wpinv_bp_per_page' => array( |
315 | 315 | 'id' => 'wpinv_bp_per_page', |
316 | - 'name' => __( 'Max invoices per page', 'invoicing' ), |
|
317 | - 'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ), |
|
316 | + 'name' => __('Max invoices per page', 'invoicing'), |
|
317 | + 'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'), |
|
318 | 318 | 'type' => 'number', |
319 | 319 | 'size' => 'small', |
320 | 320 | 'min' => '1', |
@@ -339,25 +339,25 @@ discard block |
||
339 | 339 | public $pag_links = ''; |
340 | 340 | public $total_invoice_count = 0; |
341 | 341 | |
342 | - public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) { |
|
343 | - $this->invoices = array( 'invoices' => array(), 'total' => 0 ); |
|
342 | + public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') { |
|
343 | + $this->invoices = array('invoices' => array(), 'total' => 0); |
|
344 | 344 | |
345 | - $this->pag_arg = sanitize_key( $page_arg ); |
|
346 | - $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page ); |
|
347 | - $this->pag_num = bp_sanitize_pagination_arg( 'num', $per_page ); |
|
345 | + $this->pag_arg = sanitize_key($page_arg); |
|
346 | + $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page); |
|
347 | + $this->pag_num = bp_sanitize_pagination_arg('num', $per_page); |
|
348 | 348 | |
349 | - $query_args = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true ); |
|
350 | - if ( !empty( $status ) && $status != 'all' ) { |
|
349 | + $query_args = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true); |
|
350 | + if (!empty($status) && $status != 'all') { |
|
351 | 351 | $query_args['status'] = $status; |
352 | 352 | } |
353 | - $invoices = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) ); |
|
353 | + $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args)); |
|
354 | 354 | |
355 | - if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) { |
|
356 | - $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
355 | + if (!empty($invoices) && !empty($invoices->found_posts)) { |
|
356 | + $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts); |
|
357 | 357 | $this->invoices['total'] = $invoices->found_posts; |
358 | 358 | } |
359 | 359 | |
360 | - if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) { |
|
360 | + if (empty($max) || ($max >= (int)$this->invoices['total'])) { |
|
361 | 361 | $this->total_invoice_count = (int)$this->invoices['total']; |
362 | 362 | } else { |
363 | 363 | $this->total_invoice_count = (int)$max; |
@@ -365,52 +365,52 @@ discard block |
||
365 | 365 | |
366 | 366 | $this->invoices = $this->invoices['invoices']; |
367 | 367 | |
368 | - $invoice_count = count( $this->invoices ); |
|
368 | + $invoice_count = count($this->invoices); |
|
369 | 369 | |
370 | - if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) { |
|
370 | + if (empty($max) || ($max >= (int)$invoice_count)) { |
|
371 | 371 | $this->invoice_count = (int)$invoice_count; |
372 | 372 | } else { |
373 | 373 | $this->invoice_count = (int)$max; |
374 | 374 | } |
375 | 375 | |
376 | - if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) { |
|
377 | - $this->pag_links = paginate_links( array( |
|
378 | - 'base' => add_query_arg( $this->pag_arg, '%#%' ), |
|
376 | + if (!empty($this->total_invoice_count) && !empty($this->pag_num)) { |
|
377 | + $this->pag_links = paginate_links(array( |
|
378 | + 'base' => add_query_arg($this->pag_arg, '%#%'), |
|
379 | 379 | 'format' => '', |
380 | - 'total' => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ), |
|
380 | + 'total' => ceil((int)$this->total_invoice_count / (int)$this->pag_num), |
|
381 | 381 | 'current' => (int)$this->pag_page, |
382 | - 'prev_text' => _x( '←', 'Invoice pagination previous text', 'invoicing' ), |
|
383 | - 'next_text' => _x( '→', 'Invoice pagination next text', 'invoicing' ), |
|
382 | + 'prev_text' => _x('←', 'Invoice pagination previous text', 'invoicing'), |
|
383 | + 'next_text' => _x('→', 'Invoice pagination next text', 'invoicing'), |
|
384 | 384 | 'mid_size' => 1, |
385 | 385 | 'add_args' => array(), |
386 | - ) ); |
|
386 | + )); |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
390 | 390 | public function has_invoices() { |
391 | - return (bool) ! empty( $this->invoice_count ); |
|
391 | + return (bool)!empty($this->invoice_count); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | public function next_invoice() { |
395 | 395 | $this->current_invoice++; |
396 | - $this->invoice = $this->invoices[ $this->current_invoice ]; |
|
396 | + $this->invoice = $this->invoices[$this->current_invoice]; |
|
397 | 397 | |
398 | 398 | return $this->invoice; |
399 | 399 | } |
400 | 400 | |
401 | 401 | public function rewind_invoices() { |
402 | 402 | $this->current_invoice = -1; |
403 | - if ( $this->invoice_count > 0 ) { |
|
403 | + if ($this->invoice_count > 0) { |
|
404 | 404 | $this->invoice = $this->invoices[0]; |
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | 408 | public function invoices() { |
409 | - if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) { |
|
409 | + if (($this->current_invoice + 1) < $this->invoice_count) { |
|
410 | 410 | return true; |
411 | - } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) { |
|
411 | + } elseif (($this->current_invoice + 1) === $this->invoice_count) { |
|
412 | 412 | |
413 | - do_action( 'wpinv_bp_invoice_loop_end' ); |
|
413 | + do_action('wpinv_bp_invoice_loop_end'); |
|
414 | 414 | |
415 | 415 | $this->rewind_invoices(); |
416 | 416 | } |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | $this->in_the_loop = true; |
425 | 425 | $this->invoice = $this->next_invoice(); |
426 | 426 | |
427 | - if ( 0 === $this->current_invoice ) { |
|
428 | - do_action( 'wpinv_bp_invoice_loop_start' ); |
|
427 | + if (0 === $this->current_invoice) { |
|
428 | + do_action('wpinv_bp_invoice_loop_start'); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | } |
@@ -435,9 +435,9 @@ discard block |
||
435 | 435 | |
436 | 436 | $bp->invoicing = new WPInv_BP_Component(); |
437 | 437 | |
438 | - add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
439 | - add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) ); |
|
440 | - add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 ); |
|
441 | - add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 ); |
|
438 | + add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
439 | + add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content')); |
|
440 | + add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1); |
|
441 | + add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1); |
|
442 | 442 | } |
443 | -add_action( 'bp_loaded', 'wpinv_bp_setup_component' ); |
|
444 | 443 | \ No newline at end of file |
444 | +add_action('bp_loaded', 'wpinv_bp_setup_component'); |
|
445 | 445 | \ No newline at end of file |
@@ -7,195 +7,195 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $is_checkout = is_page( wpinv_get_option( 'checkout_page' ) ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $is_checkout = is_page(wpinv_get_option('checkout_page')); |
|
20 | 20 | |
21 | - if ( !$is_object_set ) { |
|
22 | - unset( $wp_query->queried_object ); |
|
21 | + if (!$is_object_set) { |
|
22 | + unset($wp_query->queried_object); |
|
23 | 23 | } |
24 | 24 | |
25 | - if ( !$is_object_id_set ) { |
|
26 | - unset( $wp_query->queried_object_id ); |
|
25 | + if (!$is_object_id_set) { |
|
26 | + unset($wp_query->queried_object_id); |
|
27 | 27 | } |
28 | 28 | |
29 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
29 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | function wpinv_can_checkout() { |
33 | 33 | $can_checkout = true; // Always true for now |
34 | 34 | |
35 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
35 | + return (bool)apply_filters('wpinv_can_checkout', $can_checkout); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | function wpinv_get_success_page_uri() { |
39 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
40 | - $page_id = absint( $page_id ); |
|
39 | + $page_id = wpinv_get_option('success_page', 0); |
|
40 | + $page_id = absint($page_id); |
|
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
42 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | function wpinv_get_history_page_uri() { |
46 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
47 | - $page_id = absint( $page_id ); |
|
46 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
47 | + $page_id = absint($page_id); |
|
48 | 48 | |
49 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
49 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | function wpinv_is_success_page() { |
53 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
54 | - $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
53 | + $is_success_page = wpinv_get_option('success_page', false); |
|
54 | + $is_success_page = isset($is_success_page) ? is_page($is_success_page) : false; |
|
55 | 55 | |
56 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
56 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_invoice_history_page() { |
60 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
61 | - $ret = $ret ? is_page( $ret ) : false; |
|
62 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
60 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
61 | + $ret = $ret ? is_page($ret) : false; |
|
62 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
63 | 63 | } |
64 | 64 | |
65 | -function wpinv_send_to_success_page( $args = null ) { |
|
65 | +function wpinv_send_to_success_page($args = null) { |
|
66 | 66 | $redirect = wpinv_get_success_page_uri(); |
67 | 67 | |
68 | - if ( !empty( $args ) ) { |
|
68 | + if (!empty($args)) { |
|
69 | 69 | // Check for backward compatibility |
70 | - if ( is_string( $args ) ) |
|
71 | - $args = str_replace( '?', '', $args ); |
|
70 | + if (is_string($args)) |
|
71 | + $args = str_replace('?', '', $args); |
|
72 | 72 | |
73 | - $args = wp_parse_args( $args ); |
|
73 | + $args = wp_parse_args($args); |
|
74 | 74 | |
75 | - $redirect = add_query_arg( $args, $redirect ); |
|
75 | + $redirect = add_query_arg($args, $redirect); |
|
76 | 76 | } |
77 | 77 | |
78 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
78 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
79 | 79 | |
80 | - $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args ); |
|
81 | - wp_redirect( $redirect ); |
|
80 | + $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args); |
|
81 | + wp_redirect($redirect); |
|
82 | 82 | exit; |
83 | 83 | } |
84 | 84 | |
85 | -function wpinv_send_to_failed_page( $args = null ) { |
|
85 | +function wpinv_send_to_failed_page($args = null) { |
|
86 | 86 | $redirect = wpinv_get_failed_transaction_uri(); |
87 | 87 | |
88 | - if ( !empty( $args ) ) { |
|
88 | + if (!empty($args)) { |
|
89 | 89 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
90 | + if (is_string($args)) |
|
91 | + $args = str_replace('?', '', $args); |
|
92 | 92 | |
93 | - $args = wp_parse_args( $args ); |
|
93 | + $args = wp_parse_args($args); |
|
94 | 94 | |
95 | - $redirect = add_query_arg( $args, $redirect ); |
|
95 | + $redirect = add_query_arg($args, $redirect); |
|
96 | 96 | } |
97 | 97 | |
98 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
98 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
99 | 99 | |
100 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
101 | - wp_redirect( $redirect ); |
|
100 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
101 | + wp_redirect($redirect); |
|
102 | 102 | exit; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
105 | +function wpinv_get_checkout_uri($args = array()) { |
|
106 | + $uri = wpinv_get_option('checkout_page', false); |
|
107 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
109 | + if (!empty($args)) { |
|
110 | 110 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
111 | + if (is_string($args)) |
|
112 | + $args = str_replace('?', '', $args); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args($args); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
116 | + $uri = add_query_arg($args, $uri); |
|
117 | 117 | } |
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
123 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
124 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
125 | 125 | } |
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_send_back_to_checkout( $args = array() ) { |
|
130 | +function wpinv_send_back_to_checkout($args = array()) { |
|
131 | 131 | $redirect = wpinv_get_checkout_uri(); |
132 | 132 | |
133 | - if ( ! empty( $args ) ) { |
|
133 | + if (!empty($args)) { |
|
134 | 134 | // Check for backward compatibility |
135 | - if ( is_string( $args ) ) |
|
136 | - $args = str_replace( '?', '', $args ); |
|
135 | + if (is_string($args)) |
|
136 | + $args = str_replace('?', '', $args); |
|
137 | 137 | |
138 | - $args = wp_parse_args( $args ); |
|
138 | + $args = wp_parse_args($args); |
|
139 | 139 | |
140 | - $redirect = add_query_arg( $args, $redirect ); |
|
140 | + $redirect = add_query_arg($args, $redirect); |
|
141 | 141 | } |
142 | 142 | |
143 | - wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) ); |
|
143 | + wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args)); |
|
144 | 144 | exit; |
145 | 145 | } |
146 | 146 | |
147 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
148 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
149 | - $success_page = get_permalink( $success_page ); |
|
147 | +function wpinv_get_success_page_url($query_string = null) { |
|
148 | + $success_page = wpinv_get_option('success_page', 0); |
|
149 | + $success_page = get_permalink($success_page); |
|
150 | 150 | |
151 | - if ( $query_string ) |
|
151 | + if ($query_string) |
|
152 | 152 | $success_page .= $query_string; |
153 | 153 | |
154 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
154 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
158 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
159 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
157 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
158 | + $uri = wpinv_get_option('failure_page', ''); |
|
159 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
160 | 160 | |
161 | - if ( $extras ) |
|
161 | + if ($extras) |
|
162 | 162 | $uri .= $extras; |
163 | 163 | |
164 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
164 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | function wpinv_is_failed_transaction_page() { |
168 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
169 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
168 | + $ret = wpinv_get_option('failure_page', false); |
|
169 | + $ret = isset($ret) ? is_page($ret) : false; |
|
170 | 170 | |
171 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
171 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
172 | 172 | } |
173 | 173 | |
174 | -function wpinv_transaction_query( $type = 'start' ) { |
|
174 | +function wpinv_transaction_query($type = 'start') { |
|
175 | 175 | global $wpdb; |
176 | 176 | |
177 | 177 | $wpdb->hide_errors(); |
178 | 178 | |
179 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
180 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
179 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
180 | + define('WPINV_USE_TRANSACTIONS', true); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
184 | - switch ( $type ) { |
|
183 | + if (WPINV_USE_TRANSACTIONS) { |
|
184 | + switch ($type) { |
|
185 | 185 | case 'commit' : |
186 | - $wpdb->query( 'COMMIT' ); |
|
186 | + $wpdb->query('COMMIT'); |
|
187 | 187 | break; |
188 | 188 | case 'rollback' : |
189 | - $wpdb->query( 'ROLLBACK' ); |
|
189 | + $wpdb->query('ROLLBACK'); |
|
190 | 190 | break; |
191 | 191 | default : |
192 | - $wpdb->query( 'START TRANSACTION' ); |
|
192 | + $wpdb->query('START TRANSACTION'); |
|
193 | 193 | break; |
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | -function wpinv_create_invoice( $args = array(), $data = array() ) { |
|
198 | +function wpinv_create_invoice($args = array(), $data = array()) { |
|
199 | 199 | $default_args = array( |
200 | 200 | 'status' => '', |
201 | 201 | 'user_id' => null, |
@@ -205,191 +205,191 @@ discard block |
||
205 | 205 | 'parent' => 0 |
206 | 206 | ); |
207 | 207 | |
208 | - $args = wp_parse_args( $args, $default_args ); |
|
208 | + $args = wp_parse_args($args, $default_args); |
|
209 | 209 | $invoice_data = array(); |
210 | 210 | |
211 | - if ( $args['invoice_id'] > 0 ) { |
|
212 | - $updating = true; |
|
211 | + if ($args['invoice_id'] > 0) { |
|
212 | + $updating = true; |
|
213 | 213 | $invoice_data['post_type'] = 'wpi_invoice'; |
214 | 214 | $invoice_data['ID'] = $args['invoice_id']; |
215 | 215 | } else { |
216 | 216 | $updating = false; |
217 | 217 | $invoice_data['post_type'] = 'wpi_invoice'; |
218 | - $invoice_data['post_status'] = apply_filters( 'wpinv_default_invoice_status', 'pending' ); |
|
218 | + $invoice_data['post_status'] = apply_filters('wpinv_default_invoice_status', 'pending'); |
|
219 | 219 | $invoice_data['ping_status'] = 'closed'; |
220 | - $invoice_data['post_author'] = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
221 | - $invoice_data['post_title'] = wpinv_format_invoice_number( '0' ); |
|
222 | - $invoice_data['post_parent'] = absint( $args['parent'] ); |
|
223 | - if ( !empty( $args['created_date'] ) ) { |
|
220 | + $invoice_data['post_author'] = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
221 | + $invoice_data['post_title'] = wpinv_format_invoice_number('0'); |
|
222 | + $invoice_data['post_parent'] = absint($args['parent']); |
|
223 | + if (!empty($args['created_date'])) { |
|
224 | 224 | $invoice_data['post_date'] = $args['created_date']; |
225 | - $invoice_data['post_date_gmt'] = get_gmt_from_date( $args['created_date'] ); |
|
225 | + $invoice_data['post_date_gmt'] = get_gmt_from_date($args['created_date']); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - if ( $args['status'] ) { |
|
230 | - if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
231 | - return new WP_Error( 'wpinv_invalid_invoice_status', __( 'Invalid invoice status', 'invoicing' ) ); |
|
229 | + if ($args['status']) { |
|
230 | + if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) { |
|
231 | + return new WP_Error('wpinv_invalid_invoice_status', __('Invalid invoice status', 'invoicing')); |
|
232 | 232 | } |
233 | - $invoice_data['post_status'] = $args['status']; |
|
233 | + $invoice_data['post_status'] = $args['status']; |
|
234 | 234 | } |
235 | 235 | |
236 | - if ( ! is_null( $args['user_note'] ) ) { |
|
237 | - $invoice_data['post_excerpt'] = $args['user_note']; |
|
236 | + if (!is_null($args['user_note'])) { |
|
237 | + $invoice_data['post_excerpt'] = $args['user_note']; |
|
238 | 238 | } |
239 | 239 | |
240 | - if ( $updating ) { |
|
241 | - $invoice_id = wp_update_post( $invoice_data ); |
|
240 | + if ($updating) { |
|
241 | + $invoice_id = wp_update_post($invoice_data); |
|
242 | 242 | } else { |
243 | - $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true ); |
|
243 | + $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true); |
|
244 | 244 | } |
245 | 245 | |
246 | - if ( is_wp_error( $invoice_id ) ) { |
|
246 | + if (is_wp_error($invoice_id)) { |
|
247 | 247 | return $invoice_id; |
248 | 248 | } else { |
249 | - if ( !$updating ) { |
|
250 | - $invoice_number = wpinv_format_invoice_number( $invoice_id ); |
|
249 | + if (!$updating) { |
|
250 | + $invoice_number = wpinv_format_invoice_number($invoice_id); |
|
251 | 251 | |
252 | - $update = array( 'ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title( $invoice_number ) ); |
|
253 | - wp_update_post( $update ); |
|
252 | + $update = array('ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title($invoice_number)); |
|
253 | + wp_update_post($update); |
|
254 | 254 | |
255 | - update_post_meta( $invoice_id, '_wpinv_number', $invoice_number ); |
|
255 | + update_post_meta($invoice_id, '_wpinv_number', $invoice_number); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - if ( !$updating ) { |
|
260 | - update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) ); |
|
261 | - update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() ); |
|
262 | - update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) ); |
|
263 | - update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() ); |
|
264 | - update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() ); |
|
259 | + if (!$updating) { |
|
260 | + update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_'))); |
|
261 | + update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency()); |
|
262 | + update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax')); |
|
263 | + update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip()); |
|
264 | + update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent()); |
|
265 | 265 | ///update_post_meta( $invoice_id, '_wpinv_user_id', 0 ); |
266 | - update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) ); |
|
266 | + update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via'])); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | ///if ( is_numeric( $args['user_id'] ) ) { |
270 | 270 | ///update_post_meta( $invoice_id, '_wpinv_user_id', $args['user_id'] ); |
271 | 271 | ///} |
272 | 272 | |
273 | - update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION ); |
|
273 | + update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION); |
|
274 | 274 | |
275 | - return wpinv_get_invoice( $invoice_id ); |
|
275 | + return wpinv_get_invoice($invoice_id); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | function wpinv_get_prefix() { |
279 | 279 | $invoice_prefix = 'INV-'; |
280 | 280 | |
281 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
281 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | function wpinv_get_business_logo() { |
285 | - $business_logo = wpinv_get_option( 'logo' ); |
|
286 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
285 | + $business_logo = wpinv_get_option('logo'); |
|
286 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | function wpinv_get_business_name() { |
290 | 290 | $business_name = wpinv_get_option('store_name'); |
291 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
291 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | function wpinv_get_blogname() { |
295 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
295 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | function wpinv_get_admin_email() { |
299 | - $admin_email = get_option( 'admin_email' ); |
|
300 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
299 | + $admin_email = get_option('admin_email'); |
|
300 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | function wpinv_get_business_website() { |
304 | - $business_website = home_url( '/' ); |
|
305 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
304 | + $business_website = home_url('/'); |
|
305 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
306 | 306 | } |
307 | 307 | |
308 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
308 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
309 | 309 | $terms_text = ''; |
310 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
310 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | function wpinv_get_business_footer() { |
314 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
315 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
316 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
314 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
315 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
316 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | function wpinv_checkout_required_fields() { |
320 | 320 | $required_fields = array(); |
321 | 321 | |
322 | 322 | // Let payment gateways and other extensions determine if address fields should be required |
323 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
323 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
324 | 324 | |
325 | - if ( $require_billing_details ) { |
|
325 | + if ($require_billing_details) { |
|
326 | 326 | ///$required_fields['email'] = array( |
327 | 327 | ///'error_id' => 'invalid_email', |
328 | 328 | ///'error_message' => __( 'Please enter a valid email address', 'invoicing' ) |
329 | 329 | ///); |
330 | 330 | $required_fields['first_name'] = array( |
331 | 331 | 'error_id' => 'invalid_first_name', |
332 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
332 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
333 | 333 | ); |
334 | 334 | $required_fields['address'] = array( |
335 | 335 | 'error_id' => 'invalid_address', |
336 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
336 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
337 | 337 | ); |
338 | 338 | $required_fields['city'] = array( |
339 | 339 | 'error_id' => 'invalid_city', |
340 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
340 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
341 | 341 | ); |
342 | 342 | $required_fields['state'] = array( |
343 | 343 | 'error_id' => 'invalid_state', |
344 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
344 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
345 | 345 | ); |
346 | 346 | $required_fields['country'] = array( |
347 | 347 | 'error_id' => 'invalid_country', |
348 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
348 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
349 | 349 | ); |
350 | 350 | } |
351 | 351 | |
352 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
352 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | function wpinv_is_ssl_enforced() { |
356 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
357 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
356 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
357 | + return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
358 | 358 | } |
359 | 359 | |
360 | -function wpinv_user_can_print_invoice( $post ) { |
|
360 | +function wpinv_user_can_print_invoice($post) { |
|
361 | 361 | $allow = false; |
362 | 362 | |
363 | - if ( !( $user_id = get_current_user_id() ) ) { |
|
363 | + if (!($user_id = get_current_user_id())) { |
|
364 | 364 | return $allow; |
365 | 365 | } |
366 | 366 | |
367 | - if ( is_int( $post ) ) { |
|
368 | - $post = get_post( $post ); |
|
367 | + if (is_int($post)) { |
|
368 | + $post = get_post($post); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | // Allow to owner. |
372 | - if ( is_object( $post ) && !empty( $post->post_author ) && $post->post_author == $user_id ) { |
|
372 | + if (is_object($post) && !empty($post->post_author) && $post->post_author == $user_id) { |
|
373 | 373 | $allow = true; |
374 | 374 | } |
375 | 375 | |
376 | 376 | // Allow to admin user. |
377 | - if ( current_user_can( 'manage_options' ) ) { |
|
377 | + if (current_user_can('manage_options')) { |
|
378 | 378 | $allow = true; |
379 | 379 | } |
380 | 380 | |
381 | - return apply_filters( 'wpinv_can_print_invoice', $allow, $post ); |
|
381 | + return apply_filters('wpinv_can_print_invoice', $allow, $post); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | function wpinv_schedule_events() { |
385 | 385 | // hourly, daily and twicedaily |
386 | - if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) { |
|
387 | - wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' ); |
|
386 | + if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) { |
|
387 | + wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily'); |
|
388 | 388 | } |
389 | 389 | } |
390 | -add_action( 'wp', 'wpinv_schedule_events' ); |
|
390 | +add_action('wp', 'wpinv_schedule_events'); |
|
391 | 391 | |
392 | 392 | function wpinv_schedule_event_twicedaily() { |
393 | 393 | wpinv_email_payment_reminders(); |
394 | 394 | } |
395 | -add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' ); |
|
396 | 395 | \ No newline at end of file |
396 | +add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily'); |
|
397 | 397 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | 'wpinv_receipt' => __CLASS__ . '::receipt', |
15 | 15 | ); |
16 | 16 | |
17 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
18 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
17 | + foreach ($shortcodes as $shortcode => $function) { |
|
18 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
19 | 19 | } |
20 | 20 | |
21 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
21 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function shortcode_wrapper( |
@@ -32,24 +32,24 @@ discard block |
||
32 | 32 | ) { |
33 | 33 | ob_start(); |
34 | 34 | |
35 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
36 | - call_user_func( $function, $atts ); |
|
37 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
35 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
36 | + call_user_func($function, $atts); |
|
37 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
38 | 38 | |
39 | 39 | return ob_get_clean(); |
40 | 40 | } |
41 | 41 | |
42 | - public static function checkout( $atts = array(), $content = null ) { |
|
43 | - return wpinv_checkout_form( $atts, $content ); |
|
42 | + public static function checkout($atts = array(), $content = null) { |
|
43 | + return wpinv_checkout_form($atts, $content); |
|
44 | 44 | } |
45 | 45 | |
46 | - public static function messages( $atts, $content = null ) { |
|
46 | + public static function messages($atts, $content = null) { |
|
47 | 47 | ob_start(); |
48 | 48 | wpinv_print_errors(); |
49 | 49 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
50 | 50 | } |
51 | 51 | |
52 | - public static function history( $atts, $content = null ) { |
|
52 | + public static function history($atts, $content = null) { |
|
53 | 53 | ob_start(); |
54 | 54 | |
55 | 55 | wpinv_user_invoices(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return ob_get_clean(); |
58 | 58 | } |
59 | 59 | |
60 | - public static function receipt( $atts, $content = null ) { |
|
61 | - return wpinv_payment_receipt( $atts, $content ); |
|
60 | + public static function receipt($atts, $content = null) { |
|
61 | + return wpinv_payment_receipt($atts, $content); |
|
62 | 62 | } |
63 | 63 | } |
@@ -1,34 +1,34 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Billing_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $user_ID; |
10 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
11 | - $invoice = new WPInv_Invoice( $post_id ); |
|
10 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
11 | + $invoice = new WPInv_Invoice($post_id); |
|
12 | 12 | ?> |
13 | 13 | <div class="gdmbx2-wrap form-table"> |
14 | 14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
15 | 15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
16 | 16 | <div class="gdmbx-th"> |
17 | - <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
|
17 | + <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label> |
|
18 | 18 | </div> |
19 | 19 | <div class="gdmbx-td gdmbx-customer-div"> |
20 | - <?php wpinv_dropdown_users( array( |
|
20 | + <?php wpinv_dropdown_users(array( |
|
21 | 21 | 'name' => 'post_author_override', |
22 | 22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
23 | 23 | 'include_selected' => true, |
24 | 24 | 'show' => 'user_email', |
25 | 25 | 'orderby' => 'user_email', |
26 | 26 | 'class' => 'gdmbx2-text-large' |
27 | - ) ); ?> |
|
27 | + )); ?> |
|
28 | 28 | </div> |
29 | 29 | </div> |
30 | 30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
31 | - <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
|
31 | + <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label> |
|
32 | 32 | </div> |
33 | 33 | <div class="gdmbx-td"> |
34 | 34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
@@ -36,56 +36,56 @@ discard block |
||
36 | 36 | </div> |
37 | 37 | </div> |
38 | 38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
39 | - <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
|
39 | + <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label> |
|
40 | 40 | </div> |
41 | 41 | <div class="gdmbx-td"> |
42 | - <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
|
43 | - <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
|
44 | - <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
|
42 | + <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a> |
|
43 | + <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a> |
|
44 | + <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a> |
|
45 | 45 | </div> |
46 | 46 | </div> |
47 | 47 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
48 | - <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?> <span class="required">*</span></label></div> |
|
48 | + <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
49 | 49 | <div class="gdmbx-td"> |
50 | - <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" required="required" /> |
|
50 | + <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" required="required" /> |
|
51 | 51 | </div> |
52 | 52 | </div> |
53 | 53 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
54 | - <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
|
54 | + <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div> |
|
55 | 55 | <div class="gdmbx-td"> |
56 | - <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
|
56 | + <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" /> |
|
57 | 57 | </div> |
58 | 58 | </div> |
59 | 59 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
60 | - <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
|
60 | + <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div> |
|
61 | 61 | <div class="gdmbx-td"> |
62 | - <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
|
62 | + <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" /> |
|
63 | 63 | </div> |
64 | 64 | </div> |
65 | 65 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
66 | - <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
|
66 | + <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div> |
|
67 | 67 | <div class="gdmbx-td"> |
68 | - <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
|
68 | + <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" /> |
|
69 | 69 | </div> |
70 | 70 | </div> |
71 | 71 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
72 | - <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?> <span class="required">*</span></label></div> |
|
72 | + <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
73 | 73 | <div class="gdmbx-td"> |
74 | - <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" required="required" /> |
|
74 | + <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" required="required" /> |
|
75 | 75 | </div> |
76 | 76 | </div> |
77 | 77 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
78 | - <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?> <span class="required">*</span></label></div> |
|
78 | + <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
79 | 79 | <div class="gdmbx-td"> |
80 | - <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" required="required" /> |
|
80 | + <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" required="required" /> |
|
81 | 81 | </div> |
82 | 82 | </div> |
83 | 83 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
84 | - <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="required">*</span> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
84 | + <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="required">*</span> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
|
85 | 85 | <div class="gdmbx-td"> |
86 | 86 | <?php |
87 | - echo wpinv_html_select( array( |
|
88 | - 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
|
87 | + echo wpinv_html_select(array( |
|
88 | + 'options' => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()), |
|
89 | 89 | 'name' => 'wpinv_country', |
90 | 90 | 'id' => 'wpinv_country', |
91 | 91 | 'selected' => $invoice->country, |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'show_option_none' => false, |
94 | 94 | 'class' => 'gdmbx2-text-large', |
95 | 95 | 'chosen' => false, |
96 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
96 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
97 | 97 | 'required' => true, |
98 | - ) ); |
|
98 | + )); |
|
99 | 99 | ?> |
100 | 100 | </div> |
101 | 101 | </div> |
102 | 102 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
103 | - <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?> <span class="required">*</span></label></div> |
|
103 | + <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?> <span class="required">*</span></label></div> |
|
104 | 104 | <div class="gdmbx-td"> |
105 | 105 | <?php |
106 | - $states = wpinv_get_country_states( $invoice->country ); |
|
107 | - if( !empty( $states ) ) { |
|
108 | - echo wpinv_html_select( array( |
|
109 | - 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
|
106 | + $states = wpinv_get_country_states($invoice->country); |
|
107 | + if (!empty($states)) { |
|
108 | + echo wpinv_html_select(array( |
|
109 | + 'options' => array_merge(array('' => __('Choose a state', 'invoicing')), $states), |
|
110 | 110 | 'name' => 'wpinv_state', |
111 | 111 | 'id' => 'wpinv_state', |
112 | 112 | 'selected' => $invoice->state, |
@@ -114,44 +114,44 @@ discard block |
||
114 | 114 | 'show_option_none' => false, |
115 | 115 | 'class' => 'gdmbx2-text-large', |
116 | 116 | 'chosen' => false, |
117 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
117 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
118 | 118 | 'required' => true, |
119 | - ) ); |
|
119 | + )); |
|
120 | 120 | } else { |
121 | - echo wpinv_html_text( array( |
|
121 | + echo wpinv_html_text(array( |
|
122 | 122 | 'name' => 'wpinv_state', |
123 | - 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
|
123 | + 'value' => !empty($invoice->state) ? $invoice->state : '', |
|
124 | 124 | 'id' => 'wpinv_state', |
125 | 125 | 'class' => 'gdmbx2-text-large', |
126 | 126 | 'required' => true, |
127 | - ) ); |
|
127 | + )); |
|
128 | 128 | } |
129 | 129 | ?> |
130 | 130 | </div> |
131 | 131 | </div> |
132 | 132 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
133 | - <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
|
133 | + <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div> |
|
134 | 134 | <div class="gdmbx-td"> |
135 | - <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
|
135 | + <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" /> |
|
136 | 136 | </div> |
137 | 137 | </div> |
138 | 138 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
139 | - <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?> <?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="required">*</span>'; } ?></label></div> |
|
139 | + <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?> <?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="required">*</span>'; } ?></label></div> |
|
140 | 140 | <div class="gdmbx-td"> |
141 | - <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" <?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo 'required="required"'; } ?> /> |
|
141 | + <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" <?php if (wpinv_get_option('phone_mandatory')) { echo 'required="required"'; } ?> /> |
|
142 | 142 | </div> |
143 | 143 | </div> |
144 | 144 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
145 | - <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
|
146 | - <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
145 | + <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?> |
|
146 | + <a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
|
147 | 147 | <?php } ?></label></div> |
148 | 148 | <div class="gdmbx-td"> |
149 | - <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
|
149 | + <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly /> |
|
150 | 150 | </div> |
151 | 151 | </div> |
152 | 152 | </div> |
153 | 153 | </div> |
154 | -<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
|
154 | +<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?> |
|
155 | 155 | <?php |
156 | 156 | } |
157 | 157 | } |
@@ -1,153 +1,153 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Details { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | $currency_symbol = wpinv_currency_symbol(); |
10 | 10 | $statuses = wpinv_get_invoice_statuses(); |
11 | 11 | |
12 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
13 | - $invoice = new WPInv_Invoice( $post_id ); |
|
12 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
13 | + $invoice = new WPInv_Invoice($post_id); |
|
14 | 14 | |
15 | - $status = $invoice->get_status( false ); // Current status |
|
15 | + $status = $invoice->get_status(false); // Current status |
|
16 | 16 | $discount = $invoice->get_discount(); |
17 | 17 | $discount_code = $discount > 0 ? $invoice->get_discount_code() : ''; |
18 | 18 | $invoice_number = $invoice->get_number(); |
19 | 19 | |
20 | 20 | $date_created = $invoice->get_created_date(); |
21 | - $datetime_created = strtotime( $date_created ); |
|
22 | - $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : ''; |
|
21 | + $datetime_created = strtotime($date_created); |
|
22 | + $date_created = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : ''; |
|
23 | 23 | $date_completed = $invoice->get_completed_date(); |
24 | - $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a'; |
|
24 | + $date_completed = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a'; |
|
25 | 25 | ?> |
26 | 26 | <div class="gdmbx2-wrap form-table"> |
27 | 27 | <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details"> |
28 | 28 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created"> |
29 | - <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div> |
|
30 | - <div class="gdmbx-td"><?php echo $date_created;?></div> |
|
29 | + <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div> |
|
30 | + <div class="gdmbx-td"><?php echo $date_created; ?></div> |
|
31 | 31 | </div> |
32 | - <?php if ( wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?> |
|
32 | + <?php if (wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?> |
|
33 | 33 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue"> |
34 | - <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div> |
|
34 | + <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div> |
|
35 | 35 | <div class="gdmbx-td"> |
36 | - <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd"> |
|
36 | + <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd"> |
|
37 | 37 | </div> |
38 | 38 | </div> |
39 | 39 | <?php } ?> |
40 | - <?php if ( $date_completed && $date_completed != 'n/a' ) { ?> |
|
40 | + <?php if ($date_completed && $date_completed != 'n/a') { ?> |
|
41 | 41 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed"> |
42 | - <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div> |
|
43 | - <div class="gdmbx-td"><?php echo $date_completed;?></div> |
|
42 | + <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div> |
|
43 | + <div class="gdmbx-td"><?php echo $date_completed; ?></div> |
|
44 | 44 | </div> |
45 | 45 | <?php } ?> |
46 | 46 | <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status"> |
47 | - <div class="gdmbx-th"><label for="wpinv_status"><?php _e( 'Invoice Status:', 'invoicing' );?></label></div> |
|
47 | + <div class="gdmbx-th"><label for="wpinv_status"><?php _e('Invoice Status:', 'invoicing'); ?></label></div> |
|
48 | 48 | <div class="gdmbx-td"> |
49 | 49 | <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select"> |
50 | - <?php foreach ( $statuses as $value => $label ) { ?> |
|
51 | - <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option> |
|
50 | + <?php foreach ($statuses as $value => $label) { ?> |
|
51 | + <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option> |
|
52 | 52 | <?php } ?> |
53 | 53 | </select> |
54 | 54 | </div> |
55 | 55 | </div> |
56 | 56 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout"> |
57 | - <div class="gdmbx-th"><label for="wpinv_number"><?php _e( 'Invoice Number:', 'invoicing' );?></label></div> |
|
57 | + <div class="gdmbx-th"><label for="wpinv_number"><?php _e('Invoice Number:', 'invoicing'); ?></label></div> |
|
58 | 58 | <div class="gdmbx-td"> |
59 | - <input type="text" placeholder="<?php echo esc_attr( wpinv_format_invoice_number( 1 ) ); ?>" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text"> |
|
59 | + <input type="text" placeholder="<?php echo esc_attr(wpinv_format_invoice_number(1)); ?>" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text"> |
|
60 | 60 | </div> |
61 | 61 | </div> |
62 | - <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); ?> |
|
63 | - <?php if ( !( $is_paid = $invoice->is_paid() ) || $discount_code ) { ?> |
|
62 | + <?php do_action('wpinv_meta_box_details_inner', $post_id); ?> |
|
63 | + <?php if (!($is_paid = $invoice->is_paid()) || $discount_code) { ?> |
|
64 | 64 | <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout"> |
65 | - <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div> |
|
65 | + <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div> |
|
66 | 66 | <div class="gdmbx-td"> |
67 | - <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
67 | + <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | <?php } ?> |
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout"> |
74 | - <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php _e( 'Send Invoice:', 'invoicing' ); ?></label> |
|
74 | + <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php _e('Send Invoice:', 'invoicing'); ?></label> |
|
75 | 75 | <select id="wpi_save_send" name="wpi_save_send"> |
76 | - <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option> |
|
77 | - <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option> |
|
76 | + <option value="1"><?php _e('Yes', 'invoicing'); ?></option> |
|
77 | + <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option> |
|
78 | 78 | </select> |
79 | 79 | </p> |
80 | - <p class="wpi-meta-row wpi-send-info"><?php esc_attr_e( 'After save invoice this will send a copy of the invoice to the user’s email address.', 'invoicing' ); ?></p> |
|
80 | + <p class="wpi-meta-row wpi-send-info"><?php esc_attr_e('After save invoice this will send a copy of the invoice to the user’s email address.', 'invoicing'); ?></p> |
|
81 | 81 | </div> |
82 | -<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?> |
|
82 | +<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?> |
|
83 | 83 | <?php |
84 | 84 | } |
85 | 85 | |
86 | - public static function resend_invoice( $post ) { |
|
86 | + public static function resend_invoice($post) { |
|
87 | 87 | global $wpi_mb_invoice; |
88 | 88 | |
89 | - if ( empty( $wpi_mb_invoice ) ) { |
|
89 | + if (empty($wpi_mb_invoice)) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
93 | - do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice ); |
|
93 | + do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice); |
|
94 | 94 | |
95 | - if ( $email = $wpi_mb_invoice->get_email() ) { |
|
96 | - $email_url = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ); |
|
97 | - $reminder_url = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) ); |
|
95 | + if ($email = $wpi_mb_invoice->get_email()) { |
|
96 | + $email_url = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)); |
|
97 | + $reminder_url = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID)); |
|
98 | 98 | ?> |
99 | - <p class="wpi-meta-row wpi-resend-info"><?php esc_attr_e( 'This will send a copy of the invoice to the user’s email address.', 'invoicing' ); ?></p> |
|
100 | - <p class="wpi-meta-row wpi-resend-email"><a title="<?php esc_attr_e( 'Send invoice to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_url ); ?>" class="button button-secondary"><?php esc_attr_e( 'Resend Invoice', 'invoicing' ); ?></a></p> |
|
101 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?> |
|
102 | - <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $reminder_url ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p> |
|
99 | + <p class="wpi-meta-row wpi-resend-info"><?php esc_attr_e('This will send a copy of the invoice to the user’s email address.', 'invoicing'); ?></p> |
|
100 | + <p class="wpi-meta-row wpi-resend-email"><a title="<?php esc_attr_e('Send invoice to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_url); ?>" class="button button-secondary"><?php esc_attr_e('Resend Invoice', 'invoicing'); ?></a></p> |
|
101 | + <?php if (wpinv_get_option('overdue_active') && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?> |
|
102 | + <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($reminder_url); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p> |
|
103 | 103 | <?php } ?> |
104 | 104 | <?php |
105 | 105 | } |
106 | 106 | |
107 | - do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice ); |
|
107 | + do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice); |
|
108 | 108 | } |
109 | 109 | |
110 | - public static function subscriptions( $post ) { |
|
110 | + public static function subscriptions($post) { |
|
111 | 111 | global $wpi_mb_invoice; |
112 | 112 | |
113 | 113 | $invoice = $wpi_mb_invoice; |
114 | 114 | |
115 | - if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) { |
|
115 | + if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) { |
|
116 | 116 | $payments = $invoice->get_child_payments(); |
117 | 117 | |
118 | 118 | $total_payments = (int)$invoice->get_total_payments(); |
119 | 119 | $subscription = $invoice->get_subscription_data(); |
120 | 120 | |
121 | - $billing_cycle = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() ); |
|
122 | - $times_billed = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] ); |
|
121 | + $billing_cycle = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency()); |
|
122 | + $times_billed = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']); |
|
123 | 123 | $subscription_status = $invoice->get_subscription_status(); |
124 | 124 | ?> |
125 | - <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p> |
|
126 | - <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?> |
|
127 | - <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p> |
|
125 | + <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p> |
|
126 | + <?php if ($subscription_id = $invoice->get_subscription_id()) { ?> |
|
127 | + <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p> |
|
128 | 128 | <?php } ?> |
129 | - <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p> |
|
130 | - <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p> |
|
131 | - <?php if ( !empty( $payments ) || $invoice->is_paid() ) { ?> |
|
132 | - <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p> |
|
133 | - <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p> |
|
134 | - <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?> |
|
135 | - <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p> |
|
129 | + <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p> |
|
130 | + <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p> |
|
131 | + <?php if (!empty($payments) || $invoice->is_paid()) { ?> |
|
132 | + <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p> |
|
133 | + <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p> |
|
134 | + <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?> |
|
135 | + <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p> |
|
136 | 136 | <?php } ?> |
137 | - <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?> |
|
138 | - <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p> |
|
137 | + <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?> |
|
138 | + <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p> |
|
139 | 139 | <?php } ?> |
140 | - <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?> |
|
141 | - <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p> |
|
140 | + <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?> |
|
141 | + <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p> |
|
142 | 142 | <?php } ?> |
143 | - <?php if ( !empty( $payments ) ) { ?> |
|
144 | - <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p> |
|
143 | + <?php if (!empty($payments)) { ?> |
|
144 | + <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p> |
|
145 | 145 | <ul id="wpi-sub-payments"> |
146 | - <?php foreach ( $payments as $invoice_id ) { ?> |
|
146 | + <?php foreach ($payments as $invoice_id) { ?> |
|
147 | 147 | <li> |
148 | - <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a> – |
|
149 | - <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?> – </span> |
|
150 | - <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span> |
|
148 | + <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a> – |
|
149 | + <span><?php echo wpinv_get_invoice_date($invoice_id); ?> – </span> |
|
150 | + <span><?php echo wpinv_payment_total($invoice_id, true); ?></span> |
|
151 | 151 | </li> |
152 | 152 | <?php } ?> |
153 | 153 | </ul> |
@@ -155,47 +155,47 @@ discard block |
||
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | - public static function renewals( $post ) { |
|
158 | + public static function renewals($post) { |
|
159 | 159 | global $wpi_mb_invoice; |
160 | 160 | |
161 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
162 | - $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice ); |
|
163 | - $parent_id = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice ); |
|
161 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
162 | + $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice); |
|
163 | + $parent_id = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice); |
|
164 | 164 | ?> |
165 | - <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p> |
|
166 | - <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p> |
|
165 | + <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p> |
|
166 | + <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p> |
|
167 | 167 | <?php |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - public static function payment_meta( $post ) { |
|
171 | + public static function payment_meta($post) { |
|
172 | 172 | global $wpi_mb_invoice; |
173 | 173 | |
174 | - $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false; |
|
175 | - if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() ) { |
|
174 | + $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false; |
|
175 | + if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid()) { |
|
176 | 176 | $set_dateway = true; |
177 | 177 | } |
178 | 178 | |
179 | 179 | ?> |
180 | 180 | <p class="wpi-meta-row"> |
181 | - <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?> |
|
182 | - <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label> |
|
181 | + <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?> |
|
182 | + <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label> |
|
183 | 183 | <select required="required" id="wpinv_gateway" name="wpinv_gateway"> |
184 | - <?php foreach ( $gateways as $name => $gateway ) { |
|
185 | - if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) { |
|
184 | + <?php foreach ($gateways as $name => $gateway) { |
|
185 | + if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) { |
|
186 | 186 | continue; |
187 | 187 | } |
188 | 188 | ?> |
189 | - <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
189 | + <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option> |
|
190 | 190 | <?php } ?> |
191 | 191 | </select> |
192 | 192 | <?php } else { |
193 | - echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) ); |
|
193 | + echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway)); |
|
194 | 194 | } ?> |
195 | 195 | </p> |
196 | - <?php if ( $wpi_mb_invoice->is_paid() ) { ?> |
|
197 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $wpi_mb_invoice->get_key() ); ?></p> |
|
198 | - <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p> |
|
196 | + <?php if ($wpi_mb_invoice->is_paid()) { ?> |
|
197 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $wpi_mb_invoice->get_key()); ?></p> |
|
198 | + <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p> |
|
199 | 199 | <?php } ?> |
200 | 200 | <?php |
201 | 201 | } |
@@ -1,39 +1,39 @@ |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | class WPInv_Meta_Box_Notes { |
8 | - public static function output( $post ) { |
|
8 | + public static function output($post) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $notes = wpinv_get_invoice_notes( $post->ID ); |
|
11 | + $notes = wpinv_get_invoice_notes($post->ID); |
|
12 | 12 | |
13 | 13 | echo '<ul class="invoice_notes">'; |
14 | 14 | |
15 | - if ( $notes ) { |
|
16 | - foreach( $notes as $note ) { |
|
17 | - wpinv_get_invoice_note_line_item( $note ); |
|
15 | + if ($notes) { |
|
16 | + foreach ($notes as $note) { |
|
17 | + wpinv_get_invoice_note_line_item($note); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | } else { |
21 | - echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>'; |
|
21 | + echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | echo '</ul>'; |
25 | 25 | ?> |
26 | 26 | <div class="add_note"> |
27 | - <h4><?php _e( 'Add note', 'invoicing' ); ?></h4> |
|
27 | + <h4><?php _e('Add note', 'invoicing'); ?></h4> |
|
28 | 28 | <p> |
29 | 29 | <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea> |
30 | 30 | </p> |
31 | 31 | <p> |
32 | 32 | <select name="invoice_note_type" id="invoice_note_type"> |
33 | - <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option> |
|
34 | - <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option> |
|
33 | + <option value=""><?php _e('Private note', 'invoicing'); ?></option> |
|
34 | + <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option> |
|
35 | 35 | </select> |
36 | - <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span> |
|
36 | + <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span> |
|
37 | 37 | </p> |
38 | 38 | </div> |
39 | 39 | <?php |
@@ -1,22 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | -register_activation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_activation' ); |
|
3 | -register_deactivation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation' ); |
|
2 | +register_activation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_activation'); |
|
3 | +register_deactivation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation'); |
|
4 | 4 | |
5 | -function wpinv_plugin_activation( $network_wide = false ) { |
|
6 | - set_transient( '_wpinv_activation_redirect', true, 30 ); |
|
7 | - wpinv_install( $network_wide ); |
|
5 | +function wpinv_plugin_activation($network_wide = false) { |
|
6 | + set_transient('_wpinv_activation_redirect', true, 30); |
|
7 | + wpinv_install($network_wide); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | function wpinv_plugin_deactivation() { |
11 | 11 | // plugin deactivation stuff |
12 | 12 | } |
13 | 13 | |
14 | -function wpinv_install( $network_wide = false ) { |
|
14 | +function wpinv_install($network_wide = false) { |
|
15 | 15 | global $wpdb; |
16 | 16 | |
17 | - if ( is_multisite() && $network_wide ) { |
|
18 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
19 | - switch_to_blog( $blog_id ); |
|
17 | + if (is_multisite() && $network_wide) { |
|
18 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
19 | + switch_to_blog($blog_id); |
|
20 | 20 | wpinv_run_install(); |
21 | 21 | restore_current_blog(); |
22 | 22 | } |
@@ -32,75 +32,75 @@ discard block |
||
32 | 32 | wpinv_register_post_types(); |
33 | 33 | |
34 | 34 | // Clear the permalinks |
35 | - flush_rewrite_rules( false ); |
|
35 | + flush_rewrite_rules(false); |
|
36 | 36 | |
37 | 37 | // Add Upgraded From Option |
38 | - $current_version = get_option( 'wpinv_version' ); |
|
39 | - if ( $current_version ) { |
|
40 | - update_option( 'wpinv_version_upgraded_from', $current_version ); |
|
38 | + $current_version = get_option('wpinv_version'); |
|
39 | + if ($current_version) { |
|
40 | + update_option('wpinv_version_upgraded_from', $current_version); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // Pull options from WP, not GD Invoice's global |
44 | - $current_options = get_option( 'wpinv_settings', array() ); |
|
44 | + $current_options = get_option('wpinv_settings', array()); |
|
45 | 45 | |
46 | 46 | // Setup some default options |
47 | 47 | $options = wpinv_create_pages(); |
48 | 48 | |
49 | 49 | // Populate some default values |
50 | - foreach( wpinv_get_registered_settings() as $tab => $sections ) { |
|
51 | - foreach( $sections as $section => $settings) { |
|
50 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
51 | + foreach ($sections as $section => $settings) { |
|
52 | 52 | // Check for backwards compatibility |
53 | - $tab_sections = wpinv_get_settings_tab_sections( $tab ); |
|
54 | - if( ! is_array( $tab_sections ) || ! array_key_exists( $section, $tab_sections ) ) { |
|
53 | + $tab_sections = wpinv_get_settings_tab_sections($tab); |
|
54 | + if (!is_array($tab_sections) || !array_key_exists($section, $tab_sections)) { |
|
55 | 55 | $section = 'main'; |
56 | 56 | $settings = $sections; |
57 | 57 | } |
58 | 58 | |
59 | - foreach ( $settings as $option ) { |
|
60 | - if ( !empty( $option['id'] ) && !isset( $wpinv_options[ $option['id'] ] ) ) { |
|
61 | - if ( 'checkbox' == $option['type'] && !empty( $option['std'] ) ) { |
|
62 | - $options[ $option['id'] ] = '1'; |
|
63 | - } else if ( !empty( $option['std'] ) ) { |
|
64 | - $options[ $option['id'] ] = $option['std']; |
|
59 | + foreach ($settings as $option) { |
|
60 | + if (!empty($option['id']) && !isset($wpinv_options[$option['id']])) { |
|
61 | + if ('checkbox' == $option['type'] && !empty($option['std'])) { |
|
62 | + $options[$option['id']] = '1'; |
|
63 | + } else if (!empty($option['std'])) { |
|
64 | + $options[$option['id']] = $option['std']; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - $merged_options = array_merge( $wpinv_options, $options ); |
|
71 | + $merged_options = array_merge($wpinv_options, $options); |
|
72 | 72 | $wpinv_options = $merged_options; |
73 | 73 | |
74 | - update_option( 'wpinv_settings', $merged_options ); |
|
75 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
74 | + update_option('wpinv_settings', $merged_options); |
|
75 | + update_option('wpinv_version', WPINV_VERSION); |
|
76 | 76 | |
77 | 77 | // Check for PHP Session support, and enable if available |
78 | 78 | $wpi_session->use_php_sessions(); |
79 | 79 | |
80 | 80 | // Add a temporary option to note that GD Invoice pages have been created |
81 | - set_transient( '_wpinv_installed', $merged_options, 30 ); |
|
81 | + set_transient('_wpinv_installed', $merged_options, 30); |
|
82 | 82 | |
83 | 83 | // Bail if activating from network, or bulk |
84 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
84 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
85 | 85 | return; |
86 | 86 | } |
87 | 87 | |
88 | 88 | // Add the transient to redirect |
89 | - set_transient( '_wpinv_activation_redirect', true, 30 ); |
|
89 | + set_transient('_wpinv_activation_redirect', true, 30); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * When a new Blog is created in multisite, see if Invoicing is network activated, and run the installer. |
94 | 94 | * |
95 | 95 | */ |
96 | -function wpinv_new_blog_created( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
97 | - if ( is_plugin_active_for_network( plugin_basename( WPINV_PLUGIN_FILE ) ) ) { |
|
98 | - switch_to_blog( $blog_id ); |
|
96 | +function wpinv_new_blog_created($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
97 | + if (is_plugin_active_for_network(plugin_basename(WPINV_PLUGIN_FILE))) { |
|
98 | + switch_to_blog($blog_id); |
|
99 | 99 | wpinv_run_install(); |
100 | 100 | restore_current_blog(); |
101 | 101 | } |
102 | 102 | } |
103 | -add_action( 'wpmu_new_blog', 'wpinv_new_blog_created', 10, 6 ); |
|
103 | +add_action('wpmu_new_blog', 'wpinv_new_blog_created', 10, 6); |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Post-installation. |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | * Runs just after plugin installation and exposes the wpinv_after_install hook. |
109 | 109 | */ |
110 | 110 | function wpinv_after_install() { |
111 | - if ( ! is_admin() ) { |
|
111 | + if (!is_admin()) { |
|
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | - $wpinv_options = get_transient( '_wpinv_installed' ); |
|
116 | - $wpinv_table_check = get_option( '_wpinv_table_check', false ); |
|
115 | + $wpinv_options = get_transient('_wpinv_installed'); |
|
116 | + $wpinv_table_check = get_option('_wpinv_table_check', false); |
|
117 | 117 | |
118 | - if ( false === $wpinv_table_check || current_time( 'timestamp' ) > $wpinv_table_check ) { |
|
119 | - update_option( '_wpinv_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
118 | + if (false === $wpinv_table_check || current_time('timestamp') > $wpinv_table_check) { |
|
119 | + update_option('_wpinv_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
120 | 120 | } |
121 | 121 | |
122 | - if ( false !== $wpinv_options ) { |
|
122 | + if (false !== $wpinv_options) { |
|
123 | 123 | // Delete the transient |
124 | - delete_transient( '_wpinv_installed' ); |
|
124 | + delete_transient('_wpinv_installed'); |
|
125 | 125 | } |
126 | 126 | } |
127 | -add_action( 'admin_init', 'wpinv_after_install' ); |
|
127 | +add_action('admin_init', 'wpinv_after_install'); |
|
128 | 128 | |
129 | 129 | function wpinv_create_pages() { |
130 | 130 | global $wpinv_options; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | $options = array(); |
133 | 133 | |
134 | 134 | // Checks if the purchase page option exists |
135 | - if ( ! array_key_exists( 'checkout_page', $wpinv_options ) ) { |
|
135 | + if (!array_key_exists('checkout_page', $wpinv_options)) { |
|
136 | 136 | // Checkout Page |
137 | 137 | $checkout = wp_insert_post( |
138 | 138 | array( |
139 | - 'post_title' => __( 'Checkout', 'invoicing' ), |
|
139 | + 'post_title' => __('Checkout', 'invoicing'), |
|
140 | 140 | 'post_content' => '[wpinv_checkout]', |
141 | 141 | 'post_status' => 'publish', |
142 | 142 | 'post_author' => 1, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | // Invoice History (History) Page |
151 | 151 | $history = wp_insert_post( |
152 | 152 | array( |
153 | - 'post_title' => __( 'Invoice History', 'invoicing' ), |
|
153 | + 'post_title' => __('Invoice History', 'invoicing'), |
|
154 | 154 | 'post_content' => '[wpinv_history]', |
155 | 155 | 'post_status' => 'publish', |
156 | 156 | 'post_author' => 1, |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | // Payment Confirmation (Success) Page |
165 | 165 | $success = wp_insert_post( |
166 | 166 | array( |
167 | - 'post_title' => __( 'Payment Confirmation', 'invoicing' ), |
|
168 | - 'post_content' => __( '[wpinv_receipt]', 'invoicing' ), |
|
167 | + 'post_title' => __('Payment Confirmation', 'invoicing'), |
|
168 | + 'post_content' => __('[wpinv_receipt]', 'invoicing'), |
|
169 | 169 | 'post_status' => 'publish', |
170 | 170 | 'post_author' => 1, |
171 | 171 | 'post_parent' => $checkout, |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | // Failed Payment Page |
179 | 179 | $failed = wp_insert_post( |
180 | 180 | array( |
181 | - 'post_title' => __( 'Transaction Failed', 'invoicing' ), |
|
182 | - 'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
181 | + 'post_title' => __('Transaction Failed', 'invoicing'), |
|
182 | + 'post_content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
183 | 183 | 'post_status' => 'publish', |
184 | 184 | 'post_author' => 1, |
185 | 185 | 'post_type' => 'page', |
@@ -1,65 +1,65 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // MUST have WordPress. |
3 | -if ( !defined( 'WPINC' ) ) { |
|
4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
3 | +if (!defined('WPINC')) { |
|
4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
5 | 5 | } |
6 | 6 | |
7 | -function wpinv_add_meta_boxes( $post_type, $post ) { |
|
7 | +function wpinv_add_meta_boxes($post_type, $post) { |
|
8 | 8 | global $wpi_mb_invoice; |
9 | - if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) { |
|
10 | - $wpi_mb_invoice = wpinv_get_invoice( $post->ID ); |
|
9 | + if ($post_type == 'wpi_invoice' && !empty($post->ID)) { |
|
10 | + $wpi_mb_invoice = wpinv_get_invoice($post->ID); |
|
11 | 11 | } |
12 | 12 | |
13 | - if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) { |
|
14 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' ); |
|
13 | + if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) { |
|
14 | + add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high'); |
|
15 | 15 | } |
16 | 16 | |
17 | - if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) { |
|
18 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' ); |
|
17 | + if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) { |
|
18 | + add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high'); |
|
19 | 19 | } |
20 | 20 | |
21 | - if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) { |
|
22 | - add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' ); |
|
21 | + if (wpinv_is_subscription_payment($wpi_mb_invoice)) { |
|
22 | + add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high'); |
|
23 | 23 | } |
24 | 24 | |
25 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
26 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' ); |
|
25 | + add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default'); |
|
26 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default'); |
|
27 | 27 | |
28 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' ); |
|
29 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
30 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
28 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high'); |
|
29 | + add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high'); |
|
30 | + add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high'); |
|
31 | 31 | } |
32 | -add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
|
32 | +add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2); |
|
33 | 33 | |
34 | -function wpinv_save_meta_boxes( $post_id, $post, $update = false ) { |
|
35 | - remove_action( 'save_post', __FUNCTION__ ); |
|
34 | +function wpinv_save_meta_boxes($post_id, $post, $update = false) { |
|
35 | + remove_action('save_post', __FUNCTION__); |
|
36 | 36 | |
37 | 37 | // $post_id and $post are required |
38 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
38 | + if (empty($post_id) || empty($post)) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | |
42 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
42 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Dont' save meta boxes for revisions or autosaves |
47 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
47 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | - if ( $post->post_type == 'wpi_invoice' ) { |
|
52 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
51 | + if ($post->post_type == 'wpi_invoice') { |
|
52 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | - if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) { |
|
57 | - WPInv_Meta_Box_Items::save( $post_id, $_POST, $post ); |
|
56 | + if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) { |
|
57 | + WPInv_Meta_Box_Items::save($post_id, $_POST, $post); |
|
58 | 58 | } |
59 | - } else if ( $post->post_type == 'wpi_item' ) { |
|
59 | + } else if ($post->post_type == 'wpi_item') { |
|
60 | 60 | // verify nonce |
61 | - if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) { |
|
62 | - $fields = array(); |
|
61 | + if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) { |
|
62 | + $fields = array(); |
|
63 | 63 | $fields['_wpinv_price'] = 'wpinv_item_price'; |
64 | 64 | $fields['_wpinv_vat_class'] = 'wpinv_vat_class'; |
65 | 65 | $fields['_wpinv_vat_rule'] = 'wpinv_vat_rules'; |
@@ -72,291 +72,291 @@ discard block |
||
72 | 72 | $fields['_wpinv_trial_period'] = 'wpinv_trial_period'; |
73 | 73 | $fields['_wpinv_trial_interval'] = 'wpinv_trial_interval'; |
74 | 74 | |
75 | - if ( !isset( $_POST['wpinv_is_recurring'] ) ) { |
|
75 | + if (!isset($_POST['wpinv_is_recurring'])) { |
|
76 | 76 | $_POST['wpinv_is_recurring'] = 0; |
77 | 77 | } |
78 | 78 | |
79 | - if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) { |
|
79 | + if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) { |
|
80 | 80 | $_POST['wpinv_free_trial'] = 0; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( $fields as $field => $name ) { |
|
84 | - if ( isset( $_POST[ $name ] ) ) { |
|
85 | - if ( $field == '_wpinv_price' ) { |
|
86 | - if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) { |
|
87 | - $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price. |
|
83 | + foreach ($fields as $field => $name) { |
|
84 | + if (isset($_POST[$name])) { |
|
85 | + if ($field == '_wpinv_price') { |
|
86 | + if (get_post_meta($post_id, '_wpinv_type', true) === 'package') { |
|
87 | + $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price. |
|
88 | 88 | } else { |
89 | - $value = wpinv_sanitize_amount( $_POST[ $name ] ); |
|
89 | + $value = wpinv_sanitize_amount($_POST[$name]); |
|
90 | 90 | } |
91 | 91 | } else { |
92 | - $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ]; |
|
92 | + $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name]; |
|
93 | 93 | } |
94 | 94 | |
95 | - $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name ); |
|
96 | - update_post_meta( $post_id, $field, $value ); |
|
95 | + $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name); |
|
96 | + update_post_meta($post_id, $field, $value); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | -add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 ); |
|
102 | +add_action('save_post', 'wpinv_save_meta_boxes', 10, 3); |
|
103 | 103 | |
104 | -function wpinv_bulk_and_quick_edit_save( $post_id, $post, $update = false ) { |
|
105 | - if ( !( !empty( $_POST['action'] ) && $_POST['action'] == 'inline-save' ) ) { |
|
104 | +function wpinv_bulk_and_quick_edit_save($post_id, $post, $update = false) { |
|
105 | + if (!(!empty($_POST['action']) && $_POST['action'] == 'inline-save')) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
109 | 109 | // $post_id and $post are required |
110 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
110 | + if (empty($post_id) || empty($post)) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
114 | - if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) { |
|
114 | + if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Dont' save meta boxes for revisions or autosaves |
119 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
119 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $post->post_type == 'wpi_item' ) { |
|
123 | + if ($post->post_type == 'wpi_item') { |
|
124 | 124 | // verify nonce |
125 | - if ( isset( $_POST['_wpinv_item_price'] ) && get_post_meta( $post->ID, '_wpinv_type', true ) !== 'package' ) { |
|
126 | - update_post_meta( $post_id, '_wpinv_price', wpinv_sanitize_amount( $_POST['_wpinv_item_price'] ) ); |
|
125 | + if (isset($_POST['_wpinv_item_price']) && get_post_meta($post->ID, '_wpinv_type', true) !== 'package') { |
|
126 | + update_post_meta($post_id, '_wpinv_price', wpinv_sanitize_amount($_POST['_wpinv_item_price'])); |
|
127 | 127 | } |
128 | 128 | |
129 | - if ( isset( $_POST['_wpinv_vat_class'] ) ) { |
|
130 | - update_post_meta( $post_id, '_wpinv_vat_class', sanitize_text_field( $_POST['_wpinv_vat_class'] ) ); |
|
129 | + if (isset($_POST['_wpinv_vat_class'])) { |
|
130 | + update_post_meta($post_id, '_wpinv_vat_class', sanitize_text_field($_POST['_wpinv_vat_class'])); |
|
131 | 131 | } |
132 | 132 | |
133 | - if ( isset( $_POST['_wpinv_vat_rules'] ) ) { |
|
134 | - update_post_meta( $post_id, '_wpinv_vat_rule', sanitize_text_field( $_POST['_wpinv_vat_rules'] ) ); |
|
133 | + if (isset($_POST['_wpinv_vat_rules'])) { |
|
134 | + update_post_meta($post_id, '_wpinv_vat_rule', sanitize_text_field($_POST['_wpinv_vat_rules'])); |
|
135 | 135 | } |
136 | 136 | |
137 | - if ( isset( $_POST['_wpinv_item_type'] ) ) { |
|
138 | - update_post_meta( $post_id, '_wpinv_type', sanitize_text_field( $_POST['_wpinv_item_type'] ) ); |
|
137 | + if (isset($_POST['_wpinv_item_type'])) { |
|
138 | + update_post_meta($post_id, '_wpinv_type', sanitize_text_field($_POST['_wpinv_item_type'])); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | } |
142 | -add_action( 'save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3 ); |
|
142 | +add_action('save_post', 'wpinv_bulk_and_quick_edit_save', 10, 3); |
|
143 | 143 | |
144 | 144 | function wpinv_register_item_meta_boxes() { |
145 | 145 | global $wpinv_euvat; |
146 | 146 | |
147 | - add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' ); |
|
147 | + add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high'); |
|
148 | 148 | |
149 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
150 | - add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' ); |
|
149 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
150 | + add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high'); |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
154 | - add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' ); |
|
153 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
154 | + add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high'); |
|
155 | 155 | } |
156 | 156 | |
157 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' ); |
|
157 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core'); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | function wpinv_register_discount_meta_boxes() { |
161 | - add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' ); |
|
161 | + add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high'); |
|
162 | 162 | } |
163 | 163 | |
164 | -function wpinv_discount_metabox_details( $post ) { |
|
164 | +function wpinv_discount_metabox_details($post) { |
|
165 | 165 | $discount_id = $post->ID; |
166 | - $discount = wpinv_get_discount( $discount_id ); |
|
166 | + $discount = wpinv_get_discount($discount_id); |
|
167 | 167 | |
168 | - $type = wpinv_get_discount_type( $discount_id ); |
|
169 | - $item_reqs = wpinv_get_discount_item_reqs( $discount_id ); |
|
170 | - $excluded_items = wpinv_get_discount_excluded_items( $discount_id ); |
|
171 | - $min_total = wpinv_get_discount_min_total( $discount_id ); |
|
172 | - $max_total = wpinv_get_discount_max_total( $discount_id ); |
|
173 | - $max_uses = wpinv_get_discount_max_uses( $discount_id ); |
|
174 | - $single_use = wpinv_discount_is_single_use( $discount_id ); |
|
175 | - $recurring = (bool)wpinv_discount_is_recurring( $discount_id ); |
|
168 | + $type = wpinv_get_discount_type($discount_id); |
|
169 | + $item_reqs = wpinv_get_discount_item_reqs($discount_id); |
|
170 | + $excluded_items = wpinv_get_discount_excluded_items($discount_id); |
|
171 | + $min_total = wpinv_get_discount_min_total($discount_id); |
|
172 | + $max_total = wpinv_get_discount_max_total($discount_id); |
|
173 | + $max_uses = wpinv_get_discount_max_uses($discount_id); |
|
174 | + $single_use = wpinv_discount_is_single_use($discount_id); |
|
175 | + $recurring = (bool)wpinv_discount_is_recurring($discount_id); |
|
176 | 176 | |
177 | 177 | $min_total = $min_total > 0 ? $min_total : ''; |
178 | 178 | $max_total = $max_total > 0 ? $max_total : ''; |
179 | 179 | $max_uses = $max_uses > 0 ? $max_uses : ''; |
180 | 180 | ?> |
181 | -<?php do_action( 'wpinv_discount_form_top', $post ); ?> |
|
182 | -<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?> |
|
181 | +<?php do_action('wpinv_discount_form_top', $post); ?> |
|
182 | +<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?> |
|
183 | 183 | <table class="form-table wpi-form-table"> |
184 | 184 | <tbody> |
185 | - <?php do_action( 'wpinv_discount_form_first', $post ); ?> |
|
186 | - <?php do_action( 'wpinv_discount_form_before_code', $post ); ?> |
|
185 | + <?php do_action('wpinv_discount_form_first', $post); ?> |
|
186 | + <?php do_action('wpinv_discount_form_before_code', $post); ?> |
|
187 | 187 | <tr> |
188 | 188 | <th valign="top" scope="row"> |
189 | - <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label> |
|
189 | + <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label> |
|
190 | 190 | </th> |
191 | 191 | <td> |
192 | - <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required> |
|
193 | - <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p> |
|
192 | + <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required> |
|
193 | + <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p> |
|
194 | 194 | </td> |
195 | 195 | </tr> |
196 | - <?php do_action( 'wpinv_discount_form_before_type', $post ); ?> |
|
196 | + <?php do_action('wpinv_discount_form_before_type', $post); ?> |
|
197 | 197 | <tr> |
198 | 198 | <th valign="top" scope="row"> |
199 | - <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label> |
|
199 | + <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label> |
|
200 | 200 | </th> |
201 | 201 | <td> |
202 | 202 | <select id="wpinv_discount_type" name="type" class="medium-text"> |
203 | - <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?> |
|
204 | - <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option> |
|
203 | + <?php foreach (wpinv_get_discount_types() as $value => $label) { ?> |
|
204 | + <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option> |
|
205 | 205 | <?php } ?> |
206 | 206 | </select> |
207 | - <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p> |
|
207 | + <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p> |
|
208 | 208 | </td> |
209 | 209 | </tr> |
210 | - <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?> |
|
210 | + <?php do_action('wpinv_discount_form_before_amount', $post); ?> |
|
211 | 211 | <tr> |
212 | 212 | <th valign="top" scope="row"> |
213 | - <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label> |
|
213 | + <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label> |
|
214 | 214 | </th> |
215 | 215 | <td> |
216 | - <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font> |
|
217 | - <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p> |
|
218 | - <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p> |
|
216 | + <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font> |
|
217 | + <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p> |
|
218 | + <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p> |
|
219 | 219 | </td> |
220 | 220 | </tr> |
221 | - <?php do_action( 'wpinv_discount_form_before_items', $post ); ?> |
|
221 | + <?php do_action('wpinv_discount_form_before_items', $post); ?> |
|
222 | 222 | <tr> |
223 | 223 | <th valign="top" scope="row"> |
224 | - <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label> |
|
224 | + <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label> |
|
225 | 225 | </th> |
226 | 226 | <td> |
227 | - <p><?php echo wpinv_item_dropdown( array( |
|
227 | + <p><?php echo wpinv_item_dropdown(array( |
|
228 | 228 | 'name' => 'items[]', |
229 | 229 | 'id' => 'items', |
230 | 230 | 'selected' => $item_reqs, |
231 | 231 | 'multiple' => true, |
232 | 232 | 'chosen' => true, |
233 | 233 | 'class' => 'medium-text', |
234 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
234 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
235 | 235 | 'show_recurring' => true, |
236 | - ) ); ?> |
|
236 | + )); ?> |
|
237 | 237 | </p> |
238 | - <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p> |
|
238 | + <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p> |
|
239 | 239 | </td> |
240 | 240 | </tr> |
241 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?> |
|
241 | + <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?> |
|
242 | 242 | <tr> |
243 | 243 | <th valign="top" scope="row"> |
244 | - <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label> |
|
244 | + <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label> |
|
245 | 245 | </th> |
246 | 246 | <td> |
247 | - <p><?php echo wpinv_item_dropdown( array( |
|
247 | + <p><?php echo wpinv_item_dropdown(array( |
|
248 | 248 | 'name' => 'excluded_items[]', |
249 | 249 | 'id' => 'excluded_items', |
250 | 250 | 'selected' => $excluded_items, |
251 | 251 | 'multiple' => true, |
252 | 252 | 'chosen' => true, |
253 | 253 | 'class' => 'medium-text', |
254 | - 'placeholder' => __( 'Select one or more Items', 'invoicing' ), |
|
254 | + 'placeholder' => __('Select one or more Items', 'invoicing'), |
|
255 | 255 | 'show_recurring' => true, |
256 | - ) ); ?> |
|
256 | + )); ?> |
|
257 | 257 | </p> |
258 | - <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p> |
|
258 | + <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p> |
|
259 | 259 | </td> |
260 | 260 | </tr> |
261 | - <?php do_action( 'wpinv_discount_form_before_start', $post ); ?> |
|
261 | + <?php do_action('wpinv_discount_form_before_start', $post); ?> |
|
262 | 262 | <tr> |
263 | 263 | <th valign="top" scope="row"> |
264 | - <label for="wpinv_discount_start"><?php _e( 'Start date', 'invoicing' ); ?></label> |
|
264 | + <label for="wpinv_discount_start"><?php _e('Start date', 'invoicing'); ?></label> |
|
265 | 265 | </th> |
266 | 266 | <td> |
267 | - <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>"> |
|
268 | - <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p> |
|
267 | + <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>"> |
|
268 | + <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p> |
|
269 | 269 | </td> |
270 | 270 | </tr> |
271 | - <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?> |
|
271 | + <?php do_action('wpinv_discount_form_before_expiration', $post); ?> |
|
272 | 272 | <tr> |
273 | 273 | <th valign="top" scope="row"> |
274 | - <label for="wpinv_discount_expiration"><?php _e( 'Expiration date', 'invoicing' ); ?></label> |
|
274 | + <label for="wpinv_discount_expiration"><?php _e('Expiration date', 'invoicing'); ?></label> |
|
275 | 275 | </th> |
276 | 276 | <td> |
277 | - <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>"> |
|
278 | - <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p> |
|
277 | + <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>"> |
|
278 | + <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p> |
|
279 | 279 | </td> |
280 | 280 | </tr> |
281 | - <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?> |
|
281 | + <?php do_action('wpinv_discount_form_before_min_total', $post); ?> |
|
282 | 282 | <tr> |
283 | 283 | <th valign="top" scope="row"> |
284 | - <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label> |
|
284 | + <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label> |
|
285 | 285 | </th> |
286 | 286 | <td> |
287 | 287 | <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>"> |
288 | - <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
288 | + <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
289 | 289 | </td> |
290 | 290 | </tr> |
291 | - <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?> |
|
291 | + <?php do_action('wpinv_discount_form_before_max_total', $post); ?> |
|
292 | 292 | <tr> |
293 | 293 | <th valign="top" scope="row"> |
294 | - <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label> |
|
294 | + <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label> |
|
295 | 295 | </th> |
296 | 296 | <td> |
297 | 297 | <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>"> |
298 | - <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p> |
|
298 | + <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p> |
|
299 | 299 | </td> |
300 | 300 | </tr> |
301 | - <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?> |
|
301 | + <?php do_action('wpinv_discount_form_before_recurring', $post); ?> |
|
302 | 302 | <tr> |
303 | 303 | <th valign="top" scope="row"> |
304 | - <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label> |
|
304 | + <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label> |
|
305 | 305 | </th> |
306 | 306 | <td> |
307 | 307 | <select id="wpinv_discount_recurring" name="recurring" class="medium-text"> |
308 | - <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option> |
|
309 | - <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option> |
|
308 | + <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option> |
|
309 | + <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option> |
|
310 | 310 | </select> |
311 | - <p class="description"><?php _e( '<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p> |
|
311 | + <p class="description"><?php _e('<b>All payments:</b> apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p> |
|
312 | 312 | </td> |
313 | 313 | </tr> |
314 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?> |
|
314 | + <?php do_action('wpinv_discount_form_before_max_uses', $post); ?> |
|
315 | 315 | <tr> |
316 | 316 | <th valign="top" scope="row"> |
317 | - <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label> |
|
317 | + <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label> |
|
318 | 318 | </th> |
319 | 319 | <td> |
320 | 320 | <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>"> |
321 | - <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p> |
|
321 | + <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p> |
|
322 | 322 | </td> |
323 | 323 | </tr> |
324 | - <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?> |
|
324 | + <?php do_action('wpinv_discount_form_before_single_use', $post); ?> |
|
325 | 325 | <tr> |
326 | 326 | <th valign="top" scope="row"> |
327 | - <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label> |
|
327 | + <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label> |
|
328 | 328 | </th> |
329 | 329 | <td> |
330 | - <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>> |
|
331 | - <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span> |
|
330 | + <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>> |
|
331 | + <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span> |
|
332 | 332 | </td> |
333 | 333 | </tr> |
334 | - <?php do_action( 'wpinv_discount_form_last', $post ); ?> |
|
334 | + <?php do_action('wpinv_discount_form_last', $post); ?> |
|
335 | 335 | </tbody> |
336 | 336 | </table> |
337 | -<?php do_action( 'wpinv_discount_form_bottom', $post ); ?> |
|
337 | +<?php do_action('wpinv_discount_form_bottom', $post); ?> |
|
338 | 338 | <?php |
339 | 339 | } |
340 | 340 | |
341 | -function wpinv_discount_metabox_save( $post_id, $post, $update = false ) { |
|
342 | - $post_type = !empty( $post ) ? $post->post_type : ''; |
|
341 | +function wpinv_discount_metabox_save($post_id, $post, $update = false) { |
|
342 | + $post_type = !empty($post) ? $post->post_type : ''; |
|
343 | 343 | |
344 | - if ( $post_type != 'wpi_discount' ) { |
|
344 | + if ($post_type != 'wpi_discount') { |
|
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) { |
|
348 | + if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) { |
|
349 | 349 | return; |
350 | 350 | } |
351 | 351 | |
352 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
352 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
353 | 353 | return; |
354 | 354 | } |
355 | 355 | |
356 | - if ( !current_user_can( 'manage_options', $post_id ) ) { |
|
356 | + if (!current_user_can('manage_options', $post_id)) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
360 | - return wpinv_store_discount( $post_id, $_POST, $post, $update ); |
|
360 | + return wpinv_store_discount($post_id, $_POST, $post, $update); |
|
361 | 361 | } |
362 | -add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 ); |
|
363 | 362 | \ No newline at end of file |
363 | +add_action('save_post', 'wpinv_discount_metabox_save', 10, 3); |
|
364 | 364 | \ No newline at end of file |