Polylang Connect for Elementor – Templates Translation & Language Switcher - Version 2.3.1

Version Description

  • Fix Widget initialization on Elementor 3.7
Download this release

Release Info

Developer pacotole
Plugin Icon 128x128 Polylang Connect for Elementor – Templates Translation & Language Switcher
Version 2.3.1
Comparing to
See all releases

Code changes from version 2.3.0 to 2.3.1

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: elementor, polylang, multilingual, language switcher, languages, templates
5
  Requires at least: 5.4
6
  Tested up to: 6.0
7
  Requires PHP: 5.6
8
- Stable tag: 2.3.0
9
  License: GPL-2.0-or-later
10
  License URI: https://opensource.org/licenses/GPL-2.0
11
 
@@ -197,6 +197,9 @@ There are quite a few:
197
 
198
  == Changelog ==
199
 
 
 
 
200
  = 2.3.0 =
201
  * Added dropdown controls to show on mouse hover and drop to up.
202
  * Added Elementor Kit translation support.
5
  Requires at least: 5.4
6
  Tested up to: 6.0
7
  Requires PHP: 5.6
8
+ Stable tag: 2.3.1
9
  License: GPL-2.0-or-later
10
  License URI: https://opensource.org/licenses/GPL-2.0
11
 
197
 
198
  == Changelog ==
199
 
200
+ = 2.3.1 =
201
+ * Fix Widget initialization on Elementor 3.7
202
+
203
  = 2.3.0 =
204
  * Added dropdown controls to show on mouse hover and drop to up.
205
  * Added Elementor Kit translation support.
connect-polylang-elementor.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
  /**
 
 
3
  * @package ConnectPolylangElementor
4
  * @license GPL-2.0-or-later
5
  * @link https://wordpress.org/plugins/connect-polylang-elementor/
@@ -8,7 +10,7 @@
8
  * Plugin Name: Polylang Connect for Elementor
9
  * Plugin URI: https://github.com/creame/connect-polylang-elementor
10
  * Description: Connect Polylang with Elementor. Display templates in the correct language, language switcher widget, language visibility conditions and dynamic tags.
11
- * Version: 2.3.0
12
  * Author: Creame
13
  * Author URI: https://crea.me/
14
  * License: GPL-2.0-or-later
@@ -23,6 +25,7 @@
23
  * Copyright (c) 2021 Paco Toledo - CREAME
24
  * Copyright (c) 2018-2021 David Decker - DECKERWEB
25
  */
 
26
  namespace ConnectPolylangElementor;
27
 
28
  defined( 'ABSPATH' ) || exit;
@@ -33,7 +36,7 @@ defined( 'ABSPATH' ) || exit;
33
  *
34
  * @since 2.0.0
35
  */
36
- define( 'CPEL_PLUGIN_VERSION', '2.3.0' );
37
  define( 'CPEL_FILE', __FILE__ );
38
  define( 'CPEL_DIR', plugin_dir_path( CPEL_FILE ) );
39
  define( 'CPEL_BASENAME', plugin_basename( CPEL_FILE ) );
@@ -46,10 +49,10 @@ define( 'CPEL_BASENAME', plugin_basename( CPEL_FILE ) );
46
  */
