Skip to content

Commit

Permalink
feat: add notificationToPost helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmikita committed May 27, 2024
1 parent 981799a commit 28aba9b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Integration/WordPressIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ public static function postToNotification($post): ?Notification
return NotificationStore::has($hash) ? NotificationStore::get($hash) : null;
}

/**
* Translates Notification to WP_Post
*
* @since [Next]
* @param string|Notification $notification Notification object or hash.
* @return ?\WP_Post
*/
public static function notificationToPost($notification): ?\WP_Post
{
$hash = $notification instanceof Notification ? $notification->getHash() : $notification;

return get_page_by_path($hash, OBJECT, 'post');
}

/**
* --------------------------
* Loaders & Cache
Expand Down

0 comments on commit 28aba9b

Please sign in to comment.