feat(templates): add archive-header and post-grid components
- Add ArchiveHeader component (schema, renderer, formbuilder) - Add PostGrid component (schema, renderer, formbuilder) - Unify archive templates (home, archive, category, tag, author, date, search) - Add page visibility system with VisibilityDefaults - Register components in AdminDashboardRenderer - Fix boolean conversion in functions-addon.php - All 172 unit tests passed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
262
archive.php
262
archive.php
@@ -2,8 +2,9 @@
|
||||
/**
|
||||
* The template for displaying archive pages
|
||||
*
|
||||
* This template displays date-based, category, tag, author, and post type
|
||||
* archives with a dynamic title, description, and post loop.
|
||||
* Estructura unificada siguiendo el patron de single.php.
|
||||
* Usa roi_render_component() para todos los componentes.
|
||||
* La visibilidad se controla via PageVisibilityHelper::shouldShow().
|
||||
*
|
||||
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#archive
|
||||
*
|
||||
@@ -14,213 +15,78 @@
|
||||
get_header();
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main" role="main">
|
||||
<main id="main-content" class="site-main" role="main">
|
||||
|
||||
<div class="content-wrapper">
|
||||
<!-- Hero Section - Componente dinamico -->
|
||||
<?php
|
||||
if (function_exists('roi_render_component')) {
|
||||
echo roi_render_component('hero');
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Primary Content Area -->
|
||||
<div id="primary" class="content-area">
|
||||
<!-- Archive Header - Componente dinamico -->
|
||||
<?php
|
||||
if (function_exists('roi_render_component')) {
|
||||
echo roi_render_component('archive-header');
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( have_posts() ) : ?>
|
||||
<!-- Main Content Grid -->
|
||||
<?php
|
||||
// Determinar si mostrar sidebar basandose en visibilidad de componentes
|
||||
$sidebar_components = ['table-of-contents', 'cta-box-sidebar'];
|
||||
$show_sidebar = function_exists('roi_should_render_any_wrapper')
|
||||
? roi_should_render_any_wrapper($sidebar_components)
|
||||
: false;
|
||||
$main_col_class = $show_sidebar ? 'col-lg-9' : 'col-lg-12';
|
||||
?>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<!-- Archive Header -->
|
||||
<header class="page-header">
|
||||
<?php
|
||||
// Archive title
|
||||
the_archive_title( '<h1 class="page-title">', '</h1>' );
|
||||
<!-- Main Content Column -->
|
||||
<div class="<?php echo esc_attr($main_col_class); ?>">
|
||||
|
||||
// Archive description
|
||||
$archive_description = get_the_archive_description();
|
||||
if ( ! empty( $archive_description ) ) :
|
||||
?>
|
||||
<div class="archive-description">
|
||||
<?php echo wp_kses_post( wpautop( $archive_description ) ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</header><!-- .page-header -->
|
||||
<!-- Post Grid - Componente dinamico -->
|
||||
<?php
|
||||
if (function_exists('roi_render_component')) {
|
||||
echo roi_render_component('post-grid');
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- Archive Posts Loop -->
|
||||
<div class="archive-posts">
|
||||
</div><!-- .<?php echo esc_attr($main_col_class); ?> -->
|
||||
|
||||
<?php
|
||||
// Start the WordPress Loop
|
||||
while ( have_posts() ) :
|
||||
the_post();
|
||||
?>
|
||||
<?php if ($show_sidebar): ?>
|
||||
<!-- Sidebar Column (col-lg-3) -->
|
||||
<div class="col-lg-3">
|
||||
<div class="sidebar-sticky">
|
||||
<!-- Table of Contents - Componente dinamico -->
|
||||
<?php
|
||||
if (function_exists('roi_render_component')) {
|
||||
echo roi_render_component('table-of-contents');
|
||||
}
|
||||
?>
|
||||
|
||||
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
<!-- CTA Box Sidebar - Componente dinamico -->
|
||||
<?php
|
||||
if (function_exists('roi_render_component')) {
|
||||
echo roi_render_component('cta-box-sidebar');
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Post Thumbnail -->
|
||||
<?php if ( has_post_thumbnail() ) : ?>
|
||||
<div class="post-thumbnail">
|
||||
<a href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
|
||||
<?php
|
||||
the_post_thumbnail(
|
||||
'roi-featured-medium',
|
||||
array(
|
||||
'alt' => the_title_attribute(
|
||||
array(
|
||||
'echo' => false,
|
||||
)
|
||||
),
|
||||
'loading' => 'lazy',
|
||||
)
|
||||
);
|
||||
?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div><!-- .row -->
|
||||
</div><!-- .container -->
|
||||
|
||||
<!-- Post Content -->
|
||||
<div class="post-content">
|
||||
</main><!-- #main-content -->
|
||||
|
||||
<!-- Post Header -->
|
||||
<header class="entry-header">
|
||||
|
||||
<!-- Category Badges -->
|
||||
<?php
|
||||
$categories = get_the_category();
|
||||
if ( ! empty( $categories ) ) :
|
||||
?>
|
||||
<div class="entry-categories">
|
||||
<?php foreach ( $categories as $category ) : ?>
|
||||
<a href="<?php echo esc_url( get_category_link( $category->term_id ) ); ?>"
|
||||
class="category-badge"
|
||||
rel="category tag">
|
||||
<?php echo esc_html( $category->name ); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Post Title -->
|
||||
<?php
|
||||
if ( is_singular() ) :
|
||||
the_title( '<h1 class="entry-title">', '</h1>' );
|
||||
else :
|
||||
the_title(
|
||||
sprintf(
|
||||
'<h2 class="entry-title"><a href="%s" rel="bookmark">',
|
||||
esc_url( get_permalink() )
|
||||
),
|
||||
'</a></h2>'
|
||||
);
|
||||
endif;
|
||||
?>
|
||||
|
||||
<!-- Post Meta -->
|
||||
<div class="entry-meta">
|
||||
<span class="posted-on">
|
||||
<time class="entry-date published" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>">
|
||||
<?php echo esc_html( get_the_date() ); ?>
|
||||
</time>
|
||||
</span>
|
||||
<span class="byline">
|
||||
<span class="author vcard">
|
||||
<a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
|
||||
<?php echo esc_html( get_the_author() ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</span>
|
||||
</div><!-- .entry-meta -->
|
||||
|
||||
</header><!-- .entry-header -->
|
||||
|
||||
<!-- Post Excerpt -->
|
||||
<div class="entry-summary">
|
||||
<?php the_excerpt(); ?>
|
||||
</div><!-- .entry-summary -->
|
||||
|
||||
<!-- Read More Link -->
|
||||
<div class="entry-footer">
|
||||
<a href="<?php the_permalink(); ?>" class="read-more-link">
|
||||
<?php
|
||||
printf(
|
||||
wp_kses(
|
||||
/* translators: %s: Post title. Only visible to screen readers. */
|
||||
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'roi-theme' ),
|
||||
array(
|
||||
'span' => array(
|
||||
'class' => array(),
|
||||
),
|
||||
)
|
||||
),
|
||||
get_the_title()
|
||||
);
|
||||
?>
|
||||
<span class="read-more-icon" aria-hidden="true">→</span>
|
||||
</a>
|
||||
</div><!-- .entry-footer -->
|
||||
|
||||
</div><!-- .post-content -->
|
||||
|
||||
</article><!-- #post-<?php the_ID(); ?> -->
|
||||
|
||||
<?php endwhile; ?>
|
||||
|
||||
</div><!-- .archive-posts -->
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Pagination
|
||||
* Display navigation to next/previous set of posts when applicable.
|
||||
*/
|
||||
the_posts_pagination(
|
||||
array(
|
||||
'mid_size' => 2,
|
||||
'prev_text' => sprintf(
|
||||
'%s <span class="nav-prev-text">%s</span>',
|
||||
'<span class="nav-icon" aria-hidden="true">«</span>',
|
||||
esc_html__( 'Previous', 'roi-theme' )
|
||||
),
|
||||
'next_text' => sprintf(
|
||||
'<span class="nav-next-text">%s</span> %s',
|
||||
esc_html__( 'Next', 'roi-theme' ),
|
||||
'<span class="nav-icon" aria-hidden="true">»</span>'
|
||||
),
|
||||
'before_page_number' => '<span class="screen-reader-text">' . esc_html__( 'Page', 'roi-theme' ) . ' </span>',
|
||||
'aria_label' => esc_attr__( 'Posts navigation', 'roi-theme' ),
|
||||
)
|
||||
);
|
||||
|
||||
else :
|
||||
|
||||
/**
|
||||
* No posts found
|
||||
* Display a message when no content is available.
|
||||
*/
|
||||
?>
|
||||
<section class="no-results not-found">
|
||||
<header class="page-header">
|
||||
<h1 class="page-title">
|
||||
<?php esc_html_e( 'Nothing Found', 'roi-theme' ); ?>
|
||||
</h1>
|
||||
</header><!-- .page-header -->
|
||||
|
||||
<div class="page-content">
|
||||
<p>
|
||||
<?php esc_html_e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'roi-theme' ); ?>
|
||||
</p>
|
||||
</div><!-- .page-content -->
|
||||
</section><!-- .no-results -->
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</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 -->
|
||||
<!-- Contact Form Section - Componente dinamico -->
|
||||
<?php
|
||||
if (function_exists('roi_render_component')) {
|
||||
echo roi_render_component('contact-form');
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
|
||||
Reference in New Issue
Block a user