Skip to content

Commit

Permalink
Ensure breakpoints is an array in render callback
Browse files Browse the repository at this point in the history
  • Loading branch information
roborourke committed Sep 5, 2024
1 parent 2fb892a commit e2d1b6f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lottie-lite.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@
* @return string The block content.
*/
add_filter( 'render_block', function( string $block_content, array $block ) : string {
if ( empty( $block['attrs']['lottie'] ) ) {
if ( empty( $block['attrs']['lottie'] ) || empty( $block['attrs']['lottie']['breakpoints'] ) ) {
return $block_content;
}

// Only enqueue if we have a lottie file.
wp_enqueue_script( 'lottie-lite' );

usort( $block['attrs']['lottie']['breakpoints'], function ( $a, $b ) {
usort( $block['attrs']['lottie']['breakpoints'] ?? [], function ( $a, $b ) {
return $a['minWidth'] <=> $b['minWidth'];
} );

Expand Down

0 comments on commit e2d1b6f

Please sign in to comment.