PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.2
YayMail – WooCommerce Email Customizer v4.3.2
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
← All changes | src/Abstracts/BaseController.php +5 -8 trunk4.3.2 View file →
@@ -11,9 +11,9 @@
11 11 *
12 12 * @return bool
13 13 */
14 14 public function permission_callback() {
15 - return current_user_can( 'manage_options' );
15 + return current_user_can( 'manage_woocommerce' );
16 16 }
17 17
18 18 /**
19 19 * Returns response when verify nonce failed
@@ -20,18 +20,14 @@
20 20 *
21 21 * @return \WP_REST_Response
22 22 */
23 23 public function nonce_failure_response() {
24 - // 403 so HTTP clients reject instead of treating this object as payload
25 - // (a 200 here used to flow into array states and crash the customizer).
26 24 return new \WP_REST_Response(
27 25 [
28 26 'success' => false,
29 - 'isError' => true,
30 27 'code' => 'nonce_failure',
31 28 'message' => __( 'Verify nonce failed', 'yaymail' ),
32 - ],
33 - 403
29 + ]
34 30 );
35 31 }
36 32
37 33 /**
@@ -46,9 +42,9 @@
46 42
47 43 /**
48 44 * Function API exec
49 45 *
50 - * @param callable $callable
46 + * @param callable $callable
51 47 * @param \WP_REST_Request $request
52 48 * @return \WP_REST_Response|\WP_Error
53 49 */
54 50 public function exec( $callable, \WP_REST_Request $request ) {
@@ -53,9 +49,9 @@
53 49 */
54 50 public function exec( $callable, \WP_REST_Request $request ) {
55 51
56 52 if ( ! $this->verify_nonce( $request ) ) {
57 - return rest_ensure_response( $this->nonce_failure_response() );
53 + return rest_ensure_request( $this->nonce_failure_response() );
58 54 }
59 55
60 56 try {
61 57 if ( is_callable( $callable ) ) {
@@ -72,5 +68,6 @@
72 68 }
73 69
74 70 return rest_ensure_response( $response );
75 71 }
72 +
76 73 }