@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | // Load WP_List_Table if not loaded |
11 | 11 | if ( ! class_exists( 'WP_List_Table' ) ) { |
12 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
12 | + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
@@ -21,223 +21,223 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class WPInv_Customers_Table extends WP_List_Table { |
23 | 23 | |
24 | - /** |
|
25 | - * @var int Number of items per page |
|
26 | - * @since 1.0.19 |
|
27 | - */ |
|
28 | - public $per_page = 10; |
|
29 | - |
|
30 | - /** |
|
31 | - * Get things started |
|
32 | - * |
|
33 | - * @since 1.0.19 |
|
34 | - * @see WP_List_Table::__construct() |
|
35 | - */ |
|
36 | - public function __construct() { |
|
37 | - |
|
38 | - // Set parent defaults |
|
39 | - parent::__construct( array( |
|
40 | - 'singular' => 'id', |
|
41 | - 'plural' => 'ids', |
|
42 | - 'ajax' => false, |
|
43 | - ) ); |
|
44 | - |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Gets the name of the primary column. |
|
49 | - * |
|
50 | - * @since 1.0.19 |
|
51 | - * @access protected |
|
52 | - * |
|
53 | - * @return string Name of the primary column. |
|
54 | - */ |
|
55 | - protected function get_primary_column_name() { |
|
56 | - return 'name'; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * This function renders most of the columns in the list table. |
|
61 | - * |
|
62 | - * @since 1.0.19 |
|
63 | - * |
|
64 | - * @param WP_User $item |
|
65 | - * @param string $column_name The name of the column |
|
66 | - * |
|
67 | - * @return string Column Name |
|
68 | - */ |
|
69 | - public function column_default( $item, $column_name ) { |
|
70 | - $value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
71 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Displays the country column. |
|
76 | - * |
|
77 | - * @since 1.0.19 |
|
78 | - * |
|
79 | - * @param WP_User $user |
|
80 | - * |
|
81 | - * @return string Column Name |
|
82 | - */ |
|
83 | - public function column_country( $user ) { |
|
84 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
85 | - if ( $country ) { |
|
86 | - $country = wpinv_country_name( $country ); |
|
87 | - } |
|
88 | - return sanitize_text_field( $country ); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Displays the state column. |
|
93 | - * |
|
94 | - * @since 1.0.19 |
|
95 | - * |
|
96 | - * @param WP_User $user |
|
97 | - * |
|
98 | - * @return string Column Name |
|
99 | - */ |
|
100 | - public function column_state( $user ) { |
|
101 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
102 | - $state = $user->_wpinv_state; |
|
103 | - if ( $state ) { |
|
104 | - $state = wpinv_state_name( $state, $country ); |
|
105 | - } |
|
106 | - |
|
107 | - return sanitize_text_field( $state ); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Generates content for a single row of the table |
|
112 | - * @since 1.0.19 |
|
113 | - * |
|
114 | - * @param int $item The user id. |
|
115 | - */ |
|
116 | - public function single_row( $item ) { |
|
117 | - $item = get_user_by( 'id', $item ); |
|
118 | - |
|
119 | - if ( empty( $item ) ) { |
|
120 | - return; |
|
121 | - } |
|
122 | - |
|
123 | - echo '<tr>'; |
|
124 | - $this->single_row_columns( $item ); |
|
125 | - echo '</tr>'; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Displays the customers name |
|
130 | - * |
|
131 | - * @param WP_User $customer customer. |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function column_name( $customer ) { |
|
135 | - |
|
136 | - // Customer view URL. |
|
137 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
138 | - $row_actions = $this->row_actions( |
|
139 | - array( |
|
140 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
141 | - ) |
|
142 | - ); |
|
143 | - |
|
144 | - // Get user's address. |
|
145 | - $address = wpinv_get_user_address( $customer->ID ); |
|
146 | - |
|
147 | - // Customer email address. |
|
148 | - $email = sanitize_email( $customer->user_email ); |
|
149 | - |
|
150 | - // Customer's avatar. |
|
151 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
152 | - $avatar = "<img src='$avatar' height='32' width='32'/>"; |
|
153 | - |
|
154 | - // Customer's name. |
|
155 | - $name = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" ); |
|
156 | - |
|
157 | - if ( ! empty( $name ) ) { |
|
158 | - $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
|
159 | - } |
|
160 | - |
|
161 | - $email = "<div class='row-title'><a href='$view_url'>$email</a></div>"; |
|
162 | - |
|
163 | - return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>"; |
|
164 | - |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Retrieve the table columns |
|
169 | - * |
|
170 | - * @since 1.0.19 |
|
171 | - * @return array $columns Array of all the list table columns |
|
172 | - */ |
|
173 | - public function get_columns() { |
|
174 | - |
|
175 | - $columns = array( |
|
176 | - 'name' => __( 'Name', 'invoicing' ), |
|
177 | - 'country' => __( 'Country', 'invoicing' ), |
|
178 | - 'state' => __( 'State', 'invoicing' ), |
|
179 | - 'city' => __( 'City', 'invoicing' ), |
|
180 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
181 | - 'address' => __( 'Address', 'invoicing' ), |
|
182 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
183 | - 'company' => __( 'Company', 'invoicing' ), |
|
184 | - ); |
|
185 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
186 | - |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Retrieve the current page number |
|
191 | - * |
|
192 | - * @since 1.0.19 |
|
193 | - * @return int Current page number |
|
194 | - */ |
|
195 | - public function get_paged() { |
|
196 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Returns bulk actions. |
|
201 | - * |
|
202 | - * @since 1.0.19 |
|
203 | - * @return void |
|
204 | - */ |
|
205 | - public function bulk_actions( $which = '' ) { |
|
206 | - return array(); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Prepares the display query |
|
211 | - */ |
|
212 | - public function prepare_query() { |
|
213 | - global $wpdb; |
|
214 | - |
|
215 | - // Users with invoices. |
|
216 | - $customers = $wpdb->get_col( |
|
217 | - $wpdb->prepare( |
|
218 | - "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE post_type=%s LIMIT %d,%d", |
|
219 | - 'wpi_invoice', |
|
220 | - $this->get_paged() * 10 - 10, |
|
221 | - $this->per_page |
|
222 | - ) |
|
223 | - ); |
|
224 | - |
|
225 | - $this->items = $customers; |
|
226 | - $this->total = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE post_type=%s", 'wpi_invoice' ) ); |
|
227 | - |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Setup the final data for the table |
|
232 | - * |
|
233 | - * @since 1.0.19 |
|
234 | - * @return void |
|
235 | - */ |
|
236 | - public function prepare_items() { |
|
237 | - $columns = $this->get_columns(); |
|
238 | - $hidden = array(); // No hidden columns |
|
239 | - $sortable = $this->get_sortable_columns(); |
|
240 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
241 | - $this->prepare_query(); |
|
242 | - } |
|
24 | + /** |
|
25 | + * @var int Number of items per page |
|
26 | + * @since 1.0.19 |
|
27 | + */ |
|
28 | + public $per_page = 10; |
|
29 | + |
|
30 | + /** |
|
31 | + * Get things started |
|
32 | + * |
|
33 | + * @since 1.0.19 |
|
34 | + * @see WP_List_Table::__construct() |
|
35 | + */ |
|
36 | + public function __construct() { |
|
37 | + |
|
38 | + // Set parent defaults |
|
39 | + parent::__construct( array( |
|
40 | + 'singular' => 'id', |
|
41 | + 'plural' => 'ids', |
|
42 | + 'ajax' => false, |
|
43 | + ) ); |
|
44 | + |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Gets the name of the primary column. |
|
49 | + * |
|
50 | + * @since 1.0.19 |
|
51 | + * @access protected |
|
52 | + * |
|
53 | + * @return string Name of the primary column. |
|
54 | + */ |
|
55 | + protected function get_primary_column_name() { |
|
56 | + return 'name'; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * This function renders most of the columns in the list table. |
|
61 | + * |
|
62 | + * @since 1.0.19 |
|
63 | + * |
|
64 | + * @param WP_User $item |
|
65 | + * @param string $column_name The name of the column |
|
66 | + * |
|
67 | + * @return string Column Name |
|
68 | + */ |
|
69 | + public function column_default( $item, $column_name ) { |
|
70 | + $value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
71 | + return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Displays the country column. |
|
76 | + * |
|
77 | + * @since 1.0.19 |
|
78 | + * |
|
79 | + * @param WP_User $user |
|
80 | + * |
|
81 | + * @return string Column Name |
|
82 | + */ |
|
83 | + public function column_country( $user ) { |
|
84 | + $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
85 | + if ( $country ) { |
|
86 | + $country = wpinv_country_name( $country ); |
|
87 | + } |
|
88 | + return sanitize_text_field( $country ); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Displays the state column. |
|
93 | + * |
|
94 | + * @since 1.0.19 |
|
95 | + * |
|
96 | + * @param WP_User $user |
|
97 | + * |
|
98 | + * @return string Column Name |
|
99 | + */ |
|
100 | + public function column_state( $user ) { |
|
101 | + $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
102 | + $state = $user->_wpinv_state; |
|
103 | + if ( $state ) { |
|
104 | + $state = wpinv_state_name( $state, $country ); |
|
105 | + } |
|
106 | + |
|
107 | + return sanitize_text_field( $state ); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Generates content for a single row of the table |
|
112 | + * @since 1.0.19 |
|
113 | + * |
|
114 | + * @param int $item The user id. |
|
115 | + */ |
|
116 | + public function single_row( $item ) { |
|
117 | + $item = get_user_by( 'id', $item ); |
|
118 | + |
|
119 | + if ( empty( $item ) ) { |
|
120 | + return; |
|
121 | + } |
|
122 | + |
|
123 | + echo '<tr>'; |
|
124 | + $this->single_row_columns( $item ); |
|
125 | + echo '</tr>'; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Displays the customers name |
|
130 | + * |
|
131 | + * @param WP_User $customer customer. |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function column_name( $customer ) { |
|
135 | + |
|
136 | + // Customer view URL. |
|
137 | + $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
138 | + $row_actions = $this->row_actions( |
|
139 | + array( |
|
140 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
141 | + ) |
|
142 | + ); |
|
143 | + |
|
144 | + // Get user's address. |
|
145 | + $address = wpinv_get_user_address( $customer->ID ); |
|
146 | + |
|
147 | + // Customer email address. |
|
148 | + $email = sanitize_email( $customer->user_email ); |
|
149 | + |
|
150 | + // Customer's avatar. |
|
151 | + $avatar = esc_url( get_avatar_url( $email ) ); |
|
152 | + $avatar = "<img src='$avatar' height='32' width='32'/>"; |
|
153 | + |
|
154 | + // Customer's name. |
|
155 | + $name = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" ); |
|
156 | + |
|
157 | + if ( ! empty( $name ) ) { |
|
158 | + $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
|
159 | + } |
|
160 | + |
|
161 | + $email = "<div class='row-title'><a href='$view_url'>$email</a></div>"; |
|
162 | + |
|
163 | + return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>"; |
|
164 | + |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Retrieve the table columns |
|
169 | + * |
|
170 | + * @since 1.0.19 |
|
171 | + * @return array $columns Array of all the list table columns |
|
172 | + */ |
|
173 | + public function get_columns() { |
|
174 | + |
|
175 | + $columns = array( |
|
176 | + 'name' => __( 'Name', 'invoicing' ), |
|
177 | + 'country' => __( 'Country', 'invoicing' ), |
|
178 | + 'state' => __( 'State', 'invoicing' ), |
|
179 | + 'city' => __( 'City', 'invoicing' ), |
|
180 | + 'zip' => __( 'ZIP', 'invoicing' ), |
|
181 | + 'address' => __( 'Address', 'invoicing' ), |
|
182 | + 'phone' => __( 'Phone', 'invoicing' ), |
|
183 | + 'company' => __( 'Company', 'invoicing' ), |
|
184 | + ); |
|
185 | + return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
186 | + |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Retrieve the current page number |
|
191 | + * |
|
192 | + * @since 1.0.19 |
|
193 | + * @return int Current page number |
|
194 | + */ |
|
195 | + public function get_paged() { |
|
196 | + return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Returns bulk actions. |
|
201 | + * |
|
202 | + * @since 1.0.19 |
|
203 | + * @return void |
|
204 | + */ |
|
205 | + public function bulk_actions( $which = '' ) { |
|
206 | + return array(); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Prepares the display query |
|
211 | + */ |
|
212 | + public function prepare_query() { |
|
213 | + global $wpdb; |
|
214 | + |
|
215 | + // Users with invoices. |
|
216 | + $customers = $wpdb->get_col( |
|
217 | + $wpdb->prepare( |
|
218 | + "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE post_type=%s LIMIT %d,%d", |
|
219 | + 'wpi_invoice', |
|
220 | + $this->get_paged() * 10 - 10, |
|
221 | + $this->per_page |
|
222 | + ) |
|
223 | + ); |
|
224 | + |
|
225 | + $this->items = $customers; |
|
226 | + $this->total = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE post_type=%s", 'wpi_invoice' ) ); |
|
227 | + |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Setup the final data for the table |
|
232 | + * |
|
233 | + * @since 1.0.19 |
|
234 | + * @return void |
|
235 | + */ |
|
236 | + public function prepare_items() { |
|
237 | + $columns = $this->get_columns(); |
|
238 | + $hidden = array(); // No hidden columns |
|
239 | + $sortable = $this->get_sortable_columns(); |
|
240 | + $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
241 | + $this->prepare_query(); |
|
242 | + } |
|
243 | 243 | } |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // Exit if accessed directly |
8 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
8 | +if (!defined('ABSPATH')) exit; |
|
9 | 9 | |
10 | 10 | // Load WP_List_Table if not loaded |
11 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
11 | +if (!class_exists('WP_List_Table')) { |
|
12 | 12 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
13 | 13 | } |
14 | 14 | |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | public function __construct() { |
37 | 37 | |
38 | 38 | // Set parent defaults |
39 | - parent::__construct( array( |
|
39 | + parent::__construct(array( |
|
40 | 40 | 'singular' => 'id', |
41 | 41 | 'plural' => 'ids', |
42 | 42 | 'ajax' => false, |
43 | - ) ); |
|
43 | + )); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return string Column Name |
68 | 68 | */ |
69 | - public function column_default( $item, $column_name ) { |
|
70 | - $value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
71 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
69 | + public function column_default($item, $column_name) { |
|
70 | + $value = sanitize_text_field(get_user_meta($item->ID, '_wpinv_' . $column_name, true)); |
|
71 | + return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return string Column Name |
82 | 82 | */ |
83 | - public function column_country( $user ) { |
|
84 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
85 | - if ( $country ) { |
|
86 | - $country = wpinv_country_name( $country ); |
|
83 | + public function column_country($user) { |
|
84 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
85 | + if ($country) { |
|
86 | + $country = wpinv_country_name($country); |
|
87 | 87 | } |
88 | - return sanitize_text_field( $country ); |
|
88 | + return sanitize_text_field($country); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return string Column Name |
99 | 99 | */ |
100 | - public function column_state( $user ) { |
|
101 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
100 | + public function column_state($user) { |
|
101 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
102 | 102 | $state = $user->_wpinv_state; |
103 | - if ( $state ) { |
|
104 | - $state = wpinv_state_name( $state, $country ); |
|
103 | + if ($state) { |
|
104 | + $state = wpinv_state_name($state, $country); |
|
105 | 105 | } |
106 | 106 | |
107 | - return sanitize_text_field( $state ); |
|
107 | + return sanitize_text_field($state); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @param int $item The user id. |
115 | 115 | */ |
116 | - public function single_row( $item ) { |
|
117 | - $item = get_user_by( 'id', $item ); |
|
116 | + public function single_row($item) { |
|
117 | + $item = get_user_by('id', $item); |
|
118 | 118 | |
119 | - if ( empty( $item ) ) { |
|
119 | + if (empty($item)) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | 123 | echo '<tr>'; |
124 | - $this->single_row_columns( $item ); |
|
124 | + $this->single_row_columns($item); |
|
125 | 125 | echo '</tr>'; |
126 | 126 | } |
127 | 127 | |
@@ -131,30 +131,30 @@ discard block |
||
131 | 131 | * @param WP_User $customer customer. |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function column_name( $customer ) { |
|
134 | + public function column_name($customer) { |
|
135 | 135 | |
136 | 136 | // Customer view URL. |
137 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
137 | + $view_url = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php'))); |
|
138 | 138 | $row_actions = $this->row_actions( |
139 | 139 | array( |
140 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
140 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>', |
|
141 | 141 | ) |
142 | 142 | ); |
143 | 143 | |
144 | 144 | // Get user's address. |
145 | - $address = wpinv_get_user_address( $customer->ID ); |
|
145 | + $address = wpinv_get_user_address($customer->ID); |
|
146 | 146 | |
147 | 147 | // Customer email address. |
148 | - $email = sanitize_email( $customer->user_email ); |
|
148 | + $email = sanitize_email($customer->user_email); |
|
149 | 149 | |
150 | 150 | // Customer's avatar. |
151 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
151 | + $avatar = esc_url(get_avatar_url($email)); |
|
152 | 152 | $avatar = "<img src='$avatar' height='32' width='32'/>"; |
153 | 153 | |
154 | 154 | // Customer's name. |
155 | - $name = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" ); |
|
155 | + $name = sanitize_text_field("{$address['first_name']} {$address['last_name']}"); |
|
156 | 156 | |
157 | - if ( ! empty( $name ) ) { |
|
157 | + if (!empty($name)) { |
|
158 | 158 | $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
159 | 159 | } |
160 | 160 | |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | public function get_columns() { |
174 | 174 | |
175 | 175 | $columns = array( |
176 | - 'name' => __( 'Name', 'invoicing' ), |
|
177 | - 'country' => __( 'Country', 'invoicing' ), |
|
178 | - 'state' => __( 'State', 'invoicing' ), |
|
179 | - 'city' => __( 'City', 'invoicing' ), |
|
180 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
181 | - 'address' => __( 'Address', 'invoicing' ), |
|
182 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
183 | - 'company' => __( 'Company', 'invoicing' ), |
|
176 | + 'name' => __('Name', 'invoicing'), |
|
177 | + 'country' => __('Country', 'invoicing'), |
|
178 | + 'state' => __('State', 'invoicing'), |
|
179 | + 'city' => __('City', 'invoicing'), |
|
180 | + 'zip' => __('ZIP', 'invoicing'), |
|
181 | + 'address' => __('Address', 'invoicing'), |
|
182 | + 'phone' => __('Phone', 'invoicing'), |
|
183 | + 'company' => __('Company', 'invoicing'), |
|
184 | 184 | ); |
185 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
185 | + return apply_filters('wpinv_customers_table_columns', $columns); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @return int Current page number |
194 | 194 | */ |
195 | 195 | public function get_paged() { |
196 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
196 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @since 1.0.19 |
203 | 203 | * @return void |
204 | 204 | */ |
205 | - public function bulk_actions( $which = '' ) { |
|
205 | + public function bulk_actions($which = '') { |
|
206 | 206 | return array(); |
207 | 207 | } |
208 | 208 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | ); |
224 | 224 | |
225 | 225 | $this->items = $customers; |
226 | - $this->total = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE post_type=%s", 'wpi_invoice' ) ); |
|
226 | + $this->total = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts WHERE post_type=%s", 'wpi_invoice')); |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | $columns = $this->get_columns(); |
238 | 238 | $hidden = array(); // No hidden columns |
239 | 239 | $sortable = $this->get_sortable_columns(); |
240 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
240 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
241 | 241 | $this->prepare_query(); |
242 | 242 | } |
243 | 243 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Setup menus in WP admin. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WC_Admin_Menus Class. |
@@ -13,24 +13,24 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
17 | - add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 ); |
|
19 | - add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 ); |
|
20 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
21 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
17 | + add_action('admin_menu', array($this, 'add_customers_menu'), 18); |
|
18 | + add_action('admin_menu', array($this, 'add_addons_menu'), 100); |
|
19 | + add_action('admin_menu', array($this, 'add_settings_menu'), 60); |
|
20 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
21 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function admin_menu() { |
25 | 25 | |
26 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
26 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
27 | 27 | add_menu_page( |
28 | - __( 'GetPaid', 'invoicing' ), |
|
29 | - __( 'GetPaid', 'invoicing' ), |
|
28 | + __('GetPaid', 'invoicing'), |
|
29 | + __('GetPaid', 'invoicing'), |
|
30 | 30 | $capability, |
31 | 31 | 'wpinv', |
32 | 32 | null, |
33 | - 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ), |
|
33 | + 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')), |
|
34 | 34 | '54.123460' |
35 | 35 | ); |
36 | 36 | |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | public function add_customers_menu() { |
43 | 43 | add_submenu_page( |
44 | 44 | 'wpinv', |
45 | - __( 'Customers', 'invoicing' ), |
|
46 | - __( 'Customers', 'invoicing' ), |
|
45 | + __('Customers', 'invoicing'), |
|
46 | + __('Customers', 'invoicing'), |
|
47 | 47 | wpinv_get_capability(), |
48 | 48 | 'wpinv-customers', |
49 | - array( $this, 'customers_page' ) |
|
49 | + array($this, 'customers_page') |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * Displays the customers page. |
55 | 55 | */ |
56 | 56 | public function customers_page() { |
57 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' ); |
|
57 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php'); |
|
58 | 58 | ?> |
59 | 59 | <div class="wrap wpi-customers-wrap"> |
60 | 60 | <style> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | width: 30%; |
63 | 63 | } |
64 | 64 | </style> |
65 | - <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1> |
|
65 | + <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1> |
|
66 | 66 | <?php |
67 | 67 | $table = new WPInv_Customers_Table(); |
68 | 68 | $table->prepare_items(); |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | public function add_settings_menu() { |
79 | 79 | add_submenu_page( |
80 | 80 | 'wpinv', |
81 | - __( 'Invoice Settings', 'invoicing' ), |
|
82 | - __( 'Settings', 'invoicing' ), |
|
83 | - apply_filters( 'invoicing_capability', wpinv_get_capability() ), |
|
81 | + __('Invoice Settings', 'invoicing'), |
|
82 | + __('Settings', 'invoicing'), |
|
83 | + apply_filters('invoicing_capability', wpinv_get_capability()), |
|
84 | 84 | 'wpinv-settings', |
85 | - array( $this, 'options_page' ) |
|
85 | + array($this, 'options_page') |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
89 | - public function add_addons_menu(){ |
|
90 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
89 | + public function add_addons_menu() { |
|
90 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
91 | 91 | return; |
92 | 92 | } |
93 | 93 | |
@@ -97,78 +97,78 @@ discard block |
||
97 | 97 | __('Extensions', 'invoicing'), |
98 | 98 | 'manage_options', |
99 | 99 | 'wpi-addons', |
100 | - array( $this, 'addons_page' ) |
|
100 | + array($this, 'addons_page') |
|
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
104 | - public function addons_page(){ |
|
104 | + public function addons_page() { |
|
105 | 105 | $addon_obj = new WPInv_Admin_Addons(); |
106 | 106 | $addon_obj->output(); |
107 | 107 | } |
108 | 108 | |
109 | 109 | function options_page() { |
110 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
110 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
111 | 111 | |
112 | - if ( $page !== 'wpinv-settings' ) { |
|
112 | + if ($page !== 'wpinv-settings') { |
|
113 | 113 | return; |
114 | 114 | } |
115 | 115 | |
116 | 116 | $settings_tabs = wpinv_get_settings_tabs(); |
117 | 117 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
118 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
119 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
118 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
119 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
120 | 120 | $key = 'main'; |
121 | 121 | |
122 | - if ( is_array( $sections ) ) { |
|
123 | - $key = key( $sections ); |
|
122 | + if (is_array($sections)) { |
|
123 | + $key = key($sections); |
|
124 | 124 | } |
125 | 125 | |
126 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
127 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
126 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
127 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
128 | 128 | ob_start(); |
129 | 129 | ?> |
130 | 130 | <div class="wrap"> |
131 | 131 | <h1 class="nav-tab-wrapper"> |
132 | 132 | <?php |
133 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
134 | - $tab_url = add_query_arg( array( |
|
133 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
134 | + $tab_url = add_query_arg(array( |
|
135 | 135 | 'settings-updated' => false, |
136 | 136 | 'tab' => $tab_id, |
137 | - ) ); |
|
137 | + )); |
|
138 | 138 | |
139 | 139 | // Remove the section from the tabs so we always end up at the main section |
140 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
141 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
140 | + $tab_url = remove_query_arg('section', $tab_url); |
|
141 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
142 | 142 | |
143 | 143 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
144 | 144 | |
145 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
146 | - echo esc_html( $tab_name ); |
|
145 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
146 | + echo esc_html($tab_name); |
|
147 | 147 | echo '</a>'; |
148 | 148 | } |
149 | 149 | ?> |
150 | 150 | </h1> |
151 | 151 | <?php |
152 | - $number_of_sections = count( $sections ); |
|
152 | + $number_of_sections = count($sections); |
|
153 | 153 | $number = 0; |
154 | - if ( $number_of_sections > 1 ) { |
|
154 | + if ($number_of_sections > 1) { |
|
155 | 155 | echo '<div><ul class="subsubsub">'; |
156 | - foreach( $sections as $section_id => $section_name ) { |
|
156 | + foreach ($sections as $section_id => $section_name) { |
|
157 | 157 | echo '<li>'; |
158 | 158 | $number++; |
159 | - $tab_url = add_query_arg( array( |
|
159 | + $tab_url = add_query_arg(array( |
|
160 | 160 | 'settings-updated' => false, |
161 | 161 | 'tab' => $active_tab, |
162 | 162 | 'section' => $section_id |
163 | - ) ); |
|
164 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
163 | + )); |
|
164 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
165 | 165 | $class = ''; |
166 | - if ( $section == $section_id ) { |
|
166 | + if ($section == $section_id) { |
|
167 | 167 | $class = 'current'; |
168 | 168 | } |
169 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
169 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
170 | 170 | |
171 | - if ( $number != $number_of_sections ) { |
|
171 | + if ($number != $number_of_sections) { |
|
172 | 172 | echo ' | '; |
173 | 173 | } |
174 | 174 | echo '</li>'; |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | <form method="post" action="options.php"> |
181 | 181 | <table class="form-table"> |
182 | 182 | <?php |
183 | - settings_fields( 'wpinv_settings' ); |
|
183 | + settings_fields('wpinv_settings'); |
|
184 | 184 | |
185 | - if ( 'main' === $section ) { |
|
186 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
185 | + if ('main' === $section) { |
|
186 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
187 | 187 | } |
188 | 188 | |
189 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
190 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
191 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
189 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
190 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
191 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
192 | 192 | |
193 | 193 | // For backwards compatibility |
194 | - if ( 'main' === $section ) { |
|
195 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
194 | + if ('main' === $section) { |
|
195 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
196 | 196 | } |
197 | 197 | ?> |
198 | 198 | </table> |
@@ -206,18 +206,18 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | public function remove_admin_submenus() { |
209 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
209 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
210 | 210 | } |
211 | 211 | |
212 | - public function add_nav_menu_meta_boxes(){ |
|
213 | - add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' ); |
|
212 | + public function add_nav_menu_meta_boxes() { |
|
213 | + add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low'); |
|
214 | 214 | } |
215 | 215 | |
216 | - public function nav_menu_links(){ |
|
216 | + public function nav_menu_links() { |
|
217 | 217 | $endpoints = $this->get_menu_items(); |
218 | 218 | ?> |
219 | 219 | <div id="invoicing-endpoints" class="posttypediv"> |
220 | - <?php if(!empty($endpoints['pages'])){ ?> |
|
220 | + <?php if (!empty($endpoints['pages'])) { ?> |
|
221 | 221 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
222 | 222 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
223 | 223 | <?php |
@@ -229,29 +229,29 @@ discard block |
||
229 | 229 | <?php } ?> |
230 | 230 | <p class="button-controls"> |
231 | 231 | <span class="list-controls"> |
232 | - <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a> |
|
232 | + <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a> |
|
233 | 233 | </span> |
234 | 234 | <span class="add-to-menu"> |
235 | - <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
235 | + <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
236 | 236 | <span class="spinner"></span> |
237 | 237 | </span> |
238 | 238 | </p> |
239 | 239 | <?php |
240 | 240 | } |
241 | 241 | |
242 | - public function get_menu_items(){ |
|
242 | + public function get_menu_items() { |
|
243 | 243 | $items = array(); |
244 | 244 | |
245 | - $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' ); |
|
246 | - if($wpinv_history_page_id > 0){ |
|
245 | + $wpinv_history_page_id = (int) wpinv_get_option('invoice_history_page'); |
|
246 | + if ($wpinv_history_page_id > 0) { |
|
247 | 247 | $item = new stdClass(); |
248 | 248 | $item->object_id = $wpinv_history_page_id; |
249 | 249 | $item->db_id = 0; |
250 | - $item->object = 'page'; |
|
250 | + $item->object = 'page'; |
|
251 | 251 | $item->menu_item_parent = 0; |
252 | 252 | $item->type = 'post_type'; |
253 | - $item->title = __('Invoice History Page','invoicing'); |
|
254 | - $item->url = get_permalink( $wpinv_history_page_id ); |
|
253 | + $item->title = __('Invoice History Page', 'invoicing'); |
|
254 | + $item->url = get_permalink($wpinv_history_page_id); |
|
255 | 255 | $item->target = ''; |
256 | 256 | $item->attr_title = ''; |
257 | 257 | $item->classes = array('wpinv-menu-item'); |
@@ -260,16 +260,16 @@ discard block |
||
260 | 260 | $items['pages'][] = $item; |
261 | 261 | } |
262 | 262 | |
263 | - $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' ); |
|
264 | - if($wpinv_sub_history_page_id > 0){ |
|
263 | + $wpinv_sub_history_page_id = (int) wpinv_get_option('invoice_subscription_page'); |
|
264 | + if ($wpinv_sub_history_page_id > 0) { |
|
265 | 265 | $item = new stdClass(); |
266 | 266 | $item->object_id = $wpinv_sub_history_page_id; |
267 | 267 | $item->db_id = 0; |
268 | - $item->object = 'page'; |
|
268 | + $item->object = 'page'; |
|
269 | 269 | $item->menu_item_parent = 0; |
270 | 270 | $item->type = 'post_type'; |
271 | - $item->title = __('Invoice Subscriptions Page','invoicing'); |
|
272 | - $item->url = get_permalink( $wpinv_sub_history_page_id ); |
|
271 | + $item->title = __('Invoice Subscriptions Page', 'invoicing'); |
|
272 | + $item->url = get_permalink($wpinv_sub_history_page_id); |
|
273 | 273 | $item->target = ''; |
274 | 274 | $item->attr_title = ''; |
275 | 275 | $item->classes = array('wpinv-menu-item'); |
@@ -278,16 +278,16 @@ discard block |
||
278 | 278 | $items['pages'][] = $item; |
279 | 279 | } |
280 | 280 | |
281 | - $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' ); |
|
282 | - if($wpinv_checkout_page_id > 0){ |
|
281 | + $wpinv_checkout_page_id = (int) wpinv_get_option('checkout_page'); |
|
282 | + if ($wpinv_checkout_page_id > 0) { |
|
283 | 283 | $item = new stdClass(); |
284 | 284 | $item->object_id = $wpinv_checkout_page_id; |
285 | 285 | $item->db_id = 0; |
286 | - $item->object = 'page'; |
|
286 | + $item->object = 'page'; |
|
287 | 287 | $item->menu_item_parent = 0; |
288 | 288 | $item->type = 'post_type'; |
289 | - $item->title = __('Checkout Page','invoicing'); |
|
290 | - $item->url = get_permalink( $wpinv_checkout_page_id ); |
|
289 | + $item->title = __('Checkout Page', 'invoicing'); |
|
290 | + $item->url = get_permalink($wpinv_checkout_page_id); |
|
291 | 291 | $item->target = ''; |
292 | 292 | $item->attr_title = ''; |
293 | 293 | $item->classes = array('wpinv-menu-item'); |
@@ -296,16 +296,16 @@ discard block |
||
296 | 296 | $items['pages'][] = $item; |
297 | 297 | } |
298 | 298 | |
299 | - $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' ); |
|
300 | - if($wpinv_tandc_page_id > 0){ |
|
299 | + $wpinv_tandc_page_id = (int) wpinv_get_option('tandc_page'); |
|
300 | + if ($wpinv_tandc_page_id > 0) { |
|
301 | 301 | $item = new stdClass(); |
302 | 302 | $item->object_id = $wpinv_tandc_page_id; |
303 | 303 | $item->db_id = 0; |
304 | - $item->object = 'page'; |
|
304 | + $item->object = 'page'; |
|
305 | 305 | $item->menu_item_parent = 0; |
306 | 306 | $item->type = 'post_type'; |
307 | - $item->title = __('Terms & Conditions','invoicing'); |
|
308 | - $item->url = get_permalink( $wpinv_tandc_page_id ); |
|
307 | + $item->title = __('Terms & Conditions', 'invoicing'); |
|
308 | + $item->url = get_permalink($wpinv_tandc_page_id); |
|
309 | 309 | $item->target = ''; |
310 | 310 | $item->attr_title = ''; |
311 | 311 | $item->classes = array('wpinv-menu-item'); |
@@ -314,16 +314,16 @@ discard block |
||
314 | 314 | $items['pages'][] = $item; |
315 | 315 | } |
316 | 316 | |
317 | - $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' ); |
|
318 | - if($wpinv_success_page_id > 0){ |
|
317 | + $wpinv_success_page_id = (int) wpinv_get_option('success_page'); |
|
318 | + if ($wpinv_success_page_id > 0) { |
|
319 | 319 | $item = new stdClass(); |
320 | 320 | $item->object_id = $wpinv_success_page_id; |
321 | 321 | $item->db_id = 0; |
322 | - $item->object = 'page'; |
|
322 | + $item->object = 'page'; |
|
323 | 323 | $item->menu_item_parent = 0; |
324 | 324 | $item->type = 'post_type'; |
325 | - $item->title = __('Success Page','invoicing'); |
|
326 | - $item->url = get_permalink( $wpinv_success_page_id ); |
|
325 | + $item->title = __('Success Page', 'invoicing'); |
|
326 | + $item->url = get_permalink($wpinv_success_page_id); |
|
327 | 327 | $item->target = ''; |
328 | 328 | $item->attr_title = ''; |
329 | 329 | $item->classes = array('wpinv-menu-item'); |
@@ -332,16 +332,16 @@ discard block |
||
332 | 332 | $items['pages'][] = $item; |
333 | 333 | } |
334 | 334 | |
335 | - $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' ); |
|
336 | - if($wpinv_failure_page_id > 0){ |
|
335 | + $wpinv_failure_page_id = (int) wpinv_get_option('failure_page'); |
|
336 | + if ($wpinv_failure_page_id > 0) { |
|
337 | 337 | $item = new stdClass(); |
338 | 338 | $item->object_id = $wpinv_failure_page_id; |
339 | 339 | $item->db_id = 0; |
340 | - $item->object = 'page'; |
|
340 | + $item->object = 'page'; |
|
341 | 341 | $item->menu_item_parent = 0; |
342 | 342 | $item->type = 'post_type'; |
343 | - $item->title = __('Failed Transaction Page','invoicing'); |
|
344 | - $item->url = get_permalink( $wpinv_failure_page_id ); |
|
343 | + $item->title = __('Failed Transaction Page', 'invoicing'); |
|
344 | + $item->url = get_permalink($wpinv_failure_page_id); |
|
345 | 345 | $item->target = ''; |
346 | 346 | $item->attr_title = ''; |
347 | 347 | $item->classes = array('wpinv-menu-item'); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $items['pages'][] = $item; |
351 | 351 | } |
352 | 352 | |
353 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
353 | + return apply_filters('wpinv_menu_items', $items); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | } |
@@ -5,106 +5,106 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
8 | - exit; // Exit if accessed directly |
|
8 | + exit; // Exit if accessed directly |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
12 | 12 | |
13 | - /** |
|
14 | - * GetPaid_Admin_Profile Class. |
|
15 | - */ |
|
16 | - class GetPaid_Admin_Profile { |
|
17 | - |
|
18 | - /** |
|
19 | - * Hook in tabs. |
|
20 | - */ |
|
21 | - public function __construct() { |
|
22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
24 | - |
|
25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * Get Address Fields for the edit user pages. |
|
31 | - * |
|
32 | - * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
33 | - */ |
|
34 | - public function get_customer_meta_fields() { |
|
35 | - |
|
36 | - $show_fields = apply_filters( |
|
37 | - 'getpaid_customer_meta_fields', |
|
38 | - array( |
|
39 | - 'billing' => array( |
|
40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
41 | - 'fields' => array( |
|
42 | - '_wpinv_first_name' => array( |
|
43 | - 'label' => __( 'First name', 'invoicing' ), |
|
44 | - 'description' => '', |
|
45 | - ), |
|
46 | - '_wpinv_last_name' => array( |
|
47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
48 | - 'description' => '', |
|
49 | - ), |
|
50 | - '_wpinv_company' => array( |
|
51 | - 'label' => __( 'Company', 'invoicing' ), |
|
52 | - 'description' => '', |
|
53 | - ), |
|
54 | - '_wpinv_address' => array( |
|
55 | - 'label' => __( 'Address', 'invoicing' ), |
|
56 | - 'description' => '', |
|
57 | - ), |
|
58 | - '_wpinv_city' => array( |
|
59 | - 'label' => __( 'City', 'invoicing' ), |
|
60 | - 'description' => '', |
|
61 | - ), |
|
62 | - '_wpinv_zip' => array( |
|
63 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
64 | - 'description' => '', |
|
65 | - ), |
|
66 | - '_wpinv_country' => array( |
|
67 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
68 | - 'description' => '', |
|
69 | - 'class' => 'getpaid_js_field-country', |
|
70 | - 'type' => 'select', |
|
71 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
72 | - ), |
|
73 | - '_wpinv_state' => array( |
|
74 | - 'label' => __( 'State / County', 'invoicing' ), |
|
75 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
76 | - 'class' => 'getpaid_js_field-state regular-text', |
|
77 | - ), |
|
78 | - '_wpinv_phone' => array( |
|
79 | - 'label' => __( 'Phone', 'invoicing' ), |
|
80 | - 'description' => '', |
|
81 | - ), |
|
82 | - '_wpinv_vat_number' => array( |
|
83 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
84 | - 'description' => '', |
|
85 | - ), |
|
86 | - ), |
|
87 | - ), |
|
88 | - ) |
|
89 | - ); |
|
90 | - return $show_fields; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Show Address Fields on edit user pages. |
|
95 | - * |
|
96 | - * @param WP_User $user |
|
97 | - */ |
|
98 | - public function add_customer_meta_fields( $user ) { |
|
99 | - |
|
100 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
101 | - return; |
|
102 | - } |
|
103 | - |
|
104 | - $show_fields = $this->get_customer_meta_fields(); |
|
105 | - |
|
106 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
107 | - ?> |
|
13 | + /** |
|
14 | + * GetPaid_Admin_Profile Class. |
|
15 | + */ |
|
16 | + class GetPaid_Admin_Profile { |
|
17 | + |
|
18 | + /** |
|
19 | + * Hook in tabs. |
|
20 | + */ |
|
21 | + public function __construct() { |
|
22 | + add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | + add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
24 | + |
|
25 | + add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | + add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * Get Address Fields for the edit user pages. |
|
31 | + * |
|
32 | + * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned |
|
33 | + */ |
|
34 | + public function get_customer_meta_fields() { |
|
35 | + |
|
36 | + $show_fields = apply_filters( |
|
37 | + 'getpaid_customer_meta_fields', |
|
38 | + array( |
|
39 | + 'billing' => array( |
|
40 | + 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
41 | + 'fields' => array( |
|
42 | + '_wpinv_first_name' => array( |
|
43 | + 'label' => __( 'First name', 'invoicing' ), |
|
44 | + 'description' => '', |
|
45 | + ), |
|
46 | + '_wpinv_last_name' => array( |
|
47 | + 'label' => __( 'Last name', 'invoicing' ), |
|
48 | + 'description' => '', |
|
49 | + ), |
|
50 | + '_wpinv_company' => array( |
|
51 | + 'label' => __( 'Company', 'invoicing' ), |
|
52 | + 'description' => '', |
|
53 | + ), |
|
54 | + '_wpinv_address' => array( |
|
55 | + 'label' => __( 'Address', 'invoicing' ), |
|
56 | + 'description' => '', |
|
57 | + ), |
|
58 | + '_wpinv_city' => array( |
|
59 | + 'label' => __( 'City', 'invoicing' ), |
|
60 | + 'description' => '', |
|
61 | + ), |
|
62 | + '_wpinv_zip' => array( |
|
63 | + 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
64 | + 'description' => '', |
|
65 | + ), |
|
66 | + '_wpinv_country' => array( |
|
67 | + 'label' => __( 'Country / Region', 'invoicing' ), |
|
68 | + 'description' => '', |
|
69 | + 'class' => 'getpaid_js_field-country', |
|
70 | + 'type' => 'select', |
|
71 | + 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
72 | + ), |
|
73 | + '_wpinv_state' => array( |
|
74 | + 'label' => __( 'State / County', 'invoicing' ), |
|
75 | + 'description' => __( 'State / County or state code', 'invoicing' ), |
|
76 | + 'class' => 'getpaid_js_field-state regular-text', |
|
77 | + ), |
|
78 | + '_wpinv_phone' => array( |
|
79 | + 'label' => __( 'Phone', 'invoicing' ), |
|
80 | + 'description' => '', |
|
81 | + ), |
|
82 | + '_wpinv_vat_number' => array( |
|
83 | + 'label' => __( 'VAT Number', 'invoicing' ), |
|
84 | + 'description' => '', |
|
85 | + ), |
|
86 | + ), |
|
87 | + ), |
|
88 | + ) |
|
89 | + ); |
|
90 | + return $show_fields; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Show Address Fields on edit user pages. |
|
95 | + * |
|
96 | + * @param WP_User $user |
|
97 | + */ |
|
98 | + public function add_customer_meta_fields( $user ) { |
|
99 | + |
|
100 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
101 | + return; |
|
102 | + } |
|
103 | + |
|
104 | + $show_fields = $this->get_customer_meta_fields(); |
|
105 | + |
|
106 | + foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
107 | + ?> |
|
108 | 108 | <h2><?php echo $fieldset['title']; ?></h2> |
109 | 109 | <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
110 | 110 | <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
117 | 117 | <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
118 | 118 | <?php |
119 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
120 | - foreach ( $field['options'] as $option_key => $option_value ) : |
|
121 | - ?> |
|
119 | + $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
120 | + foreach ( $field['options'] as $option_key => $option_value ) : |
|
121 | + ?> |
|
122 | 122 | <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
123 | 123 | <?php endforeach; ?> |
124 | 124 | </select> |
@@ -133,52 +133,52 @@ discard block |
||
133 | 133 | <?php endforeach; ?> |
134 | 134 | </table> |
135 | 135 | <?php |
136 | - endforeach; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Save Address Fields on edit user pages. |
|
141 | - * |
|
142 | - * @param int $user_id User ID of the user being saved |
|
143 | - */ |
|
144 | - public function save_customer_meta_fields( $user_id ) { |
|
145 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
146 | - return; |
|
147 | - } |
|
148 | - |
|
149 | - $save_fields = $this->get_customer_meta_fields(); |
|
150 | - |
|
151 | - foreach ( $save_fields as $fieldset ) { |
|
152 | - |
|
153 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
154 | - |
|
155 | - if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
156 | - update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
157 | - } elseif ( isset( $_POST[ $key ] ) ) { |
|
158 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
166 | - * |
|
167 | - * @since 3.1.0 |
|
168 | - * @param int $user_id User ID of the user being edited |
|
169 | - * @param string $key Key for user meta field |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - protected function get_user_meta( $user_id, $key ) { |
|
173 | - $value = get_user_meta( $user_id, $key, true ); |
|
174 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
175 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
176 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
177 | - } |
|
178 | - |
|
179 | - return $value; |
|
180 | - } |
|
181 | - } |
|
136 | + endforeach; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Save Address Fields on edit user pages. |
|
141 | + * |
|
142 | + * @param int $user_id User ID of the user being saved |
|
143 | + */ |
|
144 | + public function save_customer_meta_fields( $user_id ) { |
|
145 | + if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
146 | + return; |
|
147 | + } |
|
148 | + |
|
149 | + $save_fields = $this->get_customer_meta_fields(); |
|
150 | + |
|
151 | + foreach ( $save_fields as $fieldset ) { |
|
152 | + |
|
153 | + foreach ( $fieldset['fields'] as $key => $field ) { |
|
154 | + |
|
155 | + if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
156 | + update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
157 | + } elseif ( isset( $_POST[ $key ] ) ) { |
|
158 | + update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Get user meta for a given key, with fallbacks to core user info for pre-existing fields. |
|
166 | + * |
|
167 | + * @since 3.1.0 |
|
168 | + * @param int $user_id User ID of the user being edited |
|
169 | + * @param string $key Key for user meta field |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + protected function get_user_meta( $user_id, $key ) { |
|
173 | + $value = get_user_meta( $user_id, $key, true ); |
|
174 | + $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
175 | + if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
176 | + $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
177 | + } |
|
178 | + |
|
179 | + return $value; |
|
180 | + } |
|
181 | + } |
|
182 | 182 | |
183 | 183 | endif; |
184 | 184 |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; // Exit if accessed directly |
9 | 9 | } |
10 | 10 | |
11 | -if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) : |
|
11 | +if (!class_exists('GetPaid_Admin_Profile', false)) : |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * GetPaid_Admin_Profile Class. |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | * Hook in tabs. |
20 | 20 | */ |
21 | 21 | public function __construct() { |
22 | - add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
23 | - add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 ); |
|
22 | + add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
23 | + add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100); |
|
24 | 24 | |
25 | - add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) ); |
|
26 | - add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) ); |
|
25 | + add_action('personal_options_update', array($this, 'save_customer_meta_fields')); |
|
26 | + add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields')); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -37,50 +37,50 @@ discard block |
||
37 | 37 | 'getpaid_customer_meta_fields', |
38 | 38 | array( |
39 | 39 | 'billing' => array( |
40 | - 'title' => __( 'Billing Details (GetPaid)', 'invoicing' ), |
|
40 | + 'title' => __('Billing Details (GetPaid)', 'invoicing'), |
|
41 | 41 | 'fields' => array( |
42 | 42 | '_wpinv_first_name' => array( |
43 | - 'label' => __( 'First name', 'invoicing' ), |
|
43 | + 'label' => __('First name', 'invoicing'), |
|
44 | 44 | 'description' => '', |
45 | 45 | ), |
46 | 46 | '_wpinv_last_name' => array( |
47 | - 'label' => __( 'Last name', 'invoicing' ), |
|
47 | + 'label' => __('Last name', 'invoicing'), |
|
48 | 48 | 'description' => '', |
49 | 49 | ), |
50 | 50 | '_wpinv_company' => array( |
51 | - 'label' => __( 'Company', 'invoicing' ), |
|
51 | + 'label' => __('Company', 'invoicing'), |
|
52 | 52 | 'description' => '', |
53 | 53 | ), |
54 | 54 | '_wpinv_address' => array( |
55 | - 'label' => __( 'Address', 'invoicing' ), |
|
55 | + 'label' => __('Address', 'invoicing'), |
|
56 | 56 | 'description' => '', |
57 | 57 | ), |
58 | 58 | '_wpinv_city' => array( |
59 | - 'label' => __( 'City', 'invoicing' ), |
|
59 | + 'label' => __('City', 'invoicing'), |
|
60 | 60 | 'description' => '', |
61 | 61 | ), |
62 | 62 | '_wpinv_zip' => array( |
63 | - 'label' => __( 'Postcode / ZIP', 'invoicing' ), |
|
63 | + 'label' => __('Postcode / ZIP', 'invoicing'), |
|
64 | 64 | 'description' => '', |
65 | 65 | ), |
66 | 66 | '_wpinv_country' => array( |
67 | - 'label' => __( 'Country / Region', 'invoicing' ), |
|
67 | + 'label' => __('Country / Region', 'invoicing'), |
|
68 | 68 | 'description' => '', |
69 | 69 | 'class' => 'getpaid_js_field-country', |
70 | 70 | 'type' => 'select', |
71 | - 'options' => array( '' => __( 'Select a country / region…', 'invoicing' ) ) + wpinv_get_country_list(), |
|
71 | + 'options' => array('' => __('Select a country / region…', 'invoicing')) + wpinv_get_country_list(), |
|
72 | 72 | ), |
73 | 73 | '_wpinv_state' => array( |
74 | - 'label' => __( 'State / County', 'invoicing' ), |
|
75 | - 'description' => __( 'State / County or state code', 'invoicing' ), |
|
74 | + 'label' => __('State / County', 'invoicing'), |
|
75 | + 'description' => __('State / County or state code', 'invoicing'), |
|
76 | 76 | 'class' => 'getpaid_js_field-state regular-text', |
77 | 77 | ), |
78 | 78 | '_wpinv_phone' => array( |
79 | - 'label' => __( 'Phone', 'invoicing' ), |
|
79 | + 'label' => __('Phone', 'invoicing'), |
|
80 | 80 | 'description' => '', |
81 | 81 | ), |
82 | 82 | '_wpinv_vat_number' => array( |
83 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
83 | + 'label' => __('VAT Number', 'invoicing'), |
|
84 | 84 | 'description' => '', |
85 | 85 | ), |
86 | 86 | ), |
@@ -95,39 +95,39 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param WP_User $user |
97 | 97 | */ |
98 | - public function add_customer_meta_fields( $user ) { |
|
98 | + public function add_customer_meta_fields($user) { |
|
99 | 99 | |
100 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) { |
|
100 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
104 | 104 | $show_fields = $this->get_customer_meta_fields(); |
105 | 105 | |
106 | - foreach ( $show_fields as $fieldset_key => $fieldset ) : |
|
106 | + foreach ($show_fields as $fieldset_key => $fieldset) : |
|
107 | 107 | ?> |
108 | 108 | <h2><?php echo $fieldset['title']; ?></h2> |
109 | - <table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>"> |
|
110 | - <?php foreach ( $fieldset['fields'] as $key => $field ) : ?> |
|
109 | + <table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>"> |
|
110 | + <?php foreach ($fieldset['fields'] as $key => $field) : ?> |
|
111 | 111 | <tr> |
112 | 112 | <th> |
113 | - <label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label> |
|
113 | + <label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label> |
|
114 | 114 | </th> |
115 | 115 | <td> |
116 | - <?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?> |
|
117 | - <select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;"> |
|
116 | + <?php if (!empty($field['type']) && 'select' === $field['type']) : ?> |
|
117 | + <select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;"> |
|
118 | 118 | <?php |
119 | - $selected = esc_attr( get_user_meta( $user->ID, $key, true ) ); |
|
120 | - foreach ( $field['options'] as $option_key => $option_value ) : |
|
119 | + $selected = esc_attr(get_user_meta($user->ID, $key, true)); |
|
120 | + foreach ($field['options'] as $option_key => $option_value) : |
|
121 | 121 | ?> |
122 | - <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option> |
|
122 | + <option value="<?php echo esc_attr($option_key); ?>" <?php selected($selected, $option_key, true); ?>><?php echo esc_html($option_value); ?></option> |
|
123 | 123 | <?php endforeach; ?> |
124 | 124 | </select> |
125 | - <?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?> |
|
126 | - <input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> /> |
|
125 | + <?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?> |
|
126 | + <input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) get_user_meta($user->ID, $key, true), 1, true); ?> /> |
|
127 | 127 | <?php else : ?> |
128 | - <input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> |
|
128 | + <input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($this->get_user_meta($user->ID, $key)); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" /> |
|
129 | 129 | <?php endif; ?> |
130 | - <p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p> |
|
130 | + <p class="description"><?php echo wp_kses_post($field['description']); ?></p> |
|
131 | 131 | </td> |
132 | 132 | </tr> |
133 | 133 | <?php endforeach; ?> |
@@ -141,21 +141,21 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param int $user_id User ID of the user being saved |
143 | 143 | */ |
144 | - public function save_customer_meta_fields( $user_id ) { |
|
145 | - if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) { |
|
144 | + public function save_customer_meta_fields($user_id) { |
|
145 | + if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
149 | 149 | $save_fields = $this->get_customer_meta_fields(); |
150 | 150 | |
151 | - foreach ( $save_fields as $fieldset ) { |
|
151 | + foreach ($save_fields as $fieldset) { |
|
152 | 152 | |
153 | - foreach ( $fieldset['fields'] as $key => $field ) { |
|
153 | + foreach ($fieldset['fields'] as $key => $field) { |
|
154 | 154 | |
155 | - if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) { |
|
156 | - update_user_meta( $user_id, $key, isset( $_POST[ $key ] ) ); |
|
157 | - } elseif ( isset( $_POST[ $key ] ) ) { |
|
158 | - update_user_meta( $user_id, $key, wpinv_clean( $_POST[ $key ] ) ); |
|
155 | + if (isset($field['type']) && 'checkbox' === $field['type']) { |
|
156 | + update_user_meta($user_id, $key, isset($_POST[$key])); |
|
157 | + } elseif (isset($_POST[$key])) { |
|
158 | + update_user_meta($user_id, $key, wpinv_clean($_POST[$key])); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $key Key for user meta field |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - protected function get_user_meta( $user_id, $key ) { |
|
173 | - $value = get_user_meta( $user_id, $key, true ); |
|
174 | - $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' ); |
|
175 | - if ( ! $value && in_array( $key, $existing_fields ) ) { |
|
176 | - $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true ); |
|
172 | + protected function get_user_meta($user_id, $key) { |
|
173 | + $value = get_user_meta($user_id, $key, true); |
|
174 | + $existing_fields = array('_wpinv_first_name', '_wpinv_last_name'); |
|
175 | + if (!$value && in_array($key, $existing_fields)) { |
|
176 | + $value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | return $value; |
@@ -124,8 +124,11 @@ |
||
124 | 124 | </select> |
125 | 125 | <?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?> |
126 | 126 | <input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> /> |
127 | - <?php else : ?> |
|
128 | - <input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> |
|
127 | + <?php else { |
|
128 | + : ?> |
|
129 | + <input type="text" name="<?php echo esc_attr( $key ); |
|
130 | +} |
|
131 | +?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" /> |
|
129 | 132 | <?php endif; ?> |
130 | 133 | <p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p> |
131 | 134 | </td> |
@@ -7,15 +7,15 @@ 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 | class WPInv_Plugin { |
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
19 | 19 | self::$instance = new WPInv_Plugin; |
20 | 20 | self::$instance->includes(); |
21 | 21 | self::$instance->actions(); |
@@ -33,35 +33,35 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public function define_constants() { |
36 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
37 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
36 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
37 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | private function actions() { |
41 | 41 | /* Internationalize the text strings used. */ |
42 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
42 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
43 | 43 | |
44 | 44 | /* Perform actions on admin initialization. */ |
45 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
46 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
47 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
45 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
46 | + add_action('init', array(&$this, 'init'), 3); |
|
47 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
48 | 48 | |
49 | - if ( class_exists( 'BuddyPress' ) ) { |
|
50 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
49 | + if (class_exists('BuddyPress')) { |
|
50 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
51 | 51 | } |
52 | 52 | |
53 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
54 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
55 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
56 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
53 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
54 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
55 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
56 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
57 | 57 | |
58 | - if ( is_admin() ) { |
|
59 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
60 | - add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
61 | - add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) ); |
|
58 | + if (is_admin()) { |
|
59 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
60 | + add_filter('admin_body_class', array(&$this, 'admin_body_class')); |
|
61 | + add_action('admin_init', array(&$this, 'init_ayecode_connect_helper')); |
|
62 | 62 | |
63 | 63 | } else { |
64 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
64 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,28 +71,28 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
73 | 73 | */ |
74 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
74 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
75 | 75 | |
76 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
76 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Maybe show the AyeCode Connect Notice. |
81 | 81 | */ |
82 | - public function init_ayecode_connect_helper(){ |
|
82 | + public function init_ayecode_connect_helper() { |
|
83 | 83 | // AyeCode Connect notice |
84 | - if ( is_admin() ){ |
|
84 | + if (is_admin()) { |
|
85 | 85 | // set the strings so they can be translated |
86 | 86 | $strings = array( |
87 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
88 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
89 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
90 | - 'connect_button' => __("Connect Site","invoicing"), |
|
91 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
92 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
93 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
87 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
88 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
89 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
90 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
91 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
92 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
93 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
94 | 94 | ); |
95 | - new AyeCode_Connect_Helper($strings,array('wpi-addons')); |
|
95 | + new AyeCode_Connect_Helper($strings, array('wpi-addons')); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | /* Internationalize the text strings used. */ |
101 | 101 | $this->load_textdomain(); |
102 | 102 | |
103 | - do_action( 'wpinv_loaded' ); |
|
103 | + do_action('wpinv_loaded'); |
|
104 | 104 | |
105 | 105 | // Fix oxygen page builder conflict |
106 | - if ( function_exists( 'ct_css_output' ) ) { |
|
106 | + if (function_exists('ct_css_output')) { |
|
107 | 107 | wpinv_oxygen_fix_conflict(); |
108 | 108 | } |
109 | 109 | } |
@@ -113,128 +113,128 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @since 1.0 |
115 | 115 | */ |
116 | - public function load_textdomain( $locale = NULL ) { |
|
117 | - if ( empty( $locale ) ) { |
|
118 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
116 | + public function load_textdomain($locale = NULL) { |
|
117 | + if (empty($locale)) { |
|
118 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
119 | 119 | } |
120 | 120 | |
121 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
121 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
122 | 122 | |
123 | - unload_textdomain( 'invoicing' ); |
|
124 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
125 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
123 | + unload_textdomain('invoicing'); |
|
124 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
125 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Define language constants. |
129 | 129 | */ |
130 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | public function includes() { |
134 | 134 | global $wpinv_options; |
135 | 135 | |
136 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
137 | 137 | $wpinv_options = wpinv_get_settings(); |
138 | 138 | |
139 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
140 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
|
141 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
142 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
143 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
144 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
145 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
146 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
147 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
148 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
149 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
150 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
151 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
152 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
153 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
154 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
155 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
156 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' ); |
|
157 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
158 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
159 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
160 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
161 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
162 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
163 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
164 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
165 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
166 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
168 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
169 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
170 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
171 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
172 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
173 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
174 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
175 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
176 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
177 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
178 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
179 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
180 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
181 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
182 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
183 | - |
|
184 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
185 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
139 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php'); |
|
141 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
142 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
143 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
144 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
145 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
146 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
147 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
148 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
149 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
150 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
151 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
152 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
153 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
154 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
155 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
156 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php'); |
|
157 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
158 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
159 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
160 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
161 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
162 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
163 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
164 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
165 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
166 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
168 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
169 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
170 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
172 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
173 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
174 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
175 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
176 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
177 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
178 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
179 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
181 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
182 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php'); |
|
183 | + |
|
184 | + if (!class_exists('WPInv_EUVat')) { |
|
185 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
186 | 186 | } |
187 | 187 | |
188 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
189 | - if ( !empty( $gateways ) ) { |
|
190 | - foreach ( $gateways as $gateway ) { |
|
191 | - if ( $gateway == 'manual' ) { |
|
188 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
189 | + if (!empty($gateways)) { |
|
190 | + foreach ($gateways as $gateway) { |
|
191 | + if ($gateway == 'manual') { |
|
192 | 192 | continue; |
193 | 193 | } |
194 | 194 | |
195 | 195 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
196 | 196 | |
197 | - if ( file_exists( $gateway_file ) ) { |
|
198 | - require_once( $gateway_file ); |
|
197 | + if (file_exists($gateway_file)) { |
|
198 | + require_once($gateway_file); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
203 | 203 | |
204 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
204 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
205 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
207 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
208 | 208 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
209 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
210 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
211 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
212 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
209 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
210 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
211 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
212 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
213 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
214 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
215 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
216 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
218 | 218 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
219 | 219 | // load the user class only on the users.php page |
220 | 220 | global $pagenow; |
221 | - if($pagenow=='users.php'){ |
|
221 | + if ($pagenow == 'users.php') { |
|
222 | 222 | new WPInv_Admin_Users(); |
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | 226 | // Register cli commands |
227 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
229 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
227 | + if (defined('WP_CLI') && WP_CLI) { |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
229 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | // include css inliner |
233 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
234 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
233 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
234 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
235 | 235 | } |
236 | 236 | |
237 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
237 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | public function init() { |
@@ -242,114 +242,114 @@ discard block |
||
242 | 242 | |
243 | 243 | public function admin_init() { |
244 | 244 | self::$instance->default_payment_form = wpinv_get_default_payment_form(); |
245 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
245 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | public function activation_redirect() { |
249 | 249 | // Bail if no activation redirect |
250 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
250 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
251 | 251 | return; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // Delete the redirect transient |
255 | - delete_transient( '_wpinv_activation_redirect' ); |
|
255 | + delete_transient('_wpinv_activation_redirect'); |
|
256 | 256 | |
257 | 257 | // Bail if activating from network, or bulk |
258 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
258 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | 261 | |
262 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
262 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
263 | 263 | exit; |
264 | 264 | } |
265 | 265 | |
266 | 266 | public function enqueue_scripts() { |
267 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
267 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
268 | 268 | |
269 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
270 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
269 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
270 | + wp_enqueue_style('wpinv_front_style'); |
|
271 | 271 | |
272 | 272 | // Register scripts |
273 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
274 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
273 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
274 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js')); |
|
275 | 275 | |
276 | 276 | $localize = array(); |
277 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
278 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
277 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
278 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
279 | 279 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
280 | 280 | $localize['currency_pos'] = wpinv_currency_position(); |
281 | 281 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
282 | 282 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
283 | 283 | $localize['decimals'] = wpinv_decimals(); |
284 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
284 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
285 | 285 | $localize['UseTaxes'] = wpinv_use_taxes(); |
286 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
286 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
287 | 287 | |
288 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
288 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
289 | 289 | |
290 | - wp_enqueue_script( 'jquery-blockui' ); |
|
290 | + wp_enqueue_script('jquery-blockui'); |
|
291 | 291 | $autofill_api = wpinv_get_option('address_autofill_api'); |
292 | 292 | $autofill_active = wpinv_get_option('address_autofill_active'); |
293 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
294 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
295 | - wp_dequeue_script( 'google-maps-api' ); |
|
293 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
294 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
295 | + wp_dequeue_script('google-maps-api'); |
|
296 | 296 | } |
297 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
298 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
297 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
298 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
299 | 299 | } |
300 | 300 | |
301 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
302 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
301 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
302 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
303 | 303 | |
304 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
305 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
304 | + wp_enqueue_script('wpinv-front-script'); |
|
305 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
306 | 306 | |
307 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
308 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
307 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
308 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
309 | 309 | } |
310 | 310 | |
311 | - public function admin_enqueue_scripts( $hook ) { |
|
311 | + public function admin_enqueue_scripts($hook) { |
|
312 | 312 | global $post, $pagenow; |
313 | 313 | |
314 | 314 | $post_type = wpinv_admin_post_type(); |
315 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
316 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
315 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
316 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
317 | 317 | |
318 | 318 | $jquery_ui_css = false; |
319 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
319 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
320 | 320 | $jquery_ui_css = true; |
321 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
321 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
322 | 322 | $jquery_ui_css = true; |
323 | 323 | } |
324 | - if ( $jquery_ui_css ) { |
|
325 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
326 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
327 | - wp_deregister_style( 'yoast-seo-select2' ); |
|
328 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
324 | + if ($jquery_ui_css) { |
|
325 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
326 | + wp_enqueue_style('jquery-ui-css'); |
|
327 | + wp_deregister_style('yoast-seo-select2'); |
|
328 | + wp_deregister_style('yoast-seo-monorepo'); |
|
329 | 329 | } |
330 | 330 | |
331 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
332 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
331 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
332 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
333 | 333 | |
334 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
335 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version ); |
|
336 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
337 | - |
|
338 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
339 | - if ( $page == 'wpinv-subscriptions' ) { |
|
340 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
341 | - wp_deregister_style( 'yoast-seo-select2' ); |
|
342 | - wp_deregister_style( 'yoast-seo-monorepo' ); |
|
334 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
335 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version); |
|
336 | + wp_enqueue_style('wpinv_admin_style'); |
|
337 | + |
|
338 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
339 | + if ($page == 'wpinv-subscriptions') { |
|
340 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
341 | + wp_deregister_style('yoast-seo-select2'); |
|
342 | + wp_deregister_style('yoast-seo-monorepo'); |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
346 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
345 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
346 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
347 | 347 | } |
348 | 348 | |
349 | - wp_enqueue_style( 'wp-color-picker' ); |
|
350 | - wp_enqueue_script( 'wp-color-picker' ); |
|
349 | + wp_enqueue_style('wp-color-picker'); |
|
350 | + wp_enqueue_script('wp-color-picker'); |
|
351 | 351 | |
352 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
352 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
353 | 353 | |
354 | 354 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
355 | 355 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -360,21 +360,21 @@ discard block |
||
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
363 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
364 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
363 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
364 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
365 | 365 | |
366 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
367 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), $version ); |
|
368 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
366 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
367 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version); |
|
368 | + wp_enqueue_script('wpinv-admin-script'); |
|
369 | 369 | |
370 | 370 | $localize = array(); |
371 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
372 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
373 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
374 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
375 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
376 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
377 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
371 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
372 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
373 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
374 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
375 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
376 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
377 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
378 | 378 | $localize['tax'] = wpinv_tax_amount(); |
379 | 379 | $localize['discount'] = wpinv_discount_amount(); |
380 | 380 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -382,100 +382,100 @@ discard block |
||
382 | 382 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
383 | 383 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
384 | 384 | $localize['decimals'] = wpinv_decimals(); |
385 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
386 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
387 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
388 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
389 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
390 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
391 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
392 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
393 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
394 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
395 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
396 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
397 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
398 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
399 | - |
|
400 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
401 | - |
|
402 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
385 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
386 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
387 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
388 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
389 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
390 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
391 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
392 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
393 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
394 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
395 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
396 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
397 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
398 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
399 | + |
|
400 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
401 | + |
|
402 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
403 | 403 | |
404 | 404 | // Load payment form scripts on our admin pages only. |
405 | - if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) { |
|
405 | + if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) { |
|
406 | 406 | |
407 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
408 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
409 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
407 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
408 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
409 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
410 | 410 | |
411 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
412 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
411 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
412 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
413 | 413 | |
414 | - wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
414 | + wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array( |
|
415 | 415 | 'elements' => $this->form_elements->get_elements(), |
416 | - 'form_elements' => $this->form_elements->get_form_elements( $post->ID ), |
|
416 | + 'form_elements' => $this->form_elements->get_form_elements($post->ID), |
|
417 | 417 | 'all_items' => $this->form_elements->get_published_items(), |
418 | 418 | 'currency' => wpinv_currency_symbol(), |
419 | 419 | 'position' => wpinv_currency_position(), |
420 | 420 | 'decimals' => (int) wpinv_decimals(), |
421 | 421 | 'thousands_sep' => wpinv_thousands_separator(), |
422 | 422 | 'decimals_sep' => wpinv_decimal_separator(), |
423 | - 'form_items' => $this->form_elements->get_form_items( $post->ID ), |
|
423 | + 'form_items' => $this->form_elements->get_form_items($post->ID), |
|
424 | 424 | 'is_default' => $post->ID == $this->default_payment_form, |
425 | - ) ); |
|
425 | + )); |
|
426 | 426 | |
427 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
427 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
428 | 428 | } |
429 | 429 | |
430 | - if ( $page == 'wpinv-subscriptions' ) { |
|
431 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
432 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
430 | + if ($page == 'wpinv-subscriptions') { |
|
431 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
432 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
433 | 433 | } |
434 | 434 | |
435 | - if ( $page == 'wpinv-reports' ) { |
|
436 | - wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
435 | + if ($page == 'wpinv-reports') { |
|
436 | + wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7'); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | } |
440 | 440 | |
441 | - public function admin_body_class( $classes ) { |
|
441 | + public function admin_body_class($classes) { |
|
442 | 442 | global $pagenow, $post, $current_screen; |
443 | 443 | |
444 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
444 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) { |
|
445 | 445 | $classes .= ' wpinv-cpt'; |
446 | 446 | } |
447 | 447 | |
448 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
448 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
449 | 449 | |
450 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
451 | - if ( $add_class ) { |
|
452 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
450 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
451 | + if ($add_class) { |
|
452 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | $settings_class = array(); |
456 | - if ( $page == 'wpinv-settings' ) { |
|
457 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
458 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
456 | + if ($page == 'wpinv-settings') { |
|
457 | + if (!empty($_REQUEST['tab'])) { |
|
458 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
459 | 459 | } |
460 | 460 | |
461 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
462 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
461 | + if (!empty($_REQUEST['section'])) { |
|
462 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
463 | 463 | } |
464 | 464 | |
465 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
465 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
466 | 466 | } |
467 | 467 | |
468 | - if ( !empty( $settings_class ) ) { |
|
469 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
468 | + if (!empty($settings_class)) { |
|
469 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | $post_type = wpinv_admin_post_type(); |
473 | 473 | |
474 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
474 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
475 | 475 | return $classes .= ' wpinv'; |
476 | 476 | } |
477 | 477 | |
478 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
478 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
479 | 479 | $classes .= ' wpi-editable-n'; |
480 | 480 | } |
481 | 481 | |
@@ -487,21 +487,21 @@ discard block |
||
487 | 487 | } |
488 | 488 | |
489 | 489 | public function wpinv_actions() { |
490 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
491 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
490 | + if (isset($_REQUEST['wpi_action'])) { |
|
491 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | - public function pre_get_posts( $wp_query ) { |
|
496 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
497 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
495 | + public function pre_get_posts($wp_query) { |
|
496 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
497 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | return $wp_query; |
501 | 501 | } |
502 | 502 | |
503 | 503 | public function bp_invoicing_init() { |
504 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
504 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -509,13 +509,13 @@ discard block |
||
509 | 509 | * |
510 | 510 | */ |
511 | 511 | public function register_widgets() { |
512 | - register_widget( "WPInv_Checkout_Widget" ); |
|
513 | - register_widget( "WPInv_History_Widget" ); |
|
514 | - register_widget( "WPInv_Receipt_Widget" ); |
|
515 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
516 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
517 | - register_widget( "WPInv_Messages_Widget" ); |
|
518 | - register_widget( 'WPInv_GetPaid_Widget' ); |
|
512 | + register_widget("WPInv_Checkout_Widget"); |
|
513 | + register_widget("WPInv_History_Widget"); |
|
514 | + register_widget("WPInv_Receipt_Widget"); |
|
515 | + register_widget("WPInv_Subscriptions_Widget"); |
|
516 | + register_widget("WPInv_Buy_Item_Widget"); |
|
517 | + register_widget("WPInv_Messages_Widget"); |
|
518 | + register_widget('WPInv_GetPaid_Widget'); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -524,10 +524,10 @@ discard block |
||
524 | 524 | * @since 1.0.19 |
525 | 525 | * @param int[] $excluded_posts_ids |
526 | 526 | */ |
527 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
527 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
528 | 528 | |
529 | 529 | // Ensure that we have an array. |
530 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
530 | + if (!is_array($excluded_posts_ids)) { |
|
531 | 531 | $excluded_posts_ids = array(); |
532 | 532 | } |
533 | 533 | |
@@ -535,24 +535,24 @@ discard block |
||
535 | 535 | $our_pages = array(); |
536 | 536 | |
537 | 537 | // Checkout page. |
538 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
538 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
539 | 539 | |
540 | 540 | // Success page. |
541 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
541 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
542 | 542 | |
543 | 543 | // Failure page. |
544 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
544 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
545 | 545 | |
546 | 546 | // History page. |
547 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
547 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
548 | 548 | |
549 | 549 | // Subscriptions page. |
550 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
550 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
551 | 551 | |
552 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
552 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
553 | 553 | |
554 | 554 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
555 | - return array_unique( $excluded_posts_ids ); |
|
555 | + return array_unique($excluded_posts_ids); |
|
556 | 556 | |
557 | 557 | } |
558 | 558 |