wc_replace_policy_page_link_placeholders( string $text )
Replaces placeholders with links to WooCommerce policy pages.
Description Description
Parameters Parameters
- $text
-
(Required) Text to find/replace within.
Return Return
(string)
Source Source
File: includes/wc-template-functions.php
function wc_replace_policy_page_link_placeholders( $text ) {
$privacy_page_id = wc_privacy_policy_page_id();
$terms_page_id = wc_terms_and_conditions_page_id();
$privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="woocommerce-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'woocommerce' ) . '</a>' : __( 'privacy policy', 'woocommerce' );
$terms_link = $terms_page_id ? '<a href="' . esc_url( get_permalink( $terms_page_id ) ) . '" class="woocommerce-terms-and-conditions-link" target="_blank">' . __( 'terms and conditions', 'woocommerce' ) . '</a>' : __( 'terms and conditions', 'woocommerce' );
$find_replace = array(
'[terms]' => $terms_link,
'[privacy_policy]' => $privacy_link,
);
return str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |