Skip to content

Commit

Permalink
Merge pull request #72 from dd32/patch-1
Browse files Browse the repository at this point in the history
Avoid a PHP Warning when no posts exist on the current page
  • Loading branch information
mkaz committed May 26, 2020
2 parents 6f917cb + 5730ca5 commit 1bac886
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
// if not forcing the loading of assets check if the block
// is found and if no block skip loading assets
if ( ! $force_load ) {
if ( empty( $posts ) ) {
return;
}

$found_block = array_reduce( $posts, function($found, $post) {
return $found || has_block( 'code', $post );
}, false );
Expand Down

0 comments on commit 1bac886

Please sign in to comment.