-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support chat using Zendesk Messaging - attempt 2 (#77024)
Reverts #77016 Second attempt at #76777 We're switching from Happy Chat to Zendesk Messaging for live chat support. This PR is big, but it's also the smallest I could get given the scope of the project. Any cleanup of Happy Chat code, old contact forms, etc. will be done as a follow-up. I want to keep this PR as easy to revert as possible if needed.
- Loading branch information
Showing
42 changed files
with
679 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...toolkit/editing-toolkit-plugin/help-center/class-wp-rest-help-center-support-activity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* WP_REST_Help_Center_Support_Activity file. | ||
* | ||
* @package A8C\FSE | ||
*/ | ||
|
||
namespace A8C\FSE; | ||
|
||
use Automattic\Jetpack\Connection\Client; | ||
|
||
/** | ||
* Class WP_REST_Help_Center_Support_Activity. | ||
*/ | ||
class WP_REST_Help_Center_Support_Activity extends \WP_REST_Controller { | ||
/** | ||
* WP_REST_Help_Center_Support_Activity constructor. | ||
*/ | ||
public function __construct() { | ||
$this->namespace = 'help-center'; | ||
$this->rest_base = '/support-activity'; | ||
} | ||
|
||
/** | ||
* Register available routes. | ||
*/ | ||
public function register_rest_route() { | ||
register_rest_route( | ||
$this->namespace, | ||
$this->rest_base, | ||
array( | ||
'methods' => \WP_REST_Server::READABLE, | ||
'callback' => array( $this, 'get_support_activity' ), | ||
'permission_callback' => 'is_user_logged_in', | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Get support activity through Jetpack. | ||
*/ | ||
public function get_support_activity() { | ||
$body = Client::wpcom_json_api_request_as_user( '/support-activity' ); | ||
|
||
if ( is_wp_error( $body ) ) { | ||
return $body; | ||
} | ||
|
||
$response = json_decode( wp_remote_retrieve_body( $body ) ); | ||
|
||
return rest_ensure_response( $response ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 0 additions & 72 deletions
72
...-toolkit/editing-toolkit-plugin/help-center/class-wp-rest-help-center-support-history.php
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...ting-toolkit/editing-toolkit-plugin/help-center/class-wp-rest-help-center-user-fields.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* WP_REST_Help_Center_User_Fields file. | ||
* | ||
* @package A8C\FSE | ||
*/ | ||
|
||
namespace A8C\FSE; | ||
|
||
use Automattic\Jetpack\Connection\Client; | ||
|
||
/** | ||
* Class WP_REST_Help_Center_User_Fields. | ||
*/ | ||
class WP_REST_Help_Center_User_Fields extends \WP_REST_Controller { | ||
/** | ||
* WP_REST_Help_Center_User_Fields constructor. | ||
*/ | ||
public function __construct() { | ||
$this->namespace = 'help-center'; | ||
$this->rest_base = '/zendesk/user-fields'; | ||
} | ||
|
||
/** | ||
* Register available routes. | ||
*/ | ||
public function register_rest_route() { | ||
register_rest_route( | ||
$this->namespace, | ||
$this->rest_base, | ||
array( | ||
'methods' => \WP_REST_Server::CREATABLE, | ||
'callback' => array( $this, 'update_user_fields' ), | ||
'permission_callback' => array( $this, 'permission_callback' ), | ||
'args' => array( | ||
'fields' => array( | ||
'type' => 'object', | ||
'required' => true, | ||
), | ||
), | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Callback to update user fields in Zendesk | ||
* | ||
* @param \WP_REST_Request $request The request sent to the API. | ||
* | ||
* @return WP_REST_Response | ||
*/ | ||
public function update_user_fields( \WP_REST_Request $request ) { | ||
$body = Client::wpcom_json_api_request_as_user( | ||
'help/zendesk/update-user-fields', | ||
'2', | ||
array( | ||
'method' => 'POST', | ||
), | ||
$request['fields'] | ||
); | ||
|
||
if ( is_wp_error( $body ) ) { | ||
return $body; | ||
} | ||
$response = json_decode( wp_remote_retrieve_body( $body ) ); | ||
return rest_ensure_response( $response ); | ||
} | ||
|
||
/** | ||
* Callback to determine whether the user has permission to access. | ||
*/ | ||
public function permission_callback() { | ||
return is_user_logged_in(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.