/** * Build terms. * * @param array $terms Contains all terms. * @uses add_action() * * @since 3.3.6 */ public function setTerms($terms) { $this->terms = $terms; //Add WP Hooks add_action('init', function () { //Check post types if (empty($this->terms)) { return; } //Register post type foreach ($this->terms as $term) { $t = $this->registerTerm($term); if (empty($t) || empty($t[0])) { unset($this->terms[$term['slug']]); continue; } //Get all admin details if (TTO_IS_ADMIN) { //Display custom fields add_action($t[1] . '_edit_form_fields', array(&$this, 'hookFieldsDisplay'), 10, 1); //add_action($t[1].'_add_form_fields', array(&$this, 'hookFieldsDisplay'), 10, 1); //Save custom fields add_action('created_' . $t[1], array(&$this, 'hookFieldsSave'), 10, 2); add_action('edited_' . $t[1], array(&$this, 'hookFieldsSave'), 10, 2); //Display custom columns add_filter('manage_edit-' . $t[1] . '_columns', array(&$this, 'hookColumns'), 10); add_filter('manage_' . $t[1] . '_custom_column', array(&$this, 'hookCustomColumn'), 11, 3); //Special case: single choice on post edit page if (isset($term['choice']) && 'single' === $term['choice']) { //Define slug $termslug = $t[1]; //Apply filter add_filter('wp_terms_checklist_args', function ($args, $post_id) use($termslug) { //Check taxonomy if (isset($args['taxonomy']) && $termslug === $args['taxonomy']) { $args['walker'] = new WalkerSingle(); $args['popular_cats'] = array(); $args['checked_ontop'] = false; } return $args; }, 10, 2); } } $this->terms[$term['slug']] = $t[0]; } //Admin panel if (TTO_IS_ADMIN) { //Update DB TeaThemeOptions::setConfigs(Engine::getIndex(), $this->terms); //Flush all rewrite rules //flush_rewrite_rules(); } }, 10, 1); }
/** * Register terms. * * @since 3.3.4 */ public function buildTerms() { $this->engine->buildTerms(); }
/** * 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')); }