Exemple #1
0
 /**
  * register_taxonomies
  * registers Taxonomies that use the piklist_taxonomies filter.
  *
  * @access public
  * @static
  * @since 1.0
  */
 public static function register_taxonomies()
 {
     global $wp_taxonomies, $pagenow;
     /**
      * Register Taxonomies with Piklist
      *
      * Allows for all custom Piklist parameters when registering a Taxonomy
      *
      * @param array $taxonomies 
      *
      * @since 1.0
      */
     self::$taxonomies = apply_filters('piklist_taxonomies', self::$taxonomies);
     $check = array();
     foreach (self::$taxonomies as $taxonomy_name => $taxonomy) {
         $taxonomy['name'] = isset($taxonomy['name']) || is_numeric($taxonomy_name) ? $taxonomy['name'] : $taxonomy_name;
         $type = isset($taxonomy['object_type']) ? $taxonomy['object_type'] : $taxonomy['post_type'];
         if (!isset($taxonomy['update_count_callback'])) {
             $taxonomy['update_count_callback'] = '_update_generic_term_count';
         }
         register_taxonomy($taxonomy['name'], $type, $taxonomy['configuration']);
         if (!isset($check[$taxonomy['name']]) || !$check[$taxonomy['name']]) {
             $check[$taxonomy['name']] = $taxonomy;
         }
         if (isset($taxonomy['configuration']['hide_meta_box']) && !empty($taxonomy['configuration']['hide_meta_box'])) {
             $object_types = is_array($type) ? $type : array($type);
             foreach ($object_types as $object_type) {
                 if (!isset(self::$meta_boxes_hidden[$object_type])) {
                     self::$meta_boxes_hidden[$object_type] = array();
                 }
                 array_push(self::$meta_boxes_hidden[$object_type], $taxonomy['configuration']['hierarchical'] ? $taxonomy['name'] . 'div' : 'tagsdiv-' . $taxonomy['name']);
             }
         }
         add_action('admin_head', array('piklist_cpt', 'hide_meta_boxes'), 100);
         if (isset($taxonomy['configuration']['page_icon']) && !empty($taxonomy['configuration']['page_icon'])) {
             if ($pagenow == 'edit-tags.php' && $_REQUEST['taxonomy'] == $taxonomy['name']) {
                 piklist_admin::$page_icon = array('page_id' => isset($taxonomy['object_type']) && $taxonomy['object_type'] == 'user' ? '#icon-users.icon32' : '#icon-edit.icon32', 'icon_url' => $taxonomy['configuration']['page_icon']);
             }
         }
         if (isset($taxonomy['object_type']) && $taxonomy['object_type'] == 'user') {
             if (isset($taxonomy['configuration']['show_admin_column']) && $taxonomy['configuration']['show_admin_column'] == true) {
                 piklist_cpt::$taxonomy = $taxonomy;
                 add_filter('manage_users_columns', array('piklist_cpt', 'user_column_header'), 10);
                 add_action('manage_users_custom_column', array('piklist_cpt', 'user_column_data'), 10, 3);
             }
         }
         if (isset($taxonomy['configuration']['meta_box_filter']) && $taxonomy['configuration']['meta_box_filter'] == '1') {
             if (in_array($pagenow, array('post.php', 'post-new.php'))) {
                 array_push(self::$taxonomy_filter_meta_box, $taxonomy);
                 add_action('admin_head', array('piklist_cpt', 'taxonomy_filter_meta_box'));
             }
         }
     }
     self::flush_rewrite_rules(md5(serialize($check)), 'piklist_taxonomy_rules_flushed');
 }