[英]How to change woocommerce Registration Successful text
當我在“帳戶”頁面上注冊時,收到一條消息:
“注冊成功!您將在帳戶獲得批准后收到通知。”
如何更改此文字?
我四處搜尋,但沒有人在搜尋,我感到很驚訝。
更新:
由於它是Wordpress的通知,並且大多數情況下都是使用sprintf()函數(部分文本+變量)生成的,因此您可以在這種情況下使用
stripos()
php函數檢查是否部分摘錄了該句子,方法如下:
add_filter( 'gettext', 'customizing_specific_text_in_woocommerce', 10, 2 );
function customizing_specific_text_in_woocommerce( $customized_text, $targeted_text, $domain )
{
// Set Here an extract of the text to replace:
$text_to_find = 'be notified upon approval of your account';
if ( stripos( strtolower( $targeted_text ), '$text_to_find' ) !== false && is_account_page() ) {
// Set here your replacement text.
$customized_text = __('My custom text goes here.', $domain);
}
return $customized_text;
}
您必須進行不同的嘗試才能使其正常工作...
這段文字無疑是您自定義主題的一部分,這就是為什么您在互聯網上找不到任何相關問題的原因。 您應該嘗試以這種方式使用WordPress gettext
過濾器掛鈎函數 (沒有任何保證,因為我無法真正測試它) :
add_filter( 'gettext', 'customizing_specific_text_in_woocommerce', 10, 2 );
function customizing_specific_text_in_woocommerce( $customized_text, $targeted_text, $domain )
{
// Set Here the text to replace:
$text_to_find = 'Registration successful! You will be notified upon approval of your account.';
if ( $text_to_find == $targeted_text && is_account_page() ) {
// Set here your replacement text.
$customized_text = __('My custom text goes here.', $domain);
}
return $customized_text;
}
這段代碼會出現在您活動的子主題(或主題)的function.php文件中,也可能會出現在任何插件文件中。
該文本當然是主題自定義,並且應位於您的主要活動父主題文件,woocommerce template文件夾或某些其他主題文件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.