Segunda ola de implementaciones masivas con agentes paralelos para funcionalidades avanzadas de SEO, accesibilidad y contenido especializado. **Issue #17 - Imágenes responsive con srcset/WebP/AVIF:** - inc/image-optimization.php: 8 nuevas funciones para optimización - Soporte WebP/AVIF con detección de servidor - Srcset y sizes automáticos contextuales - Lazy loading inteligente (excluye LCP) - Threshold 2560px para big images - Picture element con fallbacks - Preload de featured images - Calidad JPEG optimizada (85%) - Dimensiones explícitas (previene CLS) - 14 filtros WordPress implementados - Beneficios: 30-50% reducción con WebP, 50-70% con AVIF - Core Web Vitals: Mejora LCP y CLS **Issue #18 - Accesibilidad WCAG 2.1 AA:** - assets/css/accessibility.css: +461 líneas - Focus styles visibles (3px outline) - Screen reader utilities - Touch targets ≥44px - High contrast mode support - Reduced motion support - Color contrast AA (4.5:1, 3:1) - assets/js/accessibility.js: 19KB nuevo - Skip links con smooth scroll - Navegación por teclado en dropdowns - Arrow keys en menús WordPress - Modal keyboard support - Focus management y trap - ARIA live regions - Announcements para screen readers - header.php: ARIA labels en navbar - Actualizaciones JS: Respeto prefers-reduced-motion en main.js, toc.js, header.js - Cumplimiento completo WCAG 2.1 Level AA **Issue #30 - Tablas APU (Análisis Precios Unitarios):** - assets/css/tables-apu.css: 560 líneas - Diseño sin bordes, moderno - Zebra striping (#f8f9fa/#ffffff) - Headers sticky con degradado azul - 4 tipos de filas: normal, section-header, subtotal, total - Fuente monospace para columnas monetarias - Responsive (scroll horizontal móvil) - Print styles con color-adjust: exact - inc/apu-tables.php: 330 líneas, 6 funciones - apus_process_apu_tables() - Procesamiento automático - Shortcodes: [apu_table], [apu_row type=""] - apus_generate_apu_table($data) - Generación programática - 4 métodos de uso: data-apu, shortcode, clase manual, PHP - docs/APU-TABLES-GUIDE.md: Guía completa de usuario - docs/APU-TABLE-EXAMPLE.html: Ejemplo funcional - 6 columnas: Clave, Descripción, Unidad, Cantidad, Costo, Importe - CRÍTICO: Contenido principal del sitio de construcción **Issue #31 - Botones de compartir en redes sociales:** - inc/social-share.php: 127 líneas - apus_get_social_share_buttons() - Genera HTML - apus_display_social_share() - Template tag - 5 redes: Facebook, X/Twitter, LinkedIn, WhatsApp, Email - URLs nativas sin JavaScript de terceros - Encoding seguro, ARIA labels - assets/css/social-share.css: 137 líneas - Animaciones hover (translateY, scale) - Colores específicos por red - Responsive (576px, 360px) - Focus styles accesibles - single.php: Integración después del contenido - Bootstrap Icons CDN (v1.11.3) - Panel de opciones con configuración **Issue #33 - Schema.org completo (5 tipos):** - inc/schema-org.php: 468 líneas, 7 funciones - Organization schema con logo y redes sociales - WebSite schema con SearchAction - Article schema (posts) con autor, imagen, categorías, wordCount - WebPage schema (páginas) con featured image - BreadcrumbList schema (8 contextos diferentes) - JSON-LD format en <head> - Referencias cruzadas con @id - Google Rich Results compliant - Deshabilita schemas Rank Math/Yoast (evita duplicación) - Locale: es-MX - Hook: wp_head (prioridad 5) **Archivos Modificados:** - functions.php: Includes de nuevos módulos (schema-org, apu-tables, social-share) - inc/enqueue-scripts.php: Enqueue de nuevos CSS/JS, Bootstrap Icons CDN - inc/image-optimization.php: 8 funciones nuevas WebP/AVIF - assets/css/accessibility.css: +461 líneas - assets/js/main.js, toc.js, header.js: Reduced motion support - single.php: Social share buttons - header.php: ARIA labels - inc/admin/options-api.php: Social share settings **Archivos Creados:** - 3 archivos PHP funcionales (apu-tables, social-share, schema-org) - 1 archivo JavaScript (accessibility.js - 19KB) - 3 archivos CSS (tables-apu, social-share) - 2 archivos docs/ (APU guide y example) - 5 reportes .md de documentación **Estadísticas:** - Total funciones nuevas: 30+ - Líneas de código nuevas: 2,500+ - Archivos nuevos: 13 - Archivos modificados: 10 - Mejoras de accesibilidad: WCAG 2.1 AA compliant - Mejoras SEO: 5 schemas JSON-LD - Mejoras performance: WebP/AVIF, lazy loading, srcset 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
262 lines
7.9 KiB
PHP
262 lines
7.9 KiB
PHP
<?php
|
|
/**
|
|
* Apus Theme Functions and Definitions
|
|
*
|
|
* @package Apus_Theme
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Theme Version
|
|
*/
|
|
define('APUS_VERSION', '1.0.0');
|
|
|
|
/**
|
|
* Theme Setup
|
|
*/
|
|
function apus_theme_setup() {
|
|
// Make theme available for translation
|
|
load_theme_textdomain('apus-theme', get_template_directory() . '/languages');
|
|
|
|
// Let WordPress manage the document title
|
|
add_theme_support('title-tag');
|
|
|
|
// Enable support for Post Thumbnails
|
|
add_theme_support('post-thumbnails');
|
|
|
|
// Add image sizes
|
|
add_image_size('apus-thumbnail', 400, 300, true);
|
|
add_image_size('apus-medium', 800, 600, true);
|
|
add_image_size('apus-large', 1200, 900, true);
|
|
add_image_size('apus-featured-large', 1200, 600, true);
|
|
add_image_size('apus-featured-medium', 800, 400, true);
|
|
|
|
// Switch default core markup to output valid HTML5
|
|
add_theme_support('html5', array(
|
|
'gallery',
|
|
'caption',
|
|
'style',
|
|
'script',
|
|
));
|
|
|
|
// Set content width
|
|
if (!isset($content_width)) {
|
|
$content_width = 1200;
|
|
}
|
|
|
|
// Register navigation menus
|
|
register_nav_menus(array(
|
|
'primary' => __('Primary Menu', 'apus-theme'),
|
|
'footer' => __('Footer Menu', 'apus-theme'),
|
|
));
|
|
}
|
|
add_action('after_setup_theme', 'apus_theme_setup');
|
|
|
|
/**
|
|
* Set the content width in pixels
|
|
*/
|
|
function apus_content_width() {
|
|
$GLOBALS['content_width'] = apply_filters('apus_content_width', 1200);
|
|
}
|
|
add_action('after_setup_theme', 'apus_content_width', 0);
|
|
|
|
/**
|
|
* Enqueue Scripts and Styles
|
|
*/
|
|
function apus_enqueue_scripts() {
|
|
// Main stylesheet
|
|
wp_enqueue_style(
|
|
'apus-theme-style',
|
|
get_stylesheet_uri(),
|
|
array(),
|
|
APUS_VERSION
|
|
);
|
|
|
|
// Print styles
|
|
wp_enqueue_style(
|
|
'apus-print-style',
|
|
get_template_directory_uri() . '/assets/css/print.css',
|
|
array('apus-theme-style'),
|
|
APUS_VERSION,
|
|
'print'
|
|
);
|
|
}
|
|
add_action('wp_enqueue_scripts', 'apus_enqueue_scripts');
|
|
|
|
/**
|
|
* Register Widget Areas
|
|
*/
|
|
function apus_register_widget_areas() {
|
|
// Primary Sidebar
|
|
register_sidebar(array(
|
|
'name' => __('Primary Sidebar', 'apus-theme'),
|
|
'id' => 'sidebar-1',
|
|
'description' => __('Main sidebar widget area', 'apus-theme'),
|
|
'before_widget' => '<section id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</section>',
|
|
'before_title' => '<h2 class="widget-title">',
|
|
'after_title' => '</h2>',
|
|
));
|
|
|
|
// Footer Widget Areas
|
|
for ($i = 1; $i <= 4; $i++) {
|
|
register_sidebar(array(
|
|
'name' => sprintf(__('Footer Column %d', 'apus-theme'), $i),
|
|
'id' => 'footer-' . $i,
|
|
'description' => sprintf(__('Footer widget area %d', 'apus-theme'), $i),
|
|
'before_widget' => '<div id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</div>',
|
|
'before_title' => '<h3 class="widget-title">',
|
|
'after_title' => '</h3>',
|
|
));
|
|
}
|
|
}
|
|
add_action('widgets_init', 'apus_register_widget_areas');
|
|
|
|
/**
|
|
* Configure locale and date format
|
|
*/
|
|
function apus_configure_locale() {
|
|
// Set locale to es_MX
|
|
add_filter('locale', function($locale) {
|
|
return 'es_MX';
|
|
});
|
|
}
|
|
add_action('after_setup_theme', 'apus_configure_locale');
|
|
|
|
/**
|
|
* Custom date format
|
|
*/
|
|
function apus_custom_date_format($format) {
|
|
return 'd/m/Y'; // Format: day/month/year
|
|
}
|
|
add_filter('date_format', 'apus_custom_date_format');
|
|
|
|
/**
|
|
* Include modular files
|
|
*/
|
|
// Sanitize Functions (load first to avoid redeclaration errors)
|
|
if (file_exists(get_template_directory() . '/inc/sanitize-functions.php')) {
|
|
require_once get_template_directory() . '/inc/sanitize-functions.php';
|
|
}
|
|
|
|
// Theme Options Helpers (load first as other files may depend on it)
|
|
if (file_exists(get_template_directory() . '/inc/theme-options-helpers.php')) {
|
|
require_once get_template_directory() . '/inc/theme-options-helpers.php';
|
|
}
|
|
|
|
// Admin Options API
|
|
if (is_admin()) {
|
|
if (file_exists(get_template_directory() . '/inc/admin/options-api.php')) {
|
|
require_once get_template_directory() . '/inc/admin/options-api.php';
|
|
}
|
|
if (file_exists(get_template_directory() . '/inc/admin/theme-options.php')) {
|
|
require_once get_template_directory() . '/inc/admin/theme-options.php';
|
|
}
|
|
}
|
|
|
|
// Bootstrap Nav Walker
|
|
if (file_exists(get_template_directory() . '/inc/nav-walker.php')) {
|
|
require_once get_template_directory() . '/inc/nav-walker.php';
|
|
}
|
|
|
|
// Bootstrap and Script Enqueuing
|
|
if (file_exists(get_template_directory() . '/inc/enqueue-scripts.php')) {
|
|
require_once get_template_directory() . '/inc/enqueue-scripts.php';
|
|
}
|
|
|
|
// Font customizer options
|
|
if (file_exists(get_template_directory() . '/inc/customizer-fonts.php')) {
|
|
require_once get_template_directory() . '/inc/customizer-fonts.php';
|
|
}
|
|
|
|
// SEO optimizations and Rank Math compatibility
|
|
if (file_exists(get_template_directory() . '/inc/seo.php')) {
|
|
require_once get_template_directory() . '/inc/seo.php';
|
|
}
|
|
|
|
// Schema.org JSON-LD implementation (Issue #33)
|
|
if (file_exists(get_template_directory() . '/inc/schema-org.php')) {
|
|
require_once get_template_directory() . '/inc/schema-org.php';
|
|
}
|
|
|
|
// Performance optimizations
|
|
if (file_exists(get_template_directory() . '/inc/performance.php')) {
|
|
require_once get_template_directory() . '/inc/performance.php';
|
|
}
|
|
|
|
// Critical CSS (optional, disabled by default)
|
|
if (file_exists(get_template_directory() . '/inc/critical-css.php')) {
|
|
require_once get_template_directory() . '/inc/critical-css.php';
|
|
}
|
|
|
|
// Image optimization
|
|
if (file_exists(get_template_directory() . '/inc/image-optimization.php')) {
|
|
require_once get_template_directory() . '/inc/image-optimization.php';
|
|
}
|
|
|
|
// Template functions
|
|
if (file_exists(get_template_directory() . '/inc/template-functions.php')) {
|
|
require_once get_template_directory() . '/inc/template-functions.php';
|
|
}
|
|
|
|
// Template tags
|
|
if (file_exists(get_template_directory() . '/inc/template-tags.php')) {
|
|
require_once get_template_directory() . '/inc/template-tags.php';
|
|
}
|
|
|
|
// Featured image functions
|
|
if (file_exists(get_template_directory() . '/inc/featured-image.php')) {
|
|
require_once get_template_directory() . '/inc/featured-image.php';
|
|
}
|
|
|
|
// Category badge functions
|
|
if (file_exists(get_template_directory() . '/inc/category-badge.php')) {
|
|
require_once get_template_directory() . '/inc/category-badge.php';
|
|
}
|
|
|
|
// AdSense delay loading
|
|
if (file_exists(get_template_directory() . '/inc/adsense-delay.php')) {
|
|
require_once get_template_directory() . '/inc/adsense-delay.php';
|
|
}
|
|
|
|
// Related posts functionality
|
|
if (file_exists(get_template_directory() . '/inc/related-posts.php')) {
|
|
require_once get_template_directory() . '/inc/related-posts.php';
|
|
}
|
|
|
|
// Related posts configuration options (admin helpers)
|
|
if (file_exists(get_template_directory() . '/inc/admin/related-posts-options.php')) {
|
|
require_once get_template_directory() . '/inc/admin/related-posts-options.php';
|
|
}
|
|
|
|
// Table of Contents
|
|
if (file_exists(get_template_directory() . '/inc/toc.php')) {
|
|
require_once get_template_directory() . '/inc/toc.php';
|
|
}
|
|
|
|
// APU Tables - Funciones para tablas de Análisis de Precios Unitarios (Issue #30)
|
|
if (file_exists(get_template_directory() . '/inc/apu-tables.php')) {
|
|
require_once get_template_directory() . '/inc/apu-tables.php';
|
|
}
|
|
|
|
// Desactivar búsqueda nativa (Issue #3)
|
|
if (file_exists(get_template_directory() . '/inc/search-disable.php')) {
|
|
require_once get_template_directory() . '/inc/search-disable.php';
|
|
}
|
|
|
|
// Desactivar comentarios (Issue #4)
|
|
if (file_exists(get_template_directory() . '/inc/comments-disable.php')) {
|
|
require_once get_template_directory() . '/inc/comments-disable.php';
|
|
}
|
|
|
|
// Social share buttons (Issue #31)
|
|
if (file_exists(get_template_directory() . '/inc/social-share.php')) {
|
|
require_once get_template_directory() . '/inc/social-share.php';
|
|
}
|