Passed
Push — main ( 67eb22...ce3ddb )
by TARIQ
01:40
created

Invoices_Feature   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 63
c 1
b 0
f 0
dl 0
loc 77
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A init() 0 3 1
B register_custom_post_type() 0 65 1
1
<?php
2
namespace BrightyCorePlugin;
3
4
class Invoices_Feature implements Brighty_Core_Plugin_Feature_Interface  {
5
    private $plugin;
6
7
    public function __construct($plugin) {
8
        $this->plugin = $plugin;
9
    }
10
11
    public function init() {
12
        // Register the custom post type 'Invoices'
13
        add_action('init', array($this, 'register_custom_post_type'));
14
    }
15
16
    public function register_custom_post_type() {
17
        $labels = [
18
            'name'                     => esc_html__( 'Invoices', 'brighty' ),
19
            'singular_name'            => esc_html__( 'Invoice', 'brighty' ),
20
            'add_new'                  => esc_html__( 'Add New', 'brighty' ),
21
            'add_new_item'             => esc_html__( 'Add new invoice', 'brighty' ),
22
            'edit_item'                => esc_html__( 'Edit Invoice', 'brighty' ),
23
            'new_item'                 => esc_html__( 'New Invoice', 'brighty' ),
24
            'view_item'                => esc_html__( 'View Invoice', 'brighty' ),
25
            'view_items'               => esc_html__( 'View Invoices', 'brighty' ),
26
            'search_items'             => esc_html__( 'Search Invoices', 'brighty' ),
27
            'not_found'                => esc_html__( 'No invoices found', 'brighty' ),
28
            'not_found_in_trash'       => esc_html__( 'No invoices found in Trash', 'brighty' ),
29
            'parent_item_colon'        => esc_html__( 'Parent Invoice:', 'brighty' ),
30
            'all_items'                => esc_html__( 'All Invoices', 'brighty' ),
31
            'archives'                 => esc_html__( 'Invoice Archives', 'brighty' ),
32
            'attributes'               => esc_html__( 'Invoice Attributes', 'brighty' ),
33
            'insert_into_item'         => esc_html__( 'Insert into invoice', 'brighty' ),
34
            'uploaded_to_this_item'    => esc_html__( 'Uploaded to this invoice', 'brighty' ),
35
            'featured_image'           => esc_html__( 'Featured image', 'brighty' ),
36
            'set_featured_image'       => esc_html__( 'Set featured image', 'brighty' ),
37
            'remove_featured_image'    => esc_html__( 'Remove featured image', 'brighty' ),
38
            'use_featured_image'       => esc_html__( 'Use as featured image', 'brighty' ),
39
            'menu_name'                => esc_html__( 'Invoices', 'brighty' ),
40
            'filter_items_list'        => esc_html__( 'Filter invoices list', 'brighty' ),
41
            'filter_by_date'           => esc_html__( '', 'brighty' ),
42
            'items_list_navigation'    => esc_html__( 'Invoices list navigation', 'brighty' ),
43
            'items_list'               => esc_html__( 'Invoices list', 'brighty' ),
44
            'item_published'           => esc_html__( 'Invoice published', 'brighty' ),
45
            'item_published_privately' => esc_html__( 'Invoice published privately', 'brighty' ),
46
            'item_reverted_to_draft'   => esc_html__( 'Invoice reverted to draft', 'brighty' ),
47
            'item_scheduled'           => esc_html__( 'Invoice scheduled', 'brighty' ),
48
            'item_updated'             => esc_html__( 'Invoice updated', 'brighty' ),
49
            'text_domain'              => esc_html__( 'brighty', 'brighty' ),
50
        ];
51
        $args = [
52
            'label'               => esc_html__( 'Invoices', 'brighty' ),
53
            'labels'              => $labels,
54
            'description'         => '',
55
            'public'              => true,
56
            'hierarchical'        => false,
57
            'exclude_from_search' => false,
58
            'publicly_queryable'  => true,
59
            'show_ui'             => true,
60
            'show_in_nav_menus'   => true,
61
            'show_in_admin_bar'   => true,
62
            'show_in_rest'        => true,
63
            'query_var'           => true,
64
            'can_export'          => true,
65
            'delete_with_user'    => true,
66
            'has_archive'         => true,
67
            'rest_base'           => '',
68
            'show_in_menu'        => true,
69
            'menu_position'       => '',
70
            'menu_icon'           => 'dashicons-index-card',
71
            'capability_type'     => 'post',
72
            'supports'            => ['title', 'revisions', 'author'],
73
            'taxonomies'          => ['product_type'],
74
            'rewrite'             => [
75
                'with_front' => false,
76
            ],
77
        ];
78
79
        // Register the 'Invoices' custom post type
80
        register_post_type('invoice', $args);
81
    }
82
}