Skip to content

Commit c001a39

Browse files
committed
the all improved
1 parent 1b3377b commit c001a39

7 files changed

Lines changed: 132 additions & 80 deletions

File tree

README.md

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,38 @@
1-
wordpress-factory
2-
=================
3-
4-
#Inspiration
5-
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.
6-
7-
##components 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-
-a well fixed documentation
17-
1+
Wordpress Factory By SourceScript
2+
===
3+
A Well Placed Elegant Wordpress Factory Generated to you by [SourceScript Innovations](http://sourcescript.ph/img/logo.png). The Wordpress Factory is a boilerplate plugin that would allow the developer to use 3rd party classes easily. Not only that you could use 3rd party classes easily, The developer now can autoload's his/her own classes from other frameworks easily. No more procedural development on wordpress plugins, and no more hard-coding development on wordpress plugins.
184

5+
This plugin is <> with <3 for the Open Source Community.
6+
![SourceScript Innovations](http://sourcescript.ph/img/logo.png)
197
#Installation
20-
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```
21-
22-
##File Structure
23-
The File structure is composed of the ```Core``` class.
24-
25-
-functions/classes/Core
26-
-functions/classes/Options
27-
28-
Each class requires its own ```config.php``` that is found depending on its namespace. for example, ```\Core\Core``` has its ```config.php``` on ```config\Core\Core\config.php```
29-
30-
##Initialization
31-
initialization or bootstrapping happened under ```functions.php``` and autoloads each objects with the use of ```CADBootstrap```.
32-
33-
##Basic Example
34-
###Generating A View Component
35-
Generating a Views Component is as easy as generating it in your own favorite frameworks. With the use of Twig Templating Engine, Wordpress Factory can generate a template easy as
8+
You are required first and foremost to download [The Composer](http://getcomposer.org/download). After you have downloaded and installed this plugin. all you have to do is run 'php composer.phar install --prefer-dist'
9+
You will be then given one beautiful placed folder ```app``` this folder has two folders inside, the ```functions``` and the ```views``` the ```functions``` component will harbor all of your autoloaded class files (with / without) namespaces. While the ```views``` folder (you guessed it right) harbors all the template files generated by Twig. Yes, Awesome isn't it! We use twig! on Wordpress!
10+
##Configurations
11+
All configuration shall be manifested under ```app.php```.
12+
###Configuring the Options Page
13+
Is it hard to create your own options page WITH elegance on wordpress? Now its autoloaded for you, all you have to do is open and edit ```app.php``` it houses a 'options'. These would hold the 4 required files.
14+
15+
If editing the files are too much of a burden, you open the ```functions/OptionsPage.php``` and edit it yourself. The Views component is autoloaded already under ```views/options/options.html.twig```.
16+
17+
#Calling The Views Component
18+
We Have graciously wrapped Twig for you.
19+
all you have to do is
3620
```php
37-
echo \Core\ViewCore::make('options/options.tpl')->load();
21+
echo View::factorize('options/options.html.twig')->load();
3822
```
39-
The Views folder houses all required fields
40-
###Queueing and Registering scripts
23+
24+
You may add parameters
4125
```php
42-
\Assets\AdminAsset::load()->queue(); //for backend
43-
\Assets\FrontAsset::load()->queue(); //for Frontend
26+
echo View::factorize('options/options.html.twig')->load(['title'=>'Options Title', 'content'=>'content']);
4427
```
45-
###With Config Php
46-
####Creating an Options Page
47-
There is already an options page generated in ```functions\classes\Options\Page\OptionsPage```
4828

29+
#Adding more packages
30+
You may add your own packages with the use of composer. After downloading the composer file you may easily autoload it with ```app.php``` just add your folder like so.
4931
```php
50-
//notice that the optionspage already extended \Core\Core to have the generic requirements of the plugins page
51-
52-
public function init()
53-
{
54-
if(is_admin()) {
55-
self::factorize();
56-
}
57-
}
58-
```
32+
'libs' => array(
33+
'MyLib' => base_path().'/../vendor/sourcescript/wf-core-framework/src', //add your own file
34+
),
35+
```
36+
#Made With Love Using
37+
-Symfony
38+
-Twig

app/app.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
<?php
22
return array(
3+
/*
4+
* autoloaded functions should be added to the libs
5+
*/
36
'libs' => array(
47
'Core' => base_path().'/../vendor/sourcescript/wf-core-framework/src',
5-
'Options' => base_path().'/../vendor/sourcescript/wf-core-framework/src',
8+
'View' => base_path().'/../vendor/sourcescript/wf-core-framework/src',
9+
'Twig' => base_path().'/../vendor/twig/twig/lib'
10+
),
11+
/*
12+
* Since every plugin requires an options page, the title shall be added here
13+
*/
14+
'options' => array(
15+
'page_title' => 'Wordpress Factory',
16+
'menu_title' => 'Wordpress Factory Settings',
17+
'capability' => 'manage_options',
18+
'menu_slug' => 'manage_options'
19+
),
20+
21+
/*
22+
* Twig Templating Engine Configs
23+
*/
24+
'twig' => array(
25+
'cache' => false
626
)
727
);

app/bootstrap.php

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
11
<?php
2-
function base_path()
3-
{
4-
return dirname(__FILE__);
5-
}
2+
require_once "functions.php";
3+
require_once base_path()."/../vendor/autoload.php";
64

7-
function storage_path()
8-
{
9-
return base_path()."/storage";
10-
}
11-
12-
function cache_path()
13-
{
14-
return storage_path()."/cache";
15-
}
16-
function base_url()
17-
{
18-
return site_url('/');
19-
}
20-
function plugin_url()
21-
{
22-
return plugins_url().'/wordpress-factory/';
23-
}
24-
function dd($value)
25-
{
26-
var_dump($value);
27-
die();
28-
}
29-
30-
require_once base_path()."/../vendor/symfony/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php";
315
use Symfony\Component\ClassLoader\UniversalClassLoader;
326

337
$config = include "app.php";
8+
9+
3410
$loader = new UniversalClassLoader();
3511
$loader->registerNamespaces($config['libs']);
3612
$loader->register();
3713

38-
\Core\Core::make()->init();
14+
15+
\Core\Core::make($config)->init();
16+
OptionsPage::make()->load();

app/functions.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
function base_path()
3+
{
4+
return dirname(__FILE__);
5+
}
6+
7+
function storage_path()
8+
{
9+
return base_path()."/storage";
10+
}
11+
12+
function cache_path()
13+
{
14+
return storage_path()."/cache";
15+
}
16+
function base_url()
17+
{
18+
return site_url('/');
19+
}
20+
function plugin_url()
21+
{
22+
return plugins_url().'/wordpress-factory/';
23+
}
24+
function dd($value)
25+
{
26+
var_dump($value);
27+
die();
28+
}

app/functions/OptionsPage.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
use \Core\Core as Core;
3+
use \View\View as View;
4+
5+
class OptionsPage
6+
{
7+
private static $instance = null;
8+
9+
public static function make()
10+
{
11+
self::$instance = new OptionsPage;
12+
return self::$instance;
13+
}
14+
15+
public function load()
16+
{
17+
add_action('admin_menu', array($this, 'displayPluginsPage'));
18+
return $this;
19+
}
20+
21+
public function displayPluginsPage()
22+
{
23+
$options = Core::config('options');
24+
$settings = add_options_page(
25+
$options['page_title'],
26+
$options['menu_title'],
27+
$options['capability'],
28+
$options['menu_slug'],
29+
array($this, "createPluginspage")
30+
);
31+
32+
return $this;
33+
}
34+
35+
public function createPluginspage()
36+
{
37+
View::factorize('options/options.html.twig')->load();
38+
return $this;
39+
}
40+
41+
}

app/views/options/options.html.twig

Whitespace-only changes.

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
"minimum-stability": "dev",
1111
"require": {
1212
"sourcescript/wf-core-framework": "dev-master"
13+
},
14+
"autoload": {
15+
"classmap":[
16+
"app/functions"
17+
]
1318
}
1419
}

0 commit comments

Comments
 (0)