@@ -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 | |
@@ -42,11 +42,11 @@ discard block |
||
| 42 | 42 | public function __construct() { |
| 43 | 43 | |
| 44 | 44 | // Set parent defaults |
| 45 | - parent::__construct( array( |
|
| 45 | + parent::__construct(array( |
|
| 46 | 46 | 'singular' => 'id', |
| 47 | 47 | 'plural' => 'ids', |
| 48 | 48 | 'ajax' => false, |
| 49 | - ) ); |
|
| 49 | + )); |
|
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return string Column Name |
| 74 | 74 | */ |
| 75 | - public function column_default( $item, $column_name ) { |
|
| 76 | - $value = sanitize_text_field( get_user_meta( $item->ID, '_wpinv_' . $column_name, true ) ); |
|
| 77 | - return apply_filters( 'wpinv_customers_table_column' . $column_name, $value, $item ); |
|
| 75 | + public function column_default($item, $column_name) { |
|
| 76 | + $value = sanitize_text_field(get_user_meta($item->ID, '_wpinv_' . $column_name, true)); |
|
| 77 | + return apply_filters('wpinv_customers_table_column' . $column_name, $value, $item); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return string Column Name |
| 88 | 88 | */ |
| 89 | - public function column_country( $user ) { |
|
| 90 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 91 | - if ( $country ) { |
|
| 92 | - $country = wpinv_country_name( $country ); |
|
| 89 | + public function column_country($user) { |
|
| 90 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
| 91 | + if ($country) { |
|
| 92 | + $country = wpinv_country_name($country); |
|
| 93 | 93 | } |
| 94 | - return sanitize_text_field( $country ); |
|
| 94 | + return sanitize_text_field($country); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return string Column Name |
| 105 | 105 | */ |
| 106 | - public function column_state( $user ) { |
|
| 107 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 106 | + public function column_state($user) { |
|
| 107 | + $country = wpinv_sanitize_country($user->_wpinv_country); |
|
| 108 | 108 | $state = $user->_wpinv_state; |
| 109 | - if ( $state ) { |
|
| 110 | - $state = wpinv_state_name( $state, $country ); |
|
| 109 | + if ($state) { |
|
| 110 | + $state = wpinv_state_name($state, $country); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return sanitize_text_field( $state ); |
|
| 113 | + return sanitize_text_field($state); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return string Column Name |
| 124 | 124 | */ |
| 125 | - public function column_signup( $user ) { |
|
| 126 | - return getpaid_format_date_value( $user->user_registered ); |
|
| 125 | + public function column_signup($user) { |
|
| 126 | + return getpaid_format_date_value($user->user_registered); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return string Column Name |
| 137 | 137 | */ |
| 138 | - public function column_total( $user ) { |
|
| 138 | + public function column_total($user) { |
|
| 139 | 139 | |
| 140 | 140 | $args = array( |
| 141 | 141 | 'data' => array( |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | 'author' => array( |
| 153 | 153 | 'type' => 'post_data', |
| 154 | - 'value' => absint( $user->ID ), |
|
| 154 | + 'value' => absint($user->ID), |
|
| 155 | 155 | 'key' => 'posts.post_author', |
| 156 | 156 | 'operator' => '=', |
| 157 | 157 | ), |
| 158 | 158 | |
| 159 | 159 | ), |
| 160 | 160 | 'query_type' => 'get_var', |
| 161 | - 'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ), |
|
| 161 | + 'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'), |
|
| 162 | 162 | ); |
| 163 | 163 | |
| 164 | - return wpinv_price( (float) GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
| 164 | + return wpinv_price((float) GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @return string Column Name |
| 176 | 176 | */ |
| 177 | - public function column_invoices( $user ) { |
|
| 177 | + public function column_invoices($user) { |
|
| 178 | 178 | |
| 179 | 179 | $args = array( |
| 180 | 180 | 'data' => array( |
@@ -191,17 +191,17 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | 'author' => array( |
| 193 | 193 | 'type' => 'post_data', |
| 194 | - 'value' => absint( $user->ID ), |
|
| 194 | + 'value' => absint($user->ID), |
|
| 195 | 195 | 'key' => 'posts.post_author', |
| 196 | 196 | 'operator' => '=', |
| 197 | 197 | ), |
| 198 | 198 | |
| 199 | 199 | ), |
| 200 | 200 | 'query_type' => 'get_var', |
| 201 | - 'invoice_status' => array_keys( wpinv_get_invoice_statuses() ), |
|
| 201 | + 'invoice_status' => array_keys(wpinv_get_invoice_statuses()), |
|
| 202 | 202 | ); |
| 203 | 203 | |
| 204 | - return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) ); |
|
| 204 | + return absint(GetPaid_Reports_Helper::get_invoice_report_data($args)); |
|
| 205 | 205 | |
| 206 | 206 | } |
| 207 | 207 | |
@@ -211,15 +211,15 @@ discard block |
||
| 211 | 211 | * |
| 212 | 212 | * @param int $item The user id. |
| 213 | 213 | */ |
| 214 | - public function single_row( $item ) { |
|
| 215 | - $item = get_user_by( 'id', $item ); |
|
| 214 | + public function single_row($item) { |
|
| 215 | + $item = get_user_by('id', $item); |
|
| 216 | 216 | |
| 217 | - if ( empty( $item ) ) { |
|
| 217 | + if (empty($item)) { |
|
| 218 | 218 | return; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | echo '<tr>'; |
| 222 | - $this->single_row_columns( $item ); |
|
| 222 | + $this->single_row_columns($item); |
|
| 223 | 223 | echo '</tr>'; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -229,30 +229,30 @@ discard block |
||
| 229 | 229 | * @param WP_User $customer customer. |
| 230 | 230 | * @return string |
| 231 | 231 | */ |
| 232 | - public function column_name( $customer ) { |
|
| 232 | + public function column_name($customer) { |
|
| 233 | 233 | |
| 234 | 234 | // Customer view URL. |
| 235 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
| 235 | + $view_url = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php'))); |
|
| 236 | 236 | $row_actions = $this->row_actions( |
| 237 | 237 | array( |
| 238 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
| 238 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>', |
|
| 239 | 239 | ) |
| 240 | 240 | ); |
| 241 | 241 | |
| 242 | 242 | // Get user's address. |
| 243 | - $address = wpinv_get_user_address( $customer->ID ); |
|
| 243 | + $address = wpinv_get_user_address($customer->ID); |
|
| 244 | 244 | |
| 245 | 245 | // Customer email address. |
| 246 | - $email = sanitize_email( $customer->user_email ); |
|
| 246 | + $email = sanitize_email($customer->user_email); |
|
| 247 | 247 | |
| 248 | 248 | // Customer's avatar. |
| 249 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
| 249 | + $avatar = esc_url(get_avatar_url($email)); |
|
| 250 | 250 | $avatar = "<img src='$avatar' height='32' width='32'/>"; |
| 251 | 251 | |
| 252 | 252 | // Customer's name. |
| 253 | - $name = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" ); |
|
| 253 | + $name = sanitize_text_field("{$address['first_name']} {$address['last_name']}"); |
|
| 254 | 254 | |
| 255 | - if ( ! empty( $name ) ) { |
|
| 255 | + if (!empty($name)) { |
|
| 256 | 256 | $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -271,19 +271,19 @@ discard block |
||
| 271 | 271 | public function get_columns() { |
| 272 | 272 | |
| 273 | 273 | $columns = array( |
| 274 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 275 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 276 | - 'state' => __( 'State', 'invoicing' ), |
|
| 277 | - 'city' => __( 'City', 'invoicing' ), |
|
| 278 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 279 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 280 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 281 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 282 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
| 283 | - 'total' => __( 'Total Spend', 'invoicing' ), |
|
| 284 | - 'signup' => __( 'Date created', 'invoicing' ), |
|
| 274 | + 'name' => __('Name', 'invoicing'), |
|
| 275 | + 'country' => __('Country', 'invoicing'), |
|
| 276 | + 'state' => __('State', 'invoicing'), |
|
| 277 | + 'city' => __('City', 'invoicing'), |
|
| 278 | + 'zip' => __('ZIP', 'invoicing'), |
|
| 279 | + 'address' => __('Address', 'invoicing'), |
|
| 280 | + 'phone' => __('Phone', 'invoicing'), |
|
| 281 | + 'company' => __('Company', 'invoicing'), |
|
| 282 | + 'invoices' => __('Invoices', 'invoicing'), |
|
| 283 | + 'total' => __('Total Spend', 'invoicing'), |
|
| 284 | + 'signup' => __('Date created', 'invoicing'), |
|
| 285 | 285 | ); |
| 286 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
| 286 | + return apply_filters('wpinv_customers_table_columns', $columns); |
|
| 287 | 287 | |
| 288 | 288 | } |
| 289 | 289 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @return int Current page number |
| 295 | 295 | */ |
| 296 | 296 | public function get_paged() { |
| 297 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 297 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * @since 1.0.19 |
| 304 | 304 | * @return void |
| 305 | 305 | */ |
| 306 | - public function bulk_actions( $which = '' ) { |
|
| 306 | + public function bulk_actions($which = '') { |
|
| 307 | 307 | return array(); |
| 308 | 308 | } |
| 309 | 309 | |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | $post_types = 'WHERE '; |
| 317 | 317 | |
| 318 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 319 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
| 318 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
| 319 | + $post_types .= $wpdb->prepare("post_type=%s OR ", $post_type); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $post_types = rtrim( $post_types, ' OR' ); |
|
| 322 | + $post_types = rtrim($post_types, ' OR'); |
|
| 323 | 323 | |
| 324 | 324 | // Users with invoices. |
| 325 | 325 | $customers = $wpdb->get_col( |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | ); |
| 332 | 332 | |
| 333 | 333 | $this->items = $customers; |
| 334 | - $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types" ); |
|
| 334 | + $this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types"); |
|
| 335 | 335 | |
| 336 | 336 | } |
| 337 | 337 | |
@@ -345,14 +345,14 @@ discard block |
||
| 345 | 345 | $columns = $this->get_columns(); |
| 346 | 346 | $hidden = array(); // No hidden columns |
| 347 | 347 | $sortable = $this->get_sortable_columns(); |
| 348 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 348 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 349 | 349 | $this->prepare_query(); |
| 350 | 350 | |
| 351 | 351 | $this->set_pagination_args( |
| 352 | 352 | array( |
| 353 | 353 | 'total_items' => $this->total, |
| 354 | 354 | 'per_page' => $this->per_page, |
| 355 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
| 355 | + 'total_pages' => ceil($this->total / $this->per_page) |
|
| 356 | 356 | ) |
| 357 | 357 | ); |
| 358 | 358 | |