From 0af72b85256cee96e588719529229904666020d6 Mon Sep 17 00:00:00 2001 From: kalenjohnson Date: Sun, 27 Nov 2016 18:40:33 -0800 Subject: [PATCH 01/13] Unused use keyword --- src/setup.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/setup.php b/src/setup.php index 414c0cd..0661100 100644 --- a/src/setup.php +++ b/src/setup.php @@ -2,8 +2,6 @@ namespace App; -use Roots\Sage\Template; - /** * Theme assets */ From 0918597d4a2970b4e42d9a68bfa972dcbb444901 Mon Sep 17 00:00:00 2001 From: kalenjohnson Date: Sat, 3 Dec 2016 10:27:22 -0800 Subject: [PATCH 02/13] First pass at Blade templating --- composer.json | 3 +- composer.lock | 557 +++++++++++++++++- index.php | 2 +- src/filters.php | 66 ++- src/lib/Sage/Template/ViewServiceProvider.php | 132 +++++ templates/404.blade.php | 14 + templates/404.php | 7 - templates/index.blade.php | 19 + templates/index.php | 14 - templates/layouts/base.blade.php | 28 + templates/layouts/base.php | 32 - templates/page.blade.php | 9 + templates/page.php | 4 - templates/partials/comments.blade.php | 38 ++ templates/partials/comments.php | 36 -- templates/partials/content-page.blade.php | 2 + templates/partials/content-page.php | 2 - templates/partials/content-search.blade.php | 11 + templates/partials/content-search.php | 9 - templates/partials/content-single.blade.php | 13 + templates/partials/content-single.php | 13 - templates/partials/content.blade.php | 9 + templates/partials/content.php | 9 - templates/partials/entry-meta.blade.php | 6 + templates/partials/entry-meta.php | 2 - .../partials/{footer.php => footer.blade.php} | 2 +- .../partials/{head.php => head.blade.php} | 2 +- templates/partials/header.blade.php | 10 + templates/partials/header.php | 12 - ...{page-header.php => page-header.blade.php} | 2 +- templates/partials/sidebar.blade.php | 1 + templates/partials/sidebar.php | 1 - templates/search.blade.php | 20 + templates/search.php | 14 - templates/single.blade.php | 9 + templates/single.php | 3 - templates/template-custom.blade.php | 15 + templates/template-custom.php | 10 - 38 files changed, 957 insertions(+), 181 deletions(-) create mode 100644 src/lib/Sage/Template/ViewServiceProvider.php create mode 100644 templates/404.blade.php delete mode 100644 templates/404.php create mode 100644 templates/index.blade.php delete mode 100644 templates/index.php create mode 100644 templates/layouts/base.blade.php delete mode 100644 templates/layouts/base.php create mode 100644 templates/page.blade.php delete mode 100644 templates/page.php create mode 100644 templates/partials/comments.blade.php delete mode 100644 templates/partials/comments.php create mode 100644 templates/partials/content-page.blade.php delete mode 100644 templates/partials/content-page.php create mode 100644 templates/partials/content-search.blade.php delete mode 100644 templates/partials/content-search.php create mode 100644 templates/partials/content-single.blade.php delete mode 100644 templates/partials/content-single.php create mode 100644 templates/partials/content.blade.php delete mode 100644 templates/partials/content.php create mode 100644 templates/partials/entry-meta.blade.php delete mode 100644 templates/partials/entry-meta.php rename templates/partials/{footer.php => footer.blade.php} (60%) rename templates/partials/{head.php => head.blade.php} (89%) create mode 100644 templates/partials/header.blade.php delete mode 100644 templates/partials/header.php rename templates/partials/{page-header.php => page-header.blade.php} (51%) create mode 100644 templates/partials/sidebar.blade.php delete mode 100644 templates/partials/sidebar.php create mode 100644 templates/search.blade.php delete mode 100644 templates/search.php create mode 100644 templates/single.blade.php delete mode 100644 templates/single.php create mode 100644 templates/template-custom.blade.php delete mode 100644 templates/template-custom.php diff --git a/composer.json b/composer.json index 0caf4ed..7831d67 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ }, "require": { "php": ">=5.5.0", - "composer/installers": "~1.0" + "composer/installers": "~1.0", + "illuminate/view": "^5.3" }, "require-dev": { "squizlabs/php_codesniffer": "^2.5.1", diff --git a/composer.lock b/composer.lock index 6fae444..83fca22 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "5f4d419852a5551e2b54ef851cab83b4", - "content-hash": "1ee82adf8a4565a48214e5686e6b3293", + "hash": "255f61d85f71037ef5fc7872e31015f1", + "content-hash": "a1a2a4510be5494654cdd98e6308e48e", "packages": [ { "name": "composer/installers", @@ -104,6 +104,559 @@ "zikula" ], "time": "2016-01-27 12:54:22" + }, + { + "name": "doctrine/inflector", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "90b2128806bfde671b6952ab8bea493942c1fdae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", + "reference": "90b2128806bfde671b6952ab8bea493942c1fdae", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Inflector\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2015-11-06 14:35:42" + }, + { + "name": "illuminate/container", + "version": "v5.3.23", + "source": { + "type": "git", + "url": "https://github.com/illuminate/container.git", + "reference": "8047b47e1f731c975d9aa0fe0b269064d3f1346d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/container/zipball/8047b47e1f731c975d9aa0fe0b269064d3f1346d", + "reference": "8047b47e1f731c975d9aa0fe0b269064d3f1346d", + "shasum": "" + }, + "require": { + "illuminate/contracts": "5.3.*", + "php": ">=5.6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Container\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Container package.", + "homepage": "https://laravel.com", + "time": "2016-10-02 01:14:30" + }, + { + "name": "illuminate/contracts", + "version": "v5.3.23", + "source": { + "type": "git", + "url": "https://github.com/illuminate/contracts.git", + "reference": "ce5d73c6015b2054d32f3f8530767847b358ae4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/ce5d73c6015b2054d32f3f8530767847b358ae4e", + "reference": "ce5d73c6015b2054d32f3f8530767847b358ae4e", + "shasum": "" + }, + "require": { + "php": ">=5.6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Contracts\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Contracts package.", + "homepage": "https://laravel.com", + "time": "2016-09-26 20:36:27" + }, + { + "name": "illuminate/events", + "version": "v5.3.23", + "source": { + "type": "git", + "url": "https://github.com/illuminate/events.git", + "reference": "cb29124d4eaba8a60bad40e95e3d8b199d040d77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/events/zipball/cb29124d4eaba8a60bad40e95e3d8b199d040d77", + "reference": "cb29124d4eaba8a60bad40e95e3d8b199d040d77", + "shasum": "" + }, + "require": { + "illuminate/container": "5.3.*", + "illuminate/contracts": "5.3.*", + "illuminate/support": "5.3.*", + "php": ">=5.6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Events\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Events package.", + "homepage": "https://laravel.com", + "time": "2016-08-12 14:24:30" + }, + { + "name": "illuminate/filesystem", + "version": "v5.3.23", + "source": { + "type": "git", + "url": "https://github.com/illuminate/filesystem.git", + "reference": "82576e0a6193e76929c929c8a2d3e1552ab64e76" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/filesystem/zipball/82576e0a6193e76929c929c8a2d3e1552ab64e76", + "reference": "82576e0a6193e76929c929c8a2d3e1552ab64e76", + "shasum": "" + }, + "require": { + "illuminate/contracts": "5.3.*", + "illuminate/support": "5.3.*", + "php": ">=5.6.4", + "symfony/finder": "3.1.*" + }, + "suggest": { + "league/flysystem": "Required to use the Flysystem local and FTP drivers (~1.0).", + "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (~1.0).", + "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (~1.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Filesystem package.", + "homepage": "https://laravel.com", + "time": "2016-11-07 22:09:46" + }, + { + "name": "illuminate/support", + "version": "v5.3.23", + "source": { + "type": "git", + "url": "https://github.com/illuminate/support.git", + "reference": "050d0ed3e1c0e1d129d73b2eaa14044e46a66f77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/support/zipball/050d0ed3e1c0e1d129d73b2eaa14044e46a66f77", + "reference": "050d0ed3e1c0e1d129d73b2eaa14044e46a66f77", + "shasum": "" + }, + "require": { + "doctrine/inflector": "~1.0", + "ext-mbstring": "*", + "illuminate/contracts": "5.3.*", + "paragonie/random_compat": "~1.4|~2.0", + "php": ">=5.6.4" + }, + "replace": { + "tightenco/collect": "self.version" + }, + "suggest": { + "illuminate/filesystem": "Required to use the composer class (5.2.*).", + "symfony/process": "Required to use the composer class (3.1.*).", + "symfony/var-dumper": "Required to use the dd function (3.1.*)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + }, + "files": [ + "helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Support package.", + "homepage": "https://laravel.com", + "time": "2016-11-03 15:25:28" + }, + { + "name": "illuminate/view", + "version": "v5.3.23", + "source": { + "type": "git", + "url": "https://github.com/illuminate/view.git", + "reference": "f840676c98e3cb1224267786f35eb420de55d41c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/view/zipball/f840676c98e3cb1224267786f35eb420de55d41c", + "reference": "f840676c98e3cb1224267786f35eb420de55d41c", + "shasum": "" + }, + "require": { + "illuminate/container": "5.3.*", + "illuminate/contracts": "5.3.*", + "illuminate/events": "5.3.*", + "illuminate/filesystem": "5.3.*", + "illuminate/support": "5.3.*", + "php": ">=5.6.4", + "symfony/debug": "3.1.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.3-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\View\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate View package.", + "homepage": "https://laravel.com", + "time": "2016-10-24 18:18:15" + }, + { + "name": "paragonie/random_compat", + "version": "v2.0.4", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e", + "reference": "a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "autoload": { + "files": [ + "lib/random.php" + ] + }, + "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", + "pseudorandom", + "random" + ], + "time": "2016-11-07 23:38:38" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10 12:19:37" + }, + { + "name": "symfony/debug", + "version": "v3.1.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "c058661c32f5b462722e36d120905940089cbd9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/c058661c32f5b462722e36d120905940089cbd9a", + "reference": "c058661c32f5b462722e36d120905940089cbd9a", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2016-11-15 12:55:20" + }, + { + "name": "symfony/finder", + "version": "v3.1.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "9925935bf7144f9e4d2b976905881b4face036fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/9925935bf7144f9e4d2b976905881b4face036fb", + "reference": "9925935bf7144f9e4d2b976905881b4face036fb", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2016-11-03 08:04:31" } ], "packages-dev": [ diff --git a/index.php b/index.php index 04501c1..1ae695e 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,3 @@ classes @@ -32,11 +35,62 @@ add_filter('excerpt_more', function () { }); /** - * Use theme wrapper + * Use Blade template engine */ -add_filter('template_include', function ($main) { - if (!is_string($main) && !(is_object($main) && method_exists($main, '__toString'))) { - return $main; +foreach(['index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', 'front_page', 'page', 'paged', 'search', 'single', 'singular', 'attachment'] as $type) { + add_filter("{$type}_template_hierarchy", function($templates) { + foreach ($templates as $template) { + $templates[] = str_replace('.php', '.blade.php', $template); + } + return $templates; + }); +} +add_filter('template_include', function ($template) { + $blade_template = (!strpos($template, '.blade.php')) ? str_replace('.php', '.blade.php', $template) : $template; + $blade_template = locate_template(basename($blade_template)); + + if (!file_exists($blade_template)) { + return $template; } - return ((new Template(new Wrapper($main)))->layout()); -}, 109); + + $container = Container::getInstance(); + + $container->singleton('files', function () { + return new Filesystem; + }); + + $provider = new ViewServiceProvider($container); + $provider->register(); + + $template_engine = $container->make('view'); + + $template_name = basename(str_replace('.blade', '', $blade_template)); + $template_name = str_replace('.php', '', $template_name); + $html = $template_engine->make($template_name, apply_filters('laravel/blade/template_data', []))->render(); + + if (!$html) { + return $template; + } + + echo $html; + + return false; +}, 1000); + +add_filter('comments_template', function ($theme_template) { + $container = Container::getInstance(); + $template_engine = $container->make('view'); + + $template_name = basename(str_replace('.blade.php', '', $theme_template)); + $html = $template_engine->make('partials/'.$template_name, []); + var_dump($template_engine->exists('partials/'.$template_name)); + $engine = $html->getEngine(); + $compiler = $engine->getCompiler(); + $template = $compiler->getCompiledPath($compiler->getPath()); + + if ($compiler->isExpired($template)) { + $compiler->compile($theme_template); + } + + return $template; +}); diff --git a/src/lib/Sage/Template/ViewServiceProvider.php b/src/lib/Sage/Template/ViewServiceProvider.php new file mode 100644 index 0000000..50ecc6f --- /dev/null +++ b/src/lib/Sage/Template/ViewServiceProvider.php @@ -0,0 +1,132 @@ +registerEngineResolver(); + + $this->registerViewFinder(); + + $this->registerFactory(); + } + + /** + * Register the engine resolver instance. + * + * @return void + */ + public function registerEngineResolver() + { + $this->app->singleton('view.engine.resolver', function () { + $resolver = new EngineResolver; + + // Next we will register the various engines with the resolver so that the + // environment can resolve the engines it needs for various views based + // on the extension of view files. We call a method for each engines. + foreach (['php', 'blade'] as $engine) { + $this->{'register'.ucfirst($engine).'Engine'}($resolver); + } + + return $resolver; + }); + } + + /** + * Register the PHP engine implementation. + * + * @param \Illuminate\View\Engines\EngineResolver $resolver + * @return void + */ + public function registerPhpEngine($resolver) + { + $resolver->register('php', function () { + return new PhpEngine; + }); + } + + /** + * Register the Blade engine implementation. + * + * @param \Illuminate\View\Engines\EngineResolver $resolver + * @return void + */ + public function registerBladeEngine($resolver) + { + $app = $this->app; + + // The Compiler engine requires an instance of the CompilerInterface, which in + // this case will be the Blade compiler, so we'll first create the compiler + // instance to pass into the engine so it can compile the views properly. + $app->singleton('blade.compiler', function ($app) { + $cache = apply_filters('roots/views/blade/compiled_path', wp_upload_dir()['basedir'] . '/cache/compiled'); + if (!file_exists($cache)) { + wp_mkdir_p($cache); + } + + return new BladeCompiler($app->make('Illuminate\\Filesystem\\Filesystem'), $cache); + }); + + $resolver->register('blade', function () use ($app) { + return new CompilerEngine($app['blade.compiler']); + }); + } + + /** + * Register the view finder implementation. + * + * @return void + */ + public function registerViewFinder() + { + $this->app->bind('view.finder', function ($app) { + $paths = apply_filters('roots/views/blade/template_directories', [TEMPLATEPATH]); + + return new FileViewFinder($app['files'], $paths); + }); + } + + /** + * Register the view environment. + * + * @return void + */ + public function registerFactory() + { + $this->app->singleton('view', function ($app) { + // Next we need to grab the engine resolver instance that will be used by the + // environment. The resolver will be used by an environment to get each of + // the various engine implementations such as plain PHP or Blade engine. + $resolver = $app['view.engine.resolver']; + + $finder = $app['view.finder']; + + $env = new Factory($resolver, $finder, new Dispatcher($app)); + + // We will also set the container instance on this view environment since the + // view composers may be classes registered in the container, which allows + // for great testable, flexible composers for the application developer. + $env->setContainer($app); + + $env->share('app', $app); + + return $env; + }); + } +} diff --git a/templates/404.blade.php b/templates/404.blade.php new file mode 100644 index 0000000..a61aebd --- /dev/null +++ b/templates/404.blade.php @@ -0,0 +1,14 @@ +@extends('layouts.base') + +@section('content') + @include('partials.page-header') + + @if(!have_posts()) +
+ {{ __('Sorry, but the page you were trying to view does not exist.', 'sage') }} +
+ {!! get_search_form(false) !!} + @endif + + {!! get_the_posts_navigation() !!} +@endsection diff --git a/templates/404.php b/templates/404.php deleted file mode 100644 index 5ef0100..0000000 --- a/templates/404.php +++ /dev/null @@ -1,7 +0,0 @@ - - -
- -
- - diff --git a/templates/index.blade.php b/templates/index.blade.php new file mode 100644 index 0000000..98e220d --- /dev/null +++ b/templates/index.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.base') + +@section('content') + @include('partials.page-header') + + @if(!have_posts()) +
+ {{ __('Sorry, no results were found.', 'sage') }} +
+ {{ get_search_form(false) }} + @endif + + @while(have_posts()) + {!! the_post() !!} + @include('partials.content') + @endwhile + + {{ get_the_posts_navigation() }} +@endsection diff --git a/templates/index.php b/templates/index.php deleted file mode 100644 index bb39ccc..0000000 --- a/templates/index.php +++ /dev/null @@ -1,14 +0,0 @@ - - - -
- -
- - - - - - - - diff --git a/templates/layouts/base.blade.php b/templates/layouts/base.blade.php new file mode 100644 index 0000000..b88d998 --- /dev/null +++ b/templates/layouts/base.blade.php @@ -0,0 +1,28 @@ + + + @include('partials.head') + + + {!! do_action('get_header') !!} + @include('partials.header') +
+
+
+ @yield('content') +
+ {{--@if(App\display_sidebar())--}} + {{----}} + {{--@endif--}} +
+
+ {!! do_action('get_footer') !!} + @include('partials.footer') + {!! wp_footer() !!} + + diff --git a/templates/layouts/base.php b/templates/layouts/base.php deleted file mode 100644 index 0e37279..0000000 --- a/templates/layouts/base.php +++ /dev/null @@ -1,32 +0,0 @@ - -> - - > - - -
-
-
- main(); ?> -
- - - -
-
- - - diff --git a/templates/page.blade.php b/templates/page.blade.php new file mode 100644 index 0000000..0599920 --- /dev/null +++ b/templates/page.blade.php @@ -0,0 +1,9 @@ +@extends('layouts.base') + +@section('content') + @while(have_posts()) + {!! the_post() !!} + @include('partials.page-header') + @include('partials.content-page') + @endwhile +@endsection diff --git a/templates/page.php b/templates/page.php deleted file mode 100644 index dc2adff..0000000 --- a/templates/page.php +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/templates/partials/comments.blade.php b/templates/partials/comments.blade.php new file mode 100644 index 0000000..cb5c832 --- /dev/null +++ b/templates/partials/comments.blade.php @@ -0,0 +1,38 @@ + + +
+ @if(have_comments()) +

+ {!! sprintf(_nx('One response to “%2$s”', '%1$s responses to “%2$s”', get_comments_number(), 'comments title', 'sage'), number_format_i18n(get_comments_number()), '' . get_the_title() . '') !!} +

+ +
    + {!! wp_list_comments(['style' => 'ol', 'short_ping' => true]) !!} +
+ + @if(get_comment_pages_count() > 1 && get_option('page_comments')) + + @endif + @endif + + @if(!comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments')) +
+ {{ __('Comments are closed.', 'sage') }} +
+ @endif + + {!! comment_form() !!} +
diff --git a/templates/partials/comments.php b/templates/partials/comments.php deleted file mode 100644 index 167a4d1..0000000 --- a/templates/partials/comments.php +++ /dev/null @@ -1,36 +0,0 @@ - - -
- -

' . get_the_title() . ''); ?>

- -
    - 'ol', 'short_ping' => true]); ?> -
- - 1 && get_option('page_comments')) : ?> - - - - - -
- -
- - - -
diff --git a/templates/partials/content-page.blade.php b/templates/partials/content-page.blade.php new file mode 100644 index 0000000..5c590d0 --- /dev/null +++ b/templates/partials/content-page.blade.php @@ -0,0 +1,2 @@ +{!! the_content() !!} +{!! wp_link_pages(['before' => '']) !!} diff --git a/templates/partials/content-page.php b/templates/partials/content-page.php deleted file mode 100644 index 5f98362..0000000 --- a/templates/partials/content-page.php +++ /dev/null @@ -1,2 +0,0 @@ - - '']); ?> diff --git a/templates/partials/content-search.blade.php b/templates/partials/content-search.blade.php new file mode 100644 index 0000000..c7265ed --- /dev/null +++ b/templates/partials/content-search.blade.php @@ -0,0 +1,11 @@ +
+
+

