AddCampaignFormFromRequest.php
1 year ago
AddNewBadgeToAdminMenuItem.php
1 year ago
AllowGiveRolesToEditCampaignPages.php
5 months ago
ArchiveCampaignFormsAsDraftStatus.php
1 year ago
ArchiveCampaignPagesAsDraftStatus.php
1 year ago
AssignDuplicatedFormToCampaign.php
1 year ago
AssociateCampaignPageWithCampaign.php
1 year ago
CacheCampaignData.php
7 months ago
ConvertQueryDataToCampaign.php
1 year ago
CreateCampaignPage.php
1 year ago
CreateDefaultCampaignForm.php
4 months ago
CreateDefaultLayoutForCampaignPage.php
1 year ago
DuplicateCampaign.php
7 months ago
EnqueueCampaignPageEditorAssets.php
1 year ago
FormInheritsCampaignGoal.php
1 year ago
LoadCampaignAdminOptions.php
11 months ago
LoadCampaignDetailsAssets.php
1 year ago
LoadCampaignPublicOptions.php
11 months ago
LoadCampaignsListTableAssets.php
11 months ago
PreventDeleteDefaultForm.php
1 year ago
RedirectLegacyCreateFormToCreateCampaign.php
4 months ago
RegisterCampaignBlocks.php
6 months ago
RegisterCampaignIdRestField.php
1 year ago
RegisterCampaignShortcodes.php
10 months ago
RenderDonateButton.php
9 months ago
ReplaceGiveFormsCptLabels.php
1 year ago
UnarchiveCampaignFormAsPublishStatus.php
1 year ago
AddNewBadgeToAdminMenuItem.php
46 lines
| 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 |