Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions wpsc-admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function wpsc_admin_edit_posts_orderby( $orderby_sql ) {
add_filter( 'posts_orderby', 'wpsc_admin_edit_posts_orderby' );

/**
* setting the screen option to between 1 and 999
* setting the product & variations per page screen option to between 1 and 999
*
* @since 3.8
* @access public
Expand All @@ -102,7 +102,7 @@ function wpsc_admin_edit_posts_orderby( $orderby_sql ) {
* @return $value after changes...
*/
function wpsc_set_screen_option($status, $option, $value){
if( in_array($option, array ("edit_wpsc_variation_per_page","edit_wpsc_product_per_page" )) ){
if( in_array($option, array ("edit_wpsc_variation_per_page","edit_wpsc_product_per_page", "wpsc_purchases_per_page" )) ){
if ( "edit_wpsc_variation_per_page" == $option ){
global $user_ID;
update_user_option($user_ID,'edit_wpsc-variation_per_page',$value);
Expand Down Expand Up @@ -264,6 +264,8 @@ function wpsc_admin_pages() {
add_action( 'load-post-new.php' , 'wpsc_add_help_tabs' );
add_action( 'load-edit-tags.php' , 'wpsc_add_help_tabs' );

// screen options on Sales Log
add_action( 'load-' . $purchase_logs_page , 'wpsc_add_purchase_logs_screen_option' );
}

/**
Expand Down Expand Up @@ -367,6 +369,24 @@ function wpsc_add_help_tabs() {
}
}

/**
* This function allows change in number of purchase logs shown on Sales Log (Screen Options).
*
* @since 3.8.14.2
* @access public
*
* @uses add_screen_option()
*/
function wpsc_add_purchase_logs_screen_option() {

// setup Screen Option for purchase logs per page
add_screen_option ( 'per_page', array(
'label' => __( 'Sales Orders', 'wpsc' ),
'default' => 20,
'option' => 'wpsc_purchases_per_page'
) );
}

/**
* Includes purchase logs CSS and JS
*
Expand Down
28 changes: 28 additions & 0 deletions wpsc-admin/includes/purchase-log-list-table-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class WPSC_Purchase_Log_List_Table extends WP_List_Table {

public function __construct( $args = array() ) {
$args['plural'] = 'purchase-logs';

$this->set_per_page( $this->set_purchase_logs_per_page_by_user() );

parent::__construct( $args );

if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
Expand All @@ -46,6 +49,31 @@ public function disable_views() {
$this->views = false;
}

/**
* This function changes the number of purchase logs shown on Sales Log (Screen Options) based
* on the user meta (if set).
* Based on an example from http://chrismarslender.com/2012/01/26/wordpress-screen-options-tutorial/
*
* @since 3.8.14.2
* @access private
*
* @uses get_current_user_id()
* @uses get_user_meta()
*/
private function set_purchase_logs_per_page_by_user() {

$user = get_current_user_id();

$per_page = get_user_meta( $user, 'wpsc_purchases_per_page', true );
if ( empty ( $per_page ) || $per_page < 1 ) {

$per_page = 20;
}

return $per_page;
}

// Override the default Purchase Logs Per Page
public function set_per_page( $per_page ) {
$this->per_page = (int) $per_page;
}
Expand Down