Example #1
1
    /**
     * 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' => __('&larr; Previous', 'farmtoyou'), 'next_text' => __('Next &rarr;', 'farmtoyou')));
        if ($links) {
            ?>
	<nav class="navigation paging-navigation" role="navigation">
		<div class="pagination loop-pagination">
			<?php 
            echo $links;
            ?>
		</div><!-- .pagination -->
	</nav><!-- .navigation -->
	<?php 
        }
    }
Example #2
0
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 
    }
}
Example #3
0
function pagenavi($args = array())
{
    //デフォルト値
    $defaults = array('class_name' => 'pagenavi', 'show_all' => false, 'prev_next' => true, 'prev_text' => __('&laquo; Previous'), 'next_text' => __('Next &raquo;'), '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>';
}
 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;
 }
Example #5
0
/**
 * 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' => __('&laquo;', 'edd-digitalstore'), 'next_text' => __('&raquo;', '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;
    }
}
Example #6
0
    /**
     * 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' => __('&larr; Plus récents', 'anciela'), 'next_text' => __('Plus anciens &rarr;', 'anciela')));
        if ($links) {
            ?>
	<nav class="navigation paging-navigation" role="navigation">
        <?php 
            echo $links;
            ?>
	</nav><!-- .navigation -->
	<?php 
        }
    }
    /**
     * 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 
        }
    }
Example #8
0
/**
 * 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;
}
    /**
     * 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 
        }
    }
 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() ? __('&larr; Previous ') : __(' &rarr; Previous'), 'next_text' => !is_rtl() ? __('Next &rarr;') : __('Next &larr;')));
     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>';
     }
 }
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' => __('&larr; Previous', 'agency'), 'next_text' => __('Next &rarr;', '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";
}
Example #12
0
 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>';
         }
     }
 }
Example #13
0
    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 
        }
    }
 /**
  * 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' => __('&larr; Previous', 'iva_theme_front'), 'next_text' => __('Next &rarr;', '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;
 }
 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;
 }
    function createPagination($query)
    {
        global $wp_rewrite;
        $total = $query->max_num_pages;
        $current = max(1, ThemeHelper::getPageNumber());
        $Validation = new ThemeValidation();
        $pagination = array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'current' => $current, 'total' => $total, 'next_text' => __(' >', THEME_CONTEXT), 'prev_text' => __('< ', THEME_CONTEXT));
        if ($wp_rewrite->using_permalinks()) {
            $pagination['base'] = user_trailingslashit(trailingslashit(remove_query_arg('s', get_pagenum_link(1))) . 'page/%#%/', 'paged');
        }
        if (is_search()) {
            $pagination['add_args'] = array('s' => urlencode(get_query_var('s')));
        }
        $html = paginate_links($pagination);
        if ($Validation->isNotEmpty($html)) {
            $html = '
				<div class="theme-blog-pagination-box">
					<div class="theme-blog-pagination">
						' . $html . '
					</div>
				</div>
			';
        }
        return $html;
    }
Example #17
0
/**
 * The Progress post type loop.
 *
 * @param array|string $args All the arguments supported by {@link WP_Query}, and some more.
 * @return bool Returns true if the query has any results to loop over
 * @since Achievements (3.0)
 */
