git clone https://github.com/fardous80/wp-plugin-boilerplate.git plugin_name
To create a Custom Post Type, In 'index.php' add the following lines
w::Post('book', 'Book')
->register();
You can add more parameters by chaining them
w::Post('book', 'Book')
->plural('Books')
->labels(['all_items' => 'All Books'])
->args([
'supports' => ['title', 'thumbnail'],
'rewrite' => true,
])
->register();
Creating MetaBox for Custom Post Type
w::MetaBox('book_attributes', 'Book Attributes')
->belongsTo('book')
->attach( function($post){
$isbn = 'ZZZZZZZZZZ';
echo _sf_view('test.form', compact('isbn'));
})
->save(function($post_id){
_sf_verify_nonce('nonce_id', 'nonce_value');
if( $isbn = _sf_post('isbn') ) {
update_post_meta($post_id, 'isbn', $isbn);
}
});
All view / template files should be inside 'views' folder, in the example above the file 'view/test/form.php' will be parsed and outputted.
<?=wp_nonce_field( 'nonce_id', 'nonce_value')?>
<p>
<label>ISBN</label>
<input type="text" name="isbn" value="<?=$isbn?>">
</p>
c::ImageGallery('book_image_gallery', 'Image Gallery', 'book');
w::Taxonomy('book-category', 'Category')
->plural('Categories')
->belongsTo('book')
->register();
w::TermMeta('book-category')
->create(function(){
echo _sf_view('template', $data);
})
->save(function($term_id) {
// create term
})
->edit(function($term){
// edit form
})
->update(function($term_id){
// update term
});