* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio
* @copyright Copyright (c) 2017, Ernest Marcinko
*/
class wpdreamsCustomPostTypes extends wpdreamsType {
private $args = array(
'exclude' => array("revision", "nav_menu_item", "attachment")
);
function getType() {
parent::getType();
$this->processData();
echo "
";
}
function processData() {
// Get the args first if exists
if ( is_array($this->data) && isset($this->data['args']) )
$this->args = array_merge($this->args, $this->data['args']);
$this->types = get_post_types('', "objects");
foreach ($this->types as $k => &$v) {
if (count($this->args['exclude']) > 0 && in_array($k, $this->args['exclude'])) {
unset($this->types[$k]);
continue;
}
if ( $k == 'attachment' ) {
$v->labels->name = 'Attachment - Media';
}
}
if ( is_array($this->data) && isset($this->data['value']) ) {
// If called from back-end non-post context
$this->selected = $this->decode_param($this->data['value']);
$this->data = $this->encode_param($this->data['value']);
} else {
// POST method or something else
$this->selected = $this->decode_param($this->data);
$this->data = $this->encode_param($this->data);
}
}
final function getData() {
return $this->data;
}
final function getSelected() {
return $this->selected;
}
}
}