| | |
| | | <?php |
| | | namespace JVBase\managers\SEO; |
| | | |
| | | use JVBase\meta\MetaManager; |
| | | use JVBase\meta\Meta; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | * |
| | | * @param string $fieldName Field name |
| | | * @param mixed $value Raw value |
| | | * @param MetaManager|null $meta Optional MetaManager for accessing related fields |
| | | * @param Meta|null $meta Optional Meta for accessing related fields |
| | | * @return mixed Enhanced value |
| | | */ |
| | | public static function autoResolve(string $fieldName, mixed $value, ?MetaManager $meta = null): mixed |
| | | public static function autoResolve(string $fieldName, mixed $value, ?Meta $meta = null): mixed |
| | | { |
| | | // Skip empty values |
| | | if ($value === null || $value === '') { |
| | |
| | | |
| | | // Rating -> AggregateRating (needs rating_count from meta) |
| | | 'rating' |
| | | => $meta ? self::buildAggregateRating($value, $meta->getValue('rating_count')) : $value, |
| | | => $meta ? self::buildAggregateRating($value, $meta->get('rating_count')) : $value, |
| | | |
| | | // Geo coordinates |
| | | 'geo' |
| | |
| | | * |
| | | * Returns array with 'address' and 'geo' keys |
| | | * |
| | | * @param array $location Location data from MetaManager |
| | | * @param array $location Location data from Meta |
| | | * @return array Schema with address and geo fields |
| | | */ |
| | | public static function buildLocation(array $location): array |
| | |
| | | /** |
| | | * Build opening hours from repeater field |
| | | * |
| | | * @param array $hours Hours data from MetaManager |
| | | * @param array $hours Hours data from Meta |
| | | * @return array Schema with openingHours field |
| | | */ |
| | | public static function buildOpeningHours(array $hours): array |
| | |
| | | /** |
| | | * Build sameAs array from links repeater |
| | | * |
| | | * @param array $links Links data from MetaManager |
| | | * @param array $links Links data from Meta |
| | | * @return array Schema with sameAs field |
| | | */ |
| | | public static function buildSameAs(array $links): array |