diff --git a/.babelrc b/.babelrc deleted file mode 100644 index a9b68d19ea..0000000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["@babel/plugin-syntax-dynamic-import"] -} diff --git a/.editorconfig b/.editorconfig index 9bfbfb933c..2ca82c5eee 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,3 +19,6 @@ indent_size = 2 [resources/views/**.php] indent_size = 2 + +[index.php] +indent_size = 2 diff --git a/.stylelintrc b/.stylelintrc index 631d5870bb..0ac2ff33cb 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -5,6 +5,7 @@ "value-list-comma-newline-after": null, "no-empty-source": null, "no-descending-specificity": null, + "at-rule-empty-line-before": null, "at-rule-no-unknown": [ true, { diff --git a/README.md b/README.md index 490a1b836d..dae23ce6cd 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ See a working example at [roots-example-project.com](https://roots-example-proje Make sure all dependencies have been installed before moving on: -* [WordPress](https://wordpress.org/) >= 5.2 -* [PHP](https://secure.php.net/manual/en/install.php) >= 7.1.3 (with [`php-mbstring`](https://secure.php.net/manual/en/book.mbstring.php) enabled) +* [WordPress](https://wordpress.org/) >= 5.4 +* [PHP](https://secure.php.net/manual/en/install.php) >= 7.2.0 (with [`php-mbstring`](https://secure.php.net/manual/en/book.mbstring.php) enabled) * [Composer](https://getcomposer.org/download/) * [Node.js](http://nodejs.org/) >= 8.0.0 * [Yarn](https://yarnpkg.com/en/docs/install) @@ -114,7 +114,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 Scale Dynamix Wisdom +Kinsta KM Digital Nestify ## Community diff --git a/app/View/Components/Alert.php b/app/View/Components/Alert.php new file mode 100644 index 0000000000..cc579ba125 --- /dev/null +++ b/app/View/Components/Alert.php @@ -0,0 +1,45 @@ +type = $type; + $this->message = $message; + } + + /** + * Get the view / contents that represent the component. + * + * @return \Illuminate\View\View|string + */ + public function render() + { + return $this->view('components.alert'); + } +} diff --git a/app/Composers/App.php b/app/View/Composers/App.php similarity index 95% rename from app/Composers/App.php rename to app/View/Composers/App.php index 8462717310..0d870d4438 100644 --- a/app/Composers/App.php +++ b/app/View/Composers/App.php @@ -1,6 +1,6 @@ get()) { - wp_enqueue_script('sage/vendor.js', asset('scripts/vendor.js')->uri(), ['jquery'], null, true); - wp_enqueue_script( - 'sage/editor.js', - asset('scripts/editor.js')->uri(), - array_merge($manifest['dependencies'], ['sage/vendor.js']), - $manifest['version'] - ); - - wp_add_inline_script('sage/editor.js', asset('scripts/manifest.js')->contents(), 'before'); + wp_enqueue_script('sage/vendor.js', asset('scripts/vendor.js')->uri(), $manifest['dependencies'], null, true); + wp_enqueue_script('sage/editor.js', asset('scripts/editor.js')->uri(), ['sage/vendor.js'], null, true); + + wp_add_inline_script('sage/vendor.js', asset('scripts/manifest.js')->contents(), 'before'); } wp_enqueue_style('sage/editor.css', asset('styles/editor.css')->uri(), false, null); diff --git a/composer.json b/composer.json index b2c88ee101..652f2959b8 100644 --- a/composer.json +++ b/composer.json @@ -39,11 +39,11 @@ } }, "require": { - "php": "^7.2", - "roots/acorn": "dev-master" + "php": "^7.2.5", + "roots/acorn": "^1.0.1" }, "require-dev": { - "filp/whoops": "^2.5", + "filp/whoops": "^2.7", "squizlabs/php_codesniffer": "^3.5" }, "suggest": { @@ -59,7 +59,7 @@ "prefer-stable": true, "scripts": { "lint": [ - "phpcs --ignore=vendor,resources,storage,dist --extensions=php --standard=PSR12 ." + "phpcs --ignore=index.php,vendor,resources,storage,dist --extensions=php --standard=PSR12 ." ], "post-autoload-dump": [ "Roots\\Acorn\\ComposerScripts::postAutoloadDump" diff --git a/config/app.php b/config/app.php index 3a95033b19..363b53a257 100644 --- a/config/app.php +++ b/config/app.php @@ -120,13 +120,20 @@ */ 'providers' => [ + /** + * Package Service Providers + */ + // ExamplePackage\Providers\ExamplePackageServiceProvider::class, + + /** + * Application Service Providers + */ App\Providers\ThemeServiceProvider::class, - // App\SomeService\SomeServiceServiceProvider::class, ], /* |-------------------------------------------------------------------------- - | Class Aliases (formerly "Facades") + | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application @@ -137,6 +144,7 @@ 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, + 'Arr' => Illuminate\Support\Arr::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, @@ -152,6 +160,7 @@ 'File' => Illuminate\Support\Facades\File::class, 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, + 'Http' => Illuminate\Support\Facades\Http::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, @@ -166,6 +175,7 @@ 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, + 'Str' => Illuminate\Support\Str::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, diff --git a/config/filesystems.php b/config/filesystems.php index 491ae4a679..773e01d3fd 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -9,9 +9,9 @@ | Default Filesystem Disk |-------------------------------------------------------------------------- | - | Here you may specify the default filesystem disk that should be used. - | The "local" disk, as well as a variety of cloud-based disks are - | available to your application. Just store away! + | Here you may specify the default filesystem disk that should be used + | by the framework. The "local" disk, as well as a variety of cloud + | based disks are available to your application. Just store away! | */ @@ -39,7 +39,7 @@ | may even configure multiple disks of the same driver. Defaults have | been setup for each driver as an example of the required options. | - | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace" + | Supported Drivers: "local", "ftp", "sftp", "s3" | */ diff --git a/config/logging.php b/config/logging.php index 4d80d5a007..18428d97a5 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,5 +1,6 @@ [ 'stack' => [ 'driver' => 'stack', - 'channels' => ['daily'], + 'channels' => ['single'], 'ignore_exceptions' => false, ], @@ -59,7 +60,7 @@ 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Sage Log', + 'username' => 'App Log', 'emoji' => ':boom:', 'level' => 'critical', ], @@ -92,5 +93,14 @@ 'driver' => 'errorlog', 'level' => 'debug', ], + + 'null' => [ + 'driver' => 'monolog', + 'handler' => NullHandler::class, + ], + + 'emergency' => [ + 'path' => storage_path('logs/sage.log'), + ], ], ]; diff --git a/config/view.php b/config/view.php index 52b725ec72..09f59b7a08 100755 --- a/config/view.php +++ b/config/view.php @@ -64,21 +64,6 @@ // 'MyPlugin' => WP_PLUGIN_DIR . '/my-plugin/resources/views', ], - /* - |-------------------------------------------------------------------------- - | View Composers - |-------------------------------------------------------------------------- - | - | View composers allow data to always be passed to certain views. This can - | be useful when passing data to components such as hero elements, - | navigation, banners, etc. - | - */ - - 'composers' => [ - // App\Composers\Alert::class, - ], - /* |-------------------------------------------------------------------------- | View Directives @@ -92,31 +77,4 @@ 'directives' => [ 'asset' => Roots\Acorn\Assets\AssetDirective::class, ], - - /* - |-------------------------------------------------------------------------- - | Blade Component Aliases - |-------------------------------------------------------------------------- - | - | Component aliases allow you to use a shorthand to call a Blade component. - | Instead of referencing your components like this: - | - | @component('components.alert', ['type' => 'warning']) - | {{ __('Page not found') }} - | @endcomponent - | - | You can use an alias instead: - | - | @alert(['type' => 'error']) - | {{ __('Page not found') }} - | @endalert - | - | Use the key to set the alias and the value to set the path to the - | view. - | - */ - - 'components' => [ - 'alert' => 'components.alert', - ], ]; diff --git a/functions.php b/functions.php index 94e0c82fe2..d3d5bd0aa6 100644 --- a/functions.php +++ b/functions.php @@ -1,67 +1,68 @@ roots.io/sage/docs/'; - $message = "

{$title}
{$subtitle}

{$message}

{$footer}

"; - wp_die($message, $title); -}; - -/** - * Ensure a compatible version of PHP is being used. - */ -if (version_compare('7.2', phpversion(), '>')) { - $sage_error(__('You must be using PHP 7.2 or greater.', 'sage'), __('Invalid PHP version', 'sage')); +if (! file_exists($composer = __DIR__ . '/vendor/autoload.php')) { + wp_die(__('Error locating autoloader. Please run composer install.', 'sage')); } -/** - * Ensure a compatible version of WordPress is being used. - */ -if (version_compare('5.2', get_bloginfo('version'), '>')) { - $sage_error(__('You must be using WordPress 5.2 or greater.', 'sage'), __('Invalid WordPress version', 'sage')); -} +require $composer; -/** - * Ensure dependencies are loaded. - */ -if (! file_exists($composer = __DIR__ . '/vendor/autoload.php')) { - $sage_error( - __('You must run composer install from the Sage directory.', 'sage'), - __('Autoloader not found.', 'sage') - ); -} -require_once $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. +| +*/ -/** - * 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 %s for inclusion.', 'sage'), $file), - __('File not found', 'sage') - ); - } -}, ['helpers', 'setup', 'filters', 'admin', 'demo']); +collect(['helpers', 'setup', 'filters', 'admin', 'demo']) + ->each(function ($file) { + $file = "app/{$file}.php"; + + if (! locate_template($file, true, true)) { + wp_die( + sprintf(__('Error locating %s 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. +| +*/ -/** - * Boot Acorn with the Sage provider. - * @link https://roots.io/acorn/ - */ 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(); diff --git a/index.php b/index.php index 234c9f8c28..922baccc34 100644 --- a/index.php +++ b/index.php @@ -1,10 +1,21 @@ - +> + + + + + + -/** - * Loads the template hierarchy view file. - */ + > + + -use function Roots\app; -use function Roots\view; +
+ render(); ?> +
-echo view(app('sage.view'), app('sage.data'))->render(); + + + + diff --git a/package.json b/package.json index 4028b12569..2047260447 100644 --- a/package.json +++ b/package.json @@ -31,30 +31,29 @@ ] }, "devDependencies": { - "@babel/plugin-syntax-dynamic-import": "^7.2", - "@wordpress/babel-preset-default": "^4.7.0", + "@tinypixelco/laravel-mix-wp-blocks": "^1.0.0", + "@wordpress/babel-preset-default": "^4.11.0", "@wordpress/browserslist-config": "^2.6.0", - "@wordpress/dependency-extraction-webpack-plugin": "^2.1.0", - "babel-eslint": "^10.0.3", + "@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": "^6.0.3", - "eslint": "^6.7.2", + "cross-env": "^7.0.2", + "eslint": "^6.8.0", "eslint-plugin-genero": "git+https://github.com/generoi/eslint-plugin-genero.git", - "eslint-plugin-import": "^2.18.2", + "eslint-plugin-import": "^2.20.2", "eslint-plugin-vue": "^6.1.2", - "laravel-mix": "^5.0.0", - "laravel-mix-copy-watched": "^2.2.1", - "laravel-mix-purgecss": "^4.2.0", - "laravel-mix-wp-blocks": "^0.2.0", + "laravel-mix": "^5.0.4", + "laravel-mix-copy-watched": "^2.2.3", + "laravel-mix-purgecss": "^5.0.0-rc.1", "npm-run-all": "^4.1", - "postcss-inline-svg": "^4.1.0", - "rimraf": "^3.0", - "sass": "^1.23.7", - "sass-loader": "^8.0.0", - "stylelint": "^12.0.0", - "stylelint-config-standard": "^19.0.0", - "vue-template-compiler": "^2.6.10" + "purgecss-with-wordpress": "^2.1.0", + "rimraf": "^3.0.2", + "sass": "^1.26.3", + "sass-loader": "^8.0.2", + "stylelint": "^13.3.0", + "stylelint-config-standard": "^20.0.0", + "vue-template-compiler": "^2.6.11" }, "dependencies": { "@fortawesome/fontawesome-free": "^5.12.0", diff --git a/resources/assets/scripts/customizer.js b/resources/assets/scripts/customizer.js index 753280b500..ade7b8d1cf 100644 --- a/resources/assets/scripts/customizer.js +++ b/resources/assets/scripts/customizer.js @@ -10,6 +10,6 @@ * * @param {string} value */ -wp.customize('blogname', (value) => { +wp.customize('blogname', value => { value.bind(to => $('.brand').text(to)); }); diff --git a/resources/assets/styles/components/index.scss b/resources/assets/styles/components/index.scss index 656f6de7f7..c173512acb 100644 --- a/resources/assets/styles/components/index.scss +++ b/resources/assets/styles/components/index.scss @@ -1,3 +1,7 @@ +/** + * Components + */ + @import 'alignment'; @import 'spacing'; @import 'site'; diff --git a/resources/views/404.blade.php b/resources/views/404.blade.php index 58e68b2189..9d4fe4ccee 100644 --- a/resources/views/404.blade.php +++ b/resources/views/404.blade.php @@ -4,9 +4,9 @@ @include('partials.page-header') @if (! have_posts()) - @alert(['type' => 'warning']) - {{ __('Sorry, but the page you were trying to view does not exist.', 'sage') }} - @endalert + + {!! __('Sorry, but the page you are trying to view does not exist.', 'sage') !!} + {!! get_search_form(false) !!} @endif diff --git a/resources/views/components/alert.blade.php b/resources/views/components/alert.blade.php index 1d6e2f41dc..c0c2a7530a 100644 --- a/resources/views/components/alert.blade.php +++ b/resources/views/components/alert.blade.php @@ -1,3 +1,3 @@ -
- {{ $slot }} +
+ {!! $message ?? $slot !!}
diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index 110647018f..4e0e065371 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -4,9 +4,9 @@ @include('partials.page-header') @if (! have_posts()) - @alert(['type' => 'warning']) - {{ __('Sorry, no results were found.', 'sage') }} - @endalert + + {!! __('Sorry, no results were found.', 'sage') !!} + {!! get_search_form(false) !!} @endif diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 3c98b9e882..ae88cdbe63 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -1,27 +1,16 @@ - - - @include('partials.head') +
+ + @php(do_action('get_header')) + @include('partials.header') + - - @php(wp_body_open()) -
- - @php(do_action('get_header')) - @include('partials.header') - - -
-
- @yield('content') -
-
- -
- @php(do_action('get_footer')) - @include('partials.footer') -
+
+
+ @yield('content')
+
- @php(wp_footer()) - - +
+ @include('partials.footer') +
+
diff --git a/resources/views/partials/comments.blade.php b/resources/views/partials/comments.blade.php index 1c44288014..27b0014aa2 100644 --- a/resources/views/partials/comments.blade.php +++ b/resources/views/partials/comments.blade.php @@ -29,9 +29,9 @@ @endif @if (! comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments')) - @alert(['type' => 'warning']) - {{ __('Comments are closed.', 'sage') }} - @endalert + + {!! __('Comments are closed.', 'sage') !!} + @endif @php(comment_form()) diff --git a/resources/views/partials/head.blade.php b/resources/views/partials/head.blade.php deleted file mode 100644 index b6adcc562e..0000000000 --- a/resources/views/partials/head.blade.php +++ /dev/null @@ -1,6 +0,0 @@ - - - - - @php(wp_head()) - diff --git a/resources/views/partials/page-header.blade.php b/resources/views/partials/page-header.blade.php index e0f7ac7e9b..1b700b06d3 100644 --- a/resources/views/partials/page-header.blade.php +++ b/resources/views/partials/page-header.blade.php @@ -1,5 +1,3 @@ diff --git a/resources/views/search.blade.php b/resources/views/search.blade.php index 20b1d3e0e2..1a50a5a455 100644 --- a/resources/views/search.blade.php +++ b/resources/views/search.blade.php @@ -4,9 +4,9 @@ @include('partials.page-header') @if (! have_posts()) - @alert(['type' => 'warning']) - {{ __('Sorry, no results were found.', 'sage') }} - @endalert + + {!! __('Sorry, no results were found.', 'sage') !!} + {!! get_search_form(false) !!} @endif diff --git a/style.css b/style.css index 53d8c3eae5..7f479bc970 100644 --- a/style.css +++ b/style.css @@ -8,4 +8,6 @@ Author URI: https://roots.io/ Text Domain: sage License: MIT License License URI: https://opensource.org/licenses/MIT +Requires PHP: 7.2.5 +Requires at least: 5.4 */ diff --git a/webpack.mix.js b/webpack.mix.js index dab2299905..ac5755be1c 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -1,7 +1,7 @@ const mix = require('laravel-mix'); - require('laravel-mix-wp-blocks'); - require('laravel-mix-purgecss'); - require('laravel-mix-copy-watched'); +require('@tinypixelco/laravel-mix-wp-blocks'); +require('laravel-mix-purgecss'); +require('laravel-mix-copy-watched'); /* |-------------------------------------------------------------------------- @@ -20,15 +20,18 @@ mix.setPublicPath('./dist') mix.sass('resources/assets/styles/app.scss', 'styles') .sass('resources/assets/styles/admin.scss', 'styles') .sass('resources/assets/styles/editor.scss', 'styles') - .purgeCss(); + .purgeCss({ + whitelist: require('purgecss-with-wordpress').whitelist, + whitelistPatterns: require('purgecss-with-wordpress').whitelistPatterns, + }); mix.js('resources/assets/scripts/app.js', 'scripts') .js('resources/assets/scripts/customizer.js', 'scripts') .blocks('resources/assets/scripts/editor.js', 'scripts') .extract(); -mix.copyWatched('resources/assets/images', 'dist/images') - .copyWatched('resources/assets/fonts', 'dist/fonts'); +mix.copyWatched('resources/assets/images/**', 'dist/images') + .copyWatched('resources/assets/fonts/**', 'dist/fonts'); mix.copy('resources/assets/scripts/polyfill.js', 'dist/scripts/polyfill.js') .copy('node_modules/jquery/dist/jquery.min.js', 'dist/scripts/jquery.js');