编辑WordPress中的WooCommerce默认警报措辞

8ehkhllq  于 9个月前  发布在  WordPress
关注(0)|答案(1)|浏览(86)

是否有一个正确的,更新证明的方法来编辑默认系统警报和WooCommerce WordPress插件使用的赘言?(这个问题可能适用于所有WordPress插件,但WooCommerce是我现在特别关心的问题。
举个简单的例子,假设我想将“您的密码已成功重置”更改为“您的密码已设置”。当前的措辞是特定于WooCommerce的,存在于以下两个文件中:
1./wp-content/plugins/woocommerce/i18n/languages/woocommerce.pot

  1. /wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-my-account.php
    如果我把我的编辑硬编码到第二个文件中,它可以工作,但在更新插件时会有被覆盖的风险。有没有一种正确的方法可以防止更新?
mtb9vblg

mtb9vblg1#

对于通知,您可以使用woocommerce_add_notice过滤器。

function custom_reset_password_confirmation_message( $message, $notice_type ) {
    // Check if it's the password reset notice
    if ( 'success' === $notice_type && ! empty( $_GET['password-reset'] ) ) {
        // Modify the password reset success message
        $message = __( 'Your password has been set.', 'your-text-domain' );
    }

    return $message;
}

add_filter( 'woocommerce_add_notice', 'custom_reset_password_confirmation_message', 10, 2 );

字符串

相关问题