示例#1
0
 /**
  * Register post types.
  *
  * @since 3.3.6
  */
 public function buildPostTypes()
 {
     $this->engine->buildPostTypes();
 }
示例#2
0
 /**
  * Build post types.
  *
  * @param array $pts Contains all post types.
  * @uses add_action()
  *
  * @since 3.3.6
  */
 public function setPostTypes($pts)
 {
     //Define post types
     $this->posttypes = $pts;
     //Add WP Hooks
     add_action('init', function () {
         //Check post types
         if (empty($this->posttypes)) {
             return;
         }
         //Get all registered post types
         $posttypes = array();
         //Register post type
         foreach ($this->posttypes as $pt) {
             $p = $this->registerPostType($pt);
             if (empty($p) || empty($p[0])) {
                 unset($this->posttypes[$pt['slug']]);
                 continue;
             }
             //Manage columns
             if (TTO_IS_ADMIN) {
                 add_filter('manage_edit-' . $p[1] . '_columns', array(&$this, 'hookColumns'), 10);
                 add_action('manage_' . $p[1] . '_posts_custom_column', array(&$this, 'hookCustomColumn'), 11, 2);
             }
             $this->posttypes[$pt['slug']] = $p[0];
         }
         //Update DB
         if (TTO_IS_ADMIN) {
             TeaThemeOptions::setConfigs(Engine::getIndex(), $this->posttypes);
         }
         //Permalink structures
         add_action('post_type_link', array(&$this, 'hookPermalinkMake'), 10, 3);
         if (TTO_IS_ADMIN) {
             //Display post type's custom fields
             add_action('admin_init', array(&$this, 'hookFieldsDisplay'));
             //Display settings in permalinks page
             add_action('admin_init', array(&$this, 'hookFieldsPermalink'));
             //Save post type's custom fields
             add_action('save_post', array(&$this, 'hookFieldsSave'));
         }
     }, 10, 1);
 }
示例#3
0
 /**
  * Create roles and capabilities.
  *
  * @since 3.3.0
  */
 protected function updateFooter($make = 'capabilities')
 {
     //Admin panel
     if (!TTO_IS_ADMIN) {
         return;
     }
     //Update capabilities
     if ('capabilities' === $make) {
         //Get global WP roles
         global $wp_roles;
         //Check them
         if (class_exists('WP_Roles')) {
             $wp_roles = !isset($wp_roles) ? new WP_Roles() : $wp_roles;
         }
         if (!is_object($wp_roles)) {
             return;
         }
         //Add custom role
         $wp_roles->add_cap('administrator', TTO_WP_CAP_MAX);
         //Update DB
         TeaThemeOptions::setConfigs('capabilities', true);
     } elseif ('posttypes' === $make || 'terms' === $make) {
         //Get post type's index
         $index = 'posttypes' === $make ? PostTypeEngine::getIndex() : TermEngine::getIndex();
         //Get all registered pages
         $contents = TeaThemeOptions::getConfigs($index);
         //Check params and if a master page already exists
         if (!empty($contents)) {
             //Delete configurations to built them back
             TeaThemeOptions::setConfigs($index, array());
         }
         //Flush all rewrite rules
         flush_rewrite_rules();
     }
     //Redirect to Tea TO homepage
     wp_safe_redirect(admin_url('admin.php?page=' . $this->identifier . '&do=tto-action&from=dashboard'));
 }