@@ -52,31 +52,31 @@ discard block |
||
| 52 | 52 | jQuery(listSel).children('li').switchClass('gridview_onehalf gridview_onethird gridview_onefourth', 'gridview_onefifth', 600);
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - jQuery.post("<?php echo geodir_get_ajax_url();?>&gd_listing_view=" + val, function (data) {
|
|
| 55 | + jQuery.post("<?php echo geodir_get_ajax_url(); ?>&gd_listing_view=" + val, function (data) {
|
|
| 56 | 56 | //alert(data ); |
| 57 | 57 | }); |
| 58 | 58 | } |
| 59 | 59 | </script> |
| 60 | 60 | <div class="geodir-list-view-select"> |
| 61 | 61 | <select name="gd_list_view" id="gd_list_view" onchange="geodir_list_view_select(this);"> |
| 62 | - <?php $listing_view = (int) $gd_session->get( 'gd_listing_view' ); ?> |
|
| 63 | - <option value=""><?php _e( 'View:', 'geodirectory' ); ?></option> |
|
| 62 | + <?php $listing_view = (int) $gd_session->get('gd_listing_view'); ?>
|
|
| 63 | + <option value=""><?php _e('View:', 'geodirectory'); ?></option>
|
|
| 64 | 64 | <option |
| 65 | - value="1" <?php selected( 1, $listing_view ); ?>><?php _e( 'View: List', 'geodirectory' ); ?></option> |
|
| 65 | + value="1" <?php selected(1, $listing_view); ?>><?php _e('View: List', 'geodirectory'); ?></option>
|
|
| 66 | 66 | <option |
| 67 | - value="2" <?php selected( 2, $listing_view ); ?>><?php _e( 'View: Grid 2', 'geodirectory' ); ?></option> |
|
| 67 | + value="2" <?php selected(2, $listing_view); ?>><?php _e('View: Grid 2', 'geodirectory'); ?></option>
|
|
| 68 | 68 | <option |
| 69 | - value="3" <?php selected( 3, $listing_view ); ?>><?php _e( 'View: Grid 3', 'geodirectory' ); ?></option> |
|
| 69 | + value="3" <?php selected(3, $listing_view); ?>><?php _e('View: Grid 3', 'geodirectory'); ?></option>
|
|
| 70 | 70 | <option |
| 71 | - value="4" <?php selected( 4, $listing_view ); ?>><?php _e( 'View: Grid 4', 'geodirectory' ); ?></option> |
|
| 71 | + value="4" <?php selected(4, $listing_view); ?>><?php _e('View: Grid 4', 'geodirectory'); ?></option>
|
|
| 72 | 72 | <option |
| 73 | - value="5" <?php selected( 5, $listing_view ); ?>><?php _e( 'View: Grid 5', 'geodirectory' ); ?></option> |
|
| 73 | + value="5" <?php selected(5, $listing_view); ?>><?php _e('View: Grid 5', 'geodirectory'); ?></option>
|
|
| 74 | 74 | </select> |
| 75 | 75 | </div> |
| 76 | 76 | <?php |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | -add_action( 'geodir_before_listing', 'geodir_list_view_select', 100 ); |
|
| 79 | +add_action('geodir_before_listing', 'geodir_list_view_select', 100);
|
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Limit the listing excerpt. |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | * @global object $post The current post object. |
| 92 | 92 | * @return string The modified excerpt. |
| 93 | 93 | */ |
| 94 | -function geodir_max_excerpt( $charlength ) {
|
|
| 94 | +function geodir_max_excerpt($charlength) {
|
|
| 95 | 95 | global $post; |
| 96 | - if ( $charlength == '0' ) {
|
|
| 96 | + if ($charlength == '0') {
|
|
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | $out = ''; |
@@ -101,46 +101,46 @@ discard block |
||
| 101 | 101 | $temp_post = $post; |
| 102 | 102 | $excerpt = get_the_excerpt(); |
| 103 | 103 | |
| 104 | - $charlength ++; |
|
| 105 | - $excerpt_more = function_exists( 'geodirf_excerpt_more' ) ? geodirf_excerpt_more( '' ) : geodir_excerpt_more( '' ); |
|
| 106 | - if ( geodir_utf8_strlen( $excerpt ) > $charlength ) {
|
|
| 107 | - if ( geodir_utf8_strlen( $excerpt_more ) > 0 && geodir_utf8_strpos( $excerpt, $excerpt_more ) !== false ) {
|
|
| 108 | - $excut = - ( geodir_utf8_strlen( $excerpt_more ) ); |
|
| 109 | - $subex = geodir_utf8_substr( $excerpt, 0, $excut ); |
|
| 110 | - if ( $charlength > 0 && geodir_utf8_strlen( $subex ) > $charlength ) {
|
|
| 111 | - $subex = geodir_utf8_substr( $subex, 0, $charlength ); |
|
| 104 | + $charlength++; |
|
| 105 | + $excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
|
|
| 106 | + if (geodir_utf8_strlen($excerpt) > $charlength) {
|
|
| 107 | + if (geodir_utf8_strlen($excerpt_more) > 0 && geodir_utf8_strpos($excerpt, $excerpt_more) !== false) {
|
|
| 108 | + $excut = - (geodir_utf8_strlen($excerpt_more)); |
|
| 109 | + $subex = geodir_utf8_substr($excerpt, 0, $excut); |
|
| 110 | + if ($charlength > 0 && geodir_utf8_strlen($subex) > $charlength) {
|
|
| 111 | + $subex = geodir_utf8_substr($subex, 0, $charlength); |
|
| 112 | 112 | } |
| 113 | 113 | $out .= $subex; |
| 114 | 114 | } else {
|
| 115 | - $subex = geodir_utf8_substr( $excerpt, 0, $charlength - 5 ); |
|
| 116 | - $exwords = explode( ' ', $subex ); |
|
| 117 | - $excut = - ( geodir_utf8_strlen( $exwords[ count( $exwords ) - 1 ] ) ); |
|
| 118 | - if ( $excut < 0 ) {
|
|
| 119 | - $out .= geodir_utf8_substr( $subex, 0, $excut ); |
|
| 115 | + $subex = geodir_utf8_substr($excerpt, 0, $charlength - 5); |
|
| 116 | + $exwords = explode(' ', $subex);
|
|
| 117 | + $excut = - (geodir_utf8_strlen($exwords[count($exwords) - 1])); |
|
| 118 | + if ($excut < 0) {
|
|
| 119 | + $out .= geodir_utf8_substr($subex, 0, $excut); |
|
| 120 | 120 | } else {
|
| 121 | 121 | $out .= $subex; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; |
|
| 124 | + $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">'; |
|
| 125 | 125 | /** |
| 126 | 126 | * Filter excerpt read more text. |
| 127 | 127 | * |
| 128 | 128 | * @since 1.0.0 |
| 129 | 129 | */ |
| 130 | - $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); |
|
| 130 | + $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 131 | 131 | $out .= '</a>'; |
| 132 | 132 | |
| 133 | 133 | } else {
|
| 134 | - if ( geodir_utf8_strlen( $excerpt_more ) > 0 && geodir_utf8_strpos( $excerpt, $excerpt_more ) !== false ) {
|
|
| 135 | - $excut = - ( geodir_utf8_strlen( $excerpt_more ) ); |
|
| 136 | - $out .= geodir_utf8_substr( $excerpt, 0, $excut ); |
|
| 137 | - $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; |
|
| 134 | + if (geodir_utf8_strlen($excerpt_more) > 0 && geodir_utf8_strpos($excerpt, $excerpt_more) !== false) {
|
|
| 135 | + $excut = - (geodir_utf8_strlen($excerpt_more)); |
|
| 136 | + $out .= geodir_utf8_substr($excerpt, 0, $excut); |
|
| 137 | + $out .= ' <a class="excerpt-read-more" href="'.get_permalink().'" title="'.get_the_title().'">'; |
|
| 138 | 138 | /** |
| 139 | 139 | * Filter excerpt read more text. |
| 140 | 140 | * |
| 141 | 141 | * @since 1.0.0 |
| 142 | 142 | */ |
| 143 | - $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); |
|
| 143 | + $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 144 | 144 | $out .= '</a>'; |
| 145 | 145 | } else {
|
| 146 | 146 | $out .= $excerpt; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return object Returns filtered package info as an object. |
| 165 | 165 | */ |
| 166 | -function geodir_post_package_info( $package_info, $post = '', $post_type = '' ) {
|
|
| 166 | +function geodir_post_package_info($package_info, $post = '', $post_type = '') {
|
|
| 167 | 167 | $package_info['pid'] = 0; |
| 168 | 168 | $package_info['days'] = 0; |
| 169 | 169 | $package_info['amount'] = 0; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param object|string $post The post object. |
| 193 | 193 | * @param string $post_type The post type. |
| 194 | 194 | */ |
| 195 | - return (object) apply_filters( 'geodir_post_package_info', $package_info, $post, $post_type ); |
|
| 195 | + return (object) apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
|
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * } |
| 222 | 222 | */ |
| 223 | -function geodir_send_inquiry( $request ) {
|
|
| 223 | +function geodir_send_inquiry($request) {
|
|
| 224 | 224 | global $wpdb; |
| 225 | 225 | |
| 226 | 226 | // strip slashes from text |
| 227 | - $request = ! empty( $request ) ? stripslashes_deep( $request ) : $request; |
|
| 227 | + $request = !empty($request) ? stripslashes_deep($request) : $request; |
|
| 228 | 228 | |
| 229 | 229 | $yourname = $request['inq_name']; |
| 230 | 230 | $youremail = $request['inq_email']; |
@@ -235,26 +235,26 @@ discard block |
||
| 235 | 235 | $author_id = ''; |
| 236 | 236 | $post_title = ''; |
| 237 | 237 | |
| 238 | - if ( $request['pid'] ) {
|
|
| 238 | + if ($request['pid']) {
|
|
| 239 | 239 | |
| 240 | 240 | $productinfosql = $wpdb->prepare( |
| 241 | 241 | "select ID,post_author,post_title from $wpdb->posts where ID =%d", |
| 242 | - array( $request['pid'] ) |
|
| 242 | + array($request['pid']) |
|
| 243 | 243 | ); |
| 244 | - $productinfo = $wpdb->get_row( $productinfosql ); |
|
| 244 | + $productinfo = $wpdb->get_row($productinfosql); |
|
| 245 | 245 | |
| 246 | 246 | $author_id = $productinfo->post_author; |
| 247 | 247 | $post_title = $productinfo->post_title; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $post_title = '<a href="' . get_permalink( $pid ) . '">' . $post_title . '</a>'; |
|
| 250 | + $post_title = '<a href="'.get_permalink($pid).'">'.$post_title.'</a>'; |
|
| 251 | 251 | |
| 252 | - $user_info = get_userdata( $author_id ); |
|
| 253 | - $to_email = geodir_get_post_meta( $pid, 'geodir_email', true ); |
|
| 254 | - $to_name = geodir_get_client_name( $author_id ); |
|
| 252 | + $user_info = get_userdata($author_id); |
|
| 253 | + $to_email = geodir_get_post_meta($pid, 'geodir_email', true); |
|
| 254 | + $to_name = geodir_get_client_name($author_id); |
|
| 255 | 255 | |
| 256 | - if ( $to_email == '' ) {
|
|
| 257 | - $to_email = get_option( 'admin_email' ); |
|
| 256 | + if ($to_email == '') {
|
|
| 257 | + $to_email = get_option('admin_email');
|
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -275,10 +275,10 @@ discard block |
||
| 275 | 275 | * } |
| 276 | 276 | * @param string $type The form type, default: `Enquiry`. |
| 277 | 277 | */ |
| 278 | - do_action( 'geodir_after_send_enquiry', $request, 'Enquiry' ); |
|
| 278 | + do_action('geodir_after_send_enquiry', $request, 'Enquiry');
|
|
| 279 | 279 | |
| 280 | 280 | $client_message = $frnd_comments; |
| 281 | - $client_message .= '<br>' . __( 'From :', 'geodirectory' ) . ' ' . $yourname . '<br>' . __( 'Phone :', 'geodirectory' ) . ' ' . $inq_phone . '<br>' . __( 'Email :', 'geodirectory' ) . ' ' . $youremail . '<br><br>' . __( 'Sent from', 'geodirectory' ) . ' - <b><a href="' . trailingslashit( home_url() ) . '">' . get_option( 'blogname' ) . '</a></b>.'; |
|
| 281 | + $client_message .= '<br>'.__('From :', 'geodirectory').' '.$yourname.'<br>'.__('Phone :', 'geodirectory').' '.$inq_phone.'<br>'.__('Email :', 'geodirectory').' '.$youremail.'<br><br>'.__('Sent from', 'geodirectory').' - <b><a href="'.trailingslashit(home_url()).'">'.get_option('blogname').'</a></b>.';
|
|
| 282 | 282 | /** |
| 283 | 283 | * Filter client message text. |
| 284 | 284 | * |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @param string $client_message Client message text. |
| 288 | 288 | */ |
| 289 | - $client_message = apply_filters( 'geodir_inquiry_email_msg', $client_message ); |
|
| 289 | + $client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
|
|
| 290 | 290 | |
| 291 | 291 | /** |
| 292 | 292 | * Called before the send enquiry email is sent. |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | * |
| 306 | 306 | * } |
| 307 | 307 | */ |
| 308 | - do_action( 'geodir_before_send_enquiry_email', $request ); |
|
| 309 | - if ( $to_email ) {
|
|
| 308 | + do_action('geodir_before_send_enquiry_email', $request);
|
|
| 309 | + if ($to_email) {
|
|
| 310 | 310 | // strip slashes message |
| 311 | - $client_message = stripslashes_deep( $client_message ); |
|
| 311 | + $client_message = stripslashes_deep($client_message); |
|
| 312 | 312 | |
| 313 | - geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid'] );//To client email |
|
| 313 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']); //To client email |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -330,12 +330,12 @@ discard block |
||
| 330 | 330 | * |
| 331 | 331 | * } |
| 332 | 332 | */ |
| 333 | - do_action( 'geodir_after_send_enquiry_email', $request ); |
|
| 334 | - $url = get_permalink( $pid ); |
|
| 335 | - if ( strstr( $url, '?' ) ) {
|
|
| 336 | - $url = $url . "&send_inquiry=success"; |
|
| 333 | + do_action('geodir_after_send_enquiry_email', $request);
|
|
| 334 | + $url = get_permalink($pid); |
|
| 335 | + if (strstr($url, '?')) {
|
|
| 336 | + $url = $url."&send_inquiry=success"; |
|
| 337 | 337 | } else {
|
| 338 | - $url = $url . "?send_inquiry=success"; |
|
| 338 | + $url = $url."?send_inquiry=success"; |
|
| 339 | 339 | } |
| 340 | 340 | /** |
| 341 | 341 | * Filter redirect url after the send enquiry email is sent. |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | * |
| 345 | 345 | * @param string $url Redirect url. |
| 346 | 346 | */ |
| 347 | - $url = apply_filters( 'geodir_send_enquiry_after_submit_redirect', $url ); |
|
| 348 | - wp_redirect( $url ); |
|
| 347 | + $url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
|
|
| 348 | + wp_redirect($url); |
|
| 349 | 349 | gd_die(); |
| 350 | 350 | |
| 351 | 351 | } |
@@ -374,11 +374,11 @@ discard block |
||
| 374 | 374 | * } |
| 375 | 375 | * @global object $wpdb WordPress Database object. |
| 376 | 376 | */ |
| 377 | -function geodir_send_friend( $request ) {
|
|
| 377 | +function geodir_send_friend($request) {
|
|
| 378 | 378 | global $wpdb; |
| 379 | 379 | |
| 380 | 380 | // strip slashes from text |
| 381 | - $request = ! empty( $request ) ? stripslashes_deep( $request ) : $request; |
|
| 381 | + $request = !empty($request) ? stripslashes_deep($request) : $request; |
|
| 382 | 382 | |
| 383 | 383 | $yourname = $request['yourname']; |
| 384 | 384 | $youremail = $request['youremail']; |
@@ -387,13 +387,13 @@ discard block |
||
| 387 | 387 | $pid = $request['pid']; |
| 388 | 388 | $to_email = $request['to_email']; |
| 389 | 389 | $to_name = $request['to_name']; |
| 390 | - if ( $request['pid'] ) {
|
|
| 390 | + if ($request['pid']) {
|
|
| 391 | 391 | $productinfosql = $wpdb->prepare( |
| 392 | 392 | "select ID,post_title from $wpdb->posts where ID =%d", |
| 393 | - array( $request['pid'] ) |
|
| 393 | + array($request['pid']) |
|
| 394 | 394 | ); |
| 395 | - $productinfo = $wpdb->get_results( $productinfosql ); |
|
| 396 | - foreach ( $productinfo as $productinfoObj ) {
|
|
| 395 | + $productinfo = $wpdb->get_results($productinfosql); |
|
| 396 | + foreach ($productinfo as $productinfoObj) {
|
|
| 397 | 397 | $post_title = $productinfoObj->post_title; |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | * |
| 418 | 418 | * } |
| 419 | 419 | */ |
| 420 | - do_action( 'geodir_before_send_to_friend_email', $request ); |
|
| 421 | - geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid'] );//To client email |
|
| 420 | + do_action('geodir_before_send_to_friend_email', $request);
|
|
| 421 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']); //To client email |
|
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | 424 | * Called after the send to friend email is sent. |
@@ -439,13 +439,13 @@ discard block |
||
| 439 | 439 | * |
| 440 | 440 | * } |
| 441 | 441 | */ |
| 442 | - do_action( 'geodir_after_send_to_friend_email', $request ); |
|
| 442 | + do_action('geodir_after_send_to_friend_email', $request);
|
|
| 443 | 443 | |
| 444 | - $url = get_permalink( $pid ); |
|
| 445 | - if ( strstr( $url, '?' ) ) {
|
|
| 446 | - $url = $url . "&sendtofrnd=success"; |
|
| 444 | + $url = get_permalink($pid); |
|
| 445 | + if (strstr($url, '?')) {
|
|
| 446 | + $url = $url."&sendtofrnd=success"; |
|
| 447 | 447 | } else {
|
| 448 | - $url = $url . "?sendtofrnd=success"; |
|
| 448 | + $url = $url."?sendtofrnd=success"; |
|
| 449 | 449 | } |
| 450 | 450 | /** |
| 451 | 451 | * Filter redirect url after the send to friend email is sent. |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | * |
| 455 | 455 | * @param string $url Redirect url. |
| 456 | 456 | */ |
| 457 | - $url = apply_filters( 'geodir_send_to_friend_after_submit_redirect', $url ); |
|
| 458 | - wp_redirect( $url ); |
|
| 457 | + $url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
|
|
| 458 | + wp_redirect($url); |
|
| 459 | 459 | gd_die(); |
| 460 | 460 | } |
| 461 | 461 | |
@@ -469,8 +469,8 @@ discard block |
||
| 469 | 469 | * |
| 470 | 470 | * @param string $hash_key |
| 471 | 471 | */ |
| 472 | -function geodir_before_tab_content( $hash_key ) {
|
|
| 473 | - switch ( $hash_key ) {
|
|
| 472 | +function geodir_before_tab_content($hash_key) {
|
|
| 473 | + switch ($hash_key) {
|
|
| 474 | 474 | case 'post_info' : |
| 475 | 475 | echo '<div class="geodir-company_info field-group">'; |
| 476 | 476 | break; |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @since 1.0.0 |
| 482 | 482 | */ |
| 483 | - echo ' <div id="' . apply_filters( 'geodir_post_gallery_id', 'geodir-post-gallery' ) . '" class="clearfix" >'; |
|
| 483 | + echo ' <div id="'.apply_filters('geodir_post_gallery_id', 'geodir-post-gallery').'" class="clearfix" >';
|
|
| 484 | 484 | break; |
| 485 | 485 | case 'reviews' : |
| 486 | 486 | echo '<div id="reviews-wrap" class="clearfix"> '; |
@@ -504,8 +504,8 @@ discard block |
||
| 504 | 504 | * |
| 505 | 505 | * @param string $hash_key |
| 506 | 506 | */ |
| 507 | -function geodir_after_tab_content( $hash_key ) {
|
|
| 508 | - switch ( $hash_key ) {
|
|
| 507 | +function geodir_after_tab_content($hash_key) {
|
|
| 508 | + switch ($hash_key) {
|
|
| 509 | 509 | case 'post_info' : |
| 510 | 510 | echo '</div>'; |
| 511 | 511 | break; |
@@ -536,25 +536,25 @@ discard block |
||
| 536 | 536 | * @global object $wpdb WordPress Database object. |
| 537 | 537 | * @return bool|null|string Returns default sort results, when the post type is valid. Otherwise returns false. |
| 538 | 538 | */ |
| 539 | -function geodir_get_posts_default_sort( $post_type ) {
|
|
| 539 | +function geodir_get_posts_default_sort($post_type) {
|
|
| 540 | 540 | |
| 541 | 541 | global $wpdb; |
| 542 | 542 | |
| 543 | - if ( $post_type != '' ) {
|
|
| 543 | + if ($post_type != '') {
|
|
| 544 | 544 | |
| 545 | 545 | $all_postypes = geodir_get_posttypes(); |
| 546 | 546 | |
| 547 | - if ( ! in_array( $post_type, $all_postypes ) ) {
|
|
| 547 | + if (!in_array($post_type, $all_postypes)) {
|
|
| 548 | 548 | return false; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $sort_field_info = $wpdb->get_var( $wpdb->prepare( "select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type= %s and is_active=%d and is_default=%d", array( |
|
| 551 | + $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." where post_type= %s and is_active=%d and is_default=%d", array(
|
|
| 552 | 552 | $post_type, |
| 553 | 553 | 1, |
| 554 | 554 | 1 |
| 555 | - ) ) ); |
|
| 555 | + ))); |
|
| 556 | 556 | |
| 557 | - if ( ! empty( $sort_field_info ) ) {
|
|
| 557 | + if (!empty($sort_field_info)) {
|
|
| 558 | 558 | return $sort_field_info; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -574,20 +574,20 @@ discard block |
||
| 574 | 574 | * @global object $wpdb WordPress Database object. |
| 575 | 575 | * @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false. |
| 576 | 576 | */ |
| 577 | -function geodir_get_sort_options( $post_type ) {
|
|
| 577 | +function geodir_get_sort_options($post_type) {
|
|
| 578 | 578 | global $wpdb; |
| 579 | 579 | |
| 580 | - if ( $post_type != '' ) {
|
|
| 580 | + if ($post_type != '') {
|
|
| 581 | 581 | $all_postypes = geodir_get_posttypes(); |
| 582 | 582 | |
| 583 | - if ( ! in_array( $post_type, $all_postypes ) ) {
|
|
| 583 | + if (!in_array($post_type, $all_postypes)) {
|
|
| 584 | 584 | return false; |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - $sort_field_info = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array( |
|
| 587 | + $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array(
|
|
| 588 | 588 | $post_type, |
| 589 | 589 | 1 |
| 590 | - ) ) ); |
|
| 590 | + ))); |
|
| 591 | 591 | |
| 592 | 592 | /** |
| 593 | 593 | * Filter post sort options. |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | * @param array $sort_field_info Unfiltered sort field array. |
| 598 | 598 | * @param string $post_type Post type. |
| 599 | 599 | */ |
| 600 | - return apply_filters( 'geodir_get_sort_options', $sort_field_info, $post_type ); |
|
| 600 | + return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
|
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | } |
@@ -618,63 +618,63 @@ discard block |
||
| 618 | 618 | * |
| 619 | 619 | * @since 1.4.4 |
| 620 | 620 | */ |
| 621 | - if ( is_search() ) {
|
|
| 621 | + if (is_search()) {
|
|
| 622 | 622 | return; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | $sort_by = ''; |
| 626 | 626 | |
| 627 | - if ( isset( $_REQUEST['sort_by'] ) ) {
|
|
| 627 | + if (isset($_REQUEST['sort_by'])) {
|
|
| 628 | 628 | $sort_by = $_REQUEST['sort_by']; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | $gd_post_type = geodir_get_current_posttype(); |
| 632 | 632 | |
| 633 | - $sort_options = geodir_get_sort_options( $gd_post_type ); |
|
| 633 | + $sort_options = geodir_get_sort_options($gd_post_type); |
|
| 634 | 634 | |
| 635 | 635 | |
| 636 | 636 | $sort_field_options = ''; |
| 637 | 637 | |
| 638 | - if ( ! empty( $sort_options ) ) {
|
|
| 639 | - foreach ( $sort_options as $sort ) {
|
|
| 640 | - $sort = stripslashes_deep( $sort ); // strip slashes |
|
| 638 | + if (!empty($sort_options)) {
|
|
| 639 | + foreach ($sort_options as $sort) {
|
|
| 640 | + $sort = stripslashes_deep($sort); // strip slashes |
|
| 641 | 641 | |
| 642 | - $label = __( $sort->site_title, 'geodirectory' ); |
|
| 642 | + $label = __($sort->site_title, 'geodirectory'); |
|
| 643 | 643 | |
| 644 | - if ( $sort->field_type == 'random' ) {
|
|
| 644 | + if ($sort->field_type == 'random') {
|
|
| 645 | 645 | $key = $sort->field_type; |
| 646 | - ( $sort_by == $key || ( $sort->is_default == '1' && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 647 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; |
|
| 646 | + ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 647 | + $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
|
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - if ( $sort->htmlvar_name == 'comment_count' ) {
|
|
| 650 | + if ($sort->htmlvar_name == 'comment_count') {
|
|
| 651 | 651 | $sort->htmlvar_name = 'rating_count'; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - if ( $sort->sort_asc ) {
|
|
| 655 | - $key = $sort->htmlvar_name . '_asc'; |
|
| 654 | + if ($sort->sort_asc) {
|
|
| 655 | + $key = $sort->htmlvar_name.'_asc'; |
|
| 656 | 656 | $label = $sort->site_title; |
| 657 | - if ( $sort->asc_title ) {
|
|
| 657 | + if ($sort->asc_title) {
|
|
| 658 | 658 | $label = $sort->asc_title; |
| 659 | 659 | } |
| 660 | - ( $sort_by == $key || ( $sort->is_default == '1' && $sort->default_order == $key && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 661 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; |
|
| 660 | + ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 661 | + $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
|
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - if ( $sort->sort_desc ) {
|
|
| 665 | - $key = $sort->htmlvar_name . '_desc'; |
|
| 664 | + if ($sort->sort_desc) {
|
|
| 665 | + $key = $sort->htmlvar_name.'_desc'; |
|
| 666 | 666 | $label = $sort->site_title; |
| 667 | - if ( $sort->desc_title ) {
|
|
| 667 | + if ($sort->desc_title) {
|
|
| 668 | 668 | $label = $sort->desc_title; |
| 669 | 669 | } |
| 670 | - ( $sort_by == $key || ( $sort->is_default == '1' && $sort->default_order == $key && ! isset( $_REQUEST['sort_by'] ) ) ) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 671 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg( 'sort_by', $key ) ) . '">' . __( $label, 'geodirectory' ) . '</option>'; |
|
| 670 | + ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 671 | + $sort_field_options .= '<option '.$selected.' value="'.esc_url(add_query_arg('sort_by', $key)).'">'.__($label, 'geodirectory').'</option>';
|
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | } |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - if ( $sort_field_options != '' ) {
|
|
| 677 | + if ($sort_field_options != '') {
|
|
| 678 | 678 | |
| 679 | 679 | ?> |
| 680 | 680 | |
@@ -683,9 +683,9 @@ discard block |
||
| 683 | 683 | <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;"> |
| 684 | 684 | |
| 685 | 685 | <option |
| 686 | - value="<?php echo esc_url( add_query_arg( 'sort_by', '' ) ); ?>" <?php if ( $sort_by == '' ) {
|
|
| 686 | + value="<?php echo esc_url(add_query_arg('sort_by', '')); ?>" <?php if ($sort_by == '') {
|
|
| 687 | 687 | echo 'selected="selected"'; |
| 688 | - } ?>><?php _e( 'Sort By', 'geodirectory' ); ?></option><?php |
|
| 688 | + } ?>><?php _e('Sort By', 'geodirectory'); ?></option><?php
|
|
| 689 | 689 | |
| 690 | 690 | echo $sort_field_options; ?> |
| 691 | 691 | |
@@ -713,9 +713,9 @@ discard block |
||
| 713 | 713 | * |
| 714 | 714 | * @return string Returns the section title. |
| 715 | 715 | */ |
| 716 | -function geodir_advance_customfields_heading( $title, $field_type ) {
|
|
| 716 | +function geodir_advance_customfields_heading($title, $field_type) {
|
|
| 717 | 717 | |
| 718 | - if ( in_array( $field_type, array( 'multiselect', 'textarea', 'taxonomy' ) ) ) {
|
|
| 718 | + if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
|
|
| 719 | 719 | $title = ''; |
| 720 | 720 | } |
| 721 | 721 | |
@@ -737,19 +737,19 @@ discard block |
||
| 737 | 737 | * @global object $gd_session GeoDirectory Session object. |
| 738 | 738 | * @return string Returns related posts html. |
| 739 | 739 | */ |
| 740 | -function geodir_related_posts_display( $request ) {
|
|
| 741 | - if ( ! empty( $request ) ) {
|
|
| 742 | - $before_title = ( isset( $request['before_title'] ) && ! empty( $request['before_title'] ) ) ? $request['before_title'] : ''; |
|
| 743 | - $after_title = ( isset( $request['after_title'] ) && ! empty( $request['after_title'] ) ) ? $request['after_title'] : ''; |
|
| 744 | - |
|
| 745 | - $title = ( isset( $request['title'] ) && ! empty( $request['title'] ) ) ? $request['title'] : __( 'Related Listings', 'geodirectory' ); |
|
| 746 | - $post_number = ( isset( $request['post_number'] ) && ! empty( $request['post_number'] ) ) ? $request['post_number'] : '5'; |
|
| 747 | - $relate_to = ( isset( $request['relate_to'] ) && ! empty( $request['relate_to'] ) ) ? $request['relate_to'] : 'category'; |
|
| 748 | - $layout = ( isset( $request['layout'] ) && ! empty( $request['layout'] ) ) ? $request['layout'] : 'gridview_onehalf'; |
|
| 749 | - $add_location_filter = ( isset( $request['add_location_filter'] ) && ! empty( $request['add_location_filter'] ) ) ? $request['add_location_filter'] : '0'; |
|
| 750 | - $listing_width = ( isset( $request['listing_width'] ) && ! empty( $request['listing_width'] ) ) ? $request['listing_width'] : ''; |
|
| 751 | - $list_sort = ( isset( $request['list_sort'] ) && ! empty( $request['list_sort'] ) ) ? $request['list_sort'] : 'latest'; |
|
| 752 | - $character_count = ( isset( $request['character_count'] ) && ! empty( $request['character_count'] ) ) ? $request['character_count'] : ''; |
|
| 740 | +function geodir_related_posts_display($request) {
|
|
| 741 | + if (!empty($request)) {
|
|
| 742 | + $before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : ''; |
|
| 743 | + $after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : ''; |
|
| 744 | + |
|
| 745 | + $title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
|
|
| 746 | + $post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5'; |
|
| 747 | + $relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category'; |
|
| 748 | + $layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf'; |
|
| 749 | + $add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0'; |
|
| 750 | + $listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : ''; |
|
| 751 | + $list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest'; |
|
| 752 | + $character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : ''; |
|
| 753 | 753 | |
| 754 | 754 | global $wpdb, $post, $gd_session, $related_nearest, $related_parent_lat, $related_parent_lon; |
| 755 | 755 | $related_parent_lat = !empty($post->post_latitude) ? $post->post_latitude : ''; |
@@ -757,10 +757,10 @@ discard block |
||
| 757 | 757 | $arr_detail_page_tabs = geodir_detail_page_tabs_list(); |
| 758 | 758 | |
| 759 | 759 | $related_listing_array = array(); |
| 760 | - if ( get_option( 'geodir_add_related_listing_posttypes' ) ) {
|
|
| 761 | - $related_listing_array = get_option( 'geodir_add_related_listing_posttypes' ); |
|
| 760 | + if (get_option('geodir_add_related_listing_posttypes')) {
|
|
| 761 | + $related_listing_array = get_option('geodir_add_related_listing_posttypes');
|
|
| 762 | 762 | } |
| 763 | - if ( isset($post->post_type) && in_array( $post->post_type, $related_listing_array ) ) {
|
|
| 763 | + if (isset($post->post_type) && in_array($post->post_type, $related_listing_array)) {
|
|
| 764 | 764 | $arr_detail_page_tabs['related_listing']['is_display'] = true; |
| 765 | 765 | } |
| 766 | 766 | |
@@ -772,90 +772,90 @@ discard block |
||
| 772 | 772 | $tax_field = 'id'; |
| 773 | 773 | $category = array(); |
| 774 | 774 | |
| 775 | - if ( isset( $_REQUEST['backandedit'] ) ) {
|
|
| 776 | - $post = (object) $gd_session->get( 'listing' ); |
|
| 775 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 776 | + $post = (object) $gd_session->get('listing');
|
|
| 777 | 777 | $post_type = $post->listing_type; |
| 778 | - if ( isset( $_REQUEST['pid'] ) && $_REQUEST['pid'] != '' ) {
|
|
| 778 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 779 | 779 | $post_id = $_REQUEST['pid']; |
| 780 | 780 | } |
| 781 | - } elseif ( isset( $_REQUEST['pid'] ) && $_REQUEST['pid'] != '' ) {
|
|
| 782 | - $post = geodir_get_post_info( $_REQUEST['pid'] ); |
|
| 781 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 782 | + $post = geodir_get_post_info($_REQUEST['pid']); |
|
| 783 | 783 | $post_type = $post->post_type; |
| 784 | 784 | $post_id = $_REQUEST['pid']; |
| 785 | - } elseif ( isset( $post->post_type ) && $post->post_type != '' ) {
|
|
| 785 | + } elseif (isset($post->post_type) && $post->post_type != '') {
|
|
| 786 | 786 | $post_type = $post->post_type; |
| 787 | 787 | $post_id = $post->ID; |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - if ( $relate_to == 'category' ) {
|
|
| 790 | + if ($relate_to == 'category') {
|
|
| 791 | 791 | |
| 792 | - $category_taxonomy = $post_type . $relate_to; |
|
| 793 | - if ( isset( $post->{$category_taxonomy} ) && $post->{$category_taxonomy} != '' ) {
|
|
| 794 | - $category = explode( ',', trim( $post->{$category_taxonomy}, ',' ) );
|
|
| 792 | + $category_taxonomy = $post_type.$relate_to; |
|
| 793 | + if (isset($post->{$category_taxonomy} ) && $post->{$category_taxonomy} != '') {
|
|
| 794 | + $category = explode(',', trim($post->{$category_taxonomy}, ','));
|
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - } elseif ( $relate_to == 'tags' ) {
|
|
| 797 | + } elseif ($relate_to == 'tags') {
|
|
| 798 | 798 | |
| 799 | - $category_taxonomy = $post_type . '_' . $relate_to; |
|
| 800 | - if ( $post->post_tags != '' ) {
|
|
| 801 | - $category = explode( ',', trim( $post->post_tags, ',' ) ); |
|
| 799 | + $category_taxonomy = $post_type.'_'.$relate_to; |
|
| 800 | + if ($post->post_tags != '') {
|
|
| 801 | + $category = explode(',', trim($post->post_tags, ','));
|
|
| 802 | 802 | } |
| 803 | 803 | $tax_field = 'name'; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | /* --- return false in invalid request --- */ |
| 807 | - if ( empty( $category ) ) {
|
|
| 807 | + if (empty($category)) {
|
|
| 808 | 808 | return false; |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | $all_postypes = geodir_get_posttypes(); |
| 812 | 812 | |
| 813 | - if ( ! in_array( $post_type, $all_postypes ) ) {
|
|
| 813 | + if (!in_array($post_type, $all_postypes)) {
|
|
| 814 | 814 | return false; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /* --- return false in invalid request --- */ |
| 818 | 818 | |
| 819 | 819 | $location_url = ''; |
| 820 | - if ( $add_location_filter != '0' ) {
|
|
| 820 | + if ($add_location_filter != '0') {
|
|
| 821 | 821 | $location_url = array(); |
| 822 | - $geodir_show_location_url = get_option( 'geodir_show_location_url' ); |
|
| 822 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 823 | 823 | |
| 824 | - $gd_city = get_query_var( 'gd_city' ); |
|
| 824 | + $gd_city = get_query_var('gd_city');
|
|
| 825 | 825 | |
| 826 | - if ( $gd_city ) {
|
|
| 827 | - $gd_country = get_query_var( 'gd_country' ); |
|
| 828 | - $gd_region = get_query_var( 'gd_region' ); |
|
| 826 | + if ($gd_city) {
|
|
| 827 | + $gd_country = get_query_var('gd_country');
|
|
| 828 | + $gd_region = get_query_var('gd_region');
|
|
| 829 | 829 | } else {
|
| 830 | 830 | $location = geodir_get_default_location(); |
| 831 | 831 | |
| 832 | - $gd_country = isset( $location->country_slug ) ? $location->country_slug : ''; |
|
| 833 | - $gd_region = isset( $location->region_slug ) ? $location->region_slug : ''; |
|
| 834 | - $gd_city = isset( $location->city_slug ) ? $location->city_slug : ''; |
|
| 832 | + $gd_country = isset($location->country_slug) ? $location->country_slug : ''; |
|
| 833 | + $gd_region = isset($location->region_slug) ? $location->region_slug : ''; |
|
| 834 | + $gd_city = isset($location->city_slug) ? $location->city_slug : ''; |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if ( $geodir_show_location_url == 'all' ) {
|
|
| 837 | + if ($geodir_show_location_url == 'all') {
|
|
| 838 | 838 | $location_url[] = $gd_country; |
| 839 | 839 | $location_url[] = $gd_region; |
| 840 | - } else if ( $geodir_show_location_url == 'country_city' ) {
|
|
| 840 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 841 | 841 | $location_url[] = $gd_country; |
| 842 | - } else if ( $geodir_show_location_url == 'region_city' ) {
|
|
| 842 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 843 | 843 | $location_url[] = $gd_region; |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | $location_url[] = $gd_city; |
| 847 | 847 | |
| 848 | - $location_url = implode( '/', $location_url ); |
|
| 848 | + $location_url = implode('/', $location_url);
|
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | |
| 852 | - if ( ! empty( $category ) ) {
|
|
| 852 | + if (!empty($category)) {
|
|
| 853 | 853 | global $geodir_add_location_url; |
| 854 | 854 | $geodir_add_location_url = '0'; |
| 855 | - if ( $add_location_filter != '0' ) {
|
|
| 855 | + if ($add_location_filter != '0') {
|
|
| 856 | 856 | $geodir_add_location_url = '1'; |
| 857 | 857 | } |
| 858 | - $viewall_url = get_term_link( (int) $category[0], $post_type . $category_taxonomy ); |
|
| 858 | + $viewall_url = get_term_link((int) $category[0], $post_type.$category_taxonomy); |
|
| 859 | 859 | $geodir_add_location_url = null; |
| 860 | 860 | } |
| 861 | 861 | ob_start(); |
@@ -865,24 +865,24 @@ discard block |
||
| 865 | 865 | <div class="geodir_locations geodir_location_listing"> |
| 866 | 866 | |
| 867 | 867 | <?php |
| 868 | - if ( isset( $request['is_widget'] ) && $request['is_widget'] == '1' ) {
|
|
| 868 | + if (isset($request['is_widget']) && $request['is_widget'] == '1') {
|
|
| 869 | 869 | /** geodir_before_title filter Documented in geodirectory_widgets.php */ |
| 870 | - $before_title = isset( $before_title ) ? $before_title : apply_filters( 'geodir_before_title', '<h3 class="widget-title">' ); |
|
| 870 | + $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
|
|
| 871 | 871 | /** geodir_after_title filter Documented in geodirectory_widgets.php */ |
| 872 | - $after_title = isset( $after_title ) ? $after_title : apply_filters( 'geodir_after_title', '</h3>' ); |
|
| 872 | + $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
|
|
| 873 | 873 | ?> |
| 874 | 874 | <div class="location_list_heading clearfix"> |
| 875 | - <?php echo $before_title . $title . $after_title; ?> |
|
| 875 | + <?php echo $before_title.$title.$after_title; ?> |
|
| 876 | 876 | </div> |
| 877 | 877 | <?php |
| 878 | 878 | } |
| 879 | 879 | $query_args = array( |
| 880 | 880 | 'posts_per_page' => $post_number, |
| 881 | 881 | 'is_geodir_loop' => true, |
| 882 | - 'gd_location' => ( $add_location_filter ) ? true : false, |
|
| 882 | + 'gd_location' => ($add_location_filter) ? true : false, |
|
| 883 | 883 | 'post_type' => $post_type, |
| 884 | 884 | 'order_by' => $list_sort, |
| 885 | - 'post__not_in' => array( $post_id ), |
|
| 885 | + 'post__not_in' => array($post_id), |
|
| 886 | 886 | 'excerpt_length' => $character_count, |
| 887 | 887 | 'related_listings' => $is_display |
| 888 | 888 | ); |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | 'terms' => $category |
| 894 | 894 | ); |
| 895 | 895 | |
| 896 | - $query_args['tax_query'] = array( $tax_query ); |
|
| 896 | + $query_args['tax_query'] = array($tax_query); |
|
| 897 | 897 | |
| 898 | 898 | global $gridview_columns, $post; |
| 899 | 899 | |
@@ -905,21 +905,21 @@ discard block |
||
| 905 | 905 | * @param array $query_args The query array. |
| 906 | 906 | * @param array $request Related posts request array. |
| 907 | 907 | */ |
| 908 | - $query_args = apply_filters( 'geodir_related_posts_widget_query_args', $query_args, $request ); |
|
| 908 | + $query_args = apply_filters('geodir_related_posts_widget_query_args', $query_args, $request);
|
|
| 909 | 909 | |
| 910 | - query_posts( $query_args ); |
|
| 910 | + query_posts($query_args); |
|
| 911 | 911 | |
| 912 | - if ( strstr( $layout, 'gridview' ) ) {
|
|
| 913 | - $listing_view_exp = explode( '_', $layout ); |
|
| 912 | + if (strstr($layout, 'gridview')) {
|
|
| 913 | + $listing_view_exp = explode('_', $layout);
|
|
| 914 | 914 | $gridview_columns = $layout; |
| 915 | 915 | $layout = $listing_view_exp[0]; |
| 916 | - } else if ( $layout == 'list' ) {
|
|
| 916 | + } else if ($layout == 'list') {
|
|
| 917 | 917 | $gridview_columns = ''; |
| 918 | 918 | } |
| 919 | 919 | $related_posts = true; |
| 920 | 920 | |
| 921 | 921 | $related_nearest = false; |
| 922 | - if ( $list_sort == 'nearest' ) {
|
|
| 922 | + if ($list_sort == 'nearest') {
|
|
| 923 | 923 | $related_nearest = true; |
| 924 | 924 | } |
| 925 | 925 | |
@@ -929,14 +929,14 @@ discard block |
||
| 929 | 929 | * |
| 930 | 930 | * @since 1.0.0 |
| 931 | 931 | */ |
| 932 | - $template = apply_filters( "geodir_template_part-related-listing-listview", geodir_locate_template( 'listing-listview' ) ); |
|
| 932 | + $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
|
|
| 933 | 933 | |
| 934 | 934 | /** |
| 935 | 935 | * Includes related listing listview template. |
| 936 | 936 | * |
| 937 | 937 | * @since 1.0.0 |
| 938 | 938 | */ |
| 939 | - include( $template ); |
|
| 939 | + include($template); |
|
| 940 | 940 | |
| 941 | 941 | wp_reset_query(); |
| 942 | 942 | $post = $origi_post; |
@@ -964,12 +964,12 @@ discard block |
||
| 964 | 964 | function geodir_category_count_script() {
|
| 965 | 965 | global $geodir_post_category_str; |
| 966 | 966 | |
| 967 | - if ( ! empty( $geodir_post_category_str ) ) {
|
|
| 968 | - $geodir_post_category_str = serialize( $geodir_post_category_str ); |
|
| 967 | + if (!empty($geodir_post_category_str)) {
|
|
| 968 | + $geodir_post_category_str = serialize($geodir_post_category_str); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - $all_var['post_category_array'] = html_entity_decode( (string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8' ); |
|
| 972 | - $script = "var post_category_array = " . json_encode( $all_var ) . ';'; |
|
| 971 | + $all_var['post_category_array'] = html_entity_decode((string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8'); |
|
| 972 | + $script = "var post_category_array = ".json_encode($all_var).';'; |
|
| 973 | 973 | echo '<script>'; |
| 974 | 974 | echo $script; |
| 975 | 975 | echo '</script>'; |
@@ -984,8 +984,8 @@ discard block |
||
| 984 | 984 | * @return string Returns the default language. |
| 985 | 985 | */ |
| 986 | 986 | function geodir_get_map_default_language() {
|
| 987 | - $geodir_default_map_language = get_option( 'geodir_default_map_language' ); |
|
| 988 | - if ( empty( $geodir_default_map_language ) ) {
|
|
| 987 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 988 | + if (empty($geodir_default_map_language)) {
|
|
| 989 | 989 | $geodir_default_map_language = 'en'; |
| 990 | 990 | } |
| 991 | 991 | |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | * |
| 997 | 997 | * @param string $geodir_default_map_language Default map language. |
| 998 | 998 | */ |
| 999 | - return apply_filters( 'geodir_default_map_language', $geodir_default_map_language ); |
|
| 999 | + return apply_filters('geodir_default_map_language', $geodir_default_map_language);
|
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | * @return string Returns the api key. |
| 1008 | 1008 | */ |
| 1009 | 1009 | function geodir_get_map_api_key() {
|
| 1010 | - $key = get_option( 'geodir_google_api_key' ); |
|
| 1010 | + $key = get_option('geodir_google_api_key');
|
|
| 1011 | 1011 | |
| 1012 | 1012 | /** |
| 1013 | 1013 | * Filter Google maps api key. |
@@ -1016,7 +1016,7 @@ discard block |
||
| 1016 | 1016 | * |
| 1017 | 1017 | * @param string $key Google maps api key. |
| 1018 | 1018 | */ |
| 1019 | - return apply_filters( 'geodir_google_api_key', $key ); |
|
| 1019 | + return apply_filters('geodir_google_api_key', $key);
|
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | |
@@ -1036,20 +1036,20 @@ discard block |
||
| 1036 | 1036 | global $wp, $post, $wp_query, $wpdb, $geodir_addon_list; |
| 1037 | 1037 | |
| 1038 | 1038 | $is_geodir_page = geodir_is_geodir_page(); |
| 1039 | - if ( ! $is_geodir_page ) {
|
|
| 1039 | + if (!$is_geodir_page) {
|
|
| 1040 | 1040 | return; |
| 1041 | 1041 | }// if non GD page, bail |
| 1042 | 1042 | |
| 1043 | 1043 | $use_gd_meta = true; |
| 1044 | - if ( ( class_exists( 'WPSEO_Frontend' ) || class_exists( 'All_in_One_SEO_Pack' ) ) && !geodir_disable_yoast_seo_metas() ) {
|
|
| 1044 | + if ((class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) && !geodir_disable_yoast_seo_metas()) {
|
|
| 1045 | 1045 | $use_gd_meta = false; |
| 1046 | 1046 | |
| 1047 | - if ( geodir_is_page( 'search' ) ) {
|
|
| 1047 | + if (geodir_is_page('search')) {
|
|
| 1048 | 1048 | $use_gd_meta = true; |
| 1049 | 1049 | } |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - if ( ! $use_gd_meta ) {
|
|
| 1052 | + if (!$use_gd_meta) {
|
|
| 1053 | 1053 | return; |
| 1054 | 1054 | }// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active. |
| 1055 | 1055 | |
@@ -1057,170 +1057,170 @@ discard block |
||
| 1057 | 1057 | |
| 1058 | 1058 | $all_postypes = geodir_get_posttypes(); |
| 1059 | 1059 | |
| 1060 | - $geodir_taxonomies = geodir_get_taxonomies( '', true ); |
|
| 1060 | + $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 1061 | 1061 | |
| 1062 | 1062 | $meta_desc = ''; |
| 1063 | 1063 | $meta_key = ''; |
| 1064 | - if ( isset( $current_term->ID ) && $current_term->ID == geodir_location_page_id() ) {
|
|
| 1064 | + if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
|
|
| 1065 | 1065 | /** |
| 1066 | 1066 | * Filter SEO meta location description. |
| 1067 | 1067 | * |
| 1068 | 1068 | * @since 1.0.0 |
| 1069 | 1069 | */ |
| 1070 | - $meta_desc = apply_filters( 'geodir_seo_meta_location_description', '' ); |
|
| 1070 | + $meta_desc = apply_filters('geodir_seo_meta_location_description', '');
|
|
| 1071 | 1071 | $meta_desc .= ''; |
| 1072 | 1072 | } |
| 1073 | - if ( have_posts() && is_single() OR is_page() ) {
|
|
| 1074 | - while ( have_posts() ) {
|
|
| 1073 | + if (have_posts() && is_single() OR is_page()) {
|
|
| 1074 | + while (have_posts()) {
|
|
| 1075 | 1075 | the_post(); |
| 1076 | 1076 | |
| 1077 | - if ( has_excerpt() ) {
|
|
| 1078 | - $out_excerpt = strip_tags( strip_shortcodes( get_the_excerpt() ) ); |
|
| 1079 | - if ( empty( $out_excerpt ) ) {
|
|
| 1080 | - $out_excerpt = strip_tags( do_shortcode( get_the_excerpt() ) ); |
|
| 1077 | + if (has_excerpt()) {
|
|
| 1078 | + $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt())); |
|
| 1079 | + if (empty($out_excerpt)) {
|
|
| 1080 | + $out_excerpt = strip_tags(do_shortcode(get_the_excerpt())); |
|
| 1081 | 1081 | } |
| 1082 | - $out_excerpt = str_replace( array( "\r\n", "\r", "\n" ), "", $out_excerpt ); |
|
| 1082 | + $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
|
|
| 1083 | 1083 | } else {
|
| 1084 | - $out_excerpt = str_replace( array( "\r\n", "\r", "\n" ), "", $post->post_content ); |
|
| 1085 | - $out_excerpt = strip_tags( strip_shortcodes( $out_excerpt ) ); |
|
| 1086 | - if ( empty( $out_excerpt ) ) {
|
|
| 1087 | - $out_excerpt = strip_tags( do_shortcode( $out_excerpt ) ); // parse short code from content |
|
| 1084 | + $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
|
|
| 1085 | + $out_excerpt = strip_tags(strip_shortcodes($out_excerpt)); |
|
| 1086 | + if (empty($out_excerpt)) {
|
|
| 1087 | + $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content |
|
| 1088 | 1088 | } |
| 1089 | - $out_excerpt = trim( wp_trim_words( $out_excerpt, 35, '' ), '.!?,;:-' ); |
|
| 1089 | + $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-'); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | $meta_desc .= $out_excerpt; |
| 1093 | 1093 | } |
| 1094 | - } elseif ( ( is_category() || is_tag() ) && isset( $current_term->taxonomy ) && in_array( $current_term->taxonomy, $geodir_taxonomies ) ) {
|
|
| 1095 | - if ( is_category() ) {
|
|
| 1096 | - $meta_desc .= __( "Posts related to Category:", 'geodirectory' ) . " " . ucfirst( single_cat_title( "", false ) ); |
|
| 1097 | - } elseif ( is_tag() ) {
|
|
| 1098 | - $meta_desc .= __( "Posts related to Tag:", 'geodirectory' ) . " " . ucfirst( single_tag_title( "", false ) ); |
|
| 1094 | + } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
|
|
| 1095 | + if (is_category()) {
|
|
| 1096 | + $meta_desc .= __("Posts related to Category:", 'geodirectory')." ".ucfirst(single_cat_title("", false));
|
|
| 1097 | + } elseif (is_tag()) {
|
|
| 1098 | + $meta_desc .= __("Posts related to Tag:", 'geodirectory')." ".ucfirst(single_tag_title("", false));
|
|
| 1099 | 1099 | } |
| 1100 | - } elseif ( isset( $current_term->taxonomy ) && in_array( $current_term->taxonomy, $geodir_taxonomies ) ) {
|
|
| 1101 | - $meta_desc .= isset( $current_term->description ) ? $current_term->description : ''; |
|
| 1100 | + } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
|
|
| 1101 | + $meta_desc .= isset($current_term->description) ? $current_term->description : ''; |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | |
| 1105 | 1105 | $geodir_post_type = geodir_get_current_posttype(); |
| 1106 | - $geodir_post_type_info = get_post_type_object( $geodir_post_type ); |
|
| 1107 | - $geodir_is_page_listing = geodir_is_page( 'listing' ) ? true : false; |
|
| 1108 | - |
|
| 1109 | - $category_taxonomy = geodir_get_taxonomies( $geodir_post_type ); |
|
| 1110 | - $tag_taxonomy = geodir_get_taxonomies( $geodir_post_type, true ); |
|
| 1111 | - |
|
| 1112 | - $geodir_is_category = isset( $category_taxonomy[0] ) && get_query_var( $category_taxonomy[0] ) ? get_query_var( $category_taxonomy[0] ) : false; |
|
| 1113 | - $geodir_is_tag = isset( $tag_taxonomy[0] ) && get_query_var( $tag_taxonomy[0] ) ? true : false; |
|
| 1114 | - |
|
| 1115 | - $geodir_is_search = geodir_is_page( 'search' ) ? true : false; |
|
| 1116 | - $geodir_is_location = geodir_is_page( 'location' ) ? true : false; |
|
| 1117 | - $geodir_location_manager = isset( $geodir_addon_list['geodir_location_manager'] ) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false; |
|
| 1118 | - $godir_location_terms = geodir_get_current_location_terms( 'query_vars' ); |
|
| 1119 | - $gd_city = $geodir_location_manager && isset( $godir_location_terms['gd_city'] ) ? $godir_location_terms['gd_city'] : null; |
|
| 1120 | - $gd_region = $geodir_location_manager && isset( $godir_location_terms['gd_region'] ) ? $godir_location_terms['gd_region'] : null; |
|
| 1121 | - $gd_country = $geodir_location_manager && isset( $godir_location_terms['gd_country'] ) ? $godir_location_terms['gd_country'] : null; |
|
| 1122 | - $replace_location = __( 'Everywhere', 'geodirectory' ); |
|
| 1106 | + $geodir_post_type_info = get_post_type_object($geodir_post_type); |
|
| 1107 | + $geodir_is_page_listing = geodir_is_page('listing') ? true : false;
|
|
| 1108 | + |
|
| 1109 | + $category_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
| 1110 | + $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true); |
|
| 1111 | + |
|
| 1112 | + $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false; |
|
| 1113 | + $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false; |
|
| 1114 | + |
|
| 1115 | + $geodir_is_search = geodir_is_page('search') ? true : false;
|
|
| 1116 | + $geodir_is_location = geodir_is_page('location') ? true : false;
|
|
| 1117 | + $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false; |
|
| 1118 | + $godir_location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1119 | + $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : null; |
|
| 1120 | + $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : null; |
|
| 1121 | + $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : null; |
|
| 1122 | + $replace_location = __('Everywhere', 'geodirectory');
|
|
| 1123 | 1123 | $location_id = null; |
| 1124 | - if ( $geodir_location_manager ) {
|
|
| 1125 | - $sql = $wpdb->prepare( "SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array( $gd_city ) ); |
|
| 1126 | - $location_id = (int) $wpdb->get_var( $sql ); |
|
| 1124 | + if ($geodir_location_manager) {
|
|
| 1125 | + $sql = $wpdb->prepare("SELECT location_id FROM ".POST_LOCATION_TABLE." WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
|
|
| 1126 | + $location_id = (int) $wpdb->get_var($sql); |
|
| 1127 | 1127 | $location_type = geodir_what_is_current_location(); |
| 1128 | - if ( $location_type == 'city' ) {
|
|
| 1129 | - $replace_location = geodir_get_current_location( array( 'what' => 'city', 'echo' => false ) ); |
|
| 1130 | - } elseif ( $location_type == 'region' ) {
|
|
| 1131 | - $replace_location = geodir_get_current_location( array( 'what' => 'region', 'echo' => false ) ); |
|
| 1132 | - } elseif ( $location_type == 'country' ) {
|
|
| 1133 | - $replace_location = geodir_get_current_location( array( 'what' => 'country', 'echo' => false ) ); |
|
| 1134 | - $replace_location = __( $replace_location, 'geodirectory' ); |
|
| 1128 | + if ($location_type == 'city') {
|
|
| 1129 | + $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
|
|
| 1130 | + } elseif ($location_type == 'region') {
|
|
| 1131 | + $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
|
|
| 1132 | + } elseif ($location_type == 'country') {
|
|
| 1133 | + $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
|
|
| 1134 | + $replace_location = __($replace_location, 'geodirectory'); |
|
| 1135 | 1135 | } |
| 1136 | - $country = get_query_var( 'gd_country' ); |
|
| 1137 | - $region = get_query_var( 'gd_region' ); |
|
| 1138 | - $city = get_query_var( 'gd_city' ); |
|
| 1136 | + $country = get_query_var('gd_country');
|
|
| 1137 | + $region = get_query_var('gd_region');
|
|
| 1138 | + $city = get_query_var('gd_city');
|
|
| 1139 | 1139 | $current_location = ''; |
| 1140 | - if ( $country != '' ) {
|
|
| 1141 | - $current_location = get_actual_location_name( 'country', $country, true ); |
|
| 1140 | + if ($country != '') {
|
|
| 1141 | + $current_location = get_actual_location_name('country', $country, true);
|
|
| 1142 | 1142 | } |
| 1143 | - if ( $region != '' ) {
|
|
| 1144 | - $current_location = get_actual_location_name( 'region', $region ); |
|
| 1143 | + if ($region != '') {
|
|
| 1144 | + $current_location = get_actual_location_name('region', $region);
|
|
| 1145 | 1145 | } |
| 1146 | - if ( $city != '' ) {
|
|
| 1147 | - $current_location = get_actual_location_name( 'city', $city ); |
|
| 1146 | + if ($city != '') {
|
|
| 1147 | + $current_location = get_actual_location_name('city', $city);
|
|
| 1148 | 1148 | } |
| 1149 | 1149 | $replace_location = $current_location != '' ? $current_location : $replace_location; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | $geodir_meta_keys = ''; |
| 1153 | 1153 | $geodir_meta_desc = ''; |
| 1154 | - if ( $is_geodir_page && ! empty( $geodir_post_type_info ) ) {
|
|
| 1155 | - if ( $geodir_is_page_listing || $geodir_is_search || geodir_is_page( 'add-listing' ) ) {
|
|
| 1156 | - $geodir_meta_keys = isset( $geodir_post_type_info->seo['meta_keyword'] ) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys; |
|
| 1154 | + if ($is_geodir_page && !empty($geodir_post_type_info)) {
|
|
| 1155 | + if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
|
|
| 1156 | + $geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys; |
|
| 1157 | 1157 | |
| 1158 | - $geodir_meta_desc = isset( $geodir_post_type_info->description ) ? $geodir_post_type_info->description : $geodir_meta_desc; |
|
| 1159 | - $geodir_meta_desc = isset( $geodir_post_type_info->seo['meta_description'] ) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc; |
|
| 1158 | + $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc; |
|
| 1159 | + $geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc; |
|
| 1160 | 1160 | |
| 1161 | - if ( $geodir_is_category ) {
|
|
| 1162 | - $category = $geodir_is_category ? get_term_by( 'slug', $geodir_is_category, $category_taxonomy[0] ) : null; |
|
| 1163 | - if ( isset( $category->term_id ) && ! empty( $category->term_id ) ) {
|
|
| 1161 | + if ($geodir_is_category) {
|
|
| 1162 | + $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : null;
|
|
| 1163 | + if (isset($category->term_id) && !empty($category->term_id)) {
|
|
| 1164 | 1164 | $category_id = $category->term_id; |
| 1165 | - $category_desc = trim( $category->description ) != '' ? trim( $category->description ) : get_tax_meta( $category_id, 'ct_cat_top_desc', false, $geodir_post_type ); |
|
| 1166 | - if ( $location_id ) {
|
|
| 1167 | - $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id; |
|
| 1168 | - $cat_loc_option = get_option( $option_name ); |
|
| 1169 | - |
|
| 1170 | - $gd_cat_loc_default = ! empty( $cat_loc_option ) && isset( $cat_loc_option['gd_cat_loc_default'] ) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false; |
|
| 1171 | - if ( ! $gd_cat_loc_default ) {
|
|
| 1172 | - $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id; |
|
| 1173 | - $option = get_option( $option_name ); |
|
| 1174 | - $category_desc = isset( $option['gd_cat_loc_desc'] ) && trim( $option['gd_cat_loc_desc'] ) != '' ? trim( $option['gd_cat_loc_desc'] ) : $category_desc; |
|
| 1165 | + $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type); |
|
| 1166 | + if ($location_id) {
|
|
| 1167 | + $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id; |
|
| 1168 | + $cat_loc_option = get_option($option_name); |
|
| 1169 | + |
|
| 1170 | + $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false; |
|
| 1171 | + if (!$gd_cat_loc_default) {
|
|
| 1172 | + $option_name = 'geodir_cat_loc_'.$geodir_post_type.'_'.$category_id.'_'.$location_id; |
|
| 1173 | + $option = get_option($option_name); |
|
| 1174 | + $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc; |
|
| 1175 | 1175 | } |
| 1176 | 1176 | } |
| 1177 | - $geodir_meta_desc = __( "Posts related to Category:", 'geodirectory' ) . " " . ucfirst( single_cat_title( "", false ) ) . '. ' . $category_desc; |
|
| 1177 | + $geodir_meta_desc = __("Posts related to Category:", 'geodirectory')." ".ucfirst(single_cat_title("", false)).'. '.$category_desc;
|
|
| 1178 | 1178 | } |
| 1179 | - } else if ( $geodir_is_tag ) {
|
|
| 1180 | - $geodir_meta_desc = __( "Posts related to Tag:", 'geodirectory' ) . " " . ucfirst( single_tag_title( "", false ) ) . '. ' . $geodir_meta_desc; |
|
| 1179 | + } else if ($geodir_is_tag) {
|
|
| 1180 | + $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory')." ".ucfirst(single_tag_title("", false)).'. '.$geodir_meta_desc;
|
|
| 1181 | 1181 | } |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | |
| 1186 | 1186 | $gd_page = ''; |
| 1187 | - if ( geodir_is_page( 'home' ) ) {
|
|
| 1187 | + if (geodir_is_page('home')) {
|
|
| 1188 | 1188 | $gd_page = 'home'; |
| 1189 | - $meta_desc = ( get_option( 'geodir_meta_desc_homepage' ) ) ? get_option( 'geodir_meta_desc_homepage' ) : $meta_desc; |
|
| 1190 | - } elseif ( geodir_is_page( 'detail' ) ) {
|
|
| 1189 | + $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
|
|
| 1190 | + } elseif (geodir_is_page('detail')) {
|
|
| 1191 | 1191 | $gd_page = 'detail'; |
| 1192 | - $meta_desc = ( get_option( 'geodir_meta_desc_detail' ) ) ? get_option( 'geodir_meta_desc_detail' ) : $meta_desc; |
|
| 1193 | - } elseif ( geodir_is_page( 'pt' ) ) {
|
|
| 1192 | + $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
|
|
| 1193 | + } elseif (geodir_is_page('pt')) {
|
|
| 1194 | 1194 | $gd_page = 'pt'; |
| 1195 | - $meta_desc = ( get_option( 'geodir_meta_desc_pt' ) ) ? get_option( 'geodir_meta_desc_pt' ) : $meta_desc; |
|
| 1196 | - } elseif ( geodir_is_page( 'listing' ) ) {
|
|
| 1195 | + $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
|
|
| 1196 | + } elseif (geodir_is_page('listing')) {
|
|
| 1197 | 1197 | $gd_page = 'listing'; |
| 1198 | - $meta_desc = ( get_option( 'geodir_meta_desc_listing' ) ) ? get_option( 'geodir_meta_desc_listing' ) : $meta_desc; |
|
| 1199 | - } elseif ( geodir_is_page( 'location' ) ) {
|
|
| 1198 | + $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
|
|
| 1199 | + } elseif (geodir_is_page('location')) {
|
|
| 1200 | 1200 | $gd_page = 'location'; |
| 1201 | - $meta_desc = ( get_option( 'geodir_meta_desc_location' ) ) ? get_option( 'geodir_meta_desc_location' ) : $meta_desc; |
|
| 1202 | - $meta_desc = apply_filters( 'geodir_seo_meta_location_description', $meta_desc ); |
|
| 1201 | + $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
|
|
| 1202 | + $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
|
|
| 1203 | 1203 | |
| 1204 | - } elseif ( geodir_is_page( 'search' ) ) {
|
|
| 1204 | + } elseif (geodir_is_page('search')) {
|
|
| 1205 | 1205 | $gd_page = 'search'; |
| 1206 | - $meta_desc = ( get_option( 'geodir_meta_desc_search' ) ) ? get_option( 'geodir_meta_desc_search' ) : $meta_desc; |
|
| 1207 | - } elseif ( geodir_is_page( 'add-listing' ) ) {
|
|
| 1206 | + $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
|
|
| 1207 | + } elseif (geodir_is_page('add-listing')) {
|
|
| 1208 | 1208 | $gd_page = 'add-listing'; |
| 1209 | - $meta_desc = ( get_option( 'geodir_meta_desc_add-listing' ) ) ? get_option( 'geodir_meta_desc_add-listing' ) : $meta_desc; |
|
| 1210 | - } elseif ( geodir_is_page( 'author' ) ) {
|
|
| 1209 | + $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
|
|
| 1210 | + } elseif (geodir_is_page('author')) {
|
|
| 1211 | 1211 | $gd_page = 'author'; |
| 1212 | - $meta_desc = ( get_option( 'geodir_meta_desc_author' ) ) ? get_option( 'geodir_meta_desc_author' ) : $meta_desc; |
|
| 1213 | - } elseif ( geodir_is_page( 'login' ) ) {
|
|
| 1212 | + $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
|
|
| 1213 | + } elseif (geodir_is_page('login')) {
|
|
| 1214 | 1214 | $gd_page = 'login'; |
| 1215 | - $meta_desc = ( get_option( 'geodir_meta_desc_login' ) ) ? get_option( 'geodir_meta_desc_login' ) : $meta_desc; |
|
| 1216 | - } elseif ( geodir_is_page( 'listing-success' ) ) {
|
|
| 1215 | + $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
|
|
| 1216 | + } elseif (geodir_is_page('listing-success')) {
|
|
| 1217 | 1217 | $gd_page = 'listing-success'; |
| 1218 | - $meta_desc = ( get_option( 'geodir_meta_desc_listing-success' ) ) ? get_option( 'geodir_meta_desc_listing-success' ) : $meta_desc; |
|
| 1218 | + $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
|
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | |
| 1222 | - if ( $meta_desc ) {
|
|
| 1223 | - $meta_desc = stripslashes_deep( $meta_desc ); |
|
| 1222 | + if ($meta_desc) {
|
|
| 1223 | + $meta_desc = stripslashes_deep($meta_desc); |
|
| 1224 | 1224 | /** |
| 1225 | 1225 | * Filter page description to replace variables. |
| 1226 | 1226 | * |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | * @param string $title The page description including variables. |
| 1230 | 1230 | * @param string $gd_page The GeoDirectory page type if any. |
| 1231 | 1231 | */ |
| 1232 | - $meta_desc = apply_filters( 'geodir_seo_meta_description_pre', __( $meta_desc, 'geodirectory' ), $gd_page, '' ); |
|
| 1232 | + $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, '');
|
|
| 1233 | 1233 | |
| 1234 | 1234 | /** |
| 1235 | 1235 | * Filter SEO meta description. |
@@ -1238,49 +1238,49 @@ discard block |
||
| 1238 | 1238 | * |
| 1239 | 1239 | * @param string $meta_desc Meta description content. |
| 1240 | 1240 | */ |
| 1241 | - echo apply_filters( 'geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc ); |
|
| 1241 | + echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="'.$meta_desc.'" />', $meta_desc);
|
|
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | // meta keywords |
| 1245 | - if ( isset( $post->post_type ) && in_array( $post->post_type, $all_postypes ) ) {
|
|
| 1246 | - $place_tags = wp_get_post_terms( $post->ID, $post->post_type . '_tags', array( "fields" => "names" ) ); |
|
| 1247 | - $place_cats = wp_get_post_terms( $post->ID, $post->post_type . 'category', array( "fields" => "names" ) ); |
|
| 1245 | + if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
|
|
| 1246 | + $place_tags = wp_get_post_terms($post->ID, $post->post_type.'_tags', array("fields" => "names"));
|
|
| 1247 | + $place_cats = wp_get_post_terms($post->ID, $post->post_type.'category', array("fields" => "names"));
|
|
| 1248 | 1248 | |
| 1249 | - $meta_key .= implode( ", ", array_merge( (array) $place_cats, (array) $place_tags ) ); |
|
| 1249 | + $meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags));
|
|
| 1250 | 1250 | } else {
|
| 1251 | 1251 | $posttags = get_the_tags(); |
| 1252 | - if ( $posttags ) {
|
|
| 1253 | - foreach ( $posttags as $tag ) {
|
|
| 1254 | - $meta_key .= $tag->name . ' '; |
|
| 1252 | + if ($posttags) {
|
|
| 1253 | + foreach ($posttags as $tag) {
|
|
| 1254 | + $meta_key .= $tag->name.' '; |
|
| 1255 | 1255 | } |
| 1256 | 1256 | } else {
|
| 1257 | - $tags = get_tags( array( 'orderby' => 'count', 'order' => 'DESC' ) ); |
|
| 1257 | + $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
|
|
| 1258 | 1258 | $xt = 1; |
| 1259 | 1259 | |
| 1260 | - foreach ( $tags as $tag ) {
|
|
| 1261 | - if ( $xt <= 20 ) {
|
|
| 1262 | - $meta_key .= $tag->name . ", "; |
|
| 1260 | + foreach ($tags as $tag) {
|
|
| 1261 | + if ($xt <= 20) {
|
|
| 1262 | + $meta_key .= $tag->name.", "; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | - $xt ++; |
|
| 1265 | + $xt++; |
|
| 1266 | 1266 | } |
| 1267 | 1267 | } |
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | - $meta_key = $meta_key != '' ? rtrim( trim( $meta_key ), "," ) : $meta_key; |
|
| 1271 | - $geodir_meta_keys = $geodir_meta_keys != '' ? ( $meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys ) : $meta_key; |
|
| 1272 | - if ( $geodir_meta_keys != '' ) {
|
|
| 1273 | - $geodir_meta_keys = strip_tags( $geodir_meta_keys ); |
|
| 1274 | - $geodir_meta_keys = esc_html( $geodir_meta_keys ); |
|
| 1275 | - $geodir_meta_keys = geodir_strtolower( $geodir_meta_keys ); |
|
| 1276 | - $geodir_meta_keys = wp_html_excerpt( $geodir_meta_keys, 1000, '' ); |
|
| 1277 | - $geodir_meta_keys = str_replace( '%location%', $replace_location, $geodir_meta_keys ); |
|
| 1270 | + $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key; |
|
| 1271 | + $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key.', '.$geodir_meta_keys : $geodir_meta_keys) : $meta_key; |
|
| 1272 | + if ($geodir_meta_keys != '') {
|
|
| 1273 | + $geodir_meta_keys = strip_tags($geodir_meta_keys); |
|
| 1274 | + $geodir_meta_keys = esc_html($geodir_meta_keys); |
|
| 1275 | + $geodir_meta_keys = geodir_strtolower($geodir_meta_keys); |
|
| 1276 | + $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, ''); |
|
| 1277 | + $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
|
|
| 1278 | 1278 | |
| 1279 | - $meta_key = rtrim( trim( $geodir_meta_keys ), "," ); |
|
| 1279 | + $meta_key = rtrim(trim($geodir_meta_keys), ","); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | - if ( $meta_key ) {
|
|
| 1283 | - $meta_key = stripslashes_deep( $meta_key ); |
|
| 1282 | + if ($meta_key) {
|
|
| 1283 | + $meta_key = stripslashes_deep($meta_key); |
|
| 1284 | 1284 | /** |
| 1285 | 1285 | * Filter SEO meta keywords. |
| 1286 | 1286 | * |
@@ -1288,7 +1288,7 @@ discard block |
||
| 1288 | 1288 | * |
| 1289 | 1289 | * @param string $meta_desc Meta keywords. |
| 1290 | 1290 | */ |
| 1291 | - echo apply_filters( 'geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key ); |
|
| 1291 | + echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="'.$meta_key.'" />', $meta_key);
|
|
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | 1294 | } |
@@ -1308,8 +1308,8 @@ discard block |
||
| 1308 | 1308 | |
| 1309 | 1309 | $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array(); |
| 1310 | 1310 | |
| 1311 | - foreach ( $geodir_detail_page_tabs_array as $key => $tabs_obj ) {
|
|
| 1312 | - $geodir_detail_page_tabs_key_value_array[ $key ] = $tabs_obj['heading_text']; |
|
| 1311 | + foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
|
|
| 1312 | + $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text']; |
|
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | return $geodir_detail_page_tabs_key_value_array; |
@@ -1331,57 +1331,57 @@ discard block |
||
| 1331 | 1331 | * @since 1.0.0 |
| 1332 | 1332 | */ |
| 1333 | 1333 | $arr_tabs['post_profile'] = array( |
| 1334 | - 'heading_text' => __( 'Profile', 'geodirectory' ), |
|
| 1334 | + 'heading_text' => __('Profile', 'geodirectory'),
|
|
| 1335 | 1335 | 'is_active_tab' => true, |
| 1336 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_profile' ), |
|
| 1336 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
|
|
| 1337 | 1337 | 'tab_content' => '' |
| 1338 | 1338 | ); |
| 1339 | - $arr_tabs['post_info'] = array( |
|
| 1340 | - 'heading_text' => __( 'More Info', 'geodirectory' ), |
|
| 1339 | + $arr_tabs['post_info'] = array( |
|
| 1340 | + 'heading_text' => __('More Info', 'geodirectory'),
|
|
| 1341 | 1341 | 'is_active_tab' => false, |
| 1342 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_info' ), |
|
| 1342 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
|
|
| 1343 | 1343 | 'tab_content' => '' |
| 1344 | 1344 | ); |
| 1345 | 1345 | |
| 1346 | 1346 | $arr_tabs['post_images'] = array( |
| 1347 | - 'heading_text' => __( 'Photos', 'geodirectory' ), |
|
| 1347 | + 'heading_text' => __('Photos', 'geodirectory'),
|
|
| 1348 | 1348 | 'is_active_tab' => false, |
| 1349 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_images' ), |
|
| 1349 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
|
|
| 1350 | 1350 | 'tab_content' => '' |
| 1351 | 1351 | ); |
| 1352 | 1352 | |
| 1353 | 1353 | $arr_tabs['post_video'] = array( |
| 1354 | - 'heading_text' => __( 'Video', 'geodirectory' ), |
|
| 1354 | + 'heading_text' => __('Video', 'geodirectory'),
|
|
| 1355 | 1355 | 'is_active_tab' => false, |
| 1356 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_video' ), |
|
| 1356 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
|
|
| 1357 | 1357 | 'tab_content' => '' |
| 1358 | 1358 | ); |
| 1359 | 1359 | |
| 1360 | 1360 | $arr_tabs['special_offers'] = array( |
| 1361 | - 'heading_text' => __( 'Special Offers', 'geodirectory' ), |
|
| 1361 | + 'heading_text' => __('Special Offers', 'geodirectory'),
|
|
| 1362 | 1362 | 'is_active_tab' => false, |
| 1363 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'special_offers' ), |
|
| 1363 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
|
|
| 1364 | 1364 | 'tab_content' => '' |
| 1365 | 1365 | ); |
| 1366 | 1366 | |
| 1367 | 1367 | $arr_tabs['post_map'] = array( |
| 1368 | - 'heading_text' => __( 'Map', 'geodirectory' ), |
|
| 1368 | + 'heading_text' => __('Map', 'geodirectory'),
|
|
| 1369 | 1369 | 'is_active_tab' => false, |
| 1370 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'post_map' ), |
|
| 1370 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
|
|
| 1371 | 1371 | 'tab_content' => '' |
| 1372 | 1372 | ); |
| 1373 | 1373 | |
| 1374 | 1374 | $arr_tabs['reviews'] = array( |
| 1375 | - 'heading_text' => __( 'Reviews', 'geodirectory' ), |
|
| 1375 | + 'heading_text' => __('Reviews', 'geodirectory'),
|
|
| 1376 | 1376 | 'is_active_tab' => false, |
| 1377 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'reviews' ), |
|
| 1377 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
|
|
| 1378 | 1378 | 'tab_content' => 'review display' |
| 1379 | 1379 | ); |
| 1380 | 1380 | |
| 1381 | 1381 | $arr_tabs['related_listing'] = array( |
| 1382 | - 'heading_text' => __( 'Related Listing', 'geodirectory' ), |
|
| 1382 | + 'heading_text' => __('Related Listing', 'geodirectory'),
|
|
| 1383 | 1383 | 'is_active_tab' => false, |
| 1384 | - 'is_display' => apply_filters( 'geodir_detail_page_tab_is_display', true, 'related_listing' ), |
|
| 1384 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
|
|
| 1385 | 1385 | 'tab_content' => '' |
| 1386 | 1386 | ); |
| 1387 | 1387 | |
@@ -1390,7 +1390,7 @@ discard block |
||
| 1390 | 1390 | * |
| 1391 | 1391 | * @since 1.0.0 |
| 1392 | 1392 | */ |
| 1393 | - return apply_filters( 'geodir_detail_page_tab_list_extend', $arr_tabs ); |
|
| 1393 | + return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
|
|
| 1394 | 1394 | |
| 1395 | 1395 | |
| 1396 | 1396 | } |
@@ -1404,13 +1404,13 @@ discard block |
||
| 1404 | 1404 | * @return mixed|array Tabs array. |
| 1405 | 1405 | */ |
| 1406 | 1406 | function geodir_detail_page_tabs_list() {
|
| 1407 | - $tabs_excluded = get_option( 'geodir_detail_page_tabs_excluded' ); |
|
| 1407 | + $tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
|
|
| 1408 | 1408 | $tabs_array = geodir_detail_page_tabs_array(); |
| 1409 | 1409 | |
| 1410 | - if ( ! empty( $tabs_excluded ) ) {
|
|
| 1411 | - foreach ( $tabs_excluded as $tab ) {
|
|
| 1412 | - if ( array_key_exists( $tab, $tabs_array ) ) {
|
|
| 1413 | - unset( $tabs_array[ $tab ] ); |
|
| 1410 | + if (!empty($tabs_excluded)) {
|
|
| 1411 | + foreach ($tabs_excluded as $tab) {
|
|
| 1412 | + if (array_key_exists($tab, $tabs_array)) {
|
|
| 1413 | + unset($tabs_array[$tab]); |
|
| 1414 | 1414 | } |
| 1415 | 1415 | } |
| 1416 | 1416 | } |
@@ -1434,58 +1434,58 @@ discard block |
||
| 1434 | 1434 | function geodir_show_detail_page_tabs() {
|
| 1435 | 1435 | global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields, $preview; |
| 1436 | 1436 | |
| 1437 | - $post_id = ! empty( $post ) && isset( $post->ID ) ? (int) $post->ID : 0; |
|
| 1438 | - $request_post_id = ! empty( $_REQUEST['p'] ) ? (int) $_REQUEST['p'] : 0; |
|
| 1439 | - $is_backend_preview = ( is_single() && ! empty( $_REQUEST['post_type'] ) && ! empty( $_REQUEST['preview'] ) && ! empty( $_REQUEST['p'] ) ) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 1437 | + $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0; |
|
| 1438 | + $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; |
|
| 1439 | + $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 1440 | 1440 | |
| 1441 | - if ( $is_backend_preview && ! $post_id > 0 && $request_post_id > 0 ) {
|
|
| 1442 | - $post = geodir_get_post_info( $request_post_id ); |
|
| 1443 | - setup_postdata( $post ); |
|
| 1441 | + if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
|
|
| 1442 | + $post = geodir_get_post_info($request_post_id); |
|
| 1443 | + setup_postdata($post); |
|
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | - $geodir_post_detail_fields = geodir_show_listing_info( 'moreinfo' ); |
|
| 1446 | + $geodir_post_detail_fields = geodir_show_listing_info('moreinfo');
|
|
| 1447 | 1447 | |
| 1448 | 1448 | |
| 1449 | - if ( geodir_is_page( 'detail' ) ) {
|
|
| 1450 | - $video = geodir_get_video( $post->ID ); |
|
| 1451 | - $special_offers = geodir_get_special_offers( $post->ID ); |
|
| 1449 | + if (geodir_is_page('detail')) {
|
|
| 1450 | + $video = geodir_get_video($post->ID); |
|
| 1451 | + $special_offers = geodir_get_special_offers($post->ID); |
|
| 1452 | 1452 | $related_listing_array = array(); |
| 1453 | - if ( get_option( 'geodir_add_related_listing_posttypes' ) ) {
|
|
| 1454 | - $related_listing_array = get_option( 'geodir_add_related_listing_posttypes' ); |
|
| 1453 | + if (get_option('geodir_add_related_listing_posttypes')) {
|
|
| 1454 | + $related_listing_array = get_option('geodir_add_related_listing_posttypes');
|
|
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | |
| 1458 | - $excluded_tabs = get_option( 'geodir_detail_page_tabs_excluded' ); |
|
| 1459 | - if ( ! $excluded_tabs ) {
|
|
| 1458 | + $excluded_tabs = get_option('geodir_detail_page_tabs_excluded');
|
|
| 1459 | + if (!$excluded_tabs) {
|
|
| 1460 | 1460 | $excluded_tabs = array(); |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | 1463 | $related_listing = ''; |
| 1464 | - if ( in_array( $post->post_type, $related_listing_array ) && ! in_array( 'related_listing', $excluded_tabs ) ) {
|
|
| 1464 | + if (in_array($post->post_type, $related_listing_array) && !in_array('related_listing', $excluded_tabs)) {
|
|
| 1465 | 1465 | $request = array( |
| 1466 | - 'post_number' => get_option( 'geodir_related_post_count' ), |
|
| 1467 | - 'relate_to' => get_option( 'geodir_related_post_relate_to' ), |
|
| 1468 | - 'layout' => get_option( 'geodir_related_post_listing_view' ), |
|
| 1469 | - 'add_location_filter' => get_option( 'geodir_related_post_location_filter' ), |
|
| 1470 | - 'list_sort' => get_option( 'geodir_related_post_sortby' ), |
|
| 1471 | - 'character_count' => get_option( 'geodir_related_post_excerpt' ) |
|
| 1466 | + 'post_number' => get_option('geodir_related_post_count'),
|
|
| 1467 | + 'relate_to' => get_option('geodir_related_post_relate_to'),
|
|
| 1468 | + 'layout' => get_option('geodir_related_post_listing_view'),
|
|
| 1469 | + 'add_location_filter' => get_option('geodir_related_post_location_filter'),
|
|
| 1470 | + 'list_sort' => get_option('geodir_related_post_sortby'),
|
|
| 1471 | + 'character_count' => get_option('geodir_related_post_excerpt')
|
|
| 1472 | 1472 | ); |
| 1473 | 1473 | |
| 1474 | - if ( $post->post_type == 'gd_event' && defined( 'GDEVENTS_VERSION' ) ) {
|
|
| 1475 | - $related_listing = geodir_get_detail_page_related_events( $request ); |
|
| 1474 | + if ($post->post_type == 'gd_event' && defined('GDEVENTS_VERSION')) {
|
|
| 1475 | + $related_listing = geodir_get_detail_page_related_events($request); |
|
| 1476 | 1476 | } else {
|
| 1477 | - $related_listing = geodir_related_posts_display( $request ); |
|
| 1477 | + $related_listing = geodir_related_posts_display($request); |
|
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | - $post_images = geodir_get_images( $post->ID, 'thumbnail' ); |
|
| 1482 | + $post_images = geodir_get_images($post->ID, 'thumbnail'); |
|
| 1483 | 1483 | $thumb_image = ''; |
| 1484 | - if ( ! empty( $post_images ) ) {
|
|
| 1485 | - foreach ( $post_images as $image ) {
|
|
| 1486 | - $caption = ( ! empty( $image->caption ) ) ? $image->caption : ''; |
|
| 1487 | - $thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">'; |
|
| 1488 | - $thumb_image .= geodir_show_image( $image, 'thumbnail', true, false ); |
|
| 1484 | + if (!empty($post_images)) {
|
|
| 1485 | + foreach ($post_images as $image) {
|
|
| 1486 | + $caption = (!empty($image->caption)) ? $image->caption : ''; |
|
| 1487 | + $thumb_image .= '<a href="'.$image->src.'" title="'.$caption.'">'; |
|
| 1488 | + $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); |
|
| 1489 | 1489 | $thumb_image .= '</a>'; |
| 1490 | 1490 | } |
| 1491 | 1491 | } |
@@ -1494,11 +1494,11 @@ discard block |
||
| 1494 | 1494 | $map_args['map_canvas_name'] = 'detail_page_map_canvas'; |
| 1495 | 1495 | $map_args['width'] = '600'; |
| 1496 | 1496 | $map_args['height'] = '300'; |
| 1497 | - if ( $post->post_mapzoom ) {
|
|
| 1498 | - $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
| 1497 | + if ($post->post_mapzoom) {
|
|
| 1498 | + $map_args['zoom'] = ''.$post->post_mapzoom.''; |
|
| 1499 | 1499 | } |
| 1500 | 1500 | $map_args['autozoom'] = false; |
| 1501 | - $map_args['scrollwheel'] = ( get_option( 'geodir_add_listing_mouse_scroll' ) ) ? 0 : 1; |
|
| 1501 | + $map_args['scrollwheel'] = (get_option('geodir_add_listing_mouse_scroll')) ? 0 : 1;
|
|
| 1502 | 1502 | $map_args['child_collapse'] = '0'; |
| 1503 | 1503 | $map_args['enable_cat_filters'] = false; |
| 1504 | 1504 | $map_args['enable_text_search'] = false; |
@@ -1507,43 +1507,43 @@ discard block |
||
| 1507 | 1507 | $map_args['enable_jason_on_load'] = true; |
| 1508 | 1508 | $map_args['enable_map_direction'] = true; |
| 1509 | 1509 | $map_args['map_class_name'] = 'geodir-map-detail-page'; |
| 1510 | - $map_args['maptype'] = ( ! empty( $post->post_mapview ) ) ? $post->post_mapview : 'ROADMAP'; |
|
| 1511 | - } else if ( geodir_is_page( 'preview' ) ) {
|
|
| 1512 | - $video = isset( $post->geodir_video ) ? $post->geodir_video : ''; |
|
| 1513 | - $special_offers = isset( $post->geodir_special_offers ) ? $post->geodir_special_offers : ''; |
|
| 1510 | + $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; |
|
| 1511 | + } else if (geodir_is_page('preview')) {
|
|
| 1512 | + $video = isset($post->geodir_video) ? $post->geodir_video : ''; |
|
| 1513 | + $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; |
|
| 1514 | 1514 | |
| 1515 | - if ( isset( $post->post_images ) ) {
|
|
| 1516 | - $post->post_images = trim( $post->post_images, "," ); |
|
| 1515 | + if (isset($post->post_images)) {
|
|
| 1516 | + $post->post_images = trim($post->post_images, ","); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | - if ( isset( $post->post_images ) && ! empty( $post->post_images ) ) {
|
|
| 1520 | - $post_images = explode( ",", $post->post_images ); |
|
| 1519 | + if (isset($post->post_images) && !empty($post->post_images)) {
|
|
| 1520 | + $post_images = explode(",", $post->post_images);
|
|
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | 1523 | $thumb_image = ''; |
| 1524 | - if ( ! empty( $post_images ) ) {
|
|
| 1525 | - foreach ( $post_images as $image ) {
|
|
| 1526 | - if ( $image != '' ) {
|
|
| 1527 | - $thumb_image .= '<a href="' . $image . '">'; |
|
| 1528 | - $thumb_image .= geodir_show_image( array( 'src' => $image ), 'thumbnail', true, false ); |
|
| 1524 | + if (!empty($post_images)) {
|
|
| 1525 | + foreach ($post_images as $image) {
|
|
| 1526 | + if ($image != '') {
|
|
| 1527 | + $thumb_image .= '<a href="'.$image.'">'; |
|
| 1528 | + $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
|
|
| 1529 | 1529 | $thumb_image .= '</a>'; |
| 1530 | 1530 | } |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | 1534 | global $map_jason; |
| 1535 | - $marker_json = $post->marker_json != '' ? json_decode( $post->marker_json, true ) : array(); |
|
| 1536 | - $marker_icon = ( ! empty( $marker_json ) && ! empty( $marker_json['i'] ) ) ? $marker_json['i'] : ''; |
|
| 1537 | - $icon_size = geodir_get_marker_size( $marker_icon ); |
|
| 1535 | + $marker_json = $post->marker_json != '' ? json_decode($post->marker_json, true) : array(); |
|
| 1536 | + $marker_icon = (!empty($marker_json) && !empty($marker_json['i'])) ? $marker_json['i'] : ''; |
|
| 1537 | + $icon_size = geodir_get_marker_size($marker_icon); |
|
| 1538 | 1538 | $marker_json['w'] = $icon_size['w']; |
| 1539 | 1539 | $marker_json['h'] = $icon_size['h']; |
| 1540 | - $map_jason[] = json_encode( $marker_json ); |
|
| 1540 | + $map_jason[] = json_encode($marker_json); |
|
| 1541 | 1541 | |
| 1542 | - $address_latitude = isset( $post->post_latitude ) ? $post->post_latitude : ''; |
|
| 1543 | - $address_longitude = isset( $post->post_longitude ) ? $post->post_longitude : ''; |
|
| 1544 | - $mapview = isset( $post->post_mapview ) ? $post->post_mapview : ''; |
|
| 1545 | - $mapzoom = isset( $post->post_mapzoom ) ? $post->post_mapzoom : ''; |
|
| 1546 | - if ( ! $mapzoom ) {
|
|
| 1542 | + $address_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; |
|
| 1543 | + $address_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; |
|
| 1544 | + $mapview = isset($post->post_mapview) ? $post->post_mapview : ''; |
|
| 1545 | + $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : ''; |
|
| 1546 | + if (!$mapzoom) {
|
|
| 1547 | 1547 | $mapzoom = 12; |
| 1548 | 1548 | } |
| 1549 | 1549 | |
@@ -1566,37 +1566,37 @@ discard block |
||
| 1566 | 1566 | $map_args['map_class_name'] = 'geodir-map-preview-page'; |
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | - $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user |
|
| 1569 | + $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user |
|
| 1570 | 1570 | |
| 1571 | 1571 | $active_tab = ''; |
| 1572 | 1572 | $active_tab_name = ''; |
| 1573 | 1573 | $default_tab = ''; |
| 1574 | 1574 | $default_tab_name = ''; |
| 1575 | - foreach ( $arr_detail_page_tabs as $tab_index => $tabs ) {
|
|
| 1576 | - if ( isset( $tabs['is_active_tab'] ) && $tabs['is_active_tab'] && ! empty( $tabs['is_display'] ) && isset( $tabs['heading_text'] ) && $tabs['heading_text'] ) {
|
|
| 1575 | + foreach ($arr_detail_page_tabs as $tab_index => $tabs) {
|
|
| 1576 | + if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
|
|
| 1577 | 1577 | $active_tab = $tab_index; |
| 1578 | - $active_tab_name = __( $tabs['heading_text'], 'geodirectory' ); |
|
| 1578 | + $active_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | - if ( $default_tab === '' && ! empty( $tabs['is_display'] ) && ! empty( $tabs['heading_text'] ) ) {
|
|
| 1581 | + if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
|
|
| 1582 | 1582 | $default_tab = $tab_index; |
| 1583 | - $default_tab_name = __( $tabs['heading_text'], 'geodirectory' ); |
|
| 1583 | + $default_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1584 | 1584 | } |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | - if ( $active_tab === '' && $default_tab !== '' ) { // Make first tab acs a active tab if not any tab is active.
|
|
| 1588 | - if ( isset( $arr_detail_page_tabs[ $active_tab ] ) && isset( $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] ) ) {
|
|
| 1589 | - $arr_detail_page_tabs[ $active_tab ]['is_active_tab'] = false; |
|
| 1587 | + if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
|
|
| 1588 | + if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
|
|
| 1589 | + $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false; |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | - $arr_detail_page_tabs[ $default_tab ]['is_active_tab'] = true; |
|
| 1592 | + $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true; |
|
| 1593 | 1593 | $active_tab = $default_tab; |
| 1594 | 1594 | $active_tab_name = $default_tab_name; |
| 1595 | 1595 | } |
| 1596 | - $tab_list = ( get_option( 'geodir_disable_tabs', false ) ) ? true : false; |
|
| 1596 | + $tab_list = (get_option('geodir_disable_tabs', false)) ? true : false;
|
|
| 1597 | 1597 | ?> |
| 1598 | 1598 | <div class="geodir-tabs" id="gd-tabs" style="position:relative;"> |
| 1599 | - <?php if ( ! $tab_list ){ ?>
|
|
| 1599 | + <?php if (!$tab_list) { ?>
|
|
| 1600 | 1600 | <div id="geodir-tab-mobile-menu"> |
| 1601 | 1601 | <i class="fa fa-bars"></i> |
| 1602 | 1602 | <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?></span> |
@@ -1611,26 +1611,26 @@ discard block |
||
| 1611 | 1611 | * @since 1.0.0 |
| 1612 | 1612 | * @see 'geodir_after_tab_list' |
| 1613 | 1613 | */ |
| 1614 | - do_action( 'geodir_before_tab_list' ); ?> |
|
| 1614 | + do_action('geodir_before_tab_list'); ?>
|
|
| 1615 | 1615 | <?php |
| 1616 | 1616 | |
| 1617 | - foreach ( $arr_detail_page_tabs as $tab_index => $detail_page_tab ) {
|
|
| 1618 | - if ( $detail_page_tab['is_display'] ) {
|
|
| 1617 | + foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
|
|
| 1618 | + if ($detail_page_tab['is_display']) {
|
|
| 1619 | 1619 | |
| 1620 | - if ( ! $tab_list ) {
|
|
| 1620 | + if (!$tab_list) {
|
|
| 1621 | 1621 | ?> |
| 1622 | 1622 | <dt></dt> <!-- added to comply with validation --> |
| 1623 | - <dd <?php if ( $detail_page_tab['is_active_tab'] ){ ?>class="geodir-tab-active"<?php } ?> ><a
|
|
| 1623 | + <dd <?php if ($detail_page_tab['is_active_tab']) { ?>class="geodir-tab-active"<?php } ?> ><a
|
|
| 1624 | 1624 | data-tab="#<?php echo $tab_index; ?>" |
| 1625 | - data-status="enable"><?php _e( $detail_page_tab['heading_text'], 'geodirectory' ); ?></a> |
|
| 1625 | + data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a> |
|
| 1626 | 1626 | </dd> |
| 1627 | 1627 | <?php |
| 1628 | 1628 | } |
| 1629 | 1629 | ob_start() // start tab content buffering |
| 1630 | 1630 | ?> |
| 1631 | 1631 | <li id="<?php echo $tab_index; ?>Tab"> |
| 1632 | - <?php if ( $tab_list ) {
|
|
| 1633 | - $tab_title = '<span class="gd-tab-list-title" ><a href="#' . $tab_index . '">' . __( $detail_page_tab['heading_text'], 'geodirectory' ) . '</a></span><hr />'; |
|
| 1632 | + <?php if ($tab_list) {
|
|
| 1633 | + $tab_title = '<span class="gd-tab-list-title" ><a href="#'.$tab_index.'">'.__($detail_page_tab['heading_text'], 'geodirectory').'</a></span><hr />'; |
|
| 1634 | 1634 | /** |
| 1635 | 1635 | * Filter the tab list title html. |
| 1636 | 1636 | * |
@@ -1640,7 +1640,7 @@ discard block |
||
| 1640 | 1640 | * @param string $tab_index The tab index type. |
| 1641 | 1641 | * @param array $detail_page_tab The array of values including title text. |
| 1642 | 1642 | */ |
| 1643 | - echo apply_filters( 'geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab ); |
|
| 1643 | + echo apply_filters('geodir_tab_list_title', $tab_title, $tab_index, $detail_page_tab);
|
|
| 1644 | 1644 | } ?> |
| 1645 | 1645 | <div id="<?php echo $tab_index; ?>" class="hash-offset"></div> |
| 1646 | 1646 | <?php |
@@ -1651,7 +1651,7 @@ discard block |
||
| 1651 | 1651 | * |
| 1652 | 1652 | * @param string $tab_index The tab name ID. |
| 1653 | 1653 | */ |
| 1654 | - do_action( 'geodir_before_tab_content', $tab_index ); |
|
| 1654 | + do_action('geodir_before_tab_content', $tab_index);
|
|
| 1655 | 1655 | |
| 1656 | 1656 | /** |
| 1657 | 1657 | * Called before the details tab content is output per tab. |
@@ -1661,21 +1661,21 @@ discard block |
||
| 1661 | 1661 | * @since 1.0.0 |
| 1662 | 1662 | * @todo do we need this if we have the hook above? 'geodir_before_tab_content' |
| 1663 | 1663 | */ |
| 1664 | - do_action( 'geodir_before_' . $tab_index . '_tab_content' ); |
|
| 1664 | + do_action('geodir_before_'.$tab_index.'_tab_content');
|
|
| 1665 | 1665 | /// write a code to generate content of each tab |
| 1666 | - switch ( $tab_index ) {
|
|
| 1666 | + switch ($tab_index) {
|
|
| 1667 | 1667 | case 'post_profile': |
| 1668 | 1668 | /** |
| 1669 | 1669 | * Called before the listing description content on the details page tab. |
| 1670 | 1670 | * |
| 1671 | 1671 | * @since 1.0.0 |
| 1672 | 1672 | */ |
| 1673 | - do_action( 'geodir_before_description_on_listing_detail' ); |
|
| 1674 | - if ( geodir_is_page( 'detail' ) ) {
|
|
| 1673 | + do_action('geodir_before_description_on_listing_detail');
|
|
| 1674 | + if (geodir_is_page('detail')) {
|
|
| 1675 | 1675 | the_content(); |
| 1676 | 1676 | } else {
|
| 1677 | 1677 | /** This action is documented in geodirectory_template_actions.php */ |
| 1678 | - echo apply_filters( 'the_content', stripslashes( $post->post_desc ) ); |
|
| 1678 | + echo apply_filters('the_content', stripslashes($post->post_desc));
|
|
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | 1681 | /** |
@@ -1683,7 +1683,7 @@ discard block |
||
| 1683 | 1683 | * |
| 1684 | 1684 | * @since 1.0.0 |
| 1685 | 1685 | */ |
| 1686 | - do_action( 'geodir_after_description_on_listing_detail' ); |
|
| 1686 | + do_action('geodir_after_description_on_listing_detail');
|
|
| 1687 | 1687 | break; |
| 1688 | 1688 | case 'post_info': |
| 1689 | 1689 | echo $geodir_post_detail_fields; |
@@ -1693,32 +1693,32 @@ discard block |
||
| 1693 | 1693 | break; |
| 1694 | 1694 | case 'post_video': |
| 1695 | 1695 | // some browsers hide $_POST data if used for embeds so we repalce with a placeholder |
| 1696 | - if ( $preview ) {
|
|
| 1697 | - if ( $video ) {
|
|
| 1698 | - echo "<span class='gd-video-embed-preview' ><p class='gd-video-preview-text'><i class=\"fa fa-video-camera\" aria-hidden=\"true\"></i><br />" . __( 'Video Preview Placeholder', 'geodirectory' ) . "</p></span>"; |
|
| 1696 | + if ($preview) {
|
|
| 1697 | + if ($video) {
|
|
| 1698 | + echo "<span class='gd-video-embed-preview' ><p class='gd-video-preview-text'><i class=\"fa fa-video-camera\" aria-hidden=\"true\"></i><br />".__('Video Preview Placeholder', 'geodirectory')."</p></span>";
|
|
| 1699 | 1699 | } |
| 1700 | 1700 | } else {
|
| 1701 | 1701 | |
| 1702 | 1702 | // stop payment manager filtering content length |
| 1703 | - $filter_priority = has_filter( 'the_content', 'geodir_payments_the_content' ); |
|
| 1704 | - if ( false !== $filter_priority ) {
|
|
| 1705 | - remove_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1703 | + $filter_priority = has_filter('the_content', 'geodir_payments_the_content');
|
|
| 1704 | + if (false !== $filter_priority) {
|
|
| 1705 | + remove_filter('the_content', 'geodir_payments_the_content', $filter_priority);
|
|
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | 1708 | /** This action is documented in geodirectory_template_actions.php */ |
| 1709 | - echo apply_filters( 'the_content', stripslashes( $video ) );// we apply the_content filter so oembed works also; |
|
| 1709 | + echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also;
|
|
| 1710 | 1710 | |
| 1711 | - if ( false !== $filter_priority ) {
|
|
| 1712 | - add_filter( 'the_content', 'geodir_payments_the_content', $filter_priority ); |
|
| 1711 | + if (false !== $filter_priority) {
|
|
| 1712 | + add_filter('the_content', 'geodir_payments_the_content', $filter_priority);
|
|
| 1713 | 1713 | } |
| 1714 | 1714 | } |
| 1715 | 1715 | break; |
| 1716 | 1716 | case 'special_offers': |
| 1717 | - echo apply_filters( 'gd_special_offers_content', wpautop( stripslashes( $special_offers ) ) ); |
|
| 1717 | + echo apply_filters('gd_special_offers_content', wpautop(stripslashes($special_offers)));
|
|
| 1718 | 1718 | |
| 1719 | 1719 | break; |
| 1720 | 1720 | case 'post_map': |
| 1721 | - geodir_draw_map( $map_args ); |
|
| 1721 | + geodir_draw_map($map_args); |
|
| 1722 | 1722 | break; |
| 1723 | 1723 | case 'reviews': |
| 1724 | 1724 | comments_template(); |
@@ -1727,7 +1727,7 @@ discard block |
||
| 1727 | 1727 | echo $related_listing; |
| 1728 | 1728 | break; |
| 1729 | 1729 | default: {
|
| 1730 | - if ( ( isset( $post->{$tab_index} ) || ( ! isset( $post->{$tab_index} ) && ( strpos( $tab_index, 'gd_tab_' ) !== false || $tab_index == 'link_business' ) ) ) && ! empty( $detail_page_tab['tab_content'] ) ) {
|
|
| 1730 | + if ((isset($post->{$tab_index} ) || (!isset($post->{$tab_index} ) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
|
|
| 1731 | 1731 | echo $detail_page_tab['tab_content']; |
| 1732 | 1732 | } |
| 1733 | 1733 | } |
@@ -1739,7 +1739,7 @@ discard block |
||
| 1739 | 1739 | * |
| 1740 | 1740 | * @since 1.0.0 |
| 1741 | 1741 | */ |
| 1742 | - do_action( 'geodir_after_tab_content', $tab_index ); |
|
| 1742 | + do_action('geodir_after_tab_content', $tab_index);
|
|
| 1743 | 1743 | |
| 1744 | 1744 | /** |
| 1745 | 1745 | * Called after the details tab content is output per tab. |
@@ -1749,7 +1749,7 @@ discard block |
||
| 1749 | 1749 | * @since 1.0.0 |
| 1750 | 1750 | * @todo do we need this if we have the hook above? 'geodir_after_tab_content' |
| 1751 | 1751 | */ |
| 1752 | - do_action( 'geodir_after_' . $tab_index . '_tab_content' ); |
|
| 1752 | + do_action('geodir_after_'.$tab_index.'_tab_content');
|
|
| 1753 | 1753 | ?> </li> |
| 1754 | 1754 | <?php |
| 1755 | 1755 | /** |
@@ -1757,7 +1757,7 @@ discard block |
||
| 1757 | 1757 | * |
| 1758 | 1758 | * @since 1.0.0 |
| 1759 | 1759 | */ |
| 1760 | - $arr_detail_page_tabs[ $tab_index ]['tab_content'] = apply_filters( "geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean() ); |
|
| 1760 | + $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_".$detail_page_tab['tab_content']."_tab_content", ob_get_clean());
|
|
| 1761 | 1761 | } // end of if for is_display |
| 1762 | 1762 | }// end of foreach |
| 1763 | 1763 | |
@@ -1767,14 +1767,14 @@ discard block |
||
| 1767 | 1767 | * @since 1.0.0 |
| 1768 | 1768 | * @see 'geodir_before_tab_list' |
| 1769 | 1769 | */ |
| 1770 | - do_action( 'geodir_after_tab_list' ); |
|
| 1770 | + do_action('geodir_after_tab_list');
|
|
| 1771 | 1771 | ?> |
| 1772 | - <?php if ( ! $tab_list ){ ?></dl><?php } ?>
|
|
| 1773 | - <ul class="geodir-tabs-content entry-content <?php if ( $tab_list ) { ?>geodir-tabs-list<?php } ?>"
|
|
| 1772 | + <?php if (!$tab_list) { ?></dl><?php } ?>
|
|
| 1773 | + <ul class="geodir-tabs-content entry-content <?php if ($tab_list) { ?>geodir-tabs-list<?php } ?>"
|
|
| 1774 | 1774 | style="position:relative;"> |
| 1775 | 1775 | <?php |
| 1776 | - foreach ( $arr_detail_page_tabs as $detail_page_tab ) {
|
|
| 1777 | - if ( $detail_page_tab['is_display'] && ! empty( $detail_page_tab['tab_content'] ) ) {
|
|
| 1776 | + foreach ($arr_detail_page_tabs as $detail_page_tab) {
|
|
| 1777 | + if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
|
|
| 1778 | 1778 | echo $detail_page_tab['tab_content']; |
| 1779 | 1779 | }// end of if |
| 1780 | 1780 | }// end of foreach |
@@ -1784,11 +1784,11 @@ discard block |
||
| 1784 | 1784 | * |
| 1785 | 1785 | * @since 1.0.0 |
| 1786 | 1786 | */ |
| 1787 | - do_action( 'geodir_add_tab_content' ); ?> |
|
| 1787 | + do_action('geodir_add_tab_content'); ?>
|
|
| 1788 | 1788 | </ul> |
| 1789 | 1789 | <!--gd-tabs-content ul end--> |
| 1790 | 1790 | </div> |
| 1791 | - <?php if ( ! $tab_list ) { ?>
|
|
| 1791 | + <?php if (!$tab_list) { ?>
|
|
| 1792 | 1792 | <script> |
| 1793 | 1793 | if (window.location.hash && window.location.hash.indexOf('&') === -1 && jQuery(window.location.hash + 'Tab').length) {
|
| 1794 | 1794 | hashVal = window.location.hash; |
@@ -1820,31 +1820,31 @@ discard block |
||
| 1820 | 1820 | * |
| 1821 | 1821 | * @return mixed Image file. |
| 1822 | 1822 | */ |
| 1823 | -function geodir_exif( $file ) {
|
|
| 1824 | - if ( empty( $file ) || ! is_array( $file ) ) {
|
|
| 1823 | +function geodir_exif($file) {
|
|
| 1824 | + if (empty($file) || !is_array($file)) {
|
|
| 1825 | 1825 | return $file; |
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | - $file_path = ! empty( $file['tmp_name'] ) ? sanitize_text_field( $file['tmp_name'] ) : ''; |
|
| 1829 | - if ( ! ( $file_path && file_exists( $file_path ) ) ) {
|
|
| 1828 | + $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : ''; |
|
| 1829 | + if (!($file_path && file_exists($file_path))) {
|
|
| 1830 | 1830 | return $file; |
| 1831 | 1831 | } |
| 1832 | 1832 | $file['file'] = $file_path; |
| 1833 | 1833 | |
| 1834 | - if ( ! file_is_valid_image( $file_path ) ) {
|
|
| 1834 | + if (!file_is_valid_image($file_path)) {
|
|
| 1835 | 1835 | return $file; // Bail if file is not an image. |
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | - if ( ! function_exists( 'wp_get_image_editor' ) ) {
|
|
| 1838 | + if (!function_exists('wp_get_image_editor')) {
|
|
| 1839 | 1839 | return $file; |
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | 1842 | $mime_type = $file['type']; |
| 1843 | 1843 | $exif = array(); |
| 1844 | - if ( $mime_type == 'image/jpeg' && function_exists( 'exif_read_data' ) ) {
|
|
| 1844 | + if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
|
|
| 1845 | 1845 | try {
|
| 1846 | - $exif = exif_read_data( $file_path ); |
|
| 1847 | - } catch ( Exception $e ) {
|
|
| 1846 | + $exif = exif_read_data($file_path); |
|
| 1847 | + } catch (Exception $e) {
|
|
| 1848 | 1848 | $exif = array(); |
| 1849 | 1849 | } |
| 1850 | 1850 | } |
@@ -1853,13 +1853,13 @@ discard block |
||
| 1853 | 1853 | $flip = false; |
| 1854 | 1854 | $modify = false; |
| 1855 | 1855 | $orientation = 0; |
| 1856 | - if ( ! empty( $exif ) && isset( $exif['Orientation'] ) ) {
|
|
| 1857 | - switch ( (int) $exif['Orientation'] ) {
|
|
| 1856 | + if (!empty($exif) && isset($exif['Orientation'])) {
|
|
| 1857 | + switch ((int) $exif['Orientation']) {
|
|
| 1858 | 1858 | case 1: |
| 1859 | 1859 | // do nothing |
| 1860 | 1860 | break; |
| 1861 | 1861 | case 2: |
| 1862 | - $flip = array( false, true ); |
|
| 1862 | + $flip = array(false, true); |
|
| 1863 | 1863 | $modify = true; |
| 1864 | 1864 | break; |
| 1865 | 1865 | case 3: |
@@ -1868,13 +1868,13 @@ discard block |
||
| 1868 | 1868 | $modify = true; |
| 1869 | 1869 | break; |
| 1870 | 1870 | case 4: |
| 1871 | - $flip = array( true, false ); |
|
| 1871 | + $flip = array(true, false); |
|
| 1872 | 1872 | $modify = true; |
| 1873 | 1873 | break; |
| 1874 | 1874 | case 5: |
| 1875 | 1875 | $orientation = - 90; |
| 1876 | 1876 | $rotate = true; |
| 1877 | - $flip = array( false, true ); |
|
| 1877 | + $flip = array(false, true); |
|
| 1878 | 1878 | $modify = true; |
| 1879 | 1879 | break; |
| 1880 | 1880 | case 6: |
@@ -1885,7 +1885,7 @@ discard block |
||
| 1885 | 1885 | case 7: |
| 1886 | 1886 | $orientation = - 270; |
| 1887 | 1887 | $rotate = true; |
| 1888 | - $flip = array( false, true ); |
|
| 1888 | + $flip = array(false, true); |
|
| 1889 | 1889 | $modify = true; |
| 1890 | 1890 | break; |
| 1891 | 1891 | case 8: |
@@ -1911,31 +1911,31 @@ discard block |
||
| 1911 | 1911 | * @param int|null $quality Image Compression quality between 1-100% scale. Default null. |
| 1912 | 1912 | * @param string $quality Image mime type. |
| 1913 | 1913 | */ |
| 1914 | - $quality = apply_filters( 'geodir_image_upload_set_quality', $quality, $mime_type ); |
|
| 1915 | - if ( $quality !== null ) {
|
|
| 1914 | + $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
|
|
| 1915 | + if ($quality !== null) {
|
|
| 1916 | 1916 | $modify = true; |
| 1917 | 1917 | } |
| 1918 | 1918 | |
| 1919 | - if ( ! $modify ) {
|
|
| 1919 | + if (!$modify) {
|
|
| 1920 | 1920 | return $file; // no change |
| 1921 | 1921 | } |
| 1922 | 1922 | |
| 1923 | - $image = wp_get_image_editor( $file_path ); |
|
| 1924 | - if ( ! is_wp_error( $image ) ) {
|
|
| 1925 | - if ( $rotate ) {
|
|
| 1926 | - $image->rotate( $orientation ); |
|
| 1923 | + $image = wp_get_image_editor($file_path); |
|
| 1924 | + if (!is_wp_error($image)) {
|
|
| 1925 | + if ($rotate) {
|
|
| 1926 | + $image->rotate($orientation); |
|
| 1927 | 1927 | } |
| 1928 | 1928 | |
| 1929 | - if ( ! empty( $flip ) ) {
|
|
| 1930 | - $image->flip( $flip[0], $flip[1] ); |
|
| 1929 | + if (!empty($flip)) {
|
|
| 1930 | + $image->flip($flip[0], $flip[1]); |
|
| 1931 | 1931 | } |
| 1932 | 1932 | |
| 1933 | - if ( $quality !== null ) {
|
|
| 1934 | - $image->set_quality( (int) $quality ); |
|
| 1933 | + if ($quality !== null) {
|
|
| 1934 | + $image->set_quality((int) $quality); |
|
| 1935 | 1935 | } |
| 1936 | 1936 | |
| 1937 | - $result = $image->save( $file_path ); |
|
| 1938 | - if ( ! is_wp_error( $result ) ) {
|
|
| 1937 | + $result = $image->save($file_path); |
|
| 1938 | + if (!is_wp_error($result)) {
|
|
| 1939 | 1939 | $file['file'] = $result['path']; |
| 1940 | 1940 | $file['tmp_name'] = $result['path']; |
| 1941 | 1941 | } |
@@ -1962,7 +1962,7 @@ discard block |
||
| 1962 | 1962 | * |
| 1963 | 1963 | * @return string Returns the recent reviews html. |
| 1964 | 1964 | */ |
| 1965 | -function geodir_get_recent_reviews( $g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false ) {
|
|
| 1965 | +function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
|
|
| 1966 | 1966 | global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session; |
| 1967 | 1967 | $tablecomments = $wpdb->comments; |
| 1968 | 1968 | $tableposts = $wpdb->posts; |
@@ -1972,28 +1972,28 @@ discard block |
||
| 1972 | 1972 | $region_filter = ''; |
| 1973 | 1973 | $country_filter = ''; |
| 1974 | 1974 | |
| 1975 | - if ( $gd_session->get( 'gd_multi_location' ) ) {
|
|
| 1976 | - if ( $gd_ses_country = $gd_session->get( 'gd_country' ) ) {
|
|
| 1977 | - $country_filter = $wpdb->prepare( " AND r.post_country=%s ", str_replace( "-", " ", $gd_ses_country ) ); |
|
| 1975 | + if ($gd_session->get('gd_multi_location')) {
|
|
| 1976 | + if ($gd_ses_country = $gd_session->get('gd_country')) {
|
|
| 1977 | + $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
|
|
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | - if ( $gd_ses_region = $gd_session->get( 'gd_region' ) ) {
|
|
| 1981 | - $region_filter = $wpdb->prepare( " AND r.post_region=%s ", str_replace( "-", " ", $gd_ses_region ) ); |
|
| 1980 | + if ($gd_ses_region = $gd_session->get('gd_region')) {
|
|
| 1981 | + $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
|
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | - if ( $gd_ses_city = $gd_session->get( 'gd_city' ) ) {
|
|
| 1985 | - $city_filter = $wpdb->prepare( " AND r.post_city=%s ", str_replace( "-", " ", $gd_ses_city ) ); |
|
| 1984 | + if ($gd_ses_city = $gd_session->get('gd_city')) {
|
|
| 1985 | + $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
|
|
| 1986 | 1986 | } |
| 1987 | 1987 | } |
| 1988 | 1988 | |
| 1989 | 1989 | $review_table = GEODIR_REVIEW_TABLE; |
| 1990 | 1990 | $request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments"; |
| 1991 | 1991 | |
| 1992 | - $comments = $wpdb->get_results( $request ); |
|
| 1992 | + $comments = $wpdb->get_results($request); |
|
| 1993 | 1993 | |
| 1994 | - foreach ( $comments as $comment ) {
|
|
| 1994 | + foreach ($comments as $comment) {
|
|
| 1995 | 1995 | // Set the extra comment info needed. |
| 1996 | - $comment_extra = $wpdb->get_row( "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID" ); |
|
| 1996 | + $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
|
|
| 1997 | 1997 | //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID"; |
| 1998 | 1998 | $comment->comment_content = $comment_extra->comment_content; |
| 1999 | 1999 | $comment->comment_author = $comment_extra->comment_author; |
@@ -2001,75 +2001,75 @@ discard block |
||
| 2001 | 2001 | |
| 2002 | 2002 | $comment_id = ''; |
| 2003 | 2003 | $comment_id = $comment->comment_ID; |
| 2004 | - $comment_content = strip_tags( $comment->comment_content ); |
|
| 2004 | + $comment_content = strip_tags($comment->comment_content); |
|
| 2005 | 2005 | |
| 2006 | - $comment_content = preg_replace( '#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content ); |
|
| 2006 | + $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
|
|
| 2007 | 2007 | |
| 2008 | - $permalink = get_permalink( $comment->ID ) . "#comment-" . $comment->comment_ID; |
|
| 2008 | + $permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID; |
|
| 2009 | 2009 | $comment_author_email = $comment->comment_author_email; |
| 2010 | 2010 | $comment_post_ID = $comment->post_id; |
| 2011 | 2011 | |
| 2012 | 2012 | $na = true; |
| 2013 | - if ( function_exists( 'icl_object_id' ) && icl_object_id( $comment_post_ID, $comment->post_type, true ) ) {
|
|
| 2014 | - $comment_post_ID2 = icl_object_id( $comment_post_ID, $comment->post_type, false ); |
|
| 2015 | - if ( $comment_post_ID == $comment_post_ID2 ) {
|
|
| 2013 | + if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
|
|
| 2014 | + $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false); |
|
| 2015 | + if ($comment_post_ID == $comment_post_ID2) {
|
|
| 2016 | 2016 | } else {
|
| 2017 | 2017 | $na = false; |
| 2018 | 2018 | } |
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | - $post_title = get_the_title( $comment_post_ID ); |
|
| 2022 | - $permalink = get_permalink( $comment_post_ID ); |
|
| 2023 | - $comment_permalink = $permalink . "#comment-" . $comment->comment_ID; |
|
| 2024 | - $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __( 'Read more', 'geodirectory' ) . '</a>'; |
|
| 2021 | + $post_title = get_the_title($comment_post_ID); |
|
| 2022 | + $permalink = get_permalink($comment_post_ID); |
|
| 2023 | + $comment_permalink = $permalink."#comment-".$comment->comment_ID; |
|
| 2024 | + $read_more = '<a class="comment_excerpt" href="'.$comment_permalink.'">'.__('Read more', 'geodirectory').'</a>';
|
|
| 2025 | 2025 | |
| 2026 | - $comment_content_length = strlen( $comment_content ); |
|
| 2027 | - if ( $comment_content_length > $comment_lenth ) {
|
|
| 2028 | - $comment_excerpt = geodir_utf8_substr( $comment_content, 0, $comment_lenth ) . '... ' . $read_more; |
|
| 2026 | + $comment_content_length = strlen($comment_content); |
|
| 2027 | + if ($comment_content_length > $comment_lenth) {
|
|
| 2028 | + $comment_excerpt = geodir_utf8_substr($comment_content, 0, $comment_lenth).'... '.$read_more; |
|
| 2029 | 2029 | } else {
|
| 2030 | 2030 | $comment_excerpt = $comment_content; |
| 2031 | 2031 | } |
| 2032 | 2032 | |
| 2033 | - if ( $comment->user_id ) {
|
|
| 2034 | - $user_profile_url = get_author_posts_url( $comment->user_id ); |
|
| 2033 | + if ($comment->user_id) {
|
|
| 2034 | + $user_profile_url = get_author_posts_url($comment->user_id); |
|
| 2035 | 2035 | } else {
|
| 2036 | 2036 | $user_profile_url = ''; |
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | - if ( $comment_id && $na ) {
|
|
| 2039 | + if ($comment_id && $na) {
|
|
| 2040 | 2040 | $comments_echo .= '<li class="clearfix">'; |
| 2041 | - $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">"; |
|
| 2042 | - if ( function_exists( 'get_avatar' ) ) {
|
|
| 2043 | - if ( ! isset( $comment->comment_type ) ) {
|
|
| 2044 | - if ( $user_profile_url ) {
|
|
| 2045 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 2041 | + $comments_echo .= "<span class=\"li".$comment_id." geodir_reviewer_image\">"; |
|
| 2042 | + if (function_exists('get_avatar')) {
|
|
| 2043 | + if (!isset($comment->comment_type)) {
|
|
| 2044 | + if ($user_profile_url) {
|
|
| 2045 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; |
|
| 2046 | 2046 | } |
| 2047 | - $comments_echo .= get_avatar( $comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); |
|
| 2048 | - if ( $user_profile_url ) {
|
|
| 2047 | + $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); |
|
| 2048 | + if ($user_profile_url) {
|
|
| 2049 | 2049 | $comments_echo .= '</a>'; |
| 2050 | 2050 | } |
| 2051 | - } elseif ( ( isset( $comment->comment_type ) && $comment->comment_type == 'trackback' ) || ( isset( $comment->comment_type ) && $comment->comment_type == 'pingback' ) ) {
|
|
| 2052 | - if ( $user_profile_url ) {
|
|
| 2053 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 2051 | + } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
|
|
| 2052 | + if ($user_profile_url) {
|
|
| 2053 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; |
|
| 2054 | 2054 | } |
| 2055 | - $comments_echo .= get_avatar( $comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); |
|
| 2055 | + $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); |
|
| 2056 | 2056 | } |
| 2057 | - } elseif ( function_exists( 'gravatar' ) ) {
|
|
| 2058 | - if ( $user_profile_url ) {
|
|
| 2059 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 2057 | + } elseif (function_exists('gravatar')) {
|
|
| 2058 | + if ($user_profile_url) {
|
|
| 2059 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; |
|
| 2060 | 2060 | } |
| 2061 | 2061 | $comments_echo .= "<img src=\""; |
| 2062 | - if ( '' == $comment->comment_type ) {
|
|
| 2063 | - $comments_echo .= gravatar( $comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); |
|
| 2064 | - if ( $user_profile_url ) {
|
|
| 2062 | + if ('' == $comment->comment_type) {
|
|
| 2063 | + $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); |
|
| 2064 | + if ($user_profile_url) {
|
|
| 2065 | 2065 | $comments_echo .= '</a>'; |
| 2066 | 2066 | } |
| 2067 | - } elseif ( ( 'trackback' == $comment->comment_type ) || ( 'pingback' == $comment->comment_type ) ) {
|
|
| 2068 | - if ( $user_profile_url ) {
|
|
| 2069 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 2067 | + } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
|
|
| 2068 | + if ($user_profile_url) {
|
|
| 2069 | + $comments_echo .= '<a href="'.$user_profile_url.'">'; |
|
| 2070 | 2070 | } |
| 2071 | - $comments_echo .= gravatar( $comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png' ); |
|
| 2072 | - if ( $user_profile_url ) {
|
|
| 2071 | + $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url().'/geodirectory-assets/images/gravatar2.png'); |
|
| 2072 | + if ($user_profile_url) {
|
|
| 2073 | 2073 | $comments_echo .= '</a>'; |
| 2074 | 2074 | } |
| 2075 | 2075 | } |
@@ -2079,17 +2079,17 @@ discard block |
||
| 2079 | 2079 | $comments_echo .= "</span>\n"; |
| 2080 | 2080 | |
| 2081 | 2081 | $comments_echo .= '<span class="geodir_reviewer_content">'; |
| 2082 | - if ( $comment->user_id ) {
|
|
| 2083 | - $comments_echo .= '<a href="' . get_author_posts_url( $comment->user_id ) . '">'; |
|
| 2082 | + if ($comment->user_id) {
|
|
| 2083 | + $comments_echo .= '<a href="'.get_author_posts_url($comment->user_id).'">'; |
|
| 2084 | 2084 | } |
| 2085 | - $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> '; |
|
| 2086 | - if ( $comment->user_id ) {
|
|
| 2085 | + $comments_echo .= '<span class="geodir_reviewer_author">'.$comment->comment_author.'</span> '; |
|
| 2086 | + if ($comment->user_id) {
|
|
| 2087 | 2087 | $comments_echo .= '</a>'; |
| 2088 | 2088 | } |
| 2089 | - $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __( 'reviewed', 'geodirectory' ) . '</span> '; |
|
| 2090 | - $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>'; |
|
| 2091 | - $comments_echo .= geodir_get_rating_stars( $comment->overall_rating, $comment_post_ID ); |
|
| 2092 | - $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . ''; |
|
| 2089 | + $comments_echo .= '<span class="geodir_reviewer_reviewed">'.__('reviewed', 'geodirectory').'</span> ';
|
|
| 2090 | + $comments_echo .= '<a href="'.$permalink.'" class="geodir_reviewer_title">'.$post_title.'</a>'; |
|
| 2091 | + $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID); |
|
| 2092 | + $comments_echo .= '<p class="geodir_reviewer_text">'.$comment_excerpt.''; |
|
| 2093 | 2093 | //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
|
| 2094 | 2094 | $comments_echo .= '</p>'; |
| 2095 | 2095 | |
@@ -2109,25 +2109,25 @@ discard block |
||
| 2109 | 2109 | * @return array Returns post categories as an array. |
| 2110 | 2110 | */ |
| 2111 | 2111 | function geodir_home_map_cats_key_value_array() {
|
| 2112 | - $post_types = geodir_get_posttypes( 'object' ); |
|
| 2112 | + $post_types = geodir_get_posttypes('object');
|
|
| 2113 | 2113 | |
| 2114 | 2114 | $return = array(); |
| 2115 | - if ( ! empty( $post_types ) ) {
|
|
| 2116 | - foreach ( $post_types as $key => $post_type ) {
|
|
| 2117 | - $cpt_name = __( $post_type->labels->singular_name, 'geodirectory' ); |
|
| 2118 | - $post_type_name = sprintf( __( '%s Categories', 'geodirectory' ), $cpt_name ); |
|
| 2119 | - $taxonomies = geodir_get_taxonomies( $key ); |
|
| 2120 | - $cat_taxonomy = ! empty( $taxonomies[0] ) ? $taxonomies[0] : null; |
|
| 2121 | - $cat_terms = $cat_taxonomy ? get_terms( $cat_taxonomy ) : null; |
|
| 2122 | - |
|
| 2123 | - if ( ! empty( $cat_terms ) ) {
|
|
| 2124 | - $return[ 'optgroup_start-' . $key ] = $post_type_name; |
|
| 2125 | - |
|
| 2126 | - foreach ( $cat_terms as $cat_term ) {
|
|
| 2127 | - $return[ $key . '_' . $cat_term->term_id ] = $cat_term->name; |
|
| 2115 | + if (!empty($post_types)) {
|
|
| 2116 | + foreach ($post_types as $key => $post_type) {
|
|
| 2117 | + $cpt_name = __($post_type->labels->singular_name, 'geodirectory'); |
|
| 2118 | + $post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
|
|
| 2119 | + $taxonomies = geodir_get_taxonomies($key); |
|
| 2120 | + $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : null; |
|
| 2121 | + $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : null; |
|
| 2122 | + |
|
| 2123 | + if (!empty($cat_terms)) {
|
|
| 2124 | + $return['optgroup_start-'.$key] = $post_type_name; |
|
| 2125 | + |
|
| 2126 | + foreach ($cat_terms as $cat_term) {
|
|
| 2127 | + $return[$key.'_'.$cat_term->term_id] = $cat_term->name; |
|
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | - $return[ 'optgroup_end-' . $key ] = $post_type_name; |
|
| 2130 | + $return['optgroup_end-'.$key] = $post_type_name; |
|
| 2131 | 2131 | } |
| 2132 | 2132 | } |
| 2133 | 2133 | } |
@@ -2143,14 +2143,14 @@ discard block |
||
| 2143 | 2143 | * @package GeoDirectory |
| 2144 | 2144 | */ |
| 2145 | 2145 | function geodir_twitter_tweet_button() {
|
| 2146 | - if ( isset( $_GET['gde'] ) ) {
|
|
| 2147 | - $link = '?url=' . urlencode( geodir_curPageURL() ); |
|
| 2146 | + if (isset($_GET['gde'])) {
|
|
| 2147 | + $link = '?url='.urlencode(geodir_curPageURL()); |
|
| 2148 | 2148 | } else {
|
| 2149 | 2149 | $link = ''; |
| 2150 | 2150 | } |
| 2151 | 2151 | ?> |
| 2152 | 2152 | <a href="http://twitter.com/share<?php echo $link; ?>" |
| 2153 | - class="twitter-share-button"><?php _e( 'Tweet', 'geodirectory' ); ?></a> |
|
| 2153 | + class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
|
|
| 2154 | 2154 | <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> |
| 2155 | 2155 | <?php |
| 2156 | 2156 | } |
@@ -2167,10 +2167,10 @@ discard block |
||
| 2167 | 2167 | function geodir_fb_like_button() {
|
| 2168 | 2168 | global $post; |
| 2169 | 2169 | ?> |
| 2170 | - <iframe <?php if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) ) {
|
|
| 2170 | + <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
|
|
| 2171 | 2171 | echo 'allowtransparency="true"'; |
| 2172 | 2172 | } ?> class="facebook" |
| 2173 | - src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode( get_permalink( $post->ID ) ); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light" |
|
| 2173 | + src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light" |
|
| 2174 | 2174 | style="border:none; overflow:hidden; width:100px; height:20px"></iframe> |
| 2175 | 2175 | <?php |
| 2176 | 2176 | } |
@@ -2201,7 +2201,7 @@ discard block |
||
| 2201 | 2201 | |
| 2202 | 2202 | |
| 2203 | 2203 | function geodir_listing_bounce_map_pin_on_hover() {
|
| 2204 | - if ( get_option( 'geodir_listing_hover_bounce_map_pin', true ) ) {
|
|
| 2204 | + if (get_option('geodir_listing_hover_bounce_map_pin', true)) {
|
|
| 2205 | 2205 | ?> |
| 2206 | 2206 | <script> |
| 2207 | 2207 | jQuery(function ($) {
|
@@ -2224,44 +2224,44 @@ discard block |
||
| 2224 | 2224 | } |
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | -add_action( 'geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10 ); |
|
| 2227 | +add_action('geodir_after_listing_listview', 'geodir_listing_bounce_map_pin_on_hover', 10);
|
|
| 2228 | 2228 | |
| 2229 | -add_action( 'geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1 ); |
|
| 2230 | -function geodir_output_favourite_html_listings( $post_id ) {
|
|
| 2231 | - geodir_favourite_html( '', $post_id ); |
|
| 2229 | +add_action('geodir_after_favorite_html', 'geodir_output_favourite_html_listings', 1, 1);
|
|
| 2230 | +function geodir_output_favourite_html_listings($post_id) {
|
|
| 2231 | + geodir_favourite_html('', $post_id);
|
|
| 2232 | 2232 | } |
| 2233 | 2233 | |
| 2234 | -add_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2 ); |
|
| 2235 | -function geodir_output_pinpoint_html_listings( $post_id, $post ) {
|
|
| 2234 | +add_action('geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings', 1, 2);
|
|
| 2235 | +function geodir_output_pinpoint_html_listings($post_id, $post) {
|
|
| 2236 | 2236 | global $wp_query; |
| 2237 | 2237 | |
| 2238 | 2238 | $show_pin_point = $wp_query->is_main_query(); |
| 2239 | 2239 | |
| 2240 | - if ( ! empty( $show_pin_point ) && is_active_widget( false, "", "geodir_map_v3_listing_map" ) ) {
|
|
| 2241 | - $term_icon_url = get_tax_meta( $post->default_category, 'ct_cat_icon', false, $post->post_type ); |
|
| 2242 | - $marker_icon = isset( $term_icon_url['src'] ) ? $term_icon_url['src'] : get_option( 'geodir_default_marker_icon' ); |
|
| 2240 | + if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
|
|
| 2241 | + $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type); |
|
| 2242 | + $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
|
|
| 2243 | 2243 | ?> |
| 2244 | 2244 | <span class="geodir-pinpoint" |
| 2245 | - style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters( 'geodir_listing_listview_pinpoint_inner_content', '', 'listing' ); ?></span>
|
|
| 2245 | + style="background:url('<?php echo $marker_icon; ?>') no-repeat scroll left top transparent;background-size:auto 100%; -webkit-background-size:auto 100%;-moz-background-size:auto 100%;height:9px;width:14px;"><?php echo apply_filters('geodir_listing_listview_pinpoint_inner_content', '', 'listing'); ?></span>
|
|
| 2246 | 2246 | <a class="geodir-pinpoint-link" href="javascript:void(0)" |
| 2247 | 2247 | onclick="if(typeof openMarker=='function'){openMarker('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"
|
| 2248 | 2248 | onmouseover="if(typeof animate_marker=='function'){animate_marker('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"
|
| 2249 | - onmouseout="if(typeof stop_marker_animation=='function'){stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"><?php _e( 'Pinpoint', 'geodirectory' ); ?></a>
|
|
| 2249 | + onmouseout="if(typeof stop_marker_animation=='function'){stop_marker_animation('listing_map_canvas' ,'<?php echo $post->ID; ?>')}"><?php _e('Pinpoint', 'geodirectory'); ?></a>
|
|
| 2250 | 2250 | <?php |
| 2251 | 2251 | } |
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | 2254 | function geodir_search_form_submit_button() {
|
| 2255 | 2255 | |
| 2256 | - $new_style = get_option( 'geodir_show_search_old_search_from' ) ? false : true; |
|
| 2256 | + $new_style = get_option('geodir_show_search_old_search_from') ? false : true;
|
|
| 2257 | 2257 | |
| 2258 | - if ( $new_style ) {
|
|
| 2258 | + if ($new_style) {
|
|
| 2259 | 2259 | $default_search_button_label = '<i class="fa fa-search" aria-hidden="true"></i>'; |
| 2260 | - }else{
|
|
| 2260 | + } else {
|
|
| 2261 | 2261 | $default_search_button_label = 'Search'; |
| 2262 | 2262 | } |
| 2263 | - if ( get_option( 'geodir_search_button_label' ) && get_option( 'geodir_search_button_label' ) != 'Search' ) {
|
|
| 2264 | - $default_search_button_label = __( get_option( 'geodir_search_button_label' ), 'geodirectory' ); |
|
| 2263 | + if (get_option('geodir_search_button_label') && get_option('geodir_search_button_label') != 'Search') {
|
|
| 2264 | + $default_search_button_label = __(get_option('geodir_search_button_label'), 'geodirectory');
|
|
| 2265 | 2265 | } |
| 2266 | 2266 | |
| 2267 | 2267 | /** |
@@ -2273,78 +2273,78 @@ discard block |
||
| 2273 | 2273 | * |
| 2274 | 2274 | * @param string $default_search_button_label The current search button text. |
| 2275 | 2275 | */ |
| 2276 | - $default_search_button_label = apply_filters( 'geodir_search_default_search_button_text', $default_search_button_label ); |
|
| 2276 | + $default_search_button_label = apply_filters('geodir_search_default_search_button_text', $default_search_button_label);
|
|
| 2277 | 2277 | |
| 2278 | 2278 | $fa_class = ''; |
| 2279 | - if ( strpos( $default_search_button_label, '&#' ) !== false ) {
|
|
| 2279 | + if (strpos($default_search_button_label, '&#') !== false) {
|
|
| 2280 | 2280 | $fa_class = 'fa'; |
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | |
| 2284 | - if ( $new_style ) {
|
|
| 2284 | + if ($new_style) {
|
|
| 2285 | 2285 | ?> |
| 2286 | - <button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e( $default_search_button_label ,'geodirectory'); ?></button> |
|
| 2287 | -<?php }else{?>
|
|
| 2288 | - <input type="button" value="<?php esc_attr_e( $default_search_button_label ); ?>" |
|
| 2286 | + <button class="geodir_submit_search <?php echo $fa_class; ?>"><?php _e($default_search_button_label, 'geodirectory'); ?></button> |
|
| 2287 | +<?php } else {?>
|
|
| 2288 | + <input type="button" value="<?php esc_attr_e($default_search_button_label); ?>" |
|
| 2289 | 2289 | class="geodir_submit_search <?php echo $fa_class; ?>"/> |
| 2290 | 2290 | <?php } |
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | -add_action( 'geodir_before_search_button', 'geodir_search_form_submit_button', 5000 ); |
|
| 2293 | +add_action('geodir_before_search_button', 'geodir_search_form_submit_button', 5000);
|
|
| 2294 | 2294 | |
| 2295 | 2295 | function geodir_search_form_post_type_input() {
|
| 2296 | 2296 | global $geodir_search_post_type; |
| 2297 | - $post_types = apply_filters( 'geodir_search_form_post_types', geodir_get_posttypes( 'object' ) ); |
|
| 2297 | + $post_types = apply_filters('geodir_search_form_post_types', geodir_get_posttypes('object'));
|
|
| 2298 | 2298 | $curr_post_type = $geodir_search_post_type; |
| 2299 | 2299 | |
| 2300 | - if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
|
|
| 2300 | + if (!empty($post_types) && count((array) $post_types) > 1) {
|
|
| 2301 | 2301 | |
| 2302 | - foreach ( $post_types as $post_type => $info ){
|
|
| 2302 | + foreach ($post_types as $post_type => $info) {
|
|
| 2303 | 2303 | global $wpdb; |
| 2304 | - $has_posts = $wpdb->get_row( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type ) ); |
|
| 2305 | - if ( ! $has_posts ) {
|
|
| 2304 | + $has_posts = $wpdb->get_row($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type = %s AND post_status='publish' LIMIT 1", $post_type));
|
|
| 2305 | + if (!$has_posts) {
|
|
| 2306 | 2306 | unset($post_types->{$post_type});
|
| 2307 | 2307 | } |
| 2308 | 2308 | } |
| 2309 | 2309 | |
| 2310 | - if ( ! empty( $post_types ) && count( (array) $post_types ) > 1 ) {
|
|
| 2310 | + if (!empty($post_types) && count((array) $post_types) > 1) {
|
|
| 2311 | 2311 | |
| 2312 | - $new_style = get_option( 'geodir_show_search_old_search_from' ) ? false : true; |
|
| 2313 | - if ( $new_style ) {
|
|
| 2312 | + $new_style = get_option('geodir_show_search_old_search_from') ? false : true;
|
|
| 2313 | + if ($new_style) {
|
|
| 2314 | 2314 | echo "<div class='gd-search-input-wrapper gd-search-field-cpt'>"; |
| 2315 | 2315 | } |
| 2316 | 2316 | ?> |
| 2317 | 2317 | <select name="stype" class="search_by_post"> |
| 2318 | - <?php foreach ( $post_types as $post_type => $info ): |
|
| 2318 | + <?php foreach ($post_types as $post_type => $info): |
|
| 2319 | 2319 | global $wpdb; |
| 2320 | 2320 | ?> |
| 2321 | 2321 | |
| 2322 | - <option data-label="<?php echo get_post_type_archive_link( $post_type ); ?>" |
|
| 2323 | - value="<?php echo $post_type; ?>" <?php if ( isset( $_REQUEST['stype'] ) ) {
|
|
| 2324 | - if ( $post_type == $_REQUEST['stype'] ) {
|
|
| 2322 | + <option data-label="<?php echo get_post_type_archive_link($post_type); ?>" |
|
| 2323 | + value="<?php echo $post_type; ?>" <?php if (isset($_REQUEST['stype'])) {
|
|
| 2324 | + if ($post_type == $_REQUEST['stype']) {
|
|
| 2325 | 2325 | echo 'selected="selected"'; |
| 2326 | 2326 | } |
| 2327 | - } elseif ( $curr_post_type == $post_type ) {
|
|
| 2327 | + } elseif ($curr_post_type == $post_type) {
|
|
| 2328 | 2328 | echo 'selected="selected"'; |
| 2329 | - } ?>><?php _e( ucfirst( $info->labels->name ), 'geodirectory' ); ?></option> |
|
| 2329 | + } ?>><?php _e(ucfirst($info->labels->name), 'geodirectory'); ?></option> |
|
| 2330 | 2330 | |
| 2331 | 2331 | <?php endforeach; ?> |
| 2332 | 2332 | </select> |
| 2333 | 2333 | <?php |
| 2334 | - if ( $new_style ) {
|
|
| 2334 | + if ($new_style) {
|
|
| 2335 | 2335 | echo "</div>"; |
| 2336 | 2336 | } |
| 2337 | - }else{
|
|
| 2338 | - if(! empty( $post_types )){
|
|
| 2339 | - $pt_arr = (array)$post_types; |
|
| 2340 | - echo '<input type="hidden" name="stype" value="' . key( $pt_arr ) . '" />'; |
|
| 2341 | - }else{
|
|
| 2337 | + } else {
|
|
| 2338 | + if (!empty($post_types)) {
|
|
| 2339 | + $pt_arr = (array) $post_types; |
|
| 2340 | + echo '<input type="hidden" name="stype" value="'.key($pt_arr).'" />'; |
|
| 2341 | + } else {
|
|
| 2342 | 2342 | echo '<input type="hidden" name="stype" value="gd_place" />'; |
| 2343 | 2343 | } |
| 2344 | 2344 | |
| 2345 | 2345 | } |
| 2346 | 2346 | |
| 2347 | - }elseif ( ! empty( $post_types ) ) {
|
|
| 2347 | + }elseif (!empty($post_types)) {
|
|
| 2348 | 2348 | echo '<input type="hidden" name="stype" value="gd_place" />'; |
| 2349 | 2349 | } |
| 2350 | 2350 | } |
@@ -2352,26 +2352,26 @@ discard block |
||
| 2352 | 2352 | function geodir_search_form_search_input() {
|
| 2353 | 2353 | |
| 2354 | 2354 | $default_search_for_text = SEARCH_FOR_TEXT; |
| 2355 | - if ( get_option( 'geodir_search_field_default_text' ) ) {
|
|
| 2356 | - $default_search_for_text = __( get_option( 'geodir_search_field_default_text' ), 'geodirectory' ); |
|
| 2355 | + if (get_option('geodir_search_field_default_text')) {
|
|
| 2356 | + $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
|
|
| 2357 | 2357 | } |
| 2358 | 2358 | |
| 2359 | 2359 | $new_style = get_option('geodir_show_search_old_search_from') ? false : true;
|
| 2360 | - if($new_style){
|
|
| 2360 | + if ($new_style) {
|
|
| 2361 | 2361 | echo "<div class='gd-search-input-wrapper gd-search-field-search'>"; |
| 2362 | 2362 | } |
| 2363 | 2363 | ?> |
| 2364 | 2364 | <input class="search_text" name="s" |
| 2365 | - value="<?php if ( isset( $_REQUEST['s'] ) && trim( $_REQUEST['s'] ) != '' ) {
|
|
| 2366 | - echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) ); |
|
| 2365 | + value="<?php if (isset($_REQUEST['s']) && trim($_REQUEST['s']) != '') {
|
|
| 2366 | + echo esc_attr(stripslashes_deep($_REQUEST['s'])); |
|
| 2367 | 2367 | } else {
|
| 2368 | 2368 | echo $default_search_for_text; |
| 2369 | 2369 | } ?>" type="text" |
| 2370 | - onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql( $default_search_for_text ); ?>';}"
|
|
| 2371 | - onfocus="if (this.value == '<?php echo esc_sql( $default_search_for_text ); ?>') {this.value = '';}"
|
|
| 2370 | + onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql($default_search_for_text); ?>';}"
|
|
| 2371 | + onfocus="if (this.value == '<?php echo esc_sql($default_search_for_text); ?>') {this.value = '';}"
|
|
| 2372 | 2372 | onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);"> |
| 2373 | 2373 | <?php |
| 2374 | - if($new_style){
|
|
| 2374 | + if ($new_style) {
|
|
| 2375 | 2375 | echo "</div>"; |
| 2376 | 2376 | } |
| 2377 | 2377 | } |
@@ -2379,12 +2379,12 @@ discard block |
||
| 2379 | 2379 | function geodir_search_form_near_input() {
|
| 2380 | 2380 | |
| 2381 | 2381 | $default_near_text = NEAR_TEXT; |
| 2382 | - if ( get_option( 'geodir_near_field_default_text' ) ) {
|
|
| 2383 | - $default_near_text = __( get_option( 'geodir_near_field_default_text' ), 'geodirectory' ); |
|
| 2382 | + if (get_option('geodir_near_field_default_text')) {
|
|
| 2383 | + $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
|
|
| 2384 | 2384 | } |
| 2385 | 2385 | |
| 2386 | - if ( isset( $_REQUEST['snear'] ) && $_REQUEST['snear'] != '' ) {
|
|
| 2387 | - $near = esc_attr( stripslashes_deep( $_REQUEST['snear'] ) ); |
|
| 2386 | + if (isset($_REQUEST['snear']) && $_REQUEST['snear'] != '') {
|
|
| 2387 | + $near = esc_attr(stripslashes_deep($_REQUEST['snear'])); |
|
| 2388 | 2388 | } else {
|
| 2389 | 2389 | $near = $default_near_text; |
| 2390 | 2390 | } |
@@ -2398,7 +2398,7 @@ discard block |
||
| 2398 | 2398 | * @since 1.6.9 |
| 2399 | 2399 | * @param string $curr_post_type The current post type. |
| 2400 | 2400 | */ |
| 2401 | - $near_input_extra = apply_filters('geodir_near_input_extra','',$curr_post_type);
|
|
| 2401 | + $near_input_extra = apply_filters('geodir_near_input_extra', '', $curr_post_type);
|
|
| 2402 | 2402 | |
| 2403 | 2403 | |
| 2404 | 2404 | /** |
@@ -2411,7 +2411,7 @@ discard block |
||
| 2411 | 2411 | * @param string $near The current near value. |
| 2412 | 2412 | * @param string $default_near_text The default near value. |
| 2413 | 2413 | */ |
| 2414 | - $near = apply_filters( 'geodir_search_near_text', $near, $default_near_text ); |
|
| 2414 | + $near = apply_filters('geodir_search_near_text', $near, $default_near_text);
|
|
| 2415 | 2415 | /** |
| 2416 | 2416 | * Filter the default "Near" text value for the search form. |
| 2417 | 2417 | * |
@@ -2422,7 +2422,7 @@ discard block |
||
| 2422 | 2422 | * @param string $near The current near value. |
| 2423 | 2423 | * @param string $default_near_text The default near value. |
| 2424 | 2424 | */ |
| 2425 | - $default_near_text = apply_filters( 'geodir_search_default_near_text', $default_near_text, $near ); |
|
| 2425 | + $default_near_text = apply_filters('geodir_search_default_near_text', $default_near_text, $near);
|
|
| 2426 | 2426 | /** |
| 2427 | 2427 | * Filter the class for the near search input. |
| 2428 | 2428 | * |
@@ -2430,10 +2430,10 @@ discard block |
||
| 2430 | 2430 | * |
| 2431 | 2431 | * @param string $class The class for the HTML near input, default is blank. |
| 2432 | 2432 | */ |
| 2433 | - $near_class = apply_filters( 'geodir_search_near_class', '' ); |
|
| 2433 | + $near_class = apply_filters('geodir_search_near_class', '');
|
|
| 2434 | 2434 | |
| 2435 | 2435 | $new_style = get_option('geodir_show_search_old_search_from') ? false : true;
|
| 2436 | - if($new_style){
|
|
| 2436 | + if ($new_style) {
|
|
| 2437 | 2437 | echo "<div class='gd-search-input-wrapper gd-search-field-near' $near_input_extra>"; |
| 2438 | 2438 | |
| 2439 | 2439 | do_action('geodir_before_near_input');
|
@@ -2441,30 +2441,30 @@ discard block |
||
| 2441 | 2441 | |
| 2442 | 2442 | ?> |
| 2443 | 2443 | <input name="snear" class="snear <?php echo $near_class; ?>" type="text" value="<?php echo $near; ?>" |
| 2444 | - onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql( $near ); ?>' != '' ? '<?php echo esc_sql( $near ); ?>' : '<?php echo $default_near_text; ?>');}"
|
|
| 2445 | - onfocus="if (this.value == '<?php echo $default_near_text; ?>' || this.value =='<?php echo esc_sql( $near ); ?>') {this.value = '';}"
|
|
| 2446 | - onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);" <?php echo $near_input_extra;?>/> |
|
| 2444 | + onblur="if (this.value.trim() == '') {this.value = ('<?php echo esc_sql($near); ?>' != '' ? '<?php echo esc_sql($near); ?>' : '<?php echo $default_near_text; ?>');}"
|
|
| 2445 | + onfocus="if (this.value == '<?php echo $default_near_text; ?>' || this.value =='<?php echo esc_sql($near); ?>') {this.value = '';}"
|
|
| 2446 | + onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);" <?php echo $near_input_extra; ?>/> |
|
| 2447 | 2447 | <?php |
| 2448 | - if($new_style){
|
|
| 2448 | + if ($new_style) {
|
|
| 2449 | 2449 | do_action('geodir_after_near_input');
|
| 2450 | 2450 | |
| 2451 | 2451 | echo "</div>"; |
| 2452 | 2452 | } |
| 2453 | 2453 | } |
| 2454 | 2454 | |
| 2455 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_post_type_input', 10 ); |
|
| 2456 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_search_input', 20 ); |
|
| 2457 | -add_action( 'geodir_search_form_inputs', 'geodir_search_form_near_input', 30 ); |
|
| 2455 | +add_action('geodir_search_form_inputs', 'geodir_search_form_post_type_input', 10);
|
|
| 2456 | +add_action('geodir_search_form_inputs', 'geodir_search_form_search_input', 20);
|
|
| 2457 | +add_action('geodir_search_form_inputs', 'geodir_search_form_near_input', 30);
|
|
| 2458 | 2458 | |
| 2459 | -function geodir_get_search_post_type($pt=''){
|
|
| 2459 | +function geodir_get_search_post_type($pt = '') {
|
|
| 2460 | 2460 | global $geodir_search_post_type; |
| 2461 | 2461 | |
| 2462 | - if($pt!=''){return $geodir_search_post_type = $pt;}
|
|
| 2463 | - if(!empty($geodir_search_post_type)){ return $geodir_search_post_type;}
|
|
| 2462 | + if ($pt != '') {return $geodir_search_post_type = $pt; }
|
|
| 2463 | + if (!empty($geodir_search_post_type)) { return $geodir_search_post_type; }
|
|
| 2464 | 2464 | |
| 2465 | 2465 | $geodir_search_post_type = geodir_get_current_posttype(); |
| 2466 | 2466 | |
| 2467 | - if(!$geodir_search_post_type) {
|
|
| 2467 | + if (!$geodir_search_post_type) {
|
|
| 2468 | 2468 | $geodir_search_post_type = geodir_get_default_posttype(); |
| 2469 | 2469 | } |
| 2470 | 2470 | |
@@ -2472,7 +2472,7 @@ discard block |
||
| 2472 | 2472 | return $geodir_search_post_type; |
| 2473 | 2473 | } |
| 2474 | 2474 | |
| 2475 | -function geodir_search_form(){
|
|
| 2475 | +function geodir_search_form() {
|
|
| 2476 | 2476 | |
| 2477 | 2477 | geodir_get_search_post_type(); |
| 2478 | 2478 | |
@@ -2482,8 +2482,8 @@ discard block |
||
| 2482 | 2482 | die(); |
| 2483 | 2483 | } |
| 2484 | 2484 | |
| 2485 | -add_action( 'wp_ajax_geodir_search_form', 'geodir_search_form' ); |
|
| 2486 | -add_action( 'wp_ajax_nopriv_geodir_search_form', 'geodir_search_form' ); |
|
| 2485 | +add_action('wp_ajax_geodir_search_form', 'geodir_search_form');
|
|
| 2486 | +add_action('wp_ajax_nopriv_geodir_search_form', 'geodir_search_form');
|
|
| 2487 | 2487 | |
| 2488 | 2488 | /** |
| 2489 | 2489 | * Check wpml active or not. |
@@ -2557,7 +2557,7 @@ discard block |
||
| 2557 | 2557 | } |
| 2558 | 2558 | } |
| 2559 | 2559 | } |
| 2560 | -add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); |
|
| 2560 | +add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
|
|
| 2561 | 2561 | |
| 2562 | 2562 | /** |
| 2563 | 2563 | * Duplicate post listing manually after listing saved. |
@@ -2598,7 +2598,7 @@ discard block |
||
| 2598 | 2598 | function geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang) {
|
| 2599 | 2599 | global $wpdb; |
| 2600 | 2600 | |
| 2601 | - $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A);
|
|
| 2601 | + $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM ".GEODIR_REVIEW_TABLE." WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A);
|
|
| 2602 | 2602 | |
| 2603 | 2603 | if (!empty($reviews)) {
|
| 2604 | 2604 | foreach ($reviews as $review) {
|
@@ -2626,14 +2626,14 @@ discard block |
||
| 2626 | 2626 | global $wpdb, $plugin_prefix; |
| 2627 | 2627 | |
| 2628 | 2628 | $post_type = get_post_type($master_post_id); |
| 2629 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 2629 | + $post_table = $plugin_prefix.$post_type.'_detail'; |
|
| 2630 | 2630 | |
| 2631 | - $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
|
| 2632 | - $data = (array)$wpdb->get_row($query); |
|
| 2631 | + $query = $wpdb->prepare("SELECT * FROM ".$post_table." WHERE post_id = %d", array($master_post_id));
|
|
| 2632 | + $data = (array) $wpdb->get_row($query); |
|
| 2633 | 2633 | |
| 2634 | - if ( !empty( $data ) ) {
|
|
| 2634 | + if (!empty($data)) {
|
|
| 2635 | 2635 | $data['post_id'] = $tr_post_id; |
| 2636 | - unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category']); |
|
| 2636 | + unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type.'category']); |
|
| 2637 | 2637 | $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
|
| 2638 | 2638 | return true; |
| 2639 | 2639 | } |
@@ -2658,7 +2658,7 @@ discard block |
||
| 2658 | 2658 | global $sitepress, $wpdb; |
| 2659 | 2659 | $post_type = get_post_type($master_post_id); |
| 2660 | 2660 | |
| 2661 | - remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 2661 | + remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 2662 | 2662 | |
| 2663 | 2663 | $taxonomies = get_object_taxonomies($post_type); |
| 2664 | 2664 | foreach ($taxonomies as $taxonomy) {
|
@@ -2667,9 +2667,9 @@ discard block |
||
| 2667 | 2667 | |
| 2668 | 2668 | if ($terms) {
|
| 2669 | 2669 | foreach ($terms as $term) {
|
| 2670 | - $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 2670 | + $tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
|
|
| 2671 | 2671 | |
| 2672 | - if (!is_null($tr_id)){
|
|
| 2672 | + if (!is_null($tr_id)) {
|
|
| 2673 | 2673 | // not using get_term - unfiltered get_term |
| 2674 | 2674 | $translated_term = $wpdb->get_row($wpdb->prepare("
|
| 2675 | 2675 | SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
|
@@ -2678,14 +2678,14 @@ discard block |
||
| 2678 | 2678 | } |
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | - if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 2682 | - $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 2681 | + if (!is_taxonomy_hierarchical($taxonomy)) {
|
|
| 2682 | + $terms_array = array_unique(array_map('intval', $terms_array));
|
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
| 2686 | 2686 | |
| 2687 | - if ($taxonomy == $post_type . 'category') {
|
|
| 2688 | - geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
| 2687 | + if ($taxonomy == $post_type.'category') {
|
|
| 2688 | + geodir_set_postcat_structure($tr_post_id, $post_type.'category'); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | } |
| 2691 | 2691 | } |
@@ -2706,15 +2706,15 @@ discard block |
||
| 2706 | 2706 | function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
|
| 2707 | 2707 | global $wpdb; |
| 2708 | 2708 | |
| 2709 | - $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 2709 | + $query = $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 2710 | 2710 | $wpdb->query($query); |
| 2711 | 2711 | |
| 2712 | - $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 2712 | + $query = $wpdb->prepare("SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 2713 | 2713 | $post_images = $wpdb->get_results($query); |
| 2714 | 2714 | |
| 2715 | - if ( !empty( $post_images ) ) {
|
|
| 2716 | - foreach ( $post_images as $post_image) {
|
|
| 2717 | - $image_data = (array)$post_image; |
|
| 2715 | + if (!empty($post_images)) {
|
|
| 2716 | + foreach ($post_images as $post_image) {
|
|
| 2717 | + $image_data = (array) $post_image; |
|
| 2718 | 2718 | unset($image_data['ID']); |
| 2719 | 2719 | $image_data['post_id'] = $tr_post_id; |
| 2720 | 2720 | |
@@ -2747,13 +2747,13 @@ discard block |
||
| 2747 | 2747 | function geodir_wpml_duplicate_post_review($master_comment_id, $master_post_id, $tr_post_id, $lang) {
|
| 2748 | 2748 | global $wpdb, $plugin_prefix, $sitepress; |
| 2749 | 2749 | |
| 2750 | - $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A);
|
|
| 2750 | + $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A);
|
|
| 2751 | 2751 | |
| 2752 | 2752 | if (empty($review)) {
|
| 2753 | 2753 | return false; |
| 2754 | 2754 | } |
| 2755 | 2755 | if ($review['post_id'] != $master_post_id) {
|
| 2756 | - $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id));
|
|
| 2756 | + $wpdb->query($wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id));
|
|
| 2757 | 2757 | geodir_update_postrating($master_post_id, $post_type); |
| 2758 | 2758 | } |
| 2759 | 2759 | |
@@ -2764,9 +2764,9 @@ discard block |
||
| 2764 | 2764 | } |
| 2765 | 2765 | |
| 2766 | 2766 | $post_type = get_post_type($master_post_id); |
| 2767 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 2767 | + $post_table = $plugin_prefix.$post_type.'_detail'; |
|
| 2768 | 2768 | |
| 2769 | - $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM " . $post_table . " WHERE post_id = %d", $tr_post_id), ARRAY_A);
|
|
| 2769 | + $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM ".$post_table." WHERE post_id = %d", $tr_post_id), ARRAY_A);
|
|
| 2770 | 2770 | if (empty($translated_post)) {
|
| 2771 | 2771 | return false; |
| 2772 | 2772 | } |
@@ -2784,7 +2784,7 @@ discard block |
||
| 2784 | 2784 | unset($review['id']); |
| 2785 | 2785 | } |
| 2786 | 2786 | |
| 2787 | - $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id));
|
|
| 2787 | + $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM ".GEODIR_REVIEW_TABLE." WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id));
|
|
| 2788 | 2788 | |
| 2789 | 2789 | if ($tr_review_id) { // update review
|
| 2790 | 2790 | $wpdb->update(GEODIR_REVIEW_TABLE, $review, array('id' => $tr_review_id));
|
@@ -2797,8 +2797,8 @@ discard block |
||
| 2797 | 2797 | geodir_update_postrating($tr_post_id, $post_type); |
| 2798 | 2798 | |
| 2799 | 2799 | if (defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_review') && $sitepress->get_setting('sync_comments_on_duplicates')) {
|
| 2800 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id = %d", array($tr_comment_id)));
|
|
| 2801 | - $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A);
|
|
| 2800 | + $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_COMMENTS_REVIEWS_TABLE." WHERE comment_id = %d", array($tr_comment_id)));
|
|
| 2801 | + $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_COMMENTS_REVIEWS_TABLE." WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A);
|
|
| 2802 | 2802 | |
| 2803 | 2803 | if (!empty($likes)) {
|
| 2804 | 2804 | foreach ($likes as $like) {
|
@@ -2900,7 +2900,7 @@ discard block |
||
| 2900 | 2900 | * @return bool True if review star disabled, otherwise false. |
| 2901 | 2901 | */ |
| 2902 | 2902 | function geodir_rating_disabled_post_types() {
|
| 2903 | - $post_types = get_option( 'geodir_disable_rating_cpt' ); |
|
| 2903 | + $post_types = get_option('geodir_disable_rating_cpt');
|
|
| 2904 | 2904 | |
| 2905 | 2905 | /** |
| 2906 | 2906 | * Filter the post types array which have rating disabled. |
@@ -2909,7 +2909,7 @@ discard block |
||
| 2909 | 2909 | * |
| 2910 | 2910 | * @param array $post_types Array of post types which have rating starts disabled. |
| 2911 | 2911 | */ |
| 2912 | - return apply_filters( 'geodir_rating_disabled_post_types', $post_types ); |
|
| 2912 | + return apply_filters('geodir_rating_disabled_post_types', $post_types);
|
|
| 2913 | 2913 | } |
| 2914 | 2914 | |
| 2915 | 2915 | /** |
@@ -2921,30 +2921,30 @@ discard block |
||
| 2921 | 2921 | * @param bool $taxonomy Whether $post_type is taxonomy or not. |
| 2922 | 2922 | * @return bool True if review star disabled, otherwise false. |
| 2923 | 2923 | */ |
| 2924 | -function geodir_cpt_has_rating_disabled( $post_type = '', $taxonomy = false ) {
|
|
| 2924 | +function geodir_cpt_has_rating_disabled($post_type = '', $taxonomy = false) {
|
|
| 2925 | 2925 | $post_types = geodir_rating_disabled_post_types(); |
| 2926 | 2926 | |
| 2927 | - if ( empty( $post_types ) ) {
|
|
| 2927 | + if (empty($post_types)) {
|
|
| 2928 | 2928 | return false; |
| 2929 | 2929 | } |
| 2930 | 2930 | |
| 2931 | - if ( is_int( $post_type ) ) {
|
|
| 2932 | - $post_type = get_post_type( $post_type ); |
|
| 2931 | + if (is_int($post_type)) {
|
|
| 2932 | + $post_type = get_post_type($post_type); |
|
| 2933 | 2933 | } |
| 2934 | 2934 | |
| 2935 | - if ( $taxonomy && !empty( $post_types ) ) {
|
|
| 2935 | + if ($taxonomy && !empty($post_types)) {
|
|
| 2936 | 2936 | $posttypes = array(); |
| 2937 | 2937 | |
| 2938 | - foreach ( $post_types as $posttype ) {
|
|
| 2939 | - $posttypes[] = $posttype . 'category'; |
|
| 2940 | - $posttypes[] = $posttype . '_tags'; |
|
| 2938 | + foreach ($post_types as $posttype) {
|
|
| 2939 | + $posttypes[] = $posttype.'category'; |
|
| 2940 | + $posttypes[] = $posttype.'_tags'; |
|
| 2941 | 2941 | } |
| 2942 | 2942 | |
| 2943 | 2943 | $post_types = $posttypes; |
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | 2946 | $return = false; |
| 2947 | - if ( $post_type != '' && !empty( $post_types ) && in_array( $post_type, $post_types ) ) {
|
|
| 2947 | + if ($post_type != '' && !empty($post_types) && in_array($post_type, $post_types)) {
|
|
| 2948 | 2948 | $return = true; |
| 2949 | 2949 | } |
| 2950 | 2950 | |
@@ -2959,5 +2959,5 @@ discard block |
||
| 2959 | 2959 | * @return bool True if Yoast SEO disabled on GD pages. |
| 2960 | 2960 | */ |
| 2961 | 2961 | function geodir_disable_yoast_seo_metas() {
|
| 2962 | - return (bool)get_option( 'geodir_disable_yoast_meta' ); |
|
| 2962 | + return (bool) get_option('geodir_disable_yoast_meta');
|
|
| 2963 | 2963 | } |
| 2964 | 2964 | \ No newline at end of file |
@@ -20,492 +20,492 @@ discard block |
||
| 20 | 20 | function geodir_set_postcat_structure($post_id, $taxonomy, $default_cat = '', $category_str = '') |
| 21 | 21 | {
|
| 22 | 22 | |
| 23 | - $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
|
| 24 | - if (!empty($post_cat_ids)) |
|
| 25 | - $post_cat_array = explode(",", trim($post_cat_ids, ","));
|
|
| 26 | - |
|
| 27 | - if (!isset($default_cat) || empty($default_cat)) {
|
|
| 28 | - $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
|
| 29 | - }else{
|
|
| 30 | - if(!is_int($default_cat)){
|
|
| 31 | - $category = get_term_by('name', $default_cat, $taxonomy);
|
|
| 32 | - if(isset($category->term_id)){
|
|
| 33 | - $default_cat = $category->term_id; |
|
| 34 | - } |
|
| 35 | - } |
|
| 23 | + $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
|
| 24 | + if (!empty($post_cat_ids)) |
|
| 25 | + $post_cat_array = explode(",", trim($post_cat_ids, ","));
|
|
| 26 | + |
|
| 27 | + if (!isset($default_cat) || empty($default_cat)) {
|
|
| 28 | + $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
|
| 29 | + }else{
|
|
| 30 | + if(!is_int($default_cat)){
|
|
| 31 | + $category = get_term_by('name', $default_cat, $taxonomy);
|
|
| 32 | + if(isset($category->term_id)){
|
|
| 33 | + $default_cat = $category->term_id; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - geodir_save_post_meta($post_id, 'default_category', $default_cat); |
|
| 40 | + geodir_save_post_meta($post_id, 'default_category', $default_cat); |
|
| 41 | 41 | |
| 42 | - if (isset($category_str) && empty($category_str)) {
|
|
| 42 | + if (isset($category_str) && empty($category_str)) {
|
|
| 43 | 43 | |
| 44 | - $post_cat_str = ''; |
|
| 45 | - $post_categories = array(); |
|
| 46 | - if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
|
|
| 47 | - $post_cat_str = implode(",y:#", $post_cat_array);
|
|
| 48 | - $post_cat_str .= ",y:"; |
|
| 49 | - $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
|
|
| 50 | - } |
|
| 51 | - $post_categories[$taxonomy] = $post_cat_str; |
|
| 52 | - $category_str = $post_categories; |
|
| 53 | - } |
|
| 44 | + $post_cat_str = ''; |
|
| 45 | + $post_categories = array(); |
|
| 46 | + if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
|
|
| 47 | + $post_cat_str = implode(",y:#", $post_cat_array);
|
|
| 48 | + $post_cat_str .= ",y:"; |
|
| 49 | + $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
|
|
| 50 | + } |
|
| 51 | + $post_categories[$taxonomy] = $post_cat_str; |
|
| 52 | + $category_str = $post_categories; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - $change_cat_str = $category_str[$taxonomy]; |
|
| 55 | + $change_cat_str = $category_str[$taxonomy]; |
|
| 56 | 56 | |
| 57 | - $default_pos = strpos($change_cat_str, 'd:'); |
|
| 57 | + $default_pos = strpos($change_cat_str, 'd:'); |
|
| 58 | 58 | |
| 59 | - if ($default_pos === false) {
|
|
| 59 | + if ($default_pos === false) {
|
|
| 60 | 60 | |
| 61 | - $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
| 61 | + $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
| 62 | 62 | |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $category_str[$taxonomy] = $change_cat_str; |
|
| 65 | + $category_str[$taxonomy] = $change_cat_str; |
|
| 66 | 66 | |
| 67 | - update_post_meta($post_id, 'post_categories', $category_str); |
|
| 67 | + update_post_meta($post_id, 'post_categories', $category_str); |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | if (!function_exists('geodir_save_listing')) {
|
| 73 | - /** |
|
| 74 | - * Saves listing in the database using given information. |
|
| 75 | - * |
|
| 76 | - * @since 1.0.0 |
|
| 77 | - * @since 1.5.4 New parameter $wp_error added. |
|
| 78 | - * @since 1.6.18 Admin use only date field should not lost value if saved by user - FIXED |
|
| 79 | - * @package GeoDirectory |
|
| 80 | - * @global object $wpdb WordPress Database object. |
|
| 81 | - * @global object $post The current post object. |
|
| 82 | - * @global object $current_user Current user object. |
|
| 83 | - * @global object $gd_session GeoDirectory Session object. |
|
| 84 | - * @param array $request_info {
|
|
| 85 | - * Array of request info arguments. |
|
| 86 | - * |
|
| 87 | - * @type string $action Ajax action name. |
|
| 88 | - * @type string $geodir_ajax Ajax type. |
|
| 89 | - * @type string $ajax_action Ajax action. |
|
| 90 | - * @type string $listing_type Listing type. |
|
| 91 | - * @type string $pid Default Post ID. |
|
| 92 | - * @type string $preview Todo Desc needed. |
|
| 93 | - * @type string $add_listing_page_id Add listing page ID. |
|
| 94 | - * @type string $post_title Listing title. |
|
| 95 | - * @type string $post_desc Listing Description. |
|
| 96 | - * @type string $post_tags Listing tags. |
|
| 97 | - * @type array $cat_limit Category limit. |
|
| 98 | - * @type array $post_category Category IDs. |
|
| 99 | - * @type array $post_category_str Category string. |
|
| 100 | - * @type string $post_default_category Default category ID. |
|
| 101 | - * @type string $post_address Listing address. |
|
| 102 | - * @type string $geodir_location_add_listing_country_val Add listing country value. |
|
| 103 | - * @type string $post_country Listing country. |
|
| 104 | - * @type string $geodir_location_add_listing_region_val Add listing region value. |
|
| 105 | - * @type string $post_region Listing region. |
|
| 106 | - * @type string $geodir_location_add_listing_city_val Add listing city value. |
|
| 107 | - * @type string $post_city Listing city. |
|
| 108 | - * @type string $post_zip Listing zip. |
|
| 109 | - * @type string $post_latitude Listing latitude. |
|
| 110 | - * @type string $post_longitude Listing longitude. |
|
| 111 | - * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 112 | - * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 113 | - * @type string $geodir_timing Business timing info. |
|
| 114 | - * @type string $geodir_contact Contact number. |
|
| 115 | - * @type string $geodir_email Business contact email. |
|
| 116 | - * @type string $geodir_website Business website. |
|
| 117 | - * @type string $geodir_twitter Twitter link. |
|
| 118 | - * @type string $geodir_facebook Facebook link. |
|
| 119 | - * @type string $geodir_video Video link. |
|
| 120 | - * @type string $geodir_special_offers Special offers. |
|
| 121 | - * @type string $post_images Post image urls. |
|
| 122 | - * @type string $post_imagesimage_limit Post images limit. |
|
| 123 | - * @type string $post_imagestotImg Todo Desc needed. |
|
| 124 | - * @type string $geodir_accept_term_condition Has accepted terms and conditions?. |
|
| 125 | - * @type string $geodir_spamblocker Todo Desc needed. |
|
| 126 | - * @type string $geodir_filled_by_spam_bot Todo Desc needed. |
|
| 127 | - * |
|
| 128 | - * } |
|
| 129 | - * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 130 | - * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. |
|
| 131 | - * @return int|string|WP_Error Created post id or WP_Error on failure. |
|
| 132 | - */ |
|
| 133 | - function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false) |
|
| 134 | - {
|
|
| 135 | - global $wpdb, $current_user, $gd_session; |
|
| 136 | - |
|
| 137 | - $last_post_id = ''; |
|
| 138 | - |
|
| 139 | - if ($gd_session->get('listing') && !$dummy) {
|
|
| 140 | - $request_info = array(); |
|
| 141 | - $request_session = $gd_session->get('listing');
|
|
| 142 | - $request_info = array_merge($_REQUEST, $request_session); |
|
| 143 | - } else if (!$gd_session->get('listing') && !$dummy) {
|
|
| 144 | - global $post; |
|
| 73 | + /** |
|
| 74 | + * Saves listing in the database using given information. |
|
| 75 | + * |
|
| 76 | + * @since 1.0.0 |
|
| 77 | + * @since 1.5.4 New parameter $wp_error added. |
|
| 78 | + * @since 1.6.18 Admin use only date field should not lost value if saved by user - FIXED |
|
| 79 | + * @package GeoDirectory |
|
| 80 | + * @global object $wpdb WordPress Database object. |
|
| 81 | + * @global object $post The current post object. |
|
| 82 | + * @global object $current_user Current user object. |
|
| 83 | + * @global object $gd_session GeoDirectory Session object. |
|
| 84 | + * @param array $request_info {
|
|
| 85 | + * Array of request info arguments. |
|
| 86 | + * |
|
| 87 | + * @type string $action Ajax action name. |
|
| 88 | + * @type string $geodir_ajax Ajax type. |
|
| 89 | + * @type string $ajax_action Ajax action. |
|
| 90 | + * @type string $listing_type Listing type. |
|
| 91 | + * @type string $pid Default Post ID. |
|
| 92 | + * @type string $preview Todo Desc needed. |
|
| 93 | + * @type string $add_listing_page_id Add listing page ID. |
|
| 94 | + * @type string $post_title Listing title. |
|
| 95 | + * @type string $post_desc Listing Description. |
|
| 96 | + * @type string $post_tags Listing tags. |
|
| 97 | + * @type array $cat_limit Category limit. |
|
| 98 | + * @type array $post_category Category IDs. |
|
| 99 | + * @type array $post_category_str Category string. |
|
| 100 | + * @type string $post_default_category Default category ID. |
|
| 101 | + * @type string $post_address Listing address. |
|
| 102 | + * @type string $geodir_location_add_listing_country_val Add listing country value. |
|
| 103 | + * @type string $post_country Listing country. |
|
| 104 | + * @type string $geodir_location_add_listing_region_val Add listing region value. |
|
| 105 | + * @type string $post_region Listing region. |
|
| 106 | + * @type string $geodir_location_add_listing_city_val Add listing city value. |
|
| 107 | + * @type string $post_city Listing city. |
|
| 108 | + * @type string $post_zip Listing zip. |
|
| 109 | + * @type string $post_latitude Listing latitude. |
|
| 110 | + * @type string $post_longitude Listing longitude. |
|
| 111 | + * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 112 | + * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 113 | + * @type string $geodir_timing Business timing info. |
|
| 114 | + * @type string $geodir_contact Contact number. |
|
| 115 | + * @type string $geodir_email Business contact email. |
|
| 116 | + * @type string $geodir_website Business website. |
|
| 117 | + * @type string $geodir_twitter Twitter link. |
|
| 118 | + * @type string $geodir_facebook Facebook link. |
|
| 119 | + * @type string $geodir_video Video link. |
|
| 120 | + * @type string $geodir_special_offers Special offers. |
|
| 121 | + * @type string $post_images Post image urls. |
|
| 122 | + * @type string $post_imagesimage_limit Post images limit. |
|
| 123 | + * @type string $post_imagestotImg Todo Desc needed. |
|
| 124 | + * @type string $geodir_accept_term_condition Has accepted terms and conditions?. |
|
| 125 | + * @type string $geodir_spamblocker Todo Desc needed. |
|
| 126 | + * @type string $geodir_filled_by_spam_bot Todo Desc needed. |
|
| 127 | + * |
|
| 128 | + * } |
|
| 129 | + * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 130 | + * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. |
|
| 131 | + * @return int|string|WP_Error Created post id or WP_Error on failure. |
|
| 132 | + */ |
|
| 133 | + function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false) |
|
| 134 | + {
|
|
| 135 | + global $wpdb, $current_user, $gd_session; |
|
| 136 | + |
|
| 137 | + $last_post_id = ''; |
|
| 138 | + |
|
| 139 | + if ($gd_session->get('listing') && !$dummy) {
|
|
| 140 | + $request_info = array(); |
|
| 141 | + $request_session = $gd_session->get('listing');
|
|
| 142 | + $request_info = array_merge($_REQUEST, $request_session); |
|
| 143 | + } else if (!$gd_session->get('listing') && !$dummy) {
|
|
| 144 | + global $post; |
|
| 145 | 145 | |
| 146 | - $gd_post = $post; |
|
| 147 | - if (!empty($gd_post) && is_array($gd_post)) {
|
|
| 148 | - $gd_post = (object)$post; |
|
| 146 | + $gd_post = $post; |
|
| 147 | + if (!empty($gd_post) && is_array($gd_post)) {
|
|
| 148 | + $gd_post = (object)$post; |
|
| 149 | 149 | |
| 150 | - // Fix WPML duplicate. |
|
| 151 | - if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
|
|
| 152 | - return false; |
|
| 153 | - } |
|
| 154 | - } |
|
| 150 | + // Fix WPML duplicate. |
|
| 151 | + if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
|
|
| 152 | + return false; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - $request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL); |
|
| 157 | - $request_info['post_title'] = $request_info['post_title']; |
|
| 158 | - $request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid'])); |
|
| 159 | - $request_info['post_desc'] = $request_info['content']; |
|
| 160 | - } else if (!$dummy) {
|
|
| 161 | - return false; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Filter the request_info array. |
|
| 166 | - * |
|
| 167 | - * You can use this filter to modify request_info array. |
|
| 168 | - * |
|
| 169 | - * @since 1.0.0 |
|
| 170 | - * @package GeoDirectory |
|
| 171 | - * @param array $request_info See {@see geodir_save_listing()} for accepted args.
|
|
| 172 | - */ |
|
| 173 | - $request_info = apply_filters('geodir_action_get_request_info', $request_info);
|
|
| 174 | - |
|
| 175 | - // Check if we need to save post location as new location |
|
| 176 | - $location_result = geodir_get_default_location(); |
|
| 177 | - |
|
| 178 | - if ($location_result->location_id > 0) {
|
|
| 179 | - if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
|
|
| 180 | - $request_info['post_location'] = array( |
|
| 181 | - 'city' => $request_info['post_city'], |
|
| 182 | - 'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '', |
|
| 183 | - 'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '', |
|
| 184 | - 'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '', |
|
| 185 | - 'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : '' |
|
| 186 | - ); |
|
| 187 | - |
|
| 188 | - $post_location_info = $request_info['post_location']; |
|
| 189 | - |
|
| 190 | - if ($location_id = geodir_add_new_location($post_location_info)) {
|
|
| 191 | - $post_location_id = $location_id; |
|
| 192 | - } |
|
| 193 | - } else {
|
|
| 194 | - $post_location_id = $location_result->location_id; |
|
| 195 | - } |
|
| 196 | - } else {
|
|
| 197 | - $post_location_id = $location_result->location_id; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if ($dummy) {
|
|
| 201 | - $post_status = 'publish'; |
|
| 202 | - } else {
|
|
| 203 | - $post_status = geodir_new_post_default_status(); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 207 | - $post_status = get_post_status($request_info['pid']); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /* fix change of slug on every title edit */ |
|
| 211 | - if (!isset($request_info['post_name'])) {
|
|
| 212 | - $request_info['post_name'] = $request_info['post_title']; |
|
| 213 | - |
|
| 214 | - if (!empty($request_info['pid'])) {
|
|
| 215 | - $post_info = get_post($request_info['pid']); |
|
| 216 | - |
|
| 217 | - if (!empty($post_info) && isset($post_info->post_name)) {
|
|
| 218 | - $request_info['post_name'] = $post_info->post_name; |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - $post = array( |
|
| 224 | - 'post_content' => $request_info['post_desc'], |
|
| 225 | - 'post_status' => $post_status, |
|
| 226 | - 'post_title' => $request_info['post_title'], |
|
| 227 | - 'post_name' => $request_info['post_name'], |
|
| 228 | - 'post_type' => $request_info['listing_type'] |
|
| 229 | - ); |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Called before a listing is saved to the database. |
|
| 233 | - * |
|
| 234 | - * @since 1.0.0 |
|
| 235 | - * @param object $post The post object. |
|
| 236 | - */ |
|
| 237 | - do_action_ref_array('geodir_before_save_listing', $post);
|
|
| 156 | + $request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL); |
|
| 157 | + $request_info['post_title'] = $request_info['post_title']; |
|
| 158 | + $request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid'])); |
|
| 159 | + $request_info['post_desc'] = $request_info['content']; |
|
| 160 | + } else if (!$dummy) {
|
|
| 161 | + return false; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Filter the request_info array. |
|
| 166 | + * |
|
| 167 | + * You can use this filter to modify request_info array. |
|
| 168 | + * |
|
| 169 | + * @since 1.0.0 |
|
| 170 | + * @package GeoDirectory |
|
| 171 | + * @param array $request_info See {@see geodir_save_listing()} for accepted args.
|
|
| 172 | + */ |
|
| 173 | + $request_info = apply_filters('geodir_action_get_request_info', $request_info);
|
|
| 174 | + |
|
| 175 | + // Check if we need to save post location as new location |
|
| 176 | + $location_result = geodir_get_default_location(); |
|
| 177 | + |
|
| 178 | + if ($location_result->location_id > 0) {
|
|
| 179 | + if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
|
|
| 180 | + $request_info['post_location'] = array( |
|
| 181 | + 'city' => $request_info['post_city'], |
|
| 182 | + 'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '', |
|
| 183 | + 'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '', |
|
| 184 | + 'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '', |
|
| 185 | + 'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : '' |
|
| 186 | + ); |
|
| 187 | + |
|
| 188 | + $post_location_info = $request_info['post_location']; |
|
| 189 | + |
|
| 190 | + if ($location_id = geodir_add_new_location($post_location_info)) {
|
|
| 191 | + $post_location_id = $location_id; |
|
| 192 | + } |
|
| 193 | + } else {
|
|
| 194 | + $post_location_id = $location_result->location_id; |
|
| 195 | + } |
|
| 196 | + } else {
|
|
| 197 | + $post_location_id = $location_result->location_id; |
|
| 198 | + } |
|
| 238 | 199 | |
| 239 | - $send_post_submit_mail = false; |
|
| 200 | + if ($dummy) {
|
|
| 201 | + $post_status = 'publish'; |
|
| 202 | + } else {
|
|
| 203 | + $post_status = geodir_new_post_default_status(); |
|
| 204 | + } |
|
| 240 | 205 | |
| 241 | - // unhook this function so it doesn't loop infinitely |
|
| 242 | - remove_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 206 | + if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 207 | + $post_status = get_post_status($request_info['pid']); |
|
| 208 | + } |
|
| 243 | 209 | |
| 244 | - if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 245 | - $post['ID'] = $request_info['pid']; |
|
| 210 | + /* fix change of slug on every title edit */ |
|
| 211 | + if (!isset($request_info['post_name'])) {
|
|
| 212 | + $request_info['post_name'] = $request_info['post_title']; |
|
| 246 | 213 | |
| 247 | - $last_post_id = wp_update_post($post, $wp_error); |
|
| 248 | - } else {
|
|
| 249 | - $last_post_id = wp_insert_post($post, $wp_error); |
|
| 214 | + if (!empty($request_info['pid'])) {
|
|
| 215 | + $post_info = get_post($request_info['pid']); |
|
| 250 | 216 | |
| 251 | - if (!$dummy && $last_post_id) {
|
|
| 252 | - $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email) |
|
| 253 | - //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
|
|
| 254 | - } |
|
| 255 | - } |
|
| 217 | + if (!empty($post_info) && isset($post_info->post_name)) {
|
|
| 218 | + $request_info['post_name'] = $post_info->post_name; |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + $post = array( |
|
| 224 | + 'post_content' => $request_info['post_desc'], |
|
| 225 | + 'post_status' => $post_status, |
|
| 226 | + 'post_title' => $request_info['post_title'], |
|
| 227 | + 'post_name' => $request_info['post_name'], |
|
| 228 | + 'post_type' => $request_info['listing_type'] |
|
| 229 | + ); |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Called before a listing is saved to the database. |
|
| 233 | + * |
|
| 234 | + * @since 1.0.0 |
|
| 235 | + * @param object $post The post object. |
|
| 236 | + */ |
|
| 237 | + do_action_ref_array('geodir_before_save_listing', $post);
|
|
| 238 | + |
|
| 239 | + $send_post_submit_mail = false; |
|
| 240 | + |
|
| 241 | + // unhook this function so it doesn't loop infinitely |
|
| 242 | + remove_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 243 | + |
|
| 244 | + if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 245 | + $post['ID'] = $request_info['pid']; |
|
| 246 | + |
|
| 247 | + $last_post_id = wp_update_post($post, $wp_error); |
|
| 248 | + } else {
|
|
| 249 | + $last_post_id = wp_insert_post($post, $wp_error); |
|
| 250 | + |
|
| 251 | + if (!$dummy && $last_post_id) {
|
|
| 252 | + $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email) |
|
| 253 | + //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
|
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - if ($wp_error && is_wp_error($last_post_id)) {
|
|
| 258 | - return $last_post_id; // Return WP_Error on save failure. |
|
| 259 | - } |
|
| 257 | + if ($wp_error && is_wp_error($last_post_id)) {
|
|
| 258 | + return $last_post_id; // Return WP_Error on save failure. |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - if (!$last_post_id) {
|
|
| 262 | - return false; // Save failure. |
|
| 263 | - } |
|
| 261 | + if (!$last_post_id) {
|
|
| 262 | + return false; // Save failure. |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - // re-hook this function |
|
| 266 | - add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 265 | + // re-hook this function |
|
| 266 | + add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 267 | 267 | |
| 268 | - $post_tags = ''; |
|
| 269 | - if (!isset($request_info['post_tags'])) {
|
|
| 268 | + $post_tags = ''; |
|
| 269 | + if (!isset($request_info['post_tags'])) {
|
|
| 270 | 270 | |
| 271 | - $post_type = $request_info['listing_type']; |
|
| 272 | - $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
|
|
| 271 | + $post_type = $request_info['listing_type']; |
|
| 272 | + $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
|
|
| 273 | 273 | |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - $gd_post_info = array( |
|
| 277 | - "post_title" => $request_info['post_title'], |
|
| 278 | - "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags, |
|
| 279 | - "post_status" => $post_status, |
|
| 280 | - "post_location_id" => $post_location_id, |
|
| 281 | - "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '', |
|
| 282 | - "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '', |
|
| 283 | - "submit_time" => time(), |
|
| 284 | - "submit_ip" => $_SERVER['REMOTE_ADDR'], |
|
| 285 | - ); |
|
| 276 | + $gd_post_info = array( |
|
| 277 | + "post_title" => $request_info['post_title'], |
|
| 278 | + "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags, |
|
| 279 | + "post_status" => $post_status, |
|
| 280 | + "post_location_id" => $post_location_id, |
|
| 281 | + "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '', |
|
| 282 | + "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '', |
|
| 283 | + "submit_time" => time(), |
|
| 284 | + "submit_ip" => $_SERVER['REMOTE_ADDR'], |
|
| 285 | + ); |
|
| 286 | 286 | |
| 287 | - $payment_info = array(); |
|
| 288 | - $package_info = array(); |
|
| 287 | + $payment_info = array(); |
|
| 288 | + $package_info = array(); |
|
| 289 | 289 | |
| 290 | - $package_info = (array)geodir_post_package_info($package_info, $post); |
|
| 290 | + $package_info = (array)geodir_post_package_info($package_info, $post); |
|
| 291 | 291 | |
| 292 | - $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
|
| 292 | + $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
|
| 293 | 293 | |
| 294 | - if (!empty($package_info) && !$post_package_id) {
|
|
| 295 | - if (isset($package_info['days']) && $package_info['days'] != 0) {
|
|
| 296 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
|
|
| 297 | - } else {
|
|
| 298 | - $payment_info['expire_date'] = 'Never'; |
|
| 299 | - } |
|
| 294 | + if (!empty($package_info) && !$post_package_id) {
|
|
| 295 | + if (isset($package_info['days']) && $package_info['days'] != 0) {
|
|
| 296 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
|
|
| 297 | + } else {
|
|
| 298 | + $payment_info['expire_date'] = 'Never'; |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - $payment_info['package_id'] = $package_info['pid']; |
|
| 302 | - $payment_info['alive_days'] = $package_info['days']; |
|
| 303 | - $payment_info['is_featured'] = $package_info['is_featured']; |
|
| 301 | + $payment_info['package_id'] = $package_info['pid']; |
|
| 302 | + $payment_info['alive_days'] = $package_info['days']; |
|
| 303 | + $payment_info['is_featured'] = $package_info['is_featured']; |
|
| 304 | 304 | |
| 305 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 306 | - } |
|
| 305 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
|
|
| 308 | + $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
|
|
| 309 | 309 | |
| 310 | - foreach ($custom_metaboxes as $key => $val): |
|
| 310 | + foreach ($custom_metaboxes as $key => $val): |
|
| 311 | 311 | |
| 312 | - $name = $val['name']; |
|
| 313 | - $type = $val['type']; |
|
| 314 | - $extrafields = $val['extra_fields']; |
|
| 312 | + $name = $val['name']; |
|
| 313 | + $type = $val['type']; |
|
| 314 | + $extrafields = $val['extra_fields']; |
|
| 315 | 315 | |
| 316 | - if (trim($type) == 'address') {
|
|
| 317 | - $prefix = $name . '_'; |
|
| 318 | - $address = $prefix . 'address'; |
|
| 316 | + if (trim($type) == 'address') {
|
|
| 317 | + $prefix = $name . '_'; |
|
| 318 | + $address = $prefix . 'address'; |
|
| 319 | 319 | |
| 320 | - if (isset($request_info[$address]) && $request_info[$address] != '') {
|
|
| 321 | - $gd_post_info[$address] = wp_slash($request_info[$address]); |
|
| 322 | - } |
|
| 320 | + if (isset($request_info[$address]) && $request_info[$address] != '') {
|
|
| 321 | + $gd_post_info[$address] = wp_slash($request_info[$address]); |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - if ($extrafields != '') {
|
|
| 325 | - $extrafields = unserialize($extrafields); |
|
| 324 | + if ($extrafields != '') {
|
|
| 325 | + $extrafields = unserialize($extrafields); |
|
| 326 | 326 | |
| 327 | 327 | |
| 328 | - if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
|
|
| 328 | + if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
|
|
| 329 | 329 | |
| 330 | - $location_result = geodir_get_default_location(); |
|
| 330 | + $location_result = geodir_get_default_location(); |
|
| 331 | 331 | |
| 332 | - $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
| 333 | - $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
| 334 | - $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
| 332 | + $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
| 333 | + $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
| 334 | + $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
| 335 | 335 | |
| 336 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 336 | + $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 337 | 337 | |
| 338 | - } else {
|
|
| 338 | + } else {
|
|
| 339 | 339 | |
| 340 | - $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
| 341 | - $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
| 342 | - $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
| 340 | + $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
| 341 | + $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
| 342 | + $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
| 343 | 343 | |
| 344 | - //----------set post locations when import dummy data------- |
|
| 345 | - $location_result = geodir_get_default_location(); |
|
| 344 | + //----------set post locations when import dummy data------- |
|
| 345 | + $location_result = geodir_get_default_location(); |
|
| 346 | 346 | |
| 347 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 348 | - //----------------------------------------------------------------- |
|
| 347 | + $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 348 | + //----------------------------------------------------------------- |
|
| 349 | 349 | |
| 350 | - } |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | 352 | |
| 353 | - if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
|
|
| 354 | - $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
| 355 | - } |
|
| 353 | + if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
|
|
| 354 | + $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | 357 | |
| 358 | - if (isset($extrafields['show_map']) && $extrafields['show_map']) {
|
|
| 358 | + if (isset($extrafields['show_map']) && $extrafields['show_map']) {
|
|
| 359 | 359 | |
| 360 | - if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
|
|
| 361 | - $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
| 362 | - } |
|
| 360 | + if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
|
|
| 361 | + $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
|
|
| 365 | - $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
| 366 | - } |
|
| 364 | + if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
|
|
| 365 | + $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
|
|
| 369 | - $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
| 370 | - } |
|
| 368 | + if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
|
|
| 369 | + $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
|
|
| 373 | - $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
| 374 | - } |
|
| 372 | + if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
|
|
| 373 | + $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - } |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - // show lat lng |
|
| 379 | - if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
|
|
| 380 | - $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
| 381 | - } |
|
| 382 | - } |
|
| 378 | + // show lat lng |
|
| 379 | + if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
|
|
| 380 | + $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
| 381 | + } |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - } elseif (trim($type) == 'file') {
|
|
| 385 | - if (isset($request_info[$name])) {
|
|
| 386 | - $request_files = array(); |
|
| 387 | - if ($request_info[$name] != '') |
|
| 388 | - $request_files = explode(",", $request_info[$name]);
|
|
| 384 | + } elseif (trim($type) == 'file') {
|
|
| 385 | + if (isset($request_info[$name])) {
|
|
| 386 | + $request_files = array(); |
|
| 387 | + if ($request_info[$name] != '') |
|
| 388 | + $request_files = explode(",", $request_info[$name]);
|
|
| 389 | 389 | |
| 390 | - $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
|
| 391 | - geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
|
| 392 | - } |
|
| 393 | - } elseif (trim($type) == 'datepicker') {
|
|
| 394 | - if (isset($request_info[$name])) {
|
|
| 395 | - $datetime = ''; |
|
| 390 | + $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
|
| 391 | + geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
|
| 392 | + } |
|
| 393 | + } elseif (trim($type) == 'datepicker') {
|
|
| 394 | + if (isset($request_info[$name])) {
|
|
| 395 | + $datetime = ''; |
|
| 396 | 396 | |
| 397 | - if (!empty($request_info[$name])) {
|
|
| 398 | - $date_format = geodir_default_date_format(); |
|
| 399 | - if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
|
|
| 400 | - $extra_fields = unserialize($val['extra_fields']); |
|
| 401 | - $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // check if we need to change the format or not |
|
| 405 | - $date_format_len = strlen(str_replace(' ', '', $date_format));
|
|
| 406 | - if($date_format_len>5){// if greater then 5 then it's the old style format.
|
|
| 397 | + if (!empty($request_info[$name])) {
|
|
| 398 | + $date_format = geodir_default_date_format(); |
|
| 399 | + if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
|
|
| 400 | + $extra_fields = unserialize($val['extra_fields']); |
|
| 401 | + $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format; |
|
| 402 | + } |
|
| 407 | 403 | |
| 408 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 409 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 404 | + // check if we need to change the format or not |
|
| 405 | + $date_format_len = strlen(str_replace(' ', '', $date_format));
|
|
| 406 | + if($date_format_len>5){// if greater then 5 then it's the old style format.
|
|
| 410 | 407 | |
| 411 | - $date_format = str_replace($search, $replace, $date_format); |
|
| 408 | + $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 409 | + $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 412 | 410 | |
| 413 | - $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
|
|
| 411 | + $date_format = str_replace($search, $replace, $date_format); |
|
| 414 | 412 | |
| 415 | - }else{
|
|
| 416 | - $post_htmlvar_value = $request_info[$name]; |
|
| 417 | - } |
|
| 413 | + $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
|
|
| 418 | 414 | |
| 419 | - $post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d |
|
| 420 | - $datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated |
|
| 421 | - } |
|
| 415 | + }else{
|
|
| 416 | + $post_htmlvar_value = $request_info[$name]; |
|
| 417 | + } |
|
| 422 | 418 | |
| 423 | - $gd_post_info[$name] = $datetime; |
|
| 424 | - } |
|
| 425 | - } else if ($type == 'multiselect') {
|
|
| 426 | - if (isset($request_info[$name])) {
|
|
| 427 | - $gd_post_info[$name] = $request_info[$name]; |
|
| 428 | - } else {
|
|
| 429 | - if (isset($request_info['gd_field_' . $name])) {
|
|
| 430 | - $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - } else if (isset($request_info[$name])) {
|
|
| 434 | - $gd_post_info[$name] = $request_info[$name]; |
|
| 435 | - } |
|
| 419 | + $post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d |
|
| 420 | + $datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + $gd_post_info[$name] = $datetime; |
|
| 424 | + } |
|
| 425 | + } else if ($type == 'multiselect') {
|
|
| 426 | + if (isset($request_info[$name])) {
|
|
| 427 | + $gd_post_info[$name] = $request_info[$name]; |
|
| 428 | + } else {
|
|
| 429 | + if (isset($request_info['gd_field_' . $name])) {
|
|
| 430 | + $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + } else if (isset($request_info[$name])) {
|
|
| 434 | + $gd_post_info[$name] = $request_info[$name]; |
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | - endforeach; |
|
| 437 | + endforeach; |
|
| 438 | 438 | |
| 439 | - if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
|
|
| 440 | - $gd_post_info['post_dummy'] = $request_info['post_dummy']; |
|
| 441 | - } |
|
| 439 | + if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
|
|
| 440 | + $gd_post_info['post_dummy'] = $request_info['post_dummy']; |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | - // Save post detail info in detail table |
|
| 444 | - if (!empty($gd_post_info)) {
|
|
| 445 | - geodir_save_post_info($last_post_id, $gd_post_info); |
|
| 446 | - } |
|
| 443 | + // Save post detail info in detail table |
|
| 444 | + if (!empty($gd_post_info)) {
|
|
| 445 | + geodir_save_post_info($last_post_id, $gd_post_info); |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | 448 | |
| 449 | - // Set categories to the listing |
|
| 450 | - if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
|
|
| 451 | - $post_category = array(); |
|
| 449 | + // Set categories to the listing |
|
| 450 | + if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
|
|
| 451 | + $post_category = array(); |
|
| 452 | 452 | |
| 453 | - foreach ($request_info['post_category'] as $taxonomy => $cat) {
|
|
| 453 | + foreach ($request_info['post_category'] as $taxonomy => $cat) {
|
|
| 454 | 454 | |
| 455 | - if ($dummy) |
|
| 456 | - $post_category = $cat; |
|
| 457 | - else {
|
|
| 455 | + if ($dummy) |
|
| 456 | + $post_category = $cat; |
|
| 457 | + else {
|
|
| 458 | 458 | |
| 459 | - if (!is_array($cat) && strstr($cat, ',')) |
|
| 460 | - $cat = explode(',', $cat);
|
|
| 459 | + if (!is_array($cat) && strstr($cat, ',')) |
|
| 460 | + $cat = explode(',', $cat);
|
|
| 461 | 461 | |
| 462 | - if (!empty($cat) && is_array($cat)) |
|
| 463 | - $post_category = array_map('intval', $cat);
|
|
| 464 | - } |
|
| 462 | + if (!empty($cat) && is_array($cat)) |
|
| 463 | + $post_category = array_map('intval', $cat);
|
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | - wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
|
| 467 | - } |
|
| 466 | + wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : ''; |
|
| 469 | + $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : ''; |
|
| 470 | 470 | |
| 471 | - $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : ''; |
|
| 472 | - geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str); |
|
| 471 | + $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : ''; |
|
| 472 | + geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str); |
|
| 473 | 473 | |
| 474 | - } |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - $post_tags = ''; |
|
| 477 | - // Set tags to the listing |
|
| 478 | - if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
|
|
| 479 | - $post_tags = explode(",", $request_info['post_tags']);
|
|
| 480 | - } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
|
|
| 481 | - if ($dummy) |
|
| 482 | - $post_tags = $request_info['post_tags']; |
|
| 483 | - } else {
|
|
| 484 | - if ($dummy) |
|
| 485 | - $post_tags = array($request_info['post_title']); |
|
| 486 | - } |
|
| 476 | + $post_tags = ''; |
|
| 477 | + // Set tags to the listing |
|
| 478 | + if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
|
|
| 479 | + $post_tags = explode(",", $request_info['post_tags']);
|
|
| 480 | + } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
|
|
| 481 | + if ($dummy) |
|
| 482 | + $post_tags = $request_info['post_tags']; |
|
| 483 | + } else {
|
|
| 484 | + if ($dummy) |
|
| 485 | + $post_tags = array($request_info['post_title']); |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | - if (is_array($post_tags)) {
|
|
| 489 | - $taxonomy = $request_info['listing_type'] . '_tags'; |
|
| 490 | - wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
|
| 491 | - } |
|
| 488 | + if (is_array($post_tags)) {
|
|
| 489 | + $taxonomy = $request_info['listing_type'] . '_tags'; |
|
| 490 | + wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | 493 | |
| 494 | - // Insert attachment |
|
| 494 | + // Insert attachment |
|
| 495 | 495 | |
| 496 | - if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
|
|
| 497 | - if (!$dummy) {
|
|
| 498 | - $tmpimgArr = trim($request_info['post_images'], ","); |
|
| 499 | - $tmpimgArr = explode(",", $tmpimgArr);
|
|
| 500 | - geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
|
| 501 | - } else{
|
|
| 502 | - geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
|
| 503 | - } |
|
| 496 | + if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
|
|
| 497 | + if (!$dummy) {
|
|
| 498 | + $tmpimgArr = trim($request_info['post_images'], ","); |
|
| 499 | + $tmpimgArr = explode(",", $tmpimgArr);
|
|
| 500 | + geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
|
| 501 | + } else{
|
|
| 502 | + geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | 505 | |
| 506 | - } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
|
|
| 506 | + } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
|
|
| 507 | 507 | |
| 508 | - /* Delete Attachments |
|
| 508 | + /* Delete Attachments |
|
| 509 | 509 | $postcurr_images = geodir_get_images($last_post_id); |
| 510 | 510 | |
| 511 | 511 | $wpdb->query( |
@@ -521,34 +521,34 @@ discard block |
||
| 521 | 521 | geodir_save_post_info($last_post_id, $gd_post_featured_img); |
| 522 | 522 | */ |
| 523 | 523 | |
| 524 | - } |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - geodir_remove_temp_images(); |
|
| 527 | - geodir_set_wp_featured_image($last_post_id); |
|
| 526 | + geodir_remove_temp_images(); |
|
| 527 | + geodir_set_wp_featured_image($last_post_id); |
|
| 528 | 528 | |
| 529 | - /** |
|
| 530 | - * Called after a listing is saved to the database and before any email have been sent. |
|
| 531 | - * |
|
| 532 | - * @since 1.0.0 |
|
| 533 | - * @param int $last_post_id The saved post ID. |
|
| 534 | - * @param array $request_info The post details in an array. |
|
| 535 | - * @see 'geodir_after_save_listinginfo' |
|
| 536 | - */ |
|
| 537 | - do_action('geodir_after_save_listing', $last_post_id, $request_info);
|
|
| 529 | + /** |
|
| 530 | + * Called after a listing is saved to the database and before any email have been sent. |
|
| 531 | + * |
|
| 532 | + * @since 1.0.0 |
|
| 533 | + * @param int $last_post_id The saved post ID. |
|
| 534 | + * @param array $request_info The post details in an array. |
|
| 535 | + * @see 'geodir_after_save_listinginfo' |
|
| 536 | + */ |
|
| 537 | + do_action('geodir_after_save_listing', $last_post_id, $request_info);
|
|
| 538 | 538 | |
| 539 | - //die; |
|
| 539 | + //die; |
|
| 540 | 540 | |
| 541 | - if ($send_post_submit_mail) { // if new post send out email
|
|
| 542 | - $to_name = geodir_get_client_name($current_user->ID); |
|
| 543 | - geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
|
|
| 544 | - } |
|
| 545 | - /* |
|
| 541 | + if ($send_post_submit_mail) { // if new post send out email
|
|
| 542 | + $to_name = geodir_get_client_name($current_user->ID); |
|
| 543 | + geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
|
|
| 544 | + } |
|
| 545 | + /* |
|
| 546 | 546 | * Unset the session so we don't loop. |
| 547 | 547 | */ |
| 548 | - $gd_session->un_set('listing');
|
|
| 549 | - return $last_post_id; |
|
| 548 | + $gd_session->un_set('listing');
|
|
| 549 | + return $last_post_id; |
|
| 550 | 550 | |
| 551 | - } |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | 553 | } |
| 554 | 554 | |
@@ -567,599 +567,599 @@ discard block |
||
| 567 | 567 | function geodir_get_post_info($post_id = '') |
| 568 | 568 | {
|
| 569 | 569 | |
| 570 | - global $wpdb, $plugin_prefix, $post, $post_info; |
|
| 570 | + global $wpdb, $plugin_prefix, $post, $post_info; |
|
| 571 | 571 | |
| 572 | - if ($post_id == '' && !empty($post)) |
|
| 573 | - $post_id = $post->ID; |
|
| 572 | + if ($post_id == '' && !empty($post)) |
|
| 573 | + $post_id = $post->ID; |
|
| 574 | 574 | |
| 575 | - $post_type = get_post_type($post_id); |
|
| 575 | + $post_type = get_post_type($post_id); |
|
| 576 | 576 | |
| 577 | - $all_postypes = geodir_get_posttypes(); |
|
| 577 | + $all_postypes = geodir_get_posttypes(); |
|
| 578 | 578 | |
| 579 | - if (!in_array($post_type, $all_postypes)) |
|
| 580 | - return false; |
|
| 579 | + if (!in_array($post_type, $all_postypes)) |
|
| 580 | + return false; |
|
| 581 | 581 | |
| 582 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 582 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 583 | 583 | |
| 584 | - /** |
|
| 585 | - * Apply Filter to change Post info |
|
| 586 | - * |
|
| 587 | - * You can use this filter to change Post info. |
|
| 588 | - * |
|
| 589 | - * @since 1.0.0 |
|
| 590 | - * @package GeoDirectory |
|
| 591 | - */ |
|
| 592 | - $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
|
|
| 584 | + /** |
|
| 585 | + * Apply Filter to change Post info |
|
| 586 | + * |
|
| 587 | + * You can use this filter to change Post info. |
|
| 588 | + * |
|
| 589 | + * @since 1.0.0 |
|
| 590 | + * @package GeoDirectory |
|
| 591 | + */ |
|
| 592 | + $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
|
|
| 593 | 593 | WHERE p.ID = pd.post_id |
| 594 | 594 | AND pd.post_id = %d", $post_id)); |
| 595 | 595 | |
| 596 | - $post_detail = $wpdb->get_row($query); |
|
| 596 | + $post_detail = $wpdb->get_row($query); |
|
| 597 | 597 | |
| 598 | - return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false; |
|
| 598 | + return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false; |
|
| 599 | 599 | |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | |
| 603 | 603 | if (!function_exists('geodir_save_post_info')) {
|
| 604 | - /** |
|
| 605 | - * Saves post detail info in detail table. |
|
| 606 | - * |
|
| 607 | - * @since 1.0.0 |
|
| 608 | - * @package GeoDirectory |
|
| 609 | - * @global object $wpdb WordPress Database object. |
|
| 610 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 611 | - * @param int $post_id The post ID. |
|
| 612 | - * @param array $postinfo_array {
|
|
| 613 | - * Post info that needs to be saved in detail table. |
|
| 614 | - * |
|
| 615 | - * @type string $post_title Listing title. |
|
| 616 | - * @type string $post_tags Listing tags. |
|
| 617 | - * @type string $post_status Listing post status. |
|
| 618 | - * @type string $post_location_id Listing location ID. |
|
| 619 | - * @type string $claimed Todo Desc needed. |
|
| 620 | - * @type string $businesses Todo Desc needed. |
|
| 621 | - * @type int $submit_time Submitted time in unix timestamp. |
|
| 622 | - * @type string $submit_ip Submitted IP. |
|
| 623 | - * @type string $expire_date Listing expiration date. |
|
| 624 | - * @type int $package_id Listing package ID. |
|
| 625 | - * @type int $alive_days Todo Desc needed. |
|
| 626 | - * @type int $is_featured Is this a featured listing?. |
|
| 627 | - * @type string $post_address Listing address. |
|
| 628 | - * @type string $post_city Listing city. |
|
| 629 | - * @type string $post_region Listing region. |
|
| 630 | - * @type string $post_country Listing country. |
|
| 631 | - * @type string $post_locations Listing locations. |
|
| 632 | - * @type string $post_zip Listing zip. |
|
| 633 | - * @type string $post_latitude Listing latitude. |
|
| 634 | - * @type string $post_longitude Listing longitude. |
|
| 635 | - * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 636 | - * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 637 | - * @type string $geodir_timing Business timing info. |
|
| 638 | - * @type string $geodir_contact Contact number. |
|
| 639 | - * @type string $geodir_email Business contact email. |
|
| 640 | - * @type string $geodir_website Business website. |
|
| 641 | - * @type string $geodir_twitter Twitter link. |
|
| 642 | - * @type string $geodir_facebook Facebook link. |
|
| 643 | - * @type string $geodir_video Video link. |
|
| 644 | - * @type string $geodir_special_offers Special offers. |
|
| 645 | - * |
|
| 646 | - * } |
|
| 647 | - * @return bool |
|
| 648 | - */ |
|
| 649 | - function geodir_save_post_info($post_id, $postinfo_array = array()) |
|
| 650 | - {
|
|
| 651 | - global $wpdb, $plugin_prefix; |
|
| 652 | - |
|
| 653 | - $post_type = get_post_type($post_id); |
|
| 654 | - |
|
| 655 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 656 | - |
|
| 657 | - /** |
|
| 658 | - * Filter to change Post info |
|
| 659 | - * |
|
| 660 | - * You can use this filter to change Post info. |
|
| 661 | - * |
|
| 662 | - * @since 1.0.0 |
|
| 663 | - * @package GeoDirectory |
|
| 664 | - * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 665 | - * @param int $post_id The post ID. |
|
| 666 | - */ |
|
| 667 | - $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
|
|
| 604 | + /** |
|
| 605 | + * Saves post detail info in detail table. |
|
| 606 | + * |
|
| 607 | + * @since 1.0.0 |
|
| 608 | + * @package GeoDirectory |
|
| 609 | + * @global object $wpdb WordPress Database object. |
|
| 610 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 611 | + * @param int $post_id The post ID. |
|
| 612 | + * @param array $postinfo_array {
|
|
| 613 | + * Post info that needs to be saved in detail table. |
|
| 614 | + * |
|
| 615 | + * @type string $post_title Listing title. |
|
| 616 | + * @type string $post_tags Listing tags. |
|
| 617 | + * @type string $post_status Listing post status. |
|
| 618 | + * @type string $post_location_id Listing location ID. |
|
| 619 | + * @type string $claimed Todo Desc needed. |
|
| 620 | + * @type string $businesses Todo Desc needed. |
|
| 621 | + * @type int $submit_time Submitted time in unix timestamp. |
|
| 622 | + * @type string $submit_ip Submitted IP. |
|
| 623 | + * @type string $expire_date Listing expiration date. |
|
| 624 | + * @type int $package_id Listing package ID. |
|
| 625 | + * @type int $alive_days Todo Desc needed. |
|
| 626 | + * @type int $is_featured Is this a featured listing?. |
|
| 627 | + * @type string $post_address Listing address. |
|
| 628 | + * @type string $post_city Listing city. |
|
| 629 | + * @type string $post_region Listing region. |
|
| 630 | + * @type string $post_country Listing country. |
|
| 631 | + * @type string $post_locations Listing locations. |
|
| 632 | + * @type string $post_zip Listing zip. |
|
| 633 | + * @type string $post_latitude Listing latitude. |
|
| 634 | + * @type string $post_longitude Listing longitude. |
|
| 635 | + * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 636 | + * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 637 | + * @type string $geodir_timing Business timing info. |
|
| 638 | + * @type string $geodir_contact Contact number. |
|
| 639 | + * @type string $geodir_email Business contact email. |
|
| 640 | + * @type string $geodir_website Business website. |
|
| 641 | + * @type string $geodir_twitter Twitter link. |
|
| 642 | + * @type string $geodir_facebook Facebook link. |
|
| 643 | + * @type string $geodir_video Video link. |
|
| 644 | + * @type string $geodir_special_offers Special offers. |
|
| 645 | + * |
|
| 646 | + * } |
|
| 647 | + * @return bool |
|
| 648 | + */ |
|
| 649 | + function geodir_save_post_info($post_id, $postinfo_array = array()) |
|
| 650 | + {
|
|
| 651 | + global $wpdb, $plugin_prefix; |
|
| 652 | + |
|
| 653 | + $post_type = get_post_type($post_id); |
|
| 654 | + |
|
| 655 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 656 | + |
|
| 657 | + /** |
|
| 658 | + * Filter to change Post info |
|
| 659 | + * |
|
| 660 | + * You can use this filter to change Post info. |
|
| 661 | + * |
|
| 662 | + * @since 1.0.0 |
|
| 663 | + * @package GeoDirectory |
|
| 664 | + * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 665 | + * @param int $post_id The post ID. |
|
| 666 | + */ |
|
| 667 | + $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
|
|
| 668 | + |
|
| 669 | + $query_string_escaped = ''; |
|
| 670 | + $query_string_array = array(); |
|
| 671 | + |
|
| 672 | + if (!empty($postmeta) && $post_id) {
|
|
| 673 | + |
|
| 674 | + $columns = $wpdb->get_col("show columns from $table");
|
|
| 675 | + foreach ($postmeta as $mkey => $mval) {
|
|
| 676 | + if(in_array($mkey,$columns)) {
|
|
| 677 | + if (is_array($mval)) {
|
|
| 678 | + $mval = implode(",", $mval);
|
|
| 679 | + } |
|
| 680 | + $query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above |
|
| 681 | + $query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare |
|
| 668 | 682 | |
| 669 | - $query_string_escaped = ''; |
|
| 670 | - $query_string_array = array(); |
|
| 683 | + } |
|
| 684 | + } |
|
| 671 | 685 | |
| 672 | - if (!empty($postmeta) && $post_id) {
|
|
| 686 | + $query_string_escaped = trim($query_string_escaped, ", "); |
|
| 673 | 687 | |
| 674 | - $columns = $wpdb->get_col("show columns from $table");
|
|
| 675 | - foreach ($postmeta as $mkey => $mval) {
|
|
| 676 | - if(in_array($mkey,$columns)) {
|
|
| 677 | - if (is_array($mval)) {
|
|
| 678 | - $mval = implode(",", $mval);
|
|
| 679 | - } |
|
| 680 | - $query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above |
|
| 681 | - $query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare |
|
| 688 | + if (empty($query_string_array) || trim($query_string_escaped) == '') {
|
|
| 689 | + return false; |
|
| 690 | + } |
|
| 682 | 691 | |
| 683 | - } |
|
| 684 | - } |
|
| 692 | + $query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array);
|
|
| 685 | 693 | |
| 686 | - $query_string_escaped = trim($query_string_escaped, ", "); |
|
| 687 | 694 | |
| 688 | - if (empty($query_string_array) || trim($query_string_escaped) == '') {
|
|
| 689 | - return false; |
|
| 690 | - } |
|
| 695 | + /** |
|
| 696 | + * Called before saving the listing info. |
|
| 697 | + * |
|
| 698 | + * @since 1.0.0 |
|
| 699 | + * @package GeoDirectory |
|
| 700 | + * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 701 | + * @param int $post_id The post ID. |
|
| 702 | + */ |
|
| 703 | + do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
|
|
| 691 | 704 | |
| 692 | - $query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array);
|
|
| 705 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 693 | 706 | |
| 707 | + $query_string_array[] = $post_id; |
|
| 708 | + $wpdb->query( |
|
| 709 | + $wpdb->prepare( |
|
| 710 | + "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d", |
|
| 711 | + $query_string_array |
|
| 712 | + ) |
|
| 713 | + ); |
|
| 694 | 714 | |
| 695 | - /** |
|
| 696 | - * Called before saving the listing info. |
|
| 697 | - * |
|
| 698 | - * @since 1.0.0 |
|
| 699 | - * @package GeoDirectory |
|
| 700 | - * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 701 | - * @param int $post_id The post ID. |
|
| 702 | - */ |
|
| 703 | - do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
|
|
| 704 | 715 | |
| 705 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 716 | + } else {
|
|
| 706 | 717 | |
| 707 | - $query_string_array[] = $post_id; |
|
| 708 | - $wpdb->query( |
|
| 709 | - $wpdb->prepare( |
|
| 710 | - "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d", |
|
| 711 | - $query_string_array |
|
| 712 | - ) |
|
| 713 | - ); |
|
| 718 | + array_unshift($query_string_array, $post_id); |
|
| 719 | + $wpdb->query( |
|
| 720 | + $wpdb->prepare( |
|
| 721 | + "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped, |
|
| 722 | + $query_string_array |
|
| 723 | + ) |
|
| 724 | + ); |
|
| 725 | + |
|
| 726 | + } |
|
| 714 | 727 | |
| 728 | + /** |
|
| 729 | + * Called after saving the listing info. |
|
| 730 | + * |
|
| 731 | + * @since 1.0.0 |
|
| 732 | + * @package GeoDirectory |
|
| 733 | + * @param array $postinfo_array Post info that needs to be saved in detail table. |
|
| 734 | + * @param int $post_id The post ID. |
|
| 735 | + * @see 'geodir_after_save_listing' |
|
| 736 | + */ |
|
| 737 | + do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
|
|
| 738 | + |
|
| 739 | + return true; |
|
| 740 | + } else |
|
| 741 | + return false; |
|
| 715 | 742 | |
| 716 | - } else {
|
|
| 743 | + } |
|
| 744 | +} |
|
| 717 | 745 | |
| 718 | - array_unshift($query_string_array, $post_id); |
|
| 719 | - $wpdb->query( |
|
| 720 | - $wpdb->prepare( |
|
| 721 | - "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped, |
|
| 722 | - $query_string_array |
|
| 723 | - ) |
|
| 724 | - ); |
|
| 725 | - |
|
| 726 | - } |
|
| 727 | 746 | |
| 728 | - /** |
|
| 729 | - * Called after saving the listing info. |
|
| 730 | - * |
|
| 731 | - * @since 1.0.0 |
|
| 732 | - * @package GeoDirectory |
|
| 733 | - * @param array $postinfo_array Post info that needs to be saved in detail table. |
|
| 734 | - * @param int $post_id The post ID. |
|
| 735 | - * @see 'geodir_after_save_listing' |
|
| 736 | - */ |
|
| 737 | - do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
|
|
| 747 | +if (!function_exists('geodir_save_post_meta')) {
|
|
| 748 | + /** |
|
| 749 | + * Save or update post custom fields. |
|
| 750 | + * |
|
| 751 | + * @since 1.0.0 |
|
| 752 | + * @package GeoDirectory |
|
| 753 | + * @global object $wpdb WordPress Database object. |
|
| 754 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 755 | + * @param int $post_id The post ID. |
|
| 756 | + * @param string $postmeta Detail table column name. |
|
| 757 | + * @param string $meta_value Detail table column value. |
|
| 758 | + * @return void|bool |
|
| 759 | + */ |
|
| 760 | + function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '') |
|
| 761 | + {
|
|
| 762 | + |
|
| 763 | + global $wpdb, $plugin_prefix; |
|
| 764 | + |
|
| 765 | + $post_type = get_post_type($post_id); |
|
| 766 | + |
|
| 767 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 768 | + |
|
| 769 | + if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
|
|
| 770 | + |
|
| 771 | + if (is_array($meta_value)) {
|
|
| 772 | + $meta_value = implode(",", $meta_value);
|
|
| 773 | + } |
|
| 738 | 774 | |
| 739 | - return true; |
|
| 740 | - } else |
|
| 741 | - return false; |
|
| 775 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 742 | 776 | |
| 743 | - } |
|
| 744 | -} |
|
| 777 | + $wpdb->query( |
|
| 778 | + $wpdb->prepare( |
|
| 779 | + "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
| 780 | + array($post_id) |
|
| 781 | + ) |
|
| 782 | + ); |
|
| 745 | 783 | |
| 784 | + } else {
|
|
| 746 | 785 | |
| 747 | -if (!function_exists('geodir_save_post_meta')) {
|
|
| 748 | - /** |
|
| 749 | - * Save or update post custom fields. |
|
| 750 | - * |
|
| 751 | - * @since 1.0.0 |
|
| 752 | - * @package GeoDirectory |
|
| 753 | - * @global object $wpdb WordPress Database object. |
|
| 754 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 755 | - * @param int $post_id The post ID. |
|
| 756 | - * @param string $postmeta Detail table column name. |
|
| 757 | - * @param string $meta_value Detail table column value. |
|
| 758 | - * @return void|bool |
|
| 759 | - */ |
|
| 760 | - function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '') |
|
| 761 | - {
|
|
| 762 | - |
|
| 763 | - global $wpdb, $plugin_prefix; |
|
| 764 | - |
|
| 765 | - $post_type = get_post_type($post_id); |
|
| 766 | - |
|
| 767 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 768 | - |
|
| 769 | - if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
|
|
| 770 | - |
|
| 771 | - if (is_array($meta_value)) {
|
|
| 772 | - $meta_value = implode(",", $meta_value);
|
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 776 | - |
|
| 777 | - $wpdb->query( |
|
| 778 | - $wpdb->prepare( |
|
| 779 | - "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
| 780 | - array($post_id) |
|
| 781 | - ) |
|
| 782 | - ); |
|
| 783 | - |
|
| 784 | - } else {
|
|
| 785 | - |
|
| 786 | - $wpdb->query( |
|
| 787 | - $wpdb->prepare( |
|
| 788 | - "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
| 789 | - array($post_id) |
|
| 790 | - ) |
|
| 791 | - ); |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - |
|
| 795 | - } else |
|
| 796 | - return false; |
|
| 797 | - } |
|
| 786 | + $wpdb->query( |
|
| 787 | + $wpdb->prepare( |
|
| 788 | + "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
| 789 | + array($post_id) |
|
| 790 | + ) |
|
| 791 | + ); |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + |
|
| 795 | + } else |
|
| 796 | + return false; |
|
| 797 | + } |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | if (!function_exists('geodir_delete_post_meta')) {
|
| 801 | - /** |
|
| 802 | - * Delete post custom fields. |
|
| 803 | - * |
|
| 804 | - * @since 1.0.0 |
|
| 805 | - * @package GeoDirectory |
|
| 806 | - * @global object $wpdb WordPress Database object. |
|
| 807 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 808 | - * @param int $post_id The post ID. |
|
| 809 | - * @param string $postmeta Detail table column name. |
|
| 810 | - * @todo check if this is depreciated |
|
| 811 | - * @todo Fix unknown variable mval |
|
| 812 | - * @return bool |
|
| 813 | - */ |
|
| 814 | - function geodir_delete_post_meta($post_id, $postmeta) |
|
| 815 | - {
|
|
| 816 | - |
|
| 817 | - global $wpdb, $plugin_prefix; |
|
| 818 | - |
|
| 819 | - $post_type = get_post_type($post_id); |
|
| 820 | - |
|
| 821 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 822 | - |
|
| 823 | - if (is_array($postmeta) && !empty($postmeta) && $post_id) {
|
|
| 824 | - $post_meta_set_query = ''; |
|
| 825 | - |
|
| 826 | - foreach ($postmeta as $mkey) {
|
|
| 827 | - if ($mval != '') |
|
| 828 | - $post_meta_set_query .= $mkey . " = '', "; |
|
| 829 | - } |
|
| 830 | - |
|
| 831 | - $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
| 801 | + /** |
|
| 802 | + * Delete post custom fields. |
|
| 803 | + * |
|
| 804 | + * @since 1.0.0 |
|
| 805 | + * @package GeoDirectory |
|
| 806 | + * @global object $wpdb WordPress Database object. |
|
| 807 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 808 | + * @param int $post_id The post ID. |
|
| 809 | + * @param string $postmeta Detail table column name. |
|
| 810 | + * @todo check if this is depreciated |
|
| 811 | + * @todo Fix unknown variable mval |
|
| 812 | + * @return bool |
|
| 813 | + */ |
|
| 814 | + function geodir_delete_post_meta($post_id, $postmeta) |
|
| 815 | + {
|
|
| 816 | + |
|
| 817 | + global $wpdb, $plugin_prefix; |
|
| 818 | + |
|
| 819 | + $post_type = get_post_type($post_id); |
|
| 820 | + |
|
| 821 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 822 | + |
|
| 823 | + if (is_array($postmeta) && !empty($postmeta) && $post_id) {
|
|
| 824 | + $post_meta_set_query = ''; |
|
| 825 | + |
|
| 826 | + foreach ($postmeta as $mkey) {
|
|
| 827 | + if ($mval != '') |
|
| 828 | + $post_meta_set_query .= $mkey . " = '', "; |
|
| 829 | + } |
|
| 830 | + |
|
| 831 | + $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
| 832 | 832 | |
| 833 | - if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') {
|
|
| 834 | - return false; |
|
| 835 | - } |
|
| 836 | - |
|
| 837 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 838 | - |
|
| 839 | - $wpdb->query( |
|
| 840 | - $wpdb->prepare( |
|
| 841 | - "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
| 842 | - array($post_id) |
|
| 843 | - ) |
|
| 844 | - ); |
|
| 845 | - |
|
| 846 | - return true; |
|
| 847 | - } |
|
| 848 | - |
|
| 849 | - } elseif ($postmeta != '' && $post_id) {
|
|
| 850 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 851 | - |
|
| 852 | - $wpdb->query( |
|
| 853 | - $wpdb->prepare( |
|
| 854 | - "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
| 855 | - array($post_id) |
|
| 856 | - ) |
|
| 857 | - ); |
|
| 858 | - |
|
| 859 | - return true; |
|
| 860 | - } |
|
| 861 | - |
|
| 862 | - } else |
|
| 863 | - return false; |
|
| 864 | - } |
|
| 833 | + if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') {
|
|
| 834 | + return false; |
|
| 835 | + } |
|
| 836 | + |
|
| 837 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 838 | + |
|
| 839 | + $wpdb->query( |
|
| 840 | + $wpdb->prepare( |
|
| 841 | + "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
| 842 | + array($post_id) |
|
| 843 | + ) |
|
| 844 | + ); |
|
| 845 | + |
|
| 846 | + return true; |
|
| 847 | + } |
|
| 848 | + |
|
| 849 | + } elseif ($postmeta != '' && $post_id) {
|
|
| 850 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 851 | + |
|
| 852 | + $wpdb->query( |
|
| 853 | + $wpdb->prepare( |
|
| 854 | + "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
| 855 | + array($post_id) |
|
| 856 | + ) |
|
| 857 | + ); |
|
| 858 | + |
|
| 859 | + return true; |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + } else |
|
| 863 | + return false; |
|
| 864 | + } |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | |
| 868 | 868 | if (!function_exists('geodir_get_post_meta')) {
|
| 869 | - /** |
|
| 870 | - * Get post custom meta. |
|
| 871 | - * |
|
| 872 | - * @since 1.0.0 |
|
| 873 | - * @package GeoDirectory |
|
| 874 | - * @global object $wpdb WordPress Database object. |
|
| 875 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 876 | - * @param int $post_id The post ID. |
|
| 877 | - * @param string $meta_key The meta key to retrieve. |
|
| 878 | - * @param bool $single Optional. Whether to return a single value. Default false. |
|
| 879 | - * @todo single variable not yet implemented. |
|
| 880 | - * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
| 881 | - */ |
|
| 882 | - function geodir_get_post_meta($post_id, $meta_key, $single = false) |
|
| 883 | - {
|
|
| 884 | - if (!$post_id) {
|
|
| 885 | - return false; |
|
| 886 | - } |
|
| 887 | - global $wpdb, $plugin_prefix; |
|
| 888 | - |
|
| 889 | - $all_postypes = geodir_get_posttypes(); |
|
| 890 | - |
|
| 891 | - $post_type = get_post_type($post_id); |
|
| 892 | - |
|
| 893 | - if (!in_array($post_type, $all_postypes)) |
|
| 894 | - return false; |
|
| 895 | - |
|
| 896 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 897 | - |
|
| 898 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
|
|
| 899 | - $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
|
| 900 | - if ($meta_value && $meta_value !== '') {
|
|
| 901 | - return maybe_serialize($meta_value); |
|
| 902 | - } else |
|
| 903 | - return $meta_value; |
|
| 904 | - } else {
|
|
| 905 | - return false; |
|
| 906 | - } |
|
| 907 | - } |
|
| 869 | + /** |
|
| 870 | + * Get post custom meta. |
|
| 871 | + * |
|
| 872 | + * @since 1.0.0 |
|
| 873 | + * @package GeoDirectory |
|
| 874 | + * @global object $wpdb WordPress Database object. |
|
| 875 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 876 | + * @param int $post_id The post ID. |
|
| 877 | + * @param string $meta_key The meta key to retrieve. |
|
| 878 | + * @param bool $single Optional. Whether to return a single value. Default false. |
|
| 879 | + * @todo single variable not yet implemented. |
|
| 880 | + * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
| 881 | + */ |
|
| 882 | + function geodir_get_post_meta($post_id, $meta_key, $single = false) |
|
| 883 | + {
|
|
| 884 | + if (!$post_id) {
|
|
| 885 | + return false; |
|
| 886 | + } |
|
| 887 | + global $wpdb, $plugin_prefix; |
|
| 888 | + |
|
| 889 | + $all_postypes = geodir_get_posttypes(); |
|
| 890 | + |
|
| 891 | + $post_type = get_post_type($post_id); |
|
| 892 | + |
|
| 893 | + if (!in_array($post_type, $all_postypes)) |
|
| 894 | + return false; |
|
| 895 | + |
|
| 896 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 897 | + |
|
| 898 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
|
|
| 899 | + $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
|
| 900 | + if ($meta_value && $meta_value !== '') {
|
|
| 901 | + return maybe_serialize($meta_value); |
|
| 902 | + } else |
|
| 903 | + return $meta_value; |
|
| 904 | + } else {
|
|
| 905 | + return false; |
|
| 906 | + } |
|
| 907 | + } |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | |
| 911 | 911 | if (!function_exists('geodir_save_post_images')) {
|
| 912 | - /** |
|
| 913 | - * Save post attachments. |
|
| 914 | - * |
|
| 915 | - * @since 1.0.0 |
|
| 916 | - * @package GeoDirectory |
|
| 917 | - * @global object $wpdb WordPress Database object. |
|
| 918 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 919 | - * @global object $current_user Current user object. |
|
| 920 | - * @param int $post_id The post ID. |
|
| 921 | - * @param array $post_image Post image urls as an array. |
|
| 922 | - * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 923 | - */ |
|
| 924 | - function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false) |
|
| 925 | - {
|
|
| 926 | - |
|
| 912 | + /** |
|
| 913 | + * Save post attachments. |
|
| 914 | + * |
|
| 915 | + * @since 1.0.0 |
|
| 916 | + * @package GeoDirectory |
|
| 917 | + * @global object $wpdb WordPress Database object. |
|
| 918 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 919 | + * @global object $current_user Current user object. |
|
| 920 | + * @param int $post_id The post ID. |
|
| 921 | + * @param array $post_image Post image urls as an array. |
|
| 922 | + * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 923 | + */ |
|
| 924 | + function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false) |
|
| 925 | + {
|
|
| 927 | 926 | |
| 928 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 929 | 927 | |
| 930 | - $post_type = get_post_type($post_id); |
|
| 928 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 931 | 929 | |
| 932 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 930 | + $post_type = get_post_type($post_id); |
|
| 933 | 931 | |
| 934 | - $post_images = geodir_get_images($post_id); |
|
| 932 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 935 | 933 | |
| 936 | - $wpdb->query( |
|
| 937 | - $wpdb->prepare( |
|
| 938 | - "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
| 939 | - array($post_id) |
|
| 940 | - ) |
|
| 941 | - ); |
|
| 934 | + $post_images = geodir_get_images($post_id); |
|
| 942 | 935 | |
| 943 | - $invalid_files = $post_images; |
|
| 944 | - $valid_file_ids = array(); |
|
| 945 | - $valid_files_condition = ''; |
|
| 946 | - $geodir_uploaddir = ''; |
|
| 936 | + $wpdb->query( |
|
| 937 | + $wpdb->prepare( |
|
| 938 | + "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
| 939 | + array($post_id) |
|
| 940 | + ) |
|
| 941 | + ); |
|
| 947 | 942 | |
| 948 | - $remove_files = array(); |
|
| 943 | + $invalid_files = $post_images; |
|
| 944 | + $valid_file_ids = array(); |
|
| 945 | + $valid_files_condition = ''; |
|
| 946 | + $geodir_uploaddir = ''; |
|
| 949 | 947 | |
| 950 | - if (!empty($post_image)) {
|
|
| 948 | + $remove_files = array(); |
|
| 951 | 949 | |
| 952 | - $uploads = wp_upload_dir(); |
|
| 953 | - $uploads_dir = $uploads['path']; |
|
| 950 | + if (!empty($post_image)) {
|
|
| 954 | 951 | |
| 955 | - $geodir_uploadpath = $uploads['path']; |
|
| 956 | - $geodir_uploadurl = $uploads['url']; |
|
| 957 | - $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : ''; |
|
| 952 | + $uploads = wp_upload_dir(); |
|
| 953 | + $uploads_dir = $uploads['path']; |
|
| 958 | 954 | |
| 959 | - $invalid_files = array(); |
|
| 960 | - $postcurr_images = array(); |
|
| 955 | + $geodir_uploadpath = $uploads['path']; |
|
| 956 | + $geodir_uploadurl = $uploads['url']; |
|
| 957 | + $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : ''; |
|
| 961 | 958 | |
| 962 | - for ($m = 0; $m < count($post_image); $m++) {
|
|
| 963 | - $menu_order = $m + 1; |
|
| 959 | + $invalid_files = array(); |
|
| 960 | + $postcurr_images = array(); |
|
| 964 | 961 | |
| 965 | - $file_path = ''; |
|
| 966 | - /* --------- start ------- */ |
|
| 962 | + for ($m = 0; $m < count($post_image); $m++) {
|
|
| 963 | + $menu_order = $m + 1; |
|
| 967 | 964 | |
| 968 | - $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
|
|
| 965 | + $file_path = ''; |
|
| 966 | + /* --------- start ------- */ |
|
| 969 | 967 | |
| 970 | - $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
| 968 | + $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
|
|
| 971 | 969 | |
| 970 | + $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
| 972 | 971 | |
| 973 | - if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 974 | 972 | |
| 975 | - /* --------- end ------- */ |
|
| 976 | - $curr_img_url = $post_image[$m]; |
|
| 973 | + if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 977 | 974 | |
| 978 | - $image_name_arr = explode('/', $curr_img_url);
|
|
| 975 | + /* --------- end ------- */ |
|
| 976 | + $curr_img_url = $post_image[$m]; |
|
| 979 | 977 | |
| 980 | - $count_image_name_arr = count($image_name_arr) - 2; |
|
| 978 | + $image_name_arr = explode('/', $curr_img_url);
|
|
| 981 | 979 | |
| 982 | - $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0; |
|
| 980 | + $count_image_name_arr = count($image_name_arr) - 2; |
|
| 983 | 981 | |
| 984 | - $curr_img_dir = $image_name_arr[$count_image_name_arr]; |
|
| 982 | + $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0; |
|
| 985 | 983 | |
| 986 | - $filename = end($image_name_arr); |
|
| 987 | - if (strpos($filename, '?') !== false) {
|
|
| 988 | - list($filename) = explode('?', $filename);
|
|
| 989 | - } |
|
| 984 | + $curr_img_dir = $image_name_arr[$count_image_name_arr]; |
|
| 990 | 985 | |
| 991 | - $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url); |
|
| 992 | - $curr_img_dir = str_replace($filename, "", $curr_img_dir); |
|
| 986 | + $filename = end($image_name_arr); |
|
| 987 | + if (strpos($filename, '?') !== false) {
|
|
| 988 | + list($filename) = explode('?', $filename);
|
|
| 989 | + } |
|
| 993 | 990 | |
| 994 | - $img_name_arr = explode('.', $filename);
|
|
| 991 | + $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url); |
|
| 992 | + $curr_img_dir = str_replace($filename, "", $curr_img_dir); |
|
| 995 | 993 | |
| 996 | - $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename; |
|
| 997 | - if (!empty($img_name_arr) && count($img_name_arr) > 2) {
|
|
| 998 | - $new_img_name_arr = $img_name_arr; |
|
| 999 | - if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
|
|
| 1000 | - unset($new_img_name_arr[count($img_name_arr) - 1]); |
|
| 1001 | - $file_title = implode('.', $new_img_name_arr);
|
|
| 1002 | - } |
|
| 1003 | - } |
|
| 1004 | - $file_title = sanitize_file_name($file_title); |
|
| 1005 | - $file_name = sanitize_file_name($filename); |
|
| 994 | + $img_name_arr = explode('.', $filename);
|
|
| 1006 | 995 | |
| 1007 | - $arr_file_type = wp_check_filetype($filename); |
|
| 996 | + $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename; |
|
| 997 | + if (!empty($img_name_arr) && count($img_name_arr) > 2) {
|
|
| 998 | + $new_img_name_arr = $img_name_arr; |
|
| 999 | + if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
|
|
| 1000 | + unset($new_img_name_arr[count($img_name_arr) - 1]); |
|
| 1001 | + $file_title = implode('.', $new_img_name_arr);
|
|
| 1002 | + } |
|
| 1003 | + } |
|
| 1004 | + $file_title = sanitize_file_name($file_title); |
|
| 1005 | + $file_name = sanitize_file_name($filename); |
|
| 1008 | 1006 | |
| 1009 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 1007 | + $arr_file_type = wp_check_filetype($filename); |
|
| 1010 | 1008 | |
| 1011 | - // Set an array containing a list of acceptable formats |
|
| 1012 | - $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
|
|
| 1009 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 1013 | 1010 | |
| 1014 | - // If the uploaded file is the right format |
|
| 1015 | - if (in_array($uploaded_file_type, $allowed_file_types)) {
|
|
| 1016 | - if (!function_exists('wp_handle_upload')) {
|
|
| 1017 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1018 | - } |
|
| 1011 | + // Set an array containing a list of acceptable formats |
|
| 1012 | + $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
|
|
| 1019 | 1013 | |
| 1020 | - if (!is_dir($geodir_uploadpath)) {
|
|
| 1021 | - mkdir($geodir_uploadpath); |
|
| 1022 | - } |
|
| 1014 | + // If the uploaded file is the right format |
|
| 1015 | + if (in_array($uploaded_file_type, $allowed_file_types)) {
|
|
| 1016 | + if (!function_exists('wp_handle_upload')) {
|
|
| 1017 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1018 | + } |
|
| 1023 | 1019 | |
| 1024 | - $external_img = false; |
|
| 1025 | - if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
|
|
| 1026 | - } else {
|
|
| 1027 | - $external_img = true; |
|
| 1028 | - } |
|
| 1020 | + if (!is_dir($geodir_uploadpath)) {
|
|
| 1021 | + mkdir($geodir_uploadpath); |
|
| 1022 | + } |
|
| 1029 | 1023 | |
| 1030 | - if ($dummy || $external_img) {
|
|
| 1031 | - $uploaded_file = array(); |
|
| 1032 | - $uploaded = (array)fetch_remote_file($curr_img_url); |
|
| 1024 | + $external_img = false; |
|
| 1025 | + if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
|
|
| 1026 | + } else {
|
|
| 1027 | + $external_img = true; |
|
| 1028 | + } |
|
| 1033 | 1029 | |
| 1034 | - if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
|
| 1035 | - $new_name = basename($uploaded['file']); |
|
| 1036 | - $uploaded_file = $uploaded; |
|
| 1037 | - }else{
|
|
| 1038 | - print_r($uploaded);exit; |
|
| 1039 | - } |
|
| 1040 | - $external_img = false; |
|
| 1041 | - } else {
|
|
| 1042 | - $new_name = $post_id . '_' . $file_name; |
|
| 1030 | + if ($dummy || $external_img) {
|
|
| 1031 | + $uploaded_file = array(); |
|
| 1032 | + $uploaded = (array)fetch_remote_file($curr_img_url); |
|
| 1043 | 1033 | |
| 1044 | - if ($curr_img_dir == $sub_dir) {
|
|
| 1045 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1046 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1047 | - } else {
|
|
| 1048 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1049 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1050 | - } |
|
| 1034 | + if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
|
| 1035 | + $new_name = basename($uploaded['file']); |
|
| 1036 | + $uploaded_file = $uploaded; |
|
| 1037 | + }else{
|
|
| 1038 | + print_r($uploaded);exit; |
|
| 1039 | + } |
|
| 1040 | + $external_img = false; |
|
| 1041 | + } else {
|
|
| 1042 | + $new_name = $post_id . '_' . $file_name; |
|
| 1051 | 1043 | |
| 1052 | - $uploaded_file = ''; |
|
| 1044 | + if ($curr_img_dir == $sub_dir) {
|
|
| 1045 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1046 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1047 | + } else {
|
|
| 1048 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1049 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1050 | + } |
|
| 1053 | 1051 | |
| 1054 | - if (file_exists($img_path)) {
|
|
| 1055 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1056 | - $file_path = ''; |
|
| 1057 | - } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
|
|
| 1058 | - $uploaded_file = true; |
|
| 1059 | - $file_path = $curr_img_dir . '/' . $filename; |
|
| 1060 | - } |
|
| 1052 | + $uploaded_file = ''; |
|
| 1061 | 1053 | |
| 1062 | - if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
| 1063 | - unlink($img_path); |
|
| 1064 | - } |
|
| 1054 | + if (file_exists($img_path)) {
|
|
| 1055 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1056 | + $file_path = ''; |
|
| 1057 | + } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
|
|
| 1058 | + $uploaded_file = true; |
|
| 1059 | + $file_path = $curr_img_dir . '/' . $filename; |
|
| 1060 | + } |
|
| 1065 | 1061 | |
| 1066 | - if (!empty($uploaded_file)) {
|
|
| 1067 | - if (!isset($file_path) || !$file_path) {
|
|
| 1068 | - $file_path = $sub_dir . '/' . $new_name; |
|
| 1069 | - } |
|
| 1062 | + if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
| 1063 | + unlink($img_path); |
|
| 1064 | + } |
|
| 1070 | 1065 | |
| 1071 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
|
|
| 1066 | + if (!empty($uploaded_file)) {
|
|
| 1067 | + if (!isset($file_path) || !$file_path) {
|
|
| 1068 | + $file_path = $sub_dir . '/' . $new_name; |
|
| 1069 | + } |
|
| 1072 | 1070 | |
| 1073 | - if ($menu_order == 1) {
|
|
| 1071 | + $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
|
|
| 1074 | 1072 | |
| 1075 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1073 | + if ($menu_order == 1) {
|
|
| 1076 | 1074 | |
| 1077 | - } |
|
| 1075 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1078 | 1076 | |
| 1079 | - // Set up options array to add this file as an attachment |
|
| 1080 | - $attachment = array(); |
|
| 1081 | - $attachment['post_id'] = $post_id; |
|
| 1082 | - $attachment['title'] = $file_title; |
|
| 1083 | - $attachment['content'] = ''; |
|
| 1084 | - $attachment['file'] = $file_path; |
|
| 1085 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 1086 | - $attachment['menu_order'] = $menu_order; |
|
| 1087 | - $attachment['is_featured'] = 0; |
|
| 1077 | + } |
|
| 1088 | 1078 | |
| 1089 | - $attachment_set = ''; |
|
| 1079 | + // Set up options array to add this file as an attachment |
|
| 1080 | + $attachment = array(); |
|
| 1081 | + $attachment['post_id'] = $post_id; |
|
| 1082 | + $attachment['title'] = $file_title; |
|
| 1083 | + $attachment['content'] = ''; |
|
| 1084 | + $attachment['file'] = $file_path; |
|
| 1085 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 1086 | + $attachment['menu_order'] = $menu_order; |
|
| 1087 | + $attachment['is_featured'] = 0; |
|
| 1090 | 1088 | |
| 1091 | - foreach ($attachment as $key => $val) {
|
|
| 1092 | - if ($val != '') |
|
| 1093 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1094 | - } |
|
| 1089 | + $attachment_set = ''; |
|
| 1095 | 1090 | |
| 1096 | - $attachment_set = trim($attachment_set, ", "); |
|
| 1091 | + foreach ($attachment as $key => $val) {
|
|
| 1092 | + if ($val != '') |
|
| 1093 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1094 | + } |
|
| 1097 | 1095 | |
| 1098 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1096 | + $attachment_set = trim($attachment_set, ", "); |
|
| 1097 | + |
|
| 1098 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1099 | 1099 | |
| 1100 | - $valid_file_ids[] = $wpdb->insert_id; |
|
| 1101 | - } |
|
| 1100 | + $valid_file_ids[] = $wpdb->insert_id; |
|
| 1101 | + } |
|
| 1102 | 1102 | |
| 1103 | - } |
|
| 1103 | + } |
|
| 1104 | 1104 | |
| 1105 | 1105 | |
| 1106 | - } else {
|
|
| 1107 | - $valid_file_ids[] = $find_image; |
|
| 1106 | + } else {
|
|
| 1107 | + $valid_file_ids[] = $find_image; |
|
| 1108 | 1108 | |
| 1109 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
|
|
| 1109 | + $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
|
|
| 1110 | 1110 | |
| 1111 | - $wpdb->query( |
|
| 1112 | - $wpdb->prepare( |
|
| 1113 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1114 | - array($menu_order, $split_img_path[1], $post_id) |
|
| 1115 | - ) |
|
| 1116 | - ); |
|
| 1111 | + $wpdb->query( |
|
| 1112 | + $wpdb->prepare( |
|
| 1113 | + "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1114 | + array($menu_order, $split_img_path[1], $post_id) |
|
| 1115 | + ) |
|
| 1116 | + ); |
|
| 1117 | 1117 | |
| 1118 | - if ($menu_order == 1) |
|
| 1119 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1118 | + if ($menu_order == 1) |
|
| 1119 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1120 | 1120 | |
| 1121 | - } |
|
| 1121 | + } |
|
| 1122 | 1122 | |
| 1123 | 1123 | |
| 1124 | - } |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | - if (!empty($valid_file_ids)) {
|
|
| 1126 | + if (!empty($valid_file_ids)) {
|
|
| 1127 | 1127 | |
| 1128 | - $remove_files = $valid_file_ids; |
|
| 1128 | + $remove_files = $valid_file_ids; |
|
| 1129 | 1129 | |
| 1130 | - $remove_files_length = count($remove_files); |
|
| 1131 | - $remove_files_format = array_fill(0, $remove_files_length, '%d'); |
|
| 1132 | - $format = implode(',', $remove_files_format);
|
|
| 1133 | - $valid_files_condition = " ID NOT IN ($format) AND "; |
|
| 1130 | + $remove_files_length = count($remove_files); |
|
| 1131 | + $remove_files_format = array_fill(0, $remove_files_length, '%d'); |
|
| 1132 | + $format = implode(',', $remove_files_format);
|
|
| 1133 | + $valid_files_condition = " ID NOT IN ($format) AND "; |
|
| 1134 | 1134 | |
| 1135 | - } |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | - //Get and remove all old images of post from database to set by new order |
|
| 1137 | + //Get and remove all old images of post from database to set by new order |
|
| 1138 | 1138 | |
| 1139 | - if (!empty($post_images)) {
|
|
| 1139 | + if (!empty($post_images)) {
|
|
| 1140 | 1140 | |
| 1141 | - foreach ($post_images as $img) {
|
|
| 1141 | + foreach ($post_images as $img) {
|
|
| 1142 | 1142 | |
| 1143 | - if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
|
|
| 1143 | + if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
|
|
| 1144 | 1144 | |
| 1145 | - $invalid_files[] = (object)array('src' => $img->src);
|
|
| 1145 | + $invalid_files[] = (object)array('src' => $img->src);
|
|
| 1146 | 1146 | |
| 1147 | - } |
|
| 1147 | + } |
|
| 1148 | 1148 | |
| 1149 | - } |
|
| 1149 | + } |
|
| 1150 | 1150 | |
| 1151 | - } |
|
| 1151 | + } |
|
| 1152 | 1152 | |
| 1153 | - $invalid_files = (object)$invalid_files; |
|
| 1154 | - } |
|
| 1153 | + $invalid_files = (object)$invalid_files; |
|
| 1154 | + } |
|
| 1155 | 1155 | |
| 1156 | - $remove_files[] = $post_id; |
|
| 1156 | + $remove_files[] = $post_id; |
|
| 1157 | 1157 | |
| 1158 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
|
| 1158 | + $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
|
| 1159 | 1159 | |
| 1160 | - if (!empty($invalid_files)) |
|
| 1161 | - geodir_remove_attachments($invalid_files); |
|
| 1162 | - } |
|
| 1160 | + if (!empty($invalid_files)) |
|
| 1161 | + geodir_remove_attachments($invalid_files); |
|
| 1162 | + } |
|
| 1163 | 1163 | |
| 1164 | 1164 | } |
| 1165 | 1165 | |
@@ -1173,12 +1173,12 @@ discard block |
||
| 1173 | 1173 | function geodir_remove_temp_images() |
| 1174 | 1174 | {
|
| 1175 | 1175 | |
| 1176 | - global $current_user; |
|
| 1176 | + global $current_user; |
|
| 1177 | 1177 | |
| 1178 | - $uploads = wp_upload_dir(); |
|
| 1179 | - $uploads_dir = $uploads['path']; |
|
| 1178 | + $uploads = wp_upload_dir(); |
|
| 1179 | + $uploads_dir = $uploads['path']; |
|
| 1180 | 1180 | |
| 1181 | - /* if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
|
|
| 1181 | + /* if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
|
|
| 1182 | 1182 | |
| 1183 | 1183 | $dirPath = $uploads_dir.'/temp_'.$current_user->data->ID; |
| 1184 | 1184 | if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
|
@@ -1195,8 +1195,8 @@ discard block |
||
| 1195 | 1195 | rmdir($dirPath); |
| 1196 | 1196 | } */ |
| 1197 | 1197 | |
| 1198 | - $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
| 1199 | - geodir_delete_directory($dirname); |
|
| 1198 | + $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
| 1199 | + geodir_delete_directory($dirname); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | |
@@ -1210,116 +1210,116 @@ discard block |
||
| 1210 | 1210 | */ |
| 1211 | 1211 | function geodir_delete_directory($dirname) |
| 1212 | 1212 | {
|
| 1213 | - $dir_handle = ''; |
|
| 1214 | - if (is_dir($dirname)) |
|
| 1215 | - $dir_handle = opendir($dirname); |
|
| 1216 | - if (!$dir_handle) |
|
| 1217 | - return false; |
|
| 1218 | - while ($file = readdir($dir_handle)) {
|
|
| 1219 | - if ($file != "." && $file != "..") {
|
|
| 1220 | - if (!is_dir($dirname . "/" . $file)) |
|
| 1221 | - unlink($dirname . "/" . $file); |
|
| 1222 | - else |
|
| 1223 | - geodir_delete_directory($dirname . '/' . $file); |
|
| 1224 | - } |
|
| 1225 | - } |
|
| 1226 | - closedir($dir_handle); |
|
| 1227 | - rmdir($dirname); |
|
| 1228 | - return true; |
|
| 1213 | + $dir_handle = ''; |
|
| 1214 | + if (is_dir($dirname)) |
|
| 1215 | + $dir_handle = opendir($dirname); |
|
| 1216 | + if (!$dir_handle) |
|
| 1217 | + return false; |
|
| 1218 | + while ($file = readdir($dir_handle)) {
|
|
| 1219 | + if ($file != "." && $file != "..") {
|
|
| 1220 | + if (!is_dir($dirname . "/" . $file)) |
|
| 1221 | + unlink($dirname . "/" . $file); |
|
| 1222 | + else |
|
| 1223 | + geodir_delete_directory($dirname . '/' . $file); |
|
| 1224 | + } |
|
| 1225 | + } |
|
| 1226 | + closedir($dir_handle); |
|
| 1227 | + rmdir($dirname); |
|
| 1228 | + return true; |
|
| 1229 | 1229 | |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | 1232 | |
| 1233 | 1233 | if (!function_exists('geodir_remove_attachments')) {
|
| 1234 | - /** |
|
| 1235 | - * Remove post attachments. |
|
| 1236 | - * |
|
| 1237 | - * @since 1.0.0 |
|
| 1238 | - * @package GeoDirectory |
|
| 1239 | - * @param array $postcurr_images Array of image objects. |
|
| 1240 | - */ |
|
| 1241 | - function geodir_remove_attachments($postcurr_images = array()) |
|
| 1242 | - {
|
|
| 1243 | - // Unlink all past images of post |
|
| 1244 | - if (!empty($postcurr_images)) {
|
|
| 1245 | - |
|
| 1246 | - $uploads = wp_upload_dir(); |
|
| 1247 | - $uploads_dir = $uploads['path']; |
|
| 1248 | - |
|
| 1249 | - foreach ($postcurr_images as $postimg) {
|
|
| 1250 | - $image_name_arr = explode('/', $postimg->src);
|
|
| 1251 | - $filename = end($image_name_arr); |
|
| 1252 | - if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1253 | - unlink($uploads_dir . '/' . $filename); |
|
| 1254 | - } |
|
| 1255 | - |
|
| 1256 | - } // endif |
|
| 1257 | - // Unlink all past images of post end |
|
| 1258 | - } |
|
| 1234 | + /** |
|
| 1235 | + * Remove post attachments. |
|
| 1236 | + * |
|
| 1237 | + * @since 1.0.0 |
|
| 1238 | + * @package GeoDirectory |
|
| 1239 | + * @param array $postcurr_images Array of image objects. |
|
| 1240 | + */ |
|
| 1241 | + function geodir_remove_attachments($postcurr_images = array()) |
|
| 1242 | + {
|
|
| 1243 | + // Unlink all past images of post |
|
| 1244 | + if (!empty($postcurr_images)) {
|
|
| 1245 | + |
|
| 1246 | + $uploads = wp_upload_dir(); |
|
| 1247 | + $uploads_dir = $uploads['path']; |
|
| 1248 | + |
|
| 1249 | + foreach ($postcurr_images as $postimg) {
|
|
| 1250 | + $image_name_arr = explode('/', $postimg->src);
|
|
| 1251 | + $filename = end($image_name_arr); |
|
| 1252 | + if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1253 | + unlink($uploads_dir . '/' . $filename); |
|
| 1254 | + } |
|
| 1255 | + |
|
| 1256 | + } // endif |
|
| 1257 | + // Unlink all past images of post end |
|
| 1258 | + } |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | if (!function_exists('geodir_get_featured_image')) {
|
| 1262 | - /** |
|
| 1263 | - * Gets the post featured image. |
|
| 1264 | - * |
|
| 1265 | - * @since 1.0.0 |
|
| 1266 | - * @package GeoDirectory |
|
| 1267 | - * @global object $wpdb WordPress Database object. |
|
| 1268 | - * @global object $post The current post object. |
|
| 1269 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1270 | - * @param int|string $post_id The post ID. |
|
| 1271 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1272 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1273 | - * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false. |
|
| 1274 | - * @return bool|object Image details as an object. |
|
| 1275 | - */ |
|
| 1276 | - function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false) |
|
| 1277 | - {
|
|
| 1278 | - |
|
| 1279 | - /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id, 'medium');//medium/thumbnail |
|
| 1262 | + /** |
|
| 1263 | + * Gets the post featured image. |
|
| 1264 | + * |
|
| 1265 | + * @since 1.0.0 |
|
| 1266 | + * @package GeoDirectory |
|
| 1267 | + * @global object $wpdb WordPress Database object. |
|
| 1268 | + * @global object $post The current post object. |
|
| 1269 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1270 | + * @param int|string $post_id The post ID. |
|
| 1271 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1272 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1273 | + * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false. |
|
| 1274 | + * @return bool|object Image details as an object. |
|
| 1275 | + */ |
|
| 1276 | + function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false) |
|
| 1277 | + {
|
|
| 1278 | + |
|
| 1279 | + /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id, 'medium');//medium/thumbnail |
|
| 1280 | 1280 | $img_arr['path'] = ''; |
| 1281 | 1281 | $img_arr['width'] = ''; |
| 1282 | 1282 | $img_arr['height'] = ''; |
| 1283 | 1283 | $img_arr['title'] = ''; |
| 1284 | 1284 | return (object)$img_arr;*/ |
| 1285 | - global $wpdb, $plugin_prefix, $post; |
|
| 1285 | + global $wpdb, $plugin_prefix, $post; |
|
| 1286 | 1286 | |
| 1287 | - if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
|
|
| 1288 | - $post_type = $post->post_type; |
|
| 1289 | - } else {
|
|
| 1290 | - $post_type = get_post_type($post_id); |
|
| 1291 | - } |
|
| 1287 | + if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
|
|
| 1288 | + $post_type = $post->post_type; |
|
| 1289 | + } else {
|
|
| 1290 | + $post_type = get_post_type($post_id); |
|
| 1291 | + } |
|
| 1292 | 1292 | |
| 1293 | - if (!in_array($post_type, geodir_get_posttypes())) {
|
|
| 1294 | - return false;// if not a GD CPT return; |
|
| 1295 | - } |
|
| 1293 | + if (!in_array($post_type, geodir_get_posttypes())) {
|
|
| 1294 | + return false;// if not a GD CPT return; |
|
| 1295 | + } |
|
| 1296 | 1296 | |
| 1297 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1297 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1298 | 1298 | |
| 1299 | - if (!$file) {
|
|
| 1300 | - if (isset($post->featured_image)) {
|
|
| 1301 | - $file = $post->featured_image; |
|
| 1302 | - } else {
|
|
| 1303 | - $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
|
|
| 1304 | - } |
|
| 1305 | - } |
|
| 1299 | + if (!$file) {
|
|
| 1300 | + if (isset($post->featured_image)) {
|
|
| 1301 | + $file = $post->featured_image; |
|
| 1302 | + } else {
|
|
| 1303 | + $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
|
|
| 1304 | + } |
|
| 1305 | + } |
|
| 1306 | 1306 | |
| 1307 | - if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
|
| 1308 | - $img_arr = array(); |
|
| 1307 | + if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
|
| 1308 | + $img_arr = array(); |
|
| 1309 | 1309 | |
| 1310 | - $file_info = pathinfo($file); |
|
| 1311 | - $sub_dir = ''; |
|
| 1312 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1313 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1310 | + $file_info = pathinfo($file); |
|
| 1311 | + $sub_dir = ''; |
|
| 1312 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1313 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1314 | 1314 | |
| 1315 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1316 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1317 | - $uploads_path = $uploads['path']; |
|
| 1315 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1316 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1317 | + $uploads_path = $uploads['path']; |
|
| 1318 | 1318 | |
| 1319 | - $file_name = $file_info['basename']; |
|
| 1319 | + $file_name = $file_info['basename']; |
|
| 1320 | 1320 | |
| 1321 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1322 | - /* |
|
| 1321 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1322 | + /* |
|
| 1323 | 1323 | * Allows the filter of image src for such things as CDN change. |
| 1324 | 1324 | * |
| 1325 | 1325 | * @since 1.5.7 |
@@ -1328,158 +1328,158 @@ discard block |
||
| 1328 | 1328 | * @param string $uploads_url The server upload directory url. |
| 1329 | 1329 | * @param string $uploads_baseurl The uploads dir base url. |
| 1330 | 1330 | */ |
| 1331 | - $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1332 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1333 | - $width = 0; |
|
| 1334 | - $height = 0; |
|
| 1335 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1336 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1337 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1338 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1339 | - } |
|
| 1340 | - $img_arr['width'] = $width; |
|
| 1341 | - $img_arr['height'] = $height; |
|
| 1342 | - $img_arr['title'] = ''; |
|
| 1343 | - } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
|
|
| 1344 | - foreach ($post_images as $image) {
|
|
| 1345 | - return $image; |
|
| 1346 | - } |
|
| 1347 | - } else if ($no_image) {
|
|
| 1348 | - $img_arr = array(); |
|
| 1349 | - |
|
| 1350 | - $default_img = ''; |
|
| 1351 | - if (isset($post->default_category) && $post->default_category) {
|
|
| 1352 | - $default_cat = $post->default_category; |
|
| 1353 | - } else {
|
|
| 1354 | - $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1355 | - } |
|
| 1356 | - |
|
| 1357 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1358 | - $default_img = $default_catimg['src']; |
|
| 1359 | - elseif ($no_image) {
|
|
| 1360 | - $default_img = get_option('geodir_listing_no_img');
|
|
| 1361 | - } |
|
| 1362 | - |
|
| 1363 | - if (!empty($default_img)) {
|
|
| 1364 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1365 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1366 | - $uploads_path = $uploads['path']; |
|
| 1367 | - |
|
| 1368 | - $img_arr = array(); |
|
| 1369 | - |
|
| 1370 | - $file_info = pathinfo($default_img); |
|
| 1371 | - |
|
| 1372 | - $file_name = $file_info['basename']; |
|
| 1373 | - |
|
| 1374 | - $img_arr['src'] = $default_img; |
|
| 1375 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1376 | - |
|
| 1377 | - $width = 0; |
|
| 1378 | - $height = 0; |
|
| 1379 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1380 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1381 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1382 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1383 | - } |
|
| 1384 | - $img_arr['width'] = $width; |
|
| 1385 | - $img_arr['height'] = $height; |
|
| 1386 | - |
|
| 1387 | - $img_arr['title'] = ''; // add the title to the array |
|
| 1388 | - } |
|
| 1389 | - } |
|
| 1390 | - |
|
| 1391 | - if (!empty($img_arr)) |
|
| 1392 | - return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1393 | - else |
|
| 1394 | - return false; |
|
| 1395 | - } |
|
| 1331 | + $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1332 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1333 | + $width = 0; |
|
| 1334 | + $height = 0; |
|
| 1335 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1336 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1337 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1338 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1339 | + } |
|
| 1340 | + $img_arr['width'] = $width; |
|
| 1341 | + $img_arr['height'] = $height; |
|
| 1342 | + $img_arr['title'] = ''; |
|
| 1343 | + } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
|
|
| 1344 | + foreach ($post_images as $image) {
|
|
| 1345 | + return $image; |
|
| 1346 | + } |
|
| 1347 | + } else if ($no_image) {
|
|
| 1348 | + $img_arr = array(); |
|
| 1349 | + |
|
| 1350 | + $default_img = ''; |
|
| 1351 | + if (isset($post->default_category) && $post->default_category) {
|
|
| 1352 | + $default_cat = $post->default_category; |
|
| 1353 | + } else {
|
|
| 1354 | + $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1355 | + } |
|
| 1356 | + |
|
| 1357 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1358 | + $default_img = $default_catimg['src']; |
|
| 1359 | + elseif ($no_image) {
|
|
| 1360 | + $default_img = get_option('geodir_listing_no_img');
|
|
| 1361 | + } |
|
| 1362 | + |
|
| 1363 | + if (!empty($default_img)) {
|
|
| 1364 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1365 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1366 | + $uploads_path = $uploads['path']; |
|
| 1367 | + |
|
| 1368 | + $img_arr = array(); |
|
| 1369 | + |
|
| 1370 | + $file_info = pathinfo($default_img); |
|
| 1371 | + |
|
| 1372 | + $file_name = $file_info['basename']; |
|
| 1373 | + |
|
| 1374 | + $img_arr['src'] = $default_img; |
|
| 1375 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1376 | + |
|
| 1377 | + $width = 0; |
|
| 1378 | + $height = 0; |
|
| 1379 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1380 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1381 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1382 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1383 | + } |
|
| 1384 | + $img_arr['width'] = $width; |
|
| 1385 | + $img_arr['height'] = $height; |
|
| 1386 | + |
|
| 1387 | + $img_arr['title'] = ''; // add the title to the array |
|
| 1388 | + } |
|
| 1389 | + } |
|
| 1390 | + |
|
| 1391 | + if (!empty($img_arr)) |
|
| 1392 | + return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1393 | + else |
|
| 1394 | + return false; |
|
| 1395 | + } |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | if (!function_exists('geodir_show_featured_image')) {
|
| 1399 | - /** |
|
| 1400 | - * Gets the post featured image. |
|
| 1401 | - * |
|
| 1402 | - * @since 1.0.0 |
|
| 1403 | - * @package GeoDirectory |
|
| 1404 | - * @param int|string $post_id The post ID. |
|
| 1405 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1406 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1407 | - * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1408 | - * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. |
|
| 1409 | - * @return bool|string Returns image html. |
|
| 1410 | - */ |
|
| 1411 | - function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) |
|
| 1412 | - {
|
|
| 1413 | - $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); |
|
| 1414 | - |
|
| 1415 | - $html = geodir_show_image($image, $size, $no_image, false); |
|
| 1416 | - |
|
| 1417 | - if (!empty($html) && $echo) {
|
|
| 1418 | - echo $html; |
|
| 1419 | - } elseif (!empty($html)) {
|
|
| 1420 | - return $html; |
|
| 1421 | - } else |
|
| 1422 | - return false; |
|
| 1423 | - } |
|
| 1399 | + /** |
|
| 1400 | + * Gets the post featured image. |
|
| 1401 | + * |
|
| 1402 | + * @since 1.0.0 |
|
| 1403 | + * @package GeoDirectory |
|
| 1404 | + * @param int|string $post_id The post ID. |
|
| 1405 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1406 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1407 | + * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1408 | + * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. |
|
| 1409 | + * @return bool|string Returns image html. |
|
| 1410 | + */ |
|
| 1411 | + function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) |
|
| 1412 | + {
|
|
| 1413 | + $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); |
|
| 1414 | + |
|
| 1415 | + $html = geodir_show_image($image, $size, $no_image, false); |
|
| 1416 | + |
|
| 1417 | + if (!empty($html) && $echo) {
|
|
| 1418 | + echo $html; |
|
| 1419 | + } elseif (!empty($html)) {
|
|
| 1420 | + return $html; |
|
| 1421 | + } else |
|
| 1422 | + return false; |
|
| 1423 | + } |
|
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | 1426 | if (!function_exists('geodir_get_images')) {
|
| 1427 | - /** |
|
| 1428 | - * Gets the post images. |
|
| 1429 | - * |
|
| 1430 | - * @since 1.0.0 |
|
| 1431 | - * @package GeoDirectory |
|
| 1432 | - * @global object $wpdb WordPress Database object. |
|
| 1433 | - * @param int $post_id The post ID. |
|
| 1434 | - * @param string $img_size Optional. Thumbnail size. |
|
| 1435 | - * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1436 | - * @param bool $add_featured Optional. Do you want to include featured images too? Default: true. |
|
| 1437 | - * @param int|string $limit Optional. Number of images. |
|
| 1438 | - * @return array|bool Returns images as an array. Each item is an object. |
|
| 1439 | - */ |
|
| 1440 | - function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '') |
|
| 1441 | - {
|
|
| 1442 | - global $wpdb; |
|
| 1443 | - if ($limit) {
|
|
| 1444 | - $limit_q = " LIMIT $limit "; |
|
| 1445 | - } else {
|
|
| 1446 | - $limit_q = ''; |
|
| 1447 | - } |
|
| 1448 | - $not_featured = ''; |
|
| 1449 | - $sub_dir = ''; |
|
| 1450 | - if (!$add_featured) |
|
| 1451 | - $not_featured = " AND is_featured = 0 "; |
|
| 1452 | - |
|
| 1453 | - $arrImages = $wpdb->get_results( |
|
| 1454 | - $wpdb->prepare( |
|
| 1455 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1456 | - array('%image%', $post_id)
|
|
| 1457 | - ) |
|
| 1458 | - ); |
|
| 1459 | - |
|
| 1460 | - $counter = 0; |
|
| 1461 | - $return_arr = array(); |
|
| 1462 | - |
|
| 1463 | - if (!empty($arrImages)) {
|
|
| 1464 | - foreach ($arrImages as $attechment) {
|
|
| 1465 | - |
|
| 1466 | - $img_arr = array(); |
|
| 1467 | - $img_arr['id'] = $attechment->ID; |
|
| 1468 | - $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0; |
|
| 1469 | - |
|
| 1470 | - $file_info = pathinfo($attechment->file); |
|
| 1471 | - |
|
| 1472 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1473 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1474 | - |
|
| 1475 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1476 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1477 | - $uploads_path = $uploads['path']; |
|
| 1478 | - |
|
| 1479 | - $file_name = $file_info['basename']; |
|
| 1480 | - |
|
| 1481 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1482 | - /* |
|
| 1427 | + /** |
|
| 1428 | + * Gets the post images. |
|
| 1429 | + * |
|
| 1430 | + * @since 1.0.0 |
|
| 1431 | + * @package GeoDirectory |
|
| 1432 | + * @global object $wpdb WordPress Database object. |
|
| 1433 | + * @param int $post_id The post ID. |
|
| 1434 | + * @param string $img_size Optional. Thumbnail size. |
|
| 1435 | + * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1436 | + * @param bool $add_featured Optional. Do you want to include featured images too? Default: true. |
|
| 1437 | + * @param int|string $limit Optional. Number of images. |
|
| 1438 | + * @return array|bool Returns images as an array. Each item is an object. |
|
| 1439 | + */ |
|
| 1440 | + function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '') |
|
| 1441 | + {
|
|
| 1442 | + global $wpdb; |
|
| 1443 | + if ($limit) {
|
|
| 1444 | + $limit_q = " LIMIT $limit "; |
|
| 1445 | + } else {
|
|
| 1446 | + $limit_q = ''; |
|
| 1447 | + } |
|
| 1448 | + $not_featured = ''; |
|
| 1449 | + $sub_dir = ''; |
|
| 1450 | + if (!$add_featured) |
|
| 1451 | + $not_featured = " AND is_featured = 0 "; |
|
| 1452 | + |
|
| 1453 | + $arrImages = $wpdb->get_results( |
|
| 1454 | + $wpdb->prepare( |
|
| 1455 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1456 | + array('%image%', $post_id)
|
|
| 1457 | + ) |
|
| 1458 | + ); |
|
| 1459 | + |
|
| 1460 | + $counter = 0; |
|
| 1461 | + $return_arr = array(); |
|
| 1462 | + |
|
| 1463 | + if (!empty($arrImages)) {
|
|
| 1464 | + foreach ($arrImages as $attechment) {
|
|
| 1465 | + |
|
| 1466 | + $img_arr = array(); |
|
| 1467 | + $img_arr['id'] = $attechment->ID; |
|
| 1468 | + $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0; |
|
| 1469 | + |
|
| 1470 | + $file_info = pathinfo($attechment->file); |
|
| 1471 | + |
|
| 1472 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1473 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1474 | + |
|
| 1475 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1476 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1477 | + $uploads_path = $uploads['path']; |
|
| 1478 | + |
|
| 1479 | + $file_name = $file_info['basename']; |
|
| 1480 | + |
|
| 1481 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1482 | + /* |
|
| 1483 | 1483 | * Allows the filter of image src for such things as CDN change. |
| 1484 | 1484 | * |
| 1485 | 1485 | * @since 1.5.7 |
@@ -1488,514 +1488,514 @@ discard block |
||
| 1488 | 1488 | * @param string $uploads_url The server upload directory url. |
| 1489 | 1489 | * @param string $uploads_baseurl The uploads dir base url. |
| 1490 | 1490 | */ |
| 1491 | - $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1492 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1493 | - $width = 0; |
|
| 1494 | - $height = 0; |
|
| 1495 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1496 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1497 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1498 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1499 | - } |
|
| 1500 | - $img_arr['width'] = $width; |
|
| 1501 | - $img_arr['height'] = $height; |
|
| 1502 | - |
|
| 1503 | - $img_arr['file'] = $file_name; // add the title to the array |
|
| 1504 | - $img_arr['title'] = $attechment->title; // add the title to the array |
|
| 1505 | - $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array |
|
| 1506 | - $img_arr['content'] = $attechment->content; // add the description to the array |
|
| 1507 | - $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
|
| 1508 | - |
|
| 1509 | - $return_arr[] = (object)$img_arr; |
|
| 1510 | - |
|
| 1511 | - $counter++; |
|
| 1512 | - } |
|
| 1513 | - return (object)$return_arr; |
|
| 1514 | - } else if ($no_images) {
|
|
| 1515 | - $default_img = ''; |
|
| 1516 | - $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1517 | - $post_type = get_post_type($post_id); |
|
| 1518 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1519 | - $default_img = $default_catimg['src']; |
|
| 1520 | - elseif ($no_images) {
|
|
| 1521 | - $default_img = get_option('geodir_listing_no_img');
|
|
| 1522 | - } |
|
| 1523 | - |
|
| 1524 | - if (!empty($default_img)) {
|
|
| 1525 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1491 | + $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1492 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1493 | + $width = 0; |
|
| 1494 | + $height = 0; |
|
| 1495 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1496 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1497 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1498 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1499 | + } |
|
| 1500 | + $img_arr['width'] = $width; |
|
| 1501 | + $img_arr['height'] = $height; |
|
| 1502 | + |
|
| 1503 | + $img_arr['file'] = $file_name; // add the title to the array |
|
| 1504 | + $img_arr['title'] = $attechment->title; // add the title to the array |
|
| 1505 | + $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array |
|
| 1506 | + $img_arr['content'] = $attechment->content; // add the description to the array |
|
| 1507 | + $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
|
| 1508 | + |
|
| 1509 | + $return_arr[] = (object)$img_arr; |
|
| 1510 | + |
|
| 1511 | + $counter++; |
|
| 1512 | + } |
|
| 1513 | + return (object)$return_arr; |
|
| 1514 | + } else if ($no_images) {
|
|
| 1515 | + $default_img = ''; |
|
| 1516 | + $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1517 | + $post_type = get_post_type($post_id); |
|
| 1518 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1519 | + $default_img = $default_catimg['src']; |
|
| 1520 | + elseif ($no_images) {
|
|
| 1521 | + $default_img = get_option('geodir_listing_no_img');
|
|
| 1522 | + } |
|
| 1523 | + |
|
| 1524 | + if (!empty($default_img)) {
|
|
| 1525 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1526 | 1526 | |
| 1527 | - $image_path = $default_img; |
|
| 1528 | - if (!path_is_absolute($image_path)) {
|
|
| 1529 | - $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path); |
|
| 1530 | - } |
|
| 1531 | - |
|
| 1532 | - $file_info = pathinfo($default_img); |
|
| 1533 | - $file_name = $file_info['basename']; |
|
| 1534 | - |
|
| 1535 | - $width = ''; |
|
| 1536 | - $height = ''; |
|
| 1537 | - if (is_file($image_path) && file_exists($image_path)) {
|
|
| 1538 | - $imagesize = getimagesize($image_path); |
|
| 1539 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1540 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1541 | - } |
|
| 1527 | + $image_path = $default_img; |
|
| 1528 | + if (!path_is_absolute($image_path)) {
|
|
| 1529 | + $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path); |
|
| 1530 | + } |
|
| 1531 | + |
|
| 1532 | + $file_info = pathinfo($default_img); |
|
| 1533 | + $file_name = $file_info['basename']; |
|
| 1534 | + |
|
| 1535 | + $width = ''; |
|
| 1536 | + $height = ''; |
|
| 1537 | + if (is_file($image_path) && file_exists($image_path)) {
|
|
| 1538 | + $imagesize = getimagesize($image_path); |
|
| 1539 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1540 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1541 | + } |
|
| 1542 | 1542 | |
| 1543 | - $img_arr = array(); |
|
| 1544 | - $img_arr['src'] = $default_img; |
|
| 1545 | - $img_arr['path'] = $image_path; |
|
| 1546 | - $img_arr['width'] = $width; |
|
| 1547 | - $img_arr['height'] = $height; |
|
| 1548 | - $img_arr['file'] = $file_name; // add the title to the array |
|
| 1549 | - $img_arr['title'] = $file_info['filename']; // add the title to the array |
|
| 1550 | - $img_arr['content'] = $file_info['filename']; // add the description to the array |
|
| 1551 | - |
|
| 1552 | - $return_arr[] = (object)$img_arr; |
|
| 1553 | - |
|
| 1554 | - return $return_arr; |
|
| 1555 | - } else |
|
| 1556 | - return false; |
|
| 1557 | - } |
|
| 1558 | - } |
|
| 1543 | + $img_arr = array(); |
|
| 1544 | + $img_arr['src'] = $default_img; |
|
| 1545 | + $img_arr['path'] = $image_path; |
|
| 1546 | + $img_arr['width'] = $width; |
|
| 1547 | + $img_arr['height'] = $height; |
|
| 1548 | + $img_arr['file'] = $file_name; // add the title to the array |
|
| 1549 | + $img_arr['title'] = $file_info['filename']; // add the title to the array |
|
| 1550 | + $img_arr['content'] = $file_info['filename']; // add the description to the array |
|
| 1551 | + |
|
| 1552 | + $return_arr[] = (object)$img_arr; |
|
| 1553 | + |
|
| 1554 | + return $return_arr; |
|
| 1555 | + } else |
|
| 1556 | + return false; |
|
| 1557 | + } |
|
| 1558 | + } |
|
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | 1561 | if (!function_exists('geodir_show_image')) {
|
| 1562 | - /** |
|
| 1563 | - * Show image using image details. |
|
| 1564 | - * |
|
| 1565 | - * @since 1.0.0 |
|
| 1566 | - * @package GeoDirectory |
|
| 1567 | - * @param array|object $request Image info either as an array or object. |
|
| 1568 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1569 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1570 | - * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1571 | - * @return bool|string Returns image html. |
|
| 1572 | - */ |
|
| 1573 | - function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true) |
|
| 1574 | - {
|
|
| 1575 | - $image = new stdClass(); |
|
| 1576 | - |
|
| 1577 | - $html = ''; |
|
| 1578 | - if (!empty($request)) {
|
|
| 1579 | - if (!is_object($request)){
|
|
| 1580 | - $request = (object)$request; |
|
| 1581 | - } |
|
| 1582 | - |
|
| 1583 | - if (isset($request->src) && !isset($request->path)) {
|
|
| 1584 | - $request->path = $request->src; |
|
| 1585 | - } |
|
| 1586 | - |
|
| 1587 | - /* |
|
| 1562 | + /** |
|
| 1563 | + * Show image using image details. |
|
| 1564 | + * |
|
| 1565 | + * @since 1.0.0 |
|
| 1566 | + * @package GeoDirectory |
|
| 1567 | + * @param array|object $request Image info either as an array or object. |
|
| 1568 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1569 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1570 | + * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1571 | + * @return bool|string Returns image html. |
|
| 1572 | + */ |
|
| 1573 | + function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true) |
|
| 1574 | + {
|
|
| 1575 | + $image = new stdClass(); |
|
| 1576 | + |
|
| 1577 | + $html = ''; |
|
| 1578 | + if (!empty($request)) {
|
|
| 1579 | + if (!is_object($request)){
|
|
| 1580 | + $request = (object)$request; |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + if (isset($request->src) && !isset($request->path)) {
|
|
| 1584 | + $request->path = $request->src; |
|
| 1585 | + } |
|
| 1586 | + |
|
| 1587 | + /* |
|
| 1588 | 1588 | * getimagesize() works faster from path than url so we try and get path if we can. |
| 1589 | 1589 | */ |
| 1590 | - $upload_dir = wp_upload_dir(); |
|
| 1591 | - $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
|
|
| 1592 | - $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
|
|
| 1593 | - if (strpos($img_no_http, $upload_no_http) !== false) {
|
|
| 1594 | - $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
| 1595 | - } |
|
| 1590 | + $upload_dir = wp_upload_dir(); |
|
| 1591 | + $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
|
|
| 1592 | + $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
|
|
| 1593 | + if (strpos($img_no_http, $upload_no_http) !== false) {
|
|
| 1594 | + $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
| 1595 | + } |
|
| 1596 | 1596 | |
| 1597 | - $width = 0; |
|
| 1598 | - $height = 0; |
|
| 1599 | - if (is_file($request->path) && file_exists($request->path)) {
|
|
| 1600 | - $imagesize = getimagesize($request->path); |
|
| 1601 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1602 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1603 | - } |
|
| 1604 | - |
|
| 1605 | - $image->src = $request->src; |
|
| 1606 | - $image->width = $width; |
|
| 1607 | - $image->height = $height; |
|
| 1608 | - |
|
| 1609 | - $max_size = (object)geodir_get_imagesize($size); |
|
| 1610 | - |
|
| 1611 | - if (!is_wp_error($max_size)) {
|
|
| 1612 | - if ($image->width) {
|
|
| 1613 | - if ($image->height >= $image->width) {
|
|
| 1614 | - $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
|
| 1615 | - } else if ($image->width < ($max_size->h)) {
|
|
| 1616 | - $width_per = round((($image->width / $max_size->w) * 100), 2); |
|
| 1617 | - } else |
|
| 1618 | - $width_per = 100; |
|
| 1619 | - } |
|
| 1620 | - |
|
| 1621 | - if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
|
| 1622 | - $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
| 1623 | - } else {
|
|
| 1624 | - if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
|
| 1625 | - $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1626 | - }else{
|
|
| 1627 | - //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1628 | - //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>'; |
|
| 1629 | - $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
|
|
| 1630 | - |
|
| 1631 | - } |
|
| 1632 | - |
|
| 1633 | - } |
|
| 1634 | - } |
|
| 1635 | - } |
|
| 1636 | - |
|
| 1637 | - if (!empty($html) && $echo) {
|
|
| 1638 | - echo $html; |
|
| 1639 | - } elseif (!empty($html)) {
|
|
| 1640 | - return $html; |
|
| 1641 | - } else |
|
| 1642 | - return false; |
|
| 1643 | - } |
|
| 1644 | -} |
|
| 1597 | + $width = 0; |
|
| 1598 | + $height = 0; |
|
| 1599 | + if (is_file($request->path) && file_exists($request->path)) {
|
|
| 1600 | + $imagesize = getimagesize($request->path); |
|
| 1601 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1602 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1603 | + } |
|
| 1645 | 1604 | |
| 1646 | -if (!function_exists('geodir_set_post_terms')) {
|
|
| 1647 | - /** |
|
| 1648 | - * Set post Categories. |
|
| 1649 | - * |
|
| 1650 | - * @since 1.0.0 |
|
| 1651 | - * @package GeoDirectory |
|
| 1652 | - * @global object $wpdb WordPress Database object. |
|
| 1653 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1654 | - * @param int $post_id The post ID. |
|
| 1655 | - * @param array $terms An array of term objects. |
|
| 1656 | - * @param array $tt_ids An array of term taxonomy IDs. |
|
| 1657 | - * @param string $taxonomy Taxonomy slug. |
|
| 1658 | - */ |
|
| 1659 | - function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy) |
|
| 1660 | - {
|
|
| 1661 | - global $wpdb, $plugin_prefix; |
|
| 1605 | + $image->src = $request->src; |
|
| 1606 | + $image->width = $width; |
|
| 1607 | + $image->height = $height; |
|
| 1662 | 1608 | |
| 1663 | - $post_type = get_post_type($post_id); |
|
| 1609 | + $max_size = (object)geodir_get_imagesize($size); |
|
| 1664 | 1610 | |
| 1665 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1611 | + if (!is_wp_error($max_size)) {
|
|
| 1612 | + if ($image->width) {
|
|
| 1613 | + if ($image->height >= $image->width) {
|
|
| 1614 | + $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
|
| 1615 | + } else if ($image->width < ($max_size->h)) {
|
|
| 1616 | + $width_per = round((($image->width / $max_size->w) * 100), 2); |
|
| 1617 | + } else |
|
| 1618 | + $width_per = 100; |
|
| 1619 | + } |
|
| 1620 | + |
|
| 1621 | + if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
|
| 1622 | + $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
| 1623 | + } else {
|
|
| 1624 | + if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
|
| 1625 | + $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1626 | + }else{
|
|
| 1627 | + //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1628 | + //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>'; |
|
| 1629 | + $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
|
|
| 1666 | 1630 | |
| 1667 | - if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
|
|
| 1631 | + } |
|
| 1668 | 1632 | |
| 1669 | - if ($taxonomy == $post_type . '_tags') {
|
|
| 1670 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1671 | - geodir_save_post_meta($post_id, 'post_tags', $terms); |
|
| 1672 | - } |
|
| 1673 | - } elseif ($taxonomy == $post_type . 'category') {
|
|
| 1674 | - $srcharr = array('"', '\\');
|
|
| 1675 | - $replarr = array(""", '');
|
|
| 1633 | + } |
|
| 1634 | + } |
|
| 1635 | + } |
|
| 1636 | + |
|
| 1637 | + if (!empty($html) && $echo) {
|
|
| 1638 | + echo $html; |
|
| 1639 | + } elseif (!empty($html)) {
|
|
| 1640 | + return $html; |
|
| 1641 | + } else |
|
| 1642 | + return false; |
|
| 1643 | + } |
|
| 1644 | +} |
|
| 1676 | 1645 | |
| 1677 | - $post_obj = get_post($post_id); |
|
| 1646 | +if (!function_exists('geodir_set_post_terms')) {
|
|
| 1647 | + /** |
|
| 1648 | + * Set post Categories. |
|
| 1649 | + * |
|
| 1650 | + * @since 1.0.0 |
|
| 1651 | + * @package GeoDirectory |
|
| 1652 | + * @global object $wpdb WordPress Database object. |
|
| 1653 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1654 | + * @param int $post_id The post ID. |
|
| 1655 | + * @param array $terms An array of term objects. |
|
| 1656 | + * @param array $tt_ids An array of term taxonomy IDs. |
|
| 1657 | + * @param string $taxonomy Taxonomy slug. |
|
| 1658 | + */ |
|
| 1659 | + function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy) |
|
| 1660 | + {
|
|
| 1661 | + global $wpdb, $plugin_prefix; |
|
| 1662 | + |
|
| 1663 | + $post_type = get_post_type($post_id); |
|
| 1664 | + |
|
| 1665 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1666 | + |
|
| 1667 | + if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
|
|
| 1668 | + |
|
| 1669 | + if ($taxonomy == $post_type . '_tags') {
|
|
| 1670 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1671 | + geodir_save_post_meta($post_id, 'post_tags', $terms); |
|
| 1672 | + } |
|
| 1673 | + } elseif ($taxonomy == $post_type . 'category') {
|
|
| 1674 | + $srcharr = array('"', '\\');
|
|
| 1675 | + $replarr = array(""", '');
|
|
| 1678 | 1676 | |
| 1679 | - $cat_ids = array('0');
|
|
| 1680 | - if (is_array($tt_ids)) |
|
| 1681 | - $cat_ids = $tt_ids; |
|
| 1677 | + $post_obj = get_post($post_id); |
|
| 1682 | 1678 | |
| 1679 | + $cat_ids = array('0');
|
|
| 1680 | + if (is_array($tt_ids)) |
|
| 1681 | + $cat_ids = $tt_ids; |
|
| 1683 | 1682 | |
| 1684 | - if (!empty($cat_ids)) {
|
|
| 1685 | - $cat_ids_array = $cat_ids; |
|
| 1686 | - $cat_ids_length = count($cat_ids_array); |
|
| 1687 | - $cat_ids_format = array_fill(0, $cat_ids_length, '%d'); |
|
| 1688 | - $format = implode(',', $cat_ids_format);
|
|
| 1689 | 1683 | |
| 1690 | - $cat_ids_array_del = $cat_ids_array; |
|
| 1691 | - $cat_ids_array_del[] = $post_id; |
|
| 1684 | + if (!empty($cat_ids)) {
|
|
| 1685 | + $cat_ids_array = $cat_ids; |
|
| 1686 | + $cat_ids_length = count($cat_ids_array); |
|
| 1687 | + $cat_ids_format = array_fill(0, $cat_ids_length, '%d'); |
|
| 1688 | + $format = implode(',', $cat_ids_format);
|
|
| 1692 | 1689 | |
| 1693 | - $wpdb->get_var( |
|
| 1694 | - $wpdb->prepare( |
|
| 1695 | - "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1696 | - $cat_ids_array_del |
|
| 1697 | - ) |
|
| 1698 | - ); |
|
| 1690 | + $cat_ids_array_del = $cat_ids_array; |
|
| 1691 | + $cat_ids_array_del[] = $post_id; |
|
| 1699 | 1692 | |
| 1693 | + $wpdb->get_var( |
|
| 1694 | + $wpdb->prepare( |
|
| 1695 | + "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1696 | + $cat_ids_array_del |
|
| 1697 | + ) |
|
| 1698 | + ); |
|
| 1700 | 1699 | |
| 1701 | - $post_term = $wpdb->get_col( |
|
| 1702 | - $wpdb->prepare( |
|
| 1703 | - "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1704 | - $cat_ids_array |
|
| 1705 | - ) |
|
| 1706 | - ); |
|
| 1707 | 1700 | |
| 1708 | - } |
|
| 1701 | + $post_term = $wpdb->get_col( |
|
| 1702 | + $wpdb->prepare( |
|
| 1703 | + "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1704 | + $cat_ids_array |
|
| 1705 | + ) |
|
| 1706 | + ); |
|
| 1709 | 1707 | |
| 1710 | - $post_marker_json = ''; |
|
| 1708 | + } |
|
| 1711 | 1709 | |
| 1712 | - if (!empty($post_term)): |
|
| 1710 | + $post_marker_json = ''; |
|
| 1713 | 1711 | |
| 1714 | - foreach ($post_term as $cat_id): |
|
| 1712 | + if (!empty($post_term)): |
|
| 1715 | 1713 | |
| 1716 | - $term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type); |
|
| 1717 | - $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : ''; |
|
| 1714 | + foreach ($post_term as $cat_id): |
|
| 1718 | 1715 | |
| 1719 | - $post_title = $post_obj->title; |
|
| 1720 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
| 1716 | + $term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type); |
|
| 1717 | + $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : ''; |
|
| 1721 | 1718 | |
| 1722 | - $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
|
| 1723 | - $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
|
| 1719 | + $post_title = $post_obj->title; |
|
| 1720 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
| 1724 | 1721 | |
| 1725 | - $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1726 | - $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1722 | + $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
|
| 1723 | + $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
|
| 1727 | 1724 | |
| 1728 | - $json = '{';
|
|
| 1729 | - $json .= '"id":"' . $post_id . '",'; |
|
| 1730 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 1731 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 1732 | - $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
| 1733 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 1734 | - $json .= '"group":"catgroup' . $cat_id . '"'; |
|
| 1735 | - $json .= '}'; |
|
| 1725 | + $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1726 | + $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1736 | 1727 | |
| 1728 | + $json = '{';
|
|
| 1729 | + $json .= '"id":"' . $post_id . '",'; |
|
| 1730 | + $json .= '"lat_pos": "' . $lat . '",'; |
|
| 1731 | + $json .= '"long_pos": "' . $lng . '",'; |
|
| 1732 | + $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
| 1733 | + $json .= '"icon":"' . $term_icon . '",'; |
|
| 1734 | + $json .= '"group":"catgroup' . $cat_id . '"'; |
|
| 1735 | + $json .= '}'; |
|
| 1737 | 1736 | |
| 1738 | - if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
| 1739 | - $post_marker_json = $json; |
|
| 1740 | 1737 | |
| 1738 | + if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
| 1739 | + $post_marker_json = $json; |
|
| 1741 | 1740 | |
| 1742 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1743 | 1741 | |
| 1744 | - $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
|
|
| 1742 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1743 | + |
|
| 1744 | + $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
|
|
| 1745 | 1745 | post_title = %s, |
| 1746 | 1746 | json = %s |
| 1747 | 1747 | WHERE post_id = %d AND cat_id = %d ", |
| 1748 | - array($post_title, $json, $post_id, $cat_id)); |
|
| 1748 | + array($post_title, $json, $post_id, $cat_id)); |
|
| 1749 | 1749 | |
| 1750 | - } else {
|
|
| 1750 | + } else {
|
|
| 1751 | 1751 | |
| 1752 | - $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
|
|
| 1752 | + $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
|
|
| 1753 | 1753 | post_id = %d, |
| 1754 | 1754 | post_title = %s, |
| 1755 | 1755 | cat_id = %d, |
| 1756 | 1756 | json = %s", |
| 1757 | - array($post_id, $post_title, $cat_id, $json)); |
|
| 1757 | + array($post_id, $post_title, $cat_id, $json)); |
|
| 1758 | 1758 | |
| 1759 | - } |
|
| 1759 | + } |
|
| 1760 | 1760 | |
| 1761 | - $wpdb->query($json_query); |
|
| 1761 | + $wpdb->query($json_query); |
|
| 1762 | 1762 | |
| 1763 | - endforeach; |
|
| 1763 | + endforeach; |
|
| 1764 | 1764 | |
| 1765 | - endif; |
|
| 1765 | + endif; |
|
| 1766 | 1766 | |
| 1767 | - if (!empty($post_term) && is_array($post_term)) {
|
|
| 1768 | - $categories = implode(',', $post_term);
|
|
| 1767 | + if (!empty($post_term) && is_array($post_term)) {
|
|
| 1768 | + $categories = implode(',', $post_term);
|
|
| 1769 | 1769 | |
| 1770 | - if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1770 | + if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1771 | 1771 | |
| 1772 | - if (empty($post_marker_json)) |
|
| 1773 | - $post_marker_json = isset($json) ? $json : ''; |
|
| 1772 | + if (empty($post_marker_json)) |
|
| 1773 | + $post_marker_json = isset($json) ? $json : ''; |
|
| 1774 | 1774 | |
| 1775 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 1775 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 1776 | 1776 | |
| 1777 | - $wpdb->query( |
|
| 1778 | - $wpdb->prepare( |
|
| 1779 | - "UPDATE " . $table . " SET |
|
| 1777 | + $wpdb->query( |
|
| 1778 | + $wpdb->prepare( |
|
| 1779 | + "UPDATE " . $table . " SET |
|
| 1780 | 1780 | " . $taxonomy . " = %s, |
| 1781 | 1781 | marker_json = %s |
| 1782 | 1782 | where post_id = %d", |
| 1783 | - array($categories, $post_marker_json, $post_id) |
|
| 1784 | - ) |
|
| 1785 | - ); |
|
| 1783 | + array($categories, $post_marker_json, $post_id) |
|
| 1784 | + ) |
|
| 1785 | + ); |
|
| 1786 | 1786 | |
| 1787 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
|
|
| 1787 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
|
|
| 1788 | 1788 | |
| 1789 | - $categories = trim($categories, ','); |
|
| 1789 | + $categories = trim($categories, ','); |
|
| 1790 | 1790 | |
| 1791 | - if ($categories) {
|
|
| 1791 | + if ($categories) {
|
|
| 1792 | 1792 | |
| 1793 | - $categories = explode(',', $categories);
|
|
| 1793 | + $categories = explode(',', $categories);
|
|
| 1794 | 1794 | |
| 1795 | - $default_category = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1795 | + $default_category = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1796 | 1796 | |
| 1797 | - if (!in_array($default_category, $categories)) {
|
|
| 1797 | + if (!in_array($default_category, $categories)) {
|
|
| 1798 | 1798 | |
| 1799 | - $wpdb->query( |
|
| 1800 | - $wpdb->prepare( |
|
| 1801 | - "UPDATE " . $table . " SET |
|
| 1799 | + $wpdb->query( |
|
| 1800 | + $wpdb->prepare( |
|
| 1801 | + "UPDATE " . $table . " SET |
|
| 1802 | 1802 | default_category = %s |
| 1803 | 1803 | where post_id = %d", |
| 1804 | - array($categories[0], $post_id) |
|
| 1805 | - ) |
|
| 1806 | - ); |
|
| 1804 | + array($categories[0], $post_id) |
|
| 1805 | + ) |
|
| 1806 | + ); |
|
| 1807 | 1807 | |
| 1808 | - $default_category = $categories[0]; |
|
| 1808 | + $default_category = $categories[0]; |
|
| 1809 | 1809 | |
| 1810 | - } |
|
| 1810 | + } |
|
| 1811 | 1811 | |
| 1812 | - if ($default_category == '') |
|
| 1813 | - $default_category = $categories[0]; |
|
| 1812 | + if ($default_category == '') |
|
| 1813 | + $default_category = $categories[0]; |
|
| 1814 | 1814 | |
| 1815 | - geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
|
| 1815 | + geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
|
| 1816 | 1816 | |
| 1817 | - } |
|
| 1817 | + } |
|
| 1818 | 1818 | |
| 1819 | - } |
|
| 1819 | + } |
|
| 1820 | 1820 | |
| 1821 | 1821 | |
| 1822 | - } else {
|
|
| 1822 | + } else {
|
|
| 1823 | 1823 | |
| 1824 | - $wpdb->query( |
|
| 1825 | - $wpdb->prepare( |
|
| 1826 | - "INSERT INTO " . $table . " SET |
|
| 1824 | + $wpdb->query( |
|
| 1825 | + $wpdb->prepare( |
|
| 1826 | + "INSERT INTO " . $table . " SET |
|
| 1827 | 1827 | post_id = %d, |
| 1828 | 1828 | " . $taxonomy . " = %s, |
| 1829 | 1829 | marker_json = %s ", |
| 1830 | 1830 | |
| 1831 | - array($post_id, $categories, $post_marker_json) |
|
| 1832 | - ) |
|
| 1833 | - ); |
|
| 1834 | - } |
|
| 1835 | - } |
|
| 1836 | - } |
|
| 1837 | - } |
|
| 1838 | - } |
|
| 1831 | + array($post_id, $categories, $post_marker_json) |
|
| 1832 | + ) |
|
| 1833 | + ); |
|
| 1834 | + } |
|
| 1835 | + } |
|
| 1836 | + } |
|
| 1837 | + } |
|
| 1838 | + } |
|
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | 1841 | if (!function_exists('geodir_get_infowindow_html')) {
|
| 1842 | - /** |
|
| 1843 | - * Set post Map Marker info html. |
|
| 1844 | - * |
|
| 1845 | - * @since 1.0.0 |
|
| 1846 | - * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". |
|
| 1847 | - * @since 1.6.16 Changes for disable review stars for certain post type. |
|
| 1848 | - * @package GeoDirectory |
|
| 1849 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
| 1850 | - * @global object $gd_session GeoDirectory Session object. |
|
| 1851 | - * @param object $postinfo_obj The post details object. |
|
| 1852 | - * @param string $post_preview Is this a post preview?. |
|
| 1853 | - * @return mixed|string|void |
|
| 1854 | - */ |
|
| 1855 | - function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') |
|
| 1856 | - {
|
|
| 1857 | - global $preview, $gd_session; |
|
| 1858 | - $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 1859 | - $replarr = array("′", "⁄", "–", "“", '');
|
|
| 1860 | - |
|
| 1861 | - if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1862 | - $ID = ''; |
|
| 1863 | - $plink = ''; |
|
| 1864 | - |
|
| 1865 | - if (isset($postinfo_obj->pid)) {
|
|
| 1866 | - $ID = $postinfo_obj->pid; |
|
| 1867 | - $plink = get_permalink($ID); |
|
| 1868 | - } |
|
| 1869 | - |
|
| 1870 | - $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title)); |
|
| 1871 | - $lat = $postinfo_obj->post_latitude; |
|
| 1872 | - $lng = $postinfo_obj->post_longitude; |
|
| 1873 | - } else {
|
|
| 1874 | - $ID = $postinfo_obj->post_id; |
|
| 1875 | - $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
| 1876 | - $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08 |
|
| 1877 | - $plink = get_permalink($ID); |
|
| 1878 | - $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); |
|
| 1879 | - $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); |
|
| 1880 | - } |
|
| 1842 | + /** |
|
| 1843 | + * Set post Map Marker info html. |
|
| 1844 | + * |
|
| 1845 | + * @since 1.0.0 |
|
| 1846 | + * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". |
|
| 1847 | + * @since 1.6.16 Changes for disable review stars for certain post type. |
|
| 1848 | + * @package GeoDirectory |
|
| 1849 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
| 1850 | + * @global object $gd_session GeoDirectory Session object. |
|
| 1851 | + * @param object $postinfo_obj The post details object. |
|
| 1852 | + * @param string $post_preview Is this a post preview?. |
|
| 1853 | + * @return mixed|string|void |
|
| 1854 | + */ |
|
| 1855 | + function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') |
|
| 1856 | + {
|
|
| 1857 | + global $preview, $gd_session; |
|
| 1858 | + $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 1859 | + $replarr = array("′", "⁄", "–", "“", '');
|
|
| 1860 | + |
|
| 1861 | + if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1862 | + $ID = ''; |
|
| 1863 | + $plink = ''; |
|
| 1864 | + |
|
| 1865 | + if (isset($postinfo_obj->pid)) {
|
|
| 1866 | + $ID = $postinfo_obj->pid; |
|
| 1867 | + $plink = get_permalink($ID); |
|
| 1868 | + } |
|
| 1869 | + |
|
| 1870 | + $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title)); |
|
| 1871 | + $lat = $postinfo_obj->post_latitude; |
|
| 1872 | + $lng = $postinfo_obj->post_longitude; |
|
| 1873 | + } else {
|
|
| 1874 | + $ID = $postinfo_obj->post_id; |
|
| 1875 | + $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
| 1876 | + $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08 |
|
| 1877 | + $plink = get_permalink($ID); |
|
| 1878 | + $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); |
|
| 1879 | + $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); |
|
| 1880 | + } |
|
| 1881 | 1881 | |
| 1882 | - $post_type = $ID ? get_post_type($ID) : ''; |
|
| 1883 | - |
|
| 1884 | - // filter field as per price package |
|
| 1885 | - global $geodir_addon_list; |
|
| 1886 | - if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
|
|
| 1887 | - $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; |
|
| 1888 | - $field_name = 'geodir_contact'; |
|
| 1889 | - if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1890 | - $contact = ''; |
|
| 1891 | - } |
|
| 1892 | - |
|
| 1893 | - $field_name = 'geodir_timing'; |
|
| 1894 | - if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1895 | - $timing = ''; |
|
| 1896 | - } |
|
| 1897 | - } |
|
| 1898 | - |
|
| 1899 | - if ($lat && $lng) {
|
|
| 1900 | - ob_start(); ?> |
|
| 1882 | + $post_type = $ID ? get_post_type($ID) : ''; |
|
| 1883 | + |
|
| 1884 | + // filter field as per price package |
|
| 1885 | + global $geodir_addon_list; |
|
| 1886 | + if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
|
|
| 1887 | + $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; |
|
| 1888 | + $field_name = 'geodir_contact'; |
|
| 1889 | + if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1890 | + $contact = ''; |
|
| 1891 | + } |
|
| 1892 | + |
|
| 1893 | + $field_name = 'geodir_timing'; |
|
| 1894 | + if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1895 | + $timing = ''; |
|
| 1896 | + } |
|
| 1897 | + } |
|
| 1898 | + |
|
| 1899 | + if ($lat && $lng) {
|
|
| 1900 | + ob_start(); ?> |
|
| 1901 | 1901 | <div class="gd-bubble" style=""> |
| 1902 | 1902 | <div class="gd-bubble-inside"> |
| 1903 | 1903 | <?php |
| 1904 | - $comment_count = ''; |
|
| 1905 | - $rating_star = ''; |
|
| 1906 | - if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
|
|
| 1907 | - $rating_star = ''; |
|
| 1908 | - $comment_count = geodir_get_review_count_total($ID); |
|
| 1909 | - |
|
| 1910 | - if (!$preview) {
|
|
| 1911 | - $post_avgratings = geodir_get_post_rating($ID); |
|
| 1912 | - |
|
| 1913 | - $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); |
|
| 1914 | - |
|
| 1915 | - /** |
|
| 1916 | - * Filter to change rating stars |
|
| 1917 | - * |
|
| 1918 | - * You can use this filter to change Rating stars. |
|
| 1919 | - * |
|
| 1920 | - * @since 1.0.0 |
|
| 1921 | - * @package GeoDirectory |
|
| 1922 | - * @param string $rating_star Rating stars. |
|
| 1923 | - * @param float $post_avgratings Average ratings of the post. |
|
| 1924 | - * @param int $ID The post ID. |
|
| 1925 | - */ |
|
| 1926 | - $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
|
|
| 1927 | - } |
|
| 1928 | - } |
|
| 1929 | - ?> |
|
| 1904 | + $comment_count = ''; |
|
| 1905 | + $rating_star = ''; |
|
| 1906 | + if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
|
|
| 1907 | + $rating_star = ''; |
|
| 1908 | + $comment_count = geodir_get_review_count_total($ID); |
|
| 1909 | + |
|
| 1910 | + if (!$preview) {
|
|
| 1911 | + $post_avgratings = geodir_get_post_rating($ID); |
|
| 1912 | + |
|
| 1913 | + $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); |
|
| 1914 | + |
|
| 1915 | + /** |
|
| 1916 | + * Filter to change rating stars |
|
| 1917 | + * |
|
| 1918 | + * You can use this filter to change Rating stars. |
|
| 1919 | + * |
|
| 1920 | + * @since 1.0.0 |
|
| 1921 | + * @package GeoDirectory |
|
| 1922 | + * @param string $rating_star Rating stars. |
|
| 1923 | + * @param float $post_avgratings Average ratings of the post. |
|
| 1924 | + * @param int $ID The post ID. |
|
| 1925 | + */ |
|
| 1926 | + $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
|
|
| 1927 | + } |
|
| 1928 | + } |
|
| 1929 | + ?> |
|
| 1930 | 1930 | <div class="geodir-bubble_desc"> |
| 1931 | 1931 | <h4> |
| 1932 | 1932 | <a href="<?php if ($plink != '') {
|
| 1933 | - echo $plink; |
|
| 1934 | - } else {
|
|
| 1935 | - echo 'javascript:void(0);'; |
|
| 1936 | - } ?>"><?php echo $title; ?></a> |
|
| 1933 | + echo $plink; |
|
| 1934 | + } else {
|
|
| 1935 | + echo 'javascript:void(0);'; |
|
| 1936 | + } ?>"><?php echo $title; ?></a> |
|
| 1937 | 1937 | </h4> |
| 1938 | 1938 | <?php |
| 1939 | - if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1940 | - $post_images = array(); |
|
| 1941 | - if (!empty($postinfo_obj->post_images)) {
|
|
| 1942 | - $post_images = explode(",", $postinfo_obj->post_images);
|
|
| 1943 | - } |
|
| 1944 | - |
|
| 1945 | - if (!empty($post_images)) {
|
|
| 1946 | - ?> |
|
| 1939 | + if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1940 | + $post_images = array(); |
|
| 1941 | + if (!empty($postinfo_obj->post_images)) {
|
|
| 1942 | + $post_images = explode(",", $postinfo_obj->post_images);
|
|
| 1943 | + } |
|
| 1944 | + |
|
| 1945 | + if (!empty($post_images)) {
|
|
| 1946 | + ?> |
|
| 1947 | 1947 | <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
|
| 1948 | - echo $plink; |
|
| 1949 | - } else {
|
|
| 1950 | - echo 'javascript:void(0);'; |
|
| 1951 | - } ?>"><img alt="bubble image" style="max-height:50px;" |
|
| 1948 | + echo $plink; |
|
| 1949 | + } else {
|
|
| 1950 | + echo 'javascript:void(0);'; |
|
| 1951 | + } ?>"><img alt="bubble image" style="max-height:50px;" |
|
| 1952 | 1952 | src="<?php echo $post_images[0]; ?>"/></a></div> |
| 1953 | 1953 | <?php |
| 1954 | - }else{
|
|
| 1955 | - echo '<div class="geodir-bubble_image"></div>'; |
|
| 1956 | - } |
|
| 1957 | - } else {
|
|
| 1958 | - if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
|
|
| 1959 | - ?> |
|
| 1954 | + }else{
|
|
| 1955 | + echo '<div class="geodir-bubble_image"></div>'; |
|
| 1956 | + } |
|
| 1957 | + } else {
|
|
| 1958 | + if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
|
|
| 1959 | + ?> |
|
| 1960 | 1960 | <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div> |
| 1961 | 1961 | <?php |
| 1962 | - }else{
|
|
| 1963 | - echo '<div class="geodir-bubble_image"></div>'; |
|
| 1964 | - } |
|
| 1965 | - } |
|
| 1966 | - ?> |
|
| 1962 | + }else{
|
|
| 1963 | + echo '<div class="geodir-bubble_image"></div>'; |
|
| 1964 | + } |
|
| 1965 | + } |
|
| 1966 | + ?> |
|
| 1967 | 1967 | <div class="geodir-bubble-meta-side"> |
| 1968 | 1968 | <?php |
| 1969 | - /** |
|
| 1970 | - * Fires before the meta info in the map info window. |
|
| 1971 | - * |
|
| 1972 | - * This can be used to add more info to the map info window before the normal meta info. |
|
| 1973 | - * |
|
| 1974 | - * @since 1.5.4 |
|
| 1975 | - * @param int $ID The post id. |
|
| 1976 | - * @param object $postinfo_obj The posts info as an object. |
|
| 1977 | - * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 1978 | - */ |
|
| 1979 | - do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
|
|
| 1980 | - |
|
| 1981 | - echo geodir_show_listing_info('mapbubble');
|
|
| 1982 | - |
|
| 1983 | - /** |
|
| 1984 | - * Fires after the meta info in the map info window. |
|
| 1985 | - * |
|
| 1986 | - * This can be used to add more info to the map info window after the normal meta info. |
|
| 1987 | - * |
|
| 1988 | - * @since 1.4.2 |
|
| 1989 | - * @param object $postinfo_obj The posts info as an object. |
|
| 1990 | - * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 1991 | - */ |
|
| 1992 | - do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
|
|
| 1993 | - ?> |
|
| 1969 | + /** |
|
| 1970 | + * Fires before the meta info in the map info window. |
|
| 1971 | + * |
|
| 1972 | + * This can be used to add more info to the map info window before the normal meta info. |
|
| 1973 | + * |
|
| 1974 | + * @since 1.5.4 |
|
| 1975 | + * @param int $ID The post id. |
|
| 1976 | + * @param object $postinfo_obj The posts info as an object. |
|
| 1977 | + * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 1978 | + */ |
|
| 1979 | + do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
|
|
| 1980 | + |
|
| 1981 | + echo geodir_show_listing_info('mapbubble');
|
|
| 1982 | + |
|
| 1983 | + /** |
|
| 1984 | + * Fires after the meta info in the map info window. |
|
| 1985 | + * |
|
| 1986 | + * This can be used to add more info to the map info window after the normal meta info. |
|
| 1987 | + * |
|
| 1988 | + * @since 1.4.2 |
|
| 1989 | + * @param object $postinfo_obj The posts info as an object. |
|
| 1990 | + * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 1991 | + */ |
|
| 1992 | + do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
|
|
| 1993 | + ?> |
|
| 1994 | 1994 | </div> |
| 1995 | 1995 | <?php |
| 1996 | - if ($ID) {
|
|
| 1997 | - $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
|
|
| 1998 | - ?> |
|
| 1996 | + if ($ID) {
|
|
| 1997 | + $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
|
|
| 1998 | + ?> |
|
| 1999 | 1999 | <div class="geodir-bubble-meta-fade"></div> |
| 2000 | 2000 | <div class="geodir-bubble-meta-bottom"> |
| 2001 | 2001 | <?php if ($rating_star != '') { ?>
|
@@ -2011,69 +2011,69 @@ discard block |
||
| 2011 | 2011 | </div> |
| 2012 | 2012 | </div> |
| 2013 | 2013 | <?php |
| 2014 | - $html = ob_get_clean(); |
|
| 2015 | - /** |
|
| 2016 | - * Filter to change infowindow html |
|
| 2017 | - * |
|
| 2018 | - * You can use this filter to change infowindow html. |
|
| 2019 | - * |
|
| 2020 | - * @since 1.0.0 |
|
| 2021 | - * @package GeoDirectory |
|
| 2022 | - * @param string $html Infowindow html. |
|
| 2023 | - * @param object $postinfo_obj The Post object. |
|
| 2024 | - * @param bool|string $post_preview Is this a post preview? |
|
| 2025 | - */ |
|
| 2026 | - $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
|
|
| 2027 | - return $html; |
|
| 2028 | - } |
|
| 2029 | - } |
|
| 2014 | + $html = ob_get_clean(); |
|
| 2015 | + /** |
|
| 2016 | + * Filter to change infowindow html |
|
| 2017 | + * |
|
| 2018 | + * You can use this filter to change infowindow html. |
|
| 2019 | + * |
|
| 2020 | + * @since 1.0.0 |
|
| 2021 | + * @package GeoDirectory |
|
| 2022 | + * @param string $html Infowindow html. |
|
| 2023 | + * @param object $postinfo_obj The Post object. |
|
| 2024 | + * @param bool|string $post_preview Is this a post preview? |
|
| 2025 | + */ |
|
| 2026 | + $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
|
|
| 2027 | + return $html; |
|
| 2028 | + } |
|
| 2029 | + } |
|
| 2030 | 2030 | } |
| 2031 | 2031 | |
| 2032 | 2032 | |
| 2033 | 2033 | if (!function_exists('geodir_new_post_default_status')) {
|
| 2034 | - /** |
|
| 2035 | - * Default post status for new posts. |
|
| 2036 | - * |
|
| 2037 | - * @since 1.0.0 |
|
| 2038 | - * @package GeoDirectory |
|
| 2039 | - * @return string Returns the default post status for new posts. Ex: draft, publish etc. |
|
| 2040 | - */ |
|
| 2041 | - function geodir_new_post_default_status() |
|
| 2042 | - {
|
|
| 2043 | - if (get_option('geodir_new_post_default_status'))
|
|
| 2044 | - return get_option('geodir_new_post_default_status');
|
|
| 2045 | - else |
|
| 2046 | - return 'publish'; |
|
| 2047 | - |
|
| 2048 | - } |
|
| 2034 | + /** |
|
| 2035 | + * Default post status for new posts. |
|
| 2036 | + * |
|
| 2037 | + * @since 1.0.0 |
|
| 2038 | + * @package GeoDirectory |
|
| 2039 | + * @return string Returns the default post status for new posts. Ex: draft, publish etc. |
|
| 2040 | + */ |
|
| 2041 | + function geodir_new_post_default_status() |
|
| 2042 | + {
|
|
| 2043 | + if (get_option('geodir_new_post_default_status'))
|
|
| 2044 | + return get_option('geodir_new_post_default_status');
|
|
| 2045 | + else |
|
| 2046 | + return 'publish'; |
|
| 2047 | + |
|
| 2048 | + } |
|
| 2049 | 2049 | } |
| 2050 | 2050 | |
| 2051 | 2051 | if (!function_exists('geodir_change_post_status')) {
|
| 2052 | - /** |
|
| 2053 | - * Change post status of a post. |
|
| 2054 | - * |
|
| 2055 | - * @global object $wpdb WordPress Database object. |
|
| 2056 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2057 | - * @param int|string $post_id The post ID. |
|
| 2058 | - * @param string $status New post status. Ex: draft, publish etc. |
|
| 2059 | - */ |
|
| 2060 | - function geodir_change_post_status($post_id = '', $status = '') |
|
| 2061 | - {
|
|
| 2062 | - global $wpdb, $plugin_prefix; |
|
| 2063 | - |
|
| 2064 | - $post_type = get_post_type($post_id); |
|
| 2065 | - |
|
| 2066 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2067 | - |
|
| 2068 | - $wpdb->query( |
|
| 2069 | - $wpdb->prepare( |
|
| 2070 | - "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
| 2071 | - array($status, $post_id) |
|
| 2072 | - ) |
|
| 2073 | - ); |
|
| 2074 | - |
|
| 2075 | - |
|
| 2076 | - } |
|
| 2052 | + /** |
|
| 2053 | + * Change post status of a post. |
|
| 2054 | + * |
|
| 2055 | + * @global object $wpdb WordPress Database object. |
|
| 2056 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2057 | + * @param int|string $post_id The post ID. |
|
| 2058 | + * @param string $status New post status. Ex: draft, publish etc. |
|
| 2059 | + */ |
|
| 2060 | + function geodir_change_post_status($post_id = '', $status = '') |
|
| 2061 | + {
|
|
| 2062 | + global $wpdb, $plugin_prefix; |
|
| 2063 | + |
|
| 2064 | + $post_type = get_post_type($post_id); |
|
| 2065 | + |
|
| 2066 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2067 | + |
|
| 2068 | + $wpdb->query( |
|
| 2069 | + $wpdb->prepare( |
|
| 2070 | + "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
| 2071 | + array($status, $post_id) |
|
| 2072 | + ) |
|
| 2073 | + ); |
|
| 2074 | + |
|
| 2075 | + |
|
| 2076 | + } |
|
| 2077 | 2077 | } |
| 2078 | 2078 | |
| 2079 | 2079 | /** |
@@ -2087,13 +2087,13 @@ discard block |
||
| 2087 | 2087 | */ |
| 2088 | 2088 | function geodir_set_post_status($pid, $status) |
| 2089 | 2089 | {
|
| 2090 | - if ($pid) {
|
|
| 2091 | - global $wpdb; |
|
| 2092 | - $my_post = array(); |
|
| 2093 | - $my_post['post_status'] = $status; |
|
| 2094 | - $my_post['ID'] = $pid; |
|
| 2095 | - $last_postid = wp_update_post($my_post); |
|
| 2096 | - } |
|
| 2090 | + if ($pid) {
|
|
| 2091 | + global $wpdb; |
|
| 2092 | + $my_post = array(); |
|
| 2093 | + $my_post['post_status'] = $status; |
|
| 2094 | + $my_post['ID'] = $pid; |
|
| 2095 | + $last_postid = wp_update_post($my_post); |
|
| 2096 | + } |
|
| 2097 | 2097 | } |
| 2098 | 2098 | |
| 2099 | 2099 | |
@@ -2109,384 +2109,384 @@ discard block |
||
| 2109 | 2109 | */ |
| 2110 | 2110 | function geodir_update_poststatus($new_status, $old_status, $post) |
| 2111 | 2111 | {
|
| 2112 | - global $wpdb; |
|
| 2112 | + global $wpdb; |
|
| 2113 | 2113 | |
| 2114 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 2114 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 2115 | 2115 | |
| 2116 | - if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 2116 | + if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 2117 | 2117 | |
| 2118 | - geodir_change_post_status($post->ID, $new_status); |
|
| 2119 | - } |
|
| 2118 | + geodir_change_post_status($post->ID, $new_status); |
|
| 2119 | + } |
|
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | 2122 | |
| 2123 | 2123 | if (!function_exists('geodir_update_listing_info')) {
|
| 2124 | - /** |
|
| 2125 | - * Update post info. |
|
| 2126 | - * |
|
| 2127 | - * @since 1.0.0 |
|
| 2128 | - * @package GeoDirectory |
|
| 2129 | - * @global object $wpdb WordPress Database object. |
|
| 2130 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2131 | - * @param int $updatingpost The updating post ID. |
|
| 2132 | - * @param int $temppost The temporary post ID. |
|
| 2133 | - * @todo fix post_id variable |
|
| 2134 | - */ |
|
| 2135 | - function geodir_update_listing_info($updatingpost, $temppost) |
|
| 2136 | - {
|
|
| 2137 | - |
|
| 2138 | - global $wpdb, $plugin_prefix; |
|
| 2139 | - |
|
| 2140 | - $post_type = get_post_type($post_id); |
|
| 2141 | - |
|
| 2142 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2143 | - |
|
| 2144 | - $wpdb->query( |
|
| 2145 | - $wpdb->prepare( |
|
| 2146 | - "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2147 | - array($updatingpost, $temppost) |
|
| 2148 | - ) |
|
| 2149 | - ); |
|
| 2150 | - |
|
| 2151 | - $wpdb->query( |
|
| 2152 | - $wpdb->prepare( |
|
| 2153 | - "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2154 | - array($updatingpost, $temppost) |
|
| 2155 | - ) |
|
| 2156 | - ); |
|
| 2157 | - |
|
| 2158 | - /* Update Attachments*/ |
|
| 2159 | - |
|
| 2160 | - $wpdb->query( |
|
| 2161 | - $wpdb->prepare( |
|
| 2162 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2163 | - array($updatingpost, $temppost) |
|
| 2164 | - ) |
|
| 2165 | - ); |
|
| 2166 | - |
|
| 2167 | - } |
|
| 2124 | + /** |
|
| 2125 | + * Update post info. |
|
| 2126 | + * |
|
| 2127 | + * @since 1.0.0 |
|
| 2128 | + * @package GeoDirectory |
|
| 2129 | + * @global object $wpdb WordPress Database object. |
|
| 2130 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2131 | + * @param int $updatingpost The updating post ID. |
|
| 2132 | + * @param int $temppost The temporary post ID. |
|
| 2133 | + * @todo fix post_id variable |
|
| 2134 | + */ |
|
| 2135 | + function geodir_update_listing_info($updatingpost, $temppost) |
|
| 2136 | + {
|
|
| 2137 | + |
|
| 2138 | + global $wpdb, $plugin_prefix; |
|
| 2139 | + |
|
| 2140 | + $post_type = get_post_type($post_id); |
|
| 2141 | + |
|
| 2142 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2143 | + |
|
| 2144 | + $wpdb->query( |
|
| 2145 | + $wpdb->prepare( |
|
| 2146 | + "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2147 | + array($updatingpost, $temppost) |
|
| 2148 | + ) |
|
| 2149 | + ); |
|
| 2150 | + |
|
| 2151 | + $wpdb->query( |
|
| 2152 | + $wpdb->prepare( |
|
| 2153 | + "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2154 | + array($updatingpost, $temppost) |
|
| 2155 | + ) |
|
| 2156 | + ); |
|
| 2157 | + |
|
| 2158 | + /* Update Attachments*/ |
|
| 2159 | + |
|
| 2160 | + $wpdb->query( |
|
| 2161 | + $wpdb->prepare( |
|
| 2162 | + "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2163 | + array($updatingpost, $temppost) |
|
| 2164 | + ) |
|
| 2165 | + ); |
|
| 2166 | + |
|
| 2167 | + } |
|
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | 2170 | |
| 2171 | 2171 | if (!function_exists('geodir_delete_listing_info')) {
|
| 2172 | - /** |
|
| 2173 | - * Delete Listing info from details table for the given post id. |
|
| 2174 | - * |
|
| 2175 | - * @since 1.0.0 |
|
| 2176 | - * @package GeoDirectory |
|
| 2177 | - * @global object $wpdb WordPress Database object. |
|
| 2178 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2179 | - * @param int $deleted_postid The post ID. |
|
| 2180 | - * @param bool $force Optional. Do you want to force delete it? Default: false. |
|
| 2181 | - * @return bool|void |
|
| 2182 | - */ |
|
| 2183 | - function geodir_delete_listing_info($deleted_postid, $force = false) |
|
| 2184 | - {
|
|
| 2185 | - global $wpdb, $plugin_prefix; |
|
| 2186 | - |
|
| 2187 | - // check for multisite deletions |
|
| 2188 | - if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
|
|
| 2189 | - } else {
|
|
| 2190 | - return; |
|
| 2191 | - } |
|
| 2192 | - |
|
| 2193 | - $post_type = get_post_type($deleted_postid); |
|
| 2194 | - |
|
| 2195 | - $all_postypes = geodir_get_posttypes(); |
|
| 2196 | - |
|
| 2197 | - if (!in_array($post_type, $all_postypes)) |
|
| 2198 | - return false; |
|
| 2199 | - |
|
| 2200 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2201 | - |
|
| 2202 | - /* Delete custom post meta*/ |
|
| 2203 | - $wpdb->query( |
|
| 2204 | - $wpdb->prepare( |
|
| 2205 | - "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
| 2206 | - array($deleted_postid) |
|
| 2207 | - ) |
|
| 2208 | - ); |
|
| 2209 | - |
|
| 2210 | - /* Delete post map icons*/ |
|
| 2211 | - |
|
| 2212 | - $wpdb->query( |
|
| 2213 | - $wpdb->prepare( |
|
| 2214 | - "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
| 2215 | - array($deleted_postid) |
|
| 2216 | - ) |
|
| 2217 | - ); |
|
| 2218 | - |
|
| 2219 | - /* Delete Attachments*/ |
|
| 2220 | - $postcurr_images = geodir_get_images($deleted_postid); |
|
| 2221 | - |
|
| 2222 | - $wpdb->query( |
|
| 2223 | - $wpdb->prepare( |
|
| 2224 | - "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
| 2225 | - array($deleted_postid) |
|
| 2226 | - ) |
|
| 2227 | - ); |
|
| 2228 | - geodir_remove_attachments($postcurr_images); |
|
| 2229 | - |
|
| 2230 | - } |
|
| 2172 | + /** |
|
| 2173 | + * Delete Listing info from details table for the given post id. |
|
| 2174 | + * |
|
| 2175 | + * @since 1.0.0 |
|
| 2176 | + * @package GeoDirectory |
|
| 2177 | + * @global object $wpdb WordPress Database object. |
|
| 2178 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2179 | + * @param int $deleted_postid The post ID. |
|
| 2180 | + * @param bool $force Optional. Do you want to force delete it? Default: false. |
|
| 2181 | + * @return bool|void |
|
| 2182 | + */ |
|
| 2183 | + function geodir_delete_listing_info($deleted_postid, $force = false) |
|
| 2184 | + {
|
|
| 2185 | + global $wpdb, $plugin_prefix; |
|
| 2186 | + |
|
| 2187 | + // check for multisite deletions |
|
| 2188 | + if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
|
|
| 2189 | + } else {
|
|
| 2190 | + return; |
|
| 2191 | + } |
|
| 2192 | + |
|
| 2193 | + $post_type = get_post_type($deleted_postid); |
|
| 2194 | + |
|
| 2195 | + $all_postypes = geodir_get_posttypes(); |
|
| 2196 | + |
|
| 2197 | + if (!in_array($post_type, $all_postypes)) |
|
| 2198 | + return false; |
|
| 2199 | + |
|
| 2200 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2201 | + |
|
| 2202 | + /* Delete custom post meta*/ |
|
| 2203 | + $wpdb->query( |
|
| 2204 | + $wpdb->prepare( |
|
| 2205 | + "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
| 2206 | + array($deleted_postid) |
|
| 2207 | + ) |
|
| 2208 | + ); |
|
| 2209 | + |
|
| 2210 | + /* Delete post map icons*/ |
|
| 2211 | + |
|
| 2212 | + $wpdb->query( |
|
| 2213 | + $wpdb->prepare( |
|
| 2214 | + "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
| 2215 | + array($deleted_postid) |
|
| 2216 | + ) |
|
| 2217 | + ); |
|
| 2218 | + |
|
| 2219 | + /* Delete Attachments*/ |
|
| 2220 | + $postcurr_images = geodir_get_images($deleted_postid); |
|
| 2221 | + |
|
| 2222 | + $wpdb->query( |
|
| 2223 | + $wpdb->prepare( |
|
| 2224 | + "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
| 2225 | + array($deleted_postid) |
|
| 2226 | + ) |
|
| 2227 | + ); |
|
| 2228 | + geodir_remove_attachments($postcurr_images); |
|
| 2229 | + |
|
| 2230 | + } |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | |
| 2234 | 2234 | if (!function_exists('geodir_add_to_favorite')) {
|
| 2235 | - /** |
|
| 2236 | - * This function would add listing to favorite listing. |
|
| 2237 | - * |
|
| 2238 | - * @since 1.0.0 |
|
| 2239 | - * @package GeoDirectory |
|
| 2240 | - * @global object $current_user Current user object. |
|
| 2241 | - * @param int $post_id The post ID. |
|
| 2242 | - */ |
|
| 2243 | - function geodir_add_to_favorite($post_id) |
|
| 2244 | - {
|
|
| 2245 | - |
|
| 2246 | - global $current_user; |
|
| 2247 | - |
|
| 2248 | - /** |
|
| 2249 | - * Filter to modify "Unfavorite" text |
|
| 2250 | - * |
|
| 2251 | - * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2252 | - * |
|
| 2253 | - * @since 1.0.0 |
|
| 2254 | - * @package GeoDirectory |
|
| 2255 | - */ |
|
| 2256 | - $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2257 | - |
|
| 2258 | - /** |
|
| 2259 | - * Filter to modify "Remove from Favorites" text |
|
| 2260 | - * |
|
| 2261 | - * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2262 | - * |
|
| 2263 | - * @since 1.0.0 |
|
| 2264 | - * @package GeoDirectory |
|
| 2265 | - */ |
|
| 2266 | - $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2267 | - |
|
| 2268 | - /** |
|
| 2269 | - * Filter to modify "fa fa-heart" icon |
|
| 2270 | - * |
|
| 2271 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2272 | - * |
|
| 2273 | - * @since 1.0.0 |
|
| 2274 | - * @package GeoDirectory |
|
| 2275 | - */ |
|
| 2276 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2277 | - |
|
| 2278 | - $user_meta_data = array(); |
|
| 2279 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2280 | - |
|
| 2281 | - if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
|
|
| 2282 | - $user_meta_data[] = $post_id; |
|
| 2283 | - } |
|
| 2284 | - |
|
| 2285 | - update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
| 2286 | - |
|
| 2287 | - /** |
|
| 2288 | - * Called before adding the post from favourites. |
|
| 2289 | - * |
|
| 2290 | - * @since 1.0.0 |
|
| 2291 | - * @package GeoDirectory |
|
| 2292 | - * @param int $post_id The post ID. |
|
| 2293 | - */ |
|
| 2294 | - do_action('geodir_before_add_from_favorite', $post_id);
|
|
| 2295 | - |
|
| 2296 | - echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
| 2235 | + /** |
|
| 2236 | + * This function would add listing to favorite listing. |
|
| 2237 | + * |
|
| 2238 | + * @since 1.0.0 |
|
| 2239 | + * @package GeoDirectory |
|
| 2240 | + * @global object $current_user Current user object. |
|
| 2241 | + * @param int $post_id The post ID. |
|
| 2242 | + */ |
|
| 2243 | + function geodir_add_to_favorite($post_id) |
|
| 2244 | + {
|
|
| 2245 | + |
|
| 2246 | + global $current_user; |
|
| 2247 | + |
|
| 2248 | + /** |
|
| 2249 | + * Filter to modify "Unfavorite" text |
|
| 2250 | + * |
|
| 2251 | + * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2252 | + * |
|
| 2253 | + * @since 1.0.0 |
|
| 2254 | + * @package GeoDirectory |
|
| 2255 | + */ |
|
| 2256 | + $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2257 | + |
|
| 2258 | + /** |
|
| 2259 | + * Filter to modify "Remove from Favorites" text |
|
| 2260 | + * |
|
| 2261 | + * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2262 | + * |
|
| 2263 | + * @since 1.0.0 |
|
| 2264 | + * @package GeoDirectory |
|
| 2265 | + */ |
|
| 2266 | + $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2267 | + |
|
| 2268 | + /** |
|
| 2269 | + * Filter to modify "fa fa-heart" icon |
|
| 2270 | + * |
|
| 2271 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2272 | + * |
|
| 2273 | + * @since 1.0.0 |
|
| 2274 | + * @package GeoDirectory |
|
| 2275 | + */ |
|
| 2276 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2277 | + |
|
| 2278 | + $user_meta_data = array(); |
|
| 2279 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2280 | + |
|
| 2281 | + if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
|
|
| 2282 | + $user_meta_data[] = $post_id; |
|
| 2283 | + } |
|
| 2284 | + |
|
| 2285 | + update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
| 2286 | + |
|
| 2287 | + /** |
|
| 2288 | + * Called before adding the post from favourites. |
|
| 2289 | + * |
|
| 2290 | + * @since 1.0.0 |
|
| 2291 | + * @package GeoDirectory |
|
| 2292 | + * @param int $post_id The post ID. |
|
| 2293 | + */ |
|
| 2294 | + do_action('geodir_before_add_from_favorite', $post_id);
|
|
| 2295 | + |
|
| 2296 | + echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
| 2297 | + |
|
| 2298 | + /** |
|
| 2299 | + * Called after adding the post from favourites. |
|
| 2300 | + * |
|
| 2301 | + * @since 1.0.0 |
|
| 2302 | + * @package GeoDirectory |
|
| 2303 | + * @param int $post_id The post ID. |
|
| 2304 | + */ |
|
| 2305 | + do_action('geodir_after_add_from_favorite', $post_id);
|
|
| 2297 | 2306 | |
| 2298 | - /** |
|
| 2299 | - * Called after adding the post from favourites. |
|
| 2300 | - * |
|
| 2301 | - * @since 1.0.0 |
|
| 2302 | - * @package GeoDirectory |
|
| 2303 | - * @param int $post_id The post ID. |
|
| 2304 | - */ |
|
| 2305 | - do_action('geodir_after_add_from_favorite', $post_id);
|
|
| 2306 | - |
|
| 2307 | - } |
|
| 2307 | + } |
|
| 2308 | 2308 | } |
| 2309 | 2309 | |
| 2310 | 2310 | if (!function_exists('geodir_remove_from_favorite')) {
|
| 2311 | - /** |
|
| 2312 | - * This function would remove the favourited property earlier. |
|
| 2313 | - * |
|
| 2314 | - * @since 1.0.0 |
|
| 2315 | - * @package GeoDirectory |
|
| 2316 | - * @global object $current_user Current user object. |
|
| 2317 | - * @param int $post_id The post ID. |
|
| 2318 | - */ |
|
| 2319 | - function geodir_remove_from_favorite($post_id) |
|
| 2320 | - {
|
|
| 2321 | - global $current_user; |
|
| 2322 | - |
|
| 2323 | - /** |
|
| 2324 | - * Filter to modify "Add to Favorites" text |
|
| 2325 | - * |
|
| 2326 | - * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2327 | - * |
|
| 2328 | - * @since 1.0.0 |
|
| 2329 | - * @package GeoDirectory |
|
| 2330 | - */ |
|
| 2331 | - $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2332 | - |
|
| 2333 | - /** |
|
| 2334 | - * Filter to modify "Favourite" text |
|
| 2335 | - * |
|
| 2336 | - * You can use this filter to rename "Favourite" text to something else. |
|
| 2337 | - * |
|
| 2338 | - * @since 1.0.0 |
|
| 2339 | - * @package GeoDirectory |
|
| 2340 | - */ |
|
| 2341 | - $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2342 | - |
|
| 2343 | - /** |
|
| 2344 | - * Filter to modify "fa fa-heart" icon |
|
| 2345 | - * |
|
| 2346 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2347 | - * |
|
| 2348 | - * @since 1.0.0 |
|
| 2349 | - * @package GeoDirectory |
|
| 2350 | - */ |
|
| 2351 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2352 | - |
|
| 2353 | - $user_meta_data = array(); |
|
| 2354 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2355 | - |
|
| 2356 | - if (!empty($user_meta_data)) {
|
|
| 2311 | + /** |
|
| 2312 | + * This function would remove the favourited property earlier. |
|
| 2313 | + * |
|
| 2314 | + * @since 1.0.0 |
|
| 2315 | + * @package GeoDirectory |
|
| 2316 | + * @global object $current_user Current user object. |
|
| 2317 | + * @param int $post_id The post ID. |
|
| 2318 | + */ |
|
| 2319 | + function geodir_remove_from_favorite($post_id) |
|
| 2320 | + {
|
|
| 2321 | + global $current_user; |
|
| 2322 | + |
|
| 2323 | + /** |
|
| 2324 | + * Filter to modify "Add to Favorites" text |
|
| 2325 | + * |
|
| 2326 | + * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2327 | + * |
|
| 2328 | + * @since 1.0.0 |
|
| 2329 | + * @package GeoDirectory |
|
| 2330 | + */ |
|
| 2331 | + $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2332 | + |
|
| 2333 | + /** |
|
| 2334 | + * Filter to modify "Favourite" text |
|
| 2335 | + * |
|
| 2336 | + * You can use this filter to rename "Favourite" text to something else. |
|
| 2337 | + * |
|
| 2338 | + * @since 1.0.0 |
|
| 2339 | + * @package GeoDirectory |
|
| 2340 | + */ |
|
| 2341 | + $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2342 | + |
|
| 2343 | + /** |
|
| 2344 | + * Filter to modify "fa fa-heart" icon |
|
| 2345 | + * |
|
| 2346 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2347 | + * |
|
| 2348 | + * @since 1.0.0 |
|
| 2349 | + * @package GeoDirectory |
|
| 2350 | + */ |
|
| 2351 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2352 | + |
|
| 2353 | + $user_meta_data = array(); |
|
| 2354 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2355 | + |
|
| 2356 | + if (!empty($user_meta_data)) {
|
|
| 2357 | + |
|
| 2358 | + if (($key = array_search($post_id, $user_meta_data)) !== false) {
|
|
| 2359 | + unset($user_meta_data[$key]); |
|
| 2360 | + } |
|
| 2357 | 2361 | |
| 2358 | - if (($key = array_search($post_id, $user_meta_data)) !== false) {
|
|
| 2359 | - unset($user_meta_data[$key]); |
|
| 2360 | - } |
|
| 2362 | + } |
|
| 2361 | 2363 | |
| 2362 | - } |
|
| 2364 | + update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
| 2363 | 2365 | |
| 2364 | - update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
| 2366 | + /** |
|
| 2367 | + * Called before removing the post from favourites. |
|
| 2368 | + * |
|
| 2369 | + * @since 1.0.0 |
|
| 2370 | + * @package GeoDirectory |
|
| 2371 | + * @param int $post_id The post ID. |
|
| 2372 | + */ |
|
| 2373 | + do_action('geodir_before_remove_from_favorite', $post_id);
|
|
| 2365 | 2374 | |
| 2366 | - /** |
|
| 2367 | - * Called before removing the post from favourites. |
|
| 2368 | - * |
|
| 2369 | - * @since 1.0.0 |
|
| 2370 | - * @package GeoDirectory |
|
| 2371 | - * @param int $post_id The post ID. |
|
| 2372 | - */ |
|
| 2373 | - do_action('geodir_before_remove_from_favorite', $post_id);
|
|
| 2375 | + echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
| 2374 | 2376 | |
| 2375 | - echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
| 2377 | + /** |
|
| 2378 | + * Called after removing the post from favourites. |
|
| 2379 | + * |
|
| 2380 | + * @since 1.0.0 |
|
| 2381 | + * @package GeoDirectory |
|
| 2382 | + * @param int $post_id The post ID. |
|
| 2383 | + */ |
|
| 2384 | + do_action('geodir_after_remove_from_favorite', $post_id);
|
|
| 2376 | 2385 | |
| 2377 | - /** |
|
| 2378 | - * Called after removing the post from favourites. |
|
| 2379 | - * |
|
| 2380 | - * @since 1.0.0 |
|
| 2381 | - * @package GeoDirectory |
|
| 2382 | - * @param int $post_id The post ID. |
|
| 2383 | - */ |
|
| 2384 | - do_action('geodir_after_remove_from_favorite', $post_id);
|
|
| 2385 | - |
|
| 2386 | - } |
|
| 2386 | + } |
|
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | if (!function_exists('geodir_favourite_html')) {
|
| 2390 | - /** |
|
| 2391 | - * This function would display the html content for add to favorite or remove from favorite. |
|
| 2392 | - * |
|
| 2393 | - * @since 1.0.0 |
|
| 2394 | - * @package GeoDirectory |
|
| 2395 | - * @global object $current_user Current user object. |
|
| 2396 | - * @global object $post The current post object. |
|
| 2397 | - * @param int $user_id The user ID. |
|
| 2398 | - * @param int $post_id The post ID. |
|
| 2399 | - */ |
|
| 2400 | - function geodir_favourite_html($user_id, $post_id) |
|
| 2401 | - {
|
|
| 2402 | - |
|
| 2403 | - global $current_user, $post; |
|
| 2404 | - |
|
| 2405 | - /** |
|
| 2406 | - * Filter to modify "Add to Favorites" text |
|
| 2407 | - * |
|
| 2408 | - * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2409 | - * |
|
| 2410 | - * @since 1.0.0 |
|
| 2411 | - * @package GeoDirectory |
|
| 2412 | - */ |
|
| 2413 | - $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2414 | - |
|
| 2415 | - /** |
|
| 2416 | - * Filter to modify "Favourite" text |
|
| 2417 | - * |
|
| 2418 | - * You can use this filter to rename "Favourite" text to something else. |
|
| 2419 | - * |
|
| 2420 | - * @since 1.0.0 |
|
| 2421 | - * @package GeoDirectory |
|
| 2422 | - */ |
|
| 2423 | - $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2424 | - |
|
| 2425 | - /** |
|
| 2426 | - * Filter to modify "Unfavorite" text |
|
| 2427 | - * |
|
| 2428 | - * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2429 | - * |
|
| 2430 | - * @since 1.0.0 |
|
| 2431 | - * @package GeoDirectory |
|
| 2432 | - */ |
|
| 2433 | - $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2434 | - |
|
| 2435 | - /** |
|
| 2436 | - * Filter to modify "Remove from Favorites" text |
|
| 2437 | - * |
|
| 2438 | - * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2439 | - * |
|
| 2440 | - * @since 1.0.0 |
|
| 2441 | - * @package GeoDirectory |
|
| 2442 | - */ |
|
| 2443 | - $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2444 | - |
|
| 2445 | - /** |
|
| 2446 | - * Filter to modify "fa fa-heart" icon |
|
| 2447 | - * |
|
| 2448 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2449 | - * |
|
| 2450 | - * @since 1.0.0 |
|
| 2451 | - * @package GeoDirectory |
|
| 2452 | - */ |
|
| 2453 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2454 | - |
|
| 2455 | - /** |
|
| 2456 | - * Filter to modify "fa fa-heart" icon for "remove from favorites" link |
|
| 2457 | - * |
|
| 2458 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2459 | - * |
|
| 2460 | - * @since 1.0.0 |
|
| 2461 | - * @package GeoDirectory |
|
| 2462 | - */ |
|
| 2463 | - $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
|
|
| 2464 | - |
|
| 2465 | - $user_meta_data = ''; |
|
| 2466 | - if (isset($current_user->data->ID)) |
|
| 2467 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2468 | - |
|
| 2469 | - if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
|
| 2470 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
| 2390 | + /** |
|
| 2391 | + * This function would display the html content for add to favorite or remove from favorite. |
|
| 2392 | + * |
|
| 2393 | + * @since 1.0.0 |
|
| 2394 | + * @package GeoDirectory |
|
| 2395 | + * @global object $current_user Current user object. |
|
| 2396 | + * @global object $post The current post object. |
|
| 2397 | + * @param int $user_id The user ID. |
|
| 2398 | + * @param int $post_id The post ID. |
|
| 2399 | + */ |
|
| 2400 | + function geodir_favourite_html($user_id, $post_id) |
|
| 2401 | + {
|
|
| 2402 | + |
|
| 2403 | + global $current_user, $post; |
|
| 2404 | + |
|
| 2405 | + /** |
|
| 2406 | + * Filter to modify "Add to Favorites" text |
|
| 2407 | + * |
|
| 2408 | + * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2409 | + * |
|
| 2410 | + * @since 1.0.0 |
|
| 2411 | + * @package GeoDirectory |
|
| 2412 | + */ |
|
| 2413 | + $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2414 | + |
|
| 2415 | + /** |
|
| 2416 | + * Filter to modify "Favourite" text |
|
| 2417 | + * |
|
| 2418 | + * You can use this filter to rename "Favourite" text to something else. |
|
| 2419 | + * |
|
| 2420 | + * @since 1.0.0 |
|
| 2421 | + * @package GeoDirectory |
|
| 2422 | + */ |
|
| 2423 | + $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2424 | + |
|
| 2425 | + /** |
|
| 2426 | + * Filter to modify "Unfavorite" text |
|
| 2427 | + * |
|
| 2428 | + * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2429 | + * |
|
| 2430 | + * @since 1.0.0 |
|
| 2431 | + * @package GeoDirectory |
|
| 2432 | + */ |
|
| 2433 | + $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2434 | + |
|
| 2435 | + /** |
|
| 2436 | + * Filter to modify "Remove from Favorites" text |
|
| 2437 | + * |
|
| 2438 | + * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2439 | + * |
|
| 2440 | + * @since 1.0.0 |
|
| 2441 | + * @package GeoDirectory |
|
| 2442 | + */ |
|
| 2443 | + $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2444 | + |
|
| 2445 | + /** |
|
| 2446 | + * Filter to modify "fa fa-heart" icon |
|
| 2447 | + * |
|
| 2448 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2449 | + * |
|
| 2450 | + * @since 1.0.0 |
|
| 2451 | + * @package GeoDirectory |
|
| 2452 | + */ |
|
| 2453 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2454 | + |
|
| 2455 | + /** |
|
| 2456 | + * Filter to modify "fa fa-heart" icon for "remove from favorites" link |
|
| 2457 | + * |
|
| 2458 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2459 | + * |
|
| 2460 | + * @since 1.0.0 |
|
| 2461 | + * @package GeoDirectory |
|
| 2462 | + */ |
|
| 2463 | + $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
|
|
| 2464 | + |
|
| 2465 | + $user_meta_data = ''; |
|
| 2466 | + if (isset($current_user->data->ID)) |
|
| 2467 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2468 | + |
|
| 2469 | + if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
|
| 2470 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
| 2471 | 2471 | class="geodir-removetofav-icon" href="javascript:void(0);" |
| 2472 | 2472 | onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');" |
| 2473 | 2473 | title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?> |
| 2474 | 2474 | </a> </span><?php |
| 2475 | 2475 | |
| 2476 | - } else {
|
|
| 2476 | + } else {
|
|
| 2477 | 2477 | |
| 2478 | - if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
|
| 2479 | - $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
| 2480 | - } else |
|
| 2481 | - $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2478 | + if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
|
| 2479 | + $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
| 2480 | + } else |
|
| 2481 | + $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2482 | 2482 | |
| 2483 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
| 2483 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
| 2484 | 2484 | href="javascript:void(0);" |
| 2485 | 2485 | onclick="<?php echo $script_text;?>" |
| 2486 | 2486 | title="<?php echo $add_favourite_text;?>"><i |
| 2487 | 2487 | class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span> |
| 2488 | 2488 | <?php } |
| 2489 | - } |
|
| 2489 | + } |
|
| 2490 | 2490 | } |
| 2491 | 2491 | |
| 2492 | 2492 | |
@@ -2503,54 +2503,54 @@ discard block |
||
| 2503 | 2503 | function geodir_get_cat_postcount($term = array()) |
| 2504 | 2504 | {
|
| 2505 | 2505 | |
| 2506 | - if (!empty($term)) {
|
|
| 2506 | + if (!empty($term)) {
|
|
| 2507 | 2507 | |
| 2508 | - global $wpdb, $plugin_prefix; |
|
| 2508 | + global $wpdb, $plugin_prefix; |
|
| 2509 | 2509 | |
| 2510 | - $where = ''; |
|
| 2511 | - $join = ''; |
|
| 2512 | - if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
|
|
| 2513 | - $taxonomy_obj = get_taxonomy($term->taxonomy); |
|
| 2510 | + $where = ''; |
|
| 2511 | + $join = ''; |
|
| 2512 | + if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
|
|
| 2513 | + $taxonomy_obj = get_taxonomy($term->taxonomy); |
|
| 2514 | 2514 | |
| 2515 | - $post_type = $taxonomy_obj->object_type[0]; |
|
| 2515 | + $post_type = $taxonomy_obj->object_type[0]; |
|
| 2516 | 2516 | |
| 2517 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2517 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2518 | 2518 | |
| 2519 | - /** |
|
| 2520 | - * Filter to modify the 'join' query |
|
| 2521 | - * |
|
| 2522 | - * @since 1.0.0 |
|
| 2523 | - * @package GeoDirectory |
|
| 2524 | - * @param object|array $term category / term object that need to be processed. |
|
| 2525 | - * @param string $join The join query. |
|
| 2526 | - */ |
|
| 2527 | - $join = apply_filters('geodir_cat_post_count_join', $join, $term);
|
|
| 2519 | + /** |
|
| 2520 | + * Filter to modify the 'join' query |
|
| 2521 | + * |
|
| 2522 | + * @since 1.0.0 |
|
| 2523 | + * @package GeoDirectory |
|
| 2524 | + * @param object|array $term category / term object that need to be processed. |
|
| 2525 | + * @param string $join The join query. |
|
| 2526 | + */ |
|
| 2527 | + $join = apply_filters('geodir_cat_post_count_join', $join, $term);
|
|
| 2528 | 2528 | |
| 2529 | - /** |
|
| 2530 | - * Filter to modify the 'where' query |
|
| 2531 | - * |
|
| 2532 | - * @since 1.0.0 |
|
| 2533 | - * @package GeoDirectory |
|
| 2534 | - * @param object|array $term category / term object that need to be processed. |
|
| 2535 | - * @param string $where The where query. |
|
| 2536 | - */ |
|
| 2537 | - $where = apply_filters('geodir_cat_post_count_where', $where, $term);
|
|
| 2529 | + /** |
|
| 2530 | + * Filter to modify the 'where' query |
|
| 2531 | + * |
|
| 2532 | + * @since 1.0.0 |
|
| 2533 | + * @package GeoDirectory |
|
| 2534 | + * @param object|array $term category / term object that need to be processed. |
|
| 2535 | + * @param string $where The where query. |
|
| 2536 | + */ |
|
| 2537 | + $where = apply_filters('geodir_cat_post_count_where', $where, $term);
|
|
| 2538 | 2538 | |
| 2539 | - $count_query = "SELECT count(post_id) FROM |
|
| 2539 | + $count_query = "SELECT count(post_id) FROM |
|
| 2540 | 2540 | " . $table . " as pd " . $join . " |
| 2541 | 2541 | WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
|
| 2542 | 2542 | |
| 2543 | - $cat_post_count = $wpdb->get_var($count_query); |
|
| 2544 | - if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
| 2545 | - $cat_post_count = 0; |
|
| 2543 | + $cat_post_count = $wpdb->get_var($count_query); |
|
| 2544 | + if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
| 2545 | + $cat_post_count = 0; |
|
| 2546 | 2546 | |
| 2547 | - return $cat_post_count; |
|
| 2547 | + return $cat_post_count; |
|
| 2548 | 2548 | |
| 2549 | - } else |
|
| 2549 | + } else |
|
| 2550 | 2550 | |
| 2551 | - return $term->count; |
|
| 2552 | - } |
|
| 2553 | - return false; |
|
| 2551 | + return $term->count; |
|
| 2552 | + } |
|
| 2553 | + return false; |
|
| 2554 | 2554 | |
| 2555 | 2555 | } |
| 2556 | 2556 | |
@@ -2563,17 +2563,17 @@ discard block |
||
| 2563 | 2563 | */ |
| 2564 | 2564 | function geodir_allow_post_type_frontend() |
| 2565 | 2565 | {
|
| 2566 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2566 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2567 | 2567 | |
| 2568 | - if (!is_admin() && isset($_REQUEST['listing_type']) |
|
| 2569 | - && !empty($geodir_allow_posttype_frontend) |
|
| 2570 | - && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend) |
|
| 2571 | - ) {
|
|
| 2568 | + if (!is_admin() && isset($_REQUEST['listing_type']) |
|
| 2569 | + && !empty($geodir_allow_posttype_frontend) |
|
| 2570 | + && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend) |
|
| 2571 | + ) {
|
|
| 2572 | 2572 | |
| 2573 | - wp_redirect(home_url()); |
|
| 2574 | - exit; |
|
| 2573 | + wp_redirect(home_url()); |
|
| 2574 | + exit; |
|
| 2575 | 2575 | |
| 2576 | - } |
|
| 2576 | + } |
|
| 2577 | 2577 | |
| 2578 | 2578 | } |
| 2579 | 2579 | |
@@ -2590,20 +2590,20 @@ discard block |
||
| 2590 | 2590 | */ |
| 2591 | 2591 | function geodir_excerpt_length($length) |
| 2592 | 2592 | {
|
| 2593 | - global $wp_query, $geodir_is_widget_listing; |
|
| 2593 | + global $wp_query, $geodir_is_widget_listing; |
|
| 2594 | 2594 | if ($geodir_is_widget_listing) {
|
| 2595 | 2595 | return $length; |
| 2596 | 2596 | } |
| 2597 | 2597 | |
| 2598 | - if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
|
|
| 2599 | - $length = get_option('geodir_desc_word_limit');
|
|
| 2600 | - elseif (get_query_var('excerpt_length'))
|
|
| 2601 | - $length = get_query_var('excerpt_length');
|
|
| 2598 | + if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
|
|
| 2599 | + $length = get_option('geodir_desc_word_limit');
|
|
| 2600 | + elseif (get_query_var('excerpt_length'))
|
|
| 2601 | + $length = get_query_var('excerpt_length');
|
|
| 2602 | 2602 | |
| 2603 | - if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
|
|
| 2604 | - $length = get_option('geodir_author_desc_word_limit');
|
|
| 2603 | + if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
|
|
| 2604 | + $length = get_option('geodir_author_desc_word_limit');
|
|
| 2605 | 2605 | |
| 2606 | - return $length; |
|
| 2606 | + return $length; |
|
| 2607 | 2607 | } |
| 2608 | 2608 | |
| 2609 | 2609 | /** |
@@ -2618,13 +2618,13 @@ discard block |
||
| 2618 | 2618 | */ |
| 2619 | 2619 | function geodir_excerpt_more($more) |
| 2620 | 2620 | {
|
| 2621 | - global $post; |
|
| 2622 | - $all_postypes = geodir_get_posttypes(); |
|
| 2623 | - if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
|
| 2624 | - return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>'; |
|
| 2625 | - } |
|
| 2621 | + global $post; |
|
| 2622 | + $all_postypes = geodir_get_posttypes(); |
|
| 2623 | + if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
|
| 2624 | + return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>'; |
|
| 2625 | + } |
|
| 2626 | 2626 | |
| 2627 | - return $more; |
|
| 2627 | + return $more; |
|
| 2628 | 2628 | } |
| 2629 | 2629 | |
| 2630 | 2630 | |
@@ -2641,63 +2641,63 @@ discard block |
||
| 2641 | 2641 | */ |
| 2642 | 2642 | function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy) |
| 2643 | 2643 | {
|
| 2644 | - global $plugin_prefix, $wpdb; |
|
| 2644 | + global $plugin_prefix, $wpdb; |
|
| 2645 | 2645 | |
| 2646 | - $gd_taxonomies = geodir_get_taxonomies(); |
|
| 2646 | + $gd_taxonomies = geodir_get_taxonomies(); |
|
| 2647 | 2647 | |
| 2648 | - if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
|
|
| 2648 | + if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
|
|
| 2649 | 2649 | |
| 2650 | - $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
|
| 2651 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 2650 | + $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
|
| 2651 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 2652 | 2652 | |
| 2653 | - $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
|
| 2654 | - $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
| 2653 | + $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
|
| 2654 | + $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
| 2655 | 2655 | |
| 2656 | - $posts = $wpdb->get_results( |
|
| 2657 | - $wpdb->prepare( |
|
| 2658 | - "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2659 | - array($term_id, $taxonomy) |
|
| 2660 | - ) |
|
| 2661 | - ); |
|
| 2656 | + $posts = $wpdb->get_results( |
|
| 2657 | + $wpdb->prepare( |
|
| 2658 | + "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2659 | + array($term_id, $taxonomy) |
|
| 2660 | + ) |
|
| 2661 | + ); |
|
| 2662 | 2662 | |
| 2663 | - if (!empty($posts)): |
|
| 2664 | - foreach ($posts as $post_obj) {
|
|
| 2663 | + if (!empty($posts)): |
|
| 2664 | + foreach ($posts as $post_obj) {
|
|
| 2665 | 2665 | |
| 2666 | - $lat = $post_obj->post_latitude; |
|
| 2667 | - $lng = $post_obj->post_longitude; |
|
| 2666 | + $lat = $post_obj->post_latitude; |
|
| 2667 | + $lng = $post_obj->post_longitude; |
|
| 2668 | 2668 | |
| 2669 | - $json = '{';
|
|
| 2670 | - $json .= '"id":"' . $post_obj->post_id . '",'; |
|
| 2671 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 2672 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 2673 | - $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
| 2674 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 2675 | - $json .= '"group":"catgroup' . $term_id . '"'; |
|
| 2676 | - $json .= '}'; |
|
| 2669 | + $json = '{';
|
|
| 2670 | + $json .= '"id":"' . $post_obj->post_id . '",'; |
|
| 2671 | + $json .= '"lat_pos": "' . $lat . '",'; |
|
| 2672 | + $json .= '"long_pos": "' . $lng . '",'; |
|
| 2673 | + $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
| 2674 | + $json .= '"icon":"' . $term_icon . '",'; |
|
| 2675 | + $json .= '"group":"catgroup' . $term_id . '"'; |
|
| 2676 | + $json .= '}'; |
|
| 2677 | 2677 | |
| 2678 | - if ($post_obj->default_category == $term_id) {
|
|
| 2678 | + if ($post_obj->default_category == $term_id) {
|
|
| 2679 | 2679 | |
| 2680 | - $wpdb->query( |
|
| 2681 | - $wpdb->prepare( |
|
| 2682 | - "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
| 2683 | - array($json, $post_obj->post_id) |
|
| 2684 | - ) |
|
| 2685 | - ); |
|
| 2686 | - } |
|
| 2680 | + $wpdb->query( |
|
| 2681 | + $wpdb->prepare( |
|
| 2682 | + "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
| 2683 | + array($json, $post_obj->post_id) |
|
| 2684 | + ) |
|
| 2685 | + ); |
|
| 2686 | + } |
|
| 2687 | 2687 | |
| 2688 | - $wpdb->query( |
|
| 2689 | - $wpdb->prepare( |
|
| 2690 | - "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2691 | - array($json, $post_obj->post_id, $term_id) |
|
| 2692 | - ) |
|
| 2693 | - ); |
|
| 2688 | + $wpdb->query( |
|
| 2689 | + $wpdb->prepare( |
|
| 2690 | + "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2691 | + array($json, $post_obj->post_id, $term_id) |
|
| 2692 | + ) |
|
| 2693 | + ); |
|
| 2694 | 2694 | |
| 2695 | - } |
|
| 2695 | + } |
|
| 2696 | 2696 | |
| 2697 | 2697 | |
| 2698 | - endif; |
|
| 2698 | + endif; |
|
| 2699 | 2699 | |
| 2700 | - } |
|
| 2700 | + } |
|
| 2701 | 2701 | |
| 2702 | 2702 | } |
| 2703 | 2703 | |
@@ -2711,14 +2711,14 @@ discard block |
||
| 2711 | 2711 | */ |
| 2712 | 2712 | function geodir_get_listing_author($listing_id = '') |
| 2713 | 2713 | {
|
| 2714 | - if ($listing_id == '') {
|
|
| 2715 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2716 | - $listing_id = $_REQUEST['pid']; |
|
| 2717 | - } |
|
| 2718 | - } |
|
| 2719 | - $listing = get_post(strip_tags($listing_id)); |
|
| 2720 | - $listing_author_id = $listing->post_author; |
|
| 2721 | - return $listing_author_id; |
|
| 2714 | + if ($listing_id == '') {
|
|
| 2715 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2716 | + $listing_id = $_REQUEST['pid']; |
|
| 2717 | + } |
|
| 2718 | + } |
|
| 2719 | + $listing = get_post(strip_tags($listing_id)); |
|
| 2720 | + $listing_author_id = $listing->post_author; |
|
| 2721 | + return $listing_author_id; |
|
| 2722 | 2722 | } |
| 2723 | 2723 | |
| 2724 | 2724 | |
@@ -2733,11 +2733,11 @@ discard block |
||
| 2733 | 2733 | */ |
| 2734 | 2734 | function geodir_lisiting_belong_to_user($listing_id, $user_id) |
| 2735 | 2735 | {
|
| 2736 | - $listing_author_id = geodir_get_listing_author($listing_id); |
|
| 2737 | - if ($listing_author_id == $user_id) |
|
| 2738 | - return true; |
|
| 2739 | - else |
|
| 2740 | - return false; |
|
| 2736 | + $listing_author_id = geodir_get_listing_author($listing_id); |
|
| 2737 | + if ($listing_author_id == $user_id) |
|
| 2738 | + return true; |
|
| 2739 | + else |
|
| 2740 | + return false; |
|
| 2741 | 2741 | |
| 2742 | 2742 | } |
| 2743 | 2743 | |
@@ -2753,17 +2753,17 @@ discard block |
||
| 2753 | 2753 | */ |
| 2754 | 2754 | function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true) |
| 2755 | 2755 | {
|
| 2756 | - global $current_user; |
|
| 2757 | - if ($exclude_admin) {
|
|
| 2758 | - foreach ($current_user->caps as $key => $caps) {
|
|
| 2759 | - if (geodir_strtolower($key) == 'administrator') {
|
|
| 2760 | - return true; |
|
| 2761 | - break; |
|
| 2762 | - } |
|
| 2763 | - } |
|
| 2764 | - } |
|
| 2765 | - |
|
| 2766 | - return geodir_lisiting_belong_to_user($listing_id, $current_user->ID); |
|
| 2756 | + global $current_user; |
|
| 2757 | + if ($exclude_admin) {
|
|
| 2758 | + foreach ($current_user->caps as $key => $caps) {
|
|
| 2759 | + if (geodir_strtolower($key) == 'administrator') {
|
|
| 2760 | + return true; |
|
| 2761 | + break; |
|
| 2762 | + } |
|
| 2763 | + } |
|
| 2764 | + } |
|
| 2765 | + |
|
| 2766 | + return geodir_lisiting_belong_to_user($listing_id, $current_user->ID); |
|
| 2767 | 2767 | } |
| 2768 | 2768 | |
| 2769 | 2769 | |
@@ -2779,17 +2779,17 @@ discard block |
||
| 2779 | 2779 | function geodir_only_supportable_attachments_remove($file) |
| 2780 | 2780 | {
|
| 2781 | 2781 | |
| 2782 | - global $wpdb; |
|
| 2782 | + global $wpdb; |
|
| 2783 | 2783 | |
| 2784 | - $matches = array(); |
|
| 2784 | + $matches = array(); |
|
| 2785 | 2785 | |
| 2786 | - $pattern = '/-\d+x\d+\./'; |
|
| 2787 | - preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
|
| 2786 | + $pattern = '/-\d+x\d+\./'; |
|
| 2787 | + preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
|
| 2788 | 2788 | |
| 2789 | - if (empty($matches)) |
|
| 2790 | - return ''; |
|
| 2791 | - else |
|
| 2792 | - return $file; |
|
| 2789 | + if (empty($matches)) |
|
| 2790 | + return ''; |
|
| 2791 | + else |
|
| 2792 | + return $file; |
|
| 2793 | 2793 | |
| 2794 | 2794 | } |
| 2795 | 2795 | |
@@ -2806,78 +2806,78 @@ discard block |
||
| 2806 | 2806 | function geodir_set_wp_featured_image($post_id) |
| 2807 | 2807 | {
|
| 2808 | 2808 | |
| 2809 | - global $wpdb, $plugin_prefix; |
|
| 2810 | - $uploads = wp_upload_dir(); |
|
| 2809 | + global $wpdb, $plugin_prefix; |
|
| 2810 | + $uploads = wp_upload_dir(); |
|
| 2811 | 2811 | // print_r($uploads ) ; |
| 2812 | - $post_first_image = $wpdb->get_results( |
|
| 2813 | - $wpdb->prepare( |
|
| 2814 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2815 | - ) |
|
| 2816 | - ); |
|
| 2817 | - |
|
| 2818 | - $old_attachment_name = ''; |
|
| 2819 | - $post_thumbnail_id = ''; |
|
| 2820 | - if (has_post_thumbnail($post_id)) {
|
|
| 2812 | + $post_first_image = $wpdb->get_results( |
|
| 2813 | + $wpdb->prepare( |
|
| 2814 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2815 | + ) |
|
| 2816 | + ); |
|
| 2821 | 2817 | |
| 2822 | - if (has_post_thumbnail($post_id)) {
|
|
| 2818 | + $old_attachment_name = ''; |
|
| 2819 | + $post_thumbnail_id = ''; |
|
| 2820 | + if (has_post_thumbnail($post_id)) {
|
|
| 2823 | 2821 | |
| 2824 | - $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 2822 | + if (has_post_thumbnail($post_id)) {
|
|
| 2825 | 2823 | |
| 2826 | - $old_attachment_name = basename(get_attached_file($post_thumbnail_id)); |
|
| 2824 | + $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 2827 | 2825 | |
| 2828 | - } |
|
| 2829 | - } |
|
| 2826 | + $old_attachment_name = basename(get_attached_file($post_thumbnail_id)); |
|
| 2830 | 2827 | |
| 2831 | - if (!empty($post_first_image)) {
|
|
| 2828 | + } |
|
| 2829 | + } |
|
| 2832 | 2830 | |
| 2833 | - $post_type = get_post_type($post_id); |
|
| 2831 | + if (!empty($post_first_image)) {
|
|
| 2834 | 2832 | |
| 2835 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2833 | + $post_type = get_post_type($post_id); |
|
| 2836 | 2834 | |
| 2837 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
|
|
| 2835 | + $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2838 | 2836 | |
| 2839 | - $new_attachment_name = basename($post_first_image[0]->file); |
|
| 2837 | + $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
|
|
| 2840 | 2838 | |
| 2841 | - if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
|
|
| 2839 | + $new_attachment_name = basename($post_first_image[0]->file); |
|
| 2842 | 2840 | |
| 2843 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
|
|
| 2841 | + if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
|
|
| 2844 | 2842 | |
| 2845 | - add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
|
|
| 2843 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
|
|
| 2846 | 2844 | |
| 2847 | - wp_delete_attachment($post_thumbnail_id); |
|
| 2845 | + add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
|
|
| 2848 | 2846 | |
| 2849 | - } |
|
| 2850 | - $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
| 2847 | + wp_delete_attachment($post_thumbnail_id); |
|
| 2851 | 2848 | |
| 2852 | - $attachment = array( |
|
| 2853 | - 'post_mime_type' => $post_first_image[0]->mime_type, |
|
| 2854 | - 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
| 2855 | - 'post_parent' => $post_id, |
|
| 2856 | - 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
|
|
| 2857 | - 'post_content' => '' |
|
| 2858 | - ); |
|
| 2849 | + } |
|
| 2850 | + $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
| 2851 | + |
|
| 2852 | + $attachment = array( |
|
| 2853 | + 'post_mime_type' => $post_first_image[0]->mime_type, |
|
| 2854 | + 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
| 2855 | + 'post_parent' => $post_id, |
|
| 2856 | + 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
|
|
| 2857 | + 'post_content' => '' |
|
| 2858 | + ); |
|
| 2859 | 2859 | |
| 2860 | 2860 | |
| 2861 | - $id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 2861 | + $id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 2862 | 2862 | |
| 2863 | - if (!is_wp_error($id)) {
|
|
| 2863 | + if (!is_wp_error($id)) {
|
|
| 2864 | 2864 | |
| 2865 | - set_post_thumbnail($post_id, $id); |
|
| 2865 | + set_post_thumbnail($post_id, $id); |
|
| 2866 | 2866 | |
| 2867 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 2868 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 2867 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 2868 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 2869 | 2869 | |
| 2870 | - } |
|
| 2870 | + } |
|
| 2871 | 2871 | |
| 2872 | - } |
|
| 2872 | + } |
|
| 2873 | 2873 | |
| 2874 | - } else {
|
|
| 2875 | - //set_post_thumbnail($post_id,-1); |
|
| 2874 | + } else {
|
|
| 2875 | + //set_post_thumbnail($post_id,-1); |
|
| 2876 | 2876 | |
| 2877 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
| 2878 | - wp_delete_attachment($post_thumbnail_id); |
|
| 2877 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
| 2878 | + wp_delete_attachment($post_thumbnail_id); |
|
| 2879 | 2879 | |
| 2880 | - } |
|
| 2880 | + } |
|
| 2881 | 2881 | } |
| 2882 | 2882 | |
| 2883 | 2883 | |
@@ -2892,53 +2892,53 @@ discard block |
||
| 2892 | 2892 | */ |
| 2893 | 2893 | function gd_copy_original_translation() |
| 2894 | 2894 | {
|
| 2895 | - if (function_exists('icl_object_id')) {
|
|
| 2896 | - global $wpdb, $table_prefix, $plugin_prefix; |
|
| 2897 | - $post_id = absint($_POST['post_id']); |
|
| 2898 | - $upload_dir = wp_upload_dir(); |
|
| 2899 | - $post_type = get_post_type($_POST['post_id']); |
|
| 2900 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2901 | - |
|
| 2902 | - $post_arr = $wpdb->get_results($wpdb->prepare( |
|
| 2903 | - "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 2904 | - array($post_id) |
|
| 2905 | - ) |
|
| 2906 | - , ARRAY_A); |
|
| 2907 | - |
|
| 2908 | - $arrImages = $wpdb->get_results( |
|
| 2909 | - $wpdb->prepare( |
|
| 2910 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 2911 | - array('%image%', $post_id)
|
|
| 2912 | - ) |
|
| 2913 | - ); |
|
| 2914 | - if ($arrImages) {
|
|
| 2915 | - $image_arr = array(); |
|
| 2916 | - foreach ($arrImages as $img) {
|
|
| 2917 | - $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
| 2918 | - } |
|
| 2919 | - $comma_separated = implode(",", $image_arr);
|
|
| 2920 | - $post_arr[0]['post_images'] = $comma_separated; |
|
| 2921 | - } |
|
| 2922 | - |
|
| 2923 | - |
|
| 2924 | - $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
| 2925 | - $cat_arr = array_filter(explode(",", $cats));
|
|
| 2926 | - $trans_cat = array(); |
|
| 2927 | - foreach ($cat_arr as $cat) {
|
|
| 2928 | - $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
| 2929 | - } |
|
| 2930 | - |
|
| 2931 | - |
|
| 2932 | - $post_arr[0]['categories'] = array_filter($trans_cat); |
|
| 2895 | + if (function_exists('icl_object_id')) {
|
|
| 2896 | + global $wpdb, $table_prefix, $plugin_prefix; |
|
| 2897 | + $post_id = absint($_POST['post_id']); |
|
| 2898 | + $upload_dir = wp_upload_dir(); |
|
| 2899 | + $post_type = get_post_type($_POST['post_id']); |
|
| 2900 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2901 | + |
|
| 2902 | + $post_arr = $wpdb->get_results($wpdb->prepare( |
|
| 2903 | + "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 2904 | + array($post_id) |
|
| 2905 | + ) |
|
| 2906 | + , ARRAY_A); |
|
| 2907 | + |
|
| 2908 | + $arrImages = $wpdb->get_results( |
|
| 2909 | + $wpdb->prepare( |
|
| 2910 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 2911 | + array('%image%', $post_id)
|
|
| 2912 | + ) |
|
| 2913 | + ); |
|
| 2914 | + if ($arrImages) {
|
|
| 2915 | + $image_arr = array(); |
|
| 2916 | + foreach ($arrImages as $img) {
|
|
| 2917 | + $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
| 2918 | + } |
|
| 2919 | + $comma_separated = implode(",", $image_arr);
|
|
| 2920 | + $post_arr[0]['post_images'] = $comma_separated; |
|
| 2921 | + } |
|
| 2922 | + |
|
| 2923 | + |
|
| 2924 | + $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
| 2925 | + $cat_arr = array_filter(explode(",", $cats));
|
|
| 2926 | + $trans_cat = array(); |
|
| 2927 | + foreach ($cat_arr as $cat) {
|
|
| 2928 | + $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
| 2929 | + } |
|
| 2930 | + |
|
| 2931 | + |
|
| 2932 | + $post_arr[0]['categories'] = array_filter($trans_cat); |
|
| 2933 | 2933 | //print_r($image_arr); |
| 2934 | - //print_r($arrImages); |
|
| 2935 | - //echo $_REQUEST['lang']; |
|
| 2934 | + //print_r($arrImages); |
|
| 2935 | + //echo $_REQUEST['lang']; |
|
| 2936 | 2936 | //print_r($post_arr); |
| 2937 | 2937 | //print_r($trans_cat); |
| 2938 | - echo json_encode($post_arr[0]); |
|
| 2938 | + echo json_encode($post_arr[0]); |
|
| 2939 | 2939 | |
| 2940 | - } |
|
| 2941 | - die(); |
|
| 2940 | + } |
|
| 2941 | + die(); |
|
| 2942 | 2942 | } |
| 2943 | 2943 | |
| 2944 | 2944 | |
@@ -2958,54 +2958,54 @@ discard block |
||
| 2958 | 2958 | function geodir_get_custom_fields_type($listing_type = '') |
| 2959 | 2959 | {
|
| 2960 | 2960 | |
| 2961 | - global $wpdb; |
|
| 2961 | + global $wpdb; |
|
| 2962 | 2962 | |
| 2963 | - if ($listing_type == '') |
|
| 2964 | - $listing_type = 'gd_place'; |
|
| 2963 | + if ($listing_type == '') |
|
| 2964 | + $listing_type = 'gd_place'; |
|
| 2965 | 2965 | |
| 2966 | - $fields_info = array(); |
|
| 2966 | + $fields_info = array(); |
|
| 2967 | 2967 | |
| 2968 | - $get_data = $wpdb->get_results( |
|
| 2969 | - $wpdb->prepare( |
|
| 2970 | - "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
| 2971 | - array($listing_type) |
|
| 2972 | - ) |
|
| 2973 | - ); |
|
| 2968 | + $get_data = $wpdb->get_results( |
|
| 2969 | + $wpdb->prepare( |
|
| 2970 | + "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
| 2971 | + array($listing_type) |
|
| 2972 | + ) |
|
| 2973 | + ); |
|
| 2974 | 2974 | |
| 2975 | - if (!empty($get_data)) {
|
|
| 2975 | + if (!empty($get_data)) {
|
|
| 2976 | 2976 | |
| 2977 | - foreach ($get_data as $data) {
|
|
| 2977 | + foreach ($get_data as $data) {
|
|
| 2978 | 2978 | |
| 2979 | - if ($data->field_type == 'address') {
|
|
| 2979 | + if ($data->field_type == 'address') {
|
|
| 2980 | 2980 | |
| 2981 | - $extra_fields = unserialize($data->extra_fields); |
|
| 2981 | + $extra_fields = unserialize($data->extra_fields); |
|
| 2982 | 2982 | |
| 2983 | - $prefix = $data->htmlvar_name . '_'; |
|
| 2983 | + $prefix = $data->htmlvar_name . '_'; |
|
| 2984 | 2984 | |
| 2985 | - $fields_info[$prefix . 'address'] = $data->field_type; |
|
| 2985 | + $fields_info[$prefix . 'address'] = $data->field_type; |
|
| 2986 | 2986 | |
| 2987 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
| 2988 | - $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 2987 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
| 2988 | + $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 2989 | 2989 | |
| 2990 | - } else {
|
|
| 2990 | + } else {
|
|
| 2991 | 2991 | |
| 2992 | - $fields_info[$data->htmlvar_name] = $data->field_type; |
|
| 2992 | + $fields_info[$data->htmlvar_name] = $data->field_type; |
|
| 2993 | 2993 | |
| 2994 | - } |
|
| 2994 | + } |
|
| 2995 | 2995 | |
| 2996 | - } |
|
| 2996 | + } |
|
| 2997 | 2997 | |
| 2998 | - } |
|
| 2998 | + } |
|
| 2999 | 2999 | |
| 3000 | - /** |
|
| 3001 | - * Filter to modify custom fields info using listing post type. |
|
| 3002 | - * |
|
| 3003 | - * @since 1.0.0 |
|
| 3004 | - * @package GeoDirectory |
|
| 3005 | - * @return array $fields_info Custom fields info. |
|
| 3006 | - * @param string $listing_type The listing post type. |
|
| 3007 | - */ |
|
| 3008 | - return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
|
|
| 3000 | + /** |
|
| 3001 | + * Filter to modify custom fields info using listing post type. |
|
| 3002 | + * |
|
| 3003 | + * @since 1.0.0 |
|
| 3004 | + * @package GeoDirectory |
|
| 3005 | + * @return array $fields_info Custom fields info. |
|
| 3006 | + * @param string $listing_type The listing post type. |
|
| 3007 | + */ |
|
| 3008 | + return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
|
|
| 3009 | 3009 | } |
| 3010 | 3010 | |
| 3011 | 3011 | |
@@ -3020,58 +3020,58 @@ discard block |
||
| 3020 | 3020 | */ |
| 3021 | 3021 | function geodir_function_post_updated($post_ID, $post_after, $post_before) |
| 3022 | 3022 | {
|
| 3023 | - $post_type = get_post_type($post_ID); |
|
| 3023 | + $post_type = get_post_type($post_ID); |
|
| 3024 | 3024 | |
| 3025 | - if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
|
|
| 3026 | - // send notification to client when post moves from draft to publish |
|
| 3027 | - if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
|
|
| 3028 | - $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; |
|
| 3029 | - $post_author_data = get_userdata($post_author_id); |
|
| 3025 | + if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
|
|
| 3026 | + // send notification to client when post moves from draft to publish |
|
| 3027 | + if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
|
|
| 3028 | + $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; |
|
| 3029 | + $post_author_data = get_userdata($post_author_id); |
|
| 3030 | 3030 | |
| 3031 | - $to_name = geodir_get_client_name($post_author_id); |
|
| 3031 | + $to_name = geodir_get_client_name($post_author_id); |
|
| 3032 | 3032 | |
| 3033 | - $from_email = geodir_get_site_email_id(); |
|
| 3034 | - $from_name = get_site_emailName(); |
|
| 3035 | - $to_email = $post_author_data->user_email; |
|
| 3033 | + $from_email = geodir_get_site_email_id(); |
|
| 3034 | + $from_name = get_site_emailName(); |
|
| 3035 | + $to_email = $post_author_data->user_email; |
|
| 3036 | 3036 | |
| 3037 | - if (!is_email($to_email) && !empty($post_author_data->user_email)) {
|
|
| 3038 | - $to_email = $post_author_data->user_email; |
|
| 3039 | - } |
|
| 3037 | + if (!is_email($to_email) && !empty($post_author_data->user_email)) {
|
|
| 3038 | + $to_email = $post_author_data->user_email; |
|
| 3039 | + } |
|
| 3040 | 3040 | |
| 3041 | - $message_type = 'listing_published'; |
|
| 3041 | + $message_type = 'listing_published'; |
|
| 3042 | 3042 | |
| 3043 | - if (get_option('geodir_post_published_email_subject') == '') {
|
|
| 3044 | - update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
|
|
| 3045 | - } |
|
| 3043 | + if (get_option('geodir_post_published_email_subject') == '') {
|
|
| 3044 | + update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
|
|
| 3045 | + } |
|
| 3046 | 3046 | |
| 3047 | - if (get_option('geodir_post_published_email_content') == '') {
|
|
| 3048 | - update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
|
|
| 3049 | - } |
|
| 3047 | + if (get_option('geodir_post_published_email_content') == '') {
|
|
| 3048 | + update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
|
|
| 3049 | + } |
|
| 3050 | 3050 | |
| 3051 | - /** |
|
| 3052 | - * Called before sending the email when listing gets published. |
|
| 3053 | - * |
|
| 3054 | - * @since 1.0.0 |
|
| 3055 | - * @package GeoDirectory |
|
| 3056 | - * @param object $post_after The post object after update. |
|
| 3057 | - * @param object $post_before The post object before update. |
|
| 3058 | - */ |
|
| 3059 | - do_action('geodir_before_listing_published_email', $post_after, $post_before);
|
|
| 3060 | - if (is_email($to_email)) {
|
|
| 3061 | - geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 3062 | - } |
|
| 3051 | + /** |
|
| 3052 | + * Called before sending the email when listing gets published. |
|
| 3053 | + * |
|
| 3054 | + * @since 1.0.0 |
|
| 3055 | + * @package GeoDirectory |
|
| 3056 | + * @param object $post_after The post object after update. |
|
| 3057 | + * @param object $post_before The post object before update. |
|
| 3058 | + */ |
|
| 3059 | + do_action('geodir_before_listing_published_email', $post_after, $post_before);
|
|
| 3060 | + if (is_email($to_email)) {
|
|
| 3061 | + geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 3062 | + } |
|
| 3063 | 3063 | |
| 3064 | - /** |
|
| 3065 | - * Called after sending the email when listing gets published. |
|
| 3066 | - * |
|
| 3067 | - * @since 1.0.0 |
|
| 3068 | - * @package GeoDirectory |
|
| 3069 | - * @param object $post_after The post object after update. |
|
| 3070 | - * @param object $post_before The post object before update. |
|
| 3071 | - */ |
|
| 3072 | - do_action('geodir_after_listing_published_email', $post_after, $post_before);
|
|
| 3073 | - } |
|
| 3074 | - } |
|
| 3064 | + /** |
|
| 3065 | + * Called after sending the email when listing gets published. |
|
| 3066 | + * |
|
| 3067 | + * @since 1.0.0 |
|
| 3068 | + * @package GeoDirectory |
|
| 3069 | + * @param object $post_after The post object after update. |
|
| 3070 | + * @param object $post_before The post object before update. |
|
| 3071 | + */ |
|
| 3072 | + do_action('geodir_after_listing_published_email', $post_after, $post_before);
|
|
| 3073 | + } |
|
| 3074 | + } |
|
| 3075 | 3075 | } |
| 3076 | 3076 | |
| 3077 | 3077 | add_action('wp_head', 'geodir_fb_like_thumbnail');
|
@@ -3085,14 +3085,14 @@ discard block |
||
| 3085 | 3085 | */ |
| 3086 | 3086 | function geodir_fb_like_thumbnail(){
|
| 3087 | 3087 | |
| 3088 | - // return if not a single post |
|
| 3089 | - if(!is_single()){return;}
|
|
| 3088 | + // return if not a single post |
|
| 3089 | + if(!is_single()){return;}
|
|
| 3090 | 3090 | |
| 3091 | - global $post; |
|
| 3092 | - if(isset($post->featured_image) && $post->featured_image){
|
|
| 3093 | - $upload_dir = wp_upload_dir(); |
|
| 3094 | - $thumb = $upload_dir['baseurl'].$post->featured_image; |
|
| 3095 | - echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
|
| 3091 | + global $post; |
|
| 3092 | + if(isset($post->featured_image) && $post->featured_image){
|
|
| 3093 | + $upload_dir = wp_upload_dir(); |
|
| 3094 | + $thumb = $upload_dir['baseurl'].$post->featured_image; |
|
| 3095 | + echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
|
| 3096 | 3096 | |
| 3097 | - } |
|
| 3097 | + } |
|
| 3098 | 3098 | } |
| 3099 | 3099 | \ No newline at end of file |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | if (!isset($default_cat) || empty($default_cat)) {
|
| 28 | 28 | $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
| 29 | - }else{
|
|
| 30 | - if(!is_int($default_cat)){
|
|
| 29 | + } else {
|
|
| 30 | + if (!is_int($default_cat)) {
|
|
| 31 | 31 | $category = get_term_by('name', $default_cat, $taxonomy);
|
| 32 | - if(isset($category->term_id)){
|
|
| 33 | - $default_cat = $category->term_id; |
|
| 32 | + if (isset($category->term_id)) {
|
|
| 33 | + $default_cat = $category->term_id; |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | if ($default_pos === false) {
|
| 60 | 60 | |
| 61 | - $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
| 61 | + $change_cat_str = str_replace($default_cat.',y:', $default_cat.',y,d:', $change_cat_str); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $gd_post = $post; |
| 147 | 147 | if (!empty($gd_post) && is_array($gd_post)) {
|
| 148 | - $gd_post = (object)$post; |
|
| 148 | + $gd_post = (object) $post; |
|
| 149 | 149 | |
| 150 | 150 | // Fix WPML duplicate. |
| 151 | 151 | if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
|
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $send_post_submit_mail = false; |
| 240 | 240 | |
| 241 | 241 | // unhook this function so it doesn't loop infinitely |
| 242 | - remove_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 242 | + remove_action('save_post', 'geodir_post_information_save', 10, 2);
|
|
| 243 | 243 | |
| 244 | 244 | if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
| 245 | 245 | $post['ID'] = $request_info['pid']; |
@@ -263,13 +263,13 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // re-hook this function |
| 266 | - add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 266 | + add_action('save_post', 'geodir_post_information_save', 10, 2);
|
|
| 267 | 267 | |
| 268 | 268 | $post_tags = ''; |
| 269 | 269 | if (!isset($request_info['post_tags'])) {
|
| 270 | 270 | |
| 271 | 271 | $post_type = $request_info['listing_type']; |
| 272 | - $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
|
|
| 272 | + $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type.'_tags', array('fields' => 'names')));
|
|
| 273 | 273 | |
| 274 | 274 | } |
| 275 | 275 | |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | $payment_info = array(); |
| 288 | 288 | $package_info = array(); |
| 289 | 289 | |
| 290 | - $package_info = (array)geodir_post_package_info($package_info, $post); |
|
| 290 | + $package_info = (array) geodir_post_package_info($package_info, $post); |
|
| 291 | 291 | |
| 292 | 292 | $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
| 293 | 293 | |
| 294 | 294 | if (!empty($package_info) && !$post_package_id) {
|
| 295 | 295 | if (isset($package_info['days']) && $package_info['days'] != 0) {
|
| 296 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
|
|
| 296 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['days']." days"));
|
|
| 297 | 297 | } else {
|
| 298 | 298 | $payment_info['expire_date'] = 'Never'; |
| 299 | 299 | } |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | $extrafields = $val['extra_fields']; |
| 315 | 315 | |
| 316 | 316 | if (trim($type) == 'address') {
|
| 317 | - $prefix = $name . '_'; |
|
| 318 | - $address = $prefix . 'address'; |
|
| 317 | + $prefix = $name.'_'; |
|
| 318 | + $address = $prefix.'address'; |
|
| 319 | 319 | |
| 320 | 320 | if (isset($request_info[$address]) && $request_info[$address] != '') {
|
| 321 | 321 | $gd_post_info[$address] = wp_slash($request_info[$address]); |
@@ -325,59 +325,59 @@ discard block |
||
| 325 | 325 | $extrafields = unserialize($extrafields); |
| 326 | 326 | |
| 327 | 327 | |
| 328 | - if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
|
|
| 328 | + if (!isset($request_info[$prefix.'city']) || $request_info[$prefix.'city'] == '') {
|
|
| 329 | 329 | |
| 330 | 330 | $location_result = geodir_get_default_location(); |
| 331 | 331 | |
| 332 | - $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
| 333 | - $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
| 334 | - $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
| 332 | + $gd_post_info[$prefix.'city'] = $location_result->city; |
|
| 333 | + $gd_post_info[$prefix.'region'] = $location_result->region; |
|
| 334 | + $gd_post_info[$prefix.'country'] = $location_result->country; |
|
| 335 | 335 | |
| 336 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 336 | + $gd_post_info['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // set all overall post location |
|
| 337 | 337 | |
| 338 | 338 | } else {
|
| 339 | 339 | |
| 340 | - $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
| 341 | - $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
| 342 | - $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
| 340 | + $gd_post_info[$prefix.'city'] = $request_info[$prefix.'city']; |
|
| 341 | + $gd_post_info[$prefix.'region'] = $request_info[$prefix.'region']; |
|
| 342 | + $gd_post_info[$prefix.'country'] = $request_info[$prefix.'country']; |
|
| 343 | 343 | |
| 344 | 344 | //----------set post locations when import dummy data------- |
| 345 | 345 | $location_result = geodir_get_default_location(); |
| 346 | 346 | |
| 347 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 347 | + $gd_post_info['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // set all overall post location |
|
| 348 | 348 | //----------------------------------------------------------------- |
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | |
| 353 | - if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
|
|
| 354 | - $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
| 353 | + if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix.'zip'])) {
|
|
| 354 | + $gd_post_info[$prefix.'zip'] = $request_info[$prefix.'zip']; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | |
| 358 | 358 | if (isset($extrafields['show_map']) && $extrafields['show_map']) {
|
| 359 | 359 | |
| 360 | - if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
|
|
| 361 | - $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
| 360 | + if (isset($request_info[$prefix.'latitude']) && $request_info[$prefix.'latitude'] != '') {
|
|
| 361 | + $gd_post_info[$prefix.'latitude'] = $request_info[$prefix.'latitude']; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
|
|
| 365 | - $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
| 364 | + if (isset($request_info[$prefix.'longitude']) && $request_info[$prefix.'longitude'] != '') {
|
|
| 365 | + $gd_post_info[$prefix.'longitude'] = $request_info[$prefix.'longitude']; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
|
|
| 369 | - $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
| 368 | + if (isset($request_info[$prefix.'mapview']) && $request_info[$prefix.'mapview'] != '') {
|
|
| 369 | + $gd_post_info[$prefix.'mapview'] = $request_info[$prefix.'mapview']; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
|
|
| 373 | - $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
| 372 | + if (isset($request_info[$prefix.'mapzoom']) && $request_info[$prefix.'mapzoom'] != '') {
|
|
| 373 | + $gd_post_info[$prefix.'mapzoom'] = $request_info[$prefix.'mapzoom']; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | // show lat lng |
| 379 | - if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
|
|
| 380 | - $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
| 379 | + if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix.'latlng'])) {
|
|
| 380 | + $gd_post_info[$prefix.'latlng'] = $request_info[$prefix.'latlng']; |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
@@ -403,16 +403,16 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | // check if we need to change the format or not |
| 405 | 405 | $date_format_len = strlen(str_replace(' ', '', $date_format));
|
| 406 | - if($date_format_len>5){// if greater then 5 then it's the old style format.
|
|
| 406 | + if ($date_format_len > 5) {// if greater then 5 then it's the old style format.
|
|
| 407 | 407 | |
| 408 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 409 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 408 | + $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format
|
|
| 409 | + $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format
|
|
| 410 | 410 | |
| 411 | 411 | $date_format = str_replace($search, $replace, $date_format); |
| 412 | 412 | |
| 413 | 413 | $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
|
| 414 | 414 | |
| 415 | - }else{
|
|
| 415 | + } else {
|
|
| 416 | 416 | $post_htmlvar_value = $request_info[$name]; |
| 417 | 417 | } |
| 418 | 418 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | if (isset($request_info[$name])) {
|
| 427 | 427 | $gd_post_info[$name] = $request_info[$name]; |
| 428 | 428 | } else {
|
| 429 | - if (isset($request_info['gd_field_' . $name])) {
|
|
| 429 | + if (isset($request_info['gd_field_'.$name])) {
|
|
| 430 | 430 | $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
| 431 | 431 | } |
| 432 | 432 | } |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | if (is_array($post_tags)) {
|
| 489 | - $taxonomy = $request_info['listing_type'] . '_tags'; |
|
| 489 | + $taxonomy = $request_info['listing_type'].'_tags'; |
|
| 490 | 490 | wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
| 491 | 491 | } |
| 492 | 492 | |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | $tmpimgArr = trim($request_info['post_images'], ","); |
| 499 | 499 | $tmpimgArr = explode(",", $tmpimgArr);
|
| 500 | 500 | geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
| 501 | - } else{
|
|
| 501 | + } else {
|
|
| 502 | 502 | geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
| 503 | 503 | } |
| 504 | 504 | |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | if (!in_array($post_type, $all_postypes)) |
| 580 | 580 | return false; |
| 581 | 581 | |
| 582 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 582 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 583 | 583 | |
| 584 | 584 | /** |
| 585 | 585 | * Apply Filter to change Post info |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | * @since 1.0.0 |
| 590 | 590 | * @package GeoDirectory |
| 591 | 591 | */ |
| 592 | - $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
|
|
| 592 | + $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM ".$wpdb->posts." p,".$table." pd
|
|
| 593 | 593 | WHERE p.ID = pd.post_id |
| 594 | 594 | AND pd.post_id = %d", $post_id)); |
| 595 | 595 | |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | $post_type = get_post_type($post_id); |
| 654 | 654 | |
| 655 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 655 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 656 | 656 | |
| 657 | 657 | /** |
| 658 | 658 | * Filter to change Post info |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | $columns = $wpdb->get_col("show columns from $table");
|
| 675 | 675 | foreach ($postmeta as $mkey => $mval) {
|
| 676 | - if(in_array($mkey,$columns)) {
|
|
| 676 | + if (in_array($mkey, $columns)) {
|
|
| 677 | 677 | if (is_array($mval)) {
|
| 678 | 678 | $mval = implode(",", $mval);
|
| 679 | 679 | } |
@@ -702,12 +702,12 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
|
| 704 | 704 | |
| 705 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 705 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
|
|
| 706 | 706 | |
| 707 | 707 | $query_string_array[] = $post_id; |
| 708 | 708 | $wpdb->query( |
| 709 | 709 | $wpdb->prepare( |
| 710 | - "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d", |
|
| 710 | + "UPDATE ".$table." SET ".$query_string_escaped." where post_id =%d", |
|
| 711 | 711 | $query_string_array |
| 712 | 712 | ) |
| 713 | 713 | ); |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | array_unshift($query_string_array, $post_id); |
| 719 | 719 | $wpdb->query( |
| 720 | 720 | $wpdb->prepare( |
| 721 | - "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped, |
|
| 721 | + "INSERT INTO ".$table." SET post_id = %d,".$query_string_escaped, |
|
| 722 | 722 | $query_string_array |
| 723 | 723 | ) |
| 724 | 724 | ); |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | |
| 765 | 765 | $post_type = get_post_type($post_id); |
| 766 | 766 | |
| 767 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 767 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 768 | 768 | |
| 769 | 769 | if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
|
| 770 | 770 | |
@@ -772,11 +772,11 @@ discard block |
||
| 772 | 772 | $meta_value = implode(",", $meta_value);
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 775 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
|
|
| 776 | 776 | |
| 777 | 777 | $wpdb->query( |
| 778 | 778 | $wpdb->prepare( |
| 779 | - "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
| 779 | + "UPDATE ".$table." SET ".$postmeta." = '".$meta_value."' where post_id =%d", |
|
| 780 | 780 | array($post_id) |
| 781 | 781 | ) |
| 782 | 782 | ); |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | $wpdb->query( |
| 787 | 787 | $wpdb->prepare( |
| 788 | - "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
| 788 | + "INSERT INTO ".$table." SET post_id = %d, ".$postmeta." = '".$meta_value."'", |
|
| 789 | 789 | array($post_id) |
| 790 | 790 | ) |
| 791 | 791 | ); |
@@ -818,14 +818,14 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | $post_type = get_post_type($post_id); |
| 820 | 820 | |
| 821 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 821 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 822 | 822 | |
| 823 | 823 | if (is_array($postmeta) && !empty($postmeta) && $post_id) {
|
| 824 | 824 | $post_meta_set_query = ''; |
| 825 | 825 | |
| 826 | 826 | foreach ($postmeta as $mkey) {
|
| 827 | 827 | if ($mval != '') |
| 828 | - $post_meta_set_query .= $mkey . " = '', "; |
|
| 828 | + $post_meta_set_query .= $mkey." = '', "; |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | $post_meta_set_query = trim($post_meta_set_query, ", "); |
@@ -834,11 +834,11 @@ discard block |
||
| 834 | 834 | return false; |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 837 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$postmeta."'") != '') {
|
|
| 838 | 838 | |
| 839 | 839 | $wpdb->query( |
| 840 | 840 | $wpdb->prepare( |
| 841 | - "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
| 841 | + "UPDATE ".$table." SET ".$post_meta_set_query." where post_id = %d", |
|
| 842 | 842 | array($post_id) |
| 843 | 843 | ) |
| 844 | 844 | ); |
@@ -847,11 +847,11 @@ discard block |
||
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | } elseif ($postmeta != '' && $post_id) {
|
| 850 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 850 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$postmeta."'") != '') {
|
|
| 851 | 851 | |
| 852 | 852 | $wpdb->query( |
| 853 | 853 | $wpdb->prepare( |
| 854 | - "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
| 854 | + "UPDATE ".$table." SET ".$postmeta."= '' where post_id = %d", |
|
| 855 | 855 | array($post_id) |
| 856 | 856 | ) |
| 857 | 857 | ); |
@@ -893,10 +893,10 @@ discard block |
||
| 893 | 893 | if (!in_array($post_type, $all_postypes)) |
| 894 | 894 | return false; |
| 895 | 895 | |
| 896 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 896 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 897 | 897 | |
| 898 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
|
|
| 899 | - $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
|
| 898 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$meta_key."'") != '') {
|
|
| 899 | + $meta_value = $wpdb->get_var($wpdb->prepare("SELECT ".$meta_key." from ".$table." where post_id = %d", array($post_id)));
|
|
| 900 | 900 | if ($meta_value && $meta_value !== '') {
|
| 901 | 901 | return maybe_serialize($meta_value); |
| 902 | 902 | } else |
@@ -929,13 +929,13 @@ discard block |
||
| 929 | 929 | |
| 930 | 930 | $post_type = get_post_type($post_id); |
| 931 | 931 | |
| 932 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 932 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 933 | 933 | |
| 934 | 934 | $post_images = geodir_get_images($post_id); |
| 935 | 935 | |
| 936 | 936 | $wpdb->query( |
| 937 | 937 | $wpdb->prepare( |
| 938 | - "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
| 938 | + "UPDATE ".$table." SET featured_image = '' where post_id =%d", |
|
| 939 | 939 | array($post_id) |
| 940 | 940 | ) |
| 941 | 941 | ); |
@@ -965,12 +965,12 @@ discard block |
||
| 965 | 965 | $file_path = ''; |
| 966 | 966 | /* --------- start ------- */ |
| 967 | 967 | |
| 968 | - $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
|
|
| 968 | + $split_img_path = explode(str_replace(array('http://', 'https://'), '', $uploads['baseurl']), str_replace(array('http://', 'https://'), '', $post_image[$m]));
|
|
| 969 | 969 | |
| 970 | 970 | $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
| 971 | 971 | |
| 972 | 972 | |
| 973 | - if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 973 | + if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".GEODIR_ATTACHMENT_TABLE." WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 974 | 974 | |
| 975 | 975 | /* --------- end ------- */ |
| 976 | 976 | $curr_img_url = $post_image[$m]; |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | // If the uploaded file is the right format |
| 1015 | 1015 | if (in_array($uploaded_file_type, $allowed_file_types)) {
|
| 1016 | 1016 | if (!function_exists('wp_handle_upload')) {
|
| 1017 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1017 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | if (!is_dir($geodir_uploadpath)) {
|
@@ -1022,41 +1022,41 @@ discard block |
||
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | $external_img = false; |
| 1025 | - if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
|
|
| 1025 | + if (strpos(str_replace(array('http://', 'https://'), '', $curr_img_url), str_replace(array('http://', 'https://'), '', $uploads['baseurl'])) !== false) {
|
|
| 1026 | 1026 | } else {
|
| 1027 | 1027 | $external_img = true; |
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | if ($dummy || $external_img) {
|
| 1031 | 1031 | $uploaded_file = array(); |
| 1032 | - $uploaded = (array)fetch_remote_file($curr_img_url); |
|
| 1032 | + $uploaded = (array) fetch_remote_file($curr_img_url); |
|
| 1033 | 1033 | |
| 1034 | 1034 | if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
| 1035 | 1035 | $new_name = basename($uploaded['file']); |
| 1036 | 1036 | $uploaded_file = $uploaded; |
| 1037 | - }else{
|
|
| 1038 | - print_r($uploaded);exit; |
|
| 1037 | + } else {
|
|
| 1038 | + print_r($uploaded); exit; |
|
| 1039 | 1039 | } |
| 1040 | 1040 | $external_img = false; |
| 1041 | 1041 | } else {
|
| 1042 | - $new_name = $post_id . '_' . $file_name; |
|
| 1042 | + $new_name = $post_id.'_'.$file_name; |
|
| 1043 | 1043 | |
| 1044 | 1044 | if ($curr_img_dir == $sub_dir) {
|
| 1045 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1046 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1045 | + $img_path = $geodir_uploadpath.'/'.$filename; |
|
| 1046 | + $img_url = $geodir_uploadurl.'/'.$filename; |
|
| 1047 | 1047 | } else {
|
| 1048 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1049 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1048 | + $img_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename; |
|
| 1049 | + $img_url = $uploads['url'].'/temp_'.$current_user->data->ID.'/'.$filename; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | $uploaded_file = ''; |
| 1053 | 1053 | |
| 1054 | 1054 | if (file_exists($img_path)) {
|
| 1055 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1055 | + $uploaded_file = copy($img_path, $geodir_uploadpath.'/'.$new_name); |
|
| 1056 | 1056 | $file_path = ''; |
| 1057 | - } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
|
|
| 1057 | + } else if (file_exists($uploads['basedir'].$curr_img_dir.$filename)) {
|
|
| 1058 | 1058 | $uploaded_file = true; |
| 1059 | - $file_path = $curr_img_dir . '/' . $filename; |
|
| 1059 | + $file_path = $curr_img_dir.'/'.$filename; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
@@ -1065,14 +1065,14 @@ discard block |
||
| 1065 | 1065 | |
| 1066 | 1066 | if (!empty($uploaded_file)) {
|
| 1067 | 1067 | if (!isset($file_path) || !$file_path) {
|
| 1068 | - $file_path = $sub_dir . '/' . $new_name; |
|
| 1068 | + $file_path = $sub_dir.'/'.$new_name; |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
|
|
| 1071 | + $postcurr_images[] = str_replace(array('http://', 'https://'), '', $uploads['baseurl'].$file_path);
|
|
| 1072 | 1072 | |
| 1073 | 1073 | if ($menu_order == 1) {
|
| 1074 | 1074 | |
| 1075 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1075 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1076 | 1076 | |
| 1077 | 1077 | } |
| 1078 | 1078 | |
@@ -1090,12 +1090,12 @@ discard block |
||
| 1090 | 1090 | |
| 1091 | 1091 | foreach ($attachment as $key => $val) {
|
| 1092 | 1092 | if ($val != '') |
| 1093 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1093 | + $attachment_set .= $key." = '".$val."', "; |
|
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | 1096 | $attachment_set = trim($attachment_set, ", "); |
| 1097 | 1097 | |
| 1098 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1098 | + $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
|
|
| 1099 | 1099 | |
| 1100 | 1100 | $valid_file_ids[] = $wpdb->insert_id; |
| 1101 | 1101 | } |
@@ -1106,17 +1106,17 @@ discard block |
||
| 1106 | 1106 | } else {
|
| 1107 | 1107 | $valid_file_ids[] = $find_image; |
| 1108 | 1108 | |
| 1109 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
|
|
| 1109 | + $postcurr_images[] = str_replace(array('http://', 'https://'), '', $post_image[$m]);
|
|
| 1110 | 1110 | |
| 1111 | 1111 | $wpdb->query( |
| 1112 | 1112 | $wpdb->prepare( |
| 1113 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1113 | + "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1114 | 1114 | array($menu_order, $split_img_path[1], $post_id) |
| 1115 | 1115 | ) |
| 1116 | 1116 | ); |
| 1117 | 1117 | |
| 1118 | 1118 | if ($menu_order == 1) |
| 1119 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1119 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1120 | 1120 | |
| 1121 | 1121 | } |
| 1122 | 1122 | |
@@ -1140,9 +1140,9 @@ discard block |
||
| 1140 | 1140 | |
| 1141 | 1141 | foreach ($post_images as $img) {
|
| 1142 | 1142 | |
| 1143 | - if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
|
|
| 1143 | + if (!in_array(str_replace(array('http://', 'https://'), '', $img->src), $postcurr_images)) {
|
|
| 1144 | 1144 | |
| 1145 | - $invalid_files[] = (object)array('src' => $img->src);
|
|
| 1145 | + $invalid_files[] = (object) array('src' => $img->src);
|
|
| 1146 | 1146 | |
| 1147 | 1147 | } |
| 1148 | 1148 | |
@@ -1150,12 +1150,12 @@ discard block |
||
| 1150 | 1150 | |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | - $invalid_files = (object)$invalid_files; |
|
| 1153 | + $invalid_files = (object) $invalid_files; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | $remove_files[] = $post_id; |
| 1157 | 1157 | |
| 1158 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
|
| 1158 | + $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE ".$valid_files_condition." post_id = %d", $remove_files));
|
|
| 1159 | 1159 | |
| 1160 | 1160 | if (!empty($invalid_files)) |
| 1161 | 1161 | geodir_remove_attachments($invalid_files); |
@@ -1195,7 +1195,7 @@ discard block |
||
| 1195 | 1195 | rmdir($dirPath); |
| 1196 | 1196 | } */ |
| 1197 | 1197 | |
| 1198 | - $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
| 1198 | + $dirname = $uploads_dir.'/temp_'.$current_user->ID; |
|
| 1199 | 1199 | geodir_delete_directory($dirname); |
| 1200 | 1200 | } |
| 1201 | 1201 | |
@@ -1217,10 +1217,10 @@ discard block |
||
| 1217 | 1217 | return false; |
| 1218 | 1218 | while ($file = readdir($dir_handle)) {
|
| 1219 | 1219 | if ($file != "." && $file != "..") {
|
| 1220 | - if (!is_dir($dirname . "/" . $file)) |
|
| 1221 | - unlink($dirname . "/" . $file); |
|
| 1220 | + if (!is_dir($dirname."/".$file)) |
|
| 1221 | + unlink($dirname."/".$file); |
|
| 1222 | 1222 | else |
| 1223 | - geodir_delete_directory($dirname . '/' . $file); |
|
| 1223 | + geodir_delete_directory($dirname.'/'.$file); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | } |
| 1226 | 1226 | closedir($dir_handle); |
@@ -1249,8 +1249,8 @@ discard block |
||
| 1249 | 1249 | foreach ($postcurr_images as $postimg) {
|
| 1250 | 1250 | $image_name_arr = explode('/', $postimg->src);
|
| 1251 | 1251 | $filename = end($image_name_arr); |
| 1252 | - if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1253 | - unlink($uploads_dir . '/' . $filename); |
|
| 1252 | + if (file_exists($uploads_dir.'/'.$filename)) |
|
| 1253 | + unlink($uploads_dir.'/'.$filename); |
|
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | 1256 | } // endif |
@@ -1291,16 +1291,16 @@ discard block |
||
| 1291 | 1291 | } |
| 1292 | 1292 | |
| 1293 | 1293 | if (!in_array($post_type, geodir_get_posttypes())) {
|
| 1294 | - return false;// if not a GD CPT return; |
|
| 1294 | + return false; // if not a GD CPT return; |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1297 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 1298 | 1298 | |
| 1299 | 1299 | if (!$file) {
|
| 1300 | 1300 | if (isset($post->featured_image)) {
|
| 1301 | 1301 | $file = $post->featured_image; |
| 1302 | 1302 | } else {
|
| 1303 | - $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
|
|
| 1303 | + $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM ".$table." WHERE post_id = %d", array($post_id)));
|
|
| 1304 | 1304 | } |
| 1305 | 1305 | } |
| 1306 | 1306 | |
@@ -1318,7 +1318,7 @@ discard block |
||
| 1318 | 1318 | |
| 1319 | 1319 | $file_name = $file_info['basename']; |
| 1320 | 1320 | |
| 1321 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1321 | + $uploads_url = $uploads_baseurl.$sub_dir; |
|
| 1322 | 1322 | /* |
| 1323 | 1323 | * Allows the filter of image src for such things as CDN change. |
| 1324 | 1324 | * |
@@ -1328,8 +1328,8 @@ discard block |
||
| 1328 | 1328 | * @param string $uploads_url The server upload directory url. |
| 1329 | 1329 | * @param string $uploads_baseurl The uploads dir base url. |
| 1330 | 1330 | */ |
| 1331 | - $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1332 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1331 | + $img_arr['src'] = apply_filters('geodir_get_featured_image_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
|
|
| 1332 | + $img_arr['path'] = $uploads_path.'/'.$file_name; |
|
| 1333 | 1333 | $width = 0; |
| 1334 | 1334 | $height = 0; |
| 1335 | 1335 | if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | $file_name = $file_info['basename']; |
| 1373 | 1373 | |
| 1374 | 1374 | $img_arr['src'] = $default_img; |
| 1375 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1375 | + $img_arr['path'] = $uploads_path.'/'.$file_name; |
|
| 1376 | 1376 | |
| 1377 | 1377 | $width = 0; |
| 1378 | 1378 | $height = 0; |
@@ -1389,7 +1389,7 @@ discard block |
||
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | 1391 | if (!empty($img_arr)) |
| 1392 | - return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1392 | + return (object) $img_arr; //return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1393 | 1393 | else |
| 1394 | 1394 | return false; |
| 1395 | 1395 | } |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | |
| 1453 | 1453 | $arrImages = $wpdb->get_results( |
| 1454 | 1454 | $wpdb->prepare( |
| 1455 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1455 | + "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d".$not_featured." ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1456 | 1456 | array('%image%', $post_id)
|
| 1457 | 1457 | ) |
| 1458 | 1458 | ); |
@@ -1478,7 +1478,7 @@ discard block |
||
| 1478 | 1478 | |
| 1479 | 1479 | $file_name = $file_info['basename']; |
| 1480 | 1480 | |
| 1481 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1481 | + $uploads_url = $uploads_baseurl.$sub_dir; |
|
| 1482 | 1482 | /* |
| 1483 | 1483 | * Allows the filter of image src for such things as CDN change. |
| 1484 | 1484 | * |
@@ -1488,8 +1488,8 @@ discard block |
||
| 1488 | 1488 | * @param string $uploads_url The server upload directory url. |
| 1489 | 1489 | * @param string $uploads_baseurl The uploads dir base url. |
| 1490 | 1490 | */ |
| 1491 | - $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1492 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1491 | + $img_arr['src'] = apply_filters('geodir_get_images_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
|
|
| 1492 | + $img_arr['path'] = $uploads_path.'/'.$file_name; |
|
| 1493 | 1493 | $width = 0; |
| 1494 | 1494 | $height = 0; |
| 1495 | 1495 | if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
@@ -1506,11 +1506,11 @@ discard block |
||
| 1506 | 1506 | $img_arr['content'] = $attechment->content; // add the description to the array |
| 1507 | 1507 | $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
| 1508 | 1508 | |
| 1509 | - $return_arr[] = (object)$img_arr; |
|
| 1509 | + $return_arr[] = (object) $img_arr; |
|
| 1510 | 1510 | |
| 1511 | 1511 | $counter++; |
| 1512 | 1512 | } |
| 1513 | - return (object)$return_arr; |
|
| 1513 | + return (object) $return_arr; |
|
| 1514 | 1514 | } else if ($no_images) {
|
| 1515 | 1515 | $default_img = ''; |
| 1516 | 1516 | $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
@@ -1549,7 +1549,7 @@ discard block |
||
| 1549 | 1549 | $img_arr['title'] = $file_info['filename']; // add the title to the array |
| 1550 | 1550 | $img_arr['content'] = $file_info['filename']; // add the description to the array |
| 1551 | 1551 | |
| 1552 | - $return_arr[] = (object)$img_arr; |
|
| 1552 | + $return_arr[] = (object) $img_arr; |
|
| 1553 | 1553 | |
| 1554 | 1554 | return $return_arr; |
| 1555 | 1555 | } else |
@@ -1576,8 +1576,8 @@ discard block |
||
| 1576 | 1576 | |
| 1577 | 1577 | $html = ''; |
| 1578 | 1578 | if (!empty($request)) {
|
| 1579 | - if (!is_object($request)){
|
|
| 1580 | - $request = (object)$request; |
|
| 1579 | + if (!is_object($request)) {
|
|
| 1580 | + $request = (object) $request; |
|
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | 1583 | if (isset($request->src) && !isset($request->path)) {
|
@@ -1591,7 +1591,7 @@ discard block |
||
| 1591 | 1591 | $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
|
| 1592 | 1592 | $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
|
| 1593 | 1593 | if (strpos($img_no_http, $upload_no_http) !== false) {
|
| 1594 | - $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
| 1594 | + $request->path = str_replace($img_no_http, $upload_dir['basedir'], $request->path); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | 1597 | $width = 0; |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | $image->width = $width; |
| 1607 | 1607 | $image->height = $height; |
| 1608 | 1608 | |
| 1609 | - $max_size = (object)geodir_get_imagesize($size); |
|
| 1609 | + $max_size = (object) geodir_get_imagesize($size); |
|
| 1610 | 1610 | |
| 1611 | 1611 | if (!is_wp_error($max_size)) {
|
| 1612 | 1612 | if ($image->width) {
|
@@ -1618,15 +1618,15 @@ discard block |
||
| 1618 | 1618 | $width_per = 100; |
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | - if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
|
| 1622 | - $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
| 1621 | + if (is_admin() && !isset($_REQUEST['geodir_ajax'])) {
|
|
| 1622 | + $html = '<div class="geodir_thumbnail"><img style="max-height:'.$max_size->h.'px;" alt="place image" src="'.$image->src.'" /></div>'; |
|
| 1623 | 1623 | } else {
|
| 1624 | - if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
|
| 1625 | - $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1626 | - }else{
|
|
| 1624 | + if ($size == 'widget-thumb' || !get_option('geodir_lazy_load', 1)) {
|
|
| 1625 | + $html = '<div class="geodir_thumbnail" style="background-image:url(\''.$image->src.'\');"></div>'; |
|
| 1626 | + } else {
|
|
| 1627 | 1627 | //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
| 1628 | 1628 | //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>'; |
| 1629 | - $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
|
|
| 1629 | + $html = '<div data-src="'.str_replace(' ', '%20', $image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
|
|
| 1630 | 1630 | |
| 1631 | 1631 | } |
| 1632 | 1632 | |
@@ -1662,15 +1662,15 @@ discard block |
||
| 1662 | 1662 | |
| 1663 | 1663 | $post_type = get_post_type($post_id); |
| 1664 | 1664 | |
| 1665 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1665 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 1666 | 1666 | |
| 1667 | 1667 | if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
|
| 1668 | 1668 | |
| 1669 | - if ($taxonomy == $post_type . '_tags') {
|
|
| 1669 | + if ($taxonomy == $post_type.'_tags') {
|
|
| 1670 | 1670 | if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
| 1671 | 1671 | geodir_save_post_meta($post_id, 'post_tags', $terms); |
| 1672 | 1672 | } |
| 1673 | - } elseif ($taxonomy == $post_type . 'category') {
|
|
| 1673 | + } elseif ($taxonomy == $post_type.'category') {
|
|
| 1674 | 1674 | $srcharr = array('"', '\\');
|
| 1675 | 1675 | $replarr = array(""", '');
|
| 1676 | 1676 | |
@@ -1692,7 +1692,7 @@ discard block |
||
| 1692 | 1692 | |
| 1693 | 1693 | $wpdb->get_var( |
| 1694 | 1694 | $wpdb->prepare( |
| 1695 | - "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1695 | + "DELETE from ".GEODIR_ICON_TABLE." WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1696 | 1696 | $cat_ids_array_del |
| 1697 | 1697 | ) |
| 1698 | 1698 | ); |
@@ -1700,7 +1700,7 @@ discard block |
||
| 1700 | 1700 | |
| 1701 | 1701 | $post_term = $wpdb->get_col( |
| 1702 | 1702 | $wpdb->prepare( |
| 1703 | - "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1703 | + "SELECT term_id FROM ".$wpdb->term_taxonomy." WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1704 | 1704 | $cat_ids_array |
| 1705 | 1705 | ) |
| 1706 | 1706 | ); |
@@ -1722,16 +1722,16 @@ discard block |
||
| 1722 | 1722 | $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
| 1723 | 1723 | $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
| 1724 | 1724 | |
| 1725 | - $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1726 | - $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1725 | + $timing = ' - '.date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1726 | + $timing .= ' - '.geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1727 | 1727 | |
| 1728 | 1728 | $json = '{';
|
| 1729 | - $json .= '"id":"' . $post_id . '",'; |
|
| 1730 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 1731 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 1732 | - $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
| 1733 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 1734 | - $json .= '"group":"catgroup' . $cat_id . '"'; |
|
| 1729 | + $json .= '"id":"'.$post_id.'",'; |
|
| 1730 | + $json .= '"lat_pos": "'.$lat.'",'; |
|
| 1731 | + $json .= '"long_pos": "'.$lng.'",'; |
|
| 1732 | + $json .= '"marker_id":"'.$post_id.'_'.$cat_id.'",'; |
|
| 1733 | + $json .= '"icon":"'.$term_icon.'",'; |
|
| 1734 | + $json .= '"group":"catgroup'.$cat_id.'"'; |
|
| 1735 | 1735 | $json .= '}'; |
| 1736 | 1736 | |
| 1737 | 1737 | |
@@ -1739,9 +1739,9 @@ discard block |
||
| 1739 | 1739 | $post_marker_json = $json; |
| 1740 | 1740 | |
| 1741 | 1741 | |
| 1742 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1742 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".GEODIR_ICON_TABLE." WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1743 | 1743 | |
| 1744 | - $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
|
|
| 1744 | + $json_query = $wpdb->prepare("UPDATE ".GEODIR_ICON_TABLE." SET
|
|
| 1745 | 1745 | post_title = %s, |
| 1746 | 1746 | json = %s |
| 1747 | 1747 | WHERE post_id = %d AND cat_id = %d ", |
@@ -1749,7 +1749,7 @@ discard block |
||
| 1749 | 1749 | |
| 1750 | 1750 | } else {
|
| 1751 | 1751 | |
| 1752 | - $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
|
|
| 1752 | + $json_query = $wpdb->prepare("INSERT INTO ".GEODIR_ICON_TABLE." SET
|
|
| 1753 | 1753 | post_id = %d, |
| 1754 | 1754 | post_title = %s, |
| 1755 | 1755 | cat_id = %d, |
@@ -1767,17 +1767,17 @@ discard block |
||
| 1767 | 1767 | if (!empty($post_term) && is_array($post_term)) {
|
| 1768 | 1768 | $categories = implode(',', $post_term);
|
| 1769 | 1769 | |
| 1770 | - if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1770 | + if ($categories != '' && $categories != 0) $categories = ','.$categories.','; |
|
| 1771 | 1771 | |
| 1772 | 1772 | if (empty($post_marker_json)) |
| 1773 | 1773 | $post_marker_json = isset($json) ? $json : ''; |
| 1774 | 1774 | |
| 1775 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 1775 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
|
|
| 1776 | 1776 | |
| 1777 | 1777 | $wpdb->query( |
| 1778 | 1778 | $wpdb->prepare( |
| 1779 | - "UPDATE " . $table . " SET |
|
| 1780 | - " . $taxonomy . " = %s, |
|
| 1779 | + "UPDATE ".$table." SET |
|
| 1780 | + " . $taxonomy." = %s, |
|
| 1781 | 1781 | marker_json = %s |
| 1782 | 1782 | where post_id = %d", |
| 1783 | 1783 | array($categories, $post_marker_json, $post_id) |
@@ -1798,7 +1798,7 @@ discard block |
||
| 1798 | 1798 | |
| 1799 | 1799 | $wpdb->query( |
| 1800 | 1800 | $wpdb->prepare( |
| 1801 | - "UPDATE " . $table . " SET |
|
| 1801 | + "UPDATE ".$table." SET |
|
| 1802 | 1802 | default_category = %s |
| 1803 | 1803 | where post_id = %d", |
| 1804 | 1804 | array($categories[0], $post_id) |
@@ -1823,9 +1823,9 @@ discard block |
||
| 1823 | 1823 | |
| 1824 | 1824 | $wpdb->query( |
| 1825 | 1825 | $wpdb->prepare( |
| 1826 | - "INSERT INTO " . $table . " SET |
|
| 1826 | + "INSERT INTO ".$table." SET |
|
| 1827 | 1827 | post_id = %d, |
| 1828 | - " . $taxonomy . " = %s, |
|
| 1828 | + " . $taxonomy." = %s, |
|
| 1829 | 1829 | marker_json = %s ", |
| 1830 | 1830 | |
| 1831 | 1831 | array($post_id, $categories, $post_marker_json) |
@@ -1951,7 +1951,7 @@ discard block |
||
| 1951 | 1951 | } ?>"><img alt="bubble image" style="max-height:50px;" |
| 1952 | 1952 | src="<?php echo $post_images[0]; ?>"/></a></div> |
| 1953 | 1953 | <?php |
| 1954 | - }else{
|
|
| 1954 | + } else {
|
|
| 1955 | 1955 | echo '<div class="geodir-bubble_image"></div>'; |
| 1956 | 1956 | } |
| 1957 | 1957 | } else {
|
@@ -1959,7 +1959,7 @@ discard block |
||
| 1959 | 1959 | ?> |
| 1960 | 1960 | <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div> |
| 1961 | 1961 | <?php |
| 1962 | - }else{
|
|
| 1962 | + } else {
|
|
| 1963 | 1963 | echo '<div class="geodir-bubble_image"></div>'; |
| 1964 | 1964 | } |
| 1965 | 1965 | } |
@@ -1989,7 +1989,7 @@ discard block |
||
| 1989 | 1989 | * @param object $postinfo_obj The posts info as an object. |
| 1990 | 1990 | * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
| 1991 | 1991 | */ |
| 1992 | - do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
|
|
| 1992 | + do_action('geodir_infowindow_meta_after', $postinfo_obj, $post_preview);
|
|
| 1993 | 1993 | ?> |
| 1994 | 1994 | </div> |
| 1995 | 1995 | <?php |
@@ -1999,9 +1999,9 @@ discard block |
||
| 1999 | 1999 | <div class="geodir-bubble-meta-fade"></div> |
| 2000 | 2000 | <div class="geodir-bubble-meta-bottom"> |
| 2001 | 2001 | <?php if ($rating_star != '') { ?>
|
| 2002 | - <span class="geodir-bubble-rating"><?php echo $rating_star;?></span> |
|
| 2002 | + <span class="geodir-bubble-rating"><?php echo $rating_star; ?></span> |
|
| 2003 | 2003 | <?php } ?> |
| 2004 | - <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID);?></span> |
|
| 2004 | + <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID); ?></span> |
|
| 2005 | 2005 | <span class="geodir-bubble-reviews"> |
| 2006 | 2006 | <a href="<?php echo get_comments_link($ID); ?>" class="geodir-pcomments"><i class="fa fa-comments"></i> <?php echo get_comments_number($ID); ?></a> |
| 2007 | 2007 | </span> |
@@ -2063,11 +2063,11 @@ discard block |
||
| 2063 | 2063 | |
| 2064 | 2064 | $post_type = get_post_type($post_id); |
| 2065 | 2065 | |
| 2066 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2066 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2067 | 2067 | |
| 2068 | 2068 | $wpdb->query( |
| 2069 | 2069 | $wpdb->prepare( |
| 2070 | - "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
| 2070 | + "UPDATE ".$table." SET post_status=%s WHERE post_id=%d", |
|
| 2071 | 2071 | array($status, $post_id) |
| 2072 | 2072 | ) |
| 2073 | 2073 | ); |
@@ -2139,18 +2139,18 @@ discard block |
||
| 2139 | 2139 | |
| 2140 | 2140 | $post_type = get_post_type($post_id); |
| 2141 | 2141 | |
| 2142 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2142 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2143 | 2143 | |
| 2144 | 2144 | $wpdb->query( |
| 2145 | 2145 | $wpdb->prepare( |
| 2146 | - "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2146 | + "UPDATE ".$table." SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2147 | 2147 | array($updatingpost, $temppost) |
| 2148 | 2148 | ) |
| 2149 | 2149 | ); |
| 2150 | 2150 | |
| 2151 | 2151 | $wpdb->query( |
| 2152 | 2152 | $wpdb->prepare( |
| 2153 | - "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2153 | + "UPDATE ".GEODIR_ICON_TABLE." SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2154 | 2154 | array($updatingpost, $temppost) |
| 2155 | 2155 | ) |
| 2156 | 2156 | ); |
@@ -2159,7 +2159,7 @@ discard block |
||
| 2159 | 2159 | |
| 2160 | 2160 | $wpdb->query( |
| 2161 | 2161 | $wpdb->prepare( |
| 2162 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2162 | + "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2163 | 2163 | array($updatingpost, $temppost) |
| 2164 | 2164 | ) |
| 2165 | 2165 | ); |
@@ -2197,12 +2197,12 @@ discard block |
||
| 2197 | 2197 | if (!in_array($post_type, $all_postypes)) |
| 2198 | 2198 | return false; |
| 2199 | 2199 | |
| 2200 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2200 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2201 | 2201 | |
| 2202 | 2202 | /* Delete custom post meta*/ |
| 2203 | 2203 | $wpdb->query( |
| 2204 | 2204 | $wpdb->prepare( |
| 2205 | - "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
| 2205 | + "DELETE FROM ".$table." WHERE `post_id` = %d", |
|
| 2206 | 2206 | array($deleted_postid) |
| 2207 | 2207 | ) |
| 2208 | 2208 | ); |
@@ -2211,7 +2211,7 @@ discard block |
||
| 2211 | 2211 | |
| 2212 | 2212 | $wpdb->query( |
| 2213 | 2213 | $wpdb->prepare( |
| 2214 | - "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
| 2214 | + "DELETE FROM ".GEODIR_ICON_TABLE." WHERE `post_id` = %d", |
|
| 2215 | 2215 | array($deleted_postid) |
| 2216 | 2216 | ) |
| 2217 | 2217 | ); |
@@ -2221,7 +2221,7 @@ discard block |
||
| 2221 | 2221 | |
| 2222 | 2222 | $wpdb->query( |
| 2223 | 2223 | $wpdb->prepare( |
| 2224 | - "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
| 2224 | + "DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE `post_id` = %d", |
|
| 2225 | 2225 | array($deleted_postid) |
| 2226 | 2226 | ) |
| 2227 | 2227 | ); |
@@ -2293,7 +2293,7 @@ discard block |
||
| 2293 | 2293 | */ |
| 2294 | 2294 | do_action('geodir_before_add_from_favorite', $post_id);
|
| 2295 | 2295 | |
| 2296 | - echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
| 2296 | + echo '<a href="javascript:void(0);" title="'.$remove_favourite_text.'" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\''.$post_id.'\',\'remove\');"><i class="'.$favourite_icon.'"></i> '.$unfavourite_text.'</a>'; |
|
| 2297 | 2297 | |
| 2298 | 2298 | /** |
| 2299 | 2299 | * Called after adding the post from favourites. |
@@ -2372,7 +2372,7 @@ discard block |
||
| 2372 | 2372 | */ |
| 2373 | 2373 | do_action('geodir_before_remove_from_favorite', $post_id);
|
| 2374 | 2374 | |
| 2375 | - echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
| 2375 | + echo '<a href="javascript:void(0);" title="'.$add_favourite_text.'" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\''.$post_id.'\',\'add\');"><i class="'.$favourite_icon.'"></i> '.$favourite_text.'</a>'; |
|
| 2376 | 2376 | |
| 2377 | 2377 | /** |
| 2378 | 2378 | * Called after removing the post from favourites. |
@@ -2467,24 +2467,24 @@ discard block |
||
| 2467 | 2467 | $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
| 2468 | 2468 | |
| 2469 | 2469 | if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
| 2470 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
| 2470 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>" ><a |
|
| 2471 | 2471 | class="geodir-removetofav-icon" href="javascript:void(0);" |
| 2472 | - onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');" |
|
| 2473 | - title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?> |
|
| 2472 | + onclick="javascript:addToFavourite(<?php echo $post_id; ?>,'remove');" |
|
| 2473 | + title="<?php echo $remove_favourite_text; ?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text; ?> |
|
| 2474 | 2474 | </a> </span><?php |
| 2475 | 2475 | |
| 2476 | 2476 | } else {
|
| 2477 | 2477 | |
| 2478 | 2478 | if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
| 2479 | - $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
| 2479 | + $script_text = 'javascript:window.location.href=\''.geodir_login_url().'\''; |
|
| 2480 | 2480 | } else |
| 2481 | - $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2481 | + $script_text = 'javascript:addToFavourite('.$post_id.',\'add\')';
|
|
| 2482 | 2482 | |
| 2483 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
| 2483 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"><a class="geodir-addtofav-icon" |
|
| 2484 | 2484 | href="javascript:void(0);" |
| 2485 | - onclick="<?php echo $script_text;?>" |
|
| 2486 | - title="<?php echo $add_favourite_text;?>"><i |
|
| 2487 | - class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span> |
|
| 2485 | + onclick="<?php echo $script_text; ?>" |
|
| 2486 | + title="<?php echo $add_favourite_text; ?>"><i |
|
| 2487 | + class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text; ?></a></span> |
|
| 2488 | 2488 | <?php } |
| 2489 | 2489 | } |
| 2490 | 2490 | } |
@@ -2514,7 +2514,7 @@ discard block |
||
| 2514 | 2514 | |
| 2515 | 2515 | $post_type = $taxonomy_obj->object_type[0]; |
| 2516 | 2516 | |
| 2517 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2517 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2518 | 2518 | |
| 2519 | 2519 | /** |
| 2520 | 2520 | * Filter to modify the 'join' query |
@@ -2537,8 +2537,8 @@ discard block |
||
| 2537 | 2537 | $where = apply_filters('geodir_cat_post_count_where', $where, $term);
|
| 2538 | 2538 | |
| 2539 | 2539 | $count_query = "SELECT count(post_id) FROM |
| 2540 | - " . $table . " as pd " . $join . " |
|
| 2541 | - WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
|
|
| 2540 | + " . $table." as pd ".$join." |
|
| 2541 | + WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id."',".$term->taxonomy.") ".$where;
|
|
| 2542 | 2542 | |
| 2543 | 2543 | $cat_post_count = $wpdb->get_var($count_query); |
| 2544 | 2544 | if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
@@ -2621,7 +2621,7 @@ discard block |
||
| 2621 | 2621 | global $post; |
| 2622 | 2622 | $all_postypes = geodir_get_posttypes(); |
| 2623 | 2623 | if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
| 2624 | - return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>'; |
|
| 2624 | + return ' <a href="'.get_permalink($post->ID).'">'.READ_MORE_TXT.'</a>'; |
|
| 2625 | 2625 | } |
| 2626 | 2626 | |
| 2627 | 2627 | return $more; |
@@ -2648,14 +2648,14 @@ discard block |
||
| 2648 | 2648 | if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
|
| 2649 | 2649 | |
| 2650 | 2650 | $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
| 2651 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 2651 | + $table = $plugin_prefix.$geodir_post_type.'_detail'; |
|
| 2652 | 2652 | |
| 2653 | 2653 | $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
| 2654 | - $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
| 2654 | + $term_icon = $path_parts['dirname'].'/cat_icon_'.$term_id.'.png'; |
|
| 2655 | 2655 | |
| 2656 | 2656 | $posts = $wpdb->get_results( |
| 2657 | 2657 | $wpdb->prepare( |
| 2658 | - "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2658 | + "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM ".$table." WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2659 | 2659 | array($term_id, $taxonomy) |
| 2660 | 2660 | ) |
| 2661 | 2661 | ); |
@@ -2667,19 +2667,19 @@ discard block |
||
| 2667 | 2667 | $lng = $post_obj->post_longitude; |
| 2668 | 2668 | |
| 2669 | 2669 | $json = '{';
|
| 2670 | - $json .= '"id":"' . $post_obj->post_id . '",'; |
|
| 2671 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 2672 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 2673 | - $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
| 2674 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 2675 | - $json .= '"group":"catgroup' . $term_id . '"'; |
|
| 2670 | + $json .= '"id":"'.$post_obj->post_id.'",'; |
|
| 2671 | + $json .= '"lat_pos": "'.$lat.'",'; |
|
| 2672 | + $json .= '"long_pos": "'.$lng.'",'; |
|
| 2673 | + $json .= '"marker_id":"'.$post_obj->post_id.'_'.$term_id.'",'; |
|
| 2674 | + $json .= '"icon":"'.$term_icon.'",'; |
|
| 2675 | + $json .= '"group":"catgroup'.$term_id.'"'; |
|
| 2676 | 2676 | $json .= '}'; |
| 2677 | 2677 | |
| 2678 | 2678 | if ($post_obj->default_category == $term_id) {
|
| 2679 | 2679 | |
| 2680 | 2680 | $wpdb->query( |
| 2681 | 2681 | $wpdb->prepare( |
| 2682 | - "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
| 2682 | + "UPDATE ".$table." SET marker_json = %s where post_id = %d", |
|
| 2683 | 2683 | array($json, $post_obj->post_id) |
| 2684 | 2684 | ) |
| 2685 | 2685 | ); |
@@ -2687,7 +2687,7 @@ discard block |
||
| 2687 | 2687 | |
| 2688 | 2688 | $wpdb->query( |
| 2689 | 2689 | $wpdb->prepare( |
| 2690 | - "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2690 | + "UPDATE ".GEODIR_ICON_TABLE." SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2691 | 2691 | array($json, $post_obj->post_id, $term_id) |
| 2692 | 2692 | ) |
| 2693 | 2693 | ); |
@@ -2811,7 +2811,7 @@ discard block |
||
| 2811 | 2811 | // print_r($uploads ) ; |
| 2812 | 2812 | $post_first_image = $wpdb->get_results( |
| 2813 | 2813 | $wpdb->prepare( |
| 2814 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2814 | + "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2815 | 2815 | ) |
| 2816 | 2816 | ); |
| 2817 | 2817 | |
@@ -2832,9 +2832,9 @@ discard block |
||
| 2832 | 2832 | |
| 2833 | 2833 | $post_type = get_post_type($post_id); |
| 2834 | 2834 | |
| 2835 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2835 | + $table_name = $plugin_prefix.$post_type.'_detail'; |
|
| 2836 | 2836 | |
| 2837 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
|
|
| 2837 | + $wpdb->query("UPDATE ".$table_name." SET featured_image='".$post_first_image[0]->file."' WHERE post_id =".$post_id);
|
|
| 2838 | 2838 | |
| 2839 | 2839 | $new_attachment_name = basename($post_first_image[0]->file); |
| 2840 | 2840 | |
@@ -2847,11 +2847,11 @@ discard block |
||
| 2847 | 2847 | wp_delete_attachment($post_thumbnail_id); |
| 2848 | 2848 | |
| 2849 | 2849 | } |
| 2850 | - $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
| 2850 | + $filename = $uploads['basedir'].$post_first_image[0]->file; |
|
| 2851 | 2851 | |
| 2852 | 2852 | $attachment = array( |
| 2853 | 2853 | 'post_mime_type' => $post_first_image[0]->mime_type, |
| 2854 | - 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
| 2854 | + 'guid' => $uploads['baseurl'].$post_first_image[0]->file, |
|
| 2855 | 2855 | 'post_parent' => $post_id, |
| 2856 | 2856 | 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
|
| 2857 | 2857 | 'post_content' => '' |
@@ -2864,7 +2864,7 @@ discard block |
||
| 2864 | 2864 | |
| 2865 | 2865 | set_post_thumbnail($post_id, $id); |
| 2866 | 2866 | |
| 2867 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 2867 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 2868 | 2868 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
| 2869 | 2869 | |
| 2870 | 2870 | } |
@@ -2897,35 +2897,35 @@ discard block |
||
| 2897 | 2897 | $post_id = absint($_POST['post_id']); |
| 2898 | 2898 | $upload_dir = wp_upload_dir(); |
| 2899 | 2899 | $post_type = get_post_type($_POST['post_id']); |
| 2900 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2900 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2901 | 2901 | |
| 2902 | 2902 | $post_arr = $wpdb->get_results($wpdb->prepare( |
| 2903 | - "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 2903 | + "SELECT * FROM $wpdb->posts p JOIN ".$table." gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 2904 | 2904 | array($post_id) |
| 2905 | 2905 | ) |
| 2906 | 2906 | , ARRAY_A); |
| 2907 | 2907 | |
| 2908 | 2908 | $arrImages = $wpdb->get_results( |
| 2909 | 2909 | $wpdb->prepare( |
| 2910 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 2910 | + "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 2911 | 2911 | array('%image%', $post_id)
|
| 2912 | 2912 | ) |
| 2913 | 2913 | ); |
| 2914 | 2914 | if ($arrImages) {
|
| 2915 | 2915 | $image_arr = array(); |
| 2916 | 2916 | foreach ($arrImages as $img) {
|
| 2917 | - $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
| 2917 | + $image_arr[] = $upload_dir['baseurl'].$img->file; |
|
| 2918 | 2918 | } |
| 2919 | 2919 | $comma_separated = implode(",", $image_arr);
|
| 2920 | 2920 | $post_arr[0]['post_images'] = $comma_separated; |
| 2921 | 2921 | } |
| 2922 | 2922 | |
| 2923 | 2923 | |
| 2924 | - $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
| 2924 | + $cats = $post_arr[0][$post_arr[0]['post_type'].'category']; |
|
| 2925 | 2925 | $cat_arr = array_filter(explode(",", $cats));
|
| 2926 | 2926 | $trans_cat = array(); |
| 2927 | 2927 | foreach ($cat_arr as $cat) {
|
| 2928 | - $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
| 2928 | + $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'].'category', false); |
|
| 2929 | 2929 | } |
| 2930 | 2930 | |
| 2931 | 2931 | |
@@ -2967,7 +2967,7 @@ discard block |
||
| 2967 | 2967 | |
| 2968 | 2968 | $get_data = $wpdb->get_results( |
| 2969 | 2969 | $wpdb->prepare( |
| 2970 | - "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
| 2970 | + "SELECT htmlvar_name, field_type, extra_fields FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND is_active='1'", |
|
| 2971 | 2971 | array($listing_type) |
| 2972 | 2972 | ) |
| 2973 | 2973 | ); |
@@ -2980,12 +2980,12 @@ discard block |
||
| 2980 | 2980 | |
| 2981 | 2981 | $extra_fields = unserialize($data->extra_fields); |
| 2982 | 2982 | |
| 2983 | - $prefix = $data->htmlvar_name . '_'; |
|
| 2983 | + $prefix = $data->htmlvar_name.'_'; |
|
| 2984 | 2984 | |
| 2985 | - $fields_info[$prefix . 'address'] = $data->field_type; |
|
| 2985 | + $fields_info[$prefix.'address'] = $data->field_type; |
|
| 2986 | 2986 | |
| 2987 | 2987 | if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
| 2988 | - $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 2988 | + $fields_info[$prefix.'zip'] = $data->field_type; |
|
| 2989 | 2989 | |
| 2990 | 2990 | } else {
|
| 2991 | 2991 | |
@@ -3083,13 +3083,13 @@ discard block |
||
| 3083 | 3083 | * @since 1.4.9 |
| 3084 | 3084 | * @package GeoDirectory |
| 3085 | 3085 | */ |
| 3086 | -function geodir_fb_like_thumbnail(){
|
|
| 3086 | +function geodir_fb_like_thumbnail() {
|
|
| 3087 | 3087 | |
| 3088 | 3088 | // return if not a single post |
| 3089 | - if(!is_single()){return;}
|
|
| 3089 | + if (!is_single()) {return; }
|
|
| 3090 | 3090 | |
| 3091 | 3091 | global $post; |
| 3092 | - if(isset($post->featured_image) && $post->featured_image){
|
|
| 3092 | + if (isset($post->featured_image) && $post->featured_image) {
|
|
| 3093 | 3093 | $upload_dir = wp_upload_dir(); |
| 3094 | 3094 | $thumb = $upload_dir['baseurl'].$post->featured_image; |
| 3095 | 3095 | echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
@@ -21,12 +21,13 @@ discard block |
||
| 21 | 21 | {
|
| 22 | 22 | |
| 23 | 23 | $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
| 24 | - if (!empty($post_cat_ids)) |
|
| 25 | - $post_cat_array = explode(",", trim($post_cat_ids, ","));
|
|
| 24 | + if (!empty($post_cat_ids)) { |
|
| 25 | + $post_cat_array = explode(",", trim($post_cat_ids, ",")); |
|
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | if (!isset($default_cat) || empty($default_cat)) {
|
| 28 | 29 | $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
| 29 | - }else{
|
|
| 30 | + } else{
|
|
| 30 | 31 | if(!is_int($default_cat)){
|
| 31 | 32 | $category = get_term_by('name', $default_cat, $taxonomy);
|
| 32 | 33 | if(isset($category->term_id)){
|
@@ -384,8 +385,9 @@ discard block |
||
| 384 | 385 | } elseif (trim($type) == 'file') {
|
| 385 | 386 | if (isset($request_info[$name])) {
|
| 386 | 387 | $request_files = array(); |
| 387 | - if ($request_info[$name] != '') |
|
| 388 | - $request_files = explode(",", $request_info[$name]);
|
|
| 388 | + if ($request_info[$name] != '') { |
|
| 389 | + $request_files = explode(",", $request_info[$name]); |
|
| 390 | + } |
|
| 389 | 391 | |
| 390 | 392 | $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
| 391 | 393 | geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
@@ -412,7 +414,7 @@ discard block |
||
| 412 | 414 | |
| 413 | 415 | $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
|
| 414 | 416 | |
| 415 | - }else{
|
|
| 417 | + } else{
|
|
| 416 | 418 | $post_htmlvar_value = $request_info[$name]; |
| 417 | 419 | } |
| 418 | 420 | |
@@ -452,15 +454,17 @@ discard block |
||
| 452 | 454 | |
| 453 | 455 | foreach ($request_info['post_category'] as $taxonomy => $cat) {
|
| 454 | 456 | |
| 455 | - if ($dummy) |
|
| 456 | - $post_category = $cat; |
|
| 457 | - else {
|
|
| 457 | + if ($dummy) { |
|
| 458 | + $post_category = $cat; |
|
| 459 | + } else {
|
|
| 458 | 460 | |
| 459 | - if (!is_array($cat) && strstr($cat, ',')) |
|
| 460 | - $cat = explode(',', $cat);
|
|
| 461 | + if (!is_array($cat) && strstr($cat, ',')) { |
|
| 462 | + $cat = explode(',', $cat); |
|
| 463 | + } |
|
| 461 | 464 | |
| 462 | - if (!empty($cat) && is_array($cat)) |
|
| 463 | - $post_category = array_map('intval', $cat);
|
|
| 465 | + if (!empty($cat) && is_array($cat)) { |
|
| 466 | + $post_category = array_map('intval', $cat); |
|
| 467 | + } |
|
| 464 | 468 | } |
| 465 | 469 | |
| 466 | 470 | wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
@@ -478,11 +482,13 @@ discard block |
||
| 478 | 482 | if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
|
| 479 | 483 | $post_tags = explode(",", $request_info['post_tags']);
|
| 480 | 484 | } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
|
| 481 | - if ($dummy) |
|
| 482 | - $post_tags = $request_info['post_tags']; |
|
| 485 | + if ($dummy) { |
|
| 486 | + $post_tags = $request_info['post_tags']; |
|
| 487 | + } |
|
| 483 | 488 | } else {
|
| 484 | - if ($dummy) |
|
| 485 | - $post_tags = array($request_info['post_title']); |
|
| 489 | + if ($dummy) { |
|
| 490 | + $post_tags = array($request_info['post_title']); |
|
| 491 | + } |
|
| 486 | 492 | } |
| 487 | 493 | |
| 488 | 494 | if (is_array($post_tags)) {
|
@@ -569,15 +575,17 @@ discard block |
||
| 569 | 575 | |
| 570 | 576 | global $wpdb, $plugin_prefix, $post, $post_info; |
| 571 | 577 | |
| 572 | - if ($post_id == '' && !empty($post)) |
|
| 573 | - $post_id = $post->ID; |
|
| 578 | + if ($post_id == '' && !empty($post)) { |
|
| 579 | + $post_id = $post->ID; |
|
| 580 | + } |
|
| 574 | 581 | |
| 575 | 582 | $post_type = get_post_type($post_id); |
| 576 | 583 | |
| 577 | 584 | $all_postypes = geodir_get_posttypes(); |
| 578 | 585 | |
| 579 | - if (!in_array($post_type, $all_postypes)) |
|
| 580 | - return false; |
|
| 586 | + if (!in_array($post_type, $all_postypes)) { |
|
| 587 | + return false; |
|
| 588 | + } |
|
| 581 | 589 | |
| 582 | 590 | $table = $plugin_prefix . $post_type . '_detail'; |
| 583 | 591 | |
@@ -737,8 +745,9 @@ discard block |
||
| 737 | 745 | do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
|
| 738 | 746 | |
| 739 | 747 | return true; |
| 740 | - } else |
|
| 741 | - return false; |
|
| 748 | + } else { |
|
| 749 | + return false; |
|
| 750 | + } |
|
| 742 | 751 | |
| 743 | 752 | } |
| 744 | 753 | } |
@@ -792,8 +801,9 @@ discard block |
||
| 792 | 801 | } |
| 793 | 802 | |
| 794 | 803 | |
| 795 | - } else |
|
| 796 | - return false; |
|
| 804 | + } else { |
|
| 805 | + return false; |
|
| 806 | + } |
|
| 797 | 807 | } |
| 798 | 808 | } |
| 799 | 809 | |
@@ -824,8 +834,9 @@ discard block |
||
| 824 | 834 | $post_meta_set_query = ''; |
| 825 | 835 | |
| 826 | 836 | foreach ($postmeta as $mkey) {
|
| 827 | - if ($mval != '') |
|
| 828 | - $post_meta_set_query .= $mkey . " = '', "; |
|
| 837 | + if ($mval != '') { |
|
| 838 | + $post_meta_set_query .= $mkey . " = '', "; |
|
| 839 | + } |
|
| 829 | 840 | } |
| 830 | 841 | |
| 831 | 842 | $post_meta_set_query = trim($post_meta_set_query, ", "); |
@@ -859,8 +870,9 @@ discard block |
||
| 859 | 870 | return true; |
| 860 | 871 | } |
| 861 | 872 | |
| 862 | - } else |
|
| 863 | - return false; |
|
| 873 | + } else { |
|
| 874 | + return false; |
|
| 875 | + } |
|
| 864 | 876 | } |
| 865 | 877 | } |
| 866 | 878 | |
@@ -890,8 +902,9 @@ discard block |
||
| 890 | 902 | |
| 891 | 903 | $post_type = get_post_type($post_id); |
| 892 | 904 | |
| 893 | - if (!in_array($post_type, $all_postypes)) |
|
| 894 | - return false; |
|
| 905 | + if (!in_array($post_type, $all_postypes)) { |
|
| 906 | + return false; |
|
| 907 | + } |
|
| 895 | 908 | |
| 896 | 909 | $table = $plugin_prefix . $post_type . '_detail'; |
| 897 | 910 | |
@@ -899,8 +912,9 @@ discard block |
||
| 899 | 912 | $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
| 900 | 913 | if ($meta_value && $meta_value !== '') {
|
| 901 | 914 | return maybe_serialize($meta_value); |
| 902 | - } else |
|
| 903 | - return $meta_value; |
|
| 915 | + } else { |
|
| 916 | + return $meta_value; |
|
| 917 | + } |
|
| 904 | 918 | } else {
|
| 905 | 919 | return false; |
| 906 | 920 | } |
@@ -1034,7 +1048,7 @@ discard block |
||
| 1034 | 1048 | if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
| 1035 | 1049 | $new_name = basename($uploaded['file']); |
| 1036 | 1050 | $uploaded_file = $uploaded; |
| 1037 | - }else{
|
|
| 1051 | + } else{
|
|
| 1038 | 1052 | print_r($uploaded);exit; |
| 1039 | 1053 | } |
| 1040 | 1054 | $external_img = false; |
@@ -1059,8 +1073,9 @@ discard block |
||
| 1059 | 1073 | $file_path = $curr_img_dir . '/' . $filename; |
| 1060 | 1074 | } |
| 1061 | 1075 | |
| 1062 | - if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
| 1063 | - unlink($img_path); |
|
| 1076 | + if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) { |
|
| 1077 | + unlink($img_path); |
|
| 1078 | + } |
|
| 1064 | 1079 | } |
| 1065 | 1080 | |
| 1066 | 1081 | if (!empty($uploaded_file)) {
|
@@ -1089,8 +1104,9 @@ discard block |
||
| 1089 | 1104 | $attachment_set = ''; |
| 1090 | 1105 | |
| 1091 | 1106 | foreach ($attachment as $key => $val) {
|
| 1092 | - if ($val != '') |
|
| 1093 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1107 | + if ($val != '') { |
|
| 1108 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1109 | + } |
|
| 1094 | 1110 | } |
| 1095 | 1111 | |
| 1096 | 1112 | $attachment_set = trim($attachment_set, ", "); |
@@ -1115,8 +1131,9 @@ discard block |
||
| 1115 | 1131 | ) |
| 1116 | 1132 | ); |
| 1117 | 1133 | |
| 1118 | - if ($menu_order == 1) |
|
| 1119 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1134 | + if ($menu_order == 1) { |
|
| 1135 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id))); |
|
| 1136 | + } |
|
| 1120 | 1137 | |
| 1121 | 1138 | } |
| 1122 | 1139 | |
@@ -1157,8 +1174,9 @@ discard block |
||
| 1157 | 1174 | |
| 1158 | 1175 | $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
| 1159 | 1176 | |
| 1160 | - if (!empty($invalid_files)) |
|
| 1161 | - geodir_remove_attachments($invalid_files); |
|
| 1177 | + if (!empty($invalid_files)) { |
|
| 1178 | + geodir_remove_attachments($invalid_files); |
|
| 1179 | + } |
|
| 1162 | 1180 | } |
| 1163 | 1181 | |
| 1164 | 1182 | } |
@@ -1211,16 +1229,19 @@ discard block |
||
| 1211 | 1229 | function geodir_delete_directory($dirname) |
| 1212 | 1230 | {
|
| 1213 | 1231 | $dir_handle = ''; |
| 1214 | - if (is_dir($dirname)) |
|
| 1215 | - $dir_handle = opendir($dirname); |
|
| 1216 | - if (!$dir_handle) |
|
| 1217 | - return false; |
|
| 1232 | + if (is_dir($dirname)) { |
|
| 1233 | + $dir_handle = opendir($dirname); |
|
| 1234 | + } |
|
| 1235 | + if (!$dir_handle) { |
|
| 1236 | + return false; |
|
| 1237 | + } |
|
| 1218 | 1238 | while ($file = readdir($dir_handle)) {
|
| 1219 | 1239 | if ($file != "." && $file != "..") {
|
| 1220 | - if (!is_dir($dirname . "/" . $file)) |
|
| 1221 | - unlink($dirname . "/" . $file); |
|
| 1222 | - else |
|
| 1223 | - geodir_delete_directory($dirname . '/' . $file); |
|
| 1240 | + if (!is_dir($dirname . "/" . $file)) { |
|
| 1241 | + unlink($dirname . "/" . $file); |
|
| 1242 | + } else { |
|
| 1243 | + geodir_delete_directory($dirname . '/' . $file); |
|
| 1244 | + } |
|
| 1224 | 1245 | } |
| 1225 | 1246 | } |
| 1226 | 1247 | closedir($dir_handle); |
@@ -1249,8 +1270,9 @@ discard block |
||
| 1249 | 1270 | foreach ($postcurr_images as $postimg) {
|
| 1250 | 1271 | $image_name_arr = explode('/', $postimg->src);
|
| 1251 | 1272 | $filename = end($image_name_arr); |
| 1252 | - if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1253 | - unlink($uploads_dir . '/' . $filename); |
|
| 1273 | + if (file_exists($uploads_dir . '/' . $filename)) { |
|
| 1274 | + unlink($uploads_dir . '/' . $filename); |
|
| 1275 | + } |
|
| 1254 | 1276 | } |
| 1255 | 1277 | |
| 1256 | 1278 | } // endif |
@@ -1309,8 +1331,9 @@ discard block |
||
| 1309 | 1331 | |
| 1310 | 1332 | $file_info = pathinfo($file); |
| 1311 | 1333 | $sub_dir = ''; |
| 1312 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1313 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1334 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
| 1335 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1336 | + } |
|
| 1314 | 1337 | |
| 1315 | 1338 | $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
| 1316 | 1339 | $uploads_baseurl = $uploads['baseurl']; |
@@ -1354,9 +1377,9 @@ discard block |
||
| 1354 | 1377 | $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
| 1355 | 1378 | } |
| 1356 | 1379 | |
| 1357 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1358 | - $default_img = $default_catimg['src']; |
|
| 1359 | - elseif ($no_image) {
|
|
| 1380 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) { |
|
| 1381 | + $default_img = $default_catimg['src']; |
|
| 1382 | + } elseif ($no_image) {
|
|
| 1360 | 1383 | $default_img = get_option('geodir_listing_no_img');
|
| 1361 | 1384 | } |
| 1362 | 1385 | |
@@ -1388,10 +1411,13 @@ discard block |
||
| 1388 | 1411 | } |
| 1389 | 1412 | } |
| 1390 | 1413 | |
| 1391 | - if (!empty($img_arr)) |
|
| 1392 | - return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1393 | - else |
|
| 1394 | - return false; |
|
| 1414 | + if (!empty($img_arr)) { |
|
| 1415 | + return (object)$img_arr; |
|
| 1416 | + } |
|
| 1417 | + //return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1418 | + else { |
|
| 1419 | + return false; |
|
| 1420 | + } |
|
| 1395 | 1421 | } |
| 1396 | 1422 | } |
| 1397 | 1423 | |
@@ -1418,8 +1444,9 @@ discard block |
||
| 1418 | 1444 | echo $html; |
| 1419 | 1445 | } elseif (!empty($html)) {
|
| 1420 | 1446 | return $html; |
| 1421 | - } else |
|
| 1422 | - return false; |
|
| 1447 | + } else { |
|
| 1448 | + return false; |
|
| 1449 | + } |
|
| 1423 | 1450 | } |
| 1424 | 1451 | } |
| 1425 | 1452 | |
@@ -1447,8 +1474,9 @@ discard block |
||
| 1447 | 1474 | } |
| 1448 | 1475 | $not_featured = ''; |
| 1449 | 1476 | $sub_dir = ''; |
| 1450 | - if (!$add_featured) |
|
| 1451 | - $not_featured = " AND is_featured = 0 "; |
|
| 1477 | + if (!$add_featured) { |
|
| 1478 | + $not_featured = " AND is_featured = 0 "; |
|
| 1479 | + } |
|
| 1452 | 1480 | |
| 1453 | 1481 | $arrImages = $wpdb->get_results( |
| 1454 | 1482 | $wpdb->prepare( |
@@ -1469,8 +1497,9 @@ discard block |
||
| 1469 | 1497 | |
| 1470 | 1498 | $file_info = pathinfo($attechment->file); |
| 1471 | 1499 | |
| 1472 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1473 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1500 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
| 1501 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1502 | + } |
|
| 1474 | 1503 | |
| 1475 | 1504 | $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
| 1476 | 1505 | $uploads_baseurl = $uploads['baseurl']; |
@@ -1515,9 +1544,9 @@ discard block |
||
| 1515 | 1544 | $default_img = ''; |
| 1516 | 1545 | $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
| 1517 | 1546 | $post_type = get_post_type($post_id); |
| 1518 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1519 | - $default_img = $default_catimg['src']; |
|
| 1520 | - elseif ($no_images) {
|
|
| 1547 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) { |
|
| 1548 | + $default_img = $default_catimg['src']; |
|
| 1549 | + } elseif ($no_images) {
|
|
| 1521 | 1550 | $default_img = get_option('geodir_listing_no_img');
|
| 1522 | 1551 | } |
| 1523 | 1552 | |
@@ -1552,8 +1581,9 @@ discard block |
||
| 1552 | 1581 | $return_arr[] = (object)$img_arr; |
| 1553 | 1582 | |
| 1554 | 1583 | return $return_arr; |
| 1555 | - } else |
|
| 1556 | - return false; |
|
| 1584 | + } else { |
|
| 1585 | + return false; |
|
| 1586 | + } |
|
| 1557 | 1587 | } |
| 1558 | 1588 | } |
| 1559 | 1589 | } |
@@ -1614,8 +1644,9 @@ discard block |
||
| 1614 | 1644 | $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
| 1615 | 1645 | } else if ($image->width < ($max_size->h)) {
|
| 1616 | 1646 | $width_per = round((($image->width / $max_size->w) * 100), 2); |
| 1617 | - } else |
|
| 1618 | - $width_per = 100; |
|
| 1647 | + } else { |
|
| 1648 | + $width_per = 100; |
|
| 1649 | + } |
|
| 1619 | 1650 | } |
| 1620 | 1651 | |
| 1621 | 1652 | if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
@@ -1623,7 +1654,7 @@ discard block |
||
| 1623 | 1654 | } else {
|
| 1624 | 1655 | if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
| 1625 | 1656 | $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
| 1626 | - }else{
|
|
| 1657 | + } else{
|
|
| 1627 | 1658 | //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
| 1628 | 1659 | //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>'; |
| 1629 | 1660 | $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>';
|
@@ -1638,8 +1669,9 @@ discard block |
||
| 1638 | 1669 | echo $html; |
| 1639 | 1670 | } elseif (!empty($html)) {
|
| 1640 | 1671 | return $html; |
| 1641 | - } else |
|
| 1642 | - return false; |
|
| 1672 | + } else { |
|
| 1673 | + return false; |
|
| 1674 | + } |
|
| 1643 | 1675 | } |
| 1644 | 1676 | } |
| 1645 | 1677 | |
@@ -1677,8 +1709,9 @@ discard block |
||
| 1677 | 1709 | $post_obj = get_post($post_id); |
| 1678 | 1710 | |
| 1679 | 1711 | $cat_ids = array('0');
|
| 1680 | - if (is_array($tt_ids)) |
|
| 1681 | - $cat_ids = $tt_ids; |
|
| 1712 | + if (is_array($tt_ids)) { |
|
| 1713 | + $cat_ids = $tt_ids; |
|
| 1714 | + } |
|
| 1682 | 1715 | |
| 1683 | 1716 | |
| 1684 | 1717 | if (!empty($cat_ids)) {
|
@@ -1735,8 +1768,9 @@ discard block |
||
| 1735 | 1768 | $json .= '}'; |
| 1736 | 1769 | |
| 1737 | 1770 | |
| 1738 | - if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
| 1739 | - $post_marker_json = $json; |
|
| 1771 | + if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) { |
|
| 1772 | + $post_marker_json = $json; |
|
| 1773 | + } |
|
| 1740 | 1774 | |
| 1741 | 1775 | |
| 1742 | 1776 | if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
@@ -1767,10 +1801,13 @@ discard block |
||
| 1767 | 1801 | if (!empty($post_term) && is_array($post_term)) {
|
| 1768 | 1802 | $categories = implode(',', $post_term);
|
| 1769 | 1803 | |
| 1770 | - if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1804 | + if ($categories != '' && $categories != 0) { |
|
| 1805 | + $categories = ',' . $categories . ','; |
|
| 1806 | + } |
|
| 1771 | 1807 | |
| 1772 | - if (empty($post_marker_json)) |
|
| 1773 | - $post_marker_json = isset($json) ? $json : ''; |
|
| 1808 | + if (empty($post_marker_json)) { |
|
| 1809 | + $post_marker_json = isset($json) ? $json : ''; |
|
| 1810 | + } |
|
| 1774 | 1811 | |
| 1775 | 1812 | if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
| 1776 | 1813 | |
@@ -1809,8 +1846,9 @@ discard block |
||
| 1809 | 1846 | |
| 1810 | 1847 | } |
| 1811 | 1848 | |
| 1812 | - if ($default_category == '') |
|
| 1813 | - $default_category = $categories[0]; |
|
| 1849 | + if ($default_category == '') { |
|
| 1850 | + $default_category = $categories[0]; |
|
| 1851 | + } |
|
| 1814 | 1852 | |
| 1815 | 1853 | geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
| 1816 | 1854 | |
@@ -1951,7 +1989,7 @@ discard block |
||
| 1951 | 1989 | } ?>"><img alt="bubble image" style="max-height:50px;" |
| 1952 | 1990 | src="<?php echo $post_images[0]; ?>"/></a></div> |
| 1953 | 1991 | <?php |
| 1954 | - }else{
|
|
| 1992 | + } else{
|
|
| 1955 | 1993 | echo '<div class="geodir-bubble_image"></div>'; |
| 1956 | 1994 | } |
| 1957 | 1995 | } else {
|
@@ -1959,7 +1997,7 @@ discard block |
||
| 1959 | 1997 | ?> |
| 1960 | 1998 | <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div> |
| 1961 | 1999 | <?php |
| 1962 | - }else{
|
|
| 2000 | + } else{
|
|
| 1963 | 2001 | echo '<div class="geodir-bubble_image"></div>'; |
| 1964 | 2002 | } |
| 1965 | 2003 | } |
@@ -2040,10 +2078,11 @@ discard block |
||
| 2040 | 2078 | */ |
| 2041 | 2079 | function geodir_new_post_default_status() |
| 2042 | 2080 | {
|
| 2043 | - if (get_option('geodir_new_post_default_status'))
|
|
| 2044 | - return get_option('geodir_new_post_default_status');
|
|
| 2045 | - else |
|
| 2046 | - return 'publish'; |
|
| 2081 | + if (get_option('geodir_new_post_default_status')) { |
|
| 2082 | + return get_option('geodir_new_post_default_status'); |
|
| 2083 | + } else { |
|
| 2084 | + return 'publish'; |
|
| 2085 | + } |
|
| 2047 | 2086 | |
| 2048 | 2087 | } |
| 2049 | 2088 | } |
@@ -2194,8 +2233,9 @@ discard block |
||
| 2194 | 2233 | |
| 2195 | 2234 | $all_postypes = geodir_get_posttypes(); |
| 2196 | 2235 | |
| 2197 | - if (!in_array($post_type, $all_postypes)) |
|
| 2198 | - return false; |
|
| 2236 | + if (!in_array($post_type, $all_postypes)) { |
|
| 2237 | + return false; |
|
| 2238 | + } |
|
| 2199 | 2239 | |
| 2200 | 2240 | $table = $plugin_prefix . $post_type . '_detail'; |
| 2201 | 2241 | |
@@ -2463,8 +2503,9 @@ discard block |
||
| 2463 | 2503 | $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
|
| 2464 | 2504 | |
| 2465 | 2505 | $user_meta_data = ''; |
| 2466 | - if (isset($current_user->data->ID)) |
|
| 2467 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2506 | + if (isset($current_user->data->ID)) { |
|
| 2507 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2508 | + } |
|
| 2468 | 2509 | |
| 2469 | 2510 | if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
| 2470 | 2511 | ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
@@ -2477,8 +2518,9 @@ discard block |
||
| 2477 | 2518 | |
| 2478 | 2519 | if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
| 2479 | 2520 | $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
| 2480 | - } else |
|
| 2481 | - $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2521 | + } else { |
|
| 2522 | + $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')'; |
|
| 2523 | + } |
|
| 2482 | 2524 | |
| 2483 | 2525 | ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
| 2484 | 2526 | href="javascript:void(0);" |
@@ -2541,14 +2583,16 @@ discard block |
||
| 2541 | 2583 | WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
|
| 2542 | 2584 | |
| 2543 | 2585 | $cat_post_count = $wpdb->get_var($count_query); |
| 2544 | - if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
| 2545 | - $cat_post_count = 0; |
|
| 2586 | + if (empty($cat_post_count) || is_wp_error($cat_post_count)) { |
|
| 2587 | + $cat_post_count = 0; |
|
| 2588 | + } |
|
| 2546 | 2589 | |
| 2547 | 2590 | return $cat_post_count; |
| 2548 | 2591 | |
| 2549 | - } else |
|
| 2550 | - |
|
| 2551 | - return $term->count; |
|
| 2592 | + } else { |
|
| 2593 | + |
|
| 2594 | + return $term->count; |
|
| 2595 | + } |
|
| 2552 | 2596 | } |
| 2553 | 2597 | return false; |
| 2554 | 2598 | |
@@ -2595,13 +2639,15 @@ discard block |
||
| 2595 | 2639 | return $length; |
| 2596 | 2640 | } |
| 2597 | 2641 | |
| 2598 | - if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
|
|
| 2599 | - $length = get_option('geodir_desc_word_limit');
|
|
| 2600 | - elseif (get_query_var('excerpt_length'))
|
|
| 2601 | - $length = get_query_var('excerpt_length');
|
|
| 2642 | + if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit')) { |
|
| 2643 | + $length = get_option('geodir_desc_word_limit'); |
|
| 2644 | + } elseif (get_query_var('excerpt_length')) { |
|
| 2645 | + $length = get_query_var('excerpt_length'); |
|
| 2646 | + } |
|
| 2602 | 2647 | |
| 2603 | - if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
|
|
| 2604 | - $length = get_option('geodir_author_desc_word_limit');
|
|
| 2648 | + if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit')) { |
|
| 2649 | + $length = get_option('geodir_author_desc_word_limit'); |
|
| 2650 | + } |
|
| 2605 | 2651 | |
| 2606 | 2652 | return $length; |
| 2607 | 2653 | } |
@@ -2734,10 +2780,11 @@ discard block |
||
| 2734 | 2780 | function geodir_lisiting_belong_to_user($listing_id, $user_id) |
| 2735 | 2781 | {
|
| 2736 | 2782 | $listing_author_id = geodir_get_listing_author($listing_id); |
| 2737 | - if ($listing_author_id == $user_id) |
|
| 2738 | - return true; |
|
| 2739 | - else |
|
| 2740 | - return false; |
|
| 2783 | + if ($listing_author_id == $user_id) { |
|
| 2784 | + return true; |
|
| 2785 | + } else { |
|
| 2786 | + return false; |
|
| 2787 | + } |
|
| 2741 | 2788 | |
| 2742 | 2789 | } |
| 2743 | 2790 | |
@@ -2786,10 +2833,11 @@ discard block |
||
| 2786 | 2833 | $pattern = '/-\d+x\d+\./'; |
| 2787 | 2834 | preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
| 2788 | 2835 | |
| 2789 | - if (empty($matches)) |
|
| 2790 | - return ''; |
|
| 2791 | - else |
|
| 2792 | - return $file; |
|
| 2836 | + if (empty($matches)) { |
|
| 2837 | + return ''; |
|
| 2838 | + } else { |
|
| 2839 | + return $file; |
|
| 2840 | + } |
|
| 2793 | 2841 | |
| 2794 | 2842 | } |
| 2795 | 2843 | |
@@ -2874,8 +2922,9 @@ discard block |
||
| 2874 | 2922 | } else {
|
| 2875 | 2923 | //set_post_thumbnail($post_id,-1); |
| 2876 | 2924 | |
| 2877 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
| 2878 | - wp_delete_attachment($post_thumbnail_id); |
|
| 2925 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) { |
|
| 2926 | + wp_delete_attachment($post_thumbnail_id); |
|
| 2927 | + } |
|
| 2879 | 2928 | |
| 2880 | 2929 | } |
| 2881 | 2930 | } |
@@ -2960,8 +3009,9 @@ discard block |
||
| 2960 | 3009 | |
| 2961 | 3010 | global $wpdb; |
| 2962 | 3011 | |
| 2963 | - if ($listing_type == '') |
|
| 2964 | - $listing_type = 'gd_place'; |
|
| 3012 | + if ($listing_type == '') { |
|
| 3013 | + $listing_type = 'gd_place'; |
|
| 3014 | + } |
|
| 2965 | 3015 | |
| 2966 | 3016 | $fields_info = array(); |
| 2967 | 3017 | |
@@ -2984,8 +3034,9 @@ discard block |
||
| 2984 | 3034 | |
| 2985 | 3035 | $fields_info[$prefix . 'address'] = $data->field_type; |
| 2986 | 3036 | |
| 2987 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
| 2988 | - $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 3037 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { |
|
| 3038 | + $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 3039 | + } |
|
| 2989 | 3040 | |
| 2990 | 3041 | } else {
|
| 2991 | 3042 | |