getAttribute( 'class' ) ); unset( $classes[ array_search( 'has-animation', $classes, true ) ] ); $classes[] = 'will-animate'; if ( $event === 'enter-infinite' ) { $classes[] = 'has-enter-infinite'; } $first->setAttribute( 'class', implode( ' ', $classes ) ); $styles = css_string_to_array( $first->getAttribute( 'style' ) ); $first->setAttribute( 'style', css_array_to_string( $styles ) ); $content = $dom->saveHTML(); } $content = str_replace( ';animation-play-state:paused', '', $content ); return $content; } add_filter( 'blockify_inline_js', NS . 'add_animation_js', 10, 2 ); /** * Conditionally add animation JS. * * @since 0.9.10 * * @param string $js The inline JS. * @param string $content The block content. * * @return string */ function add_animation_js( string $js, string $content ): string { if ( str_contains( $content, ' will-animate' ) ) { $js .= file_get_contents( DIR . 'assets/js/animation.js' ); } return $js; }