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
1952      $n = 0;
1953      $dots = false;
1954
1955      if ( $prev_next && $current && 1 < $current ) :
1956           $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
1957           $link = str_replace('%#%', $current - 1, $link);
1958           if ( $add_args )
1959                $link = add_query_arg( $add_args, $link );
1960           $link .= $add_fragment;
1961           $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $prev_text . '</a>';
1962      endif;
1963      for ( $n = 1; $n <= $total; $n++ ) :
1964           $n_display = number_format_i18n($n);
1965           if ( $n == $current ) :
1966                $page_links[] = "<span class='page-numbers current'>$n_display</span>";
1967                $dots = true;
1968           else :
1969                if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
1970                     $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
1971                     $link = str_replace('%#%', $n, $link);
1972                     if ( $add_args )
1973                          $link = add_query_arg( $add_args, $link );
1974                     $link .= $add_fragment;
1975                     $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
1976                     $dots = true;
1977                elseif ( $dots && !$show_all ) :
1978                     $page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
1979                     $dots = false;
1980                endif;
1981           endif;
1982      endfor;
1983      if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
1984           $link = str_replace('%_%', $format, $base);
1985           $link = str_replace('%#%', $current + 1, $link);
1986           if ( $add_args )
1987                $link = add_query_arg( $add_args, $link );
1988           $link .= $add_fragment;
1989           $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>';
1990      endif;
1991      switch ( $type ) :
1992           case 'array' :
1993                return $page_links;
1994                break;
1995           case 'list' :
1996                $r .= "<ul class='page-numbers'>\n\t<li>";
1997                $r .= join("</li>\n\t<li>", $page_links);
1998                $r .= "</li>\n</ul>\n";