Filter tin-canny-learndash-reporting

tincanny_contents_per_page

Filters the number of items displayed per page within the Tincanny plugin, allowing customization of pagination.

add_filter( 'tincanny_contents_per_page', $callback, 10, 1 );

Description

Filters the number of Tincanny content items displayed per page in the Tincanny admin list table. Use this hook to dynamically adjust the pagination count for Tincanny content.


Usage

add_filter( 'tincanny_contents_per_page', 'your_function_name', 10, 1 );

Parameters

$this (mixed)
This filter parameter contains the number of content items to display per page.

Return Value

The filtered value.


Examples

/**
 * Filter to customize the number of Tin Can content items displayed per page.
 *
 * This function allows administrators to change the default number of content
 * items shown in the Tin Can Content List Table.
 *
 * @param int $per_page The current number of items per page.
 * @return int The modified number of items per page.
 */
function my_tin_canny_items_per_page( $per_page ) {
    // Get the user's role. If they are an administrator, allow them to set a higher limit.
    $user = wp_get_current_user();
    if ( in_array( 'administrator', (array) $user->roles ) ) {
        // Administrators can see up to 50 items per page.
        $per_page = 50;
    } else {
        // Regular users will see the default 20 items per page.
        $per_page = 20;
    }

    return $per_page;
}
add_filter( 'tincanny_contents_per_page', 'my_tin_canny_items_per_page', 10, 1 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/includes/TinCan_Content_List_Table.php:70

public function __construct( $args = array() ) {
		$this->per_page = apply_filters( 'tincanny_contents_per_page', $this->per_page );
		parent::__construct();
		
	}

Scroll to Top