CMB2 - Classe para criar uma galeria padrão, usando CMB2
<?php
namespace OOPFunctions\MetaBoxes\Gallery;
if ( !class_exists('\OOPFunctions\MetaBoxes\Gallery\Gallery') ) {
/**
* Description of Gallery
*
* @author Pablo Pacheco <pablo.pacheco@origgami.com.br>
*/
class Gallery {
private $id = 'gallerycmb';
/**
*
* @var Metas
*/
private $metas;
public function __construct() {
$this->setMetas(new Metas());
add_action('cmb2_admin_init', array($this, 'addCmb'));
}
public function addCmb() {
/**
* Sample metabox to demonstrate each field type included
*/
$cmb_demo = new_cmb2_box(array(
'id' => $this->getId(),
'title' => __('Galeria', 'cmb2'),
'object_types' => array('page',), // Post type
'show_on' => array('key' => 'page-template', 'value' => 'page-templates/santo-gostinho.php'),
));
$cmb_demo->add_field(array(
//'name' => __('Test Text', 'cmb2'),
//'desc' => __('field description (optional)', 'cmb2'),
'id' => $this->getMetas()->fileList,
'type' => 'file_list',
'preview_size' => array(130, 130), // Default: array( 50, 50 )
));
}
function getId() {
return $this->id;
}
function getMetas() {
return $this->metas;
}
function setId( $id ) {
$this->id = $id;
}
function setMetas( Metas $metas ) {
$this->metas = $metas;
}
}
class Metas {
public $fileList = 'gal_filelist';
}
}