← All changes
|
jetpack_vendor/automattic/jetpack-jitm/src/class-rest-api-endpoints.php
+15
-3
12.3.2
→
16.3-beta
View file →
| @@ -7,10 +7,16 @@ | ||
| 7 | 7 | |
| 8 | 8 | namespace Automattic\Jetpack\JITMS; |
| 9 | 9 | |
| 10 | 10 | use Automattic\Jetpack\Connection\REST_Connector; |
| 11 | +use WP_Error; | |
| 12 | +use WP_REST_Request; | |
| 11 | 13 | use WP_REST_Server; |
| 12 | 14 | |
| 15 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 16 | + exit( 0 ); | |
| 17 | +} | |
| 18 | + | |
| 13 | 19 | /** |
| 14 | 20 | * Register the JITM's REST API Endpoints and their callbacks. |
| 15 | 21 | */ |
| 16 | 22 | class Rest_Api_Endpoints { |
| @@ -54,9 +60,16 @@ | ||
| 54 | 60 | if ( ! $jitm->jitms_enabled() ) { |
| 55 | 61 | return array(); |
| 56 | 62 | } |
| 57 | 63 | |
| 58 | - return $jitm->get_messages( $request['message_path'], urldecode_deep( $request['query'] ), 'true' === $request['full_jp_logo_exists'] ? true : false ); | |
| 64 | + $query_string = $request['query'] ?? ''; | |
| 65 | + $query_array = array(); | |
| 66 | + if ( ! empty( $query_string ) ) { | |
| 67 | + parse_str( $query_string, $query_array ); | |
| 68 | + $query_array = urldecode_deep( $query_array ); | |
| 69 | + } | |
| 70 | + | |
| 71 | + return $jitm->get_messages( $request['message_path'], $query_array, 'true' === $request['full_jp_logo_exists'] ); | |
| 59 | 72 | } |
| 60 | 73 | |
| 61 | 74 | /** |
| 62 | 75 | * Dismisses a jitm. |
| @@ -84,8 +97,7 @@ | ||
| 84 | 97 | if ( current_user_can( 'read' ) ) { |
| 85 | 98 | return true; |
| 86 | 99 | } |
| 87 | 100 | |
| 88 | - return new \WP_Error( 'invalid_user_permission_jetpack_delete_jitm_message', REST_Connector::get_user_permissions_error_msg(), array( 'status' => rest_authorization_required_code() ) ); | |
| 101 | + return new WP_Error( 'invalid_user_permission_jetpack_delete_jitm_message', REST_Connector::get_user_permissions_error_msg(), array( 'status' => rest_authorization_required_code() ) ); | |
| 89 | 102 | } |
| 90 | - | |
| 91 | 103 | } |