| 开发者 | vsmash |
|---|---|
| 更新时间 | 2025年10月3日 10:17 |
| 捐献地址: | 去捐款 |
| PHP版本: | 5.4 及以上 |
| WordPress版本: | 6.8 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
[slackhooker text="Here is a message from my WordPress site"]
or
[slackhooker text="Here is a message" channel="general" username="My WordPress"]
or
[slackhooker text="Here is a message" channel="https://myorg.slack.com/services/xxoxlsodsfsfsdfds#channelname" username="My WordPress"]
Messages are queued last in the PHP process to ensure your other page processing is not interrupted, but you can override:
[slackhooker text="Here is a message from my WordPress." sendnow="true"]
Multiple or custom webhooks supported:
[slackhooker text="Here is a message to multiple webhooks" alsoto="https://hooks.slack.com/services/T03TDTbUF/BBG9SQV6X/abcdefghij,https://hooks.slack.com/services/T03TDTbUF/BBG9SQV6X/abcxxxxxxx"]
Programmatic Examples
Simple text messages:
if(function_exists('\VanillaBeans\SlackHooker\vbean_slackhooker')){ \VanillaBeans\SlackHooker\vbean_slackhooker('Here is my notification'); }
if(function_exists('\VanillaBeans\SlackHooker\vbean_slackhooker')){ \VanillaBeans\SlackHooker\vbean_slackhooker('Here is my notification','mychannel','Username',':specific_icon:'); }
if(function_exists('\VanillaBeans\SlackHooker\vbean_slacknotify')){ \VanillaBeans\SlackHooker\vbean_slacknotify(array('text'=>'Here is my notification','icon'=>':open_mouth:')); }
Formatted data messages (NEW in 5.5.2):
if(function_exists('\VanillaBeans\SlackHooker\vbean_send_data')){ $data = array( 'User ID' => '12345', 'Email' => 'user@example.com', 'Status' => 'Active', 'Last Login' => '2025-10-03 14:30:00' ); \VanillaBeans\SlackHooker\vbean_send_data('User Registration', $data); }
Custom formatted messages with options:
`if(function_exists('\VanillaBeans\SlackHooker\vbean_send_data')){
$data = array(
'Order ID' => '#WC-12345',
'Amount' => '$299.99',
'Customer' => 'John Doe',
'Payment Method' => 'Credit Card'
);
$options = array(
'color' => '#00ff00',
'pretext' => 'New WooCommerce Sale!',
'text' => 'Payment processed successfully'
);
\VanillaBeans\SlackHooker\vbean_send_data('E-commerce Sale', $data, $options);
}`
Building custom attachment messages:
`if(function_exists('\VanillaBeans\SlackHooker\vbean_build_data_message')){
$message = \VanillaBeans\SlackHooker\vbean_build_data_message('System Alert', array(
'Server' => 'web-01.example.com',
'CPU Usage' => '85%',
'Memory' => '3.2GB / 4GB',
'Disk Space' => '75% full'
), array('color' => '#ff9900'));
// Send using existing notification system
Vanilla_Bean_Slack_Hooker::notification_send($message);
}`
Parameters
There are defaults for all except the message. You can specify:
/wp-content/plugins/vanilla-bean-slack-hooker/The plugin supports any webhook-compatible service including Slack, Mattermost, Discord, Microsoft Teams, and custom webhook endpoints. Email addresses can also be used as fallback endpoints.
By default, messages are queued and sent via WordPress cron to avoid blocking page loads. You can force immediate sending by setting sendnow="true" in shortcodes or $now=true in programmatic calls.
Yes! You can configure multiple default endpoints in the admin settings, or specify additional endpoints using the alsoto parameter in shortcodes and programmatic calls.
WooCommerce notifications include order ID, customer name, total amount, payment status, and admin links to view the order details.
Yes, the plugin works on WordPress multisite installations. Each site maintains its own webhook configuration and notification settings.
Absolutely! The new data message functions (5.5.2+) allow you to create rich formatted messages with custom colors, structured data fields, and flexible styling options.