Automattic\WooCommerce\Blocks\BlockTypes

ProductGallery::inject_dialog()protectedWC 1.0

Inject dialog into the product gallery HTML.

Method of the class: ProductGallery{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->inject_dialog( $gallery_html, $dialog_html );
$gallery_html(string) (required)
The gallery HTML.
$dialog_html(string) (required)
The dialog HTML.

ProductGallery::inject_dialog() code WC 9.4.2

protected function inject_dialog( $gallery_html, $dialog_html ) {

	// Find the position of the last </div>.
	$pos = strrpos( $gallery_html, '</div>' );

	if ( false !== $pos ) {
		// Inject the dialog_html at the correct position.
		$html = substr_replace( $gallery_html, $dialog_html, $pos, 0 );

		return $html;
	}
}