fixed the indentation in includes/admin/reports/class-wc-report-customer-list.php
This commit is contained in:
parent
94586aa5b9
commit
b68b6f2faf
|
@ -10,27 +10,27 @@ if ( ! class_exists( 'WP_List_Table' ) )
|
||||||
*/
|
*/
|
||||||
class WC_Report_Customer_List extends WP_List_Table {
|
class WC_Report_Customer_List extends WP_List_Table {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct function.
|
* __construct function.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __construct(){
|
function __construct(){
|
||||||
global $status, $page;
|
global $status, $page;
|
||||||
|
|
||||||
parent::__construct( array(
|
parent::__construct( array(
|
||||||
'singular' => __( 'Customer', 'woocommerce' ),
|
'singular' => __( 'Customer', 'woocommerce' ),
|
||||||
'plural' => __( 'Customers', 'woocommerce' ),
|
'plural' => __( 'Customers', 'woocommerce' ),
|
||||||
'ajax' => false
|
'ajax' => false
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No items found text
|
* No items found text
|
||||||
*/
|
*/
|
||||||
public function no_items() {
|
public function no_items() {
|
||||||
_e( 'No customers found.', 'woocommerce' );
|
_e( 'No customers found.', 'woocommerce' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output the report
|
* Output the report
|
||||||
|
@ -40,16 +40,16 @@ class WC_Report_Customer_List extends WP_List_Table {
|
||||||
|
|
||||||
echo '<div id="poststuff" class="woocommerce-reports-wide">';
|
echo '<div id="poststuff" class="woocommerce-reports-wide">';
|
||||||
|
|
||||||
if ( ! empty( $_GET['link_orders'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'link_orders' ) ) {
|
if ( ! empty( $_GET['link_orders'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'link_orders' ) ) {
|
||||||
$linked = wc_update_new_customer_past_orders( absint( $_GET['link_orders'] ) );
|
$linked = wc_update_new_customer_past_orders( absint( $_GET['link_orders'] ) );
|
||||||
|
|
||||||
echo '<div class="updated"><p>' . sprintf( _n( '%s previous order linked', '%s previous orders linked', $linked, 'woocommerce' ), $linked ) . '</p></div>';
|
echo '<div class="updated"><p>' . sprintf( _n( '%s previous order linked', '%s previous orders linked', $linked, 'woocommerce' ), $linked ) . '</p></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<form method="post" id="woocommerce_customers">';
|
echo '<form method="post" id="woocommerce_customers">';
|
||||||
|
|
||||||
$this->search_box( __( 'Search customers', 'woocommerce' ), 'customer_search' );
|
$this->search_box( __( 'Search customers', 'woocommerce' ), 'customer_search' );
|
||||||
$this->display();
|
$this->display();
|
||||||
|
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
@ -63,19 +63,19 @@ class WC_Report_Customer_List extends WP_List_Table {
|
||||||
* @return int|string
|
* @return int|string
|
||||||
* @todo Inconsistent return types, and void return at the end. Needs a rewrite.
|
* @todo Inconsistent return types, and void return at the end. Needs a rewrite.
|
||||||
*/
|
*/
|
||||||
function column_default( $user, $column_name ) {
|
function column_default( $user, $column_name ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
switch( $column_name ) {
|
switch( $column_name ) {
|
||||||
case 'customer_name' :
|
case 'customer_name' :
|
||||||
if ( $user->last_name && $user->first_name )
|
if ( $user->last_name && $user->first_name )
|
||||||
return $user->last_name . ', ' . $user->first_name;
|
return $user->last_name . ', ' . $user->first_name;
|
||||||
else
|
else
|
||||||
return '-';
|
return '-';
|
||||||
case 'username' :
|
case 'username' :
|
||||||
return $user->user_login;
|
return $user->user_login;
|
||||||
break;
|
break;
|
||||||
case 'location' :
|
case 'location' :
|
||||||
|
|
||||||
$state_code = get_user_meta( $user->ID, 'billing_state', true );
|
$state_code = get_user_meta( $user->ID, 'billing_state', true );
|
||||||
$country_code = get_user_meta( $user->ID, 'billing_country', true );
|
$country_code = get_user_meta( $user->ID, 'billing_country', true );
|
||||||
|
@ -93,10 +93,10 @@ class WC_Report_Customer_List extends WP_List_Table {
|
||||||
if ( $value )
|
if ( $value )
|
||||||
return $value;
|
return $value;
|
||||||
else
|
else
|
||||||
return '-';
|
return '-';
|
||||||
break;
|
break;
|
||||||
case 'email' :
|
case 'email' :
|
||||||
return '<a href="mailto:' . $user->user_email . '">' . $user->user_email . '</a>';
|
return '<a href="mailto:' . $user->user_email . '">' . $user->user_email . '</a>';
|
||||||
case 'spent' :
|
case 'spent' :
|
||||||
if ( ! $spent = get_user_meta( $user->ID, '_money_spent', true ) ) {
|
if ( ! $spent = get_user_meta( $user->ID, '_money_spent', true ) ) {
|
||||||
|
|
||||||
|
@ -224,16 +224,16 @@ class WC_Report_Customer_List extends WP_List_Table {
|
||||||
?>
|
?>
|
||||||
</p><?php
|
</p><?php
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_columns function.
|
* get_columns function.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function get_columns(){
|
function get_columns(){
|
||||||
$columns = array(
|
$columns = array(
|
||||||
'customer_name' => __( 'Name (Last, First)', 'woocommerce' ),
|
'customer_name' => __( 'Name (Last, First)', 'woocommerce' ),
|
||||||
'username' => __( 'Username', 'woocommerce' ),
|
'username' => __( 'Username', 'woocommerce' ),
|
||||||
'email' => __( 'Email', 'woocommerce' ),
|
'email' => __( 'Email', 'woocommerce' ),
|
||||||
|
@ -242,54 +242,54 @@ class WC_Report_Customer_List extends WP_List_Table {
|
||||||
'spent' => __( 'Spent', 'woocommerce' ),
|
'spent' => __( 'Spent', 'woocommerce' ),
|
||||||
'last_order' => __( 'Last order', 'woocommerce' ),
|
'last_order' => __( 'Last order', 'woocommerce' ),
|
||||||
'user_actions' => __( 'Actions', 'woocommerce' )
|
'user_actions' => __( 'Actions', 'woocommerce' )
|
||||||
);
|
);
|
||||||
|
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Order users by name
|
|
||||||
*/
|
|
||||||
public function order_by_last_name( $query ) {
|
|
||||||
global $wpdb;
|
|
||||||
|
|
||||||
$s = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
|
|
||||||
|
|
||||||
$query->query_from .= " LEFT JOIN {$wpdb->usermeta} as meta2 ON ({$wpdb->users}.ID = meta2.user_id) ";
|
|
||||||
$query->query_where .= " AND meta2.meta_key = 'last_name' ";
|
|
||||||
$query->query_orderby = " ORDER BY meta2.meta_value, user_login ASC ";
|
|
||||||
|
|
||||||
if ( $s ) {
|
|
||||||
$query->query_from .= " LEFT JOIN {$wpdb->usermeta} as meta3 ON ({$wpdb->users}.ID = meta3.user_id)";
|
|
||||||
$query->query_where .= " AND ( user_login LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' OR user_nicename LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' OR meta3.meta_value LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' ) ";
|
|
||||||
$query->query_orderby = " GROUP BY ID " . $query->query_orderby;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prepare_items function.
|
* Order users by name
|
||||||
*
|
*/
|
||||||
* @access public
|
public function order_by_last_name( $query ) {
|
||||||
*/
|
global $wpdb;
|
||||||
public function prepare_items() {
|
|
||||||
global $wpdb;
|
$s = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
|
||||||
|
|
||||||
|
$query->query_from .= " LEFT JOIN {$wpdb->usermeta} as meta2 ON ({$wpdb->users}.ID = meta2.user_id) ";
|
||||||
|
$query->query_where .= " AND meta2.meta_key = 'last_name' ";
|
||||||
|
$query->query_orderby = " ORDER BY meta2.meta_value, user_login ASC ";
|
||||||
|
|
||||||
|
if ( $s ) {
|
||||||
|
$query->query_from .= " LEFT JOIN {$wpdb->usermeta} as meta3 ON ({$wpdb->users}.ID = meta3.user_id)";
|
||||||
|
$query->query_where .= " AND ( user_login LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' OR user_nicename LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' OR meta3.meta_value LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' ) ";
|
||||||
|
$query->query_orderby = " GROUP BY ID " . $query->query_orderby;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prepare_items function.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function prepare_items() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
$current_page = absint( $this->get_pagenum() );
|
$current_page = absint( $this->get_pagenum() );
|
||||||
$per_page = 20;
|
$per_page = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init column headers
|
* Init column headers
|
||||||
*/
|
*/
|
||||||
$this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
|
$this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() );
|
||||||
|
|
||||||
add_action( 'pre_user_query', array( $this, 'order_by_last_name' ) );
|
add_action( 'pre_user_query', array( $this, 'order_by_last_name' ) );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get users
|
* Get users
|
||||||
*/
|
*/
|
||||||
$admin_users = new WP_User_Query(
|
$admin_users = new WP_User_Query(
|
||||||
array(
|
array(
|
||||||
'role' => 'administrator',
|
'role' => 'administrator',
|
||||||
'fields' => 'ID'
|
'fields' => 'ID'
|
||||||
|
@ -313,13 +313,13 @@ class WC_Report_Customer_List extends WP_List_Table {
|
||||||
|
|
||||||
remove_action( 'pre_user_query', array( $this, 'order_by_last_name' ) );
|
remove_action( 'pre_user_query', array( $this, 'order_by_last_name' ) );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pagination
|
* Pagination
|
||||||
*/
|
*/
|
||||||
$this->set_pagination_args( array(
|
$this->set_pagination_args( array(
|
||||||
'total_items' => $query->total_users,
|
'total_items' => $query->total_users,
|
||||||
'per_page' => $per_page,
|
'per_page' => $per_page,
|
||||||
'total_pages' => ceil( $query->total_users / $per_page )
|
'total_pages' => ceil( $query->total_users / $per_page )
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue