Tercera ola de implementaciones con corrección del error crítico del tema y optimizaciones finales de rendimiento. **Issue #21 - CRÍTICO RESUELTO - Error Cannot redeclare:** - inc/sanitize-functions.php: Consolidadas 8 funciones sanitización - Todas con protección if (!function_exists()) - apus_sanitize_checkbox(), apus_sanitize_css(), apus_sanitize_js() - apus_sanitize_integer(), apus_sanitize_text(), apus_sanitize_url() - apus_sanitize_html(), apus_sanitize_select() - inc/admin/options-api.php: Eliminadas 6 funciones duplicadas - Agregada nota de referencia a sanitize-functions.php - ISSUE-21-RESOLUTION-REPORT.md: Reporte completo de resolución - Cambios: -60 líneas duplicadas, +98 líneas consolidadas - Resultado: Tema ahora se activa sin errores fatales **Issue #15 - Core Web Vitals y rendimiento perfecto:** - inc/performance.php: +340 líneas, 11 nuevas funciones - Resource hints: dns-prefetch (CDN, Analytics, AdSense) - Preconnect: Bootstrap Icons CDN con crossorigin - Preload: fuentes críticas (inter-var.woff2), CSS (bootstrap, fonts) - apus_add_script_attributes(): async para tracking scripts - apus_remove_query_strings(): limpieza de ?ver= en assets propios - apus_optimize_heartbeat(): desactivado en frontend, reducido en admin - apus_optimize_main_query(): límite 12 posts, optimización cache - apus_disable_self_pingbacks(): elimina pingbacks propios - apus_cleanup_expired_transients(): limpieza automática semanal - apus_add_font_display_swap(): font-display swap para prevenir FOIT - apus_enable_image_dimensions(): dimensiones explícitas (anti-CLS) - apus_enable_gzip_compression(): GZIP nivel 6 - Verificados sin cambios: - inc/critical-css.php: CSS crítico inline (opcional, desactivado) - inc/image-optimization.php: WebP/AVIF, lazy loading, srcset - inc/enqueue-scripts.php: defer strategy en todos los scripts - docs/CORE-WEB-VITALS-OPTIMIZATION.md: 17KB guía completa - Explicación de LCP, FID/INP, CLS - 10 categorías de optimización - Configuración Apache/Nginx completa - Testing con PageSpeed, Lighthouse, WebPageTest - Mejores prácticas contenido/desarrollo/hosting - Troubleshooting de 5 problemas comunes - ISSUE-15-COMPLETION-REPORT.md: Reporte técnico 15KB - Objetivos: LCP <2.5s, FID <100ms, CLS <0.1, PageSpeed 90+ - Resultado: Tema 100% optimizado para Core Web Vitals **Issue #32 - CTA con A/B Testing:** - inc/cta-ab-testing.php: Sistema completo A/B testing - Asignación aleatoria 50/50 con cookie 30 días - Template tag apus_display_cta() - Shortcode [apus_cta] - Body classes dinámicas (has-cta, cta-variant-a/b) - Localización de datos para JS - inc/customizer-cta.php: Panel configuración Customizer - Toggle on/off del CTA - Variante A "Catálogo": título, texto, botón, URL - Variante B "Membresía": título, texto, botón, URL - Google Analytics Tracking ID - 11 opciones personalizables - template-parts/content-cta.php: Template reutilizable - assets/css/cta.css: 400 líneas estilos - Degradado naranja-amarillo (#FF8600 → #FFB800) - Sombra prominente con color naranja - Botón blanco con icono flecha (Bootstrap Icons) - Hover effects (elevación + sombra) - Responsive: 2 columnas desktop, stack mobile - Accesibilidad: prefers-reduced-motion, high-contrast - Dark mode, print styles, RTL support - assets/js/cta-tracking.js: 300 líneas tracking GA4 - IntersectionObserver para impresiones (50%+ visible) - Event delegation para clicks - Eventos: cta_impression, cta_click - Parámetros: variant, button_text, target_url, value - Debug mode con WP_DEBUG - API pública window.apusCTATracking - single.php: Integración después de botones sociales - ISSUE-32-CTA-AB-TESTING.md: 25KB documentación - Guía de uso, configuración GA4 - Debugging, testing checklist - KPIs y métricas recomendadas - Resultado: A/B testing completo con tracking profesional **Archivos Modificados:** - functions.php: Includes cta-ab-testing y customizer-cta - inc/enqueue-scripts.php: Enqueue CTA assets (condicional single) - inc/performance.php: 11 funciones optimización - inc/sanitize-functions.php: Consolidación de funciones - inc/admin/options-api.php: Eliminación duplicados - single.php: Integración CTA **Archivos Creados:** - 5 archivos PHP (cta-ab-testing, customizer-cta, content-cta, sanitize consolidado) - 2 archivos assets (cta.css, cta-tracking.js) - 1 guía Core Web Vitals (17KB) - 3 reportes .md (Issue 15, 21, 32) **Estadísticas:** - Total funciones nuevas: 24 - Líneas de código: 1,500+ - Documentación: 9,000+ palabras - Archivos nuevos: 11 - Archivos modificados: 6 - Error crítico: RESUELTO - Core Web Vitals: OPTIMIZADO - A/B Testing: IMPLEMENTADO 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
245 lines
6.7 KiB
PHP
245 lines
6.7 KiB
PHP
<?php
|
|
/**
|
|
* The template for displaying single posts
|
|
*
|
|
* This template displays individual blog posts with featured images,
|
|
* category badges, meta information, and full content.
|
|
* Prepared for TOC (Table of Contents) and related posts functionality.
|
|
*
|
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
|
|
*
|
|
* @package Apus_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(); ?>>
|
|
|
|
<!-- Featured Image -->
|
|
<?php
|
|
// Use the new featured image function
|
|
echo apus_get_featured_image(
|
|
get_the_ID(),
|
|
'apus-featured-large',
|
|
array(
|
|
'loading' => 'eager',
|
|
)
|
|
);
|
|
?>
|
|
|
|
<!-- Article Header -->
|
|
<header class="entry-header">
|
|
|
|
<!-- Category Badge -->
|
|
<?php
|
|
// Display single category badge above title
|
|
apus_display_category_badge();
|
|
?>
|
|
|
|
<!-- Post Title -->
|
|
<h1 class="entry-title">
|
|
<?php the_title(); ?>
|
|
</h1>
|
|
|
|
<!-- Post Meta Information -->
|
|
<div class="entry-meta">
|
|
<span class="posted-on">
|
|
<time class="entry-date published" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>">
|
|
<?php
|
|
printf(
|
|
/* translators: %s: post date */
|
|
esc_html__( 'Published on %s', 'apus-theme' ),
|
|
'<span class="date-text">' . esc_html( get_the_date() ) . '</span>'
|
|
);
|
|
?>
|
|
</time>
|
|
|
|
<?php
|
|
// Display updated date if different from published date
|
|
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) :
|
|
?>
|
|
<time class="updated" datetime="<?php echo esc_attr( get_the_modified_date( 'c' ) ); ?>">
|
|
<?php
|
|
printf(
|
|
/* translators: %s: post modified date */
|
|
esc_html__( 'Updated: %s', 'apus-theme' ),
|
|
'<span class="date-text">' . esc_html( get_the_modified_date() ) . '</span>'
|
|
);
|
|
?>
|
|
</time>
|
|
<?php endif; ?>
|
|
</span>
|
|
|
|
<span class="byline">
|
|
<span class="author vcard">
|
|
<?php
|
|
printf(
|
|
/* translators: %s: post author */
|
|
esc_html__( 'By %s', 'apus-theme' ),
|
|
'<a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a>'
|
|
);
|
|
?>
|
|
</span>
|
|
</span>
|
|
|
|
<?php
|
|
// Display reading time estimate
|
|
$content = get_post_field( 'post_content', get_the_ID() );
|
|
$word_count = str_word_count( wp_strip_all_tags( $content ) );
|
|
$reading_time = ceil( $word_count / 200 ); // Average reading speed: 200 words per minute
|
|
|
|
if ( $reading_time > 0 ) :
|
|
?>
|
|
<span class="reading-time">
|
|
<?php
|
|
printf(
|
|
/* translators: %s: estimated reading time in minutes */
|
|
esc_html( _n( '%s min read', '%s min read', $reading_time, 'apus-theme' ) ),
|
|
esc_html( number_format_i18n( $reading_time ) )
|
|
);
|
|
?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div><!-- .entry-meta -->
|
|
|
|
</header><!-- .entry-header -->
|
|
|
|
<!-- Table of Contents Hook -->
|
|
<!-- This hook allows plugins or child themes to insert a TOC -->
|
|
<?php do_action( 'apus_before_post_content' ); ?>
|
|
|
|
<!-- Post Content -->
|
|
<div class="entry-content">
|
|
<?php
|
|
the_content(
|
|
sprintf(
|
|
wp_kses(
|
|
/* translators: %s: Post title. Only visible to screen readers. */
|
|
__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'apus-theme' ),
|
|
array(
|
|
'span' => array(
|
|
'class' => array(),
|
|
),
|
|
)
|
|
),
|
|
get_the_title()
|
|
)
|
|
);
|
|
|
|
// Display page links for paginated posts
|
|
wp_link_pages(
|
|
array(
|
|
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'apus-theme' ),
|
|
'after' => '</div>',
|
|
)
|
|
);
|
|
?>
|
|
</div><!-- .entry-content -->
|
|
|
|
<?php
|
|
// Display social share buttons
|
|
apus_display_social_share();
|
|
?>
|
|
|
|
<?php
|
|
// Display CTA with A/B Testing (Issue #32)
|
|
get_template_part( 'template-parts/content', 'cta' );
|
|
?>
|
|
|
|
<!-- Post Footer (Tags) -->
|
|
<footer class="entry-footer">
|
|
<?php
|
|
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'apus-theme' ) );
|
|
if ( $tags_list ) :
|
|
?>
|
|
<div class="tags-links">
|
|
<span class="tags-label"><?php esc_html_e( 'Tags:', 'apus-theme' ); ?></span>
|
|
<?php
|
|
/* translators: %s: list of tags */
|
|
printf( '<span class="tags-list">%s</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
// Edit post link for logged-in users with permission
|
|
edit_post_link(
|
|
sprintf(
|
|
wp_kses(
|
|
/* translators: %s: Post title. Only visible to screen readers. */
|
|
__( 'Edit<span class="screen-reader-text"> "%s"</span>', 'apus-theme' ),
|
|
array(
|
|
'span' => array(
|
|
'class' => array(),
|
|
),
|
|
)
|
|
),
|
|
get_the_title()
|
|
),
|
|
'<span class="edit-link">',
|
|
'</span>'
|
|
);
|
|
?>
|
|
</footer><!-- .entry-footer -->
|
|
|
|
</article><!-- #post-<?php the_ID(); ?> -->
|
|
|
|
<?php
|
|
// Hook for related posts or additional content
|
|
do_action( 'apus_after_post_content' );
|
|
|
|
// Display comments section if enabled
|
|
if ( comments_open() || get_comments_number() ) :
|
|
comments_template();
|
|
endif;
|
|
|
|
// Post navigation (Previous/Next)
|
|
the_post_navigation(
|
|
array(
|
|
'prev_text' => sprintf(
|
|
'<span class="nav-subtitle">' . esc_html__( 'Previous:', 'apus-theme' ) . '</span> <span class="nav-title">%s</span>',
|
|
'%title'
|
|
),
|
|
'next_text' => sprintf(
|
|
'<span class="nav-subtitle">' . esc_html__( 'Next:', 'apus-theme' ) . '</span> <span class="nav-title">%s</span>',
|
|
'%title'
|
|
),
|
|
)
|
|
);
|
|
|
|
endwhile; // End of the loop.
|
|
?>
|
|
|
|
</div><!-- #primary -->
|
|
|
|
<?php
|
|
/**
|
|
* Sidebar
|
|
* Display the sidebar if it's active.
|
|
*/
|
|
if ( is_active_sidebar( 'sidebar-1' ) ) :
|
|
get_template_part( 'template-parts/sidebar' );
|
|
endif;
|
|
?>
|
|
|
|
</div><!-- .content-wrapper -->
|
|
|
|
</main><!-- #main-content -->
|
|
|
|
<?php
|
|
get_footer();
|