1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* Plugin general functions
|
4
|
|
|
*
|
5
|
|
|
* @since 1.0.0
|
6
|
|
|
* @package GeoDirectory
|
7
|
|
|
*/
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
/**
|
11
|
|
|
* Get All Plugin functions from WordPress
|
12
|
|
|
*/
|
13
|
|
|
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
14
|
|
|
|
15
|
|
|
/*-----------------------------------------------------------------------------------*/
|
16
|
|
|
/* Helper functions */
|
17
|
|
|
/*-----------------------------------------------------------------------------------*/
|
18
|
|
|
|
19
|
|
|
/**
|
20
|
|
|
* Return the plugin url.
|
21
|
|
|
*
|
22
|
|
|
* Return the plugin folder url WITHOUT TRAILING SLASH.
|
23
|
|
|
*
|
24
|
|
|
* @since 1.0.0
|
25
|
|
|
* @package GeoDirectory
|
26
|
|
|
* @return string example url eg: http://wpgeo.directory/wp-content/plugins/geodirectory
|
27
|
|
|
*/
|
28
|
|
|
function geodir_plugin_url() {
|
29
|
|
|
|
30
|
|
|
if ( is_ssl() ) :
|
31
|
21 |
|
return str_replace( 'http://', 'https://', WP_PLUGIN_URL ) . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) );
|
32
|
|
|
else :
|
33
|
|
|
return WP_PLUGIN_URL . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) );
|
34
|
21 |
|
endif;
|
35
|
|
|
}
|
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/**
|
39
|
|
|
* Return the plugin path.
|
40
|
|
|
*
|
41
|
|
|
* Return the plugin folder path WITHOUT TRAILING SLASH.
|
42
|
|
|
*
|
43
|
|
|
* @since 1.0.0
|
44
|
|
|
* @package GeoDirectory
|
45
|
|
|
* @return string example url eg: /home/geo/public_html/wp-content/plugins/geodirectory
|
46
|
|
|
*/
|
47
|
|
|
function geodir_plugin_path() {
|
48
|
|
|
if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
|
49
|
|
|
return dirname( dirname( __FILE__ ) );
|
50
|
34 |
|
} else {
|
51
|
34 |
|
return WP_PLUGIN_DIR . "/" . plugin_basename( dirname( dirname( __FILE__ ) ) );
|
52
|
|
|
}
|
53
|
|
|
}
|
54
|
|
|
|
55
|
|
|
/**
|
56
|
|
|
* Check if a GeoDirectory addon plugin is active.
|
57
|
|
|
*
|
58
|
|
|
* @since 1.0.0
|
59
|
|
|
* @package GeoDirectory
|
60
|
|
|
*
|
61
|
|
|
* @param string $plugin plugin uri.
|
62
|
|
|
*
|
63
|
|
|
* @return bool true or false.
|
64
|
|
|
* @todo check if this is faster than normal WP check and remove if not.
|
65
|
|
|
*/
|
66
|
|
|
function geodir_is_plugin_active( $plugin ) {
|
67
|
|
|
$active_plugins = get_option( 'active_plugins' );
|
68
|
|
|
foreach ( $active_plugins as $key => $active_plugin ) {
|
69
|
|
|
if ( strstr( $active_plugin, $plugin ) ) {
|
70
|
|
|
return true;
|
71
|
|
|
}
|
72
|
|
|
}
|
73
|
|
|
|
74
|
|
|
return false;
|
75
|
|
|
}
|
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/**
|
79
|
|
|
* Return the formatted date.
|
80
|
|
|
*
|
81
|
|
|
* Return a formatted date from a date/time string according to WordPress date format. $date must be in format : 'Y-m-d
|
82
|
|
|
* H:i:s'.
|
83
|
|
|
*
|
84
|
|
|
* @since 1.0.0
|
85
|
|
|
* @package GeoDirectory
|
86
|
|
|
*
|
87
|
|
|
* @param string $date must be in format: 'Y-m-d H:i:s'.
|
88
|
|
|
*
|
89
|
|
|
* @return bool|int|string the formatted date.
|
90
|
|
|
*/
|
91
|
|
|
function geodir_get_formated_date( $date ) {
|
|
|
|
|
92
|
|
|
return mysql2date( get_option( 'date_format' ), $date );
|
93
|
|
|
}
|
94
|
|
|
|
95
|
|
|
/**
|
96
|
|
|
* Return the formatted time.
|
97
|
|
|
*
|
98
|
|
|
* Return a formatted time from a date/time string according to WordPress time format. $time must be in format : 'Y-m-d
|
99
|
|
|
* H:i:s'.
|
100
|
|
|
*
|
101
|
|
|
* @since 1.0.0
|
102
|
|
|
* @package GeoDirectory
|
103
|
|
|
*
|
104
|
|
|
* @param string $time must be in format: 'Y-m-d H:i:s'.
|
105
|
|
|
*
|
106
|
|
|
* @return bool|int|string the formatted time.
|
107
|
|
|
*/
|
108
|
|
|
function geodir_get_formated_time( $time ) {
|
|
|
|
|
109
|
|
|
return mysql2date( get_option( 'time_format' ), $time, $translate = true );
|
110
|
|
|
}
|
111
|
|
|
|
112
|
|
|
|
113
|
|
|
/**
|
114
|
|
|
* Return a formatted link with parameters.
|
115
|
|
|
*
|
116
|
|
|
* Returns a link with new parameters and currently used parameters regardless of ? or & in the $url parameter.
|
117
|
|
|
*
|
118
|
|
|
* @since 1.0.0
|
119
|
|
|
* @package GeoDirectory
|
120
|
|
|
*
|
121
|
15 |
|
* @param string $url The main url to be used.
|
122
|
15 |
|
* @param array $params The arguments array.
|
123
|
15 |
|
* @param bool $use_existing_arguments Do you want to use existing arguments? Default: false.
|
124
|
15 |
|
*
|
125
|
15 |
|
* @return string Formatted link.
|
126
|
15 |
|
*/
|
127
|
|
|
function geodir_getlink( $url, $params = array(), $use_existing_arguments = false ) {
|
128
|
15 |
|
if ( $use_existing_arguments ) {
|
129
|
15 |
|
$params = $params + $_GET;
|
130
|
15 |
|
}
|
131
|
|
|
if ( ! $params ) {
|
|
|
|
|
132
|
|
|
return $url;
|
133
|
|
|
}
|
134
|
|
|
$link = $url;
|
135
|
15 |
|
if ( strpos( $link, '?' ) === false ) {
|
136
|
|
|
$link .= '?';
|
137
|
15 |
|
} //If there is no '?' add one at the end
|
138
|
15 |
|
elseif ( strpos( $link, '//maps.google.com/maps/api/js?language=' ) ) {
|
139
|
|
|
$link .= '&';
|
140
|
15 |
|
} //If there is no '&' at the END, add one.
|
141
|
|
|
elseif ( ! preg_match( '/(\?|\&(amp;)?)$/', $link ) ) {
|
142
|
|
|
$link .= '&';
|
143
|
|
|
} //If there is no '&' at the END, add one.
|
144
|
|
|
|
145
|
|
|
$params_arr = array();
|
146
|
|
|
foreach ( $params as $key => $value ) {
|
147
|
|
|
if ( gettype( $value ) == 'array' ) { //Handle array data properly
|
148
|
|
|
foreach ( $value as $val ) {
|
149
|
|
|
$params_arr[] = $key . '[]=' . urlencode( $val );
|
150
|
|
|
}
|
151
|
|
|
} else {
|
152
|
|
|
$params_arr[] = $key . '=' . urlencode( $value );
|
153
|
|
|
}
|
154
|
|
|
}
|
155
|
3 |
|
$link .= implode( '&', $params_arr );
|
156
|
|
|
|
157
|
|
|
return $link;
|
158
|
3 |
|
}
|
159
|
3 |
|
|
160
|
|
|
|
161
|
3 |
|
/**
|
162
|
|
|
* Returns add listing page link.
|
163
|
3 |
|
*
|
164
|
|
|
* @since 1.0.0
|
165
|
|
|
* @package GeoDirectory
|
166
|
|
|
* @global object $wpdb WordPress Database object.
|
167
|
|
|
*
|
168
|
|
|
* @param string $post_type The post type.
|
169
|
|
|
*
|
170
|
|
|
* @return string Listing page url if valid. Otherwise home url will be returned.
|
171
|
|
|
*/
|
172
|
|
|
function geodir_get_addlisting_link( $post_type = '' ) {
|
173
|
|
|
global $wpdb;
|
174
|
|
|
|
175
|
|
|
//$check_pkg = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
|
|
|
|
|
176
|
|
|
$check_pkg = 1;
|
177
|
|
|
if ( post_type_exists( $post_type ) && $check_pkg ) {
|
178
|
9 |
|
|
179
|
9 |
|
$add_listing_link = get_page_link( geodir_add_listing_page_id() );
|
180
|
|
|
|
181
|
|
|
return esc_url( add_query_arg( array( 'listing_type' => $post_type ), $add_listing_link ) );
|
182
|
9 |
|
} else {
|
183
|
9 |
|
return get_bloginfo( 'url' );
|
184
|
|
|
}
|
185
|
|
|
}
|
186
|
|
|
|
187
|
|
|
/**
|
188
|
|
|
* Get the current page URL.
|
189
|
|
|
*
|
190
|
9 |
|
* @since 1.0.0
|
191
|
|
|
* @package GeoDirectory
|
192
|
|
|
* @since 1.4.2 Removed the port number from the URL if port 80 is not being used.
|
193
|
|
|
* @return string The current URL.
|
194
|
|
|
*/
|
195
|
|
|
function geodir_curPageURL() {
|
196
|
|
|
$pageURL = 'http';
|
197
|
|
|
if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) {
|
198
|
|
|
$pageURL .= "s";
|
199
|
|
|
}
|
200
|
|
|
$pageURL .= "://";
|
201
|
|
|
$pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
202
|
|
|
|
203
|
|
|
/**
|
204
|
|
|
* Filter the current page URL returned by function geodir_curPageURL().
|
205
|
|
|
*
|
206
|
|
|
* @since 1.4.1
|
207
|
|
|
*
|
208
|
|
|
* @param string $pageURL The URL of the current page.
|
209
|
|
|
*/
|
210
|
|
|
return apply_filters( 'geodir_curPageURL', $pageURL );
|
211
|
|
|
}
|
212
|
|
|
|
213
|
|
|
|
214
|
|
|
/**
|
215
|
|
|
* Clean variables.
|
216
|
|
|
*
|
217
|
|
|
* This function is used to create posttype, posts, taxonomy and terms slug.
|
218
|
|
|
*
|
219
|
|
|
* @since 1.0.0
|
220
|
|
|
* @package GeoDirectory
|
221
|
|
|
*
|
222
|
|
|
* @param string $string The variable to clean.
|
223
|
|
|
*
|
224
|
|
|
* @return string Cleaned variable.
|
225
|
|
|
*/
|
226
|
|
|
function geodir_clean( $string ) {
|
227
|
|
|
|
228
|
|
|
$string = trim( strip_tags( stripslashes( $string ) ) );
|
229
|
|
|
$string = str_replace( " ", "-", $string ); // Replaces all spaces with hyphens.
|
230
|
|
|
$string = preg_replace( '/[^A-Za-z0-9\-\_]/', '', $string ); // Removes special chars.
|
231
|
|
|
$string = preg_replace( '/-+/', '-', $string ); // Replaces multiple hyphens with single one.
|
232
|
|
|
|
233
|
|
|
return $string;
|
234
|
|
|
}
|
235
|
|
|
|
236
|
|
|
/**
|
237
|
|
|
* Get Week Days list.
|
238
|
|
|
*
|
239
|
|
|
* @since 1.0.0
|
240
|
|
|
* @package GeoDirectory
|
241
|
|
|
* @return array Week days.
|
242
|
|
|
*/
|
243
|
|
|
function geodir_get_weekday() {
|
244
|
|
|
return array(
|
245
|
|
|
__( 'Sunday', 'geodirectory' ),
|
246
|
|
|
__( 'Monday', 'geodirectory' ),
|
247
|
|
|
__( 'Tuesday', 'geodirectory' ),
|
248
|
|
|
__( 'Wednesday', 'geodirectory' ),
|
249
|
|
|
__( 'Thursday', 'geodirectory' ),
|
250
|
|
|
__( 'Friday', 'geodirectory' ),
|
251
|
|
|
__( 'Saturday', 'geodirectory' )
|
252
|
|
|
);
|
253
|
|
|
}
|
254
|
|
|
|
255
|
28 |
|
/**
|
256
|
|
|
* Get Weeks lists.
|
257
|
|
|
*
|
258
|
|
|
* @since 1.0.0
|
259
|
28 |
|
* @package GeoDirectory
|
260
|
|
|
* @return array Weeks.
|
261
|
25 |
|
*/
|
262
|
1 |
|
function geodir_get_weeks() {
|
263
|
24 |
|
return array(
|
264
|
|
|
__( 'First', 'geodirectory' ),
|
265
|
|
|
__( 'Second', 'geodirectory' ),
|
266
|
|
|
__( 'Third', 'geodirectory' ),
|
267
|
24 |
|
__( 'Fourth', 'geodirectory' ),
|
268
|
27 |
|
__( 'Last', 'geodirectory' )
|
269
|
22 |
|
);
|
270
|
22 |
|
}
|
271
|
1 |
|
|
272
|
22 |
|
|
273
|
21 |
|
/**
|
274
|
27 |
|
* Check that page is.
|
275
|
6 |
|
*
|
276
|
6 |
|
* @since 1.0.0
|
277
|
5 |
|
* @since 1.5.6 Added to check GD invoices and GD checkout pages.
|
278
|
27 |
|
* @since 1.5.7 Updated to validate buddypress dashboard listings page as a author page.
|
279
|
12 |
|
* @package GeoDirectory
|
280
|
12 |
|
* @global object $wp_query WordPress Query object.
|
281
|
12 |
|
* @global object $post The current post object.
|
282
|
12 |
|
*
|
283
|
10 |
|
* @param string $gdpage The page type.
|
284
|
26 |
|
*
|
285
|
7 |
|
* @return bool If valid returns true. Otherwise false.
|
286
|
7 |
|
*/
|
287
|
7 |
|
function geodir_is_page( $gdpage = '' ) {
|
288
|
7 |
|
|
289
|
|
|
global $wp_query, $post, $wp;
|
290
|
7 |
|
//if(!is_admin()):
|
|
|
|
|
291
|
26 |
|
|
292
|
12 |
|
switch ( $gdpage ):
|
293
|
|
|
case 'add-listing':
|
294
|
|
|
|
295
|
|
|
if ( is_page() && get_query_var( 'page_id' ) == geodir_add_listing_page_id() ) {
|
296
|
|
|
return true;
|
297
|
12 |
|
} elseif ( is_page() && isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
|
298
|
12 |
|
return true;
|
299
|
12 |
|
}
|
300
|
12 |
|
|
301
|
|
|
break;
|
302
|
12 |
|
case 'preview':
|
303
|
25 |
|
if ( ( is_page() && get_query_var( 'page_id' ) == geodir_preview_page_id() ) && isset( $_REQUEST['listing_type'] )
|
304
|
|
|
&& in_array( $_REQUEST['listing_type'], geodir_get_posttypes() )
|
305
|
8 |
|
) {
|
306
|
8 |
|
return true;
|
307
|
|
|
}
|
308
|
9 |
|
break;
|
309
|
25 |
|
case 'listing-success':
|
310
|
7 |
|
if ( is_page() && get_query_var( 'page_id' ) == geodir_success_page_id() ) {
|
311
|
7 |
|
return true;
|
312
|
6 |
|
}
|
313
|
25 |
|
break;
|
314
|
24 |
View Code Duplication |
case 'detail':
|
315
|
24 |
|
$post_type = get_query_var( 'post_type' );
|
316
|
|
|
if ( is_array( $post_type ) ) {
|
317
|
24 |
|
$post_type = reset( $post_type );
|
318
|
|
|
}
|
319
|
|
|
if ( is_single() && in_array( $post_type, geodir_get_posttypes() ) ) {
|
320
|
|
|
return true;
|
321
|
|
|
}
|
322
|
24 |
|
break;
|
323
|
25 |
View Code Duplication |
case 'pt':
|
324
|
24 |
|
$post_type = get_query_var( 'post_type' );
|
325
|
24 |
|
if ( is_array( $post_type ) ) {
|
326
|
23 |
|
$post_type = reset( $post_type );
|
327
|
10 |
|
}
|
328
|
1 |
|
if ( is_post_type_archive() && in_array( $post_type, geodir_get_posttypes() ) && ! is_tax() ) {
|
329
|
1 |
|
return true;
|
330
|
1 |
|
}
|
331
|
9 |
|
|
332
|
9 |
|
break;
|
333
|
9 |
|
case 'listing':
|
334
|
9 |
|
if ( is_tax() && geodir_get_taxonomy_posttype() ) {
|
335
|
7 |
|
global $current_term, $taxonomy, $term;
|
336
|
|
|
|
337
|
|
|
return true;
|
338
|
|
|
}
|
339
|
7 |
|
$post_type = get_query_var( 'post_type' );
|
340
|
|
|
if ( is_array( $post_type ) ) {
|
341
|
|
|
$post_type = reset( $post_type );
|
342
|
|
|
}
|
343
|
7 |
|
if ( is_post_type_archive() && in_array( $post_type, geodir_get_posttypes() ) ) {
|
344
|
7 |
|
return true;
|
345
|
|
|
}
|
346
|
|
|
|
347
|
7 |
|
break;
|
348
|
|
|
case 'home':
|
349
|
|
|
|
350
|
|
|
if ( ( is_page() && get_query_var( 'page_id' ) == geodir_home_page_id() ) || is_page_geodir_home() ) {
|
351
|
28 |
|
return true;
|
352
|
|
|
}
|
353
|
|
|
|
354
|
|
|
break;
|
355
|
|
|
case 'location':
|
356
|
|
|
if ( is_page() && get_query_var( 'page_id' ) == geodir_location_page_id() ) {
|
357
|
|
|
return true;
|
358
|
|
|
}
|
359
|
|
|
break;
|
360
|
|
|
case 'author':
|
361
|
|
|
if ( is_author() && isset( $_REQUEST['geodir_dashbord'] ) ) {
|
362
|
|
|
return true;
|
363
|
|
|
}
|
364
|
|
|
|
365
|
|
|
if ( function_exists( 'bp_loggedin_user_id' ) && function_exists( 'bp_displayed_user_id' ) && $my_id = (int) bp_loggedin_user_id() ) {
|
366
|
|
|
if ( ( (bool) bp_is_current_component( 'listings' ) || (bool) bp_is_current_component( 'favorites' ) ) && $my_id > 0 && $my_id == (int) bp_displayed_user_id() ) {
|
367
|
|
|
return true;
|
368
|
|
|
}
|
369
|
|
|
}
|
370
|
|
|
break;
|
371
|
|
|
case 'search':
|
372
|
|
|
if ( is_search() && isset( $_REQUEST['geodir_search'] ) ) {
|
373
|
|
|
return true;
|
374
|
|
|
}
|
375
|
|
|
break;
|
376
|
|
|
case 'info':
|
377
|
|
|
if ( is_page() && get_query_var( 'page_id' ) == geodir_info_page_id() ) {
|
378
|
|
|
return true;
|
379
|
|
|
}
|
380
|
|
|
break;
|
381
|
|
|
case 'login':
|
382
|
|
|
if ( is_page() && get_query_var( 'page_id' ) == geodir_login_page_id() ) {
|
383
|
|
|
return true;
|
384
|
|
|
}
|
385
|
|
|
break;
|
386
|
|
|
case 'checkout':
|
387
|
|
View Code Duplication |
if ( is_page() && function_exists( 'geodir_payment_checkout_page_id' ) && get_query_var( 'page_id' ) == geodir_payment_checkout_page_id() ) {
|
388
|
|
|
return true;
|
389
|
|
|
}
|
390
|
|
|
break;
|
391
|
|
|
case 'invoices':
|
392
|
|
View Code Duplication |
if ( is_page() && function_exists( 'geodir_payment_invoices_page_id' ) && get_query_var( 'page_id' ) == geodir_payment_invoices_page_id() ) {
|
393
|
|
|
return true;
|
394
|
|
|
}
|
395
|
|
|
break;
|
396
|
|
|
default:
|
397
|
|
|
return false;
|
398
|
|
|
break;
|
|
|
|
|
399
|
|
|
|
400
|
|
|
endswitch;
|
401
|
|
|
|
402
|
|
|
//endif;
|
403
|
|
|
|
404
|
|
|
return false;
|
405
|
|
|
}
|
406
|
|
|
|
407
|
|
|
/**
|
408
|
|
|
* Sets a key and value in $wp object if the current page is a geodir page.
|
409
|
|
|
*
|
410
|
|
|
* @since 1.0.0
|
411
|
|
|
* @since 1.5.4 Added check for new style GD homepage.
|
412
|
|
|
* @since 1.5.6 Added check for GD invoices and GD checkout page.
|
413
|
|
|
* @package GeoDirectory
|
414
|
|
|
*
|
415
|
|
|
* @param object $wp WordPress object.
|
416
|
|
|
*/
|
417
|
|
|
function geodir_set_is_geodir_page( $wp ) {
|
418
|
|
|
if ( ! is_admin() ) {
|
419
|
|
|
//$wp->query_vars['gd_is_geodir_page'] = false;
|
|
|
|
|
420
|
|
|
//print_r()
|
421
|
|
|
if ( empty( $wp->query_vars ) || ! array_diff( array_keys( $wp->query_vars ), array(
|
422
|
|
|
'preview',
|
423
|
|
|
'page',
|
424
|
|
|
'paged',
|
425
|
|
|
'cpage'
|
426
|
|
|
) )
|
427
|
|
|
) {
|
428
|
|
|
if ( get_option( 'geodir_set_as_home' ) ) {
|
429
|
|
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
430
|
|
|
}
|
431
|
|
|
if ( geodir_is_page( 'home' ) ) {
|
432
|
|
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
433
|
|
|
}
|
434
|
|
|
|
435
|
|
|
|
436
|
|
|
}
|
437
|
|
|
|
438
|
|
|
if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['page_id'] ) ) {
|
439
|
|
|
if (
|
440
|
|
|
$wp->query_vars['page_id'] == geodir_add_listing_page_id()
|
441
|
|
|
|| $wp->query_vars['page_id'] == geodir_preview_page_id()
|
442
|
|
|
|| $wp->query_vars['page_id'] == geodir_success_page_id()
|
443
|
|
|
|| $wp->query_vars['page_id'] == geodir_location_page_id()
|
444
|
|
|
|| $wp->query_vars['page_id'] == geodir_home_page_id()
|
445
|
|
|
|| $wp->query_vars['page_id'] == geodir_info_page_id()
|
446
|
|
|
|| $wp->query_vars['page_id'] == geodir_login_page_id()
|
447
|
|
|
|| ( function_exists( 'geodir_payment_checkout_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id() )
|
448
|
|
|
|| ( function_exists( 'geodir_payment_invoices_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id() )
|
449
|
|
|
) {
|
450
|
|
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
451
|
|
|
}
|
452
|
|
|
}
|
453
|
|
|
|
454
|
|
|
if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['pagename'] ) ) {
|
455
|
|
|
$page = get_page_by_path( $wp->query_vars['pagename'] );
|
456
|
|
|
|
457
|
|
|
if ( ! empty( $page ) && (
|
458
|
|
|
$page->ID == geodir_add_listing_page_id()
|
459
|
|
|
|| $page->ID == geodir_preview_page_id()
|
460
|
|
|
|| $page->ID == geodir_success_page_id()
|
461
|
|
|
|| $page->ID == geodir_location_page_id()
|
462
|
|
|
|| ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_home_page_id() )
|
463
|
|
|
|| ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_info_page_id() )
|
464
|
|
|
|| ( isset( $wp->query_vars['page_id'] ) && $wp->query_vars['page_id'] == geodir_login_page_id() )
|
465
|
|
|
|| ( isset( $wp->query_vars['page_id'] ) && function_exists( 'geodir_payment_checkout_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id() )
|
466
|
|
|
|| ( isset( $wp->query_vars['page_id'] ) && function_exists( 'geodir_payment_invoices_page_id' ) && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id() )
|
467
|
|
|
)
|
468
|
30 |
|
) {
|
469
|
30 |
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
470
|
30 |
|
}
|
471
|
|
|
}
|
472
|
30 |
|
|
473
|
|
|
|
474
|
|
|
if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['post_type'] ) && $wp->query_vars['post_type'] != '' ) {
|
475
|
|
|
$requested_post_type = $wp->query_vars['post_type'];
|
476
|
|
|
// check if this post type is geodirectory post types
|
477
|
|
|
$post_type_array = geodir_get_posttypes();
|
478
|
|
|
if ( in_array( $requested_post_type, $post_type_array ) ) {
|
479
|
|
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
480
|
|
|
}
|
481
|
|
|
}
|
482
|
|
|
|
483
|
|
|
if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) ) {
|
484
|
|
|
$geodir_taxonomis = geodir_get_taxonomies( '', true );
|
485
|
|
|
if ( ! empty( $geodir_taxonomis ) ) {
|
486
|
|
|
foreach ( $geodir_taxonomis as $taxonomy ) {
|
|
|
|
|
487
|
9 |
|
if ( array_key_exists( $taxonomy, $wp->query_vars ) ) {
|
488
|
9 |
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
489
|
9 |
|
break;
|
490
|
9 |
|
}
|
491
|
9 |
|
}
|
492
|
|
|
}
|
493
|
|
|
|
494
|
|
|
}
|
495
|
|
|
|
496
|
|
|
if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $wp->query_vars['author_name'] ) && isset( $_REQUEST['geodir_dashbord'] ) ) {
|
497
|
|
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
498
|
|
|
}
|
499
|
9 |
|
|
500
|
|
|
|
501
|
9 |
|
if ( ! isset( $wp->query_vars['gd_is_geodir_page'] ) && isset( $_REQUEST['geodir_search'] ) ) {
|
502
|
|
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
503
|
|
|
}
|
504
|
|
|
|
505
|
|
|
|
506
|
|
|
//check if homepage
|
507
|
|
|
if ( ! isset( $wp->query_vars['gd_is_geodir_page'] )
|
508
|
9 |
|
&& ! isset( $wp->query_vars['page_id'] )
|
509
|
|
|
&& ! isset( $wp->query_vars['pagename'] )
|
510
|
|
|
&& is_page_geodir_home()
|
511
|
|
|
) {
|
512
|
|
|
$wp->query_vars['gd_is_geodir_page'] = true;
|
513
|
|
|
}
|
514
|
|
|
//echo $wp->query_vars['gd_is_geodir_page'] ;
|
|
|
|
|
515
|
|
|
/*echo "<pre>" ;
|
|
|
|
|
516
|
|
|
print_r($wp) ;
|
517
|
|
|
echo "</pre>" ;
|
518
|
|
|
// exit();
|
519
|
|
|
*/
|
520
|
|
|
} // end of is admin
|
521
|
|
|
}
|
522
|
|
|
|
523
|
|
|
/**
|
524
|
|
|
* Checks whether the current page is a GD page or not.
|
525
|
|
|
*
|
526
|
|
|
* @since 1.0.0
|
527
|
|
|
* @package GeoDirectory
|
528
|
|
|
* @global object $wp WordPress object.
|
529
|
|
|
* @return bool If the page is GD page returns true. Otherwise false.
|
530
|
|
|
*/
|
531
|
|
|
function geodir_is_geodir_page() {
|
532
|
|
|
global $wp;
|
533
|
|
|
if ( isset( $wp->query_vars['gd_is_geodir_page'] ) && $wp->query_vars['gd_is_geodir_page'] ) {
|
534
|
|
|
return true;
|
535
|
|
|
} else {
|
536
|
|
|
return false;
|
537
|
|
|
}
|
538
|
|
|
}
|
539
|
|
|
|
540
|
|
|
if ( ! function_exists( 'geodir_get_imagesize' ) ) {
|
541
|
|
|
/**
|
542
|
|
|
* Get image size using the size key .
|
543
|
|
|
*
|
544
|
|
|
* @since 1.0.0
|
545
|
|
|
* @package GeoDirectory
|
546
|
|
|
*
|
547
|
|
|
* @param string $size The image size key.
|
548
|
|
|
*
|
549
|
|
|
* @return array|mixed|void|WP_Error If valid returns image size. Else returns error.
|
550
|
|
|
*/
|
551
|
|
|
function geodir_get_imagesize( $size = '' ) {
|
552
|
|
|
|
553
|
|
|
$imagesizes = array(
|
554
|
|
|
'list-thumb' => array( 'w' => 283, 'h' => 188 ),
|
555
|
|
|
'thumbnail' => array( 'w' => 125, 'h' => 125 ),
|
556
|
|
|
'widget-thumb' => array( 'w' => 50, 'h' => 50 ),
|
557
|
|
|
'slider-thumb' => array( 'w' => 100, 'h' => 100 )
|
558
|
|
|
);
|
559
|
|
|
|
560
|
|
|
/**
|
561
|
|
|
* Filter the image sizes array.
|
562
|
|
|
*
|
563
|
|
|
* @since 1.0.0
|
564
|
|
|
*
|
565
|
|
|
* @param array $imagesizes Image size array.
|
566
|
|
|
*/
|
567
|
|
|
$imagesizes = apply_filters( 'geodir_imagesizes', $imagesizes );
|
568
|
|
|
|
569
|
|
|
if ( ! empty( $size ) && array_key_exists( $size, $imagesizes ) ) {
|
570
|
|
|
/**
|
571
|
|
|
* Filters image size of the passed key.
|
572
|
1 |
|
*
|
573
|
1 |
|
* @since 1.0.0
|
574
|
|
|
*
|
575
|
|
|
* @param array $imagesizes [$size] Image size array of the passed key.
|
576
|
1 |
|
*/
|
577
|
1 |
|
return apply_filters( 'geodir_get_imagesize_' . $size, $imagesizes[ $size ] );
|
578
|
|
|
|
579
|
|
|
} elseif ( ! empty( $size ) ) {
|
580
|
1 |
|
|
581
|
1 |
|
return new WP_Error( 'geodir_no_imagesize', __( "Given image size is not valid", 'geodirectory' ) );
|
582
|
1 |
|
|
583
|
|
|
}
|
584
|
|
|
|
585
|
|
|
return $imagesizes;
|
586
|
|
|
}
|
587
|
|
|
}
|
588
|
|
|
|
589
|
|
|
/**
|
590
|
|
|
* Get an image size
|
591
|
|
|
*
|
592
|
|
|
* Variable is filtered by geodir_get_image_size_{image_size}
|
593
|
|
|
*/
|
594
|
|
|
/*
|
|
|
|
|
595
|
|
|
function geodir_get_image_size( $image_size ) {
|
596
|
|
|
$return = '';
|
597
|
1 |
|
switch ($image_size) :
|
598
|
1 |
|
case "list_thumbnail_size" : $return = get_option('geodirectory_list_thumbnail_size'); break;
|
599
|
|
|
endswitch;
|
600
|
|
|
return apply_filters( 'geodir_get_image_size_'.$image_size, $return );
|
601
|
|
|
}
|
602
|
|
|
*/
|
603
|
|
|
|
604
|
|
|
|
605
|
|
|
if ( ! function_exists( 'createRandomString' ) ) {
|
606
|
|
|
/**
|
607
|
|
|
* Creates random string.
|
608
|
|
|
*
|
609
|
|
|
* @since 1.0.0
|
610
|
|
|
* @package GeoDirectory
|
611
|
|
|
* @return string Random string.
|
612
|
|
|
*/
|
613
|
|
|
function createRandomString() {
|
614
|
|
|
$chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
|
615
|
|
|
srand( (double) microtime() * 1000000 );
|
616
|
|
|
$i = 0;
|
617
|
|
|
$rstring = '';
|
618
|
1 |
|
while ( $i <= 25 ) {
|
619
|
|
|
$num = rand() % 33;
|
620
|
1 |
|
$tmp = substr( $chars, $num, 1 );
|
621
|
1 |
|
$rstring = $rstring . $tmp;
|
622
|
1 |
|
$i ++;
|
623
|
1 |
|
}
|
624
|
1 |
|
|
625
|
1 |
|
return $rstring;
|
626
|
1 |
|
}
|
627
|
1 |
|
}
|
628
|
|
|
|
629
|
|
|
if ( ! function_exists( 'geodir_getDistanceRadius' ) ) {
|
630
|
|
|
/**
|
631
|
|
|
* Calculates the distance radius.
|
632
|
|
|
*
|
633
|
|
|
* @since 1.0.0
|
634
|
|
|
* @package GeoDirectory
|
635
|
|
|
*
|
636
|
|
|
* @param string $uom Measurement unit type.
|
637
|
|
|
*
|
638
|
|
|
* @return float The mean radius.
|
639
|
|
|
*/
|
640
|
|
|
function geodir_getDistanceRadius( $uom = 'km' ) {
|
641
|
|
|
// Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
|
642
|
|
|
switch ( geodir_strtolower( $uom ) ):
|
643
|
|
|
case 'km' :
|
644
|
|
|
$earthMeanRadius = 6371.009; // km
|
645
|
|
|
break;
|
646
|
|
|
case 'm' :
|
647
|
|
|
case 'meters' :
|
648
|
|
|
$earthMeanRadius = 6371.009 * 1000; // km
|
649
|
|
|
break;
|
650
|
|
|
case 'miles' :
|
651
|
|
|
$earthMeanRadius = 3958.761; // miles
|
652
|
9 |
|
break;
|
653
|
|
|
case 'yards' :
|
654
|
|
|
case 'yds' :
|
655
|
9 |
|
$earthMeanRadius = 3958.761 * 1760; // yards
|
656
|
9 |
|
break;
|
657
|
|
|
case 'feet' :
|
658
|
9 |
|
case 'ft' :
|
659
|
2 |
|
$earthMeanRadius = 3958.761 * 1760 * 3; // feet
|
660
|
2 |
|
break;
|
661
|
9 |
|
case 'nm' :
|
662
|
2 |
|
$earthMeanRadius = 3440.069; // miles
|
663
|
2 |
|
break;
|
664
|
7 |
|
default:
|
665
|
1 |
|
$earthMeanRadius = 3958.761; // miles
|
666
|
1 |
|
break;
|
667
|
1 |
|
endswitch;
|
668
|
5 |
|
|
669
|
2 |
|
return $earthMeanRadius;
|
670
|
2 |
|
}
|
671
|
2 |
|
}
|
672
|
4 |
|
|
673
|
1 |
|
|
674
|
1 |
|
if ( ! function_exists( 'geodir_calculateDistanceFromLatLong' ) ) {
|
675
|
2 |
|
/**
|
676
|
1 |
|
* Calculate the great circle distance between two points identified by longitude and latitude.
|
677
|
1 |
|
*
|
678
|
1 |
|
* @since 1.0.0
|
679
|
|
|
* @package GeoDirectory
|
680
|
|
|
*
|
681
|
|
|
* @param array $point1 Latitude and Longitude of point 1.
|
682
|
|
|
* @param array $point2 Latitude and Longitude of point 2.
|
683
|
9 |
|
* @param string $uom Unit of measurement.
|
684
|
9 |
|
*
|
685
|
9 |
|
* @return float The distance.
|
686
|
|
|
*/
|
687
|
9 |
|
function geodir_calculateDistanceFromLatLong( $point1, $point2, $uom = 'km' ) {
|
688
|
9 |
|
// Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude
|
689
|
9 |
|
|
690
|
|
|
$earthMeanRadius = geodir_getDistanceRadius( $uom );
|
691
|
9 |
|
|
692
|
9 |
|
$deltaLatitude = deg2rad( (float) $point2['latitude'] - (float) $point1['latitude'] );
|
693
|
9 |
|
$deltaLongitude = deg2rad( (float) $point2['longitude'] - (float) $point1['longitude'] );
|
694
|
9 |
|
$a = sin( $deltaLatitude / 2 ) * sin( $deltaLatitude / 2 ) +
|
695
|
|
|
cos( deg2rad( (float) $point1['latitude'] ) ) * cos( deg2rad( (float) $point2['latitude'] ) ) *
|
696
|
9 |
|
sin( $deltaLongitude / 2 ) * sin( $deltaLongitude / 2 );
|
697
|
9 |
|
$c = 2 * atan2( sqrt( $a ), sqrt( 1 - $a ) );
|
698
|
1 |
|
$distance = $earthMeanRadius * $c;
|
699
|
1 |
|
|
700
|
|
|
return $distance;
|
701
|
9 |
|
|
702
|
9 |
|
}
|
703
|
|
|
}
|
704
|
9 |
|
|
705
|
|
|
|
706
|
9 |
|
if ( ! function_exists( 'geodir_sendEmail' ) ) {
|
707
|
2 |
|
/**
|
708
|
2 |
|
* The main function that send transactional emails using the args provided.
|
709
|
2 |
|
*
|
710
|
9 |
|
* @since 1.0.0
|
711
|
9 |
|
* @since 1.5.7 Added db translations for notifications subject and content.
|
712
|
9 |
|
* @package GeoDirectory
|
713
|
9 |
|
*
|
714
|
|
|
* @param string $fromEmail Sender email address.
|
715
|
9 |
|
* @param string $fromEmailName Sender name.
|
716
|
9 |
|
* @param string $toEmail Receiver email address.
|
717
|
9 |
|
* @param string $toEmailName Receiver name.
|
718
|
|
|
* @param string $to_subject Email subject.
|
719
|
9 |
|
* @param string $to_message Email content.
|
720
|
6 |
|
* @param string $extra Not being used.
|
721
|
6 |
|
* @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
|
722
|
|
|
* @param string $post_id The post ID.
|
723
|
9 |
|
* @param string $user_id The user ID.
|
724
|
6 |
|
*/
|
725
|
6 |
|
function geodir_sendEmail( $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '' ) {
|
726
|
|
|
$login_details = '';
|
727
|
9 |
|
|
728
|
9 |
|
// strip slashes from subject & message text
|
729
|
9 |
|
$to_subject = stripslashes_deep( $to_subject );
|
730
|
|
|
$to_message = stripslashes_deep( $to_message );
|
731
|
9 |
|
|
732
|
9 |
|
if ( $message_type == 'send_friend' ) {
|
733
|
9 |
|
$subject = get_option( 'geodir_email_friend_subject' );
|
734
|
|
|
$message = get_option( 'geodir_email_friend_content' );
|
735
|
9 |
|
} elseif ( $message_type == 'send_enquiry' ) {
|
736
|
9 |
|
$subject = get_option( 'geodir_email_enquiry_subject' );
|
737
|
9 |
|
$message = get_option( 'geodir_email_enquiry_content' );
|
738
|
9 |
|
} elseif ( $message_type == 'forgot_password' ) {
|
739
|
|
|
$subject = get_option( 'geodir_forgot_password_subject' );
|
740
|
9 |
|
$message = get_option( 'geodir_forgot_password_content' );
|
741
|
|
|
$login_details = $to_message;
|
742
|
|
|
} elseif ( $message_type == 'registration' ) {
|
743
|
|
|
$subject = get_option( 'geodir_registration_success_email_subject' );
|
744
|
|
|
$message = get_option( 'geodir_registration_success_email_content' );
|
745
|
|
|
$login_details = $to_message;
|
746
|
|
|
} elseif ( $message_type == 'post_submit' ) {
|
747
|
|
|
$subject = get_option( 'geodir_post_submited_success_email_subject' );
|
748
|
|
|
$message = get_option( 'geodir_post_submited_success_email_content' );
|
749
|
|
|
} elseif ( $message_type == 'listing_published' ) {
|
750
|
|
|
$subject = get_option( 'geodir_post_published_email_subject' );
|
751
|
|
|
$message = get_option( 'geodir_post_published_email_content' );
|
752
|
|
|
} elseif ( $message_type == 'listing_edited' ) {
|
753
|
|
|
$subject = get_option( 'geodir_post_edited_email_subject_admin' );
|
754
|
|
|
$message = get_option( 'geodir_post_edited_email_content_admin' );
|
755
|
|
|
}
|
756
|
|
|
|
757
|
|
|
if ( ! empty( $subject ) ) {
|
758
|
|
|
$subject = __( stripslashes_deep( $subject ), 'geodirectory' );
|
759
|
9 |
|
}
|
760
|
|
|
|
761
|
|
|
if ( ! empty( $message ) ) {
|
762
|
|
|
$message = __( stripslashes_deep( $message ), 'geodirectory' );
|
763
|
|
|
}
|
764
|
|
|
|
765
|
|
|
$to_message = nl2br( $to_message );
|
766
|
|
|
$sitefromEmail = get_option( 'site_email' );
|
767
|
|
|
$sitefromEmailName = get_site_emailName();
|
768
|
|
|
$productlink = get_permalink( $post_id );
|
769
|
|
|
|
770
|
|
|
$user_login = '';
|
771
|
|
|
if ( $user_id > 0 && $user_info = get_userdata( $user_id ) ) {
|
772
|
|
|
$user_login = $user_info->user_login;
|
773
|
|
|
}
|
774
|
|
|
|
775
|
|
|
$posted_date = '';
|
776
|
|
|
$listingLink = '';
|
777
|
9 |
|
|
778
|
|
|
$post_info = get_post( $post_id );
|
779
|
|
|
|
780
|
|
|
if ( $post_info ) {
|
781
|
|
|
$posted_date = $post_info->post_date;
|
782
|
|
|
$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
|
783
|
|
|
}
|
784
|
|
|
$siteurl = home_url();
|
785
|
|
|
$siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>';
|
786
|
|
|
$loginurl = geodir_login_url();
|
787
|
|
|
$loginurl_link = '<a href="' . $loginurl . '">login</a>';
|
788
|
|
|
|
789
|
|
|
$post_author_id = ! empty( $post_info ) ? $post_info->post_author : 0;
|
790
|
|
|
$post_author_name = geodir_get_client_name( $post_author_id );
|
791
|
|
|
$current_date = date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) );
|
792
|
|
|
|
793
|
|
|
if ( $fromEmail == '' ) {
|
794
|
|
|
$fromEmail = get_option( 'site_email' );
|
795
|
9 |
|
}
|
796
|
|
|
|
797
|
|
|
if ( $fromEmailName == '' ) {
|
798
|
|
|
$fromEmailName = get_option( 'site_email_name' );
|
799
|
|
|
}
|
800
|
|
|
|
801
|
|
|
$search_array = array(
|
802
|
|
|
'[#listing_link#]',
|
803
|
|
|
'[#site_name_url#]',
|
804
|
|
|
'[#post_id#]',
|
805
|
|
|
'[#site_name#]',
|
806
|
|
|
'[#to_name#]',
|
807
|
|
|
'[#from_name#]',
|
808
|
|
|
'[#subject#]',
|
809
|
|
|
'[#comments#]',
|
810
|
|
|
'[#login_url#]',
|
811
|
|
|
'[#login_details#]',
|
812
|
|
|
'[#client_name#]',
|
813
|
9 |
|
'[#posted_date#]',
|
814
|
|
|
'[#from_email#]',
|
815
|
9 |
|
'[#user_login#]',
|
816
|
|
|
'[#username#]',
|
817
|
9 |
|
'[#post_author_id#]',
|
818
|
|
|
'[#post_author_name#]',
|
819
|
|
|
'[#current_date#]'
|
820
|
|
|
);
|
821
|
|
|
$replace_array = array(
|
822
|
|
|
$listingLink,
|
823
|
|
|
$siteurl_link,
|
824
|
|
|
$post_id,
|
825
|
|
|
$sitefromEmailName,
|
826
|
|
|
$toEmailName,
|
827
|
|
|
$fromEmailName,
|
828
|
|
|
$to_subject,
|
829
|
|
|
$to_message,
|
830
|
|
|
$loginurl_link,
|
831
|
|
|
$login_details,
|
832
|
9 |
|
$toEmailName,
|
833
|
9 |
|
$posted_date,
|
834
|
|
|
$fromEmail,
|
835
|
9 |
|
$user_login,
|
836
|
9 |
|
$user_login,
|
837
|
1 |
|
$post_author_id,
|
838
|
1 |
|
$post_author_name,
|
839
|
|
|
$current_date
|
840
|
1 |
|
);
|
841
|
1 |
|
$message = str_replace( $search_array, $replace_array, $message );
|
|
|
|
|
842
|
1 |
|
|
843
|
|
|
$search_array = array(
|
844
|
1 |
|
'[#listing_link#]',
|
845
|
1 |
|
'[#site_name_url#]',
|
846
|
1 |
|
'[#post_id#]',
|
847
|
|
|
'[#site_name#]',
|
848
|
1 |
|
'[#to_name#]',
|
849
|
1 |
|
'[#from_name#]',
|
850
|
|
|
'[#subject#]',
|
851
|
1 |
|
'[#client_name#]',
|
852
|
8 |
|
'[#posted_date#]',
|
853
|
2 |
|
'[#from_email#]',
|
854
|
2 |
|
'[#user_login#]',
|
855
|
2 |
|
'[#username#]',
|
856
|
6 |
|
'[#post_author_id#]',
|
857
|
2 |
|
'[#post_author_name#]',
|
858
|
2 |
|
'[#current_date#]'
|
859
|
2 |
|
);
|
860
|
4 |
|
$replace_array = array(
|
861
|
2 |
|
$listingLink,
|
862
|
2 |
|
$siteurl_link,
|
863
|
2 |
|
$post_id,
|
864
|
2 |
|
$sitefromEmailName,
|
865
|
1 |
|
$toEmailName,
|
866
|
1 |
|
$fromEmailName,
|
867
|
1 |
|
$to_subject,
|
868
|
|
|
$toEmailName,
|
869
|
9 |
|
$posted_date,
|
870
|
8 |
|
$fromEmail,
|
871
|
|
|
$user_login,
|
872
|
8 |
|
$user_login,
|
873
|
|
|
$post_author_id,
|
874
|
|
|
$post_author_name,
|
875
|
|
|
$current_date
|
876
|
|
|
);
|
877
|
|
|
$subject = str_replace( $search_array, $replace_array, $subject );
|
|
|
|
|
878
|
|
|
|
879
|
|
|
$headers = 'MIME-Version: 1.0' . "\r\n";
|
880
|
|
|
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
|
881
|
|
|
$headers .= "Reply-To: " . $fromEmail . "\r\n";
|
882
|
|
|
$headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n";
|
883
|
|
|
|
884
|
|
|
$to = $toEmail;
|
885
|
8 |
|
|
886
|
|
|
/**
|
887
|
9 |
|
* Filter the client email to address.
|
888
|
|
|
*
|
889
|
|
|
* @since 1.6.1
|
890
|
|
|
* @package GeoDirectory
|
891
|
|
|
*
|
892
|
|
|
* @param string $to The email address the email is being sent to.
|
893
|
|
|
* @param string $fromEmail Sender email address.
|
894
|
|
|
* @param string $fromEmailName Sender name.
|
895
|
|
|
* @param string $toEmail Receiver email address.
|
896
|
|
|
* @param string $toEmailName Receiver name.
|
897
|
|
|
* @param string $to_subject Email subject.
|
898
|
|
|
* @param string $to_message Email content.
|
899
|
|
|
* @param string $extra Not being used.
|
900
|
|
|
* @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
|
901
|
|
|
* @param string $post_id The post ID.
|
902
|
|
|
* @param string $user_id The user ID.
|
903
|
|
|
*/
|
904
|
|
|
$to = apply_filters( 'geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
905
|
|
|
/**
|
906
|
|
|
* Filter the client email subject.
|
907
|
|
|
*
|
908
|
|
|
* @since 1.6.1
|
909
|
|
|
* @package GeoDirectory_Payment_Manager
|
910
|
|
|
*
|
911
|
|
|
* @param string $subject The email subject.
|
912
|
|
|
* @param string $fromEmail Sender email address.
|
913
|
|
|
* @param string $fromEmailName Sender name.
|
914
|
|
|
* @param string $toEmail Receiver email address.
|
915
|
|
|
* @param string $toEmailName Receiver name.
|
916
|
|
|
* @param string $to_subject Email subject.
|
917
|
|
|
* @param string $to_message Email content.
|
918
|
|
|
* @param string $extra Not being used.
|
919
|
|
|
* @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
|
920
|
|
|
* @param string $post_id The post ID.
|
921
|
|
|
* @param string $user_id The user ID.
|
922
|
|
|
*/
|
923
|
|
|
$subject = apply_filters( 'geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
924
|
|
|
/**
|
925
|
|
|
* Filter the client email message.
|
926
|
|
|
*
|
927
|
|
|
* @since 1.6.1
|
928
|
|
|
* @package GeoDirectory_Payment_Manager
|
929
|
|
|
*
|
930
|
|
|
* @param string $message The email message text.
|
931
|
|
|
* @param string $fromEmail Sender email address.
|
932
|
|
|
* @param string $fromEmailName Sender name.
|
933
|
|
|
* @param string $toEmail Receiver email address.
|
934
|
|
|
* @param string $toEmailName Receiver name.
|
935
|
|
|
* @param string $to_subject Email subject.
|
936
|
5 |
|
* @param string $to_message Email content.
|
937
|
|
|
* @param string $extra Not being used.
|
938
|
|
|
* @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
|
939
|
|
|
* @param string $post_id The post ID.
|
940
|
|
|
* @param string $user_id The user ID.
|
941
|
|
|
*/
|
942
|
|
|
$message = apply_filters( 'geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
943
|
5 |
|
/**
|
944
|
|
|
* Filter the client email headers.
|
945
|
5 |
|
*
|
946
|
5 |
|
* @since 1.6.1
|
947
|
5 |
|
* @package GeoDirectory_Payment_Manager
|
948
|
5 |
|
*
|
949
|
|
|
* @param string $headers The email headers.
|
950
|
|
|
* @param string $fromEmail Sender email address.
|
951
|
|
|
* @param string $fromEmailName Sender name.
|
952
|
|
|
* @param string $toEmail Receiver email address.
|
953
|
|
|
* @param string $toEmailName Receiver name.
|
954
|
5 |
|
* @param string $to_subject Email subject.
|
955
|
|
|
* @param string $to_message Email content.
|
956
|
5 |
|
* @param string $extra Not being used.
|
957
|
5 |
|
* @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published.
|
958
|
|
|
* @param string $post_id The post ID.
|
959
|
5 |
|
* @param string $user_id The user ID.
|
960
|
|
|
*/
|
961
|
5 |
|
$headers = apply_filters( 'geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
962
|
|
|
|
963
|
5 |
|
$sent = wp_mail( $to, $subject, $message, $headers );
|
964
|
5 |
|
|
965
|
5 |
|
if ( ! $sent ) {
|
966
|
|
|
if ( is_array( $to ) ) {
|
967
|
5 |
|
$to = implode( ',', $to );
|
968
|
5 |
|
}
|
969
|
|
|
$log_message = sprintf(
|
970
|
5 |
|
__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
|
971
|
5 |
|
$message_type,
|
972
|
|
|
date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
|
973
|
5 |
|
$to,
|
974
|
2 |
|
$subject
|
975
|
2 |
|
);
|
976
|
2 |
|
geodir_error_log( $log_message );
|
977
|
|
|
}
|
978
|
2 |
|
|
979
|
|
|
///////// ADMIN BCC EMIALS
|
980
|
|
|
$adminEmail = get_bloginfo( 'admin_email' );
|
981
|
|
|
$to = $adminEmail;
|
982
|
|
|
|
983
|
|
|
$admin_bcc = false;
|
984
|
|
|
if ( $message_type == 'registration' ) {
|
985
|
|
|
$message_raw = explode( __( "Password:", 'geodirectory' ), $message );
|
986
|
|
|
$message_raw2 = explode( "</p>", $message_raw[1], 2 );
|
987
|
|
|
$message = $message_raw[0] . __( 'Password:', 'geodirectory' ) . ' **********</p>' . $message_raw2[1];
|
988
|
|
|
}
|
989
|
|
|
if ( $message_type == 'post_submit' ) {
|
990
|
2 |
|
$subject = __( stripslashes_deep( get_option( 'geodir_post_submited_success_email_subject_admin' ) ), 'geodirectory' );
|
991
|
|
|
$message = __( stripslashes_deep( get_option( 'geodir_post_submited_success_email_content_admin' ) ), 'geodirectory' );
|
992
|
2 |
|
|
993
|
2 |
|
$search_array = array(
|
994
|
|
|
'[#listing_link#]',
|
995
|
|
|
'[#site_name_url#]',
|
996
|
|
|
'[#post_id#]',
|
997
|
|
|
'[#site_name#]',
|
998
|
|
|
'[#to_name#]',
|
999
|
|
|
'[#from_name#]',
|
1000
|
|
|
'[#subject#]',
|
1001
|
|
|
'[#comments#]',
|
1002
|
|
|
'[#login_url#]',
|
1003
|
|
|
'[#login_details#]',
|
1004
|
|
|
'[#client_name#]',
|
1005
|
|
|
'[#posted_date#]',
|
1006
|
2 |
|
'[#user_login#]',
|
1007
|
2 |
|
'[#username#]'
|
1008
|
|
|
);
|
1009
|
|
|
$replace_array = array(
|
1010
|
|
|
$listingLink,
|
1011
|
|
|
$siteurl_link,
|
1012
|
|
|
$post_id,
|
1013
|
2 |
|
$sitefromEmailName,
|
1014
|
|
|
$toEmailName,
|
1015
|
|
|
$fromEmailName,
|
1016
|
|
|
$to_subject,
|
1017
|
|
|
$to_message,
|
1018
|
|
|
$loginurl_link,
|
1019
|
2 |
|
$login_details,
|
1020
|
|
|
$toEmailName,
|
1021
|
|
|
$posted_date,
|
1022
|
|
|
$user_login,
|
1023
|
|
|
$user_login
|
1024
|
|
|
);
|
1025
|
|
|
$message = str_replace( $search_array, $replace_array, $message );
|
1026
|
|
|
|
1027
|
|
|
$search_array = array(
|
1028
|
|
|
'[#listing_link#]',
|
1029
|
|
|
'[#site_name_url#]',
|
1030
|
2 |
|
'[#post_id#]',
|
1031
|
2 |
|
'[#site_name#]',
|
1032
|
2 |
|
'[#to_name#]',
|
1033
|
2 |
|
'[#from_name#]',
|
1034
|
2 |
|
'[#subject#]',
|
1035
|
2 |
|
'[#client_name#]',
|
1036
|
|
|
'[#posted_date#]',
|
1037
|
|
|
'[#user_login#]',
|
1038
|
2 |
|
'[#username#]'
|
1039
|
2 |
|
);
|
1040
|
2 |
|
$replace_array = array(
|
1041
|
|
|
$listingLink,
|
1042
|
1 |
|
$siteurl_link,
|
1043
|
|
|
$post_id,
|
1044
|
2 |
|
$sitefromEmailName,
|
1045
|
2 |
|
$toEmailName,
|
1046
|
|
|
$fromEmailName,
|
1047
|
2 |
|
$to_subject,
|
1048
|
|
|
$toEmailName,
|
1049
|
2 |
|
$posted_date,
|
1050
|
|
|
$user_login,
|
1051
|
|
|
$user_login
|
1052
|
|
|
);
|
1053
|
|
|
$subject = str_replace( $search_array, $replace_array, $subject );
|
1054
|
|
|
|
1055
|
|
|
$subject .= ' - ADMIN BCC COPY';
|
1056
|
|
|
$admin_bcc = true;
|
1057
|
|
|
|
1058
|
|
|
} elseif ( $message_type == 'registration' && get_option( 'geodir_bcc_new_user' ) ) {
|
1059
|
|
|
$subject .= ' - ADMIN BCC COPY';
|
1060
|
|
|
$admin_bcc = true;
|
1061
|
|
|
} elseif ( $message_type == 'send_friend' && get_option( 'geodir_bcc_friend' ) ) {
|
1062
|
|
|
$subject .= ' - ADMIN BCC COPY';
|
1063
|
|
|
$admin_bcc = true;
|
1064
|
|
|
} elseif ( $message_type == 'send_enquiry' && get_option( 'geodir_bcc_enquiry' ) ) {
|
1065
|
|
|
$subject .= ' - ADMIN BCC COPY';
|
1066
|
|
|
$admin_bcc = true;
|
1067
|
|
|
} elseif ( $message_type == 'listing_published' && get_option( 'geodir_bcc_listing_published' ) ) {
|
1068
|
|
|
$subject .= ' - ADMIN BCC COPY';
|
1069
|
|
|
$admin_bcc = true;
|
1070
|
|
|
}
|
1071
|
|
|
|
1072
|
|
|
if ( $admin_bcc === true ) {
|
1073
|
|
|
$sent = wp_mail( $to, $subject, $message, $headers );
|
1074
|
|
|
|
1075
|
|
|
if ( ! $sent ) {
|
1076
|
|
|
if ( is_array( $to ) ) {
|
1077
|
|
|
$to = implode( ',', $to );
|
1078
|
|
|
}
|
1079
|
|
|
$log_message = sprintf(
|
1080
|
|
|
__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
|
1081
|
|
|
$message_type,
|
1082
|
|
|
date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
|
1083
|
|
|
$to,
|
1084
|
|
|
$subject
|
1085
|
|
|
);
|
1086
|
|
|
geodir_error_log( $log_message );
|
1087
|
|
|
}
|
1088
|
|
|
}
|
1089
|
|
|
|
1090
|
|
|
}
|
1091
|
|
|
}
|
1092
|
|
|
|
1093
|
|
|
|
1094
|
|
|
/**
|
1095
|
|
|
* Generates breadcrumb for taxonomy (category, tags etc.) pages.
|
1096
|
|
|
*
|
1097
|
|
|
* @since 1.0.0
|
1098
|
|
|
* @package GeoDirectory
|
1099
|
|
|
*/
|
1100
|
|
|
function geodir_taxonomy_breadcrumb() {
|
1101
|
|
|
|
1102
|
|
|
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
|
1103
|
|
|
$parent = $term->parent;
|
1104
|
|
|
|
1105
|
|
|
while ( $parent ):
|
1106
|
|
|
$parents[] = $parent;
|
|
|
|
|
1107
|
|
|
$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
|
1108
|
|
|
$parent = $new_parent->parent;
|
1109
|
|
|
endwhile;
|
1110
|
|
|
|
1111
|
|
|
if ( ! empty( $parents ) ):
|
1112
|
|
|
$parents = array_reverse( $parents );
|
1113
|
|
|
|
1114
|
|
|
foreach ( $parents as $parent ):
|
1115
|
|
|
$item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ) );
|
1116
|
|
|
$url = get_term_link( $item, get_query_var( 'taxonomy' ) );
|
1117
|
|
|
echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>';
|
1118
|
|
|
endforeach;
|
1119
|
|
|
|
1120
|
|
|
endif;
|
1121
|
|
|
|
1122
|
2 |
|
echo '<li> > ' . $term->name . '</li>';
|
1123
|
|
|
}
|
1124
|
|
|
|
1125
|
|
|
|
1126
|
|
|
/**
|
1127
|
|
|
* Main function that generates breadcrumb for all pages.
|
1128
|
|
|
*
|
1129
|
|
|
* @since 1.0.0
|
1130
|
|
|
* @since 1.5.7 Changes for the neighbourhood system improvement.
|
1131
|
|
|
* @package GeoDirectory
|
1132
|
|
|
* @global object $wp_query WordPress Query object.
|
1133
|
|
|
* @global object $post The current post object.
|
1134
|
|
|
* @global object $gd_session GeoDirectory Session object.
|
1135
|
|
|
*/
|
1136
|
|
|
function geodir_breadcrumb() {
|
1137
|
|
|
global $wp_query, $geodir_add_location_url;
|
1138
|
|
|
|
1139
|
|
|
/**
|
1140
|
|
|
* Filter breadcrumb separator.
|
1141
|
|
|
*
|
1142
|
|
|
* @since 1.0.0
|
1143
|
|
|
*/
|
1144
|
|
|
$separator = apply_filters( 'geodir_breadcrumb_separator', ' > ' );
|
1145
|
|
|
|
1146
|
|
|
if ( ! geodir_is_page( 'home' ) ) {
|
1147
|
|
|
$breadcrumb = '';
|
1148
|
|
|
$url_categoris = '';
|
|
|
|
|
1149
|
|
|
$breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
|
1150
|
|
|
/**
|
1151
|
|
|
* Filter breadcrumb's first link.
|
1152
|
|
|
*
|
1153
|
|
|
* @since 1.0.0
|
1154
|
|
|
*/
|
1155
|
|
|
$breadcrumb .= '<li>' . apply_filters( 'geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __( 'Home', 'geodirectory' ) . '</a>' ) . '</li>';
|
1156
|
|
|
|
1157
|
|
|
$gd_post_type = geodir_get_current_posttype();
|
1158
|
|
|
$post_type_info = get_post_type_object( $gd_post_type );
|
1159
|
|
|
|
1160
|
|
|
remove_filter( 'post_type_archive_link', 'geodir_get_posttype_link' );
|
1161
|
|
|
|
1162
|
|
|
$listing_link = get_post_type_archive_link( $gd_post_type );
|
1163
|
|
|
|
1164
|
|
|
add_filter( 'post_type_archive_link', 'geodir_get_posttype_link', 10, 2 );
|
1165
|
|
|
$listing_link = rtrim( $listing_link, '/' );
|
1166
|
|
|
$listing_link .= '/';
|
1167
|
|
|
|
1168
|
|
|
$post_type_for_location_link = $listing_link;
|
1169
|
|
|
$location_terms = geodir_get_current_location_terms( 'query_vars', $gd_post_type );
|
1170
|
2 |
|
|
1171
|
2 |
|
global $wp, $gd_session;
|
1172
|
|
|
$location_link = $post_type_for_location_link;
|
1173
|
2 |
|
|
1174
|
|
|
if ( geodir_is_page( 'detail' ) || geodir_is_page( 'listing' ) ) {
|
1175
|
|
|
global $post;
|
1176
|
5 |
|
$location_manager = defined( 'POST_LOCATION_TABLE' ) ? true : false;
|
1177
|
1 |
|
$neighbourhood_active = $location_manager && get_option( 'location_neighbourhoods' ) ? true : false;
|
1178
|
1 |
|
|
1179
|
1 |
View Code Duplication |
if ( geodir_is_page( 'detail' ) && isset( $post->country_slug ) ) {
|
1180
|
|
|
$location_terms = array(
|
1181
|
|
|
'gd_country' => $post->country_slug,
|
1182
|
|
|
'gd_region' => $post->region_slug,
|
1183
|
|
|
'gd_city' => $post->city_slug
|
1184
|
|
|
);
|
1185
|
|
|
|
1186
|
|
|
if ( $neighbourhood_active && ! empty( $location_terms['gd_city'] ) && $gd_ses_neighbourhood = $gd_session->get( 'gd_neighbourhood' ) ) {
|
1187
|
|
|
$location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood;
|
1188
|
1 |
|
}
|
1189
|
|
|
}
|
1190
|
1 |
|
|
1191
|
1 |
|
$geodir_show_location_url = get_option( 'geodir_show_location_url' );
|
1192
|
|
|
|
1193
|
1 |
|
$hide_url_part = array();
|
1194
|
|
|
if ( $location_manager ) {
|
1195
|
|
|
$hide_country_part = get_option( 'geodir_location_hide_country_part' );
|
1196
|
|
|
$hide_region_part = get_option( 'geodir_location_hide_region_part' );
|
1197
|
|
|
|
1198
|
|
|
if ( $hide_region_part && $hide_country_part ) {
|
1199
|
|
|
$hide_url_part = array( 'gd_country', 'gd_region' );
|
1200
|
|
|
} else if ( $hide_region_part && ! $hide_country_part ) {
|
1201
|
|
|
$hide_url_part = array( 'gd_region' );
|
1202
|
|
|
} else if ( ! $hide_region_part && $hide_country_part ) {
|
1203
|
|
|
$hide_url_part = array( 'gd_country' );
|
1204
|
|
|
}
|
1205
|
|
|
}
|
1206
|
|
|
|
1207
|
|
|
$hide_text_part = array();
|
|
|
|
|
1208
|
|
|
if ( $geodir_show_location_url == 'country_city' ) {
|
1209
|
1 |
|
$hide_text_part = array( 'gd_region' );
|
|
|
|
|
1210
|
|
|
|
1211
|
1 |
|
if ( isset( $location_terms['gd_region'] ) && ! $location_manager ) {
|
1212
|
4 |
|
unset( $location_terms['gd_region'] );
|
1213
|
|
|
}
|
1214
|
|
|
} else if ( $geodir_show_location_url == 'region_city' ) {
|
1215
|
|
|
$hide_text_part = array( 'gd_country' );
|
|
|
|
|
1216
|
|
|
|
1217
|
|
|
if ( isset( $location_terms['gd_country'] ) && ! $location_manager ) {
|
1218
|
|
|
unset( $location_terms['gd_country'] );
|
1219
|
|
|
}
|
1220
|
|
|
} else if ( $geodir_show_location_url == 'city' ) {
|
1221
|
|
|
$hide_text_part = array( 'gd_country', 'gd_region' );
|
|
|
|
|
1222
|
3 |
|
|
1223
|
2 |
|
if ( isset( $location_terms['gd_country'] ) && ! $location_manager ) {
|
1224
|
|
|
unset( $location_terms['gd_country'] );
|
1225
|
2 |
|
}
|
1226
|
1 |
|
if ( isset( $location_terms['gd_region'] ) && ! $location_manager ) {
|
1227
|
1 |
|
unset( $location_terms['gd_region'] );
|
1228
|
1 |
|
}
|
1229
|
1 |
|
}
|
1230
|
1 |
|
|
1231
|
1 |
|
$is_location_last = '';
|
|
|
|
|
1232
|
|
|
$is_taxonomy_last = '';
|
|
|
|
|
1233
|
2 |
|
$breadcrumb .= '<li>';
|
1234
|
2 |
|
if ( get_query_var( $gd_post_type . 'category' ) ) {
|
1235
|
2 |
|
$gd_taxonomy = $gd_post_type . 'category';
|
1236
|
3 |
|
} elseif ( get_query_var( $gd_post_type . '_tags' ) ) {
|
1237
|
|
|
$gd_taxonomy = $gd_post_type . '_tags';
|
1238
|
1 |
|
}
|
1239
|
|
|
|
1240
|
|
|
$breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __( ucfirst( $post_type_info->label ), 'geodirectory' ) . '</a>';
|
1241
|
|
|
if ( ! empty( $gd_taxonomy ) || geodir_is_page( 'detail' ) ) {
|
1242
|
1 |
|
$is_location_last = false;
|
1243
|
|
|
} else {
|
1244
|
|
|
$is_location_last = true;
|
1245
|
|
|
}
|
1246
|
1 |
|
|
1247
|
|
|
if ( ! empty( $gd_taxonomy ) && geodir_is_page( 'listing' ) ) {
|
1248
|
|
|
$is_taxonomy_last = true;
|
1249
|
|
|
} else {
|
1250
|
1 |
|
$is_taxonomy_last = false;
|
1251
|
|
|
}
|
1252
|
|
|
|
1253
|
1 |
|
if ( ! empty( $location_terms ) ) {
|
1254
|
|
|
$geodir_get_locations = function_exists( 'get_actual_location_name' ) ? true : false;
|
1255
|
|
|
|
1256
|
1 |
|
foreach ( $location_terms as $key => $location_term ) {
|
1257
|
1 |
|
if ( $location_term != '' ) {
|
1258
|
1 |
|
if ( ! empty( $hide_url_part ) && in_array( $key, $hide_url_part ) ) { // Hide location part from url & breadcrumb.
|
1259
|
1 |
|
continue;
|
1260
|
5 |
|
}
|
1261
|
|
|
|
1262
|
|
|
$gd_location_link_text = preg_replace( '/-(\d+)$/', '', $location_term );
|
1263
|
|
|
$gd_location_link_text = preg_replace( '/[_-]/', ' ', $gd_location_link_text );
|
1264
|
|
|
$gd_location_link_text = ucfirst( $gd_location_link_text );
|
1265
|
|
|
|
1266
|
|
|
$location_term_actual_country = '';
|
1267
|
|
|
$location_term_actual_region = '';
|
1268
|
|
|
$location_term_actual_city = '';
|
1269
|
5 |
|
if ( $geodir_get_locations ) {
|
1270
|
5 |
|
if ( $key == 'gd_country' ) {
|
1271
|
5 |
|
$location_term_actual_country = get_actual_location_name( 'country', $location_term, true );
|
1272
|
|
|
} else if ( $key == 'gd_region' ) {
|
1273
|
|
|
$location_term_actual_region = get_actual_location_name( 'region', $location_term, true );
|
1274
|
|
|
} else if ( $key == 'gd_city' ) {
|
1275
|
|
|
$location_term_actual_city = get_actual_location_name( 'city', $location_term, true );
|
1276
|
|
|
}
|
1277
|
|
|
} else {
|
1278
|
|
|
$location_info = geodir_get_location();
|
1279
|
|
|
|
1280
|
|
|
if ( ! empty( $location_info ) && isset( $location_info->location_id ) ) {
|
1281
|
|
|
if ( $key == 'gd_country' ) {
|
1282
|
|
|
$location_term_actual_country = __( $location_info->country, 'geodirectory' );
|
1283
|
|
|
} else if ( $key == 'gd_region' ) {
|
1284
|
|
|
$location_term_actual_region = __( $location_info->region, 'geodirectory' );
|
1285
|
|
|
} else if ( $key == 'gd_city' ) {
|
1286
|
|
|
$location_term_actual_city = __( $location_info->city, 'geodirectory' );
|
1287
|
1 |
|
}
|
1288
|
1 |
|
}
|
1289
|
1 |
|
}
|
1290
|
|
|
|
1291
|
|
|
if ( $is_location_last && $key == 'gd_country' && ! ( isset( $location_terms['gd_region'] ) && $location_terms['gd_region'] != '' ) && ! ( isset( $location_terms['gd_city'] ) && $location_terms['gd_city'] != '' ) ) {
|
1292
|
|
|
$breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text;
|
1293
|
|
|
} else if ( $is_location_last && $key == 'gd_region' && ! ( isset( $location_terms['gd_city'] ) && $location_terms['gd_city'] != '' ) ) {
|
1294
|
|
|
$breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text;
|
1295
|
|
|
} else if ( $is_location_last && $key == 'gd_city' && empty( $location_terms['gd_neighbourhood'] ) ) {
|
1296
|
|
|
$breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text;
|
1297
|
|
|
} else if ( $is_location_last && $key == 'gd_neighbourhood' ) {
|
1298
|
1 |
|
$breadcrumb .= $separator . $gd_location_link_text;
|
1299
|
|
|
} else {
|
1300
|
|
|
if ( get_option( 'permalink_structure' ) != '' ) {
|
1301
|
|
|
$location_link .= $location_term . '/';
|
1302
|
|
|
} else {
|
1303
|
|
|
$location_link .= "&$key=" . $location_term;
|
1304
|
|
|
}
|
1305
|
|
|
|
1306
|
|
|
if ( $key == 'gd_country' && $location_term_actual_country != '' ) {
|
1307
|
|
|
$gd_location_link_text = $location_term_actual_country;
|
1308
|
|
|
} else if ( $key == 'gd_region' && $location_term_actual_region != '' ) {
|
1309
|
|
|
$gd_location_link_text = $location_term_actual_region;
|
1310
|
|
|
} else if ( $key == 'gd_city' && $location_term_actual_city != '' ) {
|
1311
|
|
|
$gd_location_link_text = $location_term_actual_city;
|
1312
|
|
|
}
|
1313
|
1 |
|
|
1314
|
1 |
|
/*
|
|
|
|
|
1315
|
1 |
|
if (geodir_is_page('detail') && !empty($hide_text_part) && in_array($key, $hide_text_part)) {
|
1316
|
|
|
continue;
|
1317
|
|
|
}
|
1318
|
1 |
|
*/
|
1319
|
1 |
|
|
1320
|
1 |
|
$breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>';
|
1321
|
1 |
|
}
|
1322
|
1 |
|
}
|
1323
|
1 |
|
}
|
1324
|
1 |
|
}
|
1325
|
1 |
|
|
1326
|
1 |
|
if ( ! empty( $gd_taxonomy ) ) {
|
1327
|
1 |
|
$term_index = 1;
|
1328
|
|
|
|
1329
|
1 |
|
//if(get_option('geodir_add_categories_url'))
|
|
|
|
|
1330
|
|
|
{
|
1331
|
1 |
|
if ( get_query_var( $gd_post_type . '_tags' ) ) {
|
1332
|
|
|
$cat_link = $listing_link . 'tags/';
|
1333
|
|
|
} else {
|
1334
|
1 |
|
$cat_link = $listing_link;
|
1335
|
|
|
}
|
1336
|
|
|
|
1337
|
|
|
foreach ( $location_terms as $key => $location_term ) {
|
1338
|
1 |
|
if ( $location_manager && in_array( $key, $hide_url_part ) ) {
|
1339
|
|
|
continue;
|
1340
|
1 |
|
}
|
1341
|
1 |
|
|
1342
|
1 |
|
if ( $location_term != '' ) {
|
1343
|
|
|
if ( get_option( 'permalink_structure' ) != '' ) {
|
1344
|
|
|
$cat_link .= $location_term . '/';
|
1345
|
1 |
|
}
|
1346
|
|
|
}
|
1347
|
|
|
}
|
1348
|
1 |
|
|
1349
|
|
|
$term_array = explode( "/", trim( $wp_query->query[ $gd_taxonomy ], "/" ) );
|
1350
|
1 |
|
foreach ( $term_array as $term ) {
|
1351
|
1 |
|
$term_link_text = preg_replace( '/-(\d+)$/', '', $term );
|
1352
|
|
|
$term_link_text = preg_replace( '/[_-]/', ' ', $term_link_text );
|
|
|
|
|
1353
|
|
|
|
1354
|
|
|
// get term actual name
|
1355
|
|
|
$term_info = get_term_by( 'slug', $term, $gd_taxonomy, 'ARRAY_A' );
|
1356
|
1 |
|
if ( ! empty( $term_info ) && isset( $term_info['name'] ) && $term_info['name'] != '' ) {
|
1357
|
|
|
$term_link_text = urldecode( $term_info['name'] );
|
1358
|
1 |
|
} else {
|
1359
|
|
|
continue;
|
1360
|
|
|
//$term_link_text = wp_strip_all_tags(geodir_ucwords(urldecode($term_link_text)));
|
|
|
|
|
1361
|
|
|
}
|
1362
|
1 |
|
|
1363
|
|
|
if ( $term_index == count( $term_array ) && $is_taxonomy_last ) {
|
1364
|
|
|
$breadcrumb .= $separator . $term_link_text;
|
1365
|
1 |
|
} else {
|
1366
|
|
|
$cat_link .= $term . '/';
|
1367
|
|
|
$breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>';
|
1368
|
1 |
|
}
|
1369
|
|
|
$term_index ++;
|
1370
|
|
|
}
|
1371
|
|
|
}
|
1372
|
1 |
|
|
1373
|
|
|
|
1374
|
|
|
}
|
1375
|
|
|
|
1376
|
|
|
if ( geodir_is_page( 'detail' ) ) {
|
1377
|
|
|
$breadcrumb .= $separator . get_the_title();
|
1378
|
1 |
|
}
|
1379
|
1 |
|
|
1380
|
1 |
|
$breadcrumb .= '</li>';
|
1381
|
1 |
|
|
1382
|
|
|
|
1383
|
|
|
} elseif ( geodir_is_page( 'author' ) ) {
|
1384
|
|
|
$user_id = get_current_user_id();
|
1385
|
|
|
$author_link = get_author_posts_url( $user_id );
|
1386
|
1 |
|
$default_author_link = geodir_getlink( $author_link, array(
|
1387
|
1 |
|
'geodir_dashbord' => 'true',
|
1388
|
|
|
'stype' => 'gd_place'
|
1389
|
1 |
|
), false );
|
1390
|
|
|
|
1391
|
|
|
/**
|
1392
|
|
|
* Filter author page link.
|
1393
|
|
|
*
|
1394
|
|
|
* @since 1.0.0
|
1395
|
|
|
*
|
1396
|
|
|
* @param string $default_author_link Default author link.
|
1397
|
|
|
* @param int $user_id Author ID.
|
1398
|
|
|
*/
|
1399
|
|
|
$default_author_link = apply_filters( 'geodir_dashboard_author_link', $default_author_link, $user_id );
|
1400
|
|
|
|
1401
|
1 |
|
$breadcrumb .= '<li>';
|
1402
|
|
|
$breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __( 'My Dashboard', 'geodirectory' ) . '</a>';
|
1403
|
1 |
|
|
1404
|
|
|
if ( isset( $_REQUEST['list'] ) ) {
|
1405
|
|
|
$author_link = geodir_getlink( $author_link, array(
|
1406
|
1 |
|
'geodir_dashbord' => 'true',
|
1407
|
|
|
'stype' => $_REQUEST['stype']
|
1408
|
|
|
), false );
|
1409
|
|
|
|
1410
|
|
|
/**
|
1411
|
|
|
* Filter author page link.
|
1412
|
|
|
*
|
1413
|
|
|
* @since 1.0.0
|
1414
|
|
|
*
|
1415
|
1 |
|
* @param string $author_link Author page link.
|
1416
|
|
|
* @param int $user_id Author ID.
|
1417
|
|
|
* @param string $_REQUEST ['stype'] Post type.
|
1418
|
|
|
*/
|
1419
|
|
|
$author_link = apply_filters( 'geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype'] );
|
1420
|
|
|
|
1421
|
|
|
$breadcrumb .= $separator . '<a href="' . $author_link . '">' . __( ucfirst( $post_type_info->label ), 'geodirectory' ) . '</a>';
|
1422
|
|
|
$breadcrumb .= $separator . ucfirst( __( 'My', 'geodirectory' ) . ' ' . $_REQUEST['list'] );
|
1423
|
|
|
} else {
|
1424
|
|
|
$breadcrumb .= $separator . __( ucfirst( $post_type_info->label ), 'geodirectory' );
|
1425
|
|
|
}
|
1426
|
|
|
|
1427
|
|
|
$breadcrumb .= '</li>';
|
1428
|
|
|
} elseif ( is_category() || is_single() ) {
|
1429
|
1 |
|
$category = get_the_category();
|
1430
|
1 |
|
if ( is_category() ) {
|
1431
|
1 |
|
$breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>';
|
1432
|
|
|
}
|
1433
|
|
|
if ( is_single() ) {
|
1434
|
|
|
$breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link( $category[0]->term_id ) . '">' . $category[0]->cat_name . '</a></li>';
|
1435
|
|
|
$breadcrumb .= '<li>' . $separator . get_the_title() . '</li>';
|
1436
|
|
|
}
|
1437
|
|
|
/* End of my version ##################################################### */
|
1438
|
|
|
} else if ( is_page() ) {
|
1439
|
|
|
$page_title = get_the_title();
|
1440
|
|
|
|
1441
|
|
|
if ( geodir_is_page( 'location' ) ) {
|
1442
|
|
|
$location_page_id = geodir_location_page_id();
|
1443
|
|
|
$loc_post = get_post( $location_page_id );
|
1444
|
|
|
$post_name = $loc_post->post_name;
|
1445
|
|
|
$slug = ucwords( str_replace( '-', ' ', $post_name ) );
|
1446
|
|
|
$page_title = ! empty( $slug ) ? $slug : __( 'Location', 'geodirectory' );
|
1447
|
|
|
}
|
1448
|
|
|
|
1449
|
|
|
$breadcrumb .= '<li>' . $separator;
|
1450
|
|
|
$breadcrumb .= stripslashes_deep( $page_title );
|
1451
|
|
|
$breadcrumb .= '</li>';
|
1452
|
|
|
} else if ( is_tag() ) {
|
1453
|
|
|
$breadcrumb .= "<li> " . $separator . single_tag_title( '', false ) . '</li>';
|
1454
|
|
|
} else if ( is_day() ) {
|
1455
|
|
|
$breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " ";
|
1456
|
|
|
the_time( 'F jS, Y' );
|
1457
|
|
|
$breadcrumb .= '</li>';
|
1458
|
|
|
} else if ( is_month() ) {
|
1459
|
|
|
$breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " ";
|
1460
|
|
|
the_time( 'F, Y' );
|
1461
|
|
|
$breadcrumb .= '</li>';
|
1462
|
|
|
} else if ( is_year() ) {
|
1463
|
|
|
$breadcrumb .= "<li> " . $separator . __( " Archive for", 'geodirectory' ) . " ";
|
1464
|
|
|
the_time( 'Y' );
|
1465
|
|
|
$breadcrumb .= '</li>';
|
1466
|
|
|
} else if ( is_author() ) {
|
1467
|
|
|
$breadcrumb .= "<li> " . $separator . __( " Author Archive", 'geodirectory' );
|
1468
|
|
|
$breadcrumb .= '</li>';
|
1469
|
|
|
} else if ( isset( $_GET['paged'] ) && ! empty( $_GET['paged'] ) ) {
|
1470
|
|
|
$breadcrumb .= "<li>" . $separator . __( "Blog Archives", 'geodirectory' );
|
1471
|
|
|
$breadcrumb .= '</li>';
|
1472
|
|
|
} else if ( is_search() ) {
|
1473
|
|
|
$breadcrumb .= "<li> " . $separator . __( " Search Results", 'geodirectory' );
|
1474
|
|
|
$breadcrumb .= '</li>';
|
1475
|
|
|
}
|
1476
|
|
|
$breadcrumb .= '</ul></div>';
|
1477
|
|
|
|
1478
|
|
|
/**
|
1479
|
|
|
* Filter breadcrumb html output.
|
1480
|
|
|
*
|
1481
|
|
|
* @since 1.0.0
|
1482
|
|
|
*
|
1483
|
|
|
* @param string $breadcrumb Breadcrumb HTML.
|
1484
|
|
|
* @param string $separator Breadcrumb separator.
|
1485
|
|
|
*/
|
1486
|
|
|
echo $breadcrumb = apply_filters( 'geodir_breadcrumb', $breadcrumb, $separator );
|
1487
|
|
|
}
|
1488
|
|
|
}
|
1489
|
|
|
|
1490
|
|
|
|
1491
|
|
|
add_action( "admin_init", "geodir_allow_wpadmin" ); // check user is admin
|
1492
|
|
|
if ( ! function_exists( 'geodir_allow_wpadmin' ) ) {
|
1493
|
|
|
/**
|
1494
|
|
|
* Allow only admins to access wp-admin.
|
1495
|
|
|
*
|
1496
|
|
|
* Normal users will be redirected to home page.
|
1497
|
|
|
*
|
1498
|
|
|
* @since 1.0.0
|
1499
|
|
|
* @package GeoDirectory
|
1500
|
|
|
* @global object $wpdb WordPress Database object.
|
1501
|
|
|
*/
|
1502
|
|
|
function geodir_allow_wpadmin() {
|
1503
|
|
|
global $wpdb;
|
1504
|
|
|
if ( get_option( 'geodir_allow_wpadmin' ) == '0' && is_user_logged_in() && ( ! defined( 'DOING_AJAX' ) ) ) // checking action in request to allow ajax request go through
|
1505
|
|
|
{
|
1506
|
|
|
if ( current_user_can( 'administrator' ) ) {
|
1507
|
|
|
} else {
|
1508
|
|
|
|
1509
|
|
|
wp_redirect( home_url() );
|
1510
|
|
|
exit;
|
1511
|
|
|
}
|
1512
|
|
|
|
1513
|
|
|
}
|
1514
|
|
|
}
|
1515
|
|
|
}
|
1516
|
|
|
|
1517
|
|
|
|
1518
|
|
|
/**
|
1519
|
|
|
* Move Images from a remote url to upload directory.
|
1520
|
|
|
*
|
1521
|
|
|
* @since 1.0.0
|
1522
|
|
|
* @package GeoDirectory
|
1523
|
|
|
*
|
1524
|
|
|
* @param string $url The remote image url.
|
1525
|
|
|
*
|
1526
|
|
|
* @return array|WP_Error The uploaded data as array. When failure returns error.
|
1527
|
|
|
*/
|
1528
|
|
|
function fetch_remote_file( $url ) {
|
1529
|
|
|
// extract the file name and extension from the url
|
1530
|
|
|
require_once( ABSPATH . 'wp-includes/pluggable.php' );
|
1531
|
|
|
$file_name = basename( $url );
|
1532
|
|
|
if ( strpos( $file_name, '?' ) !== false ) {
|
1533
|
|
|
list( $file_name ) = explode( '?', $file_name );
|
1534
|
|
|
}
|
1535
|
|
|
$dummy = false;
|
1536
|
|
|
$add_to_cache = false;
|
1537
|
|
|
$key = null;
|
1538
|
|
|
if ( strpos( $url, '/dummy/' ) !== false ) {
|
1539
|
|
|
$dummy = true;
|
1540
|
|
|
$key = "dummy_" . str_replace( '.', '_', $file_name );
|
1541
|
|
|
$value = get_transient( 'cached_dummy_images' );
|
1542
|
|
|
if ( $value ) {
|
1543
|
|
|
if ( isset( $value[ $key ] ) ) {
|
1544
|
|
|
return $value[ $key ];
|
1545
|
|
|
} else {
|
1546
|
|
|
$add_to_cache = true;
|
1547
|
|
|
}
|
1548
|
|
|
} else {
|
1549
|
|
|
$add_to_cache = true;
|
1550
|
|
|
}
|
1551
|
|
|
}
|
1552
|
|
|
|
1553
|
|
|
// get placeholder file in the upload dir with a unique, sanitized filename
|
1554
|
|
|
|
1555
|
|
|
$post_upload_date = isset( $post['upload_date'] ) ? $post['upload_date'] : '';
|
|
|
|
|
1556
|
|
|
|
1557
|
|
|
$upload = wp_upload_bits( $file_name, 0, '', $post_upload_date );
|
1558
|
|
|
if ( $upload['error'] ) {
|
1559
|
|
|
return new WP_Error( 'upload_dir_error', $upload['error'] );
|
1560
|
|
|
}
|
1561
|
|
|
|
1562
|
|
|
|
1563
|
|
|
sleep( 0.3 );// if multiple remote file this can cause the remote server to timeout so we add a slight delay
|
1564
|
|
|
|
1565
|
|
|
// fetch the remote url and write it to the placeholder file
|
1566
|
|
|
$headers = wp_remote_get( $url, array( 'stream' => true, 'filename' => $upload['file'] ) );
|
1567
|
|
|
|
1568
|
|
|
$log_message = '';
|
1569
|
|
|
if ( is_wp_error( $headers ) ) {
|
1570
|
|
|
echo 'file: ' . $url;
|
1571
|
|
|
|
1572
|
|
|
return new WP_Error( 'import_file_error', $headers->get_error_message() );
|
1573
|
|
|
}
|
1574
|
|
|
|
1575
|
|
|
$filesize = filesize( $upload['file'] );
|
1576
|
|
|
// request failed
|
1577
|
|
|
if ( ! $headers ) {
|
1578
|
|
|
$log_message = __( 'Remote server did not respond', 'geodirectory' );
|
1579
|
|
|
} // make sure the fetch was successful
|
1580
|
|
|
elseif ( $headers['response']['code'] != '200' ) {
|
1581
|
|
|
$log_message = sprintf( __( 'Remote server returned error response %1$d %2$s', 'geodirectory' ), esc_html( $headers['response'] ), get_status_header_desc( $headers['response'] ) );
|
1582
|
|
|
} elseif ( isset( $headers['headers']['content-length'] ) && $filesize != $headers['headers']['content-length'] ) {
|
1583
|
|
|
$log_message = __( 'Remote file is incorrect size', 'geodirectory' );
|
1584
|
|
|
} elseif ( 0 == $filesize ) {
|
1585
|
|
|
$log_message = __( 'Zero size file downloaded', 'geodirectory' );
|
1586
|
|
|
}
|
1587
|
|
|
|
1588
|
|
|
if ( $log_message ) {
|
1589
|
|
|
$del = unlink( $upload['file'] );
|
1590
|
|
|
if ( ! $del ) {
|
1591
|
|
|
geodir_error_log( __( 'GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory' ) );
|
1592
|
|
|
}
|
1593
|
|
|
|
1594
|
|
|
return new WP_Error( 'import_file_error', $log_message );
|
1595
|
|
|
}
|
1596
|
|
|
|
1597
|
|
|
if ( $dummy && $add_to_cache && is_array( $upload ) ) {
|
1598
|
|
|
$images = get_transient( 'cached_dummy_images' );
|
1599
|
|
|
if ( is_array( $images ) ) {
|
1600
|
|
|
$images[ $key ] = $upload;
|
1601
|
|
|
} else {
|
1602
|
|
|
$images = array( $key => $upload );
|
1603
|
|
|
}
|
1604
|
|
|
|
1605
|
|
|
//setting the cache using the WP Transient API
|
1606
|
|
|
set_transient( 'cached_dummy_images', $images, 60 * 10 ); //10 minutes cache
|
1607
|
|
|
}
|
1608
|
|
|
|
1609
|
|
|
return $upload;
|
1610
|
|
|
}
|
1611
|
|
|
|
1612
|
|
|
/**
|
1613
|
|
|
* Get maximum file upload size.
|
1614
|
|
|
*
|
1615
|
|
|
* @since 1.0.0
|
1616
|
|
|
* @package GeoDirectory
|
1617
|
|
|
* @return string|void Max upload size.
|
1618
|
|
|
*/
|
1619
|
|
View Code Duplication |
function geodir_max_upload_size() {
|
|
|
|
|
1620
|
|
|
$max_filesize = (float) get_option( 'geodir_upload_max_filesize', 2 );
|
1621
|
|
|
|
1622
|
|
|
if ( $max_filesize > 0 && $max_filesize < 1 ) {
|
1623
|
|
|
$max_filesize = (int) ( $max_filesize * 1024 ) . 'kb';
|
1624
|
|
|
} else {
|
1625
|
|
|
$max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb';
|
1626
|
|
|
}
|
1627
|
|
|
|
1628
|
|
|
/**
|
1629
|
|
|
* Filter default image upload size limit.
|
1630
|
|
|
*
|
1631
|
|
|
* @since 1.0.0
|
1632
|
|
|
*
|
1633
|
|
|
* @param string $max_filesize Max file upload size. Ex. 10mb, 512kb.
|
1634
|
|
|
*/
|
1635
|
|
|
return apply_filters( 'geodir_default_image_upload_size_limit', $max_filesize );
|
1636
|
|
|
}
|
1637
|
|
|
|
1638
|
|
|
/**
|
1639
|
|
|
* Check if dummy folder exists or not.
|
1640
|
|
|
*
|
1641
|
|
|
* Check if dummy folder exists or not , if not then fetch from live url.
|
1642
|
|
|
*
|
1643
|
|
|
* @since 1.0.0
|
1644
|
|
|
* @package GeoDirectory
|
1645
|
|
|
* @return bool If dummy folder exists returns true, else false.
|
1646
|
|
|
*/
|
1647
|
|
|
function geodir_dummy_folder_exists() {
|
1648
|
|
|
$path = geodir_plugin_path() . '/geodirectory-admin/dummy/';
|
1649
|
|
|
if ( ! is_dir( $path ) ) {
|
1650
|
|
|
return false;
|
1651
|
|
|
} else {
|
1652
|
|
|
return true;
|
1653
|
|
|
}
|
1654
|
|
|
|
1655
|
|
|
}
|
1656
|
|
|
|
1657
|
|
|
/**
|
1658
|
|
|
* Get the author info.
|
1659
|
|
|
*
|
1660
|
|
|
* @since 1.0.0
|
1661
|
|
|
* @package GeoDirectory
|
1662
|
|
|
* @global object $wpdb WordPress Database object.
|
1663
|
|
|
*
|
1664
|
|
|
* @param int $aid The author ID.
|
1665
|
|
|
*
|
1666
|
|
|
* @return object Author info.
|
1667
|
|
|
*/
|
1668
|
|
|
function geodir_get_author_info( $aid ) {
|
1669
|
|
|
global $wpdb;
|
1670
|
|
|
/*$infosql = "select * from $wpdb->users where ID=$aid";*/
|
|
|
|
|
1671
|
|
|
$infosql = $wpdb->prepare( "select * from $wpdb->users where ID=%d", array( $aid ) );
|
1672
|
|
|
$info = $wpdb->get_results( $infosql );
|
1673
|
|
|
if ( $info ) {
|
1674
|
|
|
return $info[0];
|
1675
|
|
|
}
|
1676
|
|
|
}
|
1677
|
|
|
|
1678
|
|
|
if ( ! function_exists( 'adminEmail' ) ) {
|
1679
|
|
|
/**
|
1680
|
|
|
* Send emails to client on post submission, renew etc.
|
1681
|
|
|
*
|
1682
|
|
|
* @since 1.0.0
|
1683
|
|
|
* @package GeoDirectory
|
1684
|
|
|
* @global object $wpdb WordPress Database object.
|
1685
|
|
|
*
|
1686
|
|
|
* @param int|string $page_id Page ID.
|
1687
|
|
|
* @param int|string $user_id User ID.
|
1688
|
|
|
* @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
|
1689
|
|
|
* @param string $custom_1 Custom data to be sent.
|
1690
|
|
|
*/
|
1691
|
|
|
function adminEmail( $page_id, $user_id, $message_type, $custom_1 = '' ) {
|
1692
|
|
|
global $wpdb;
|
1693
|
|
|
if ( $message_type == 'expiration' ) {
|
1694
|
|
|
$subject = stripslashes( __( get_option( 'renew_email_subject' ), 'geodirectory' ) );
|
1695
|
|
|
$client_message = stripslashes( __( get_option( 'renew_email_content' ), 'geodirectory' ) );
|
1696
|
|
|
} elseif ( $message_type == 'post_submited' ) {
|
1697
|
|
|
$subject = __( get_option( 'post_submited_success_email_subject_admin' ), 'geodirectory' );
|
1698
|
|
|
$client_message = __( get_option( 'post_submited_success_email_content_admin' ), 'geodirectory' );
|
1699
|
|
|
} elseif ( $message_type == 'renew' ) {
|
1700
|
|
|
$subject = __( get_option( 'post_renew_success_email_subject_admin' ), 'geodirectory' );
|
1701
|
|
|
$client_message = __( get_option( 'post_renew_success_email_content_admin' ), 'geodirectory' );
|
1702
|
|
|
} elseif ( $message_type == 'upgrade' ) {
|
1703
|
|
|
$subject = __( get_option( 'post_upgrade_success_email_subject_admin' ), 'geodirectory' );
|
1704
|
|
|
$client_message = __( get_option( 'post_upgrade_success_email_content_admin' ), 'geodirectory' );
|
1705
|
|
|
} elseif ( $message_type == 'claim_approved' ) {
|
1706
|
|
|
$subject = __( get_option( 'claim_approved_email_subject' ), 'geodirectory' );
|
1707
|
|
|
$client_message = __( get_option( 'claim_approved_email_content' ), 'geodirectory' );
|
1708
|
|
|
} elseif ( $message_type == 'claim_rejected' ) {
|
1709
|
|
|
$subject = __( get_option( 'claim_rejected_email_subject' ), 'geodirectory' );
|
1710
|
|
|
$client_message = __( get_option( 'claim_rejected_email_content' ), 'geodirectory' );
|
1711
|
|
|
} elseif ( $message_type == 'claim_requested' ) {
|
1712
|
|
|
$subject = __( get_option( 'claim_email_subject_admin' ), 'geodirectory' );
|
1713
|
|
|
$client_message = __( get_option( 'claim_email_content_admin' ), 'geodirectory' );
|
1714
|
|
|
} elseif ( $message_type == 'auto_claim' ) {
|
1715
|
|
|
$subject = __( get_option( 'auto_claim_email_subject' ), 'geodirectory' );
|
1716
|
|
|
$client_message = __( get_option( 'auto_claim_email_content' ), 'geodirectory' );
|
1717
|
|
|
} elseif ( $message_type == 'payment_success' ) {
|
1718
|
|
|
$subject = __( get_option( 'post_payment_success_admin_email_subject' ), 'geodirectory' );
|
1719
|
|
|
$client_message = __( get_option( 'post_payment_success_admin_email_content' ), 'geodirectory' );
|
1720
|
|
|
} elseif ( $message_type == 'payment_fail' ) {
|
1721
|
|
|
$subject = __( get_option( 'post_payment_fail_admin_email_subject' ), 'geodirectory' );
|
1722
|
|
|
$client_message = __( get_option( 'post_payment_fail_admin_email_content' ), 'geodirectory' );
|
1723
|
|
|
}
|
1724
|
|
|
$transaction_details = $custom_1;
|
1725
|
|
|
$fromEmail = get_option( 'site_email' );
|
1726
|
|
|
$fromEmailName = get_site_emailName();
|
1727
|
|
|
//$alivedays = get_post_meta($page_id,'alive_days',true);
|
|
|
|
|
1728
|
|
|
$pkg_limit = get_property_price_info_listing( $page_id );
|
1729
|
|
|
$alivedays = $pkg_limit['days'];
|
1730
|
|
|
$productlink = get_permalink( $page_id );
|
1731
|
|
|
$post_info = get_post( $page_id );
|
1732
|
|
|
$post_date = date( 'dS F,Y', strtotime( $post_info->post_date ) );
|
1733
|
|
|
$listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>';
|
1734
|
|
|
$loginurl = geodir_login_url();
|
1735
|
|
|
$loginurl_link = '<a href="' . $loginurl . '">login</a>';
|
1736
|
|
|
$siteurl = home_url();
|
1737
|
|
|
$siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>';
|
1738
|
|
|
$user_info = get_userdata( $user_id );
|
1739
|
|
|
$user_email = $user_info->user_email;
|
1740
|
|
|
$display_name = geodir_get_client_name( $user_id );
|
1741
|
|
|
$user_login = $user_info->user_login;
|
1742
|
|
|
$number_of_grace_days = get_option( 'ptthemes_listing_preexpiry_notice_days' );
|
1743
|
|
|
if ( $number_of_grace_days == '' ) {
|
1744
|
|
|
$number_of_grace_days = 1;
|
1745
|
|
|
}
|
1746
|
|
|
if ( $post_info->post_type == 'event' ) {
|
1747
|
|
|
$post_type = 'event';
|
1748
|
|
|
} else {
|
1749
|
|
|
$post_type = 'listing';
|
1750
|
|
|
}
|
1751
|
|
|
$renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>';
|
1752
|
|
|
$search_array = array(
|
1753
|
|
|
'[#client_name#]',
|
1754
|
|
|
'[#listing_link#]',
|
1755
|
|
|
'[#posted_date#]',
|
1756
|
|
|
'[#number_of_days#]',
|
1757
|
|
|
'[#number_of_grace_days#]',
|
1758
|
|
|
'[#login_url#]',
|
1759
|
|
|
'[#username#]',
|
1760
|
|
|
'[#user_email#]',
|
1761
|
|
|
'[#site_name_url#]',
|
1762
|
|
|
'[#renew_link#]',
|
1763
|
|
|
'[#post_id#]',
|
1764
|
|
|
'[#site_name#]',
|
1765
|
|
|
'[#transaction_details#]'
|
1766
|
|
|
);
|
1767
|
|
|
$replace_array = array(
|
1768
|
|
|
$display_name,
|
1769
|
|
|
$listingLink,
|
1770
|
|
|
$post_date,
|
1771
|
|
|
$alivedays,
|
1772
|
|
|
$number_of_grace_days,
|
1773
|
7 |
|
$loginurl_link,
|
1774
|
7 |
|
$user_login,
|
1775
|
7 |
|
$user_email,
|
1776
|
|
|
$siteurl_link,
|
1777
|
|
|
$renew_link,
|
1778
|
|
|
$page_id,
|
1779
|
|
|
$fromEmailName,
|
1780
|
7 |
|
$transaction_details
|
1781
|
|
|
);
|
1782
|
|
|
$client_message = str_replace( $search_array, $replace_array, $client_message );
|
|
|
|
|
1783
|
|
|
$subject = str_replace( $search_array, $replace_array, $subject );
|
|
|
|
|
1784
|
|
|
$headers = 'MIME-Version: 1.0' . "\r\n";
|
1785
|
|
|
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
|
1786
|
|
|
$headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n";
|
1787
|
|
|
|
1788
|
|
|
$to = $fromEmail;
|
1789
|
|
|
$message = $client_message;
|
1790
|
|
|
|
1791
|
|
|
|
1792
|
|
|
/**
|
1793
|
7 |
|
* Filter the admin email to address.
|
1794
|
|
|
*
|
1795
|
|
|
* @since 1.6.1
|
1796
|
|
|
* @package GeoDirectory
|
1797
|
7 |
|
*
|
1798
|
|
|
* @param string $to The email address the email is being sent to.
|
1799
|
|
|
* @param int|string $page_id Page ID.
|
1800
|
|
|
* @param int|string $user_id User ID.
|
1801
|
|
|
* @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
|
1802
|
|
|
* @param string $custom_1 Custom data to be sent.
|
1803
|
|
|
*/
|
1804
|
|
|
$to = apply_filters( 'geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1 );
|
1805
|
|
|
/**
|
1806
|
|
|
* Filter the admin email subject.
|
1807
|
|
|
*
|
1808
|
|
|
* @since 1.6.1
|
1809
|
|
|
* @package GeoDirectory_Payment_Manager
|
1810
|
|
|
*
|
1811
|
|
|
* @param string $subject The email subject.
|
1812
|
|
|
* @param int|string $page_id Page ID.
|
1813
|
|
|
* @param int|string $user_id User ID.
|
1814
|
|
|
* @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
|
1815
|
|
|
* @param string $custom_1 Custom data to be sent.
|
1816
|
|
|
*/
|
1817
|
2 |
|
$subject = apply_filters( 'geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1 );
|
1818
|
|
|
/**
|
1819
|
|
|
* Filter the admin email message.
|
1820
|
|
|
*
|
1821
|
|
|
* @since 1.6.1
|
1822
|
|
|
* @package GeoDirectory_Payment_Manager
|
1823
|
|
|
*
|
1824
|
|
|
* @param string $message The email message text.
|
1825
|
|
|
* @param int|string $page_id Page ID.
|
1826
|
|
|
* @param int|string $user_id User ID.
|
1827
|
|
|
* @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
|
1828
|
|
|
* @param string $custom_1 Custom data to be sent.
|
1829
|
|
|
*/
|
1830
|
|
|
$message = apply_filters( 'geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1 );
|
1831
|
|
|
/**
|
1832
|
|
|
* Filter the admin email headers.
|
1833
|
|
|
*
|
1834
|
|
|
* @since 1.6.1
|
1835
|
|
|
* @package GeoDirectory_Payment_Manager
|
1836
|
|
|
*
|
1837
|
|
|
* @param string $headers The email headers.
|
1838
|
|
|
* @param int|string $page_id Page ID.
|
1839
|
|
|
* @param int|string $user_id User ID.
|
1840
|
|
|
* @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'.
|
1841
|
|
|
* @param string $custom_1 Custom data to be sent.
|
1842
|
|
|
*/
|
1843
|
|
|
$headers = apply_filters( 'geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1 );
|
1844
|
|
|
|
1845
|
|
|
|
1846
|
|
|
$sent = wp_mail( $to, $subject, $message, $headers );
|
1847
|
|
|
if ( ! $sent ) {
|
1848
|
|
|
if ( is_array( $to ) ) {
|
1849
|
18 |
|
$to = implode( ',', $to );
|
1850
|
|
|
}
|
1851
|
|
|
$log_message = sprintf(
|
1852
|
|
|
__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
|
1853
|
18 |
|
$message_type,
|
1854
|
|
|
date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
|
1855
|
|
|
$to,
|
1856
|
|
|
$subject
|
1857
|
|
|
);
|
1858
|
|
|
geodir_error_log( $log_message );
|
1859
|
|
|
}
|
1860
|
|
|
}
|
1861
|
|
|
}
|
1862
|
|
|
|
1863
|
|
|
/*
|
1864
|
|
|
Language translation helper functions
|
1865
|
18 |
|
*/
|
1866
|
|
|
|
1867
|
|
|
/**
|
1868
|
18 |
|
* Function to get the translated category id's.
|
1869
|
|
|
*
|
1870
|
|
|
* @since 1.0.0
|
1871
|
|
|
* @package GeoDirectory
|
1872
|
|
|
*
|
1873
|
|
|
* @param array $ids_array Category IDs.
|
1874
|
|
|
* @param string $type Category taxonomy.
|
1875
|
|
|
*
|
1876
|
|
|
* @return array Category IDs.
|
1877
|
|
|
*/
|
1878
|
|
|
function gd_lang_object_ids( $ids_array, $type ) {
|
1879
|
|
|
if ( function_exists( 'icl_object_id' ) ) {
|
1880
|
|
|
$res = array();
|
1881
|
|
|
foreach ( $ids_array as $id ) {
|
1882
|
|
|
$xlat = icl_object_id( $id, $type, false );
|
1883
|
|
|
if ( ! is_null( $xlat ) ) {
|
1884
|
|
|
$res[] = $xlat;
|
1885
|
|
|
}
|
1886
|
|
|
}
|
1887
|
|
|
|
1888
|
|
|
return $res;
|
1889
|
|
|
} else {
|
1890
|
|
|
return $ids_array;
|
1891
|
|
|
}
|
1892
|
|
|
}
|
1893
|
|
|
|
1894
|
|
|
|
1895
|
|
|
/**
|
1896
|
|
|
* function to add class to body when multi post type is active.
|
1897
|
|
|
*
|
1898
|
|
|
* @since 1.0.0
|
1899
|
|
|
* @since 1.5.6 Add geodir-page class to body for all gd pages.
|
1900
|
|
|
* @package GeoDirectory
|
1901
|
|
|
* @global object $wpdb WordPress Database object.
|
1902
|
|
|
*
|
1903
|
|
|
* @param array $classes Body CSS classes.
|
1904
|
|
|
*
|
1905
|
|
|
* @return array Modified Body CSS classes.
|
1906
|
|
|
*/
|
1907
|
|
|
function geodir_custom_posts_body_class( $classes ) {
|
1908
|
|
|
global $wpdb, $wp;
|
1909
|
|
|
$post_types = geodir_get_posttypes( 'object' );
|
1910
|
|
|
if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
|
1911
|
|
|
$classes[] = 'geodir_custom_posts';
|
1912
|
|
|
}
|
1913
|
|
|
|
1914
|
|
|
// fix body class for signup page
|
1915
|
|
|
if ( geodir_is_page( 'login' ) ) {
|
1916
|
|
|
$new_classes = array();
|
1917
|
|
|
$new_classes[] = 'signup page-geodir-signup';
|
1918
|
|
|
if ( ! empty( $classes ) ) {
|
1919
|
|
|
foreach ( $classes as $class ) {
|
1920
|
|
|
if ( $class && $class != 'home' && $class != 'blog' ) {
|
1921
|
|
|
$new_classes[] = $class;
|
1922
|
|
|
}
|
1923
|
|
|
}
|
1924
|
|
|
}
|
1925
|
|
|
$classes = $new_classes;
|
1926
|
|
|
}
|
1927
|
|
|
|
1928
|
|
|
if ( geodir_is_geodir_page() ) {
|
1929
|
|
|
$classes[] = 'geodir-page';
|
1930
|
|
|
}
|
1931
|
|
|
|
1932
|
|
|
return $classes;
|
1933
|
|
|
}
|
1934
|
|
|
|
1935
|
|
|
add_filter( 'body_class', 'geodir_custom_posts_body_class' ); // let's add a class to the body so we can style the new addition to the search
|
1936
|
|
|
|
1937
|
8 |
|
|
1938
|
|
|
/**
|
1939
|
8 |
|
* Returns available map zoom levels.
|
1940
|
8 |
|
*
|
1941
|
|
|
* @since 1.0.0
|
1942
|
|
|
* @package GeoDirectory
|
1943
|
|
|
* @return array Available map zoom levels.
|
1944
|
8 |
|
*/
|
1945
|
8 |
|
function geodir_map_zoom_level() {
|
1946
|
|
|
/**
|
1947
|
8 |
|
* Filter GD map zoom level.
|
1948
|
|
|
*
|
1949
|
|
|
* @since 1.0.0
|
1950
|
8 |
|
*/
|
1951
|
8 |
|
return apply_filters( 'geodir_map_zoom_level', array(
|
1952
|
4 |
|
1,
|
1953
|
4 |
|
2,
|
1954
|
4 |
|
3,
|
1955
|
|
|
4,
|
1956
|
|
|
5,
|
1957
|
4 |
|
6,
|
1958
|
|
|
7,
|
1959
|
|
|
8,
|
1960
|
4 |
|
9,
|
1961
|
3 |
|
10,
|
1962
|
3 |
|
11,
|
1963
|
1 |
|
12,
|
1964
|
|
|
13,
|
1965
|
|
|
14,
|
1966
|
1 |
|
15,
|
1967
|
|
|
16,
|
1968
|
|
|
17,
|
1969
|
1 |
|
18,
|
1970
|
1 |
|
19
|
1971
|
1 |
|
) );
|
1972
|
1 |
|
|
1973
|
|
|
}
|
1974
|
8 |
|
|
1975
|
|
|
|
1976
|
|
|
/**
|
1977
|
|
|
* This function takes backup of an option so they can be restored later.
|
1978
|
|
|
*
|
1979
|
|
|
* @since 1.0.0
|
1980
|
|
|
* @package GeoDirectory
|
1981
|
|
|
*
|
1982
|
|
|
* @param string $geodir_option_name Option key.
|
1983
|
|
|
*/
|
1984
|
|
|
function geodir_option_version_backup( $geodir_option_name ) {
|
1985
|
|
|
$version_date = time();
|
1986
|
|
|
$geodir_option = get_option( $geodir_option_name );
|
1987
|
|
|
|
1988
|
|
|
if ( ! empty( $geodir_option ) ) {
|
1989
|
|
|
add_option( $geodir_option_name . '_' . $version_date, $geodir_option );
|
1990
|
|
|
}
|
1991
|
|
|
}
|
1992
|
8 |
|
|
1993
|
8 |
|
/**
|
1994
|
8 |
|
* display add listing page for wpml.
|
1995
|
|
|
*
|
1996
|
8 |
|
* @since 1.0.0
|
1997
|
8 |
|
* @package GeoDirectory
|
1998
|
|
|
*
|
1999
|
8 |
|
* @param int $page_id The page ID.
|
2000
|
|
|
*
|
2001
|
|
|
* @return int Page ID.
|
2002
|
|
|
*/
|
2003
|
|
|
function get_page_id_geodir_add_listing_page( $page_id ) {
|
2004
|
|
|
if ( geodir_wpml_multilingual_status() ) {
|
2005
|
|
|
$post_type = 'post_page';
|
2006
|
|
|
$page_id = geodir_get_wpml_element_id( $page_id, $post_type );
|
2007
|
|
|
}
|
2008
|
8 |
|
|
2009
|
|
|
return $page_id;
|
2010
|
8 |
|
}
|
2011
|
|
|
|
2012
|
|
|
/**
|
2013
|
|
|
* Returns wpml multilingual status.
|
2014
|
8 |
|
*
|
2015
|
|
|
* @since 1.0.0
|
2016
|
|
|
* @package GeoDirectory
|
2017
|
|
|
* @return bool Returns true when sitepress multilingual CMS active. else returns false.
|
2018
|
|
|
*/
|
2019
|
|
|
function geodir_wpml_multilingual_status() {
|
2020
|
|
|
if ( function_exists( 'icl_object_id' ) ) {
|
2021
|
|
|
return true;
|
2022
|
|
|
}
|
2023
|
|
|
|
2024
|
|
|
return false;
|
2025
|
|
|
}
|
2026
|
|
|
|
2027
|
|
|
/**
|
2028
|
|
|
* Returns WPML element ID.
|
2029
|
|
|
*
|
2030
|
|
|
* @since 1.0.0
|
2031
|
8 |
|
* @package GeoDirectory
|
2032
|
|
|
*
|
2033
|
8 |
|
* @param int $page_id The page ID.
|
2034
|
|
|
* @param string $post_type The post type.
|
2035
|
8 |
|
*
|
2036
|
|
|
* @return int Element ID when exists. Else the page id.
|
2037
|
|
|
*/
|
2038
|
8 |
|
function geodir_get_wpml_element_id( $page_id, $post_type ) {
|
2039
|
|
|
global $sitepress;
|
2040
|
|
|
if ( geodir_wpml_multilingual_status() && ! empty( $sitepress ) && isset( $sitepress->queries ) ) {
|
2041
|
|
|
$trid = $sitepress->get_element_trid( $page_id, $post_type );
|
2042
|
|
|
|
2043
|
|
|
if ( $trid > 0 ) {
|
2044
|
|
|
$translations = $sitepress->get_element_translations( $trid, $post_type );
|
2045
|
|
|
|
2046
|
|
|
$lang = $sitepress->get_current_language();
|
2047
|
|
|
$lang = $lang ? $lang : $sitepress->get_default_language();
|
2048
|
|
|
|
2049
|
|
|
if ( ! empty( $translations ) && ! empty( $lang ) && isset( $translations[ $lang ] ) && isset( $translations[ $lang ]->element_id ) && ! empty( $translations[ $lang ]->element_id ) ) {
|
2050
|
|
|
$page_id = $translations[ $lang ]->element_id;
|
2051
|
8 |
|
}
|
2052
|
8 |
|
}
|
2053
|
|
|
}
|
2054
|
8 |
|
|
2055
|
|
|
return $page_id;
|
2056
|
|
|
}
|
2057
|
|
|
|
2058
|
|
|
/**
|
2059
|
|
|
* WPML check element ID.
|
2060
|
|
|
*
|
2061
|
|
|
* @since 1.0.0
|
2062
|
8 |
|
* @package GeoDirectory
|
2063
|
|
|
* @deprecated 1.4.6 No longer needed as we handle translating GD pages as normal now.
|
2064
|
8 |
|
*/
|
2065
|
1 |
|
function geodir_wpml_check_element_id() {
|
2066
|
1 |
|
global $sitepress;
|
2067
|
1 |
|
if ( geodir_wpml_multilingual_status() && ! empty( $sitepress ) && isset( $sitepress->queries ) ) {
|
2068
|
1 |
|
$el_type = 'post_page';
|
2069
|
1 |
|
$el_id = get_option( 'geodir_add_listing_page' );
|
2070
|
8 |
|
$default_lang = $sitepress->get_default_language();
|
2071
|
|
|
$el_details = $sitepress->get_element_language_details( $el_id, $el_type );
|
2072
|
|
|
|
2073
|
|
|
if ( ! ( $el_id > 0 && $default_lang && ! empty( $el_details ) && isset( $el_details->language_code ) && $el_details->language_code == $default_lang ) ) {
|
2074
|
|
|
if ( ! $el_details->source_language_code ) {
|
2075
|
|
|
$sitepress->set_element_language_details( $el_id, $el_type, '', $default_lang );
|
2076
|
|
|
$sitepress->icl_translations_cache->clear();
|
2077
|
|
|
}
|
2078
|
|
|
}
|
2079
|
8 |
|
}
|
2080
|
8 |
|
}
|
2081
|
8 |
|
|
2082
|
|
|
/**
|
2083
|
8 |
|
* Returns orderby SQL using the given query args.
|
2084
|
|
|
*
|
2085
|
|
|
* @since 1.0.0
|
2086
|
|
|
* @package GeoDirectory
|
2087
|
|
|
* @global object $wpdb WordPress Database object.
|
2088
|
|
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
2089
|
|
|
*
|
2090
|
|
|
* @param array $query_args The query array.
|
2091
|
8 |
|
*
|
2092
|
|
|
* @return string Orderby SQL.
|
2093
|
8 |
|
*/
|
2094
|
8 |
|
function geodir_widget_listings_get_order( $query_args ) {
|
|
|
|
|
2095
|
8 |
|
global $wpdb, $plugin_prefix, $gd_query_args_widgets;
|
2096
|
|
|
|
2097
|
8 |
|
$query_args = $gd_query_args_widgets;
|
2098
|
|
|
if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
2099
|
8 |
|
return $wpdb->posts . ".post_date DESC, ";
|
2100
|
8 |
|
}
|
2101
|
8 |
|
|
2102
|
8 |
|
$post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type'];
|
2103
|
8 |
|
$table = $plugin_prefix . $post_type . '_detail';
|
2104
|
8 |
|
|
2105
|
8 |
|
$sort_by = ! empty( $query_args['order_by'] ) ? $query_args['order_by'] : '';
|
2106
|
|
|
|
2107
|
|
|
switch ( $sort_by ) {
|
2108
|
8 |
|
case 'latest':
|
2109
|
8 |
|
case 'newest':
|
2110
|
|
|
$orderby = $wpdb->posts . ".post_date DESC, ";
|
2111
|
8 |
|
break;
|
2112
|
|
|
case 'featured':
|
2113
|
|
|
$orderby = $table . ".is_featured ASC, ";
|
2114
|
|
|
break;
|
2115
|
|
|
case 'az':
|
2116
|
|
|
$orderby = $wpdb->posts . ".post_title ASC, ";
|
2117
|
|
|
break;
|
2118
|
|
|
case 'high_review':
|
2119
|
|
|
$orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, ";
|
2120
|
|
|
break;
|
2121
|
|
|
case 'high_rating':
|
2122
|
|
|
$orderby = "( " . $table . ".overall_rating ) DESC, ";
|
2123
|
|
|
break;
|
2124
|
|
|
case 'random':
|
2125
|
|
|
$orderby = "RAND(), ";
|
2126
|
8 |
|
break;
|
2127
|
|
|
default:
|
2128
|
8 |
|
$orderby = $wpdb->posts . ".post_title ASC, ";
|
2129
|
8 |
|
break;
|
2130
|
|
|
}
|
2131
|
|
|
|
2132
|
|
|
return $orderby;
|
2133
|
8 |
|
}
|
2134
|
|
|
|
2135
|
|
|
/**
|
2136
|
|
|
* Retrieve listings/count using requested filter parameters.
|
2137
|
|
|
*
|
2138
|
|
|
* @since 1.0.0
|
2139
|
|
|
* @package GeoDirectory
|
2140
|
|
|
* @since 1.4.2 New parameter $count_only added
|
2141
|
|
|
* @global object $wpdb WordPress Database object.
|
2142
|
|
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
2143
|
|
|
* @global string $table_prefix WordPress Database Table prefix.
|
2144
|
|
|
*
|
2145
|
|
|
* @param array $query_args The query array.
|
2146
|
|
|
* @param int|bool $count_only If true returns listings count only, otherwise returns array
|
2147
|
|
|
*
|
2148
|
8 |
|
* @return mixed Result object.
|
2149
|
|
|
*/
|
2150
|
8 |
|
function geodir_get_widget_listings( $query_args = array(), $count_only = false ) {
|
2151
|
8 |
|
global $wpdb, $plugin_prefix, $table_prefix;
|
2152
|
|
|
$GLOBALS['gd_query_args_widgets'] = $query_args;
|
2153
|
|
|
$gd_query_args_widgets = $query_args;
|
2154
|
|
|
|
2155
|
8 |
|
$post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type'];
|
2156
|
8 |
|
$table = $plugin_prefix . $post_type . '_detail';
|
2157
|
|
|
|
2158
|
8 |
|
$fields = $wpdb->posts . ".*, " . $table . ".*";
|
2159
|
|
|
/**
|
2160
|
|
|
* Filter widget listing fields string part that is being used for query.
|
2161
|
|
|
*
|
2162
|
8 |
|
* @since 1.0.0
|
2163
|
4 |
|
*
|
2164
|
4 |
|
* @param string $fields Fields string.
|
2165
|
2 |
|
* @param string $table Table name.
|
2166
|
2 |
|
* @param string $post_type Post type.
|
2167
|
4 |
|
*/
|
2168
|
|
|
$fields = apply_filters( 'geodir_filter_widget_listings_fields', $fields, $table, $post_type );
|
2169
|
8 |
|
|
2170
|
|
|
$join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
|
2171
|
|
|
|
2172
|
|
|
########### WPML ###########
|
2173
|
|
|
|
2174
|
|
|
if ( function_exists( 'icl_object_id' ) ) {
|
2175
|
|
|
global $sitepress;
|
2176
|
|
|
$lang_code = ICL_LANGUAGE_CODE;
|
2177
|
|
|
if ( $lang_code ) {
|
2178
|
|
|
$join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID";
|
2179
|
|
|
}
|
2180
|
|
|
}
|
2181
|
|
|
|
2182
|
|
|
########### WPML ###########
|
2183
|
|
|
|
2184
|
8 |
|
/**
|
2185
|
|
|
* Filter widget listing join clause string part that is being used for query.
|
2186
|
8 |
|
*
|
2187
|
8 |
|
* @since 1.0.0
|
2188
|
|
|
*
|
2189
|
|
|
* @param string $join Join clause string.
|
2190
|
8 |
|
* @param string $post_type Post type.
|
2191
|
8 |
|
*/
|
2192
|
|
|
$join = apply_filters( 'geodir_filter_widget_listings_join', $join, $post_type );
|
2193
|
8 |
|
|
2194
|
8 |
|
$post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
|
2195
|
|
|
|
2196
|
|
|
$where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'";
|
2197
|
|
|
|
2198
|
8 |
|
########### WPML ###########
|
2199
|
|
|
if ( function_exists( 'icl_object_id' ) ) {
|
2200
|
|
|
if ( $lang_code ) {
|
2201
|
|
|
$where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' ";
|
|
|
|
|
2202
|
8 |
|
}
|
2203
|
2 |
|
}
|
2204
|
2 |
|
########### WPML ###########
|
2205
|
|
|
/**
|
2206
|
8 |
|
* Filter widget listing where clause string part that is being used for query.
|
2207
|
|
|
*
|
2208
|
|
|
* @since 1.0.0
|
2209
|
|
|
*
|
2210
|
8 |
|
* @param string $where Where clause string.
|
2211
|
|
|
* @param string $post_type Post type.
|
2212
|
|
|
*/
|
2213
|
|
|
$where = apply_filters( 'geodir_filter_widget_listings_where', $where, $post_type );
|
2214
|
8 |
|
$where = $where != '' ? " WHERE 1=1 " . $where : '';
|
2215
|
2 |
|
|
2216
|
2 |
|
$groupby = " GROUP BY $wpdb->posts.ID ";
|
2217
|
|
|
/**
|
2218
|
8 |
|
* Filter widget listing groupby clause string part that is being used for query.
|
2219
|
|
|
*
|
2220
|
|
|
* @since 1.0.0
|
2221
|
|
|
*
|
2222
|
8 |
|
* @param string $groupby Group by clause string.
|
2223
|
4 |
|
* @param string $post_type Post type.
|
2224
|
|
|
*/
|
2225
|
4 |
|
$groupby = apply_filters( 'geodir_filter_widget_listings_groupby', $groupby, $post_type );
|
2226
|
2 |
|
|
2227
|
2 |
|
if ( $count_only ) {
|
2228
|
4 |
|
$sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
|
2229
|
8 |
|
" . $join . "
|
2230
|
|
|
" . $where;
|
2231
|
8 |
|
$rows = (int) $wpdb->get_var( $sql );
|
2232
|
|
|
} else {
|
2233
|
|
|
$orderby = geodir_widget_listings_get_order( $query_args );
|
2234
|
|
|
/**
|
2235
|
|
|
* Filter widget listing orderby clause string part that is being used for query.
|
2236
|
|
|
*
|
2237
|
|
|
* @since 1.0.0
|
2238
|
|
|
*
|
2239
|
|
|
* @param string $orderby Order by clause string.
|
2240
|
|
|
* @param string $table Table name.
|
2241
|
|
|
* @param string $post_type Post type.
|
2242
|
|
|
*/
|
2243
|
|
|
$orderby = apply_filters( 'geodir_filter_widget_listings_orderby', $orderby, $table, $post_type );
|
2244
|
|
|
$orderby .= $wpdb->posts . ".post_title ASC";
|
2245
|
|
|
$orderby = $orderby != '' ? " ORDER BY " . $orderby : '';
|
2246
|
8 |
|
|
2247
|
|
|
$limit = ! empty( $query_args['posts_per_page'] ) ? $query_args['posts_per_page'] : 5;
|
2248
|
8 |
|
/**
|
2249
|
8 |
|
* Filter widget listing limit that is being used for query.
|
2250
|
|
|
*
|
2251
|
|
|
* @since 1.0.0
|
2252
|
|
|
*
|
2253
|
8 |
|
* @param int $limit Query results limit.
|
2254
|
|
|
* @param string $post_type Post type.
|
2255
|
|
|
*/
|
2256
|
|
|
$limit = apply_filters( 'geodir_filter_widget_listings_limit', $limit, $post_type );
|
2257
|
|
|
|
2258
|
|
|
$page = ! empty( $query_args['pageno'] ) ? absint( $query_args['pageno'] ) : 1;
|
2259
|
|
|
if ( ! $page ) {
|
2260
|
|
|
$page = 1;
|
2261
|
|
|
}
|
2262
|
|
|
|
2263
|
|
|
$limit = (int) $limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int) $limit ) . ", " . (int) $limit : "";
|
2264
|
|
|
|
2265
|
|
|
$sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . "
|
2266
|
|
|
" . $join . "
|
2267
|
|
|
" . $where . "
|
2268
|
8 |
|
" . $groupby . "
|
2269
|
|
|
" . $orderby . "
|
2270
|
8 |
|
" . $limit;
|
2271
|
8 |
|
$rows = $wpdb->get_results( $sql );
|
2272
|
|
|
}
|
2273
|
|
|
|
2274
|
|
|
unset( $GLOBALS['gd_query_args_widgets'] );
|
2275
|
8 |
|
unset( $gd_query_args_widgets );
|
2276
|
8 |
|
|
2277
|
8 |
|
return $rows;
|
2278
|
|
|
}
|
2279
|
8 |
|
|
2280
|
|
|
/**
|
2281
|
|
|
* Listing query fields SQL part for widgets.
|
2282
|
|
|
*
|
2283
|
|
|
* @since 1.0.0
|
2284
|
|
|
* @package GeoDirectory
|
2285
|
|
|
* @global object $wpdb WordPress Database object.
|
2286
|
|
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
2287
|
|
|
*
|
2288
|
|
|
* @param string $fields Fields SQL.
|
2289
|
|
|
*
|
2290
|
|
|
* @return string Modified fields SQL.
|
2291
|
|
|
*/
|
2292
|
|
|
function geodir_function_widget_listings_fields( $fields ) {
|
2293
|
2 |
|
global $wpdb, $plugin_prefix, $gd_query_args_widgets;
|
2294
|
2 |
|
|
2295
|
2 |
|
$query_args = $gd_query_args_widgets;
|
2296
|
|
|
if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
2297
|
2 |
|
return $fields;
|
2298
|
2 |
|
}
|
2299
|
2 |
|
|
2300
|
|
|
return $fields;
|
2301
|
|
|
}
|
2302
|
|
|
|
2303
|
|
|
/**
|
2304
|
|
|
* Listing query join clause SQL part for widgets.
|
2305
|
|
|
*
|
2306
|
|
|
* @since 1.0.0
|
2307
|
|
|
* @package GeoDirectory
|
2308
|
|
|
* @global object $wpdb WordPress Database object.
|
2309
|
2 |
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
2310
|
2 |
|
*
|
2311
|
|
|
* @param string $join Join clause SQL.
|
2312
|
|
|
*
|
2313
|
|
|
* @return string Modified join clause SQL.
|
2314
|
|
|
*/
|
2315
|
|
|
function geodir_function_widget_listings_join( $join ) {
|
2316
|
|
|
global $wpdb, $plugin_prefix, $gd_query_args_widgets;
|
2317
|
|
|
|
2318
|
|
|
$query_args = $gd_query_args_widgets;
|
2319
|
|
|
if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
2320
|
|
|
return $join;
|
2321
|
|
|
}
|
2322
|
|
|
|
2323
|
|
|
$post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type'];
|
2324
|
2 |
|
$table = $plugin_prefix . $post_type . '_detail';
|
2325
|
2 |
|
|
2326
|
2 |
View Code Duplication |
if ( ! empty( $query_args['with_pics_only'] ) ) {
|
2327
|
|
|
$join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )";
|
2328
|
2 |
|
}
|
2329
|
2 |
|
|
2330
|
2 |
View Code Duplication |
if ( ! empty( $query_args['tax_query'] ) ) {
|
2331
|
|
|
$tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' );
|
2332
|
|
|
if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) {
|
2333
|
|
|
$join .= $tax_queries['join'];
|
2334
|
|
|
}
|
2335
|
|
|
}
|
2336
|
|
|
|
2337
|
|
|
return $join;
|
2338
|
|
|
}
|
2339
|
|
|
|
2340
|
2 |
|
/**
|
2341
|
|
|
* Listing query where clause SQL part for widgets.
|
2342
|
2 |
|
*
|
2343
|
|
|
* @since 1.0.0
|
2344
|
|
|
* @package GeoDirectory
|
2345
|
|
|
* @global object $wpdb WordPress Database object.
|
2346
|
|
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
2347
|
|
|
*
|
2348
|
|
|
* @param string $where Where clause SQL.
|
2349
|
|
|
*
|
2350
|
|
|
* @return string Modified where clause SQL.
|
2351
|
|
|
*/
|
2352
|
|
|
function geodir_function_widget_listings_where( $where ) {
|
2353
|
|
|
global $wpdb, $plugin_prefix, $gd_query_args_widgets;
|
2354
|
|
|
|
2355
|
|
|
$query_args = $gd_query_args_widgets;
|
2356
|
|
|
if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
2357
|
|
|
return $where;
|
2358
|
|
|
}
|
2359
|
|
|
$post_type = empty( $query_args['post_type'] ) ? 'gd_place' : $query_args['post_type'];
|
2360
|
|
|
$table = $plugin_prefix . $post_type . '_detail';
|
2361
|
|
|
|
2362
|
|
|
if ( ! empty( $query_args ) ) {
|
2363
|
|
|
if ( ! empty( $query_args['gd_location'] ) && function_exists( 'geodir_default_location_where' ) ) {
|
2364
|
|
|
$where = geodir_default_location_where( $where, $table );
|
2365
|
|
|
}
|
2366
|
|
|
|
2367
|
|
|
if ( ! empty( $query_args['post_author'] ) ) {
|
2368
|
|
|
$where .= " AND " . $wpdb->posts . ".post_author = " . (int) $query_args['post_author'];
|
2369
|
|
|
}
|
2370
|
|
|
|
2371
|
|
|
if ( ! empty( $query_args['show_featured_only'] ) ) {
|
2372
|
|
|
$where .= " AND " . $table . ".is_featured = '1'";
|
2373
|
|
|
}
|
2374
|
|
|
|
2375
|
|
|
if ( ! empty( $query_args['show_special_only'] ) ) {
|
2376
|
|
|
$where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )";
|
2377
|
|
|
}
|
2378
|
|
|
|
2379
|
|
|
if ( ! empty( $query_args['with_pics_only'] ) ) {
|
2380
|
|
|
$where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL ";
|
2381
|
|
|
}
|
2382
|
|
|
|
2383
|
|
|
if ( ! empty( $query_args['featured_image_only'] ) ) {
|
2384
|
|
|
$where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' ";
|
2385
|
|
|
}
|
2386
|
|
|
|
2387
|
|
|
if ( ! empty( $query_args['with_videos_only'] ) ) {
|
2388
|
|
|
$where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )";
|
2389
|
9 |
|
}
|
2390
|
|
|
|
2391
|
9 |
View Code Duplication |
if ( ! empty( $query_args['tax_query'] ) ) {
|
2392
|
9 |
|
$tax_queries = get_tax_sql( $query_args['tax_query'], $wpdb->posts, 'ID' );
|
2393
|
9 |
|
|
2394
|
4 |
|
if ( ! empty( $tax_queries['join'] ) && ! empty( $tax_queries['where'] ) ) {
|
2395
|
|
|
$where .= $tax_queries['where'];
|
2396
|
9 |
|
}
|
2397
|
9 |
|
}
|
2398
|
|
|
}
|
2399
|
|
|
|
2400
|
|
|
return $where;
|
2401
|
|
|
}
|
2402
|
|
|
|
2403
|
|
|
/**
|
2404
|
|
|
* Listing query orderby clause SQL part for widgets.
|
2405
|
|
|
*
|
2406
|
|
|
* @since 1.0.0
|
2407
|
|
|
* @package GeoDirectory
|
2408
|
|
|
* @global object $wpdb WordPress Database object.
|
2409
|
8 |
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
2410
|
8 |
|
*
|
2411
|
8 |
|
* @param string $orderby Orderby clause SQL.
|
2412
|
|
|
*
|
2413
|
|
|
* @return string Modified orderby clause SQL.
|
2414
|
8 |
|
*/
|
2415
|
8 |
|
function geodir_function_widget_listings_orderby( $orderby ) {
|
2416
|
|
|
global $wpdb, $plugin_prefix, $gd_query_args_widgets;
|
2417
|
|
|
|
2418
|
8 |
|
$query_args = $gd_query_args_widgets;
|
2419
|
8 |
|
if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
2420
|
|
|
return $orderby;
|
2421
|
8 |
|
}
|
2422
|
|
|
|
2423
|
|
|
return $orderby;
|
2424
|
8 |
|
}
|
2425
|
|
|
|
2426
|
|
|
/**
|
2427
|
|
|
* Listing query limit for widgets.
|
2428
|
|
|
*
|
2429
|
|
|
* @since 1.0.0
|
2430
|
|
|
* @package GeoDirectory
|
2431
|
|
|
* @global object $wpdb WordPress Database object.
|
2432
|
|
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
2433
|
|
|
*
|
2434
|
|
|
* @param int $limit Query limit.
|
2435
|
|
|
*
|
2436
|
|
|
* @return int Query limit.
|
2437
|
|
|
*/
|
2438
|
|
|
function geodir_function_widget_listings_limit( $limit ) {
|
2439
|
|
|
global $wpdb, $plugin_prefix, $gd_query_args_widgets;
|
2440
|
|
|
|
2441
|
|
|
$query_args = $gd_query_args_widgets;
|
2442
|
|
|
if ( empty( $query_args ) || empty( $query_args['is_geodir_loop'] ) ) {
|
2443
|
|
|
return $limit;
|
2444
|
|
|
}
|
2445
|
|
|
|
2446
|
|
|
if ( ! empty( $query_args ) && ! empty( $query_args['posts_per_page'] ) ) {
|
2447
|
|
|
$limit = (int) $query_args['posts_per_page'];
|
2448
|
|
|
}
|
2449
|
|
|
|
2450
|
|
|
return $limit;
|
2451
|
|
|
}
|
2452
|
|
|
|
2453
|
|
|
/**
|
2454
|
|
|
* WP media large width.
|
2455
|
|
|
*
|
2456
|
|
|
* @since 1.0.0
|
2457
|
|
|
* @package GeoDirectory
|
2458
|
|
|
*
|
2459
|
|
|
* @param int $default Default width.
|
2460
|
|
|
* @param string|array $params Image parameters.
|
2461
|
|
|
*
|
2462
|
|
|
* @return int Large size width.
|
2463
|
|
|
*/
|
2464
|
7 |
View Code Duplication |
function geodir_media_image_large_width( $default = 800, $params = '' ) {
|
|
|
|
|
2465
|
7 |
|
$large_size_w = get_option( 'large_size_w' );
|
2466
|
7 |
|
$large_size_w = $large_size_w > 0 ? $large_size_w : $default;
|
2467
|
|
|
$large_size_w = absint( $large_size_w );
|
2468
|
|
|
|
2469
|
7 |
|
if ( ! get_option( 'geodir_use_wp_media_large_size' ) ) {
|
2470
|
1 |
|
$large_size_w = 800;
|
2471
|
1 |
|
}
|
2472
|
|
|
|
2473
|
7 |
|
/**
|
2474
|
|
|
* Filter large image width.
|
2475
|
|
|
*
|
2476
|
|
|
* @since 1.0.0
|
2477
|
|
|
*
|
2478
|
|
|
* @param int $large_size_w Large image width.
|
2479
|
|
|
* @param int $default Default width.
|
2480
|
|
|
* @param string|array $params Image parameters.
|
2481
|
|
|
*/
|
2482
|
|
|
$large_size_w = apply_filters( 'geodir_filter_media_image_large_width', $large_size_w, $default, $params );
|
2483
|
|
|
|
2484
|
|
|
return $large_size_w;
|
2485
|
|
|
}
|
2486
|
|
|
|
2487
|
|
|
/**
|
2488
|
|
|
* WP media large height.
|
2489
|
|
|
*
|
2490
|
|
|
* @since 1.0.0
|
2491
|
|
|
* @package GeoDirectory
|
2492
|
|
|
*
|
2493
|
|
|
* @param int $default Default height.
|
2494
|
3 |
|
* @param string $params Image parameters.
|
2495
|
3 |
|
*
|
2496
|
|
|
* @return int Large size height.
|
2497
|
3 |
|
*/
|
2498
|
|
View Code Duplication |
function geodir_media_image_large_height( $default = 800, $params = '' ) {
|
|
|
|
|
2499
|
|
|
$large_size_h = get_option( 'large_size_h' );
|
2500
|
3 |
|
$large_size_h = $large_size_h > 0 ? $large_size_h : $default;
|
2501
|
|
|
$large_size_h = absint( $large_size_h );
|
2502
|
3 |
|
|
2503
|
|
|
if ( ! get_option( 'geodir_use_wp_media_large_size' ) ) {
|
2504
|
3 |
|
$large_size_h = 800;
|
2505
|
3 |
|
}
|
2506
|
|
|
|
2507
|
3 |
|
/**
|
2508
|
|
|
* Filter large image height.
|
2509
|
|
|
*
|
2510
|
3 |
|
* @since 1.0.0
|
2511
|
3 |
|
*
|
2512
|
|
|
* @param int $large_size_h Large image height.
|
2513
|
|
|
* @param int $default Default height.
|
2514
|
3 |
|
* @param string|array $params Image parameters.
|
2515
|
3 |
|
*/
|
2516
|
|
|
$large_size_h = apply_filters( 'geodir_filter_media_image_large_height', $large_size_h, $default, $params );
|
2517
|
|
|
|
2518
|
3 |
|
return $large_size_h;
|
2519
|
|
|
}
|
2520
|
|
|
|
2521
|
3 |
|
/**
|
2522
|
3 |
|
* Sanitize location name.
|
2523
|
3 |
|
*
|
2524
|
|
|
* @since 1.0.0
|
2525
|
3 |
|
* @package GeoDirectory
|
2526
|
3 |
|
*
|
2527
|
3 |
|
* @param string $type Location type. Can be gd_country, gd_region, gd_city.
|
2528
|
3 |
|
* @param string $name Location name.
|
2529
|
3 |
|
* @param bool $translate Do you want to translate the name? Default: true.
|
2530
|
|
|
*
|
2531
|
3 |
|
* @return string Sanitized name.
|
2532
|
3 |
|
*/
|
2533
|
3 |
|
function geodir_sanitize_location_name( $type, $name, $translate = true ) {
|
2534
|
3 |
|
if ( $name == '' ) {
|
2535
|
|
|
return null;
|
2536
|
3 |
|
}
|
2537
|
|
|
|
2538
|
3 |
|
$type = $type == 'gd_country' ? 'country' : $type;
|
2539
|
3 |
|
$type = $type == 'gd_region' ? 'region' : $type;
|
2540
|
|
|
$type = $type == 'gd_city' ? 'city' : $type;
|
2541
|
|
|
|
2542
|
|
|
$return = $name;
|
2543
|
|
|
if ( function_exists( 'get_actual_location_name' ) ) {
|
2544
|
|
|
$return = get_actual_location_name( $type, $name, $translate );
|
2545
|
|
|
} else {
|
2546
|
|
|
$return = preg_replace( '/-(\d+)$/', '', $return );
|
2547
|
|
|
$return = preg_replace( '/[_-]/', ' ', $return );
|
2548
|
|
|
$return = geodir_ucwords( $return );
|
2549
|
3 |
|
$return = $translate ? __( $return, 'geodirectory' ) : $return;
|
2550
|
3 |
|
}
|
2551
|
3 |
|
|
2552
|
3 |
|
return $return;
|
2553
|
|
|
}
|
2554
|
|
|
|
2555
|
|
|
|
2556
|
|
|
/**
|
2557
|
3 |
|
* Pluralize comment number.
|
2558
|
|
|
*
|
2559
|
3 |
|
* @since 1.0.0
|
2560
|
|
|
* @package GeoDirectory
|
2561
|
3 |
|
*
|
2562
|
|
|
* @param int $number Comments number.
|
2563
|
3 |
|
*/
|
2564
|
|
|
function geodir_comments_number( $number ) {
|
2565
|
3 |
|
|
2566
|
|
|
if ( $number > 1 ) {
|
2567
|
|
|
$output = str_replace( '%', number_format_i18n( $number ), __( '% Reviews', 'geodirectory' ) );
|
2568
|
|
|
} elseif ( $number == 0 || $number == '' ) {
|
2569
|
3 |
|
$output = __( 'No Reviews', 'geodirectory' );
|
2570
|
3 |
|
} else { // must be one
|
2571
|
3 |
|
$output = __( '1 Review', 'geodirectory' );
|
2572
|
3 |
|
}
|
2573
|
3 |
|
echo $output;
|
2574
|
3 |
|
}
|
2575
|
3 |
|
|
2576
|
3 |
|
/**
|
2577
|
|
|
* Checks whether the current page is geodirectory home page or not.
|
2578
|
3 |
|
*
|
2579
|
|
|
* @since 1.0.0
|
2580
|
|
|
* @package GeoDirectory
|
2581
|
|
|
* @global object $wpdb WordPress Database object.
|
2582
|
3 |
|
* @return bool If current page is GD home page returns true, else false.
|
2583
|
3 |
|
*/
|
2584
|
3 |
|
function is_page_geodir_home() {
|
2585
|
3 |
|
global $wpdb;
|
2586
|
|
|
$cur_url = str_replace( array( "https://", "http://", "www." ), array( '', '', '' ), geodir_curPageURL() );
|
2587
|
|
|
if ( function_exists( 'geodir_location_geo_home_link' ) ) {
|
2588
|
|
|
remove_filter( 'home_url', 'geodir_location_geo_home_link', 100000 );
|
2589
|
|
|
}
|
2590
|
|
|
$home_url = home_url( '', 'http' );
|
2591
|
|
|
if ( function_exists( 'geodir_location_geo_home_link' ) ) {
|
2592
|
|
|
add_filter( 'home_url', 'geodir_location_geo_home_link', 100000, 2 );
|
2593
|
|
|
}
|
2594
|
|
|
$home_url = str_replace( "www.", "", $home_url );
|
2595
|
|
|
if ( ( strpos( $home_url, $cur_url ) !== false || strpos( $home_url . '/', $cur_url ) !== false ) && ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && get_option( 'page_on_front' ) == get_option( 'geodir_home_page' ) ) ) {
|
2596
|
|
|
return true;
|
2597
|
|
|
} elseif ( get_query_var( 'page_id' ) == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && get_option( 'page_on_front' ) == get_option( 'geodir_home_page' ) ) {
|
2598
|
3 |
|
return true;
|
2599
|
3 |
|
} else {
|
2600
|
|
|
return false;
|
2601
|
3 |
|
}
|
2602
|
|
|
|
2603
|
|
|
}
|
2604
|
3 |
|
|
2605
|
3 |
|
|
2606
|
3 |
|
/**
|
2607
|
|
|
* Returns homepage canonical url for SEO plugins.
|
2608
|
3 |
|
*
|
2609
|
|
|
* @since 1.0.0
|
2610
|
3 |
|
* @package GeoDirectory
|
2611
|
|
|
* @global object $post The current post object.
|
2612
|
3 |
|
*
|
2613
|
3 |
|
* @param string $url The old url.
|
2614
|
|
|
*
|
2615
|
3 |
|
* @return string The canonical URL.
|
2616
|
|
|
*/
|
2617
|
|
|
function geodir_wpseo_homepage_canonical( $url ) {
|
2618
|
|
|
global $post;
|
2619
|
|
|
|
2620
|
|
|
if ( is_page_geodir_home() ) {
|
2621
|
|
|
return home_url();
|
2622
|
|
|
}
|
2623
|
|
|
|
2624
|
3 |
|
return $url;
|
2625
|
|
|
}
|
2626
|
3 |
|
|
2627
|
3 |
|
add_filter( 'wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10 );
|
2628
|
3 |
|
add_filter( 'aioseop_canonical_url', 'geodir_wpseo_homepage_canonical', 10 );
|
2629
|
3 |
|
|
2630
|
3 |
|
/**
|
2631
|
|
|
* Add extra fields to google maps script call.
|
2632
|
|
|
*
|
2633
|
|
|
* @since 1.0.0
|
2634
|
|
|
* @package GeoDirectory
|
2635
|
|
|
* @global object $post The current post object.
|
2636
|
|
|
*
|
2637
|
|
|
* @param string $extra Old extra string.
|
2638
|
|
|
*
|
2639
|
|
|
* @return string Modified extra string.
|
2640
|
|
|
*/
|
2641
|
|
|
function geodir_googlemap_script_extra_details_page( $extra ) {
|
2642
|
|
|
global $post;
|
2643
|
|
|
$add_google_places_api = false;
|
2644
|
2 |
|
if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'gd_add_listing' ) ) {
|
2645
|
|
|
$add_google_places_api = true;
|
2646
|
2 |
|
}
|
2647
|
|
|
if ( ! str_replace( 'libraries=places', '', $extra ) && ( geodir_is_page( 'detail' ) || $add_google_places_api ) ) {
|
2648
|
|
|
$extra .= "&libraries=places";
|
2649
|
2 |
|
}
|
2650
|
|
|
|
2651
|
|
|
return $extra;
|
2652
|
|
|
}
|
2653
|
|
|
|
2654
|
|
|
add_filter( 'geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1 );
|
2655
|
|
|
|
2656
|
2 |
|
|
2657
|
|
|
/**
|
2658
|
|
|
* Generates popular post category HTML.
|
2659
|
|
|
*
|
2660
|
|
|
* @since 1.0.0
|
2661
|
|
|
* @since 1.5.1 Added option to set default post type.
|
2662
|
|
|
* @package GeoDirectory
|
2663
|
2 |
|
* @global object $wpdb WordPress Database object.
|
2664
|
|
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
2665
|
|
|
* @global string $geodir_post_category_str The geodirectory post category.
|
2666
|
|
|
*
|
2667
|
|
|
* @param array|string $args Display arguments including before_title, after_title, before_widget, and
|
2668
|
|
|
* after_widget.
|
2669
|
|
|
* @param array|string $instance The settings for the particular instance of the widget.
|
2670
|
2 |
|
*/
|
2671
|
|
|
function geodir_popular_post_category_output( $args = '', $instance = '' ) {
|
2672
|
|
|
// prints the widget
|
2673
|
|
|
global $wpdb, $plugin_prefix, $geodir_post_category_str;
|
2674
|
|
|
extract( $args, EXTR_SKIP );
|
2675
|
|
|
|
2676
|
|
|
echo $before_widget;
|
2677
|
2 |
|
|
2678
|
|
|
/** This filter is documented in geodirectory_widgets.php */
|
2679
|
|
|
$title = empty( $instance['title'] ) ? __( 'Popular Categories', 'geodirectory' ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) );
|
2680
|
|
|
|
2681
|
|
|
$gd_post_type = geodir_get_current_posttype();
|
2682
|
|
|
|
2683
|
|
|
$category_limit = isset( $instance['category_limit'] ) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15;
|
2684
|
2 |
|
if ( ! empty( $gd_post_type ) ) {
|
2685
|
|
|
$default_post_type = $gd_post_type;
|
2686
|
|
|
} elseif ( isset( $instance['default_post_type'] ) && gdsc_is_post_type_valid( $instance['default_post_type'] ) ) {
|
2687
|
|
|
$default_post_type = $instance['default_post_type'];
|
2688
|
|
|
} else {
|
2689
|
|
|
$all_gd_post_type = geodir_get_posttypes();
|
2690
|
|
|
$default_post_type = ( isset( $all_gd_post_type[0] ) ) ? $all_gd_post_type[0] : '';
|
2691
|
2 |
|
}
|
2692
|
|
|
|
2693
|
|
|
$taxonomy = array();
|
2694
|
|
|
if ( ! empty( $gd_post_type ) ) {
|
2695
|
|
|
$taxonomy[] = $gd_post_type . "category";
|
2696
|
|
|
} else {
|
2697
|
|
|
$taxonomy = geodir_get_taxonomies( $gd_post_type );
|
2698
|
2 |
|
}
|
2699
|
|
|
|
2700
|
|
|
$terms = get_terms( $taxonomy );
|
2701
|
|
|
$a_terms = array();
|
2702
|
|
|
$b_terms = array();
|
2703
|
|
|
|
2704
|
|
|
foreach ( $terms as $term ) {
|
2705
|
2 |
|
if ( $term->count > 0 ) {
|
2706
|
|
|
$a_terms[ $term->taxonomy ][] = $term;
|
2707
|
|
|
}
|
2708
|
|
|
}
|
2709
|
|
|
|
2710
|
|
|
if ( ! empty( $a_terms ) ) {
|
2711
|
|
|
foreach ( $a_terms as $b_key => $b_val ) {
|
2712
|
2 |
|
$b_terms[ $b_key ] = geodir_sort_terms( $b_val, 'count' );
|
2713
|
|
|
}
|
2714
|
|
|
|
2715
|
|
|
$default_taxonomy = $default_post_type != '' && isset( $b_terms[ $default_post_type . 'category' ] ) ? $default_post_type . 'category' : '';
|
2716
|
|
|
|
2717
|
|
|
$tax_change_output = '';
|
2718
|
|
|
if ( count( $b_terms ) > 1 ) {
|
2719
|
2 |
|
$tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>";
|
2720
|
|
|
foreach ( $b_terms as $key => $val ) {
|
2721
|
|
|
$ptype = get_post_type_object( str_replace( "category", "", $key ) );
|
2722
|
|
|
$cpt_name = __( $ptype->labels->singular_name, 'geodirectory' );
|
2723
|
|
|
$tax_change_output .= "<option value='$key' " . selected( $key, $default_taxonomy, false ) . ">" . sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name ) . "</option>";
|
2724
|
|
|
}
|
2725
|
|
|
$tax_change_output .= "</select>";
|
2726
|
2 |
|
}
|
2727
|
|
|
|
2728
|
|
|
if ( ! empty( $b_terms ) ) {
|
2729
|
|
|
$terms = $default_taxonomy != '' && isset( $b_terms[ $default_taxonomy ] ) ? $b_terms[ $default_taxonomy ] : reset( $b_terms );// get the first array
|
2730
|
|
|
global $cat_count;//make global so we can change via function
|
2731
|
|
|
$cat_count = 0;
|
2732
|
|
|
?>
|
2733
|
2 |
|
<div class="geodir-category-list-in clearfix">
|
2734
|
|
|
<div class="geodir-cat-list clearfix">
|
2735
|
|
|
<?php
|
2736
|
|
|
echo $before_title . __( $title ) . $after_title;
|
2737
|
|
|
|
2738
|
|
|
echo $tax_change_output;
|
2739
|
|
|
|
2740
|
2 |
|
echo '<ul class="geodir-popular-cat-list">';
|
2741
|
2 |
|
|
2742
|
|
|
geodir_helper_cat_list_output( $terms, $category_limit );
|
2743
|
2 |
|
|
2744
|
|
|
echo '</ul>';
|
2745
|
|
|
?>
|
2746
|
|
|
</div>
|
2747
|
|
|
<?php
|
2748
|
|
|
$hide = '';
|
2749
|
|
|
if ( $cat_count < $category_limit ) {
|
2750
|
|
|
$hide = 'style="display:none;"';
|
2751
|
|
|
}
|
2752
|
|
|
echo "<div class='geodir-cat-list-more' $hide >";
|
2753
|
|
|
echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __( 'More Categories', 'geodirectory' ) . '</a>';
|
2754
|
|
|
echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __( 'Less Categories', 'geodirectory' ) . '</a>';
|
2755
|
|
|
echo "</div>";
|
2756
|
|
|
/* add scripts */
|
2757
|
|
|
add_action( 'wp_footer', 'geodir_popular_category_add_scripts', 100 );
|
2758
|
|
|
?>
|
2759
|
|
|
</div>
|
2760
|
|
|
<?php
|
2761
|
|
|
}
|
2762
|
|
|
}
|
2763
|
|
|
echo $after_widget;
|
2764
|
|
|
}
|
2765
|
|
|
|
2766
|
|
|
/**
|
2767
|
|
|
* Generates category list HTML.
|
2768
|
|
|
*
|
2769
|
|
|
* @since 1.0.0
|
2770
|
|
|
* @package GeoDirectory
|
2771
|
|
|
* @global string $geodir_post_category_str The geodirectory post category.
|
2772
|
|
|
*
|
2773
|
|
|
* @param array $terms An array of term objects.
|
2774
|
|
|
* @param int $category_limit Number of categories to display by default.
|
2775
|
|
|
*/
|
2776
|
|
|
function geodir_helper_cat_list_output( $terms, $category_limit ) {
|
2777
|
|
|
global $geodir_post_category_str, $cat_count;
|
2778
|
|
|
$term_icons = geodir_get_term_icon();
|
2779
|
|
|
|
2780
|
|
|
$geodir_post_category_str = array();
|
2781
|
|
|
|
2782
|
|
|
|
2783
|
|
|
foreach ( $terms as $cat ) {
|
2784
|
|
|
$post_type = str_replace( "category", "", $cat->taxonomy );
|
2785
|
|
|
$term_icon_url = ! empty( $term_icons ) && isset( $term_icons[ $cat->term_id ] ) ? $term_icons[ $cat->term_id ] : '';
|
2786
|
2 |
|
|
2787
|
2 |
|
$cat_count ++;
|
2788
|
2 |
|
|
2789
|
|
|
$geodir_post_category_str[] = array( 'posttype' => $post_type, 'termid' => $cat->term_id );
|
2790
|
2 |
|
|
2791
|
2 |
|
$class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show';
|
2792
|
1 |
|
$total_post = $cat->count;
|
2793
|
1 |
|
|
2794
|
|
|
$term_link = get_term_link( $cat, $cat->taxonomy );
|
2795
|
2 |
|
/**
|
2796
|
2 |
|
* Filer the category term link.
|
2797
|
|
|
*
|
2798
|
2 |
|
* @since 1.4.5
|
2799
|
2 |
|
*
|
2800
|
|
|
* @param string $term_link The term permalink.
|
2801
|
2 |
|
* @param int $cat ->term_id The term id.
|
2802
|
|
|
* @param string $post_type Wordpress post type.
|
2803
|
2 |
|
*/
|
2804
|
2 |
|
$term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type );
|
2805
|
|
|
|
2806
|
|
|
echo '<li class="' . $class_row . '"><a href="' . $term_link . '">';
|
2807
|
2 |
|
echo '<img alt="' . esc_attr( $cat->name ) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">';
|
2808
|
|
|
echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
|
2809
|
2 |
|
echo '</a></li>';
|
2810
|
|
|
}
|
2811
|
|
|
}
|
2812
|
|
|
|
2813
|
2 |
|
/**
|
2814
|
2 |
|
* Generates listing slider HTML.
|
2815
|
1 |
|
*
|
2816
|
|
|
* @since 1.0.0
|
2817
|
|
|
* @package GeoDirectory
|
2818
|
|
|
* @global object $post The current post object.
|
2819
|
1 |
|
*
|
2820
|
|
|
* @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
2821
|
1 |
|
* @param array|string $instance The settings for the particular instance of the widget.
|
2822
|
|
|
*/
|
2823
|
1 |
|
function geodir_listing_slider_widget_output( $args = '', $instance = '' ) {
|
2824
|
1 |
|
// prints the widget
|
2825
|
1 |
|
extract( $args, EXTR_SKIP );
|
2826
|
|
|
|
2827
|
1 |
|
echo $before_widget;
|
2828
|
1 |
|
|
2829
|
1 |
|
/** This filter is documented in geodirectory_widgets.php */
|
2830
|
1 |
|
$title = empty( $instance['title'] ) ? '' : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) );
|
2831
|
|
|
/**
|
2832
|
1 |
|
* Filter the widget post type.
|
2833
|
1 |
|
*
|
2834
|
1 |
|
* @since 1.0.0
|
2835
|
1 |
|
*
|
2836
|
1 |
|
* @param string $instance ['post_type'] Post type of listing.
|
2837
|
|
|
*/
|
2838
|
|
|
$post_type = empty( $instance['post_type'] ) ? 'gd_place' : apply_filters( 'widget_post_type', $instance['post_type'] );
|
2839
|
1 |
|
/**
|
2840
|
|
|
* Filter the widget's term.
|
2841
|
1 |
|
*
|
2842
|
1 |
|
* @since 1.0.0
|
2843
|
|
|
*
|
2844
|
|
|
* @param string $instance ['category'] Filter by term. Can be any valid term.
|
2845
|
|
|
*/
|
2846
|
|
|
$category = empty( $instance['category'] ) ? '0' : apply_filters( 'widget_category', $instance['category'] );
|
2847
|
|
|
/**
|
2848
|
|
|
* Filter the widget listings limit.
|
2849
|
|
|
*
|
2850
|
|
|
* @since 1.0.0
|
2851
|
|
|
*
|
2852
|
|
|
* @param string $instance ['post_number'] Number of listings to display.
|
2853
|
|
|
*/
|
2854
|
|
|
$post_number = empty( $instance['post_number'] ) ? '5' : apply_filters( 'widget_post_number', $instance['post_number'] );
|
2855
|
|
|
/**
|
2856
|
|
|
* Filter the widget listings limit shown at one time.
|
2857
|
|
|
*
|
2858
|
|
|
* @since 1.5.0
|
2859
|
1 |
|
*
|
2860
|
1 |
|
* @param string $instance ['max_show'] Number of listings to display on screen.
|
2861
|
1 |
|
*/
|
2862
|
1 |
|
$max_show = empty( $instance['max_show'] ) ? '1' : apply_filters( 'widget_max_show', $instance['max_show'] );
|
2863
|
1 |
|
/**
|
2864
|
|
|
* Filter the widget slide width.
|
2865
|
|
|
*
|
2866
|
|
|
* @since 1.5.0
|
2867
|
|
|
*
|
2868
|
|
|
* @param string $instance ['slide_width'] Width of the slides shown.
|
2869
|
|
|
*/
|
2870
|
|
|
$slide_width = empty( $instance['slide_width'] ) ? '' : apply_filters( 'widget_slide_width', $instance['slide_width'] );
|
2871
|
|
|
/**
|
2872
|
|
|
* Filter widget's "show title" value.
|
2873
|
|
|
*
|
2874
|
|
|
* @since 1.0.0
|
2875
|
|
|
*
|
2876
|
|
|
* @param string|bool $instance ['show_title'] Do you want to display title? Can be 1 or 0.
|
2877
|
1 |
|
*/
|
2878
|
1 |
|
$show_title = empty( $instance['show_title'] ) ? '' : apply_filters( 'widget_show_title', $instance['show_title'] );
|
2879
|
1 |
|
/**
|
2880
|
2 |
|
* Filter widget's "slideshow" value.
|
2881
|
2 |
|
*
|
2882
|
|
|
* @since 1.0.0
|
2883
|
|
|
*
|
2884
|
|
|
* @param int $instance ['slideshow'] Setup a slideshow for the slider to animate automatically.
|
2885
|
|
|
*/
|
2886
|
|
|
$slideshow = empty( $instance['slideshow'] ) ? 0 : apply_filters( 'widget_slideshow', $instance['slideshow'] );
|
2887
|
|
|
/**
|
2888
|
|
|
* Filter widget's "animationLoop" value.
|
2889
|
|
|
*
|
2890
|
|
|
* @since 1.0.0
|
2891
|
|
|
*
|
2892
|
|
|
* @param int $instance ['animationLoop'] Gives the slider a seamless infinite loop.
|
2893
|
|
|
*/
|
2894
|
|
|
$animationLoop = empty( $instance['animationLoop'] ) ? 0 : apply_filters( 'widget_animationLoop', $instance['animationLoop'] );
|
2895
|
|
|
/**
|
2896
|
|
|
* Filter widget's "directionNav" value.
|
2897
|
|
|
*
|
2898
|
2 |
|
* @since 1.0.0
|
2899
|
|
|
*
|
2900
|
|
|
* @param int $instance ['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0.
|
2901
|
2 |
|
*/
|
2902
|
|
|
$directionNav = empty( $instance['directionNav'] ) ? 0 : apply_filters( 'widget_directionNav', $instance['directionNav'] );
|
2903
|
2 |
|
/**
|
2904
|
2 |
|
* Filter widget's "slideshowSpeed" value.
|
2905
|
|
|
*
|
2906
|
2 |
|
* @since 1.0.0
|
2907
|
2 |
|
*
|
2908
|
|
|
* @param int $instance ['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds.
|
2909
|
2 |
|
*/
|
2910
|
2 |
|
$slideshowSpeed = empty( $instance['slideshowSpeed'] ) ? 5000 : apply_filters( 'widget_slideshowSpeed', $instance['slideshowSpeed'] );
|
2911
|
|
|
/**
|
2912
|
2 |
|
* Filter widget's "animationSpeed" value.
|
2913
|
2 |
|
*
|
2914
|
|
|
* @since 1.0.0
|
2915
|
|
|
*
|
2916
|
|
|
* @param int $instance ['animationSpeed'] Set the speed of animations, in milliseconds.
|
2917
|
|
|
*/
|
2918
|
2 |
|
$animationSpeed = empty( $instance['animationSpeed'] ) ? 600 : apply_filters( 'widget_animationSpeed', $instance['animationSpeed'] );
|
2919
|
2 |
|
/**
|
2920
|
2 |
|
* Filter widget's "animation" value.
|
2921
|
|
|
*
|
2922
|
2 |
|
* @since 1.0.0
|
2923
|
2 |
|
*
|
2924
|
2 |
|
* @param string $instance ['animation'] Controls the animation type, "fade" or "slide".
|
2925
|
|
|
*/
|
2926
|
2 |
|
$animation = empty( $instance['animation'] ) ? 'slide' : apply_filters( 'widget_animation', $instance['animation'] );
|
2927
|
|
|
/**
|
2928
|
2 |
|
* Filter widget's "list_sort" type.
|
2929
|
|
|
*
|
2930
|
2 |
|
* @since 1.0.0
|
2931
|
|
|
*
|
2932
|
2 |
|
* @param string $instance ['list_sort'] Listing sort by type.
|
2933
|
2 |
|
*/
|
2934
|
2 |
|
$list_sort = empty( $instance['list_sort'] ) ? 'latest' : apply_filters( 'widget_list_sort', $instance['list_sort'] );
|
2935
|
|
|
$show_featured_only = ! empty( $instance['show_featured_only'] ) ? 1 : null;
|
2936
|
|
|
|
2937
|
|
|
wp_enqueue_script( 'geodirectory-jquery-flexslider-js' );
|
2938
|
|
|
?>
|
2939
|
|
|
<script type="text/javascript">
|
2940
|
|
|
jQuery(window).load(function () {
|
2941
|
|
|
jQuery('#geodir_widget_carousel').flexslider({
|
2942
|
|
|
animation: "slide",
|
2943
|
|
|
selector: ".geodir-slides > li",
|
2944
|
2 |
|
namespace: "geodir-",
|
2945
|
|
|
controlNav: false,
|
2946
|
2 |
|
directionNav: false,
|
2947
|
|
|
animationLoop: false,
|
2948
|
2 |
|
slideshow: false,
|
2949
|
2 |
|
itemWidth: 75,
|
2950
|
|
|
itemMargin: 5,
|
2951
|
2 |
|
asNavFor: '#geodir_widget_slider',
|
2952
|
|
|
rtl: <?php echo( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
|
2953
|
|
|
});
|
2954
|
|
|
|
2955
|
|
|
jQuery('#geodir_widget_slider').flexslider({
|
2956
|
|
|
animation: "<?php echo $animation;?>",
|
2957
|
|
|
selector: ".geodir-slides > li",
|
2958
|
|
|
namespace: "geodir-",
|
2959
|
|
|
controlNav: true,
|
2960
|
|
|
animationLoop: <?php echo $animationLoop;?>,
|
2961
|
|
|
slideshow: <?php echo $slideshow;?>,
|
2962
|
2 |
|
slideshowSpeed: <?php echo $slideshowSpeed;?>,
|
2963
|
|
|
animationSpeed: <?php echo $animationSpeed;?>,
|
2964
|
2 |
|
directionNav: <?php echo $directionNav;?>,
|
2965
|
|
|
maxItems: <?php echo $max_show;?>,
|
2966
|
2 |
|
move: 1,
|
2967
|
2 |
|
<?php if ( $slide_width ) {
|
2968
|
|
|
echo "itemWidth: " . $slide_width . ",";
|
2969
|
2 |
|
}?>
|
2970
|
|
|
sync: "#geodir_widget_carousel",
|
2971
|
|
|
start: function (slider) {
|
2972
|
|
|
jQuery('.geodir-listing-flex-loader').hide();
|
2973
|
|
|
jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
|
2974
|
|
|
jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
|
2975
|
|
|
},
|
2976
|
|
|
rtl: <?php echo( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?>
|
2977
|
|
|
});
|
2978
|
|
|
});
|
2979
|
|
|
</script>
|
2980
|
|
|
<?php
|
2981
|
|
|
$query_args = array(
|
2982
|
|
|
'posts_per_page' => $post_number,
|
2983
|
|
|
'is_geodir_loop' => true,
|
2984
|
|
|
'post_type' => $post_type,
|
2985
|
|
|
'order_by' => $list_sort
|
2986
|
|
|
);
|
2987
|
|
|
if ( $show_featured_only ) {
|
|
|
|
|
2988
|
|
|
$query_args['show_featured_only'] = 1;
|
2989
|
|
|
}
|
2990
|
|
|
|
2991
|
|
|
if ( $category != 0 || $category != '' ) {
|
2992
|
|
|
$category_taxonomy = geodir_get_taxonomies( $post_type );
|
2993
|
|
|
$tax_query = array(
|
2994
|
|
|
'taxonomy' => $category_taxonomy[0],
|
2995
|
|
|
'field' => 'id',
|
2996
|
|
|
'terms' => $category
|
2997
|
|
|
);
|
2998
|
|
|
|
2999
|
|
|
$query_args['tax_query'] = array( $tax_query );
|
3000
|
|
|
}
|
3001
|
|
|
|
3002
|
|
|
// we want listings with featured image only
|
3003
|
|
|
$query_args['featured_image_only'] = 1;
|
3004
|
|
|
|
3005
|
|
|
if ( $post_type == 'gd_event' ) {
|
3006
|
|
|
$query_args['gedir_event_listing_filter'] = 'upcoming';
|
3007
|
|
|
}// show only upcoming events
|
3008
|
|
|
|
3009
|
|
|
$widget_listings = geodir_get_widget_listings( $query_args );
|
3010
|
|
|
if ( ! empty( $widget_listings ) || ( isset( $with_no_results ) && $with_no_results ) ) {
|
3011
|
2 |
|
if ( $title ) {
|
3012
|
2 |
|
echo $before_title . $title . $after_title;
|
3013
|
|
|
}
|
3014
|
2 |
|
|
3015
|
2 |
|
global $post;
|
3016
|
|
|
|
3017
|
2 |
|
$current_post = $post;// keep current post info
|
3018
|
2 |
|
|
3019
|
2 |
|
$widget_main_slides = '';
|
3020
|
2 |
|
$nav_slides = '';
|
3021
|
|
|
$widget_slides = 0;
|
3022
|
2 |
|
|
3023
|
2 |
|
foreach ( $widget_listings as $widget_listing ) {
|
3024
|
1 |
|
global $gd_widget_listing_type;
|
3025
|
1 |
|
$post = $widget_listing;
|
3026
|
|
|
$widget_image = geodir_get_featured_image( $post->ID, 'thumbnail', get_option( 'geodir_listing_no_img' ) );
|
3027
|
|
|
|
3028
|
|
|
if ( ! empty( $widget_image ) ) {
|
3029
|
|
|
if ( $widget_image->height >= 200 ) {
|
3030
|
|
|
$widget_spacer_height = 0;
|
3031
|
|
|
} else {
|
3032
|
|
|
$widget_spacer_height = ( ( 200 - $widget_image->height ) / 2 );
|
3033
|
|
|
}
|
3034
|
|
|
|
3035
|
2 |
|
$widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />';
|
3036
|
|
|
|
3037
|
2 |
|
$title = '';
|
3038
|
2 |
|
if ( $show_title ) {
|
3039
|
2 |
|
$title_html = '<div class="geodir-slider-title"><a href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a></div>';
|
3040
|
|
|
$post_id = $post->ID;
|
3041
|
2 |
|
$post_permalink = get_permalink( $post->ID );
|
3042
|
|
|
$post_title = get_the_title( $post->ID );
|
3043
|
|
|
/**
|
3044
|
|
|
* Filter the listing slider widget title.
|
3045
|
|
|
*
|
3046
|
|
|
* @since 1.6.1
|
3047
|
|
|
*
|
3048
|
|
|
* @param string $title_html The html output of the title.
|
3049
|
|
|
* @param int $post_id The post id.
|
3050
|
|
|
* @param string $post_permalink The post permalink url.
|
3051
|
|
|
* @param string $post_title The post title text.
|
3052
|
2 |
|
*/
|
3053
|
2 |
|
$title = apply_filters( 'geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title );
|
3054
|
|
|
}
|
3055
|
2 |
|
|
3056
|
|
|
$widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>';
|
3057
|
|
|
$nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>';
|
3058
|
|
|
$widget_slides ++;
|
3059
|
|
|
}
|
3060
|
|
|
}
|
3061
|
|
|
?>
|
3062
|
2 |
|
<div class="flex-container" style="min-height:200px;">
|
3063
|
2 |
|
<div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div>
|
3064
|
2 |
|
<div id="geodir_widget_slider" class="geodir_flexslider">
|
3065
|
|
|
<ul class="geodir-slides clearfix"><?php echo $widget_main_slides; ?></ul>
|
3066
|
|
|
</div>
|
3067
|
|
|
<?php if ( $widget_slides > 1 ) { ?>
|
3068
|
|
|
<div id="geodir_widget_carousel" class="geodir_flexslider">
|
3069
|
|
|
<ul class="geodir-slides clearfix"><?php echo $nav_slides; ?></ul>
|
3070
|
|
|
</div>
|
3071
|
|
|
<?php } ?>
|
3072
|
|
|
</div>
|
3073
|
|
|
<?php
|
3074
|
|
|
$GLOBALS['post'] = $current_post;
|
3075
|
|
|
setup_postdata( $current_post );
|
3076
|
|
|
}
|
3077
|
|
|
echo $after_widget;
|
3078
|
|
|
}
|
3079
|
|
|
|
3080
|
|
|
|
3081
|
|
|
/**
|
3082
|
|
|
* Generates login box HTML.
|
3083
|
|
|
*
|
3084
|
|
|
* @since 1.0.0
|
3085
|
|
|
* @package GeoDirectory
|
3086
|
|
|
* @global object $current_user Current user object.
|
3087
|
|
|
*
|
3088
|
|
|
* @param array|string $args Display arguments including before_title, after_title, before_widget, and after_widget.
|
3089
|
|
|
* @param array|string $instance The settings for the particular instance of the widget.
|
3090
|
|
|
*/
|
3091
|
|
|
function geodir_loginwidget_output( $args = '', $instance = '' ) {
|
3092
|
|
|
//print_r($args);
|
3093
|
|
|
//print_r($instance);
|
3094
|
|
|
// prints the widget
|
3095
|
|
|
extract( $args, EXTR_SKIP );
|
3096
|
|
|
|
3097
|
|
|
/** This filter is documented in geodirectory_widgets.php */
|
3098
|
|
|
$title = empty( $instance['title'] ) ? __( 'My Dashboard', 'geodirectory' ) : apply_filters( 'my_dashboard_widget_title', __( $instance['title'], 'geodirectory' ) );
|
3099
|
|
|
|
3100
|
|
|
echo $before_widget;
|
3101
|
|
|
echo $before_title . $title . $after_title;
|
3102
|
|
|
|
3103
|
|
|
if ( is_user_logged_in() ) {
|
3104
|
|
|
global $current_user;
|
3105
|
|
|
|
3106
|
|
|
$author_link = get_author_posts_url( $current_user->data->ID );
|
3107
|
|
|
$author_link = geodir_getlink( $author_link, array( 'geodir_dashbord' => 'true' ), false );
|
3108
|
|
|
|
3109
|
|
|
echo '<ul class="geodir-loginbox-list">';
|
3110
|
|
|
ob_start();
|
3111
|
|
|
?>
|
3112
|
|
|
<li><a class="signin"
|
3113
|
2 |
|
href="<?php echo wp_logout_url( home_url() ); ?>"><?php _e( 'Logout', 'geodirectory' ); ?></a></li>
|
3114
|
2 |
|
<?php
|
3115
|
|
|
$post_types = geodir_get_posttypes( 'object' );
|
3116
|
|
|
$show_add_listing_post_types_main_nav = get_option( 'geodir_add_listing_link_user_dashboard' );
|
3117
|
|
|
$geodir_allow_posttype_frontend = get_option( 'geodir_allow_posttype_frontend' );
|
|
|
|
|
3118
|
|
|
|
3119
|
|
|
if ( ! empty( $show_add_listing_post_types_main_nav ) ) {
|
3120
|
|
|
$addlisting_links = '';
|
3121
|
|
|
foreach ( $post_types as $key => $postobj ) {
|
|
|
|
|
3122
|
|
|
|
3123
|
|
|
if ( in_array( $key, $show_add_listing_post_types_main_nav ) ) {
|
3124
|
|
|
|
3125
|
|
|
if ( $add_link = geodir_get_addlisting_link( $key ) ) {
|
3126
|
|
|
|
3127
|
|
|
$name = $postobj->labels->name;
|
3128
|
|
|
|
3129
|
|
|
$selected = '';
|
3130
|
|
|
if ( geodir_get_current_posttype() == $key && geodir_is_page( 'add-listing' ) ) {
|
3131
|
|
|
$selected = 'selected="selected"';
|
3132
|
2 |
|
}
|
3133
|
|
|
|
3134
|
|
|
/**
|
3135
|
2 |
|
* Filter add listing link.
|
3136
|
|
|
*
|
3137
|
2 |
|
* @since 1.0.0
|
3138
|
|
|
*
|
3139
|
|
|
* @param string $add_link Add listing link.
|
3140
|
2 |
|
* @param string $key Add listing array key.
|
3141
|
|
|
* @param int $current_user ->ID Current user ID.
|
3142
|
|
|
*/
|
3143
|
|
|
$add_link = apply_filters( 'geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID );
|
3144
|
|
|
|
3145
|
|
|
$addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>';
|
3146
|
|
|
|
3147
|
2 |
|
}
|
3148
|
|
|
}
|
3149
|
|
|
|
3150
|
|
|
}
|
3151
|
|
|
|
3152
|
|
View Code Duplication |
if ( $addlisting_links != '' ) { ?>
|
3153
|
|
|
|
3154
|
2 |
|
<li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value"
|
3155
|
|
|
option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false"
|
3156
|
|
|
data-placeholder="<?php echo esc_attr( __( 'Add Listing', 'geodirectory' ) ); ?>">
|
3157
|
|
|
<option value="" disabled="disabled" selected="selected"
|
3158
|
|
|
style='display:none;'><?php echo esc_attr( __( 'Add Listing', 'geodirectory' ) ); ?></option>
|
3159
|
|
|
<?php echo $addlisting_links; ?>
|
3160
|
|
|
</select></li> <?php
|
3161
|
2 |
|
|
3162
|
|
|
}
|
3163
|
|
|
|
3164
|
|
|
}
|
3165
|
|
|
// My Favourites in Dashboard
|
3166
|
|
|
$show_favorite_link_user_dashboard = get_option( 'geodir_favorite_link_user_dashboard' );
|
3167
|
|
|
$user_favourite = geodir_user_favourite_listing_count();
|
3168
|
2 |
|
|
3169
|
|
|
if ( ! empty( $show_favorite_link_user_dashboard ) && ! empty( $user_favourite ) ) {
|
3170
|
|
|
$favourite_links = '';
|
3171
|
|
|
|
3172
|
|
|
foreach ( $post_types as $key => $postobj ) {
|
|
|
|
|
3173
|
|
|
if ( in_array( $key, $show_favorite_link_user_dashboard ) && array_key_exists( $key, $user_favourite ) ) {
|
3174
|
|
|
$name = $postobj->labels->name;
|
3175
|
2 |
|
$post_type_link = geodir_getlink( $author_link, array(
|
3176
|
|
|
'stype' => $key,
|
3177
|
|
|
'list' => 'favourite'
|
3178
|
|
|
), false );
|
3179
|
|
|
|
3180
|
|
|
$selected = '';
|
3181
|
|
|
|
3182
|
2 |
View Code Duplication |
if ( isset( $_REQUEST['list'] ) && $_REQUEST['list'] == 'favourite' && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key && isset( $_REQUEST['geodir_dashbord'] ) ) {
|
3183
|
|
|
$selected = 'selected="selected"';
|
3184
|
|
|
}
|
3185
|
|
|
/**
|
3186
|
|
|
* Filter favorite listing link.
|
3187
|
|
|
*
|
3188
|
|
|
* @since 1.0.0
|
3189
|
2 |
|
*
|
3190
|
2 |
|
* @param string $post_type_link Favorite listing link.
|
3191
|
|
|
* @param string $key Favorite listing array key.
|
3192
|
|
|
* @param int $current_user ->ID Current user ID.
|
3193
|
2 |
|
*/
|
3194
|
1 |
|
$post_type_link = apply_filters( 'geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID );
|
3195
|
1 |
|
|
3196
|
|
|
$favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>';
|
3197
|
|
|
}
|
3198
|
|
|
}
|
3199
|
1 |
|
|
3200
|
|
View Code Duplication |
if ( $favourite_links != '' ) {
|
3201
|
2 |
|
?>
|
3202
|
2 |
|
<li>
|
3203
|
|
|
<select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value"
|
3204
|
2 |
|
option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false"
|
3205
|
2 |
|
data-placeholder="<?php echo esc_attr( __( 'My Favorites', 'geodirectory' ) ); ?>">
|
3206
|
|
|
<option value="" disabled="disabled" selected="selected"
|
3207
|
2 |
|
style='display:none;'><?php echo esc_attr( __( 'My Favorites', 'geodirectory' ) ); ?></option>
|
3208
|
|
|
<?php echo $favourite_links; ?>
|
3209
|
|
|
</select>
|
3210
|
|
|
</li>
|
3211
|
|
|
<?php
|
3212
|
|
|
}
|
3213
|
|
|
}
|
3214
|
1 |
|
|
3215
|
1 |
|
|
3216
|
1 |
|
$show_listing_link_user_dashboard = get_option( 'geodir_listing_link_user_dashboard' );
|
3217
|
|
|
$user_listing = geodir_user_post_listing_count();
|
3218
|
|
|
|
3219
|
2 |
|
if ( ! empty( $show_listing_link_user_dashboard ) && ! empty( $user_listing ) ) {
|
3220
|
2 |
|
$listing_links = '';
|
3221
|
2 |
|
|
3222
|
|
|
foreach ( $post_types as $key => $postobj ) {
|
|
|
|
|
3223
|
2 |
|
if ( in_array( $key, $show_listing_link_user_dashboard ) && array_key_exists( $key, $user_listing ) ) {
|
3224
|
2 |
|
$name = $postobj->labels->name;
|
3225
|
2 |
|
$listing_link = geodir_getlink( $author_link, array( 'stype' => $key ), false );
|
3226
|
|
|
|
3227
|
|
|
$selected = '';
|
3228
|
|
View Code Duplication |
if ( ! isset( $_REQUEST['list'] ) && isset( $_REQUEST['geodir_dashbord'] ) && isset( $_REQUEST['stype'] ) && $_REQUEST['stype'] == $key ) {
|
3229
|
|
|
$selected = 'selected="selected"';
|
3230
|
|
|
}
|
3231
|
|
|
|
3232
|
|
|
/**
|
3233
|
|
|
* Filter my listing link.
|
3234
|
|
|
*
|
3235
|
|
|
* @since 1.0.0
|
3236
|
|
|
*
|
3237
|
|
|
* @param string $listing_link My listing link.
|
3238
|
|
|
* @param string $key My listing array key.
|
3239
|
|
|
* @param int $current_user ->ID Current user ID.
|
3240
|
|
|
*/
|
3241
|
|
|
$listing_link = apply_filters( 'geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID );
|
3242
|
|
|
|
3243
|
|
|
$listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __( ucfirst( $name ), 'geodirectory' ) . '</option>';
|
3244
|
|
|
}
|
3245
|
|
|
}
|
3246
|
|
|
|
3247
|
|
View Code Duplication |
if ( $listing_links != '' ) {
|
3248
|
|
|
?>
|
3249
|
|
|
<li>
|
3250
|
|
|
<select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value"
|
3251
|
|
|
option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false"
|
3252
|
2 |
|
data-placeholder="<?php echo esc_attr( __( 'My Listings', 'geodirectory' ) ); ?>">
|
3253
|
2 |
|
<option value="" disabled="disabled" selected="selected"
|
3254
|
2 |
|
style='display:none;'><?php echo esc_attr( __( 'My Listings', 'geodirectory' ) ); ?></option>
|
3255
|
|
|
<?php echo $listing_links; ?>
|
3256
|
|
|
</select>
|
3257
|
|
|
</li>
|
3258
|
|
|
<?php
|
3259
|
2 |
|
}
|
3260
|
|
|
}
|
3261
|
|
|
|
3262
|
2 |
|
$dashboard_link = ob_get_clean();
|
3263
|
|
|
/**
|
3264
|
|
|
* Filter dashboard links HTML.
|
3265
|
2 |
|
*
|
3266
|
|
|
* @since 1.0.0
|
3267
|
|
|
*
|
3268
|
|
|
* @param string $dashboard_link Dashboard links HTML.
|
3269
|
|
|
*/
|
3270
|
|
|
echo apply_filters( 'geodir_dashboard_links', $dashboard_link );
|
3271
|
|
|
echo '</ul>';
|
3272
|
|
|
|
3273
|
|
|
/**
|
3274
|
|
|
* Called after the loginwidget form for logged in users.
|
3275
|
|
|
*
|
3276
|
|
|
* @since 1.6.6
|
3277
|
|
|
*/
|
3278
|
2 |
|
do_action( 'geodir_after_loginwidget_form_logged_in' );
|
3279
|
|
|
|
3280
|
|
|
|
3281
|
|
|
} else {
|
3282
|
2 |
|
?>
|
3283
|
|
|
<?php
|
3284
|
|
|
/**
|
3285
|
2 |
|
* Filter signup form action link.
|
3286
|
2 |
|
*
|
3287
|
2 |
|
* @since 1.0.0
|
3288
|
2 |
|
*/
|
3289
|
|
|
?>
|
3290
|
2 |
|
<form name="loginform" class="loginform1"
|
3291
|
|
|
action="<?php echo geodir_login_url(); ?>"
|
3292
|
2 |
|
method="post">
|
3293
|
1 |
|
<div class="geodir_form_row"><input placeholder="<?php _e( 'Email', 'geodirectory' ); ?>" name="log"
|
3294
|
1 |
|
type="text" class="textfield user_login1"/> <span
|
3295
|
|
|
class="user_loginInfo"></span></div>
|
3296
|
2 |
|
<div class="geodir_form_row"><input placeholder="<?php _e( 'Password', 'geodirectory' ); ?>"
|
3297
|
1 |
|
name="pwd" type="password"
|
3298
|
1 |
|
class="textfield user_pass1 input-text"/><span
|
3299
|
|
|
class="user_passInfo"></span></div>
|
3300
|
2 |
|
|
3301
|
|
|
<input type="hidden" name="redirect_to" value="<?php echo htmlspecialchars( geodir_curPageURL() ); ?>"/>
|
3302
|
|
|
<input type="hidden" name="testcookie" value="1"/>
|
3303
|
|
|
|
3304
|
2 |
|
<?php do_action( 'login_form' ); ?>
|
3305
|
|
|
|
3306
|
|
|
<div class="geodir_form_row clearfix"><input type="submit" name="submit"
|
3307
|
|
|
value="<?php echo SIGN_IN_BUTTON; ?>" class="b_signin"/>
|
3308
|
|
|
|
3309
|
2 |
|
<p class="geodir-new-forgot-link">
|
3310
|
|
|
<?php
|
3311
|
|
|
/**
|
3312
|
2 |
|
* Filter signup page register form link.
|
3313
|
|
|
*
|
3314
|
2 |
|
* @since 1.0.0
|
3315
|
|
|
*/
|
3316
|
|
|
?>
|
3317
|
|
|
<a href="<?php echo geodir_login_url( array( 'signup' => true ) ); ?>"
|
3318
|
|
|
class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a>
|
3319
|
|
|
|
3320
|
|
|
<?php
|
3321
|
|
|
/**
|
3322
|
|
|
* Filter signup page forgot password form link.
|
3323
|
|
|
*
|
3324
|
|
|
* @since 1.0.0
|
3325
|
|
|
*/
|
3326
|
|
|
?>
|
3327
|
|
|
<a href="<?php echo geodir_login_url( array( 'forgot' => true ) ); ?>"
|
3328
|
|
|
class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div>
|
3329
|
|
|
</form>
|
3330
|
|
|
<?php
|
3331
|
|
|
/**
|
3332
|
2 |
|
* Called after the loginwidget form for logged out users.
|
3333
|
|
|
*
|
3334
|
2 |
|
* @since 1.6.6
|
3335
|
|
|
*/
|
3336
|
2 |
|
do_action( 'geodir_after_loginwidget_form_logged_out' );
|
3337
|
|
|
}
|
3338
|
|
|
|
3339
|
|
|
echo $after_widget;
|
3340
|
|
|
}
|
3341
|
|
|
|
3342
|
|
|
|
3343
|
|
|
/**
|
3344
|
|
|
* Generates popular postview HTML.
|
3345
|
|
|
*
|
3346
|
|
|
* @since 1.0.0
|
3347
|
|
|
* @since 1.5.1 View all link fixed for location filter disabled.
|
3348
|
|
|
* @package GeoDirectory
|
3349
|
|
|
* @global object $post The current post object.
|
3350
|
|
|
* @global string $gridview_columns_widget The girdview style of the listings for widget.
|
3351
|
|
|
* @global bool $geodir_is_widget_listing Is this a widget listing?. Default: false.
|
3352
|
|
|
* @global object $gd_session GeoDirectory Session object.
|
3353
|
|
|
*
|
3354
|
|
|
* @param array|string $args Display arguments including before_title, after_title, before_widget, and
|
3355
|
|
|
* after_widget.
|
3356
|
|
|
* @param array|string $instance The settings for the particular instance of the widget.
|
3357
|
|
|
*/
|
3358
|
|
|
function geodir_popular_postview_output( $args = '', $instance = '' ) {
|
3359
|
|
|
global $gd_session;
|
3360
|
2 |
|
|
3361
|
2 |
|
// prints the widget
|
3362
|
2 |
|
extract( $args, EXTR_SKIP );
|
3363
|
2 |
|
|
3364
|
2 |
|
echo $before_widget;
|
3365
|
|
|
|
3366
|
|
|
/** This filter is documented in geodirectory_widgets.php */
|
3367
|
|
|
$title = empty( $instance['title'] ) ? geodir_ucwords( $instance['category_title'] ) : apply_filters( 'widget_title', __( $instance['title'], 'geodirectory' ) );
|
3368
|
|
|
/**
|
3369
|
|
|
* Filter the widget post type.
|
3370
|
|
|
*
|
3371
|
|
|
* @since 1.0.0
|
3372
|
|
|
*
|
3373
|
2 |
|
* @param string $instance ['post_type'] Post type of listing.
|
3374
|
2 |
|
*/
|
3375
|
|
|
$post_type = empty( $instance['post_type'] ) ? 'gd_place' : apply_filters( 'widget_post_type', $instance['post_type'] );
|
3376
|
|
|
/**
|
3377
|
|
|
* Filter the widget's term.
|
3378
|
|
|
*
|
3379
|
|
|
* @since 1.0.0
|
3380
|
|
|
*
|
3381
|
|
|
* @param string $instance ['category'] Filter by term. Can be any valid term.
|
3382
|
|
|
*/
|
3383
|
|
|
$category = empty( $instance['category'] ) ? '0' : apply_filters( 'widget_category', $instance['category'] );
|
3384
|
2 |
|
/**
|
3385
|
|
|
* Filter the widget listings limit.
|
3386
|
2 |
|
*
|
3387
|
2 |
|
* @since 1.0.0
|
3388
|
2 |
|
*
|
3389
|
2 |
|
* @param string $instance ['post_number'] Number of listings to display.
|
3390
|
|
|
*/
|
3391
|
|
|
$post_number = empty( $instance['post_number'] ) ? '5' : apply_filters( 'widget_post_number', $instance['post_number'] );
|
3392
|
|
|
/**
|
3393
|
|
|
* Filter widget's "layout" type.
|
3394
|
|
|
*
|
3395
|
|
|
* @since 1.0.0
|
3396
|
2 |
|
*
|
3397
|
|
|
* @param string $instance ['layout'] Widget layout type.
|
3398
|
2 |
|
*/
|
3399
|
|
|
$layout = empty( $instance['layout'] ) ? 'gridview_onehalf' : apply_filters( 'widget_layout', $instance['layout'] );
|
3400
|
2 |
|
/**
|
3401
|
2 |
|
* Filter widget's "add_location_filter" value.
|
3402
|
2 |
|
*
|
3403
|
2 |
|
* @since 1.0.0
|
3404
|
2 |
|
*
|
3405
|
|
|
* @param string|bool $instance ['add_location_filter'] Do you want to add location filter? Can be 1 or 0.
|
3406
|
|
|
*/
|
3407
|
|
|
$add_location_filter = empty( $instance['add_location_filter'] ) ? '0' : apply_filters( 'widget_add_location_filter', $instance['add_location_filter'] );
|
3408
|
2 |
|
/**
|
3409
|
2 |
|
* Filter widget's listing width.
|
3410
|
|
|
*
|
3411
|
2 |
|
* @since 1.0.0
|
3412
|
|
|
*
|
3413
|
|
|
* @param string $instance ['listing_width'] Listing width.
|
3414
|
|
|
*/
|
3415
|
|
|
$listing_width = empty( $instance['listing_width'] ) ? '' : apply_filters( 'widget_listing_width', $instance['listing_width'] );
|
3416
|
|
|
/**
|
3417
|
|
|
* Filter widget's "list_sort" type.
|
3418
|
|
|
*
|
3419
|
|
|
* @since 1.0.0
|
3420
|
|
|
*
|
3421
|
|
|
* @param string $instance ['list_sort'] Listing sort by type.
|
3422
|
|
|
*/
|
3423
|
|
|
$list_sort = empty( $instance['list_sort'] ) ? 'latest' : apply_filters( 'widget_list_sort', $instance['list_sort'] );
|
3424
|
|
|
$use_viewing_post_type = ! empty( $instance['use_viewing_post_type'] ) ? true : false;
|
3425
|
|
|
|
3426
|
|
|
// set post type to current viewing post type
|
3427
|
|
View Code Duplication |
if ( $use_viewing_post_type ) {
|
3428
|
|
|
$current_post_type = geodir_get_current_posttype();
|
3429
|
|
|
if ( $current_post_type != '' && $current_post_type != $post_type ) {
|
3430
|
|
|
$post_type = $current_post_type;
|
3431
|
|
|
$category = array(); // old post type category will not work for current changed post type
|
3432
|
2 |
|
}
|
3433
|
|
|
}
|
3434
|
2 |
|
// replace widget title dynamically
|
3435
|
|
|
$posttype_plural_label = __( get_post_type_plural_label( $post_type ), 'geodirectory' );
|
3436
|
2 |
|
$posttype_singular_label = __( get_post_type_singular_label( $post_type ), 'geodirectory' );
|
3437
|
|
|
|
3438
|
|
|
$title = str_replace( "%posttype_plural_label%", $posttype_plural_label, $title );
|
3439
|
|
|
$title = str_replace( "%posttype_singular_label%", $posttype_singular_label, $title );
|
3440
|
|
|
|
3441
|
|
View Code Duplication |
if ( isset( $instance['character_count'] ) ) {
|
3442
|
|
|
/**
|
3443
|
|
|
* Filter the widget's excerpt character count.
|
3444
|
|
|
*
|
3445
|
|
|
* @since 1.0.0
|
3446
|
|
|
*
|
3447
|
2 |
|
* @param int $instance ['character_count'] Excerpt character count.
|
3448
|
|
|
*/
|
3449
|
2 |
|
$character_count = apply_filters( 'widget_list_character_count', $instance['character_count'] );
|
3450
|
|
|
} else {
|
3451
|
2 |
|
$character_count = '';
|
3452
|
|
|
}
|
3453
|
|
|
|
3454
|
|
|
if ( empty( $title ) || $title == 'All' ) {
|
3455
|
|
|
$title .= ' ' . __( get_post_type_plural_label( $post_type ), 'geodirectory' );
|
3456
|
|
|
}
|
3457
|
|
|
|
3458
|
|
|
$location_url = array();
|
3459
|
|
|
$city = get_query_var( 'gd_city' );
|
3460
|
|
|
if ( ! empty( $city ) ) {
|
3461
|
|
|
$country = get_query_var( 'gd_country' );
|
3462
|
|
|
$region = get_query_var( 'gd_region' );
|
3463
|
|
|
|
3464
|
|
|
$geodir_show_location_url = get_option( 'geodir_show_location_url' );
|
3465
|
|
|
|
3466
|
|
|
if ( $geodir_show_location_url == 'all' ) {
|
3467
|
|
|
if ( $country != '' ) {
|
3468
|
|
|
$location_url[] = $country;
|
3469
|
|
|
}
|
3470
|
|
|
|
3471
|
|
|
if ( $region != '' ) {
|
3472
|
|
|
$location_url[] = $region;
|
3473
|
|
|
}
|
3474
|
|
|
} else if ( $geodir_show_location_url == 'country_city' ) {
|
3475
|
8 |
|
if ( $country != '' ) {
|
3476
|
8 |
|
$location_url[] = $country;
|
3477
|
|
|
}
|
3478
|
|
|
} else if ( $geodir_show_location_url == 'region_city' ) {
|
3479
|
|
|
if ( $region != '' ) {
|
3480
|
8 |
|
$location_url[] = $region;
|
3481
|
|
|
}
|
3482
|
8 |
|
}
|
3483
|
7 |
|
|
3484
|
7 |
|
$location_url[] = $city;
|
3485
|
7 |
|
}
|
3486
|
7 |
|
|
3487
|
7 |
|
$location_url = implode( '/', $location_url );
|
3488
|
7 |
|
$skip_location = false;
|
3489
|
|
|
if ( ! $add_location_filter && $gd_session->get( 'gd_multi_location' ) ) {
|
3490
|
7 |
|
$skip_location = true;
|
3491
|
2 |
|
$gd_session->un_set( 'gd_multi_location' );
|
3492
|
2 |
|
}
|
3493
|
2 |
|
|
3494
|
2 |
|
if ( get_option( 'permalink_structure' ) ) {
|
3495
|
2 |
|
$viewall_url = get_post_type_archive_link( $post_type );
|
3496
|
2 |
|
} else {
|
3497
|
|
|
$viewall_url = get_post_type_archive_link( $post_type );
|
3498
|
7 |
|
}
|
3499
|
|
|
|
3500
|
7 |
|
if ( ! empty( $category ) && $category[0] != '0' ) {
|
3501
|
7 |
|
global $geodir_add_location_url;
|
3502
|
|
|
|
3503
|
7 |
|
$geodir_add_location_url = '0';
|
3504
|
|
|
|
3505
|
|
|
if ( $add_location_filter != '0' ) {
|
3506
|
|
|
$geodir_add_location_url = '1';
|
3507
|
7 |
|
}
|
3508
|
|
|
|
3509
|
|
|
$viewall_url = get_term_link( (int) $category[0], $post_type . 'category' );
|
3510
|
|
|
|
3511
|
|
|
$geodir_add_location_url = null;
|
3512
|
|
|
}
|
3513
|
|
|
if ( $skip_location ) {
|
3514
|
|
|
$gd_session->set( 'gd_multi_location', 1 );
|
3515
|
|
|
}
|
3516
|
7 |
|
|
3517
|
|
|
if ( is_wp_error( $viewall_url ) ) {
|
3518
|
|
|
$viewall_url = '';
|
3519
|
|
|
}
|
3520
|
|
|
|
3521
|
|
|
$query_args = array(
|
3522
|
|
|
'posts_per_page' => $post_number,
|
3523
|
|
|
'is_geodir_loop' => true,
|
3524
|
|
|
'gd_location' => $add_location_filter ? true : false,
|
3525
|
|
|
'post_type' => $post_type,
|
3526
|
|
|
'order_by' => $list_sort
|
3527
|
|
|
);
|
3528
|
|
|
|
3529
|
|
|
if ( $character_count ) {
|
3530
|
|
|
$query_args['excerpt_length'] = $character_count;
|
3531
|
|
|
}
|
3532
|
|
|
|
3533
|
|
|
if ( ! empty( $instance['show_featured_only'] ) ) {
|
3534
|
|
|
$query_args['show_featured_only'] = 1;
|
3535
|
|
|
}
|
3536
|
|
|
|
3537
|
|
|
if ( ! empty( $instance['show_special_only'] ) ) {
|
3538
|
|
|
$query_args['show_special_only'] = 1;
|
3539
|
|
|
}
|
3540
|
|
|
|
3541
|
|
View Code Duplication |
if ( ! empty( $instance['with_pics_only'] ) ) {
|
3542
|
|
|
$query_args['with_pics_only'] = 0;
|
3543
|
|
|
$query_args['featured_image_only'] = 1;
|
3544
|
7 |
|
}
|
3545
|
|
|
|
3546
|
7 |
|
if ( ! empty( $instance['with_videos_only'] ) ) {
|
3547
|
7 |
|
$query_args['with_videos_only'] = 1;
|
3548
|
|
|
}
|
3549
|
1 |
|
$with_no_results = ! empty( $instance['without_no_results'] ) ? false : true;
|
3550
|
|
|
|
3551
|
|
View Code Duplication |
if ( ! empty( $category ) && $category[0] != '0' ) {
|
3552
|
|
|
$category_taxonomy = geodir_get_taxonomies( $post_type );
|
3553
|
|
|
|
3554
|
|
|
######### WPML #########
|
3555
|
|
|
if ( function_exists( 'icl_object_id' ) ) {
|
3556
|
|
|
$category = gd_lang_object_ids( $category, $category_taxonomy[0] );
|
3557
|
|
|
}
|
3558
|
|
|
######### WPML #########
|
3559
|
|
|
|
3560
|
|
|
$tax_query = array(
|
3561
|
|
|
'taxonomy' => $category_taxonomy[0],
|
3562
|
8 |
|
'field' => 'id',
|
3563
|
|
|
'terms' => $category
|
3564
|
|
|
);
|
3565
|
|
|
|
3566
|
8 |
|
$query_args['tax_query'] = array( $tax_query );
|
3567
|
|
|
}
|
3568
|
|
|
|
3569
|
|
|
global $gridview_columns_widget, $geodir_is_widget_listing;
|
3570
|
8 |
|
|
3571
|
8 |
|
$widget_listings = geodir_get_widget_listings( $query_args );
|
3572
|
8 |
|
|
3573
|
2 |
|
if ( ! empty( $widget_listings ) || $with_no_results ) {
|
3574
|
|
|
?>
|
3575
|
|
|
<div class="geodir_locations geodir_location_listing">
|
3576
|
6 |
|
|
3577
|
|
|
<?php
|
3578
|
|
|
/**
|
3579
|
|
|
* Called before the div containing the title and view all link in popular post view widget.
|
3580
|
6 |
|
*
|
3581
|
6 |
|
* @since 1.0.0
|
3582
|
6 |
|
*/
|
3583
|
6 |
|
do_action( 'geodir_before_view_all_link_in_widget' ); ?>
|
3584
|
|
|
<div class="geodir_list_heading clearfix">
|
3585
|
6 |
|
<?php echo $before_title . $title . $after_title; ?>
|
3586
|
5 |
|
<a href="<?php echo $viewall_url; ?>"
|
3587
|
5 |
|
class="geodir-viewall"><?php _e( 'View all', 'geodirectory' ); ?></a>
|
3588
|
|
|
</div>
|
3589
|
6 |
|
<?php
|
3590
|
|
|
/**
|
3591
|
|
|
* Called after the div containing the title and view all link in popular post view widget.
|
3592
|
|
|
*
|
3593
|
4 |
|
* @since 1.0.0
|
3594
|
4 |
|
*/
|
3595
|
|
|
do_action( 'geodir_after_view_all_link_in_widget' ); ?>
|
3596
|
|
|
<?php
|
3597
|
|
View Code Duplication |
if ( strstr( $layout, 'gridview' ) ) {
|
3598
|
|
|
$listing_view_exp = explode( '_', $layout );
|
3599
|
|
|
$gridview_columns_widget = $layout;
|
3600
|
|
|
$layout = $listing_view_exp[0];
|
3601
|
|
|
} else {
|
3602
|
|
|
$gridview_columns_widget = '';
|
3603
|
|
|
}
|
3604
|
|
|
|
3605
|
|
|
/**
|
3606
|
|
|
* Filter the widget listing listview template path.
|
3607
|
|
|
*
|
3608
|
|
|
* @since 1.0.0
|
3609
|
|
|
*/
|
3610
|
|
|
$template = apply_filters( "geodir_template_part-widget-listing-listview", geodir_locate_template( 'widget-listing-listview' ) );
|
3611
|
|
|
if ( ! isset( $character_count ) ) {
|
3612
|
|
|
/**
|
3613
|
|
|
* Filter the widget's excerpt character count.
|
3614
|
|
|
*
|
3615
|
|
|
* @since 1.0.0
|
3616
|
|
|
*
|
3617
|
|
|
* @param int $instance ['character_count'] Excerpt character count.
|
3618
|
|
|
*/
|
3619
|
|
|
$character_count = $character_count == '' ? 50 : apply_filters( 'widget_character_count', $character_count );
|
3620
|
|
|
}
|
3621
|
|
|
|
3622
|
|
|
global $post, $map_jason, $map_canvas_arr;
|
3623
|
|
|
|
3624
|
|
|
$current_post = $post;
|
3625
|
|
|
$current_map_jason = $map_jason;
|
3626
|
|
|
$current_map_canvas_arr = $map_canvas_arr;
|
3627
|
|
|
$geodir_is_widget_listing = true;
|
3628
|
|
|
|
3629
|
|
|
/**
|
3630
|
|
|
* Includes related listing listview template.
|
3631
|
|
|
*
|
3632
|
4 |
|
* @since 1.0.0
|
3633
|
4 |
|
*/
|
3634
|
|
|
include( $template );
|
3635
|
|
|
|
3636
|
|
|
$geodir_is_widget_listing = false;
|
3637
|
|
|
|
3638
|
|
|
$GLOBALS['post'] = $current_post;
|
3639
|
|
|
if ( ! empty( $current_post ) ) {
|
3640
|
|
|
setup_postdata( $current_post );
|
3641
|
|
|
}
|
3642
|
|
|
$map_jason = $current_map_jason;
|
3643
|
|
|
$map_canvas_arr = $current_map_canvas_arr;
|
3644
|
|
|
?>
|
3645
|
|
|
</div>
|
3646
|
1 |
|
<?php
|
3647
|
1 |
|
}
|
3648
|
|
|
echo $after_widget;
|
3649
|
|
|
|
3650
|
|
|
}
|
3651
|
|
|
|
3652
|
|
|
|
3653
|
|
|
/*-----------------------------------------------------------------------------------*/
|
3654
|
|
|
/* Review count functions
|
3655
|
|
|
/*-----------------------------------------------------------------------------------*/
|
3656
|
|
|
/**
|
3657
|
|
|
* Count reviews by term ID.
|
3658
|
|
|
*
|
3659
|
|
|
* @since 1.0.0
|
3660
|
|
|
* @since 1.5.1 Added filter to change SQL.
|
3661
|
5 |
|
* @package GeoDirectory
|
3662
|
4 |
|
* @global object $wpdb WordPress Database object.
|
3663
|
|
|
* @global string $plugin_prefix Geodirectory plugin table prefix.
|
3664
|
1 |
|
*
|
3665
|
1 |
|
* @param int $term_id The term ID.
|
3666
|
|
|
* @param int $taxonomy The taxonomy Id.
|
3667
|
|
|
* @param string $post_type The post type.
|
3668
|
|
|
*
|
3669
|
|
|
* @return int Reviews count.
|
3670
|
|
|
*/
|
3671
|
|
|
function geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type ) {
|
3672
|
|
|
global $wpdb, $plugin_prefix;
|
3673
|
|
|
|
3674
|
|
|
$detail_table = $plugin_prefix . $post_type . '_detail';
|
3675
|
|
|
|
3676
|
|
|
$sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
|
3677
|
|
|
|
3678
|
|
|
/**
|
3679
|
|
|
* Filter count review sql query.
|
3680
|
|
|
*
|
3681
|
|
|
* @since 1.5.1
|
3682
|
|
|
*
|
3683
|
|
|
* @param string $sql Database sql query..
|
3684
|
|
|
* @param int $term_id The term ID.
|
3685
|
|
|
* @param int $taxonomy The taxonomy Id.
|
3686
|
|
|
* @param string $post_type The post type.
|
3687
|
|
|
*/
|
3688
|
|
|
$sql = apply_filters( 'geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type );
|
3689
|
|
|
|
3690
|
|
|
$count = $wpdb->get_var( $sql );
|
3691
|
|
|
|
3692
|
|
|
return $count;
|
3693
|
|
|
}
|
3694
|
|
|
|
3695
|
|
|
/**
|
3696
|
|
|
* Count reviews by terms.
|
3697
|
4 |
|
*
|
3698
|
|
|
* @since 1.0.0
|
3699
|
|
|
* @since 1.6.1 Fixed add listing page load time.
|
3700
|
|
|
* @package GeoDirectory
|
3701
|
|
|
*
|
3702
|
|
|
* @global object $gd_session GeoDirectory Session object.
|
3703
|
|
|
*
|
3704
|
|
|
* @param bool $force_update Force update option value?. Default.false.
|
3705
|
|
|
*
|
3706
|
|
|
* @return array Term array data.
|
3707
|
|
|
*/
|
3708
|
|
|
function geodir_count_reviews_by_terms( $force_update = false, $post_ID = 0 ) {
|
3709
|
|
|
/**
|
3710
|
|
|
* Filter review count option data.
|
3711
|
1 |
|
*
|
3712
|
|
|
* @since 1.0.0
|
3713
|
|
|
* @since 1.6.1 Added $post_ID param.
|
3714
|
|
|
*
|
3715
|
|
|
* @param bool $force_update Force update option value?. Default.false.
|
3716
|
|
|
* @param int $post_ID The post id to update if any.
|
3717
|
|
|
*/
|
3718
|
|
|
$option_data = apply_filters( 'geodir_count_reviews_by_terms_before', '', $force_update, $post_ID );
|
3719
|
|
|
if ( ! empty( $option_data ) ) {
|
3720
|
|
|
return $option_data;
|
3721
|
|
|
}
|
3722
|
|
|
|
3723
|
|
|
$option_data = get_option( 'geodir_global_review_count' );
|
3724
|
|
|
|
3725
|
|
|
if ( ! $option_data || $force_update ) {
|
3726
|
|
|
if ( (int) $post_ID > 0 ) { // Update reviews count for specific post categories only.
|
3727
|
|
|
global $gd_session;
|
3728
|
|
|
$term_array = (array) $option_data;
|
3729
|
|
|
$post_type = get_post_type( $post_ID );
|
3730
|
|
|
$taxonomy = $post_type . 'category';
|
3731
|
|
|
$terms = wp_get_object_terms( $post_ID, $taxonomy, array( 'fields' => 'ids' ) );
|
3732
|
|
|
|
3733
|
|
View Code Duplication |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
|
3734
|
|
|
foreach ( $terms as $term_id ) {
|
3735
|
|
|
$count = geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type );
|
3736
|
|
|
$children = get_term_children( $term_id, $taxonomy );
|
|
|
|
|
3737
|
|
|
$term_array[ $term_id ] = $count;
|
3738
|
|
|
}
|
3739
|
|
|
}
|
3740
|
|
|
|
3741
|
|
|
$session_listing = $gd_session->get( 'listing' );
|
3742
|
|
|
|
3743
|
|
|
$terms = array();
|
3744
|
|
|
if ( isset( $_POST['post_category'][ $taxonomy ] ) ) {
|
3745
|
|
|
$terms = (array) $_POST['post_category'][ $taxonomy ];
|
3746
|
|
|
} else if ( ! empty( $session_listing ) && isset( $session_listing['post_category'][ $taxonomy ] ) ) {
|
3747
|
|
|
$terms = (array) $session_listing['post_category'][ $taxonomy ];
|
3748
|
|
|
}
|
3749
|
|
|
|
3750
|
|
View Code Duplication |
if ( ! empty( $terms ) ) {
|
3751
|
|
|
foreach ( $terms as $term_id ) {
|
3752
|
|
|
if ( $term_id > 0 ) {
|
3753
|
|
|
$count = geodir_count_reviews_by_term_id( $term_id, $taxonomy, $post_type );
|
3754
|
|
|
$children = get_term_children( $term_id, $taxonomy );
|
|
|
|
|
3755
|
|
|
$term_array[ $term_id ] = $count;
|
3756
|
|
|
}
|
3757
|
|
|
}
|
3758
|
|
|
}
|
3759
|
|
|
} else { // Update reviews count for all post categories.
|
3760
|
|
|
$term_array = array();
|
3761
|
|
|
$post_types = geodir_get_posttypes();
|
3762
|
|
|
foreach ( $post_types as $post_type ) {
|
|
|
|
|
3763
|
|
|
|
3764
|
|
|
$taxonomy = geodir_get_taxonomies( $post_type );
|
3765
|
|
|
$taxonomy = $taxonomy[0];
|
3766
|
|
|
|
3767
|
|
|
$args = array(
|
3768
|
|
|
'hide_empty' => false
|
3769
|
|
|
);
|
3770
|
|
|
|
3771
|
1 |
|
$terms = get_terms( $taxonomy, $args );
|
3772
|
1 |
|
|
3773
|
1 |
|
foreach ( $terms as $term ) {
|
3774
|
1 |
|
$count = geodir_count_reviews_by_term_id( $term->term_id, $taxonomy, $post_type );
|
3775
|
1 |
|
$children = get_term_children( $term->term_id, $taxonomy );
|
|
|
|
|
3776
|
1 |
|
/*if ( is_array( $children ) ) {
|
|
|
|
|
3777
|
|
|
foreach ( $children as $child_id ) {
|
3778
|
1 |
|
$child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type);
|
3779
|
|
|
$count = $count + $child_count;
|
3780
|
1 |
|
}
|
3781
|
1 |
|
}*/
|
3782
|
|
|
$term_array[ $term->term_id ] = $count;
|
3783
|
1 |
|
}
|
3784
|
1 |
|
}
|
3785
|
|
|
}
|
3786
|
1 |
|
|
3787
|
|
|
update_option( 'geodir_global_review_count', $term_array );
|
3788
|
|
|
//clear cache
|
3789
|
|
|
wp_cache_delete( 'geodir_global_review_count' );
|
3790
|
|
|
|
3791
|
|
|
return $term_array;
|
3792
|
|
|
} else {
|
3793
|
|
|
return $option_data;
|
3794
|
|
|
}
|
3795
|
1 |
|
}
|
3796
|
|
|
|
3797
|
1 |
|
/**
|
3798
|
|
|
* Force update review count.
|
3799
|
1 |
|
*
|
3800
|
1 |
|
* @since 1.0.0
|
3801
|
1 |
|
* @since 1.6.1 Fixed add listing page load time.
|
3802
|
1 |
|
* @package GeoDirectory
|
3803
|
1 |
|
* @return bool
|
3804
|
1 |
|
*/
|
3805
|
1 |
|
function geodir_term_review_count_force_update( $new_status, $old_status = '', $post = '' ) {
|
3806
|
1 |
|
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'geodir_import_export' ) {
|
3807
|
1 |
|
return; // do not run if importing listings
|
3808
|
1 |
|
}
|
3809
|
|
|
|
3810
|
1 |
|
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
3811
|
1 |
|
return;
|
3812
|
1 |
|
}
|
3813
|
|
|
|
3814
|
1 |
|
$post_ID = 0;
|
3815
|
|
|
if ( ! empty( $post ) ) {
|
3816
|
1 |
|
if ( isset( $post->post_type ) && strpos( $post->post_type, 'gd_' ) !== 0 ) {
|
3817
|
1 |
|
return;
|
3818
|
1 |
|
}
|
3819
|
1 |
|
|
3820
|
1 |
|
if ( $new_status == 'auto-draft' && $old_status == 'new' ) {
|
3821
|
1 |
|
return;
|
3822
|
1 |
|
}
|
3823
|
1 |
|
|
3824
|
|
|
if ( ! empty( $post->ID ) ) {
|
3825
|
1 |
|
$post_ID = $post->ID;
|
3826
|
|
|
}
|
3827
|
1 |
|
}
|
3828
|
1 |
|
|
3829
|
|
|
if ( $new_status != $old_status ) {
|
3830
|
|
|
geodir_count_reviews_by_terms( true, $post_ID );
|
3831
|
|
|
}
|
3832
|
|
|
|
3833
|
|
|
return true;
|
3834
|
|
|
}
|
3835
|
|
|
|
3836
|
|
|
function geodir_term_review_count_force_update_single_post( $post_id ) {
|
3837
|
|
|
geodir_count_reviews_by_terms( true, $post_id );
|
3838
|
|
|
}
|
3839
|
|
|
|
3840
|
|
|
/*-----------------------------------------------------------------------------------*/
|
3841
|
|
|
/* Term count functions
|
3842
|
|
|
/*-----------------------------------------------------------------------------------*/
|
3843
|
|
|
/**
|
3844
|
|
|
* Count posts by term.
|
3845
|
|
|
*
|
3846
|
1 |
|
* @since 1.0.0
|
3847
|
|
|
* @package GeoDirectory
|
3848
|
|
|
*
|
3849
|
1 |
|
* @param array $data Count data array.
|
3850
|
1 |
|
* @param object $term The term object.
|
3851
|
|
|
*
|
3852
|
1 |
|
* @return int Post count.
|
3853
|
1 |
|
*/
|
3854
|
1 |
|
function geodir_count_posts_by_term( $data, $term ) {
|
3855
|
1 |
|
|
3856
|
|
|
if ( $data ) {
|
|
|
|
|
3857
|
1 |
|
if ( isset( $data[ $term->term_id ] ) ) {
|
3858
|
1 |
|
return $data[ $term->term_id ];
|
3859
|
|
|
} else {
|
3860
|
1 |
|
return 0;
|
3861
|
1 |
|
}
|
3862
|
|
|
} else {
|
3863
|
1 |
|
return $term->count;
|
3864
|
1 |
|
}
|
3865
|
|
|
}
|
3866
|
1 |
|
|
3867
|
1 |
|
/**
|
3868
|
|
|
* Sort terms object by post count.
|
3869
|
1 |
|
*
|
3870
|
1 |
|
* @since 1.0.0
|
3871
|
|
|
* @package GeoDirectory
|
3872
|
1 |
|
* param array $terms An array of term objects.
|
3873
|
1 |
|
* @return array Sorted terms array.
|
3874
|
|
|
*/
|
3875
|
1 |
|
function geodir_sort_terms_by_count( $terms ) {
|
3876
|
1 |
|
usort( $terms, "geodir_sort_by_count_obj" );
|
3877
|
1 |
|
|
3878
|
1 |
|
return $terms;
|
3879
|
1 |
|
}
|
3880
|
1 |
|
|
3881
|
1 |
|
/**
|
3882
|
1 |
|
* Sort terms object by review count.
|
3883
|
1 |
|
*
|
3884
|
1 |
|
* @since 1.0.0
|
3885
|
|
|
* @package GeoDirectory
|
3886
|
|
|
*
|
3887
|
1 |
|
* @param array $terms An array of term objects.
|
3888
|
1 |
|
*
|
3889
|
|
|
* @return array Sorted terms array.
|
3890
|
1 |
|
*/
|
3891
|
|
|
function geodir_sort_terms_by_review_count( $terms ) {
|
3892
|
|
|
usort( $terms, "geodir_sort_by_review_count_obj" );
|
3893
|
|
|
|
3894
|
|
|
return $terms;
|
3895
|
|
|
}
|
3896
|
|
|
|
3897
|
|
|
/**
|
3898
|
|
|
* Sort terms either by post count or review count.
|
3899
|
|
|
*
|
3900
|
|
|
* @since 1.0.0
|
3901
|
|
|
* @package GeoDirectory
|
3902
|
|
|
*
|
3903
|
|
|
* @param array $terms An array of term objects.
|
3904
|
1 |
|
* @param string $sort The sort type. Can be count (Post Count) or review_count. Default. count.
|
3905
|
|
|
*
|
3906
|
|
|
* @return array Sorted terms array.
|
3907
|
|
|
*/
|
3908
|
|
|
function geodir_sort_terms( $terms, $sort = 'count' ) {
|
3909
|
|
|
if ( $sort == 'count' ) {
|
3910
|
|
|
return geodir_sort_terms_by_count( $terms );
|
3911
|
|
|
}
|
3912
|
|
|
if ( $sort == 'review_count' ) {
|
3913
|
|
|
return geodir_sort_terms_by_review_count( $terms );
|
3914
|
|
|
}
|
3915
|
|
|
}
|
3916
|
|
|
|
3917
|
|
|
/*-----------------------------------------------------------------------------------*/
|
3918
|
|
|
/* Utils
|
3919
|
|
|
/*-----------------------------------------------------------------------------------*/
|
3920
|
|
|
/**
|
3921
|
|
|
* Compares post count from array for sorting.
|
3922
|
1 |
|
*
|
3923
|
|
|
* @since 1.0.0
|
3924
|
1 |
|
* @package GeoDirectory
|
3925
|
|
|
*
|
3926
|
|
|
* @param array $a The left side array to compare.
|
3927
|
|
|
* @param array $b The right side array to compare.
|
3928
|
|
|
*
|
3929
|
|
|
* @return bool
|
3930
|
|
|
*/
|
3931
|
|
|
function geodir_sort_by_count( $a, $b ) {
|
3932
|
|
|
return $a['count'] < $b['count'];
|
3933
|
|
|
}
|
3934
|
|
|
|
3935
|
|
|
/**
|
3936
|
|
|
* Compares post count from object for sorting.
|
3937
|
|
|
*
|
3938
|
|
|
* @since 1.0.0
|
3939
|
|
|
* @package GeoDirectory
|
3940
|
|
|
*
|
3941
|
|
|
* @param object $a The left side object to compare.
|
3942
|
|
|
* @param object $b The right side object to compare.
|
3943
|
|
|
*
|
3944
|
|
|
* @return bool
|
3945
|
|
|
*/
|
3946
|
|
|
function geodir_sort_by_count_obj( $a, $b ) {
|
3947
|
|
|
return $a->count < $b->count;
|
3948
|
|
|
}
|
3949
|
|
|
|
3950
|
|
|
/**
|
3951
|
|
|
* Compares review count from object for sorting.
|
3952
|
|
|
*
|
3953
|
|
|
* @since 1.0.0
|
3954
|
|
|
* @package GeoDirectory
|
3955
|
|
|
*
|
3956
|
|
|
* @param object $a The left side object to compare.
|
3957
|
|
|
* @param object $b The right side object to compare.
|
3958
|
|
|
*
|
3959
|
|
|
* @return bool
|
3960
|
|
|
*/
|
3961
|
|
|
function geodir_sort_by_review_count_obj( $a, $b ) {
|
3962
|
|
|
return $a->review_count < $b->review_count;
|
3963
|
|
|
}
|
3964
|
|
|
|
3965
|
|
|
/**
|
3966
|
|
|
* Load geodirectory plugin textdomain.
|
3967
|
|
|
*
|
3968
|
|
|
* @since 1.4.2
|
3969
|
|
|
* @package GeoDirectory
|
3970
|
|
|
*/
|
3971
|
|
|
function geodir_load_textdomain() {
|
3972
|
|
|
/**
|
3973
|
|
|
* Filter the plugin locale.
|
3974
|
|
|
*
|
3975
|
|
|
* @since 1.4.2
|
3976
|
|
|
* @package GeoDirectory
|
3977
|
|
|
*/
|
3978
|
|
|
$locale = apply_filters( 'plugin_locale', get_locale(), 'geodirectory' );
|
3979
|
|
|
|
3980
|
|
|
load_textdomain( 'geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo' );
|
3981
|
|
|
load_plugin_textdomain( 'geodirectory', false, plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/geodirectory-languages' );
|
3982
|
|
|
|
3983
|
|
|
/**
|
3984
|
|
|
* Define language constants.
|
3985
|
|
|
*
|
3986
|
|
|
* @since 1.0.0
|
3987
|
|
|
*/
|
3988
|
|
|
require_once( geodir_plugin_path() . '/language.php' );
|
3989
|
|
|
|
3990
|
|
|
$language_file = geodir_plugin_path() . '/db-language.php';
|
3991
|
|
|
|
3992
|
|
|
// Load language string file if not created yet
|
3993
|
|
|
if ( ! file_exists( $language_file ) ) {
|
3994
|
|
|
geodirectory_load_db_language();
|
3995
|
|
|
}
|
3996
|
|
|
|
3997
|
|
|
if ( file_exists( $language_file ) ) {
|
3998
|
|
|
/**
|
3999
|
|
|
* Language strings from database.
|
4000
|
|
|
*
|
4001
|
|
|
* @since 1.4.2
|
4002
|
|
|
*/
|
4003
|
|
|
try {
|
4004
|
|
|
require_once( $language_file );
|
4005
|
|
|
} catch ( Exception $e ) {
|
4006
|
|
|
error_log( 'Language Error: ' . $e->getMessage() );
|
4007
|
|
|
}
|
4008
|
|
|
}
|
4009
|
|
|
}
|
4010
|
|
|
|
4011
|
|
|
/**
|
4012
|
9 |
|
* Load language strings in to file to translate via po editor
|
4013
|
|
|
*
|
4014
|
9 |
|
* @since 1.4.2
|
4015
|
|
|
* @package GeoDirectory
|
4016
|
9 |
|
*
|
4017
|
2 |
|
* @global null|object $wp_filesystem WP_Filesystem object.
|
4018
|
2 |
|
*
|
4019
|
2 |
|
* @return bool True if file created otherwise false
|
4020
|
|
|
*/
|
4021
|
|
|
function geodirectory_load_db_language() {
|
4022
|
|
|
global $wp_filesystem;
|
4023
|
|
|
if ( empty( $wp_filesystem ) ) {
|
4024
|
2 |
|
require_once( ABSPATH . '/wp-admin/includes/file.php' );
|
4025
|
|
|
WP_Filesystem();
|
4026
|
9 |
|
global $wp_filesystem;
|
4027
|
|
|
}
|
4028
|
|
|
|
4029
|
|
|
$language_file = geodir_plugin_path() . '/db-language.php';
|
4030
|
|
|
|
4031
|
|
|
if ( is_file( $language_file ) && ! is_writable( $language_file ) ) {
|
4032
|
|
|
return false;
|
4033
|
|
|
} // Not possible to create.
|
4034
|
|
|
|
4035
|
|
|
if ( ! is_file( $language_file ) && ! is_writable( dirname( $language_file ) ) ) {
|
4036
|
|
|
return false;
|
4037
|
|
|
} // Not possible to create.
|
4038
|
|
|
|
4039
|
|
|
$contents_strings = array();
|
4040
|
|
|
|
4041
|
|
|
/**
|
4042
|
|
|
* Filter the language string from database to translate via po editor
|
4043
|
|
|
*
|
4044
|
|
|
* @since 1.4.2
|
4045
|
|
|
*
|
4046
|
|
|
* @param array $contents_strings Array of strings.
|
4047
|
|
|
*/
|
4048
|
|
|
$contents_strings = apply_filters( 'geodir_load_db_language', $contents_strings );
|
4049
|
|
|
|
4050
|
|
|
$contents_strings = array_unique( $contents_strings );
|
4051
|
|
|
|
4052
|
|
|
$contents_head = array();
|
4053
|
|
|
$contents_head[] = "<?php";
|
4054
|
|
|
$contents_head[] = "/**";
|
4055
|
|
|
$contents_head[] = " * Translate language string stored in database. Ex: Custom Fields";
|
4056
|
|
|
$contents_head[] = " *";
|
4057
|
|
|
$contents_head[] = " * @package GeoDirectory";
|
4058
|
|
|
$contents_head[] = " * @since 1.4.2";
|
4059
|
|
|
$contents_head[] = " */";
|
4060
|
|
|
$contents_head[] = "";
|
4061
|
|
|
$contents_head[] = "// Language keys";
|
4062
|
|
|
|
4063
|
|
|
$contents_foot = array();
|
4064
|
|
|
$contents_foot[] = "";
|
4065
|
|
|
$contents_foot[] = "";
|
4066
|
|
|
|
4067
|
|
|
$contents = implode( PHP_EOL, $contents_head );
|
4068
|
|
|
|
4069
|
|
|
if ( ! empty( $contents_strings ) ) {
|
4070
|
|
|
foreach ( $contents_strings as $string ) {
|
4071
|
|
|
if ( is_scalar( $string ) && $string != '' ) {
|
4072
|
|
|
$string = str_replace( "'", "\'", $string );
|
4073
|
|
|
$contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
4074
|
|
|
}
|
4075
|
|
|
}
|
4076
|
|
|
}
|
4077
|
|
|
|
4078
|
|
|
$contents .= implode( PHP_EOL, $contents_foot );
|
4079
|
|
|
|
4080
|
|
|
if ( $wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE ) ) {
|
4081
|
|
|
return false;
|
4082
|
|
|
} // Failure; could not write file.
|
4083
|
|
|
|
4084
|
|
|
return true;
|
4085
|
|
|
}
|
4086
|
|
|
|
4087
|
|
|
/**
|
4088
|
|
|
* Get the custom fields texts for translation
|
4089
|
|
|
*
|
4090
|
|
|
* @since 1.4.2
|
4091
|
|
|
* @since 1.5.7 Option values are translatable via db translation.
|
4092
|
|
|
* @package GeoDirectory
|
4093
|
|
|
*
|
4094
|
|
|
* @global object $wpdb WordPress database abstraction object.
|
4095
|
|
|
*
|
4096
|
|
|
* @param array $translation_texts Array of text strings.
|
4097
|
|
|
*
|
4098
|
|
|
* @return array Translation texts.
|
4099
|
|
|
*/
|
4100
|
|
|
function geodir_load_custom_field_translation( $translation_texts = array() ) {
|
4101
|
|
|
global $wpdb;
|
4102
|
|
|
|
4103
|
|
|
// Custom fields table
|
4104
|
|
|
$sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE;
|
4105
|
|
|
$rows = $wpdb->get_results( $sql );
|
4106
|
|
|
|
4107
|
|
|
if ( ! empty( $rows ) ) {
|
4108
|
|
|
foreach ( $rows as $row ) {
|
4109
|
|
|
if ( ! empty( $row->admin_title ) ) {
|
4110
|
|
|
$translation_texts[] = stripslashes_deep( $row->admin_title );
|
4111
|
|
|
}
|
4112
|
|
|
|
4113
|
|
|
if ( ! empty( $row->admin_desc ) ) {
|
4114
|
|
|
$translation_texts[] = stripslashes_deep( $row->admin_desc );
|
4115
|
|
|
}
|
4116
|
|
|
|
4117
|
|
|
if ( ! empty( $row->site_title ) ) {
|
4118
|
|
|
$translation_texts[] = stripslashes_deep( $row->site_title );
|
4119
|
|
|
}
|
4120
|
|
|
|
4121
|
|
|
if ( ! empty( $row->clabels ) ) {
|
4122
|
|
|
$translation_texts[] = stripslashes_deep( $row->clabels );
|
4123
|
|
|
}
|
4124
|
|
|
|
4125
|
|
|
if ( ! empty( $row->required_msg ) ) {
|
4126
|
|
|
$translation_texts[] = stripslashes_deep( $row->required_msg );
|
4127
|
|
|
}
|
4128
|
|
|
|
4129
|
|
|
if ( ! empty( $row->default_value ) ) {
|
4130
|
|
|
$translation_texts[] = stripslashes_deep( $row->default_value );
|
4131
|
|
|
}
|
4132
|
|
|
|
4133
|
|
|
if ( ! empty( $row->option_values ) ) {
|
4134
|
|
|
$option_values = geodir_string_values_to_options( stripslashes_deep( $row->option_values ) );
|
4135
|
|
|
|
4136
|
|
|
if ( ! empty( $option_values ) ) {
|
4137
|
|
|
foreach ( $option_values as $option_value ) {
|
4138
|
|
|
if ( ! empty( $option_value['label'] ) ) {
|
4139
|
|
|
$translation_texts[] = $option_value['label'];
|
4140
|
|
|
}
|
4141
|
|
|
}
|
4142
|
|
|
}
|
4143
|
|
|
}
|
4144
|
|
|
}
|
4145
|
|
|
}
|
4146
|
|
|
|
4147
|
|
|
// Custom sorting fields table
|
4148
|
|
|
$sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE;
|
4149
|
|
|
$rows = $wpdb->get_results( $sql );
|
4150
|
|
|
|
4151
|
|
View Code Duplication |
if ( ! empty( $rows ) ) {
|
4152
|
|
|
foreach ( $rows as $row ) {
|
4153
|
|
|
if ( ! empty( $row->site_title ) ) {
|
4154
|
|
|
$translation_texts[] = stripslashes_deep( $row->site_title );
|
4155
|
|
|
}
|
4156
|
|
|
|
4157
|
|
|
if ( ! empty( $row->asc_title ) ) {
|
4158
|
|
|
$translation_texts[] = stripslashes_deep( $row->asc_title );
|
4159
|
|
|
}
|
4160
|
|
|
|
4161
|
|
|
if ( ! empty( $row->desc_title ) ) {
|
4162
|
|
|
$translation_texts[] = stripslashes_deep( $row->desc_title );
|
4163
|
|
|
}
|
4164
|
|
|
}
|
4165
|
|
|
}
|
4166
|
|
|
|
4167
|
|
|
// Advance search filter fields table
|
4168
|
|
|
if ( defined( 'GEODIR_ADVANCE_SEARCH_TABLE' ) ) {
|
4169
|
|
|
$sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE;
|
4170
|
|
|
$rows = $wpdb->get_results( $sql );
|
4171
|
|
|
|
4172
|
|
View Code Duplication |
if ( ! empty( $rows ) ) {
|
4173
|
|
|
foreach ( $rows as $row ) {
|
4174
|
|
|
if ( ! empty( $row->field_site_name ) ) {
|
4175
|
|
|
$translation_texts[] = stripslashes_deep( $row->field_site_name );
|
4176
|
|
|
}
|
4177
|
|
|
|
4178
|
|
|
if ( ! empty( $row->front_search_title ) ) {
|
4179
|
|
|
$translation_texts[] = stripslashes_deep( $row->front_search_title );
|
4180
|
|
|
}
|
4181
|
|
|
|
4182
|
|
|
if ( ! empty( $row->field_desc ) ) {
|
4183
|
|
|
$translation_texts[] = stripslashes_deep( $row->field_desc );
|
4184
|
|
|
}
|
4185
|
|
|
}
|
4186
|
|
|
}
|
4187
|
|
|
}
|
4188
|
|
|
|
4189
|
|
|
$translation_texts = ! empty( $translation_texts ) ? array_unique( $translation_texts ) : $translation_texts;
|
4190
|
|
|
|
4191
|
|
|
return $translation_texts;
|
4192
|
|
|
}
|
4193
|
|
|
|
4194
|
|
|
/**
|
4195
|
|
|
* Retrieve list of mime types and file extensions allowed for file upload.
|
4196
|
|
|
*
|
4197
|
|
|
* @since 1.4.7
|
4198
|
|
|
* @package GeoDirectory
|
4199
|
|
|
*
|
4200
|
|
|
* @return array Array of mime types.
|
4201
|
|
|
*/
|
4202
|
|
|
function geodir_allowed_mime_types() {
|
4203
|
|
|
/**
|
4204
|
|
|
* Filter the list of mime types and file extensions allowed for file upload.
|
4205
|
|
|
*
|
4206
|
|
|
* @since 1.4.7
|
4207
|
7 |
|
* @package GeoDirectory
|
4208
|
|
|
*
|
4209
|
7 |
|
* @param array $geodir_allowed_mime_types and file extensions.
|
4210
|
3 |
|
*/
|
4211
|
|
|
return apply_filters( 'geodir_allowed_mime_types', array(
|
4212
|
|
|
'Image' => array( // Image formats.
|
4213
|
5 |
|
'jpg' => 'image/jpeg',
|
4214
|
|
|
'jpe' => 'image/jpeg',
|
4215
|
|
|
'jpeg' => 'image/jpeg',
|
4216
|
|
|
'gif' => 'image/gif',
|
4217
|
|
|
'png' => 'image/png',
|
4218
|
|
|
'bmp' => 'image/bmp',
|
4219
|
|
|
'ico' => 'image/x-icon',
|
4220
|
|
|
),
|
4221
|
2 |
|
'Video' => array( // Video formats.
|
4222
|
2 |
|
'asf' => 'video/x-ms-asf',
|
4223
|
|
|
'avi' => 'video/avi',
|
4224
|
5 |
|
'flv' => 'video/x-flv',
|
4225
|
3 |
|
'mkv' => 'video/x-matroska',
|
4226
|
3 |
|
'mp4' => 'video/mp4',
|
4227
|
|
|
'mpeg' => 'video/mpeg',
|
4228
|
5 |
|
'mpg' => 'video/mpeg',
|
4229
|
5 |
|
'wmv' => 'video/x-ms-wmv',
|
4230
|
5 |
|
'3gp' => 'video/3gpp',
|
4231
|
|
|
),
|
4232
|
5 |
|
'Audio' => array( // Audio formats.
|
4233
|
|
|
'ogg' => 'audio/ogg',
|
4234
|
|
|
'mp3' => 'audio/mpeg',
|
4235
|
|
|
'wav' => 'audio/wav',
|
4236
|
5 |
|
'wma' => 'audio/x-ms-wma',
|
4237
|
|
|
),
|
4238
|
|
|
'Text' => array( // Text formats.
|
4239
|
|
|
'css' => 'text/css',
|
4240
|
5 |
|
'csv' => 'text/csv',
|
4241
|
2 |
|
'htm' => 'text/html',
|
4242
|
5 |
|
'html' => 'text/html',
|
4243
|
1 |
|
'txt' => 'text/plain',
|
4244
|
1 |
|
'rtx' => 'text/richtext',
|
4245
|
4 |
|
'vtt' => 'text/vtt',
|
4246
|
1 |
|
),
|
4247
|
1 |
|
'Application' => array( // Application formats.
|
4248
|
2 |
|
'doc' => 'application/msword',
|
4249
|
|
|
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
4250
|
|
|
'exe' => 'application/x-msdownload',
|
4251
|
5 |
|
'js' => 'application/javascript',
|
4252
|
1 |
|
'odt' => 'application/vnd.oasis.opendocument.text',
|
4253
|
1 |
|
'pdf' => 'application/pdf',
|
4254
|
1 |
|
'pot' => 'application/vnd.ms-powerpoint',
|
4255
|
1 |
|
'ppt' => 'application/vnd.ms-powerpoint',
|
4256
|
|
|
'pptx' => 'application/vnd.ms-powerpoint',
|
4257
|
1 |
|
'psd' => 'application/octet-stream',
|
4258
|
1 |
|
'rar' => 'application/rar',
|
4259
|
|
|
'rtf' => 'application/rtf',
|
4260
|
5 |
|
'swf' => 'application/x-shockwave-flash',
|
4261
|
2 |
|
'tar' => 'application/x-tar',
|
4262
|
2 |
|
'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
4263
|
2 |
|
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
4264
|
2 |
|
'zip' => 'application/zip',
|
4265
|
|
|
)
|
4266
|
2 |
|
)
|
4267
|
2 |
|
);
|
4268
|
|
|
}
|
4269
|
5 |
|
|
4270
|
|
|
/**
|
4271
|
|
|
* Retrieve list of user display name for user id.
|
4272
|
|
|
*
|
4273
|
|
|
* @since 1.5.0
|
4274
|
|
|
*
|
4275
|
|
|
* @param string $user_id The WP user id.
|
4276
|
|
|
*
|
4277
|
|
|
* @return string User display name.
|
4278
|
|
|
*/
|
4279
|
|
|
function geodir_get_client_name( $user_id ) {
|
4280
|
|
|
$client_name = '';
|
4281
|
|
|
|
4282
|
|
|
$user_data = get_userdata( $user_id );
|
4283
|
|
|
|
4284
|
|
|
if ( ! empty( $user_data ) ) {
|
4285
|
|
|
if ( isset( $user_data->display_name ) && trim( $user_data->display_name ) != '' ) {
|
4286
|
5 |
|
$client_name = trim( $user_data->display_name );
|
4287
|
|
|
} else if ( isset( $user_data->user_nicename ) && trim( $user_data->user_nicename ) != '' ) {
|
4288
|
|
|
$client_name = trim( $user_data->user_nicename );
|
4289
|
|
|
} else {
|
4290
|
|
|
$client_name = trim( $user_data->user_login );
|
4291
|
|
|
}
|
4292
|
|
|
}
|
4293
|
|
|
|
4294
|
|
|
return $client_name;
|
4295
|
|
|
}
|
4296
|
|
|
|
4297
|
|
|
|
4298
|
|
|
add_filter( 'wpseo_replacements', 'geodir_wpseo_replacements', 10, 1 );
|
4299
|
|
|
/*
|
4300
|
|
|
* Add location variables to wpseo replacements.
|
4301
|
|
|
*
|
4302
|
|
|
* @since 1.5.4
|
4303
|
5 |
|
*/
|
4304
|
|
|
function geodir_wpseo_replacements( $vars ) {
|
4305
|
|
|
|
4306
|
|
|
global $wp;
|
4307
|
|
|
$title = '';
|
|
|
|
|
4308
|
5 |
|
// location variables
|
4309
|
5 |
|
$gd_post_type = geodir_get_current_posttype();
|
4310
|
5 |
|
$location_array = geodir_get_current_location_terms( 'query_vars', $gd_post_type );
|
4311
|
|
|
/**
|
4312
|
|
|
* Filter the title variables location variables array
|
4313
|
5 |
|
*
|
4314
|
5 |
|
* @since 1.5.5
|
4315
|
|
|
* @package GeoDirectory
|
4316
|
|
|
*
|
4317
|
|
|
* @param array $location_array The array of location variables.
|
4318
|
|
|
* @param array $vars The page title variables.
|
4319
|
|
|
*/
|
4320
|
|
|
$location_array = apply_filters( 'geodir_filter_title_variables_location_arr_seo', $location_array, $vars );
|
4321
|
|
|
$location_titles = array();
|
4322
|
|
View Code Duplication |
if ( get_query_var( 'gd_country_full' ) ) {
|
4323
|
|
|
if ( get_query_var( 'gd_country_full' ) ) {
|
4324
|
|
|
$location_array['gd_country'] = get_query_var( 'gd_country_full' );
|
4325
|
5 |
|
}
|
4326
|
5 |
|
if ( get_query_var( 'gd_region_full' ) ) {
|
4327
|
5 |
|
$location_array['gd_region'] = get_query_var( 'gd_region_full' );
|
4328
|
|
|
}
|
4329
|
|
|
if ( get_query_var( 'gd_city_full' ) ) {
|
4330
|
|
|
$location_array['gd_city'] = get_query_var( 'gd_city_full' );
|
4331
|
|
|
}
|
4332
|
5 |
|
}
|
4333
|
5 |
|
$location_single = '';
|
4334
|
5 |
|
$gd_country = ( isset( $wp->query_vars['gd_country'] ) && $wp->query_vars['gd_country'] != '' ) ? $wp->query_vars['gd_country'] : '';
|
4335
|
5 |
|
$gd_region = ( isset( $wp->query_vars['gd_region'] ) && $wp->query_vars['gd_region'] != '' ) ? $wp->query_vars['gd_region'] : '';
|
4336
|
|
|
$gd_city = ( isset( $wp->query_vars['gd_city'] ) && $wp->query_vars['gd_city'] != '' ) ? $wp->query_vars['gd_city'] : '';
|
4337
|
5 |
|
|
4338
|
|
|
$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
|
4339
|
5 |
|
|
4340
|
|
View Code Duplication |
if ( function_exists( 'get_actual_location_name' ) ) {
|
4341
|
|
|
$gd_country_actual = $gd_country != '' ? get_actual_location_name( 'country', $gd_country, true ) : $gd_country;
|
4342
|
|
|
$gd_region_actual = $gd_region != '' ? get_actual_location_name( 'region', $gd_region ) : $gd_region;
|
4343
|
|
|
$gd_city_actual = $gd_city != '' ? get_actual_location_name( 'city', $gd_city ) : $gd_city;
|
4344
|
|
|
}
|
4345
|
5 |
|
|
4346
|
|
View Code Duplication |
if ( $gd_city != '' ) {
|
4347
|
|
|
if ( $gd_city_actual != '' ) {
|
4348
|
|
|
$gd_city = $gd_city_actual;
|
4349
|
|
|
} else {
|
4350
|
|
|
$gd_city = preg_replace( '/-(\d+)$/', '', $gd_city );
|
4351
|
|
|
$gd_city = preg_replace( '/[_-]/', ' ', $gd_city );
|
4352
|
|
|
$gd_city = __( geodir_ucwords( $gd_city ), 'geodirectory' );
|
4353
|
|
|
}
|
4354
|
|
|
$location_single = $gd_city;
|
4355
|
5 |
|
|
4356
|
|
|
} else if ( $gd_region != '' ) {
|
4357
|
|
|
if ( $gd_region_actual != '' ) {
|
4358
|
|
|
$gd_region = $gd_region_actual;
|
4359
|
|
|
} else {
|
4360
|
|
|
$gd_region = preg_replace( '/-(\d+)$/', '', $gd_region );
|
4361
|
|
|
$gd_region = preg_replace( '/[_-]/', ' ', $gd_region );
|
4362
|
|
|
$gd_region = __( geodir_ucwords( $gd_region ), 'geodirectory' );
|
4363
|
|
|
}
|
4364
|
|
|
|
4365
|
5 |
|
$location_single = $gd_region;
|
4366
|
|
|
} else if ( $gd_country != '' ) {
|
4367
|
|
|
if ( $gd_country_actual != '' ) {
|
4368
|
|
|
$gd_country = $gd_country_actual;
|
4369
|
|
|
} else {
|
4370
|
|
|
$gd_country = preg_replace( '/-(\d+)$/', '', $gd_country );
|
4371
|
|
|
$gd_country = preg_replace( '/[_-]/', ' ', $gd_country );
|
4372
|
|
|
$gd_country = __( geodir_ucwords( $gd_country ), 'geodirectory' );
|
4373
|
|
|
}
|
4374
|
|
|
|
4375
|
|
|
$location_single = $gd_country;
|
4376
|
|
|
}
|
4377
|
5 |
|
|
4378
|
|
View Code Duplication |
if ( ! empty( $location_array ) ) {
|
4379
|
|
|
|
4380
|
|
|
$actual_location_name = function_exists( 'get_actual_location_name' ) ? true : false;
|
4381
|
|
|
$location_array = array_reverse( $location_array );
|
4382
|
|
|
|
4383
|
|
|
foreach ( $location_array as $location_type => $location ) {
|
4384
|
|
|
$gd_location_link_text = preg_replace( '/-(\d+)$/', '', $location );
|
4385
|
|
|
$gd_location_link_text = preg_replace( '/[_-]/', ' ', $gd_location_link_text );
|
4386
|
|
|
|
4387
|
|
|
$location_name = geodir_ucwords( $gd_location_link_text );
|
4388
|
|
|
$location_name = __( $location_name, 'geodirectory' );
|
4389
|
|
|
|
4390
|
|
|
if ( $actual_location_name ) {
|
4391
|
|
|
$location_type = strpos( $location_type, 'gd_' ) === 0 ? substr( $location_type, 3 ) : $location_type;
|
4392
|
|
|
$location_name = get_actual_location_name( $location_type, $location, true );
|
4393
|
|
|
}
|
4394
|
|
|
|
4395
|
|
|
$location_titles[] = $location_name;
|
4396
|
|
|
}
|
4397
|
|
|
if ( ! empty( $location_titles ) ) {
|
4398
|
|
|
$location_titles = array_unique( $location_titles );
|
4399
|
|
|
}
|
4400
|
|
|
}
|
4401
|
|
|
|
4402
|
5 |
|
|
4403
|
1 |
|
if ( ! empty( $location_titles ) ) {
|
4404
|
1 |
|
$vars['%%location%%'] = implode( ", ", $location_titles );
|
4405
|
|
|
}
|
4406
|
|
|
|
4407
|
1 |
|
|
4408
|
1 |
|
if ( ! empty( $location_titles ) ) {
|
4409
|
|
|
$vars['%%in_location%%'] = __( 'in ', 'geodirectory' ) . implode( ", ", $location_titles );
|
4410
|
5 |
|
}
|
4411
|
1 |
|
|
4412
|
1 |
|
|
4413
|
|
|
if ( $location_single ) {
|
4414
|
|
|
$vars['%%in_location_single%%'] = __( 'in', 'geodirectory' ) . ' ' . $location_single;
|
4415
|
1 |
|
}
|
4416
|
1 |
|
|
4417
|
|
|
|
4418
|
5 |
|
if ( $location_single ) {
|
4419
|
1 |
|
$vars['%%location_single%%'] = $location_single;
|
4420
|
|
|
}
|
4421
|
|
|
|
4422
|
1 |
|
/**
|
4423
|
1 |
|
* Filter the title variables after standard ones have been filtered for wpseo.
|
4424
|
|
|
*
|
4425
|
5 |
|
* @since 1.5.7
|
4426
|
|
|
* @package GeoDirectory
|
4427
|
|
|
*
|
4428
|
|
|
* @param string $vars The title with variables.
|
4429
|
|
|
* @param array $location_array The array of location variables.
|
4430
|
5 |
|
*/
|
4431
|
1 |
|
return apply_filters( 'geodir_wpseo_replacements_vars', $vars, $location_array );
|
4432
|
1 |
|
}
|
4433
|
|
|
|
4434
|
|
|
|
4435
|
1 |
|
add_filter( 'geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3 );
|
4436
|
1 |
|
add_filter( 'geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2 );
|
4437
|
|
|
add_filter( 'geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3 );
|
4438
|
5 |
|
|
4439
|
1 |
|
/**
|
4440
|
1 |
|
* Filter the title variables.
|
4441
|
|
|
*
|
4442
|
|
|
* %%date%% Replaced with the date of the post/page
|
4443
|
1 |
|
* %%title%% Replaced with the title of the post/page
|
4444
|
1 |
|
* %%sitename%% The site's name
|
4445
|
|
|
* %%sitedesc%% The site's tagline / description
|
4446
|
5 |
|
* %%excerpt%% Replaced with the post/page excerpt (or auto-generated if it does not exist)
|
4447
|
1 |
|
* %%tag%% Replaced with the current tag/tags
|
4448
|
1 |
|
* %%category%% Replaced with the post categories (comma separated)
|
4449
|
1 |
|
* %%category_description%% Replaced with the category description
|
4450
|
|
|
* %%tag_description%% Replaced with the tag description
|
4451
|
1 |
|
* %%term_description%% Replaced with the term description
|
4452
|
1 |
|
* %%term_title%% Replaced with the term name
|
4453
|
1 |
|
* %%searchphrase%% Replaced with the current search phrase
|
4454
|
1 |
|
* %%sep%% The separator defined in your theme's wp_title() tag.
|
4455
|
1 |
|
*
|
4456
|
1 |
|
* ADVANCED
|
4457
|
|
|
* %%pt_single%% Replaced with the post type single label
|
4458
|
5 |
|
* %%pt_plural%% Replaced with the post type plural label
|
4459
|
|
|
* %%modified%% Replaced with the post/page modified time
|
4460
|
|
|
* %%id%% Replaced with the post/page ID
|
4461
|
|
|
* %%name%% Replaced with the post/page author's 'nicename'
|
4462
|
5 |
|
* %%userid%% Replaced with the post/page author's userid
|
4463
|
|
|
* %%page%% Replaced with the current page number (i.e. page 2 of 4)
|
4464
|
|
|
* %%pagetotal%% Replaced with the current page total
|
4465
|
|
|
* %%pagenumber%% Replaced with the current page number
|
4466
|
5 |
|
*
|
4467
|
|
|
* @since 1.5.7
|
4468
|
|
|
* @package GeoDirectory
|
4469
|
|
|
*
|
4470
|
|
|
* @global object $wp WordPress object.
|
4471
|
5 |
|
* @global object $post The current post object.
|
4472
|
5 |
|
*
|
4473
|
5 |
|
* @param string $title The title with variables.
|
4474
|
|
|
* @param string $gd_page The page being filtered.
|
4475
|
|
|
* @param string $sep The separator, default: `|`.
|
4476
|
|
|
*
|
4477
|
|
|
* @return string Title after filtered variables.
|
4478
|
|
|
*/
|
4479
|
|
|
function geodir_filter_title_variables( $title, $gd_page, $sep = '' ) {
|
4480
|
|
|
global $wp, $post;
|
4481
|
|
|
|
4482
|
|
|
if ( ! $gd_page || ! $title ) {
|
4483
|
|
|
return $title; // if no a GD page then bail.
|
4484
|
|
|
}
|
4485
|
|
|
|
4486
|
5 |
|
if ( $sep == '' ) {
|
4487
|
|
|
/**
|
4488
|
|
|
* Filter the page title separator.
|
4489
|
|
|
*
|
4490
|
|
|
* @since 1.0.0
|
4491
|
|
|
* @package GeoDirectory
|
4492
|
|
|
*
|
4493
|
|
|
* @param string $sep The separator, default: `|`.
|
4494
|
|
|
*/
|
4495
|
|
|
$sep = apply_filters( 'geodir_page_title_separator', '|' );
|
4496
|
|
|
}
|
4497
|
|
|
|
4498
|
|
|
if ( strpos( $title, '%%title%%' ) !== false ) {
|
4499
|
1 |
|
$title = str_replace( "%%title%%", $post->post_title, $title );
|
4500
|
|
|
}
|
4501
|
1 |
|
|
4502
|
1 |
View Code Duplication |
if ( strpos( $title, '%%sitename%%' ) !== false ) {
|
4503
|
1 |
|
$title = str_replace( "%%sitename%%", get_bloginfo( 'name' ), $title );
|
4504
|
1 |
|
}
|
4505
|
1 |
|
|
4506
|
|
View Code Duplication |
if ( strpos( $title, '%%sitedesc%%' ) !== false ) {
|
4507
|
1 |
|
$title = str_replace( "%%sitedesc%%", get_bloginfo( 'description' ), $title );
|
4508
|
1 |
|
}
|
4509
|
1 |
|
|
4510
|
1 |
|
if ( strpos( $title, '%%excerpt%%' ) !== false ) {
|
4511
|
1 |
|
$title = str_replace( "%%excerpt%%", strip_tags( get_the_excerpt() ), $title );
|
4512
|
1 |
|
}
|
4513
|
1 |
|
|
4514
|
1 |
|
if ( $gd_page == 'search' || $gd_page == 'author' ) {
|
4515
|
1 |
|
$post_type = isset( $_REQUEST['stype'] ) ? sanitize_text_field( $_REQUEST['stype'] ) : '';
|
4516
|
1 |
|
} else if ( $gd_page == 'add-listing' ) {
|
4517
|
1 |
|
$post_type = ( isset( $_REQUEST['listing_type'] ) ) ? sanitize_text_field( $_REQUEST['listing_type'] ) : '';
|
4518
|
1 |
|
$post_type = ! $post_type && ! empty( $_REQUEST['pid'] ) ? get_post_type( (int) $_REQUEST['pid'] ) : $post_type;
|
4519
|
1 |
|
} else if ( isset( $post->post_type ) && $post->post_type && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
4520
|
1 |
|
$post_type = $post->post_type;
|
4521
|
1 |
|
} else {
|
4522
|
1 |
|
$post_type = get_query_var( 'post_type' );
|
4523
|
1 |
|
}
|
4524
|
1 |
|
|
4525
|
1 |
View Code Duplication |
if ( strpos( $title, '%%pt_single%%' ) !== false ) {
|
4526
|
1 |
|
$singular_name = '';
|
4527
|
1 |
|
if ( $post_type && $singular_name = get_post_type_singular_label( $post_type ) ) {
|
4528
|
1 |
|
$singular_name = __( $singular_name, 'geodirectory' );
|
4529
|
1 |
|
}
|
4530
|
1 |
|
|
4531
|
1 |
|
$title = str_replace( "%%pt_single%%", $singular_name, $title );
|
4532
|
1 |
|
}
|
4533
|
1 |
|
|
4534
|
1 |
View Code Duplication |
if ( strpos( $title, '%%pt_plural%%' ) !== false ) {
|
4535
|
1 |
|
$plural_name = '';
|
4536
|
1 |
|
if ( $post_type && $plural_name = get_post_type_plural_label( $post_type ) ) {
|
4537
|
1 |
|
$plural_name = __( $plural_name, 'geodirectory' );
|
4538
|
1 |
|
}
|
4539
|
1 |
|
|
4540
|
1 |
|
$title = str_replace( "%%pt_plural%%", $plural_name, $title );
|
4541
|
|
|
}
|
4542
|
1 |
|
|
4543
|
1 |
View Code Duplication |
if ( strpos( $title, '%%category%%' ) !== false ) {
|
4544
|
1 |
|
$cat_name = '';
|
4545
|
|
|
|
4546
|
1 |
|
if ( $gd_page == 'detail' ) {
|
4547
|
|
|
if ( $post->default_category ) {
|
4548
|
|
|
$cat = get_term( $post->default_category, $post->post_type . 'category' );
|
4549
|
|
|
$cat_name = ( isset( $cat->name ) ) ? $cat->name : '';
|
4550
|
|
|
}
|
4551
|
|
|
} else if ( $gd_page == 'listing' ) {
|
4552
|
|
|
$queried_object = get_queried_object();
|
4553
|
1 |
|
if ( isset( $queried_object->name ) ) {
|
4554
|
1 |
|
$cat_name = $queried_object->name;
|
4555
|
1 |
|
}
|
4556
|
|
|
}
|
4557
|
1 |
|
$title = str_replace( "%%category%%", $cat_name, $title );
|
4558
|
|
|
}
|
4559
|
|
|
|
4560
|
|
View Code Duplication |
if ( strpos( $title, '%%tag%%' ) !== false ) {
|
4561
|
|
|
$cat_name = '';
|
4562
|
|
|
|
4563
|
|
|
if ( $gd_page == 'detail' ) {
|
4564
|
|
|
if ( $post->default_category ) {
|
4565
|
|
|
$cat = get_term( $post->default_category, $post->post_type . 'category' );
|
4566
|
|
|
$cat_name = ( isset( $cat->name ) ) ? $cat->name : '';
|
4567
|
|
|
}
|
4568
|
|
|
} else if ( $gd_page == 'listing' ) {
|
4569
|
|
|
$queried_object = get_queried_object();
|
4570
|
|
|
if ( isset( $queried_object->name ) ) {
|
4571
|
|
|
$cat_name = $queried_object->name;
|
4572
|
|
|
}
|
4573
|
|
|
}
|
4574
|
|
|
$title = str_replace( "%%tag%%", $cat_name, $title );
|
4575
|
|
|
}
|
4576
|
|
|
|
4577
|
|
|
if ( strpos( $title, '%%id%%' ) !== false ) {
|
4578
|
|
|
$ID = ( isset( $post->ID ) ) ? $post->ID : '';
|
4579
|
|
|
$title = str_replace( "%%id%%", $ID, $title );
|
4580
|
|
|
}
|
4581
|
|
|
|
4582
|
|
|
if ( strpos( $title, '%%sep%%' ) !== false ) {
|
4583
|
|
|
$title = str_replace( "%%sep%%", $sep, $title );
|
4584
|
|
|
}
|
4585
|
|
|
|
4586
|
|
|
// location variables
|
4587
|
|
|
$gd_post_type = geodir_get_current_posttype();
|
4588
|
|
|
$location_array = geodir_get_current_location_terms( 'query_vars', $gd_post_type );
|
4589
|
|
|
/**
|
4590
|
|
|
* Filter the title variables location variables array
|
4591
|
|
|
*
|
4592
|
|
|
* @since 1.5.5
|
4593
|
|
|
* @package GeoDirectory
|
4594
|
|
|
*
|
4595
|
|
|
* @param array $location_array The array of location variables.
|
4596
|
|
|
* @param string $title The title with variables..
|
4597
|
|
|
* @param string $gd_page The page being filtered.
|
4598
|
|
|
* @param string $sep The separator, default: `|`.
|
4599
|
|
|
*/
|
4600
|
|
|
$location_array = apply_filters( 'geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep );
|
4601
|
|
|
$location_titles = array();
|
4602
|
|
View Code Duplication |
if ( $gd_page == 'location' && get_query_var( 'gd_country_full' ) ) {
|
4603
|
|
|
if ( get_query_var( 'gd_country_full' ) ) {
|
4604
|
8 |
|
$location_array['gd_country'] = get_query_var( 'gd_country_full' );
|
4605
|
7 |
|
}
|
4606
|
|
|
if ( get_query_var( 'gd_region_full' ) ) {
|
4607
|
|
|
$location_array['gd_region'] = get_query_var( 'gd_region_full' );
|
4608
|
1 |
|
}
|
4609
|
1 |
|
if ( get_query_var( 'gd_city_full' ) ) {
|
4610
|
1 |
|
$location_array['gd_city'] = get_query_var( 'gd_city_full' );
|
4611
|
|
|
}
|
4612
|
1 |
|
}
|
4613
|
|
|
$location_single = '';
|
4614
|
|
|
$gd_country = ( isset( $wp->query_vars['gd_country'] ) && $wp->query_vars['gd_country'] != '' ) ? $wp->query_vars['gd_country'] : '';
|
4615
|
|
|
$gd_region = ( isset( $wp->query_vars['gd_region'] ) && $wp->query_vars['gd_region'] != '' ) ? $wp->query_vars['gd_region'] : '';
|
4616
|
1 |
|
$gd_city = ( isset( $wp->query_vars['gd_city'] ) && $wp->query_vars['gd_city'] != '' ) ? $wp->query_vars['gd_city'] : '';
|
4617
|
|
|
|
4618
|
|
|
$gd_country_actual = $gd_region_actual = $gd_city_actual = '';
|
4619
|
|
|
|
4620
|
1 |
View Code Duplication |
if ( function_exists( 'get_actual_location_name' ) ) {
|
4621
|
|
|
$gd_country_actual = $gd_country != '' ? get_actual_location_name( 'country', $gd_country, true ) : $gd_country;
|
4622
|
1 |
|
$gd_region_actual = $gd_region != '' ? get_actual_location_name( 'region', $gd_region ) : $gd_region;
|
4623
|
|
|
$gd_city_actual = $gd_city != '' ? get_actual_location_name( 'city', $gd_city ) : $gd_city;
|
4624
|
|
|
}
|
4625
|
|
|
|
4626
|
|
View Code Duplication |
if ( $gd_city != '' ) {
|
4627
|
|
|
if ( $gd_city_actual != '' ) {
|
4628
|
|
|
$gd_city = $gd_city_actual;
|
4629
|
|
|
} else {
|
4630
|
|
|
$gd_city = preg_replace( '/-(\d+)$/', '', $gd_city );
|
4631
|
|
|
$gd_city = preg_replace( '/[_-]/', ' ', $gd_city );
|
4632
|
|
|
$gd_city = __( geodir_ucwords( $gd_city ), 'geodirectory' );
|
4633
|
|
|
}
|
4634
|
|
|
$location_single = $gd_city;
|
4635
|
|
|
|
4636
|
|
|
} else if ( $gd_region != '' ) {
|
4637
|
|
|
if ( $gd_region_actual != '' ) {
|
4638
|
|
|
$gd_region = $gd_region_actual;
|
4639
|
|
|
} else {
|
4640
|
|
|
$gd_region = preg_replace( '/-(\d+)$/', '', $gd_region );
|
4641
|
|
|
$gd_region = preg_replace( '/[_-]/', ' ', $gd_region );
|
4642
|
|
|
$gd_region = __( geodir_ucwords( $gd_region ), 'geodirectory' );
|
4643
|
|
|
}
|
4644
|
|
|
|
4645
|
1 |
|
$location_single = $gd_region;
|
4646
|
|
|
} else if ( $gd_country != '' ) {
|
4647
|
|
|
if ( $gd_country_actual != '' ) {
|
4648
|
|
|
$gd_country = $gd_country_actual;
|
4649
|
|
|
} else {
|
4650
|
|
|
$gd_country = preg_replace( '/-(\d+)$/', '', $gd_country );
|
4651
|
|
|
$gd_country = preg_replace( '/[_-]/', ' ', $gd_country );
|
4652
|
|
|
$gd_country = __( geodir_ucwords( $gd_country ), 'geodirectory' );
|
4653
|
|
|
}
|
4654
|
|
|
|
4655
|
|
|
$location_single = $gd_country;
|
4656
|
|
|
}
|
4657
|
|
|
|
4658
|
|
View Code Duplication |
if ( ! empty( $location_array ) ) {
|
4659
|
|
|
|
4660
|
|
|
$actual_location_name = function_exists( 'get_actual_location_name' ) ? true : false;
|
4661
|
|
|
$location_array = array_reverse( $location_array );
|
4662
|
|
|
|
4663
|
|
|
foreach ( $location_array as $location_type => $location ) {
|
4664
|
|
|
$gd_location_link_text = preg_replace( '/-(\d+)$/', '', $location );
|
4665
|
|
|
$gd_location_link_text = preg_replace( '/[_-]/', ' ', $gd_location_link_text );
|
4666
|
|
|
|
4667
|
|
|
$location_name = geodir_ucwords( $gd_location_link_text );
|
4668
|
|
|
$location_name = __( $location_name, 'geodirectory' );
|
4669
|
|
|
|
4670
|
|
|
if ( $actual_location_name ) {
|
4671
|
|
|
$location_type = strpos( $location_type, 'gd_' ) === 0 ? substr( $location_type, 3 ) : $location_type;
|
4672
|
|
|
$location_name = get_actual_location_name( $location_type, $location, true );
|
4673
|
|
|
}
|
4674
|
|
|
|
4675
|
|
|
$location_titles[] = $location_name;
|
4676
|
|
|
}
|
4677
|
|
|
if ( ! empty( $location_titles ) ) {
|
4678
|
|
|
$location_titles = array_unique( $location_titles );
|
4679
|
|
|
}
|
4680
|
|
|
}
|
4681
|
|
|
|
4682
|
|
|
|
4683
|
|
|
if ( strpos( $title, '%%location%%' ) !== false ) {
|
4684
|
|
|
$location = '';
|
4685
|
|
|
if ( $location_titles ) {
|
|
|
|
|
4686
|
|
|
$location = implode( ", ", $location_titles );
|
4687
|
|
|
}
|
4688
|
|
|
$title = str_replace( "%%location%%", $location, $title );
|
4689
|
|
|
}
|
4690
|
|
|
|
4691
|
|
View Code Duplication |
if ( strpos( $title, '%%in_location%%' ) !== false ) {
|
4692
|
|
|
$location = '';
|
4693
|
|
|
if ( $location_titles ) {
|
|
|
|
|
4694
|
|
|
$location = __( 'in ', 'geodirectory' ) . implode( ", ", $location_titles );
|
4695
|
|
|
}
|
4696
|
|
|
$title = str_replace( "%%in_location%%", $location, $title );
|
4697
|
|
|
}
|
4698
|
|
|
|
4699
|
|
View Code Duplication |
if ( strpos( $title, '%%in_location_single%%' ) !== false ) {
|
4700
|
|
|
if ( $location_single ) {
|
4701
|
|
|
$location_single = __( 'in', 'geodirectory' ) . ' ' . $location_single;
|
4702
|
|
|
}
|
4703
|
|
|
$title = str_replace( "%%in_location_single%%", $location_single, $title );
|
4704
|
|
|
}
|
4705
|
|
|
|
4706
|
|
|
if ( strpos( $title, '%%location_single%%' ) !== false ) {
|
4707
|
|
|
$title = str_replace( "%%location_single%%", $location_single, $title );
|
4708
|
|
|
}
|
4709
|
|
|
|
4710
|
|
|
|
4711
|
|
View Code Duplication |
if ( strpos( $title, '%%search_term%%' ) !== false ) {
|
4712
|
|
|
$search_term = '';
|
4713
|
|
|
if ( isset( $_REQUEST['s'] ) ) {
|
4714
|
|
|
$search_term = esc_attr( $_REQUEST['s'] );
|
4715
|
|
|
}
|
4716
|
|
|
$title = str_replace( "%%search_term%%", $search_term, $title );
|
4717
|
|
|
}
|
4718
|
|
|
|
4719
|
|
View Code Duplication |
if ( strpos( $title, '%%search_near%%' ) !== false ) {
|
4720
|
|
|
$search_term = '';
|
4721
|
|
|
if ( isset( $_REQUEST['snear'] ) ) {
|
4722
|
|
|
$search_term = esc_attr( $_REQUEST['snear'] );
|
4723
|
|
|
}
|
4724
|
|
|
$title = str_replace( "%%search_near%%", $search_term, $title );
|
4725
|
|
|
}
|
4726
|
|
|
|
4727
|
|
|
if ( strpos( $title, '%%name%%' ) !== false ) {
|
4728
|
|
|
if ( is_author() ) {
|
4729
|
|
|
$curauth = ( get_query_var( 'author_name' ) ) ? get_user_by( 'slug', get_query_var( 'author_name' ) ) : get_userdata( get_query_var( 'author' ) );
|
4730
|
|
|
$author_name = $curauth->display_name;
|
4731
|
|
|
} else {
|
4732
|
|
|
$author_name = get_the_author();
|
4733
|
|
|
}
|
4734
|
|
|
if ( ! $author_name || $author_name === '' ) {
|
4735
|
|
|
$queried_object = get_queried_object();
|
4736
|
|
|
|
4737
|
|
|
if ( isset( $queried_object->data->user_nicename ) ) {
|
4738
|
|
|
$author_name = $queried_object->data->display_name;
|
4739
|
|
|
}
|
4740
|
|
|
}
|
4741
|
|
|
$title = str_replace( "%%name%%", $author_name, $title );
|
4742
|
|
|
}
|
4743
|
|
|
|
4744
|
|
|
if ( strpos( $title, '%%page%%' ) !== false ) {
|
4745
|
|
|
$page = geodir_title_meta_page( $sep );
|
4746
|
|
|
$title = str_replace( "%%page%%", $page, $title );
|
4747
|
|
|
}
|
4748
|
|
|
if ( strpos( $title, '%%pagenumber%%' ) !== false ) {
|
4749
|
|
|
$pagenumber = geodir_title_meta_pagenumber();
|
4750
|
|
|
$title = str_replace( "%%pagenumber%%", $pagenumber, $title );
|
4751
|
|
|
}
|
4752
|
|
|
if ( strpos( $title, '%%pagetotal%%' ) !== false ) {
|
4753
|
|
|
$pagetotal = geodir_title_meta_pagetotal();
|
4754
|
|
|
$title = str_replace( "%%pagetotal%%", $pagetotal, $title );
|
4755
|
|
|
}
|
4756
|
|
|
|
4757
|
|
|
$title = wptexturize( $title );
|
4758
|
|
|
$title = convert_chars( $title );
|
4759
|
|
|
$title = esc_html( $title );
|
4760
|
|
|
|
4761
|
|
|
/**
|
4762
|
|
|
* Filter the title variables after standard ones have been filtered.
|
4763
|
|
|
*
|
4764
|
|
|
* @since 1.5.7
|
4765
|
|
|
* @package GeoDirectory
|
4766
|
|
|
*
|
4767
|
|
|
* @param string $title The title with variables.
|
4768
|
|
|
* @param array $location_array The array of location variables.
|
4769
|
|
|
* @param string $gd_page The page being filtered.
|
4770
|
|
|
* @param string $sep The separator, default: `|`.
|
4771
|
3 |
|
*/
|
4772
|
3 |
|
|
4773
|
|
|
return apply_filters( 'geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep );
|
4774
|
|
|
}
|
4775
|
3 |
|
|
4776
|
3 |
|
/**
|
4777
|
3 |
|
* Get the cpt texts for translation.
|
4778
|
3 |
|
*
|
4779
|
3 |
|
* @since 1.5.5
|
4780
|
3 |
|
* @package GeoDirectory
|
4781
|
3 |
|
*
|
4782
|
|
|
* @param array $translation_texts Array of text strings.
|
4783
|
|
|
*
|
4784
|
|
|
* @return array Translation texts.
|
4785
|
|
|
*/
|
4786
|
|
|
function geodir_load_cpt_text_translation( $translation_texts = array() ) {
|
4787
|
|
|
$gd_post_types = geodir_get_posttypes( 'array' );
|
4788
|
|
|
|
4789
|
|
|
if ( ! empty( $gd_post_types ) ) {
|
4790
|
|
|
foreach ( $gd_post_types as $post_type => $cpt_info ) {
|
|
|
|
|
4791
|
|
|
$labels = isset( $cpt_info['labels'] ) ? $cpt_info['labels'] : '';
|
4792
|
|
|
$description = isset( $cpt_info['description'] ) ? $cpt_info['description'] : '';
|
4793
|
|
|
$seo = isset( $cpt_info['seo'] ) ? $cpt_info['seo'] : '';
|
4794
|
2 |
|
|
4795
|
1 |
|
if ( ! empty( $labels ) ) {
|
4796
|
1 |
View Code Duplication |
if ( $labels['name'] != '' && ! in_array( $labels['name'], $translation_texts ) ) {
|
4797
|
2 |
|
$translation_texts[] = $labels['name'];
|
4798
|
|
|
}
|
4799
|
|
View Code Duplication |
if ( $labels['singular_name'] != '' && ! in_array( $labels['singular_name'], $translation_texts ) ) {
|
4800
|
|
|
$translation_texts[] = $labels['singular_name'];
|
4801
|
|
|
}
|
4802
|
|
View Code Duplication |
if ( $labels['add_new'] != '' && ! in_array( $labels['add_new'], $translation_texts ) ) {
|
4803
|
|
|
$translation_texts[] = $labels['add_new'];
|
4804
|
|
|
}
|
4805
|
|
View Code Duplication |
if ( $labels['add_new_item'] != '' && ! in_array( $labels['add_new_item'], $translation_texts ) ) {
|
4806
|
|
|
$translation_texts[] = $labels['add_new_item'];
|
4807
|
|
|
}
|
4808
|
|
View Code Duplication |
if ( $labels['edit_item'] != '' && ! in_array( $labels['edit_item'], $translation_texts ) ) {
|
4809
|
|
|
$translation_texts[] = $labels['edit_item'];
|
4810
|
|
|
}
|
4811
|
|
View Code Duplication |
if ( $labels['new_item'] != '' && ! in_array( $labels['new_item'], $translation_texts ) ) {
|
4812
|
|
|
$translation_texts[] = $labels['new_item'];
|
4813
|
|
|
}
|
4814
|
|
View Code Duplication |
if ( $labels['view_item'] != '' && ! in_array( $labels['view_item'], $translation_texts ) ) {
|
4815
|
|
|
$translation_texts[] = $labels['view_item'];
|
4816
|
|
|
}
|
4817
|
|
View Code Duplication |
if ( $labels['search_items'] != '' && ! in_array( $labels['search_items'], $translation_texts ) ) {
|
4818
|
|
|
$translation_texts[] = $labels['search_items'];
|
4819
|
|
|
}
|
4820
|
|
View Code Duplication |
if ( $labels['not_found'] != '' && ! in_array( $labels['not_found'], $translation_texts ) ) {
|
4821
|
|
|
$translation_texts[] = $labels['not_found'];
|
4822
|
|
|
}
|
4823
|
|
View Code Duplication |
if ( $labels['not_found_in_trash'] != '' && ! in_array( $labels['not_found_in_trash'], $translation_texts ) ) {
|
4824
|
|
|
$translation_texts[] = $labels['not_found_in_trash'];
|
4825
|
|
|
}
|
4826
|
|
View Code Duplication |
if ( isset( $labels['label_post_profile'] ) && $labels['label_post_profile'] != '' && ! in_array( $labels['label_post_profile'], $translation_texts ) ) {
|
4827
|
|
|
$translation_texts[] = $labels['label_post_profile'];
|
4828
|
|
|
}
|
4829
|
|
View Code Duplication |
if ( isset( $labels['label_post_info'] ) && $labels['label_post_info'] != '' && ! in_array( $labels['label_post_info'], $translation_texts ) ) {
|
4830
|
|
|
$translation_texts[] = $labels['label_post_info'];
|
4831
|
|
|
}
|
4832
|
|
View Code Duplication |
if ( isset( $labels['label_post_images'] ) && $labels['label_post_images'] != '' && ! in_array( $labels['label_post_images'], $translation_texts ) ) {
|
4833
|
|
|
$translation_texts[] = $labels['label_post_images'];
|
4834
|
|
|
}
|
4835
|
|
View Code Duplication |
if ( isset( $labels['label_post_map'] ) && $labels['label_post_map'] != '' && ! in_array( $labels['label_post_map'], $translation_texts ) ) {
|
4836
|
|
|
$translation_texts[] = $labels['label_post_map'];
|
4837
|
|
|
}
|
4838
|
|
View Code Duplication |
if ( isset( $labels['label_reviews'] ) && $labels['label_reviews'] != '' && ! in_array( $labels['label_reviews'], $translation_texts ) ) {
|
4839
|
|
|
$translation_texts[] = $labels['label_reviews'];
|
4840
|
|
|
}
|
4841
|
|
View Code Duplication |
if ( isset( $labels['label_related_listing'] ) && $labels['label_related_listing'] != '' && ! in_array( $labels['label_related_listing'], $translation_texts ) ) {
|
4842
|
|
|
$translation_texts[] = $labels['label_related_listing'];
|
4843
|
|
|
}
|
4844
|
|
|
}
|
4845
|
|
|
|
4846
|
|
|
if ( $description != '' && ! in_array( $description, $translation_texts ) ) {
|
4847
|
|
|
$translation_texts[] = normalize_whitespace( $description );
|
4848
|
|
|
}
|
4849
|
|
|
|
4850
|
|
|
if ( ! empty( $seo ) ) {
|
4851
|
|
View Code Duplication |
if ( isset( $seo['meta_keyword'] ) && $seo['meta_keyword'] != '' && ! in_array( $seo['meta_keyword'], $translation_texts ) ) {
|
4852
|
|
|
$translation_texts[] = normalize_whitespace( $seo['meta_keyword'] );
|
4853
|
|
|
}
|
4854
|
|
|
|
4855
|
|
View Code Duplication |
if ( isset( $seo['meta_description'] ) && $seo['meta_description'] != '' && ! in_array( $seo['meta_description'], $translation_texts ) ) {
|
4856
|
|
|
$translation_texts[] = normalize_whitespace( $seo['meta_description'] );
|
4857
|
|
|
}
|
4858
|
|
|
}
|
4859
|
|
|
}
|
4860
|
|
|
}
|
4861
|
|
|
$translation_texts = ! empty( $translation_texts ) ? array_unique( $translation_texts ) : $translation_texts;
|
4862
|
|
|
|
4863
|
|
|
return $translation_texts;
|
4864
|
|
|
}
|
4865
|
|
|
|
4866
|
|
|
/**
|
4867
|
|
|
* Remove the location terms to hide term from location url.
|
4868
|
|
|
*
|
4869
|
|
|
* @since 1.5.5
|
4870
|
|
|
* @package GeoDirectory
|
4871
|
|
|
*
|
4872
|
|
|
* @param array $location_terms Array of location terms.
|
4873
|
|
|
*
|
4874
|
|
|
* @return array Location terms.
|
4875
|
|
|
*/
|
4876
|
|
|
function geodir_remove_location_terms( $location_terms = array() ) {
|
4877
|
|
|
$location_manager = defined( 'POST_LOCATION_TABLE' ) ? true : false;
|
4878
|
|
|
|
4879
|
|
|
if ( ! empty( $location_terms ) && $location_manager ) {
|
4880
|
|
|
$hide_country_part = get_option( 'geodir_location_hide_country_part' );
|
4881
|
|
|
$hide_region_part = get_option( 'geodir_location_hide_region_part' );
|
4882
|
|
|
|
4883
|
|
|
if ( $hide_region_part && $hide_country_part ) {
|
4884
|
|
|
if ( isset( $location_terms['gd_country'] ) ) {
|
4885
|
|
|
unset( $location_terms['gd_country'] );
|
4886
|
|
|
}
|
4887
|
|
|
if ( isset( $location_terms['gd_region'] ) ) {
|
4888
|
|
|
unset( $location_terms['gd_region'] );
|
4889
|
|
|
}
|
4890
|
|
|
} else if ( $hide_region_part && ! $hide_country_part ) {
|
4891
|
|
|
if ( isset( $location_terms['gd_region'] ) ) {
|
4892
|
|
|
unset( $location_terms['gd_region'] );
|
4893
|
|
|
}
|
4894
|
|
|
} else if ( ! $hide_region_part && $hide_country_part ) {
|
4895
|
|
|
if ( isset( $location_terms['gd_country'] ) ) {
|
4896
|
|
|
unset( $location_terms['gd_country'] );
|
4897
|
|
|
}
|
4898
|
|
|
}
|
4899
|
|
|
}
|
4900
|
|
|
|
4901
|
|
|
return $location_terms;
|
4902
|
|
|
}
|
4903
|
|
|
|
4904
|
|
|
/**
|
4905
|
|
|
* Send notification when a listing has been edited by it's author.
|
4906
|
|
|
*
|
4907
|
|
|
* @since 1.5.9
|
4908
|
|
|
* @package GeoDirectory
|
4909
|
|
|
*
|
4910
|
|
|
* @param int $post_ID Post ID.
|
4911
|
|
|
* @param WP_Post $post Post object.
|
4912
|
|
|
* @param bool $update Whether this is an existing listing being updated or not.
|
4913
|
|
|
*/
|
4914
|
|
|
function geodir_on_wp_insert_post( $post_ID, $post, $update ) {
|
4915
|
|
|
if ( ! $update ) {
|
4916
|
|
|
return;
|
4917
|
|
|
}
|
4918
|
|
|
|
4919
|
|
|
$action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
|
4920
|
|
|
$is_admin = is_admin() && ( ! defined( 'DOING_AJAX' ) || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) ? true : false;
|
4921
|
|
|
$inline_save = $action == 'inline-save' ? true : false;
|
4922
|
|
|
|
4923
|
|
|
if ( empty( $post->post_type ) || $is_admin || $inline_save || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ) {
|
4924
|
|
|
return;
|
4925
|
|
|
}
|
4926
|
|
|
|
4927
|
|
|
if ( $action != '' && in_array( $action, array( 'geodir_import_export' ) ) ) {
|
4928
|
|
|
return;
|
4929
|
|
|
}
|
4930
|
|
|
|
4931
|
|
|
$user_id = (int) get_current_user_id();
|
4932
|
|
|
|
4933
|
|
|
if ( $user_id > 0 && get_option( 'geodir_notify_post_edited' ) && ! wp_is_post_revision( $post_ID ) && in_array( $post->post_type, geodir_get_posttypes() ) ) {
|
4934
|
|
|
$author_id = ! empty( $post->post_author ) ? $post->post_author : 0;
|
4935
|
|
|
|
4936
|
|
|
if ( $user_id == $author_id && ! is_super_admin() ) {
|
4937
|
|
|
$from_email = get_option( 'site_email' );
|
4938
|
|
|
$from_name = get_site_emailName();
|
4939
|
|
|
$to_email = get_option( 'admin_email' );
|
4940
|
|
|
$to_name = get_option( 'name' );
|
4941
|
|
|
$message_type = 'listing_edited';
|
4942
|
|
|
|
4943
|
|
|
$notify_edited = true;
|
4944
|
|
|
/**
|
4945
|
|
|
* Send notification when listing edited by author?
|
4946
|
|
|
*
|
4947
|
|
|
* @since 1.6.0
|
4948
|
|
|
*
|
4949
|
|
|
* @param bool $notify_edited Notify on listing edited by author?
|
4950
|
|
|
* @param object $post The current post object.
|
4951
|
|
|
*/
|
4952
|
|
|
$notify_edited = apply_filters( 'geodir_notify_on_listing_edited', $notify_edited, $post );
|
|
|
|
|
4953
|
|
|
|
4954
|
|
|
geodir_sendEmail( $from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID );
|
4955
|
|
|
}
|
4956
|
|
|
}
|
4957
|
|
|
}
|
4958
|
|
|
|
4959
|
|
|
/**
|
4960
|
|
|
* Retrieve the current page start & end numbering with context (i.e. 'page 2 of 4') for use as replacement string.
|
4961
|
|
|
*
|
4962
|
|
|
* @since 1.6.0
|
4963
|
|
|
* @package GeoDirectory
|
4964
|
|
|
*
|
4965
|
|
|
* @param string $sep The separator tag.
|
4966
|
|
|
*
|
4967
|
|
|
* @return string|null The current page start & end numbering.
|
4968
|
|
|
*/
|
4969
|
|
|
function geodir_title_meta_page( $sep ) {
|
4970
|
|
|
$replacement = null;
|
4971
|
|
|
|
4972
|
|
|
$max = geodir_title_meta_pagenumbering( 'max' );
|
4973
|
|
|
$nr = geodir_title_meta_pagenumbering( 'nr' );
|
4974
|
|
|
|
4975
|
|
|
if ( $max > 1 && $nr > 1 ) {
|
4976
|
|
|
$replacement = sprintf( $sep . ' ' . __( 'Page %1$d of %2$d', 'geodirectory' ), $nr, $max );
|
4977
|
|
|
}
|
4978
|
|
|
|
4979
|
|
|
return $replacement;
|
4980
|
|
|
}
|
4981
|
|
|
|
4982
|
|
|
/**
|
4983
|
|
|
* Retrieve the current page number for use as replacement string.
|
4984
|
|
|
*
|
4985
|
|
|
* @since 1.6.0
|
4986
|
|
|
* @package GeoDirectory
|
4987
|
|
|
*
|
4988
|
|
|
* @return string|null The current page number.
|
4989
|
|
|
*/
|
4990
|
|
View Code Duplication |
function geodir_title_meta_pagenumber() {
|
|
|
|
|
4991
|
|
|
$replacement = null;
|
4992
|
|
|
|
4993
|
|
|
$nr = geodir_title_meta_pagenumbering( 'nr' );
|
4994
|
|
|
if ( isset( $nr ) && $nr > 0 ) {
|
4995
|
|
|
$replacement = (string) $nr;
|
4996
|
|
|
}
|
4997
|
|
|
|
4998
|
|
|
return $replacement;
|
4999
|
|
|
}
|
5000
|
|
|
|
5001
|
|
|
/**
|
5002
|
|
|
* Retrieve the current page total for use as replacement string.
|
5003
|
|
|
*
|
5004
|
|
|
* @since 1.6.0
|
5005
|
|
|
* @package GeoDirectory
|
5006
|
|
|
*
|
5007
|
|
|
* @return string|null The current page total.
|
5008
|
|
|
*/
|
5009
|
|
View Code Duplication |
function geodir_title_meta_pagetotal() {
|
|
|
|
|
5010
|
|
|
$replacement = null;
|
5011
|
|
|
|
5012
|
|
|
$max = geodir_title_meta_pagenumbering( 'max' );
|
5013
|
|
|
if ( isset( $max ) && $max > 0 ) {
|
5014
|
|
|
$replacement = (string) $max;
|
5015
|
|
|
}
|
5016
|
|
|
|
5017
|
|
|
return $replacement;
|
5018
|
|
|
}
|
5019
|
|
|
|
5020
|
|
|
/**
|
5021
|
|
|
* Determine the page numbering of the current post/page/cpt.
|
5022
|
|
|
*
|
5023
|
|
|
* @param string $request 'nr'|'max' - whether to return the page number or the max number of pages.
|
5024
|
|
|
*
|
5025
|
|
|
* @since 1.6.0
|
5026
|
|
|
* @package GeoDirectory
|
5027
|
|
|
*
|
5028
|
|
|
* @global object $wp_query WordPress Query object.
|
5029
|
|
|
* @global object $post The current post object.
|
5030
|
|
|
*
|
5031
|
|
|
* @return int|null The current page numbering.
|
5032
|
|
|
*/
|
5033
|
|
|
function geodir_title_meta_pagenumbering( $request = 'nr' ) {
|
5034
|
|
|
global $wp_query, $post;
|
5035
|
|
|
$max_num_pages = null;
|
|
|
|
|
5036
|
|
|
$page_number = null;
|
|
|
|
|
5037
|
|
|
|
5038
|
|
|
$max_num_pages = 1;
|
5039
|
|
|
|
5040
|
|
|
if ( ! is_singular() ) {
|
5041
|
|
|
$page_number = get_query_var( 'paged' );
|
5042
|
|
|
if ( $page_number === 0 || $page_number === '' ) {
|
5043
|
|
|
$page_number = 1;
|
5044
|
|
|
}
|
5045
|
|
|
|
5046
|
|
|
if ( isset( $wp_query->max_num_pages ) && ( $wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0 ) ) {
|
5047
|
|
|
$max_num_pages = $wp_query->max_num_pages;
|
5048
|
|
|
}
|
5049
|
|
|
} else {
|
5050
|
|
|
$page_number = get_query_var( 'page' );
|
5051
|
|
|
if ( $page_number === 0 || $page_number === '' ) {
|
5052
|
|
|
$page_number = 1;
|
5053
|
|
|
}
|
5054
|
|
|
|
5055
|
|
|
if ( isset( $post->post_content ) ) {
|
5056
|
|
|
$max_num_pages = ( substr_count( $post->post_content, '<!--nextpage-->' ) + 1 );
|
5057
|
|
|
}
|
5058
|
|
|
}
|
5059
|
|
|
|
5060
|
|
|
$return = null;
|
5061
|
|
|
|
5062
|
|
|
switch ( $request ) {
|
5063
|
|
|
case 'nr':
|
5064
|
|
|
$return = $page_number;
|
5065
|
|
|
break;
|
5066
|
|
|
case 'max':
|
5067
|
|
|
$return = $max_num_pages;
|
5068
|
|
|
break;
|
5069
|
|
|
}
|
5070
|
|
|
|
5071
|
|
|
return $return;
|
5072
|
|
|
}
|
5073
|
|
|
|
5074
|
|
|
/**
|
5075
|
|
|
* Filter the terms with count empty.
|
5076
|
|
|
*
|
5077
|
|
|
* @since 1.5.4
|
5078
|
|
|
*
|
5079
|
|
|
* @param array $terms Terms array.
|
5080
|
|
|
*
|
5081
|
|
|
* @return array Terms.
|
5082
|
|
|
*/
|
5083
|
|
View Code Duplication |
function geodir_filter_empty_terms( $terms ) {
|
|
|
|
|
5084
|
|
|
if ( empty( $terms ) ) {
|
5085
|
|
|
return $terms;
|
5086
|
|
|
}
|
5087
|
|
|
|
5088
|
|
|
$return = array();
|
5089
|
|
|
foreach ( $terms as $term ) {
|
5090
|
|
|
if ( isset( $term->count ) && $term->count > 0 ) {
|
5091
|
|
|
$return[] = $term;
|
5092
|
|
|
} else {
|
5093
|
|
|
/**
|
5094
|
|
|
* Allow to filter terms with no count.
|
5095
|
|
|
*
|
5096
|
|
|
* @since 1.6.6
|
5097
|
|
|
*
|
5098
|
|
|
* @param array $return The array of terms to return.
|
5099
|
|
|
* @param object $term The term object.
|
5100
|
|
|
*/
|
5101
|
|
|
$return = apply_filters( 'geodir_filter_empty_terms_filter', $return, $term );
|
5102
|
|
|
}
|
5103
|
|
|
}
|
5104
|
|
|
|
5105
|
|
|
return $return;
|
5106
|
|
|
}
|
5107
|
|
|
|
5108
|
|
|
|
5109
|
|
|
/**
|
5110
|
|
|
* Remove the hentry class structured data from details pages.
|
5111
|
|
|
*
|
5112
|
|
|
* @since 1.6.5
|
5113
|
|
|
*
|
5114
|
|
|
* @param $class
|
5115
|
|
|
*
|
5116
|
|
|
* @return array
|
5117
|
|
|
*/
|
5118
|
|
|
function geodir_remove_hentry( $class ) {
|
5119
|
|
|
if ( geodir_is_page( 'detail' ) ) {
|
5120
|
|
|
$class = array_diff( $class, array( 'hentry' ) );
|
5121
|
|
|
}
|
5122
|
|
|
|
5123
|
|
|
return $class;
|
5124
|
|
|
}
|
5125
|
|
|
|
5126
|
|
|
add_filter( 'post_class', 'geodir_remove_hentry' ); |
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignore
annotation.See also the PhpDoc documentation for @ignore.