diff --git a/wp-content/plugins/feed-import/post.php b/wp-content/plugins/feed-import/post.php index 2e468842..3a6d323c 100644 --- a/wp-content/plugins/feed-import/post.php +++ b/wp-content/plugins/feed-import/post.php @@ -33,6 +33,7 @@ function save() { } $this->update_metadata(); $this->attach_image(); + do_action('feed_import_post_saved', $this); } function has_updates() { diff --git a/wp-content/themes/mediasanctuary/functions.php b/wp-content/themes/mediasanctuary/functions.php index 80111849..505ffb83 100644 --- a/wp-content/themes/mediasanctuary/functions.php +++ b/wp-content/themes/mediasanctuary/functions.php @@ -466,4 +466,20 @@ function feed_import_post_date($date, $post) { } else { return 'publish'; } -}, 10, 2); \ No newline at end of file +}, 10, 2); + +add_action('feed_import_post_saved', function($post) { + if (! defined('SLACK_WEBHOOK')) { + return false; + } + $edit_url = home_url("/wp-admin/post.php?post=$post->id&action=edit"); + $payload = [ + 'type' => 'mrkdwn', + 'text' => "Imported <$edit_url|{$post->title()}> from <{$post->data['link']}|soundcloud.com>"; + ]; + $rsp = wp_remote_post(SLACK_WEBHOOK, [ + 'body' => [ + 'payload' => json_encode($payload) + ] + ]); +}); \ No newline at end of file