| | |
| | | namespace JVBase\managers\SEO; |
| | | |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Post; |
| | | use WP_Term; |
| | | use WP_User; |
| | |
| | | */ |
| | | private function isRelatedPostsField(string $fieldName): bool |
| | | { |
| | | if (!defined('JVB_CONTENT')) { |
| | | $posts = Registrar::getRegistered('post'); |
| | | if (empty($posts)) { |
| | | return false; |
| | | } |
| | | |
| | | // Check if field name matches any plural content type |
| | | foreach (JVB_CONTENT as $type => $config) { |
| | | $plural = strtolower($config['plural'] ?? ''); |
| | | if ($plural && $fieldName === $plural) { |
| | | foreach ($posts as $post) { |
| | | $registrar = Registrar::getInstance($post); |
| | | if ($registrar && strtolower($registrar->getPlural()) === $fieldName){ |
| | | return true; |
| | | } |
| | | } |
| | |
| | | */ |
| | | private function isRelatedTermsField(string $fieldName): bool |
| | | { |
| | | if (!defined('JVB_TAXONOMY')) { |
| | | |
| | | $posts = Registrar::getRegistered('term'); |
| | | if (empty($posts)) { |
| | | return false; |
| | | } |
| | | |
| | | // Check if field name matches any plural taxonomy |
| | | foreach (JVB_TAXONOMY as $taxonomy => $config) { |
| | | $plural = strtolower($config['plural'] ?? ''); |
| | | if ($plural && $fieldName === $plural) { |
| | | foreach ($posts as $post) { |
| | | $registrar = Registrar::getInstance($post); |
| | | if ($registrar && strtolower($registrar->getPlural()) === $fieldName){ |
| | | return true; |
| | | } |
| | | } |
| | |
| | | */ |
| | | private function getPostTypeFromPluralName(string $pluralName): ?string |
| | | { |
| | | if (!defined('JVB_CONTENT')) { |
| | | |
| | | $posts = Registrar::getRegistered('post'); |
| | | if (empty($posts)) { |
| | | return null; |
| | | } |
| | | |
| | | foreach (JVB_CONTENT as $type => $config) { |
| | | $plural = strtolower($config['plural'] ?? ''); |
| | | if ($plural === $pluralName) { |
| | | return $type; |
| | | foreach ($posts as $post) { |
| | | $registrar = Registrar::getInstance($post); |
| | | if ($registrar && strtolower($registrar->getPlural()) === $pluralName){ |
| | | return $post; |
| | | } |
| | | } |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | |
| | | */ |
| | | private function getTaxonomyFromPluralName(string $pluralName): ?string |
| | | { |
| | | if (!defined('JVB_TAXONOMY')) { |
| | | |
| | | $posts = Registrar::getRegistered('term'); |
| | | if (empty($posts)) { |
| | | return null; |
| | | } |
| | | |
| | | foreach (JVB_TAXONOMY as $taxonomy => $config) { |
| | | $plural = strtolower($config['plural'] ?? ''); |
| | | if ($plural === $pluralName) { |
| | | return $taxonomy; |
| | | foreach ($posts as $post) { |
| | | $registrar = Registrar::getInstance($post); |
| | | if ($registrar && strtolower($registrar->getPlural()) === $pluralName){ |
| | | return $post; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | $typeKey = str_replace(BASE, '', $this->contentType); |
| | | |
| | | if ($this->objectType === 'post' && defined('JVB_CONTENT')) { |
| | | $this->fieldDefinitions = JVB_CONTENT[$typeKey]['fields'] ?? []; |
| | | } elseif ($this->objectType === 'term' && defined('JVB_TAXONOMY')) { |
| | | $this->fieldDefinitions = JVB_TAXONOMY[$typeKey]['fields'] ?? []; |
| | | } elseif ($this->objectType === 'user' && defined('JVB_USER')) { |
| | | $this->fieldDefinitions = JVB_USER[$typeKey]['fields'] ?? []; |
| | | $registrar = Registrar::getInstance($this->contentType)); |
| | | if ($registrar) { |
| | | $this->fieldDefinitions = $registrar->getFields(); |
| | | } |
| | | } |
| | | } |