• 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 file includes/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 if attachments exists, it adds it to it. That’s all.

    • This topic was modified 6 years, 4 months ago by disagree.
  • The topic ‘Attachment support ( code included )’ is closed to new replies.