llms_modify_dashboard_pagination_links( string $link )

Modify the pagination links displayed on endpoints using the default LLMS loop


Parameters Parameters

$link

(string) (Required) Default link.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/functions/llms.functions.templates.dashboard.php

function llms_modify_dashboard_pagination_links( $link ) {

	/**
	 * Allow 3rd parties to disable dashboard pagination link rewriting
	 *
	 * Resolves compatibility issues with LifterLMS WooCommerce.
	 *
	 * @since unknown
	 *
	 * @param bool   $disable Whether or not the dashboard pagination links should be disabled. Default `false`.
	 * @param string $link    The default link.
	 */
	if ( apply_filters( 'llms_modify_dashboard_pagination_links_disable', false, $link ) ) {
		return $link;
	}

	global $wp_rewrite;

	$query = wp_parse_url( $link, PHP_URL_QUERY );

	if ( $query ) {
		$link = str_replace( '?' . $query, '', $link );
	}
	// No plain permalinks.
	if ( get_option( 'permalink_structure' ) ) {
		$parts = explode( '/', untrailingslashit( $link ) );
		$page  = end( $parts );
		$link  = llms_get_endpoint_url( LLMS_Student_Dashboard::get_current_tab( 'slug' ), $wp_rewrite->pagination_base . '/' . $page . '/', llms_get_page_url( 'myaccount' ) );
	} else { // With plain permalinks.
		preg_match( '/paged?=([0-9]+)/', $link, $pages ); // Extract the 'page(d)' var.
		$paged  = empty( $pages ) || count( $pages ) < 2 || $pages[1] < 2 ? '' : $pages[0]; // No pagination or page 1 nothing to add.
		$query .= $paged ? '&' . $paged : '';
		$link   = home_url();
	}

	if ( $query ) {
		$link .= '?' . $query;
	}

	return $link;

}


Top ↑

Changelog Changelog

Changelog
Version Description
6.3.0 Fixed pagination when using plain permalinks.
3.26.3 Unknown.
3.24.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.