-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JITM: Show ToS update notice (#14541)
- Allows JITMs to trigger AJAX actions when the CTA button is clicked. - Adds an AJAX action for the ToS JITM to mark the ToS as accepted.
- Loading branch information
Showing
5 changed files
with
68 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/** | ||
* Handles acceptance of WordPress.com Terms of Service for sites connected to WP.com. | ||
* | ||
* This is auto-loaded as of Jetpack v8.3 for WP.com connected-sites only. | ||
* | ||
* @package Jetpack | ||
*/ | ||
|
||
namespace Automattic\Jetpack\TOS; | ||
|
||
use Automattic\Jetpack\Connection\Client; | ||
|
||
/** | ||
* Makes a request to the WP.com legal endpoint to mark the Terms of Service as accepted. | ||
*/ | ||
function accept_tos() { | ||
check_ajax_referer( 'wp_ajax_action', '_nonce' ); | ||
|
||
$response = Client::wpcom_json_api_request_as_user( | ||
'/legal', | ||
'2', | ||
array( | ||
'method' => 'POST', | ||
), | ||
array( | ||
'action' => 'accept_tos', | ||
) | ||
); | ||
|
||
if ( is_wp_error( $response ) ) { | ||
wp_send_json_error( array( 'message' => __( 'Could not accept the Terms of Service. Please try again later.', 'jetpack' ) ) ); | ||
wp_die(); | ||
} | ||
|
||
wp_send_json_success( $response ); | ||
|
||
wp_die(); | ||
} | ||
|
||
add_action( 'wp_ajax_jetpack_accept_tos', __NAMESPACE__ . '\accept_tos' ); |
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