| | |
| | | namespace JVBase\managers; |
| | | |
| | | use JVBase\JVB; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Error; |
| | | use Exception; |
| | | use WP_Post; |
| | |
| | | */ |
| | | public function notifyEveryone(string $type, int|null $action_user_id = null, string $message = '', int|null $target_id = null, string|null $target_type = null, array|null $context = null):bool|WP_Error |
| | | { |
| | | $artists = $this->getUserIDs(array_keys(JVB_USER)); |
| | | $artists = $this->getUserIDs(Registrar::getRegistered('user')); |
| | | return $this->addNotification($artists, $type, $action_user_id, $message, $target_id, $target_type, $context); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // Check if this is a relevant content type |
| | | $content_types = jvbBasedFeedContent(); |
| | | $content_types = array_map(function($type) {return jvbCheckBase($type->getSlug()); }, Registrar::getFeatured('show_feed', 'post')); |
| | | if (!in_array($post->post_type, $content_types)) { |
| | | return; |
| | | } |
| | |
| | | */ |
| | | protected function pluralize(string $content):string |
| | | { |
| | | if (array_key_exists($content, JVB_CONTENT)) { |
| | | return JVB_CONTENT[$content]['plural']; |
| | | } elseif (array_key_exists($content, JVB_TAXONOMY)) { |
| | | return JVB_TAXONOMY[$content]['plural']; |
| | | } elseif (array_key_exists($content, JVB_USER)) { |
| | | return JVB_USER[$content]['plural']; |
| | | } |
| | | return $content; |
| | | $registrar = Registrar::getInstance($content); |
| | | return ($registrar) ? $registrar->getPlural() |
| | | : str_replace('_', ' ', $content.'s'); |
| | | } |
| | | |
| | | /** |
| | |
| | | return array_map(function ($r) { |
| | | return jvbCheckBase(trim($r)); |
| | | }, array_filter($roles, function ($r) { |
| | | return array_key_exists(trim($r), JVB_USER); |
| | | return Registrar::getInstance(trim($r))!== false; |
| | | })); |
| | | } |
| | | |