| @@ -1,20 +1,49 @@ | ||
| 1 | -<?php | |
| 2 | -/* | |
| 3 | - Functions that should be included first | |
| 4 | -*/ | |
| 5 | -function usces_filter_locale($locale){ | |
| 6 | - if( !is_admin() | |
| 7 | - || ( isset($_POST['action']) && isset($_POST['mode']) && 'order_item_ajax' == $_POST['action'] && in_array($_POST['mode'], array('completionMail', 'orderConfirmMail', 'changeConfirmMail', 'receiptConfirmMail', 'mitumoriConfirmMail', 'cancelConfirmMail', 'otherConfirmMail'))) | |
| 8 | - || ( isset($_REQUEST['order_action']) && 'pdfout' == $_REQUEST['order_action'] ) | |
| 9 | - ){ | |
| 10 | - $usces_options = get_option('usces'); | |
| 11 | - if( isset($usces_options['system']['front_lang']) && !empty($usces_options['system']['front_lang']) ){ | |
| 12 | - return $usces_options['system']['front_lang']; | |
| 13 | - }else{ | |
| 14 | - return $locale; | |
| 15 | - } | |
| 16 | - }else{ | |
| 17 | - return $locale; | |
| 18 | - } | |
| 19 | -} | |
| 20 | -?> | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Functions that should be included first | |
| 4 | + * | |
| 5 | + * @package Welcart | |
| 6 | + */ | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Locale | |
| 10 | + * | |
| 11 | + * @param string $locale Locale. | |
| 12 | + * @return string | |
| 13 | + */ | |
| 14 | +function usces_filter_locale( $locale ) { | |
| 15 | + $mode = array( | |
| 16 | + 'completionMail', | |
| 17 | + 'orderConfirmMail', | |
| 18 | + 'changeConfirmMail', | |
| 19 | + 'receiptConfirmMail', | |
| 20 | + 'mitumoriConfirmMail', | |
| 21 | + 'cancelConfirmMail', | |
| 22 | + 'otherConfirmMail', | |
| 23 | + ); | |
| 24 | + if ( ! is_admin() | |
| 25 | + || ( isset( $_POST['action'] ) && isset( $_POST['mode'] ) && 'order_item_ajax' == $_POST['action'] && in_array( $_POST['mode'], $mode ) ) | |
| 26 | + || ( isset( $_REQUEST['order_action'] ) && 'pdfout' == $_REQUEST['order_action'] ) | |
| 27 | + ) { | |
| 28 | + $usces_options = get_option( 'usces', array() ); | |
| 29 | + if ( isset( $usces_options['system']['front_lang'] ) && ! empty( $usces_options['system']['front_lang'] ) ) { | |
| 30 | + $locale = $usces_options['system']['front_lang']; | |
| 31 | + } | |
| 32 | + } | |
| 33 | + return $locale; | |
| 34 | +} | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * Dual textdomain | |
| 38 | + */ | |
| 39 | +function usces_dual_textdomain() { | |
| 40 | + $locale = get_locale(); | |
| 41 | + $usces_options = get_option( 'usces', array() ); | |
| 42 | + if ( isset( $usces_options['system']['front_lang'] ) && ! empty( $usces_options['system']['front_lang'] ) ) { | |
| 43 | + $locale = $usces_options['system']['front_lang']; | |
| 44 | + } | |
| 45 | + if ( file_exists( USCES_PLUGIN_DIR . '/languages/usces-' . $locale . '.mo' ) ) { | |
| 46 | + load_textdomain( 'usces_dual', USCES_PLUGIN_DIR . '/languages/usces-' . $locale . '.mo' ); | |
| 47 | + } | |
| 48 | +} | |
| 49 | +add_action( 'usces_construct', 'usces_dual_textdomain' ); | |