From 28aba9b611f2a27e8c2161fc16b46be82a2c3a2f Mon Sep 17 00:00:00 2001 From: Jakub Mikita Date: Mon, 27 May 2024 11:50:23 +0200 Subject: [PATCH] feat: add notificationToPost helper method --- src/Integration/WordPressIntegration.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Integration/WordPressIntegration.php b/src/Integration/WordPressIntegration.php index ab435f15..9956c1be 100644 --- a/src/Integration/WordPressIntegration.php +++ b/src/Integration/WordPressIntegration.php @@ -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