{{ get_the_title() }}

+ @if(get_post_type() === 'post') + @include('partials/entry-meta') + @endif +
+
+ {!! the_excerpt() !!} +
+
diff --git a/templates/partials/content-search.php b/templates/partials/content-search.php deleted file mode 100644 index 2eac1e4..0000000 --- a/templates/partials/content-search.php +++ /dev/null @@ -1,9 +0,0 @@ -
> -
-

- -
-
- -
-
diff --git a/templates/partials/content-single.blade.php b/templates/partials/content-single.blade.php new file mode 100644 index 0000000..b247ff9 --- /dev/null +++ b/templates/partials/content-single.blade.php @@ -0,0 +1,13 @@ +
+
+

{{ get_the_title() }}

+ @include('partials/entry-meta') +
+
+ {!! the_content() !!} +
+
+ {!! wp_link_pages(['before' => '']) !!} +
+ {!! comments_template('/templates/partials/comments.blade.php') !!} +
diff --git a/templates/partials/content-single.php b/templates/partials/content-single.php deleted file mode 100644 index 0dda4e1..0000000 --- a/templates/partials/content-single.php +++ /dev/null @@ -1,13 +0,0 @@ -
> -
-

- -
-
- -
-
- '']); ?> -
- -
diff --git a/templates/partials/content.blade.php b/templates/partials/content.blade.php new file mode 100644 index 0000000..caad3cb --- /dev/null +++ b/templates/partials/content.blade.php @@ -0,0 +1,9 @@ + diff --git a/templates/partials/content.php b/templates/partials/content.php deleted file mode 100644 index 2246a63..0000000 --- a/templates/partials/content.php +++ /dev/null @@ -1,9 +0,0 @@ -
> -
-

