diff --git a/Herbert/Framework/Application.php b/Herbert/Framework/Application.php index ee7c3e1..c614587 100644 --- a/Herbert/Framework/Application.php +++ b/Herbert/Framework/Application.php @@ -149,7 +149,12 @@ public function __construct() $this->registerCoreContainerAliases(); $this->registerConfiguredProviders(); } + + public function runningInConsole() { } + public function runningUnitTests() { } + public function getCachedPackagesPath() { } + /** * Added to satisfy interface * diff --git a/Herbert/Framework/Enqueue.php b/Herbert/Framework/Enqueue.php index c0cf67a..3c35a1f 100644 --- a/Herbert/Framework/Enqueue.php +++ b/Herbert/Framework/Enqueue.php @@ -3,7 +3,8 @@ /** * @see http://getherbert.com */ -class Enqueue { +class Enqueue +{ /** * All the filters. @@ -18,7 +19,8 @@ class Enqueue { 'category', 'archive', 'search', - 'postType' + 'postType', + 'taxonomy' ]; /** @@ -45,18 +47,14 @@ public function __construct(Application $app) */ public function buildInclude($attrs, $footer) { - if (isset($attrs['filter']) && !empty($attrs['filter'])) - { + if (isset($attrs['filter']) && !empty($attrs['filter'])) { $filterBy = key($attrs['filter']); $filterWith = reset($attrs['filter']); - if (!is_array($filterWith)) - { + if (!is_array($filterWith)) { $filterWith = [$filterWith]; } - - if (!$this->filterBy($filterBy, $attrs, $filterWith)) - { + if (!$this->filterBy($filterBy, $attrs, $filterWith)) { return; } } @@ -66,16 +64,13 @@ public function buildInclude($attrs, $footer) // $attrs['src'] = ltrim($attrs['src'], '/'); // } - if (pathinfo($attrs['src'], PATHINFO_EXTENSION) === 'css') - { + if (pathinfo($attrs['src'], PATHINFO_EXTENSION) === 'css') { wp_enqueue_style($attrs['as'], $attrs['src']); - } - else - { + } else { wp_enqueue_script($attrs['as'], $attrs['src'], [], false, $footer); - if(isset($attrs['localize'])) { - wp_localize_script( $attrs['as'], $attrs['as'], $attrs['localize'] ); + if (isset($attrs['localize'])) { + wp_localize_script($attrs['as'], $attrs['as'], $attrs['localize']); } } } @@ -92,8 +87,7 @@ protected function filterBy($by, $attrs, $with) { $method = 'filter' . ucfirst($by); - if (!method_exists($this, $method)) - { + if (!method_exists($this, $method)) { return false; } @@ -108,8 +102,7 @@ protected function filterBy($by, $attrs, $with) */ public function admin($attrs, $footer = 'header') { - add_action('admin_enqueue_scripts', function ($hook) use ($attrs, $footer) - { + add_action('admin_enqueue_scripts', function ($hook) use ($attrs, $footer) { $attrs['hook'] = $hook; $this->buildInclude($attrs, $this->setFooterFlag($footer)); }); @@ -123,8 +116,7 @@ public function admin($attrs, $footer = 'header') */ public function login($attrs, $footer = 'header') { - add_action('login_enqueue_scripts', function () use ($attrs, $footer) - { + add_action('login_enqueue_scripts', function () use ($attrs, $footer) { $this->buildInclude($attrs, $this->setFooterFlag($footer)); }); } @@ -137,8 +129,7 @@ public function login($attrs, $footer = 'header') */ public function front($attrs, $footer = 'header') { - add_action('wp_enqueue_scripts', function () use ($attrs, $footer) - { + add_action('wp_enqueue_scripts', function () use ($attrs, $footer) { $this->buildInclude($attrs, $this->setFooterFlag($footer)); }); } @@ -167,8 +158,7 @@ public function filterHook($attrs, $filterWith) { $hook = $attrs['hook']; - if ($filterWith[0] === '*') - { + if ($filterWith[0] === '*') { return true; } @@ -186,22 +176,20 @@ public function filterHook($attrs, $filterWith) */ public function filterPanel($attrs, $filterWith) { + $panels = $this->app['panel']->getPanels(); $page = $this->app['http']->get('page', false); - if (!$page && function_exists('get_current_screen')) - { + if (!$page && function_exists('get_current_screen')) { $page = object_get(get_current_screen(), 'id', $page); } - foreach ($filterWith as $filter) - { + foreach ($filterWith as $filter) { $filtered = array_filter($panels, function ($panel) use ($page, $filter) { return $page === $panel['slug'] && str_is($filter, $panel['slug']); }); - if (count($filtered) > 0) - { + if (count($filtered) > 0) { return true; } } @@ -220,15 +208,12 @@ public function filterPanel($attrs, $filterWith) */ public function filterPage($attrs, $filterWith) { - if ($filterWith[0] === '*' && is_page()) - { + if ($filterWith[0] === '*' && is_page()) { return true; } - foreach ($filterWith as $filter) - { - if (is_page($filter)) - { + foreach ($filterWith as $filter) { + if (is_page($filter)) { return true; } } @@ -247,15 +232,12 @@ public function filterPage($attrs, $filterWith) */ public function filterPost($attrs, $filterWith) { - if ($filterWith[0] === '*' && is_single()) - { + if ($filterWith[0] === '*' && is_single()) { return true; } - foreach ($filterWith as $filter) - { - if (is_single($filter)) - { + foreach ($filterWith as $filter) { + if (is_single($filter)) { return true; } } @@ -274,15 +256,12 @@ public function filterPost($attrs, $filterWith) */ public function filterCategory($attrs, $filterWith) { - if ($filterWith[0] === '*' && is_category()) - { + if ($filterWith[0] === '*' && is_category()) { return true; } - foreach ($filterWith as $filter) - { - if (is_category($filter)) - { + foreach ($filterWith as $filter) { + if (is_category($filter)) { return true; } } @@ -330,4 +309,21 @@ public function filterPostType($attrs, $filterWith) return array_search(get_post_type(), $filterWith) !== FALSE; } + /** + * Filter by Taxonomy, check all values using + * + * @param $attrs + * @param $filterWith + * @return bool + */ + public function filterTaxonomy($attrs, $filterWith) + { + /* @var \Herbert\Framework\Http $http */ + $http = $this->app->get('http'); + if ($http->has('taxonomy')) { + return array_search( $http->get('taxonomy') , $filterWith) !== FALSE; + } + return false; + } + } diff --git a/Herbert/Framework/Models/Term.php b/Herbert/Framework/Models/Term.php index 8c69039..2c69f79 100644 --- a/Herbert/Framework/Models/Term.php +++ b/Herbert/Framework/Models/Term.php @@ -46,5 +46,15 @@ public function taxonomies() { return $this->hasMany(__NAMESPACE__ . '\Taxonomy', 'term_id'); } + + /** + * TermMeta relationship. + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function meta() + { + return $this->hasMany(__NAMESPACE__ . '\TermMeta', 'term_id'); + } } diff --git a/Herbert/Framework/Models/TermMeta.php b/Herbert/Framework/Models/TermMeta.php new file mode 100644 index 0000000..627aaed --- /dev/null +++ b/Herbert/Framework/Models/TermMeta.php @@ -0,0 +1,48 @@ +belongsTo(__NAMESPACE__ . '\Term', 'term_id'); + } + +} diff --git a/Herbert/Framework/Providers/TwigServiceProvider.php b/Herbert/Framework/Providers/TwigServiceProvider.php index cce2573..d15acc0 100644 --- a/Herbert/Framework/Providers/TwigServiceProvider.php +++ b/Herbert/Framework/Providers/TwigServiceProvider.php @@ -38,7 +38,7 @@ public function register() 'cache' => content_directory() . '/twig-cache', 'auto_reload' => true, 'strict_variables' => false, - 'autoescape' => true, + 'autoescape' => 'html', 'optimizations' => -1 ]; }); diff --git a/composer.json b/composer.json index 8ce4feb..ff30ed2 100644 --- a/composer.json +++ b/composer.json @@ -1,13 +1,13 @@ { - "name": "getherbert/herbert", + "name": "imajim/herbert", "description": "Herbert", "license": "MIT", "require": { - "twig/twig": "~1.16", "illuminate/database": "~5.0", "vierbergenlars/php-semver": "~3.0", "symfony/var-dumper": "~3.0", - "illuminate/http": "~5.0" + "illuminate/http": "~5.0", + "twig/twig": "2.x-dev" }, "autoload": { "psr-4": {