Welcome the WP Development Kit, or WDK for short. WDK allows a WordPress Developer to create sites easily and efficiently.
Welcome the WP Development Kit, or WDK for short. WDK allows a WordPress Developer to create sites easily and efficiently.
Some features that WDK makes available for developers are as follows:
WDK can be installed as a plugin (download and place into plugins folder) or installed via composer.
composer require joseffb/wp-development-kit
require_once __DIR__ . '/vendor/autoload.php'
;WDK\System::Start();
WDK by default expects you to have your WDK files in the following structure from the root of where you ran System::Start():
root
│
└─── wdk
│
└─── configs
│ │
│ └─── json files
│
└─── views
│
└─── twig files
Location to these files can be changed by defining the path in 'WDK_CONFIG_BASE' and 'WDK_TEMPLATE_LOCATIONS_BASE' accordingly. If you create multiple plugins and themes in the same site with WDK this may be a good option in terms of maintenance.
WDK has 8 different config files that you can use to scaffold your WordPress site:
Important: Config files must be valid and meet JSON file specifications. If they do not validate, WP will have a critical fail.
The two of the most used config files that you will use are probably Post_types.json and Taxonomy.json. An entire site can be setup within minutes with just these two files. Each file is made to mimic the parameters of the WordPress CPT and Taxonomy command.
Most of the arguments are pretty straight forward and with some being extra and explained below.
Extra Options:
Example json file:
[
{
"name": "Destinations",
...
},
{
"name": "Events",
"args": {
"use_twig": true,
"shadow_in_cpt": ["destination"],
"label": "Events",
"labels": {
"name": "Events",
"singular_name": "Event",
"menu_name": "Events",
"parent_item_colon": "Parent Events:",
"all_items": "All Events",
"view_item": "View Events",
"add_new_item": "Select Events:",
"add_new": "Add New",
"edit_item": "Edit Events",
"update_item": "Update Events",
"search_items": "Search Events",
"not_found": "Event Not Found",
"not_found_in_trash": "Event not found in Trash"
},
"description": "Conference Events",
"supports": [
"title",
"thumbnail",
"editor",
"custom-fields",
"comments"
],
"hierarchical": false,
"public": true,
"show_ui": true,
"show_in_menu": true,
"show_in_nav_menus": true,
"show_in_admin_bar": true,
"menu_position": 4,
"can_export": true,
"has_archive": true,
"exclude_from_search": true,
"publicly_queryable": true
}
}
]
Extra Options:
[
{
"name": "Event Day",
"post_types": [
"event"
],
"labels": [],
"options": {
"show_in_admin_bar": "true",
"show_admin_column": "true",
"show_as_admin_filter": "true"
},
"defaults": [
"6/1",
"6/2",
"6/3",
"6/4"
]
},
{
"name": "Event Slot",
"post_types": [
"event"
],
"labels": [],
"options": {
"show_in_admin_bar": "true",
"show_admin_column": "true",
"show_as_admin_filter": "true"
},
"defaults": [
"9am - 10am",
"11am - 12pm",
"12pm - 1pm",
"1pm - 2pm",
"2pm - 3pm"
]
}
]
WDK uses Timber plugin as a nifty way of implementing Twig on WordPress as such, WDK also uses The Timber Starter Theme as it's default backup theme (located at https://github.com/timber/starter-theme/ under MIT license).
Twig templates load when two conditions are met.
On Twig load a context hook (wdk_context_TEMPLATENAME) is fired which you can use to add data to your template.
add_filter('wdk_context_templatename', function($context) {
$context['my new data'] = "something here";
return $context;
});
0.0.41 - Added Hive class for centralized post management.
0.0.2 - Fixed warning when no config file is available.
0.0.1 - Initial Release