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
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
1 year ago
RegisterCampaignBlocks.php
11 months ago
RegisterCampaignEntity.php
1 year ago
RegisterCampaignIdRestField.php
1 year ago
RegisterCampaignShortcodes.php
10 months ago
RenderDonateButton.php
1 year ago
ReplaceGiveFormsCptLabels.php
1 year ago
UnarchiveCampaignFormAsPublishStatus.php
1 year ago
RegisterCampaignIdRestField.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Campaigns\Actions; |
| 4 | |
| 5 | use Give\Campaigns\ValueObjects\CampaignPageMetaKeys; |
| 6 | |
| 7 | /** |
| 8 | * @since 4.0.0 |
| 9 | */ |
| 10 | class RegisterCampaignIdRestField |
| 11 | { |
| 12 | /** |
| 13 | * @since 4.0.0 |
| 14 | */ |
| 15 | public function __invoke() |
| 16 | { |
| 17 | register_rest_field( |
| 18 | 'page', |
| 19 | 'campaignId', |
| 20 | [ |
| 21 | 'get_callback' => function ($object) { |
| 22 | return get_post_meta($object['id'], CampaignPageMetaKeys::CAMPAIGN_ID, true); |
| 23 | }, |
| 24 | 'update_callback' => function ($value, $object) { |
| 25 | return update_post_meta($object->ID, CampaignPageMetaKeys::CAMPAIGN_ID, (int) $value); |
| 26 | }, |
| 27 | 'schema' => [ |
| 28 | 'description' => 'Campaign ID', |
| 29 | 'type' => 'string', |
| 30 | 'context' => ['view', 'edit'], |
| 31 | ], |
| 32 | ] |
| 33 | ); |
| 34 | } |
| 35 | } |
| 36 |