Automattic\WooCommerce\Blocks\BlockTypes

ProductSummary::get_first_paragraphprivateWC 1.0

Get first paragraph from some HTML text, or return the whole string.

Method of the class: ProductSummary{}

No Hooks.

Returns

String. First paragraph found in string.

Usage

// private - for code of main (parent) class only
$result = $this->get_first_paragraph( $source );
$source(string) (required)
Source text.

ProductSummary::get_first_paragraph() code WC 9.9.4

private function get_first_paragraph( $source ) {
	$p_index = strpos( $source, '</p>' );

	if ( false === $p_index ) {
		return $source;
	}

	return substr( $source, 0, $p_index + 4 );
}