Skip to content

Commit 8668713

Browse files
committed
added shiz
1 parent d56df80 commit 8668713

File tree

6 files changed

+57
-12
lines changed

6 files changed

+57
-12
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ wordpress-factory
44
#Inspiration
55
Its very hard for Object-Oriented Developers (Or Developers who uses MVC Frameworks) to develop wordpress plugins due to the difference on the framework and platform. So, i created this little bootstrap framework that would easily help developers to create their own plugin easily.
66

7+
##comonents added
8+
-Twig
9+
-Autoloader
10+
-probably eloquent? or a good schema builder
11+
-storage
12+
-base_path()
13+
-cache_path()
14+
-storage_path()
15+
-dd()
16+
17+
718
#Installation
819
You could easily install the plugin plainly. Each component requires a ```config.php```. Since this is a pre-beta plugin framework, there are a little bit of ```offf-issues```
920

bootstrap.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ function cache_path()
3131
{
3232
return storage_path()."/cache";
3333
}
34+
function dd($value)
35+
{
36+
var_dump($value);
37+
die();
38+
}
3439

3540

3641

functions/classes/Core/Core.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public static function factorize($coreSettings = array())
3131
if(count($coreSettings) == 0) {
3232
$path = base_path()."/config/{$class}/config.php";
3333
$path = str_replace("\\", "/", $path);
34+
3435
$coreSettings = include $path;
3536
}
3637

@@ -66,9 +67,17 @@ public function set($instanceName, $value)
6667
/*
6768
* Get the whole instance settings
6869
*/
69-
public function getSettings()
70+
public static function getSettings()
7071
{
71-
return $this->coreSettings;
72+
$class = get_called_class();
73+
74+
if(count($coreSettings) == 0) {
75+
$path = base_path()."/config/{$class}/config.php";
76+
$path = str_replace("\\", "/", $path);
77+
// echo $path;
78+
$coreSettings = include $path;
79+
}
80+
return $coreSettings;
7281
}
7382

7483
}

functions/classes/Core/ViewCore.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,44 @@ class ViewCore extends \Core\Core
77
private static $loader = null;
88
private static $twig = null;
99

10+
11+
private static $twigInstance = null;
12+
13+
public function __construct($config = array(), $twigInstance = null)
14+
{
15+
parent::__construct($config);
16+
$this->twigInstance = $twigInstance;
17+
}
1018
public static function register()
1119
{
1220
$core = self::factorize();
13-
1421
\Twig_Autoloader::register();
1522
self::$loader = new \Twig_Loader_Filesystem(base_path()."/views");
16-
self::$twig = new \Twig_Environment($loader, $core->getSettings());
23+
self::$twig = new \Twig_Environment(self::$loader, $core->getSettings());
1724
}
1825

1926
public static function getTwig()
2027
{
21-
return $twig;
28+
return self::$twig;
29+
}
30+
31+
public static function make($file)
32+
{
33+
34+
$file = base_path()."/views/".$file;
35+
$viewCore = ViewCore::getSettings();
36+
$instance = new ViewCore($viewCore, self::getTwig());
37+
38+
$instance->twigInstance->loadTemplate($file);
39+
40+
41+
return $instance;
42+
}
43+
44+
public function load($array = array())
45+
{
46+
47+
return $this->twigInstance->render($array);
2248
}
2349

2450
}

functions/classes/Options/Page/OptionsPage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ public function displayPluginsPage()
4646
public function createAdminPage()
4747
{
4848
$options = \Options::getOptions();
49+
echo \Core\ViewCore::make('options/options.tpl')->load();
4950
}
5051
}

functions/classes/Views/Factory.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)