Issues (1110)

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

1
<?php
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
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...
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
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...
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...
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' ),
97
				'singular_name' => _x( 'Special Type', 'to-specials' ),
98
				'search_items' => __( 'Search Special Types' , 'to-specials' ),
0 ignored issues
show
Space found before comma in argument list
Loading history...
99
				'all_items' => __( 'Special Types' , 'to-specials' ),
0 ignored issues
show
Space found before comma in argument list
Loading history...
100
				'parent_item' => __( 'Parent Special Type' , 'to-specials' ),
0 ignored issues
show
Space found before comma in argument list
Loading history...
101
				'parent_item_colon' => __( 'Parent Special Type:' , 'to-specials' ),
0 ignored issues
show
Space found before comma in argument list
Loading history...
102
				'edit_item' => __( 'Edit Special Type' , 'to-specials' ),
0 ignored issues
show
Space found before comma in argument list
Loading history...
103
				'update_item' => __( 'Update Special Type' , 'to-specials' ),
0 ignored issues
show
Space found before comma in argument list
Loading history...
104
				'add_new_item' => __( 'Add New Special Type' , 'to-specials' ),
0 ignored issues
show
Space found before comma in argument list
Loading history...
105
				'new_item_name' => __( 'New Special Type' , 'to-specials' ),
0 ignored issues
show
Space found before comma in argument list
Loading history...
106
				'menu_name' => __( 'Special Types' , 'to-specials' ),
0 ignored issues
show
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,
112
				'labels' => $labels,
113
				'show_ui' => true,
114
				'public' => true,
115
				'show_tagcloud' => false,
116
				'exclude_from_search' => true,
117
				'show_admin_column' => true,
118
				'query_var' => true,
119
				'rewrite' => array( 'special-type' ),
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...
Expected 0 spaces before closing bracket; 1 found
Loading history...
138
			$post_type = sanitize_key( $_REQUEST['post_type'] );
139
		} elseif ( isset( $_REQUEST['post'] ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
140
			$post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) );
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',
146
				'name' => 'Specials',
147
				'type' => 'title',
148
				'cols' => 12,
149
			);
150
			$fields[] = array(
151
				'id' => 'special_to_' . $post_type,
152
				'name' => 'Specials related with this ' . $post_type,
153
				'type' => 'post_select',
154
				'use_ajax' => false,
155
				'query' => array(
156
					'post_type' => 'special',
157
					'nopagin' => true,
158
					'posts_per_page' => '-1',
159
					'orderby' => 'title',
160
					'order' => 'ASC',
161
				),
162
				'repeatable' => true,
163
				'allow_none' => true,
164
				'cols' => 12,
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