Skelet is a framework for creating WordPress plugins, it eases the creation of:
- Advanced option pages
- Widgets
- Shortcodes
- Taxonomies
- Metaboxes
- WP Customize
- Templating
- Adding custom fields in pages, posts, custom post types, taxonomies, widgets and customizer.
- Installation and Adding Skelet to a Project
- Configuration Files
- Pulling Values
- Supported Options Fields
- Credits & Links
- Changelog
Let's assume that you want to use Skelet Framework in the plugin-boilerplate.
- Download & extract a copy of Plugin Boilerplate in
wp-content/plugins/
& pull Skelet Framework from the repository and drop the folder/skelet
inplugin-boilerplate/admin/
- In the
/plugin-boilerplate/
directory, open the plugin main file and add the following codes
/**
* Skelet Config Path
*/
$skelet_paths[] = array(
'prefix' => 'pabpdemo',
'dir' => wp_normalize_path( plugin_dir_path( __FILE__ ).'/admin/' ),
'uri' => plugin_dir_url( __FILE__ ).'/admin/skelet',
);
/**
* Load Skelet Framework
*/
if( ! class_exists( 'Skelet_LoadConfig' ) ){
include_once dirname( __FILE__ ) .'/admin/skelet/skelet.php';
}
after this line or the Plugin File Header
if ( ! defined( 'WPINC' ) ) {
die;
}
Take Note: the prefix name should be unique per plugin
$skelet_paths[] = array(
'prefix' => 'your_unique_prefix_name',
....
);
- Create a new folder
options
in theplugin-boilerplate/admin
directory. - In
plugin-boilerplate/admin/options
, create a new fileframework.config.php
and add the following codes:
$settings = array(
'header_title' => 'Plugin BoilerPlate',
'current_version' => '1.0.0',
'menu_title' => 'BoilerPlate',
'menu_type' => 'add_submenu_page',
'menu_slug' => 'pa-boilerplate',
'ajax_save' => false,
);
$options = array();
/**
* a option section for options overview
*/
$options[] = array(
'name' => 'overwiew',
'title' => 'Overview',
'icon' => 'fa fa-star',
// begin: fields
'fields' => array(
// begin: a field
array(
'id' => 'text_1',
'type' => 'text',
'title' => 'Text',
'default' => 'Hello World!'
),
// end: a field
array(
'id' => 'textarea_1',
'type' => 'textarea',
'title' => 'Textarea',
'default' => 'How are you today?',
'help' => 'This option field is useful. You will love it!'
)
)
);
SkeletFramework::instance( $settings, $options );
- Now, let's activate the
plugin-boilerplate
and it should show thePressApps
in the admin side-menu.
- Your plugin is ready to use some cool features of Skelet. Read the Configuration Files.
There are 7 configuration files of Skelet that you can add in plugin-boilerplate/admin/options
directory.
- customize.config.php - Configure custom fields, sections and panels in customizer
- framework.config.php - Configure the option page, sections and fields.
- metabox.config.php - Configure custom fields, sections and panels in post/page.
- shortcode.config.php - Configure shortcodes and fields.
- taxonomy.config.php - Configure taxonomy & tags extra fields.
- template.config.php - Override template and queries.
- widget.config.php - Configure widgets custom fields, sections and display controller.
For supported options fields, read this documentation.
Here's how to pull options values with a plugin prefix name pabp
:
$skelet = new Skelet('pabp');
var_dump($skelet->get());
You can also get a specific option value by adding the name/id of the option field:
$skelet = new Skelet('pabp');
var_dump($skelet->get('text_1'));
Below example, we specify the meta id _custom_page_options
and get the section_1_text
field value.
$skelet = new Skelet('pabp');
// get all options values
var_dump($skelet->get_meta(get_the_ID(),'_custom_page_options'));
// get specific option value
var_dump($skelet->get_meta(get_the_ID(),'_custom_page_options','section_1_text'));
$skelet = new Skelet("pabp");
// get all options values
var_dump(array($skelet->get_customize_option()));
// get specific option value
var_dump(array($skelet->get_customize_option('color_option_with_default')));
```
##### Get taxonomy options values
````PHP
$skelet = new Skelet("pabp");
// get all options values
var_dump($skelet->get_taxonomy('category',50,));
// get specific option value
var_dump($skelet->get_taxonomy('category',50,'section_4_text'));
```
##### Get widget fields values
Skelet widget configuration comes up with controller settings to get fields values.
```PHP
$options[] = array(
'name' => 'skelet_widget_fields_1',
'title' => 'Skelet Widget Fields',
'description' => 'This is a description',
'settings' => array(
// text
array(
'name' => 'text_1',
'default' => 'Skelet widget is awesome',
'control' => array(
'label' => 'Sample Text Field',
'type' => 'text',
),
),
// setup widget controller
"frontend_tpl" => array(
"wrapper" => "<div class=\"item-wrapper\">%s</div>",
"before_item" => "<div>",
"after_item" => "</div>",
"show_label" => array(
"wrapper" => "<div>%s</div>",
"before" => "<label>",
"after" => ":</label> "
),
"walker_class" => array(
"name" => "SkeletWidgetWalker",
"path" => PABP_PLUGIN_DIR."template/widget/walkers/sk-widget-sample-class.php",
)
)
```
Get widget fields values in controller file `sk-widget-sample-class.php`
```PHP
if(!class_exists("SkeletWidgetWalker")){
class SkeletWidgetWalker{
public $widget_option_settings = array();
function __construct($args,$instance){
global $options;
var_dump($instance["text_1"]);
}
}
}
```
### Supported Options fields
------------
* Text
* Textarea
* Checkbox
* Radio
* Select
* Number
* Icons
* Group
* Image
* Upload
* Gallery
* Sorter
* Wysiwyg
* Switcher
* Background
* Color Picker
* Multi Checkbox
* Checkbox Image Select
* Radio Image Select
* Typography
* Backup
* Heading
* Sub Heading
* Fieldset
* Notice
* and extendable fields
### Credits and Links
------------
Skelet is based on awesome [Codestar Framework](http://codestarframework.com/), thank you for the great work.
### Changelog
-----------
* v 1.0.0 - Initial Release