From ef1854382a551e21f735a52d75ffee02a1b348c4 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 11 Aug 2025 20:08:04 +0530 Subject: [PATCH 01/18] feat : add ogtest field plugin --- .gitignore | 2 ++ .../Opengraph/OpengraphServiceInterface.php | 2 +- .../opengraph/src/Extension/opengraph.php | 2 +- .../opengraph/src/Field/OpengraphField.php | 35 ++++++++++++------- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index b936fdbaa9b..58712776cce 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,5 @@ cypress.config.mjs # WebAuthn FIDO metadata cache /plugins/system/webauthn/fido.jwt + +/plugins/fields/ogtest diff --git a/libraries/src/Opengraph/OpengraphServiceInterface.php b/libraries/src/Opengraph/OpengraphServiceInterface.php index e5dccb0e251..4fb31a91e98 100644 --- a/libraries/src/Opengraph/OpengraphServiceInterface.php +++ b/libraries/src/Opengraph/OpengraphServiceInterface.php @@ -81,5 +81,5 @@ interface MappableFieldInterface * * @since __DEPLOY_VERSION__ */ - public function getOpengraphGroup(): OpengraphGroup; + public static function getOpengraphGroup(): OpengraphGroup; } diff --git a/plugins/system/opengraph/src/Extension/opengraph.php b/plugins/system/opengraph/src/Extension/opengraph.php index 80b16da8915..54fe8db2d93 100644 --- a/plugins/system/opengraph/src/Extension/opengraph.php +++ b/plugins/system/opengraph/src/Extension/opengraph.php @@ -265,7 +265,7 @@ public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void ['ignore_request' => true] ); $categoryModel->setState('category.id', $article->catid); - $category = $categoryModel->getItem($article->catid); + $category = $categoryModel->getCategory(); diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index 1e26ee34cd8..0e87fc45471 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -113,18 +113,29 @@ protected function getGroups() // If not native-allowed, see if the field’s plugin implements our interface if (!$accept) { - // Class name convention: PlgFields{Type} - $class = 'PlgFields' . ucfirst($field->type); - - // Ensure plugin autoloaded - PluginHelper::importPlugin('fields'); - - if ( - \class_exists($class) - && \is_subclass_of($class, MappableFieldInterface::class) - && $class::getOpengraphGroup()->value === $fieldType - ) { - $accept = true; + + // Ensure the specific fields plugin is loaded + PluginHelper::importPlugin('fields', $field->type); + + $ucType = ucfirst((string) $field->type); + + // Candidate class names in priority order (modern first, then legacy) + $candidates = [ + "Joomla\\Plugin\\Fields\\{$ucType}\\Extension\\{$ucType}", // J4/5 namespaced + "Joomla\\Plugin\\Fields\\{$ucType}\\Field\\{$ucType}Field", // some third-party patterns + "PlgFields{$ucType}", // legacy non-namespaced + ]; + + $implements = false; + + foreach ($candidates as $fqcn) { + if (\class_exists($fqcn) && \is_subclass_of($fqcn, MappableFieldInterface::class)) { + $implements = ($fqcn::getOpengraphGroup()->value === $fieldType); + if ($implements) { + $accept = true; + break; + } + } } } From e9cc55bf76a84eb060ef0b33a8b1eb6c9858dd5b Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 11 Aug 2025 20:36:14 +0530 Subject: [PATCH 02/18] fix : fixed the imports in OpengraphField.php --- .../Opengraph/OpengraphServiceInterface.php | 31 +++++++++++++++++-- .../opengraph/src/Extension/opengraph.php | 18 +++++++++++ .../opengraph/src/Field/OpengraphField.php | 5 +++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/libraries/src/Opengraph/OpengraphServiceInterface.php b/libraries/src/Opengraph/OpengraphServiceInterface.php index c41ca05bcca..f8e8dae37de 100644 --- a/libraries/src/Opengraph/OpengraphServiceInterface.php +++ b/libraries/src/Opengraph/OpengraphServiceInterface.php @@ -14,6 +14,35 @@ // phpcs:enable PSR1.Files.SideEffects +/** + * Enumerates the logical OpenGraph groups that a custom field-type can + * register itself under. + * + * Third-party field-type plugins should return one of these cases from + * {@see MappableFieldInterface::getOpengraphGroup()} so the System – OpenGraph + * plugin knows how to categorise the field inside its mapping drop-down. + * + * @since __DEPLOY_VERSION__ + */ +enum OpengraphGroup: string +{ +/** Standard textual content (e.g. single-line, multi-line). */ + case TEXT = 'text-fields'; + +/** Image or media file (intro/full images, custom media fields, …). */ + case IMAGE = 'image-fields'; + +/** Alternate-text associated with an image (accessibility / SEO). */ + case IMAGE_ALT = 'image-alt-fields'; +} + + + + + + + + /** * The Opengraph service. * @@ -47,5 +76,3 @@ interface MappableFieldInterface */ public static function getOpengraphGroup(): OpengraphGroup; } - - diff --git a/plugins/system/opengraph/src/Extension/opengraph.php b/plugins/system/opengraph/src/Extension/opengraph.php index 8fc38510f60..5f5698eb1a9 100644 --- a/plugins/system/opengraph/src/Extension/opengraph.php +++ b/plugins/system/opengraph/src/Extension/opengraph.php @@ -368,6 +368,24 @@ private function getOgTagsFromCategoryMappings(Registry $categoryParams, object */ private function getFieldValue(object $article, string $fieldName, array $articleImages): string { + + // Check if it's a custom field + if (strpos($fieldName, 'field.') === 0) { + $customFieldName = substr($fieldName, 6); + // Load custom fields for the article + $customFields = FieldsHelper::getFields('com_content.article', $article, true); + + foreach ($customFields as $field) { + if ($field->name == $customFieldName) { + return $field->value ?? ''; + } + } + + return ''; + } + + // Handle standard article fields + $value = ''; switch ($fieldName) { diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index aa079fb22c2..dcf13e0c856 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -10,10 +10,15 @@ namespace Joomla\Plugin\System\Opengraph\Field; use Joomla\CMS\Factory; +use Joomla\CMS\Fields\FieldsServiceInterface; use Joomla\CMS\Form\Field\GroupedlistField; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; +use Joomla\CMS\Opengraph\MappableFieldInterface; +use Joomla\CMS\Opengraph\OpengraphGroup; use Joomla\CMS\Opengraph\OpengraphServiceInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; From 3193217e1507f78fdb091c4bc6721f611e6b8793 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Fri, 15 Aug 2025 09:24:46 +0530 Subject: [PATCH 03/18] feat : made the OpenGraph field more flexible , removed hardcoded component name --- .../opengraph/src/Field/OpengraphField.php | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index dcf13e0c856..10d90abe6b2 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -59,14 +59,36 @@ protected function getGroups() ]; - $ogOptions = []; - $component = $app->bootComponent('com_content'); + $component = ''; + if ($this->form) { + $component = (string) ($this->form->getValue('extension') + ?: $this->form->getData()->get('extension')); + } + if (!$component) { + $context = (string) ($this->form ? $this->form->getName() : ''); + $component = $context ? explode('.', $context, 2)[0] ?? '' : ''; + if (!$component) { + $component = (string) $app->input->getCmd('option', ''); + } + } + if (!$component) { + return $groups; + } - if (!$component instanceof OpengraphServiceInterface) { + try { + $cmp = $app->bootComponent($component); + } catch (\Throwable $e) { return $groups; } - $fields = $component->getOpengraphFields(); + if (!$cmp instanceof OpengraphServiceInterface) { + return $groups; + } + + + $ogOptions = []; + + $fields = $cmp->getOpengraphFields(); $fieldType = $this->getAttribute('field-type'); if (isset($fields[$fieldType])) { From a8be0cd5fc00057740df63e7a65bf7e38361bd33 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Fri, 15 Aug 2025 09:35:51 +0530 Subject: [PATCH 04/18] fix : changed component name to use dynamic value --- plugins/system/opengraph/src/Field/OpengraphField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index 10d90abe6b2..4d914657fbf 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -103,7 +103,7 @@ protected function getGroups() - if (!$component instanceof FieldsServiceInterface) { + if (!$cmp instanceof FieldsServiceInterface) { return $groups; } From 3af8e0feba1295d79a9d36404b83365b820bd74e Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Tue, 26 Aug 2025 23:16:20 +0530 Subject: [PATCH 05/18] feat : added support for multi article page view --- .gitignore | 1 - .../Opengraph/OpengraphServiceInterface.php | 6 +- .../opengraph/src/Extension/opengraph.php | 304 +++++++++++++----- .../opengraph/src/Field/OpengraphField.php | 11 +- 4 files changed, 226 insertions(+), 96 deletions(-) diff --git a/.gitignore b/.gitignore index 58712776cce..f450ce3a552 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,3 @@ cypress.config.mjs # WebAuthn FIDO metadata cache /plugins/system/webauthn/fido.jwt -/plugins/fields/ogtest diff --git a/libraries/src/Opengraph/OpengraphServiceInterface.php b/libraries/src/Opengraph/OpengraphServiceInterface.php index f8e8dae37de..433eb349fc8 100644 --- a/libraries/src/Opengraph/OpengraphServiceInterface.php +++ b/libraries/src/Opengraph/OpengraphServiceInterface.php @@ -26,13 +26,13 @@ */ enum OpengraphGroup: string { -/** Standard textual content (e.g. single-line, multi-line). */ + /** Standard textual content (e.g. single-line, multi-line). */ case TEXT = 'text-fields'; -/** Image or media file (intro/full images, custom media fields, …). */ + /** Image or media file (intro/full images, custom media fields, …). */ case IMAGE = 'image-fields'; -/** Alternate-text associated with an image (accessibility / SEO). */ + /** Alternate-text associated with an image (accessibility / SEO). */ case IMAGE_ALT = 'image-alt-fields'; } diff --git a/plugins/system/opengraph/src/Extension/opengraph.php b/plugins/system/opengraph/src/Extension/opengraph.php index 5f5698eb1a9..90e912dbdf5 100644 --- a/plugins/system/opengraph/src/Extension/opengraph.php +++ b/plugins/system/opengraph/src/Extension/opengraph.php @@ -16,7 +16,9 @@ use Joomla\CMS\Document\HtmlDocument; use Joomla\CMS\Event\Application\BeforeCompileHeadEvent; use Joomla\CMS\Event\Model\PrepareFormEvent; -use Joomla\CMS\Menu\MenuItem; +use Joomla\CMS\Filter\OutputFilter; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\Opengraph\OpengraphServiceInterface; use Joomla\CMS\Plugin\CMSPlugin; @@ -26,9 +28,7 @@ use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; use Joomla\Event\SubscriberInterface; use Joomla\Registry\Registry; -use Joomla\CMS\Filter\OutputFilter; -use Joomla\CMS\HTML\HTMLHelper; -use Joomla\CMS\Language\Text; + // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects @@ -125,8 +125,8 @@ public function onContentPrepareForm(PrepareFormEvent $event): void } // Get the article id and category id - $input = $app->input; - $articleId = (int) ($input->getInt('id') ?: $form->getValue('id')); + $input = $app->input; + $articleId = (int) ($input->getInt('id') ?: $form->getValue('id')); $categoryId = 0; if ($articleId > 0) { @@ -165,7 +165,7 @@ public function onContentPrepareForm(PrepareFormEvent $event): void $mappings = []; foreach ($catParams as $paramKey => $fieldName) { if (str_starts_with($paramKey, 'og_') && str_ends_with($paramKey, '_field')) { - $ogTag = substr($paramKey, 0, -6); // strip "_field" + $ogTag = substr($paramKey, 0, -6); // strip "_field" $mappings[$ogTag] = $fieldName; } } @@ -175,12 +175,12 @@ public function onContentPrepareForm(PrepareFormEvent $event): void return; // category has no mappings } - $maxTitleLen = $this->params->get('max_title_length', 60); - $maxDescLen = $this->params->get('max_description_length', 160); - $maxAltLen = $this->params->get('max_alt_length', 125); - $mappings["maxTitleLen"] = $maxTitleLen; - $mappings["maxDescLen"] = $maxDescLen; - $mappings["maxAltLen"] = $maxAltLen; + $maxTitleLen = $this->params->get('max_title_length', 60); + $maxDescLen = $this->params->get('max_description_length', 160); + $maxAltLen = $this->params->get('max_alt_length', 125); + $mappings["maxTitleLen"] = $maxTitleLen; + $mappings["maxDescLen"] = $maxDescLen; + $mappings["maxAltLen"] = $maxAltLen; $mappings['twitter_title'] = $mappings['og_title'] ?? ''; $mappings['twitter_description'] = $mappings['og_description'] ?? ''; @@ -225,27 +225,55 @@ public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void } $input = $app->input; - if ( - $input->getCmd('option') !== 'com_content' - || $input->getCmd('view') !== 'article' - || ! $id = $input->getInt('id') - ) { + $view = $input->getCmd('view'); + $id = $input->getInt('id'); + $option = $input->getCmd('option'); + + if ($option !== 'com_content') { return; } - // Plugin globally disabled? + + // Plugin disabled? if (!$this->params->get('enable_og_generation', 1)) { return; } + $ogTags = $this->initializeOgTags(); + + if ($view === 'article' && $id > 0) { + $this->handleSingleArticle($document, $ogTags, $id, $option, $view); + return; + } + $this->handleMultipleArticleView($document, $ogTags, $option, $view, $id); + } + + + + + /** + * Handle Single Article + * Priority: Category Mappings → Article Form → Single Article Menu (if available) + * + * @param HtmlDocument $document + * @param array $ogTags + * @param int $id + * @param string $option + * @param string $view + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function handleSingleArticle(HtmlDocument $document, array $ogTags, int $id, string $option, string $view): void + { /** @var MVCComponent $component */ - $component = $app->bootComponent('com_content'); + $component = $this->app->bootComponent('com_content'); /** @var MVCFactoryInterface $mvcFactory */ $mvcFactory = $component->getMVCFactory(); $params = ComponentHelper::getParams('com_content'); - // Fallback if for some reason it isn’t an object - if (! $params instanceof Registry) { + if (!$params instanceof Registry) { $params = new Registry(); } @@ -256,78 +284,198 @@ public function onBeforeCompileHead(BeforeCompileHeadEvent $event): void $articleModel->setState('article.id', $id); $article = $articleModel->getItem($id); - if (! $article) { + if (!$article) { return; } /** @var CategoryModel $categoryModel */ - $categoryModel = $mvcFactory->createModel( - 'Category', - 'Site', - ['ignore_request' => true] - ); + $categoryModel = $mvcFactory->createModel('Category', 'Site', ['ignore_request' => true]); $categoryModel->setState('category.id', $article->catid); $category = $categoryModel->getCategory(); - - - // Get menu parameters - $menuParams = $this->getMenuParams(); $articleAttribs = new Registry($article->attribs ?? '{}'); $categoryParams = new Registry($category->params ?? '{}'); $articleImages = $this->getAllArticleImages(new Registry($article->images ?? '{}')); + // Set article-specific properties + $ogTags['og_type'] = 'article'; + // Step 1: Get OG tags from category mappings (Priority 1) + $this->getOgTagsFromCategoryMappings($categoryParams, $article, $articleImages, $ogTags); - $ogTags = [ - 'og_title' => '', - 'og_description' => '', - 'og_image' => '', - 'og_image_alt' => '', - 'og_type' => '', - 'og_url' => '', - 'twitter_card' => '', - 'twitter_title' => '', - 'twitter_description' => '', - 'twitter_image' => '', - 'twitter_image_alt' => '', - 'fb_app_id' => '', - 'site_name' => '', - 'url' => '', - 'base_url' => '', - ]; + // Step 2: Get OG tags from article form (Priority 2) + $this->getOgTagsFromParams($articleAttribs, $ogTags); - // Get Global settings + // Step 3: Check if there's a single article menu item and override (Priority 3 - Highest) + $singleArticleMenuParams = $this->getSingleArticleMenuParams($option, $view, $id); + $this->getOgTagsFromParams($singleArticleMenuParams, $ogTags); - $config = $this->app->getConfig(); + // Get default OG tags for any missing values + $this->getDefaultOgTags($ogTags); - $ogTags['fb_app_id'] = $this->params->get('fb_app_id'); - $ogTags['site_name'] = $config->get('sitename'); - $ogTags['base_url'] = Uri::base(); - $ogTags['url'] = Uri::getInstance()->toString(); + // Get Twitter tags + $this->getTwitterOgTags($ogTags); - // get OG tags from category mappings - $this->getOgTagsFromCategoryMappings($categoryParams, $article, $articleImages, $ogTags); + // Sanitize OG tags + $this->sanitizeOgTags($ogTags); - // get OG tags from article form - $this->getOgTagsFromParams($articleAttribs, $ogTags); + // Inject the OpenGraph data into the document + $this->injectOpenGraphData($document, $ogTags); + } - // get OG tags from menu form - $this->getOgTagsFromParams($menuParams, $ogTags); + /** + * Handle Multiple Article Views (category, blog) + * Only check menu form + * + * @param HtmlDocument $document + * @param array $ogTags + * @param string $option + * @param string $view + * @param int|null $categoryId + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function handleMultipleArticleView(HtmlDocument $document, array $ogTags, string $option, string $view, int|null $categoryId): void + { - // get Default OG tags - $this->getDefaultOgTags($ogTags); - // get Twitter tags + $menuParams = $this->getMultipleArticleMenuParams($option, $view, $categoryId); + + + if (!$menuParams->count()) { + return; + } + + // Apply menu parameters only + $this->getOgTagsFromParams($menuParams, $ogTags); + + // Get Twitter tags $this->getTwitterOgTags($ogTags); - // sanitize OG tags + // Sanitize OG tags $this->sanitizeOgTags($ogTags); // Inject the OpenGraph data into the document $this->injectOpenGraphData($document, $ogTags); } + /** + * Get menu parameters only for single article menu items + * + * @param string $option + * @param string $view + * @param int $id + * + * @return Registry + * + * @since __DEPLOY_VERSION__ + */ + private function getSingleArticleMenuParams(string $option, string $view, int $id): Registry + { + $menu = $this->app->getMenu(); + $active = $menu->getActive(); + + // Default empty params + $params = new Registry(); + + if (!$active || !isset($active->query['option']) || $active->query['option'] !== $option) { + return $params; + } + + // Only return params if this is a direct single article menu item + if ( + isset($active->query['view']) && $active->query['view'] === 'article' && + isset($active->query['id']) && (int) $active->query['id'] === $id + ) { + return $active->getParams(); + } + + return $params; + } + + /** + * Get menu parameters for multiple article views (category, blog, featured) + * + * @param string $option + * @param string $view + * @param int|null $categoryId + * + * @return Registry + * + * @since __DEPLOY_VERSION__ + */ + private function getMultipleArticleMenuParams(string $option, string $view, ?int $categoryId = null): Registry + { + $menu = $this->app->getMenu(); + $active = $menu->getActive(); + + // Default empty params + $params = new Registry(); + + if (!$active || !isset($active->query['option']) || $active->query['option'] !== $option) { + return $params; + } + + // Check for direct menu match based on view type + if (isset($active->query['view']) && $active->query['view'] === $view) { + // For category-based views with an ID parameter + if (\in_array($view, ['category', 'categoryblog'], true) && isset($active->query['id'])) { + if ($categoryId !== null && (int) $active->query['id'] === (int) $categoryId) { + return $active->getParams(); + } + } + + // For featured view (no category ID) + elseif ($view === 'featured') { + return $active->getParams(); + } + + // For other multi-article views, just return menu params + else { + return $active->getParams(); + } + } + + return $params; + } + + + /** + * Initialize OG tags array + * + * @return array + * + * @since __DEPLOY_VERSION__ + */ + private function initializeOgTags(): array + { + $config = $this->app->getConfig(); + + return [ + 'og_title' => '', + 'og_description' => '', + 'og_image' => '', + 'og_image_alt' => '', + 'og_type' => 'website', + 'og_url' => Uri::getInstance()->toString(), + 'twitter_card' => 'summary', + 'twitter_title' => '', + 'twitter_description' => '', + 'twitter_image' => '', + 'twitter_image_alt' => '', + 'fb_app_id' => $this->params->get('fb_app_id', ''), + 'site_name' => $config->get('sitename'), + 'url' => Uri::getInstance()->toString(), + 'base_url' => Uri::base(), + ]; + } + + + + + /** * Generates OG metadata values based on category field mapping and article data. @@ -365,6 +513,8 @@ private function getOgTagsFromCategoryMappings(Registry $categoryParams, object * @param array $articleImages * * @return string + * + * @since __DEPLOY_VERSION__ */ private function getFieldValue(object $article, string $fieldName, array $articleImages): string { @@ -444,6 +594,7 @@ private function getFieldValue(object $article, string $fieldName, array $articl * @param Registry $articleImages * * @return array + * * @since __DEPLOY_VERSION__ */ private function getAllArticleImages(Registry $articleImages): array @@ -523,8 +674,8 @@ private function getDefaultOgTags(array &$ogTags): void 'og_description' => $this->params->get('default_og_description'), 'og_image' => $this->params->get('default_og_image'), 'og_image_alt' => $this->params->get('default_og_image_alt'), - 'site_name' => $this->params->get('default_og_site_name'), - 'fb_app_id' => $this->params->get('fb_app_id'), + 'site_name' => $this->params->get('default_og_site_name'), + 'fb_app_id' => $this->params->get('fb_app_id'), ]; foreach ($defaultOgTags as $key => $value) { @@ -727,25 +878,6 @@ private function adjustFieldsGroup(string $filePath, string $newGroup): string return $xml->asXML(); } - /** - * Get the parameters associated with the active menu item - * - * @return Registry - * - * @since __DEPLOY_VERSION__ - */ - private function getMenuParams(): Registry - { - $menu = $this->app->getMenu(); - - $active = $menu?->getActive(); - - if (!$active instanceof MenuItem) { - return new Registry(); - } - - return $menu->getParams($active->id); - } /** * Clean up and normalise all OG / Twitter tag values. diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index 4d914657fbf..ca106e329e8 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -65,7 +65,7 @@ protected function getGroups() ?: $this->form->getData()->get('extension')); } if (!$component) { - $context = (string) ($this->form ? $this->form->getName() : ''); + $context = (string) ($this->form ? $this->form->getName() : ''); $component = $context ? explode('.', $context, 2)[0] ?? '' : ''; if (!$component) { $component = (string) $app->input->getCmd('option', ''); @@ -109,9 +109,9 @@ protected function getGroups() // Allowed field types for each OpenGraph group $allowedFieldTypes = [ - OpengraphGroup::TEXT->value => ['text', 'textarea'], - OpengraphGroup::IMAGE->value => ['media', 'imagelist'], - OpengraphGroup::IMAGE_ALT->value => ['text'], + OpengraphGroup::TEXT->value => ['text', 'textarea'], + OpengraphGroup::IMAGE->value => ['media', 'imagelist'], + OpengraphGroup::IMAGE_ALT->value => ['text'], ]; $nativeTypes = $allowedFieldTypes[$fieldType] ?? []; @@ -136,7 +136,6 @@ protected function getGroups() // If not native-allowed, see if the field’s plugin implements our interface if (!$accept) { - // Ensure the specific fields plugin is loaded PluginHelper::importPlugin('fields', $field->type); @@ -152,7 +151,7 @@ protected function getGroups() $implements = false; foreach ($candidates as $fqcn) { - if (\class_exists($fqcn) && \is_subclass_of($fqcn, MappableFieldInterface::class)) { + if (class_exists($fqcn) && is_subclass_of($fqcn, MappableFieldInterface::class)) { $implements = ($fqcn::getOpengraphGroup()->value === $fieldType); if ($implements) { $accept = true; From 96038a35b2932980153bf047cbad8a2f32dcee2c Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 1 Sep 2025 19:25:33 +0530 Subject: [PATCH 06/18] fix : removed extra line from git ignore file --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index f450ce3a552..b936fdbaa9b 100644 --- a/.gitignore +++ b/.gitignore @@ -107,4 +107,3 @@ cypress.config.mjs # WebAuthn FIDO metadata cache /plugins/system/webauthn/fido.jwt - From ece09347b2604327e15cf4487078d74cb56d72b7 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 11 Aug 2025 20:08:04 +0530 Subject: [PATCH 07/18] feat : add ogtest field plugin --- .gitignore | 2 + .../Opengraph/OpengraphServiceInterface.php | 15 ++++ .../opengraph/src/Field/OpengraphField.php | 74 +++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/.gitignore b/.gitignore index b936fdbaa9b..58712776cce 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,5 @@ cypress.config.mjs # WebAuthn FIDO metadata cache /plugins/system/webauthn/fido.jwt + +/plugins/fields/ogtest diff --git a/libraries/src/Opengraph/OpengraphServiceInterface.php b/libraries/src/Opengraph/OpengraphServiceInterface.php index d8cc2eca98e..c9cf98f4817 100644 --- a/libraries/src/Opengraph/OpengraphServiceInterface.php +++ b/libraries/src/Opengraph/OpengraphServiceInterface.php @@ -31,3 +31,18 @@ interface OpengraphServiceInterface */ public function getOpengraphFields(): array; } + + + + +interface MappableFieldInterface +{ + /** + * Returns the OpenGraph group this field should be listed under. + * + * @return OpengraphGroup One of the enum cases defined in {@see OpengraphGroup}. + * + * @since __DEPLOY_VERSION__ + */ + public static function getOpengraphGroup(): OpengraphGroup; +} diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index 88de25fd638..d8d3c1c18bb 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -97,6 +97,80 @@ protected function getGroups() } + if (!$component instanceof FieldsServiceInterface) { + return $groups; + } + + // Allowed field types for each OpenGraph group + $allowedFieldTypes = [ + OpengraphGroup::TEXT->value => ['text', 'textarea'], + OpengraphGroup::IMAGE->value => ['media', 'imagelist'], + OpengraphGroup::IMAGE_ALT->value => ['text'], + ]; + + $nativeTypes = $allowedFieldTypes[$fieldType] ?? []; + + + + $catId = (int) $this->form->getValue('id'); // editing existing cat + if (!$catId) { + // Creating a new category: use the chosen parent so assignments still work + $catId = (int) $this->form->getValue('parent_id'); + } + + // Dummy item with catid so FieldsService filters by assignment + $scopeItem = $catId ? (object) ['catid' => $catId] : null; + + $customFields = FieldsHelper::getFields('com_content.article', $scopeItem); + $customOptions = []; + + foreach ($customFields as $field) { + $accept = \in_array($field->type, $nativeTypes, true); + + + // If not native-allowed, see if the field’s plugin implements our interface + if (!$accept) { + + // Ensure the specific fields plugin is loaded + PluginHelper::importPlugin('fields', $field->type); + + $ucType = ucfirst((string) $field->type); + + // Candidate class names in priority order (modern first, then legacy) + $candidates = [ + "Joomla\\Plugin\\Fields\\{$ucType}\\Extension\\{$ucType}", // J4/5 namespaced + "Joomla\\Plugin\\Fields\\{$ucType}\\Field\\{$ucType}Field", // some third-party patterns + "PlgFields{$ucType}", // legacy non-namespaced + ]; + + $implements = false; + + foreach ($candidates as $fqcn) { + if (\class_exists($fqcn) && \is_subclass_of($fqcn, MappableFieldInterface::class)) { + $implements = ($fqcn::getOpengraphGroup()->value === $fieldType); + if ($implements) { + $accept = true; + break; + } + } + } + } + + + if (!$accept) { + continue; + } + + + + $label = $field->title . ' (' . $field->name . ')'; + $customOptions[] = HTMLHelper::_('select.option', 'field.' . $field->name, $label); + } + + if (!empty($customOptions)) { + $groups['Custom Fields'] = $customOptions; + } + return $groups; } } From f308e0ea73f39c5e895888b0c662e77834412846 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 11 Aug 2025 20:36:14 +0530 Subject: [PATCH 08/18] fix : fixed the imports in OpengraphField.php --- .../Opengraph/OpengraphServiceInterface.php | 29 +++++++++++++++++++ .../opengraph/src/Extension/opengraph.php | 18 ++++++++++++ .../opengraph/src/Field/OpengraphField.php | 5 ++++ 3 files changed, 52 insertions(+) diff --git a/libraries/src/Opengraph/OpengraphServiceInterface.php b/libraries/src/Opengraph/OpengraphServiceInterface.php index c9cf98f4817..3cf81dea41c 100644 --- a/libraries/src/Opengraph/OpengraphServiceInterface.php +++ b/libraries/src/Opengraph/OpengraphServiceInterface.php @@ -14,6 +14,35 @@ // phpcs:enable PSR1.Files.SideEffects +/** + * Enumerates the logical OpenGraph groups that a custom field-type can + * register itself under. + * + * Third-party field-type plugins should return one of these cases from + * {@see MappableFieldInterface::getOpengraphGroup()} so the System – OpenGraph + * plugin knows how to categorise the field inside its mapping drop-down. + * + * @since __DEPLOY_VERSION__ + */ +enum OpengraphGroup: string +{ +/** Standard textual content (e.g. single-line, multi-line). */ + case TEXT = 'text-fields'; + +/** Image or media file (intro/full images, custom media fields, …). */ + case IMAGE = 'image-fields'; + +/** Alternate-text associated with an image (accessibility / SEO). */ + case IMAGE_ALT = 'image-alt-fields'; +} + + + + + + + + /** * The Opengraph service. * diff --git a/plugins/system/opengraph/src/Extension/opengraph.php b/plugins/system/opengraph/src/Extension/opengraph.php index 6cc08f687b2..25c94b4002c 100644 --- a/plugins/system/opengraph/src/Extension/opengraph.php +++ b/plugins/system/opengraph/src/Extension/opengraph.php @@ -517,6 +517,24 @@ private function getOgTagsFromCategoryMappings(Registry $categoryParams, object */ private function getFieldValue(object $article, string $fieldName, array $articleImages): string { + + // Check if it's a custom field + if (strpos($fieldName, 'field.') === 0) { + $customFieldName = substr($fieldName, 6); + // Load custom fields for the article + $customFields = FieldsHelper::getFields('com_content.article', $article, true); + + foreach ($customFields as $field) { + if ($field->name == $customFieldName) { + return $field->value ?? ''; + } + } + + return ''; + } + + // Handle standard article fields + $value = ''; switch ($fieldName) { diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index d8d3c1c18bb..a8796634923 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -10,10 +10,15 @@ namespace Joomla\Plugin\System\Opengraph\Field; use Joomla\CMS\Factory; +use Joomla\CMS\Fields\FieldsServiceInterface; use Joomla\CMS\Form\Field\GroupedlistField; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; +use Joomla\CMS\Opengraph\MappableFieldInterface; +use Joomla\CMS\Opengraph\OpengraphGroup; use Joomla\CMS\Opengraph\OpengraphServiceInterface; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; From 310ba1f3e4e72e1d3eb8160195b6c3dc793a9189 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Fri, 15 Aug 2025 09:24:46 +0530 Subject: [PATCH 09/18] feat : made the OpenGraph field more flexible , removed hardcoded component name --- plugins/system/opengraph/src/Field/OpengraphField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index a8796634923..52f8991493b 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -65,7 +65,7 @@ protected function getGroups() ?: $this->form->getData()->get('extension')); } if (!$component) { - $context = (string) ($this->form ? $this->form->getName() : ''); + $context = (string) ($this->form ? $this->form->getName() : ''); $component = $context ? explode('.', $context, 2)[0] ?? '' : ''; if (!$component) { $component = (string) $app->input->getCmd('option', ''); From e0ac5629bde20ac1e020da79e844b14d90c4a474 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Fri, 15 Aug 2025 09:35:51 +0530 Subject: [PATCH 10/18] fix : changed component name to use dynamic value --- plugins/system/opengraph/src/Field/OpengraphField.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index 52f8991493b..8289ebe8d38 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -102,7 +102,8 @@ protected function getGroups() } - if (!$component instanceof FieldsServiceInterface) { + + if (!$cmp instanceof FieldsServiceInterface) { return $groups; } From d7b2a27ba1b576c4041ff912037051121042c787 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Tue, 26 Aug 2025 23:16:20 +0530 Subject: [PATCH 11/18] feat : added support for multi article page view --- .gitignore | 1 - libraries/src/Opengraph/OpengraphServiceInterface.php | 6 +++--- plugins/system/opengraph/src/Field/OpengraphField.php | 11 +++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 58712776cce..f450ce3a552 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,3 @@ cypress.config.mjs # WebAuthn FIDO metadata cache /plugins/system/webauthn/fido.jwt -/plugins/fields/ogtest diff --git a/libraries/src/Opengraph/OpengraphServiceInterface.php b/libraries/src/Opengraph/OpengraphServiceInterface.php index 3cf81dea41c..222889ea0b1 100644 --- a/libraries/src/Opengraph/OpengraphServiceInterface.php +++ b/libraries/src/Opengraph/OpengraphServiceInterface.php @@ -26,13 +26,13 @@ */ enum OpengraphGroup: string { -/** Standard textual content (e.g. single-line, multi-line). */ + /** Standard textual content (e.g. single-line, multi-line). */ case TEXT = 'text-fields'; -/** Image or media file (intro/full images, custom media fields, …). */ + /** Image or media file (intro/full images, custom media fields, …). */ case IMAGE = 'image-fields'; -/** Alternate-text associated with an image (accessibility / SEO). */ + /** Alternate-text associated with an image (accessibility / SEO). */ case IMAGE_ALT = 'image-alt-fields'; } diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index 8289ebe8d38..b587833d623 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -65,7 +65,7 @@ protected function getGroups() ?: $this->form->getData()->get('extension')); } if (!$component) { - $context = (string) ($this->form ? $this->form->getName() : ''); + $context = (string) ($this->form ? $this->form->getName() : ''); $component = $context ? explode('.', $context, 2)[0] ?? '' : ''; if (!$component) { $component = (string) $app->input->getCmd('option', ''); @@ -109,9 +109,9 @@ protected function getGroups() // Allowed field types for each OpenGraph group $allowedFieldTypes = [ - OpengraphGroup::TEXT->value => ['text', 'textarea'], - OpengraphGroup::IMAGE->value => ['media', 'imagelist'], - OpengraphGroup::IMAGE_ALT->value => ['text'], + OpengraphGroup::TEXT->value => ['text', 'textarea'], + OpengraphGroup::IMAGE->value => ['media', 'imagelist'], + OpengraphGroup::IMAGE_ALT->value => ['text'], ]; $nativeTypes = $allowedFieldTypes[$fieldType] ?? []; @@ -136,7 +136,6 @@ protected function getGroups() // If not native-allowed, see if the field’s plugin implements our interface if (!$accept) { - // Ensure the specific fields plugin is loaded PluginHelper::importPlugin('fields', $field->type); @@ -152,7 +151,7 @@ protected function getGroups() $implements = false; foreach ($candidates as $fqcn) { - if (\class_exists($fqcn) && \is_subclass_of($fqcn, MappableFieldInterface::class)) { + if (class_exists($fqcn) && is_subclass_of($fqcn, MappableFieldInterface::class)) { $implements = ($fqcn::getOpengraphGroup()->value === $fieldType); if ($implements) { $accept = true; From 0519912f98ae0d921503ea4640487e11a89997ff Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 1 Sep 2025 19:25:33 +0530 Subject: [PATCH 12/18] fix : removed extra line from git ignore file --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index f450ce3a552..b936fdbaa9b 100644 --- a/.gitignore +++ b/.gitignore @@ -107,4 +107,3 @@ cypress.config.mjs # WebAuthn FIDO metadata cache /plugins/system/webauthn/fido.jwt - From 6c4de79564a4538b9db7c3ff27bfabf318ffa92a Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 1 Sep 2025 20:10:55 +0530 Subject: [PATCH 13/18] fix : add missing fieldhelper import --- plugins/system/opengraph/src/Extension/opengraph.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/system/opengraph/src/Extension/opengraph.php b/plugins/system/opengraph/src/Extension/opengraph.php index 25c94b4002c..90e912dbdf5 100644 --- a/plugins/system/opengraph/src/Extension/opengraph.php +++ b/plugins/system/opengraph/src/Extension/opengraph.php @@ -25,6 +25,7 @@ use Joomla\CMS\Uri\Uri; use Joomla\Component\Categories\Administrator\Model\CategoryModel; use Joomla\Component\Content\Administrator\Model\ArticleModel; +use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; use Joomla\Event\SubscriberInterface; use Joomla\Registry\Registry; From 1301bb9330963469b0552ad37277730bec3479a3 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 1 Sep 2025 20:18:46 +0530 Subject: [PATCH 14/18] fix : removed duplicate enum error --- .../Opengraph/OpengraphServiceInterface.php | 39 ++----------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/libraries/src/Opengraph/OpengraphServiceInterface.php b/libraries/src/Opengraph/OpengraphServiceInterface.php index d55fbeca4f7..596e82bda1b 100644 --- a/libraries/src/Opengraph/OpengraphServiceInterface.php +++ b/libraries/src/Opengraph/OpengraphServiceInterface.php @@ -14,34 +14,6 @@ // phpcs:enable PSR1.Files.SideEffects -/** - * Enumerates the logical OpenGraph groups that a custom field-type can - * register itself under. - * - * Third-party field-type plugins should return one of these cases from - * {@see MappableFieldInterface::getOpengraphGroup()} so the System – OpenGraph - * plugin knows how to categorise the field inside its mapping drop-down. - * - * @since __DEPLOY_VERSION__ - */ -enum OpengraphGroup: string -{ -/** Standard textual content (e.g. single-line, multi-line). */ - case TEXT = 'text-fields'; - -/** Image or media file (intro/full images, custom media fields, …). */ - case IMAGE = 'image-fields'; - -/** Alternate-text associated with an image (accessibility / SEO). */ - case IMAGE_ALT = 'image-alt-fields'; -} - - - - - - - /** * Enumerates the logical OpenGraph groups that a custom field-type can @@ -55,23 +27,18 @@ enum OpengraphGroup: string */ enum OpengraphGroup: string { -/** Standard textual content (e.g. single-line, multi-line). */ + /** Standard textual content (e.g. single-line, multi-line). */ case TEXT = 'text-fields'; -/** Image or media file (intro/full images, custom media fields, …). */ + /** Image or media file (intro/full images, custom media fields, …). */ case IMAGE = 'image-fields'; -/** Alternate-text associated with an image (accessibility / SEO). */ + /** Alternate-text associated with an image (accessibility / SEO). */ case IMAGE_ALT = 'image-alt-fields'; } - - - - - /** * The Opengraph service. * From d9e6d4962171a9849cff783887e5899d7bb4a5e7 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 15 Sep 2025 12:48:47 +0530 Subject: [PATCH 15/18] fix : removed the PHPstan and PHPcs errors --- .../src/Extension/ContentComponent.php | 2 +- .../src/Opengraph/MappableFieldInterface.php | 32 +++++++++++++++ libraries/src/Opengraph/OpengraphGroup.php | 36 ++++++++++++++++ .../Opengraph/OpengraphServiceInterface.php | 41 ------------------- .../opengraph/src/Extension/opengraph.php | 12 ++---- 5 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 libraries/src/Opengraph/MappableFieldInterface.php create mode 100644 libraries/src/Opengraph/OpengraphGroup.php diff --git a/administrator/components/com_content/src/Extension/ContentComponent.php b/administrator/components/com_content/src/Extension/ContentComponent.php index 12837192df0..299afb34128 100644 --- a/administrator/components/com_content/src/Extension/ContentComponent.php +++ b/administrator/components/com_content/src/Extension/ContentComponent.php @@ -216,7 +216,7 @@ public function getSchemaorgContexts(): array */ public function getOpengraphFields(): array { - Factory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR); + Factory::getApplication()->getLanguage()->load('com_content', JPATH_ADMINISTRATOR); $fields = [ 'text-fields' => [ diff --git a/libraries/src/Opengraph/MappableFieldInterface.php b/libraries/src/Opengraph/MappableFieldInterface.php new file mode 100644 index 00000000000..369b55153d6 --- /dev/null +++ b/libraries/src/Opengraph/MappableFieldInterface.php @@ -0,0 +1,32 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\CMS\Opengraph; + +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + + +/** + * Interface for fields that can be mapped to OpenGraph groups. + * + * @since __DEPLOY_VERSION__ + */ +interface MappableFieldInterface +{ + /** + * Returns the OpenGraph group this field should be listed under. + * + * @return OpengraphGroup One of the enum cases defined in {@see OpengraphGroup}. + * + * @since __DEPLOY_VERSION__ + */ + public static function getOpengraphGroup(): OpengraphGroup; +} diff --git a/libraries/src/Opengraph/OpengraphGroup.php b/libraries/src/Opengraph/OpengraphGroup.php new file mode 100644 index 00000000000..33834a20d09 --- /dev/null +++ b/libraries/src/Opengraph/OpengraphGroup.php @@ -0,0 +1,36 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\CMS\Opengraph; + +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + +/** + * Enumerates the logical OpenGraph groups that a custom field-type can + * register itself under. + * + * Third-party field-type plugins should return one of these cases from + * {@see MappableFieldInterface::getOpengraphGroup()} so the System – OpenGraph + * plugin knows how to categorise the field inside its mapping drop-down. + * + * @since __DEPLOY_VERSION__ + */ +enum OpengraphGroup: string +{ + /** Standard textual content (e.g. single-line, multi-line). */ + case TEXT = 'text-fields'; + + /** Image or media file (intro/full images, custom media fields, …). */ + case IMAGE = 'image-fields'; + + /** Alternate-text associated with an image (accessibility / SEO). */ + case IMAGE_ALT = 'image-alt-fields'; +} diff --git a/libraries/src/Opengraph/OpengraphServiceInterface.php b/libraries/src/Opengraph/OpengraphServiceInterface.php index 596e82bda1b..3be0ec4ddf1 100644 --- a/libraries/src/Opengraph/OpengraphServiceInterface.php +++ b/libraries/src/Opengraph/OpengraphServiceInterface.php @@ -13,32 +13,6 @@ \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects - - -/** - * Enumerates the logical OpenGraph groups that a custom field-type can - * register itself under. - * - * Third-party field-type plugins should return one of these cases from - * {@see MappableFieldInterface::getOpengraphGroup()} so the System – OpenGraph - * plugin knows how to categorise the field inside its mapping drop-down. - * - * @since __DEPLOY_VERSION__ - */ -enum OpengraphGroup: string -{ - /** Standard textual content (e.g. single-line, multi-line). */ - case TEXT = 'text-fields'; - - /** Image or media file (intro/full images, custom media fields, …). */ - case IMAGE = 'image-fields'; - - /** Alternate-text associated with an image (accessibility / SEO). */ - case IMAGE_ALT = 'image-alt-fields'; -} - - - /** * The Opengraph service. * @@ -56,18 +30,3 @@ interface OpengraphServiceInterface */ public function getOpengraphFields(): array; } - - - - -interface MappableFieldInterface -{ - /** - * Returns the OpenGraph group this field should be listed under. - * - * @return OpengraphGroup One of the enum cases defined in {@see OpengraphGroup}. - * - * @since __DEPLOY_VERSION__ - */ - public static function getOpengraphGroup(): OpengraphGroup; -} diff --git a/plugins/system/opengraph/src/Extension/opengraph.php b/plugins/system/opengraph/src/Extension/opengraph.php index 90e912dbdf5..6c18e4203f8 100644 --- a/plugins/system/opengraph/src/Extension/opengraph.php +++ b/plugins/system/opengraph/src/Extension/opengraph.php @@ -425,15 +425,11 @@ private function getMultipleArticleMenuParams(string $option, string $view, ?int if ($categoryId !== null && (int) $active->query['id'] === (int) $categoryId) { return $active->getParams(); } - } - - // For featured view (no category ID) - elseif ($view === 'featured') { + } elseif ($view === 'featured') { + // For featured view (no category ID) return $active->getParams(); - } - - // For other multi-article views, just return menu params - else { + } else { + // For other multi-article views, just return menu params return $active->getParams(); } } From 236b1bbb1cae9b0d21e2f4240f1853016c250b20 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 15 Sep 2025 13:25:00 +0530 Subject: [PATCH 16/18] fix : phpcs fix --- plugins/system/opengraph/src/Field/OpengraphField.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index 99dd7e7b47a..28bfe2f212f 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -10,7 +10,6 @@ namespace Joomla\Plugin\System\Opengraph\Field; use Joomla\CMS\Factory; - use Joomla\CMS\Fields\FieldsServiceInterface; use Joomla\CMS\Form\Field\GroupedlistField; use Joomla\CMS\HTML\HTMLHelper; @@ -25,7 +24,6 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\Opengraph\OpengraphServiceInterface; - // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects From 02898755b9d046662c2760570103921c194e281f Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 15 Sep 2025 13:31:03 +0530 Subject: [PATCH 17/18] fix : removed extra else statement --- plugins/system/opengraph/src/Extension/opengraph.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/system/opengraph/src/Extension/opengraph.php b/plugins/system/opengraph/src/Extension/opengraph.php index cfc67ecf712..db146727101 100644 --- a/plugins/system/opengraph/src/Extension/opengraph.php +++ b/plugins/system/opengraph/src/Extension/opengraph.php @@ -431,8 +431,6 @@ private function getMultipleArticleMenuParams(string $option, string $view, ?int } else { // For other multi-article views, just return menu params return $active->getParams(); - } else { - return $active->getParams(); } } From ae490ff79451ed7bbeb0a5dba507939091922644 Mon Sep 17 00:00:00 2001 From: shahzan01 Date: Mon, 15 Sep 2025 13:34:35 +0530 Subject: [PATCH 18/18] fix the imports --- plugins/system/opengraph/src/Field/OpengraphField.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/system/opengraph/src/Field/OpengraphField.php b/plugins/system/opengraph/src/Field/OpengraphField.php index 28bfe2f212f..7f58b742ad9 100644 --- a/plugins/system/opengraph/src/Field/OpengraphField.php +++ b/plugins/system/opengraph/src/Field/OpengraphField.php @@ -19,10 +19,6 @@ use Joomla\CMS\Opengraph\OpengraphServiceInterface; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Component\Fields\Administrator\Helper\FieldsHelper; -use Joomla\CMS\Form\Field\GroupedlistField; -use Joomla\CMS\HTML\HTMLHelper; -use Joomla\CMS\Language\Text; -use Joomla\CMS\Opengraph\OpengraphServiceInterface; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die;