` tag. * Also appended to the current item, which is not linked. Default empty. * @type string $aria_current Встановлення для aria-current attribute. Можливі значення є ‘page’, * ‘step’, ‘location’, ‘date’, ‘time’, ‘true’, ‘false’. Default is ‘page’. * @type string $next_or_number Indicates whether page numbers should be used. Valid values are number * and next. Default is ‘number’. * @type string $separator Text між pagination links. Default is ”. * @type string $nextpagelink Link text для next page link, if available. Default is ‘Next Page’. * @type string $previouspagelink Link text для попередньої page link, if available. Default is ‘Previous Page’. * @type string $pagelink Format string for page numbers. % в параметрі string буде * replaced with page number, so ‘Page %’ generates "Page 1", "Page 2", etc. * Defaults to ‘%’, just the page number. * @type int|bool $echo Whether to echo or not. Accepts 1|true or 0|false. Default 1|true. * } * @return string Formatted output in HTML. */” data-tooltip_type=”pre”>Код wp_link_pages() wp link pages WP 6.0.2function wp_link_pages( $args = '' ) {
Global $page, $numpages, $multipage, $more;
$defaults = array(
'before' => '<p class="post-nav-links">' . __( 'Pages:' ),
'after' => '</p>',
'link_before' => '',
'link_after' => '',
'aria_current' => 'page',
'next_or_number' => 'number',
'separator' => '',
'nextpagelink' => __( 'Next page' ),
'previouspagelink' => __( 'Previous page' ),
'pagelink' => '%',
'echo' => 1,
);
$parsed_args = wp_parse_args($args, $defaults);
/**
* Filters the arguments використовується в retrieving page links для paginated posts.
*
* @ Since 3.0.0
*
* @param array $parsed_args На array of page link arguments. See wp_link_pages()
* for information on accepted arguments.
*/
$parsed_args = apply_filters( 'wp_link_pages_args', $parsed_args );
$output = '';
if ( $multipage ) {
if ( 'number' === $parsed_args['next_or_number'] ) {
$output .= $parsed_args['before'];
for ( $i = 1; $i <= $numpages; $i++ ) {
$link = $parsed_args['link_before'] . str_replace( '%', $i, $parsed_args['pagelink'] ) . $parsed_args['link_after'];
if ( $i != $page || ! $more && 1 == $page ) {
$link = _wp_link_page($i). $link. '</a>';
} elseif ( $i === $page ) {
$link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $parsed_args['aria_current'] ) . '">' . $link. '</span>';
}
/**
* Filters HTML output of individual page number links.
*
* @ Since 3.6.0
*
* @param string $link page number HTML output.
* @param int $i Page number for paginated posts' page links.
*/
$link = apply_filters( 'wp_link_pages_link', $link, $i);
// Використовуйте окремі лінки separator beginning with the second link.
$output .= (1 === $i)? ' ' : $parsed_args['separator'];
$output .= $link;
}
$output .= $parsed_args['after'];
} elseif ($ more) {
$output .= $parsed_args['before'];
$prev = $page - 1;
if ( $prev > 0 ) {
$link = _wp_link_page($prev). $parsed_args['link_before'] . $parsed_args['previouspagelink'] . $parsed_args['link_after'] . '</a>';
/** Цей filter is documented в wp-includes/post-template.php */
$output .= apply_filters( 'wp_link_pages_link', $link, $prev );
}
$next = $page + 1;
if ( $next <= $numpages ) {
if ( $prev ) {
$output .= $parsed_args['separator'];
}
$link = _wp_link_page($next). $parsed_args['link_before'] . $parsed_args['nextpagelink'] . $parsed_args['link_after'] . '</a>';
/** Цей filter is documented в wp-includes/post-template.php */
$output .= apply_filters( 'wp_link_pages_link', $link, $next );
}
$output .= $parsed_args['after'];
}
}
/**
* Filters HTML output page links для paginated posts.
*
* @ Since 3.6.0
*
* @param string $output HTML output of paginated posts' page links.
* @param array|string $args На array or query string of arguments. See wp_link_pages()
* for information on accepted arguments.
*/
$html = apply_filters( 'wp_link_pages', $output, $args);
if ( $parsed_args['echo'] ) {
echo $html;
}
return $html;
}
Зв’язані функції