How sobold/sb-starter works
Project Type and Purpose
• This is a WordPress “Starter Theme” project: it provides a theme skeleton with PHP templates, SCSS/CSS styling, JavaScript logic, AJAX/REST endpoints, and helper libraries (TGM for plugin activation, WooCommerce hooks).
• Its purpose is to serve as a starting point for WordPress site development, offering a consistent folder structure and best practices (7-1 SCSS pattern, modular components, RESTful AJAX, template parts).
File-Structure Analysis
Top-level:
– style.css, functions.php: core theme metadata and bootstrap of hooks, enqueueing, registrations.
– index.php, single.php, page.php, archive.php, pagebuilder.php: WordPress template hierarchy entry points.
– header.php, footer.php, sidebar/theme parts in template-parts and elements/ (layout, components, pagebuilder).
– assets/, css/main.css, js/: compiled front-end assets.
– scss/: source styling using the 7-1 folder pattern.
– inc/: theme logic split into subfolders:
• inc/app/ (custom theme logic),
• inc/ajax/ (REST endpoint registration & handlers),
• inc/* (misc. functions, customizer, woocommerce, login-page, template-tags).
– lib/tgm/: third-party plugin-activation library.
Key Insights from README
• Elements folder holds reusable UI pieces (components, layout, ACF pagebuilder).
• SCSS follows 7-1; main.scss imports abstracts, base, components, layout, pagebuilder, pages.
• AJAX follows WP-REST best practices (rest_api_init, WP_REST_Request/Response).
• Template parts in template-parts/ are included in hierarchy files.
Main Components
A. WordPress Core
– HTTP Request Handler
– Hook System (actions/filters)
– Template Loader
– WP REST API Router
– Database layer (MySQL)
B. SoBold Starter Theme
1. Entry Points: functions.php, style.css, template files (index.php, single.php, page.php, etc.)
2. Template Parts & Elements
• elements/components (reusable UI),
• elements/layout (header, footer, nav),
• elements/pagebuilder (ACF blocks)
• template-parts (content templates)
3. Logic Modules (inc/)
• inc/app (theme-specific business logic),
• inc/ajax (REST endpoint registration & handlers),
• inc/customizer, login-page, template-functions, woocommerce, etc.
4. Asset Pipeline
• SCSS source (scss/ → compiled → css/main.css),
• JavaScript modules (js/, including ajax subfolder),
5. Third-party Libs
• lib/tgm (plugin activation),
• WooCommerce integration.
C. Frontend Browser
– Loads HTML/CSS/JS, triggers interactions, fires AJAX/REST calls.
D. External Systems
– Database (MySQL),
– WP-Hosted plugins activated via TGM.
Relationships & Interactions
• Browser → HTTP Request → WordPress Core → Template Loader → Theme entry point (e.g., pagebuilder.php)
• Theme.functions.php registers hooks/filters → modifies WP behavior (menus, custom header, widgets, etc.)
• functions.php enqueues CSS/JS → Browser loads assets.
• JS modules call REST endpoints (registered in inc/ajax/init.php) → WordPress Core REST Router → inc/ajax handlers → return WP_REST_Response → Browser updates UI.
• Template files include elements and template-parts → render final HTML.
• SCSS compilation (developer step) produces main.css; theme uses it as primary stylesheet.
Architectural Patterns & Principles
• Modular UI components (elements/components, layout, pagebuilder)
• 7-1 SCSS structure for maintainable styling
• WP-REST design pattern for AJAX (versioned endpoints, HTTP verbs)
• Separation of concerns: presentation (templates, CSS, JS) vs. logic (inc/app, template-functions)
• Third-party integration via TGM and WooCommerce hooks.