1 | <?php |
||||
0 ignored issues
–
show
introduced
by
![]() |
|||||
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
|
|||||
18 | |||||
19 | class LSX_TO_Specials_Admin extends LSX_TO_Specials { |
||||
20 | |||||
21 | /** |
||||
22 | * Constructor |
||||
23 | */ |
||||
24 | public function __construct() { |
||||
0 ignored issues
–
show
|
|||||
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
|
|||||
41 | /** |
||||
0 ignored issues
–
show
|
|||||
42 | * Register the specials post type config |
||||
43 | * |
||||
44 | * @param $objects |
||||
0 ignored issues
–
show
|
|||||
45 | * @return array |
||||
46 | */ |
||||
47 | public function post_type_config( $objects ) { |
||||
0 ignored issues
–
show
|
|||||
48 | |||||
49 | foreach ( $this->post_types as $key => $label ) { |
||||
0 ignored issues
–
show
|
|||||
50 | if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
||||
0 ignored issues
–
show
|
|||||
51 | $objects[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php'; |
||||
52 | } |
||||
53 | } |
||||
54 | |||||
55 | return $objects; |
||||
0 ignored issues
–
show
|
|||||
56 | } |
||||
0 ignored issues
–
show
|
|||||
57 | |||||
58 | /** |
||||
0 ignored issues
–
show
|
|||||
59 | * Register the activity metabox config |
||||
60 | * |
||||
61 | * @param $meta_boxes |
||||
0 ignored issues
–
show
|
|||||
62 | * @return array |
||||
63 | */ |
||||
64 | public function meta_box_config( $meta_boxes ) { |
||||
65 | foreach ( $this->post_types as $key => $label ) { |
||||
0 ignored issues
–
show
|
|||||
66 | if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
||||
0 ignored issues
–
show
|
|||||
67 | $meta_boxes[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
||||
68 | } |
||||
69 | } |
||||
0 ignored issues
–
show
|
|||||
70 | return $meta_boxes; |
||||
0 ignored issues
–
show
|
|||||
71 | } |
||||
0 ignored issues
–
show
|
|||||
72 | |||||
73 | /** |
||||
0 ignored issues
–
show
|
|||||
74 | * Register the Role taxonomy |
||||
75 | * |
||||
76 | * |
||||
77 | * @return null |
||||
0 ignored issues
–
show
|
|||||
78 | */ |
||||
79 | public function taxonomy_config( $taxonomies ) { |
||||
0 ignored issues
–
show
|
|||||
80 | |||||
81 | if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php' ) ) { |
||||
0 ignored issues
–
show
|
|||||
82 | $taxonomies['special-type'] = include LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php'; |
||||
83 | } |
||||
0 ignored issues
–
show
|
|||||
84 | return $taxonomies; |
||||
0 ignored issues
–
show
|
|||||
85 | } |
||||
0 ignored issues
–
show
|
|||||
86 | |||||
87 | /** |
||||
88 | * Register the global post types. |
||||
89 | * |
||||
90 | * |
||||
91 | * @return null |
||||
0 ignored issues
–
show
|
|||||
92 | */ |
||||
93 | public function register_taxonomies() { |
||||
0 ignored issues
–
show
|
|||||
94 | |||||
95 | $labels = array( |
||||
96 | 'name' => _x( 'Special Type', 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
97 | 'singular_name' => _x( 'Special Type', 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
98 | 'search_items' => __( 'Search Special Types' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
99 | 'all_items' => __( 'Special Types' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
100 | 'parent_item' => __( 'Parent Special Type' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
101 | 'parent_item_colon' => __( 'Parent Special Type:' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
102 | 'edit_item' => __( 'Edit Special Type' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
103 | 'update_item' => __( 'Update Special Type' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
104 | 'add_new_item' => __( 'Add New Special Type' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
105 | 'new_item_name' => __( 'New Special Type' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
106 | 'menu_name' => __( 'Special Types' , 'to-specials' ), |
||||
0 ignored issues
–
show
|
|||||
107 | ); |
||||
108 | |||||
109 | // Now register the taxonomy |
||||
0 ignored issues
–
show
|
|||||
110 | register_taxonomy('special-type',$this->plugin_slug, array( |
||||
0 ignored issues
–
show
|
|||||
111 | 'hierarchical' => true, |
||||
0 ignored issues
–
show
|
|||||
112 | 'labels' => $labels, |
||||
0 ignored issues
–
show
|
|||||
113 | 'show_ui' => true, |
||||
0 ignored issues
–
show
|
|||||
114 | 'public' => true, |
||||
0 ignored issues
–
show
|
|||||
115 | 'show_tagcloud' => false, |
||||
0 ignored issues
–
show
|
|||||
116 | 'exclude_from_search' => true, |
||||
0 ignored issues
–
show
|
|||||
117 | 'show_admin_column' => true, |
||||
0 ignored issues
–
show
|
|||||
118 | 'query_var' => true, |
||||
0 ignored issues
–
show
|
|||||
119 | 'rewrite' => array( 'special-type' ), |
||||
0 ignored issues
–
show
|
|||||
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.
![]() |
|||||
121 | |||||
122 | } |
||||
0 ignored issues
–
show
|
|||||
123 | |||||
124 | /** |
||||
0 ignored issues
–
show
|
|||||
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
|
|||||
132 | $post_type = $post->post_type; |
||||
133 | } elseif ( $typenow ) { |
||||
0 ignored issues
–
show
|
|||||
134 | $post_type = $typenow; |
||||
135 | } elseif ( $current_screen && $current_screen->post_type ) { |
||||
0 ignored issues
–
show
|
|||||
136 | $post_type = $current_screen->post_type; |
||||
137 | } elseif ( isset( $_REQUEST['post_type'] ) ) { |
||||
0 ignored issues
–
show
|
|||||
138 | $post_type = sanitize_key( $_REQUEST['post_type'] ); |
||||
0 ignored issues
–
show
|
|||||
139 | } elseif ( isset( $_REQUEST['post'] ) ) { |
||||
0 ignored issues
–
show
|
|||||
140 | $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
||||
0 ignored issues
–
show
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
![]() |
|||||
141 | } |
||||
142 | |||||
143 | if ( false !== $post_type ) { |
||||
0 ignored issues
–
show
|
|||||
144 | $fields[] = array( |
||||
145 | 'id' => 'specials_title', |
||||
0 ignored issues
–
show
|
|||||
146 | 'name' => 'Specials', |
||||
147 | 'type' => 'title', |
||||
148 | 'cols' => 12, |
||||
149 | ); |
||||
150 | $fields[] = array( |
||||
151 | 'id' => 'special_to_' . $post_type, |
||||
0 ignored issues
–
show
|
|||||
152 | 'name' => 'Specials related with this ' . $post_type, |
||||
0 ignored issues
–
show
|
|||||
153 | 'type' => 'post_select', |
||||
0 ignored issues
–
show
|
|||||
154 | 'use_ajax' => false, |
||||
0 ignored issues
–
show
|
|||||
155 | 'query' => array( |
||||
0 ignored issues
–
show
|
|||||
156 | 'post_type' => 'special', |
||||
0 ignored issues
–
show
|
|||||
157 | 'nopagin' => true, |
||||
0 ignored issues
–
show
|
|||||
158 | 'posts_per_page' => '-1', |
||||
159 | 'orderby' => 'title', |
||||
0 ignored issues
–
show
|
|||||
160 | 'order' => 'ASC', |
||||
0 ignored issues
–
show
|
|||||
161 | ), |
||||
162 | 'repeatable' => true, |
||||
163 | 'allow_none' => true, |
||||
164 | 'cols' => 12, |
||||
0 ignored issues
–
show
|
|||||
165 | ); |
||||
166 | } |
||||
0 ignored issues
–
show
|
|||||
167 | return $fields; |
||||
168 | } |
||||
0 ignored issues
–
show
|
|||||
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
|
|||||
199 | } |
||||
200 | new LSX_TO_Specials_Admin(); |
||||
201 |