From da723afccd8d204a1470ef721fa4a0acd8334100 Mon Sep 17 00:00:00 2001 From: Brandon Nifong Date: Wed, 1 May 2019 02:01:50 -0500 Subject: [PATCH 1/5] Add missing search blade Enable preflight by default Bump version to 10.0.0 in package.json and style.css Change PHP requirement to 7.1.3 Upgrade roots/sage-installer Remove deprecated qwp6t/acorn repository from composer.json Add some sane optimizations to composer.json Remove excessive linebreaks from helpers.php Make config linebreaking uniform Add missing space to ! conditionals to stay consistent with PSR-1/2 Update the file structure in README.md and add the new sponsor Revert to shorthand @php() Add aside markup to sidebar and wrap it in @hasSection Add a document wrapper Add ARIA roles to the document, main, aside, header, nav, and footer wrappers Change entry-meta conditional in content-search.blade.php to an @includeWhen Add some sane linebreaks throughout the views and codebase to increase readability Add docblocks to the example Title.php composer --- README.md | 10 +- app/Composers/Title.php | 24 ++ app/helpers.php | 2 - app/setup.php | 2 + composer.json | 20 +- composer.lock | 206 +++++++++++++++++- config/app.php | 4 +- config/assets.php | 2 - config/filesystems.php | 2 - config/view.php | 5 - package.json | 2 +- resources/functions.php | 6 +- resources/style.css | 2 +- resources/views/404.blade.php | 3 +- resources/views/forms/search.blade.php | 8 + resources/views/index.blade.php | 9 +- resources/views/layouts/app.blade.php | 37 ++-- resources/views/page.blade.php | 2 +- resources/views/partials/comments.blade.php | 17 +- .../views/partials/content-page.blade.php | 2 +- .../views/partials/content-search.blade.php | 16 +- .../views/partials/content-single.blade.php | 14 +- resources/views/partials/content.blade.php | 12 +- resources/views/partials/entry-meta.blade.php | 8 +- resources/views/partials/footer.blade.php | 4 +- resources/views/partials/head.blade.php | 2 +- resources/views/partials/header.blade.php | 9 +- .../views/partials/page-header.blade.php | 4 +- resources/views/partials/sidebar.blade.php | 2 +- resources/views/search.blade.php | 5 +- resources/views/single.blade.php | 2 +- resources/views/template-custom.blade.php | 2 +- 32 files changed, 347 insertions(+), 98 deletions(-) create mode 100644 resources/views/forms/search.blade.php diff --git a/README.md b/README.md index 49d23e281a..5d8930aaae 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,16 @@ During theme installation you will have options to update `style.css` theme head ```shell themes/your-theme-name/ # → Root of your Sage based theme ├── app/ # → Theme PHP -│ ├── Controllers/ # → Controller files +│ ├── Composers/ # → Composer files │ ├── admin.php # → Theme customizer setup │ ├── filters.php # → Theme filters │ ├── helpers.php # → Helper functions │ └── setup.php # → Theme setup +├── config/ # → Config files +│ ├── app.php # → Application configuration +│ ├── assets.php # → Asset configuration +│ ├── filesystems.php # → Filesystems configuration +│ └── view.php # → View configuration ├── composer.json # → Autoloading for `app/` files ├── composer.lock # → Composer lock file (never edit) ├── dist/ # → Built theme assets (never edit) @@ -97,7 +102,6 @@ Edit `app/setup.php` to enable or disable theme features, setup navigation menus ## Documentation * [Sage documentation](https://roots.io/sage/docs/) -* [Controller documentation](https://github.com/soberwp/controller#usage) ## Contributing @@ -107,7 +111,7 @@ Contributions are welcome from everyone. We have [contributing guidelines](https Help support our open-source development efforts by [becoming a patron](https://www.patreon.com/rootsdev). -Kinsta KM Digital +Kinsta KM Digital itineris ## Community diff --git a/app/Composers/Title.php b/app/Composers/Title.php index 5bfe9c726a..62c82ec47d 100644 --- a/app/Composers/Title.php +++ b/app/Composers/Title.php @@ -6,37 +6,61 @@ class Title extends Composer { + /** + * List of views served by this composer. + * + * @var array + */ protected static $views = [ 'partials.page-header', 'partials.content', 'partials.content-*' ]; + /** + * Data to be passed to view before rendering. + * + * @param array $data + * @param \Illuminate\View\View $view + * @return array + */ public function with($data, $view) { return ['title' => $this->title($view->getName())]; } + /** + * Returns the post title. + * + * @param \Illuminate\View\View $view + * @return string + */ public function title($view) { if ($view !== '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(__('Search Results for %s', 'sage'), get_search_query()); } + if (is_404()) { return __('Not Found', 'sage'); } + return get_the_title(); } } diff --git a/app/helpers.php b/app/helpers.php index 5034bed531..2d016488a5 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -1,5 +1,3 @@ '

', 'after_title' => '

' ]; + register_sidebar([ 'name' => __('Primary', 'sage'), 'id' => 'sidebar-primary' ] + $config); + register_sidebar([ 'name' => __('Footer', 'sage'), 'id' => 'sidebar-footer' diff --git a/composer.json b/composer.json index 09c7897d45..fe113da2be 100644 --- a/composer.json +++ b/composer.json @@ -33,21 +33,21 @@ "App\\": "app/" } }, - "repositories": [ - { - "type": "git", - "url": "https://github.com/qwp6t/acorn" - } - ], - "minimum-stability": "dev", "require": { - "php": ">=7.1", + "php": "^7.1.3", "roots/acorn": "dev-master" }, "require-dev": { - "squizlabs/php_codesniffer": "^3.3", - "roots/sage-installer": "~1.3" + "roots/sage-installer": "^1.6", + "squizlabs/php_codesniffer": "^3.3" + }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true }, + "minimum-stability": "dev", + "prefer-stable": true, "scripts": { "test": [ "phpcs" diff --git a/composer.lock b/composer.lock index 1a73ae955c..b694260df9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4e6dd4d5e94c35a36220ba54bb07f0a0", + "content-hash": "2cec6b1809bcbbfaddffc4bbac02b893", "packages": [ { "name": "doctrine/inflector", @@ -701,7 +701,7 @@ "version": "dev-master", "source": { "type": "git", - "url": "https://github.com/qwp6t/acorn", + "url": "https://github.com/roots/acorn.git", "reference": "bb3a96f323457b18289eecd6989cce7ddb8b8806" }, "require": { @@ -1166,27 +1166,155 @@ "homepage": "https://laravel.com", "time": "2018-12-13T13:53:32+00:00" }, + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" + }, + { + "name": "ramsey/uuid", + "version": "3.8.0", + "source": { + "type": "git", + "url": "https://github.com/ramsey/uuid.git", + "reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/d09ea80159c1929d75b3f9c60504d613aeb4a1e3", + "reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "^1.0|^2.0|9.99.99", + "php": "^5.4 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "replace": { + "rhumsaa/uuid": "self.version" + }, + "require-dev": { + "codeception/aspect-mock": "^1.0 | ~2.0.0", + "doctrine/annotations": "~1.2.0", + "goaop/framework": "1.0.0-alpha.2 | ^1.0 | ~2.1.0", + "ircmaxell/random-lib": "^1.1", + "jakub-onderka/php-parallel-lint": "^0.9.0", + "mockery/mockery": "^0.9.9", + "moontoast/math": "^1.1", + "php-mock/php-mock-phpunit": "^0.3|^1.1", + "phpunit/phpunit": "^4.7|^5.0|^6.5", + "squizlabs/php_codesniffer": "^2.3" + }, + "suggest": { + "ext-ctype": "Provides support for PHP Ctype functions", + "ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator", + "ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator", + "ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter", + "moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).", + "ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid", + "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Ramsey\\Uuid\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marijn Huizendveld", + "email": "marijn.huizendveld@gmail.com" + }, + { + "name": "Thibaud Fabre", + "email": "thibaud@aztech.io" + }, + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" + } + ], + "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", + "homepage": "https://github.com/ramsey/uuid", + "keywords": [ + "guid", + "identifier", + "uuid" + ], + "time": "2018-07-19T23:38:55+00:00" + }, { "name": "roots/sage-installer", - "version": "1.5.1", + "version": "1.6.2", "source": { "type": "git", "url": "https://github.com/roots/sage-installer.git", - "reference": "b5f9b2f2175b4c61dc98cd2523b2e87ea1b4ecbb" + "reference": "bff412234f9852a73d3c2f2e49bfb959f7f732e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/roots/sage-installer/zipball/b5f9b2f2175b4c61dc98cd2523b2e87ea1b4ecbb", - "reference": "b5f9b2f2175b4c61dc98cd2523b2e87ea1b4ecbb", + "url": "https://api.github.com/repos/roots/sage-installer/zipball/bff412234f9852a73d3c2f2e49bfb959f7f732e8", + "reference": "bff412234f9852a73d3c2f2e49bfb959f7f732e8", "shasum": "" }, "require": { "illuminate/console": "~5.6", "illuminate/filesystem": "~5.6", + "ramsey/uuid": "^3.8", "symfony/process": "~3.3" }, "require-dev": { - "squizlabs/php_codesniffer": "~3.0" + "squizlabs/php_codesniffer": "~3.3.1" }, "bin": [ "bin/sage" @@ -1223,7 +1351,7 @@ "theme", "wordpress" ], - "time": "2018-12-21T19:32:27+00:00" + "time": "2019-02-14T01:13:25+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -1345,6 +1473,64 @@ "homepage": "https://symfony.com", "time": "2018-12-24T10:03:37+00:00" }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "82ebae02209c21113908c229e9883c419720738a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-02-06T07:57:58+00:00" + }, { "name": "symfony/process", "version": "3.4.x-dev", @@ -1400,10 +1586,10 @@ "stability-flags": { "roots/acorn": 20 }, - "prefer-stable": false, + "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": ">=7.1" + "php": "^7.1.3" }, "platform-dev": [] } diff --git a/config/app.php b/config/app.php index 80c72eed5b..2143ecc86e 100644 --- a/config/app.php +++ b/config/app.php @@ -40,8 +40,8 @@ | or doing any other checks to ensure the service is functional. | */ - - 'preflight' => false, + + 'preflight' => true, /* |-------------------------------------------------------------------------- diff --git a/config/assets.php b/config/assets.php index 5966a8ba84..0cfcc20a1f 100644 --- a/config/assets.php +++ b/config/assets.php @@ -15,7 +15,6 @@ 'uri' => get_theme_file_uri('/dist'), - /* |-------------------------------------------------------------------------- | Assets Directory Path @@ -28,7 +27,6 @@ 'path' => get_theme_file_path('/dist'), - /* |-------------------------------------------------------------------------- | Assets Manifest diff --git a/config/filesystems.php b/config/filesystems.php index e5b6482689..491ae4a679 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -17,7 +17,6 @@ 'default' => env('FILESYSTEM_DRIVER', 'local'), - /* |-------------------------------------------------------------------------- | Default Cloud Filesystem Disk @@ -31,7 +30,6 @@ 'cloud' => env('FILESYSTEM_CLOUD', 's3'), - /* |-------------------------------------------------------------------------- | Filesystem Disks diff --git a/config/view.php b/config/view.php index c087271a45..41a2ef4c55 100644 --- a/config/view.php +++ b/config/view.php @@ -17,7 +17,6 @@ get_parent_theme_file_path('/resources/views') ], - /* |-------------------------------------------------------------------------- | Compiled View Path @@ -31,7 +30,6 @@ 'compiled' => wp_upload_dir()['basedir'] . '/acorn/cache', - /* |-------------------------------------------------------------------------- | View Debugger @@ -46,7 +44,6 @@ 'debug' => false, - /* |-------------------------------------------------------------------------- | View Namespaces @@ -67,7 +64,6 @@ // 'MyPlugin' => WP_PLUGIN_DIR . '/my-plugin/resources/views', ], - /* |-------------------------------------------------------------------------- | View Composers @@ -83,7 +79,6 @@ App\Composers\Title::class, ], - /* |-------------------------------------------------------------------------- | View Directives diff --git a/package.json b/package.json index 05990ed2fc..a893057ace 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sage", - "version": "9.0.5", + "version": "10.0.0", "author": "Roots ", "homepage": "https://roots.io/sage/", "private": true, diff --git a/resources/functions.php b/resources/functions.php index 60d88c07c3..3ed2ea3792 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -20,8 +20,8 @@ /** * Ensure compatible version of PHP is used */ -if (version_compare('7.1', phpversion(), '>=')) { - $sage_error(__('You must be using PHP 7.1 or greater.', 'sage'), __('Invalid PHP version', 'sage')); +if (version_compare('7.1.3', phpversion(), '>=')) { + $sage_error(__('You must be using PHP 7.1.3 or greater.', 'sage'), __('Invalid PHP version', 'sage')); } /** @@ -50,7 +50,7 @@ */ array_map(function ($file) use ($sage_error) { $file = "../app/{$file}.php"; - if (!locate_template($file, true, true)) { + if (! locate_template($file, true, true)) { $sage_error( sprintf(__('Error locating %s for inclusion.', 'sage'), $file), __('File not found', 'sage') diff --git a/resources/style.css b/resources/style.css index 130b8ed9cf..cbbce0430f 100644 --- a/resources/style.css +++ b/resources/style.css @@ -2,7 +2,7 @@ Theme Name: Sage Starter Theme Theme URI: https://roots.io/sage/ Description: Sage is a WordPress starter theme. -Version: 9.0.5 +Version: 10.0.0 Author: Roots Author URI: https://roots.io/ Text Domain: sage diff --git a/resources/views/404.blade.php b/resources/views/404.blade.php index ee68d543ca..67a4c9e905 100644 --- a/resources/views/404.blade.php +++ b/resources/views/404.blade.php @@ -3,10 +3,11 @@ @section('content') @include('partials.page-header') - @if (!have_posts()) + @if (! have_posts())
{{ __('Sorry, but the page you were trying to view does not exist.', 'sage') }}
+ {!! get_search_form(false) !!} @endif @endsection diff --git a/resources/views/forms/search.blade.php b/resources/views/forms/search.blade.php new file mode 100644 index 0000000000..b96584d7dc --- /dev/null +++ b/resources/views/forms/search.blade.php @@ -0,0 +1,8 @@ + diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 9bf9afdf72..15e19bdf5f 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -3,14 +3,15 @@ @section('content') @include('partials.page-header') - @if (!have_posts()) + @if (! have_posts())
{{ __('Sorry, no results were found.', 'sage') }}
+ {!! get_search_form(false) !!} @endif - @while (have_posts()) @php the_post() @endphp + @while (have_posts()) @php(the_post()) @includeFirst(['partials.content-'.get_post_type(), 'partials.content']) @endwhile @@ -18,7 +19,5 @@ @endsection @section('sidebar') - + @include('partials.sidebar') @endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index d361bf5f54..0401c5f833 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -1,19 +1,30 @@ - + @include('partials.head') - - @php do_action('get_header') @endphp - @include('partials.header') -
-
-
- @yield('content') -
- @yield('sidebar') + + +
+ @php(do_action('get_header')) + @include('partials.header') + +
+
+
+ @yield('content') +
+ + @hasSection('sidebar') + + @endif +
+ + @php(do_action('get_footer')) + @include('partials.footer')
- @php do_action('get_footer') @endphp - @include('partials.footer') - @php wp_footer() @endphp + + @php(wp_footer()) diff --git a/resources/views/page.blade.php b/resources/views/page.blade.php index c57fc94eca..38c0dabb1e 100644 --- a/resources/views/page.blade.php +++ b/resources/views/page.blade.php @@ -1,7 +1,7 @@ @extends('layouts.app') @section('content') - @while(have_posts()) @php the_post() @endphp + @while(have_posts()) @php(the_post()) @include('partials.page-header') @includeFirst(['partials.content-page', 'partials.content']) @endwhile diff --git a/resources/views/partials/comments.blade.php b/resources/views/partials/comments.blade.php index 8060b6cd04..35e992d013 100644 --- a/resources/views/partials/comments.blade.php +++ b/resources/views/partials/comments.blade.php @@ -1,8 +1,6 @@ -@php -if (post_password_required()) { - return; -} -@endphp +@if (post_password_required()) + @php(return) +@endif
@if (have_comments()) @@ -18,21 +16,22 @@ @endif @endif - @if (!comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments')) + @if (! comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments'))
{{ __('Comments are closed.', 'sage') }}
@endif - @php comment_form() @endphp + @php(comment_form())
diff --git a/resources/views/partials/content-page.blade.php b/resources/views/partials/content-page.blade.php index 347ec378e9..41e050a4fe 100644 --- a/resources/views/partials/content-page.blade.php +++ b/resources/views/partials/content-page.blade.php @@ -1,2 +1,2 @@ -@php the_content() @endphp +@php(the_content()) {!! wp_link_pages(['echo' => 0, 'before' => '']) !!} diff --git a/resources/views/partials/content-search.blade.php b/resources/views/partials/content-search.blade.php index 520ab681b3..937660fb34 100644 --- a/resources/views/partials/content-search.blade.php +++ b/resources/views/partials/content-search.blade.php @@ -1,11 +1,15 @@ -
+
-

{{ $title }}

- @if (get_post_type() === 'post') - @include('partials/entry-meta') - @endif +

+ + {!! $title !!} + +

+ + @includeWhen(get_post_type() === 'post', 'partials/entry-meta')
+
- @php the_excerpt() @endphp + @php(the_excerpt())
diff --git a/resources/views/partials/content-single.blade.php b/resources/views/partials/content-single.blade.php index 227505e492..7ebc0b37a1 100644 --- a/resources/views/partials/content-single.blade.php +++ b/resources/views/partials/content-single.blade.php @@ -1,13 +1,19 @@ -
+
-

{{ $title }}

+

+ {!! $title !!} +

+ @include('partials/entry-meta')
+
- @php the_content() @endphp + @php(the_content())
+
{!! wp_link_pages(['echo' => 0, 'before' => '']) !!}
- @php comments_template('/partials/comments.blade.php') @endphp + + @php(comments_template('/partials/comments.blade.php'))
diff --git a/resources/views/partials/content.blade.php b/resources/views/partials/content.blade.php index 1790d09fcc..c6b5bffdf0 100644 --- a/resources/views/partials/content.blade.php +++ b/resources/views/partials/content.blade.php @@ -1,9 +1,15 @@ -
+ diff --git a/resources/views/partials/entry-meta.blade.php b/resources/views/partials/entry-meta.blade.php index 301e9b74b4..f218893c8d 100644 --- a/resources/views/partials/entry-meta.blade.php +++ b/resources/views/partials/entry-meta.blade.php @@ -1,6 +1,10 @@ - + + diff --git a/resources/views/partials/footer.blade.php b/resources/views/partials/footer.blade.php index da9feba0fa..3a2cf62b78 100644 --- a/resources/views/partials/footer.blade.php +++ b/resources/views/partials/footer.blade.php @@ -1,5 +1,5 @@ -