コード例 #1
0
 /**
  * Custom post type
  *
  * @param   array   $cpt
  */
 function __construct($cpt)
 {
     $this->the_post_type = Riesma::slugify($cpt['post_type']);
     $this->labels = $cpt['labels'];
     // Setup all labels
     /*
     $lang = get_language_function_still_to_write();
     // Dutch
     if ( $lang == 'nl' ) {
     
     	if ( is_array( $this->labels ) ) {
     		$this->name     = Riesma::titleify( $this->labels['name'] );
     		$this->plural   = Riesma::titleify( $this->labels['plural'] );
     		$this->singular = Riesma::titleify( $this->labels['singular'] );
     	}
     	else {
     		$this->name     = Riesma::titleify( $this->labels . 's' );
     		$this->plural   = Riesma::titleify( $this->labels . 's' );
     		$this->singular = Riesma::titleify( $this->labels );
     	}
     
     	$this->hierarchical = !empty( $cpt['hierarchical'] ) ? $cpt['hierarchical'] : false;
     	$this->taxonomies   = !empty( $cpt['taxonomies'] ) ? $cpt['taxonomies'] : false;
     	$this->supports     = !empty( $cpt['supports'] ) ? $cpt['supports'] : $this->supports_default;
     	$this->slug         = Riesma::slugify( $this->name );
     	$this->icon         = Riesma::iconify( $this->the_post_type );
     }
     
     // English
     else {
     
     	if ( is_array( $this->labels ) ) {
     		$this->name          = Riesma::titleify( $this->labels['name'] );
     		$this->singular_name = Riesma::titleify( $this->labels['singular'] );
     		$this->plural        = Riesma::textify( $this->labels['plural'] );
     		$this->singular      = Riesma::textify( $this->labels['singular'] );
     	}
     	else {
     		$this->name          = Riesma::titleify( Riesma::pluralify( $this->labels ) );
     		$this->singular_name = Riesma::titleify( $this->labels );
     		$this->plural        = Riesma::textify( Riesma::pluralify( $this->labels ) );
     		$this->singular      = Riesma::textify( $this->labels );
     	}
     }
     */
     $this->name = Riesma::titleify($this->labels['name']);
     $this->singular_name = Riesma::titleify($this->labels['singular']);
     $this->plural = Riesma::textify($this->labels['plural']);
     $this->singular = Riesma::textify($this->labels['singular']);
     $this->hierarchical = !empty($cpt['hierarchical']) ? $cpt['hierarchical'] : false;
     $this->taxonomies = !empty($cpt['taxonomies']) ? $cpt['taxonomies'] : false;
     $this->supports = !empty($cpt['supports']) ? $cpt['supports'] : $this->supports_default;
     $this->slug = Riesma::slugify($this->name);
     $this->icon = Riesma::iconify($this->the_post_type);
     // Add the post type, if it does not exist yet
     if (!post_type_exists($this->the_post_type)) {
         add_action('init', array($this, 'register_post_type'));
         add_action('init', array($this, 'register_taxonomy'));
     }
 }