Example #1
0
 /**
  * Register post type
  *
  * @param array $posttype Contains all posttype details
  * @return array $posttype
  * @uses register_post_type()
  *
  * @since 3.3.0
  */
 public function registerPostType($posttype = array())
 {
     //Check post types
     if (empty($posttype)) {
         return array();
     }
     //Check slug
     if (!isset($posttype['slug']) || empty($posttype['slug'])) {
         return array();
     }
     //Store slug
     $slug = $posttype['slug'];
     //Special case: define a post/page as title
     //to edit default post/page component
     if (in_array($slug, array('post', 'page'))) {
         return array();
     }
     //Check if post type already exists
     if (post_type_exists($slug)) {
         return array();
     }
     //Build labels
     $labels = $this->defineLabels($posttype['labels']);
     //Build args
     $args = $this->defineArgs($posttype);
     $args['labels'] = $labels;
     //Action to register
     register_post_type($slug, $args);
     //Update post type
     $posttype = array_merge($posttype, $args);
     //Option
     $opt = str_replace('%SLUG%', $slug, Engine::getPermalink());
     //Get value
     $structure = TeaThemeOptions::getOption($opt, '/%' . $slug . '%-%post_id%');
     //Change structure
     add_rewrite_tag('%' . $slug . '%', '([^/]+)', $slug . '=');
     add_permastruct($slug, $structure, false);
     return array($posttype, $slug);
 }