示例#1
0
 /**
  * Set Custom Post Type class handler
  *
  * @param string|PostTypeAbstract $post_type
  *
  * @return $this
  * @access public
  */
 public function setPostType($post_type)
 {
     if ($post_type instanceof PostTypeAbstract) {
         $this->post_type = $post_type;
         $name = $this->post_type->getName();
         if ($this->post_type->isMetaBoxRegistered()) {
             $this->setMetaBox($this->post_type->getMetaBox());
         }
     } else {
         $name = $post_type;
     }
     $this->set('post_type', $name);
     return $this;
 }
示例#2
0
 /**
  * Set relation To with post type
  *
  * @param PostTypeAbstract $post_type
  *
  * @return $this
  * @throws Exception
  *
  * @access public
  */
 public function setTo(PostTypeAbstract $post_type)
 {
     if ($post_type instanceof PostTypeAbstract) {
         $this->settings['to'] = $post_type->getName();
     } else {
         throw new Exception(Translate::translate('The param $post_type isn\'t instance of \\SilverWp\\PostType\\PostTypeAbstract'));
     }
     return $this;
 }