@@ -17,192 +17,192 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class LSX_TO_Team_Admin extends LSX_TO_Team { |
19 | 19 | |
20 | - /** |
|
21 | - * Constructor |
|
22 | - */ |
|
23 | - public function __construct() { |
|
24 | - $this->set_vars(); |
|
25 | - |
|
26 | - add_action( 'init', array( $this, 'init' ), 20 ); |
|
27 | - |
|
28 | - add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
|
29 | - add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
|
30 | - add_filter( 'lsx_get_taxonomies_configs', array( $this, 'taxonomy_config' ), 10, 1 ); |
|
31 | - |
|
32 | - add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
|
33 | - add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
|
34 | - add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
|
35 | - |
|
36 | - add_filter( 'lsx_to_special_custom_fields', array( $this, 'custom_fields' ) ); |
|
37 | - add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
|
38 | - add_filter( 'lsx_to_activity_custom_fields', array( $this, 'custom_fields' ) ); |
|
39 | - |
|
40 | - add_filter( 'lsx_to_taxonomies', array( $this, 'to_register_taxonomy' ), 10, 1 ); |
|
41 | - add_filter( 'lsx_to_framework_taxonomies', array( $this, 'to_register_taxonomy' ), 10, 1 ); |
|
42 | - add_filter( 'lsx_to_framework_taxonomies_plural', array( $this, 'to_register_taxonomy_plural' ), 10, 1 ); |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Register the taxonomy with the TO plugin |
|
47 | - * |
|
48 | - * @since 0.1.0 |
|
49 | - */ |
|
50 | - public function to_register_taxonomy( $taxonomies ) { |
|
51 | - $taxonomies['role'] = esc_attr__( 'Role', 'to-team' ); |
|
52 | - return $taxonomies; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Register the taxonomy with the TO plugin |
|
57 | - * |
|
58 | - * @since 0.1.0 |
|
59 | - */ |
|
60 | - public function to_register_taxonomy_plural( $taxonomies ) { |
|
61 | - $taxonomies['role'] = esc_attr__( 'Roles', 'to-team' ); |
|
62 | - return $taxonomies; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Output the form field for this metadata when adding a new term |
|
67 | - * |
|
68 | - * @since 0.1.0 |
|
69 | - */ |
|
70 | - public function init() { |
|
71 | - if ( function_exists( 'lsx_to_get_taxonomies' ) ) { |
|
72 | - $this->taxonomies = array_keys( lsx_to_get_taxonomies() ); |
|
73 | - } |
|
74 | - |
|
75 | - add_filter( 'lsx_to_taxonomy_widget_taxonomies', array( $this, 'widget_taxonomies' ), 10, 1 ); |
|
76 | - |
|
77 | - if ( false !== $this->taxonomies ) { |
|
78 | - add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
79 | - add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
80 | - |
|
81 | - foreach ( $this->taxonomies as $taxonomy ) { |
|
82 | - add_action( "{$taxonomy}_edit_form_fields", array( $this, 'add_expert_form_field' ), 3, 1 ); |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - add_action( 'lsx_to_framework_team_tab_content', array( $this, 'general_settings' ), 10, 2 ); |
|
87 | - add_action( 'lsx_to_framework_team_tab_content', array( $this, 'archive_settings' ), 10, 2 ); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Register the activity post type config |
|
92 | - * |
|
93 | - * @param $objects |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public function post_type_config( $objects ) { |
|
97 | - foreach ( $this->post_types as $key => $label ) { |
|
98 | - if ( file_exists( LSX_TO_TEAM_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
99 | - $objects[ $key ] = include LSX_TO_TEAM_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - return $objects; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Register the activity metabox config |
|
108 | - * |
|
109 | - * @param $meta_boxes |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function meta_box_config( $meta_boxes ) { |
|
113 | - foreach ( $this->post_types as $key => $label ) { |
|
114 | - if ( file_exists( LSX_TO_TEAM_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
115 | - $meta_boxes[ $key ] = include LSX_TO_TEAM_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
116 | - } |
|
117 | - } |
|
118 | - |
|
119 | - return $meta_boxes; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Register the Role taxonomy |
|
124 | - * |
|
125 | - * |
|
126 | - * @return null |
|
127 | - */ |
|
128 | - public function taxonomy_config( $taxonomies ) { |
|
129 | - if ( file_exists( LSX_TO_TEAM_PATH . 'includes/taxonomies/config-role.php' ) ) { |
|
130 | - $taxonomies['role'] = include LSX_TO_TEAM_PATH . 'includes/taxonomies/config-role.php'; |
|
131 | - } |
|
132 | - |
|
133 | - return $taxonomies; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Adds in the fields to the Tour Operators Post Types. |
|
138 | - */ |
|
139 | - public function custom_fields( $fields ) { |
|
140 | - global $post, $typenow, $current_screen; |
|
141 | - |
|
142 | - if ( $post && $post->post_type ) { |
|
143 | - $post_type = $post->post_type; |
|
144 | - } elseif ( $typenow ) { |
|
145 | - $post_type = $typenow; |
|
146 | - } elseif ( $current_screen && $current_screen->post_type ) { |
|
147 | - $post_type = $current_screen->post_type; |
|
148 | - } elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
149 | - $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
150 | - } elseif ( isset( $_REQUEST['post'] ) ) { |
|
151 | - $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
152 | - } else { |
|
153 | - $post_type = false; |
|
154 | - } |
|
155 | - |
|
156 | - if ( false !== $post_type ) { |
|
157 | - $fields[] = array( |
|
158 | - 'id' => 'team_title', |
|
159 | - 'name' => 'Teams', |
|
160 | - 'type' => 'title', |
|
161 | - 'cols' => 12, |
|
162 | - ); |
|
163 | - |
|
164 | - $fields[] = array( |
|
165 | - 'id' => 'team_to_' . $post_type, |
|
166 | - 'name' => 'Specials related with this ' . $post_type, |
|
167 | - 'type' => 'post_select', |
|
168 | - 'use_ajax' => false, |
|
169 | - 'query' => array( |
|
170 | - 'post_type' => 'team', |
|
171 | - 'nopagin' => true, |
|
172 | - 'posts_per_page' => '-1', |
|
173 | - 'orderby' => 'title', |
|
174 | - 'order' => 'ASC', |
|
175 | - ), |
|
176 | - 'repeatable' => true, |
|
177 | - 'allow_none' => true, |
|
178 | - 'cols' => 12, |
|
179 | - ); |
|
180 | - } |
|
181 | - |
|
182 | - return $fields; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Output the form field for this metadata when adding a new term |
|
187 | - * |
|
188 | - * @since 0.1.0 |
|
189 | - */ |
|
190 | - public function add_expert_form_field( $term = false ) { |
|
191 | - if ( is_object( $term ) ) { |
|
192 | - $value = get_term_meta( $term->term_id, 'expert', true ); |
|
193 | - } else { |
|
194 | - $value = false; |
|
195 | - } |
|
196 | - |
|
197 | - $experts = get_posts( |
|
198 | - array( |
|
199 | - 'post_type' => 'team', |
|
200 | - 'posts_per_page' => -1, |
|
201 | - 'orderby' => 'menu_order', |
|
202 | - 'order' => 'ASC', |
|
203 | - ) |
|
204 | - ); |
|
205 | - ?> |
|
20 | + /** |
|
21 | + * Constructor |
|
22 | + */ |
|
23 | + public function __construct() { |
|
24 | + $this->set_vars(); |
|
25 | + |
|
26 | + add_action( 'init', array( $this, 'init' ), 20 ); |
|
27 | + |
|
28 | + add_filter( 'lsx_get_post-types_configs', array( $this, 'post_type_config' ), 10, 1 ); |
|
29 | + add_filter( 'lsx_get_metaboxes_configs', array( $this, 'meta_box_config' ), 10, 1 ); |
|
30 | + add_filter( 'lsx_get_taxonomies_configs', array( $this, 'taxonomy_config' ), 10, 1 ); |
|
31 | + |
|
32 | + add_filter( 'lsx_to_destination_custom_fields', array( $this, 'custom_fields' ) ); |
|
33 | + add_filter( 'lsx_to_tour_custom_fields', array( $this, 'custom_fields' ) ); |
|
34 | + add_filter( 'lsx_to_accommodation_custom_fields', array( $this, 'custom_fields' ) ); |
|
35 | + |
|
36 | + add_filter( 'lsx_to_special_custom_fields', array( $this, 'custom_fields' ) ); |
|
37 | + add_filter( 'lsx_to_review_custom_fields', array( $this, 'custom_fields' ) ); |
|
38 | + add_filter( 'lsx_to_activity_custom_fields', array( $this, 'custom_fields' ) ); |
|
39 | + |
|
40 | + add_filter( 'lsx_to_taxonomies', array( $this, 'to_register_taxonomy' ), 10, 1 ); |
|
41 | + add_filter( 'lsx_to_framework_taxonomies', array( $this, 'to_register_taxonomy' ), 10, 1 ); |
|
42 | + add_filter( 'lsx_to_framework_taxonomies_plural', array( $this, 'to_register_taxonomy_plural' ), 10, 1 ); |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Register the taxonomy with the TO plugin |
|
47 | + * |
|
48 | + * @since 0.1.0 |
|
49 | + */ |
|
50 | + public function to_register_taxonomy( $taxonomies ) { |
|
51 | + $taxonomies['role'] = esc_attr__( 'Role', 'to-team' ); |
|
52 | + return $taxonomies; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Register the taxonomy with the TO plugin |
|
57 | + * |
|
58 | + * @since 0.1.0 |
|
59 | + */ |
|
60 | + public function to_register_taxonomy_plural( $taxonomies ) { |
|
61 | + $taxonomies['role'] = esc_attr__( 'Roles', 'to-team' ); |
|
62 | + return $taxonomies; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Output the form field for this metadata when adding a new term |
|
67 | + * |
|
68 | + * @since 0.1.0 |
|
69 | + */ |
|
70 | + public function init() { |
|
71 | + if ( function_exists( 'lsx_to_get_taxonomies' ) ) { |
|
72 | + $this->taxonomies = array_keys( lsx_to_get_taxonomies() ); |
|
73 | + } |
|
74 | + |
|
75 | + add_filter( 'lsx_to_taxonomy_widget_taxonomies', array( $this, 'widget_taxonomies' ), 10, 1 ); |
|
76 | + |
|
77 | + if ( false !== $this->taxonomies ) { |
|
78 | + add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
79 | + add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
80 | + |
|
81 | + foreach ( $this->taxonomies as $taxonomy ) { |
|
82 | + add_action( "{$taxonomy}_edit_form_fields", array( $this, 'add_expert_form_field' ), 3, 1 ); |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + add_action( 'lsx_to_framework_team_tab_content', array( $this, 'general_settings' ), 10, 2 ); |
|
87 | + add_action( 'lsx_to_framework_team_tab_content', array( $this, 'archive_settings' ), 10, 2 ); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Register the activity post type config |
|
92 | + * |
|
93 | + * @param $objects |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public function post_type_config( $objects ) { |
|
97 | + foreach ( $this->post_types as $key => $label ) { |
|
98 | + if ( file_exists( LSX_TO_TEAM_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
99 | + $objects[ $key ] = include LSX_TO_TEAM_PATH . 'includes/post-types/config-' . $key . '.php'; |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + return $objects; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Register the activity metabox config |
|
108 | + * |
|
109 | + * @param $meta_boxes |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function meta_box_config( $meta_boxes ) { |
|
113 | + foreach ( $this->post_types as $key => $label ) { |
|
114 | + if ( file_exists( LSX_TO_TEAM_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
115 | + $meta_boxes[ $key ] = include LSX_TO_TEAM_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
|
116 | + } |
|
117 | + } |
|
118 | + |
|
119 | + return $meta_boxes; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Register the Role taxonomy |
|
124 | + * |
|
125 | + * |
|
126 | + * @return null |
|
127 | + */ |
|
128 | + public function taxonomy_config( $taxonomies ) { |
|
129 | + if ( file_exists( LSX_TO_TEAM_PATH . 'includes/taxonomies/config-role.php' ) ) { |
|
130 | + $taxonomies['role'] = include LSX_TO_TEAM_PATH . 'includes/taxonomies/config-role.php'; |
|
131 | + } |
|
132 | + |
|
133 | + return $taxonomies; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Adds in the fields to the Tour Operators Post Types. |
|
138 | + */ |
|
139 | + public function custom_fields( $fields ) { |
|
140 | + global $post, $typenow, $current_screen; |
|
141 | + |
|
142 | + if ( $post && $post->post_type ) { |
|
143 | + $post_type = $post->post_type; |
|
144 | + } elseif ( $typenow ) { |
|
145 | + $post_type = $typenow; |
|
146 | + } elseif ( $current_screen && $current_screen->post_type ) { |
|
147 | + $post_type = $current_screen->post_type; |
|
148 | + } elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
149 | + $post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
150 | + } elseif ( isset( $_REQUEST['post'] ) ) { |
|
151 | + $post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
152 | + } else { |
|
153 | + $post_type = false; |
|
154 | + } |
|
155 | + |
|
156 | + if ( false !== $post_type ) { |
|
157 | + $fields[] = array( |
|
158 | + 'id' => 'team_title', |
|
159 | + 'name' => 'Teams', |
|
160 | + 'type' => 'title', |
|
161 | + 'cols' => 12, |
|
162 | + ); |
|
163 | + |
|
164 | + $fields[] = array( |
|
165 | + 'id' => 'team_to_' . $post_type, |
|
166 | + 'name' => 'Specials related with this ' . $post_type, |
|
167 | + 'type' => 'post_select', |
|
168 | + 'use_ajax' => false, |
|
169 | + 'query' => array( |
|
170 | + 'post_type' => 'team', |
|
171 | + 'nopagin' => true, |
|
172 | + 'posts_per_page' => '-1', |
|
173 | + 'orderby' => 'title', |
|
174 | + 'order' => 'ASC', |
|
175 | + ), |
|
176 | + 'repeatable' => true, |
|
177 | + 'allow_none' => true, |
|
178 | + 'cols' => 12, |
|
179 | + ); |
|
180 | + } |
|
181 | + |
|
182 | + return $fields; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Output the form field for this metadata when adding a new term |
|
187 | + * |
|
188 | + * @since 0.1.0 |
|
189 | + */ |
|
190 | + public function add_expert_form_field( $term = false ) { |
|
191 | + if ( is_object( $term ) ) { |
|
192 | + $value = get_term_meta( $term->term_id, 'expert', true ); |
|
193 | + } else { |
|
194 | + $value = false; |
|
195 | + } |
|
196 | + |
|
197 | + $experts = get_posts( |
|
198 | + array( |
|
199 | + 'post_type' => 'team', |
|
200 | + 'posts_per_page' => -1, |
|
201 | + 'orderby' => 'menu_order', |
|
202 | + 'order' => 'ASC', |
|
203 | + ) |
|
204 | + ); |
|
205 | + ?> |
|
206 | 206 | <tr class="form-field form-required term-expert-wrap"> |
207 | 207 | <th scope="row"> |
208 | 208 | <label for="expert"><?php esc_html_e( 'Expert', 'to-team' ); ?></label> |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | <option value=""><?php esc_html_e( 'None', 'to-team' ); ?></option> |
213 | 213 | |
214 | 214 | <?php |
215 | - foreach ( $experts as $expert ) { |
|
216 | - echo '<option value="' . esc_attr( $expert->ID ) . '"' . selected( $value, $expert->ID, false ) . '>' . esc_html( $expert->post_title ) . '</option>'; |
|
217 | - } |
|
218 | - ?> |
|
215 | + foreach ( $experts as $expert ) { |
|
216 | + echo '<option value="' . esc_attr( $expert->ID ) . '"' . selected( $value, $expert->ID, false ) . '>' . esc_html( $expert->post_title ) . '</option>'; |
|
217 | + } |
|
218 | + ?> |
|
219 | 219 | </select> |
220 | 220 | |
221 | 221 | <?php wp_nonce_field( 'lsx_to_team_save_term_expert', 'lsx_to_team_term_expert_nonce' ); ?> |
@@ -223,52 +223,52 @@ discard block |
||
223 | 223 | </tr> |
224 | 224 | |
225 | 225 | <?php |
226 | - } |
|
227 | - /** |
|
228 | - * Saves the Taxnomy term banner image |
|
229 | - * |
|
230 | - * @since 0.1.0 |
|
231 | - * |
|
232 | - * @param int $term_id |
|
233 | - * @param string $taxonomy |
|
234 | - */ |
|
235 | - public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
236 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
237 | - return; |
|
238 | - } |
|
239 | - |
|
240 | - if ( ! isset( $_POST['expert'] ) ) { |
|
241 | - return; |
|
242 | - } |
|
243 | - |
|
244 | - if ( check_admin_referer( 'lsx_to_team_save_term_expert', 'lsx_to_team_term_expert_nonce' ) ) { |
|
245 | - $meta = ! empty( sanitize_text_field( wp_unslash( $_POST['expert'] ) ) ) ? sanitize_text_field( wp_unslash( $_POST['expert'] ) ) : ''; |
|
246 | - |
|
247 | - if ( empty( $meta ) ) { |
|
248 | - delete_term_meta( $term_id, 'expert' ); |
|
249 | - } else { |
|
250 | - update_term_meta( $term_id, 'expert', $meta ); |
|
251 | - } |
|
252 | - } |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * Adds the team specific options |
|
257 | - */ |
|
258 | - public function general_settings( $post_type = false, $tab = false ) { |
|
259 | - if ( 'general' !== $tab ) { |
|
260 | - return false; |
|
261 | - } |
|
262 | - |
|
263 | - $experts = get_posts( |
|
264 | - array( |
|
265 | - 'post_type' => 'team', |
|
266 | - 'posts_per_page' => -1, |
|
267 | - 'orderby' => 'menu_order', |
|
268 | - 'order' => 'ASC', |
|
269 | - ) |
|
270 | - ); |
|
271 | - ?> |
|
226 | + } |
|
227 | + /** |
|
228 | + * Saves the Taxnomy term banner image |
|
229 | + * |
|
230 | + * @since 0.1.0 |
|
231 | + * |
|
232 | + * @param int $term_id |
|
233 | + * @param string $taxonomy |
|
234 | + */ |
|
235 | + public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
236 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
237 | + return; |
|
238 | + } |
|
239 | + |
|
240 | + if ( ! isset( $_POST['expert'] ) ) { |
|
241 | + return; |
|
242 | + } |
|
243 | + |
|
244 | + if ( check_admin_referer( 'lsx_to_team_save_term_expert', 'lsx_to_team_term_expert_nonce' ) ) { |
|
245 | + $meta = ! empty( sanitize_text_field( wp_unslash( $_POST['expert'] ) ) ) ? sanitize_text_field( wp_unslash( $_POST['expert'] ) ) : ''; |
|
246 | + |
|
247 | + if ( empty( $meta ) ) { |
|
248 | + delete_term_meta( $term_id, 'expert' ); |
|
249 | + } else { |
|
250 | + update_term_meta( $term_id, 'expert', $meta ); |
|
251 | + } |
|
252 | + } |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * Adds the team specific options |
|
257 | + */ |
|
258 | + public function general_settings( $post_type = false, $tab = false ) { |
|
259 | + if ( 'general' !== $tab ) { |
|
260 | + return false; |
|
261 | + } |
|
262 | + |
|
263 | + $experts = get_posts( |
|
264 | + array( |
|
265 | + 'post_type' => 'team', |
|
266 | + 'posts_per_page' => -1, |
|
267 | + 'orderby' => 'menu_order', |
|
268 | + 'order' => 'ASC', |
|
269 | + ) |
|
270 | + ); |
|
271 | + ?> |
|
272 | 272 | <tr class="form-field"> |
273 | 273 | <th scope="row"> |
274 | 274 | <label for="disable_team_panel"><?php esc_html_e( 'Disable Team Panel', 'to-team' ); ?></label> |
@@ -292,16 +292,16 @@ discard block |
||
292 | 292 | </td> |
293 | 293 | </tr> |
294 | 294 | <?php |
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * Adds the team specific options |
|
299 | - */ |
|
300 | - public function archive_settings( $post_type = false, $tab = false ) { |
|
301 | - if ( 'archives' !== $tab ) { |
|
302 | - return false; |
|
303 | - } |
|
304 | - ?> |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * Adds the team specific options |
|
299 | + */ |
|
300 | + public function archive_settings( $post_type = false, $tab = false ) { |
|
301 | + if ( 'archives' !== $tab ) { |
|
302 | + return false; |
|
303 | + } |
|
304 | + ?> |
|
305 | 305 | <tr class="form-field"> |
306 | 306 | <th scope="row"> |
307 | 307 | <label for="group_items_by_role"><?php esc_html_e( 'Group by Role', 'to-team' ); ?></label> |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | </td> |
313 | 313 | </tr> |
314 | 314 | <?php |
315 | - } |
|
315 | + } |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | new LSX_TO_Team_Admin(); |
@@ -10,173 +10,173 @@ |
||
10 | 10 | |
11 | 11 | class LSX_TO_Template_Redirects { |
12 | 12 | |
13 | - /** |
|
14 | - * Plugin Path |
|
15 | - */ |
|
16 | - public $plugin_path = false; |
|
13 | + /** |
|
14 | + * Plugin Path |
|
15 | + */ |
|
16 | + public $plugin_path = false; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Post Types |
|
20 | - */ |
|
21 | - public $post_types = false; |
|
18 | + /** |
|
19 | + * Post Types |
|
20 | + */ |
|
21 | + public $post_types = false; |
|
22 | 22 | |
23 | - /** |
|
24 | - * Taxonomies |
|
25 | - */ |
|
26 | - public $taxonomies = false; |
|
23 | + /** |
|
24 | + * Taxonomies |
|
25 | + */ |
|
26 | + public $taxonomies = false; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Initialize the plugin by setting localization, filters, and administration functions. |
|
30 | - * |
|
31 | - * @param array $post_types an array of the post types to redirect. |
|
32 | - * @param array $taxonomies an array of the taxonomies to redirect. |
|
33 | - */ |
|
34 | - public function __construct( $plugin_path = false, $post_types = false, $taxonomies = false ) { |
|
35 | - if ( false !== $plugin_path ) { |
|
36 | - $this->plugin_path = $plugin_path; |
|
28 | + /** |
|
29 | + * Initialize the plugin by setting localization, filters, and administration functions. |
|
30 | + * |
|
31 | + * @param array $post_types an array of the post types to redirect. |
|
32 | + * @param array $taxonomies an array of the taxonomies to redirect. |
|
33 | + */ |
|
34 | + public function __construct( $plugin_path = false, $post_types = false, $taxonomies = false ) { |
|
35 | + if ( false !== $plugin_path ) { |
|
36 | + $this->plugin_path = $plugin_path; |
|
37 | 37 | |
38 | - add_filter( 'lsx_to_widget_path', array( $this, 'widget_path' ), 10, 2 ); |
|
39 | - add_filter( 'lsx_to_content_path', array( $this, 'content_path' ), 10, 3 ); |
|
38 | + add_filter( 'lsx_to_widget_path', array( $this, 'widget_path' ), 10, 2 ); |
|
39 | + add_filter( 'lsx_to_content_path', array( $this, 'content_path' ), 10, 3 ); |
|
40 | 40 | |
41 | - if ( false !== $post_types ) { |
|
42 | - $this->post_types = $post_types; |
|
43 | - add_filter( 'template_include', array( $this, 'post_type_archive_template_include' ), 99 ); |
|
44 | - add_filter( 'template_include', array( $this, 'post_type_single_template_include' ), 99 ); |
|
45 | - add_filter( 'template_include', array( $this, 'search_template_include' ), 99 ); |
|
46 | - } |
|
47 | - if ( false !== $taxonomies ) { |
|
48 | - $this->taxonomies = $taxonomies; |
|
49 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
50 | - } |
|
51 | - } |
|
52 | - } |
|
41 | + if ( false !== $post_types ) { |
|
42 | + $this->post_types = $post_types; |
|
43 | + add_filter( 'template_include', array( $this, 'post_type_archive_template_include' ), 99 ); |
|
44 | + add_filter( 'template_include', array( $this, 'post_type_single_template_include' ), 99 ); |
|
45 | + add_filter( 'template_include', array( $this, 'search_template_include' ), 99 ); |
|
46 | + } |
|
47 | + if ( false !== $taxonomies ) { |
|
48 | + $this->taxonomies = $taxonomies; |
|
49 | + add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
50 | + } |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Redirect wordpress to the archive template located in the plugin |
|
56 | - * |
|
57 | - * @param $template |
|
58 | - * @return $template |
|
59 | - */ |
|
60 | - public function post_type_archive_template_include( $template ) { |
|
61 | - if ( is_main_query() && is_post_type_archive( $this->post_types ) ) { |
|
62 | - $current_post_type = get_post_type(); |
|
63 | - if ( '' == locate_template( array( 'archive-' . $current_post_type . '.php' ) ) && file_exists( $this->plugin_path . 'templates/archive-' . $current_post_type . '.php' ) ) { |
|
64 | - $template = $this->plugin_path . 'templates/archive-' . $current_post_type . '.php'; |
|
65 | - } |
|
66 | - } |
|
67 | - return $template; |
|
68 | - } |
|
69 | - /** |
|
70 | - * Redirect wordpress to the single template located in the plugin |
|
71 | - * |
|
72 | - * @param $template |
|
73 | - * |
|
74 | - * @return $template |
|
75 | - */ |
|
76 | - public function post_type_single_template_include( $template ) { |
|
77 | - if ( is_main_query() && is_singular( $this->post_types ) ) { |
|
78 | - $current_post_type = get_post_type(); |
|
79 | - if ( '' == locate_template( array( 'single-' . $current_post_type . '.php' ) ) && file_exists( $this->plugin_path . 'templates/single-' . $current_post_type . '.php' ) ) { |
|
80 | - $template = $this->plugin_path . 'templates/single-' . $current_post_type . '.php'; |
|
81 | - } |
|
82 | - } |
|
83 | - return $template; |
|
84 | - } |
|
85 | - /** |
|
86 | - * Redirect wordpress to the taxonomy located in the plugin |
|
87 | - * |
|
88 | - * @param $template |
|
89 | - * |
|
90 | - * @return $template |
|
91 | - */ |
|
92 | - public function taxonomy_template_include( $template ) { |
|
54 | + /** |
|
55 | + * Redirect wordpress to the archive template located in the plugin |
|
56 | + * |
|
57 | + * @param $template |
|
58 | + * @return $template |
|
59 | + */ |
|
60 | + public function post_type_archive_template_include( $template ) { |
|
61 | + if ( is_main_query() && is_post_type_archive( $this->post_types ) ) { |
|
62 | + $current_post_type = get_post_type(); |
|
63 | + if ( '' == locate_template( array( 'archive-' . $current_post_type . '.php' ) ) && file_exists( $this->plugin_path . 'templates/archive-' . $current_post_type . '.php' ) ) { |
|
64 | + $template = $this->plugin_path . 'templates/archive-' . $current_post_type . '.php'; |
|
65 | + } |
|
66 | + } |
|
67 | + return $template; |
|
68 | + } |
|
69 | + /** |
|
70 | + * Redirect wordpress to the single template located in the plugin |
|
71 | + * |
|
72 | + * @param $template |
|
73 | + * |
|
74 | + * @return $template |
|
75 | + */ |
|
76 | + public function post_type_single_template_include( $template ) { |
|
77 | + if ( is_main_query() && is_singular( $this->post_types ) ) { |
|
78 | + $current_post_type = get_post_type(); |
|
79 | + if ( '' == locate_template( array( 'single-' . $current_post_type . '.php' ) ) && file_exists( $this->plugin_path . 'templates/single-' . $current_post_type . '.php' ) ) { |
|
80 | + $template = $this->plugin_path . 'templates/single-' . $current_post_type . '.php'; |
|
81 | + } |
|
82 | + } |
|
83 | + return $template; |
|
84 | + } |
|
85 | + /** |
|
86 | + * Redirect wordpress to the taxonomy located in the plugin |
|
87 | + * |
|
88 | + * @param $template |
|
89 | + * |
|
90 | + * @return $template |
|
91 | + */ |
|
92 | + public function taxonomy_template_include( $template ) { |
|
93 | 93 | |
94 | - if ( is_main_query() && is_tax( $this->taxonomies ) ) { |
|
95 | - $current_taxonomy = get_query_var( 'taxonomy' ); |
|
96 | - if ( '' == locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
97 | - $template = $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
|
98 | - } |
|
99 | - } |
|
100 | - return $template; |
|
101 | - } |
|
94 | + if ( is_main_query() && is_tax( $this->taxonomies ) ) { |
|
95 | + $current_taxonomy = get_query_var( 'taxonomy' ); |
|
96 | + if ( '' == locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
97 | + $template = $this->plugin_path . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
|
98 | + } |
|
99 | + } |
|
100 | + return $template; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Redirect wordpress to the search template located in the plugin |
|
105 | - * |
|
106 | - * @param $template |
|
107 | - * |
|
108 | - * @return $template |
|
109 | - */ |
|
110 | - public function search_template_include( $template ) { |
|
111 | - if ( is_main_query() && is_search() ) { |
|
112 | - if ( file_exists( $this->plugin_path . 'templates/search.php' ) ) { |
|
113 | - $template = $this->plugin_path . 'templates/search.php'; |
|
114 | - } |
|
115 | - } |
|
116 | - return $template; |
|
117 | - } |
|
103 | + /** |
|
104 | + * Redirect wordpress to the search template located in the plugin |
|
105 | + * |
|
106 | + * @param $template |
|
107 | + * |
|
108 | + * @return $template |
|
109 | + */ |
|
110 | + public function search_template_include( $template ) { |
|
111 | + if ( is_main_query() && is_search() ) { |
|
112 | + if ( file_exists( $this->plugin_path . 'templates/search.php' ) ) { |
|
113 | + $template = $this->plugin_path . 'templates/search.php'; |
|
114 | + } |
|
115 | + } |
|
116 | + return $template; |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Redirect wordpress to the single template located in the plugin |
|
121 | - * |
|
122 | - * @param $template |
|
123 | - * |
|
124 | - * @return $template |
|
125 | - */ |
|
126 | - public function content_part( $slug, $name = null ) { |
|
127 | - $template = array(); |
|
128 | - $name = (string) $name; |
|
129 | - if ( '' !== $name ) { |
|
130 | - $template = "{$slug}-{$name}.php"; |
|
131 | - } else { |
|
132 | - $template = "{$slug}.php"; |
|
133 | - } |
|
134 | - $original_name = $template; |
|
135 | - $path = apply_filters( 'lsx_to_content_path', '', get_post_type() ); |
|
119 | + /** |
|
120 | + * Redirect wordpress to the single template located in the plugin |
|
121 | + * |
|
122 | + * @param $template |
|
123 | + * |
|
124 | + * @return $template |
|
125 | + */ |
|
126 | + public function content_part( $slug, $name = null ) { |
|
127 | + $template = array(); |
|
128 | + $name = (string) $name; |
|
129 | + if ( '' !== $name ) { |
|
130 | + $template = "{$slug}-{$name}.php"; |
|
131 | + } else { |
|
132 | + $template = "{$slug}.php"; |
|
133 | + } |
|
134 | + $original_name = $template; |
|
135 | + $path = apply_filters( 'lsx_to_content_path', '', get_post_type() ); |
|
136 | 136 | |
137 | - if ( '' == locate_template( array( $template ) ) && file_exists( $path . 'templates/' . $template ) ) { |
|
138 | - $template = $path . 'templates/' . $template; |
|
139 | - } elseif ( file_exists( get_stylesheet_directory() . '/' . $template ) ) { |
|
140 | - $template = get_stylesheet_directory() . '/' . $template; |
|
141 | - } else { |
|
142 | - $template = false; |
|
143 | - } |
|
144 | - if ( false !== $template ) { |
|
145 | - load_template( $template, false ); |
|
146 | - } else { |
|
147 | - echo wp_kses_post( '<p>No ' . $original_name . ' can be found.</p>' ); |
|
148 | - } |
|
149 | - } |
|
137 | + if ( '' == locate_template( array( $template ) ) && file_exists( $path . 'templates/' . $template ) ) { |
|
138 | + $template = $path . 'templates/' . $template; |
|
139 | + } elseif ( file_exists( get_stylesheet_directory() . '/' . $template ) ) { |
|
140 | + $template = get_stylesheet_directory() . '/' . $template; |
|
141 | + } else { |
|
142 | + $template = false; |
|
143 | + } |
|
144 | + if ( false !== $template ) { |
|
145 | + load_template( $template, false ); |
|
146 | + } else { |
|
147 | + echo wp_kses_post( '<p>No ' . $original_name . ' can be found.</p>' ); |
|
148 | + } |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * Redirect wordpress to the widget template located in the plugin |
|
153 | - * |
|
154 | - * @param $path |
|
155 | - * @param $post_type |
|
156 | - * |
|
157 | - * @return $path |
|
158 | - */ |
|
159 | - public function widget_path( $path, $slug ) { |
|
160 | - if ( ( false !== $this->post_types && in_array( $slug, $this->post_types ) ) |
|
161 | - || ( false !== $this->taxonomies && in_array( $slug, $this->taxonomies ) ) || 'post' === $slug ) { |
|
162 | - $path = $this->plugin_path; |
|
163 | - } |
|
164 | - return $path; |
|
165 | - } |
|
151 | + /** |
|
152 | + * Redirect wordpress to the widget template located in the plugin |
|
153 | + * |
|
154 | + * @param $path |
|
155 | + * @param $post_type |
|
156 | + * |
|
157 | + * @return $path |
|
158 | + */ |
|
159 | + public function widget_path( $path, $slug ) { |
|
160 | + if ( ( false !== $this->post_types && in_array( $slug, $this->post_types ) ) |
|
161 | + || ( false !== $this->taxonomies && in_array( $slug, $this->taxonomies ) ) || 'post' === $slug ) { |
|
162 | + $path = $this->plugin_path; |
|
163 | + } |
|
164 | + return $path; |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * Redirect wordpress to the single template located in the plugin |
|
169 | - * |
|
170 | - * @param $path |
|
171 | - * @param $post_type |
|
172 | - * |
|
173 | - * @return $path |
|
174 | - */ |
|
175 | - public function content_path( $path, $slug ) { |
|
176 | - if ( ( false !== $this->post_types && in_array( $slug, $this->post_types ) ) |
|
177 | - || ( false !== $this->taxonomies && in_array( $slug, $this->taxonomies ) ) || 'post' === $slug ) { |
|
178 | - $path = $this->plugin_path; |
|
179 | - } |
|
180 | - return $path; |
|
181 | - } |
|
167 | + /** |
|
168 | + * Redirect wordpress to the single template located in the plugin |
|
169 | + * |
|
170 | + * @param $path |
|
171 | + * @param $post_type |
|
172 | + * |
|
173 | + * @return $path |
|
174 | + */ |
|
175 | + public function content_path( $path, $slug ) { |
|
176 | + if ( ( false !== $this->post_types && in_array( $slug, $this->post_types ) ) |
|
177 | + || ( false !== $this->taxonomies && in_array( $slug, $this->taxonomies ) ) || 'post' === $slug ) { |
|
178 | + $path = $this->plugin_path; |
|
179 | + } |
|
180 | + return $path; |
|
181 | + } |
|
182 | 182 | } |
@@ -10,50 +10,50 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | $post_type = array( |
13 | - 'class' => 'LSX_TO_Team', |
|
14 | - 'menu_icon' => 'dashicons-id-alt', |
|
15 | - 'labels' => array( |
|
16 | - 'name' => esc_html__( 'Team', 'to-team' ), |
|
17 | - 'singular_name' => esc_html__( 'Team Member', 'to-team' ), |
|
18 | - 'add_new' => esc_html__( 'Add New', 'to-team' ), |
|
19 | - 'add_new_item' => esc_html__( 'Add New Team Member', 'to-team' ), |
|
20 | - 'edit_item' => esc_html__( 'Edit', 'to-team' ), |
|
21 | - 'new_item' => esc_html__( 'New', 'to-team' ), |
|
22 | - 'all_items' => esc_html__( 'Team', 'to-team' ), |
|
23 | - 'view_item' => esc_html__( 'View', 'to-team' ), |
|
24 | - 'search_items' => esc_html__( 'Search the Team', 'to-team' ), |
|
25 | - 'not_found' => esc_html__( 'No team member found', 'to-team' ), |
|
26 | - 'not_found_in_trash' => esc_html__( 'No team member found in Trash', 'to-team' ), |
|
27 | - 'parent_item_colon' => '', |
|
28 | - 'menu_name' => esc_html__( 'Team', 'lsx-team' ), |
|
29 | - 'featured_image' => esc_html__( 'Profile Picture', 'to-team' ), |
|
30 | - 'set_featured_image' => esc_html__( 'Set Profile Picture', 'to-team' ), |
|
31 | - 'remove_featured_image' => esc_html__( 'Remove profile picture', 'to-team' ), |
|
32 | - 'use_featured_image' => esc_html__( 'Use as profile picture', 'to-team' ), |
|
33 | - ), |
|
34 | - 'public' => true, |
|
35 | - 'publicly_queryable' => true, |
|
36 | - 'show_ui' => true, |
|
37 | - 'show_in_menu' => 'tour-operator', |
|
38 | - 'menu_position' => 75, |
|
39 | - 'query_var' => true, |
|
40 | - 'rewrite' => array( |
|
41 | - 'slug' => 'team', |
|
42 | - 'with_front' => false, |
|
43 | - ), |
|
44 | - 'exclude_from_search' => false, |
|
45 | - 'capability_type' => 'post', |
|
46 | - 'has_archive' => 'team', |
|
47 | - 'hierarchical' => false, |
|
48 | - 'show_in_rest' => true, |
|
49 | - 'supports' => array( |
|
50 | - 'title', |
|
51 | - 'slug', |
|
52 | - 'editor', |
|
53 | - 'thumbnail', |
|
54 | - 'excerpt', |
|
55 | - 'custom-fields', |
|
56 | - ), |
|
13 | + 'class' => 'LSX_TO_Team', |
|
14 | + 'menu_icon' => 'dashicons-id-alt', |
|
15 | + 'labels' => array( |
|
16 | + 'name' => esc_html__( 'Team', 'to-team' ), |
|
17 | + 'singular_name' => esc_html__( 'Team Member', 'to-team' ), |
|
18 | + 'add_new' => esc_html__( 'Add New', 'to-team' ), |
|
19 | + 'add_new_item' => esc_html__( 'Add New Team Member', 'to-team' ), |
|
20 | + 'edit_item' => esc_html__( 'Edit', 'to-team' ), |
|
21 | + 'new_item' => esc_html__( 'New', 'to-team' ), |
|
22 | + 'all_items' => esc_html__( 'Team', 'to-team' ), |
|
23 | + 'view_item' => esc_html__( 'View', 'to-team' ), |
|
24 | + 'search_items' => esc_html__( 'Search the Team', 'to-team' ), |
|
25 | + 'not_found' => esc_html__( 'No team member found', 'to-team' ), |
|
26 | + 'not_found_in_trash' => esc_html__( 'No team member found in Trash', 'to-team' ), |
|
27 | + 'parent_item_colon' => '', |
|
28 | + 'menu_name' => esc_html__( 'Team', 'lsx-team' ), |
|
29 | + 'featured_image' => esc_html__( 'Profile Picture', 'to-team' ), |
|
30 | + 'set_featured_image' => esc_html__( 'Set Profile Picture', 'to-team' ), |
|
31 | + 'remove_featured_image' => esc_html__( 'Remove profile picture', 'to-team' ), |
|
32 | + 'use_featured_image' => esc_html__( 'Use as profile picture', 'to-team' ), |
|
33 | + ), |
|
34 | + 'public' => true, |
|
35 | + 'publicly_queryable' => true, |
|
36 | + 'show_ui' => true, |
|
37 | + 'show_in_menu' => 'tour-operator', |
|
38 | + 'menu_position' => 75, |
|
39 | + 'query_var' => true, |
|
40 | + 'rewrite' => array( |
|
41 | + 'slug' => 'team', |
|
42 | + 'with_front' => false, |
|
43 | + ), |
|
44 | + 'exclude_from_search' => false, |
|
45 | + 'capability_type' => 'post', |
|
46 | + 'has_archive' => 'team', |
|
47 | + 'hierarchical' => false, |
|
48 | + 'show_in_rest' => true, |
|
49 | + 'supports' => array( |
|
50 | + 'title', |
|
51 | + 'slug', |
|
52 | + 'editor', |
|
53 | + 'thumbnail', |
|
54 | + 'excerpt', |
|
55 | + 'custom-fields', |
|
56 | + ), |
|
57 | 57 | ); |
58 | 58 | |
59 | 59 | return $post_type; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | // If this file is called directly, abort. |
16 | 16 | if ( ! defined( 'WPINC' ) ) { |
17 | - die; |
|
17 | + die; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | define( 'LSX_TO_TEAM_PATH', plugin_dir_path( __FILE__ ) ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | define( 'LSX_TO_TEAM_VER', '1.2.3' ); |
24 | 24 | |
25 | 25 | if ( ! defined( 'TEAM_ARCHIVE_URL' ) ) { |
26 | - define( 'TEAM_ARCHIVE_URL', 'team-members' ); |
|
26 | + define( 'TEAM_ARCHIVE_URL', 'team-members' ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /* ======================= Below is the Plugin Class init ========================= */ |