manifest
8 years ago
settings
8 years ago
shipment
8 years ago
views
8 years ago
wpdesk
8 years ago
admin-notices.php
8 years ago
bulk-actions.php
8 years ago
flexible-shipping-export.php
8 years ago
flexible-shipping-factory.php
8 years ago
flexible-shipping-plugin.php
8 years ago
multicurrency.php
8 years ago
multilingual.php
8 years ago
order-add-shipping.php
8 years ago
shipping-method-info.php
8 years ago
shipping-method.php
8 years ago
tracker.php
8 years ago
multilingual.php
81 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } // Exit if accessed directly |
| 6 | |
| 7 | if ( ! class_exists( 'WPDesk_Flexible_Shipping_Multilingual' ) ) { |
| 8 | |
| 9 | class WPDesk_Flexible_Shipping_Multilingual { |
| 10 | |
| 11 | /** |
| 12 | * @var WPDesk_Flexible_Shipping_Plugin |
| 13 | */ |
| 14 | private $plugin; |
| 15 | |
| 16 | /** |
| 17 | * WPDesk_Flexible_Shipping_Export constructor. |
| 18 | * |
| 19 | * @param WPDesk_Flexible_Shipping_Plugin $plugin |
| 20 | */ |
| 21 | public function __construct( WPDesk_Flexible_Shipping_Plugin $plugin ) { |
| 22 | $this->plugin = $plugin; |
| 23 | $this->hooks(); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * |
| 28 | */ |
| 29 | private function hooks() { |
| 30 | add_action( 'init', array( $this, 'init_polylang') ); |
| 31 | add_action( 'admin_init', array( $this, 'init_wpml') ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * |
| 36 | */ |
| 37 | public function init_polylang() { |
| 38 | if ( function_exists( 'pll_register_string' ) ) { |
| 39 | $all_shipping_methods = flexible_shipping_get_all_shipping_methods(); |
| 40 | $flexible_shipping = $all_shipping_methods['flexible_shipping']; |
| 41 | $flexible_shipping_rates = $flexible_shipping->get_all_rates(); |
| 42 | foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) { |
| 43 | if ( isset( $flexible_shipping_rate['method_title'] ) ) { |
| 44 | pll_register_string( $flexible_shipping_rate['method_title'], $flexible_shipping_rate['method_title'], __( 'Flexible Shipping', 'flexible-shipping' ) ); |
| 45 | } |
| 46 | if ( isset( $flexible_shipping_rate['method_description'] ) ) { |
| 47 | pll_register_string( $flexible_shipping_rate['method_description'], $flexible_shipping_rate['method_description'], __( 'Flexible Shipping', 'flexible-shipping' ) ); |
| 48 | } |
| 49 | if ( isset( $flexible_shipping_rate['method_free_shipping_label'] ) ) { |
| 50 | pll_register_string( $flexible_shipping_rate['method_free_shipping_label'], $flexible_shipping_rate['method_free_shipping_label'], __( 'Flexible Shipping', 'flexible-shipping' ) ); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * |
| 58 | */ |
| 59 | public function init_wpml() { |
| 60 | if ( function_exists( 'icl_register_string' ) ) { |
| 61 | $icl_language_code = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : get_bloginfo('language'); |
| 62 | $all_shipping_methods = flexible_shipping_get_all_shipping_methods(); |
| 63 | $flexible_shipping = $all_shipping_methods['flexible_shipping']; |
| 64 | $flexible_shipping_rates = $flexible_shipping->get_all_rates(); |
| 65 | foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) { |
| 66 | if ( isset( $flexible_shipping_rate['method_title'] ) ) { |
| 67 | icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_title'], $flexible_shipping_rate['method_title'], false, $icl_language_code ); |
| 68 | } |
| 69 | if ( isset( $flexible_shipping_rate['method_description'] ) ) { |
| 70 | icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_description'], $flexible_shipping_rate['method_description'], false, $icl_language_code ); |
| 71 | } |
| 72 | if ( isset( $flexible_shipping_rate['method_free_shipping_label'] ) ) { |
| 73 | icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_free_shipping_label'], $flexible_shipping_rate['method_free_shipping_label'], false, $icl_language_code ); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | } |
| 80 | |
| 81 | } |