Skip to content

QuezonMe/skelet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Skelet Framework

Introduction

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.

Contents

Installation


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 in plugin-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',
	....
);
Now, let's test the Skelet with the plugin boilerplate...
  • Create a new folder options in the plugin-boilerplate/admin directory.
  • In plugin-boilerplate/admin/options, create a new file framework.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 the PressApps in the admin side-menu.

Alt text

Configuration Files


There are 7 configuration files of Skelet that you can add in plugin-boilerplate/admin/options directory.

For supported options fields, read this documentation.

Pulling Values


Get options values

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'));
Get post/page meta values

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'));
	
Get customize options values
	$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

About

Plugin admin framework for adding options fields to options pages, shortcodes, metaboxes, widgets and customiser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 49.1%
  • JavaScript 36.2%
  • CSS 14.7%