refactor(core): introduce modular architecture and restructure theme into clean, maintainable components
This commit introduces a complete internal refactoring of the theme architecture, transitioning from a monolithic functions.php structure to a modular, scalable system. ### Key Changes #### 1. Modular Architecture - Extracted core logic into dedicated modules under `/inc/` - Introduced clear separation of concerns: - `helpers/` → shared utility functions - `performance/` → optimization and media processing logic - `customizer/` → fully modularized Customizer structure - `template-*` → presentation and template-related logic #### 2. Customizer Refactor - Replaced legacy monolithic customizer with modular system: - `core.php` → base setup - `general.php`, `layout.php`, `toc.php`, `social.php` → feature-based modules - Improved maintainability and extensibility for future settings #### 3. Performance Layer Separation - Moved performance-related logic into `/inc/performance/` - Clearly separated: - frontend performance tweaks (scripts, CSS, cleanup) - media optimization tools (batch processing, cleanup UI) - Reduced coupling between UI, logic, and processing #### 4. Media Optimization Pipeline Stabilization - Re-aligned upload pipeline with WordPress native flow - Restored proper use of `wp_generate_attachment_metadata` - Ensured compatibility with: - format conversion (AVIF/WebP) - responsive image generation - WordPress core image handling #### 5. Cleaner Hook Management - Removed duplicated hooks and redundant filters - Standardized hook priorities and responsibilities - Ensured consistent use of feature toggles (`get_theme_mod`) #### 6. Improved Code Quality - Reduced function duplication - Standardized naming conventions - Improved readability and inline documentation - Removed legacy patterns and implicit dependencies #### 7. Asset Handling Improvements - Introduced centralized asset versioning via `filemtime` - Improved script loading strategy (defer non-critical JS) - Cleaner enqueue structure for styles and scripts #### 8. Foundation for Future Development This refactor lays the groundwork for: - easier feature expansion - better testability - improved debugging capabilities - long-term maintainability ### Breaking Changes - Internal file structure has changed significantly - Direct modifications to old functions.php logic may no longer apply - Customizer extensions must now hook into modular structure --- This is a purely structural and architectural release. No intentional changes to frontend behavior were introduced, but the internal system is now significantly more robust and maintainable.
This commit is contained in:
+51
-48
@@ -2,13 +2,8 @@
|
||||
/**
|
||||
* The header for our theme
|
||||
*
|
||||
* This is the template that displays all of the <head> section and everything up until <div id="content">
|
||||
*
|
||||
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
|
||||
*
|
||||
* @package zeitfresser
|
||||
*/
|
||||
|
||||
?>
|
||||
<!doctype html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
@@ -22,60 +17,68 @@
|
||||
</head>
|
||||
|
||||
<body <?php body_class(); ?>>
|
||||
<?php wp_body_open(); ?>
|
||||
<a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'zeitfresser' ); ?></a>
|
||||
<?php wp_body_open(); ?>
|
||||
|
||||
<a class="skip-link screen-reader-text" href="#primary">
|
||||
<?php esc_html_e( 'Skip to content', 'zeitfresser' ); ?>
|
||||
</a>
|
||||
|
||||
<header id="masthead" class="site-header">
|
||||
<header id="masthead" class="site-header">
|
||||
|
||||
<div class="header-wrapper">
|
||||
<div class="container">
|
||||
<div class="site-header-wrapper">
|
||||
<div class="site-branding">
|
||||
<div class="header-wrapper">
|
||||
<div class="container">
|
||||
<div class="site-header-wrapper">
|
||||
|
||||
<?php the_custom_logo(); ?>
|
||||
<div class="site-branding">
|
||||
|
||||
<div class="site-identity">
|
||||
<?php the_custom_logo(); ?>
|
||||
|
||||
<?php if( get_theme_mod( 'show_hide_site_title', zeitfresser_get_default_site_title_show_hide() ) ) { ?>
|
||||
<div class="site-identity">
|
||||
|
||||
<?php if ( get_theme_mod( 'show_hide_site_title', true ) ) : ?>
|
||||
<div class="site-title">
|
||||
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"
|
||||
class="logo"><?php bloginfo( 'name' ); ?></a>
|
||||
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home" class="logo">
|
||||
<?php bloginfo( 'name' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( get_theme_mod( 'show_hide_site_tagline', true ) ) : ?>
|
||||
<div class="site-description">
|
||||
<?php bloginfo( 'description' ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $daisy_blog_description = get_bloginfo( 'description' ); ?>
|
||||
<?php if( get_theme_mod( 'show_hide_site_tagline', zeitfresser_get_default_site_tagline_show_hide() ) ) { ?>
|
||||
<div class="site-description"><?php echo $daisy_blog_description; ?></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
</div><!-- .site-branding -->
|
||||
|
||||
<div class="nav-social-links">
|
||||
<nav id="site-navigation" class="main-navigation">
|
||||
<button id="nav-icon3" class="menu-toggle" aria-controls="primary-menu"
|
||||
aria-expanded="false">
|
||||
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</button>
|
||||
<?php
|
||||
wp_nav_menu(
|
||||
array(
|
||||
'theme_location' => 'menu-1',
|
||||
'menu_id' => 'primary-menu',
|
||||
)
|
||||
);
|
||||
?>
|
||||
</nav><!-- #site-navigation -->
|
||||
|
||||
<?php get_template_part( 'template-parts/social', 'links' ); ?>
|
||||
</div>
|
||||
|
||||
</div><!-- .site-branding -->
|
||||
|
||||
<div class="nav-social-links">
|
||||
|
||||
<nav id="site-navigation" class="main-navigation">
|
||||
<button id="nav-icon3" class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</button>
|
||||
|
||||
<?php
|
||||
wp_nav_menu(
|
||||
array(
|
||||
'theme_location' => 'menu-1',
|
||||
'menu_id' => 'primary-menu',
|
||||
)
|
||||
);
|
||||
?>
|
||||
</nav>
|
||||
|
||||
<?php get_template_part( 'template-parts/social', 'links' ); ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</header><!-- #masthead -->
|
||||
</div>
|
||||
|
||||
</header><!-- #masthead -->
|
||||
|
||||
Reference in New Issue
Block a user