- -
-
- -
-
diff --git a/templates/partials/entry-meta.blade.php b/templates/partials/entry-meta.blade.php new file mode 100644 index 0000000..301e9b7 --- /dev/null +++ b/templates/partials/entry-meta.blade.php @@ -0,0 +1,6 @@ + + diff --git a/templates/partials/entry-meta.php b/templates/partials/entry-meta.php deleted file mode 100644 index 95bd3b1..0000000 --- a/templates/partials/entry-meta.php +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/templates/partials/footer.php b/templates/partials/footer.blade.php similarity index 60% rename from templates/partials/footer.php rename to templates/partials/footer.blade.php index 050d688..72c31f7 100644 --- a/templates/partials/footer.php +++ b/templates/partials/footer.blade.php @@ -1,5 +1,5 @@
- + {{ dynamic_sidebar('sidebar-footer') }}
diff --git a/templates/partials/head.php b/templates/partials/head.blade.php similarity index 89% rename from templates/partials/head.php rename to templates/partials/head.blade.php index 9028b7d..8303e90 100644 --- a/templates/partials/head.php +++ b/templates/partials/head.blade.php @@ -2,5 +2,5 @@ - + {!! wp_head() !!} diff --git a/templates/partials/header.blade.php b/templates/partials/header.blade.php new file mode 100644 index 0000000..5f5b2c2 --- /dev/null +++ b/templates/partials/header.blade.php @@ -0,0 +1,10 @@ + diff --git a/templates/partials/header.php b/templates/partials/header.php deleted file mode 100644 index a971013..0000000 --- a/templates/partials/header.php +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/templates/partials/page-header.php b/templates/partials/page-header.blade.php similarity index 51% rename from templates/partials/page-header.php rename to templates/partials/page-header.blade.php index b488560..9e1a4c5 100644 --- a/templates/partials/page-header.php +++ b/templates/partials/page-header.blade.php @@ -1,3 +1,3 @@ diff --git a/templates/partials/sidebar.blade.php b/templates/partials/sidebar.blade.php new file mode 100644 index 0000000..471740f --- /dev/null +++ b/templates/partials/sidebar.blade.php @@ -0,0 +1 @@ +{!! dynamic_sidebar('sidebar-primary') !!} diff --git a/templates/partials/sidebar.php b/templates/partials/sidebar.php deleted file mode 100644 index 244f9b7..0000000 --- a/templates/partials/sidebar.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/templates/search.blade.php b/templates/search.blade.php new file mode 100644 index 0000000..9e1bf08 --- /dev/null +++ b/templates/search.blade.php @@ -0,0 +1,20 @@ +@extends('layouts.base') + +@section('content') + @include('partials.page-header') + + @if(!have_posts()) +
+ {{ __('Sorry, no results were found.', 'sage') }} +
+ {!! get_search_form(false) !!} + @endif + + @while(have_posts()) + {!! the_post() !!} + @include('partials.content-search') + @endwhile + + {{ get_the_posts_navigation() }} + +@endsection diff --git a/templates/search.php b/templates/search.php deleted file mode 100644 index 8786fa1..0000000 --- a/templates/search.php +++ /dev/null @@ -1,14 +0,0 @@ - - - -
- -
- - - - - - - - diff --git a/templates/single.blade.php b/templates/single.blade.php new file mode 100644 index 0000000..b818a77 --- /dev/null +++ b/templates/single.blade.php @@ -0,0 +1,9 @@ +@extends('layouts.base') + +@section('content') + @while(have_posts()) + {!! the_post() !!} + @include('partials/content-single') + @endwhile +@endsection + diff --git a/templates/single.php b/templates/single.php deleted file mode 100644 index 5e65d2e..0000000 --- a/templates/single.php +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/templates/template-custom.blade.php b/templates/template-custom.blade.php new file mode 100644 index 0000000..bc5f8da --- /dev/null +++ b/templates/template-custom.blade.php @@ -0,0 +1,15 @@ + + +@extends('layouts.base') + +@section('content') + @while(have_posts()) + {!! the_post() !!} + @include('partials.page-header') + @include('partials.content-page') + @endwhile +@endsection diff --git a/templates/template-custom.php b/templates/template-custom.php deleted file mode 100644 index d0bcd12..0000000 --- a/templates/template-custom.php +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - From c20f53dee437e3373c9726c6855adf24215270ad Mon Sep 17 00:00:00 2001 From: QWp6t Date: Sun, 4 Dec 2016 08:35:13 -0800 Subject: [PATCH 03/13] Resolve style issues --- composer.lock | 105 ++++++++++++++++++++++++++++-------------------- src/filters.php | 13 +++--- 2 files changed, 68 insertions(+), 50 deletions(-) diff --git a/composer.lock b/composer.lock index 83fca22..e628c58 100644 --- a/composer.lock +++ b/composer.lock @@ -9,16 +9,16 @@ "packages": [ { "name": "composer/installers", - "version": "v1.0.23", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/composer/installers.git", - "reference": "6213d900e92647831f7a406d5c530ea1f3d4360e" + "reference": "d78064c68299743e0161004f2de3a0204e33b804" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/6213d900e92647831f7a406d5c530ea1f3d4360e", - "reference": "6213d900e92647831f7a406d5c530ea1f3d4360e", + "url": "https://api.github.com/repos/composer/installers/zipball/d78064c68299743e0161004f2de3a0204e33b804", + "reference": "d78064c68299743e0161004f2de3a0204e33b804", "shasum": "" }, "require": { @@ -40,8 +40,8 @@ } }, "autoload": { - "psr-0": { - "Composer\\Installers\\": "src/" + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" } }, "notification-url": "https://packagist.org/downloads/", @@ -56,28 +56,35 @@ } ], "description": "A multi-framework Composer library installer", - "homepage": "http://composer.github.com/installers/", + "homepage": "https://composer.github.io/installers/", "keywords": [ "Craft", "Dolibarr", "Hurad", + "ImageCMS", "MODX Evo", + "Mautic", "OXID", + "Plentymarkets", + "RadPHP", "SMF", "Thelia", "WolfCMS", "agl", "aimeos", "annotatecms", + "attogram", "bitrix", "cakephp", "chef", + "cockpit", "codeigniter", "concrete5", "croogo", "dokuwiki", "drupal", "elgg", + "expressionengine", "fuelphp", "grav", "installer", @@ -94,16 +101,18 @@ "piwik", "ppi", "puppet", + "reindex", "roundcube", "shopware", "silverstripe", "symfony", "typo3", "wordpress", + "yawik", "zend", "zikula" ], - "time": "2016-01-27 12:54:22" + "time": "2016-08-13 20:53:52" }, { "name": "doctrine/inflector", @@ -662,16 +671,16 @@ "packages-dev": [ { "name": "pdepend/pdepend", - "version": "2.2.4", + "version": "2.3.2", "source": { "type": "git", "url": "https://github.com/pdepend/pdepend.git", - "reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06" + "reference": "8d7ab8fe8c1f9de5056bb7ea2c0852f4ddd44f90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdepend/pdepend/zipball/b086687f3a01dc6bb92d633aef071d2c5dd0db06", - "reference": "b086687f3a01dc6bb92d633aef071d2c5dd0db06", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/8d7ab8fe8c1f9de5056bb7ea2c0852f4ddd44f90", + "reference": "8d7ab8fe8c1f9de5056bb7ea2c0852f4ddd44f90", "shasum": "" }, "require": { @@ -698,25 +707,25 @@ "BSD-3-Clause" ], "description": "Official version of pdepend to be handled with Composer", - "time": "2016-03-10 15:15:04" + "time": "2016-11-23 20:25:02" }, { "name": "phpmd/phpmd", - "version": "2.4.2", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "fccbdb6b222f6d7a6d35af1c396ba5435cec76a9" + "reference": "9298602a922cd8c46666df8d540a60bc5925ce55" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/fccbdb6b222f6d7a6d35af1c396ba5435cec76a9", - "reference": "fccbdb6b222f6d7a6d35af1c396ba5435cec76a9", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/9298602a922cd8c46666df8d540a60bc5925ce55", + "reference": "9298602a922cd8c46666df8d540a60bc5925ce55", "shasum": "" }, "require": { - "pdepend/pdepend": "~2.0", - "php": ">=5.3.0" + "pdepend/pdepend": "^2.0.4", + "php": ">=5.3.9" }, "require-dev": { "phpunit/phpunit": "^4.0", @@ -763,23 +772,24 @@ "phpmd", "pmd" ], - "time": "2016-03-10 17:17:44" + "time": "2016-11-23 20:33:32" }, { "name": "squizlabs/php_codesniffer", - "version": "2.5.1", + "version": "2.7.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "6731851d6aaf1d0d6c58feff1065227b7fda3ba8" + "reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6731851d6aaf1d0d6c58feff1065227b7fda3ba8", - "reference": "6731851d6aaf1d0d6c58feff1065227b7fda3ba8", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9b324f3a1132459a7274a0ace2e1b766ba80930f", + "reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f", "shasum": "" }, "require": { + "ext-simplexml": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", "php": ">=5.1.2" @@ -840,33 +850,36 @@ "phpcs", "standards" ], - "time": "2016-01-19 23:39:10" + "time": "2016-11-30 04:02:31" }, { "name": "symfony/config", - "version": "v3.0.4", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "980ee40c28f00acff8906c11b778aab5f0db74c2" + "reference": "4a68f8953180bf77ea65f585020f4db0b18600b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/980ee40c28f00acff8906c11b778aab5f0db74c2", - "reference": "980ee40c28f00acff8906c11b778aab5f0db74c2", + "url": "https://api.github.com/repos/symfony/config/zipball/4a68f8953180bf77ea65f585020f4db0b18600b4", + "reference": "4a68f8953180bf77ea65f585020f4db0b18600b4", "shasum": "" }, "require": { "php": ">=5.5.9", "symfony/filesystem": "~2.8|~3.0" }, + "require-dev": { + "symfony/yaml": "~3.0" + }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -893,39 +906,43 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-03-04 07:55:57" + "time": "2016-11-29 11:12:32" }, { "name": "symfony/dependency-injection", - "version": "v3.0.4", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "6a9058101b591edced21ca3c83c80a3978f5c6b0" + "reference": "f5419adad083c90e0dfd8588ef83683d7dbcc20d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/6a9058101b591edced21ca3c83c80a3978f5c6b0", - "reference": "6a9058101b591edced21ca3c83c80a3978f5c6b0", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f5419adad083c90e0dfd8588ef83683d7dbcc20d", + "reference": "f5419adad083c90e0dfd8588ef83683d7dbcc20d", "shasum": "" }, "require": { "php": ">=5.5.9" }, + "conflict": { + "symfony/yaml": "<3.2" + }, "require-dev": { "symfony/config": "~2.8|~3.0", "symfony/expression-language": "~2.8|~3.0", - "symfony/yaml": "~2.8|~3.0" + "symfony/yaml": "~3.2" }, "suggest": { "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -952,20 +969,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2016-03-30 10:41:14" + "time": "2016-11-25 12:32:42" }, { "name": "symfony/filesystem", - "version": "v3.0.4", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "f82499a459dcade2ea56df94cc58b19c8bde3d20" + "reference": "8d4cf7561a5b17e5eb7a02b80d0b8f014a3796d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/f82499a459dcade2ea56df94cc58b19c8bde3d20", - "reference": "f82499a459dcade2ea56df94cc58b19c8bde3d20", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/8d4cf7561a5b17e5eb7a02b80d0b8f014a3796d4", + "reference": "8d4cf7561a5b17e5eb7a02b80d0b8f014a3796d4", "shasum": "" }, "require": { @@ -974,7 +991,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -1001,7 +1018,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-03-27 10:24:39" + "time": "2016-11-24 00:46:43" } ], "aliases": [], diff --git a/src/filters.php b/src/filters.php index 6a9b42d..757e6a4 100644 --- a/src/filters.php +++ b/src/filters.php @@ -37,12 +37,13 @@ add_filter('excerpt_more', function () { /** * Use Blade template engine */ -foreach(['index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', 'front_page', 'page', 'paged', 'search', 'single', 'singular', 'attachment'] as $type) { - add_filter("{$type}_template_hierarchy", function($templates) { - foreach ($templates as $template) { - $templates[] = str_replace('.php', '.blade.php', $template); - } - return $templates; +foreach (['index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', 'front_page', + 'page', 'paged', 'search', 'single', 'singular', 'attachment'] as $type) { + add_filter("{$type}_template_hierarchy", function ($templates) { + foreach ($templates as $template) { + $templates[] = str_replace('.php', '.blade.php', $template); + } + return $templates; }); } add_filter('template_include', function ($template) { From aef630d898d5f9f003c062250066642e94d387d7 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Sun, 4 Dec 2016 11:19:34 -0800 Subject: [PATCH 04/13] Remove wrapper and template classes --- src/lib/Sage/Template.php | 46 -------------- src/lib/Sage/Template/Partial.php | 72 ---------------------- src/lib/Sage/Template/Wrapper.php | 64 ------------------- src/lib/Sage/Template/WrapperInterface.php | 29 --------- 4 files changed, 211 deletions(-) delete mode 100644 src/lib/Sage/Template.php delete mode 100644 src/lib/Sage/Template/Partial.php delete mode 100644 src/lib/Sage/Template/Wrapper.php delete mode 100644 src/lib/Sage/Template/WrapperInterface.php diff --git a/src/lib/Sage/Template.php b/src/lib/Sage/Template.php deleted file mode 100644 index 6c0ab98..0000000 --- a/src/lib/Sage/Template.php +++ /dev/null @@ -1,46 +0,0 @@ -wrapper = $wrapper; - self::$instances[$wrapper->slug()] = $this; - } - - /** - * @return string Layout (FQPN of, e.g., `base-page.php`, `base.php`) - */ - public function layout() - { - return $this->wrapper->wrap(); - } - - /** - * @return string Main template (FQPN of, e.g., `page.php`, `single.php`, `singular.php`) - */ - public function main() - { - return $this->wrapper->unwrap(); - } - - /** - * @param string $template Delimited template path - * @return string Partial template (FQPN of, e.g., `content.php`, `page-header.php` - */ - public function partial($template) - { - return (new Partial($template, $this->main()))->path(); - } -} diff --git a/src/lib/Sage/Template/Partial.php b/src/lib/Sage/Template/Partial.php deleted file mode 100644 index daa8dc4..0000000 --- a/src/lib/Sage/Template/Partial.php +++ /dev/null @@ -1,72 +0,0 @@ -template = $template; - $this->main = $main; - } - - public function __toString() - { - return (string) $this->path(); - } - - /** - * Converts template into array of parts to be passed to locate_template() - * - * Here's an example of what happens: - * (new Template('partials/content-single-audio'))->parts(); - * // => ['partials/content-single-audio.php', 'partials/content-single.php', 'partials/content.php'] - * @return array Array of parts to pass to locate_template() - */ - public function parts() - { - if ($parts = $this->cache('parts')) { - return $parts; - } - $parts = explode($this->delimiter, str_replace('.php', '', $this->template)); - $templates[] = array_shift($parts); - foreach ($parts as $i => $part) { - $templates[] = $templates[$i] . $this->delimiter . $part; - } - if ($this->main) { - $templates = array_merge($templates, array_map(function ($template) { - return $template . $this->delimiter . basename($this->main, '.php'); - }, $templates)); - } - $templates = array_map(function ($template) { - return $template . '.php'; - }, $templates); - return $this->cache('parts', array_reverse($templates)); - } - - /** - * Passes $this->parts() to locate_template() to retrieve template location - * @return string Location of template - */ - public function path() - { - if (!$path = $this->cache('path')) { - $path = $this->cache('path', locate_template($this->parts())); - } - return apply_filters('sage/partial_' . basename($path, '.php'), $path, $this->parts()) ?: $path; - } - - protected function cache($key, $value = null) - { - if ($value !== null) { - self::$cache[$this->template][$key] = $value; - } - return isset(self::$cache[$this->template][$key]) ? self::$cache[$this->template][$key] : null; - } -} diff --git a/src/lib/Sage/Template/Wrapper.php b/src/lib/Sage/Template/Wrapper.php deleted file mode 100644 index b751d65..0000000 --- a/src/lib/Sage/Template/Wrapper.php +++ /dev/null @@ -1,64 +0,0 @@ -slug = sanitize_title(basename($base, '.php')); - $this->wrapper = [$base]; - $this->template = $template; - $str = substr($base, 0, -4); - array_unshift($this->wrapper, sprintf($str . '-%s.php', basename($template, '.php'))); - } - - /** - * @return string - * @see getTemplate - */ - public function __toString() - { - return $this->unwrap(); - } - - /** {@inheritdoc} */ - public function wrap() - { - $wrappers = apply_filters('sage/wrap_' . $this->slug, $this->wrapper) ?: $this->wrapper; - return locate_template($wrappers); - } - - /** {@inheritdoc} */ - public function slug() - { - return $this->slug; - } - - /** {@inheritdoc} */ - public function unwrap() - { - $template = apply_filters('sage/unwrap_' . $this->slug, $this->template) ?: $this->template; - return locate_template($template) ?: $template; - } -} diff --git a/src/lib/Sage/Template/WrapperInterface.php b/src/lib/Sage/Template/WrapperInterface.php deleted file mode 100644 index dcb9eb3..0000000 --- a/src/lib/Sage/Template/WrapperInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - Date: Sun, 4 Dec 2016 11:20:10 -0800 Subject: [PATCH 05/13] Require PHP >= 5.6.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7831d67..a38b260 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ } }, "require": { - "php": ">=5.5.0", + "php": ">=5.6.4", "composer/installers": "~1.0", "illuminate/view": "^5.3" }, From f23477386de7b0293653efb8b478b04392c1313e Mon Sep 17 00:00:00 2001 From: QWp6t Date: Sun, 4 Dec 2016 11:21:45 -0800 Subject: [PATCH 06/13] Use array_map() for blade hierarchy loop --- src/filters.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/filters.php b/src/filters.php index 757e6a4..1199622 100644 --- a/src/filters.php +++ b/src/filters.php @@ -2,8 +2,6 @@ namespace App; -use Roots\Sage\Template; -use Roots\Sage\Template\Wrapper; use Illuminate\Container\Container; use Illuminate\Filesystem\Filesystem; use Roots\Sage\Template\ViewServiceProvider; @@ -37,15 +35,14 @@ add_filter('excerpt_more', function () { /** * Use Blade template engine */ -foreach (['index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', 'front_page', - 'page', 'paged', 'search', 'single', 'singular', 'attachment'] as $type) { - add_filter("{$type}_template_hierarchy", function ($templates) { - foreach ($templates as $template) { - $templates[] = str_replace('.php', '.blade.php', $template); - } - return $templates; +array_map(function ($tag) { + add_filter("{$tag}_template_hierarchy", function($templates) { + return array_merge(str_replace('.php', '.blade.php', $templates), $templates); }); -} +}, [ + 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', + 'front_page', 'page', 'paged', 'search', 'single', 'singular', 'attachment' +]); add_filter('template_include', function ($template) { $blade_template = (!strpos($template, '.blade.php')) ? str_replace('.php', '.blade.php', $template) : $template; $blade_template = locate_template(basename($blade_template)); From c69431efa5de3c7231eeccca1a184532fc5b6ffd Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sun, 4 Dec 2016 20:19:01 -0700 Subject: [PATCH 07/13] Remove PHP 5.5 testing from Travis --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4bc8d16..1688acf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: php php: - 7.0 - 5.6 - - 5.5 - nightly env: @@ -33,7 +32,7 @@ before_install: - composer self-update install: - - source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION && nvm use $TRAVIS_NODE_VERSION + - source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION && nvm use $TRAVIS_NODE_VERSION - travis_retry npm install -g npm@latest - travis_retry npm install -g eslint - node -v && npm -v From 0d83ed4b8bf4b099a250b4ef02bdaf78d5a595e3 Mon Sep 17 00:00:00 2001 From: QWp6t Date: Tue, 6 Dec 2016 03:28:41 -0800 Subject: [PATCH 08/13] Refactor Blade implementation. Use Container --- CHANGELOG.md | 1 + composer.json | 3 +- composer.lock | 58 +++++++- index.php | 2 +- src/filters.php | 64 ++------- src/helpers.php | 52 ++++--- src/lib/Sage/Asset.php | 39 ------ src/lib/Sage/Assets/JsonManifest.php | 18 ++- src/lib/Sage/Assets/ManifestInterface.php | 15 +- src/lib/Sage/Container.php | 10 ++ src/lib/Sage/Template/BladeProvider.php | 80 +++++++++++ src/lib/Sage/Template/ViewServiceProvider.php | 132 ------------------ src/setup.php | 31 ++++ templates/partials/page-header.blade.php | 2 +- 14 files changed, 250 insertions(+), 257 deletions(-) delete mode 100644 src/lib/Sage/Asset.php create mode 100644 src/lib/Sage/Container.php create mode 100644 src/lib/Sage/Template/BladeProvider.php delete mode 100644 src/lib/Sage/Template/ViewServiceProvider.php diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2fc51..845ca2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### HEAD +* Add Blade ([#1765](https://github.com/roots/sage/pull/1765)) * Remove sidebar defaults ([#1760](https://github.com/roots/sage/pull/1760)) * Remove post formats ([#1759](https://github.com/roots/sage/pull/1759)) diff --git a/composer.json b/composer.json index a38b260..7de0f37 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,8 @@ "require": { "php": ">=5.6.4", "composer/installers": "~1.0", - "illuminate/view": "^5.3" + "illuminate/view": "^5.3", + "jenssegers/blade": "dev-master#59ba2cc" }, "require-dev": { "squizlabs/php_codesniffer": "^2.5.1", diff --git a/composer.lock b/composer.lock index e628c58..52b86a2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "255f61d85f71037ef5fc7872e31015f1", - "content-hash": "a1a2a4510be5494654cdd98e6308e48e", + "hash": "91797de2d3afdfa1a932e8c0dfe808fe", + "content-hash": "b772c090cb59fb89a2df691ecd1ffe98", "packages": [ { "name": "composer/installers", @@ -466,6 +466,54 @@ "homepage": "https://laravel.com", "time": "2016-10-24 18:18:15" }, + { + "name": "jenssegers/blade", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/jenssegers/blade.git", + "reference": "59ba2cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jenssegers/blade/zipball/59ba2cc", + "reference": "59ba2cc", + "shasum": "" + }, + "require": { + "illuminate/view": "^5.1" + }, + "require-dev": { + "mockery/mockery": "^0.9", + "phpunit/phpunit": "^4.0|^5.0", + "satooshi/php-coveralls": "^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Jenssegers\\Blade\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jens Segers", + "homepage": "https://jenssegers.com" + } + ], + "description": "The standalone version of Laravel's Blade templating engine for use outside of Laravel.", + "keywords": [ + "blade", + "laravel", + "render", + "template", + "view" + ], + "time": "2016-08-23 11:51:53" + }, { "name": "paragonie/random_compat", "version": "v2.0.4", @@ -1023,11 +1071,13 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "jenssegers/blade": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.5.0" + "php": ">=5.6.4" }, "platform-dev": [] } diff --git a/index.php b/index.php index 1ae695e..d8704e2 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,3 @@ classes */ @@ -33,62 +29,28 @@ add_filter('excerpt_more', function () { }); /** - * Use Blade template engine + * Template Hierarchy should search for .blade.php files */ array_map(function ($tag) { - add_filter("{$tag}_template_hierarchy", function($templates) { + add_filter("{$tag}_template_hierarchy", function ($templates) { return array_merge(str_replace('.php', '.blade.php', $templates), $templates); }); }, [ 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', 'front_page', 'page', 'paged', 'search', 'single', 'singular', 'attachment' ]); + +/** + * Render page using Blade + */ add_filter('template_include', function ($template) { - $blade_template = (!strpos($template, '.blade.php')) ? str_replace('.php', '.blade.php', $template) : $template; - $blade_template = locate_template(basename($blade_template)); + echo template($template); - if (!file_exists($blade_template)) { - return $template; - } - - $container = Container::getInstance(); - - $container->singleton('files', function () { - return new Filesystem; - }); - - $provider = new ViewServiceProvider($container); - $provider->register(); - - $template_engine = $container->make('view'); - - $template_name = basename(str_replace('.blade', '', $blade_template)); - $template_name = str_replace('.php', '', $template_name); - $html = $template_engine->make($template_name, apply_filters('laravel/blade/template_data', []))->render(); - - if (!$html) { - return $template; - } - - echo $html; - - return false; + // Return a blank file to make WordPress happy + return get_template_directory() . '/index.php'; }, 1000); -add_filter('comments_template', function ($theme_template) { - $container = Container::getInstance(); - $template_engine = $container->make('view'); - - $template_name = basename(str_replace('.blade.php', '', $theme_template)); - $html = $template_engine->make('partials/'.$template_name, []); - var_dump($template_engine->exists('partials/'.$template_name)); - $engine = $html->getEngine(); - $compiler = $engine->getCompiler(); - $template = $compiler->getCompiledPath($compiler->getPath()); - - if ($compiler->isExpired($template)) { - $compiler->compile($theme_template); - } - - return $template; -}); +/** + * Tell WordPress how to find the compiled path of comments.blade.php + */ +add_filter('comments_template', 'App\\template_path'); diff --git a/src/helpers.php b/src/helpers.php index db3c2c3..304d786 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -2,30 +2,50 @@ namespace App; -use Roots\Sage\Asset; -use Roots\Sage\Assets\JsonManifest; -use Roots\Sage\Template; +use Roots\Sage\Container; -function template($layout = 'base') +/** + * @param string $name + * @return Container|mixed + */ +function sage($name = '') { - return Template::$instances[$layout]; -} - -function template_part($template, array $context = [], $layout = 'base') -{ - extract($context); - include template($layout)->partial($template); + static $container; + if (!$container) { + $container = new Container; + } + return $name ? (isset($container[$name]) ? $container[$name] : $container["sage.{$name}"]) : $container; } /** - * @param $filename + * + * @param string $file + * @param array $data * @return string */ -function asset_path($filename) +function template($file, $data = []) { - static $manifest; - isset($manifest) || $manifest = new JsonManifest(get_stylesheet_directory() . '/' . Asset::$dist . '/assets.json'); - return (string) new Asset($filename, $manifest); + return sage('blade')->render($file, $data); +} + +/** + * Retrieve path to a compiled blade view + * @param $file + * @param array $data + * @return string + */ +function template_path($file, $data = []) +{ + return sage('blade')->compiledPath($file, $data); +} + +/** + * @param $asset + * @return string + */ +function asset_path($asset) +{ + return sage('assets')->getUri($asset); } /** diff --git a/src/lib/Sage/Asset.php b/src/lib/Sage/Asset.php deleted file mode 100644 index aeee9cc..0000000 --- a/src/lib/Sage/Asset.php +++ /dev/null @@ -1,39 +0,0 @@ -manifest = $manifest; - $this->asset = $file; - } - - public function __toString() - { - return $this->getUri(); - } - - public function getUri() - { - $file = ($this->manifest ? $this->manifest->get($this->asset) : $this->asset); - return get_template_directory_uri() . self::$dist . "/$file"; - } -} diff --git a/src/lib/Sage/Assets/JsonManifest.php b/src/lib/Sage/Assets/JsonManifest.php index a7835fa..37e5839 100644 --- a/src/lib/Sage/Assets/JsonManifest.php +++ b/src/lib/Sage/Assets/JsonManifest.php @@ -10,26 +10,32 @@ namespace Roots\Sage\Assets; class JsonManifest implements ManifestInterface { /** @var array */ - protected $manifest = []; + public $manifest; + + /** @var string */ + public $dist; /** * JsonManifest constructor + * * @param string $manifestPath Local filesystem path to JSON-encoded manifest + * @param string $distUri Remote URI to assets root */ - public function __construct($manifestPath) + public function __construct($manifestPath, $distUri) { $this->manifest = file_exists($manifestPath) ? json_decode(file_get_contents($manifestPath), true) : []; + $this->dist = $distUri; } /** @inheritdoc */ - public function get($file) + public function get($asset) { - return isset($this->manifest[$file]) ? $this->manifest[$file] : $file; + return isset($this->manifest[$asset]) ? $this->manifest[$asset] : $asset; } /** @inheritdoc */ - public function getAll() + public function getUri($asset) { - return $this->manifest; + return "{$this->dist}/{$this->get($asset)}"; } } diff --git a/src/lib/Sage/Assets/ManifestInterface.php b/src/lib/Sage/Assets/ManifestInterface.php index e2583af..a1542ee 100644 --- a/src/lib/Sage/Assets/ManifestInterface.php +++ b/src/lib/Sage/Assets/ManifestInterface.php @@ -12,17 +12,20 @@ interface ManifestInterface /** * Get the cache-busted filename * - * If the manifest does not have an entry for $file, then return $file + * If the manifest does not have an entry for $asset, then return $asset * - * @param string $file The original name of the file before cache-busting + * @param string $asset The original name of the file before cache-busting * @return string */ - public function get($file); + public function get($asset); /** - * Get the asset manifest + * Get the cache-busted URI * - * @return array + * If the manifest does not have an entry for $asset, then return URI for $asset + * + * @param string $asset The original name of the file before cache-busting + * @return string */ - public function getAll(); + public function getUri($asset); } diff --git a/src/lib/Sage/Container.php b/src/lib/Sage/Container.php new file mode 100644 index 0000000..c015e24 --- /dev/null +++ b/src/lib/Sage/Container.php @@ -0,0 +1,10 @@ +container['view']->make($this->normalizeViewPath($view), $data, $mergeData); + } + + /** + * @param string $view + * @param array $data + * @param array $mergeData + * @return string + */ + public function render($view, $data = [], $mergeData = []) + { + return $this->make($view, $data, $mergeData)->render(); + } + + /** + * @param string $file + * @param array $data + * @param array $mergeData + * @return string + */ + public function compiledPath($file, $data = [], $mergeData = []) + { + $rendered = $this->make($file, $data, $mergeData); + $engine = $rendered->getEngine(); + + if (!($engine instanceof CompilerEngine)) { + // Using PhpEngine, so just return the file + return $file; + } + + $compiler = $engine->getCompiler(); + $compiledPath = $compiler->getCompiledPath($rendered->getPath()); + if ($compiler->isExpired($compiledPath)) { + $compiler->compile($file); + } + return $compiledPath; + } + + /** + * @param string $file + * @return string + */ + public function normalizeViewPath($file) + { + // Convert `\` to `/` + $view = str_replace('\\', '/', $file); + + // Remove unnecessary parts of the path + $view = str_replace(array_merge((array) $this->viewPaths, ['.blade.php', '.php']), '', $view); + + // Remove leading slashes + $view = ltrim($view, '/'); + + // Convert `/` to `.` + return str_replace('/', '.', $view); + } +} diff --git a/src/lib/Sage/Template/ViewServiceProvider.php b/src/lib/Sage/Template/ViewServiceProvider.php deleted file mode 100644 index 50ecc6f..0000000 --- a/src/lib/Sage/Template/ViewServiceProvider.php +++ /dev/null @@ -1,132 +0,0 @@ -registerEngineResolver(); - - $this->registerViewFinder(); - - $this->registerFactory(); - } - - /** - * Register the engine resolver instance. - * - * @return void - */ - public function registerEngineResolver() - { - $this->app->singleton('view.engine.resolver', function () { - $resolver = new EngineResolver; - - // Next we will register the various engines with the resolver so that the - // environment can resolve the engines it needs for various views based - // on the extension of view files. We call a method for each engines. - foreach (['php', 'blade'] as $engine) { - $this->{'register'.ucfirst($engine).'Engine'}($resolver); - } - - return $resolver; - }); - } - - /** - * Register the PHP engine implementation. - * - * @param \Illuminate\View\Engines\EngineResolver $resolver - * @return void - */ - public function registerPhpEngine($resolver) - { - $resolver->register('php', function () { - return new PhpEngine; - }); - } - - /** - * Register the Blade engine implementation. - * - * @param \Illuminate\View\Engines\EngineResolver $resolver - * @return void - */ - public function registerBladeEngine($resolver) - { - $app = $this->app; - - // The Compiler engine requires an instance of the CompilerInterface, which in - // this case will be the Blade compiler, so we'll first create the compiler - // instance to pass into the engine so it can compile the views properly. - $app->singleton('blade.compiler', function ($app) { - $cache = apply_filters('roots/views/blade/compiled_path', wp_upload_dir()['basedir'] . '/cache/compiled'); - if (!file_exists($cache)) { - wp_mkdir_p($cache); - } - - return new BladeCompiler($app->make('Illuminate\\Filesystem\\Filesystem'), $cache); - }); - - $resolver->register('blade', function () use ($app) { - return new CompilerEngine($app['blade.compiler']); - }); - } - - /** - * Register the view finder implementation. - * - * @return void - */ - public function registerViewFinder() - { - $this->app->bind('view.finder', function ($app) { - $paths = apply_filters('roots/views/blade/template_directories', [TEMPLATEPATH]); - - return new FileViewFinder($app['files'], $paths); - }); - } - - /** - * Register the view environment. - * - * @return void - */ - public function registerFactory() - { - $this->app->singleton('view', function ($app) { - // Next we need to grab the engine resolver instance that will be used by the - // environment. The resolver will be used by an environment to get each of - // the various engine implementations such as plain PHP or Blade engine. - $resolver = $app['view.engine.resolver']; - - $finder = $app['view.finder']; - - $env = new Factory($resolver, $finder, new Dispatcher($app)); - - // We will also set the container instance on this view environment since the - // view composers may be classes registered in the container, which allows - // for great testable, flexible composers for the application developer. - $env->setContainer($app); - - $env->share('app', $app); - - return $env; - }); - } -} diff --git a/src/setup.php b/src/setup.php index 0661100..2b3b9ee 100644 --- a/src/setup.php +++ b/src/setup.php @@ -2,6 +2,37 @@ namespace App; +use Roots\Sage\Assets\JsonManifest; +use Roots\Sage\Template\BladeProvider; + +/** + * Add JsonManifest to Sage container + */ +sage()->singleton('sage.assets', function () { + return new JsonManifest( + get_stylesheet_directory().'/dist/assets.json', + get_stylesheet_directory_uri().'/dist' + ); +}); + +/** + * Add Blade to Sage container + */ +sage()->singleton('sage.blade', function () { + $cachePath = wp_upload_dir()['basedir'].'/cache/compiled'; + if (!file_exists($cachePath)) { + wp_mkdir_p($cachePath); + } + return new BladeProvider(TEMPLATEPATH, $cachePath, sage()); +}); + +/** + * Create @asset() Blade directive + */ +sage('blade')->compiler()->directive('asset', function ($asset) { + return ''; +}); + /** * Theme assets */ diff --git a/templates/partials/page-header.blade.php b/templates/partials/page-header.blade.php index 9e1a4c5..e60521f 100644 --- a/templates/partials/page-header.blade.php +++ b/templates/partials/page-header.blade.php @@ -1,3 +1,3 @@ From ca9af502df00af90f579e26f1e1e93dd913c31c0 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Tue, 6 Dec 2016 15:06:22 -0700 Subject: [PATCH 09/13] Update README.md --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3702de0..c5e32ce 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Sage is a WordPress starter theme with a modern development workflow. * [Webpack](https://webpack.github.io/) for compiling assets, optimizing images, and concatenating and minifying files * [BrowserSync](http://www.browsersync.io/) for synchronized browser testing * [Bootstrap 4](http://getbootstrap.com/) for a front-end framework (can be removed or replaced) -* Template inheritance with the [theme wrapper](https://roots.io/sage/docs/theme-wrapper/) +* [Laravel Blade](https://laravel.com/docs/5.3/blade) as a templating engine See a working example at [roots-example-project.com](https://roots-example-project.com/). @@ -22,16 +22,16 @@ See a working example at [roots-example-project.com](https://roots-example-proje Make sure all dependencies have been installed before moving on: -* [PHP](http://php.net/manual/en/install.php) >= 5.5.x +* [PHP](http://php.net/manual/en/install.php) >= 5.6.4 * [Composer](https://getcomposer.org/download/) -* [Node.js](http://nodejs.org/) >= 4.5 +* [Node.js](http://nodejs.org/) >= 6.9.x ## Theme installation Install Sage using Composer from your WordPress themes directory (replace `your-theme-name` below with the name of your theme): ```shell -# @ example.com/site/web/app/themes/ +# @ app/themes/ or wp-content/themes/ $ composer create-project roots/sage your-theme-name dev-master ``` @@ -55,7 +55,7 @@ themes/your-theme-name/ # → Root of your Sage based theme ├── package.json # → Node.js dependencies and scripts ├── screenshot.png # → Theme screenshot for WP admin ├── src/ # → Theme PHP -│   ├── lib/Sage/ # → Theme wrapper, asset manifest +│   ├── lib/Sage/ # → Blade implementation, asset manifest │   ├── admin.php # → Theme customizer setup │   ├── filters.php # → Theme filters │   ├── helpers.php # → Helper functions @@ -98,9 +98,9 @@ You now have all the necessary dependencies to run the build process. * `npm run lint` — Run eslint against your assets and build scripts * `composer test` — Check your PHP for code smells with `phpmd` and PSR-2 compliance with `phpcs` -### Using BrowserSync +### Using Browsersync -To use BrowserSync during `npm start` you need to update `devUrl` at the bottom of `assets/config.json` to reflect your local development hostname. +To use Browsersync during `npm start` you need to update `devUrl` at the bottom of `assets/config.json` to reflect your local development hostname. If your local development URL is `https://project-name.dev`, update the file to read: ```json @@ -117,9 +117,9 @@ If you are not using [Bedrock](https://roots.io/bedrock/), update `publicPath` t ... ``` -By default, BrowserSync will use webpack's [HMR](https://webpack.github.io/docs/hot-module-replacement.html), which won't trigger a page reload in your browser. +By default, Browsersync will use webpack's [HMR](https://webpack.github.io/docs/hot-module-replacement.html), which won't trigger a page reload in your browser. -If you would like to force BrowserSync to reload the page whenever certain file types are edited, then add them to `watch` in `assets/config.json`. +If you would like to force Browsersync to reload the page whenever certain file types are edited, then add them to `watch` in `assets/config.json`. ```json ... From ff410b1c1ead99ce79cafa2efe0b514a62f8e0c7 Mon Sep 17 00:00:00 2001 From: Ben Word Date: Tue, 6 Dec 2016 15:39:58 -0700 Subject: [PATCH 10/13] Uncomment sidebar, fix include --- templates/layouts/base.blade.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/layouts/base.blade.php b/templates/layouts/base.blade.php index b88d998..091f336 100644 --- a/templates/layouts/base.blade.php +++ b/templates/layouts/base.blade.php @@ -14,11 +14,11 @@
@yield('content')
- {{--@if(App\display_sidebar())--}} - {{----}} - {{--@endif--}} + @if(App\display_sidebar()) + + @endif {!! do_action('get_footer') !!} From 5c12f0ff8eca3caf6c211eaaacd8b76939883e2a Mon Sep 17 00:00:00 2001 From: Ben Word Date: Tue, 6 Dec 2016 15:45:19 -0700 Subject: [PATCH 11/13] :eyes: --- templates/layouts/base.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/layouts/base.blade.php b/templates/layouts/base.blade.php index 091f336..290e63d 100644 --- a/templates/layouts/base.blade.php +++ b/templates/layouts/base.blade.php @@ -16,7 +16,7 @@ @if(App\display_sidebar()) @endif From b7742fd86ff56ad6364586268bcb11077aa02c6a Mon Sep 17 00:00:00 2001 From: Kalen Johnson Date: Tue, 6 Dec 2016 15:07:37 -0800 Subject: [PATCH 12/13] Fix sidebar echoing a 1 --- templates/partials/footer.blade.php | 2 +- templates/partials/sidebar.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/partials/footer.blade.php b/templates/partials/footer.blade.php index 72c31f7..da9feba 100644 --- a/templates/partials/footer.blade.php +++ b/templates/partials/footer.blade.php @@ -1,5 +1,5 @@
- {{ dynamic_sidebar('sidebar-footer') }} + @php dynamic_sidebar('sidebar-footer') @endphp
diff --git a/templates/partials/sidebar.blade.php b/templates/partials/sidebar.blade.php index 471740f..a740998 100644 --- a/templates/partials/sidebar.blade.php +++ b/templates/partials/sidebar.blade.php @@ -1 +1 @@ -{!! dynamic_sidebar('sidebar-primary') !!} +@php dynamic_sidebar('sidebar-primary') @endphp From 3dadb86ec2c89fa4c7e9c224a0eceeb1657b44f1 Mon Sep 17 00:00:00 2001 From: Kalen Johnson Date: Tue, 6 Dec 2016 15:24:15 -0800 Subject: [PATCH 13/13] Fixing double echo's, template cleanup --- templates/404.blade.php | 4 ++-- templates/index.blade.php | 13 ++++++------- templates/layouts/base.blade.php | 14 +++++++------- templates/page.blade.php | 3 +-- templates/partials/comments.blade.php | 16 ++++++++-------- templates/partials/content-page.blade.php | 2 +- templates/partials/content-search.blade.php | 6 +++--- templates/partials/content-single.blade.php | 6 +++--- templates/partials/content.blade.php | 4 ++-- templates/partials/head.blade.php | 2 +- templates/partials/header.blade.php | 4 ++-- templates/search.blade.php | 8 +++----- templates/single.blade.php | 3 +-- templates/template-custom.blade.php | 7 +++---- 14 files changed, 43 insertions(+), 49 deletions(-) diff --git a/templates/404.blade.php b/templates/404.blade.php index a61aebd..384c394 100644 --- a/templates/404.blade.php +++ b/templates/404.blade.php @@ -3,9 +3,9 @@ @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') }} + {{ __('Sorry, but the page you were trying to view does not exist.', 'sage') }}
{!! get_search_form(false) !!} @endif diff --git a/templates/index.blade.php b/templates/index.blade.php index 98e220d..cc334fb 100644 --- a/templates/index.blade.php +++ b/templates/index.blade.php @@ -3,17 +3,16 @@ @section('content') @include('partials.page-header') - @if(!have_posts()) + @if (!have_posts())
- {{ __('Sorry, no results were found.', 'sage') }} + {{ __('Sorry, no results were found.', 'sage') }}
- {{ get_search_form(false) }} + {!! get_search_form(false) !!} @endif - @while(have_posts()) - {!! the_post() !!} - @include('partials.content') + @while (have_posts()) @php the_post() @endphp + @include ('partials.content') @endwhile - {{ get_the_posts_navigation() }} + {!! get_the_posts_navigation() !!} @endsection diff --git a/templates/layouts/base.blade.php b/templates/layouts/base.blade.php index 290e63d..dbde60f 100644 --- a/templates/layouts/base.blade.php +++ b/templates/layouts/base.blade.php @@ -1,28 +1,28 @@ - + @include('partials.head') - + - {!! do_action('get_header') !!} + @php do_action('get_header') @endphp @include('partials.header')
@yield('content')
- @if(App\display_sidebar()) + @if (App\display_sidebar()) @endif
- {!! do_action('get_footer') !!} + @php do_action('get_footer') @endphp @include('partials.footer') - {!! wp_footer() !!} + @php wp_footer() @endphp diff --git a/templates/page.blade.php b/templates/page.blade.php index 0599920..8ab09bc 100644 --- a/templates/page.blade.php +++ b/templates/page.blade.php @@ -1,8 +1,7 @@ @extends('layouts.base') @section('content') - @while(have_posts()) - {!! the_post() !!} + @while(have_posts()) @php the_post() @endphp @include('partials.page-header') @include('partials.content-page') @endwhile diff --git a/templates/partials/comments.blade.php b/templates/partials/comments.blade.php index cb5c832..a8c4d2e 100644 --- a/templates/partials/comments.blade.php +++ b/templates/partials/comments.blade.php @@ -1,11 +1,11 @@ - +@endphp
- @if(have_comments()) + @if (have_comments())

