MP_Addon_Slack::slack_notification( int|string $post_id )

Send Slack Notification Action.


Parameters Parameters

$post_id

(int|string) (Required) post id


Top ↑

Return Return

(int) send slack notification status


Top ↑

Source Source

File: calculator-slack-notification-add-on/inc/MP_Addon_Slack.php

	public function slack_notification( $post_id ) {

		if ( isset( get_option('mortgage_platform_slack')['allow_slack'] ) &&
		   ! empty( $this->hook_url ) &&
		   ! empty( $this->channel )
		) {

			$site_url = get_site_url( '', '/wp-admin/post.php?post=' . $post_id . '&action=edit' );
			if ( $this->options_style['bitly'] ) {
				$bitly    = new MP_Bitly();
				$site_url = $bitly->get_short( $site_url );
			}

			$slack_status = $this->send( $site_url );
			$status = 200 === $slack_status ? 'Success' : $slack_status;

			MP_Logs::set_logs( $post_id, 'slack', $status );

			return $slack_status;

		}
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.