currency-switcher
3 weeks ago
multi-currency
3 weeks ago
setup
3 weeks ago
status
3 weeks ago
store-urls
3 weeks ago
class-wcml-currencies-dropdown-ui.php
5 years ago
class-wcml-custom-files-ui.php
3 weeks ago
class-wcml-languages-upgrade-notice.php
4 years ago
class-wcml-menus-wrap-base.php
3 weeks ago
class-wcml-menus-wrap.php
3 weeks ago
class-wcml-multilingual-ui.php
9 months ago
class-wcml-not-translatable-attributes.php
3 weeks ago
class-wcml-pointer-ui.php
1 year ago
class-wcml-removed-cart-items-ui.php
3 weeks ago
class-wcml-settings-ui.php
3 weeks ago
class-wcml-st-taxonomy-ui.php
11 months ago
class-wcml-sync-taxonomy.php
3 weeks ago
class-wcml-templates-factory.php
3 weeks ago
class-wcml-troubleshooting-ui.php
3 weeks ago
class-wcml-settings-ui.php
166 lines
| 1 | <?php |
| 2 | |
| 3 | use WPML\Core\Twig_SimpleFunction; |
| 4 | |
| 5 | class WCML_Settings_UI extends WCML_Templates_Factory { |
| 6 | |
| 7 | private $woocommerce_wpml; |
| 8 | private $sitepress; |
| 9 | |
| 10 | public function __construct( woocommerce_wpml $woocommerce_wpml, \WPML\Core\ISitePress $sitepress ) { |
| 11 | |
| 12 | $functions = [ |
| 13 | new Twig_SimpleFunction( 'wp_do_action', [ $this, 'wp_do_action' ] ), |
| 14 | ]; |
| 15 | |
| 16 | parent::__construct( $functions ); |
| 17 | |
| 18 | $this->woocommerce_wpml = $woocommerce_wpml; |
| 19 | $this->sitepress = $sitepress; |
| 20 | } |
| 21 | |
| 22 | public function wp_do_action( $hook ) { |
| 23 | do_action( $hook ); |
| 24 | } |
| 25 | |
| 26 | public function get_model() { |
| 27 | |
| 28 | $model = [ |
| 29 | 'form' => [ |
| 30 | 'action' => $_SERVER['REQUEST_URI'], |
| 31 | |
| 32 | 'synchronization' => [ |
| 33 | 'heading' => __( 'Products Synchronization', 'woocommerce-multilingual' ), |
| 34 | 'tip' => __( 'Configure specific product properties that should be synced to translations.', 'woocommerce-multilingual' ), |
| 35 | 'sync_date' => [ |
| 36 | 'value' => $this->woocommerce_wpml->settings['products_sync_date'], |
| 37 | 'label' => __( 'Sync publishing date for translated products.', 'woocommerce-multilingual' ), |
| 38 | ], |
| 39 | 'sync_order' => [ |
| 40 | 'value' => $this->woocommerce_wpml->settings['products_sync_order'], |
| 41 | 'label' => __( 'Sync products and product taxonomies order.', 'woocommerce-multilingual' ), |
| 42 | ], |
| 43 | ], |
| 44 | |
| 45 | 'media_synchronization' => [ |
| 46 | 'heading' => __( 'Products Media Synchronization', 'woocommerce-multilingual' ), |
| 47 | 'tip' => __( 'Configure thumbnail and gallery synchronization to translations.', 'woocommerce-multilingual' ), |
| 48 | 'sync_media' => [ |
| 49 | 'value' => $this->woocommerce_wpml->get_setting( 'sync_media', true ), |
| 50 | 'label' => __( 'Display original images on the translated product front page if images not specified', 'woocommerce-multilingual' ), |
| 51 | ], |
| 52 | ], |
| 53 | |
| 54 | 'file_sync' => [ |
| 55 | 'heading' => __( 'Products Download Files', 'woocommerce-multilingual' ), |
| 56 | 'tip' => __( |
| 57 | 'If you are using downloadable products, you can choose to have their paths |
| 58 | synchronized, or seperate for each language.', |
| 59 | 'woocommerce-multilingual' |
| 60 | ), |
| 61 | 'value' => $this->woocommerce_wpml->settings[ \WCML_Downloadable_Products::SYNC_MODE_SETTING_KEY ], |
| 62 | 'label_same' => __( 'Use the same files for translations', 'woocommerce-multilingual' ), |
| 63 | 'label_diff' => __( 'Add separate download files for translations when translating products', 'woocommerce-multilingual' ), |
| 64 | ], |
| 65 | |
| 66 | 'product_reviews' => [ |
| 67 | 'heading' => __( 'Product reviews', 'woocommerce-multilingual' ), |
| 68 | 'tip' => __( 'Define how to display product reviews on the product page by default. The customer will be still able to filter reviews by language.', 'woocommerce-multilingual' ), |
| 69 | 'reviews_in_all_languages' => [ |
| 70 | 'value' => $this->woocommerce_wpml->get_setting( 'reviews_in_all_languages', false ), |
| 71 | 'label' => __( 'By default, show reviews in all languages', 'woocommerce-multilingual' ), |
| 72 | ], |
| 73 | ], |
| 74 | |
| 75 | 'cart_sync' => [ |
| 76 | 'tip' => __( 'You can choose to clear the cart contents when you change language or currency in case you have problems in cart or checkout page', 'woocommerce-multilingual' ), |
| 77 | 'heading' => __( 'Cart', 'woocommerce-multilingual' ), |
| 78 | 'lang_switch' => [ |
| 79 | 'heading' => __( 'Switching languages when there are items in the cart', 'woocommerce-multilingual' ), |
| 80 | 'sync_label' => __( 'Synchronize cart content when switching languages', 'woocommerce-multilingual' ), |
| 81 | 'clear_label' => __( 'Prompt for a confirmation and reset the cart', 'woocommerce-multilingual' ), |
| 82 | 'value' => $this->woocommerce_wpml->settings['cart_sync']['lang_switch'], |
| 83 | ], |
| 84 | 'currency_switch' => [ |
| 85 | 'heading' => __( 'Switching currencies when there are items in the cart', 'woocommerce-multilingual' ), |
| 86 | 'sync_label' => __( 'Synchronize cart content when switching currencies', 'woocommerce-multilingual' ), |
| 87 | 'clear_label' => __( 'Prompt for a confirmation and reset the cart', 'woocommerce-multilingual' ), |
| 88 | 'value' => $this->woocommerce_wpml->settings['cart_sync']['currency_switch'], |
| 89 | ], |
| 90 | 'wpml_cookie_enabled' => $this->sitepress->get_setting( WPML_Cookie_Setting::COOKIE_SETTING_FIELD ), |
| 91 | 'cookie_not_enabled_message' => sprintf( |
| 92 | /* translators: %1$s and %2$s are opening and closing HTML link tags */ |
| 93 | __( |
| 94 | 'This feature was disabled. Please enable %1$sWPML cookies%2$s to continue.', |
| 95 | 'woocommerce-multilingual' |
| 96 | ), |
| 97 | '<a href="' . admin_url( 'admin.php?page=' . WPML_PLUGIN_FOLDER . '/menu/languages.php#cookie' ) . '" target="_blank">', |
| 98 | '</a>' |
| 99 | ), |
| 100 | 'doc_link' => sprintf( |
| 101 | /* translators: %1$s and %2$s are opening and closing HTML link tags */ |
| 102 | __( |
| 103 | 'Not sure which option to choose? Read about %1$spotential issues when switching languages and currencies while the cart has items%2$s.', |
| 104 | 'woocommerce-multilingual' |
| 105 | ), |
| 106 | '<a href="' . WCML_Tracking_Link::getWcmlClearCartDoc() . '" target="_blank">', |
| 107 | '</a>' |
| 108 | ), |
| 109 | ], |
| 110 | |
| 111 | 'nonce' => wp_nonce_field( 'wcml_save_settings_nonce', 'wcml_nonce', true, false ), |
| 112 | 'save_label' => __( 'Save changes', 'woocommerce-multilingual' ), |
| 113 | |
| 114 | ], |
| 115 | |
| 116 | 'native_translation' => WCML_TRANSLATION_METHOD_MANUAL, |
| 117 | 'wpml_translation' => WCML_TRANSLATION_METHOD_EDITOR, |
| 118 | |
| 119 | 'wcml_cart_sync' => WCML_CART_SYNC, |
| 120 | 'wcml_cart_clear' => WCML_CART_CLEAR, |
| 121 | |
| 122 | 'troubleshooting' => [ |
| 123 | 'url' => \WCML\Utilities\AdminUrl::getTroubleshootingTab(), |
| 124 | 'label' => __( 'Troubleshooting', 'woocommerce-multilingual' ), |
| 125 | ], |
| 126 | ]; |
| 127 | |
| 128 | if ( $this->woocommerce_wpml->is_wpml_prior_4_2() ) { |
| 129 | $model['form']['translation_interface'] = [ |
| 130 | 'heading' => __( 'Product Translation Interface', 'woocommerce-multilingual' ), |
| 131 | 'tip' => __( |
| 132 | 'The recommended way is using the WPML Translation Editor. It is streamlined for making the translation process much easier while also providing a much better integration with various WooCommerce extensions.', |
| 133 | 'woocommerce-multilingual' |
| 134 | ), |
| 135 | 'wcml' => [ |
| 136 | 'label' => __( 'WPML Translation Editor', 'woocommerce-multilingual' ), |
| 137 | |
| 138 | ], |
| 139 | 'native' => [ |
| 140 | 'label' => __( 'Native WooCommerce product editing screen', 'woocommerce-multilingual' ), |
| 141 | |
| 142 | ], |
| 143 | 'controls_value' => $this->woocommerce_wpml->settings['trnsl_interface'], |
| 144 | 'pb_warning' => __( "If you are using a page builder to design WooCommerce products, you should only use WPML's Translation Editor.", 'woocommerce-multilingual' ), |
| 145 | 'pb_warning_ok_button' => __( 'OK (translate with the WordPress editor)', 'woocommerce-multilingual' ), |
| 146 | 'pb_warning_cancel_button' => __( 'Cancel (stay with the Translation Editor)', 'woocommerce-multilingual' ), |
| 147 | ]; |
| 148 | } |
| 149 | |
| 150 | return $model; |
| 151 | |
| 152 | } |
| 153 | |
| 154 | protected function init_template_base_dir() { |
| 155 | $this->template_paths = [ |
| 156 | WCML_PLUGIN_PATH . '/templates/', |
| 157 | ]; |
| 158 | } |
| 159 | |
| 160 | public function get_template() { |
| 161 | return 'settings-ui.twig'; |
| 162 | } |
| 163 | |
| 164 | |
| 165 | } |
| 166 |