Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/Pollora/framework/compare/v13.32.0-beta.9...develop)

### Added
- A third `pollora:make:theme` template, **Magazine** (`magazine` → `pollora/theme-buzz`): a Full Site Editing block theme whose templates, parts and patterns are edited in the Site Editor, next to `default` and `ecommerce`. The missing-theme page and admin notice list it too

### Fixed
- A Vite script was printed before WordPress's import map, which Firefox and Safari then ignore: any WordPress script module on the page — the navigation block's, the search block's, the image lightbox's — failed on `@wordpress/interactivity was a bare specifier`, so the block did nothing. Chromium tolerates the order, which hid it. In a classic theme the import map is always in the footer, so any theme with a Vite script in the head was affected as soon as an author inserted such a block. The Vite client of the dev server had the same problem
- A block theme's own `404.html` answered with HTTP 200. WordPress core resolves it to `wp-includes/template-canvas.php`, which is never a Blade view, so it always rendered through `FrontendController`'s raw-PHP-template branch — the only branch that never looked at `is_404()`. Measured on a fresh block theme: right content, wrong status
Expand Down
6 changes: 6 additions & 0 deletions resources/views/theme-missing.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@
<pre><code>{{ $prefix }}php artisan pollora:make:theme my-shop --repository=pollora/theme-apiary</code></pre>
</div>

<div class="card">
<h2>Start from the magazine theme</h2>
<p>A Full Site Editing block theme: its templates are edited in the Site Editor.</p>
<pre><code>{{ $prefix }}php artisan pollora:make:theme my-journal --repository=pollora/theme-buzz</code></pre>
</div>

<p class="note">
The command downloads the theme, fills in its metadata, installs its npm dependencies and builds
its assets, then activates it in WordPress. Run it from the project root, then reload this page.
Expand Down
13 changes: 11 additions & 2 deletions src/Theme/UI/Console/MakeThemeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,16 @@ protected function promptForMissingArgumentsUsing(): array
protected const TEMPLATES = [
'default' => 'pollora/theme-default',
'ecommerce' => 'pollora/theme-apiary',
'magazine' => 'pollora/theme-buzz',
];

/**
* What the prompt says of each built-in template, keyed like TEMPLATES.
*/
protected const TEMPLATE_LABELS = [
'default' => 'Default — Basic starter theme',
'ecommerce' => 'E-commerce — WooCommerce theme (Tailwind CSS, Alpine.js)',
'magazine' => 'Magazine — Full Site Editing block theme, edited in the Site Editor (Tailwind CSS)',
];

/**
Expand All @@ -503,8 +513,7 @@ protected function promptForRepository(): ?string
$choice = select(
label: 'Which theme template would you like to use?',
options: [
'default' => 'Default — Basic starter theme',
'ecommerce' => 'E-commerce — WooCommerce theme (Tailwind CSS, Alpine.js)',
...self::TEMPLATE_LABELS,
'repository' => 'Custom — Download from a GitHub repository',
],
default: 'default'
Expand Down
7 changes: 5 additions & 2 deletions src/Theme/UI/Http/MissingThemeNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ public function render(): void
$intro = __('No theme is installed, so the front end of this site cannot be rendered. Generate one from the project root:', 'pollora');
$default = __('Default theme', 'pollora');
$ecommerce = __('E-commerce theme (WooCommerce)', 'pollora');
$magazine = __('Magazine theme (Full Site Editing)', 'pollora');

printf(
'<div class="notice notice-warning"><p><strong>%s</strong></p><p>%s</p><p>%s<br><code>%s</code></p><p>%s<br><code>%s</code></p></div>',
'<div class="notice notice-warning"><p><strong>%s</strong></p><p>%s</p><p>%s<br><code>%s</code></p><p>%s<br><code>%s</code></p><p>%s<br><code>%s</code></p></div>',
esc_html__('Pollora: no theme installed', 'pollora'),
esc_html($intro),
esc_html($default),
esc_html($prefix.'php artisan pollora:make:theme my-theme --repository=pollora/theme-default'),
esc_html($ecommerce),
esc_html($prefix.'php artisan pollora:make:theme my-shop --repository=pollora/theme-apiary')
esc_html($prefix.'php artisan pollora:make:theme my-shop --repository=pollora/theme-apiary'),
esc_html($magazine),
esc_html($prefix.'php artisan pollora:make:theme my-journal --repository=pollora/theme-buzz')
);
}
}
8 changes: 6 additions & 2 deletions tests/Feature/Theme/MissingThemeGuidanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function viewNotFound(string $view = 'home'): InvalidArgumentException
expect($response)->toBeInstanceOf(Response::class)
->and($response->getStatusCode())->toBe(503)
->and($response->getContent())->toContain('pollora/theme-default')
->and($response->getContent())->toContain('pollora/theme-apiary');
->and($response->getContent())->toContain('pollora/theme-apiary')
->and($response->getContent())->toContain('pollora/theme-buzz');
});

it('leaves the exception alone when a theme is installed', function (): void {
Expand Down Expand Up @@ -140,7 +141,10 @@ function viewNotFound(string $view = 'home'): InvalidArgumentException

expect($output)->toContain('notice-warning')
->and($output)->toContain('no theme installed')
->and($output)->toContain('pollora:make:theme');
->and($output)->toContain('pollora:make:theme')
->and($output)->toContain('pollora/theme-default')
->and($output)->toContain('pollora/theme-apiary')
->and($output)->toContain('pollora/theme-buzz');
});

it('stays silent once a theme is installed', function (): void {
Expand Down
21 changes: 21 additions & 0 deletions tests/Unit/Theme/MakeThemeCommandTemplatesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Pollora\Theme\UI\Console\MakeThemeCommand;

describe('MakeThemeCommand templates', function (): void {
$constant = fn (string $name): array => (new ReflectionClassConstant(MakeThemeCommand::class, $name))->getValue();

it('offers every built-in template in the prompt, and nothing that has no repository', function () use ($constant): void {
expect(array_keys($constant('TEMPLATE_LABELS')))->toBe(array_keys($constant('TEMPLATES')));
});

it('offers Buzz as the magazine template', function () use ($constant): void {
expect($constant('TEMPLATES'))->toMatchArray([
'default' => 'pollora/theme-default',
'ecommerce' => 'pollora/theme-apiary',
'magazine' => 'pollora/theme-buzz',
]);
});
});
Loading