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