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

Version Description

  • Enable Elementor cross domain url fixes only for multidomain configurations.
  • Added Elementor tested headers.
Download this release

Release Info

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

Code changes from version 2.1.0 to 2.1.1

README.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: daveshine, p4fbradjohnson, deckerweb, wpautobahn, pacotole, creapu
3
  Donate link: https://www.paypal.me/pacotole
4
  Tags: elementor, polylang, multilingual, language switcher, languages, templates, widget, finder, dynamic tags
5
  Requires at least: 5.4
6
- Tested up to: 5.9
7
  Requires PHP: 5.6
8
- Stable tag: 2.1.0
9
  License: GPL-2.0-or-later
10
  License URI: https://opensource.org/licenses/GPL-2.0
11
 
@@ -195,6 +195,10 @@ There are quite a few:
195
 
196
  == Changelog ==
197
 
 
 
 
 
198
  = 2.1.0 =
199
  * Fixed cross domain issues with Polylang setup with multiple domains.
200
  * Fix flag SVG inline with some themes.
3
  Donate link: https://www.paypal.me/pacotole
4
  Tags: elementor, polylang, multilingual, language switcher, languages, templates, widget, finder, dynamic tags
5
  Requires at least: 5.4
6
+ Tested up to: 6.0
7
  Requires PHP: 5.6
8
+ Stable tag: 2.1.1
9
  License: GPL-2.0-or-later
10
  License URI: https://opensource.org/licenses/GPL-2.0
11
 
195
 
196
  == Changelog ==
197
 
198
+ = 2.1.1 =
199
+ * Enable Elementor cross domain url fixes only for multidomain configurations.
200
+ * Added Elementor tested headers.
201
+
202
  = 2.1.0 =
203
  * Fixed cross domain issues with Polylang setup with multiple domains.
204
  * Fix flag SVG inline with some themes.
connect-polylang-elementor.php CHANGED
@@ -8,7 +8,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.1.0
12
  * Author: Creame
13
  * Author URI: https://crea.me/
14
  * License: GPL-2.0-or-later
@@ -17,6 +17,8 @@
17
  * Domain Path: /languages/
18
  * Requires WP: 5.4
19
  * Requires PHP: 5.6
 
 
20
  *
21
  * Copyright (c) 2021 Paco Toledo - CREAME
22
  * Copyright (c) 2018-2021 David Decker - DECKERWEB
@@ -31,7 +33,7 @@ defined( 'ABSPATH' ) || exit;
31
  *
32
  * @since 2.0.0
33
  */
34
- define( 'CPEL_PLUGIN_VERSION', '2.1.0' );
35
  define( 'CPEL_FILE', __FILE__ );
36
  define( 'CPEL_DIR', plugin_dir_path( CPEL_FILE ) );
37
  define( 'CPEL_BASENAME', plugin_basename( CPEL_FILE ) );
