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
|
|
|
*/ |
|
|
|
|
18
|
|
|
|
19
|
|
|
class LSX_TO_Specials_Admin extends LSX_TO_Specials { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Constructor |
23
|
|
|
*/ |
24
|
|
|
public function __construct() { |
|
|
|
|
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
|
|
|
} |
|
|
|
|
41
|
|
|
/** |
|
|
|
|
42
|
|
|
* Register the specials post type config |
43
|
|
|
* |
44
|
|
|
* @param $objects |
|
|
|
|
45
|
|
|
* @return array |
46
|
|
|
*/ |
47
|
|
|
public function post_type_config( $objects ) { |
|
|
|
|
48
|
|
|
|
49
|
|
|
foreach ( $this->post_types as $key => $label ) { |
|
|
|
|
50
|
|
|
if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php' ) ) { |
|
|
|
|
51
|
|
|
$objects[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/post-types/config-' . $key . '.php'; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $objects; |
|
|
|
|
56
|
|
|
} |
|
|
|
|
57
|
|
|
|
58
|
|
|
/** |
|
|
|
|
59
|
|
|
* Register the activity metabox config |
60
|
|
|
* |
61
|
|
|
* @param $meta_boxes |
|
|
|
|
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
|
|
public function meta_box_config( $meta_boxes ) { |
65
|
|
|
foreach ( $this->post_types as $key => $label ) { |
|
|
|
|
66
|
|
|
if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php' ) ) { |
|
|
|
|
67
|
|
|
$meta_boxes[ $key ] = include LSX_TO_SPECIALS_PATH . 'includes/metaboxes/config-' . $key . '.php'; |
68
|
|
|
} |
69
|
|
|
} |
|
|
|
|
70
|
|
|
return $meta_boxes; |
|
|
|
|
71
|
|
|
} |
|
|
|
|
72
|
|
|
|
73
|
|
|
/** |
|
|
|
|
74
|
|
|
* Register the Role taxonomy |
75
|
|
|
* |
76
|
|
|
* |
77
|
|
|
* @return null |
|
|
|
|
78
|
|
|
*/ |
79
|
|
|
public function taxonomy_config( $taxonomies ) { |
|
|
|
|
80
|
|
|
|
81
|
|
|
if ( file_exists( LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php' ) ) { |
|
|
|
|
82
|
|
|
$taxonomies['special-type'] = include LSX_TO_SPECIALS_PATH . 'includes/taxonomies/config-special-type.php'; |
83
|
|
|
} |
|
|
|
|
84
|
|
|
return $taxonomies; |
|
|
|
|
85
|
|
|
} |
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Register the global post types. |
89
|
|
|
* |
90
|
|
|
* |
91
|
|
|
* @return null |
|
|
|
|
92
|
|
|
*/ |
93
|
|
|
public function register_taxonomies() { |
|
|
|
|
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' ), |
|
|
|
|
99
|
|
|
'all_items' => __( 'Special Types' , 'to-specials' ), |
|
|
|
|
100
|
|
|
'parent_item' => __( 'Parent Special Type' , 'to-specials' ), |
|
|
|
|
101
|
|
|
'parent_item_colon' => __( 'Parent Special Type:' , 'to-specials' ), |
|
|
|
|
102
|
|
|
'edit_item' => __( 'Edit Special Type' , 'to-specials' ), |
|
|
|
|
103
|
|
|
'update_item' => __( 'Update Special Type' , 'to-specials' ), |
|
|
|
|
104
|
|
|
'add_new_item' => __( 'Add New Special Type' , 'to-specials' ), |
|
|
|
|
105
|
|
|
'new_item_name' => __( 'New Special Type' , 'to-specials' ), |
|
|
|
|
106
|
|
|
'menu_name' => __( 'Special Types' , 'to-specials' ), |
|
|
|
|
107
|
|
|
); |
108
|
|
|
|
109
|
|
|
// Now register the taxonomy |
|
|
|
|
110
|
|
|
register_taxonomy('special-type',$this->plugin_slug, array( |
|
|
|
|
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
|
|
|
)); |
|
|
|
|
121
|
|
|
|
122
|
|
|
} |
|
|
|
|
123
|
|
|
|
124
|
|
|
/** |
|
|
|
|
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 ) { |
|
|
|
|
132
|
|
|
$post_type = $post->post_type; |
133
|
|
|
} elseif ( $typenow ) { |
|
|
|
|
134
|
|
|
$post_type = $typenow; |
135
|
|
|
} elseif ( $current_screen && $current_screen->post_type ) { |
|
|
|
|
136
|
|
|
$post_type = $current_screen->post_type; |
137
|
|
|
} elseif ( isset( $_REQUEST['post_type'] ) ) { |
|
|
|
|
138
|
|
|
$post_type = sanitize_key( $_REQUEST['post_type'] ); |
|
|
|
|
139
|
|
|
} elseif ( isset( $_REQUEST['post'] ) ) { |
|
|
|
|
140
|
|
|
$post_type = get_post_type( sanitize_key( $_REQUEST['post'] ) ); |
|
|
|
|
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
if ( false !== $post_type ) { |
|
|
|
|
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
|
|
|
} |
|
|
|
|
167
|
|
|
return $fields; |
168
|
|
|
} |
|
|
|
|
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
|
|
|
} |
|
|
|
|
199
|
|
|
} |
200
|
|
|
new LSX_TO_Specials_Admin(); |
201
|
|
|
|