[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

bw_navi_paginate_links() – Paginate links for shortcode pagination

You appear to be a bot. Output may be restricted

Description

Paginate links for shortcode pagination

Use paginate_links() to create special pagination links for shortcodes These work independently of WordPress pagination, which uses "page". When the user is visiting the page,

  • since each shortcode produces its own shortcode ID ( bwscid$id ),
  • then the URL will slowly build up the pagination information for each shortcode.
  • This avoids the need for cookies and/or jQuery to remember the page state of each shortcode.
Theoretically, this solution works on archive pages. Things can go awry if the displayed content changes, such that a nested shortcode with pagination suddenly appears. That's some complicated page we'd rather not attempt to deal with right now. Note: In WordPress 4.1.1 a fix was introduced that caused a new problem when you return to the first page. The workaround below is to remove the special query arg ( bwscid$id ) from $_SERVER['REQUEST_URI']

Usage

bw_navi_paginate_links( $id, $page, $pages );

Parameters

$id
( integer ) required – the 'unique' shortcode ID for this instance of a paged shortcode
$page
( integer ) required – the current page number ( starts from 1 )
$pages
( integer ) required – the total number of pages

Returns

void

Source

File name: oik/shortcodes/oik-navi.php
Lines:
1 to 39 of 39
function bw_navi_paginate_links( $id, $page, $pages ) {
  //bw_trace2(  $_SERVER['REQUEST_URI'], "request_URI" );
  $saved_request_uri = $_SERVER['REQUEST_URI'];
  $string = remove_query_arg( "bwscid$id" );
  $_SERVER['REQUEST_URI'] = $string; 
  //bw_trace2( $string, "removed request_URI", false );
  $base = add_query_arg( "bwscid$id", "%_%" );
  
  //bw_trace2( $base, "base", false );
  $base = esc_url_raw( $base );
  //bw_trace2( $base, "base", false );
  $format = "%#%";
  $args = array( "base" => $base
               , "format" => $format
               , "total" => $pages
               , "current" => $page
               , "before_page_number" => "["
               , "after_page_number" => "]"
               , "add_args" => false
              , "type" => "plain"
               );
  // We don't need to worry about these yet             
  //  'show_all' => false,
  //  'prev_next' => true,
  //  'prev_text' => __('� Previous'),
  //  'next_text' => __('Next �'),
  //  'end_size' => 1,
  //  'mid_size' => 2,
  //  'type' => 'plain',
  //  'add_args' => false, // array of query args to add
  //  'add_fragment' => '',
  $links = paginate_links( $args ); 
  //bw_trace2( $args, "args" );
  //bw_trace2( $links, "links", false );
  sdiv( "page-numbers pagination");
    e( $links );
    ediv();
  $_SERVER['REQUEST_URI'] = $saved_request_uri;
}
 
 View on GitHub View on Trac

Published: February 2, 2018 | Last updated: February 2, 2018

Information

Function name: bw_navi_paginate_links
Plugin ref: oik – oik information kit
Version: 4.9.2
Sourcefile: shortcodes/oik-navi.php
File ref: shortcodes/oik-navi.php
Deprecated?: No
API Letters: B,L,N,P

Recent plugin updates

oik v4.9.2 Upgrade to oik v4.9.2 for support for PHP 8.1 and PHP 8.2. ...
oik-block v0.3.0 oik-block v0.3.0 no longer displays the Editor selection meta box ...
oik-blocks v1.4.3 Upgrade to oik-blocks v1.4.3 for PHP 8.2 support. ...
cookie-cat v1.4.6 Upgrade to cookie-cat v1.4.6 for PHP 8.1 & PHP 8.2 support. ...
oik-fields v1.54.0 oik-fields v1.54.0 caters for the deprecation of get_page_by_title() in WordPress 6.2. ...

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: herb@bobbingwide.com

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2023. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins
WordPress 6.3.1. PHP: 7.4.33. Memory limit: 768M