PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 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 All 256 releases
give / src / Promotions / InPluginUpsells / Endpoints / HideSaleBannerRoute.php

HideSaleBannerRoute.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at src/Promotions/InPluginUpsells/Endpoints/HideSaleBannerRoute.php

61 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Promotions\InPluginUpsells\Endpoints;
4
5 use Give\API\RestRoute;
6 use Give\Promotions\InPluginUpsells\SaleBanners;
7 use WP_REST_Request;
8 use WP_REST_Response;
9
10 /**
11 * @since 2.17.0
12 */
13 class HideSaleBannerRoute implements RestRoute
14 {
15 /**
16 * @var string
17 */
18 protected $endpoint = 'sale-banner/hide';
19
20 /**
21 * @inheritDoc
22 */
23 public function registerRoute()
24 {
25 register_rest_route(
26 'give-api/v2',
27 $this->endpoint,
28 [
29 [
30 'methods' => 'POST',
31 'callback' => [$this, 'handleRequest'],
32 'permission_callback' => 'is_user_logged_in',
33 'args' => [
34 'id' => [
35 'type' => 'string',
36 'required' => true,
37 ],
38 ],
39 ],
40 ]
41 );
42 }
43
44 /**
45 * @param WP_REST_Request $request
46 *
47 * @return WP_REST_Response
48 */
49 public function handleRequest(WP_REST_Request $request)
50 {
51 give(SaleBanners::class)->hideBanner(
52 $request->get_param('id') . get_current_user_id()
53 );
54
55 return new WP_REST_Response([
56 'status' => 'success',
57 'message' => 'Banner hidden successfully'
58 ], 200); }
59
60 }
61