| | |
| | | <?php |
| | | namespace JVBase\managers\Notifications; |
| | | |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\CustomTable; |
| | | use JVBase\managers\Emails; |
| | | use JVBase\managers\NotificationManager; |
| | | use JVBase\managers\queue\Queue; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Error; |
| | | use WP_Query; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; // Exit if accessed directly |
| | |
| | | return; |
| | | } |
| | | |
| | | JVB()->queue()->add( |
| | | Queue::getInstance()->add( |
| | | 'email_notification_digest', |
| | | 0, |
| | | [ |
| | |
| | | if (!in_array($frequency, ['never', 'daily', 'weekly', 'monthly'])) { |
| | | return []; |
| | | } |
| | | return JVB()->notification()->getUsersByFrequency($frequency); |
| | | return NotificationManager::getInstance()->getUsersByFrequency($frequency); |
| | | } |
| | | |
| | | public function processOperation(WP_Error|array $result, object $operation, array $data):WP_Error|array |
| | |
| | | |
| | | protected function generateUserDigest(int $userID, string $frequency):string|false |
| | | { |
| | | $subscription = JVB()->notification()->getUserSubscriptions($userID, $frequency); |
| | | $subscription = NotificationManager::getInstance()->getUserSubscriptions($userID, $frequency); |
| | | |
| | | //TODO |
| | | $notifications = JVB()->notification()->getUserNotifications($userID); |
| | | $notifications = NotificationManager::getInstance()->getUserNotifications($userID); |
| | | |
| | | if (empty($subscription) && empty($notifications)) { |
| | | return false; |
| | |
| | | $image = sprintf( |
| | | '<a href="%s">%s</a>', |
| | | $url, |
| | | JVB()->email()->image($image[0], get_post_meta($img, '_wp_attachment_image_alt', true)) |
| | | Emails::getInstance()->image($image[0], get_post_meta($img, '_wp_attachment_image_alt', true)) |
| | | ); |
| | | $t = sprintf( |
| | | '<a href="%s">%s</a>', |
| | | $url, |
| | | $m->get('post_title') |
| | | ); |
| | | $output[] = JVB()->email()->card($image, $t); |
| | | $output[] = Emails::getInstance()->card($image, $t); |
| | | } |
| | | |
| | | $final = JVB()->email()->button($goTo, 'Want to See More?'); |
| | | return JVB()->email()->grid($output, 3, 'New from '.$title,'',$final); |
| | | $final = Emails::getInstance()->button($goTo, 'Want to See More?'); |
| | | return Emails::getInstance()->grid($output, 3, 'New from '.$title,'',$final); |
| | | } |
| | | |
| | | protected function getTermUpdates(int $termID, string $type, string $frequency):string|false |
| | |
| | | $image = sprintf( |
| | | '<a href="%s">%s</a>', |
| | | $url, |
| | | JVB()->email()->image($image[0], get_post_meta($img, '_wp_attachment_image_alt', true)) |
| | | Emails::getInstance()->image($image[0], get_post_meta($img, '_wp_attachment_image_alt', true)) |
| | | ); |
| | | $t = sprintf( |
| | | '<a href="%s">%s</a>', |
| | | $url, |
| | | $m->get('post_title') |
| | | ); |
| | | $output[] = JVB()->email()->card($image, $t); |
| | | $output[] = Emails::getInstance()->card($image, $t); |
| | | } |
| | | |
| | | $final = JVB()->email()->button($goTo, 'See More'); |
| | | return JVB()->email()->grid($output, 3, 'New in '.$title, '', $final); |
| | | $final = Emails::getInstance()->button($goTo, 'See More'); |
| | | return Emails::getInstance()->grid($output, 3, 'New in '.$title, '', $final); |
| | | } |
| | | } |