PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 All 503 releases
jetpack / modules / wpcom-tos / wpcom-tos.php

wpcom-tos.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.1, at modules/wpcom-tos/wpcom-tos.php

45 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handles acceptance of WordPress.com Terms of Service for sites connected to WP.com.
4 *
5 * This is auto-loaded as of Jetpack v8.3 for WP.com connected-sites only.
6 *
7 * @package automattic/jetpack
8 */
9
10 namespace Automattic\Jetpack\TOS;
11
12 use Automattic\Jetpack\Connection\Client;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit( 0 );
16 }
17
18 /**
19 * Makes a request to the WP.com legal endpoint to mark the Terms of Service as accepted.
20 */
21 function accept_tos() {
22 check_ajax_referer( 'wp_ajax_action', '_nonce' );
23
24 $response = Client::wpcom_json_api_request_as_user(
25 '/legal',
26 '2',
27 array(
28 'method' => 'POST',
29 ),
30 array(
31 'action' => 'accept_tos',
32 )
33 );
34
35 if ( is_wp_error( $response ) ) {
36 // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- It takes null, but its phpdoc only says int.
37 wp_send_json_error( array( 'message' => __( 'Could not accept the Terms of Service. Please try again later.', 'jetpack' ) ), null, JSON_UNESCAPED_SLASHES );
38 }
39
40 // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- It takes null, but its phpdoc only says int.
41 wp_send_json_success( $response, null, JSON_UNESCAPED_SLASHES );
42 }
43
44 add_action( 'wp_ajax_jetpack_accept_tos', __NAMESPACE__ . '\accept_tos' );
45