Skip to content

Commit

Permalink
Make sure pagination is something we can foreach on before using it #230
Browse files Browse the repository at this point in the history
  • Loading branch information
cklosowski committed May 23, 2019
1 parent 2b24bff commit 5607a98
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions includes/compatibility/edd/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ function themedd_edd_downloads_pagination( $atts, $downloads, $query = array() )

if ( filter_var( $atts['pagination'], FILTER_VALIDATE_BOOLEAN ) ) :

$pagination = false;

if ( is_single() ) {
$pagination = paginate_links( apply_filters( 'edd_download_pagination_args', array(
'base' => get_permalink() . '%#%',
Expand All @@ -231,11 +229,11 @@ function themedd_edd_downloads_pagination( $atts, $downloads, $query = array() )
), $atts, $downloads, $query ) );
}

if ( ! empty( $pagination ) ) : ?>
if ( ( is_object( $pagination ) || is_array( $pagination ) ) && ! empty( $pagination ) ) : ?>
<nav aria-label="<?php _e( 'Product navigation', 'themedd' ); ?>" class="navigation">
<ul class="pagination justify-content-center mt-5">
<?php foreach ( $pagination as $page ) :
$page = str_replace( 'page-numbers', 'page-link', $page );
$page = str_replace( 'page-numbers', 'page-link', $page );
$active = strpos( $page, 'current' ) !== false ? ' active' : '';
?>
<li class="page-item<?php echo $active; ?>"><?php echo $page; ?></li>
Expand Down

0 comments on commit 5607a98

Please sign in to comment.