src/Post/Post.php
public function registerPostType($post_type, $args = array())
    {

        if ($this->postTypeObjectExists($post_type)) {
            return new EtherError('Post type with the same name already exists');
        }

        // Args prefixed with an underscore are reserved for internal use.
        $defaults = [
            'labels'             => ['name' => 'Posts', 'singular' => 'Post',],
            'description'        => '',
            'show_ui'            => true,
            'show_in_admin_menu' => null,
            'show_in_nav_menu'   => null,
            'icon'               => null,
            'hierarchical'       => false,
            'taxonomies'         => [],
            'permissions'        => [
                'view_posts'   => 'view_posts',
                'create_posts' => 'create_posts',
                'edit_posts'   => 'edit_posts',
                'delete_posts' => 'delete_posts',
            ],
            'menu_position'      => null,
            '_built_in'          => false,
        ];

        $args = array_merge($defaults, $args);

        if (null === $args[ 'show_in_admin_menu' ]) {
            $args[ 'show_in_admin_menu' ] = $args[ 'show_ui' ];
        }

        if (null === $args[ 'show_in_nav_menu' ]) {
            $args[ 'show_in_nav_menu' ] = $args[ 'show_ui' ];
        }


        $args = (object)$args;

        $args->name = $post_type;

        if (empty($post_type) || strlen($post_type) > 20) {
            return new EtherError('Post type must be less than 20 characters length');
        }

        foreach ($args->taxonomies as $taxonomy) {
            Taxonomy::registerTaxonomyForObjectType($taxonomy, $post_type);
        }

        $this->postTypes[ $post_type ] = $args;
    }
public function registerPostType($post_type, $args = array())
    {

        if ($this->postTypeObjectExists($post_type)) {
            return new EtherError('Post type with the same name already exists');
        }

        // Args prefixed with an underscore are reserved for internal use.
        $defaults = [
            'labels'             => ['name' => 'Posts', 'singular' => 'Post',],
            'description'        => '',
            'show_ui'            => true,
            'show_in_admin_menu' => null,
            'show_in_nav_menu'   => null,
            'icon'               => null,
            'hierarchical'       => false,
            'taxonomies'         => [],
            'permissions'        => [
                'view_posts'   => 'view_posts',
                'create_posts' => 'create_posts',
                'edit_posts'   => 'edit_posts',
                'delete_posts' => 'delete_posts',
            ],
            'menu_position'      => null,
            '_built_in'          => false,
        ];

        $args = array_merge($defaults, $args);

        if (null === $args[ 'show_in_admin_menu' ]) {
            $args[ 'show_in_admin_menu' ] = $args[ 'show_ui' ];
        }

        if (null === $args[ 'show_in_nav_menu' ]) {
            $args[ 'show_in_nav_menu' ] = $args[ 'show_ui' ];
        }


        $args = (object)$args;

        $args->name = $post_type;

        if (empty($post_type) || strlen($post_type) > 20) {
            return new EtherError('Post type must be less than 20 characters length');
        }

        foreach ($args->taxonomies as $taxonomy) {
            Taxonomy::registerTaxonomyForObjectType($taxonomy, $post_type);
        }

        $this->postTypes[ $post_type ] = $args;
    }
public function registerPostType ( $ post_type , $ args = array ( ) ) { if ( $ this -> postTypeObjectExists ( $ post_type ) ) { return new EtherError ( 'Post type with the same name already exists' ) ; } // Args prefixed with an underscore are reserved for internal use. $ defaults = [ 'labels' => [ 'name' => 'Posts' , 'singular' => 'Post' , ] , 'description' => '' , 'show_ui' => true , 'show_in_admin_menu' => null , 'show_in_nav_menu' => null , 'icon' => null , 'hierarchical' => false , 'taxonomies' => [ ] , 'permissions' => [ 'view_posts' => 'view_posts' , 'create_posts' => 'create_posts' , 'edit_posts' => 'edit_posts' , 'delete_posts' => 'delete_posts' , ] , 'menu_position' => null , '_built_in' => false , ] ; $ args = array_merge ( $ defaults , $ args ) ; if ( null === $ args [ 'show_in_admin_menu' ] ) { $ args [ 'show_in_admin_menu' ] = $ args [ 'show_ui' ] ; } if ( null === $ args [ 'show_in_nav_menu' ] ) { $ args [ 'show_in_nav_menu' ] = $ args [ 'show_ui' ] ; } $ args = ( object ) $ args ; $ args -> name = $ post_type ; if ( empty ( $ post_type ) || strlen ( $ post_type ) > 20 ) { return new EtherError ( 'Post type must be less than 20 characters length' ) ; } foreach ( $ args -> taxonomies as $ taxonomy ) { Taxonomy :: registerTaxonomyForObjectType ( $ taxonomy , $ post_type ) ; } $ this -> postTypes [ $ post_type ] = $ args ; }
Register A Post Type

@param string $post_type
@param array  $args

@return void|EtherError
Register A Post Type