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