PluginProbe
Easy Basic Authentication – Add basic auth to site or admin area / 3.1
Easy Basic Authentication – Add basic auth to site or admin area v3.1
trunk 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.7 1.7.1 1.8 1.8.1 1.9 All 50 releases
easy-basic-authentication / class / easy-basic-authentication-notice-class.php

easy-basic-authentication-notice-class.php in Easy Basic Authentication – Add basic auth to site or admin area 3.1, at class/easy-basic-authentication-notice-class.php

64 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3
4 class easy_basic_authentication_notice_class {
5 public function __construct() {
6 add_action('admin_notices', array($this, 'display_notice'));
7 add_action('wp_ajax_easy_basic_authentication_dismiss_notice', array($this, 'dismiss_notice'));
8 }
9
10 public function display_notice() {
11 $current_user = wp_get_current_user();
12 $user_language = esc_html(get_user_meta($current_user->ID, 'locale', true));
13
14 $notice_dismissed = get_user_meta($current_user->ID, '_easy_basic_authentication_notice_dismissed', true);
15
16 if ($notice_dismissed) {
17 return;
18 }
19
20 ?>
21 <div class="notice notice-info is-dismissible easy-basic-authentication-notice">
22 <p>
23 <?php
24 // Translators: 1: Link to profile, 2: User language, 3: Link to translation instructions
25 printf(
26 wp_kses(
27 /* translators: 1: Link to profile, 2: User language, 3: Link to translation instructions */
28 __('Hi, I\'m <a href="%1$s">Matteo</a>, the developer of <b>Easy Basic Authentication</b>. If you are enjoying and finding this plugin useful, please consider helping us translate it into %2$s. Check if translations are available for your language and start contributing. <a href="%3$s">Click here to find out how you can help</a>.', 'easy-basic-authentication'),
29 array(
30 'a' => array(
31 'href' => array(),
32 ),
33 'b' => array(),
34 )
35 ),
36 esc_url('https://profiles.wordpress.org/matteoenna/'),
37 esc_html($user_language ? $user_language : __('your language', 'easy-basic-authentication')),
38 esc_url('https://make.wordpress.org/polyglots/handbook/translating/')
39 );
40 ?>
41 </p>
42 </div>
43 <script type="text/javascript">
44 jQuery(document).ready(function($) {
45 $('.easy-basic-authentication-notice').on('click', '.notice-dismiss', function() {
46 $.ajax({
47 url: ajaxurl,
48 type: 'POST',
49 data: {
50 action: 'easy_basic_authentication_dismiss_notice'
51 }
52 });
53 });
54 });
55 </script>
56 <?php
57 }
58
59 public function dismiss_notice() {
60 $current_user = wp_get_current_user();
61 update_user_meta($current_user->ID, '_easy_basic_authentication_notice_dismissed', true);
62 wp_die();
63 }
64 }