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
2694           $link .= $args['add_fragment'];
2695
2696           /**
2697            * Filter the paginated links for the given archive pages.
2698            *
2699            * @since 3.0.0
2700            *
2701            * @param string $link The paginated link URL.
2702            */
2703           $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
2704      endif;
2705      for ( $n = 1; $n <= $total; $n++ ) :
2706           if ( $n == $current ) :
2707                $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
2708                $dots = true;
2709           else :
2710                if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
2711                     $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
2712                     $link = str_replace( '%#%', $n, $link );
2713                     if ( $add_args )
2714                          $link = add_query_arg( $add_args, $link );
2715                     $link .= $args['add_fragment'];
2716
2717                     /** This filter is documented in wp-includes/general-template.php */
2718                     $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>";
2719                     $dots = true;
2720                elseif ( $dots && ! $args['show_all'] ) :
2721                     $page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
2722                     $dots = false;
2723                endif;
2724           endif;
2725      endfor;
2726      if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
2727           $link = str_replace( '%_%', $args['format'], $args['base'] );
2728           $link = str_replace( '%#%', $current + 1, $link );
2729           if ( $add_args )
2730                $link = add_query_arg( $add_args, $link );
2731           $link .= $args['add_fragment'];
2732
2733           /** This filter is documented in wp-includes/general-template.php */
2734           $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
2735      endif;
2736      switch ( $args['type'] ) {
2737           case 'array' :
2738                return $page_links;
2739
2740           case 'list' :
2741                $r .= "<ul class='page-numbers'>\n\t<li>";
2742                $r .= join("</li>\n\t<li>", $page_links);
2743                $r .= "</li>\n</ul>\n";