|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * Plugin Name: Books |
| 4 | + * Plugin URI: https://icodeforapurpose.com |
| 5 | + * Description: Create the Book Custom post Type |
| 6 | + * Version: 0.1. |
| 7 | + * Requires at least: 6.0 |
| 8 | + * Requires PHP: 7.2 |
| 9 | + * Author: Birgit Pauli-Haack |
| 10 | + * Author URI: https://profiles.wordpress.org/bph |
| 11 | + * License: GPL v2 or later |
| 12 | + * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 | + * Update URI: https://example.com/my-plugin/ |
| 14 | + * Text Domain: gbt |
| 15 | + * Domain Path: /languages |
| 16 | + */ |
| 17 | + |
| 18 | + |
| 19 | +// Register Custom Post Type |
| 20 | +function register_books() { |
| 21 | + |
| 22 | + $labels = array( |
| 23 | + 'name' => _x( 'Books', 'Post Type General Name', 'gbt' ), |
| 24 | + 'singular_name' => _x( 'Book', 'Post Type Singular Name', 'gbt' ), |
| 25 | + 'menu_name' => __( 'Books', 'gbt' ), |
| 26 | + 'name_admin_bar' => __( 'Books', 'gbt' ), |
| 27 | + 'archives' => __( 'Book Archives', 'gbt' ), |
| 28 | + 'attributes' => __( 'Book Attributes', 'gbt' ), |
| 29 | + 'parent_item_colon' => __( 'Parent book', 'gbt' ), |
| 30 | + 'all_items' => __( 'All Books', 'gbt' ), |
| 31 | + 'add_new_item' => __( 'Add New Book', 'gbt' ), |
| 32 | + 'add_new' => __( 'Add New Book', 'gbt' ), |
| 33 | + 'new_item' => __( 'New Book', 'gbt' ), |
| 34 | + 'edit_item' => __( 'Edit Book', 'gbt' ), |
| 35 | + 'update_item' => __( 'Update Book', 'gbt' ), |
| 36 | + 'view_item' => __( 'View Book', 'gbt' ), |
| 37 | + 'view_items' => __( 'View Books', 'gbt' ), |
| 38 | + 'search_items' => __( 'Search Books', 'gbt' ), |
| 39 | + 'not_found' => __( 'Not found', 'gbt' ), |
| 40 | + 'not_found_in_trash' => __( 'Not found in Trash', 'gbt' ), |
| 41 | + 'featured_image' => __( 'Featured Image', 'gbt' ), |
| 42 | + 'set_featured_image' => __( 'Set featured image', 'gbt' ), |
| 43 | + 'remove_featured_image' => __( 'Remove featured image', 'gbt' ), |
| 44 | + 'use_featured_image' => __( 'Use as featured image', 'gbt' ), |
| 45 | + 'insert_into_item' => __( 'Insert into item', 'gbt' ), |
| 46 | + 'uploaded_to_this_item' => __( 'Uploaded to this item', 'gbt' ), |
| 47 | + 'items_list' => __( 'Items list', 'gbt' ), |
| 48 | + 'items_list_navigation' => __( 'Items list navigation', 'gbt' ), |
| 49 | + 'filter_items_list' => __( 'Filter items list', 'gbt' ), |
| 50 | + ); |
| 51 | + $args = array( |
| 52 | + 'label' => __( 'Book', 'gbt' ), |
| 53 | + 'description' => __( 'Books', 'gbt' ), |
| 54 | + 'labels' => $labels, |
| 55 | + 'supports' => array( 'title', 'editor'), |
| 56 | + 'taxonomies' => array( 'genre', ' publisher' ), |
| 57 | + 'hierarchical' => false, |
| 58 | + 'public' => true, |
| 59 | + 'show_ui' => true, |
| 60 | + 'show_in_menu' => true, |
| 61 | + 'menu_position' => 5, |
| 62 | + 'menu_icon' => 'dashicons-book-alt', |
| 63 | + 'show_in_admin_bar' => true, |
| 64 | + 'show_in_nav_menus' => true, |
| 65 | + 'can_export' => true, |
| 66 | + 'has_archive' => true, |
| 67 | + 'exclude_from_search' => false, |
| 68 | + 'publicly_queryable' => true, |
| 69 | + 'capability_type' => 'post', |
| 70 | + 'show_in_rest' => true, |
| 71 | + ); |
| 72 | + register_post_type( 'gbtbooks', $args ); |
| 73 | + |
| 74 | +} |
| 75 | +add_action( 'init', 'register_books', 0 ); |
0 commit comments