| @@ -12,17 +12,22 @@ | ||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | libxml_use_internal_errors(true); |
| 15 | 15 | |
| 16 | + self::removeNotices('admin_notices'); | |
| 17 | + self::removeNotices('network_admin_notices'); | |
| 18 | + } | |
| 19 | + | |
| 20 | + public static function removeNotices($hook_name) { | |
| 21 | + | |
| 16 | 22 | global $wp_filter; |
| 17 | 23 | |
| 18 | - $hook_name = 'admin_notices'; | |
| 19 | - | |
| 20 | 24 | if (isset($wp_filter[$hook_name])) { |
| 21 | 25 | |
| 22 | 26 | foreach ($wp_filter[$hook_name]->callbacks as $hooks) { |
| 23 | 27 | |
| 24 | 28 | foreach ($hooks as $hook) { |
| 29 | + | |
| 25 | 30 | ob_start(); |
| 26 | 31 | call_user_func_array($hook["function"], []); |
| 27 | 32 | $notice = ob_get_clean(); |
| 28 | 33 | $notice = trim($notice); |
| @@ -31,17 +36,21 @@ | ||
| 31 | 36 | } |
| 32 | 37 | } |
| 33 | 38 | } |
| 34 | 39 | |
| 35 | - remove_all_actions($hook_name); | |
| 40 | + if(in_array($hook_name, ['admin_notices', 'network_admin_notices'])) { | |
| 41 | + remove_all_actions($hook_name); | |
| 42 | + } | |
| 36 | 43 | |
| 37 | - add_action('wpide_inline_scripts', [__CLASS__, 'append_inline_script'], 1); | |
| 44 | + add_action('wpide_inline_scripts', [__CLASS__, 'appendInlineScript'], 1); | |
| 38 | 45 | } |
| 39 | - | |
| 40 | 46 | } |
| 41 | - public static function append_inline_script($scripts): string | |
| 47 | + | |
| 48 | + public static function appendInlineScript($scripts): string | |
| 42 | 49 | { |
| 43 | 50 | |
| 51 | + $ajaxurl = is_network_admin() ? 'ajaxurl + "?_fs_network_admin=true"' : 'ajaxurl + "?_fs_blog_admin=true"'; | |
| 52 | + | |
| 44 | 53 | $scripts .= ' |
| 45 | 54 | (function( $ ) { |
| 46 | 55 | $(function() { |
| 47 | 56 | |
| @@ -61,9 +70,9 @@ | ||
| 61 | 70 | message_id: id |
| 62 | 71 | }; |
| 63 | 72 | |
| 64 | 73 | // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php |
| 65 | - $.post( ajaxurl, data); | |
| 74 | + $.post('.$ajaxurl.', data); | |
| 66 | 75 | |
| 67 | 76 | var event = new CustomEvent("wpide_notice_removed", { detail: index }); |
| 68 | 77 | document.body.dispatchEvent(event); |
| 69 | 78 | |
| @@ -139,18 +148,12 @@ | ||
| 139 | 148 | '<strong>' |
| 140 | 149 | ]; |
| 141 | 150 | $replaceTagEnd = '</strong>'; |
| 142 | 151 | |
| 143 | - $excludeWords = [ | |
| 144 | - 'dismiss', | |
| 145 | - 'Dismiss' | |
| 146 | - ]; | |
| 152 | + $notice = strip_tags($notice, ['a', 'p', 'div', 'span', 'strong', 'br', 'b', 'label', 'ul', 'li']); | |
| 147 | 153 | |
| 148 | - $notice = strip_tags($notice, ['a', 'div', 'span', 'strong', 'br', 'b', 'label', 'ul', 'li']); | |
| 149 | - | |
| 150 | 154 | $notice = str_replace($findTagStart, $replaceTagStart, $notice); |
| 151 | 155 | $notice = str_replace($findTagEnd, $replaceTagEnd, $notice); |
| 152 | - //$notice = str_replace($excludeWords, '', $notice); | |
| 153 | 156 | |
| 154 | 157 | $notice = self::removeEmptyTags($notice); |
| 155 | 158 | |
| 156 | 159 | return [ |