// 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."); }