Issues (1110)

classes/class-to-specials-admin.php (128 issues)

1
<?php
0 ignored issues
show
Class file names should be based on the class name with "class-" prepended. Expected class-lsx-to-specials-admin.php, but found class-to-specials-admin.php.
Loading history...
2
/**
3
 * LSX_TO_Specials_Admin
4
 *
5
 * @package   LSX_TO_Specials_Admin
6
 * @author    LightSpeed
7
 * @license   GPL-3.0+
8
 * @link
9
 * @copyright 2018 LightSpeedDevelopment
10
 */
11
12
/**
13
 * Main plugin class.
14
 *
15
 * @package LSX_TO_Specials_Admin
16
 * @author  LightSpeed
17
 */
0 ignored issues
show
There must be no blank lines after the class comment
Loading history...
18
19
class LSX_TO_Specials_Admin extends LSX_TO_Specials {
20
21
	/**
22
	 * Constructor
23
	 */
24
	public function __construct() {
0 ignored issues
show
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
		add_filter( 'lsx_get_taxonomies_configs', array( $this, 'taxonomy_config' ), 10, 1 );
30
31
		add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) );
32
		add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) );
33
		add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) );
34
35
		add_filter( 'lsx_to_team_custom_fields', array( $this, 'custom_fields' ) );
36
		add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) );
37
		add_filter( 'lsx_to_activity_custom_fields', array( $this, 'custom_fields' ) );
38
39
		add_action( 'lsx_to_framework_special_tab_general_settings_bottom', array( $this, 'general_settings' ), 10, 1 );
40
	}
0 ignored issues
show
Expected 2 blank lines after function; 0 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
41
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$objects" missing
Loading history...
42
	 * Register the specials post type config
43
	 *
44
	 * @param  $objects
0 ignored issues
show
Missing parameter name
Loading history...
45
	 * @return   array
46
	 */
47
	public function post_type_config( $objects ) {
0 ignored issues
show
Expected 0 blank lines after opening function brace; 1 found
Loading history...
48
49
		foreach ( $this->post_types as $key => $label ) {
0 ignored issues
show
The expression $this->post_types of type boolean is not traversable.
Loading history...
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
50
			if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
51
				$objects[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php';
52
			}
53
		}
54
55
		return 	$objects;
0 ignored issues
show
Language constructs must be followed by a single space; expected 1 space but found "··"
Loading history...
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
56
	}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
57
58
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$meta_boxes" missing
Loading history...
59
	 * Register the activity metabox config
60
	 *
61
	 * @param  $meta_boxes
0 ignored issues
show
Missing parameter name
Loading history...
62
	 * @return   array
63
	 */
64
	public function meta_box_config( $meta_boxes ) {
65
		foreach ( $this->post_types as $key => $label ) {
0 ignored issues
show
The expression $this->post_types of type boolean is not traversable.
Loading history...
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
66
			if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
67
				$meta_boxes[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php';
68
			}
69
		}
0 ignored issues
show
No blank line found after control structure
Loading history...
70
		return 	$meta_boxes;
0 ignored issues
show
Language constructs must be followed by a single space; expected 1 space but found "··"
Loading history...
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
71
	}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
72
73
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$taxonomies" missing
Loading history...
74
	 * Register the Role taxonomy
75
	 *
76
	 *
77
	 * @return    null
0 ignored issues
show
There must be exactly one blank line before the tags in a doc comment
Loading history...
78
	 */
79
	public function taxonomy_config( $taxonomies ) {
0 ignored issues
show
Expected 0 blank lines after opening function brace; 1 found
Loading history...
80
81
		if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
82
			$taxonomies['special-type'] = include LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php';
83
		}
0 ignored issues
show
No blank line found after control structure
Loading history...
84
		return 	$taxonomies;
0 ignored issues
show
Language constructs must be followed by a single space; expected 1 space but found "··"
Loading history...
Spaces must be used for mid-line alignment; tabs are not allowed
Loading history...
85
	}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
86
87
	/**
88
	 * Register the global post types.
89
	 *
90
	 *
91
	 * @return    null
0 ignored issues
show
There must be exactly one blank line before the tags in a doc comment
Loading history...
Function return type is not void, but function has no return statement
Loading history...
92
	 */
