| | |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\SEO\render\Thing\CreativeWork\MediaObject\ImageObject; |
| | | use JVBase\managers\SEO\render\Thing\Intangible\Quantity\Distance; |
| | | use JVBase\managers\SEO\render\Thing\Intangible\StructuredValue\QuantitativeValue; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | |
| | |
| | | case 'CREATOR': |
| | | return JVB()->seo()->getCreator(); |
| | | case 'name': |
| | | if (is_post_type_archive()) { |
| | | if (!$meta && is_post_type_archive()) { |
| | | $obj = get_queried_object(); |
| | | |
| | | $registrar = Registrar::getInstance($obj->name); |
| | |
| | | } |
| | | break; |
| | | } |
| | | if (str_contains($variable, '.')) { |
| | | |
| | | if (str_contains($variable, '.') && $meta) { |
| | | return self::resolveRelation($variable, $meta); |
| | | } |
| | | if ($meta && $variable === 'post_permalink') { |
| | |
| | | if ($variable === 'post_content') { |
| | | return self::resolvePostContent($variable, $meta); |
| | | } |
| | | |
| | | return match($config['type']) { |
| | | 'upload', 'image', 'gallery' => self::resolveImage($variable, $meta), |
| | | 'selector', 'taxonomy', 'user', 'post' => self::resolveObject($variable, $meta), |
| | |
| | | $relation = array_shift($parts); |
| | | $field = implode('.', $parts); |
| | | |
| | | |
| | | //We need to: |
| | | // 1) Get the id of the item we're fetching (meta value of the $relation) |
| | | if ($relation === 'registrar') { |
| | |
| | | return''; |
| | | } |
| | | $ID = $meta->get($relation); |
| | | if (!$ID || $ID === '') { |
| | | if (empty($ID)) { |
| | | return ''; |
| | | } |
| | | $IDs = explode(',',$ID); |
| | | // 2) Create new Meta for that relation |
| | | $config = $meta->config($relation); |
| | | if (!$config) { |
| | |
| | | error_log('[SEO]Meta Resolver. Could not find type for relation: '.$relation.': '.$field); |
| | | return ''; |
| | | } |
| | | $newMeta = new Meta($ID, $type); |
| | | |
| | | $results = []; |
| | | foreach ($IDs as $ID) { |
| | | $newMeta = new Meta((int)$ID, $type); |
| | | |
| | | // 3) Pass to resolver |
| | | return self::resolve($field, $newMeta); |
| | | $results[] = self::resolveVariable($field, $newMeta); |
| | | } |
| | | return jvbCommaList($results); |
| | | } |
| | | |
| | | protected static function resolvePostContent(string $variable, ?Meta $meta):string{ |
| | |
| | | } |
| | | |
| | | $ignore = ['description', 'name']; |
| | | if (!in_array($property, $ignore)) { |
| | | if (JVB_TESTING && !in_array($property, $ignore)) { |
| | | error_log('[SEO]Resolver - No method found for '.$property.' with value: '.print_r($value, true).'. Defaulting to base Resolver'); |
| | | } |
| | | |
| | |
| | | function () use ($imgID, $img) { |
| | | $imageObject = new ImageObject(); |
| | | $imageObject->setContentUrl($img[0]); |
| | | $width = new Distance(); |
| | | $width->setName($img[1].' px'); |
| | | $width = new QuantitativeValue(); |
| | | $width->setValue($img[1]); |
| | | $width->setUnitText('px'); |
| | | $imageObject->setWidth($width); |
| | | $height = new Distance(); |
| | | $height->setName($img[2].' px'); |
| | | $height = new QuantitativeValue(); |
| | | $height->setValue($img[2]); |
| | | $width->setUnitText('px'); |
| | | $imageObject->setHeight($height); |
| | | |
| | | $image_path = get_attached_file($imgID); |