PluginProbe
Import WP – CSV & XML Import Export for WordPress / trunk
Import WP – CSV & XML Import Export for WordPress vtrunk
2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 trunk 0.1.6 All 142 releases
jc-importer / class / Common / UI / AdminNotices.php

AdminNotices.php in Import WP – CSV & XML Import Export for WordPress trunk, at class/Common/UI/AdminNotices.php

64 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImportWP\Common\UI;
4
5 use ImportWP\Common\AddonAPI\AddonManager;
6
7 class AdminNotices
8 {
9
10 public function __construct()
11 {
12 add_action('admin_init', [__CLASS__, 'dismiss_notices'], 20);
13 add_action('admin_notices', [__CLASS__, 'display_notices']);
14 }
15
16 public static function dismiss_notices()
17 {
18
19 if (isset($_GET['iwp-hide-notice']) && isset($_GET['_iwp_notice_nonce'])) {
20
21 if (! wp_verify_nonce(sanitize_key(wp_unslash($_GET['_iwp_notice_nonce'])), 'importwp_hide_notices_nonce')) {
22 wp_die(esc_html__('Action failed. Please refresh the page and retry.', 'importwp'));
23 }
24
25 $notice_name = sanitize_text_field(wp_unslash($_GET['iwp-hide-notice']));
26
27 update_user_meta(get_current_user_id(), 'dismissed_' . $notice_name . '_notice', true);
28
29 wp_safe_redirect(remove_query_arg(['iwp-hide-notice', '_iwp_notice_nonce']));
30 exit;
31 }
32 }
33
34 // dismiss notices
35 public static function display_notices()
36 {
37 global $pagenow;
38 $screen = get_current_screen();
39
40 if ($screen->id != 'tools_page_importwp' && !in_array($pagenow, ['index.php', 'plugins.php'])) {
41 return;
42 }
43
44 $addons = AddonManager::instance()->getAddonList();
45 foreach ($addons as $addon) {
46
47 $notice_name = 'iwp_available_addon_' . $addon['slug'];
48
49 if (get_user_meta(get_current_user_id(), 'dismissed_' . $notice_name . '_notice', true)) {
50 continue;
51 }
52
53 $class = 'notice notice-warning is-dismissible';
54 $text = sprintf('We have noticed that you are using Import WP with %1$s. To ensure compatibility, we recommend you use', $addon['name']);
55 $plugin_name = sprintf('Import WP %1$s Addon', $addon['name']);
56
57 printf('<div class="%1$s">
58 <a href="%5$s" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a>
59 <p>%2$s <a href="%4$s" target="_blank">%3$s</a>.</p>
60 </div>', esc_attr($class), esc_html($text), esc_html($plugin_name), esc_url($addon['url']), esc_url(wp_nonce_url(add_query_arg('iwp-hide-notice', $notice_name), 'importwp_hide_notices_nonce', '_iwp_notice_nonce')));
61 }
62 }
63 }
64