Repository: roots/sage Branch: main Commit: 55ef65d093b7 Files: 49 Total size: 30.3 KB Directory structure: gitextract_mlgy7jua/ ├── .editorconfig ├── .gitattributes ├── .github/ │ ├── labeler.yml │ ├── renovate.json │ └── workflows/ │ ├── discourse.yml │ ├── labeler.yml │ └── main.yml ├── .gitignore ├── LICENSE.md ├── README.md ├── app/ │ ├── Providers/ │ │ └── ThemeServiceProvider.php │ ├── View/ │ │ └── Composers/ │ │ ├── App.php │ │ ├── Comments.php │ │ └── Post.php │ ├── filters.php │ └── setup.php ├── composer.json ├── functions.php ├── index.php ├── package.json ├── public/ │ └── .gitkeep ├── resources/ │ ├── css/ │ │ ├── app.css │ │ └── editor.css │ ├── fonts/ │ │ └── .gitkeep │ ├── images/ │ │ └── .gitkeep │ ├── js/ │ │ ├── app.js │ │ └── editor.js │ └── views/ │ ├── 404.blade.php │ ├── components/ │ │ └── alert.blade.php │ ├── forms/ │ │ └── search.blade.php │ ├── index.blade.php │ ├── layouts/ │ │ └── app.blade.php │ ├── page.blade.php │ ├── partials/ │ │ ├── comments.blade.php │ │ ├── content-page.blade.php │ │ ├── content-search.blade.php │ │ ├── content-single.blade.php │ │ ├── content.blade.php │ │ ├── entry-meta.blade.php │ │ └── page-header.blade.php │ ├── search.blade.php │ ├── sections/ │ │ ├── footer.blade.php │ │ ├── header.blade.php │ │ └── sidebar.blade.php │ ├── single.blade.php │ └── template-custom.blade.php ├── style.css ├── theme.json └── vite.config.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 2 trim_trailing_whitespace = true quote_type = single [*.md] trim_trailing_whitespace = false [*.php] indent_size = 4 [*.blade.php] indent_size = 2 [resources/views/**.php] indent_size = 2 [index.php] indent_size = 2 ================================================ FILE: .gitattributes ================================================ /.gitattributes export-ignore /.github export-ignore ================================================ FILE: .github/labeler.yml ================================================ build: - changed-files: - any-glob-to-any-file: - vite.config.js dependencies: - changed-files: - any-glob-to-any-file: - package-lock.json javascript: - changed-files: - any-glob-to-any-file: - resources/js/**/*.js php: - changed-files: - any-glob-to-any-file: - functions.php - app/**/*.php - resources/views/**/*.php views: - changed-files: - any-glob-to-any-file: - index.php - resources/views/**/*.php ================================================ FILE: .github/renovate.json ================================================ { "baseBranchPatterns": [ "main" ], "commitMessageAction": "⬆️ Bump", "commitMessageTopic": "{{depName}}", "extends": [ "config:recommended", "schedule:weekly" ], "rangeStrategy": "replace", "ignoreDeps": ["php"], "packageRules": [ { "matchUpdateTypes": ["major"], "enabled": false }, { "matchPackageNames": ["node"], "enabled": false }, { "matchManagers": ["composer"], "matchDepTypes": ["require"], "matchPackageNames": ["php"], "enabled": false }, { "matchUpdateTypes": [ "minor", "patch", "pin" ], "enabled": true } ], "timezone": "America/Detroit" } ================================================ FILE: .github/workflows/discourse.yml ================================================ name: Post release topic on Discourse on: release: types: [published] jobs: post: runs-on: ubuntu-latest steps: - uses: roots/discourse-topic-github-release-action@main with: discourse-api-key: ${{ secrets.DISCOURSE_RELEASES_API_KEY }} discourse-base-url: ${{ secrets.DISCOURSE_BASE_URL }} github-token: ${{ github.token }} discourse-category: 11 discourse-tags: releases ================================================ FILE: .github/workflows/labeler.yml ================================================ name: "Pull Request Labeler" on: - pull_request_target jobs: triage: runs-on: ubuntu-latest steps: - uses: actions/labeler@v5 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" ================================================ FILE: .github/workflows/main.yml ================================================ name: Main on: push: branches: - main pull_request: branches: - main jobs: node: name: Node ${{ matrix.node }} runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[ci skip]')" strategy: matrix: node: ['20'] steps: - name: Checkout the project uses: actions/checkout@v4 - name: Setup the Node ${{ matrix.node }} environment on ${{ runner.os }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies using npm run: npm install - name: Build and compile assets run: | npm run build cat public/build/manifest.json - name: Validate theme.json run: | THEME_JSON="public/build/assets/theme.json" if [ ! -f "$THEME_JSON" ]; then echo "❌ theme.json not found" exit 1 fi jq -e ' (.settings.color.palette | length > 0) and (.settings.typography.fontFamilies | length > 0) and (.settings.typography.fontSizes | length > 0) ' "$THEME_JSON" 2>&1 || { echo "❌ Invalid theme.json structure or missing required values" exit 1 } php: name: PHP ${{ matrix.php }} runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[ci skip]')" strategy: matrix: php: ['8.2'] steps: - name: Checkout the project uses: actions/checkout@v4 - name: Setup the PHP ${{ matrix.php }} environment on ${{ runner.os }} uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: xdebug env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Restore the Composer cache directory id: composercache run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - uses: actions/cache@v4 with: path: ${{ steps.composercache.outputs.dir }} key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer- - name: Install Composer dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader --no-suggest - name: Run Pint run: vendor/bin/pint --test ================================================ FILE: .gitignore ================================================ /node_modules /vendor /public/* !/public/.gitkeep .env npm-debug.log ================================================ FILE: LICENSE.md ================================================ Copyright (c) Roots Software LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================

Sage

Packagist Installs Build Status Follow Roots Sponsor Roots

# Sage **Advanced hybrid WordPress starter theme with Laravel Blade and Tailwind CSS** - 🔧 Clean, efficient theme templating with Laravel Blade - ⚡️ Modern front-end development workflow powered by Vite - 🎨 Out of the box support for Tailwind CSS - 🚀 Harness the power of Laravel with [Acorn integration](https://github.com/roots/acorn) - 📦 Block editor support built-in Sage brings proper PHP templating and modern JavaScript tooling to WordPress themes. Write organized, component-based code using Laravel Blade, enjoy instant builds and CSS hot-reloading with Vite, and leverage Laravel's robust feature set through Acorn. [Read the docs to get started](https://roots.io/sage/docs/installation/) ## Support us Roots is an independent open source org, supported only by developers like you. Your sponsorship funds [WP Packages](https://wp-packages.org/) and the entire Roots ecosystem, and keeps them independent. Support us by purchasing [Radicle](https://roots.io/radicle/) or [sponsoring us on GitHub](https://github.com/sponsors/roots) — sponsors get access to our private Discord. ### Sponsors Carrot WordPress.com Itineris Kinsta 40Q ## Community Keep track of development and community news. - Join us on Discord by [sponsoring us on GitHub](https://github.com/sponsors/roots) - Join us on [Roots Discourse](https://discourse.roots.io/) - Follow [@rootswp on Twitter](https://twitter.com/rootswp) - Follow the [Roots Blog](https://roots.io/blog/) - Subscribe to the [Roots Newsletter](https://roots.io/subscribe/) ================================================ FILE: app/Providers/ThemeServiceProvider.php ================================================ 'ol', 'short_ping' => true, 'echo' => false, ]); } /** * The previous comments link. */ public function previous(): ?string { if (! get_previous_comments_link()) { return null; } return get_previous_comments_link( __('← Older comments', 'sage') ); } /** * The next comments link. */ public function next(): ?string { if (! get_next_comments_link()) { return null; } return get_next_comments_link( __('Newer comments →', 'sage') ); } /** * Determine if the comments are paginated. */ public function paginated(): bool { return get_comment_pages_count() > 1 && get_option('page_comments'); } /** * Determine if the comments are closed. */ public function closed(): bool { return ! comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments'); } } ================================================ FILE: app/View/Composers/Post.php ================================================ view->name() !== 'partials.page-header') { return get_the_title(); } if (is_home()) { if ($home = get_option('page_for_posts', true)) { return get_the_title($home); } return __('Latest Posts', 'sage'); } if (is_archive()) { return get_the_archive_title(); } if (is_search()) { return sprintf( /* translators: %s is replaced with the search query */ __('Search Results for %s', 'sage'), get_search_query() ); } if (is_404()) { return __('Not Found', 'sage'); } return get_the_title(); } /** * Retrieve the pagination links. */ public function pagination(): string { return wp_link_pages([ 'echo' => 0, 'before' => '

'.__('Pages:', 'sage'), 'after' => '

', ]); } } ================================================ FILE: app/filters.php ================================================ %s', get_permalink(), __('Continued', 'sage')); }); ================================================ FILE: app/setup.php ================================================ "@import url('{$style}')", ]; return $settings; }); /** * Inject scripts into the block editor. * * @return void */ add_action('admin_head', function () { if (! get_current_screen()?->is_block_editor()) { return; } if (! Vite::isRunningHot()) { $dependencies = json_decode(Vite::content('editor.deps.json')); foreach ($dependencies as $dependency) { if (! wp_script_is($dependency)) { wp_enqueue_script($dependency); } } } echo Vite::withEntryPoints([ 'resources/js/editor.js', ])->toHtml(); }); /** * Use the generated theme.json file. * * @return string */ add_filter('theme_file_path', function ($path, $file) { return $file === 'theme.json' ? public_path('build/assets/theme.json') : $path; }, 10, 2); /** * Disable on-demand block asset loading. * * @link https://core.trac.wordpress.org/ticket/61965 */ add_filter('should_load_separate_core_block_assets', '__return_false'); /** * Register the initial theme setup. * * @return void */ add_action('after_setup_theme', function () { /** * Disable full-site editing support. * * @link https://wptavern.com/gutenberg-10-5-embeds-pdfs-adds-verse-block-color-options-and-introduces-new-patterns */ remove_theme_support('block-templates'); /** * Register the navigation menus. * * @link https://developer.wordpress.org/reference/functions/register_nav_menus/ */ register_nav_menus([ 'primary_navigation' => __('Primary Navigation', 'sage'), ]); /** * Disable the default block patterns. * * @link https://developer.wordpress.org/block-editor/developers/themes/theme-support/#disabling-the-default-block-patterns */ remove_theme_support('core-block-patterns'); /** * Enable plugins to manage the document title. * * @link https://developer.wordpress.org/reference/functions/add_theme_support/#title-tag */ add_theme_support('title-tag'); /** * Enable post thumbnail support. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support('post-thumbnails'); /** * Enable responsive embed support. * * @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#responsive-embedded-content */ add_theme_support('responsive-embeds'); /** * Enable HTML5 markup support. * * @link https://developer.wordpress.org/reference/functions/add_theme_support/#html5 */ add_theme_support('html5', [ 'caption', 'comment-form', 'comment-list', 'gallery', 'search-form', 'script', 'style', ]); /** * Enable selective refresh for widgets in customizer. * * @link https://developer.wordpress.org/reference/functions/add_theme_support/#customize-selective-refresh-widgets */ add_theme_support('customize-selective-refresh-widgets'); }, 20); /** * Register the theme sidebars. * * @return void */ add_action('widgets_init', function () { $config = [ 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ]; register_sidebar([ 'name' => __('Primary', 'sage'), 'id' => 'sidebar-primary', ] + $config); register_sidebar([ 'name' => __('Footer', 'sage'), 'id' => 'sidebar-footer', ] + $config); }); ================================================ FILE: composer.json ================================================ { "name": "roots/sage", "type": "wordpress-theme", "license": "MIT", "description": "WordPress starter theme with a modern development workflow", "homepage": "https://roots.io/sage/", "authors": [ { "name": "Ben Word", "email": "ben@benword.com", "homepage": "https://github.com/retlehs" }, { "name": "Scott Walkinshaw", "email": "scott.walkinshaw@gmail.com", "homepage": "https://github.com/swalkinshaw" }, { "name": "QWp6t", "email": "hi@qwp6t.me", "homepage": "https://github.com/qwp6t" }, { "name": "Brandon Nifong", "email": "brandon@tendency.me", "homepage": "https://github.com/log1x" } ], "keywords": [ "wordpress" ], "support": { "issues": "https://github.com/roots/sage/issues", "forum": "https://discourse.roots.io/" }, "autoload": { "psr-4": { "App\\": "app/" } }, "require": { "php": ">=8.2", "roots/acorn": "^5.0" }, "require-dev": { "laravel/pint": "^1.20" }, "suggest": { "log1x/sage-directives": "A collection of useful Blade directives for WordPress and Sage (^1.0)." }, "config": { "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { "post-autoload-dump": [ "Roots\\Acorn\\ComposerScripts::postAutoloadDump" ] } } ================================================ FILE: functions.php ================================================ composer install.', 'sage')); } require $composer; /* |-------------------------------------------------------------------------- | Register The Bootloader |-------------------------------------------------------------------------- | | The first thing we will do is schedule a new Acorn application container | to boot when WordPress is finished loading the theme. The application | serves as the "glue" for all the components of Laravel and is | the IoC container for the system binding all of the various parts. | */ Application::configure() ->withProviders([ ThemeServiceProvider::class, ]) ->boot(); /* |-------------------------------------------------------------------------- | Register Sage Theme Files |-------------------------------------------------------------------------- | | Out of the box, Sage ships with categorically named theme files | containing common functionality and setup to be bootstrapped with your | theme. Simply add (or remove) files from the array below to change what | is registered alongside Sage. | */ collect(['setup', 'filters']) ->each(function ($file) { if (! locate_template($file = "app/{$file}.php", true, true)) { wp_die( /* translators: %s is replaced with the relative file path */ sprintf(__('Error locating %s for inclusion.', 'sage'), $file) ); } }); ================================================ FILE: index.php ================================================ render(); ================================================ FILE: package.json ================================================ { "name": "sage", "private": true, "engines": { "node": ">=20.0.0" }, "type": "module", "scripts": { "dev": "vite", "build": "vite build", "translate": "npm run translate:pot && npm run translate:update", "translate:pot": "wp i18n make-pot . ./resources/lang/sage.pot --include=\"theme.json,patterns,app,resources\"", "translate:update": "for file in ./resources/lang/*.po; do wp i18n update-po ./resources/lang/sage.pot $file; done", "translate:compile": "npm run translate:mo && npm run translate:js", "translate:js": "wp i18n make-json ./resources/lang --pretty-print", "translate:mo": "wp i18n make-mo ./resources/lang ./resources/lang" }, "devDependencies": { "@roots/vite-plugin": "^1.0.0", "@tailwindcss/vite": "^4.0.0", "laravel-vite-plugin": "^2.0.0", "tailwindcss": "^4.0.0", "vite": "^7.0.0" } } ================================================ FILE: public/.gitkeep ================================================ ================================================ FILE: resources/css/app.css ================================================ @import "tailwindcss" theme(static); @source "../../app/**/*.php"; @source "../**/*.blade.php"; @source "../**/*.js"; ================================================ FILE: resources/css/editor.css ================================================ @import "tailwindcss"; ================================================ FILE: resources/fonts/.gitkeep ================================================ ================================================ FILE: resources/images/.gitkeep ================================================ ================================================ FILE: resources/js/app.js ================================================ import.meta.glob([ '../images/**', '../fonts/**', ]); ================================================ FILE: resources/js/editor.js ================================================ import domReady from '@wordpress/dom-ready'; domReady(() => { // }); ================================================ FILE: resources/views/404.blade.php ================================================ @extends('layouts.app') @section('content') @include('partials.page-header') @if (! have_posts()) {!! __('Sorry, but the page you are trying to view does not exist.', 'sage') !!} {!! get_search_form(false) !!} @endif @endsection ================================================ FILE: resources/views/components/alert.blade.php ================================================ @props([ 'type' => null, 'message' => null, ]) @php($class = match ($type) { 'success' => 'text-green-50 bg-green-400', 'caution' => 'text-yellow-50 bg-yellow-400', 'warning' => 'text-red-50 bg-red-400', default => 'text-indigo-50 bg-indigo-400', })
merge(['class' => "px-2 py-1 {$class}"]) }}> {!! $message ?? $slot !!}
================================================ FILE: resources/views/forms/search.blade.php ================================================ ================================================ FILE: resources/views/index.blade.php ================================================ @extends('layouts.app') @section('content') @include('partials.page-header') @if (! have_posts()) {!! __('Sorry, no results were found.', 'sage') !!} {!! get_search_form(false) !!} @endif @while(have_posts()) @php(the_post()) @includeFirst(['partials.content-' . get_post_type(), 'partials.content']) @endwhile {!! get_the_posts_navigation() !!} @endsection @section('sidebar') @include('sections.sidebar') @endsection ================================================ FILE: resources/views/layouts/app.blade.php ================================================ @php(do_action('get_header')) @php(wp_head()) @vite(['resources/css/app.css', 'resources/js/app.js']) @php(wp_body_open())
{{ __('Skip to content', 'sage') }} @include('sections.header')
@yield('content')
@hasSection('sidebar') @endif @include('sections.footer')
@php(do_action('get_footer')) @php(wp_footer()) ================================================ FILE: resources/views/page.blade.php ================================================ @extends('layouts.app') @section('content') @while(have_posts()) @php(the_post()) @include('partials.page-header') @includeFirst(['partials.content-page', 'partials.content']) @endwhile @endsection ================================================ FILE: resources/views/partials/comments.blade.php ================================================ @if (! post_password_required())
@if ($responses())

