Passed
Push — master ( f94701...93534b )
by Nirjhar
02:18
created

PLUGIN_CPT::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 1
1
<?php
2
if ( ! defined( 'ABSPATH' ) ) exit;
3
4
/**
5
 * Custom post type class
6
 *
7
 * @author     Nirjhar Lo
8
 * @package    wp-plugin-framework
9
 */
10
if ( ! class_exists( 'PLUGIN_CPT' ) ) {
11
12
	class PLUGIN_CPT {
13
14
		/**
15
		 * @var Array
16
		 */
17
		private $labels;
18
19
		/**
20
		 * @var Array
21
		 */
22
		private $args;
23
24
		/**
25
		 * @var String
26
		 */
27
		private static $menu_svg = '';
28
29
30
		/**
31
		 * Integrate the shortcode
32
		 *
33
		 * @return Void
34
		 */
35
		public function __construct() {
36
37
			$this->labels = $this->labels();
38
			$this->args = $this->args( $this->labels );
39
40
			//register_post_type( 'cpt_name', $this->args );
41
			//add_filter( 'post_updated_messages', array( $this, 'group_updated_messages' ) );
42
		}
43
44
45
		/**
46
		 * Define the labels
47
		 *
48
		 * @return Array
49
		 */
50
		public function labels() {
51
52
	      $labels = array(
53
	        'name'                => _x( '', 'Post Type General Name', 'textdomain' ),
0 ignored issues
show
Bug introduced by
The function _x was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
	        'name'                => /** @scrutinizer ignore-call */ _x( '', 'Post Type General Name', 'textdomain' ),
Loading history...
54
	        'singular_name'       => _x( '', 'Post Type Singular Name', 'textdomain' ),
55
	        'menu_name'           => __( '', 'textdomain' ),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
	        'menu_name'           => /** @scrutinizer ignore-call */ __( '', 'textdomain' ),
Loading history...
56
	        'parent_item_colon'   => __( '', 'textdomain' ),
57
	        'all_items'           => __( '', 'textdomain' ),
58
	        'view_item'           => __( '', 'textdomain' ),
59
	        'add_new_item'        => __( '', 'textdomain' ),
60
	        'add_new'             => __( '', 'textdomain' ),
61
	        'edit_item'           => __( '', 'textdomain' ),
62
	        'update_item'         => __( '', 'textdomain' ),
63
	        'search_items'        => __( '', 'textdomain' ),
64
	        'not_found'           => __( '', 'textdomain' ),
65
	        'not_found_in_trash'  => __( '', 'textdomain' ),
66
	      );
67
68
	      return $labels;
69
	    }
70
71
72
		/**
73
		 * Define the arguments
74
		 *
75
		 * @param Array $labels
76
		 *
77
		 * @return Array
78
		 */
79
	    public function args( $labels ) {
80
81
	      $args = array(
82
	          'label'               => __( '', 'textdomain' ),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

82
	          'label'               => /** @scrutinizer ignore-call */ __( '', 'textdomain' ),
Loading history...
83
	          'description'         => __( '', 'textdomain' ),
84
	          'labels'              => $labels,
85
	          'supports'            => array( 'title', 'editor', 'thumbnail' ),
86
	          'taxonomies'          => array( 'topics', 'post_tag' ),
87
	          'hierarchical'        => true,
88
	          'public'              => true,
89
			  'rewrite'			  	=> array( 'slug' => 'slug_name' ),
90
	          'show_ui'             => true,
91
	          'show_in_menu'        => true,
92
			  'menu_icon' 			=> 'data:image/svg+xml;base64,' . self::$menu_svg,
93
	          'show_in_nav_menus'   => true,
94
	          'show_in_admin_bar'   => true,
95
	          'menu_position'       => 5,
96
	          'can_export'          => true,
97
	          'has_archive'         => true,
98
	          'exclude_from_search' => false,
99
	          'publicly_queryable'  => true,
100
	          'capability_type'     => 'post',
101
	          'show_in_rest'        => true,
102
	      );
103
104
	      return $args;
105
	    }
106
107
108
		/**
109
	 	 * Modify the cpt messages
110
		 *
111
		 * @param Array $messages
112
		 *
113
		 * @return Array
114
	 	 */
115
		 public function cpt_updated_messages( $messages ) {
116
117
			 global $post, $post_ID;
118
119
			 $messages['cpt_name'] = array(
120
				 0 => '',
121
				 1 => sprintf( __( 'CPT updated. <a href="%s">View CPT</a>', 'textdomain' ), esc_url( get_permalink( $post_ID ) ) ),
0 ignored issues
show
Bug introduced by
The function esc_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

121
				 1 => sprintf( __( 'CPT updated. <a href="%s">View CPT</a>', 'textdomain' ), /** @scrutinizer ignore-call */ esc_url( get_permalink( $post_ID ) ) ),
Loading history...
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

121
				 1 => sprintf( /** @scrutinizer ignore-call */ __( 'CPT updated. <a href="%s">View CPT</a>', 'textdomain' ), esc_url( get_permalink( $post_ID ) ) ),
Loading history...
Bug introduced by
The function get_permalink was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

121
				 1 => sprintf( __( 'CPT updated. <a href="%s">View CPT</a>', 'textdomain' ), esc_url( /** @scrutinizer ignore-call */ get_permalink( $post_ID ) ) ),
Loading history...
122
				 2 => __( 'field updated.', 'textdomain' ),
123
				 3 => __( 'field deleted.', 'textdomain' ),
124
				 4 => __( 'CPT updated.', 'textdomain' ),
125
				 5 => ( isset( $_GET['revision'] ) ? sprintf( __( 'CPT restored to revision from %s', 'textdomain' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false ),
0 ignored issues
show
Bug introduced by
The function wp_post_revision_title was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

125
				 5 => ( isset( $_GET['revision'] ) ? sprintf( __( 'CPT restored to revision from %s', 'textdomain' ), /** @scrutinizer ignore-call */ wp_post_revision_title( (int) $_GET['revision'], false ) ) : false ),
Loading history...
126
				 6 => sprintf( __( 'CPT published. <a href="%s">View Cpt</a>', 'textdomain' ), esc_url( get_permalink( $post_ID ) ) ),
127
				 7 => __( 'CPT saved.', 'textdomain' ),
128
				 8 => sprintf( __( 'CPT submitted. <a target="_blank" href="%s">Preview cpt</a>', 'textdomain' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
0 ignored issues
show
Bug introduced by
The function add_query_arg was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

128
				 8 => sprintf( __( 'CPT submitted. <a target="_blank" href="%s">Preview cpt</a>', 'textdomain' ), esc_url( /** @scrutinizer ignore-call */ add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
Loading history...
129
				 9 => sprintf( __( 'CPT scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview cpt</a>', 'textdomain' ), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ),
0 ignored issues
show
Bug introduced by
The function date_i18n was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

129
				 9 => sprintf( __( 'CPT scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview cpt</a>', 'textdomain' ), /** @scrutinizer ignore-call */ date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ),
Loading history...
130
				 10 => sprintf( __( 'CPT draft updated. <a target="_blank" href="%s">Preview cpt</a>', 'textdomain' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
131
			 );
132
133
			 return $messages;
134
		 }
135
	}
136
}
137