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
2651           $link .= $args['add_fragment'];
2652
2653           /**
2654            * Filter the paginated links for the given archive pages.
2655            *
2656            * @since 3.0.0
2657            *
2658            * @param string $link The paginated link URL.
2659            */
2660           $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
2661      endif;
2662      for ( $n = 1; $n <= $total; $n++ ) :
2663           if ( $n == $current ) :
2664                $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
2665                $dots = true;
2666           else :
2667                if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
2668                     $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
2669                     $link = str_replace( '%#%', $n, $link );
2670                     if ( $add_args )
2671                          $link = add_query_arg( $add_args, $link );
2672                     $link .= $args['add_fragment'];
2673
2674                     /** This filter is documented in wp-includes/general-template.php */
2675                     $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>";
2676                     $dots = true;
2677                elseif ( $dots && ! $args['show_all'] ) :
2678                     $page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
2679                     $dots = false;
2680                endif;
2681           endif;
2682      endfor;
2683      if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
2684           $link = str_replace( '%_%', $args['format'], $args['base'] );
2685           $link = str_replace( '%#%', $current + 1, $link );
2686           if ( $add_args )
2687                $link = add_query_arg( $add_args, $link );
2688           $link .= $args['add_fragment'];
2689
2690           /** This filter is documented in wp-includes/general-template.php */
2691           $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
2692      endif;
2693      switch ( $args['type'] ) {
2694           case 'array' :
2695                return $page_links;
2696
2697           case 'list' :
2698                $r .= "<ul class='page-numbers'>\n\t<li>";
2699                $r .= join("</li>\n\t<li>", $page_links);
2700                $r .= "</li>\n</ul>\n";