LSX_Activities_Admin   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 51
c 1
b 0
f 0
dl 0
loc 95
rs 10
wmc 16

4 Methods

Rating   Name   Duplication   Size   Complexity  
A post_type_config() 0 7 3
A __construct() 0 13 1
B custom_fields() 0 42 9
A meta_box_config() 0 7 3
1
<?php
2
/**
3
 * LSX_Activities_Admin
4
 *
5
 * @package   LSX_Activities_Admin
6
 * @author    LightSpeed
7
 * @license   GPL-2.0+
8
 * @link
9
 * @copyright 2018 LightSpeedDevelopment
10
 */
11
12
/**
13
 * Main plugin class.
14
 *
15
 * @package LSX_Activities_Admin
16
 * @author  LightSpeed
17
 */
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the class comment
Loading history...
18
19
class LSX_Activities_Admin extends LSX_Activities {
20
21
	/**
22
	 * Constructor
23
	 */
24
	public function __construct() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
25
		$this->set_vars();
26
27
		add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 );
28
		add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 );
29
30
		add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) );
31
		add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) );
32
		add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) );
33
34
		add_filter( 'lsx_to_team_custom_fields', array( $this, 'custom_fields' ) );
35
		add_filter( 'lsx_to_special_custom_fields', array( $this, 'custom_fields' ) );
36
		add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) );
37
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
38
39
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$objects" missing
Loading history...
40
	 * Register the activity post type config
41
	 *
42
	 * @param  $objects
0 ignored issues
show
Coding Style introduced by
Missing parameter name
Loading history...
43
	 * @return   array
44
	 */
45
	public function post_type_config( $objects ) {
46
		foreach ( $this->post_types as $key => $label ) {
0 ignored issues
show
Bug introduced by
The expression $this->post_types of type boolean is not traversable.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
47
			if ( file_exists( LSX_ACTIVITIES_PATH . 'includes/post-types/config-' . $key . '.php' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
48
				$objects[ $key ] = include LSX_ACTIVITIES_PATH . 'includes/post-types/config-' . $key . '.php';
49
			}
50
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
51
		return 	$objects;
0 ignored issues
show
Coding Style introduced by
Language constructs must be followed by a single space; expected 1 space but found "··"
Loading history...
introduced by
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
52
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
53
54
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$meta_boxes" missing
Loading history...
55
	 * Register the activity metabox config
56
	 *
57
	 * @param  $meta_boxes
0 ignored issues
show
Coding Style introduced by
Missing parameter name
Loading history...
58
	 * @return   array
59
	 */
60
	public function meta_box_config( $meta_boxes ) {
61
		foreach ( $this->post_types as $key => $label ) {
0 ignored issues
show
Bug introduced by
The expression $this->post_types of type boolean is not traversable.
Loading history...
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
62
			if ( file_exists( LSX_ACTIVITIES_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
63
				$meta_boxes[ $key ] = include LSX_ACTIVITIES_PATH . 'includes/metaboxes/config-' . $key . '.php';
64
			}
65
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
66
		return 	$meta_boxes;
0 ignored issues
show
Coding Style introduced by
Language constructs must be followed by a single space; expected 1 space but found "··"
Loading history...
introduced by
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
67
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
68
69
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$fields" missing
Loading history...
70
	 * Adds in the gallery fields to the Tour Operators Post Types.
71
	 */
72
	public function custom_fields( $fields ) {
73
		global $post, $typenow, $current_screen;
74
75
		$post_type = false;
76
77
		if ( $post && $post->post_type ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
78
			$post_type = $post->post_type;
79
		} elseif ( $typenow ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
80
			$post_type = $typenow;
81
		} elseif ( $current_screen && $current_screen->post_type ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
82
			$post_type = $current_screen->post_type;
83
		} elseif ( isset( $_REQUEST['post_type'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Processing form data without nonce verification.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
84
			$post_type = sanitize_key( $_REQUEST['post_type'] );
0 ignored issues
show
introduced by
Processing form data without nonce verification.
Loading history...
85
		} elseif ( isset( $_REQUEST['post'] ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
introduced by
Processing form data without nonce verification.
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
86
			$post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) );
0 ignored issues
show
introduced by
Processing form data without nonce verification.
Loading history...
Bug introduced by
sanitize_key($_REQUEST['post']) of type string is incompatible with the type WP_Post|integer|null expected by parameter $post of get_post_type(). ( Ignorable by Annotation )

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

86
			$post_type = get_post_type( /** @scrutinizer ignore-type */ sanitize_key( $_REQUEST['post'] ) );
Loading history...
87
		}
88
89
		if ( false !== $post_type ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
90
			$fields[] = array(
91
				'id' => 'activity_title',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 3 space(s) between "'id'" and double arrow, but found 1.
Loading history...
92
				'name' => 'Activities',
93
				'type' => 'title',
94
				'cols' => 12,
95
			);
96
			$fields[] = array(
97
				'id' => 'activity_to_' . $post_type,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 9 space(s) between "'id'" and double arrow, but found 1.
Loading history...
98
				'name' => 'Activities related with this ' . $post_type,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 7 space(s) between "'name'" and double arrow, but found 1.
Loading history...
99
				'type' => 'post_select',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 7 space(s) between "'type'" and double arrow, but found 1.
Loading history...
100
				'use_ajax' => false,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 3 space(s) between "'use_ajax'" and double arrow, but found 1.
Loading history...
101
				'query' => array(
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 6 space(s) between "'query'" and double arrow, but found 1.
Loading history...
102
					'post_type' => 'activity',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
103
					'nopagin' => true,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
104
					'posts_per_page' => '-1',
105
					'orderby' => 'title',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 8 space(s) between "'orderby'" and double arrow, but found 1.
Loading history...
106
					'order' => 'ASC',
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 10 space(s) between "'order'" and double arrow, but found 1.
Loading history...
107
				),
108
				'repeatable' => true,
109
				'allow_none' => true,
110
				'cols' => 12,
0 ignored issues
show
introduced by
Array double arrow not aligned correctly; expected 7 space(s) between "'cols'" and double arrow, but found 1.
Loading history...
111
			);
112
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
113
		return $fields;
114
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
115
}
116
new LSX_Activities_Admin();
117