logger
2 weeks ago
settings
2 weeks ago
views
2 weeks ago
class-shortcode-unit-dimension.php
2 weeks ago
class-shortcode-unit-weight.php
2 weeks ago
class-wpdesk-flexible-shipping-multilingual.php
2 weeks ago
flexible-shipping-settings.php
2 weeks ago
order-item-meta.php
2 weeks ago
shipping-method.php
2 weeks ago
class-wpdesk-flexible-shipping-multilingual.php
90 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class WPDesk_Flexible_Shipping_Multilingual |
| 4 | * |
| 5 | * @package Flexible Shipping |
| 6 | */ |
| 7 | |
| 8 | use WPDesk\FS\TableRate\FreeShipping\NoticeTextSettings; |
| 9 | |
| 10 | /** |
| 11 | * Handles multilingual. |
| 12 | */ |
| 13 | class WPDesk_Flexible_Shipping_Multilingual { |
| 14 | |
| 15 | /** |
| 16 | * @var Flexible_Shipping_Plugin |
| 17 | */ |
| 18 | private $plugin; |
| 19 | |
| 20 | /** |
| 21 | * WPDesk_Flexible_Shipping_Multilingual constructor. |
| 22 | * |
| 23 | * @param Flexible_Shipping_Plugin $plugin . |
| 24 | */ |
| 25 | public function __construct( Flexible_Shipping_Plugin $plugin ) { |
| 26 | $this->plugin = $plugin; |
| 27 | $this->hooks(); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * . |
| 32 | */ |
| 33 | private function hooks() { |
| 34 | add_action( 'woocommerce_init', [ $this, 'init_polylang' ] ); |
| 35 | add_action( 'admin_init', [ $this, 'init_wpml' ] ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * . |
| 40 | */ |
| 41 | public function init_polylang() { |
| 42 | if ( function_exists( 'pll_register_string' ) ) { |
| 43 | $all_shipping_methods = flexible_shipping_get_all_shipping_methods(); |
| 44 | $flexible_shipping = $all_shipping_methods['flexible_shipping']; |
| 45 | $flexible_shipping_rates = $flexible_shipping->get_all_rates(); |
| 46 | foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) { |
| 47 | if ( isset( $flexible_shipping_rate['method_title'] ) ) { |
| 48 | pll_register_string( $flexible_shipping_rate['method_title'], $flexible_shipping_rate['method_title'], __( 'Flexible Shipping', 'flexible-shipping' ) ); |
| 49 | } |
| 50 | if ( isset( $flexible_shipping_rate['method_description'] ) ) { |
| 51 | pll_register_string( $flexible_shipping_rate['method_description'], $flexible_shipping_rate['method_description'], __( 'Flexible Shipping', 'flexible-shipping' ) ); |
| 52 | } |
| 53 | if ( isset( $flexible_shipping_rate['method_free_shipping_label'] ) ) { |
| 54 | pll_register_string( $flexible_shipping_rate['method_free_shipping_label'], $flexible_shipping_rate['method_free_shipping_label'], __( 'Flexible Shipping', 'flexible-shipping' ) ); |
| 55 | } |
| 56 | if ( isset( $flexible_shipping_rate[ NoticeTextSettings::FIELD_NAME ] ) ) { |
| 57 | pll_register_string( $flexible_shipping_rate[ NoticeTextSettings::FIELD_NAME ], $flexible_shipping_rate[ NoticeTextSettings::FIELD_NAME ], __( 'Flexible Shipping', 'flexible-shipping' ) ); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * . |
| 65 | */ |
| 66 | public function init_wpml() { |
| 67 | if ( function_exists( 'icl_register_string' ) ) { |
| 68 | $icl_language_code = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : get_bloginfo( 'language' ); |
| 69 | $all_shipping_methods = flexible_shipping_get_all_shipping_methods(); |
| 70 | $flexible_shipping = $all_shipping_methods['flexible_shipping']; |
| 71 | $flexible_shipping_rates = $flexible_shipping->get_all_rates(); |
| 72 | foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) { |
| 73 | if ( isset( $flexible_shipping_rate['method_title'] ) ) { |
| 74 | icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_title'], $flexible_shipping_rate['method_title'], false, $icl_language_code ); |
| 75 | } |
| 76 | if ( isset( $flexible_shipping_rate['method_description'] ) ) { |
| 77 | icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_description'], $flexible_shipping_rate['method_description'], false, $icl_language_code ); |
| 78 | } |
| 79 | if ( isset( $flexible_shipping_rate['method_free_shipping_label'] ) ) { |
| 80 | icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_free_shipping_label'], $flexible_shipping_rate['method_free_shipping_label'], false, $icl_language_code ); |
| 81 | } |
| 82 | if ( isset( $flexible_shipping_rate[ NoticeTextSettings::FIELD_NAME ] ) ) { |
| 83 | icl_register_string( 'flexible-shipping', $flexible_shipping_rate[ NoticeTextSettings::FIELD_NAME ], $flexible_shipping_rate[ NoticeTextSettings::FIELD_NAME ], false, $icl_language_code ); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | } |
| 90 |