$value ) { $p->setAttribute( "data-$attribute", (string) $value ); } $p->textContent = trim( $p->textContent ); return $dom->saveHTML(); } 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 $html Block html content. * * @return string */ function add_counter_js( string $js, string $html ): string { if ( str_contains( $html, 'is-style-counter' ) ) { $js .= file_get_contents( get_dir() . 'assets/js/counter.js' ); } return $js; }