wp_link_pages

The timeline below displays how wordpress function wp_link_pages has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.9

//
// Page Template Functions for usage in Themes.
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. including the `<!--nextpage-->`
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 * @since 5.1.0 Added the `aria_current` argument.
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are '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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function 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 used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $parsed_args An 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 the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links 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>';
                /** This filter is documented in 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>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $parsed_args['after'];
        }
    }
    /**
     * Filters the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string       $output HTML output of paginated posts' page links.
     * @param array|string $args   An 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;
}

WordPress Version: 5.7

//
// Page Template Functions for usage in Themes.
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. including the `<!--nextpage-->`
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 * @since 5.1.0 Added the `aria_current` argument.
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are '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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function 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 used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $parsed_args An 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 the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links 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>';
                /** This filter is documented in 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>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $parsed_args['after'];
        }
    }
    /**
     * Filters the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array 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;
}

WordPress Version: 5.5

//
// Page Template Functions for usage in Themes.
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. including the `<!--nextpage-->`
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 * @since 5.1.0 Added the `aria_current` argument.
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are '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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function 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 used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $parsed_args An array of arguments for page links for paginated posts.
     */
    $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 the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links 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>';
                /** This filter is documented in 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>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $parsed_args['after'];
        }
    }
    /**
     * Filters the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($parsed_args['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 5.4

//
// Page Template Functions for usage in Themes.
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. including the `<!--nextpage-->`
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 * @since 5.1.0 Added the `aria_current` argument.
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are '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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function 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 used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $parsed_args An array of arguments for page links for paginated posts.
     */
    $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 the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links 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>';
                /** This filter is documented in 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>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $parsed_args['after'];
        }
    }
    /**
     * Filters the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($parsed_args['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 5.3

//
// Page Template Functions for usage in Themes
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. including the `<!--nextpage-->`
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 * @since 5.1.0 Added the `aria_current` argument.
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are '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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function 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 used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $parsed_args An array of arguments for page links for paginated posts.
     */
    $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 the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links 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>';
                /** This filter is documented in 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>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $parsed_args['after'];
        }
    }
    /**
     * Filters the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($parsed_args['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 5.1

//
// Page Template Functions for usage in Themes
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. including the `<!--nextpage-->`
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 * @since 5.1.0 Added the `aria_current` argument.
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are '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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function 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);
    $params = wp_parse_args($args, $defaults);
    /**
     * Filters the arguments used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $params An array of arguments for page links for paginated posts.
     */
    $r = apply_filters('wp_link_pages_args', $params);
    $output = '';
    if ($multipage) {
        if ('number' == $r['next_or_number']) {
            $output .= $r['before'];
            for ($i = 1; $i <= $numpages; $i++) {
                $link = $r['link_before'] . str_replace('%', $i, $r['pagelink']) . $r['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($r['aria_current']) . '">' . $link . '</span>';
                }
                /**
                 * Filters the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links separator beginning with the second link.
                $output .= (1 === $i) ? ' ' : $r['separator'];
                $output .= $link;
            }
            $output .= $r['after'];
        } elseif ($more) {
            $output .= $r['before'];
            $prev = $page - 1;
            if ($prev > 0) {
                $link = _wp_link_page($prev) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $prev);
            }
            $next = $page + 1;
            if ($next <= $numpages) {
                if ($prev) {
                    $output .= $r['separator'];
                }
                $link = _wp_link_page($next) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $r['after'];
        }
    }
    /**
     * Filters the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.6

//
// Page Template Functions for usage in Themes
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function wp_link_pages($args = '')
{
    global $page, $numpages, $multipage, $more;
    $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1);
    $params = wp_parse_args($args, $defaults);
    /**
     * Filters the arguments used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $params An array of arguments for page links for paginated posts.
     */
    $r = apply_filters('wp_link_pages_args', $params);
    $output = '';
    if ($multipage) {
        if ('number' == $r['next_or_number']) {
            $output .= $r['before'];
            for ($i = 1; $i <= $numpages; $i++) {
                $link = $r['link_before'] . str_replace('%', $i, $r['pagelink']) . $r['link_after'];
                if ($i != $page || !$more && 1 == $page) {
                    $link = _wp_link_page($i) . $link . '</a>';
                }
                /**
                 * Filters the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links separator beginning with the second link.
                $output .= (1 === $i) ? ' ' : $r['separator'];
                $output .= $link;
            }
            $output .= $r['after'];
        } elseif ($more) {
            $output .= $r['before'];
            $prev = $page - 1;
            if ($prev > 0) {
                $link = _wp_link_page($prev) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $prev);
            }
            $next = $page + 1;
            if ($next <= $numpages) {
                if ($prev) {
                    $output .= $r['separator'];
                }
                $link = _wp_link_page($next) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $r['after'];
        }
    }
    /**
     * Filters the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.4

//
// Page Template Functions for usage in Themes
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function wp_link_pages($args = '')
{
    global $page, $numpages, $multipage, $more;
    $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1);
    $params = wp_parse_args($args, $defaults);
    /**
     * Filter the arguments used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $params An array of arguments for page links for paginated posts.
     */
    $r = apply_filters('wp_link_pages_args', $params);
    $output = '';
    if ($multipage) {
        if ('number' == $r['next_or_number']) {
            $output .= $r['before'];
            for ($i = 1; $i <= $numpages; $i++) {
                $link = $r['link_before'] . str_replace('%', $i, $r['pagelink']) . $r['link_after'];
                if ($i != $page || !$more && 1 == $page) {
                    $link = _wp_link_page($i) . $link . '</a>';
                }
                /**
                 * Filter the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links separator beginning with the second link.
                $output .= (1 === $i) ? ' ' : $r['separator'];
                $output .= $link;
            }
            $output .= $r['after'];
        } elseif ($more) {
            $output .= $r['before'];
            $prev = $page - 1;
            if ($prev > 0) {
                $link = _wp_link_page($prev) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $prev);
            }
            $next = $page + 1;
            if ($next <= $numpages) {
                if ($prev) {
                    $output .= $r['separator'];
                }
                $link = _wp_link_page($next) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $r['after'];
        }
    }
    /**
     * Filter the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.3

//
// Page Template Functions for usage in Themes
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 *
 * @global int $page
 * @global int $numpages
 * @global int $multipage
 * @global int $more
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function wp_link_pages($args = '')
{
    global $page, $numpages, $multipage, $more;
    $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1);
    $params = wp_parse_args($args, $defaults);
    /**
     * Filter the arguments used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $params An array of arguments for page links for paginated posts.
     */
    $r = apply_filters('wp_link_pages_args', $params);
    $output = '';
    if ($multipage) {
        if ('number' == $r['next_or_number']) {
            $output .= $r['before'];
            for ($i = 1; $i <= $numpages; $i++) {
                $link = $r['link_before'] . str_replace('%', $i, $r['pagelink']) . $r['link_after'];
                if ($i != $page || !$more && 1 == $page) {
                    $link = _wp_link_page($i) . $link . '</a>';
                }
                /**
                 * Filter the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links separator beginning with the second link.
                $output .= (1 === $i) ? ' ' : $r['separator'];
                $output .= $link;
            }
            $output .= $r['after'];
        } elseif ($more) {
            $output .= $r['before'];
            $prev = $page - 1;
            if ($prev) {
                $link = _wp_link_page($prev) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $prev);
            }
            $next = $page + 1;
            if ($next <= $numpages) {
                if ($prev) {
                    $output .= $r['separator'];
                }
                $link = _wp_link_page($next) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $r['after'];
        }
    }
    /**
     * Filter the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.1

//
// Page Template Functions for usage in Themes
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function wp_link_pages($args = '')
{
    $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1);
    $params = wp_parse_args($args, $defaults);
    /**
     * Filter the arguments used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $params An array of arguments for page links for paginated posts.
     */
    $r = apply_filters('wp_link_pages_args', $params);
    global $page, $numpages, $multipage, $more;
    $output = '';
    if ($multipage) {
        if ('number' == $r['next_or_number']) {
            $output .= $r['before'];
            for ($i = 1; $i <= $numpages; $i++) {
                $link = $r['link_before'] . str_replace('%', $i, $r['pagelink']) . $r['link_after'];
                if ($i != $page || !$more && 1 == $page) {
                    $link = _wp_link_page($i) . $link . '</a>';
                }
                /**
                 * Filter the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                // Use the custom links separator beginning with the second link.
                $output .= (1 === $i) ? ' ' : $r['separator'];
                $output .= $link;
            }
            $output .= $r['after'];
        } elseif ($more) {
            $output .= $r['before'];
            $prev = $page - 1;
            if ($prev) {
                $link = _wp_link_page($prev) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $prev);
            }
            $next = $page + 1;
            if ($next <= $numpages) {
                if ($prev) {
                    $output .= $r['separator'];
                }
                $link = _wp_link_page($next) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $output .= apply_filters('wp_link_pages_link', $link, $next);
            }
            $output .= $r['after'];
        }
    }
    /**
     * Filter the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 4.0

//
// Page Template Functions for usage in Themes
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * @since 1.2.0
 *
 * @param string|array $args {
 *     Optional. Array or string of default arguments.
 *
 *     @type string       $before           HTML or text to prepend to each link. Default is '<p> Pages:'.
 *     @type string       $after            HTML or text to append to each link. Default is '</p>'.
 *     @type string       $link_before      HTML or text to prepend to each link, inside the <a> tag.
 *                                          Also prepended to the current item, which is not linked. Default empty.
 *     @type string       $link_after       HTML or text to append to each Pages link inside the <a> tag.
 *                                          Also appended to the current item, which is not linked. Default empty.
 *     @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 between pagination links. Default is ' '.
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
 *                                          replaced with the 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.
 */
function wp_link_pages($args = '')
{
    $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1);
    $params = wp_parse_args($args, $defaults);
    /**
     * Filter the arguments used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $params An array of arguments for page links for paginated posts.
     */
    $r = apply_filters('wp_link_pages_args', $params);
    global $page, $numpages, $multipage, $more;
    $output = '';
    if ($multipage) {
        if ('number' == $r['next_or_number']) {
            $output .= $r['before'];
            for ($i = 1; $i <= $numpages; $i++) {
                $link = $r['link_before'] . str_replace('%', $i, $r['pagelink']) . $r['link_after'];
                if ($i != $page || !$more && 1 == $page) {
                    $link = _wp_link_page($i) . $link . '</a>';
                }
                /**
                 * Filter the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                $output .= $r['separator'] . $link;
            }
            $output .= $r['after'];
        } elseif ($more) {
            $output .= $r['before'];
            $prev = $page - 1;
            if ($prev) {
                $link = _wp_link_page($prev) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $link = apply_filters('wp_link_pages_link', $link, $prev);
                $output .= $r['separator'] . $link;
            }
            $next = $page + 1;
            if ($next <= $numpages) {
                $link = _wp_link_page($next) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $link = apply_filters('wp_link_pages_link', $link, $next);
                $output .= $r['separator'] . $link;
            }
            $output .= $r['after'];
        }
    }
    /**
     * Filter the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $html = apply_filters('wp_link_pages', $output, $args);
    if ($r['echo']) {
        echo $html;
    }
    return $html;
}

WordPress Version: 3.9

//
// Page Template Functions for usage in Themes
//
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * The defaults for overwriting are:
 * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to
 *      each bookmarks.
 * 'after' - Default is '</p>' (string). The html or text to append to each
 *      bookmarks.
 * 'link_before' - Default is '' (string). The html or text to prepend to each
 *      Pages link inside the <a> tag. Also prepended to the current item, which
 *      is not linked.
 * 'link_after' - Default is '' (string). The html or text to append to each
 *      Pages link inside the <a> tag. Also appended to the current item, which
 *      is not linked.
 * 'next_or_number' - Default is 'number' (string). Indicates whether page
 *      numbers should be used. Valid values are number and next.
 * 'separator' - Default is ' ' (string). Text used between pagination links.
 * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.
 *      of the bookmark.
 * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to
 *      previous page, if available.
 * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in
 *      the parameter string will be replaced with the page number, so Page %
 *      generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
 * 'echo' - Default is 1 (integer). When not 0, this triggers the HTML to be
 *      echoed and then returned.
 *
 * @since 1.2.0
 *
 * @param string|array $args Optional. Overwrite the defaults.
 * @return string Formatted output in HTML.
 */
function wp_link_pages($args = '')
{
    $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1);
    $r = wp_parse_args($args, $defaults);
    /**
     * Filter the arguments used in retrieving page links for paginated posts.
     *
     * @since 3.0.0
     *
     * @param array $r An array of arguments for page links for paginated posts.
     */
    $r = apply_filters('wp_link_pages_args', $r);
    extract($r, EXTR_SKIP);
    global $page, $numpages, $multipage, $more;
    $output = '';
    if ($multipage) {
        if ('number' == $next_or_number) {
            $output .= $before;
            for ($i = 1; $i <= $numpages; $i++) {
                $link = $link_before . str_replace('%', $i, $pagelink) . $link_after;
                if ($i != $page || !$more && 1 == $page) {
                    $link = _wp_link_page($i) . $link . '</a>';
                }
                /**
                 * Filter the HTML output of individual page number links.
                 *
                 * @since 3.6.0
                 *
                 * @param string $link The page number HTML output.
                 * @param int    $i    Page number for paginated posts' page links.
                 */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                $output .= $separator . $link;
            }
            $output .= $after;
        } elseif ($more) {
            $output .= $before;
            $i = $page - 1;
            if ($i) {
                $link = _wp_link_page($i) . $link_before . $previouspagelink . $link_after . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                $output .= $separator . $link;
            }
            $i = $page + 1;
            if ($i <= $numpages) {
                $link = _wp_link_page($i) . $link_before . $nextpagelink . $link_after . '</a>';
                /** This filter is documented in wp-includes/post-template.php */
                $link = apply_filters('wp_link_pages_link', $link, $i);
                $output .= $separator . $link;
            }
            $output .= $after;
        }
    }
    /**
     * Filter the HTML output of page links for paginated posts.
     *
     * @since 3.6.0
     *
     * @param string $output HTML output of paginated posts' page links.
     * @param array  $args   An array of arguments.
     */
    $output = apply_filters('wp_link_pages', $output, $args);
    if ($echo) {
        echo $output;
    }
    return $output;
}

WordPress Version: 3.7

/**
 * Page Template Functions for usage in Themes
 *
 * @package WordPress
 * @subpackage Template
 */
/**
 * The formatted output of a list of pages.
 *
 * Displays page links for paginated posts (i.e. includes the <!--nextpage-->.
 * Quicktag one or more times). This tag must be within The Loop.
 *
 * The defaults for overwriting are:
 * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to
 *      each bookmarks.
 * 'after' - Default is '</p>' (string). The html or text to append to each
 *      bookmarks.
 * 'link_before' - Default is '' (string). The html or text to prepend to each
 *      Pages link inside the <a> tag. Also prepended to the current item, which
 *      is not linked.
 * 'link_after' - Default is '' (string). The html or text to append to each
 *      Pages link inside the <a> tag. Also appended to the current item, which
 *      is not linked.
 * 'next_or_number' - Default is 'number' (string). Indicates whether page
 *      numbers should be used. Valid values are number and next.
 * 'separator' - Default is ' ' (string). Text used between pagination links.
 * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.
 *      of the bookmark.
 * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to
 *      previous page, if available.
 * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in
 *      the parameter string will be replaced with the page number, so Page %
 *      generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
 * 'echo' - Default is 1 (integer). When not 0, this triggers the HTML to be
 *      echoed and then returned.
 *
 * @since 1.2.0
 *
 * @param string|array $args Optional. Overwrite the defaults.
 * @return string Formatted output in HTML.
 */
function wp_link_pages($args = '')
{
    $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1);
    $r = wp_parse_args($args, $defaults);
    $r = apply_filters('wp_link_pages_args', $r);
    extract($r, EXTR_SKIP);
    global $page, $numpages, $multipage, $more;
    $output = '';
    if ($multipage) {
        if ('number' == $next_or_number) {
            $output .= $before;
            for ($i = 1; $i <= $numpages; $i++) {
                $link = $link_before . str_replace('%', $i, $pagelink) . $link_after;
                if ($i != $page || !$more && 1 == $page) {
                    $link = _wp_link_page($i) . $link . '</a>';
                }
                $link = apply_filters('wp_link_pages_link', $link, $i);
                $output .= $separator . $link;
            }
            $output .= $after;
        } elseif ($more) {
            $output .= $before;
            $i = $page - 1;
            if ($i) {
                $link = _wp_link_page($i) . $link_before . $previouspagelink . $link_after . '</a>';
                $link = apply_filters('wp_link_pages_link', $link, $i);
                $output .= $separator . $link;
            }
            $i = $page + 1;
            if ($i <= $numpages) {
                $link = _wp_link_page($i) . $link_before . $nextpagelink . $link_after . '</a>';
                $link = apply_filters('wp_link_pages_link', $link, $i);
                $output .= $separator . $link;
            }
            $output .= $after;
        }
    }
    $output = apply_filters('wp_link_pages', $output, $args);
    if ($echo) {
        echo $output;
    }
    return $output;
}