sanitizeAttributes($atts); // Obtener paged desde query var si existe $id = $atts['id'] ?? ''; $queryVar = !empty($id) ? "paged_{$id}" : 'paged'; $atts['paged'] = max(1, (int) get_query_var($queryVar, 1)); // Crear request DTO $request = RenderPostGridRequest::fromArray($atts); // Obtener UseCase desde DIContainer $container = DIContainer::getInstance(); $useCase = $container->getRenderPostGridUseCase(); return $useCase->execute($request); } /** * Sanitiza atributos del shortcode * * @param array|string $atts * @return array */ private function sanitizeAttributes($atts): array { $atts = shortcode_atts([ 'category' => '', 'exclude_category' => '', 'tag' => '', 'author' => '', 'posts_per_page' => '9', 'columns' => '3', 'orderby' => 'date', 'order' => 'DESC', 'show_pagination' => 'false', 'offset' => '0', 'exclude_posts' => '', 'show_thumbnail' => 'true', 'show_excerpt' => 'true', 'show_meta' => 'true', 'show_categories' => 'true', 'excerpt_length' => '20', 'class' => '', 'id' => '', ], $atts, self::SHORTCODE_TAG); // Sanitizar cada valor return array_map(function ($value) { return is_string($value) ? sanitize_text_field($value) : $value; }, $atts); } }