93
	public function register_taxonomies() {
0 ignored issues
show
Expected 0 blank lines after opening function brace; 1 found
Loading history...
94
95
		$labels = array(
96
				'name' => _x( 'Special Type', 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 14 space(s) between "'name'" and double arrow, but found 1.
Loading history...
97
				'singular_name' => _x( 'Special Type', 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 5 space(s) between "'singular_name'" and double arrow, but found 1.
Loading history...
98
				'search_items' => __( 'Search Special Types' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 6 space(s) between "'search_items'" and double arrow, but found 1.
Loading history...
Space found before comma in argument list
Loading history...
99
				'all_items' => __( 'Special Types' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 9 space(s) between "'all_items'" and double arrow, but found 1.
Loading history...
Space found before comma in argument list
Loading history...
100
				'parent_item' => __( 'Parent Special Type' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 7 space(s) between "'parent_item'" and double arrow, but found 1.
Loading history...
Space found before comma in argument list
Loading history...
101
				'parent_item_colon' => __( 'Parent Special Type:' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Space found before comma in argument list
Loading history...
102
				'edit_item' => __( 'Edit Special Type' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 9 space(s) between "'edit_item'" and double arrow, but found 1.
Loading history...
Space found before comma in argument list
Loading history...
103
				'update_item' => __( 'Update Special Type' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 7 space(s) between "'update_item'" and double arrow, but found 1.
Loading history...
Space found before comma in argument list
Loading history...
104
				'add_new_item' => __( 'Add New Special Type' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 6 space(s) between "'add_new_item'" and double arrow, but found 1.
Loading history...
Space found before comma in argument list
Loading history...
105
				'new_item_name' => __( 'New Special Type' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 5 space(s) between "'new_item_name'" and double arrow, but found 1.
Loading history...
Space found before comma in argument list
Loading history...
106
				'menu_name' => __( 'Special Types' , 'to-specials' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 9 space(s) between "'menu_name'" and double arrow, but found 1.
Loading history...
Space found before comma in argument list
Loading history...
107
		);
108
109
		// Now register the taxonomy
0 ignored issues
show
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
110
		register_taxonomy('special-type',$this->plugin_slug, array(
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
For multi-line function calls, each argument should be on a separate line.

For a function calls that spawns multiple lines, the coding style suggests to split arguments to separate lines like this:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
);
Loading history...
111
				'hierarchical' => true,
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 8 space(s) between "'hierarchical'" and double arrow, but found 1.
Loading history...
112
				'labels' => $labels,
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 14 space(s) between "'labels'" and double arrow, but found 1.
Loading history...
113
				'show_ui' => true,
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 13 space(s) between "'show_ui'" and double arrow, but found 1.
Loading history...
114
				'public' => true,
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 14 space(s) between "'public'" and double arrow, but found 1.
Loading history...
115
				'show_tagcloud' => false,
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 7 space(s) between "'show_tagcloud'" and double arrow, but found 1.
Loading history...
116
				'exclude_from_search' => true,
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
117
				'show_admin_column' => true,
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 3 space(s) between "'show_admin_column'" and double arrow, but found 1.
Loading history...
118
				'query_var' => true,
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 11 space(s) between "'query_var'" and double arrow, but found 1.
Loading history...
119
				'rewrite' => array( 'special-type' ),
0 ignored issues
show
Array item not aligned correctly; expected 12 spaces but found 16
Loading history...
Array double arrow not aligned correctly; expected 13 space(s) between "'rewrite'" and double arrow, but found 1.
Loading history...
120
		));
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
121
122
	}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
123
124
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$fields" missing
Loading history...
125
	 * Adds in the fields to the Tour Operators Post Types.
126
	 */
127
	public function custom_fields( $fields ) {
128
		global $post, $typenow, $current_screen;
129
130
		$post_type = false;
131
		if ( $post && $post->post_type ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
132
			$post_type = $post->post_type;
133
		} elseif ( $typenow ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
134
			$post_type = $typenow;
135
		} elseif ( $current_screen && $current_screen->post_type ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
136
			$post_type = $current_screen->post_type;
137
		} elseif ( isset( $_REQUEST['post_type'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Processing form data without nonce verification.
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
138
			$post_type = sanitize_key( $_REQUEST['post_type'] );
0 ignored issues
show
Processing form data without nonce verification.
Loading history...
139
		} elseif ( isset( $_REQUEST['post'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Processing form data without nonce verification.
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
140
			$post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) );
0 ignored issues
show
Processing form data without nonce verification.
Loading history...
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

140
			$post_type = get_post_type( /** @scrutinizer ignore-type */ sanitize_key( $_REQUEST['post'] ) );
Loading history...
141
		}
142
143
		if ( false !== $post_type ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
144
			$fields[] = array(
145
				'id' => 'specials_title',
0 ignored issues
show
Array double arrow not aligned correctly; expected 3 space(s) between "'id'" and double arrow, but found 1.
Loading history...
146
				'name' => 'Specials',
147
				'type' => 'title',
148
				'cols' => 12,
149
			);
150
			$fields[] = array(
151
				'id' => 'special_to_' . $post_type,
0 ignored issues
show
Array double arrow not aligned correctly; expected 9 space(s) between "'id'" and double arrow, but found 1.
Loading history...
152
				'name' => 'Specials related with this ' . $post_type,
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between "'name'" and double arrow, but found 1.
Loading history...
153
				'type' => 'post_select',
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between "'type'" and double arrow, but found 1.
Loading history...
154
				'use_ajax' => false,
0 ignored issues
show
Array double arrow not aligned correctly; expected 3 space(s) between "'use_ajax'" and double arrow, but found 1.
Loading history...
155
				'query' => array(
0 ignored issues
show
Array double arrow not aligned correctly; expected 6 space(s) between "'query'" and double arrow, but found 1.
Loading history...
156
					'post_type' => 'special',
0 ignored issues
show
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1.
Loading history...
157
					'nopagin' => true,
0 ignored issues
show
Array double arrow not aligned correctly; expected 8 space(s) between "'nopagin'" and double arrow, but found 1.
Loading history...
158
					'posts_per_page' => '-1',
159
					'orderby' => 'title',
0 ignored issues
show
Array double arrow not aligned correctly; expected 8 space(s) between "'orderby'" and double arrow, but found 1.
Loading history...
160
					'order' => 'ASC',
0 ignored issues
show
Array double arrow not aligned correctly; expected 10 space(s) between "'order'" and double arrow, but found 1.
Loading history...
161
				),
162
				'repeatable' => true,
163
				'allow_none' => true,
164
				'cols' => 12,
0 ignored issues
show
Array double arrow not aligned correctly; expected 7 space(s) between "'cols'" and double arrow, but found 1.
Loading history...
165
			);
166
		}
0 ignored issues
show
No blank line found after control structure
Loading history...
167
		return $fields;
168
	}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
169
170
	/**
171
	 * Adds the special specific options
172
	 */
173
	public function general_settings() {
174
		?>
175
		<tr class="form-field-wrap">
176
			<th scope="row">
177
				<label for="enable_widget_excerpt"> <?php esc_html_e( 'Disable Widget Excerpt', 'tour-operator' ); ?></label>
178
			</th>
179
			<td>
180
				<input type="checkbox" {{#if enable_widget_excerpt}} checked="checked" {{/if}} name="enable_widget_excerpt" />
181
				<small><?php esc_html_e( 'This enables the excerpt text on the widget.', 'tour-operator' ); ?></small>
182
			</td>
183
		</tr>
184
		<tr class="form-field-wrap">
185
			<th scope="row">
186
				<label for="expiration_status"> <?php esc_html_e( 'Expiration Status', 'tour-operator' ); ?></label>
187
			</th>
188
			<td>
189
				<select value="{{expiration_status}}" name="expiration_status">
190
					<option value="draft" {{#is expiration_status value=""}}selected="selected"{{/is}} {{#is expiration_status value="draft"}} selected="selected"{{/is}}><?php esc_html_e( 'Draft', 'tour-operator' ); ?></option>
191
					<option value="delete" {{#is expiration_status value="delete"}} selected="selected"{{/is}}><?php esc_html_e( 'Delete', 'tour-operator' ); ?></option>
192
					<option value="private" {{#is expiration_status value="private"}} selected="selected"{{/is}}><?php esc_html_e( 'Private', 'tour-operator' ); ?></option>
193
				</select>
194
			</td>
195
		</tr>
196
197
		<?php
198
	}
0 ignored issues
show
Expected 2 blank lines after function; 0 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
199
}
200
new LSX_TO_Specials_Admin();
201