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
3110           $link .= $args['add_fragment'];
3111
3112           /**
3113            * Filter the paginated links for the given archive pages.
3114            *
3115            * @since 3.0.0
3116            *
3117            * @param string $link The paginated link URL.
3118            */
3119           $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
3120      endif;
3121      for ( $n = 1; $n <= $total; $n++ ) :
3122           if ( $n == $current ) :
3123                $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
3124                $dots = true;
3125           else :
3126                if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
3127                     $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
3128                     $link = str_replace( '%#%', $n, $link );
3129                     if ( $add_args )
3130                          $link = add_query_arg( $add_args, $link );
3131                     $link .= $args['add_fragment'];
3132
3133                     /** This filter is documented in wp-includes/general-template.php */
3134                     $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>";
3135                     $dots = true;
3136                elseif ( $dots && ! $args['show_all'] ) :
3137                     $page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
3138                     $dots = false;
3139                endif;
3140           endif;
3141      endfor;
3142      if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
3143           $link = str_replace( '%_%', $args['format'], $args['base'] );
3144           $link = str_replace( '%#%', $current + 1, $link );
3145           if ( $add_args )
3146                $link = add_query_arg( $add_args, $link );
3147           $link .= $args['add_fragment'];
3148
3149           /** This filter is documented in wp-includes/general-template.php */
3150           $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
3151      endif;
3152      switch ( $args['type'] ) {
3153           case 'array' :
3154                return $page_links;
3155
3156           case 'list' :
3157                $r .= "<ul class='page-numbers'>\n\t<li>";
3158                $r .= join("</li>\n\t<li>", $page_links);
3159                $r .= "</li>\n</ul>\n";