function dpa_has_progress($args = array())
{
    // If multisite and running network-wide, switch_to_blog to the data store site
    if (is_multisite() && dpa_is_running_networkwide()) {
        switch_to_blog(DPA_DATA_STORE);
    }
    $defaults = array('ignore_sticky_posts' => true, 'max_num_pages' => false, 'order' => 'DESC', 'orderby' => 'date', 'paged' => dpa_get_paged(), 'post_status' => dpa_get_unlocked_status_id(), 'post_type' => dpa_get_progress_post_type(), 's' => '', 'author' => dpa_is_single_user_achievements() ? dpa_get_displayed_user_id() : null, 'post_parent' => dpa_is_single_achievement() ? dpa_get_achievement_id() : null, 'posts_per_page' => -1, 'ach_populate_achievements' => dpa_is_single_user_achievements() && is_a(achievements()->achievement_query, 'WP_Query') && empty(achievements()->achievement_query->request));
    $args = dpa_parse_args($args, $defaults, 'has_progress');
    // Run the query
    achievements()->progress_query = new WP_Query($args);
    // If no limit to posts per page, set it to the current post_count
    if (-1 === (int) $args['posts_per_page']) {
        $args['posts_per_page'] = achievements()->progress_query->post_count;
    }
    // Add pagination values to query object
    achievements()->progress_query->posts_per_page = $args['posts_per_page'];
    achievements()->progress_query->paged = $args['paged'];
    // Only add pagination if query returned results
    if (((int) achievements()->progress_query->post_count || (int) achievements()->progress_query->found_posts) && (int) achievements()->progress_query->posts_per_page) {
        // Limit the number of achievements shown based on maximum allowed pages
        if (!empty($args['max_num_pages']) && achievements()->progress_query->found_posts > achievements()->progress_query->max_num_pages * achievements()->progress_query->post_count) {
            achievements()->progress_query->found_posts = achievements()->progress_query->max_num_pages * achievements()->progress_query->post_count;
        }
        // If pretty permalinks are enabled, make our pagination pretty
        if ($GLOBALS['wp_rewrite']->using_permalinks()) {
            // Page or single post
            if (is_page() || is_single()) {
                $base = get_permalink();
            } elseif (dpa_is_single_user_achievements()) {
                $base = dpa_get_user_avatar_link(array('type' => 'url', 'user_id' => dpa_get_displayed_user_id()));
            } else {
                $base = get_permalink($args['post_parent']);
            }
            // Use pagination base
            $base = trailingslashit($base) . user_trailingslashit($GLOBALS['wp_rewrite']->pagination_base . '/%#%/');
            // Unpretty pagination
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Pagination settings with filter
        $progress_pagination = apply_filters('dpa_progress_pagination', array('base' => $base, 'current' => (int) achievements()->progress_query->paged, 'format' => '', 'mid_size' => 1, 'next_text' => is_rtl() ? '&larr;' : '&rarr;', 'prev_text' => is_rtl() ? '&rarr;' : '&larr;', 'total' => $args['posts_per_page'] == achievements()->progress_query->found_posts ? 1 : ceil((int) achievements()->progress_query->found_posts / (int) $args['posts_per_page'])));
        // Add pagination to query object
        achievements()->progress_query->pagination_links = paginate_links($progress_pagination);
        // Remove first page from pagination
        achievements()->progress_query->pagination_links = str_replace($GLOBALS['wp_rewrite']->pagination_base . "/1/'", "'", achievements()->progress_query->pagination_links);
    }
    // If on a user's achievements page, we need to fetch the achievements
    if ($args['ach_populate_achievements'] && achievements()->progress_query->have_posts()) {
        $achievement_ids = wp_list_pluck((array) achievements()->progress_query->posts, 'post_parent');
        $achievement_args = array('order' => $args['order'], 'orderby' => $args['orderby'], 'post__in' => $achievement_ids, 'posts_per_page' => -1);
        // Run the query
        dpa_has_achievements($achievement_args);
    }
    // If multisite and running network-wide, undo the switch_to_blog
    if (is_multisite() && dpa_is_running_networkwide()) {
        restore_current_blog();
    }
    return apply_filters('dpa_has_progress', achievements()->progress_query->have_posts());
}
Example #18
0
    function local_pagination()
    {
        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);
        $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=%#%';
        $ipp = get_option('posts_per_page');
        $pageNums = getPageNums($GLOBALS['wp_query']->max_num_pages * $ipp, $paged, $ipp);
        if ($pageNums) {
            ?>
			<ul class="pagination clearfix">
				<?php 
            foreach ($pageNums['pages'] as $pageNum) {
                ?>
					<li <?php 
                if ($pageNums['currentPage'] == $pageNum) {
                    ?>
class="active"<?php 
                }
                ?>
>
						<?php 
                if ($pageNums['currentPage'] == $pageNum) {
                    ?>
							<span class="current highlight_bg"><?php 
                    echo $pageNum;
                    ?>
</span>
						<?php 
                } else {
                    ?>
							<a href="<?php 
                    echo get_pagenum_link($pageNum);
                    ?>
"><?php 
                    echo $pageNum;
                    ?>
</a>
						<?php 
                }
                ?>

					</li>
				<?php 
            }
            ?>
			</ul>

		<?php 
        }
    }
 function test_get_post_embed_url_with_pretty_permalinks()
 {
     update_option('permalink_structure', '/%postname%');
     $post_id = self::factory()->post->create();
     $permalink = get_permalink($post_id);
     $embed_url = get_post_embed_url($post_id);
     $this->assertEquals(user_trailingslashit(trailingslashit($permalink) . 'embed'), $embed_url);
     update_option('permalink_structure', '');
 }
 public function redirect_old_category_url($query_vars)
 {
     if (isset($query_vars['rcb_category_redirect'])) {
         $category_link = trailingslashit(get_option('home')) . user_trailingslashit($query_vars['rcb_category_redirect'], 'category');
         wp_redirect($category_link, 301);
         exit;
     }
     return $query_vars;
 }
