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

Version Description

  • Fixed Elementor Search Form url with correct language.
Download this release

Release Info

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

Code changes from version 2.0.5 to 2.0.6

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: 5.9
7
  Requires PHP: 5.6
8
- Stable tag: 2.0.5
9
  License: GPL-2.0-or-later
10
  License URI: https://opensource.org/licenses/GPL-2.0
11
 
@@ -194,6 +194,9 @@ There are quite a few:
194
 
195
  == Changelog ==
196
 
 
 
 
197
  = 2.0.5 =
198
  * Use Polylang custom flags.
199
 
5
  Requires at least: 5.4
6
  Tested up to: 5.9
7
  Requires PHP: 5.6
8
+ Stable tag: 2.0.6
9
  License: GPL-2.0-or-later
10
  License URI: https://opensource.org/licenses/GPL-2.0
11
 
194
 
195
  == Changelog ==
196
 
197
+ = 2.0.6 =
198
+ * Fixed Elementor Search Form url with correct language.
199
+
200
  = 2.0.5 =
201
  * Use Polylang custom flags.
202
 
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.0.5
12
  * Author: Creame
13
  * Author URI: https://crea.me/
14
  * License: GPL-2.0-or-later
@@ -31,7 +31,7 @@ defined( 'ABSPATH' ) || exit;
31
  *
32
  * @since 2.0.0
33
  */
34
- define( 'CPEL_PLUGIN_VERSION', '2.0.5' );
35
  define( 'CPEL_FILE', __FILE__ );
36
  define( 'CPEL_DIR', plugin_dir_path( CPEL_FILE ) );
37
  define( 'CPEL_BASENAME', plugin_basename( CPEL_FILE ) );
@@ -47,22 +47,23 @@ spl_autoload_register(
47
  $prefix = __NAMESPACE__; // project-specific namespace prefix
48
  $base_dir = __DIR__ . '/includes'; // base directory for the namespace prefix
49
 
 
50
  $len = strlen( $prefix );
51
- if ( strncmp( $prefix, $class, $len ) !== 0 ) { // does the class use the namespace prefix?
52
- return; // no, move to the next registered autoloader
53
  }
54
 
55
  $relative_class_name = substr( $class, $len );
56
 
57
  // Replace the namespace prefix with the base directory, replace namespace
58
- // separators with directory separators in the relative class name, append
59
- // with .php and transform CamelCase to lower-dashed
60
- $file = str_replace( '\\', '/', $relative_class_name ) . '.php';
61
  $file = strtolower( preg_replace( '/([a-zA-Z])(?=[A-Z])/', '$1-', $file ) );
62
- $file = $base_dir . $file;
63
 
64
- if ( file_exists( $file ) ) {
65
- require $file;
66
  }
67
  }
68
  );
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.0.6
12
  * Author: Creame
13
  * Author URI: https://crea.me/
14
  * License: GPL-2.0-or-later
31
  *
32
  * @since 2.0.0
33
  */
34
+ define( 'CPEL_PLUGIN_VERSION', '2.0.6' );
35
  define( 'CPEL_FILE', __FILE__ );
36
  define( 'CPEL_DIR', plugin_dir_path( CPEL_FILE ) );
37
  define( 'CPEL_BASENAME', plugin_basename( CPEL_FILE ) );
47
  $prefix = __NAMESPACE__; // project-specific namespace prefix
48
  $base_dir = __DIR__ . '/includes'; // base directory for the namespace prefix
49
 
50
+ // Does the class use the namespace prefix? No, move to the next registered autoloader
51
  $len = strlen( $prefix );
52
+ if ( strncmp( $prefix, $class, $len ) !== 0 ) {
53
+ return;
54
  }
55
 
56
  $relative_class_name = substr( $class, $len );
57
 
58
  // Replace the namespace prefix with the base directory, replace namespace
59
+ // separators with directory separators in the relative class name,
60
+ // append with .php and transform CamelCase to lower-dashed
61
+ $file = str_replace( '\\', DIRECTORY_SEPARATOR, $relative_class_name );
62
  $file = strtolower( preg_replace( '/([a-zA-Z])(?=[A-Z])/', '$1-', $file ) );
63
+ $path = $base_dir . $file . '.php';
64
 
65
+ if ( file_exists( $path ) ) {
66
+ require $path;
67
  }
68
  }
69
  );
includes/connect-plugins.php CHANGED
@@ -36,6 +36,10 @@ class ConnectPlugins {
36
  add_filter( 'pll_home_url_white_list', array( $this, 'elementor_home_url_white_list' ) );
37
  add_filter( 'home_url', array( $this, 'home_url_language_dir_slash' ), 11, 2 );
38
 
 
 
 
 
39
  if ( is_admin() ) {
40
 
41
  // All langs for template conditions & global widgets.
@@ -385,6 +389,55 @@ class ConnectPlugins {
385
 
386
  }
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  /**
389
  * Elementor editor script
390
  *
36
  add_filter( 'pll_home_url_white_list', array( $this, 'elementor_home_url_white_list' ) );
37
  add_filter( 'home_url', array( $this, 'home_url_language_dir_slash' ), 11, 2 );
38
 
39
+ // Fix search url for Search Form widget.
40
+ add_action( 'elementor/frontend/widget/before_render', array( $this, 'add_search_form_home_url_filter' ) );
41
+ add_action( 'elementor/frontend/widget/after_render', array( $this, 'remove_search_form_home_url_filter' ) );
42
+
43
  if ( is_admin() ) {
44
 
45
  // All langs for template conditions & global widgets.
389
 
390
  }
391
 
392
+ /**
393
+ * Replace home_url with correct language search url
394
+ *
395
+ * Only for Elementor Search Form that uses home_url() in form action.
396
+ *
397
+ * @since 2.0.6
398
+ *
399
+ * @param string $url
400
+ * @param string $path
401
+ * @return string
402
+ */
403
+ function search_form_home_url_filter( $url, $path ) {
404
+
405
+ return function_exists( 'PLL' ) ? PLL()->curlang->search_url : $url;
406
+
407
+ }
408
+
409
+ /**
410
+ * Add home_url() filter before render Search Form
411
+ *
412
+ * @since 2.0.6
413
+ *
414
+ * @param Element_Base $element
415
+ * @return void
416
+ */
417
+ function add_search_form_home_url_filter( $element ) {
418
+
419
+ if ( 'search-form' === $element->get_name() ) {
420
+ add_filter( 'home_url', array( $this, 'search_form_home_url_filter' ), 10, 2 );
421
+ }
422
+
423
+ }
424
+
425
+ /**
426
+ * Remove home_url() filter after render Search Form
427
+ *
428
+ * @since 2.0.6
429
+ *
430
+ * @param Element_Base $element
431
+ * @return void
432
+ */
433
+ function remove_search_form_home_url_filter( $element ) {
434
+
435
+ if ( 'search-form' === $element->get_name() ) {
436
+ remove_filter( 'home_url', array( $this, 'search_form_home_url_filter' ) );
437
+ }
438
+
439
+ }
440
+
441
  /**
442
  * Elementor editor script
443
  *