PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 4.0.0
WP 2FA – Two-factor authentication for WordPress v4.0.0
4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / classes / Admin / class-plugin-updated-notice.php
wp-2fa / includes / classes / Admin Last commit date
AdminSettings 18 hours ago Controllers 18 hours ago Fly-Out 18 hours ago Helpers 18 hours ago Methods 18 hours ago Settings 18 hours ago SettingsPages 18 hours ago Views 18 hours ago class-about-us.php 18 hours ago class-docs-and-support.php 18 hours ago class-free-support-notice.php 18 hours ago class-help-contact-us.php 18 hours ago class-license-page.php 18 hours ago class-new-interface-notice.php 18 hours ago class-plugin-updated-notice.php 18 hours ago class-premium-features.php 18 hours ago class-profile-section-renderer.php 18 hours ago class-settings-page.php 18 hours ago class-setup-wizard.php 18 hours ago class-top-bar-banner.php 18 hours ago class-user-listing.php 18 hours ago class-user-notices.php 18 hours ago class-user-profile.php 18 hours ago class-user-registered.php 18 hours ago class-wizard-integration.php 18 hours ago index.php 18 hours ago
class-plugin-updated-notice.php
111 lines
1 <?php
2 /**
3 * Responsible for WP2FA update notices.
4 *
5 * @package wp2fa
6 * @subpackage user-utils
7 * @copyright 2026 Melapress
8 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
9 * @link https://wordpress.org/plugins/wp-2fa/
10 */
11
12 namespace WP2FA\Admin;
13
14 use WP2FA\Utils\Settings_Utils;
15 use WP2FA\Admin\Helpers\WP_Helper;
16 use WP2FA\Utils\Abstract_Migration;
17
18 /**
19 * Plugin_Updated_Notice class with user notification filters
20 *
21 * @since 2.7.0
22 */
23 if ( ! class_exists( '\WP2FA\Admin\Plugin_Updated_Notice' ) ) {
24 /**
25 * Plugin_Updated_Notice - Class for displaying notices to our users.
26 */
27 class Plugin_Updated_Notice {
28
29 /**
30 * Lets set things up
31 *
32 * @since 2.7.0
33 */
34 public static function init() {
35 \add_action( 'admin_notices', array( __CLASS__, 'plugin_update_banner' ), 30 );
36 \add_action( 'network_admin_notices', array( __CLASS__, 'plugin_update_banner' ), 30 );
37 if ( Settings_Utils::get_option( Abstract_Migration::UPGRADE_NOTICE, false ) ) {
38 \add_action( 'wp_ajax_dismiss_update_notice', array( __CLASS__, 'dismiss_update_notice' ) );
39 }
40 }
41
42 /**
43 * The nag content
44 *
45 * @since 2.7.0
46 * @return void
47 */
48 public static function plugin_update_banner() {
49 return;
50 global $current_screen;
51
52 if ( ! isset( $current_screen ) ) {
53 return;
54 }
55
56 $screen = \get_current_screen();
57
58 if ( in_array( $screen->base, WP_Helper::PLUGIN_PAGES, true ) && Settings_Utils::get_option( Abstract_Migration::UPGRADE_NOTICE, false ) ) {
59 include_once WP_2FA_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'Free' . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'plugin-update-card.php';
60 ?>
61 <script type="text/javascript">
62 //<![CDATA[
63 if ('scrollRestoration' in history) {
64 history.scrollRestoration = 'manual';
65 }
66
67 jQuery(document).ready(function( $ ) {
68 jQuery( 'body' ).on( 'click', '.wp-2fa-plugin-update-close', function ( e ) {
69 e.preventDefault();
70 var nonce = jQuery( '.wp-2fa-plugin-update' ).data( 'nonce' );
71
72 jQuery.ajax({
73 type: 'POST',
74 url: '<?php echo esc_url( \admin_url( 'admin-ajax.php' ) ); ?>',
75 data: {
76 action: 'dismiss_update_notice',
77 nonce : nonce,
78 },
79 success: function ( result ) {
80 jQuery( '.wp-2fa-plugin-update' ).slideUp( 300 );
81 }
82 });
83 });
84 });
85 //]]>
86 </script>
87 <?php
88 }
89 }
90
91 /**
92 * Handle notice dismissal.
93 *
94 * @since 2.7.0
95 * @return void
96 */
97 public static function dismiss_update_notice() {
98 // Grab POSTed data.
99 $nonce = isset( $_POST['nonce'] ) ? \sanitize_text_field( \wp_unslash( $_POST['nonce'] ) ) : false;
100 // Check nonce.
101 if ( ! \current_user_can( 'manage_options' ) || empty( $nonce ) || ! \wp_verify_nonce( $nonce, 'dismiss_upgrade_notice' ) ) {
102 \wp_send_json_error( esc_html__( 'Nonce Verification Failed.', 'wp-2fa' ) );
103 }
104
105 Settings_Utils::delete_option( Abstract_Migration::UPGRADE_NOTICE );
106
107 \wp_send_json_success( esc_html__( 'Complete.', 'wp-2fa' ) );
108 }
109 }
110 }
111