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

Version Description

  • 2021-05-17 =
  • Fixed Elementor editor don't load with Global Widgets in secondary language.
Download this release

Release Info

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

Code changes from version 1.0.4 to 1.0.5

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: elementor, polylang, multilingual, language switcher, languages, templates
5
  Requires at least: 4.7
6
  Tested up to: 5.7
7
  Requires PHP: 5.6
8
- Stable tag: 1.0.4
9
  License: GPL-2.0-or-later
10
  License URI: https://opensource.org/licenses/GPL-2.0
11
 
@@ -220,6 +220,9 @@ There are quite a few:
220
 
221
  == Changelog ==
222
 
 
 
 
223
  = 1.0.4 - 2021-04-30 =
224
  * Translated templates with conditions for categories/tags also works with translated categories/tags.
225
  * Fixed PHP notice on activation
5
  Requires at least: 4.7
6
  Tested up to: 5.7
7
  Requires PHP: 5.6
8
+ Stable tag: 1.0.5
9
  License: GPL-2.0-or-later
10
  License URI: https://opensource.org/licenses/GPL-2.0
11
 
220
 
221
  == Changelog ==
222
 
223
+ = 1.0.5 - 2021-05-17 =
224
+ * Fixed Elementor editor don't load with Global Widgets in secondary language.
225
+
226
  = 1.0.4 - 2021-04-30 =
227
  * Translated templates with conditions for categories/tags also works with translated categories/tags.
228
  * Fixed PHP notice on activation
connect-polylang-elementor.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Polylang Connect for Elementor
13
  * Plugin URI: https://github.com/deckerweb/connect-polylang-elementor
14
  * Description: Connect the Polylang multilingual plugin with Elementor Page Builder: This plugin will make Elementor and Polylang show the correct language templates, especially with Elementor Pro Theme Builder. Plus: native Polylang Language Switcher Elementor widget, new Dynamic Tags, and Polylang links added to the Elementor Finder feature.
15
- * Version: 1.0.4
16
  * Author: David Decker - DECKERWEB
17
  * Author URI: https://deckerweb.de/
18
  * License: GPL-2.0-or-later
@@ -41,7 +41,7 @@ if ( ! defined( 'ABSPATH' ) ) {
41
  * @since 1.0.0
42
  */
43
  /** Plugin version */
44
- define( 'CPEL_PLUGIN_VERSION', '1.0.4' );
45
 
46
  /** File */
47
  define( 'CPEL__FILE__', __FILE__ );
12
  * Plugin Name: Polylang Connect for Elementor
13
  * Plugin URI: https://github.com/deckerweb/connect-polylang-elementor
14
  * Description: Connect the Polylang multilingual plugin with Elementor Page Builder: This plugin will make Elementor and Polylang show the correct language templates, especially with Elementor Pro Theme Builder. Plus: native Polylang Language Switcher Elementor widget, new Dynamic Tags, and Polylang links added to the Elementor Finder feature.
15
+ * Version: 1.0.5
16
  * Author: David Decker - DECKERWEB
17
  * Author URI: https://deckerweb.de/
18
  * License: GPL-2.0-or-later
41
  * @since 1.0.0
42
  */
43
  /** Plugin version */
44
+ define( 'CPEL_PLUGIN_VERSION', '1.0.5' );
45
 
46
  /** File */
47
  define( 'CPEL__FILE__', __FILE__ );
modules/connect/tweaks-polylang-elementor.php CHANGED
@@ -67,13 +67,30 @@ add_action( 'parse_query', 'ddw_cpel_polylang_elementor_library_conditions_parse
67
  *
68
  * @since 1.0.0
69
  * @since 1.0.3 only check meta_key is '_elementor_conditions' & set lang 'all'
 
70
  *
71
  * @param WP_Query $query
72
  */
73
  function ddw_cpel_polylang_elementor_library_conditions_parse_query( $query ) {
74
 
75
- if ( is_admin() && ddw_cpel_is_polylang_active() && '_elementor_conditions' === $query->query_vars['meta_key'] ) {
76
- $query->set( 'lang', 'all' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
 
79
  }
67
  *
68
  * @since 1.0.0
69
  * @since 1.0.3 only check meta_key is '_elementor_conditions' & set lang 'all'
70
+ * @since 1.0.5 also filter for Global Widgets & set lang ''
71
  *
72
  * @param WP_Query $query
73
  */
74
  function ddw_cpel_polylang_elementor_library_conditions_parse_query( $query ) {
75
 
76
+ if ( ! is_admin() ) {
77
+ return;
78
+ }
79
+
80
+ $global_widget_meta_query = array(
81
+ 'key' => '_elementor_template_type',
82
+ 'value' => 'widget',
83
+ );
84
+
85
+ $is_elementor_conditions = isset( $query->query_vars['meta_key'] )
86
+ && '_elementor_conditions' === $query->query_vars['meta_key'];
87
+
88
+ $is_global_widget = 'elementor_library' === $query->query_vars['post_type']
89
+ && isset( $query->query_vars['meta_query'] )
90
+ && in_array( $global_widget_meta_query, $query->query_vars['meta_query'] );
91
+
92
+ if ( $is_elementor_conditions || $is_global_widget ) {
93
+ $query->set( 'lang', '' );
94
  }
95
 
96
  }