Attachment support ( code included )
-
I’m using this plugin to send my own slack notifications, so I’m using the
$GLOBALS['wp_slack']->notifier->notify( new WP_Slack_Event_Payload( $payload ) );
method to submit the payload.It would be great if you could take
attachments
into account when sending the payload. To make this work, the only change needed is in the fileincludes/event-payload.php
:public function toJSON() { $payload = array( 'channel' => $this->setting['channel'], 'username' => $this->setting['username'], 'text' => $this->setting['text'], 'icon_emoji' => $this->setting['icon_emoji'], /** * @todo icon_emoji with ability to select it in setting. */ ); if(array_key_exists('attachments', $this->setting)){ $payload['attachments'] = $this->setting['attachments']; } return json_encode($payload); }
It’s basically moving the current payload into a
$payload
var, and then ifattachments
exists, it adds it to it. That’s all.
- The topic ‘Attachment support ( code included )’ is closed to new replies.