Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A more powerful example of what you can do with an Illuminated WordPress Plugin
<?php
namespace YourPlugin;
use YourPlugin\Notifications\PostSaved;
/**
* Your plugin inherits everything that a Laravel container can do.
* Like, sending messages on Slack using Laravel's Notification framework.
*/
class YourPlugin extends \FatPanda\Illuminate\WordPress\Plugin
{
/**
* This function is automatically discovered and hooked
* into WordPress' "save_post" event.
*/
function onSavePost($post_id)
{
if (wp_is_post_revision($post_id)) {
return false;
} else {
$this->notifyPostSaved(get_post($post_id));
}
}
/**
* Send a notification to Slack that this post was saved.
*/
protected function notifyPostSaved($post)
{
$this->notification->send($this->currentuser, new PostSaved($post));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment