إضافة مجموعات وفئات (مع الأمان) باستخدام WP-Discourse أو API؟

عذرًا تيم، لقد كنت بعيدًا الأيام القليلة الماضية. يبدو أن طريقة discourse_request تحتاج إلى تعديل لدعم ذلك. سأقوم بإنشاء طلب سحب (PR) لذلك الأسبوع المقبل، وسيستغرق دمجه أسبوعًا آخر على الأرجح.

إذا كنت تريده في وقت أقرب من ذلك، يمكنك استخدام طرق WP الأساسية كما يلي:

$api_credentials = DiscourseUtilities::get_api_credentials();
if ( is_wp_error( $api_credentials ) ) {
    return $api_credentials;
}

$headers = array(
    'Api-Key'      => sanitize_key( $api_credentials['api_key'] ),
    'Api-Username' => sanitize_text_field( $api_credentials['api_username'] ),
    'Accept'       => 'application/json',
);
$body = array( /* specific to the endpoint you're using */ );
$url = /* The absolute url for the endpoint you're using */;

$opts = array(
   'headers' => $headers,
   'body'    => json_encode( $body ),
   'method'  => 'PUT'
);

$result =  wp_remote_request( $url, $opts );