1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Template Tags |
4
|
|
|
* |
5
|
|
|
* @package tour-operator |
6
|
|
|
* @license GPL-3.0+ |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Outputs the posts attached special |
11
|
|
|
* |
12
|
|
|
* @package to-specials |
|
|
|
|
13
|
|
|
* @subpackage template-tags |
|
|
|
|
14
|
|
|
* @category special |
|
|
|
|
15
|
|
|
*/ |
16
|
|
|
if ( ! function_exists( 'lsx_to_special_posts' ) ) { |
|
|
|
|
17
|
|
|
function lsx_to_special_posts() { |
|
|
|
|
18
|
|
|
global $lsx_to_archive; |
19
|
|
|
|
20
|
|
|
$args = array( |
21
|
|
|
'from' => 'post', |
|
|
|
|
22
|
|
|
'to' => 'special', |
|
|
|
|
23
|
|
|
'column' => '3', |
|
|
|
|
24
|
|
|
'before' => '<section id="posts" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-posts">' . esc_html__( 'Featured Posts', 'to-specials' ) . '</h2><div id="collapse-posts" class="collapse in"><div class="collapse-inner">', |
|
|
|
|
25
|
|
|
'after' => '</div></div></section>', |
|
|
|
|
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
lsx_to_connected_panel_query( $args ); |
29
|
|
|
} |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
|
|
|
|
33
|
|
|
* Find the content part in the plugin. |
34
|
|
|
* |
35
|
|
|
* @package tour-operator |
36
|
|
|
* @subpackage template-tag |
37
|
|
|
* @category to-specials |
38
|
|
|
*/ |
39
|
|
|
function lsx_to_special_content( $slug, $name = null ) { |
|
|
|
|
40
|
|
|
do_action( 'lsx_special_content', $slug, $name ); |
41
|
|
|
} |
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
|
|
|
|
44
|
|
|
* Outputs the terms and conditions. |
45
|
|
|
* |
46
|
|
|
* @param $before | string |
|
|
|
|
47
|
|
|
* @param $after | string |
|
|
|
|
48
|
|
|
* @param $echo | boolean |
|
|
|
|
49
|
|
|
* @return string |
|
|
|
|
50
|
|
|
* |
51
|
|
|
* @package tour-operator |
52
|
|
|
* @subpackage template-tag |
53
|
|
|
* @category to-specials |
54
|
|
|
*/ |
55
|
|
|
function lsx_to_specials_terms_conditions( $before = '', $after = '', $echo = true ) { |
56
|
|
|
lsx_to_custom_field_query( 'terms_conditions', $before, $after, $echo ); |
57
|
|
|
} |
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
|
|
|
|
60
|
|
|
* Outputs the travel dates. |
61
|
|
|
* |
62
|
|
|
* @param $before | string |
|
|
|
|
63
|
|
|
* @param $after | string |
|
|
|
|
64
|
|
|
* @param $echo | boolean |
|
|
|
|
65
|
|
|
* @return string |
66
|
|
|
* |
67
|
|
|
* @package tour-operator |
68
|
|
|
* @subpackage template-tag |
69
|
|
|
* @category to-specials |
70
|
|
|
*/ |
71
|
|
|
function lsx_to_travel_dates( $before = '', $after = '', $echo = true ) { |
72
|
|
|
// --- START: [legacy] migrate content from old fields to new repeatable fields (grouped fields) |
73
|
|
|
|
74
|
|
|
$start = get_post_meta( get_the_ID(), 'travel_dates_start', true ); |
|
|
|
|
75
|
|
|
$end = get_post_meta( get_the_ID(), 'travel_dates_end', true ); |
|
|
|
|
76
|
|
|
|
77
|
|
|
if ( ! empty( $start ) && ! empty( $end ) ) { |
|
|
|
|
78
|
|
|
$start = date( 'M j, Y', strtotime( $start ) ); |
|
|
|
|
79
|
|
|
$end = date( 'M j, Y', strtotime( $end ) ); |
|
|
|
|
80
|
|
|
|
81
|
|
|
$new_field = array( |
82
|
|
|
'travel_dates_start' => $start, |
83
|
|
|
'travel_dates_end' => $end, |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
delete_post_meta( get_the_ID(), 'travel_dates' ); |
|
|
|
|
87
|
|
|
update_post_meta( get_the_ID(), 'travel_dates', $new_field ); |
|
|
|
|
88
|
|
|
|
89
|
|
|
delete_post_meta( get_the_ID(), 'travel_dates_start' ); |
90
|
|
|
delete_post_meta( get_the_ID(), 'travel_dates_end' ); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
// --- END: [legacy] migrate content from old fields to new repeatable fields (grouped fields) |
94
|
|
|
|
95
|
|
|
$return = ''; |
|
|
|
|
96
|
|
|
$multiple = false; |
97
|
|
|
$dates = get_post_meta( get_the_ID(), 'travel_dates', false ); |
|
|
|
|
98
|
|
|
|
99
|
|
|
if ( is_array( $dates ) && ! empty( $dates ) ) { |
|
|
|
|
100
|
|
|
foreach ( $dates as $key => $value ) { |
|
|
|
|
101
|
|
|
$start = false; |
102
|
|
|
$end = false; |
|
|
|
|
103
|
|
|
|
104
|
|
|
if ( isset( $value['travel_dates_start'] ) ) { |
|
|
|
|
105
|
|
|
$start = $value['travel_dates_start']; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
if ( isset( $value['travel_dates_end'] ) ) { |
|
|
|
|
109
|
|
|
$end = $value['travel_dates_end']; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
if ( ! empty( $start ) ) { |
|
|
|
|
113
|
|
|
$start = date( 'd M Y', strtotime( $start ) ); |
|
|
|
|
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
if ( ! empty( $end ) ) { |
|
|
|
|
117
|
|
|
$start .= ' - ' . date( 'd M Y', strtotime( $end ) ); |
|
|
|
|
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
if ( ! empty( $start ) ) { |
|
|
|
|
121
|
|
|
if ( ! empty( $return ) ) { |
|
|
|
|
122
|
|
|
$multiple = true; |
123
|
|
|
$return .= '<br>'; |
|
|
|
|
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
$return .= $start; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
if ( ! empty( $return ) ) { |
|
|
|
|
132
|
|
|
if ( true === $multiple ) { |
|
|
|
|
133
|
|
|
$return = '<br>' . $return; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
$return = $before . $return . $after; |
137
|
|
|
|
138
|
|
|
if ( $echo ) { |
|
|
|
|
139
|
|
|
echo wp_kses_post( $return ); |
140
|
|
|
} else { |
141
|
|
|
return $return; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
} |
|
|
|
|
145
|
|
|
|
146
|
|
|
/** |
|
|
|
|
147
|
|
|
* Outputs the specials validity. |
148
|
|
|
* |
149
|
|
|
* @param $before | string |
|
|
|
|
150
|
|
|
* @param $after | string |
|
|
|
|
151
|
|
|
* @param $echo | boolean |
|
|
|
|
152
|
|
|
* @return string |
153
|
|
|
* |
154
|
|
|
* @package tour-operator |
155
|
|
|
* @subpackage template-tag |
156
|
|
|
* @category to-specials |
157
|
|
|
*/ |
158
|
|
|
function lsx_to_specials_validity( $before = '', $after = '', $echo = true ) { |
159
|
|
|
// $valid_from = get_the_date( 'M j, Y', get_the_ID() ); |
|
|
|
|
160
|
|
|
// $valid_to = get_post_meta( get_the_ID(), '_expiration-date', true ); |
161
|
|
|
|
162
|
|
|
$valid_from = get_post_meta( get_the_ID(), 'booking_validity_start', true ); |
|
|
|
|
163
|
|
|
$valid_to = get_post_meta( get_the_ID(), 'booking_validity_end', true ); |
|
|
|
|
164
|
|
|
|
165
|
|
|
if ( ! empty( $valid_from ) ) { |
|
|
|
|
166
|
|
|
$valid_from = date( 'd M Y', strtotime( $valid_from ) ); |
|
|
|
|
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
if ( ! empty( $valid_to ) ) { |
|
|
|
|
170
|
|
|
$valid_from .= ' - ' . date( 'd M Y', strtotime( $valid_to ) ); |
|
|
|
|
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
if ( ! empty( $valid_from ) ) { |
|
|
|
|
174
|
|
|
$return = $before . $valid_from . $after; |
175
|
|
|
|
176
|
|
|
if ( $echo ) { |
|
|
|
|
177
|
|
|
echo wp_kses_post( $return ); |
178
|
|
|
} else { |
179
|
|
|
return $return; |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
} |
|
|
|
|
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* Outputs the connected specials for an accommodation |
186
|
|
|
* |
187
|
|
|
* @package lsx-tour-operators |
|
|
|
|
188
|
|
|
* @subpackage template-tags |
|
|
|
|
189
|
|
|
* @category special |
|
|
|
|
190
|
|
|
*/ |
191
|
|
|
function lsx_to_accommodation_specials() { |
192
|
|
|
global $lsx_archive; |
193
|
|
|
|
194
|
|
|
if ( post_type_exists( 'special' ) && is_singular( 'accommodation' ) ) { |
|
|
|
|
195
|
|
|
$args = array( |
196
|
|
|
'from' => 'special', |
|
|
|
|
197
|
|
|
'to' => 'accommodation', |
|
|
|
|
198
|
|
|
'column' => '3', |
|
|
|
|
199
|
|
|
'before' => '<section id="special" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
|
|
|
200
|
|
|
'after' => '</div></div></section>', |
|
|
|
|
201
|
|
|
); |
202
|
|
|
|
203
|
|
|
lsx_to_connected_panel_query( $args ); |
204
|
|
|
} |
205
|
|
|
} |
|
|
|
|
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Outputs the connected specials for a tour |
209
|
|
|
* |
210
|
|
|
* @package lsx-tour-operators |
|
|
|
|
211
|
|
|
* @subpackage template-tags |
|
|
|
|
212
|
|
|
* @category special |
|
|
|
|
213
|
|
|
*/ |
214
|
|
|
function lsx_to_tour_specials() { |
215
|
|
|
global $lsx_archive; |
216
|
|
|
|
217
|
|
|
if ( post_type_exists( 'special' ) && is_singular( 'tour' ) ) { |
|
|
|
|
218
|
|
|
$args = array( |
219
|
|
|
'from' => 'special', |
|
|
|
|
220
|
|
|
'to' => 'tour', |
|
|
|
|
221
|
|
|
'column' => '3', |
|
|
|
|
222
|
|
|
'before' => '<section id="special" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
|
|
|
223
|
|
|
'after' => '</div></div></section>', |
|
|
|
|
224
|
|
|
); |
225
|
|
|
|
226
|
|
|
lsx_to_connected_panel_query( $args ); |
227
|
|
|
} |
228
|
|
|
} |
|
|
|
|
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* Outputs the connected specials for a destination |
232
|
|
|
* |
233
|
|
|
* @package lsx-tour-operators |
|
|
|
|
234
|
|
|
* @subpackage template-tags |
|
|
|
|
235
|
|
|
* @category special |
|
|
|
|
236
|
|
|
*/ |
237
|
|
|
function lsx_to_destination_specials() { |
238
|
|
|
global $lsx_archive; |
239
|
|
|
|
240
|
|
|
if ( post_type_exists( 'special' ) && is_singular( 'destination' ) ) { |
|
|
|
|
241
|
|
|
$args = array( |
242
|
|
|
'from' => 'special', |
|
|
|
|
243
|
|
|
'to' => 'destination', |
|
|
|
|
244
|
|
|
'column' => '3', |
|
|
|
|
245
|
|
|
'before' => '<section id="special" class="lsx-to-section lsx-to-collapse-section"><h2 class="lsx-to-section-title lsx-to-collapse-title lsx-title" data-toggle="collapse" data-target="#collapse-special">' . __( lsx_to_get_post_type_section_title( 'special', '', 'Featured Specials' ), 'to-specials' ) . '</h2><div id="collapse-special" class="collapse in"><div class="collapse-inner">', |
|
|
|
|
246
|
|
|
'after' => '</div></div></section>', |
|
|
|
|
247
|
|
|
); |
248
|
|
|
|
249
|
|
|
lsx_to_connected_panel_query( $args ); |
250
|
|
|
} |
251
|
|
|
} |
|
|
|
|
252
|
|
|
|