Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
implements #339 by translating store notice
Browse files Browse the repository at this point in the history
store notice is added to Strings translations under the WooCommerce
Privacy section
  • Loading branch information
Jon007 committed Jun 3, 2018
1 parent d959282 commit 244aacf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Hyyan/WPI/Privacy.php
Expand Up @@ -22,6 +22,7 @@ public function __construct()
{
$this->registerPrivacyStrings();
add_filter('woocommerce_get_privacy_policy_text', array($this, 'translatePrivacyPolicyText'), 10, 2);
add_filter( 'woocommerce_demo_store', array( $this, 'translateDemoStoreNotice' ), 10, 2 );
}

/**
Expand All @@ -32,6 +33,7 @@ public function registerPrivacyStrings()
{
$this->registerString('woocommerce_checkout_privacy_policy_text', get_option('woocommerce_checkout_privacy_policy_text', sprintf(__('Your personal data will be used to process your order, support your experience throughout this website, and for other purposes described in our %s.', 'woocommerce'), '[privacy_policy]')));
$this->registerString('woocommerce_registration_privacy_policy_text', get_option('woocommerce_registration_privacy_policy_text', sprintf(__('Your personal data will be used to support your experience throughout this website, to manage access to your account, and for other purposes described in our %s.', 'woocommerce'), '[privacy_policy]')));
$this->registerString( 'woocommerce_store_notice', get_option( 'woocommerce_demo_store_notice' ) );
}


Expand Down Expand Up @@ -61,4 +63,15 @@ public function translatePrivacyPolicyText($text, $type)
return ($trans) ? $trans : $text;
}
}

public function translateDemoStoreNotice( $html, $notice ) {
$trans = '';
if ( function_exists( 'pll_register_string' ) ) {
$trans = pll__( $notice );
return '<p class="woocommerce-store-notice demo_store">' . wp_kses_post( $trans ) . ' <a href="#" class="woocommerce-store-notice__dismiss-link">' . esc_html__( 'Dismiss', 'woocommerce' ) . '</a></p>';
} else {
return $html;
}
}

}

0 comments on commit 244aacf

Please sign in to comment.