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
3771           $link .= $args['add_fragment'];
3772
3773           /**
3774            * Filters the paginated links for the given archive pages.
3775            *
3776            * @since 3.0.0
3777            *
3778            * @param string $link The paginated link URL.
3779            */
3780           $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
3781      endif;
3782      for ( $n = 1; $n <= $total; $n++ ) :
3783           if ( $n == $current ) :
3784                $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>";
3785                $dots = true;
3786           else :
3787                if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
3788                     $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
3789                     $link = str_replace( '%#%', $n, $link );
3790                     if ( $add_args )
3791                          $link = add_query_arg( $add_args, $link );
3792                     $link .= $args['add_fragment'];
3793
3794                     /** This filter is documented in wp-includes/general-template.php */
3795                     $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>";
3796                     $dots = true;
3797                elseif ( $dots && ! $args['show_all'] ) :
3798                     $page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
3799                     $dots = false;
3800                endif;
3801           endif;
3802      endfor;
3803      if ( $args['prev_next'] && $current && $current < $total ) :
3804           $link = str_replace( '%_%', $args['format'], $args['base'] );
3805           $link = str_replace( '%#%', $current + 1, $link );
3806           if ( $add_args )
3807                $link = add_query_arg( $add_args, $link );
3808           $link .= $args['add_fragment'];
3809
3810           /** This filter is documented in wp-includes/general-template.php */
3811           $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
3812      endif;
3813      switch ( $args['type'] ) {
3814           case 'array' :
3815                return $page_links;
3816
3817           case 'list' :
3818                $r .= "<ul class='page-numbers'>\n\t<li>";
3819                $r .= join("</li>\n\t<li>", $page_links);
3820                $r .= "</li>\n</ul>\n";