47
  spl_autoload_register(
48
  function ( $class ) {
49
- $prefix = __NAMESPACE__; // project-specific namespace prefix
50
- $base_dir = __DIR__ . '/includes'; // base directory for the namespace prefix
51
 
52
- // Does the class use the namespace prefix? No, move to the next registered autoloader
53
  $len = strlen( $prefix );
54
  if ( strncmp( $prefix, $class, $len ) !== 0 ) {
55
  return;
@@ -59,7 +62,7 @@ spl_autoload_register(
59
 
60
  // Replace the namespace prefix with the base directory, replace namespace
61
  // separators with directory separators in the relative class name,
62
- // append with .php and transform CamelCase to lower-dashed
63
  $file = str_replace( '\\', DIRECTORY_SEPARATOR, $relative_class_name );
64
  $file = strtolower( preg_replace( '/([a-zA-Z])(?=[A-Z])/', '$1-', $file ) );
65
  $path = $base_dir . $file . '.php';
@@ -149,8 +152,8 @@ function fix_cross_domain_assets( $url ) {
149
  // Is a multidomain configuration.
150
  if ( isset( $pll_options['force_lang'] ) && 3 === $pll_options['force_lang'] && ! empty( $pll_options['domains'] ) ) {
151
 
152
- $srv_host = parse_url( "//{$_SERVER['HTTP_HOST']}", PHP_URL_HOST );
153
- $url_host = parse_url( $url, PHP_URL_HOST );
154
 
155
  if ( $url_host ) {
156
  foreach ( $pll_options['domains'] as $domain ) {
1
  <?php
2
  /**
3
+ * Polylang Connect for Elementor
4
+ *
5
  * @package ConnectPolylangElementor
6
  * @license GPL-2.0-or-later
7
  * @link https://wordpress.org/plugins/connect-polylang-elementor/
10
  * Plugin Name: Polylang Connect for Elementor
11
  * Plugin URI: https://github.com/creame/connect-polylang-elementor
12
  * Description: Connect Polylang with Elementor. Display templates in the correct language, language switcher widget, language visibility conditions and dynamic tags.
13
+ * Version: 2.3.1
14
  * Author: Creame
15
  * Author URI: https://crea.me/
16
  * License: GPL-2.0-or-later
25
  * Copyright (c) 2021 Paco Toledo - CREAME
26
  * Copyright (c) 2018-2021 David Decker - DECKERWEB
27
  */
28
+
29
  namespace ConnectPolylangElementor;
30
 
31
  defined( 'ABSPATH' ) || exit;
36
  *
37
  * @since 2.0.0
38
  */
39
+ define( 'CPEL_PLUGIN_VERSION', '2.3.1' );
40
  define( 'CPEL_FILE', __FILE__ );
41
  define( 'CPEL_DIR', plugin_dir_path( CPEL_FILE ) );
42
  define( 'CPEL_BASENAME', plugin_basename( CPEL_FILE ) );
49
  */
50
  spl_autoload_register(
51
  function ( $class ) {
52
+ $prefix = __NAMESPACE__; // project-specific namespace prefix.
53
+ $base_dir = __DIR__ . '/includes'; // base directory for the namespace prefix.
54
 
55
+ // Does the class use the namespace prefix? No, move to the next registered autoloader.
56
  $len = strlen( $prefix );
57
  if ( strncmp( $prefix, $class, $len ) !== 0 ) {
58
  return;
62
 
63
  // Replace the namespace prefix with the base directory, replace namespace
64
  // separators with directory separators in the relative class name,
65
+ // append with .php and transform CamelCase to lower-dashed.
66
  $file = str_replace( '\\', DIRECTORY_SEPARATOR, $relative_class_name );
67
  $file = strtolower( preg_replace( '/([a-zA-Z])(?=[A-Z])/', '$1-', $file ) );
68
  $path = $base_dir . $file . '.php';
152
  // Is a multidomain configuration.
153
  if ( isset( $pll_options['force_lang'] ) && 3 === $pll_options['force_lang'] && ! empty( $pll_options['domains'] ) ) {
154
 
155
+ $srv_host = wp_parse_url( "//{$_SERVER['HTTP_HOST']}", PHP_URL_HOST );
156
+ $url_host = wp_parse_url( $url, PHP_URL_HOST );
157
 
158
  if ( $url_host ) {
159
  foreach ( $pll_options['domains'] as $domain ) {
includes/admin-extras.php CHANGED
@@ -32,7 +32,7 @@ class AdminExtras {
32
  * @param array $cpel_links (Default) Array of plugin action links.
33
  * @return strings $cpel_links Settings & Menu Admin links.
34
  */
35
- function custom_settings_links( $cpel_links ) {
36
 
37
  $link_polylang = '';
38
  $link_elementor = '';
@@ -76,8 +76,8 @@ class AdminExtras {
76
  return apply_filters(
77
  'cpel/filter/plugins_page/settings_links',
78
  $cpel_links,
79
- $link_polylang, // additional param
80
- $link_elementor // additional param
81
  );
82
 
83
  }
@@ -87,13 +87,13 @@ class AdminExtras {
87
  *
88
  * @since 1.0.0
89
  *
90
- * @param array $cpel_links (Default) Array of plugin meta links
91
- * @param string $cpel_file Path of base plugin file
92
  * @return array $cpel_links Array of plugin link strings to build HTML markup.
93
  */
94
- function plugin_links( $cpel_links, $cpel_file ) {
95
 
96
- if ( $cpel_file === CPEL_BASENAME ) {
97
 
98
  $cpel_links[] = '<a href="https://paypal.me/pacotole" title="Support this plugin\'s development">Donate</a>';
99
  $cpel_links[] = '<a href="mailto:wespeakcomputer@gmail.com" title="Request personal one on one training on using Polylang + Elementor">Personal one-on-one training</a>';
@@ -110,10 +110,10 @@ class AdminExtras {
110
  *
111
  * @since 2.0.3
112
  *
113
- * @param array $states
114
  * @return array
115
  */
116
- function elementor_post_state_icon( $states ) {
117
 
118
  if ( isset( $states['elementor'] ) && apply_filters( 'cpel/filter/elementor_icon', true ) ) {
119
  unset( $states['elementor'] );
32
  * @param array $cpel_links (Default) Array of plugin action links.
33
  * @return strings $cpel_links Settings & Menu Admin links.
34
  */
35
+ public function custom_settings_links( $cpel_links ) {
36
 
37
  $link_polylang = '';
38
  $link_elementor = '';
76
  return apply_filters(
77
  'cpel/filter/plugins_page/settings_links',
78
  $cpel_links,
79
+ $link_polylang, // additional param.
80
+ $link_elementor // additional param.
81
  );
82
 
83
  }
87
  *
88
  * @since 1.0.0
89
  *
90
+ * @param array $cpel_links (Default) Array of plugin meta links.
91
+ * @param string $cpel_file Path of base plugin file.
92
  * @return array $cpel_links Array of plugin link strings to build HTML markup.
93
  */
94
+ public function plugin_links( $cpel_links, $cpel_file ) {
95
 
96
+ if ( CPEL_BASENAME === $cpel_file ) {
97
 
98
  $cpel_links[] = '<a href="https://paypal.me/pacotole" title="Support this plugin\'s development">Donate</a>';
99
  $cpel_links[] = '<a href="mailto:wespeakcomputer@gmail.com" title="Request personal one on one training on using Polylang + Elementor">Personal one-on-one training</a>';
110
  *
111
  * @since 2.0.3
112
  *
113
+ * @param array $states list of states.
114
  * @return array
115
  */
116
+ public function elementor_post_state_icon( $states ) {
117
 
118
  if ( isset( $states['elementor'] ) && apply_filters( 'cpel/filter/elementor_icon', true ) ) {
119
  unset( $states['elementor'] );
includes/connect-plugins.php CHANGED
@@ -81,10 +81,10 @@ class ConnectPlugins {
81
  }
82
  }
83
 
84
- // Elementor editor menu links to translations
85
  add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'elementor_editor_script' ) );
86
 
87
- // Elementor Site Editor template tweaks
88
  add_filter( 'elementor-pro/site-editor/data/template', array( $this, 'elementor_site_editor_template' ) );
89
 
90
  }
@@ -96,8 +96,8 @@ class ConnectPlugins {
96
  *
97
  * @since 2.0.0
98
  *
99
- * @param array $types The list of post type names for which Polylang manages language and translations
100
- * @param bool $is_settings True when displaying the list in Polylang settings
101
  * @return array The list of post type names for which Polylang manages language and translations
102
  */
103
  public function add_polylang_post_types( $types, $is_settings ) {
@@ -105,16 +105,16 @@ class ConnectPlugins {
105
  $relevant_types = apply_filters(
106
  'cpel/filter/polylang/post_types',
107
  array(
108
- 'elementor_library', // Elementor
109
- 'e-landing-page', // Elementor Landing pages
110
- 'oceanwp_library', // OceanWP Library
111
- 'astra-advanced-hook', // Astra Custom Layouts (Astra Pro)
112
- 'gp_elements', // GeneratePress Elements (GP Premium)
113
- 'jet-theme-core', // JetThemeCore (Kava Pro/ CrocoBlock)
114
- 'jet-engine', // JetEngine Listing Item (CrocoBlock)
115
- 'customify_hook', // Customify (Customify Pro)
116
- 'wpbf_hooks', // Page Builder Framework Sections (WPBF Premium)
117
- 'ae_global_templates', // AnyWhere Elementor plugin
118
  )
119
  );
120
 
@@ -133,7 +133,8 @@ class ConnectPlugins {
133
  *
134
  * @since 2.0.0
135
  *
136
- * @param WP_Query $query
 
137
  */
138
  public function query_all_languages( $query ) {
139
 
@@ -147,7 +148,7 @@ class ConnectPlugins {
147
 
148
  $is_global_widget = isset( $query->query_vars['post_type'], $query->query_vars['meta_query'] )
149
  && 'elementor_library' === $query->query_vars['post_type']
150
- && in_array( $global_widget_meta_query, $query->query_vars['meta_query'] );
151
 
152
  if ( $is_elementor_conditions || $is_global_widget ) {
153
  $query->set( 'lang', '' );
@@ -160,9 +161,9 @@ class ConnectPlugins {
160
  *
161
  * @since 2.0.0
162
  *
163
- * @param mixed $null
164
- * @param int $post_id
165
- * @param string $meta_key
166
  * @return mixed null or empty array
167
  */
168
  public function elementor_conditions_empty_on_translations( $null, $post_id, $meta_key ) {
@@ -176,7 +177,7 @@ class ConnectPlugins {
176
  *
177
  * @since 2.0.0
178
  *
179
- * @param array $value array of theme builder conditions
180
  * @return array filtered array
181
  */
182
  public function theme_builder_conditions_remove_empty( $value ) {
@@ -196,9 +197,9 @@ class ConnectPlugins {
196
  *
197
  * @uses pll_get_post()
198
  *
199
- * @param mixed $false false or string with bypass output
200
- * @param string $tag shortcode tag
201
- * @param array $attr shortcode attributes
202
  * @return false|string false or string with bypass output
203
  */
204
  public function template_shortcode_translate( $false, $tag, $attr ) {
@@ -212,7 +213,7 @@ class ConnectPlugins {
212
  }
213
 
214
  // Translate post_id.
215
- $attr['id'] = pll_get_post( absint( $attr['id'] ) ) ?: $attr['id'];
216
  // Skip next call.
217
  $attr['skip'] = 1;
218
 
@@ -233,7 +234,7 @@ class ConnectPlugins {
233
  * @uses pll_get_post()
234
  * @uses pll_get_post_language()
235
  *
236
- * @param mixed $value Value of 'elementor_active_kit' option, the ID of current Elementor Kit
237
  * @return int The translation ID, or the original Elementor Kit ID
238
  */
239
  public function elementor_kit_translation( $value ) {
@@ -243,7 +244,7 @@ class ConnectPlugins {
243
  // Is API REST '/wp-json/elementor/v1/globals'.
244
  if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
245
  // Referrer is Elementor Editor?
246
- wp_parse_str( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_QUERY ), $query );
247
 
248
  if ( isset( $query['action'], $query['post'] ) && 'elementor' === $query['action'] ) {
249
  $translation = pll_get_post( $value, pll_get_post_language( intval( $query['post'] ) ) );
@@ -258,7 +259,7 @@ class ConnectPlugins {
258
 
259
  }
260
 
261
- return $translation ?: $value;
262
 
263
  }
264
 
@@ -271,13 +272,13 @@ class ConnectPlugins {
271
  *
272
  * @uses pll_get_post()
273
  *
274
- * @param int $post_id ID of the current post
275
  * @return string Based translation, the translation ID, or the original Post ID
276
  */
277
  public function template_id_translation( $post_id ) {
278
 
279
- $post_id = pll_get_post( $post_id ) ?: $post_id;
280
- $this->template_id = $post_id; // Save for check sub_id
281
 
282
  return $post_id;
283
 
@@ -294,21 +295,21 @@ class ConnectPlugins {
294
  * @uses pll_get_post()
295
  * @uses pll_get_term()
296
  *
297
- * @param int $sub_id ID of the object in subcondition
298
- * @param array $parsed_condition condition parts
299
  * @return int original sub ID or translated ID
300
  */
301
  public function condition_sub_id_translation( $sub_id, $parsed_condition ) {
302
 
303
  if ( $sub_id && cpel_is_translation( $this->template_id ) ) {
304
 
305
- if ( in_array( $parsed_condition['sub_name'], get_post_types() ) ) {
306
 
307
- $sub_id = pll_get_post( $sub_id ) ?: $sub_id;
308
 
309
  } else {
310
 
311
- $sub_id = pll_get_term( $sub_id ) ?: $sub_id;
312
 
313
  }
314
  }
@@ -399,7 +400,7 @@ class ConnectPlugins {
399
  $instances = $theme_builder->get_conditions_manager()->get_document_instances( $default_post );
400
 
401
  if ( empty( $instances ) ) {
402
- $instances = array( 'none' => esc_html__( 'None', 'elementor-pro' ) );
403
  }
404
 
405
  echo '<span style="opacity:.4">' . esc_html( implode( ', ', $instances ) ) . '</span><div class="hidden" aria-hidden="true">';
@@ -475,7 +476,7 @@ class ConnectPlugins {
475
  */
476
  public function home_url_language_dir_slash( $url, $path ) {
477
 
478
- return empty( $path ) && ! is_admin() && $url !== get_option( 'home' )
479
  && function_exists( 'PLL' ) && 1 === PLL()->options['force_lang'] ? trailingslashit( $url ) : $url;
480
 
481
  }
@@ -521,7 +522,7 @@ class ConnectPlugins {
521
  * @param Element_Base $element
522
  * @return void
523
  */
524
- function remove_search_form_home_url_filter( $element ) {
525
 
526
  if ( 'search-form' === $element->get_name() ) {
527
  remove_filter( 'home_url', array( $this, 'search_form_home_url_filter' ) );
@@ -542,7 +543,7 @@ class ConnectPlugins {
542
 
543
  global $typenow, $post;
544
 
545
- // If is post type translatable
546
  if ( pll_is_translated_post_type( $typenow ) ) {
547
 
548
  $languages = pll_languages_list( array( 'fields' => '' ) );
@@ -582,7 +583,7 @@ class ConnectPlugins {
582
  $items[] = array(
583
  'name' => "cpel-{$language->slug}",
584
  'icon' => 'eicon-plus',
585
- 'title' => sprintf( __( 'Add a translation in %s', 'polylang' ), $language->name ),
586
  'type' => 'link',
587
  'link' => $link,
588
  );
@@ -592,13 +593,13 @@ class ConnectPlugins {
592
 
593
  $group = array(
594
  'name' => 'cpel',
595
- 'title' => sprintf( __( 'This item is in %s', 'polylang' ), $current ),
596
  'items' => $items,
597
  );
598
 
599
  $script = 'jQuery(window).on("elementor:init", () => {
600
  window.elementor.on("panel:init", () => {
601
- setTimeout(() => { window.elementor.modules.layouts.panel.pages.menu.Menu.groups.add(' . json_encode( $group ) . '); });
602
  });
603
  });';
604
 
@@ -612,7 +613,7 @@ class ConnectPlugins {
612
  /**
613
  * Elementor Site Editor template changes
614
  *
615
- * at 2.0.0 named "elementor_theme_editor_title"
616
  *
617
  * @since 2.0.4
618
  *
@@ -636,13 +637,13 @@ class ConnectPlugins {
636
  $instances = $theme_builder->get_conditions_manager()->get_document_instances( $default_post );
637
 
638
  if ( empty( $instances ) ) {
639
- $instances = array( 'no_instances' => esc_html__( 'No instances', 'elementor-pro' ) );
640
  $is_active = false;
641
  } else {
642
  $is_active = 'publish' === $data['status'];
643
  }
644
 
645
- $data['instances'] = array( 'cpel' => sprintf( esc_html__( '(from %s)', 'connect-polylang-elementor' ), strtoupper( $language ) ) ) + $instances;
646
  $data['isActive'] = $is_active;
647
  }
648
 
@@ -653,14 +654,14 @@ class ConnectPlugins {
653
  /**
654
  * Fix url domain
655
  *
656
- * @param mixed $url
657
- * @param mixed $post_id
658
- * @return void
659
  */
660
  private function fix_url_domain( $url, $post_id ) {
661
 
662
- $current_host = parse_url( pll_current_language( 'home_url' ) ?: trailingslashit( "//{$_SERVER['HTTP_HOST']}" ), PHP_URL_HOST );
663
- $post_host = parse_url( pll_get_post_language( $post_id, 'home_url' ), PHP_URL_HOST );
664
 
665
  if ( $current_host !== $post_host ) {
666
  $url = str_replace( $current_host, $post_host, $url );
81
  }
82
  }
83
 
84
+ // Elementor editor menu links to translations.
85
  add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'elementor_editor_script' ) );
86
 
87
+ // Elementor Site Editor template tweaks.
88
  add_filter( 'elementor-pro/site-editor/data/template', array( $this, 'elementor_site_editor_template' ) );
89
 
90
  }
96
  *
97
  * @since 2.0.0
98
  *
99
+ * @param array $types The list of post type names for which Polylang manages language and translations.
100
+ * @param bool $is_settings True when displaying the list in Polylang settings.
101
  * @return array The list of post type names for which Polylang manages language and translations
102
  */
103
  public function add_polylang_post_types( $types, $is_settings ) {
105
  $relevant_types = apply_filters(
106
  'cpel/filter/polylang/post_types',
107
  array(
108
+ 'elementor_library', // Elementor.
109
+ 'e-landing-page', // Elementor Landing pages.
110
+ 'oceanwp_library', // OceanWP Library.
111
+ 'astra-advanced-hook', // Astra Custom Layouts (Astra Pro).
112
+ 'gp_elements', // GeneratePress Elements (GP Premium).
113
+ 'jet-theme-core', // JetThemeCore (Kava Pro/ CrocoBlock).
114
+ 'jet-engine', // JetEngine Listing Item (CrocoBlock).
115
+ 'customify_hook', // Customify (Customify Pro).
116
+ 'wpbf_hooks', // Page Builder Framework Sections (WPBF Premium).
117
+ 'ae_global_templates', // AnyWhere Elementor plugin.
118
  )
119
  );
120
 
133
  *
134
  * @since 2.0.0
135
  *
136
+ * @param WP_Query $query current query.
137
+ * @return void
138
  */
139
  public function query_all_languages( $query ) {
140
 
148
 
149
  $is_global_widget = isset( $query->query_vars['post_type'], $query->query_vars['meta_query'] )
150
  && 'elementor_library' === $query->query_vars['post_type']
151
+ && in_array( $global_widget_meta_query, $query->query_vars['meta_query'], true );
152
 
153
  if ( $is_elementor_conditions || $is_global_widget ) {
154
  $query->set( 'lang', '' );
161
  *
162
  * @since 2.0.0
163
  *
164
+ * @param mixed $null null for bypass.
165
+ * @param int $post_id current post ID.
166
+ * @param string $meta_key name of meta key.
167
  * @return mixed null or empty array
168
  */
169
  public function elementor_conditions_empty_on_translations( $null, $post_id, $meta_key ) {
177
  *
178
  * @since 2.0.0
179
  *
180
+ * @param array $value array of theme builder conditions.
181
  * @return array filtered array
182
  */
183
  public function theme_builder_conditions_remove_empty( $value ) {
197
  *
198
  * @uses pll_get_post()
199
  *
200
+ * @param mixed $false false or string with bypass output.
201
+ * @param string $tag shortcode tag.
202
+ * @param array $attr shortcode attributes.
203
  * @return false|string false or string with bypass output
204
  */
205
  public function template_shortcode_translate( $false, $tag, $attr ) {
213
  }
214
 
215
  // Translate post_id.
216
+ $attr['id'] = pll_get_post( absint( $attr['id'] ) ) ?: $attr['id']; //phpcs:ignore WordPress.PHP.DisallowShortTernary
217
  // Skip next call.
218
  $attr['skip'] = 1;
219
 
234
  * @uses pll_get_post()
235
  * @uses pll_get_post_language()
236
  *
237
+ * @param mixed $value Value of 'elementor_active_kit' option, the ID of current Elementor Kit.
238
  * @return int The translation ID, or the original Elementor Kit ID
239
  */
240
  public function elementor_kit_translation( $value ) {
244
  // Is API REST '/wp-json/elementor/v1/globals'.
245
  if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
246
  // Referrer is Elementor Editor?
247
+ wp_parse_str( wp_parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_QUERY ), $query );
248
 
249
  if ( isset( $query['action'], $query['post'] ) && 'elementor' === $query['action'] ) {
250
  $translation = pll_get_post( $value, pll_get_post_language( intval( $query['post'] ) ) );
259
 
260
  }
261
 
262
+ return $translation ? $translation : $value;
263
 
264
  }
265
 
272
  *
273
  * @uses pll_get_post()
274
  *
275
+ * @param int $post_id ID of the current post.
276
  * @return string Based translation, the translation ID, or the original Post ID
277
  */
278
  public function template_id_translation( $post_id ) {
279
 
280
+ $post_id = pll_get_post( $post_id ) ?: $post_id; //phpcs:ignore WordPress.PHP.DisallowShortTernary
281
+ $this->template_id = $post_id; // Save for check sub_id.
282
 
283
  return $post_id;
284
 
295
  * @uses pll_get_post()
296
  * @uses pll_get_term()
297
  *
298
+ * @param int $sub_id ID of the object in subcondition.
299
+ * @param array $parsed_condition condition parts.
300
  * @return int original sub ID or translated ID
301
  */
302
  public function condition_sub_id_translation( $sub_id, $parsed_condition ) {
303
 
304
  if ( $sub_id && cpel_is_translation( $this->template_id ) ) {
305
 
306
+ if ( in_array( $parsed_condition['sub_name'], get_post_types(), true ) ) {
307
 
308
+ $sub_id = pll_get_post( $sub_id ) ?: $sub_id; //phpcs:ignore WordPress.PHP.DisallowShortTernary
309
 
310
  } else {
311
 
312
+ $sub_id = pll_get_term( $sub_id ) ?: $sub_id; //phpcs:ignore WordPress.PHP.DisallowShortTernary
313
 
314
  }
315
  }
400
  $instances = $theme_builder->get_conditions_manager()->get_document_instances( $default_post );
401
 
402
  if ( empty( $instances ) ) {
403
+ $instances = array( 'none' => esc_html__( 'None', 'elementor-pro' ) ); // phpcs:ignore WordPress.WP.I18n
404
  }
405
 
406
  echo '<span style="opacity:.4">' . esc_html( implode( ', ', $instances ) ) . '</span><div class="hidden" aria-hidden="true">';
476
  */
477
  public function home_url_language_dir_slash( $url, $path ) {
478
 
479
+ return empty( $path ) && ! is_admin() && get_option( 'home' ) !== $url
480
  && function_exists( 'PLL' ) && 1 === PLL()->options['force_lang'] ? trailingslashit( $url ) : $url;
481
 
482
  }
522
  * @param Element_Base $element
523
  * @return void
524
  */
525
+ public function remove_search_form_home_url_filter( $element ) {
526
 
527
  if ( 'search-form' === $element->get_name() ) {
528
  remove_filter( 'home_url', array( $this, 'search_form_home_url_filter' ) );
543
 
544
  global $typenow, $post;
545
 
546
+ // If is post type translatable.
547
  if ( pll_is_translated_post_type( $typenow ) ) {
548
 
549
  $languages = pll_languages_list( array( 'fields' => '' ) );
583
  $items[] = array(
584
  'name' => "cpel-{$language->slug}",
585
  'icon' => 'eicon-plus',
586
+ 'title' => sprintf( __( 'Add a translation in %s', 'polylang' ), $language->name ), // phpcs:ignore WordPress.WP.I18n
587
  'type' => 'link',
588
  'link' => $link,
589
  );
593
 
594
  $group = array(
595
  'name' => 'cpel',
596
+ 'title' => sprintf( __( 'This item is in %s', 'polylang' ), $current ), // phpcs:ignore WordPress.WP.I18n
597
  'items' => $items,
598
  );
599
 
600
  $script = 'jQuery(window).on("elementor:init", () => {
601
  window.elementor.on("panel:init", () => {
602
+ setTimeout(() => { window.elementor.modules.layouts.panel.pages.menu.Menu.groups.add(' . wp_json_encode( $group ) . '); });
603
  });
604
  });';
605
 
613
  /**
614
  * Elementor Site Editor template changes
615
  *
616
+ * At 2.0.0 named "elementor_theme_editor_title"
617
  *
618
  * @since 2.0.4
619
  *
637
  $instances = $theme_builder->get_conditions_manager()->get_document_instances( $default_post );
638
 
639
  if ( empty( $instances ) ) {
640
+ $instances = array( 'no_instances' => esc_html__( 'No instances', 'elementor-pro' ) ); // phpcs:ignore WordPress.WP.I18n
641
  $is_active = false;
642
  } else {
643
  $is_active = 'publish' === $data['status'];
644
  }
645
 
646
+ $data['instances'] = array( 'cpel' => sprintf( esc_html__( '(from %s)', 'connect-polylang-elementor' ), strtoupper( $language ) ) ) + $instances; // phpcs:ignore WordPress.WP.I18n
647
  $data['isActive'] = $is_active;
648
  }
649
 
654
  /**
655
  * Fix url domain
656
  *
657
+ * @param mixed $url current url.
658
+ * @param mixed $post_id current post ID.
659
+ * @return string fixed domain url
660
  */
661
  private function fix_url_domain( $url, $post_id ) {
662
 
663
+ $current_host = wp_parse_url( pll_current_language( 'home_url' ) ?: trailingslashit( "//{$_SERVER['HTTP_HOST']}" ), PHP_URL_HOST ); //phpcs:ignore WordPress.PHP.DisallowShortTernary
664
+ $post_host = wp_parse_url( pll_get_post_language( $post_id, 'home_url' ), PHP_URL_HOST );
665
 
666
  if ( $current_host !== $post_host ) {
667
  $url = str_replace( $current_host, $post_host, $url );
includes/elementor-assets.php CHANGED
@@ -54,7 +54,7 @@ class ElementorAssets {
54
  }
55
 
56
  $languages = pll_the_languages( array( 'raw' => true ) );
57
- $server_host = parse_url( "//{$_SERVER['HTTP_HOST']}", PHP_URL_HOST );
58
 
59
  foreach ( $languages as $language ) {
60
  $this->all_domains[] = $language['url'];
@@ -173,8 +173,8 @@ class ElementorAssets {
173
  }
174
 
175
  $current_url = add_query_arg( $_SERVER['QUERY_STRING'], '', admin_url( 'post.php' ) );
176
- $server_host = parse_url( "//{$_SERVER['HTTP_HOST']}", PHP_URL_HOST );
177
- $post_host = parse_url( \pll_get_post_language( intval( $_GET['post'] ), 'home_url' ), PHP_URL_HOST );
178
 
179
  if ( $server_host !== $post_host ) {
180
  \wp_redirect( \str_replace( $server_host, $post_host, $current_url ) );
54
  }
55
 
56
  $languages = pll_the_languages( array( 'raw' => true ) );
57
+ $server_host = wp_parse_url( "//{$_SERVER['HTTP_HOST']}", PHP_URL_HOST );
58
 
59
  foreach ( $languages as $language ) {
60
  $this->all_domains[] = $language['url'];
173
  }
174
 
175
  $current_url = add_query_arg( $_SERVER['QUERY_STRING'], '', admin_url( 'post.php' ) );
176
+ $server_host = wp_parse_url( "//{$_SERVER['HTTP_HOST']}", PHP_URL_HOST );
177
+ $post_host = wp_parse_url( \pll_get_post_language( intval( $_GET['post'] ), 'home_url' ), PHP_URL_HOST );
178
 
179
  if ( $server_host !== $post_host ) {
180
  \wp_redirect( \str_replace( $server_host, $post_host, $current_url ) );
includes/finder/polylang-category.php CHANGED
@@ -26,7 +26,7 @@ class PolylangCategory extends Base_Category {
26
  */
27
  public function get_title() {
28
 
29
- return __( 'Languages', 'polylang' );
30
 
31
  }
32
 
26
  */
27
  public function get_title() {
28
 
29
+ return __( 'Languages', 'polylang' ); // phpcs:ignore WordPress.WP.I18n
30
 
31
  }
32
 
includes/functions.php CHANGED
@@ -105,10 +105,10 @@ function cpel_is_elementor_editor() {
105
  */
106
  function cpel_is_translation( $post_id = null ) {
107
 
108
- $post_id = $post_id ?: get_the_ID();
109
  $default = pll_default_language();
110
 
111
- return $default !== pll_get_post_language( $post_id ) && pll_get_post( $post_id, $default );
112
 
113
  }
114
 
@@ -118,7 +118,7 @@ function cpel_is_translation( $post_id = null ) {
118
  * @since 2.0.0
119
  * @since 2.0.5 don't return code for custom flags
120
  *
121
- * @param string $flag_url
122
  * @return string|bool flag code or false
123
  */
124
  function cpel_flag_code( $flag_url ) {
@@ -132,7 +132,7 @@ function cpel_flag_code( $flag_url ) {
132
  *
133
  * @since 2.0.0
134
  *
135
- * @param string $flag_code
136
  * @return array|bool SVG flag info or false
137
  */
138
  function cpel_flag_svg( $flag_code ) {
105
  */
106
  function cpel_is_translation( $post_id = null ) {
107
 
108
+ $post_id = $post_id ? $post_id : get_the_ID();
109
  $default = pll_default_language();
110
 
111
+ return pll_get_post_language( $post_id ) !== $default && pll_get_post( $post_id, $default );
112
 
113
  }
114
 
118
  * @since 2.0.0
119
  * @since 2.0.5 don't return code for custom flags
120
  *
121
+ * @param string $flag_url full flag url.
122
  * @return string|bool flag code or false
123
  */
124
  function cpel_flag_code( $flag_url ) {
132
  *
133
  * @since 2.0.0
134
  *
135
+ * @param string $flag_code flag two letters code.
136
  * @return array|bool SVG flag info or false
137
  */
138
  function cpel_flag_svg( $flag_code ) {
includes/language-visibility.php CHANGED
@@ -75,7 +75,7 @@ class LanguageVisibility {
75
  'cpel_lv_enabled',
76
  array(
77
  'type' => Controls_Manager::SWITCHER,
78
- 'label' => __( 'Enable', 'elementor' ),
79
  'render_type' => 'template',
80
  'prefix_class' => 'cpel-lv--',
81
  'style_transfer' => false,
@@ -85,15 +85,15 @@ class LanguageVisibility {
85
  $element->add_control(
86
  'cpel_lv_action',
87
  array(
88
- 'label' => __( 'Visibility', 'elementor' ),
89
  'type' => Controls_Manager::CHOOSE,
90
  'options' => array(
91
  'show' => array(
92
- 'title' => __( 'Show', 'elementor' ),
93
  'icon' => 'eicon-preview-medium',
94
  ),
95
  'hide' => array(
96
- 'title' => __( 'Hide', 'elementor' ),
97
  'icon' => 'eicon-ban',
98
  ),
99
  ),
@@ -142,7 +142,7 @@ class LanguageVisibility {
142
  return $should_render;
143
  }
144
 
145
- return in_array( pll_current_language(), $languages ) ? $show : ! $show;
146
 
147
  }
148
 
75
  'cpel_lv_enabled',
76
  array(
77
  'type' => Controls_Manager::SWITCHER,
78
+ 'label' => __( 'Enable', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
79
  'render_type' => 'template',
80
  'prefix_class' => 'cpel-lv--',
81
  'style_transfer' => false,
85
  $element->add_control(
86
  'cpel_lv_action',
87
  array(
88
+ 'label' => __( 'Visibility', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
89
  'type' => Controls_Manager::CHOOSE,
90
  'options' => array(
91
  'show' => array(
92
+ 'title' => __( 'Show', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
93
  'icon' => 'eicon-preview-medium',
94
  ),
95
  'hide' => array(
96
+ 'title' => __( 'Hide', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
97
  'icon' => 'eicon-ban',
98
  ),
99
  ),
142
  return $should_render;
143
  }
144
 
145
+ return in_array( pll_current_language(), $languages, true ) ? $show : ! $show;
146
 
147
  }
148
 
includes/widgets/manager.php CHANGED
@@ -17,7 +17,11 @@ class Manager {
17
  */
18
  private function __construct() {
19
 
20
- add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widget' ) );
 
 
 
 
21
  add_action( 'elementor/frontend/after_enqueue_styles', array( $this, 'register_styles' ) );
22
 
23
  }
@@ -31,7 +35,11 @@ class Manager {
31
  */
32
  public function register_widget() {
33
 
34
- Plugin::instance()->widgets_manager->register_widget_type( new PolylangLanguageSwitcher() );
 
 
 
 
35
 
36
  }
37
 
17
  */
18
  private function __construct() {
19
 
20
+ if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
21
+ add_action( 'elementor/widgets/register', array( $this, 'register_widget' ) );
22
+ } else {
23
+ add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widget' ) );
24
+ }
25
  add_action( 'elementor/frontend/after_enqueue_styles', array( $this, 'register_styles' ) );
26
 
27
  }
35
  */
36
  public function register_widget() {
37
 
38
+ if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
39
+ Plugin::instance()->widgets_manager->register( new PolylangLanguageSwitcher() );
40
+ } else {
41
+ Plugin::instance()->widgets_manager->register_widget_type( new PolylangLanguageSwitcher() );
42
+ }
43
 
44
  }
45
 
includes/widgets/polylang-language-switcher.php CHANGED
@@ -56,7 +56,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
56
  */
57
  public function get_title() {
58
 
59
- return __( 'Language switcher', 'polylang' );
60
 
61
  }
62
 
@@ -169,17 +169,17 @@ class PolylangLanguageSwitcher extends Widget_Base {
169
  /** Content: Layout etc. */
170
  $this->start_controls_section(
171
  'section_content',
172
- array( 'label' => __( 'Content', 'elementor' ) )
173
  );
174
 
175
  $this->add_control(
176
  'layout',
177
  array(
178
- 'label' => __( 'Layout', 'elementor' ),
179
  'type' => Controls_Manager::SELECT,
180
  'options' => array(
181
- 'horizontal' => __( 'Horizontal', 'elementor' ),
182
- 'vertical' => __( 'Vertical', 'elementor' ),
183
  'dropdown' => __( 'Dropdown', 'connect-polylang-elementor' ),
184
  ),
185
  'default' => 'horizontal',
@@ -191,23 +191,23 @@ class PolylangLanguageSwitcher extends Widget_Base {
191
  $this->add_control(
192
  'align_items',
193
  array(
194
- 'label' => __( 'Alignment', 'elementor' ),
195
  'type' => Controls_Manager::CHOOSE,
196
  'options' => array(
197
  'left' => array(
198
- 'title' => __( 'Left', 'elementor' ),
199
  'icon' => 'eicon-h-align-left',
200
  ),
201
  'center' => array(
202
- 'title' => __( 'Center', 'elementor' ),
203
  'icon' => 'eicon-h-align-center',
204
  ),
205
  'right' => array(
206
- 'title' => __( 'Right', 'elementor' ),
207
  'icon' => 'eicon-h-align-right',
208
  ),
209
  'justify' => array(
210
- 'title' => __( 'Stretch', 'elementor' ),
211
  'icon' => 'eicon-h-align-stretch',
212
  ),
213
  ),
@@ -218,7 +218,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
218
  $this->add_control(
219
  'hide_current',
220
  array(
221
- 'label' => __( 'Hides the current language', 'polylang' ),
222
  'type' => Controls_Manager::SWITCHER,
223
  'return_value' => 'yes',
224
  'default' => '',
@@ -229,7 +229,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
229
  $this->add_control(
230
  'hide_missing',
231
  array(
232
- 'label' => __( 'Hides languages with no translation', 'polylang' ),
233
  'type' => Controls_Manager::SWITCHER,
234
  'return_value' => 'yes',
235
  'default' => '',
@@ -239,7 +239,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
239
  $this->add_control(
240
  'show_country_flag',
241
  array(
242
- 'label' => __( 'Displays flags', 'polylang' ),
243
  'type' => Controls_Manager::SWITCHER,
244
  'return_value' => 'yes',
245
  'default' => 'yes',
@@ -249,7 +249,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
249
  $this->add_control(
250
  'show_language_name',
251
  array(
252
- 'label' => __( 'Displays language names', 'polylang' ),
253
  'type' => Controls_Manager::SWITCHER,
254
  'return_value' => 'yes',
255
  'default' => 'yes',
@@ -281,7 +281,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
281
 
282
  $this->start_controls_tab(
283
  'tab_menu_item_normal',
284
- array( 'label' => __( 'Normal', 'elementor' ) )
285
  );
286
 
287
  $this->add_group_control(
@@ -296,7 +296,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
296
  $this->add_control(
297
  'color_menu_item',
298
  array(
299
- 'label' => __( 'Text Color', 'elementor' ),
300
  'type' => Controls_Manager::COLOR,
301
  'global' => array( 'default' => Global_Colors::COLOR_TEXT ),
302
  'default' => '',
@@ -310,7 +310,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
310
  $this->add_control(
311
  'bg_dropdown_item',
312
  array(
313
- 'label' => __( 'Background Color', 'elementor' ),
314
  'type' => Controls_Manager::COLOR,
315
  'default' => '#FFFFFF',
316
  'selectors' => array(
@@ -324,7 +324,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
324
 
325
  $this->start_controls_tab(
326
  'tab_menu_item_hover',
327
- array( 'label' => __( 'Hover', '__elementor' ) )
328
  );
329
 
330
  $this->add_group_control(
@@ -339,7 +339,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
339
  $this->add_control(
340
  'color_menu_item_hover',
341
  array(
342
- 'label' => __( 'Text Color', 'elementor' ),
343
  'type' => Controls_Manager::COLOR,
344
  'global' => array( 'default' => Global_Colors::COLOR_ACCENT ),
345
  'selectors' => array(
@@ -351,7 +351,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
351
  $this->add_control(
352
  'bg_dropdown_hover',
353
  array(
354
- 'label' => __( 'Background Color', 'elementor' ),
355
  'type' => Controls_Manager::COLOR,
356
  'default' => '#D9D9D9',
357
  'selectors' => array(
@@ -366,7 +366,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
366
  $this->start_controls_tab(
367
  'tab_menu_item_active',
368
  array(
369
- 'label' => __( 'Active', 'elementor' ),
370
  'condition' => array(
371
  'hide_current!' => 'yes',
372
  'layout!' => 'dropdown',
@@ -386,7 +386,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
386
  $this->add_control(
387
  'color_menu_item_active',
388
  array(
389
- 'label' => __( 'Text Color', 'elementor' ),
390
  'type' => Controls_Manager::COLOR,
391
  'default' => '',
392
  'selectors' => array( '{{WRAPPER}} .cpel-switcher__lang--active a' => 'color: {{VALUE}}' ),
@@ -429,7 +429,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
429
  $this->add_responsive_control(
430
  'menu_space_between',
431
  array(
432
- 'label' => __( 'Space Between', 'elementor' ),
433
  'type' => Controls_Manager::SLIDER,
434
  'range' => array(
435
  'px' => array( 'max' => 100 ),
@@ -478,11 +478,11 @@ class PolylangLanguageSwitcher extends Widget_Base {
478
  'type' => Controls_Manager::CHOOSE,
479
  'options' => array(
480
  'down' => array(
481
- 'title' => __( 'Down', 'elementor' ),
482
  'icon' => 'eicon-arrow-down',
483
  ),
484
  'up' => array(
485
- 'title' => __( 'Up', 'elementor' ),
486
  'icon' => 'eicon-arrow-up',
487
  ),
488
  ),
@@ -494,7 +494,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
494
  $this->add_control(
495
  'dropdown_icon',
496
  array(
497
- 'label' => __( 'Icon', 'elementor' ),
498
  'type' => Controls_Manager::ICONS,
499
  'fa4compatibility' => 'icon',
500
  'recommended' => array(
@@ -518,7 +518,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
518
  $this->add_control(
519
  'dropdown_icon_indent',
520
  array(
521
- 'label' => __( 'Icon Spacing', 'elementor' ),
522
  'type' => Controls_Manager::SLIDER,
523
  'range' => array(
524
  'px' => array( 'max' => 50 ),
@@ -540,7 +540,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
540
  $this->start_controls_section(
541
  'country_flag_section',
542
  array(
543
- 'label' => __( 'Flag', 'polylang' ),
544
  'tab' => Controls_Manager::TAB_STYLE,
545
  'condition' => array( 'show_country_flag' => 'yes' ),
546
  )
@@ -559,7 +559,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
559
  $this->add_control(
560
  'aspect_ratio_flag',
561
  array(
562
- 'label' => __( 'Aspect Ratio', 'elementor' ),
563
  'type' => Controls_Manager::SELECT,
564
  'options' => array(
565
  '43' => '4:3',
@@ -574,7 +574,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
574
  $this->add_responsive_control(
575
  'size_flag',
576
  array(
577
- 'label' => __( 'Size', 'elementor' ),
578
  'type' => Controls_Manager::SLIDER,
579
  'range' => array(
580
  'px' => array( 'min' => 16 ),
@@ -591,7 +591,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
591
  $this->add_responsive_control(
592
  'border_radius_flag',
593
  array(
594
- 'label' => __( 'Border Radius', 'elementor' ),
595
  'type' => Controls_Manager::SLIDER,
596
  'size_units' => array( 'px', '%' ),
597
  'range' => array(
@@ -621,7 +621,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
621
  $this->add_responsive_control(
622
  'text_indent_language_name',
623
  array(
624
- 'label' => __( 'Text Indent', 'elementor' ),
625
  'type' => Controls_Manager::SLIDER,
626
  'range' => array(
627
  'px' => array( 'max' => 50 ),
@@ -651,7 +651,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
651
  $this->add_control(
652
  'uppercase_language_code',
653
  array(
654
- 'label' => _x( 'Uppercase', 'Typography Control', 'elementor' ),
655
  'type' => Controls_Manager::SWITCHER,
656
  'return_value' => 'yes',
657
  'default' => 'yes',
@@ -661,7 +661,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
661
  $this->add_responsive_control(
662
  'text_indent_language_code',
663
  array(
664
- 'label' => __( 'Text Indent', 'elementor' ),
665
  'type' => Controls_Manager::SLIDER,
666
  'range' => array(
667
  'px' => array( 'max' => 50 ),
@@ -676,7 +676,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
676
  $this->add_control(
677
  'before_language_code',
678
  array(
679
- 'label' => __( 'Before', 'elementor' ),
680
  'type' => Controls_Manager::TEXT,
681
  )
682
  );
@@ -684,7 +684,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
684
  $this->add_control(
685
  'after_language_code',
686
  array(
687
- 'label' => __( 'After', 'elementor' ),
688
  'type' => Controls_Manager::TEXT,
689
  )
690
  );
@@ -758,9 +758,9 @@ class PolylangLanguageSwitcher extends Widget_Base {
758
  // Language code.
759
  $language_code = sprintf(
760
  '%s%s%s',
761
- $settings['before_language_code'] ?: '',
762
  'yes' === $settings['uppercase_language_code'] ? strtoupper( $language['slug'] ) : strtolower( $language['slug'] ),
763
- $settings['after_language_code'] ?: ''
764
  );
765
 
766
  // Language flag.
@@ -806,7 +806,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
806
 
807
  $output = '<nav ' . $this->get_render_attribute_string( 'nav' ) . '>';
808
 
809
- // Dropdown toggle link
810
  if ( count( $lang_links ) && 'dropdown' === $settings['layout'] ) {
811
  $lang_code = array_key_exists( $lang_curr, $lang_links ) ? $lang_curr : current( array_keys( $lang_links ) );
812
  $lang_link = $lang_links[ $lang_code ];
@@ -820,7 +820,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
820
  $output .= '<div class="cpel-switcher__toggle cpel-switcher__lang" onclick="this.classList.toggle(\'cpel-switcher__toggle--on\')">' . $lang_link . '</div>';
821
  }
822
 
823
- // Languages list
824
  if ( count( $lang_links ) ) {
825
 
826
  $output .= '<ul class="cpel-switcher__list">';
@@ -834,7 +834,7 @@ class PolylangLanguageSwitcher extends Widget_Base {
834
 
835
  $output .= '</nav>';
836
 
837
- echo $output;
838
 
839
  }
840
 
56
  */
57
  public function get_title() {
58
 
59
+ return __( 'Language switcher', 'polylang' ); // phpcs:ignore WordPress.WP.I18n
60
 
61
  }
62
 
169
  /** Content: Layout etc. */
170
  $this->start_controls_section(
171
  'section_content',
172
+ array( 'label' => __( 'Content', 'elementor' ) ) // phpcs:ignore WordPress.WP.I18n
173
  );
174
 
175
  $this->add_control(
176
  'layout',
177
  array(
178
+ 'label' => __( 'Layout', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
179
  'type' => Controls_Manager::SELECT,
180
  'options' => array(
181
+ 'horizontal' => __( 'Horizontal', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
182
+ 'vertical' => __( 'Vertical', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
183
  'dropdown' => __( 'Dropdown', 'connect-polylang-elementor' ),
184
  ),
185
  'default' => 'horizontal',
191
  $this->add_control(
192
  'align_items',
193
  array(
194
+ 'label' => __( 'Alignment', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
195
  'type' => Controls_Manager::CHOOSE,
196
  'options' => array(
197
  'left' => array(
198
+ 'title' => __( 'Left', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
199
  'icon' => 'eicon-h-align-left',
200
  ),
201
  'center' => array(
202
+ 'title' => __( 'Center', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
203
  'icon' => 'eicon-h-align-center',
204
  ),
205
  'right' => array(
206
+ 'title' => __( 'Right', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
207
  'icon' => 'eicon-h-align-right',
208
  ),
209
  'justify' => array(
210
+ 'title' => __( 'Stretch', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
211
  'icon' => 'eicon-h-align-stretch',
212
  ),
213
  ),
218
  $this->add_control(
219
  'hide_current',
220
  array(
221
+ 'label' => __( 'Hides the current language', 'polylang' ), // phpcs:ignore WordPress.WP.I18n
222
  'type' => Controls_Manager::SWITCHER,
223
  'return_value' => 'yes',
224
  'default' => '',
229
  $this->add_control(
230
  'hide_missing',
231
  array(
232
+ 'label' => __( 'Hides languages with no translation', 'polylang' ), // phpcs:ignore WordPress.WP.I18n
233
  'type' => Controls_Manager::SWITCHER,
234
  'return_value' => 'yes',
235
  'default' => '',
239
  $this->add_control(
240
  'show_country_flag',
241
  array(
242
+ 'label' => __( 'Displays flags', 'polylang' ), // phpcs:ignore WordPress.WP.I18n
243
  'type' => Controls_Manager::SWITCHER,
244
  'return_value' => 'yes',
245
  'default' => 'yes',
249
  $this->add_control(
250
  'show_language_name',
251
  array(
252
+ 'label' => __( 'Displays language names', 'polylang' ), // phpcs:ignore WordPress.WP.I18n
253
  'type' => Controls_Manager::SWITCHER,
254
  'return_value' => 'yes',
255
  'default' => 'yes',
281
 
282
  $this->start_controls_tab(
283
  'tab_menu_item_normal',
284
+ array( 'label' => __( 'Normal', 'elementor' ) ) // phpcs:ignore WordPress.WP.I18n
285
  );
286
 
287
  $this->add_group_control(
296
  $this->add_control(
297
  'color_menu_item',
298
  array(
299
+ 'label' => __( 'Text Color', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
300
  'type' => Controls_Manager::COLOR,
301
  'global' => array( 'default' => Global_Colors::COLOR_TEXT ),
302
  'default' => '',
310
  $this->add_control(
311
  'bg_dropdown_item',
312
  array(
313
+ 'label' => __( 'Background Color', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
314
  'type' => Controls_Manager::COLOR,
315
  'default' => '#FFFFFF',
316
  'selectors' => array(
324
 
325
  $this->start_controls_tab(
326
  'tab_menu_item_hover',
327
+ array( 'label' => __( 'Hover', '__elementor' ) ) // phpcs:ignore WordPress.WP.I18n
328
  );
329
 
330
  $this->add_group_control(
339
  $this->add_control(
340
  'color_menu_item_hover',
341
  array(
342
+ 'label' => __( 'Text Color', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
343
  'type' => Controls_Manager::COLOR,
344
  'global' => array( 'default' => Global_Colors::COLOR_ACCENT ),
345
  'selectors' => array(
351
  $this->add_control(
352
  'bg_dropdown_hover',
353
  array(
354
+ 'label' => __( 'Background Color', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
355
  'type' => Controls_Manager::COLOR,
356
  'default' => '#D9D9D9',
357
  'selectors' => array(
366
  $this->start_controls_tab(
367
  'tab_menu_item_active',
368
  array(
369
+ 'label' => __( 'Active', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
370
  'condition' => array(
371
  'hide_current!' => 'yes',
372
  'layout!' => 'dropdown',
386
  $this->add_control(
387
  'color_menu_item_active',
388
  array(
389
+ 'label' => __( 'Text Color', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
390
  'type' => Controls_Manager::COLOR,
391
  'default' => '',
392
  'selectors' => array( '{{WRAPPER}} .cpel-switcher__lang--active a' => 'color: {{VALUE}}' ),
429
  $this->add_responsive_control(
430
  'menu_space_between',
431
  array(
432
+ 'label' => __( 'Space Between', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
433
  'type' => Controls_Manager::SLIDER,
434
  'range' => array(
435
  'px' => array( 'max' => 100 ),
478
  'type' => Controls_Manager::CHOOSE,
479
  'options' => array(
480
  'down' => array(
481
+ 'title' => __( 'Down', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
482
  'icon' => 'eicon-arrow-down',
483
  ),
484
  'up' => array(
485
+ 'title' => __( 'Up', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
486
  'icon' => 'eicon-arrow-up',
487
  ),
488
  ),
494
  $this->add_control(
495
  'dropdown_icon',
496
  array(
497
+ 'label' => __( 'Icon', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
498
  'type' => Controls_Manager::ICONS,
499
  'fa4compatibility' => 'icon',
500
  'recommended' => array(
518
  $this->add_control(
519
  'dropdown_icon_indent',
520
  array(
521
+ 'label' => __( 'Icon Spacing', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
522
  'type' => Controls_Manager::SLIDER,
523
  'range' => array(
524
  'px' => array( 'max' => 50 ),
540
  $this->start_controls_section(
541
  'country_flag_section',
542
  array(
543
+ 'label' => __( 'Flag', 'polylang' ), // phpcs:ignore WordPress.WP.I18n
544
  'tab' => Controls_Manager::TAB_STYLE,
545
  'condition' => array( 'show_country_flag' => 'yes' ),
546
  )
559
  $this->add_control(
560
  'aspect_ratio_flag',
561
  array(
562
+ 'label' => __( 'Aspect Ratio', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
563
  'type' => Controls_Manager::SELECT,
564
  'options' => array(
565
  '43' => '4:3',
574
  $this->add_responsive_control(
575
  'size_flag',
576
  array(
577
+ 'label' => __( 'Size', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
578
  'type' => Controls_Manager::SLIDER,
579
  'range' => array(
580
  'px' => array( 'min' => 16 ),
591
  $this->add_responsive_control(
592
  'border_radius_flag',
593
  array(
594
+ 'label' => __( 'Border Radius', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
595
  'type' => Controls_Manager::SLIDER,
596
  'size_units' => array( 'px', '%' ),
597
  'range' => array(
621
  $this->add_responsive_control(
622
  'text_indent_language_name',
623
  array(
624
+ 'label' => __( 'Text Indent', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
625
  'type' => Controls_Manager::SLIDER,
626
  'range' => array(
627
  'px' => array( 'max' => 50 ),
651
  $this->add_control(
652
  'uppercase_language_code',
653
  array(
654
+ 'label' => _x( 'Uppercase', 'Typography Control', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
655
  'type' => Controls_Manager::SWITCHER,
656
  'return_value' => 'yes',
657
  'default' => 'yes',
661
  $this->add_responsive_control(
662
  'text_indent_language_code',
663
  array(
664
+ 'label' => __( 'Text Indent', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
665
  'type' => Controls_Manager::SLIDER,
666
  'range' => array(
667
  'px' => array( 'max' => 50 ),
676
  $this->add_control(
677
  'before_language_code',
678
  array(
679
+ 'label' => __( 'Before', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
680
  'type' => Controls_Manager::TEXT,
681
  )
682
  );
684
  $this->add_control(
685
  'after_language_code',
686
  array(
687
+ 'label' => __( 'After', 'elementor' ), // phpcs:ignore WordPress.WP.I18n
688
  'type' => Controls_Manager::TEXT,
689
  )
690
  );
758
  // Language code.
759
  $language_code = sprintf(
760
  '%s%s%s',
761
+ $settings['before_language_code'] ? $settings['before_language_code'] : '',
762
  'yes' === $settings['uppercase_language_code'] ? strtoupper( $language['slug'] ) : strtolower( $language['slug'] ),
763
+ $settings['after_language_code'] ? $settings['after_language_code'] : ''
764
  );
765
 
766
  // Language flag.
806
 
807
  $output = '<nav ' . $this->get_render_attribute_string( 'nav' ) . '>';
808
 
809
+ // Dropdown toggle link.
810
  if ( count( $lang_links ) && 'dropdown' === $settings['layout'] ) {
811
  $lang_code = array_key_exists( $lang_curr, $lang_links ) ? $lang_curr : current( array_keys( $lang_links ) );
812
  $lang_link = $lang_links[ $lang_code ];
820
  $output .= '<div class="cpel-switcher__toggle cpel-switcher__lang" onclick="this.classList.toggle(\'cpel-switcher__toggle--on\')">' . $lang_link . '</div>';
821
  }
822
 
823
+ // Languages list.
824
  if ( count( $lang_links ) ) {
825
 
826
  $output .= '<ul class="cpel-switcher__list">';
834
 
835
  $output .= '</nav>';
836
 
837
+ echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
838
 
839
  }
840
 
languages/connect-polylang-elementor.pot CHANGED
@@ -2,14 +2,14 @@
2
  # This file is distributed under the GPL-2.0-or-later.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Polylang Connect for Elementor 2.3.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/connect-polylang-elementor\n"
7
  "Last-Translator: Pacotole <pacotole@crea.me>\n"
8
  "Language-Team: Creame <hola@crea.me>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2022-07-29T11:52:06+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.6.0\n"
15
  "X-Domain: connect-polylang-elementor\n"
@@ -54,7 +54,7 @@ msgctxt "Link title attribute for Elementor My Templates"
54
  msgid "Templates"
55
  msgstr ""
56
 
57
- #: includes/connect-plugins.php:645
58
  msgid "(from %s)"
59
  msgstr ""
60
 
@@ -74,7 +74,7 @@ msgid "Current Language"
74
  msgstr ""
75
 
76
  #: includes/dynamic-tags/language-flag.php:51
77
- #: includes/widgets/polylang-language-switcher.php:563
78
  msgid "Scalable Image"
79
  msgstr ""
80
 
@@ -148,7 +148,7 @@ msgid "languages, switcher, polylang, multilingual, flags, countries, country"
148
  msgstr ""
149
 
150
  #: includes/widgets/polylang-language-switcher.php:183
151
- #: includes/widgets/polylang-language-switcher.php:451
152
  msgid "Dropdown"
153
  msgstr ""
154
 
@@ -168,26 +168,26 @@ msgstr ""
168
  msgid "Vertical Padding"
169
  msgstr ""
170
 
171
- #: includes/widgets/polylang-language-switcher.php:472
172
  msgid "Drop"
173
  msgstr ""
174
 
175
- #: includes/widgets/polylang-language-switcher.php:475
176
  msgid "On Click"
177
  msgstr ""
178
 
179
- #: includes/widgets/polylang-language-switcher.php:476
180
  msgid "On Mouse Hover"
181
  msgstr ""
182
 
183
- #: includes/widgets/polylang-language-switcher.php:487
184
  msgid "Drop Direction"
185
  msgstr ""
186
 
187
- #: includes/widgets/polylang-language-switcher.php:626
188
  msgid "Language Name"
189
  msgstr ""
190
 
191
- #: includes/widgets/polylang-language-switcher.php:656
192
  msgid "Language Code"
193
  msgstr ""
2
  # This file is distributed under the GPL-2.0-or-later.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Polylang Connect for Elementor 2.3.1\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/connect-polylang-elementor\n"
7
  "Last-Translator: Pacotole <pacotole@crea.me>\n"
8
  "Language-Team: Creame <hola@crea.me>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2022-08-26T16:39:00+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.6.0\n"
15
  "X-Domain: connect-polylang-elementor\n"
54
  msgid "Templates"
55
  msgstr ""
56
 
57
+ #: includes/connect-plugins.php:646
58
  msgid "(from %s)"
59
  msgstr ""
60
 
74
  msgstr ""
75
 
76
  #: includes/dynamic-tags/language-flag.php:51
77
+ #: includes/widgets/polylang-language-switcher.php:552
78
  msgid "Scalable Image"
79
  msgstr ""
80
 
148
  msgstr ""
149
 
150
  #: includes/widgets/polylang-language-switcher.php:183
151
+ #: includes/widgets/polylang-language-switcher.php:454
152
  msgid "Dropdown"
153
  msgstr ""
154
 
168
  msgid "Vertical Padding"
169
  msgstr ""
170
 
171
+ #: includes/widgets/polylang-language-switcher.php:463
172
  msgid "Drop"
173
  msgstr ""
174
 
175
+ #: includes/widgets/polylang-language-switcher.php:466
176
  msgid "On Click"
177
  msgstr ""
178
 
179
+ #: includes/widgets/polylang-language-switcher.php:467
180
  msgid "On Mouse Hover"
181
  msgstr ""
182
 
183
+ #: includes/widgets/polylang-language-switcher.php:477
184
  msgid "Drop Direction"
185
  msgstr ""
186
 
187
+ #: includes/widgets/polylang-language-switcher.php:615
188
  msgid "Language Name"
189
  msgstr ""
190
 
191
+ #: includes/widgets/polylang-language-switcher.php:645
192
  msgid "Language Code"
193
  msgstr ""