Files
roi-theme/attachment.php
FrankZamora de5fff4f5c Fase 1: Estructura Base y DI Container - Clean Architecture
COMPLETADO: Fase 1 de la migración a Clean Architecture + POO

## Estructura de Carpetas
- ✓ Estructura completa de 4 capas (Domain, Application, Infrastructure, Presentation)
- ✓ Carpetas de Use Cases (SaveComponent, GetComponent, DeleteComponent, SyncSchema)
- ✓ Estructura de tests (Unit, Integration, E2E)
- ✓ Carpetas de schemas y templates

## Composer y Autoloading
- ✓ PSR-4 autoloading configurado para ROITheme namespace
- ✓ Autoloader optimizado regenerado

## DI Container
- ✓ DIContainer implementado con patrón Singleton
- ✓ Métodos set(), get(), has() para gestión de servicios
- ✓ Getters específicos para ComponentRepository, ValidationService, CacheService
- ✓ Placeholders que serán implementados en Fase 5
- ✓ Prevención de clonación y deserialización

## Interfaces
- ✓ ComponentRepositoryInterface (Domain)
- ✓ ValidationServiceInterface (Application)
- ✓ CacheServiceInterface (Application)
- ✓ Component entity placeholder (Domain)

## Bootstrap
- ✓ functions.php actualizado con carga de Composer autoloader
- ✓ Inicialización del DIContainer
- ✓ Helper function roi_container() disponible globalmente

## Tests
- ✓ 10 tests unitarios para DIContainer (100% cobertura)
- ✓ Total: 13 tests unitarios, 28 assertions
- ✓ Suite de tests pasando correctamente

## Validación
- ✓ Script de validación automatizado (48/48 checks pasados)
- ✓ 100% de validaciones exitosas

La arquitectura base está lista para la Fase 2.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 13:48:24 -06:00

232 lines
6.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* The template for displaying attachment pages
*
* This template displays individual attachment pages (images, videos, documents).
* It shows the attachment file with metadata and navigation to parent post.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#attachment
*
* @package ROI_Theme
* @since 1.0.0
*/
get_header();
?>
<main id="main-content" class="site-main" role="main">
<div class="content-wrapper">
<!-- Primary Content Area -->
<div id="primary" class="content-area">
<?php
while ( have_posts() ) :
the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class( 'attachment-page' ); ?>>
<!-- Attachment Header -->
<header class="entry-header">
<h1 class="entry-title attachment-title">
<?php the_title(); ?>
</h1>
<!-- Attachment Meta Information -->
<div class="entry-meta attachment-meta">
<span class="posted-on">
<time class="entry-date published" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>">
<?php
printf(
/* translators: %s: attachment date */
esc_html__( 'Uploaded on %s', 'roi-theme' ),
'<span class="date-text">' . esc_html( get_the_date() ) . '</span>'
);
?>
</time>
</span>
<?php
// Display file size
$metadata = wp_get_attachment_metadata();
if ( isset( $metadata['filesize'] ) ) :
?>
<span class="file-size">
<?php
printf(
/* translators: %s: file size */
esc_html__( 'Size: %s', 'roi-theme' ),
esc_html( size_format( $metadata['filesize'] ) )
);
?>
</span>
<?php endif; ?>
<?php
// Display image dimensions if applicable
if ( wp_attachment_is_image() && isset( $metadata['width'] ) && isset( $metadata['height'] ) ) :
?>
<span class="image-dimensions">
<?php
printf(
/* translators: 1: width, 2: height */
esc_html__( 'Dimensions: %1$s × %2$s pixels', 'roi-theme' ),
esc_html( number_format_i18n( $metadata['width'] ) ),
esc_html( number_format_i18n( $metadata['height'] ) )
);
?>
</span>
<?php endif; ?>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
<!-- Attachment Content -->
<div class="entry-content attachment-content">
<?php
// Display the attachment
if ( wp_attachment_is_image() ) :
// Image attachment
?>
<div class="attachment-image">
<?php
echo wp_get_attachment_image(
get_the_ID(),
'full',
false,
array(
'alt' => get_the_title(),
'class' => 'attachment-full-size',
)
);
?>
</div>
<!-- Download link -->
<div class="attachment-actions">
<a href="<?php echo esc_url( wp_get_attachment_url() ); ?>"
class="btn btn-primary download-link"
download>
<?php esc_html_e( 'Download Original', 'roi-theme' ); ?>
</a>
</div>
<?php else : ?>
<!-- Non-image attachment -->
<div class="attachment-file">
<p>
<?php
printf(
/* translators: %s: attachment file name */
esc_html__( 'File: %s', 'roi-theme' ),
'<strong>' . esc_html( basename( get_attached_file( get_the_ID() ) ) ) . '</strong>'
);
?>
</p>
<!-- Download button -->
<a href="<?php echo esc_url( wp_get_attachment_url() ); ?>"
class="btn btn-primary download-link"
download>
<?php esc_html_e( 'Download File', 'roi-theme' ); ?>
</a>
</div>
<?php endif; ?>
<!-- Attachment Caption -->
<?php
if ( ! empty( wp_get_attachment_caption() ) ) :
?>
<div class="attachment-caption">
<?php echo wp_kses_post( wpautop( wp_get_attachment_caption() ) ); ?>
</div>
<?php endif; ?>
<!-- Attachment Description -->
<?php
the_content();
// Display page links for paginated content
wp_link_pages(
array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'roi-theme' ),
'after' => '</div>',
)
);
?>
</div><!-- .entry-content -->
<!-- Attachment Footer -->
<footer class="entry-footer">
<?php
// Link to parent post if exists
$parent_post = get_post_parent();
if ( $parent_post ) :
?>
<div class="parent-post-link">
<a href="<?php echo esc_url( get_permalink( $parent_post ) ); ?>">
<?php
printf(
/* translators: %s: parent post title */
esc_html__( 'View: %s', 'roi-theme' ),
'<span class="parent-title">' . esc_html( get_the_title( $parent_post ) ) . '</span>'
);
?>
</a>
</div>
<?php endif; ?>
<?php
// Edit post link for logged-in users with permission
edit_post_link(
sprintf(
wp_kses(
/* translators: %s: Attachment title. Only visible to screen readers. */
__( 'Edit<span class="screen-reader-text"> "%s"</span>', 'roi-theme' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
),
'<span class="edit-link">',
'</span>'
);
?>
</footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->
<?php
// Display comments section if enabled
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</div><!-- #primary -->
<?php
/**
* Sidebar
* Display the sidebar if it's active.
*/
if ( is_active_sidebar( 'sidebar-1' ) ) :
get_sidebar();
endif;
?>
</div><!-- .content-wrapper -->
</main><!-- #main-content -->
<?php
get_footer();