Skip to content

Commit

Permalink
Merge pull request #192 from mediasanctuary/feed-import-notify-slack
Browse files Browse the repository at this point in the history
Add 'feed_import_post_saved' action
  • Loading branch information
dphiffer authored Nov 27, 2024
2 parents a9ef7e0 + 3016307 commit 63a1731
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions wp-content/plugins/feed-import/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function save() {
}
$this->update_metadata();
$this->attach_image();
do_action('feed_import_post_saved', $this);
}

function has_updates() {
Expand Down
18 changes: 17 additions & 1 deletion wp-content/themes/mediasanctuary/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,20 @@ function feed_import_post_date($date, $post) {
} else {
return 'publish';
}
}, 10, 2);
}, 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)
]
]);
});

0 comments on commit 63a1731

Please sign in to comment.