PluginProbe
Polylang / 3.7.7
Polylang v3.7.7
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | admin/admin-notices.php +52 -26 3.03.7.7 View file →
@@ -31,9 +31,9 @@
31 31 * Setup actions
32 32 *
33 33 * @since 2.3.9
34 34 *
35 - * @param object $polylang
35 + * @param object $polylang The Polylang object.
36 36 */
37 37 public function __construct( $polylang ) {
38 38 $this->options = &$polylang->options;
39 39
@@ -96,12 +96,15 @@
96 96 * Should we display notices on this screen?
97 97 *
98 98 * @since 2.3.9
99 99 *
100 - * @param string $notice The notice name.
100 + * @param string $notice The notice name.
101 + * @param array $allowed_screens The screens allowed to display the notice.
102 + * If empty, default screens are used, i.e. dashboard, plugins, languages, strings and settings.
103 + *
101 104 * @return bool
102 105 */
103 - protected function can_display_notice( $notice ) {
106 + protected function can_display_notice( string $notice, array $allowed_screens = array() ) {
104 107 $screen = get_current_screen();
105 108
106 109 if ( empty( $screen ) ) {
107 110 return false;
@@ -106,12 +109,21 @@
106 109 if ( empty( $screen ) ) {
107 110 return false;
108 111 }
109 112
110 - $screen_id = sanitize_title( __( 'Languages', 'polylang' ) );
113 + if ( empty( $allowed_screens ) ) {
114 + $screen_id = sanitize_title( __( 'Languages', 'polylang' ) );
115 + $allowed_screens = array(
116 + 'dashboard',
117 + 'plugins',
118 + 'toplevel_page_mlang',
119 + $screen_id . '_page_mlang_strings',
120 + $screen_id . '_page_mlang_settings',
121 + );
122 + }
111 123
112 124 /**
113 - * Filter admin notices which can be displayed
125 + * Filters admin notices which can be displayed.
114 126 *
115 127 * @since 2.7.0
116 128 *
117 129 * @param bool $display Whether the notice should be displayed or not.
@@ -116,30 +128,17 @@
116 128 *
117 129 * @param bool $display Whether the notice should be displayed or not.
118 130 * @param string $notice The notice name.
119 131 */
120 - return apply_filters(
121 - 'pll_can_display_notice',
122 - in_array(
123 - $screen->id,
124 - array(
125 - 'dashboard',
126 - 'plugins',
127 - 'toplevel_page_mlang',
128 - $screen_id . '_page_mlang_strings',
129 - $screen_id . '_page_mlang_settings',
130 - )
131 - ),
132 - $notice
133 - );
132 + return apply_filters( 'pll_can_display_notice', in_array( $screen->id, $allowed_screens, true ), $notice );
134 133 }
135 134
136 135 /**
137 - * Stores a dismissed notice in database
136 + * Stores a dismissed notice in the database.
138 137 *
139 138 * @since 2.3.9
140 139 *
141 - * @param string $notice
140 + * @param string $notice Notice name.
142 141 * @return void
143 142 */
144 143 public static function dismiss( $notice ) {
145 144 $dismissed = get_option( 'pll_dismissed_notices', array() );
@@ -176,19 +175,28 @@
176 175 */
177 176 public function display_notices() {
178 177 if ( current_user_can( 'manage_options' ) ) {
179 178 // Core notices
180 - if ( defined( 'WOOCOMMERCE_VERSION' ) && ! defined( 'PLLWC_VERSION' ) && $this->can_display_notice( 'pllwc' ) && ! $this->is_dismissed( 'pllwc' ) ) {
179 + if ( defined( 'WOOCOMMERCE_VERSION' ) && ! defined( 'PLLWC_VERSION' ) && $this->can_display_notice( 'pllwc' ) && ! static::is_dismissed( 'pllwc' ) ) {
181 180 $this->pllwc_notice();
182 181 }
183 182
184 - if ( ! defined( 'POLYLANG_PRO' ) && $this->can_display_notice( 'review' ) && ! $this->is_dismissed( 'review' ) && ! empty( $this->options['first_activation'] ) && time() > $this->options['first_activation'] + 15 * DAY_IN_SECONDS ) {
183 + if ( ! defined( 'POLYLANG_PRO' ) && $this->can_display_notice( 'review' ) && ! static::is_dismissed( 'review' ) && ! empty( $this->options['first_activation'] ) && time() > $this->options['first_activation'] + 15 * DAY_IN_SECONDS ) {
185 184 $this->review_notice();
186 185 }
187 186
187 + $allowed_screen = sanitize_title( __( 'Languages', 'polylang' ) ) . '_page_mlang_strings';
188 + if (
189 + ( ! empty( $this->options['previous_version'] ) && version_compare( $this->options['previous_version'], '3.7.0', '<' ) )
190 + && $this->can_display_notice( 'empty-strings-translations', (array) $allowed_screen )
191 + && ! static::is_dismissed( 'empty-strings-translations' )
192 + ) {
193 + $this->empty_strings_translations_notice();
194 + }
195 +
188 196 // Custom notices
189 - foreach ( $this->get_notices() as $notice => $html ) {
190 - if ( $this->can_display_notice( $notice ) && ! $this->is_dismissed( $notice ) ) {
197 + foreach ( static::get_notices() as $notice => $html ) {
198 + if ( $this->can_display_notice( $notice ) && ! static::is_dismissed( $notice ) ) {
191 199 ?>
192 200 <div class="pll-notice notice notice-info">
193 201 <?php
194 202 $this->dismiss_button( $notice );
@@ -233,9 +241,9 @@
233 241 <?php
234 242 printf(
235 243 /* translators: %1$s is link start tag, %2$s is link end tag. */
236 244 esc_html__( 'We have noticed that you are using Polylang with WooCommerce. To ensure compatibility, we recommend you use %1$sPolylang for WooCommerce%2$s.', 'polylang' ),
237 - '<a href="https://polylang.pro/downloads/polylang-for-woocommerce/">',
245 + '<a href="https://polylang.pro/pricing/polylang-for-woocommerce/">',
238 246 '</a>'
239 247 );
240 248 ?>
241 249 </p>
@@ -262,8 +270,26 @@
262 270 '<a href="https://wordpress.org/support/plugin/polylang/reviews/?rate=5#new-post">',
263 271 '</a>'
264 272 );
265 273 ?>
274 + </p>
275 + </div>
276 + <?php
277 + }
278 +
279 + /**
280 + * Displays a notice about the empty strings translations.
281 + *
282 + * @since 3.7
283 + *
284 + * @return void
285 + */
286 + private function empty_strings_translations_notice() {
287 + ?>
288 + <div class="pll-notice notice notice-info">
289 + <?php $this->dismiss_button( 'empty-strings-translations' ); ?>
290 + <p>
291 + <?php esc_html_e( 'Translations matching the original string are shown as empty in the table. Untranslated content remains unchanged.', 'polylang' ); ?>
266 292 </p>
267 293 </div>
268 294 <?php
269 295 }