PHPackages                             redink-no/wpkit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. redink-no/wpkit

AbandonedArchivedLibrary[Framework](/categories/framework)

redink-no/wpkit
===============

Object-oriented development framework for WordPress.

1.8.0(5y ago)251.9k7GPL-2.0+PHPPHP &gt;=5.4.0

Since Nov 4Pushed 4y ago14 watchersCompare

[ Source](https://github.com/redink-no/wpkit)[ Packagist](https://packagist.org/packages/redink-no/wpkit)[ RSS](/packages/redink-no-wpkit/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (8)Used By (0)

WPKit
=====

[](#wpkit)

> Object-oriented development framework for WordPress to simplify developers life.

Now you can spend less time for routine operations like creating post-types, taxonomies, meta-boxes. WPKit will help you write less code -&gt; drink more beer :)

*Powered by Redink AS*

License
-------

[](#license)

The WPKit framework is open-source software and distributed under the GPL-2+ license. See [LICENSE](LICENSE) for more information.

Initalization
-------------

[](#initalization)

Just include WPKit autoloader

```
require_once __DIR__ . '/WPKit/init_autoloader.php';
```

and you can start using it. We recommend use module structure fully supported by WPKit.

Usage example
-------------

[](#usage-example)

### Post type

[](#post-type)

Lets create post type Cars. You just need create new instance of `PostType` with slug and single name in parameters.

```
$cars_post_type = new WPKit\PostType\PostType('car','Car');
```

### Metabox

[](#metabox)

Now we need add some custom fields. First of all we need create metabox

```
$metabox = new WPKit\PostType\MetaBox('data','Properties');
```

And then we need add this metabox to our post type

```
$cars_post_type->add_metabox( $metabox );
```

or

```
$metabox->add_post_type( $cars_post_type );
```

You can add one matabox to several post types.

### Fields

[](#fields)

```
$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
} );
```

[![](https://camo.githubusercontent.com/4abc4216e6c0abb4e54bf624183e6facc6688383e56507821ed8a0e380844679/68747470733a2f2f73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f7374617469632d726564696e6b2f77706b69742f6578616d706c652e706e67)](https://camo.githubusercontent.com/4abc4216e6c0abb4e54bf624183e6facc6688383e56507821ed8a0e380844679/68747470733a2f2f73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f7374617469632d726564696e6b2f77706b69742f6578616d706c652e706e67)

To get value of custom fields use `MetaBox::get()` method.

```
