MslsPostType::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
1
<?php
2
/**
3
 * MslsPostType
4
 * @author Dennis Ploetner <[email protected]>
5
 * @since 0.9.8
6
 */
7
8
namespace lloc\Msls;
9
10
/**
11
 * Content types: Post types (Pages, Posts, ...)
12
 * @package Msls
13
 */
14
class MslsPostType extends MslsContentTypes {
15
16
	/**
17
	 * Constructor
18
	 * @uses get_post_types
19
	 */
20
	public function __construct() {
21
		$this->types = array_merge(
22
			[ 'post', 'page' ], // we don't need attachment, revision or nav_menu_item here
23
			get_post_types( [ 'public' => true, '_builtin' => false ], 'names', 'and' )
24
		);
25
26
		$_request = $this->get_superglobals( [ 'post_type' ] );
27
		if ( '' != $_request['post_type'] ) {
28
			$this->request = esc_attr( $_request['post_type'] );
29
		}
30
		else {
31
			$this->request = get_post_type();
32
			if ( ! $this->request ) {
33
				$this->request = 'post';
34
			}
35
		}
36
	}
37
38
	/**
39
	 * Check for post_type
40
	 * @return bool
41
	 */
42
	function is_post_type() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
43
		return true;
44
	}
45
46
}
47