kollapsminoriteten/wp-content/plugins/jetpack/modules/wpcom-tos/wpcom-tos.php

48 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2020-03-03 18:49:45 +01:00
<?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.
*
2021-04-27 08:32:47 +02:00
* @package automattic/jetpack
2020-03-03 18:49:45 +01:00
*/
namespace Automattic\Jetpack\TOS;
use Automattic\Jetpack\Connection\Client;
2025-08-27 08:44:30 +02:00
if ( ! defined( 'ABSPATH' ) ) {
exit( 0 );
}
2020-03-03 18:49:45 +01:00
/**
* 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 ) ) {
2026-03-31 11:30:59 +02:00
// @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- It takes null, but its phpdoc only says int.
wp_send_json_error( array( 'message' => __( 'Could not accept the Terms of Service. Please try again later.', 'jetpack' ) ), null, JSON_UNESCAPED_SLASHES );
2020-03-03 18:49:45 +01:00
wp_die();
}
2026-03-31 11:30:59 +02:00
// @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- It takes null, but its phpdoc only says int.
wp_send_json_success( $response, null, JSON_UNESCAPED_SLASHES );
2020-03-03 18:49:45 +01:00
wp_die();
}
add_action( 'wp_ajax_jetpack_accept_tos', __NAMESPACE__ . '\accept_tos' );