request_security_check( $nonce ); if ( ! empty( $security_check ) ) { wp_send_json_error( $security_check ); } $action = sanitize_text_field( $_POST['action_name'] ) ?? ''; if ( in_array( $action, Admin_Actions::ACTIONS_LIST, true ) ) { setcookie( $action, $action, time() + ( 86400 ), '/' ); wp_send_json_success( $action ); } else { wp_send_json_error( 'Invalid action' ); } } /** * @param $nonce * * @return false|string */ public function request_security_check( $nonce ) { if ( ! wp_verify_nonce( $nonce, 'hts-ajax-nonce' ) ) { return 'Invalid nonce'; } if ( ! current_user_can( 'manage_options' ) ) { return 'Lack of permissions'; } return false; } }