Implementar Issues #2-4, #8-13, #16 - Funcionalidades core del tema
Implementación masiva de funcionalidades esenciales del tema apus-theme usando agentes paralelos para máxima eficiencia. **Issues Completados:** **Issue #2 - Eliminar bloat de WordPress:** - inc/performance.php: 13 funciones que remueven emojis, oEmbed, feeds, dashicons, jQuery migrate, XML-RPC, etc. - Optimización completa del frontend **Issue #3 - Desactivar búsqueda nativa:** - inc/search-disable.php: Bloquea queries de búsqueda, widget, formularios - search.php: Retorna 404 con mensaje amigable **Issue #4 - Desactivar comentarios:** - inc/comments-disable.php: 15 funciones que eliminan comentarios de frontend y backend - comments.php: Template desactivado **Issue #8 - Footer con 4 widgets:** - footer.php: Verificado con 4 áreas de widgets y copyright - assets/css/footer.css: Estilos responsive completos - Sistema de anchos configurables **Issue #9 - Jerarquía de plantillas:** - home.php, category.php, tag.php, author.php, date.php, taxonomy.php, attachment.php - 7 nuevas plantillas + 12 verificadas - Template parts completos - Paginación en todos los archives **Issue #10 - Imágenes destacadas:** - inc/featured-image.php: 12 funciones para manejo de featured images - Sin placeholders, lazy loading, alt text automático - Responsive con Bootstrap, aspect ratio **Issue #11 - Badge de categoría:** - inc/category-badge.php: Badge Bootstrap sobre H1 en single posts - Excluye "Uncategorized" - Template tag: apus_display_category_badge() **Issue #12 - TOC automático:** - inc/toc.php: Genera TOC desde H2/H3 - assets/css/toc.css: Estilos con numeración CSS counters - assets/js/toc.js: Smooth scroll, scroll spy, toggle - Configurable con apus_get_option() **Issue #13 - Posts relacionados:** - inc/related-posts.php: Query por categoría, 12 funciones - inc/admin/related-posts-options.php: Sistema de configuración - assets/css/related-posts.css: Cards responsive - Hook automático en single posts **Issue #16 - AdSense delay:** - inc/adsense-delay.php: Retardo de carga hasta scroll/click - assets/js/adsense-loader.js: Detecta interacciones - Mejora FID y TBT para Core Web Vitals **Archivos Modificados:** - functions.php: Includes de nuevos módulos, removido feed support - single.php: Integración de category badge - inc/enqueue-scripts.php: Enqueue de nuevos assets - inc/theme-options-helpers.php: Helper functions para TOC **Archivos Creados:** - 7 nuevas plantillas WordPress - 3 nuevos módulos inc/ (comments-disable, search-disable) - 8 reportes de documentación .md **Estadísticas:** - Total funciones PHP: 60+ nuevas funciones - Líneas de código: 2,500+ líneas - Archivos nuevos: 18 - Archivos modificados: 9 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,207 +2,80 @@
|
||||
/**
|
||||
* Category Badge Functions
|
||||
*
|
||||
* Display category badges for posts with configurable settings.
|
||||
* Funciones para mostrar badge de categoría sobre el H1 en single posts.
|
||||
* Utiliza clases de Bootstrap para el estilo del badge.
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
// Salir si se accede directamente
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category Badge HTML
|
||||
* Obtiene el HTML del badge de categoría
|
||||
*
|
||||
* Returns HTML markup for the first category badge.
|
||||
* Can be configured to show/hide via theme customizer.
|
||||
* Retorna el HTML del badge con la primera categoría del post,
|
||||
* excluyendo "Uncategorized" y "Sin categoría".
|
||||
* Utiliza clases de Bootstrap para el estilo.
|
||||
*
|
||||
* @param int $post_id Optional. Post ID. Defaults to current post.
|
||||
* @param bool $force_show Optional. Force display regardless of settings. Default false.
|
||||
* @return string HTML markup for category badge or empty string.
|
||||
* @return string HTML del badge de categoría o string vacío
|
||||
*/
|
||||
function apus_get_category_badge($post_id = null, $force_show = false) {
|
||||
// Get post ID if not provided
|
||||
if (!$post_id) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
|
||||
// Check if category badges are enabled
|
||||
if (!$force_show && !apus_is_category_badge_enabled()) {
|
||||
function apus_get_category_badge() {
|
||||
// Verificar si la función está habilitada en las opciones del tema
|
||||
$enabled = apus_get_option('show_category_badge', true);
|
||||
if (!$enabled) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Get categories
|
||||
$categories = get_the_category($post_id);
|
||||
// Solo mostrar en single posts (no en páginas ni archives)
|
||||
if (!is_single()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Return empty if no categories
|
||||
// Obtener todas las categorías del post actual
|
||||
$categories = get_the_category();
|
||||
|
||||
// Si no hay categorías, retornar vacío
|
||||
if (empty($categories)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Get first category
|
||||
$category = $categories[0];
|
||||
// Filtrar categorías para excluir "Uncategorized" o "Sin categoría"
|
||||
$filtered_categories = array_filter($categories, function($category) {
|
||||
$excluded_slugs = array('uncategorized', 'sin-categoria');
|
||||
return !in_array($category->slug, $excluded_slugs);
|
||||
});
|
||||
|
||||
// Build badge HTML
|
||||
$output = '<div class="category-badge-wrapper">';
|
||||
$output .= sprintf(
|
||||
'<a href="%s" class="category-badge" rel="category tag">%s</a>',
|
||||
// Si después del filtro no quedan categorías, retornar vacío
|
||||
if (empty($filtered_categories)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Tomar la primera categoría (principal)
|
||||
$category = reset($filtered_categories);
|
||||
|
||||
// Generar HTML del badge con clases Bootstrap
|
||||
// Utiliza badge bg-primary de Bootstrap 5
|
||||
$output = sprintf(
|
||||
'<div class="category-badge mb-3"><a href="%s" class="badge bg-primary text-decoration-none" rel="category tag">%s</a></div>',
|
||||
esc_url(get_category_link($category->term_id)),
|
||||
esc_html($category->name)
|
||||
);
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Category Badge
|
||||
* Muestra el badge de categoría
|
||||
*
|
||||
* Echoes the category badge HTML.
|
||||
* Template tag para imprimir directamente el badge de categoría.
|
||||
* Uso en templates: <?php apus_display_category_badge(); ?>
|
||||
*
|
||||
* @param int $post_id Optional. Post ID. Defaults to current post.
|
||||
* @param bool $force_show Optional. Force display regardless of settings. Default false.
|
||||
* @return void
|
||||
*/
|
||||
function apus_the_category_badge($post_id = null, $force_show = false) {
|
||||
echo apus_get_category_badge($post_id, $force_show);
|
||||
function apus_display_category_badge() {
|
||||
echo apus_get_category_badge();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Category Badge is Enabled
|
||||
*
|
||||
* @return bool True if enabled, false otherwise.
|
||||
*/
|
||||
function apus_is_category_badge_enabled() {
|
||||
return (bool) get_theme_mod('apus_category_badge_enabled', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Category Badge Settings in Customizer
|
||||
*
|
||||
* Adds controls to enable/disable category badges.
|
||||
*
|
||||
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
||||
*/
|
||||
function apus_category_badge_customizer($wp_customize) {
|
||||
// Add section
|
||||
$wp_customize->add_section('apus_category_badge', array(
|
||||
'title' => __('Category Badge', 'apus-theme'),
|
||||
'priority' => 31,
|
||||
));
|
||||
|
||||
// Enable/Disable setting
|
||||
$wp_customize->add_setting('apus_category_badge_enabled', array(
|
||||
'default' => true,
|
||||
'sanitize_callback' => 'wp_validate_boolean',
|
||||
'transport' => 'refresh',
|
||||
));
|
||||
|
||||
$wp_customize->add_control('apus_category_badge_enabled', array(
|
||||
'label' => __('Enable Category Badge', 'apus-theme'),
|
||||
'description' => __('Show the first category as a badge above the post title in single posts.', 'apus-theme'),
|
||||
'section' => 'apus_category_badge',
|
||||
'type' => 'checkbox',
|
||||
));
|
||||
|
||||
// Badge background color
|
||||
$wp_customize->add_setting('apus_category_badge_bg_color', array(
|
||||
'default' => '#0073aa',
|
||||
'sanitize_callback' => 'sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
));
|
||||
|
||||
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apus_category_badge_bg_color', array(
|
||||
'label' => __('Badge Background Color', 'apus-theme'),
|
||||
'section' => 'apus_category_badge',
|
||||
)));
|
||||
|
||||
// Badge text color
|
||||
$wp_customize->add_setting('apus_category_badge_text_color', array(
|
||||
'default' => '#ffffff',
|
||||
'sanitize_callback' => 'sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
));
|
||||
|
||||
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'apus_category_badge_text_color', array(
|
||||
'label' => __('Badge Text Color', 'apus-theme'),
|
||||
'section' => 'apus_category_badge',
|
||||
)));
|
||||
}
|
||||
add_action('customize_register', 'apus_category_badge_customizer');
|
||||
|
||||
/**
|
||||
* Output Category Badge Inline Styles
|
||||
*
|
||||
* Outputs custom CSS for category badge colors.
|
||||
*/
|
||||
function apus_category_badge_styles() {
|
||||
$bg_color = get_theme_mod('apus_category_badge_bg_color', '#0073aa');
|
||||
$text_color = get_theme_mod('apus_category_badge_text_color', '#ffffff');
|
||||
|
||||
$css = "
|
||||
<style id='apus-category-badge-inline-css'>
|
||||
.category-badge-wrapper {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.category-badge {
|
||||
display: inline-block;
|
||||
background-color: {$bg_color};
|
||||
color: {$text_color};
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
border-radius: 4px;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.category-badge:hover {
|
||||
opacity: 0.8;
|
||||
color: {$text_color};
|
||||
}
|
||||
|
||||
.category-badge:focus {
|
||||
outline: 2px solid {$bg_color};
|
||||
outline-offset: 2px;
|
||||
}
|
||||
</style>
|
||||
";
|
||||
|
||||
echo $css;
|
||||
}
|
||||
add_action('wp_head', 'apus_category_badge_styles');
|
||||
|
||||
/**
|
||||
* Customize Preview JS for Live Preview
|
||||
*
|
||||
* Adds live preview support for category badge color changes.
|
||||
*/
|
||||
function apus_category_badge_customize_preview_js() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
// Background Color
|
||||
wp.customize('apus_category_badge_bg_color', function(value) {
|
||||
value.bind(function(newval) {
|
||||
$('.category-badge').css('background-color', newval);
|
||||
});
|
||||
});
|
||||
|
||||
// Text Color
|
||||
wp.customize('apus_category_badge_text_color', function(value) {
|
||||
value.bind(function(newval) {
|
||||
$('.category-badge').css('color', newval);
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action('customize_preview_init', function() {
|
||||
add_action('wp_footer', 'apus_category_badge_customize_preview_js');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user