Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Herbert/Framework/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ public function __construct()
$this->registerCoreContainerAliases();
$this->registerConfiguredProviders();
}

public function runningInConsole() { }
public function runningUnitTests() { }

public function getCachedPackagesPath() { }

/**
* Added to satisfy interface
*
Expand Down
96 changes: 46 additions & 50 deletions Herbert/Framework/Enqueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/**
* @see http://getherbert.com
*/
class Enqueue {
class Enqueue
{

/**
* All the filters.
Expand All @@ -18,7 +19,8 @@ class Enqueue {
'category',
'archive',
'search',
'postType'
'postType',
'taxonomy'
];

/**
Expand All @@ -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;
}
}
Expand All @@ -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']);
}
}
}
Expand All @@ -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;
}

Expand All @@ -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));
});
Expand All @@ -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));
});
}
Expand All @@ -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));
});
}
Expand Down Expand Up @@ -167,8 +158,7 @@ public function filterHook($attrs, $filterWith)
{
$hook = $attrs['hook'];

if ($filterWith[0] === '*')
{
if ($filterWith[0] === '*') {
return true;
}

Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

}
10 changes: 10 additions & 0 deletions Herbert/Framework/Models/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

}
48 changes: 48 additions & 0 deletions Herbert/Framework/Models/TermMeta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php namespace Herbert\Framework\Models;

use Illuminate\Database\Eloquent\Model;


class TermMeta extends Model {

/**
* Disable timestamps.
*
* @var boolean
*/
public $timestamps = false;

/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'termmeta';

/**
* The primary key for the model.
*
* @var string
*/
protected $primaryKey = 'meta_id';

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'meta_key', 'meta_value'
];

/**
* Post relationship.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function term()
{
return $this->belongsTo(__NAMESPACE__ . '\Term', 'term_id');
}

}
2 changes: 1 addition & 1 deletion Herbert/Framework/Providers/TwigServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function register()
'cache' => content_directory() . '/twig-cache',
'auto_reload' => true,
'strict_variables' => false,
'autoescape' => true,
'autoescape' => 'html',
'optimizations' => -1
];
});
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down