Example #21
0
 /**
  * @param string   $link
  * @param \WP_Post $post
  *
  * @return string|void
  */
 public function method_permalink($link, $post)
 {
     if ('wp-parser-method' !== $post->post_type || 0 == $post->post_parent) {
         return $link;
     }
     list($class, $method) = explode('-', $post->post_name);
     $link = home_url(user_trailingslashit("method/{$class}/{$method}"));
     return $link;
 }
Example #22
0
function amp_get_permalink($post_id)
{
    if ('' != get_option('permalink_structure')) {
        $amp_url = trailingslashit(get_permalink($post_id)) . user_trailingslashit(AMP_QUERY_VAR, 'single_amp');
    } else {
        $amp_url = add_query_arg(AMP_QUERY_VAR, 1, get_permalink($post_id));
    }
    return apply_filters('amp_get_permalink', $amp_url, $post_id);
}
Example #23
0
 function no_category_base_request($query_vars)
 {
     if (isset($query_vars['wpseo_category_redirect'])) {
         $catlink = trailingslashit(get_option('home')) . user_trailingslashit($query_vars['wpseo_category_redirect'], 'category');
         wp_redirect($catlink, 301);
         exit;
     }
     return $query_vars;
 }
Example #24
0
 /**
  * Filter the post type archive permalink.
  *
  * @since 3.1.0
  *
  * @param string $link The post type archive permalink.
  * @param string $post_type Post type name.
  *
  * @return string
  */
 public function post_type_archive_link($link, $post_type)
 {
     $post_type_obj = get_post_type_object($post_type);
     if (get_option('permalink_structure') && is_array($post_type_obj->rewrite)) {
         $struct = $this->option->get_front_struct($post_type);
         $link = home_url(user_trailingslashit($struct, 'post_type_archive'));
     }
     return $link;
 }
 /**
  * Test permalink structure comment page usage.
  */
 public function test_comments_paged_with_pretty_permalink_structure()
 {
     global $wp_rewrite;
     $this->set_permalink_structure('/%postname%/');
     $cpage = 2;
     $link = add_query_arg(array('cpage' => $cpage, 'foo' => 'bar'), get_permalink(self::$post_id));
     $this->go_to($link);
     $expected = user_trailingslashit(trailingslashit(get_permalink(self::$post_id)) . $wp_rewrite->comments_pagination_base . '-' . $cpage, 'commentpaged') . '#comments';
     $this->assertEquals($expected, wp_get_canonical_url(self::$post_id));
 }
 /**
  * @ticket 34971
  */
 function test_static_front_page()
 {
     $this->set_permalink_structure('/%postname%/');
     $post_id = self::factory()->post->create(array('post_type' => 'page'));
     update_option('show_on_front', 'page');
     update_option('page_on_front', $post_id);
     $embed_url = get_post_embed_url($post_id);
     $this->assertSame(user_trailingslashit(trailingslashit(home_url()) . 'embed'), $embed_url);
     update_option('show_on_front', 'posts');
 }
