Permalink
Browse files

Move wfx_page_counter() out of loop.php to hooks

IMPORTANT - This may need you to tweek your child theme on Wonderflux upgrade depending on how your child theme is coded. I’ve moved this out of loop.php, because:
- it can cause layout issues when archive results are not full width
- it’s not flexible - moving this to a hooked function means it can be removed more easily
- No need to override loop.php just to remove the pagination now - just remove_action() for custom pagination layout, much neater… it’s a framework don’t you know!
  • Loading branch information...
Jonnyauk committed Nov 22, 2017
1 parent 642afcb commit aa3593c7a6db9b224a7f3ff4f82d6804dbda336f
Showing with 16 additions and 8 deletions.
  1. +12 −2 functions.php
  2. +0 −2 loop.php
  3. +4 −4 wf-includes/wf-display-functions.php
View
@@ -151,6 +151,16 @@
add_action( 'rest_api_init','wfx_rest_add_post_classes', 2 );
// Pagination
add_action( 'wfmain_after_archive_container', 'wfx_page_counter', 2 );
add_action( 'wfmain_after_search_container', 'wfx_page_counter', 2 );
add_action( 'wfmain_after_taxonomy_container', 'wfx_page_counter', 2 );
add_action( 'wfmain_after_tag_container', 'wfx_page_counter', 2 );
add_action( 'wfmain_after_date_container', 'wfx_page_counter', 2 );
add_action( 'wfmain_after_category_container', 'wfx_page_counter', 2 );
add_action( 'wfmain_after_search_container', 'wfx_page_counter', 2 );
//// 1.6 // Wonderflux debug functionality
add_action( 'admin_bar_menu', 'wfx_admin_bar_files_info', 100 );
@@ -1267,12 +1277,12 @@
* @param [string] $current_span CSS span class around current page number (set to blank to remove span). [page-counter-current]
* @param [string] $total_span CSS span class around total page number (set to blank to remove span). [page-counter-total]
* @param [string] $always_show No output is shown if there is only 1 page of results, setting to 'Y' to always show (ie page 1 of 1). Y/N [N]
* @param [string] $navigation Display next and previous navigation either side of the page display. Y/N [N]
* @param [string] $navigation Display next and previous navigation either side of the page display. Y/N [Y]
* @param [string] $nav_span CSS span class around totalnavigation links (set to blank to remove span). Y/N [page-counter-navigation]
* @param [string] $previous Text for previous link. [< ]
* @param [string] $next Text for next link. Y/N [ >]
* @param [string] $div Wrap output in containing <div>. Y/N [Y]
* @param [string] $div_class Containing <div> class if used. [row page-counter]
* @param [string] $div_class Containing <div> class if used. [container page-counter]
* @param [string] $echo Echo or return output. Y/N [Y]
*
* @todo Review code, make smarter!
View
@@ -40,7 +40,5 @@
endif;
wfx_page_counter('navigation=Y');
wfloop_after(); //WF display hook
?>
@@ -2299,12 +2299,12 @@ function wf_get_attachments($args) {
* @param [string] $current_span CSS span class around current page number (set to blank to remove span). [page-counter-current]
* @param [string] $total_span CSS span class around total page number (set to blank to remove span). [page-counter-total]
* @param [string] $always_show No output is shown if there is only 1 page of results, setting to 'Y' to always show (ie page 1 of 1). Y/N [N]
* @param [string] $navigation Display next and previous navigation either side of the page display. Y/N [N]
* @param [string] $navigation Display next and previous navigation either side of the page display. Y/N [Y]
* @param [string] $nav_span CSS span class around totalnavigation links (set to blank to remove span). Y/N [page-counter-navigation]
* @param [string] $previous Text for previous link. [&lt; ]
* @param [string] $next Text for next link. Y/N [ &gt;]
* @param [string] $div Wrap output in containing <div>. Y/N [Y]
* @param [string] $div_class Containing <div> class if used. [row page-counter]
* @param [string] $div_class Containing <div> class if used. [container page-counter]
*
* @todo Review code, make smarter!
* @todo Extend with wp_link_pages() type functionality so it can function with paged single pages, not just query lists.
@@ -2319,12 +2319,12 @@ function wf_page_counter($args) {
'current_span' => 'page-counter-current',
'total_span' => 'page-counter-total',
'always_show' => 'N',
'navigation' => 'N',
'navigation' => 'Y',
'nav_span' => 'page-counter-navigation',
'previous' => '&lt; ',
'next' => ' &gt;',
'div' => 'Y',
'div_class' => 'row page-counter'
'div_class' => 'container page-counter'
);
// Dont show navigation if this is a single post

1 comment on commit aa3593c

@Jonnyauk

This comment has been minimized.

Show comment
Hide comment
@Jonnyauk

Jonnyauk Jun 27, 2018

Owner

Example code to remove all Wonderflux pagination in your theme:

 *
 * Remove Wonderflux auto-pagination - we are doing something custom instead thanks!
 *
 */
add_filter('get_header', 'mywfx_remove_core_pagination' );
function mywfx_remove_core_pagination() {
	remove_action( 'wfmain_after_archive_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_search_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_taxonomy_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_tag_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_date_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_category_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_search_container', 'wfx_page_counter', 2 );
}
Owner

Jonnyauk commented on aa3593c Jun 27, 2018

Example code to remove all Wonderflux pagination in your theme:

 *
 * Remove Wonderflux auto-pagination - we are doing something custom instead thanks!
 *
 */
add_filter('get_header', 'mywfx_remove_core_pagination' );
function mywfx_remove_core_pagination() {
	remove_action( 'wfmain_after_archive_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_search_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_taxonomy_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_tag_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_date_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_category_container', 'wfx_page_counter', 2 );
	remove_action( 'wfmain_after_search_container', 'wfx_page_counter', 2 );
}
Please sign in to comment.