本文整理汇总了PHP中user_trailingslashit函数的典型用法代码示例。如果您正苦于以下问题:PHP user_trailingslashit函数的具体用法?PHP user_trailingslashit怎么用?PHP user_trailingslashit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_trailingslashit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: farmtoyou_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*
* @since Farmtoyou 1.0
*
* @global WP_Query $wp_query WordPress Query object.
* @global WP_Rewrite $wp_rewrite WordPress Rewrite object.
*/
function farmtoyou_paging_nav()
{
global $wp_query, $wp_rewrite;
// Don't print empty markup if there's only one page.
if ($wp_query->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $wp_rewrite->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base . '/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'farmtoyou'), 'next_text' => __('Next →', 'farmtoyou')));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<div class="pagination loop-pagination">
<?php
echo $links;
?>
</div><!-- .pagination -->
</nav><!-- .navigation -->
<?php
}
}
示例2: flat_paging_nav
function flat_paging_nav()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 4, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<i class="fa fa-chevron-left"></i>', 'flat'), 'next_text' => __('<i class="fa fa-chevron-right"></i>', 'flat')));
$allowed_html = array('a' => array('href' => array(), 'class' => array()), 'span' => array('class' => array()), 'i' => array('class' => array()));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<div class="nav-links">
<?php
echo wp_kses($links, $allowed_html);
?>
</div>
</nav>
<?php
}
}
示例3: pagenavi
function pagenavi($args = array())
{
//デフォルト値
$defaults = array('class_name' => 'pagenavi', 'show_all' => false, 'prev_next' => true, 'prev_text' => __('« Previous'), 'next_text' => __('Next »'), 'end_size' => 1, 'mid_size' => 3);
$args = wp_parse_args($args, $defaults);
//パラメータを解析し、省略されたパレメータにはデフォルト値をセット
extract($args, EXTR_SKIP);
//キーを変数名、値を変数の値として処理
echo '<div class="' . $class_name . '">';
global $wp_rewrite;
$paginate_base = get_pagenum_link(1);
if (strpos($paginate_base, '?') || !$wp_rewrite->using_permalinks()) {
$paginate_format = '';
$paginate_base = esc_url(add_query_arg('paged', '%#%'));
} else {
$paginate_format = (substr($paginate_base, -1, 1) == '/' ? '' : '/') . user_trailingslashit('page/%#%/', 'paged');
$paginate_base .= '%_%';
}
global $paged;
global $wp_query;
//paginate_links()の出力を $outputs に格納
$outputs = paginate_links(array('base' => $paginate_base, 'format' => $paginate_format, 'total' => $wp_query->max_num_pages, 'current' => $paged ? $paged : 1, 'show_all' => $show_all, 'prev_next' => $prev_next, 'prev_text' => $prev_text, 'next_text' => $next_text, 'end_size' => $end_size, 'mid_size' => $mid_size, 'type' => 'list'));
//★ ul 要素のクラス名を変更(置換)して出力
echo str_replace("<ul class='page-numbers'>", "<ul class='pagination'>", $outputs);
echo '</div>';
}
示例4: filter_recurring_event_permalinks
public function filter_recurring_event_permalinks($post_link, $post, $leavename, $sample)
{
if (!$this->should_filter_permalink($post, $sample)) {
return $post_link;
}
$permastruct = $this->get_permastruct($post);
if ($leavename && empty($post->post_parent)) {
$date = 'all';
// sample permalink for the series
} else {
$date = $this->get_date_string($post);
}
$parent = $this->get_primary_event($post);
$slug = $parent->post_name;
if (get_option('permalink_structure') == '') {
$post_link = remove_query_arg(TribeEvents::POSTTYPE, $post_link);
$post_link = add_query_arg(array(TribeEvents::POSTTYPE => $slug, 'eventDate' => $date), $post_link);
} elseif (!empty($permastruct)) {
if (!$leavename) {
$post_link = str_replace("%{$post->post_type}%", $slug, $permastruct);
}
$post_link = trailingslashit($post_link) . $date;
$post_link = str_replace(trailingslashit(home_url()), '', $post_link);
$post_link = home_url(user_trailingslashit($post_link));
}
return $post_link;
}
示例5: digitalstore_pagination
/**
* Pagination
*
* Echoes the pagination for the theme.
*
* @return string
* @access private
* @since 1.0
*/
function digitalstore_pagination($range = 4, $return = false, $_wp_query = null)
{
global $paged, $wp_query, $wp_rewrite;
$wpq = $_wp_query ? $_wp_query : $wp_query;
$max_page = $wpq->max_num_pages;
$paged = $paged ? $paged : 1;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : ($current = 1);
$out = '<p class="digitalstore-pagination">';
$pages_text = sprintf(__('Page %d of %d', 'edd-digitalstore'), number_format_i18n($paged), number_format_i18n($max_page));
$out .= '<span class="pages">' . $pages_text . '</span>';
$pagination = array('base' => esc_url(add_query_arg('paged', '%#%')), 'format' => '', 'total' => $wp_query->max_num_pages, 'current' => $current, 'end_size' => $range, 'prev_text' => __('«', 'edd-digitalstore'), 'next_text' => __('»', 'edd-digitalstore'), 'type' => 'plain');
if ($wp_rewrite->using_permalinks()) {
$base_url = get_pagenum_link(1);
if (is_search()) {
$base_url = preg_replace('/\\?.*/', '', $base_url);
}
$pagination['base'] = user_trailingslashit(trailingslashit(esc_url(remove_query_arg(array('s'), $base_url))) . 'page/%#%/', 'paged');
}
if (!empty($wp_query->query_vars['s'])) {
$pagination['add_args'] = array('s' => get_query_var('s'));
}
$out .= paginate_links($pagination);
$out .= '</p>';
if ($return) {
return $out;
} else {
echo $out;
}
}
示例6: anciela_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*
* @since Anciela 1.0
*/
function anciela_paging_nav($query = null)
{
// Don't print empty markup if there's only one page.
if ($query == null) {
$query = $GLOBALS['wp_query'];
}
if ($query->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Plus récents', 'anciela'), 'next_text' => __('Plus anciens →', 'anciela')));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<?php
echo $links;
?>
</nav><!-- .navigation -->
<?php
}
}
示例7: my_simone_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*
* @return void
*/
function my_simone_paging_nav()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 2, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'my-simone'), 'next_text' => __('Next →', 'my-simone'), 'type' => 'list'));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Posts navigation', 'my-simone');
?>
</h1>
<?php
echo $links;
?>
</nav><!-- .navigation -->
<?php
}
}
示例8: brvry_backbone_get_request_path
/**
* Build path data for current request.
*
* @return string|bool
*/
function brvry_backbone_get_request_path()
{
global $wp_rewrite;
if ($wp_rewrite->using_permalinks()) {
global $wp;
// If called too early, bail
if (!isset($wp->request)) {
return false;
}
// Determine path for paginated version of current request
if (false != preg_match('#' . $wp_rewrite->pagination_base . '/\\d+/?$#i', $wp->request)) {
$path = preg_replace('#' . $wp_rewrite->pagination_base . '/\\d+$#i', $wp_rewrite->pagination_base . '/%d', $wp->request);
} else {
$path = $wp->request . '/' . $wp_rewrite->pagination_base . '/%d';
}
// Slashes everywhere we need them
if (0 !== strpos($path, '/')) {
$path = '/' . $path;
}
$path = user_trailingslashit($path);
} else {
// Clean up raw $_REQUEST input
$path = array_map('sanitize_text_field', $_REQUEST);
$path = array_filter($path);
$path['paged'] = '%d';
$path = add_query_arg($path, '/');
}
return empty($path) ? false : $path;
}
示例9: learn_press_course_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*/
function learn_press_course_paging_nav()
{
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<', 'learn_press'), 'next_text' => __('>', 'learn_press'), 'type' => 'list'));
if ($links) {
?>
<div class="navigation pagination">
<?php
echo $links;
?>
</div>
<!-- .pagination -->
<?php
}
}
示例10: abramoca_pagination
function abramoca_pagination($query = null)
{
global $wp_query;
if (empty($query)) {
$query = $wp_query;
}
if ($query->max_num_pages < 2) {
return;
}
if (is_front_page()) {
$paged = get_query_var('page') ? intval(get_query_var('page')) : 1;
} else {
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
}
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'array', 'add_args' => array_map('urlencode', $query_args), 'prev_next' => True, 'prev_text' => !is_rtl() ? __('← Previous ') : __(' → Previous'), 'next_text' => !is_rtl() ? __('Next →') : __('Next ←')));
if (is_array($links)) {
echo '<ul class="pagination">';
//Aquí se editaría la clase CSS de la paginación
foreach ($links as $page) {
echo "<li>{$page}</li>";
}
echo '</ul>';
}
}
示例11: agency_navigation
function agency_navigation($type = 'plain', $endsize = 1, $midsize = 1)
{
echo ' <div class="paging clearfix">' . "\n";
if (function_exists('wp_pagenavi')) {
?>
<?php
wp_pagenavi();
?>
<?php
} else {
global $wp_query, $wp_rewrite;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : ($current = 1);
// Sanitize input argument values
if (!in_array($type, array('plain', 'list', 'array'))) {
$type = 'plain';
}
$endsize = (int) $endsize;
$midsize = (int) $midsize;
// Setup argument array for paginate_links()
$pagination = array('base' => @add_query_arg('paged', '%#%'), 'format' => '', 'total' => $wp_query->max_num_pages, 'current' => $current, 'show_all' => false, 'end_size' => $endsize, 'mid_size' => $midsize, 'type' => $type, 'prev_text' => __('← Previous', 'agency'), 'next_text' => __('Next →', 'agency'));
if ($wp_rewrite->using_permalinks()) {
$pagination['base'] = user_trailingslashit(trailingslashit(remove_query_arg('s', get_pagenum_link(1))) . 'page/%#%/', 'paged');
}
if (!empty($wp_query->query_vars['s'])) {
$pagination['add_args'] = array('s' => get_query_var('s'));
}
echo "<p><strong>" . paginate_links($pagination) . "</strong></p>";
}
echo ' </div>' . "\n";
}
示例12: gazeta_the_posts_pagination
function gazeta_the_posts_pagination($query, $echo = true)
{
$pagination = '';
global $wp_query;
if (empty($query)) {
$query = $wp_query;
}
if ($query->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
$args = array('base' => $pagenum_link, 'format' => $format, 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'list', 'add_args' => array_map('urlencode', $query_args), 'prev_text' => '<i class="fa fa-angle-double-left"></i>', 'next_text' => '<i class="fa fa-angle-double-right"></i>', 'before_page_number' => '<span>', 'after_page_number' => '</span>');
// Set up paginated links.
$pagination = paginate_links(apply_filters('gazeta_old_navigation_args', $args));
if ($pagination) {
if ($echo === false) {
return '<nav class="navigation pagination"><div class="nav-links">' . $pagination . '</div></nav>';
} else {
echo '<nav class="navigation pagination"><div class="nav-links">';
echo $pagination;
echo '</div></nav>';
}
}
}
示例13: pagination
function pagination($pages = '', $range = 4)
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('<i class="fa fa-angle-left"></i>', 'crunchpress'), 'next_text' => __('<i class="fa fa-angle-right"></i>', 'crunchpress')));
if ($links) {
?>
<div class="pagination-all pagination" role="navigation">
<ul id='pagination'>
<li>
<?php
echo $links;
?>
</li>
</ul><!-- .pagination -->
</div><!-- .navigation -->
<?php
}
}
示例14: iva_pagination
/**
* Display navigation to next/previous set of posts when applicable.
*
* @since hopes 1.0
*/
function iva_pagination()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit('page/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'iva_theme_front'), 'next_text' => __('Next →', 'iva_theme_front')));
if ($links) {
$out = '<nav class="navigation paging-navigation" role="navigation">';
$out .= '<div class="pagination loop-pagination">';
$out .= $links;
$out .= '</div>';
$out .= '</nav>';
}
return $out;
}
示例15: filter_post_type_link
public function filter_post_type_link($post_link, $post, $leavename, $sample)
{
switch ($post->post_type) {
case 'les':
//haal de juiste arrangementen id op
$arrangement = get_post_meta($post->ID, 'arrangement_id', true);
$post_slug = $post->post_name;
//lees de juiste terms uit
// $groep = get_the_terms($arrangement, 'groep');
// $voedselgroep = get_the_terms($arrangement, 'voedselgroep');
$arrangement_data = get_post($arrangement);
if (isset($arrangement_data->post_name)) {
// create the new permalink met als structuur /arrangement/groep-voedselgroep/titel
$post_link = home_url(user_trailingslashit('missie/' . $arrangement_data->post_name . '/' . $post_slug));
}
break;
case 'presentatie':
// I spoke with Dalton and he is using the CPT-onomies plugin to relate his custom post types so for this example, we are retrieving CPT-onomy information. this code can obviously be tweaked with whatever it takes to retrieve the desired information.
// we need to find the author the book belongs to. using array_shift() makes sure only one author is allowed
$arrangement = get_post_meta($post->ID, 'arrangement_id', true);
$post_slug = $post->post_name;
//var_dump($arrangement);
$arrangement_data = get_post($arrangement);
if (isset($arrangement_data->post_name)) {
// create the new permalink
$post_link = home_url(user_trailingslashit('missie/' . $arrangement_data->post_name . '/digibord/' . $post_slug));
}
break;
}
return $post_link;
}