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 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.9.0 4.9.1 5.0.1 5.0.2 5.1.1 5.1.2 5.1.3 5.2.0 5.2.1 5.3.2 5.3.3.1 5.3.4 5.3.5 5.3.6 5.3.7
woocommerce-multilingual / inc / template-classes / store-urls / class-wcml-store-urls-ui.php
woocommerce-multilingual / inc / template-classes / store-urls Last commit date
class-wcml-store-urls-edit-base-ui.php 4 weeks ago class-wcml-store-urls-translation-statuses-ui.php 4 weeks ago class-wcml-store-urls-ui.php 4 weeks ago
class-wcml-store-urls-ui.php
148 lines
1 <?php
2
3 class WCML_Store_URLs_UI extends WCML_Templates_Factory {
4 private $woocommerce_wpml;
5 private $sitepress;
6 private $active_languages;
7
8 public function __construct( $woocommerce_wpml, $sitepress ) {
9 parent::__construct();
10
11 $this->woocommerce_wpml = $woocommerce_wpml;
12 $this->sitepress = $sitepress;
13 $this->active_languages = $this->sitepress->get_active_languages();
14 }
15
16 public function get_model() {
17
18 $model = [
19 'data' => [
20 'flags' => $this->woocommerce_wpml->products->get_translation_flags( $this->active_languages, false, false ),
21 ],
22 'shop_base' => [
23 'flag' => $this->sitepress->get_flag_url( $this->woocommerce_wpml->url_translation->get_source_slug_language( 'shop' ) ),
24 'orig_value' => urldecode( get_post( wc_get_page_id( 'shop' ) )->post_name ),
25 'statuses' => $this->get_base_translations_statuses( 'shop', $this->active_languages ),
26 ],
27 'product_base' => [
28 'flag' => $this->sitepress->get_flag_url( $this->woocommerce_wpml->url_translation->get_source_slug_language( 'product' ) ),
29 'orig_value' => $this->woocommerce_wpml->url_translation->get_woocommerce_product_base(),
30 'statuses' => $this->get_base_translations_statuses( 'product', $this->active_languages ),
31 ],
32 'cat_base' => [
33 'flag' => $this->sitepress->get_flag_url( $this->woocommerce_wpml->url_translation->get_source_slug_language( 'product_cat' ) ),
34 'orig_value' => ! empty( $this->woocommerce_wpml->url_translation->wc_permalinks['category_base'] ) ? trim( $this->woocommerce_wpml->url_translation->wc_permalinks['category_base'], '/' ) : 'product-category',
35 'statuses' => $this->get_base_translations_statuses( 'product_cat', $this->active_languages ),
36 ],
37 'tag_base' => [
38 'flag' => $this->sitepress->get_flag_url( $this->woocommerce_wpml->url_translation->get_source_slug_language( 'product_tag' ) ),
39 'orig_value' => ! empty( $this->woocommerce_wpml->url_translation->wc_permalinks['tag_base'] ) ? trim( $this->woocommerce_wpml->url_translation->wc_permalinks['tag_base'], '/' ) : 'product-tag',
40 'statuses' => $this->get_base_translations_statuses( 'product_tag', $this->active_languages ),
41 ],
42 'attr_base' => [
43 'flag' => $this->sitepress->get_flag_url( $this->woocommerce_wpml->url_translation->get_source_slug_language( 'attribute' ) ),
44 'orig_value' => trim( $this->woocommerce_wpml->url_translation->wc_permalinks['attribute_base'], '/' ),
45 'statuses' => $this->get_base_translations_statuses( 'attribute', $this->active_languages, $this->woocommerce_wpml->url_translation->wc_permalinks['attribute_base'] ),
46 ],
47 'endpoints_base' => $this->get_endpoint_info(),
48 'attribute_slugs' => $this->get_attribute_slugs_info(),
49 'strings' => [
50 'notice' => __( 'This page allows you to translate all strings that are being used by WooCommerce in building different type of urls. Translating them enables you to have fully localized urls that match the language of the pages.', 'woocommerce-multilingual' ),
51 'notice_defaults' => sprintf(
52 /* translators: %1$s/%2$s and %3$s/%4$s are opening and closing HTML link tags */
53 __(
54 'You can enter or edit your default values on the %1$sPermalinks settings%2$s page or, for the endpoints, on the WooCommerce %3$sAdvanced settings%4$s page.',
55 'woocommerce-multilingual'
56 ),
57 '<a href="' . admin_url( 'options-permalink.php' ) . '">',
58 '</a>',
59 '<a href="' . \WCML\Utilities\AdminUrl::getWooSettings( 'advanced' ) . '">',
60 '</a>'
61 ),
62 'perm_settings' => '<a href="' . admin_url( 'options-permalink.php' ) . '" >' . __( 'permalinks settings', 'woocommerce-multilingual' ) . '</a>',
63 'account_settings' => '<a href="' . \WCML\Utilities\AdminUrl::getWooSettings( 'account' ) . '" >' . __( 'Account settings', 'woocommerce-multilingual' ) . '</a>',
64 'slug_type' => __( 'Slug type', 'woocommerce-multilingual' ),
65 'orig_slug' => __( 'Original Slug', 'woocommerce-multilingual' ),
66 'shop' => __( 'Shop page', 'woocommerce-multilingual' ),
67 'product' => __( 'Product base', 'woocommerce-multilingual' ),
68 'category' => __( 'Product category base', 'woocommerce-multilingual' ),
69 'tag' => __( 'Product tag base', 'woocommerce-multilingual' ),
70 'attr' => __( 'Product attribute base', 'woocommerce-multilingual' ),
71 /* translators: %s is a slug */
72 'endpoint' => __( 'Endpoint: %s', 'woocommerce-multilingual' ),
73 /* translators: %s is a slug */
74 'attribute_slug' => __( 'Attribute slug: %s', 'woocommerce-multilingual' ),
75 ],
76 'nonces' => [
77 'edit_base' => wp_nonce_field( 'wcml_edit_base', 'wcml_edit_base_nonce', true, false ),
78 'update_base' => wp_nonce_field( 'wcml_update_base_translation', 'wcml_update_base_nonce', true, false ),
79 ],
80 ];
81
82 return $model;
83 }
84
85 public function get_endpoint_info() {
86 $query_vars = apply_filters( 'wcml_register_endpoints_store_urls', WC()->query->query_vars );
87 $is_original_slug = function( $endpoint, $endpointName ) {
88 return (bool) apply_filters( 'wpml_get_string_language', '', WCML_Endpoints::STRING_CONTEXT, $endpointName );
89 };
90 $filtered_query_vars = wpml_collect( $query_vars )->filter( $is_original_slug )->toArray();
91
92 $endpoints_info = [];
93 foreach ( $filtered_query_vars as $key => $endpoint ) {
94 $endpoints_info[ $key ]['key'] = $key;
95 $endpoints_info[ $key ]['orig_value'] = $endpoint;
96 $endpoints_info[ $key ]['flag'] = $this->sitepress->get_flag_url( $this->woocommerce_wpml->strings->get_string_language( $endpoint, WCML_Endpoints::STRING_CONTEXT, $key ) );
97 $endpoints_info[ $key ]['statuses'] = $this->get_base_translations_statuses( $key, $this->active_languages, $endpoint );
98 }
99
100 return $endpoints_info;
101
102 }
103
104 private function get_attribute_slugs_info() {
105 $product_attributes = $this->woocommerce_wpml->attributes->get_translatable_attributes();
106
107 $attributes_info = [];
108 foreach ( $product_attributes as $attribute ) {
109
110 if ( $attribute->attribute_public ) {
111 $language = $this->woocommerce_wpml->strings->get_string_language(
112 $attribute->attribute_name,
113 $this->woocommerce_wpml->url_translation->url_strings_context(),
114 $this->woocommerce_wpml->url_translation->url_string_name( 'attribute_slug', $attribute->attribute_name )
115 );
116
117 $attributes_info[ $attribute->attribute_name ] = [
118 'label' => $attribute->attribute_label,
119 'orig_value' => $attribute->attribute_name,
120 'flag' => $this->sitepress->get_flag_url( $language ),
121 'statuses' => $this->get_base_translations_statuses( 'attribute_slug-' . $attribute->attribute_name, $this->active_languages, $attribute->attribute_name ),
122 ];
123
124 }
125 }
126
127 return $attributes_info;
128 }
129
130 public function get_base_translations_statuses( $base, $active_languages, $value = true ) {
131
132 $statuses = new WCML_Store_URLs_Translation_Statuses_UI( $base, $active_languages, $value, $this->woocommerce_wpml, $this->sitepress );
133
134 return $statuses->get_view();
135
136 }
137
138 public function init_template_base_dir() {
139 $this->template_paths = [
140 WCML_PLUGIN_PATH . '/templates/store-urls/',
141 ];
142 }
143
144 public function get_template() {
145 return 'store-urls.twig';
146 }
147 }
148