Files
Zeitfresser-Wordpress-Theme/template-parts/related-articles.php
T
Dome 9f92958651 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.
2026-04-26 03:16:00 +02:00

60 lines
2.0 KiB
PHP

<?php
$page_template = get_page_template_slug( get_queried_object_id() );
$post_count = 3;
?>
<div class="related-posts">
<?php
$args = array(
'posts_per_page' => $post_count,
'post_type' => 'post',
'category__in' => wp_get_post_categories( $post->ID ),
'post__not_in' => array( $post->ID ),
'ignore_sticky_posts' => true,
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
?>
<h2 class="main-title">Related Posts</h2>
<div class="post-holder">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="news-snippet">
<?php if ( zeitfresser_show_post_card_featured_image() && has_post_thumbnail() ) : ?>
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark" class="featured-image">
<?php the_post_thumbnail( zeitfresser_get_post_card_thumbnail_size() ); ?>
</a>
<?php endif; ?>
<div class="summary">
<h5 class="news-title">
<a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</h5>
<div class="excerpt">
<?php echo esc_html(
wp_trim_words(
get_the_excerpt(),
zeitfresser_get_post_card_excerpt_length()
)
); ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</div>
<?php endif; ?>
</div>