@@ -1,16 +1,16 @@ 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 | -add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' ); |
|
8 | -function wpinv_discount_custom_column( $column ) { |
|
7 | +add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column'); |
|
8 | +function wpinv_discount_custom_column($column) { |
|
9 | 9 | global $post; |
10 | 10 | |
11 | - $discount = new WPInv_Discount( $post ); |
|
11 | + $discount = new WPInv_Discount($post); |
|
12 | 12 | |
13 | - switch ( $column ) { |
|
13 | + switch ($column) { |
|
14 | 14 | case 'code' : |
15 | 15 | echo $discount->get_code(); |
16 | 16 | break; |
@@ -21,33 +21,33 @@ discard block |
||
21 | 21 | echo $discount->get_usage(); |
22 | 22 | break; |
23 | 23 | case 'start_date' : |
24 | - echo getpaid_format_date_value( $discount->get_start_date() ); |
|
24 | + echo getpaid_format_date_value($discount->get_start_date()); |
|
25 | 25 | break; |
26 | 26 | case 'expiry_date' : |
27 | - echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ); |
|
27 | + echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')); |
|
28 | 28 | break; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 ); |
|
33 | -function wpinv_post_row_actions( $actions, $post ) { |
|
34 | - $post_type = !empty( $post->post_type ) ? $post->post_type : ''; |
|
32 | +add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2); |
|
33 | +function wpinv_post_row_actions($actions, $post) { |
|
34 | + $post_type = !empty($post->post_type) ? $post->post_type : ''; |
|
35 | 35 | |
36 | - if ( $post_type == 'wpi_discount' ) { |
|
37 | - $actions = wpinv_discount_row_actions( $post, $actions ); |
|
36 | + if ($post_type == 'wpi_discount') { |
|
37 | + $actions = wpinv_discount_row_actions($post, $actions); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return $actions; |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_discount_row_actions( $discount, $row_actions ) { |
|
44 | - $row_actions = array(); |
|
45 | - $edit_link = get_edit_post_link( $discount->ID ); |
|
46 | - $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>'; |
|
43 | +function wpinv_discount_row_actions($discount, $row_actions) { |
|
44 | + $row_actions = array(); |
|
45 | + $edit_link = get_edit_post_link($discount->ID); |
|
46 | + $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>'; |
|
47 | 47 | |
48 | - if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) ) { |
|
48 | + if (in_array(strtolower($discount->post_status), array('publish'))) { |
|
49 | 49 | |
50 | - $url = esc_url( |
|
50 | + $url = esc_url( |
|
51 | 51 | wp_nonce_url( |
52 | 52 | add_query_arg( |
53 | 53 | array( |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | 'getpaid-nonce' |
60 | 60 | ) |
61 | 61 | ); |
62 | - $anchor = __( 'Deactivate', 'invoicing' ); |
|
63 | - $title = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' ); |
|
62 | + $anchor = __('Deactivate', 'invoicing'); |
|
63 | + $title = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing'); |
|
64 | 64 | $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
65 | 65 | |
66 | - } else if( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) ) { |
|
66 | + } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) { |
|
67 | 67 | |
68 | - $url = esc_url( |
|
68 | + $url = esc_url( |
|
69 | 69 | wp_nonce_url( |
70 | 70 | add_query_arg( |
71 | 71 | array( |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | 'getpaid-nonce' |
78 | 78 | ) |
79 | 79 | ); |
80 | - $anchor = __( 'Activate', 'invoicing' ); |
|
81 | - $title = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' ); |
|
80 | + $anchor = __('Activate', 'invoicing'); |
|
81 | + $title = esc_attr__('Are you sure you want to activate this discount?', 'invoicing'); |
|
82 | 82 | $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
83 | 83 | |
84 | 84 | } |
85 | 85 | |
86 | - $url = esc_url( |
|
86 | + $url = esc_url( |
|
87 | 87 | wp_nonce_url( |
88 | 88 | add_query_arg( |
89 | 89 | array( |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | 'getpaid-nonce' |
96 | 96 | ) |
97 | 97 | ); |
98 | - $anchor = __( 'Delete', 'invoicing' ); |
|
99 | - $title = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' ); |
|
98 | + $anchor = __('Delete', 'invoicing'); |
|
99 | + $title = esc_attr__('Are you sure you want to delete this discount?', 'invoicing'); |
|
100 | 100 | $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>"; |
101 | 101 | |
102 | - $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount ); |
|
102 | + $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount); |
|
103 | 103 | |
104 | 104 | return $row_actions; |
105 | 105 | } |
@@ -107,68 +107,68 @@ discard block |
||
107 | 107 | function wpinv_restrict_manage_posts() { |
108 | 108 | global $typenow; |
109 | 109 | |
110 | - if( 'wpi_discount' == $typenow ) { |
|
110 | + if ('wpi_discount' == $typenow) { |
|
111 | 111 | wpinv_discount_filters(); |
112 | 112 | } |
113 | 113 | } |
114 | -add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 ); |
|
114 | +add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10); |
|
115 | 115 | |
116 | 116 | function wpinv_discount_filters() { |
117 | 117 | |
118 | 118 | ?> |
119 | 119 | <select name="discount_type" id="dropdown_wpinv_discount_type"> |
120 | - <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option> |
|
120 | + <option value=""><?php _e('Show all types', 'invoicing'); ?></option> |
|
121 | 121 | <?php |
122 | 122 | $types = wpinv_get_discount_types(); |
123 | 123 | |
124 | - foreach ( $types as $name => $type ) { |
|
125 | - echo '<option value="' . esc_attr( $name ) . '"'; |
|
124 | + foreach ($types as $name => $type) { |
|
125 | + echo '<option value="' . esc_attr($name) . '"'; |
|
126 | 126 | |
127 | - if ( isset( $_GET['discount_type'] ) ) |
|
128 | - selected( $name, $_GET['discount_type'] ); |
|
127 | + if (isset($_GET['discount_type'])) |
|
128 | + selected($name, $_GET['discount_type']); |
|
129 | 129 | |
130 | - echo '>' . esc_html__( $type, 'invoicing' ) . '</option>'; |
|
130 | + echo '>' . esc_html__($type, 'invoicing') . '</option>'; |
|
131 | 131 | } |
132 | 132 | ?> |
133 | 133 | </select> |
134 | 134 | <?php |
135 | 135 | } |
136 | 136 | |
137 | -function wpinv_request( $vars ) { |
|
137 | +function wpinv_request($vars) { |
|
138 | 138 | global $typenow, $wp_post_statuses; |
139 | 139 | |
140 | - if ( getpaid_is_invoice_post_type( $typenow ) ) { |
|
141 | - if ( ! isset( $vars['post_status'] ) ) { |
|
142 | - $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow ); |
|
140 | + if (getpaid_is_invoice_post_type($typenow)) { |
|
141 | + if (!isset($vars['post_status'])) { |
|
142 | + $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow); |
|
143 | 143 | |
144 | - foreach ( $post_statuses as $status => $value ) { |
|
145 | - if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) { |
|
146 | - unset( $post_statuses[ $status ] ); |
|
144 | + foreach ($post_statuses as $status => $value) { |
|
145 | + if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) { |
|
146 | + unset($post_statuses[$status]); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - $vars['post_status'] = array_keys( $post_statuses ); |
|
150 | + $vars['post_status'] = array_keys($post_statuses); |
|
151 | 151 | } |
152 | 152 | |
153 | - } else if ( 'wpi_discount' == $typenow ) { |
|
154 | - $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array(); |
|
153 | + } else if ('wpi_discount' == $typenow) { |
|
154 | + $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array(); |
|
155 | 155 | // Filter vat rule type |
156 | - if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) { |
|
156 | + if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') { |
|
157 | 157 | $meta_query[] = array( |
158 | 158 | 'key' => '_wpi_discount_type', |
159 | - 'value' => sanitize_text_field( $_GET['discount_type'] ), |
|
159 | + 'value' => sanitize_text_field($_GET['discount_type']), |
|
160 | 160 | 'compare' => '=' |
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | - if ( !empty( $meta_query ) ) { |
|
164 | + if (!empty($meta_query)) { |
|
165 | 165 | $vars['meta_query'] = $meta_query; |
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | 169 | return $vars; |
170 | 170 | } |
171 | -add_filter( 'request', 'wpinv_request' ); |
|
171 | +add_filter('request', 'wpinv_request'); |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * Create a page and store the ID in an option. |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | * @param int $post_parent (default: 0) Parent for the new page |
181 | 181 | * @return int page ID |
182 | 182 | */ |
183 | -function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
183 | +function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) { |
|
184 | 184 | global $wpdb; |
185 | 185 | |
186 | - $option_value = wpinv_get_option( $option ); |
|
186 | + $option_value = wpinv_get_option($option); |
|
187 | 187 | |
188 | - if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) { |
|
189 | - if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) { |
|
188 | + if ($option_value > 0 && ($page_object = get_post($option_value))) { |
|
189 | + if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) { |
|
190 | 190 | // Valid page is already in place |
191 | 191 | return $page_object->ID; |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - if(!empty($post_parent)){ |
|
195 | + if (!empty($post_parent)) { |
|
196 | 196 | $page = get_page_by_path($post_parent); |
197 | 197 | if ($page) { |
198 | 198 | $post_parent = $page->ID; |
@@ -201,40 +201,40 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - if ( strlen( $page_content ) > 0 ) { |
|
204 | + if (strlen($page_content) > 0) { |
|
205 | 205 | // Search for an existing page with the specified page content (typically a shortcode) |
206 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
206 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
207 | 207 | } else { |
208 | 208 | // Search for an existing page with the specified page slug |
209 | - $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug ) ); |
|
209 | + $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_name = %s LIMIT 1;", $slug)); |
|
210 | 210 | } |
211 | 211 | |
212 | - $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content ); |
|
212 | + $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content); |
|
213 | 213 | |
214 | - if ( $valid_page_found ) { |
|
215 | - if ( $option ) { |
|
216 | - wpinv_update_option( $option, $valid_page_found ); |
|
214 | + if ($valid_page_found) { |
|
215 | + if ($option) { |
|
216 | + wpinv_update_option($option, $valid_page_found); |
|
217 | 217 | } |
218 | 218 | return $valid_page_found; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // Search for a matching valid trashed page |
222 | - if ( strlen( $page_content ) > 0 ) { |
|
222 | + if (strlen($page_content) > 0) { |
|
223 | 223 | // Search for an existing page with the specified page content (typically a shortcode) |
224 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); |
|
224 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%")); |
|
225 | 225 | } else { |
226 | 226 | // Search for an existing page with the specified page slug |
227 | - $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) ); |
|
227 | + $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug)); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( $trashed_page_found ) { |
|
230 | + if ($trashed_page_found) { |
|
231 | 231 | $page_id = $trashed_page_found; |
232 | 232 | $page_data = array( |
233 | 233 | 'ID' => $page_id, |
234 | 234 | 'post_status' => 'publish', |
235 | 235 | 'post_parent' => $post_parent, |
236 | 236 | ); |
237 | - wp_update_post( $page_data ); |
|
237 | + wp_update_post($page_data); |
|
238 | 238 | } else { |
239 | 239 | $page_data = array( |
240 | 240 | 'post_status' => 'publish', |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | 'post_parent' => $post_parent, |
247 | 247 | 'comment_status' => 'closed', |
248 | 248 | ); |
249 | - $page_id = wp_insert_post( $page_data ); |
|
249 | + $page_id = wp_insert_post($page_data); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( $option ) { |
|
253 | - wpinv_update_option( $option, (int)$page_id ); |
|
252 | + if ($option) { |
|
253 | + wpinv_update_option($option, (int) $page_id); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | return $page_id; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Post types Admin Class |
@@ -21,70 +21,70 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | 33 | |
34 | 34 | // Items table columns. |
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
35 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
36 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
37 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
38 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
39 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
40 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
41 | 41 | |
42 | 42 | // Payment forms columns. |
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
43 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
44 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
45 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
46 | 46 | |
47 | 47 | // Discount table columns. |
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
48 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
49 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
50 | 50 | |
51 | 51 | // Deleting posts. |
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
53 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Post updated messages. |
58 | 58 | */ |
59 | - public static function post_updated_messages( $messages ) { |
|
59 | + public static function post_updated_messages($messages) { |
|
60 | 60 | global $post; |
61 | 61 | |
62 | 62 | $messages['wpi_discount'] = array( |
63 | 63 | 0 => '', |
64 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
64 | + 1 => __('Discount updated.', 'invoicing'), |
|
65 | + 2 => __('Custom field updated.', 'invoicing'), |
|
66 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
67 | + 4 => __('Discount updated.', 'invoicing'), |
|
68 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
69 | + 6 => __('Discount updated.', 'invoicing'), |
|
70 | + 7 => __('Discount saved.', 'invoicing'), |
|
71 | + 8 => __('Discount submitted.', 'invoicing'), |
|
72 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
73 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $messages['wpi_payment_form'] = array( |
77 | 77 | 0 => '', |
78 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
78 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
79 | + 2 => __('Custom field updated.', 'invoicing'), |
|
80 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
81 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
82 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
83 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
84 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
85 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
86 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
87 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $messages; |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Post row actions. |
96 | 96 | */ |
97 | - public static function post_row_actions( $actions, $post ) { |
|
97 | + public static function post_row_actions($actions, $post) { |
|
98 | 98 | |
99 | - $post = get_post( $post ); |
|
99 | + $post = get_post($post); |
|
100 | 100 | |
101 | 101 | // We do not want to edit the default payment form. |
102 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | - unset( $actions['trash'] ); |
|
104 | - unset( $actions['inline hide-if-no-js'] ); |
|
102 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
103 | + unset($actions['trash']); |
|
104 | + unset($actions['inline hide-if-no-js']); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $actions; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | * @param WP_Post $post |
116 | 116 | * @return array $actions actions without edit option |
117 | 117 | */ |
118 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
118 | + public static function filter_invoice_row_actions($actions, $post) { |
|
119 | 119 | |
120 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
120 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
121 | 121 | |
122 | 122 | $actions = array(); |
123 | - $invoice = new WPInv_Invoice( $post ); |
|
123 | + $invoice = new WPInv_Invoice($post); |
|
124 | 124 | |
125 | - $actions['edit'] = sprintf( |
|
125 | + $actions['edit'] = sprintf( |
|
126 | 126 | '<a href="%1$s">%2$s</a>', |
127 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
127 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
128 | + esc_html(__('Edit', 'invoicing')) |
|
129 | 129 | ); |
130 | 130 | |
131 | - if ( ! $invoice->is_draft() ) { |
|
131 | + if (!$invoice->is_draft()) { |
|
132 | 132 | |
133 | - $actions['view'] = sprintf( |
|
133 | + $actions['view'] = sprintf( |
|
134 | 134 | '<a href="%1$s">%2$s</a>', |
135 | - esc_url( $invoice->get_view_url() ), |
|
135 | + esc_url($invoice->get_view_url()), |
|
136 | 136 | sprintf( |
137 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
137 | + esc_html(__('View %s', 'invoicing')), |
|
138 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
139 | 139 | ) |
140 | 140 | ); |
141 | 141 | |
142 | - $actions['send'] = sprintf( |
|
142 | + $actions['send'] = sprintf( |
|
143 | 143 | '<a href="%1$s">%2$s</a>', |
144 | 144 | esc_url( |
145 | 145 | wp_nonce_url( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'getpaid-nonce' |
154 | 154 | ) |
155 | 155 | ), |
156 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
156 | + esc_html(__('Send to Customer', 'invoicing')) |
|
157 | 157 | ); |
158 | 158 | |
159 | 159 | } |
@@ -166,50 +166,50 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * Returns an array of invoice table columns. |
168 | 168 | */ |
169 | - public static function invoice_columns( $columns ) { |
|
169 | + public static function invoice_columns($columns) { |
|
170 | 170 | |
171 | 171 | $columns = array( |
172 | 172 | 'cb' => $columns['cb'], |
173 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
176 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
177 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
178 | - 'status' => __( 'Status', 'invoicing' ), |
|
173 | + 'number' => __('Invoice', 'invoicing'), |
|
174 | + 'customer' => __('Customer', 'invoicing'), |
|
175 | + 'invoice_date' => __('Date', 'invoicing'), |
|
176 | + 'amount' => __('Amount', 'invoicing'), |
|
177 | + 'recurring' => __('Recurring', 'invoicing'), |
|
178 | + 'status' => __('Status', 'invoicing'), |
|
179 | 179 | ); |
180 | 180 | |
181 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
181 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | 185 | * Displays invoice table columns. |
186 | 186 | */ |
187 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
187 | + public static function display_invoice_columns($column_name, $post_id) { |
|
188 | 188 | |
189 | - $invoice = new WPInv_Invoice( $post_id ); |
|
189 | + $invoice = new WPInv_Invoice($post_id); |
|
190 | 190 | |
191 | - switch ( $column_name ) { |
|
191 | + switch ($column_name) { |
|
192 | 192 | |
193 | 193 | case 'invoice_date' : |
194 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
195 | - $date = getpaid_format_date_value( $date_time ); |
|
194 | + $date_time = esc_attr($invoice->get_created_date()); |
|
195 | + $date = getpaid_format_date_value($date_time); |
|
196 | 196 | echo "<span title='$date_time'>$date</span>"; |
197 | 197 | break; |
198 | 198 | |
199 | 199 | case 'amount' : |
200 | 200 | |
201 | 201 | $amount = $invoice->get_total(); |
202 | - $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
202 | + $formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency()); |
|
203 | 203 | |
204 | - if ( $invoice->is_refunded() ) { |
|
205 | - $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
204 | + if ($invoice->is_refunded()) { |
|
205 | + $refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency()); |
|
206 | 206 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
207 | 207 | } else { |
208 | 208 | |
209 | 209 | $discount = $invoice->get_total_discount(); |
210 | 210 | |
211 | - if ( ! empty( $discount ) ) { |
|
212 | - $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
211 | + if (!empty($discount)) { |
|
212 | + $new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency()); |
|
213 | 213 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
214 | 214 | } else { |
215 | 215 | echo $formated_amount; |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | break; |
221 | 221 | |
222 | 222 | case 'status' : |
223 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
224 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
223 | + $status = sanitize_text_field($invoice->get_status()); |
|
224 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
225 | 225 | |
226 | 226 | // If it is paid, show the gateway title. |
227 | - if ( $invoice->is_paid() ) { |
|
228 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
229 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
227 | + if ($invoice->is_paid()) { |
|
228 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
229 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
230 | 230 | |
231 | 231 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
232 | 232 | } else { |
@@ -234,22 +234,22 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | // If it is not paid, display the overdue and view status. |
237 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
237 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
238 | 238 | |
239 | 239 | // Invoice view status. |
240 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
241 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
240 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
241 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
242 | 242 | } else { |
243 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
243 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | // Display the overview status. |
247 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
247 | + if (wpinv_get_option('overdue_active')) { |
|
248 | 248 | $due_date = $invoice->get_due_date(); |
249 | - $fomatted = getpaid_format_date( $due_date ); |
|
249 | + $fomatted = getpaid_format_date($due_date); |
|
250 | 250 | |
251 | - if ( ! empty( $fomatted ) ) { |
|
252 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
251 | + if (!empty($fomatted)) { |
|
252 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
253 | 253 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
254 | 254 | } |
255 | 255 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | case 'recurring': |
262 | 262 | |
263 | - if ( $invoice->is_recurring() ) { |
|
263 | + if ($invoice->is_recurring()) { |
|
264 | 264 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
265 | 265 | } else { |
266 | 266 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | |
270 | 270 | case 'number' : |
271 | 271 | |
272 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
273 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
274 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
272 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
273 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
274 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
275 | 275 | |
276 | 276 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
277 | 277 | |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | |
282 | 282 | $customer_name = $invoice->get_user_full_name(); |
283 | 283 | |
284 | - if ( empty( $customer_name ) ) { |
|
284 | + if (empty($customer_name)) { |
|
285 | 285 | $customer_name = $invoice->get_email(); |
286 | 286 | } |
287 | 287 | |
288 | - if ( ! empty( $customer_name ) ) { |
|
289 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
290 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
288 | + if (!empty($customer_name)) { |
|
289 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
290 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
291 | 291 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
292 | 292 | } else { |
293 | 293 | echo '<div>—</div>'; |
@@ -302,50 +302,50 @@ discard block |
||
302 | 302 | /** |
303 | 303 | * Returns an array of payment forms table columns. |
304 | 304 | */ |
305 | - public static function payment_form_columns( $columns ) { |
|
305 | + public static function payment_form_columns($columns) { |
|
306 | 306 | |
307 | 307 | $columns = array( |
308 | 308 | 'cb' => $columns['cb'], |
309 | - 'title' => __( 'Name', 'invoicing' ), |
|
310 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
311 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
312 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
313 | - 'items' => __( 'Items', 'invoicing' ), |
|
314 | - 'date' => __( 'Date', 'invoicing' ), |
|
309 | + 'title' => __('Name', 'invoicing'), |
|
310 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
311 | + 'earnings' => __('Revenue', 'invoicing'), |
|
312 | + 'refunds' => __('Refunded', 'invoicing'), |
|
313 | + 'items' => __('Items', 'invoicing'), |
|
314 | + 'date' => __('Date', 'invoicing'), |
|
315 | 315 | ); |
316 | 316 | |
317 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
317 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Displays payment form table columns. |
323 | 323 | */ |
324 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
324 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
325 | 325 | |
326 | 326 | // Retrieve the payment form. |
327 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
327 | + $form = new GetPaid_Payment_Form($post_id); |
|
328 | 328 | |
329 | - switch ( $column_name ) { |
|
329 | + switch ($column_name) { |
|
330 | 330 | |
331 | 331 | case 'earnings' : |
332 | - echo wpinv_price( wpinv_format_amount( $form->get_earned() ) ); |
|
332 | + echo wpinv_price(wpinv_format_amount($form->get_earned())); |
|
333 | 333 | break; |
334 | 334 | |
335 | 335 | case 'refunds' : |
336 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
336 | + echo wpinv_price(wpinv_format_amount($form->get_refunded())); |
|
337 | 337 | break; |
338 | 338 | |
339 | 339 | case 'refunds' : |
340 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
340 | + echo wpinv_price(wpinv_format_amount($form->get_refunded())); |
|
341 | 341 | break; |
342 | 342 | |
343 | 343 | case 'shortcode' : |
344 | 344 | |
345 | - if ( $form->is_default() ) { |
|
345 | + if ($form->is_default()) { |
|
346 | 346 | echo '—'; |
347 | 347 | } else { |
348 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
348 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | break; |
@@ -354,29 +354,29 @@ discard block |
||
354 | 354 | |
355 | 355 | $items = $form->get_items(); |
356 | 356 | |
357 | - if ( $form->is_default() || empty( $items ) ) { |
|
357 | + if ($form->is_default() || empty($items)) { |
|
358 | 358 | echo '—'; |
359 | 359 | return; |
360 | 360 | } |
361 | 361 | |
362 | 362 | $_items = array(); |
363 | 363 | |
364 | - foreach ( $items as $item ) { |
|
364 | + foreach ($items as $item) { |
|
365 | 365 | $url = $item->get_edit_url(); |
366 | 366 | |
367 | - if ( empty( $url ) ) { |
|
368 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
367 | + if (empty($url)) { |
|
368 | + $_items[] = sanitize_text_field($item->get_name()); |
|
369 | 369 | } else { |
370 | 370 | $_items[] = sprintf( |
371 | 371 | '<a href="%s">%s</a>', |
372 | - esc_url( $url ), |
|
373 | - sanitize_text_field( $item->get_name() ) |
|
372 | + esc_url($url), |
|
373 | + sanitize_text_field($item->get_name()) |
|
374 | 374 | ); |
375 | 375 | } |
376 | 376 | |
377 | 377 | } |
378 | 378 | |
379 | - echo implode( '<br>', $_items ); |
|
379 | + echo implode('<br>', $_items); |
|
380 | 380 | |
381 | 381 | break; |
382 | 382 | |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | /** |
388 | 388 | * Filters post states. |
389 | 389 | */ |
390 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
390 | + public static function filter_payment_form_state($post_states, $post) { |
|
391 | 391 | |
392 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
393 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
392 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
393 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | return $post_states; |
@@ -400,35 +400,35 @@ discard block |
||
400 | 400 | /** |
401 | 401 | * Returns an array of coupon table columns. |
402 | 402 | */ |
403 | - public static function discount_columns( $columns ) { |
|
403 | + public static function discount_columns($columns) { |
|
404 | 404 | |
405 | 405 | $columns = array( |
406 | 406 | 'cb' => $columns['cb'], |
407 | - 'title' => __( 'Name', 'invoicing' ), |
|
408 | - 'code' => __( 'Code', 'invoicing' ), |
|
409 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
410 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
411 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
412 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
407 | + 'title' => __('Name', 'invoicing'), |
|
408 | + 'code' => __('Code', 'invoicing'), |
|
409 | + 'amount' => __('Amount', 'invoicing'), |
|
410 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
411 | + 'start_date' => __('Start Date', 'invoicing'), |
|
412 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
413 | 413 | ); |
414 | 414 | |
415 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
415 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Filters post states. |
420 | 420 | */ |
421 | - public static function filter_discount_state( $post_states, $post ) { |
|
421 | + public static function filter_discount_state($post_states, $post) { |
|
422 | 422 | |
423 | - if ( 'wpi_discount' == $post->post_type ) { |
|
423 | + if ('wpi_discount' == $post->post_type) { |
|
424 | 424 | |
425 | - $discount = new WPInv_Discount( $post ); |
|
425 | + $discount = new WPInv_Discount($post); |
|
426 | 426 | |
427 | 427 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
428 | 428 | |
429 | - if ( $status != 'publish' ) { |
|
429 | + if ($status != 'publish') { |
|
430 | 430 | return array( |
431 | - 'discount_status' => wpinv_discount_status( $status ), |
|
431 | + 'discount_status' => wpinv_discount_status($status), |
|
432 | 432 | ); |
433 | 433 | } |
434 | 434 | |
@@ -443,30 +443,30 @@ discard block |
||
443 | 443 | /** |
444 | 444 | * Returns an array of items table columns. |
445 | 445 | */ |
446 | - public static function item_columns( $columns ) { |
|
446 | + public static function item_columns($columns) { |
|
447 | 447 | |
448 | 448 | $columns = array( |
449 | 449 | 'cb' => $columns['cb'], |
450 | - 'title' => __( 'Name', 'invoicing' ), |
|
451 | - 'price' => __( 'Price', 'invoicing' ), |
|
452 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
453 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
454 | - 'type' => __( 'Type', 'invoicing' ), |
|
455 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
450 | + 'title' => __('Name', 'invoicing'), |
|
451 | + 'price' => __('Price', 'invoicing'), |
|
452 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
453 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
454 | + 'type' => __('Type', 'invoicing'), |
|
455 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
456 | 456 | ); |
457 | 457 | |
458 | - if ( ! wpinv_use_taxes() ) { |
|
459 | - unset( $columns['vat_rule'] ); |
|
460 | - unset( $columns['vat_class'] ); |
|
458 | + if (!wpinv_use_taxes()) { |
|
459 | + unset($columns['vat_rule']); |
|
460 | + unset($columns['vat_class']); |
|
461 | 461 | } |
462 | 462 | |
463 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
463 | + return apply_filters('wpi_item_table_columns', $columns); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
467 | 467 | * Returns an array of sortable items table columns. |
468 | 468 | */ |
469 | - public static function sortable_item_columns( $columns ) { |
|
469 | + public static function sortable_item_columns($columns) { |
|
470 | 470 | |
471 | 471 | return array_merge( |
472 | 472 | $columns, |
@@ -483,49 +483,49 @@ discard block |
||
483 | 483 | /** |
484 | 484 | * Displays items table columns. |
485 | 485 | */ |
486 | - public static function display_item_columns( $column_name, $post_id ) { |
|
486 | + public static function display_item_columns($column_name, $post_id) { |
|
487 | 487 | |
488 | - $item = new WPInv_Item( $post_id ); |
|
488 | + $item = new WPInv_Item($post_id); |
|
489 | 489 | |
490 | - switch ( $column_name ) { |
|
490 | + switch ($column_name) { |
|
491 | 491 | |
492 | 492 | case 'price' : |
493 | 493 | |
494 | - if ( ! $item->is_recurring() ) { |
|
494 | + if (!$item->is_recurring()) { |
|
495 | 495 | echo $item->get_the_price(); |
496 | 496 | break; |
497 | 497 | } |
498 | 498 | |
499 | 499 | $price = wp_sprintf( |
500 | - __( '%s / %s', 'invoicing' ), |
|
500 | + __('%s / %s', 'invoicing'), |
|
501 | 501 | $item->get_the_price(), |
502 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
502 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
503 | 503 | ); |
504 | 504 | |
505 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
505 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
506 | 506 | echo $price; |
507 | 507 | break; |
508 | 508 | } |
509 | 509 | |
510 | 510 | echo $item->get_the_initial_price(); |
511 | 511 | |
512 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
512 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
513 | 513 | break; |
514 | 514 | |
515 | 515 | case 'vat_rule' : |
516 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
516 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
517 | 517 | break; |
518 | 518 | |
519 | 519 | case 'vat_class' : |
520 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
520 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
521 | 521 | break; |
522 | 522 | |
523 | 523 | case 'shortcode' : |
524 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
524 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'type' : |
528 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
528 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
529 | 529 | break; |
530 | 530 | |
531 | 531 | } |
@@ -535,21 +535,21 @@ discard block |
||
535 | 535 | /** |
536 | 536 | * Lets users filter items using taxes. |
537 | 537 | */ |
538 | - public static function add_item_filters( $post_type ) { |
|
538 | + public static function add_item_filters($post_type) { |
|
539 | 539 | |
540 | 540 | // Abort if we're not dealing with items. |
541 | - if ( $post_type != 'wpi_item' ) { |
|
541 | + if ($post_type != 'wpi_item') { |
|
542 | 542 | return; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // Filter by vat rules. |
546 | - if ( wpinv_use_taxes() ) { |
|
546 | + if (wpinv_use_taxes()) { |
|
547 | 547 | |
548 | 548 | // Sanitize selected vat rule. |
549 | 549 | $vat_rule = ''; |
550 | 550 | $vat_rules = getpaid_get_tax_rules(); |
551 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
552 | - $vat_rule = $_GET['vat_rule']; |
|
551 | + if (isset($_GET['vat_rule'])) { |
|
552 | + $vat_rule = $_GET['vat_rule']; |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | // Filter by VAT rule. |
@@ -557,13 +557,13 @@ discard block |
||
557 | 557 | array( |
558 | 558 | 'options' => array_merge( |
559 | 559 | array( |
560 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
560 | + '' => __('All VAT rules', 'invoicing') |
|
561 | 561 | ), |
562 | 562 | $vat_rules |
563 | 563 | ), |
564 | 564 | 'name' => 'vat_rule', |
565 | 565 | 'id' => 'vat_rule', |
566 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
566 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
567 | 567 | 'show_option_all' => false, |
568 | 568 | 'show_option_none' => false, |
569 | 569 | ) |
@@ -574,21 +574,21 @@ discard block |
||
574 | 574 | // Sanitize selected vat rule. |
575 | 575 | $vat_class = ''; |
576 | 576 | $vat_classes = getpaid_get_tax_classes(); |
577 | - if ( isset( $_GET['vat_class'] ) ) { |
|
578 | - $vat_class = $_GET['vat_class']; |
|
577 | + if (isset($_GET['vat_class'])) { |
|
578 | + $vat_class = $_GET['vat_class']; |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | echo wpinv_html_select( |
582 | 582 | array( |
583 | 583 | 'options' => array_merge( |
584 | 584 | array( |
585 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
585 | + '' => __('All VAT classes', 'invoicing') |
|
586 | 586 | ), |
587 | 587 | $vat_classes |
588 | 588 | ), |
589 | 589 | 'name' => 'vat_class', |
590 | 590 | 'id' => 'vat_class', |
591 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
591 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
592 | 592 | 'show_option_all' => false, |
593 | 593 | 'show_option_none' => false, |
594 | 594 | ) |
@@ -597,22 +597,22 @@ discard block |
||
597 | 597 | } |
598 | 598 | |
599 | 599 | // Filter by item type. |
600 | - $type = ''; |
|
601 | - if ( isset( $_GET['type'] ) ) { |
|
602 | - $type = $_GET['type']; |
|
600 | + $type = ''; |
|
601 | + if (isset($_GET['type'])) { |
|
602 | + $type = $_GET['type']; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | echo wpinv_html_select( |
606 | 606 | array( |
607 | 607 | 'options' => array_merge( |
608 | 608 | array( |
609 | - '' => __( 'All item types', 'invoicing' ) |
|
609 | + '' => __('All item types', 'invoicing') |
|
610 | 610 | ), |
611 | 611 | wpinv_get_item_types() |
612 | 612 | ), |
613 | 613 | 'name' => 'type', |
614 | 614 | 'id' => 'type', |
615 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
615 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
616 | 616 | 'show_option_all' => false, |
617 | 617 | 'show_option_none' => false, |
618 | 618 | ) |
@@ -623,45 +623,45 @@ discard block |
||
623 | 623 | /** |
624 | 624 | * Filters the item query. |
625 | 625 | */ |
626 | - public static function filter_item_query( $query ) { |
|
626 | + public static function filter_item_query($query) { |
|
627 | 627 | |
628 | 628 | // modify the query only if it admin and main query. |
629 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
629 | + if (!(is_admin() && $query->is_main_query())) { |
|
630 | 630 | return $query; |
631 | 631 | } |
632 | 632 | |
633 | 633 | // we want to modify the query for our items. |
634 | - if ( 'wpi_item' != $query->query['post_type'] ){ |
|
634 | + if ('wpi_item' != $query->query['post_type']) { |
|
635 | 635 | return $query; |
636 | 636 | } |
637 | 637 | |
638 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
638 | + if (empty($query->query_vars['meta_query'])) { |
|
639 | 639 | $query->query_vars['meta_query'] = array(); |
640 | 640 | } |
641 | 641 | |
642 | 642 | // Filter vat rule type |
643 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
643 | + if (!empty($_GET['vat_rule'])) { |
|
644 | 644 | $query->query_vars['meta_query'][] = array( |
645 | 645 | 'key' => '_wpinv_vat_rule', |
646 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
646 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
647 | 647 | 'compare' => '=' |
648 | 648 | ); |
649 | 649 | } |
650 | 650 | |
651 | 651 | // Filter vat class |
652 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
652 | + if (!empty($_GET['vat_class'])) { |
|
653 | 653 | $query->query_vars['meta_query'][] = array( |
654 | 654 | 'key' => '_wpinv_vat_class', |
655 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
655 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
656 | 656 | 'compare' => '=' |
657 | 657 | ); |
658 | 658 | } |
659 | 659 | |
660 | 660 | // Filter item type |
661 | - if ( ! empty( $_GET['type'] ) ) { |
|
661 | + if (!empty($_GET['type'])) { |
|
662 | 662 | $query->query_vars['meta_query'][] = array( |
663 | 663 | 'key' => '_wpinv_type', |
664 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
664 | + 'value' => sanitize_text_field($_GET['type']), |
|
665 | 665 | 'compare' => '=' |
666 | 666 | ); |
667 | 667 | } |
@@ -671,15 +671,15 @@ discard block |
||
671 | 671 | /** |
672 | 672 | * Reorders items. |
673 | 673 | */ |
674 | - public static function reorder_items( $vars ) { |
|
674 | + public static function reorder_items($vars) { |
|
675 | 675 | global $typenow; |
676 | 676 | |
677 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
677 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
678 | 678 | return $vars; |
679 | 679 | } |
680 | 680 | |
681 | 681 | // By item type. |
682 | - if ( 'type' == $vars['orderby'] ) { |
|
682 | + if ('type' == $vars['orderby']) { |
|
683 | 683 | return array_merge( |
684 | 684 | $vars, |
685 | 685 | array( |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | } |
691 | 691 | |
692 | 692 | // By vat class. |
693 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
693 | + if ('vat_class' == $vars['orderby']) { |
|
694 | 694 | return array_merge( |
695 | 695 | $vars, |
696 | 696 | array( |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | // By vat rule. |
704 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
704 | + if ('vat_rule' == $vars['orderby']) { |
|
705 | 705 | return array_merge( |
706 | 706 | $vars, |
707 | 707 | array( |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | } |
713 | 713 | |
714 | 714 | // By price. |
715 | - if ( 'price' == $vars['orderby'] ) { |
|
715 | + if ('price' == $vars['orderby']) { |
|
716 | 716 | return array_merge( |
717 | 717 | $vars, |
718 | 718 | array( |
@@ -729,27 +729,27 @@ discard block |
||
729 | 729 | /** |
730 | 730 | * Fired when deleting a post. |
731 | 731 | */ |
732 | - public static function delete_post( $post_id ) { |
|
732 | + public static function delete_post($post_id) { |
|
733 | 733 | |
734 | - switch ( get_post_type( $post_id ) ) { |
|
734 | + switch (get_post_type($post_id)) { |
|
735 | 735 | |
736 | 736 | case 'wpi_item' : |
737 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
737 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
738 | 738 | break; |
739 | 739 | |
740 | 740 | case 'wpi_payment_form' : |
741 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
741 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
742 | 742 | break; |
743 | 743 | |
744 | 744 | case 'wpi_discount' : |
745 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
745 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
746 | 746 | break; |
747 | 747 | |
748 | 748 | case 'wpi_invoice' : |
749 | - $invoice = new WPInv_Invoice( $post_id ); |
|
750 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
751 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
752 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
749 | + $invoice = new WPInv_Invoice($post_id); |
|
750 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
751 | + $invoice->get_data_store()->delete_items($invoice); |
|
752 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
753 | 753 | break; |
754 | 754 | } |
755 | 755 | } |