Skip to content

Commit

Permalink
add filters (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesros161 authored Mar 20, 2023
1 parent 4f05e8a commit 5e9acec
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/includes/class-boldgrid-framework-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1512,4 +1512,54 @@ public function add_button_classes( $content ) {
$fixed_content = preg_replace( '/([a|li][^>]*class="[^"]*)button-secondary([^"]*")/', '$1button-secondary ' . $classes['button-secondary'] . '$2', $fixed_content );
return $fixed_content;
}

/**
* Pagination Filters
*
* Filters the wp_query statements for
* getting the 'next' and 'previous' posts.
*
* @since 2.19.1
*/
public function pagination_filters() {
add_filter(
'get_next_post_where',
function( $where, $in_same_term, $scluded_terms, $taxonomy, $post ) {
$where = str_replace( '>', '>=', $where );
$where = $where . ' AND p.ID > ' . $post->ID;
return $where;
},
10,
5
);

add_filter(
'get_next_post_sort',
function( $sort ) {
return 'ORDER BY p.post_date ASC, p.ID ASC LIMIT 1';
},
10,
1
);

add_filter(
'get_previous_post_where',
function( $where, $in_same_term, $scluded_terms, $taxonomy, $post ) {
$where = str_replace( '<', '<=', $where );
$where = $where . ' AND p.ID < ' . $post->ID;
return $where;
},
10,
5
);

add_filter(
'get_previous_post_sort',
function( $sort ) {
return 'ORDER BY p.post_date DESC, p.ID DESC LIMIT 1';
},
10,
1
);
}
}
3 changes: 3 additions & 0 deletions src/includes/class-boldgrid-framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ private function define_theme_hooks() {
$this->loader->add_filter( 'bgtfw_blog_page_title_classes', $boldgrid_theme, 'page_title_background_class' );
$this->loader->add_filter( 'bgtfw_archive_page_title_classes', $boldgrid_theme, 'page_title_background_class' );

// Pagination Filters
$this->loader->add_action( 'after_setup_theme', $boldgrid_theme, 'pagination_filters' );

// Title containers.
$this->loader->add_filter( 'bgtfw_page_header_wrapper_classes', $boldgrid_theme, 'title_container' );
$this->loader->add_filter( 'bgtfw_featured_image_classes', $boldgrid_theme, 'title_content_container' );
Expand Down

0 comments on commit 5e9acec

Please sign in to comment.