Polylang - Version 2.3.10

Version Description

(2018-08-16) =

  • Fix Lingotek notice not dismissable
  • Fix fatal error with the widget calendar
Download this release

Release Info

Developer Chouby
Plugin Icon 128x128 Polylang
Version 2.3.10
Comparing to
See all releases

Code changes from version 2.3.9 to 2.3.10

admin/admin-notices.php CHANGED
@@ -56,7 +56,7 @@ class PLL_Admin_Notices {
56
  * @param string $notice Notice name
57
  * @return bool
58
  */
59
- protected function is_dismissed( $notice ) {
60
  $dismissed = get_user_meta( get_current_user_id(), 'pll_dismissed_notices', true );
61
  return is_array( $dismissed ) && in_array( $notice, $dismissed );
62
  }
@@ -82,7 +82,25 @@ class PLL_Admin_Notices {
82
  }
83
 
84
  /**
85
- * Stores dismissed notices in database
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  *
87
  * @since 2.3.9
88
  */
@@ -90,11 +108,7 @@ class PLL_Admin_Notices {
90
  if ( isset( $_GET['pll-hide-notice'], $_GET['_pll_notice_nonce'] ) ) {
91
  $notice = sanitize_key( $_GET['pll-hide-notice'] );
92
  check_admin_referer( $notice, '_pll_notice_nonce' );
93
- if ( ! $dismissed = get_user_meta( get_current_user_id(), 'pll_dismissed_notices', true ) ) {
94
- $dismissed = array();
95
- }
96
- $dismissed[] = $notice;
97
- update_user_meta( get_current_user_id(), 'pll_dismissed_notices', $dismissed );
98
  wp_safe_redirect( remove_query_arg( array( 'pll-hide-notice', '_pll_notice_nonce' ), wp_get_referer() ) );
99
  exit;
100
  }
@@ -113,14 +127,16 @@ class PLL_Admin_Notices {
113
 
114
  // Custom notices
115
  foreach ( $this->get_notices() as $notice => $html ) {
116
- ?>
117
- <div class="pll-notice notice notice-info">
118
- <?php
119
- $this->dismiss_button( $notice );
120
- echo wp_kses_post( $html );
121
  ?>
122
- </div>
123
- <?php
 
 
 
 
 
 
124
  }
125
  }
126
  }
56
  * @param string $notice Notice name
57
  * @return bool
58
  */
59
+ static public function is_dismissed( $notice ) {
60
  $dismissed = get_user_meta( get_current_user_id(), 'pll_dismissed_notices', true );
61
  return is_array( $dismissed ) && in_array( $notice, $dismissed );
62
  }
82
  }
83
 
84
  /**
85
+ * Stores a dismissed notice in database
86
+ *
87
+ * @since 2.3.9
88
+ *
89
+ * @param string $notice
90
+ */
91
+ static public function dismiss( $notice ) {
92
+ if ( ! $dismissed = get_user_meta( get_current_user_id(), 'pll_dismissed_notices', true ) ) {
93
+ $dismissed = array();
94
+ }
95
+
96
+ if ( ! in_array( $notice, $dismissed ) ) {
97
+ $dismissed[] = $notice;
98
+ update_user_meta( get_current_user_id(), 'pll_dismissed_notices', array_unique( $dismissed ) );
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Handle a click on the dismiss button
104
  *
105
  * @since 2.3.9
106
  */
108
  if ( isset( $_GET['pll-hide-notice'], $_GET['_pll_notice_nonce'] ) ) {
109
  $notice = sanitize_key( $_GET['pll-hide-notice'] );
110
  check_admin_referer( $notice, '_pll_notice_nonce' );
111
+ self::dismiss( $notice );
 
 
 
 
112
  wp_safe_redirect( remove_query_arg( array( 'pll-hide-notice', '_pll_notice_nonce' ), wp_get_referer() ) );
113
  exit;
114
  }
127
 
128
  // Custom notices
129
  foreach ( $this->get_notices() as $notice => $html ) {
130
+ if ( ! $this->is_dismissed( $notice ) ) {
 
 
 
 
131
  ?>
132
+ <div class="pll-notice notice notice-info">
133
+ <?php
134
+ $this->dismiss_button( $notice );
135
+ echo wp_kses_post( $html );
136
+ ?>
137
+ </div>
138
+ <?php
139
+ }
140
  }
141
  }
142
  }
include/widget-calendar.php CHANGED
@@ -14,6 +14,7 @@ if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
14
  * @since 0.5
15
  */
