将WooCommerce Checkout Manager DatePicker更改为Jalali

时间:2017-11-20 作者:iMohammadreza

WooCommerce Checkout Manager 插件将此用于日期选择器:

// DatePicker
    wp_enqueue_script( \'jquery-ui-datepicker\', array( \'jquery\' ) );
    wp_enqueue_script( \'jquery.ui.datepicker-fa\', plugins_url( \'includes/pickers/di18n/jquery.ui.datepicker-fa\'.\'.js\', WOOCCM_RELPATH ), array( \'jquery\' ) );


    wp_enqueue_style(\'jquery-style\', plugins_url( \'includes/pickers/jquery.ui.css\', WOOCCM_RELPATH ) );
我怎样才能用Jalali(Shamsi-波斯日历)日期选择器来代替它?

1 个回复
SO网友:bravokeyl

通过查看plugin code, 您有不同的选择:

正在根据以下代码选择日期选取器语言。

$current_language = ( defined( \'ICL_LANGUAGE_CODE\' ) ? ICL_LANGUAGE_CODE : apply_filters( \'wooccm_language_code\', false ) );
// DatePicker
wp_enqueue_script( \'jquery-ui-datepicker\', array( \'jquery\' ) );
if( defined( \'ICL_LANGUAGE_CODE\' ) || !empty( $current_language ) ) {
    // Check if WPML is in use or the WordPress Filter has been used
    if(
            (
                    function_exists( \'icl_register_string\' ) && 
                    ICL_LANGUAGE_CODE == $current_language && 
                    ICL_LANGUAGE_CODE !== \'en\'
            ) || 
            !empty( $current_language )
    ) {
            wp_enqueue_script( \'jquery.ui.datepicker-\'.$current_language, plugins_url( \'includes/pickers/di18n/jquery.ui.datepicker-\'.$current_language.\'.js\', WOOCCM_RELPATH ), array( \'jquery\' ) );
    }
}
定义ICL_LANGUAGE_CODE 使用所需的语言区域设置(您可以找到支持的区域设置here)使用wooccm_language_code 过滤器挂钩如果ICL_LANGUAGE_CODE 未定义,否则退出队列-fa 编写自己的脚本并将其排队

结束