PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
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 2.30.0 All 255 releases
← All changes | src/Subscriptions/Endpoints/Endpoint.php +8 -32 2.30.04.16.9 View file →
@@ -3,9 +3,8 @@
3 3 namespace Give\Subscriptions\Endpoints;
4 4
5 5 use Give\API\RestRoute;
6 6 use WP_Error;
7 -use WP_REST_Request;
8 7
9 8 abstract class Endpoint implements RestRoute
10 9 {
11 10 /**
@@ -24,33 +23,10 @@
24 23 return filter_var($value, FILTER_VALIDATE_INT);
25 24 }
26 25
27 26 /**
28 - * @param string $param
29 - * @param WP_REST_Request $request
30 - * @param string $key
31 - * @since 2.20.0
32 - *
33 - * @return bool
34 - */
35 - public function validateDate($param, $request, $key)
36 - {
37 - // Check that date is valid, and formatted YYYY-MM-DD
38 - list($year, $month, $day) = explode('-', $param);
39 - $valid = checkdate($month, $day, $year);
40 -
41 - // If checking end date, check that it is after start date
42 - if ('end' === $key) {
43 - $start = date_create($request->get_param('start'));
44 - $end = date_create($request->get_param('end'));
45 - $valid = $start <= $end ? $valid : false;
46 - }
47 -
48 - return $valid;
49 - }
50 -
51 - /**
52 27 * Check user permissions
28 + * @since 4.3.1 updates permissions
53 29 * @since 2.20.0
54 30 *
55 31 * @return bool|WP_Error
56 32 */
@@ -55,17 +31,17 @@
55 31 * @return bool|WP_Error
56 32 */
57 33 public function permissionsCheck()
58 34 {
59 - if (!current_user_can('edit_posts')) {
60 - return new WP_Error(
61 - 'rest_forbidden',
62 - esc_html__('You dont have the right permissions to view Donors', 'give'),
63 - ['status' => $this->authorizationStatusCode()]
64 - );
35 + if (current_user_can('manage_options') || current_user_can('edit_give_payments')) {
36 + return true;
65 37 }
66 38
67 - return true;
39 + return new WP_Error(
40 + 'rest_forbidden',
41 + __("You don't have permission to view Subscriptions", 'give'),
42 + ['status' => is_user_logged_in() ? 403 : 401]
43 + );
68 44 }
69 45
70 46 /**
71 47 * Sets up the proper HTTP status code for authorization.