{!! $title !!}

    {!! $responses !!}
@if ($paginated()) @endif @endif @if ($closed()) {!! __('Comments are closed.', 'sage') !!} @endif @php(comment_form())
@endif ================================================ FILE: resources/views/partials/content-page.blade.php ================================================ @php(the_content()) @if ($pagination()) @endif ================================================ FILE: resources/views/partials/content-search.blade.php ================================================

{!! $title !!}

@includeWhen(get_post_type() === 'post', 'partials.entry-meta')
@php(the_excerpt())
================================================ FILE: resources/views/partials/content-single.blade.php ================================================

{!! $title !!}

@include('partials.entry-meta')
@php(the_content())
@if ($pagination()) @endif @php(comments_template())
================================================ FILE: resources/views/partials/content.blade.php ================================================

{!! $title !!}

@include('partials.entry-meta')
@php(the_excerpt())
================================================ FILE: resources/views/partials/entry-meta.blade.php ================================================

{{ __('By', 'sage') }} {{ get_the_author() }}

================================================ FILE: resources/views/partials/page-header.blade.php ================================================ ================================================ FILE: resources/views/search.blade.php ================================================ @extends('layouts.app') @section('content') @include('partials.page-header') @if (! have_posts()) {!! __('Sorry, no results were found.', 'sage') !!} {!! get_search_form(false) !!} @endif @while(have_posts()) @php(the_post()) @include('partials.content-search') @endwhile {!! get_the_posts_navigation() !!} @endsection ================================================ FILE: resources/views/sections/footer.blade.php ================================================ ================================================ FILE: resources/views/sections/header.blade.php ================================================ ================================================ FILE: resources/views/sections/sidebar.blade.php ================================================ @php(dynamic_sidebar('sidebar-primary')) ================================================ FILE: resources/views/single.blade.php ================================================ @extends('layouts.app') @section('content') @while(have_posts()) @php(the_post()) @includeFirst(['partials.content-single-' . get_post_type(), 'partials.content-single']) @endwhile @endsection ================================================ FILE: resources/views/template-custom.blade.php ================================================ {{-- Template Name: Custom Template --}} @extends('layouts.app') @section('content') @while(have_posts()) @php(the_post()) @include('partials.page-header') @include('partials.content-page') @endwhile @endsection ================================================ FILE: style.css ================================================ /* Theme Name: Sage Starter Theme Theme URI: https://roots.io/sage/ Description: Sage is a WordPress starter theme. Version: 11.x-dev Author: Roots Author URI: https://roots.io/ Text Domain: sage License: MIT License License URI: https://opensource.org/licenses/MIT Requires PHP: 8.2 Requires at least: 6.6 */ ================================================ FILE: theme.json ================================================ { "__preprocessed__": "This file is used to build the theme.json file in the `public/build/assets` directory. The built artifact includes Tailwind's colors, fonts, and font sizes.", "$schema": "https://schemas.wp.org/trunk/theme.json", "version": 3, "settings": { "layout": { "contentSize": "48rem" }, "background": { "backgroundImage": true }, "color": { "custom": false, "customDuotone": false, "customGradient": false, "defaultDuotone": false, "defaultGradients": false, "defaultPalette": false, "duotone": [] }, "custom": { "spacing": {}, "typography": { "font-size": {}, "line-height": {} } }, "spacing": { "padding": true, "units": ["px", "%", "em", "rem", "vw", "vh"] }, "typography": { "defaultFontSizes": false, "customFontSize": false } } } ================================================ FILE: vite.config.js ================================================ import { defineConfig } from 'vite' import tailwindcss from '@tailwindcss/vite'; import laravel from 'laravel-vite-plugin' import { wordpressPlugin, wordpressThemeJson } from '@roots/vite-plugin'; // Set APP_URL if it doesn't exist for Laravel Vite plugin if (! process.env.APP_URL) { process.env.APP_URL = 'http://example.test'; } export default defineConfig({ base: '/app/themes/sage/public/build/', plugins: [ tailwindcss(), laravel({ input: [ 'resources/css/app.css', 'resources/js/app.js', 'resources/css/editor.css', 'resources/js/editor.js', ], refresh: true, }), wordpressPlugin(), // Generate the theme.json file in the public/build/assets directory // based on the Tailwind config and the theme.json file from base theme folder wordpressThemeJson({ disableTailwindColors: false, disableTailwindFonts: false, disableTailwindFontSizes: false, disableTailwindBorderRadius: false, }), ], resolve: { alias: { '@scripts': '/resources/js', '@styles': '/resources/css', '@fonts': '/resources/fonts', '@images': '/resources/images', }, }, })