Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #43

Open
wants to merge 79 commits into
base: use-illuminate-request
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
57c01bb
Merge pull request #8 from getherbert/use-illuminate-request
jasonagnew May 29, 2015
2b20ecc
fixed widgets and added a shortcode fix
May 29, 2015
4c2d487
bumped version number to 0.9.4
May 29, 2015
af80542
fixed plugin loading path
May 29, 2015
aa0c88d
Update version
jasonagnew May 29, 2015
e0dabcd
fix to custom wp setups
May 29, 2015
269dc41
Merge branch 'dev' of github.com:getherbert/framework into dev
May 29, 2015
b031d54
added plugin uninstall hooks and finished up on the table creation / …
Jun 2, 2015
e4cdf2e
Panels now support different controller methods based action
jasonagnew Jun 2, 2015
93ea803
added session data using Symfony's session lib
Jun 3, 2015
bd7ee3e
Merge branch 'dev' of github.com:getherbert/framework into dev
Jun 3, 2015
85cd5c9
tidied up Panel@handler a bit
Jun 3, 2015
499bf08
added HttpErrorException
Jun 3, 2015
ed75de2
fixing panel routing for different Http verbs
Jun 3, 2015
e350b08
lowercased the http verbs and action
Jun 3, 2015
51a47d9
allow passing of an array to ->with()
Jun 3, 2015
2e56afb
speed up the redirect
Jun 3, 2015
bb1ac0b
bump herbert version up
Jun 3, 2015
d629894
remove the die
Jun 3, 2015
031fdd8
added JS to redirect to speed it up a bit; added arg passing to _url …
Jun 4, 2015
753bed2
remove esc_url filter from _url helpers
Jun 4, 2015
e9e480c
guard against array usage in Panel
Jun 4, 2015
26ec2a4
added content_directory helper and fixed the twig directory for caches
Jun 4, 2015
928f596
Changed the notifier to allow for flashes and adds a fallback for wp …
Jun 4, 2015
530ffa4
added some stuff for overriding responses
Jun 4, 2015
b2b79df
disable timestamps on the models
Jun 4, 2015
0d7a43e
provide apis to the views
Jun 5, 2015
13a6d10
allow for method.uses
Jun 5, 2015
2dd64f4
added dates to post/comment and fixed a routing bug in panel.php
Jun 5, 2015
a6e2db7
added soft deletes to Post
Jun 5, 2015
2e04b00
fixing a panel bug I created in my last panel commit
Jun 5, 2015
314ddb1
fixed soft delete's delete() and restore()
Jun 5, 2015
37c4db9
bump version
Jun 5, 2015
09a3187
Revert "bump version"
Jun 5, 2015
962ec1a
provided session and session_flashed to twig
Jun 8, 2015
8adada6
Merge branch 'dev' of github.com:getherbert/framework into dev
Jun 8, 2015
23a61e4
fix for Panel, accidentally dying when it shouldn't
Jun 8, 2015
b0058be
Merge branch 'dev' of github.com:getherbert/framework into dev
Jun 8, 2015
bd630b2
add a skip for non-GET Panel methods
Jun 8, 2015
e4226d9
fixed missing use statement
Jun 8, 2015
a6cc963
fixed softdeletes scopes
Jun 9, 2015
d1a4815
bind to new L5 contract
Jun 9, 2015
f092948
fixed a panel bug with non-GET requests
Jun 9, 2015
e6ea3f9
Revert to L5.0
Jun 9, 2015
98b4926
allow method override in query string
Jun 9, 2015
d20abf6
removed debug
Jun 9, 2015
64d2cf8
Route Exception fix
jasonagnew Jun 9, 2015
5b16bc3
bump version number
jasonagnew Jun 10, 2015
52b38a8
Typo on relationship
jasonagnew Jun 10, 2015
00eecd6
bump version number
jasonagnew Jun 11, 2015
3a49cb8
added errors() helper function
Jun 16, 2015
5fec3cb
provided errors helper to twig
Jun 16, 2015
d856229
Pull in the plugin's plugin.php
Jun 19, 2015
ab46f40
Version increase
jasonagnew Jun 19, 2015
f3f3007
support position param for menu pages
jaymcp Jun 25, 2015
ad63b43
Merge pull request #10 from JonMcPartland/panel-patch
jasonagnew Jun 30, 2015
8b4f721
Fixes #9 @twoSeats @brucevdkooij
jasonagnew Jun 30, 2015
0749fa5
fixed an enqueue bug and a panel rendering bug + bumped the version u…
Jul 10, 2015
8730b77
Set fallback for collation
jasonagnew Jul 27, 2015
de17b91
Make shortcodes handle Response object
jasonagnew Jul 27, 2015
1b53168
Return shortcode instead of echo.
jasonagnew Jul 28, 2015
c68ef04
Bump version
jasonagnew Jul 28, 2015
b2e838f
Fix: open_basedir restriction
Nov 4, 2015
0d99e37
Throw fatal error when the parameter $callable in $shortcode->add() i…
Dec 12, 2015
1153023
Adds support for script localization
tormjens Feb 22, 2016
8b6b192
To Set COLLATE as Wordpress Default Collate
Apr 20, 2016
6ad41ec
Merge pull request #21 from shankarbala33/dev
onnimonni Apr 24, 2016
6624d09
Router argument issue
codesman Apr 26, 2016
7865407
Merge pull request #22 from codesman/codesman-router-hotfix
onnimonni May 23, 2016
b492748
Merge pull request #19 from tormjens/patch-1
jeremyzahner May 23, 2016
5a504a6
Merge pull request #17 from mn-martin/patch-1
jeremyzahner May 23, 2016
56ce9cf
Merge pull request #18 from c2pdev/patch-1
jeremyzahner May 23, 2016
5632ef2
Add capabilities as argument for panels
hadronix May 25, 2016
69a456e
Merge pull request #24 from gocsp/patch-1
jeremyzahner May 25, 2016
4c0be93
Fixed filtering enqueue by post type (#38)
giwrgos88 Dec 16, 2016
c720192
MODIFIED. change the name
Jun 29, 2017
b0bd7da
MODIFIED. Is necesary for can activate the plugin
Jun 29, 2017
5b46fc8
Update
Jun 29, 2017
7aded54
MODIFIED. TEST
solvitio Jun 30, 2017
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
17 changes: 14 additions & 3 deletions Herbert/Framework/API.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Herbert\Framework;

use WP_Error;
use Exception;

/**
* @see http://getherbert.com
Expand Down Expand Up @@ -36,6 +36,17 @@ public function add($method, $fn)
$this->methods[$method] = $fn;
}

/**
* Gets a method.
*
* @param string $method
* @return Callable
*/
public function get($method)
{
return array_get($this->methods, $method);
}

/**
* Magic call from the function collection.
*
Expand All @@ -46,9 +57,9 @@ public function add($method, $fn)
*/
public function __call($method, $params)
{
if (!isset($this->methods[$method]))
if ( ! isset($this->methods[$method]))
{
throw new WP_Error('broke', "Method '{$method}' not set!");
throw new Exception("Method '{$method}' not set!");
}

return $this->app->call(
Expand Down
148 changes: 145 additions & 3 deletions Herbert/Framework/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
use Illuminate\Support\ServiceProvider;
use vierbergenlars\SemVer\version as SemVersion;
use vierbergenlars\SemVer\expression as SemVersionExpression;
use Illuminate\Database\Capsule\Manager as CapsuleManager;
use Illuminate\Database\Schema\Blueprint as SchemaBlueprint;

/**
* @see http://getherbert.com
*/
class Application extends \Illuminate\Container\Container implements \Illuminate\Contracts\Foundation\Application {

public function getCachedPackagesPath()
{

}
public function runningInConsole()
{

}
/**
* The application's version.
*/
const VERSION = '0.9.2';
const VERSION = '0.9.13';

/**
* The application's version.
Expand Down Expand Up @@ -96,6 +106,13 @@ class Application extends \Illuminate\Container\Container implements \Illuminate
*/
protected $matched = [];

/**
* The plugin apis.
*
* @var array
*/
protected $apis = [];

/**
* The plugin configurations.
*
Expand Down Expand Up @@ -144,11 +161,11 @@ public function __construct()
/**
* Added to satisfy interface
*
* @return null
* @return string
*/
public function basePath()
{
return;
return content_directory() . '/herbert-cache';
}

/**
Expand Down Expand Up @@ -441,6 +458,7 @@ protected function loadPluginAPIs($requires = [])
{
global $$name;
$api = $$name = new API($this);
$this->apis[] = [$name, $api];

require "$require";
}
Expand Down Expand Up @@ -481,6 +499,24 @@ public function activatePlugin($root)

$config = $this->getPluginConfig($root);

foreach (array_get($config, 'tables', []) as $table => $class)
{
if ( ! class_exists($class))
{
continue;
}

if (CapsuleManager::schema()->hasTable($table))
{
continue;
}

CapsuleManager::schema()->create($table, function (SchemaBlueprint $table) use ($class)
{
$this->call($class . '@activate', ['table' => $table, 'app' => $this]);
});
}

foreach (array_get($config, 'activators', []) as $activator)
{
if ( ! file_exists($activator))
Expand Down Expand Up @@ -535,6 +571,85 @@ public function deactivatePlugin($root)
'widget'
]);
}

foreach (array_get($config, 'tables', []) as $table => $class)
{
if ( ! class_exists($class))
{
continue;
}

if ( ! CapsuleManager::schema()->hasTable($table))
{
continue;
}

CapsuleManager::schema()->table($table, function (SchemaBlueprint $table) use ($class)
{
$this->call($class . '@deactivate', ['table' => $table, 'app' => $this]);
});
}
}

/**
* Deletes a plugin.
*
* @see register_uninstall_hook
* @param $root
*/
public function deletePlugin($root)
{
$plugins = array_filter($this->plugins, function (Plugin $plugin) use ($root)
{
return $plugin->getBasePath() === $root;
});

foreach ($plugins as $plugin)
{
if ( ! method_exists($plugin, 'delete'))
{
continue;
}

$plugin->deactivate();
}

$config = $this->getPluginConfig($root);

foreach (array_get($config, 'deleters', []) as $deleter)
{
if ( ! file_exists($deleter))
{
continue;
}

$this->loadWith($deleter, [
'http',
'router',
'enqueue',
'panel',
'shortcode',
'widget'
]);
}

foreach (array_get($config, 'tables', []) as $table => $class)
{
if ( ! class_exists($class))
{
continue;
}

if ( ! CapsuleManager::schema()->hasTable($table))
{
continue;
}

CapsuleManager::schema()->table($table, function (SchemaBlueprint $table) use ($class)
{
$this->call($class . '@delete', ['table' => $table, 'app' => $this]);
});
}
}

/**
Expand Down Expand Up @@ -1032,6 +1147,13 @@ protected function buildViewGlobals()
$globals = array_merge($globals, $val);
}

foreach ($this->apis as $api)
{
list($name, $instance) = $api;

$globals[$name] = $instance;
}

$this->builtViewGlobals = $globals;
}

Expand Down Expand Up @@ -1140,4 +1262,24 @@ public static function getInstance()
return static::$instance;
}

/**
* Get the path to the cached "compiled.php" file.
*
* @return string
*/
public function getCachedCompilePath()
{
return $this->basePath() . '/vendor/compiled.php';
}

/**
* Get the path to the cached services.json file.
*
* @return string
*/
public function getCachedServicesPath()
{
return $this->basePath() . '/vendor/services.json';
}

}
39 changes: 17 additions & 22 deletions Herbert/Framework/Enqueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public function buildInclude($attrs, $footer)
else
{
wp_enqueue_script($attrs['as'], $attrs['src'], [], false, $footer);

if(isset($attrs['localize'])) {
wp_localize_script( $attrs['as'], $attrs['as'], $attrs['localize'] );
}
}
}

Expand Down Expand Up @@ -183,32 +187,23 @@ public function filterHook($attrs, $filterWith)
public function filterPanel($attrs, $filterWith)
{
$panels = $this->app['panel']->getPanels();
$http = $this->app['http'];
$page = $this->app['http']->get('page', false);

if ($filterWith[0] === '*') {
if (!$http->has('page'))
{
return false;
}

foreach ($panels as $panel)
{
if ($panel['slug'] === $http->get('page'))
{
return true;
}
}
if (!$page && function_exists('get_current_screen'))
{
$page = object_get(get_current_screen(), 'id', $page);
}
else

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 ($panels[$filter]['slug'] === $http->get('page'))
{
return true;
}
return true;
}

}

return false;
Expand Down Expand Up @@ -332,7 +327,7 @@ public function filterSearch($attrs, $filterWith)
*/
public function filterPostType($attrs, $filterWith)
{
return array_search(get_post_type(), $filterWith) !== null;
return array_search(get_post_type(), $filterWith) !== FALSE;
}

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

class HttpErrorException extends \Exception {

/**
* The status code.
*
* @var integer
*/
protected $status = 500;

/**
* The response.
*
* @var \Herbert\Framework\Response
*/
protected $response = null;

/**
* Constructs the HttpErrorException.
*
* @param integer $status
* @param string|mixed $message
*/
public function __construct($status = 500, $message = null)
{
parent::__construct(is_string($message) ? $message : null);

$this->status = $status;

if ( ! is_string($message))
{
$this->response = $message;
}
}

/**
* Gets the Http status code.
*
* @return integer
*/
public function getStatus()
{
return $this->status;
}

/**
* Gets the response.
*
* @return mixed
*/
public function getResponse()
{
return $this->response;
}

}
Loading