dozent_pagination( int $total_count, int $per_page, int $current_page, null $singular_text = null, null $plural_text = null, bool $echo = true )
Generate the pagination
Description
See also
Parameters
- $total_count
-
(int) (Required)
- $per_page
-
(int) (Required)
- $current_page
-
(int) (Required)
- $singular_text
-
(null) (Optional)
Default value: null
- $plural_text
-
(null) (Optional)
Default value: null
- $echo
-
(bool) (Optional)
Default value: true
Return
(mixed|void)
Source
File: includes/template-functions.php
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 | function dozent_pagination( $total_count = 0, $per_page = 0, $current_page = 0, $singular_text = null, $plural_text = null, $echo = true ) { global $wp_query ; if ( ! $total_count ) { if ( ! empty ( $wp_query ->found_posts ) ) { $total_count = $wp_query ->found_posts; } } //First get per page form the query //TODO: Should remove this commented block /* if ( ! $per_page && ! empty( $wp_query->query_vars[ 'posts_per_page' ] ) ) { $per_page = (int) $wp_query->query_vars[ 'posts_per_page' ]; } */ //If not exists per page, then get it from the default option if ( ! $per_page ) { $per_page = dozent_show_per_page(); } if ( ! $singular_text ) { $singular_text = __( 'item' , 'dozent' ); } if ( ! $plural_text ) { $plural_text = __( 'items' , 'dozent' ); } $current_page = $current_page ? $current_page : dozent_current_page(); $from_num = ( $current_page - 1 ) * $per_page + 1; $to_num = $from_num + $per_page - 1; if ( $to_num >= $total_count ) { $to_num = $total_count ; } $defaults = apply_filters( 'dozent_pagination_args' , [ 'per_page' => $per_page , 'current_page' => $current_page , 'total' => $total_count , 'singular_text' => $singular_text , 'plural_text' => $plural_text , 'from_num' => $from_num , 'to_num' => $to_num , ] ); extract( $defaults , EXTR_SKIP ); ob_start(); dozent_load_template( 'partial/pagination' , $defaults ); $output = apply_filters( 'partial/pagination' , ob_get_clean() ); if ( $echo ) { echo $output ; } return $output ; } |
Changelog
Version | Description |
---|---|
DozentLMS 1.0.0 | Introduced. |