Skip to content

Commit

Permalink
Fix send email preview endpoint (#31499)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Jeremy Herve <[email protected]>
  • Loading branch information
lezama and jeherve authored Jun 22, 2023
1 parent b127b8c commit 62e1843
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,20 @@ trait WPCOM_REST_API_Proxy_Request_Trait {
* @return mixed|WP_Error Response from wpcom servers or an error.
*/
public function proxy_request_to_wpcom_as_user( $request, $path = '' ) {
$blog_id = \Jetpack_Options::get_option( 'id' );
$path = '/sites/' . rawurldecode( $blog_id ) . rawurldecode( $this->rest_base ) . ( $path ? '/' . rawurldecode( $path ) : '' );
$api_url = add_query_arg( $request->get_query_params(), $path );
$blog_id = \Jetpack_Options::get_option( 'id' );
$path = '/sites/' . rawurldecode( $blog_id ) . rawurldecode( $this->rest_base ) . ( $path ? '/' . rawurldecode( $path ) : '' );
$query_params = $request->get_query_params();

/*
* A rest_route parameter can be added when using plain permalinks.
* It is not necessary to pass them to WordPress.com,
* and may even cause issues with some endpoints.
* Let's remove it.
*/
if ( isset( $query_params['rest_route'] ) ) {
unset( $query_params['rest_route'] );
}
$api_url = add_query_arg( $query_params, $path );

$request_options = array(
'headers' => array(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix
Comment: fixes send preview email not working when using plain permalink

0 comments on commit 62e1843

Please sign in to comment.