예제 #1
0
 /**
  * Constructs the class with important vars and method calls
  * If the taxonomy exists, it will be attached to the post type
  *
  * @param 	string 			$name
  * @param 	string 			$post_type_name
  * @param 	array 			$args
  * @param 	array 			$labels
  *
  * @author 	Gijs Jorissen
  * @since 	0.2
  *
  */
 function __construct($name, $post_type_name = null, $args = array(), $labels = array(), $hierarchical)
 {
     if (!empty($name)) {
         $this->post_type_name = $post_type_name;
         $this->hierarchical = $hierarchical;
         if (is_array($name)) {
             $this->name = Cuztom::uglify($name[0]);
             $this->title = Cuztom::beautify($name[0]);
             $this->plural = Cuztom::beautify($name[1]);
         } else {
             $this->name = Cuztom::uglify($name);
             $this->title = Cuztom::beautify($name);
             $this->plural = Cuztom::pluralize(Cuztom::beautify($name));
         }
         $this->labels = $labels;
         $this->args = $args;
         if ($is_reserved_term = Cuztom::is_reserved_term($this->name)) {
             echo '<div id="message" class="error"><p>' . $is_reserved_term->get_error_message() . ': <strong>' . $this->name . '</strong></p></div>';
         } else {
             if (!taxonomy_exists($this->name)) {
                 add_action('init', array(&$this, 'register_taxonomy'));
             } else {
                 add_action('init', array(&$this, 'register_taxonomy_for_object_type'));
             }
             if (isset($args['show_column']) && $args['show_column']) {
                 add_filter('manage_' . $this->post_type_name . '_posts_columns', array(&$this, 'add_column'));
                 add_action('manage_' . $this->post_type_name . '_posts_custom_column', array(&$this, 'add_column_content'), 10, 2);
                 add_action('manage_edit-' . $this->post_type_name . '_sortable_columns', array(&$this, 'add_sortable_column'), 10, 2);
                 add_action('restrict_manage_posts', array(&$this, '_post_filter'));
                 add_filter('parse_query', array(&$this, '_post_filter_query'));
             }
         }
     }
 }
예제 #2
0
 /**
  * Constructs the class with important vars and method calls
  * If the taxonomy exists, it will be attached to the post type
  *
  * @param 	string 			$name
  * @param 	string 			$post_type
  * @param 	array 			$args
  * @param 	array 			$labels
  *
  * @author 	Gijs Jorissen
  * @since 	0.2
  *
  */
 function __construct($name, $post_type = null, $args = array(), $labels = array())
 {
     if (!empty($name)) {
         $this->post_type = $post_type;
         if (is_array($name)) {
             $this->name = Cuztom::uglify($name[0]);
             $this->title = Cuztom::beautify($name[0]);
             $this->plural = Cuztom::beautify($name[1]);
         } else {
             $this->name = Cuztom::uglify($name);
             $this->title = Cuztom::beautify($name);
             $this->plural = Cuztom::pluralize(Cuztom::beautify($name));
         }
         $this->labels = $labels;
         $this->args = $args;
         // Add to array for uninstall
         global $nm_uninstall;
         $nm_uninstall['taxonomies'][] = $this->name;
         if (!taxonomy_exists($this->name)) {
             if ($is_reserved_term = Cuztom::is_reserved_term($this->name)) {
                 new Cuztom_Notice($is_reserved_term->get_error_message(), 'error');
             } else {
                 add_action('init', array(&$this, 'register_taxonomy'));
             }
         } else {
             add_action('init', array(&$this, 'register_taxonomy_for_object_type'));
         }
         if (isset($args['show_admin_column']) && $args['show_admin_column']) {
             if (get_bloginfo('version') < '3.5') {
                 add_filter('manage_' . $this->post_type . '_posts_columns', array(&$this, 'add_column'));
                 add_action('manage_' . $this->post_type . '_posts_custom_column', array(&$this, 'add_column_content'), 10, 2);
             }
             if (isset($args['admin_column_sortable']) && $args['admin_column_sortable']) {
                 add_action('manage_edit-' . $this->post_type . '_sortable_columns', array(&$this, 'add_sortable_column'), 10, 2);
             }
             if (isset($args['admin_column_filter']) && $args['admin_column_filter']) {
                 add_action('restrict_manage_posts', array(&$this, '_post_filter'));
                 add_filter('parse_query', array(&$this, '_post_filter_query'));
             }
         }
     }
 }