Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: paginate_links

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
3925           $link .= $args['add_fragment'];
3926
3927           /**
3928            * Filters the paginated links for the given archive pages.
3929            *
3930            * @since 3.0.0
3931            *
3932            * @param string $link The paginated link URL.
3933            */
3934           $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
3935      endif;
3936      for ( $n = 1; $n <= $total; $n++ ) :
3937           if ( $n == $current ) :
3938                $page_links[] = "<span aria-current='" . esc_attr( $args['aria_current'] ) . "' class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . '</span>';
3939                $dots         = true;
3940           else :
3941                if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
3942                     $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
3943                     $link = str_replace( '%#%', $n, $link );
3944                     if ( $add_args ) {
3945                          $link = add_query_arg( $add_args, $link );
3946                     }
3947                     $link .= $args['add_fragment'];
3948
3949                     /** This filter is documented in wp-includes/general-template.php */
3950                     $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . '</a>';
3951                     $dots         = true;
3952                elseif ( $dots && ! $args['show_all'] ) :
3953                     $page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
3954                     $dots         = false;
3955                endif;
3956           endif;
3957      endfor;
3958      if ( $args['prev_next'] && $current && $current < $total ) :
3959           $link = str_replace( '%_%', $args['format'], $args['base'] );
3960           $link = str_replace( '%#%', $current + 1, $link );
3961           if ( $add_args ) {
3962                $link = add_query_arg( $add_args, $link );
3963           }
3964           $link .= $args['add_fragment'];
3965
3966           /** This filter is documented in wp-includes/general-template.php */
3967           $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
3968      endif;
3969      switch ( $args['type'] ) {
3970           case 'array':
3971                return $page_links;
3972
3973           case 'list':
3974                $r .= "<ul class='page-numbers'>\n\t<li>";
3975                $r .= join( "</li>\n\t<li>", $page_links );
3976                $r .= "</li>\n</ul>\n";