You've already forked wc-bootstrap
Initial theme scaffold from wp-theme-template
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
76
templates/base.html.twig
Normal file
76
templates/base.html.twig
Normal file
@@ -0,0 +1,76 @@
|
||||
{#
|
||||
# Base Template (Bootstrap 5 Override)
|
||||
#
|
||||
# Overrides the plugin's base.html.twig with Bootstrap 5 components.
|
||||
# Provides the basic structure and block definitions.
|
||||
#
|
||||
# When _theme_wrapped is true, the parent theme already provides the page
|
||||
# shell (header, footer, container). The outer wrapper, breadcrumbs,
|
||||
# sidebar, and head blocks are skipped to avoid double-wrapping.
|
||||
# The scripts block is always rendered because child templates use it for
|
||||
# page-specific inline JavaScript (e.g. AJAX form handlers).
|
||||
#
|
||||
# @package WcBootstrap
|
||||
# @since 0.1.0
|
||||
#}
|
||||
|
||||
{% set _wrapped = _theme_wrapped is defined and _theme_wrapped %}
|
||||
|
||||
{% if not _wrapped %}{% block head %}{% endblock %}{% endif %}
|
||||
|
||||
{% if not _wrapped %}<div class="container my-4">{% endif %}
|
||||
|
||||
{% block notifications %}
|
||||
{% if notifications is defined and notifications|length > 0 %}
|
||||
{% for notification in notifications %}
|
||||
<div class="alert alert-{{ notification.type|default('info') }} alert-dismissible fade show" role="alert">
|
||||
{{ notification.message|wp_kses_post }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="{{ __('Close') }}"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if flash_messages is defined %}
|
||||
{% for type, messages in flash_messages %}
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-{{ type }} alert-dismissible fade show" role="alert">
|
||||
{{ message|wp_kses_post }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="{{ __('Close') }}"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% if not _wrapped %}<main>{% endif %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{% if not _wrapped and breadcrumbs is defined and breadcrumbs|length > 0 %}
|
||||
<nav aria-label="{{ __('Breadcrumb') }}">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ home_url() }}">{{ __('Home') }}</a>
|
||||
</li>
|
||||
{% for crumb in breadcrumbs %}
|
||||
{% if crumb.url %}
|
||||
<li class="breadcrumb-item">
|
||||
<a href="{{ crumb.url|esc_url }}">{{ crumb.label|esc_html }}</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ crumb.label|esc_html }}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</nav>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
{% if not _wrapped %}</main>{% endif %}
|
||||
|
||||
{% block sidebar %}{% endblock %}
|
||||
|
||||
{% if not _wrapped %}</div>{% endif %}
|
||||
|
||||
{% block scripts %}{% endblock %}
|
||||
36
templates/components/card.html.twig
Normal file
36
templates/components/card.html.twig
Normal file
@@ -0,0 +1,36 @@
|
||||
{#
|
||||
# Card Component (Bootstrap 5)
|
||||
#
|
||||
# Reusable card component for list/grid display.
|
||||
#
|
||||
# Expected context:
|
||||
# post.title - Card title
|
||||
# post.permalink - Card link URL
|
||||
# post.excerpt - Card description text
|
||||
# post.thumbnail - Optional thumbnail URL
|
||||
#
|
||||
# @package WcBootstrap
|
||||
# @since 0.1.0
|
||||
#}
|
||||
|
||||
<article class="card h-100 shadow-sm">
|
||||
{% if post.thumbnail is defined and post.thumbnail %}
|
||||
<img src="{{ post.thumbnail|esc_url }}" class="card-img-top" alt="{{ post.title|esc_attr }}">
|
||||
{% endif %}
|
||||
|
||||
<div class="card-body">
|
||||
<h3 class="card-title h5">
|
||||
<a href="{{ post.permalink|esc_url }}" class="stretched-link text-decoration-none">
|
||||
{{ post.title|esc_html }}
|
||||
</a>
|
||||
</h3>
|
||||
|
||||
{% if post.excerpt is defined and post.excerpt %}
|
||||
<p class="card-text text-body-secondary">{{ post.excerpt|wp_kses_post }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% block card_meta %}{% endblock %}
|
||||
</div>
|
||||
|
||||
{% block card_footer %}{% endblock %}
|
||||
</article>
|
||||
49
templates/components/pagination.html.twig
Normal file
49
templates/components/pagination.html.twig
Normal file
@@ -0,0 +1,49 @@
|
||||
{#
|
||||
# Pagination Component (Bootstrap 5)
|
||||
#
|
||||
# Renders pagination navigation for search/archive pages.
|
||||
#
|
||||
# Expected context:
|
||||
# current_page - Current page number (1-based)
|
||||
# max_pages - Total number of pages
|
||||
#
|
||||
# @package WcBootstrap
|
||||
# @since 0.1.0
|
||||
#}
|
||||
|
||||
{% if max_pages is defined and max_pages > 1 %}
|
||||
<nav aria-label="{{ __('Page navigation') }}" class="mt-4">
|
||||
<ul class="pagination justify-content-center">
|
||||
{# Previous button #}
|
||||
<li class="page-item{% if current_page <= 1 %} disabled{% endif %}">
|
||||
<a class="page-link" href="?page={{ current_page - 1 }}" aria-label="{{ __('Previous') }}">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{# Page numbers #}
|
||||
{% for i in 1..max_pages %}
|
||||
{% if i == current_page %}
|
||||
<li class="page-item active" aria-current="page">
|
||||
<span class="page-link">{{ i }}</span>
|
||||
</li>
|
||||
{% elseif i == 1 or i == max_pages or (i >= current_page - 2 and i <= current_page + 2) %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="?page={{ i }}">{{ i }}</a>
|
||||
</li>
|
||||
{% elseif i == current_page - 3 or i == current_page + 3 %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">…</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{# Next button #}
|
||||
<li class="page-item{% if current_page >= max_pages %} disabled{% endif %}">
|
||||
<a class="page-link" href="?page={{ current_page + 1 }}" aria-label="{{ __('Next') }}">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
28
templates/layouts/account.html.twig
Normal file
28
templates/layouts/account.html.twig
Normal file
@@ -0,0 +1,28 @@
|
||||
{#
|
||||
# Account Layout (Bootstrap 5 Override)
|
||||
#
|
||||
# Layout for user account/settings pages.
|
||||
#
|
||||
# @package WcBootstrap
|
||||
# @since 0.1.0
|
||||
#}
|
||||
|
||||
{% extends "base.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="mb-4">
|
||||
{% block account_header %}
|
||||
<header class="mb-4">
|
||||
<h1>{{ page_title|default('')|esc_html }}</h1>
|
||||
|
||||
{% block account_description %}
|
||||
{% if page_description is defined %}
|
||||
<p class="lead text-body-secondary">{{ page_description|wp_kses_post }}</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</header>
|
||||
{% endblock %}
|
||||
|
||||
{% block account_content %}{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
61
templates/layouts/archive.html.twig
Normal file
61
templates/layouts/archive.html.twig
Normal file
@@ -0,0 +1,61 @@
|
||||
{#
|
||||
# Archive/Search Layout (Bootstrap 5 Override)
|
||||
#
|
||||
# Layout for search results and archive pages.
|
||||
# 3+9 column split: filter sidebar + results grid.
|
||||
#
|
||||
# @package WcBootstrap
|
||||
# @since 0.1.0
|
||||
#}
|
||||
|
||||
{% extends "base.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="mb-4">
|
||||
{% block archive_header %}
|
||||
<header class="mb-4">
|
||||
<h1>{{ page_title|default(__('Search Results'))|esc_html }}</h1>
|
||||
|
||||
{% if results_count is defined %}
|
||||
<p class="text-body-secondary">
|
||||
{{ _n('%d result found', '%d results found', results_count)|format(results_count) }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</header>
|
||||
{% endblock %}
|
||||
|
||||
<div class="row">
|
||||
{% block archive_sidebar %}
|
||||
<aside class="col-lg-3 mb-4 mb-lg-0">
|
||||
{% block search_filters %}{% endblock %}
|
||||
</aside>
|
||||
{% endblock %}
|
||||
|
||||
<div class="col-lg-9">
|
||||
{% block archive_results %}
|
||||
{% if results is defined and results|length > 0 %}
|
||||
<div class="row row-cols-1 row-cols-md-2 g-4">
|
||||
{% for post in results %}
|
||||
<div class="col">
|
||||
{% block result_card %}
|
||||
{% include 'components/card.html.twig' with {post: post} %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-info" role="alert">
|
||||
<p class="mb-0">{{ __('No results found. Try adjusting your filters.') }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block pagination %}
|
||||
{% if max_pages is defined and max_pages > 1 %}
|
||||
{% include 'components/pagination.html.twig' %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
98
templates/layouts/form.html.twig
Normal file
98
templates/layouts/form.html.twig
Normal file
@@ -0,0 +1,98 @@
|
||||
{#
|
||||
# Form Layout (Bootstrap 5 Override)
|
||||
#
|
||||
# Layout for registration and editing forms.
|
||||
# Uses a centered card layout with consistent Bootstrap 5 styling.
|
||||
#
|
||||
# @package WcBootstrap
|
||||
# @since 0.1.0
|
||||
#}
|
||||
|
||||
{% extends "base.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8 col-xl-7">
|
||||
{% block form_header %}
|
||||
<header class="text-center mb-4">
|
||||
<h1 class="mb-2">{{ page_title|esc_html }}</h1>
|
||||
|
||||
{% block form_description %}
|
||||
{% if form_description is defined %}
|
||||
<p class="lead text-body-secondary">{{ form_description|wp_kses_post }}</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</header>
|
||||
{% endblock %}
|
||||
|
||||
{% block form_content %}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body p-4">
|
||||
<form method="post" action="{{ form_action|default('') }}" enctype="multipart/form-data" novalidate>
|
||||
{{ wp_nonce_field(nonce_action|default('form_nonce'), nonce_name|default('_wpnonce')) }}
|
||||
|
||||
{% if form_type is defined %}
|
||||
<input type="hidden" name="form_type" value="{{ form_type|esc_attr }}">
|
||||
{% endif %}
|
||||
|
||||
{% if post_id is defined %}
|
||||
<input type="hidden" name="post_id" value="{{ post_id }}">
|
||||
{% endif %}
|
||||
|
||||
{% block form_errors %}
|
||||
{% if errors is defined and errors|length > 0 %}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<h2 class="alert-heading h6">{{ __('Please correct the following errors:') }}</h2>
|
||||
<ul class="mb-0">
|
||||
{% for error in errors %}
|
||||
<li>{{ error|esc_html }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block form_fields %}{% endblock %}
|
||||
|
||||
{% block form_actions %}
|
||||
<div class="d-grid gap-2 mt-4">
|
||||
<button type="submit" class="btn btn-primary btn-lg">
|
||||
{{ submit_label|default(__('Submit')) }}
|
||||
</button>
|
||||
|
||||
{% if cancel_url is defined %}
|
||||
<a href="{{ cancel_url|esc_url }}" class="btn btn-outline-secondary btn-lg">
|
||||
{{ __('Cancel') }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% block form_footer %}{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block form_sidebar %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{{ parent() }}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var form = document.querySelector('form');
|
||||
if (form) {
|
||||
form.addEventListener('submit', function(e) {
|
||||
var submitBtn = form.querySelector('button[type="submit"]');
|
||||
if (submitBtn) {
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>' + submitBtn.textContent;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
32
templates/layouts/page.html.twig
Normal file
32
templates/layouts/page.html.twig
Normal file
@@ -0,0 +1,32 @@
|
||||
{#
|
||||
# Page Layout (Bootstrap 5 Override)
|
||||
#
|
||||
# Layout for standard content pages.
|
||||
#
|
||||
# @package WcBootstrap
|
||||
# @since 0.1.0
|
||||
#}
|
||||
|
||||
{% extends "base.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="mb-4">
|
||||
{% block page_header %}
|
||||
<header class="mb-4">
|
||||
<h1>{{ page_title|default('')|esc_html }}</h1>
|
||||
|
||||
{% block page_description %}
|
||||
{% if page_description is defined %}
|
||||
<p class="lead text-body-secondary">{{ page_description|wp_kses_post }}</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</header>
|
||||
{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<div>
|
||||
{% block content_inner %}{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
53
templates/layouts/single.html.twig
Normal file
53
templates/layouts/single.html.twig
Normal file
@@ -0,0 +1,53 @@
|
||||
{#
|
||||
# Single Post Layout (Bootstrap 5 Override)
|
||||
#
|
||||
# Layout for single detail pages.
|
||||
# Supports an optional sidebar via the article_sidebar block.
|
||||
# When no sidebar content is provided, content spans full width.
|
||||
#
|
||||
# @package WcBootstrap
|
||||
# @since 0.1.0
|
||||
#}
|
||||
|
||||
{% extends "base.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
<article>
|
||||
{% block article_header %}
|
||||
<header class="d-flex flex-wrap align-items-start gap-3 mb-4">
|
||||
{% if has_thumbnail %}
|
||||
<div class="flex-shrink-0">
|
||||
<img src="{{ thumbnail }}" alt="{{ title|esc_attr }}" class="rounded img-fluid" style="max-width: 150px;">
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="flex-grow-1">
|
||||
<h1>{{ title|esc_html }}</h1>
|
||||
|
||||
{% block article_meta %}{% endblock %}
|
||||
</div>
|
||||
|
||||
{% block article_actions %}{% endblock %}
|
||||
</header>
|
||||
{% endblock %}
|
||||
|
||||
<div class="row g-4">
|
||||
<div class="{% block content_col_class %}col-lg-8{% endblock %}">
|
||||
{% block article_content %}
|
||||
<div>
|
||||
{{ original_content|default('')|wp_kses_post }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
{% set _sidebar_html %}{% block article_sidebar %}{% endblock %}{% endset %}
|
||||
{% if _sidebar_html|trim %}
|
||||
<aside class="col-lg-4">
|
||||
{{ _sidebar_html|raw }}
|
||||
</aside>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% block article_footer %}{% endblock %}
|
||||
</article>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user