| | |
| | | use JVBase\managers\SEO\schemas\SchemaDefinition; |
| | | use JVBase\managers\SEO\SchemaReferenceBuilder; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | */ |
| | | private function buildWorksFor(int $userId): ?array |
| | | { |
| | | if (!defined('JVB_TAXONOMY')) { |
| | | $contentTypes = Registrar::getFeatured('is_content', 'term'); |
| | | if (empty($contentTypes)) { |
| | | return null; |
| | | } |
| | | |
| | | // Find taxonomies that represent organizations (is_content taxonomies) |
| | | foreach (JVB_TAXONOMY as $slug => $config) { |
| | | if (empty($config['is_content'])) { |
| | | continue; |
| | | } |
| | | |
| | | $fullTax = BASE . $slug; |
| | | foreach ($contentTypes as $content) { |
| | | $fullTax = jvbCheckBase($content); |
| | | $terms = wp_get_object_terms($userId, $fullTax); |
| | | |
| | | if (is_wp_error($terms) || empty($terms)) { |
| | |
| | | $term = $terms[0]; |
| | | |
| | | return SchemaReferenceBuilder::build( |
| | | $term->term_id, |
| | | 'term', |
| | | null |
| | | $term->term_id |
| | | ); |
| | | } |
| | | |
| | |
| | | */ |
| | | private function buildWorkExamples(int $userId, int $limit = 5): array |
| | | { |
| | | if (!defined('JVB_CONTENT')) { |
| | | $role = jvbUserRole($userId); |
| | | $registrar = Registrar::getInstance($role); |
| | | |
| | | if (!$registrar){ |
| | | return []; |
| | | } |
| | | $types = $registrar->getCreatable(); |
| | | if (empty($types)){ |
| | | return []; |
| | | } |
| | | |
| | | $examples = []; |
| | | |
| | | foreach (JVB_CONTENT as $slug => $config) { |
| | | $fullType = BASE . $slug; |
| | | foreach ($types as $slug) { |
| | | $type = jvbCheckBase($slug); |
| | | |
| | | $posts = get_posts([ |
| | | 'post_type' => $fullType, |
| | | 'post_type' => $type, |
| | | 'author' => $userId, |
| | | 'posts_per_page' => $limit, |
| | | 'post_status' => 'publish', |
| | |
| | | continue; |
| | | } |
| | | |
| | | $refs = SchemaReferenceBuilder::buildMultiple($posts, 'post', null, true); |
| | | $refs = SchemaReferenceBuilder::buildMultiple('post', $posts, null, true); |
| | | |
| | | if (!empty($refs)) { |
| | | $examples = array_merge($examples, $refs); |