* @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 "
" . $this->label . ""; echo '

Available post types

    '; if ($this->types != null && is_array($this->types)) { foreach ($this->types as $k => $v) { if ($this->selected == null || !in_array($k, $this->selected)) { echo '
  • ' . $v->labels->name . '['.$k.']
  • '; } } } echo "
"; echo '

Drag here the post types you want to use!

    '; if ($this->selected != null && is_array($this->selected)) { foreach ($this->selected as $k => $v) { echo '
  • ' .$this->types[trim($v)]->labels->name. '['.$v.']
  • '; } } echo "
"; echo " "; echo " "; 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; } } }