WC_Emails::replace_placeholders()publicWC 3.7.0

Replace placeholder text in strings.

Method of the class: WC_Emails{}

No Hooks.

Return

String. Email footer text with any replacements done.

Usage

$WC_Emails = new WC_Emails();
$WC_Emails->replace_placeholders( $string );
$string(string) (required)
Email footer text.

Changelog

Since 3.7.0 Introduced.

WC_Emails::replace_placeholders() code WC 9.7.1

public function replace_placeholders( $string ) {
	$domain = wp_parse_url( home_url(), PHP_URL_HOST );

	if ( FeaturesUtil::feature_is_enabled( 'email_improvements' ) ) {
		$string = str_replace(
			array(
				'{store_address}',
				'{store_email}',
			),
			array(
				$this->get_store_address(),
				$this->get_from_address(),
			),
			$string
		);
	}

	return str_replace(
		array(
			'{site_title}',
			'{site_address}',
			'{site_url}',
			'{woocommerce}',
			'{WooCommerce}',
		),
		array(
			$this->get_blogname(),
			$domain,
			$domain,
			'<a href="https://woocommerce.com">WooCommerce</a>',
			'<a href="https://woocommerce.com">WooCommerce</a>',
		),
		$string
	);
}