| | |
| | | <?php |
| | | namespace JVBase\managers\SEO; |
| | | |
| | | use JVBase\meta\MetaManager; |
| | | use JVBase\meta\Meta; |
| | | use WP_Post; |
| | | use WP_Term; |
| | | use WP_User; |
| | |
| | | private ?int $objectId = null; |
| | | private ?string $objectType = null; |
| | | private ?string $contentType = null; |
| | | private ?MetaManager $meta = null; |
| | | private ?Meta $meta = null; |
| | | private array $context = []; |
| | | private array $fieldDefinitions = []; |
| | | |
| | |
| | | $this->contentType = $contentType; |
| | | |
| | | if ($objectId && $objectType) { |
| | | $this->meta = new MetaManager($objectId, $objectType, $contentType); |
| | | $this->meta = new Meta($objectId, $objectType, $contentType); |
| | | $this->loadFieldDefinitions(); |
| | | } |
| | | |
| | |
| | | return $special; |
| | | } |
| | | |
| | | // Try to get from MetaManager |
| | | // Try to get from Meta.php |
| | | if ($this->meta) { |
| | | $value = $this->meta->getValue($variable); |
| | | $value = $this->meta->get($variable); |
| | | |
| | | // Auto-resolve complex field types via SchemaFieldHelpers |
| | | $value = $this->autoResolveField($variable, $value); |
| | |
| | | } elseif ($this->objectType === 'term' && $this->objectId) { |
| | | $term = get_term($this->objectId); |
| | | if ($term && !is_wp_error($term)) { |
| | | $this->context['term_name'] = $term->name; |
| | | $this->context['term_description'] = $term->description; |
| | | $this->context['term_name'] = html_entity_decode($term->name); |
| | | $this->context['term_description'] = wptexturize($term->description); |
| | | $this->context['taxonomy'] = $term->taxonomy; |
| | | } |
| | | } elseif ($this->objectType === 'user' && $this->objectId) { |