When plugins like Thrive Visual Editor transform content for non-logged users, headings may be removed from the filtered content. This fix uses raw post_content as fallback when filtered content has no headings but raw content does. Also removes temporary debug logging added for diagnosis. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace ROITheme\Shared\Application\UseCases\EvaluatePageVisibility;
|
|
|
|
use ROITheme\Shared\Domain\Contracts\PageTypeDetectorInterface;
|
|
use ROITheme\Shared\Domain\Contracts\PageVisibilityRepositoryInterface;
|
|
use ROITheme\Shared\Domain\Constants\VisibilityDefaults;
|
|
|
|
/**
|
|
* Caso de uso: Evaluar si un componente debe mostrarse en la página actual
|
|
*
|
|
* @package ROITheme\Shared\Application\UseCases\EvaluatePageVisibility
|
|
*/
|
|
final class EvaluatePageVisibilityUseCase
|
|
{
|
|
// NOTA: Usa VisibilityDefaults::DEFAULT_VISIBILITY para cumplir DRY
|
|
|
|
public function __construct(
|
|
private readonly PageTypeDetectorInterface $pageTypeDetector,
|
|
private readonly PageVisibilityRepositoryInterface $visibilityRepository
|
|
) {}
|
|
|
|
/**
|
|
* Evalua si el componente debe mostrarse en la pagina actual
|
|
*/
|
|
public function execute(string $componentName): bool
|
|
{
|
|
$config = $this->visibilityRepository->getVisibilityConfig($componentName);
|
|
|
|
if (empty($config)) {
|
|
// Usar defaults especificos por componente si existen
|
|
$config = VisibilityDefaults::getForComponent($componentName);
|
|
}
|
|
|
|
$pageType = $this->pageTypeDetector->detect();
|
|
$visibilityField = $pageType->toVisibilityField();
|
|
|
|
return $this->toBool($config[$visibilityField] ?? true);
|
|
}
|
|
|
|
private function toBool(mixed $value): bool
|
|
{
|
|
return $value === true || $value === '1' || $value === 1;
|
|
}
|
|
}
|