diff --git a/src/Entity/Widget.php b/src/Entity/Widget.php index bb8e0f4a71980a3a26bbc050abde2a674f4d7cc3..3d9e9bb2e1569ba98cd9dd42ecd8e8aa5a4dca12 100644 --- a/src/Entity/Widget.php +++ b/src/Entity/Widget.php @@ -145,7 +145,23 @@ class Widget extends ContentEntityBase implements WidgetInterface { * {@inheritdoc} */ public function isPublished() { - return (bool) $this->getEntityKey('status'); + // Get current language. + $lang = $this->languageManager()->getCurrentLanguage()->getId(); + $is_published = (bool) $this->getEntityKey('status'); + + // Check if translation exists. + if (!$this->hasTranslation($lang)) { + return $is_published; + } + + $translation = $this->getTranslation($lang); + if (is_null($translation) || !$translation->hasField('content_translation_status')) { + return $is_published; + } + // Get translation status. + $t_status = (bool) $translation->getTranslationStatus($lang) && $translation->get('content_translation_status')->value; + + return $t_status && $is_published; } /**