// Construct Slack webhook payload
$slack_message = array(
'blocks' => array(
array(
'type' => 'header',
'text' => array(
'type' => 'plain_text',
'text' => "A comment has been reported"
)
),
array(
'type' => 'divider'
),
array(
'type' => 'section',
'text' => array(
'type' => 'mrkdwn',
'text' => "*Report ID*: {$report->report_id}\n\n*Reporter*: {$reporter_display_name}\n\n*Report*: {$report->report_text}\n*Reported at*: {$report->reported_at}"
)
),
array(
'type' => 'actions',
'elements' => array(
array(
'type' => 'button',
'text' => array(
'type' => 'plain_text',
'text' => 'Edit'
),
'url' => "https://www.ricochet.com"
),
array(
'type' => 'button',
'text' => array(
'type' => 'plain_text',
'text' => 'Preview'
),
'url' => "https://www.ricochet.com"
),
array(
'type' => 'button',
'text' => array(
'type' => 'plain_text',
'text' => 'See all Pending'
),
'url' => "https://www.ricochet.com"
),
)
),
array(
'type' => 'section', // Add a new section with empty text for blank space
'text' => array(
'type' => 'mrkdwn',
'text' => '' // Empty text element
)
)
),
'icon_url' => 'https://cdn.ricochet.com/app/uploads/2024/04/webhook-512.png',
'username' => 'Ricochetbot'
);
// Send Slack webhook
$slack_webhook_url = 'https://hooks.slack.com/services/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';
// Send message to Slack
$response = wp_remote_post($slack_webhook_url, array(
'body' => wp_json_encode($slack_message),
'headers' => array('Content-Type' => 'application/json'),
'timeout' => 15,
'redirection' => 5,
'blocking' => true,
'httpversion' => '1.0',
'sslverify' => false,
));
// Check for errors
if (is_wp_error($response)) {
$error_message = $response->get_error_message();
error_log("Slack webhook error: $error_message");
} else {
error_log("Slack notification sent successfully.");
}
Nike - Dream Crazier | Ricochet
Nike - Dream Crazier | Ricochet
Dismiss this notice Χ
Ricochet is the best place on the internet to discuss the issues of the day, either through commenting on posts or writing your own for our active and dynamic community in a fully moderated environment. In addition, the Ricochet Audio Network offers over 50 original podcasts with new episodes released every day.
There are 7 comments.
But you can't read them because you're not signed in!