PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Campaigns / Actions / AddNewBadgeToAdminMenuItem.php

AddNewBadgeToAdminMenuItem.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Campaigns/Actions/AddNewBadgeToAdminMenuItem.php

46 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Campaigns\Actions;
4
5 /**
6 * @since 4.0.0
7 */
8 class AddNewBadgeToAdminMenuItem {
9 /**
10 * @return void
11 */
12 public function __invoke()
13 {
14 // only continue if in admin
15 if (!is_admin()) {
16 return;
17 }
18
19 // only show badge for existing users who have upgraded from a version prior to 4.0.0
20 if (version_compare((string)get_option('give_version_upgraded_from', '4.0.0'), '4.0.0', '>=')) {
21 return;
22 }
23
24 // only show badge if not dismissed
25 if (get_option('givewp_new_notification_campaigns_dismissed', false) !== false) {
26 return;
27 }
28
29 // add "NEW" badge to the GiveWP menu item
30 add_action( 'admin_menu', function() {
31 global $menu;
32 array_walk($menu, static function (&$item) {
33 if ($item[0] === 'GiveWP') {
34 $title = $item[0];
35 $item[0] = sprintf('<span>%s </span><span class="update-plugins">%s</span>', $title, __('NEW', 'give'));
36 }
37 });
38 });
39
40 // dismiss the notice when visiting the campaigns list page
41 if (isset($_GET['page']) && $_GET['page'] === 'give-campaigns') {
42 update_option('givewp_new_notification_campaigns_dismissed', true);
43 }
44 }
45 }
46