@@ -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,245 +21,245 @@ 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 | - * @var int Number of items |
|
| 32 | - * @since 1.0.19 |
|
| 33 | - */ |
|
| 34 | - public $total = 0; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Get things started |
|
| 38 | - * |
|
| 39 | - * @since 1.0.19 |
|
| 40 | - * @see WP_List_Table::__construct() |
|
| 41 | - */ |
|
| 42 | - public function __construct() { |
|
| 43 | - |
|
| 44 | - // Set parent defaults |
|
| 45 | - parent::__construct( array( |
|
| 46 | - 'singular' => 'id', |
|
| 47 | - 'plural' => 'ids', |
|
| 48 | - 'ajax' => false, |
|
| 49 | - ) ); |
|
| 50 | - |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Gets the name of the primary column. |
|
| 55 | - * |
|
| 56 | - * @since 1.0.19 |
|
| 57 | - * @access protected |
|
| 58 | - * |
|
| 59 | - * @return string Name of the primary column. |
|
| 60 | - */ |
|
| 61 | - protected function get_primary_column_name() { |
|
| 62 | - return 'name'; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * This function renders most of the columns in the list table. |
|
| 67 | - * |
|
| 68 | - * @since 1.0.19 |
|
| 69 | - * |
|
| 70 | - * @param WP_User $item |
|
| 71 | - * @param string $column_name The name of the column |
|
| 72 | - * |
|
| 73 | - * @return string Column Name |
|
| 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 ); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Displays the country column. |
|
| 82 | - * |
|
| 83 | - * @since 1.0.19 |
|
| 84 | - * |
|
| 85 | - * @param WP_User $user |
|
| 86 | - * |
|
| 87 | - * @return string Column Name |
|
| 88 | - */ |
|
| 89 | - public function column_country( $user ) { |
|
| 90 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 91 | - if ( $country ) { |
|
| 92 | - $country = wpinv_country_name( $country ); |
|
| 93 | - } |
|
| 94 | - return sanitize_text_field( $country ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Displays the state column. |
|
| 99 | - * |
|
| 100 | - * @since 1.0.19 |
|
| 101 | - * |
|
| 102 | - * @param WP_User $user |
|
| 103 | - * |
|
| 104 | - * @return string Column Name |
|
| 105 | - */ |
|
| 106 | - public function column_state( $user ) { |
|
| 107 | - $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 108 | - $state = $user->_wpinv_state; |
|
| 109 | - if ( $state ) { |
|
| 110 | - $state = wpinv_state_name( $state, $country ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - return sanitize_text_field( $state ); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Generates content for a single row of the table |
|
| 118 | - * @since 1.0.19 |
|
| 119 | - * |
|
| 120 | - * @param int $item The user id. |
|
| 121 | - */ |
|
| 122 | - public function single_row( $item ) { |
|
| 123 | - $item = get_user_by( 'id', $item ); |
|
| 124 | - |
|
| 125 | - if ( empty( $item ) ) { |
|
| 126 | - return; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - echo '<tr>'; |
|
| 130 | - $this->single_row_columns( $item ); |
|
| 131 | - echo '</tr>'; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * Displays the customers name |
|
| 136 | - * |
|
| 137 | - * @param WP_User $customer customer. |
|
| 138 | - * @return string |
|
| 139 | - */ |
|
| 140 | - public function column_name( $customer ) { |
|
| 141 | - |
|
| 142 | - // Customer view URL. |
|
| 143 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
| 144 | - $row_actions = $this->row_actions( |
|
| 145 | - array( |
|
| 146 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
| 147 | - ) |
|
| 148 | - ); |
|
| 149 | - |
|
| 150 | - // Get user's address. |
|
| 151 | - $address = wpinv_get_user_address( $customer->ID ); |
|
| 152 | - |
|
| 153 | - // Customer email address. |
|
| 154 | - $email = sanitize_email( $customer->user_email ); |
|
| 155 | - |
|
| 156 | - // Customer's avatar. |
|
| 157 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
| 158 | - $avatar = "<img src='$avatar' height='32' width='32'/>"; |
|
| 159 | - |
|
| 160 | - // Customer's name. |
|
| 161 | - $name = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" ); |
|
| 162 | - |
|
| 163 | - if ( ! empty( $name ) ) { |
|
| 164 | - $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - $email = "<div class='row-title'><a href='$view_url'>$email</a></div>"; |
|
| 168 | - |
|
| 169 | - return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>"; |
|
| 170 | - |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Retrieve the table columns |
|
| 175 | - * |
|
| 176 | - * @since 1.0.19 |
|
| 177 | - * @return array $columns Array of all the list table columns |
|
| 178 | - */ |
|
| 179 | - public function get_columns() { |
|
| 180 | - |
|
| 181 | - $columns = array( |
|
| 182 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 183 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 184 | - 'state' => __( 'State', 'invoicing' ), |
|
| 185 | - 'city' => __( 'City', 'invoicing' ), |
|
| 186 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 187 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 188 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 189 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 190 | - ); |
|
| 191 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
| 192 | - |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Retrieve the current page number |
|
| 197 | - * |
|
| 198 | - * @since 1.0.19 |
|
| 199 | - * @return int Current page number |
|
| 200 | - */ |
|
| 201 | - public function get_paged() { |
|
| 202 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Returns bulk actions. |
|
| 207 | - * |
|
| 208 | - * @since 1.0.19 |
|
| 209 | - * @return void |
|
| 210 | - */ |
|
| 211 | - public function bulk_actions( $which = '' ) { |
|
| 212 | - return array(); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Prepares the display query |
|
| 217 | - */ |
|
| 218 | - public function prepare_query() { |
|
| 219 | - global $wpdb; |
|
| 220 | - |
|
| 221 | - $post_types = 'WHERE '; |
|
| 222 | - |
|
| 223 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 224 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $post_types = rtrim( $post_types, ' OR' ); |
|
| 228 | - |
|
| 229 | - // Users with invoices. |
|
| 230 | - $customers = $wpdb->get_col( |
|
| 231 | - $wpdb->prepare( |
|
| 232 | - "SELECT DISTINCT( post_author ) FROM $wpdb->posts $post_types LIMIT %d,%d", |
|
| 233 | - $this->get_paged() * 10 - 10, |
|
| 234 | - $this->per_page |
|
| 235 | - ) |
|
| 236 | - ); |
|
| 237 | - |
|
| 238 | - $this->items = $customers; |
|
| 239 | - $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types" ); |
|
| 240 | - |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Setup the final data for the table |
|
| 245 | - * |
|
| 246 | - * @since 1.0.19 |
|
| 247 | - * @return void |
|
| 248 | - */ |
|
| 249 | - public function prepare_items() { |
|
| 250 | - $columns = $this->get_columns(); |
|
| 251 | - $hidden = array(); // No hidden columns |
|
| 252 | - $sortable = $this->get_sortable_columns(); |
|
| 253 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 254 | - $this->prepare_query(); |
|
| 255 | - |
|
| 256 | - $this->set_pagination_args( |
|
| 257 | - array( |
|
| 258 | - 'total_items' => $this->total, |
|
| 259 | - 'per_page' => $this->per_page, |
|
| 260 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
| 261 | - ) |
|
| 262 | - ); |
|
| 263 | - |
|
| 264 | - } |
|
| 24 | + /** |
|
| 25 | + * @var int Number of items per page |
|
| 26 | + * @since 1.0.19 |
|
| 27 | + */ |
|
| 28 | + public $per_page = 10; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var int Number of items |
|
| 32 | + * @since 1.0.19 |
|
| 33 | + */ |
|
| 34 | + public $total = 0; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Get things started |
|
| 38 | + * |
|
| 39 | + * @since 1.0.19 |
|
| 40 | + * @see WP_List_Table::__construct() |
|
| 41 | + */ |
|
| 42 | + public function __construct() { |
|
| 43 | + |
|
| 44 | + // Set parent defaults |
|
| 45 | + parent::__construct( array( |
|
| 46 | + 'singular' => 'id', |
|
| 47 | + 'plural' => 'ids', |
|
| 48 | + 'ajax' => false, |
|
| 49 | + ) ); |
|
| 50 | + |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Gets the name of the primary column. |
|
| 55 | + * |
|
| 56 | + * @since 1.0.19 |
|
| 57 | + * @access protected |
|
| 58 | + * |
|
| 59 | + * @return string Name of the primary column. |
|
| 60 | + */ |
|
| 61 | + protected function get_primary_column_name() { |
|
| 62 | + return 'name'; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * This function renders most of the columns in the list table. |
|
| 67 | + * |
|
| 68 | + * @since 1.0.19 |
|
| 69 | + * |
|
| 70 | + * @param WP_User $item |
|
| 71 | + * @param string $column_name The name of the column |
|
| 72 | + * |
|
| 73 | + * @return string Column Name |
|
| 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 ); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Displays the country column. |
|
| 82 | + * |
|
| 83 | + * @since 1.0.19 |
|
| 84 | + * |
|
| 85 | + * @param WP_User $user |
|
| 86 | + * |
|
| 87 | + * @return string Column Name |
|
| 88 | + */ |
|
| 89 | + public function column_country( $user ) { |
|
| 90 | + $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 91 | + if ( $country ) { |
|
| 92 | + $country = wpinv_country_name( $country ); |
|
| 93 | + } |
|
| 94 | + return sanitize_text_field( $country ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Displays the state column. |
|
| 99 | + * |
|
| 100 | + * @since 1.0.19 |
|
| 101 | + * |
|
| 102 | + * @param WP_User $user |
|
| 103 | + * |
|
| 104 | + * @return string Column Name |
|
| 105 | + */ |
|
| 106 | + public function column_state( $user ) { |
|
| 107 | + $country = wpinv_sanitize_country( $user->_wpinv_country ); |
|
| 108 | + $state = $user->_wpinv_state; |
|
| 109 | + if ( $state ) { |
|
| 110 | + $state = wpinv_state_name( $state, $country ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + return sanitize_text_field( $state ); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Generates content for a single row of the table |
|
| 118 | + * @since 1.0.19 |
|
| 119 | + * |
|
| 120 | + * @param int $item The user id. |
|
| 121 | + */ |
|
| 122 | + public function single_row( $item ) { |
|
| 123 | + $item = get_user_by( 'id', $item ); |
|
| 124 | + |
|
| 125 | + if ( empty( $item ) ) { |
|
| 126 | + return; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + echo '<tr>'; |
|
| 130 | + $this->single_row_columns( $item ); |
|
| 131 | + echo '</tr>'; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * Displays the customers name |
|
| 136 | + * |
|
| 137 | + * @param WP_User $customer customer. |
|
| 138 | + * @return string |
|
| 139 | + */ |
|
| 140 | + public function column_name( $customer ) { |
|
| 141 | + |
|
| 142 | + // Customer view URL. |
|
| 143 | + $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
| 144 | + $row_actions = $this->row_actions( |
|
| 145 | + array( |
|
| 146 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
| 147 | + ) |
|
| 148 | + ); |
|
| 149 | + |
|
| 150 | + // Get user's address. |
|
| 151 | + $address = wpinv_get_user_address( $customer->ID ); |
|
| 152 | + |
|
| 153 | + // Customer email address. |
|
| 154 | + $email = sanitize_email( $customer->user_email ); |
|
| 155 | + |
|
| 156 | + // Customer's avatar. |
|
| 157 | + $avatar = esc_url( get_avatar_url( $email ) ); |
|
| 158 | + $avatar = "<img src='$avatar' height='32' width='32'/>"; |
|
| 159 | + |
|
| 160 | + // Customer's name. |
|
| 161 | + $name = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" ); |
|
| 162 | + |
|
| 163 | + if ( ! empty( $name ) ) { |
|
| 164 | + $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + $email = "<div class='row-title'><a href='$view_url'>$email</a></div>"; |
|
| 168 | + |
|
| 169 | + return "<div style='display: flex;'><div>$avatar</div><div style='margin-left: 10px;'>$name<strong>$email</strong>$row_actions</div></div>"; |
|
| 170 | + |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Retrieve the table columns |
|
| 175 | + * |
|
| 176 | + * @since 1.0.19 |
|
| 177 | + * @return array $columns Array of all the list table columns |
|
| 178 | + */ |
|
| 179 | + public function get_columns() { |
|
| 180 | + |
|
| 181 | + $columns = array( |
|
| 182 | + 'name' => __( 'Name', 'invoicing' ), |
|
| 183 | + 'country' => __( 'Country', 'invoicing' ), |
|
| 184 | + 'state' => __( 'State', 'invoicing' ), |
|
| 185 | + 'city' => __( 'City', 'invoicing' ), |
|
| 186 | + 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 187 | + 'address' => __( 'Address', 'invoicing' ), |
|
| 188 | + 'phone' => __( 'Phone', 'invoicing' ), |
|
| 189 | + 'company' => __( 'Company', 'invoicing' ), |
|
| 190 | + ); |
|
| 191 | + return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
| 192 | + |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Retrieve the current page number |
|
| 197 | + * |
|
| 198 | + * @since 1.0.19 |
|
| 199 | + * @return int Current page number |
|
| 200 | + */ |
|
| 201 | + public function get_paged() { |
|
| 202 | + return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Returns bulk actions. |
|
| 207 | + * |
|
| 208 | + * @since 1.0.19 |
|
| 209 | + * @return void |
|
| 210 | + */ |
|
| 211 | + public function bulk_actions( $which = '' ) { |
|
| 212 | + return array(); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Prepares the display query |
|
| 217 | + */ |
|
| 218 | + public function prepare_query() { |
|
| 219 | + global $wpdb; |
|
| 220 | + |
|
| 221 | + $post_types = 'WHERE '; |
|
| 222 | + |
|
| 223 | + foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 224 | + $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $post_types = rtrim( $post_types, ' OR' ); |
|
| 228 | + |
|
| 229 | + // Users with invoices. |
|
| 230 | + $customers = $wpdb->get_col( |
|
| 231 | + $wpdb->prepare( |
|
| 232 | + "SELECT DISTINCT( post_author ) FROM $wpdb->posts $post_types LIMIT %d,%d", |
|
| 233 | + $this->get_paged() * 10 - 10, |
|
| 234 | + $this->per_page |
|
| 235 | + ) |
|
| 236 | + ); |
|
| 237 | + |
|
| 238 | + $this->items = $customers; |
|
| 239 | + $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types" ); |
|
| 240 | + |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Setup the final data for the table |
|
| 245 | + * |
|
| 246 | + * @since 1.0.19 |
|
| 247 | + * @return void |
|
| 248 | + */ |
|
| 249 | + public function prepare_items() { |
|
| 250 | + $columns = $this->get_columns(); |
|
| 251 | + $hidden = array(); // No hidden columns |
|
| 252 | + $sortable = $this->get_sortable_columns(); |
|
| 253 | + $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 254 | + $this->prepare_query(); |
|
| 255 | + |
|
| 256 | + $this->set_pagination_args( |
|
| 257 | + array( |
|
| 258 | + 'total_items' => $this->total, |
|
| 259 | + 'per_page' => $this->per_page, |
|
| 260 | + 'total_pages' => ceil( $this->total / $this->per_page ) |
|
| 261 | + ) |
|
| 262 | + ); |
|
| 263 | + |
|
| 264 | + } |
|
| 265 | 265 | } |
@@ -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 | /** |
@@ -119,15 +119,15 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @param int $item The user id. |
| 121 | 121 | */ |
| 122 | - public function single_row( $item ) { |
|
| 123 | - $item = get_user_by( 'id', $item ); |
|
| 122 | + public function single_row($item) { |
|
| 123 | + $item = get_user_by('id', $item); |
|
| 124 | 124 | |
| 125 | - if ( empty( $item ) ) { |
|
| 125 | + if (empty($item)) { |
|
| 126 | 126 | return; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | echo '<tr>'; |
| 130 | - $this->single_row_columns( $item ); |
|
| 130 | + $this->single_row_columns($item); |
|
| 131 | 131 | echo '</tr>'; |
| 132 | 132 | } |
| 133 | 133 | |
@@ -137,30 +137,30 @@ discard block |
||
| 137 | 137 | * @param WP_User $customer customer. |
| 138 | 138 | * @return string |
| 139 | 139 | */ |
| 140 | - public function column_name( $customer ) { |
|
| 140 | + public function column_name($customer) { |
|
| 141 | 141 | |
| 142 | 142 | // Customer view URL. |
| 143 | - $view_url = esc_url( add_query_arg( 'user_id', $customer->ID, admin_url( 'user-edit.php' ) ) ); |
|
| 143 | + $view_url = esc_url(add_query_arg('user_id', $customer->ID, admin_url('user-edit.php'))); |
|
| 144 | 144 | $row_actions = $this->row_actions( |
| 145 | 145 | array( |
| 146 | - 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __( 'Edit Details', 'invoicing' ) . '</a>', |
|
| 146 | + 'view' => '<a href="' . $view_url . '#getpaid-fieldset-billing">' . __('Edit Details', 'invoicing') . '</a>', |
|
| 147 | 147 | ) |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | 150 | // Get user's address. |
| 151 | - $address = wpinv_get_user_address( $customer->ID ); |
|
| 151 | + $address = wpinv_get_user_address($customer->ID); |
|
| 152 | 152 | |
| 153 | 153 | // Customer email address. |
| 154 | - $email = sanitize_email( $customer->user_email ); |
|
| 154 | + $email = sanitize_email($customer->user_email); |
|
| 155 | 155 | |
| 156 | 156 | // Customer's avatar. |
| 157 | - $avatar = esc_url( get_avatar_url( $email ) ); |
|
| 157 | + $avatar = esc_url(get_avatar_url($email)); |
|
| 158 | 158 | $avatar = "<img src='$avatar' height='32' width='32'/>"; |
| 159 | 159 | |
| 160 | 160 | // Customer's name. |
| 161 | - $name = sanitize_text_field( "{$address['first_name']} {$address['last_name']}" ); |
|
| 161 | + $name = sanitize_text_field("{$address['first_name']} {$address['last_name']}"); |
|
| 162 | 162 | |
| 163 | - if ( ! empty( $name ) ) { |
|
| 163 | + if (!empty($name)) { |
|
| 164 | 164 | $name = "<div style='overflow: hidden;height: 18px;'>$name</div>"; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -179,16 +179,16 @@ discard block |
||
| 179 | 179 | public function get_columns() { |
| 180 | 180 | |
| 181 | 181 | $columns = array( |
| 182 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 183 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 184 | - 'state' => __( 'State', 'invoicing' ), |
|
| 185 | - 'city' => __( 'City', 'invoicing' ), |
|
| 186 | - 'zip' => __( 'ZIP', 'invoicing' ), |
|
| 187 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 188 | - 'phone' => __( 'Phone', 'invoicing' ), |
|
| 189 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 182 | + 'name' => __('Name', 'invoicing'), |
|
| 183 | + 'country' => __('Country', 'invoicing'), |
|
| 184 | + 'state' => __('State', 'invoicing'), |
|
| 185 | + 'city' => __('City', 'invoicing'), |
|
| 186 | + 'zip' => __('ZIP', 'invoicing'), |
|
| 187 | + 'address' => __('Address', 'invoicing'), |
|
| 188 | + 'phone' => __('Phone', 'invoicing'), |
|
| 189 | + 'company' => __('Company', 'invoicing'), |
|
| 190 | 190 | ); |
| 191 | - return apply_filters( 'wpinv_customers_table_columns', $columns ); |
|
| 191 | + return apply_filters('wpinv_customers_table_columns', $columns); |
|
| 192 | 192 | |
| 193 | 193 | } |
| 194 | 194 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @return int Current page number |
| 200 | 200 | */ |
| 201 | 201 | public function get_paged() { |
| 202 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 202 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @since 1.0.19 |
| 209 | 209 | * @return void |
| 210 | 210 | */ |
| 211 | - public function bulk_actions( $which = '' ) { |
|
| 211 | + public function bulk_actions($which = '') { |
|
| 212 | 212 | return array(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $post_types = 'WHERE '; |
| 222 | 222 | |
| 223 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
| 224 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type ); |
|
| 223 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
| 224 | + $post_types .= $wpdb->prepare("post_type=%s OR ", $post_type); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $post_types = rtrim( $post_types, ' OR' ); |
|
| 227 | + $post_types = rtrim($post_types, ' OR'); |
|
| 228 | 228 | |
| 229 | 229 | // Users with invoices. |
| 230 | 230 | $customers = $wpdb->get_col( |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | ); |
| 237 | 237 | |
| 238 | 238 | $this->items = $customers; |
| 239 | - $this->total = (int) $wpdb->get_var( "SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types" ); |
|
| 239 | + $this->total = (int) $wpdb->get_var("SELECT COUNT( DISTINCT( post_author ) ) FROM $wpdb->posts $post_types"); |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | $columns = $this->get_columns(); |
| 251 | 251 | $hidden = array(); // No hidden columns |
| 252 | 252 | $sortable = $this->get_sortable_columns(); |
| 253 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 253 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 254 | 254 | $this->prepare_query(); |
| 255 | 255 | |
| 256 | 256 | $this->set_pagination_args( |
| 257 | 257 | array( |
| 258 | 258 | 'total_items' => $this->total, |
| 259 | 259 | 'per_page' => $this->per_page, |
| 260 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
| 260 | + 'total_pages' => ceil($this->total / $this->per_page) |
|
| 261 | 261 | ) |
| 262 | 262 | ); |
| 263 | 263 | |