Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Sage 10 Chores #2431

Merged
merged 5 commits into from
Apr 2, 2020
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
2 changes: 1 addition & 1 deletion app/View/Components/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Alert extends Component
* @param string $message
* @return void
*/
public function __construct($type, $message)
public function __construct($type = 'primary', $message = null)
{
$this->type = $type;
$this->message = $message;
Expand Down
149 changes: 75 additions & 74 deletions composer.lock

Large diffs are not rendered by default.

111 changes: 63 additions & 48 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,68 @@
<?php

/**
* Do not edit this file unless you know what you're doing.
*/

/**
* Helper function for prettying up errors.
*
* @param string $message
* @param string $subtitle
* @param string $title
*/
$sage_error = function ($message, $subtitle = '', $title = '') {
$title = $title ?: __('Sage &rsaquo; Error', 'sage');
$footer = '<a href="https://roots.io/sage/docs/">roots.io/sage/docs/</a>';
$message = "<h1>{$title}<br><small>{$subtitle}</small></h1><p>{$message}</p><p>{$footer}</p>";
wp_die($message, $title);
};

/**
* Ensure dependencies are loaded.
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our theme. We will simply require it into the script here so that we
| don't have to worry about manually loading any of our classes later on.
|
*/

if (! file_exists($composer = __DIR__ . '/vendor/autoload.php')) {
$sage_error(
__('You must run <code>composer install</code> from the Sage directory.', 'sage'),
__('Autoloader not found.', 'sage')
);
wp_die(__('Error locating autoloader. Please run <code>composer install</code>.', 'sage'));
}
require_once $composer;

/**
* Register any Sage theme files.
*
* The mapped array determines the code library included in your theme.
* Add or remove files to the array as needed. Supports child theme overrides.
*/
array_map(function ($file) use ($sage_error) {
$file = "app/{$file}.php";
if (! locate_template($file, true, true)) {
$sage_error(
sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file),
__('File not found', 'sage')
);
}
}, ['helpers', 'setup', 'filters', 'admin']);

/**
* Boot Acorn with the Sage provider.
* @link https://roots.io/acorn/
*/

require $composer;

/*
|--------------------------------------------------------------------------
| 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(['helpers', 'setup', 'filters', 'admin'])
->each(function ($file) {
$file = "app/{$file}.php";

if (! locate_template($file, true, true)) {
wp_die(
sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file)
);
}
});

/*
|--------------------------------------------------------------------------
| Enable Sage Theme Support
|--------------------------------------------------------------------------
|
| Once our theme files are registered and available for use, we are almost
| ready to boot our application. But first, we need to signal to Acorn
| that we will need to initialize the necessary service providers built in
| for Sage when booting.
|
*/

add_theme_support('sage');
Roots\bootloader();

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We are ready to bootstrap the Acorn framework and get it ready for use.
| Acorn will provide us support for Blade templating as well as the ability
| to utilize the Laravel framework and its beautifully written packages.
|
*/

new Roots\Acorn\Bootloader();
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
},
"devDependencies": {
"@tinypixelco/laravel-mix-wp-blocks": "^1.0.0",
"@wordpress/babel-preset-default": "^4.10.0",
"@wordpress/babel-preset-default": "^4.11.0",
"@wordpress/browserslist-config": "^2.6.0",
"@wordpress/dependency-extraction-webpack-plugin": "^2.4.0",
"babel-eslint": "^10.1.0",
"browser-sync": "^2.26.7",
"browser-sync-webpack-plugin": "^2.0.1",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-import": "^2.20.2",
"laravel-mix": "^5.0.4",
"laravel-mix-copy-watched": "^2.2.3",
"laravel-mix-purgecss": "^5.0.0-rc.1",
Expand Down
4 changes: 3 additions & 1 deletion resources/views/404.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
@include('partials.page-header')

@if (! have_posts())
<x-alert type="warning" message="Sorry, but the page you are trying to view does not exist." />
<x-alert type="warning">
{!! __('Sorry, but the page you are trying to view does not exist.', 'sage') !!}
</x-alert>

{!! get_search_form(false) !!}
@endif
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/alert.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="alert alert-{{ $type ?? 'primary' }}">
{!! __($message, 'sage') !!}
<div class="alert alert-{{ $type }}">
{!! $message ?? $slot !!}
</div>
4 changes: 3 additions & 1 deletion resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
@include('partials.page-header')

@if (! have_posts())
<x-alert type="warning" message="Sorry, no results were found" />
<x-alert type="warning">
{!! __('Sorry, no results were found.', 'sage') !!}
</x-alert>

{!! get_search_form(false) !!}
@endif
Expand Down
4 changes: 3 additions & 1 deletion resources/views/partials/comments.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
@endif

@if (! comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments'))
<x-alert type="warning" message="Comments are closed." />
<x-alert type="warning">
{!! __('Comments are closed.', 'sage') !!}
</x-alert>
@endif

@php(comment_form())
Expand Down
4 changes: 3 additions & 1 deletion resources/views/search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
@include('partials.page-header')

@if (! have_posts())
<x-alert type="warning" message="Sorry but the page you were trying to view does not exist." />
<x-alert type="warning">
{!! __('Sorry, no results were found.', 'sage') !!}
</x-alert>

{!! get_search_form(false) !!}
@endif
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Author URI: https://roots.io/
Text Domain: sage
License: MIT License
License URI: https://opensource.org/licenses/MIT
Requires PHP: 7.2.0
Requires PHP: 7.2.5
Requires at least: 5.4
*/
Loading