<?php
/**
 * Register NOO gallery.
 * This file register Item and Category for NOO gallery.
 *
 * @package    NOO Framework
 * @subpackage NOO gallery
 * @version    1.0.0
 * @author     Manhnv <manhnv@vietbrain.com>
 * @copyright  Copyright (c) 2018, NooTheme
 * @license    http://opensource.org/licenses/gpl-2.0.php GPL v2 or later
 * @link       http://nootheme.com
 */

if ( ! function_exists('noo_init_gallery')) :
    function noo_init_gallery() {

        // Text for NOO gallery.
        $gallery_labels = array(
            'name' => __('Gallery', 'noo') ,
            'singular_name' => __('Gallery', 'noo') ,
            'menu_name' => __('Gallery', 'noo') ,
            'add_new' => __('Add New', 'noo') ,
            'add_new_item' => __('Add New gallery Item', 'noo') ,
            'edit_item' => __('Edit gallery Item', 'noo') ,
            'new_item' => __('Add New gallery Item', 'noo') ,
            'view_item' => __('View gallery', 'noo') ,
            'search_items' => __('Search gallery', 'noo') ,
            'not_found' => __('No gallery items found', 'noo') ,
            'not_found_in_trash' => __('No gallery items found in trash', 'noo') ,
            'parent_item_colon' => ''
        );

        $admin_icon = NOO_FRAMEWORK_ADMIN_URI . '/assets/images/noo20x20.png';
        if ( floatval( get_bloginfo( 'version' ) ) >= 3.8 ) {
            $admin_icon = 'dashicons-format-gallery';
        }

        $gallery_page = noo_get_option('noo_gallery_page', '');
        $gallery_slug = !empty($gallery_page) ? get_post( $gallery_page )->post_name : 'gallery';

        // Options
        $gallery_args = array(
            'labels' => $gallery_labels,
            'public' => false,
            // 'publicly_queryable' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'menu_position' => 5,
            'menu_icon' => $admin_icon,
            'capability_type' => 'post',
            'hierarchical' => false,
            'supports' => array(
                'title',
                'editor',
               // 'excerpt',
               // 'thumbnail',
                // 'comments',
                // 'custom-fields',
                'revisions'
            ) ,
            'has_archive' => true,
            'rewrite' => array(
                'slug' => $gallery_slug,
                'with_front' => false
            )
        );

        register_post_type('gallery', $gallery_args);

        // Register a taxonomy for Project Categories.
        $category_labels = array(
            'name' => __('Gallery Categories', 'noo') ,
            'singular_name' => __('Gallery Category', 'noo') ,
            'menu_name' => __('Gallery Categories', 'noo') ,
            'all_items' => __('All Gallery Categories', 'noo') ,
            'edit_item' => __('Edit Gallery Category', 'noo') ,
            'view_item' => __('View Gallery Category', 'noo') ,
            'update_item' => __('Update Gallery Category', 'noo') ,
            'add_new_item' => __('Add New Gallery Category', 'noo') ,
            'new_item_name' => __('New Gallery Category Name', 'noo') ,
            'parent_item' => __('Parent Gallery Category', 'noo') ,
            'parent_item_colon' => __('Parent Gallery Category:', 'noo') ,
            'search_items' => __('Search Gallery Categories', 'noo') ,
            'popular_items' => __('Popular Gallery Categories', 'noo') ,
            'separate_items_with_commas' => __('Separate Gallery Categories with commas', 'noo') ,
            'add_or_remove_items' => __('Add or remove Gallery Categories', 'noo') ,
            'choose_from_most_used' => __('Choose from the most used Gallery Categories', 'noo') ,
            'not_found' => __('No Gallery Categories found', 'noo') ,
        );

        $category_args = array(
            'labels' => $category_labels,
            'public' => false,
            'show_ui' => true,
            'show_in_nav_menus' => false,
            'show_tagcloud' => true,
            'show_admin_column' => true,
            'hierarchical' => true,
            'query_var' => true,
            'rewrite' => array(
                'slug' => 'gallery_category',
                'with_front' => false
            ) ,
        );

        register_taxonomy('gallery_category', array(
            'gallery'
        ) , $category_args);

    }
endif;

add_action('init', 'noo_init_gallery');