16
  class PLL_Widget_Calendar extends WP_Widget_Calendar {
 
17
 
18
  /**
19
  * Outputs the content for the current Calendar widget instance.
@@ -34,7 +35,7 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
34
  if ( $title ) {
35
  echo $args['before_title'] . $title . $args['after_title'];
36
  }
37
- if ( 0 === self::$instance ) {
38
  echo '<div id="calendar_wrap" class="calendar_wrap">';
39
  } else {
40
  echo '<div class="calendar_wrap">';
@@ -43,7 +44,7 @@ class PLL_Widget_Calendar extends WP_Widget_Calendar {
43
  echo '</div>';
44
  echo $args['after_widget'];
45
 
46
- self::$instance++;
47
  }
48
 
49
  /**
14
  * @since 0.5
15
  */
16
  class PLL_Widget_Calendar extends WP_Widget_Calendar {
17
+ protected static $pll_instance = 0; // Can't use $instance of WP_Widget_Calendar as it's private :/
18
 
19
  /**
20
  * Outputs the content for the current Calendar widget instance.
35
  if ( $title ) {
36
  echo $args['before_title'] . $title . $args['after_title'];
37
  }
38
+ if ( 0 === self::$pll_instance ) { #modified#
39
  echo '<div id="calendar_wrap" class="calendar_wrap">';
40
  } else {
41
  echo '<div class="calendar_wrap">';
44
  echo '</div>';
45
  echo $args['after_widget'];
46
 
47
+ self::$pll_instance++; #modified#
48
  }
49
 
50
  /**
lingotek/lingotek.php CHANGED
@@ -30,7 +30,7 @@ class PLL_Lingotek {
30
 
31
  // The admin notice
32
  // Honor old dismissed pointers
33
- if ( ! in_array( 'pll_lgt', explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ) ) {
34
  $content = __( 'You’ve just upgraded to the latest version of Polylang! Would you like to automatically translate your website for free?', 'polylang' );
35
 
36
  $buttons = sprintf(
@@ -49,7 +49,11 @@ class PLL_Lingotek {
49
  ) . $buttons;
50
  }
51
 
52
- PLL_Admin_Notices::add_notice( 'lingotek', '<p>' . $content . '</p><p>' . $buttons . '</p>' );
 
 
 
 
53
  }
54
  }
55
 
@@ -72,6 +76,8 @@ class PLL_Lingotek {
72
  * @since 1.7.7
73
  */
74
  public function display_tab() {
 
 
75
  $activate_link = $this->get_activate_link();
76
 
77
  $links = array(
30
 
31
  // The admin notice
32
  // Honor old dismissed pointers
33
+ if ( ! PLL_Admin_Notices::is_dismissed( 'lingotek' ) && ! in_array( 'pll_lgt', explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ) ) {
34
  $content = __( 'You’ve just upgraded to the latest version of Polylang! Would you like to automatically translate your website for free?', 'polylang' );
35
 
36
  $buttons = sprintf(
49
  ) . $buttons;
50
  }
51
 
52
+ if ( is_plugin_active( self::LINGOTEK ) ) { // Needs /wp-admin/includes/plugin.php to be loaded
53
+ PLL_Admin_Notices::dismiss( 'lingotek' );
54
+ } else {
55
+ PLL_Admin_Notices::add_notice( 'lingotek', '<p>' . $content . '</p><p>' . $buttons . '</p>' );
56
+ }
57
  }
58
  }
59
 
76
  * @since 1.7.7
77
  */
78
  public function display_tab() {
79
+ PLL_Admin_Notices::dismiss( 'lingotek' );
80
+
81
  $activate_link = $this->get_activate_link();
82
 
83
  $links = array(
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.3.9
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
@@ -53,7 +53,7 @@ if ( defined( 'POLYLANG_BASENAME' ) ) {
53
  }
54
  } else {
55
  // Go on loading the plugin
56
- define( 'POLYLANG_VERSION', '2.3.9' );
57
  define( 'PLL_MIN_WP_VERSION', '4.4' );
58
 
59
  define( 'POLYLANG_FILE', __FILE__ ); // this file
3
  /**
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
+ Version: 2.3.10
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
53
  }
54
  } else {
55
  // Go on loading the plugin
56
+ define( 'POLYLANG_VERSION', '2.3.10' );
57
  define( 'PLL_MIN_WP_VERSION', '4.4' );
58
 
59
  define( 'POLYLANG_FILE', __FILE__ ); // this file
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://polylang.pro
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.4
6
  Tested up to: 4.9
7
- Stable tag: 2.3.9
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -76,6 +76,11 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
79
  = 2.3.9 (2018-08-14) =
80
 
81
  * Add a notice to inform about Polylang for WooCommerce
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.4
6
  Tested up to: 4.9
7
+ Stable tag: 2.3.10
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
76
 
77
  == Changelog ==
78
 
79
+ = 2.3.10 (2018-08-16) =
80
+
81
+ * Fix Lingotek notice not dismissable
82
+ * Fix fatal error with the widget calendar
83
+
84
  = 2.3.9 (2018-08-14) =
85
 
86
  * Add a notice to inform about Polylang for WooCommerce