Se implementa tema WordPress personalizado para Análisis de Precios Unitarios con funcionalidades avanzadas: - Sistema de templates (front-page, single, archive, page, 404, search) - Integración de Bootstrap 5.3.8 con estructura modular de assets - Panel de opciones del tema con Customizer API - Optimizaciones de rendimiento (Critical CSS, Image Optimization, Performance) - Funcionalidades SEO y compatibilidad con Rank Math - Sistema de posts relacionados y tabla de contenidos - Badge de categorías y manejo de AdSense diferido - Tipografías Google Fonts configurables - Documentación completa del tema y guías de uso 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5.5 KiB
5.5 KiB
Apus Theme Options Panel
Overview
Complete theme options panel for managing all theme settings from WordPress admin.
Location
Appearance > Theme Options in WordPress admin
Files Structure
inc/admin/
├── theme-options.php # Main admin page registration
├── options-api.php # Settings API and sanitization
├── options-page-template.php # HTML template for options page
└── README.md # This file
inc/
└── theme-options-helpers.php # Helper functions to get options
assets/admin/
├── css/
│ └── theme-options.css # Admin styles
└── js/
└── theme-options.js # Admin JavaScript
Features
General Tab
- Site logo upload
- Site favicon upload
- Breadcrumbs enable/disable
- Breadcrumb separator customization
- Date and time format
- Copyright text
- Social media links (Facebook, Twitter, Instagram, LinkedIn, YouTube)
Content Tab
- Excerpt length
- Excerpt more text
- Default post/page layouts
- Archive posts per page
- Featured image display
- Author box display
- Comments enable/disable for posts/pages
- Post meta visibility
- Tags and categories display
Performance Tab
- Lazy loading
- Remove emoji scripts
- Remove embeds
- Remove Dashicons on frontend
- Defer JavaScript
- Minify HTML
- Disable Gutenberg
Related Posts Tab
- Enable/disable related posts
- Number of posts to show
- Taxonomy to use (category, tag, or both)
- Section title
- Number of columns
Advanced Tab
- Custom CSS
- Custom JavaScript (header)
- Custom JavaScript (footer)
Usage
Getting Options in Templates
// Get any option with default fallback
$value = apus_get_option('option_name', 'default_value');
// Check if option is enabled (boolean)
if (apus_is_option_enabled('enable_breadcrumbs')) {
// Do something
}
// Specific helper functions
$logo_url = apus_get_logo_url();
$excerpt_length = apus_get_excerpt_length();
$social_links = apus_get_social_links();
Available Helper Functions
All helper functions are in inc/theme-options-helpers.php:
apus_get_option($option_name, $default)apus_is_option_enabled($option_name)apus_get_breadcrumb_separator()apus_show_breadcrumbs()apus_get_excerpt_length()apus_get_excerpt_more()apus_show_related_posts()apus_get_related_posts_count()apus_get_related_posts_taxonomy()apus_get_related_posts_title()apus_is_performance_enabled($optimization)apus_get_copyright_text()apus_get_social_links()apus_comments_enabled_for_posts()apus_comments_enabled_for_pages()apus_get_default_post_layout()apus_get_default_page_layout()apus_get_archive_posts_per_page()apus_show_featured_image_single()apus_show_author_box()apus_get_date_format()apus_get_time_format()apus_get_logo_url()apus_get_favicon_url()apus_get_custom_css()apus_get_custom_js_header()apus_get_custom_js_footer()apus_is_lazy_loading_enabled()apus_get_all_options()apus_reset_options()
Import/Export
Export Options
- Go to
Appearance > Theme Options - Click "Export Options" button
- A JSON file will be downloaded with all current settings
Import Options
- Go to
Appearance > Theme Options - Click "Import Options" button
- Paste the JSON content from your exported file
- Click "Import"
- Page will reload with imported settings
Reset to Defaults
Click "Reset to Defaults" button to restore all options to their default values. This action requires confirmation.
Sanitization
All options are sanitized before saving:
- Text fields:
sanitize_text_field() - URLs:
esc_url_raw() - HTML content:
wp_kses_post() - Integers:
absint() - Checkboxes: Boolean conversion
- CSS: Custom sanitization removing scripts
- JavaScript: Custom sanitization removing PHP code
Hooks Available
Actions
apus_before_options_save- Before options are savedapus_after_options_save- After options are saved
Filters
apus_theme_options- Filter all optionsapus_default_options- Filter default options
JavaScript Events
Custom events triggered by the options panel:
apus:options:saved- When options are savedapus:options:reset- When options are resetapus:options:imported- When options are importedapus:options:exported- When options are exported
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
Accessibility
- Keyboard navigation supported
- Screen reader friendly
- WCAG 2.1 Level AA compliant
- Focus indicators visible
Security
- Nonce verification on all AJAX calls
- Capability checks (
manage_options) - Input sanitization
- Output escaping
- CSRF protection
Performance
- Lazy loading for tab content
- Conditional script loading (only on options page)
- Optimized AJAX requests
- Minimal DOM manipulation
Troubleshooting
Options not saving
- Check WordPress user has
manage_optionscapability - Check file permissions
- Check for JavaScript errors in browser console
- Verify WordPress nonce is valid
Images not uploading
- Check PHP upload_max_filesize setting
- Check WordPress media upload permissions
- Check browser console for errors
Import not working
- Verify JSON format is valid
- Check for special characters in JSON
- Ensure JSON is from same theme version
Version History
1.0.0
- Initial release
- All basic options implemented
- Import/Export functionality
- Reset to defaults
- Full sanitization