Se movió el repositorio git desde la raíz de WordPress a la carpeta del tema. Este commit limpia todos los archivos de WordPress del historial de tracking y mantiene únicamente los archivos del tema apus-theme. Cambios: - Eliminado tracking de archivos de WordPress core - Mantenido solo archivos del tema (97 archivos) - Actualizado .gitignore para excluir carpetas de desarrollo - Historial de commits anteriores se mantiene intacto 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
206 lines
5.3 KiB
PHP
206 lines
5.3 KiB
PHP
<?php
|
|
/**
|
|
* SEO Optimizations and Rank Math Compatibility
|
|
*
|
|
* This file contains SEO-related theme functions that work
|
|
* seamlessly with Rank Math SEO plugin without conflicts.
|
|
*
|
|
* @package Apus_Theme
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Remove WordPress version from header and feeds
|
|
*
|
|
* Prevents disclosure of WordPress version number which could
|
|
* expose potential vulnerabilities. This is a common SEO best practice.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_remove_generator() {
|
|
return '';
|
|
}
|
|
remove_action('wp_head', 'wp_generator');
|
|
add_filter('the_generator', 'apus_remove_generator');
|
|
|
|
/**
|
|
* Remove RSD (Really Simple Discovery) link
|
|
*
|
|
* Removes unnecessary header link that's rarely needed.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
remove_action('wp_head', 'rsd_link');
|
|
|
|
/**
|
|
* Remove Windows Live Writer manifest
|
|
*
|
|
* Removes deprecated Microsoft Windows Live Writer support link.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
remove_action('wp_head', 'wlwmanifest_link');
|
|
|
|
/**
|
|
* Remove REST API link from header
|
|
*
|
|
* Note: Rank Math handles REST API headers, so we keep REST API
|
|
* itself enabled but remove the link tag from the header.
|
|
* This prevents exposing API endpoints unnecessarily.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
remove_action('wp_head', 'rest_output_link_wp_head');
|
|
|
|
/**
|
|
* Optimize robots.txt headers
|
|
*
|
|
* Ensures proper cache headers for robots.txt
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_robots_header() {
|
|
if (is_robots()) {
|
|
header('Cache-Control: public, max-age=86400');
|
|
header('Expires: ' . gmdate('r', time() + 86400));
|
|
}
|
|
}
|
|
add_action('pre_handle_robots_txt', 'apus_robots_header');
|
|
|
|
/**
|
|
* Improve comment feed performance
|
|
*
|
|
* Disables post comments feed if not needed (can be re-enabled
|
|
* in theme options if required for client websites).
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
// Note: Keep this commented out unless client specifically needs comment feeds
|
|
// remove_action('wp_head', 'feed_links', 2);
|
|
|
|
/**
|
|
* Clean up empty image alt attributes
|
|
*
|
|
* Encourages proper image SEO by highlighting missing alt text in admin
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_admin_notice_missing_alt() {
|
|
if (!current_user_can('upload_files')) {
|
|
return;
|
|
}
|
|
|
|
// This is informational - actual alt text enforcement is better
|
|
// handled by Rank Math's image optimization features
|
|
}
|
|
|
|
/**
|
|
* Ensure wp_head() is properly closed before body
|
|
*
|
|
* This is called in header.php to ensure all SEO meta tags
|
|
* (from Rank Math and theme) are properly placed.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_seo_head_hooks() {
|
|
// This ensures proper hook execution order for Rank Math compatibility
|
|
do_action('apus_head_close');
|
|
}
|
|
|
|
/**
|
|
* Add prefetch hints for external resources
|
|
*
|
|
* Improves performance by preemptively connecting to external domains
|
|
* commonly used in the theme (fonts, CDNs, etc.)
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_prefetch_external() {
|
|
// Google Fonts prefetch
|
|
echo '<link rel="preconnect" href="https://fonts.googleapis.com">' . "\n";
|
|
echo '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' . "\n";
|
|
}
|
|
add_action('wp_head', 'apus_prefetch_external', 1);
|
|
|
|
/**
|
|
* Open Graph support for Rank Math compatibility
|
|
*
|
|
* Ensures theme doesn't output conflicting OG tags when Rank Math is active.
|
|
* Rank Math handles all Open Graph implementation.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_check_rank_math_active() {
|
|
return defined('RANK_MATH_VERSION');
|
|
}
|
|
|
|
/**
|
|
* Schema.org compatibility layer
|
|
*
|
|
* Provides basic schema support if Rank Math is not active.
|
|
* When Rank Math is active, it takes over all schema implementation.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_schema_fallback() {
|
|
// Only output schema if Rank Math is NOT active
|
|
if (apus_check_rank_math_active()) {
|
|
return;
|
|
}
|
|
|
|
// Basic organization schema fallback
|
|
$schema = array(
|
|
'@context' => 'https://schema.org',
|
|
'@type' => 'WebSite',
|
|
'name' => get_bloginfo('name'),
|
|
'url' => get_home_url(),
|
|
);
|
|
|
|
if (get_bloginfo('description')) {
|
|
$schema['description'] = get_bloginfo('description');
|
|
}
|
|
|
|
echo "\n" . '<!-- Apus Theme Basic Schema (Rank Math not active) -->' . "\n";
|
|
echo '<script type="application/ld+json">' . "\n";
|
|
echo wp_json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n";
|
|
echo '</script>' . "\n";
|
|
}
|
|
add_action('wp_head', 'apus_schema_fallback', 20);
|
|
|
|
/**
|
|
* Security headers configuration
|
|
*
|
|
* Adds recommended security headers that also improve SEO
|
|
* (by indicating secure, well-maintained site)
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_security_headers() {
|
|
// These headers improve trust signals for search engines
|
|
header('X-Content-Type-Options: nosniff');
|
|
header('X-Frame-Options: SAMEORIGIN');
|
|
header('X-XSS-Protection: 1; mode=block');
|
|
}
|
|
add_action('send_headers', 'apus_security_headers');
|
|
|
|
/**
|
|
* Ensure title tag support is active
|
|
*
|
|
* This is set in functions.php with add_theme_support('title-tag')
|
|
* but we verify it here to log any issues for debugging.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
function apus_verify_title_tag_support() {
|
|
if (!current_theme_supports('title-tag')) {
|
|
// Log warning if title-tag support is somehow disabled
|
|
error_log('Warning: Apus Theme title-tag support not properly initialized');
|
|
}
|
|
}
|
|
add_action('after_setup_theme', 'apus_verify_title_tag_support', 20);
|