AddCampaignFormFromRequest.php
1 year ago
AddNewBadgeToAdminMenuItem.php
1 year ago
ArchiveCampaignFormsAsDraftStatus.php
1 year ago
ArchiveCampaignPagesAsDraftStatus.php
1 year ago
AssignDuplicatedFormToCampaign.php
1 year ago
AssociateCampaignPageWithCampaign.php
1 year ago
ConvertQueryDataToCampaign.php
1 year ago
CreateCampaignPage.php
1 year ago
CreateDefaultCampaignForm.php
1 year ago
CreateDefaultLayoutForCampaignPage.php
1 year ago
EnqueueCampaignPageEditorAssets.php
1 year ago
FormInheritsCampaignGoal.php
1 year ago
LoadCampaignDetailsAssets.php
1 year ago
LoadCampaignOptions.php
1 year ago
LoadCampaignsListTableAssets.php
1 year ago
PreventDeleteDefaultForm.php
1 year ago
RedirectLegacyCreateFormToCreateCampaign.php
1 year ago
RegisterCampaignBlocks.php
1 year ago
RegisterCampaignEntity.php
1 year ago
RegisterCampaignIdRestField.php
1 year ago
RegisterCampaignShortcodes.php
1 year ago
RenderDonateButton.php
1 year ago
ReplaceGiveFormsCptLabels.php
1 year ago
UnarchiveCampaignFormAsPublishStatus.php
1 year ago
LoadCampaignOptions.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Campaigns\Actions; |
| 4 | |
| 5 | use Give\API\REST\V3\Routes\Campaigns\ValueObjects\CampaignRoute; |
| 6 | |
| 7 | /** |
| 8 | * The purpose of this action is to have a centralized place for localizing options used on many different places |
| 9 | * by campaign scripts (list tables, blocks, etc.) |
| 10 | * |
| 11 | * @since 4.0.0 |
| 12 | */ |
| 13 | class LoadCampaignOptions |
| 14 | { |
| 15 | public function __invoke() |
| 16 | { |
| 17 | wp_register_script('give-campaign-options', false); |
| 18 | |
| 19 | wp_localize_script('give-campaign-options', 'GiveCampaignOptions', |
| 20 | [ |
| 21 | 'isAdmin' => is_admin(), |
| 22 | 'adminUrl' => admin_url(), |
| 23 | 'apiRoot' => rest_url(CampaignRoute::NAMESPACE . '/' . CampaignRoute::CAMPAIGNS), |
| 24 | 'apiNonce' => wp_create_nonce('wp_rest'), |
| 25 | 'campaignsAdminUrl' => admin_url('edit.php?post_type=give_forms&page=give-campaigns'), |
| 26 | 'currency' => give_get_currency(), |
| 27 | 'currencySymbol' => give_currency_symbol(), |
| 28 | 'isRecurringEnabled' => defined('GIVE_RECURRING_VERSION') |
| 29 | ? GIVE_RECURRING_VERSION |
| 30 | : null, |
| 31 | 'admin' => is_admin() |
| 32 | ? [ |
| 33 | 'showCampaignInteractionNotice' => !get_user_meta(get_current_user_id(), 'givewp_show_campaign_interaction_notice', true), |
| 34 | 'showFormGoalNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_form_goal_notice', true), |
| 35 | 'showExistingUserIntroNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_existing_user_intro_notice', true) && |
| 36 | version_compare((string)get_option('give_version_upgraded_from', '4.0.0'), '4.0.0', '<'), |
| 37 | 'showCampaignListTableNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_listtable_notice', true), |
| 38 | 'showCampaignFormNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_form_notice', true), |
| 39 | 'showCampaignSettingsNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_settings_notice', true) |
| 40 | ] |
| 41 | : null, |
| 42 | ] |
| 43 | ); |
| 44 | |
| 45 | wp_enqueue_script('give-campaign-options'); |
| 46 | } |
| 47 | } |
| 48 |