| 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.6.1 Rename to LoadCampaignAdminOptions |
| 12 |
* @since 4.0.0 |
| 13 |
*/ |
| 14 |
class LoadCampaignAdminOptions |
| 15 |
{ |
| 16 |
public function __invoke() |
| 17 |
{ |
| 18 |
wp_register_script('give-campaign-options', false); |
| 19 |
|
| 20 |
wp_localize_script('give-campaign-options', 'GiveCampaignOptions', |
| 21 |
[ |
| 22 |
'isAdmin' => is_admin(), |
| 23 |
'adminUrl' => admin_url(), |
| 24 |
'apiRoot' => rest_url(CampaignRoute::NAMESPACE . '/' . CampaignRoute::CAMPAIGNS), |
| 25 |
'apiNonce' => wp_create_nonce('wp_rest'), |
| 26 |
'campaignsAdminUrl' => admin_url('edit.php?post_type=give_forms&page=give-campaigns'), |
| 27 |
'currency' => give_get_currency(), |
| 28 |
'currencySymbol' => give_currency_symbol(), |
| 29 |
'isRecurringEnabled' => defined('GIVE_RECURRING_VERSION') |
| 30 |
? GIVE_RECURRING_VERSION |
| 31 |
: null, |
| 32 |
'admin' => is_admin() |
| 33 |
? [ |
| 34 |
'showCampaignInteractionNotice' => !get_user_meta(get_current_user_id(), 'givewp_show_campaign_interaction_notice', true), |
| 35 |
'showFormGoalNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_form_goal_notice', true), |
| 36 |
'showExistingUserIntroNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_existing_user_intro_notice', true) && |
| 37 |
version_compare((string)get_option('give_version_upgraded_from', '4.0.0'), '4.0.0', '<'), |
| 38 |
'showCampaignListTableNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_listtable_notice', true), |
| 39 |
'showCampaignFormNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_form_notice', true), |
| 40 |
'showCampaignSettingsNotice' => !get_user_meta(get_current_user_id(), 'givewp_campaign_settings_notice', true) |
| 41 |
] |
| 42 |
: null, |
| 43 |
] |
| 44 |
); |
| 45 |
|
| 46 |
wp_enqueue_script('give-campaign-options'); |
| 47 |
} |
| 48 |
} |
| 49 |
|