Object-oriented development framework for WordPress
Object-oriented development framework for WordPress to simplify developers life., (*1)
Now you can spend less time for routine operations like creating post-types, taxonomies, meta-boxes. WPKit will help you write less code -> drink more beer :), (*2)
Powered by Redink AS, (*3)
The WPKit framework is open-source software and distributed under the GPL-2+ license. See LICENSE for more information., (*4)
Just include WPKit autoloader, (*5)
require_once __DIR__ . '/WPKit/init_autoloader.php';
and you can start using it. We recommend use module structure fully supported by WPKit., (*6)
Lets create post type Cars. You just need create new instance of PostType
with slug and single name in parameters., (*7)
$cars_post_type = new WPKit\PostType\PostType('car','Car');
Now we need add some custom fields. First of all we need create metabox, (*8)
$metabox = new WPKit\PostType\MetaBox('data','Properties');
And then we need add this metabox to our post type, (*9)
$cars_post_type->add_metabox( $metabox );
or, (*10)
$metabox->add_post_type( $cars_post_type );
You can add one matabox to several post types., (*11)
$metabox->add_field( 'reg_no', 'Registration #' ); // By default Text field will be used $metabox->add_field( 'year', 'Year', 'Number' ); // You can set Field in 3rd parameter as string $metabox->add_field( 'color', 'Color', function(){ // Or use more flexible callback function $filed = new WPKit\Fields\Select(); $filed->set_options([ // Like settings options and other 'red', 'black', 'white', 'yellow' ]); return $filed; // Function should always return created filed } );
, (*12)
To get value of custom fields use MetaBox::get()
method., (*13)
<?php $year = WPKit\PostType\MetaBox::get( get_the_ID(), 'data', 'year' ); ?>
You can use WP_Mock. There are an example of bootstrap file for tests:, (*14)
require_once 'vendor/autoload.php'; WP_Mock::bootstrap(); define( 'TEMPLATEPATH', __DIR__ ); $loader = new \WPKit\Module\Loader(); $loader->phpunit_load_modules();
More features will come in Wiki or just explore code ;), (*15)
Version 1.7.0, (*16)
Version 1.6.3, (*17)
Version 1.6.2, (*18)
Version: 1.6, (*19)
Version: 1.5.6, (*20)
Version: 1.5.5, (*21)
Version: 1.5, (*22)
Version: 1.3, (*23)
Version: 1.2.1, (*24)
Version: 1.2, (*25)
Version: 1.1, (*26)
Version: 1.0.4, (*27)