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
1972      $n = 0;
1973      $dots = false;
1974
1975      if ( $prev_next && $current && 1 < $current ) :
1976           $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
1977           $link = str_replace('%#%', $current - 1, $link);
1978           if ( $add_args )
1979                $link = add_query_arg( $add_args, $link );
1980           $link .= $add_fragment;
1981           $page_links[] = "<a class='prev page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$prev_text</a>";
1982      endif;
1983      for ( $n = 1; $n <= $total; $n++ ) :
1984           $n_display = number_format_i18n($n);
1985           if ( $n == $current ) :
1986                $page_links[] = "<span class='page-numbers current'>$n_display</span>";
1987                $dots = true;
1988           else :
1989                if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
1990                     $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
1991                     $link = str_replace('%#%', $n, $link);
1992                     if ( $add_args )
1993                          $link = add_query_arg( $add_args, $link );
1994                     $link .= $add_fragment;
1995                     $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
1996                     $dots = true;
1997                elseif ( $dots && !$show_all ) :
1998                     $page_links[] = "<span class='page-numbers dots'>...</span>";
1999                     $dots = false;
2000                endif;
2001           endif;
2002      endfor;
2003      if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
2004           $link = str_replace('%_%', $format, $base);
2005           $link = str_replace('%#%', $current + 1, $link);
2006           if ( $add_args )
2007                $link = add_query_arg( $add_args, $link );
2008           $link .= $add_fragment;
2009           $page_links[] = "<a class='next page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$next_text</a>";
2010      endif;
2011      switch ( $type ) :
2012           case 'array' :
2013                return $page_links;
2014                break;
2015           case 'list' :
2016                $r .= "<ul class='page-numbers'>\n\t<li>";
2017                $r .= join("</li>\n\t<li>", $page_links);
2018                $r .= "</li>\n</ul>\n";