更改父母主题功能

时间:2016-02-03 22:20:47

标签: php wordpress wordpress-plugin wordpress-theming

我需要更改的是__( 'Expiry (MM/YY)', 'woocommerce' )Expiration Date 我试过创建一个文件,看看它是否覆盖了父主题/wp-content/themes/customizr-child/woocommerce/includes/abstracts/abstract-wc-payment-gateway.php但是没有用。

public function credit_card_form( $args = array(), $fields = array() ) {

    wp_enqueue_script( 'wc-credit-card-form' );

        ...

    <label for="' . esc_attr( $this->id ) . '-card-expiry">' . __( 'Expiry (MM/YY)', 'woocommerce' ) . ' <span class="required">*</span></label>

        ...
    );
}

如何在不对插件本身进行硬编码的情况下更改插件功能(仅限msg)

1 个答案:

答案 0 :(得分:0)

您可以使用gettext过滤器将字符串翻译为文本域。

function __text_string_translate( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Expiry (MM/YY)' :
        $translated_text = __( 'Expiration Date', 'woocommerce' );
        break;
    }
    return $translated_text;
}
add_filter( 'gettext', '__text_string_translate', 20, 3 );
相关问题