setAttribute( 'onclick', $on_click ); } if ( ! $link && $div ) { $div->setAttribute( 'onclick', $on_click ); } $html = $dom->saveHTML(); } // Icon. if ( $on_click && $html && $link === null ) { $dom = dom( $html ); $figure = get_dom_element( 'figure', $dom ); $img = get_dom_element( 'img', $figure ); if ( $img && ! str_contains( $figure->getAttribute( 'class' ), 'wp-block-post-featured-image' ) ) { $img->setAttribute( 'onclick', $on_click ); } $html = $dom->saveHTML(); } return $html; } /** * Formats inline JS. * * @since 1.2.9 * * @param string $js JS. * * @return string */ function format_inline_js( string $js ): string { $js = str_replace( '"', "'", $js ); $js = trim( rtrim( $js, ';' ) ); $js = reduce_whitespace( $js ); $js = remove_line_breaks( $js ); return $js; }