$value ) { $p->setAttribute( "data-$attribute", (string) $value ); } $p->textContent = trim( $p->textContent ); $content = $dom->saveHTML(); return $content; } add_filter( 'blockify_inline_js', NS . 'add_counter_js', 10, 2 ); /** * Conditionally add counter JS. * * @since 0.9.10 * * @param string $js Inline js. * @param string $content Block html content. * * @return string */ function add_counter_js( string $js, string $content ): string { if ( str_contains( $content, 'is-style-counter' ) ) { $js .= file_get_contents( DIR . 'assets/js/counter.js' ); } return $js; }