function no_category_base_request($query_vars)
{
    if (isset($query_vars['category_redirect'])) {
        $catlink = trailingslashit(get_option('home')) . user_trailingslashit($query_vars['category_redirect'], 'category');
        status_header(301);
        header("Location: {$catlink}");
        exit;
    }
    return $query_vars;
}
Example #28
0
function mb_get_search_url()
{
    global $wp_rewrite;
    if ($wp_rewrite->using_permalinks()) {
        $url = user_trailingslashit(home_url(mb_get_search_slug()));
    } else {
        $url = add_query_arg('mb_custom', 'search', home_url());
    }
    return esc_url(apply_filters('mb_get_search_url', $url));
}
function no_category_parents_request($query_vars)
{
    //print_r($query_vars); // For Debugging
    if (isset($query_vars['category_redirect'])) {
        $catlink = trailingslashit(get_option('home')) . user_trailingslashit($query_vars['category_redirect'], 'category');
        status_header(301);
        header("Location: {$catlink}");
        exit;
    }
    return $query_vars;
}
Example #30
0
/**
 * Return the avatar link of a user
 *
 * @param array $args This function supports these arguments:
 *  - int $size If we're showing an avatar, set it to this size
 *  - string $type What type of link to return; either "avatar", "name", or "both", or "url".
 *  - int $user_id The ID for the user.
 * @return string
 * @since Achievements (3.0)
 */
function dpa_get_user_avatar_link($args = array())
{
    $defaults = array('size' => 50, 'type' => 'both', 'user_id' => 0);
    $r = dpa_parse_args($args, $defaults, 'get_user_avatar_link');
    extract($r);
    // Default to current user
    if (empty($user_id) && is_user_logged_in()) {
        $user_id = get_current_user_id();
    }
    // Assemble some link bits
    $user_link = array();
    // BuddyPress
    if (dpa_integrate_into_buddypress()) {
        $user_url = user_trailingslashit(bp_core_get_user_domain($user_id) . dpa_get_authors_endpoint());
        // WordPress
    } else {
        $user_url = user_trailingslashit(trailingslashit(get_author_posts_url($user_id)) . dpa_get_authors_endpoint());
        /**
         * Multisite, running network-wide.
         *
         * When this function is used by the "unlocked achievement" popup, if multisite + running network-wide + and not subdomains,
         * we'll have already done switch_to_blog( DPA_ROOT_BLOG ) by the time that this function is called. This makes inspecting
         * the current site ID, and is_main_site(), both useless as the globals will have already been changed.
         *
         * We need to find out if the user is likely to be on the "main site" in this situation. so we can modify our link.
         * The main site's author URLs are prefixed with "/blog". We do this by inspecting the _wp_switched_stack global.
         *
         * I think this solution might result in a wrong link in multi-network configuration, or if the main site has been set
         * to something non-default, but these are edge-cases for now.
         */
        if (is_multisite() && !is_subdomain_install() && dpa_is_running_networkwide() && DPA_DATA_STORE === 1 && !empty($GLOBALS['_wp_switched_stack'])) {
            $last_element = count($GLOBALS['_wp_switched_stack']) - 1;
            if (isset($GLOBALS['_wp_switched_stack'][$last_element]) && $GLOBALS['_wp_switched_stack'][$last_element] != 1) {
                $user_url = str_replace(home_url(), home_url() . '/blog', $user_url);
            }
        }
    }
    // Get avatar
    if ('avatar' === $type || 'both' === $type) {
        $user_link[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($user_url), get_avatar($user_id, $size));
    }
    // Get display name
    if ('avatar' !== $type) {
        $user_link[] = sprintf('<a href="%1$s">%2$s</a>', esc_url($user_url), get_the_author_meta('display_name', $user_id));
    }
    // Maybe return user URL only
    if ('url' === $type) {
        $user_link = $user_url;
        // Otherwise piece together the link parts and return
    } else {
        $user_link = join('&nbsp;', $user_link);
    }
    return apply_filters('dpa_get_user_avatar_link', $user_link, $args);
}