{!! sprintf(_nx('One response to “%2$s”', '%1$s responses to “%2$s”', get_comments_number(), 'comments title', 'sage'), number_format_i18n(get_comments_number()), '' . get_the_title() . '') !!}

@@ -14,13 +14,13 @@ if (post_password_required()) { {!! wp_list_comments(['style' => 'ol', 'short_ping' => true]) !!} - @if(get_comment_pages_count() > 1 && get_option('page_comments')) + @if (get_comment_pages_count() > 1 && get_option('page_comments'))
diff --git a/templates/partials/content-page.blade.php b/templates/partials/content-page.blade.php index 5c590d0..14fb20c 100644 --- a/templates/partials/content-page.blade.php +++ b/templates/partials/content-page.blade.php @@ -1,2 +1,2 @@ -{!! the_content() !!} +@php the_content() @endphp {!! wp_link_pages(['before' => '']) !!} diff --git a/templates/partials/content-search.blade.php b/templates/partials/content-search.blade.php index c7265ed..d1a0dd3 100644 --- a/templates/partials/content-search.blade.php +++ b/templates/partials/content-search.blade.php @@ -1,11 +1,11 @@ -
+

{{ get_the_title() }}

- @if(get_post_type() === 'post') + @if (get_post_type() === 'post') @include('partials/entry-meta') @endif
- {!! the_excerpt() !!} + @php the_excerpt() @endphp
diff --git a/templates/partials/content-single.blade.php b/templates/partials/content-single.blade.php index b247ff9..f251483 100644 --- a/templates/partials/content-single.blade.php +++ b/templates/partials/content-single.blade.php @@ -1,13 +1,13 @@ -
+

{{ get_the_title() }}

@include('partials/entry-meta')
- {!! the_content() !!} + @php the_content() @endphp
{!! wp_link_pages(['before' => '']) !!}
- {!! comments_template('/templates/partials/comments.blade.php') !!} + @php comments_template('/templates/partials/comments.blade.php') @endphp
diff --git a/templates/partials/content.blade.php b/templates/partials/content.blade.php index caad3cb..5035e81 100644 --- a/templates/partials/content.blade.php +++ b/templates/partials/content.blade.php @@ -1,9 +1,9 @@ -
+

{{ get_the_title() }}

@include('partials/entry-meta')
- {!! the_excerpt() !!} + @php the_excerpt() @endphp
diff --git a/templates/partials/head.blade.php b/templates/partials/head.blade.php index 8303e90..4f0e833 100644 --- a/templates/partials/head.blade.php +++ b/templates/partials/head.blade.php @@ -2,5 +2,5 @@ - {!! wp_head() !!} + @php wp_head() @endphp diff --git a/templates/partials/header.blade.php b/templates/partials/header.blade.php index 5f5b2c2..4af67fc 100644 --- a/templates/partials/header.blade.php +++ b/templates/partials/header.blade.php @@ -1,8 +1,8 @@