本文整理汇总了PHP中_wp_link_page函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_link_page函数的具体用法?PHP _wp_link_page怎么用?PHP _wp_link_page使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_wp_link_page函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_foundation_six_custom_link_pages
function wp_foundation_six_custom_link_pages($args = '')
{
$defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', '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, $pagenow;
$output = '';
if ($multipage) {
if ('number' == $next_or_number) {
$output .= $before;
$output .= '<ul class="pagination">';
for ($i = 1; $i < $numpages + 1; $i = $i + 1) {
$j = str_replace('%', $i, $pagelink);
if ($i == $page) {
$output .= '<li class="current"><a href="#">';
} else {
$output .= '<li>';
}
if ($i != $page || !$more && $page == 1) {
$output .= _wp_link_page($i);
}
$output .= $link_before . $j . $link_after;
if ($i != $page || !$more && $page == 1) {
$output .= '</a>';
}
}
$output .= '</li>';
$output .= $after;
} else {
if ($more) {
$output .= $before;
$i = $page - 1;
if ($i && $more) {
$output .= _wp_link_page($i);
$output .= $link_before . $previouspagelink . $link_after . '</a>';
}
$i = $page + 1;
if ($i <= $numpages && $more) {
$output .= _wp_link_page($i);
$output .= $link_before . $nextpagelink . $link_after . '</a>';
}
$output .= '</ul>';
$output .= $after;
}
}
}
if ($echo) {
echo $output;
}
return $output;
}
示例2: puresimple_multi_pages
/**
* Modification of wp_link_pages to enclose page links in an unordered list.
*
* Special thanks to http://wpbungee.webstractions.com/bungee-development/pagination-hybrid-core-theme-templates-twitter-bootstrap/
*
*/
function puresimple_multi_pages($args = '')
{
$defaults = array('before' => '<div class="pagination-wrapper clearfix"><label>' . __('Pages: ', 'pure-simple') . '</label><ul class="pagination">', 'after' => '</ul></div>', 'link_before' => '<li>', 'link_after' => '</li>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', 'pure-simple'), 'previouspagelink' => __('Previous page', 'pure-simple'), 'pagelink' => '%', 'echo' => 1);
$r = wp_parse_args($args, $defaults);
$r = apply_filters('puresimple_multi_pages_args', $r);
extract($r, EXTR_SKIP);
global $page, $numpages, $multipage, $more, $pagenow;
$output = '';
if ($multipage) {
if ('number' == $next_or_number) {
$output .= $before;
for ($i = 1; $i < $numpages + 1; $i = $i + 1) {
$j = str_replace('%', $i, $pagelink);
if ($i != $page || !$more && $page == 1) {
$output .= ' ' . str_replace('%', 'normal', $link_before);
$output .= _wp_link_page($i);
$output .= $j;
$output .= '</a>';
} else {
$output .= ' ' . str_replace('%', 'disabled', $link_before);
$output .= '<span class="active">' . $j . '</span>';
}
$output .= $link_after;
}
$output .= $after;
} else {
if ($more) {
$output .= $before;
$i = $page - 1;
if ($i && $more) {
$output .= $link_before;
$output .= _wp_link_page($i);
$output .= $previouspagelink . '</a>';
$output .= $link_after;
}
$i = $page + 1;
if ($i <= $numpages && $more) {
$output .= $link_before;
$output .= _wp_link_page($i);
$output .= $nextpagelink . '</a>';
$output .= $link_after;
}
$output .= $after;
}
}
}
if ($echo) {
echo $output;
}
return $output;
}
示例3: article_page_nav
/**
* Can be used instead of wp_link_pages() for showing article-specific pagination. For paginated posts ( posts which
* use <!--nextpage--> ), this method implements Foundation's pagination structure instead of WordPress's.
*
* The following arguments are accepted...
*
* 'before' - Start of generated HTML object
* 'after' - End of generated HTML object
* 'page_before' - Element to place before page link.
* 'link_before' - Place inside link at start of visible text
* 'link_after' - Place inside link at end of visible text
* 'page_after' - Closing element to place after page link
* 'echo' - Whether to echo the generated object
*
* @see wp_link_pages()
*
* @param string|array $args Optional. Overwrite the defaults.
*
* @deprecated Will be replaced or removed in next version. Use custom method instead.
*
* @return string Formatted output in HTML.
*/
public static function article_page_nav($args = array())
{
$defaults = array('before' => '<dl class="page-link sub-nav">' . '<dt>' . __('Pages:', 'nvLangScope') . '</dt>', 'page_before' => '<dd%>', 'page_after' => '</dd>', 'link_before' => '', 'link_after' => '', 'after' => '</dl>', 'max_size' => 6, 'echo' => true);
$r = wp_parse_args($args, $defaults);
//Plugin compatibility
$r = apply_filters('wp_link_pages_args', $r);
extract($r, EXTR_SKIP);
/** @var $before string */
/** @var $page_before string */
/** @var $page_after string */
/** @var $link_before string */
/** @var $link_after string */
/** @var $after string */
/** @var $max_size string */
/** @var $echo string */
global $page, $numpages, $multipage, $more, $pagenow;
$output = '';
if ($multipage) {
$output .= $before;
//Loop through and count pages...
for ($i = 1; $i < $numpages + 1; $i = $i + 1) {
//Set the page number
$pagenum = $i;
//Add a white space...
$output .= ' ';
//Generate a link only if it isn't the current page
if ($i != $page || !$more && $page == 1) {
//Is NOT the current page
$output .= preg_replace('/%/', '', $page_before);
} else {
//Current page...
$output .= preg_replace('/%/', ' class="active" ', $page_before);
}
$output .= _wp_link_page($i);
//$link_start;
$output .= $link_before;
$output .= $pagenum;
$output .= $link_after;
$output .= '</a>';
//$link_end;
$output .= $page_after;
}
$output .= $after;
}
if ($echo) {
echo $output;
}
return $output;
}
示例4: custom_wp_link_pages
function custom_wp_link_pages($args = '')
{
$defaults = array('before' => '<div id="post_pagination" class="clearfix"><h5>' . __('Pages:') . '</h5>', 'after' => '</div>', 'text_before' => '', 'text_after' => '', 'next_or_number' => 'number', '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, $pagenow;
$output = '';
if ($multipage) {
if ('number' == $next_or_number) {
$output .= $before;
for ($i = 1; $i < $numpages + 1; $i = $i + 1) {
$j = str_replace('%', $i, $pagelink);
$output .= ' ';
if ($i != $page || !$more && $page == 1) {
$output .= _wp_link_page($i);
} else {
$output .= '<p class="current-post-page">';
}
$output .= $text_before . $j . $text_after;
if ($i != $page || !$more && $page == 1) {
$output .= '</a>';
} else {
$output .= '</p>';
}
}
$output .= $after;
} else {
if ($more) {
$output .= $before;
$i = $page - 1;
if ($i && $more) {
$output .= _wp_link_page($i);
$output .= $text_before . $previouspagelink . $text_after . '</a>';
}
$i = $page + 1;
if ($i <= $numpages && $more) {
$output .= _wp_link_page($i);
$output .= $text_before . $nextpagelink . $text_after . '</a>';
}
$output .= $after;
}
}
}
if ($echo) {
echo $output;
}
return $output;
}
示例5: custom_wp_link_pages
function custom_wp_link_pages($args = '')
{
$defaults = array('before' => '<ul class="pagination number text-center" role="navigation" aria-label="Pagination">', 'after' => '</ul>', 'text_before' => '', 'text_after' => '', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', 'kindel'), 'previouspagelink' => __('Previous page', 'kindel'), '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, $pagenow;
$output = '';
if ($multipage) {
if ('number' == $next_or_number) {
$output .= $before;
for ($i = 1; $i < $numpages + 1; $i = $i + 1) {
$j = str_replace('%', $i, $pagelink);
$output .= ' ';
if ($i != $page || !$more && $page == 1) {
$output .= '<li>' . _wp_link_page($i);
} else {
$output .= '<li class="current"><span class="show-for-sr">You are on page:</span>';
}
$output .= $text_before . $j . $text_after;
if ($i != $page || !$more && $page == 1) {
$output .= '</a>';
} else {
$output .= '</li>';
}
}
$output .= $after;
} else {
if ($more) {
$output .= $before;
$i = $page - 1;
if ($i && $more) {
$output .= _wp_link_page($i);
$output .= $text_before . $previouspagelink . $text_after . '</a></li>';
}
$i = $page + 1;
if ($i <= $numpages && $more) {
$output .= _wp_link_page($i);
$output .= $text_before . $nextpagelink . $text_after . '</a></li>';
}
$output .= $after;
}
}
}
if ($echo) {
echo $output;
}
return $output;
}
示例6: add_next_and_number
public static function add_next_and_number($args)
{
global $page, $numpages, $multipage, $more;
if (!$multipage || !$more || $args['next_or_number'] !== 'next_and_number') {
return $args;
}
$args['next_or_number'] = 'number';
$prev = $next = '';
$i = $page - 1;
$prev .= _wp_link_page($i);
$prev .= $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>';
$i = $page + 1;
if ($i <= $numpages) {
$next .= _wp_link_page($i);
$next .= $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>';
}
$args['before'] = $args['before'] . ($page == 1 ? '' : $prev);
$args['after'] = $next . $args['after'];
return $args;
}
示例7: test_wp_link_pages
function test_wp_link_pages()
{
$contents = array('One', 'Two', 'Three');
$content = join('<!--nextpage-->', $contents);
$post_id = self::factory()->post->create(array('post_content' => $content));
$this->go_to('?p=' . $post_id);
setup_postdata(get_post($post_id));
$permalink = sprintf('<a href="%s">', get_permalink());
$page2 = _wp_link_page(2);
$page3 = _wp_link_page(3);
$expected = "<p>Pages: 1 {$page2}2</a> {$page3}3</a></p>";
$output = wp_link_pages(array('echo' => 0));
$this->assertEquals($expected, $output);
$before_after = " 1 {$page2}2</a> {$page3}3</a>";
$output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => ''));
$this->assertEquals($before_after, $output);
$separator = " 1{$page2}2</a>{$page3}3</a>";
$output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => ''));
$this->assertEquals($separator, $output);
$link = " <em>1</em>{$page2}<em>2</em></a>{$page3}<em>3</em></a>";
$output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '', 'link_before' => '<em>', 'link_after' => '</em>'));
$this->assertEquals($link, $output);
$next = "{$page2}<em>Next page</em></a>";
$output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '', 'link_before' => '<em>', 'link_after' => '</em>', 'next_or_number' => 'next'));
$this->assertEquals($next, $output);
$GLOBALS['page'] = 2;
$next_prev = "{$permalink}<em>Previous page</em></a>{$page3}<em>Next page</em></a>";
$output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '', 'link_before' => '<em>', 'link_after' => '</em>', 'next_or_number' => 'next'));
$this->assertEquals($next_prev, $output);
$next_prev_link = "{$permalink}Woo page</a>{$page3}Hoo page</a>";
$output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '', 'next_or_number' => 'next', 'nextpagelink' => 'Hoo page', 'previouspagelink' => 'Woo page'));
$this->assertEquals($next_prev_link, $output);
$GLOBALS['page'] = 1;
$separator = "<p>Pages: 1 | {$page2}2</a> | {$page3}3</a></p>";
$output = wp_link_pages(array('echo' => 0, 'separator' => ' | '));
$this->assertEquals($separator, $output);
$pagelink = " Page 1 | {$page2}Page 2</a> | {$page3}Page 3</a>";
$output = wp_link_pages(array('echo' => 0, 'separator' => ' | ', 'before' => '', 'after' => '', 'pagelink' => 'Page %'));
$this->assertEquals($pagelink, $output);
}
示例8: wp_link_pages_args_prevnext_add
/**
* Add prev and next links to a numbered page link list
*/
function wp_link_pages_args_prevnext_add($args)
{
global $page, $numpages, $more, $pagenow;
if (!$args['next_or_number'] == 'next_and_number') {
return $args;
}
# exit early
$args['next_or_number'] = 'number';
# keep numbering for the main part
if (!$more) {
return $args;
}
# exit early
if ($page - 1) {
# there is a previous page
$args['before'] .= _wp_link_page($page - 1) . $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>';
}
if ($page < $numpages) {
# there is a next page
$args['after'] = _wp_link_page($page + 1) . $args['link_before'] . ' ' . $args['nextpagelink'] . $args['link_after'] . '</a>' . $args['after'];
}
return $args;
}
示例9: bootstrap_link_pages
/**
* Link Pages.
*
* Modification of wp_link_pages() with an extra element to highlight the current page.
*
* @author toscho
* @link http://wordpress.stackexchange.com/questions/14406/how-to-style-current-page-number-wp-link-pages
*
* @param Array $args Arguments.
*/
function bootstrap_link_pages($args = array())
{
$defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'before_link' => '', 'after_link' => '', 'current_before' => '', 'current_after' => '', 'link_before' => '', 'link_after' => '', 'pagelink' => '%', 'echo' => 1);
$args = wp_parse_args($args, $defaults);
$args = apply_filters('wp_link_pages_args', $args);
$before = $args['before'];
$after = $args['after'];
$before_link = $args['before_link'];
$after_link = $args['after_link'];
$current_before = $args['current_before'];
$current_after = $args['current_after'];
$link_before = $args['link_before'];
$link_after = $args['link_after'];
$pagelink = $args['pagelink'];
$echo = $args['echo'];
global $page, $numpages, $multipage, $more, $pagenow;
if (!$multipage) {
return;
}
$output = $before;
for ($i = 1; $i < $numpages + 1; $i++) {
$j = str_replace('%', $i, $pagelink);
$output .= ' ';
if ($i != $page || !$more && 1 == $page) {
$output .= sprintf('%1$s%2$s%3$s%4$s%5$s</a>%6$s', $before_link, _wp_link_page($i), $link_before, $j, $link_after, $after_link);
} else {
$output .= sprintf('%1$s%2$s<a>%3$s</a>%4$s%5$s', $current_before, $link_before, $j, $link_after, $current_after);
}
}
$output .= $after;
if ($echo) {
print $output;
// WPCS: xss ok.
} else {
return $output;
}
}
示例10: zee_link_pages
function zee_link_pages($args = '')
{
$defaults = array('before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', ZEETEXTDOMAIN), 'previouspagelink' => __('Previous page', ZEETEXTDOMAIN), '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, $pagenow;
$output = '';
if ($multipage) {
if ('number' == $next_or_number) {
$output .= $before . '<ul class="pagination">';
$laquo = $page == 1 ? 'class="disabled"' : '';
$output .= '<li ' . $laquo . '>' . _wp_link_page($page - 1) . '«</li>';
for ($i = 1; $i < $numpages + 1; $i = $i + 1) {
$j = str_replace('%', $i, $pagelink);
if ($i != $page || !$more && $page == 1) {
$output .= '<li>';
$output .= _wp_link_page($i);
} else {
$output .= '<li class="active">';
$output .= _wp_link_page($i);
}
$output .= $link_before . $j . $link_after;
$output .= '</li>';
}
$raquo = $page == $numpages ? 'class="disabled"' : '';
$output .= '<li ' . $raquo . '>' . _wp_link_page($page + 1) . '»</li>';
$output .= '</ul>' . $after;
} else {
if ($more) {
$output .= $before . '<ul class="pager">';
$i = $page - 1;
if ($i && $more) {
$output .= '<li class="previous">' . _wp_link_page($i);
$output .= $link_before . $previouspagelink . $link_after . '</li>';
}
$i = $page + 1;
if ($i <= $numpages && $more) {
$output .= '<li class="next">' . _wp_link_page($i);
$output .= $link_before . $nextpagelink . $link_after . '</li>';
}
$output .= '</ul>' . $after;
}
}
}
if ($echo) {
echo $output;
} else {
return $output;
}
}
示例11: wpbootstrap_link_pages
function wpbootstrap_link_pages($args = '')
{
$defaults = array('before' => '<ul class="pagination">', 'after' => '</ul>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', "toolset_starter"), 'previouspagelink' => __('Previous page', "toolset_starter"), '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, $pagenow;
$output = '';
if ($multipage) {
if ('number' == $next_or_number) {
$output .= $before;
for ($i = 1; $i < $numpages + 1; $i = $i + 1) {
$j = str_replace('%', $i, $pagelink);
$output .= ' ';
if ($i != $page || !$more && $page == 1) {
$output .= '<li>' . _wp_link_page($i);
} else {
$output .= '<li class="active"><a href="#">';
}
$output .= $j;
if ($i != $page || !$more && $page == 1) {
$output .= '</a>';
} else {
$output .= '</a></li>';
}
}
$output .= $after;
} else {
if ($more) {
$output .= $before;
$i = $page - 1;
if ($i && $more) {
$output .= _wp_link_page($i);
$output .= $previouspagelink . '</a>';
}
$i = $page + 1;
if ($i <= $numpages && $more) {
$output .= _wp_link_page($i);
$output .= $nextpagelink . '</a>';
}
$output .= $after;
}
}
}
if ($echo) {
echo $output;
}
return $output;
}
示例12: get_wp_link_page
private static function get_wp_link_page($i)
{
$link = _wp_link_page($i);
$link = new SimpleXMLElement($link . '</a>');
if (isset($link['href'])) {
return $link['href'];
}
return '';
}
示例13: mts_wp_link_pages_args_prevnext_add
function mts_wp_link_pages_args_prevnext_add($args)
{
global $page, $numpages, $more, $pagenow;
if (!$args['next_or_number'] == 'next_and_number') {
return $args;
}
$args['next_or_number'] = 'number';
if (!$more) {
return $args;
}
if ($page - 1) {
$args['before'] .= _wp_link_page($page - 1) . $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>';
}
if ($page < $numpages) {
$args['after'] = _wp_link_page($page + 1) . $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>' . $args['after'];
}
return $args;
}
示例14: wise_custom_wp_link_pages
function wise_custom_wp_link_pages($args = '')
{
$defaults = array('before' => '<div class="post-navigation-outer"><nav class="post-navigation-wrapper"><ul class="post-pagination">', 'after' => '</ul></nav></div>', 'text_before' => '', 'text_after' => '', 'next_or_number' => 'number', 'nextpagelink' => esc_html__('Next page', 'wise-blog'), 'previouspagelink' => esc_html__('Previous page', 'wise-blog'), '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, $pagenow;
$output = '';
if ($multipage) {
if ('number' == $next_or_number) {
$output .= $before;
for ($i = 1; $i < $numpages + 1; $i = $i + 1) {
$j = str_replace('%', $i, $pagelink);
$output .= '<li> ';
if ($i != $page || !$more && $page == 1) {
$output .= _wp_link_page($i);
} else {
$output .= '<span class="post-pagination current-post-page">';
}
$output .= $text_before . $j . $text_after;
if ($i != $page || !$more && $page == 1) {
$output .= '</a>';
} else {
$output .= '</span></li>';
}
}
$output .= $after;
} else {
if ($more) {
$output .= $before;
$i = $page - 1;
if ($i && $more) {
$output .= _wp_link_page($i);
$output .= $text_before . $previouspagelink . $text_after . '</a>';
}
$i = $page + 1;
if ($i <= $numpages && $more) {
$output .= _wp_link_page($i);
$output .= $text_before . $nextpagelink . $text_after . '</a>';
}
$output .= $after;
}
}
}
if ($echo) {
echo wp_kses_post($output);
}
return $output;
}
示例15: cleanyetibasic_numerical_link_pages
/**
* Modification of wp_link_pages() with an extra element to highlight the current page.
*
* @param array $args
* @return void
*/
function cleanyetibasic_numerical_link_pages($args = array())
{
$defaults = array('before' => '<p>' . __('Pages:', 'cleanyetibasic'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', '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, $pagenow;
if (!$multipage) {
return;
}
$output = $before;
for ($i = 1; $i < $numpages + 1; $i++) {
$j = str_replace('%', $i, $pagelink);
$output .= ' ';
if ($i != $page || !$more && 1 == $page) {
$output .= "<li>" . _wp_link_page($i) . "{$link_before}{$j}{$link_after}</a></li>";
} else {
// highlight the current page
// not sure if we need $link_before and $link_after
$output .= "<li><span class=\"page-numbers current\">{$link_before}{$j}{$link_after}</span></li>";
}
}
$echo and print $output . $after;
return $output . $after;
}