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.
Return Return
(string)
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
* @since 7.2.0 Defaults to `false` only on the LifterLMS dashboard context, while `true` elsewhere.
*
* @param bool $disable Whether or not the dashboard pagination links should be disabled.
* Default `false` in the LifterLMS dashboard context, `true` elsewhere.
* @param string $link The default link.
*/
if ( apply_filters( 'llms_modify_dashboard_pagination_links_disable', ! is_page( llms_get_page_id( 'myaccount' ) ), $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;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.2.0 | Made sure the pagination links is not altered when not in the LifterLMS dashboard context. |
| 6.3.0 | Fixed pagination when using plain permalinks. |
| 3.26.3 | Unknown. |
| 3.24.0 | Introduced. |