PluginProbe
Passster – Password Protect Pages and Content / 4.3.17
Passster – Password Protect Pages and Content v4.3.17
4.3.17 4.3.16 4.3.15 4.3.14 4.3.12 4.3.13 4.3.11 4.3.10 4.3.9 4.3.8 4.3.7 4.3.6 4.3.5 trunk 3.5.4 3.5.5.2 3.5.5.8 3.5.5.9 4.0 4.1.4 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 All 49 releases
← All changes | inc/freemius/includes/managers/class-fs-admin-notice-manager.php +82 -21 3.5.5.2 → 4.3.17 View file →
@@ -159,9 +159,12 @@
159 159 $msg['id'],
160 160 false,
161 161 isset( $msg['wp_user_id'] ) ? $msg['wp_user_id'] : null,
162 162 ! empty( $msg['plugin'] ) ? $msg['plugin'] : null,
163 - $is_network_and_blog_admins
163 + $is_network_and_blog_admins,
164 + isset( $msg['dismissible'] ) ?
165 + $msg['dismissible'] :
166 + null
164 167 );
165 168 }
166 169 }
167 170 }
@@ -190,10 +193,16 @@
190 193 * @author Vova Feldman (@svovaf)
191 194 * @since 1.0.7
192 195 */
193 196 static function _add_sticky_dismiss_javascript() {
197 + $sticky_admin_notice_js_template_name = 'sticky-admin-notice-js.php';
198 +
199 + if ( ! file_exists( fs_get_template_path( $sticky_admin_notice_js_template_name ) ) ) {
200 + return;
201 + }
202 +
194 203 $params = array();
195 - fs_require_once_template( 'sticky-admin-notice-js.php', $params );
204 + fs_require_once_template( $sticky_admin_notice_js_template_name, $params );
196 205 }
197 206
198 207 private static $_added_sticky_javascript = false;
199 208
@@ -223,11 +232,8 @@
223 232 // Only show messages to admins.
224 233 return;
225 234 }
226 235
227 -
228 - $show_admin_notices = ( ! $this->is_gutenberg_page() );
229 -
230 236 foreach ( $this->_notices as $id => $msg ) {
231 237 if ( isset( $msg['wp_user_id'] ) && is_numeric( $msg['wp_user_id'] ) ) {
232 238 if ( get_current_user_id() != $msg['wp_user_id'] ) {
233 239 continue;
@@ -268,9 +274,9 @@
268 274 */
269 275 $show_notice = call_user_func_array( 'fs_apply_filter', array(
270 276 $this->_module_unique_affix,
271 277 'show_admin_notice',
272 - $show_admin_notices,
278 + $this->show_admin_notices(),
273 279 $msg
274 280 ) );
275 281
276 282 if ( true !== $show_notice ) {
@@ -323,8 +329,32 @@
323 329 return false;
324 330 }
325 331
326 332 /**
333 + * Check if admin notices should be shown on page. E.g., we don't want to show notices in the Visual Editor.
334 + *
335 + * @author Xiaheng Chen (@xhchen)
336 + * @since 2.4.2
337 + *
338 + * @return bool
339 + */
340 + function show_admin_notices() {
341 + global $pagenow;
342 +
343 + if ( 'about.php' === $pagenow ) {
344 + // Don't show admin notices on the About page.
345 + return false;
346 + }
347 +
348 + if ( $this->is_gutenberg_page() ) {
349 + // Don't show admin notices in Gutenberg (visual editor).
350 + return false;
351 + }
352 +
353 + return true;
354 + }
355 +
356 + /**
327 357 * Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
328 358 *
329 359 * @author Vova Feldman (@svovaf)
330 360 * @since 1.0.4
@@ -338,8 +368,10 @@
338 368 * @param number|null $wp_user_id
339 369 * @param string|null $plugin_title
340 370 * @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network
341 371 * and blog admin pages.
372 + * @param bool|null $is_dismissible
373 + * @param array $data
342 374 *
343 375 * @uses add_action()
344 376 */
345 377 function add(
@@ -350,9 +382,11 @@
350 382 $id = '',
351 383 $store_if_sticky = true,
352 384 $wp_user_id = null,
353 385 $plugin_title = null,
354 - $is_network_and_blog_admins = false
386 + $is_network_and_blog_admins = false,
387 + $is_dismissible = null,
388 + $data = array()
355 389 ) {
356 390 $notices_type = $this->get_notices_type();
357 391
358 392 if ( empty( $this->_notices ) ) {
@@ -370,16 +404,18 @@
370 404 $id = md5( $title . ' ' . $message . ' ' . $type );
371 405 }
372 406
373 407 $message_object = array(
374 - 'message' => $message,
375 - 'title' => $title,
376 - 'type' => $type,
377 - 'sticky' => $is_sticky,
378 - 'id' => $id,
379 - 'manager_id' => $this->_id,
380 - 'plugin' => ( ! is_null( $plugin_title ) ? $plugin_title : $this->_title ),
381 - 'wp_user_id' => $wp_user_id,
408 + 'message' => $message,
409 + 'title' => $title,
410 + 'type' => $type,
411 + 'sticky' => $is_sticky,
412 + 'id' => $id,
413 + 'manager_id' => $this->_id,
414 + 'plugin' => ( ! is_null( $plugin_title ) ? $plugin_title : $this->_title ),
415 + 'wp_user_id' => $wp_user_id,
416 + 'dismissible' => $is_dismissible,
417 + 'data' => $data
382 418 );
383 419
384 420 if ( $is_sticky && $store_if_sticky ) {
385 421 $this->_sticky_storage->{$id} = $message_object;
@@ -392,10 +428,11 @@
392 428 * @author Vova Feldman (@svovaf)
393 429 * @since 1.0.7
394 430 *
395 431 * @param string|string[] $ids
432 + * @param bool $store
396 433 */
397 - function remove_sticky( $ids ) {
434 + function remove_sticky( $ids, $store = true ) {
398 435 if ( ! is_array( $ids ) ) {
399 436 $ids = array( $ids );
400 437 }
401 438
@@ -400,9 +437,9 @@
400 437 }
401 438
402 439 foreach ( $ids as $id ) {
403 440 // Remove from sticky storage.
404 - $this->_sticky_storage->remove( $id );
441 + $this->_sticky_storage->remove( $id, $store );
405 442
406 443 if ( isset( $this->_notices[ $id ] ) ) {
407 444 unset( $this->_notices[ $id ] );
408 445 }
@@ -436,26 +473,50 @@
436 473 * @param number|null $wp_user_id
437 474 * @param string|null $plugin_title
438 475 * @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network
439 476 * and blog admin pages.
477 + * @param bool $is_dimissible
478 + * @param array $data
440 479 */
441 - function add_sticky( $message, $id, $title = '', $type = 'success', $wp_user_id = null, $plugin_title = null, $is_network_and_blog_admins = false ) {
480 + function add_sticky( $message, $id, $title = '', $type = 'success', $wp_user_id = null, $plugin_title = null, $is_network_and_blog_admins = false, $is_dimissible = true, $data = array() ) {
442 481 if ( ! empty( $this->_module_unique_affix ) ) {
443 482 $message = fs_apply_filter( $this->_module_unique_affix, "sticky_message_{$id}", $message );
444 483 $title = fs_apply_filter( $this->_module_unique_affix, "sticky_title_{$id}", $title );
445 484 }
446 485
447 - $this->add( $message, $title, $type, true, $id, true, $wp_user_id, $plugin_title, $is_network_and_blog_admins );
486 + $this->add( $message, $title, $type, true, $id, true, $wp_user_id, $plugin_title, $is_network_and_blog_admins, $is_dimissible, $data );
448 487 }
449 488
450 489 /**
490 + * Retrieves the data of an sticky notice.
491 + *
492 + * @author Leo Fajardo (@leorw)
493 + * @since 2.4.3
494 + *
495 + * @param string $id Message ID.
496 + *
497 + * @return array|null
498 + */
499 + function get_sticky( $id ) {
500 + return isset( $this->_sticky_storage->{$id} ) ?
501 + $this->_sticky_storage->{$id} :
502 + null;
503 + }
504 +
505 + /**
451 506 * Clear all sticky messages.
452 507 *
453 508 * @author Vova Feldman (@svovaf)
454 509 * @since 1.0.8
510 + *
511 + * @param bool $is_temporary @since 2.5.1
455 512 */
456 - function clear_all_sticky() {
457 - $this->_sticky_storage->clear_all();
513 + function clear_all_sticky( $is_temporary = false ) {
514 + if ( $is_temporary ) {
515 + $this->_notices = array();
516 + } else {
517 + $this->_sticky_storage->clear_all();
518 + }
458 519 }
459 520
460 521 #--------------------------------------------------------------------------------
461 522 #region Helper Method