currency-switcher
4 weeks ago
multi-currency
4 weeks ago
setup
4 weeks ago
status
4 weeks ago
store-urls
4 weeks ago
class-wcml-currencies-dropdown-ui.php
5 years ago
class-wcml-custom-files-ui.php
4 weeks ago
class-wcml-languages-upgrade-notice.php
4 years ago
class-wcml-menus-wrap-base.php
4 weeks ago
class-wcml-menus-wrap.php
4 weeks ago
class-wcml-multilingual-ui.php
9 months ago
class-wcml-not-translatable-attributes.php
4 weeks ago
class-wcml-pointer-ui.php
1 year ago
class-wcml-removed-cart-items-ui.php
4 weeks ago
class-wcml-settings-ui.php
4 weeks ago
class-wcml-st-taxonomy-ui.php
11 months ago
class-wcml-sync-taxonomy.php
4 weeks ago
class-wcml-templates-factory.php
4 weeks ago
class-wcml-troubleshooting-ui.php
4 weeks ago
class-wcml-not-translatable-attributes.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | class WCML_Not_Translatable_Attributes extends WCML_Templates_Factory { |
| 4 | |
| 5 | private $attr_id; |
| 6 | private $woocommerce_wpml; |
| 7 | |
| 8 | public function __construct( $attr_id, $woocommerce_wpml ) { |
| 9 | parent::__construct(); |
| 10 | |
| 11 | $this->attr_id = $attr_id; |
| 12 | $this->woocommerce_wpml = $woocommerce_wpml; |
| 13 | } |
| 14 | |
| 15 | public function get_model() { |
| 16 | |
| 17 | $model = [ |
| 18 | 'checked' => $this->is_translatable(), |
| 19 | 'edit_mode' => (bool) $this->attr_id, |
| 20 | 'strings' => [ |
| 21 | 'label' => __( 'Translatable?', 'woocommerce-multilingual' ), |
| 22 | 'description' => __( 'Enable this if you want to translate attribute values with WPML Multilingual & Multicurrency for WooCommerce', 'woocommerce-multilingual' ), |
| 23 | 'notice' => __( 'Existing translations and variations associated will be deleted.', 'woocommerce-multilingual' ), |
| 24 | ], |
| 25 | ]; |
| 26 | |
| 27 | return $model; |
| 28 | } |
| 29 | |
| 30 | public function is_translatable() { |
| 31 | global $wpdb; |
| 32 | |
| 33 | $attribute_to_edit = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'woocommerce_attribute_taxonomies WHERE attribute_id = %d', $this->attr_id ) ); |
| 34 | if ( $attribute_to_edit ) { |
| 35 | $att_name = wc_attribute_taxonomy_name( $attribute_to_edit->attribute_name ); |
| 36 | |
| 37 | $wcml_settings = $this->woocommerce_wpml->get_settings(); |
| 38 | |
| 39 | return $wcml_settings['attributes_settings'][ $att_name ] ?? true; |
| 40 | } |
| 41 | |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | public function init_template_base_dir() { |
| 46 | $this->template_paths = [ |
| 47 | WCML_PLUGIN_PATH . '/templates/', |
| 48 | ]; |
| 49 | } |
| 50 | |
| 51 | public function get_template() { |
| 52 | return 'trnsl-attributes.twig'; |
| 53 | } |
| 54 | } |
| 55 |