@@ -145,9 +147,9 @@ function fix_cross_domain_assets( $url ) {
145
  $pll_options = get_option( 'polylang' );
146
 
147
  // Is a multidomain configuration.
148
- if ( isset( $pll_options['force_lang'], $pll_options['domains'] ) && 3 === $pll_options['force_lang'] ) {
149
 
150
- $srv_host = $_SERVER['HTTP_HOST'];
151
  $url_host = parse_url( $url, PHP_URL_HOST );
152
 
153
  if ( $url_host ) {
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.1.1
12
  * Author: Creame
13
  * Author URI: https://crea.me/
14
  * License: GPL-2.0-or-later
17
  * Domain Path: /languages/
18
  * Requires WP: 5.4
19
  * Requires PHP: 5.6
20
+ * Elementor tested up to: 3.6.7
21
+ * Elementor Pro tested up to: 3.7.2
22
  *
23
  * Copyright (c) 2021 Paco Toledo - CREAME
24
  * Copyright (c) 2018-2021 David Decker - DECKERWEB
33
  *
34
  * @since 2.0.0
35
  */
36
+ define( 'CPEL_PLUGIN_VERSION', '2.1.1' );
37
  define( 'CPEL_FILE', __FILE__ );
38
  define( 'CPEL_DIR', plugin_dir_path( CPEL_FILE ) );
39
  define( 'CPEL_BASENAME', plugin_basename( CPEL_FILE ) );
147
  $pll_options = get_option( 'polylang' );
148
 
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 ) {
includes/connect-plugins.php CHANGED
@@ -66,7 +66,7 @@ class ConnectPlugins {
66
  add_filter( 'update_post_metadata', array( $this, 'prevent_elementor_css_meta' ), 10, 3 );
67
 
68
  // Edit links for each language domain.
69
- if ( ! empty( PLL()->options['domains'] ) && 3 === PLL()->options['force_lang'] ) {
70
 
71
  add_filter( 'post_row_actions', array( $this, 'fix_edit_link' ), 12, 2 );
72
  add_filter( 'page_row_actions', array( $this, 'fix_edit_link' ), 12, 2 );
66
  add_filter( 'update_post_metadata', array( $this, 'prevent_elementor_css_meta' ), 10, 3 );
67
 
68
  // Edit links for each language domain.
69
+ if ( cpel_is_polylang_multidomain() ) {
70
 
71
  add_filter( 'post_row_actions', array( $this, 'fix_edit_link' ), 12, 2 );
72
  add_filter( 'page_row_actions', array( $this, 'fix_edit_link' ), 12, 2 );
includes/elementor-assets.php CHANGED
@@ -12,16 +12,16 @@ class ElementorAssets {
12
 
13
  use \ConnectPolylangElementor\Util\Singleton;
14
 
15
- protected $current_domain = '';
16
- protected $default_domain = '';
17
- protected $current_language = '';
18
- protected $default_language = '';
19
- protected $all_domains = array();
20
 
21
  protected function __construct() {
22
 
23
- add_action( 'init', array( $this, 'init' ) );
24
- add_action( 'admin_init', array( $this, 'editor_domain_redirect' ) );
 
 
25
 
26
  }
27
 
@@ -43,7 +43,7 @@ class ElementorAssets {
43
  }
44
 
45
  $is_preview = isset( $_GET['elementor_preview'] );
46
- $is_editor = ( isset( $_GET['action'] ) && 'elementor' === $_GET['action'] );
47
 
48
  if ( ! $is_editor && ! $is_preview ) {
49
  return;
@@ -59,10 +59,8 @@ class ElementorAssets {
59
  }
60
  }
61
 
62
- $this->current_domain = $current_language->home_url;
63
- $this->default_domain = $default_language->home_url;
64
- $this->current_language = $current_language->slug;
65
- $this->default_language = $default_language->slug;
66
 
67
  // Add filters.
68
  add_filter( 'script_loader_src', array( $this, 'translate_url' ) );
@@ -165,13 +163,14 @@ class ElementorAssets {
165
  */
166
  public function editor_domain_redirect() {
167
 
168
- // Exist if not is Elementor Editor.
169
- if ( ! isset( $_GET['action'] ) || 'elementor' !== $_GET['action'] ) {
 
170
  return;
171
  }
172
 
173
  $current_url = add_query_arg( $_SERVER['QUERY_STRING'], '', admin_url( 'post.php' ) );
174
- $server_host = parse_url( trailingslashit( "//{$_SERVER['HTTP_HOST']}" ), PHP_URL_HOST );
175
  $post_host = parse_url( \pll_get_post_language( intval( $_GET['post'] ), 'home_url' ), PHP_URL_HOST );
176
 
177
  if ( $server_host !== $post_host ) {
12
 
13
  use \ConnectPolylangElementor\Util\Singleton;
14
 
15
+ protected $current_domain = '';
16
+ protected $default_domain = '';
17
+ protected $all_domains = array();
 
 
18
 
19
  protected function __construct() {
20
 
21
+ if ( cpel_is_polylang_multidomain() ) {
22
+ add_action( 'init', array( $this, 'init' ) );
23
+ add_action( 'admin_init', array( $this, 'editor_domain_redirect' ) );
24
+ }
25
 
26
  }
27
 
43
  }
44
 
45
  $is_preview = isset( $_GET['elementor_preview'] );
46
+ $is_editor = isset( $_GET['action'] ) && 'elementor' === $_GET['action'];
47
 
48
  if ( ! $is_editor && ! $is_preview ) {
49
  return;
59
  }
60
  }
61
 
62
+ $this->current_domain = $current_language->home_url;
63
+ $this->default_domain = $default_language->home_url;
 
 
64
 
65
  // Add filters.
66
  add_filter( 'script_loader_src', array( $this, 'translate_url' ) );
163
  */
164
  public function editor_domain_redirect() {
165
 
166
+ $is_editor = isset( $_GET['action'] ) && 'elementor' === $_GET['action'];
167
+
168
+ if ( ! $is_editor ) {
169
  return;
170
  }
171
 
172
  $current_url = add_query_arg( $_SERVER['QUERY_STRING'], '', admin_url( 'post.php' ) );
173
+ $server_host = parse_url( "//{$_SERVER['HTTP_HOST']}", PHP_URL_HOST );
174
  $post_host = parse_url( \pll_get_post_language( intval( $_GET['post'] ), 'home_url' ), PHP_URL_HOST );
175
 
176
  if ( $server_host !== $post_host ) {
includes/functions.php CHANGED
@@ -70,6 +70,19 @@ function cpel_is_polylang_api_active() {
70
 
71
  }
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  /**
74
  * Is post a translation in secondary language
75
  *
70
 
71
  }
72
 
73
+ /**
74
+ * Is Polylang Multidomain
75
+ *
76
+ * @since 2.1.1
77
+ *
78
+ * @return bool TRUE if is polylang multi-domain configuration, FALSE otherwise.
79
+ */
80
+ function cpel_is_polylang_multidomain() {
81
+
82
+ return cpel_is_polylang_api_active() && 3 === PLL()->options['force_lang'] && ! empty( PLL()->options['domains'] );
83
+
84
+ }
85
+
86
  /**
87
  * Is post a translation in secondary language
88
  *