check_nonce() ) { $api = new Api; $response = $api->request( $_POST ); wp_send_json($response); } else { die('Wrong nonce'); } } private function check_nonce() { $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : ''; $action = isset( $_POST['action'] ) ? sanitize_text_field( $_POST['action'] ) : ''; return wp_verify_nonce( $nonce, $action ); } } new Ajax();