@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Admin functions. |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Admin functions. |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Updates option value when GeoDirectory get deactivated. |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
| 133 | 133 | wp_enqueue_script('geodirectory-goMap-script');
|
| 134 | 134 | |
| 135 | - // font awesome rating script |
|
| 136 | - if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
|
| 137 | - wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 138 | - wp_enqueue_script('geodir-barrating-js');
|
|
| 139 | - } else { // default rating script
|
|
| 140 | - wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | - wp_enqueue_script('geodir-jRating-js');
|
|
| 142 | - } |
|
| 135 | + // font awesome rating script |
|
| 136 | + if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
|
| 137 | + wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 138 | + wp_enqueue_script('geodir-barrating-js');
|
|
| 139 | + } else { // default rating script
|
|
| 140 | + wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | + wp_enqueue_script('geodir-jRating-js');
|
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
| 145 | 145 | wp_enqueue_script('geodir-on-document-load');
|
@@ -337,13 +337,13 @@ discard block |
||
| 337 | 337 | flush_rewrite_rules(false); |
| 338 | 338 | |
| 339 | 339 | break; |
| 340 | - case 'fail': |
|
| 341 | - $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
|
| 340 | + case 'fail': |
|
| 341 | + $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
|
| 342 | 342 | |
| 343 | - if ($gderr == 21) |
|
| 344 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 345 | - else |
|
| 346 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 343 | + if ($gderr == 21) |
|
| 344 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 345 | + else |
|
| 346 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 347 | 347 | break; |
| 348 | 348 | } |
| 349 | 349 | } |
@@ -383,15 +383,15 @@ discard block |
||
| 383 | 383 | if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
| 384 | 384 | if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
| 385 | 385 | |
| 386 | - /** |
|
| 387 | - * Fires before updating geodirectory admin settings. |
|
| 388 | - * |
|
| 389 | - * @since 1.4.2 |
|
| 390 | - * |
|
| 391 | - * @param string $current_tab Current tab in geodirectory settings. |
|
| 392 | - * @param array $geodir_settings Array of geodirectory settings. |
|
| 393 | - */ |
|
| 394 | - do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
|
| 386 | + /** |
|
| 387 | + * Fires before updating geodirectory admin settings. |
|
| 388 | + * |
|
| 389 | + * @since 1.4.2 |
|
| 390 | + * |
|
| 391 | + * @param string $current_tab Current tab in geodirectory settings. |
|
| 392 | + * @param array $geodir_settings Array of geodirectory settings. |
|
| 393 | + */ |
|
| 394 | + do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
|
| 395 | 395 | |
| 396 | 396 | if (!empty($geodir_settings[$current_tab])) |
| 397 | 397 | geodir_update_options($geodir_settings[$current_tab]); |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | <?php |
| 481 | 481 | |
| 482 | 482 | $default_location = geodir_get_default_location(); |
| 483 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 484 | - $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 485 | - $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 486 | - $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 487 | - $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 483 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 484 | + $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 485 | + $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 486 | + $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 487 | + $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 488 | 488 | |
| 489 | 489 | ?> |
| 490 | 490 | var geocoder = new google.maps.Geocoder(); |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | */ |
| 758 | 758 | function geodir_update_options($options, $dummy = false) |
| 759 | 759 | {
|
| 760 | - // print_r($_POST); print_r($options); exit; |
|
| 760 | + // print_r($_POST); print_r($options); exit; |
|
| 761 | 761 | |
| 762 | 762 | if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
| 763 | 763 | |
@@ -2281,10 +2281,10 @@ discard block |
||
| 2281 | 2281 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 2282 | 2282 | style=" <?php echo esc_attr($value['css']); ?>" |
| 2283 | 2283 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2284 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2285 | - } else {
|
|
| 2286 | - echo esc_attr($value['std']); |
|
| 2287 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2284 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2285 | + } else {
|
|
| 2286 | + echo esc_attr($value['std']); |
|
| 2287 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2288 | 2288 | </tr><?php |
| 2289 | 2289 | break; |
| 2290 | 2290 | |
@@ -2298,10 +2298,10 @@ discard block |
||
| 2298 | 2298 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 2299 | 2299 | style="<?php echo esc_attr($value['css']); ?>" |
| 2300 | 2300 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2301 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2302 | - } else {
|
|
| 2303 | - echo esc_attr($value['std']); |
|
| 2304 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2301 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2302 | + } else {
|
|
| 2303 | + echo esc_attr($value['std']); |
|
| 2304 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2305 | 2305 | </tr><?php |
| 2306 | 2306 | break; |
| 2307 | 2307 | |
@@ -2321,10 +2321,10 @@ discard block |
||
| 2321 | 2321 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
| 2322 | 2322 | style="<?php echo esc_attr($value['css']); ?>" |
| 2323 | 2323 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2324 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2325 | - } else {
|
|
| 2326 | - echo esc_attr($value['std']); |
|
| 2327 | - } ?>" class="colorpick"/> <span |
|
| 2324 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2325 | + } else {
|
|
| 2326 | + echo esc_attr($value['std']); |
|
| 2327 | + } ?>" class="colorpick"/> <span |
|
| 2328 | 2328 | class="description"><?php echo $value['desc']; ?></span> |
| 2329 | 2329 | |
| 2330 | 2330 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
@@ -2713,22 +2713,22 @@ discard block |
||
| 2713 | 2713 | |
| 2714 | 2714 | case 'single_select_page' : |
| 2715 | 2715 | // WPML |
| 2716 | - $switch_lang = false; |
|
| 2717 | - $disabled = ''; |
|
| 2718 | - if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
|
| 2719 | - global $sitepress; |
|
| 2716 | + $switch_lang = false; |
|
| 2717 | + $disabled = ''; |
|
| 2718 | + if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
|
| 2719 | + global $sitepress; |
|
| 2720 | 2720 | |
| 2721 | - $default_lang = $sitepress->get_default_language(); |
|
| 2722 | - $current_lang = $sitepress->get_current_language(); |
|
| 2721 | + $default_lang = $sitepress->get_default_language(); |
|
| 2722 | + $current_lang = $sitepress->get_current_language(); |
|
| 2723 | 2723 | |
| 2724 | - if ($current_lang != 'all' && $current_lang != $default_lang) {
|
|
| 2725 | - $disabled = "disabled='disabled'"; |
|
| 2726 | - $switch_lang = $current_lang; |
|
| 2727 | - $sitepress->switch_lang('all', true);
|
|
| 2728 | - } |
|
| 2729 | - } |
|
| 2730 | - // |
|
| 2731 | - $page_setting = (int)get_option($value['id']); |
|
| 2724 | + if ($current_lang != 'all' && $current_lang != $default_lang) {
|
|
| 2725 | + $disabled = "disabled='disabled'"; |
|
| 2726 | + $switch_lang = $current_lang; |
|
| 2727 | + $sitepress->switch_lang('all', true);
|
|
| 2728 | + } |
|
| 2729 | + } |
|
| 2730 | + // |
|
| 2731 | + $page_setting = (int)get_option($value['id']); |
|
| 2732 | 2732 | |
| 2733 | 2733 | $args = array('name' => $value['id'],
|
| 2734 | 2734 | 'id' => $value['id'], |
@@ -2749,9 +2749,9 @@ discard block |
||
| 2749 | 2749 | <span class="description"><?php echo $value['desc'] ?></span> |
| 2750 | 2750 | </td> |
| 2751 | 2751 | </tr><?php |
| 2752 | - if ($switch_lang) {
|
|
| 2753 | - $sitepress->switch_lang($switch_lang, true); |
|
| 2754 | - } |
|
| 2752 | + if ($switch_lang) {
|
|
| 2753 | + $sitepress->switch_lang($switch_lang, true); |
|
| 2754 | + } |
|
| 2755 | 2755 | break; |
| 2756 | 2756 | case 'single_select_country' : |
| 2757 | 2757 | $countries = $geodirectory->countries->countries; |
@@ -3396,22 +3396,22 @@ discard block |
||
| 3396 | 3396 | * @return string Post type ex: gd_place |
| 3397 | 3397 | */ |
| 3398 | 3398 | function geodir_admin_current_post_type() {
|
| 3399 | - global $post, $typenow, $current_screen; |
|
| 3399 | + global $post, $typenow, $current_screen; |
|
| 3400 | 3400 | |
| 3401 | - $post_type = NULL; |
|
| 3401 | + $post_type = NULL; |
|
| 3402 | 3402 | |
| 3403 | - if ($post && isset($post->post_type)) |
|
| 3404 | - $post_type = $post->post_type; |
|
| 3405 | - elseif ($typenow) |
|
| 3406 | - $post_type = $typenow; |
|
| 3407 | - elseif ($current_screen && isset($current_screen->post_type)) |
|
| 3408 | - $post_type = $current_screen->post_type; |
|
| 3409 | - elseif (isset($_REQUEST['post_type'])) |
|
| 3410 | - $post_type = sanitize_key($_REQUEST['post_type']); |
|
| 3411 | - elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 3412 | - $post_type = get_post_type($_REQUEST['post']); |
|
| 3413 | - |
|
| 3414 | - return $post_type; |
|
| 3403 | + if ($post && isset($post->post_type)) |
|
| 3404 | + $post_type = $post->post_type; |
|
| 3405 | + elseif ($typenow) |
|
| 3406 | + $post_type = $typenow; |
|
| 3407 | + elseif ($current_screen && isset($current_screen->post_type)) |
|
| 3408 | + $post_type = $current_screen->post_type; |
|
| 3409 | + elseif (isset($_REQUEST['post_type'])) |
|
| 3410 | + $post_type = sanitize_key($_REQUEST['post_type']); |
|
| 3411 | + elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 3412 | + $post_type = get_post_type($_REQUEST['post']); |
|
| 3413 | + |
|
| 3414 | + return $post_type; |
|
| 3415 | 3415 | } |
| 3416 | 3416 | |
| 3417 | 3417 | /** |
@@ -3426,33 +3426,33 @@ discard block |
||
| 3426 | 3426 | * @param array $geodir_settings Array of geodirectory settings. |
| 3427 | 3427 | */ |
| 3428 | 3428 | function geodir_before_update_options($current_tab, $geodir_settings) {
|
| 3429 | - $active_tab = isset($_REQUEST['active_tab']) ? trim($_REQUEST['active_tab']) : ''; |
|
| 3429 | + $active_tab = isset($_REQUEST['active_tab']) ? trim($_REQUEST['active_tab']) : ''; |
|
| 3430 | 3430 | |
| 3431 | - // Permalink settings |
|
| 3432 | - if ($current_tab == 'permalink_settings') {
|
|
| 3433 | - $listing_prefix = isset($_POST['geodir_listing_prefix']) ? trim($_POST['geodir_listing_prefix']) : ''; |
|
| 3434 | - $location_prefix = isset($_POST['geodir_location_prefix']) ? trim($_POST['geodir_location_prefix']) : ''; |
|
| 3431 | + // Permalink settings |
|
| 3432 | + if ($current_tab == 'permalink_settings') {
|
|
| 3433 | + $listing_prefix = isset($_POST['geodir_listing_prefix']) ? trim($_POST['geodir_listing_prefix']) : ''; |
|
| 3434 | + $location_prefix = isset($_POST['geodir_location_prefix']) ? trim($_POST['geodir_location_prefix']) : ''; |
|
| 3435 | 3435 | |
| 3436 | - // Don't allow same slug url for listing and location |
|
| 3437 | - if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
|
| 3438 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
|
| 3439 | - wp_redirect($redirect_url); |
|
| 3440 | - exit; |
|
| 3441 | - } |
|
| 3436 | + // Don't allow same slug url for listing and location |
|
| 3437 | + if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
|
| 3438 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
|
| 3439 | + wp_redirect($redirect_url); |
|
| 3440 | + exit; |
|
| 3441 | + } |
|
| 3442 | 3442 | |
| 3443 | - // Don't allow to update page settings on different language. |
|
| 3444 | - if (geodir_is_wpml()) {
|
|
| 3445 | - global $sitepress; |
|
| 3446 | - $current_language = $sitepress->get_current_language(); |
|
| 3447 | - $default_language = $sitepress->get_default_language(); |
|
| 3443 | + // Don't allow to update page settings on different language. |
|
| 3444 | + if (geodir_is_wpml()) {
|
|
| 3445 | + global $sitepress; |
|
| 3446 | + $current_language = $sitepress->get_current_language(); |
|
| 3447 | + $default_language = $sitepress->get_default_language(); |
|
| 3448 | 3448 | |
| 3449 | - if ($current_language != 'all' && $current_language != $default_language) {
|
|
| 3450 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
|
|
| 3451 | - wp_redirect($redirect_url); |
|
| 3452 | - exit; |
|
| 3453 | - } |
|
| 3454 | - } |
|
| 3455 | - } |
|
| 3449 | + if ($current_language != 'all' && $current_language != $default_language) {
|
|
| 3450 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
|
|
| 3451 | + wp_redirect($redirect_url); |
|
| 3452 | + exit; |
|
| 3453 | + } |
|
| 3454 | + } |
|
| 3455 | + } |
|
| 3456 | 3456 | } |
| 3457 | 3457 | |
| 3458 | 3458 | |
@@ -3483,7 +3483,7 @@ discard block |
||
| 3483 | 3483 | * @return array Array of tab data. |
| 3484 | 3484 | */ |
| 3485 | 3485 | function geodir_import_export_tab( $tabs ) {
|
| 3486 | - $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
|
| 3486 | + $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
|
| 3487 | 3487 | return $tabs; |
| 3488 | 3488 | } |
| 3489 | 3489 | |
@@ -3497,8 +3497,8 @@ discard block |
||
| 3497 | 3497 | * @return string Html content. |
| 3498 | 3498 | */ |
| 3499 | 3499 | function geodir_import_export_page() {
|
| 3500 | - $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
|
| 3501 | - $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
|
| 3500 | + $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
|
| 3501 | + $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
|
| 3502 | 3502 | /** |
| 3503 | 3503 | * Filter sample category data csv file url. |
| 3504 | 3504 | * |
@@ -3507,9 +3507,9 @@ discard block |
||
| 3507 | 3507 | * |
| 3508 | 3508 | * @param string $gd_cats_sample_csv Sample category data csv file url. |
| 3509 | 3509 | */ |
| 3510 | - $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
|
| 3510 | + $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
|
| 3511 | 3511 | |
| 3512 | - $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
|
| 3512 | + $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
|
| 3513 | 3513 | /** |
| 3514 | 3514 | * Filter sample post data csv file url. |
| 3515 | 3515 | * |
@@ -3520,42 +3520,42 @@ discard block |
||
| 3520 | 3520 | */ |
| 3521 | 3521 | $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
| 3522 | 3522 | |
| 3523 | - $gd_posttypes = geodir_get_posttypes( 'array' ); |
|
| 3523 | + $gd_posttypes = geodir_get_posttypes( 'array' ); |
|
| 3524 | 3524 | |
| 3525 | - $gd_posttypes_option = ''; |
|
| 3526 | - foreach ( $gd_posttypes as $gd_posttype => $row ) {
|
|
| 3527 | - $gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>'; |
|
| 3528 | - } |
|
| 3529 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 3525 | + $gd_posttypes_option = ''; |
|
| 3526 | + foreach ( $gd_posttypes as $gd_posttype => $row ) {
|
|
| 3527 | + $gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>'; |
|
| 3528 | + } |
|
| 3529 | + wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 3530 | 3530 | |
| 3531 | - $gd_chunksize_options = array(); |
|
| 3532 | - $gd_chunksize_options[100] = 100; |
|
| 3533 | - $gd_chunksize_options[200] = 200; |
|
| 3534 | - $gd_chunksize_options[500] = 500; |
|
| 3535 | - $gd_chunksize_options[1000] = 1000; |
|
| 3536 | - $gd_chunksize_options[2000] = 2000; |
|
| 3537 | - $gd_chunksize_options[5000] = 5000; |
|
| 3538 | - $gd_chunksize_options[10000] = 10000; |
|
| 3539 | - $gd_chunksize_options[20000] = 20000; |
|
| 3540 | - $gd_chunksize_options[50000] = 50000; |
|
| 3541 | - $gd_chunksize_options[100000] = 100000; |
|
| 3531 | + $gd_chunksize_options = array(); |
|
| 3532 | + $gd_chunksize_options[100] = 100; |
|
| 3533 | + $gd_chunksize_options[200] = 200; |
|
| 3534 | + $gd_chunksize_options[500] = 500; |
|
| 3535 | + $gd_chunksize_options[1000] = 1000; |
|
| 3536 | + $gd_chunksize_options[2000] = 2000; |
|
| 3537 | + $gd_chunksize_options[5000] = 5000; |
|
| 3538 | + $gd_chunksize_options[10000] = 10000; |
|
| 3539 | + $gd_chunksize_options[20000] = 20000; |
|
| 3540 | + $gd_chunksize_options[50000] = 50000; |
|
| 3541 | + $gd_chunksize_options[100000] = 100000; |
|
| 3542 | 3542 | |
| 3543 | - /** |
|
| 3544 | - * Filter max entries per export csv file. |
|
| 3545 | - * |
|
| 3546 | - * @since 1.5.6 |
|
| 3547 | - * @package GeoDirectory |
|
| 3548 | - * |
|
| 3549 | - * @param string $gd_chunksize_options Entries options. |
|
| 3550 | - */ |
|
| 3543 | + /** |
|
| 3544 | + * Filter max entries per export csv file. |
|
| 3545 | + * |
|
| 3546 | + * @since 1.5.6 |
|
| 3547 | + * @package GeoDirectory |
|
| 3548 | + * |
|
| 3549 | + * @param string $gd_chunksize_options Entries options. |
|
| 3550 | + */ |
|
| 3551 | 3551 | $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
| 3552 | 3552 | |
| 3553 | - $gd_chunksize_option = ''; |
|
| 3554 | - foreach ($gd_chunksize_options as $value => $title) {
|
|
| 3555 | - $gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>'; |
|
| 3556 | - } |
|
| 3553 | + $gd_chunksize_option = ''; |
|
| 3554 | + foreach ($gd_chunksize_options as $value => $title) {
|
|
| 3555 | + $gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>'; |
|
| 3556 | + } |
|
| 3557 | 3557 | |
| 3558 | - $uploads = wp_upload_dir(); |
|
| 3558 | + $uploads = wp_upload_dir(); |
|
| 3559 | 3559 | ?> |
| 3560 | 3560 | </form> |
| 3561 | 3561 | <div class="inner_content_tab_main gd-import-export"> |
@@ -3617,13 +3617,13 @@ discard block |
||
| 3617 | 3617 | <input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample"> |
| 3618 | 3618 | <input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" /> |
| 3619 | 3619 | <?php |
| 3620 | - /** |
|
| 3621 | - * Called just after the sample CSV download link. |
|
| 3622 | - * |
|
| 3623 | - * @since 1.0.0 |
|
| 3624 | - */ |
|
| 3625 | - do_action('geodir_sample_csv_download_link');
|
|
| 3626 | - ?> |
|
| 3620 | + /** |
|
| 3621 | + * Called just after the sample CSV download link. |
|
| 3622 | + * |
|
| 3623 | + * @since 1.0.0 |
|
| 3624 | + */ |
|
| 3625 | + do_action('geodir_sample_csv_download_link');
|
|
| 3626 | + ?> |
|
| 3627 | 3627 | <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span> |
| 3628 | 3628 | <div class="filelist"></div> |
| 3629 | 3629 | </div> |
@@ -3731,14 +3731,14 @@ discard block |
||
| 3731 | 3731 | <input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample"> |
| 3732 | 3732 | <input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" /> |
| 3733 | 3733 | <?php |
| 3734 | - /** |
|
| 3735 | - * Called just after the sample CSV download link. |
|
| 3736 | - * |
|
| 3737 | - * @since 1.0.0 |
|
| 3734 | + /** |
|
| 3735 | + * Called just after the sample CSV download link. |
|
| 3736 | + * |
|
| 3737 | + * @since 1.0.0 |
|
| 3738 | 3738 | * @package GeoDirectory |
| 3739 | - */ |
|
| 3740 | - do_action('geodir_sample_cats_csv_download_link');
|
|
| 3741 | - ?> |
|
| 3739 | + */ |
|
| 3740 | + do_action('geodir_sample_cats_csv_download_link');
|
|
| 3741 | + ?> |
|
| 3742 | 3742 | <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span> |
| 3743 | 3743 | <div class="filelist"></div> |
| 3744 | 3744 | </div> |
@@ -3814,19 +3814,19 @@ discard block |
||
| 3814 | 3814 | </div> |
| 3815 | 3815 | </div> |
| 3816 | 3816 | <?php |
| 3817 | - /** |
|
| 3818 | - * Allows you to add more setting to the GD > Import & Export page. |
|
| 3819 | - * |
|
| 3820 | - * Called after the last setting on the GD > Import & Export page. |
|
| 3821 | - * @since 1.4.6 |
|
| 3817 | + /** |
|
| 3818 | + * Allows you to add more setting to the GD > Import & Export page. |
|
| 3819 | + * |
|
| 3820 | + * Called after the last setting on the GD > Import & Export page. |
|
| 3821 | + * @since 1.4.6 |
|
| 3822 | 3822 | * @package GeoDirectory |
| 3823 | - * |
|
| 3824 | - * @param array $gd_posttypes GD post types. |
|
| 3823 | + * |
|
| 3824 | + * @param array $gd_posttypes GD post types. |
|
| 3825 | 3825 | * @param array $gd_chunksize_options File chunk size options. |
| 3826 | 3826 | * @param string $nonce Wordpress security token for GD import & export. |
| 3827 | - */ |
|
| 3828 | - do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
|
| 3829 | - ?> |
|
| 3827 | + */ |
|
| 3828 | + do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
|
| 3829 | + ?> |
|
| 3830 | 3830 | </div> |
| 3831 | 3831 | </div> |
| 3832 | 3832 | <script type="text/javascript"> |
@@ -4547,7 +4547,7 @@ discard block |
||
| 4547 | 4547 | * @return string Json data. |
| 4548 | 4548 | */ |
| 4549 | 4549 | function geodir_ajax_import_export() {
|
| 4550 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 4550 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 4551 | 4551 | |
| 4552 | 4552 | // try to set higher limits for import |
| 4553 | 4553 | $max_input_time = ini_get('max_input_time');
|
@@ -4568,26 +4568,26 @@ discard block |
||
| 4568 | 4568 | } |
| 4569 | 4569 | } |
| 4570 | 4570 | |
| 4571 | - error_reporting(0); |
|
| 4571 | + error_reporting(0); |
|
| 4572 | 4572 | |
| 4573 | - $json = array(); |
|
| 4573 | + $json = array(); |
|
| 4574 | 4574 | |
| 4575 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 4576 | - wp_send_json( $json ); |
|
| 4577 | - } |
|
| 4575 | + if ( !current_user_can( 'manage_options' ) ) {
|
|
| 4576 | + wp_send_json( $json ); |
|
| 4577 | + } |
|
| 4578 | 4578 | |
| 4579 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 4580 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 4581 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 4579 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 4580 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 4581 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 4582 | 4582 | |
| 4583 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 4584 | - wp_send_json( $json ); |
|
| 4585 | - } |
|
| 4583 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 4584 | + wp_send_json( $json ); |
|
| 4585 | + } |
|
| 4586 | 4586 | |
| 4587 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 4588 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 4589 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 4590 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 4587 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 4588 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 4589 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 4590 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 4591 | 4591 | |
| 4592 | 4592 | $wp_filesystem = geodir_init_filesystem(); |
| 4593 | 4593 | if (!$wp_filesystem) {
|
@@ -4595,551 +4595,551 @@ discard block |
||
| 4595 | 4595 | wp_send_json( $json ); |
| 4596 | 4596 | } |
| 4597 | 4597 | |
| 4598 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 4599 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 4598 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 4599 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 4600 | 4600 | wp_send_json( $json ); |
| 4601 | - } |
|
| 4601 | + } |
|
| 4602 | 4602 | |
| 4603 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 4604 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 4605 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 4606 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4607 | - wp_send_json( $json ); |
|
| 4608 | - } |
|
| 4609 | - } |
|
| 4603 | + $csv_file_dir = geodir_path_import_export( false ); |
|
| 4604 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 4605 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 4606 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4607 | + wp_send_json( $json ); |
|
| 4608 | + } |
|
| 4609 | + } |
|
| 4610 | 4610 | |
| 4611 | - switch ( $task ) {
|
|
| 4612 | - case 'export_posts': {
|
|
| 4613 | - // WPML |
|
| 4614 | - $is_wpml = geodir_is_wpml(); |
|
| 4615 | - if ($is_wpml) {
|
|
| 4616 | - global $sitepress; |
|
| 4617 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4611 | + switch ( $task ) {
|
|
| 4612 | + case 'export_posts': {
|
|
| 4613 | + // WPML |
|
| 4614 | + $is_wpml = geodir_is_wpml(); |
|
| 4615 | + if ($is_wpml) {
|
|
| 4616 | + global $sitepress; |
|
| 4617 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4618 | 4618 | |
| 4619 | - $sitepress->switch_lang('all', true);
|
|
| 4620 | - } |
|
| 4621 | - // WPML |
|
| 4622 | - if ( $post_type == 'gd_event' ) {
|
|
| 4623 | - //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 ); |
|
| 4624 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 4625 | - } |
|
| 4626 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 4627 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 4628 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4629 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4630 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4631 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 4619 | + $sitepress->switch_lang('all', true);
|
|
| 4620 | + } |
|
| 4621 | + // WPML |
|
| 4622 | + if ( $post_type == 'gd_event' ) {
|
|
| 4623 | + //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 ); |
|
| 4624 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 4625 | + } |
|
| 4626 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 4627 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
| 4628 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4629 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4630 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4631 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 4632 | 4632 | |
| 4633 | - $chunk_file_paths = array(); |
|
| 4633 | + $chunk_file_paths = array(); |
|
| 4634 | 4634 | |
| 4635 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4636 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4637 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 4638 | - $percentage = min( $percentage, 100 ); |
|
| 4635 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4636 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4637 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 4638 | + $percentage = min( $percentage, 100 ); |
|
| 4639 | 4639 | |
| 4640 | - $json['percentage'] = $percentage; |
|
| 4641 | - // WPML |
|
| 4642 | - if ($is_wpml) {
|
|
| 4643 | - $sitepress->switch_lang($active_lang, true); |
|
| 4644 | - } |
|
| 4645 | - // WPML |
|
| 4646 | - wp_send_json( $json ); |
|
| 4647 | - exit; |
|
| 4648 | - } else {
|
|
| 4649 | - if ( !$posts_count > 0 ) {
|
|
| 4650 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4651 | - } else {
|
|
| 4652 | - $total_posts = $posts_count; |
|
| 4653 | - if ($chunk_per_page > $total_posts) {
|
|
| 4654 | - $chunk_per_page = $total_posts; |
|
| 4655 | - } |
|
| 4656 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 4640 | + $json['percentage'] = $percentage; |
|
| 4641 | + // WPML |
|
| 4642 | + if ($is_wpml) {
|
|
| 4643 | + $sitepress->switch_lang($active_lang, true); |
|
| 4644 | + } |
|
| 4645 | + // WPML |
|
| 4646 | + wp_send_json( $json ); |
|
| 4647 | + exit; |
|
| 4648 | + } else {
|
|
| 4649 | + if ( !$posts_count > 0 ) {
|
|
| 4650 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4651 | + } else {
|
|
| 4652 | + $total_posts = $posts_count; |
|
| 4653 | + if ($chunk_per_page > $total_posts) {
|
|
| 4654 | + $chunk_per_page = $total_posts; |
|
| 4655 | + } |
|
| 4656 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 4657 | 4657 | |
| 4658 | - $j = $chunk_page_no; |
|
| 4659 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 4658 | + $j = $chunk_page_no; |
|
| 4659 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 4660 | 4660 | |
| 4661 | - $per_page = 500; |
|
| 4662 | - if ($per_page > $chunk_per_page) {
|
|
| 4663 | - $per_page = $chunk_per_page; |
|
| 4664 | - } |
|
| 4665 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4661 | + $per_page = 500; |
|
| 4662 | + if ($per_page > $chunk_per_page) {
|
|
| 4663 | + $per_page = $chunk_per_page; |
|
| 4664 | + } |
|
| 4665 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4666 | 4666 | |
| 4667 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4668 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 4667 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4668 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 4669 | 4669 | |
| 4670 | - $clear = $i == 0 ? true : false; |
|
| 4671 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 4672 | - } |
|
| 4670 | + $clear = $i == 0 ? true : false; |
|
| 4671 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 4672 | + } |
|
| 4673 | 4673 | |
| 4674 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4675 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4676 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4677 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4678 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4674 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4675 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4676 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4677 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4678 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4679 | 4679 | |
| 4680 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4681 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4682 | - } |
|
| 4680 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4681 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4682 | + } |
|
| 4683 | 4683 | |
| 4684 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4685 | - $json['total'] = $posts_count; |
|
| 4686 | - $json['files'] = $chunk_file_paths; |
|
| 4687 | - } else {
|
|
| 4688 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4689 | - } |
|
| 4690 | - } |
|
| 4691 | - // WPML |
|
| 4692 | - if ($is_wpml) {
|
|
| 4693 | - $sitepress->switch_lang($active_lang, true); |
|
| 4694 | - } |
|
| 4695 | - // WPML |
|
| 4696 | - wp_send_json( $json ); |
|
| 4697 | - } |
|
| 4698 | - } |
|
| 4699 | - break; |
|
| 4700 | - case 'export_cats': {
|
|
| 4701 | - // WPML |
|
| 4702 | - $is_wpml = geodir_is_wpml(); |
|
| 4703 | - if ($is_wpml) {
|
|
| 4704 | - global $sitepress; |
|
| 4705 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4684 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4685 | + $json['total'] = $posts_count; |
|
| 4686 | + $json['files'] = $chunk_file_paths; |
|
| 4687 | + } else {
|
|
| 4688 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4689 | + } |
|
| 4690 | + } |
|
| 4691 | + // WPML |
|
| 4692 | + if ($is_wpml) {
|
|
| 4693 | + $sitepress->switch_lang($active_lang, true); |
|
| 4694 | + } |
|
| 4695 | + // WPML |
|
| 4696 | + wp_send_json( $json ); |
|
| 4697 | + } |
|
| 4698 | + } |
|
| 4699 | + break; |
|
| 4700 | + case 'export_cats': {
|
|
| 4701 | + // WPML |
|
| 4702 | + $is_wpml = geodir_is_wpml(); |
|
| 4703 | + if ($is_wpml) {
|
|
| 4704 | + global $sitepress; |
|
| 4705 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4706 | 4706 | |
| 4707 | - $sitepress->switch_lang('all', true);
|
|
| 4708 | - } |
|
| 4709 | - // WPML |
|
| 4710 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 4707 | + $sitepress->switch_lang('all', true);
|
|
| 4708 | + } |
|
| 4709 | + // WPML |
|
| 4710 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 4711 | 4711 | |
| 4712 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 4713 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4714 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4715 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4716 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 4712 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
| 4713 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4714 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4715 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4716 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 4717 | 4717 | |
| 4718 | - $chunk_file_paths = array(); |
|
| 4718 | + $chunk_file_paths = array(); |
|
| 4719 | 4719 | |
| 4720 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4721 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4722 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 4723 | - $percentage = min( $percentage, 100 ); |
|
| 4720 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4721 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4722 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 4723 | + $percentage = min( $percentage, 100 ); |
|
| 4724 | 4724 | |
| 4725 | - $json['percentage'] = $percentage; |
|
| 4726 | - // WPML |
|
| 4727 | - if ($is_wpml) {
|
|
| 4728 | - $sitepress->switch_lang($active_lang, true); |
|
| 4729 | - } |
|
| 4730 | - // WPML |
|
| 4731 | - wp_send_json( $json ); |
|
| 4732 | - } else {
|
|
| 4733 | - if ( !$terms_count > 0 ) {
|
|
| 4734 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4735 | - } else {
|
|
| 4736 | - $total_terms = $terms_count; |
|
| 4737 | - if ($chunk_per_page > $terms_count) {
|
|
| 4738 | - $chunk_per_page = $terms_count; |
|
| 4739 | - } |
|
| 4740 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 4725 | + $json['percentage'] = $percentage; |
|
| 4726 | + // WPML |
|
| 4727 | + if ($is_wpml) {
|
|
| 4728 | + $sitepress->switch_lang($active_lang, true); |
|
| 4729 | + } |
|
| 4730 | + // WPML |
|
| 4731 | + wp_send_json( $json ); |
|
| 4732 | + } else {
|
|
| 4733 | + if ( !$terms_count > 0 ) {
|
|
| 4734 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4735 | + } else {
|
|
| 4736 | + $total_terms = $terms_count; |
|
| 4737 | + if ($chunk_per_page > $terms_count) {
|
|
| 4738 | + $chunk_per_page = $terms_count; |
|
| 4739 | + } |
|
| 4740 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 4741 | 4741 | |
| 4742 | - $j = $chunk_page_no; |
|
| 4743 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 4742 | + $j = $chunk_page_no; |
|
| 4743 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 4744 | 4744 | |
| 4745 | - $per_page = 500; |
|
| 4746 | - if ($per_page > $chunk_per_page) {
|
|
| 4747 | - $per_page = $chunk_per_page; |
|
| 4748 | - } |
|
| 4749 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4745 | + $per_page = 500; |
|
| 4746 | + if ($per_page > $chunk_per_page) {
|
|
| 4747 | + $per_page = $chunk_per_page; |
|
| 4748 | + } |
|
| 4749 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4750 | 4750 | |
| 4751 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4752 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 4751 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4752 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 4753 | 4753 | |
| 4754 | - $clear = $i == 0 ? true : false; |
|
| 4755 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 4756 | - } |
|
| 4754 | + $clear = $i == 0 ? true : false; |
|
| 4755 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 4756 | + } |
|
| 4757 | 4757 | |
| 4758 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4759 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4760 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4761 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4762 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4758 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4759 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4760 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4761 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4762 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4763 | 4763 | |
| 4764 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4765 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4766 | - } |
|
| 4764 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4765 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4766 | + } |
|
| 4767 | 4767 | |
| 4768 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4769 | - $json['total'] = $terms_count; |
|
| 4770 | - $json['files'] = $chunk_file_paths; |
|
| 4771 | - } else {
|
|
| 4772 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4773 | - } |
|
| 4774 | - } |
|
| 4775 | - // WPML |
|
| 4776 | - if ($is_wpml) {
|
|
| 4777 | - $sitepress->switch_lang($active_lang, true); |
|
| 4778 | - } |
|
| 4779 | - // WPML |
|
| 4780 | - wp_send_json( $json ); |
|
| 4781 | - } |
|
| 4782 | - } |
|
| 4783 | - break; |
|
| 4784 | - case 'export_locations': {
|
|
| 4785 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4786 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 4787 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4788 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4789 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 4768 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4769 | + $json['total'] = $terms_count; |
|
| 4770 | + $json['files'] = $chunk_file_paths; |
|
| 4771 | + } else {
|
|
| 4772 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4773 | + } |
|
| 4774 | + } |
|
| 4775 | + // WPML |
|
| 4776 | + if ($is_wpml) {
|
|
| 4777 | + $sitepress->switch_lang($active_lang, true); |
|
| 4778 | + } |
|
| 4779 | + // WPML |
|
| 4780 | + wp_send_json( $json ); |
|
| 4781 | + } |
|
| 4782 | + } |
|
| 4783 | + break; |
|
| 4784 | + case 'export_locations': {
|
|
| 4785 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4786 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 4787 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4788 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4789 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 4790 | 4790 | |
| 4791 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 4791 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
| 4792 | 4792 | |
| 4793 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4794 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4795 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 4796 | - $percentage = min( $percentage, 100 ); |
|
| 4793 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4794 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4795 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 4796 | + $percentage = min( $percentage, 100 ); |
|
| 4797 | 4797 | |
| 4798 | - $json['percentage'] = $percentage; |
|
| 4799 | - wp_send_json( $json ); |
|
| 4800 | - } else {
|
|
| 4801 | - $chunk_file_paths = array(); |
|
| 4798 | + $json['percentage'] = $percentage; |
|
| 4799 | + wp_send_json( $json ); |
|
| 4800 | + } else {
|
|
| 4801 | + $chunk_file_paths = array(); |
|
| 4802 | 4802 | |
| 4803 | - if ( !$items_count > 0 ) {
|
|
| 4804 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4805 | - } else {
|
|
| 4806 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 4807 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 4803 | + if ( !$items_count > 0 ) {
|
|
| 4804 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4805 | + } else {
|
|
| 4806 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 4807 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 4808 | 4808 | |
| 4809 | - $j = $chunk_page_no; |
|
| 4810 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 4809 | + $j = $chunk_page_no; |
|
| 4810 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 4811 | 4811 | |
| 4812 | - $per_page = 500; |
|
| 4813 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 4814 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4812 | + $per_page = 500; |
|
| 4813 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 4814 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4815 | 4815 | |
| 4816 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4817 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 4816 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4817 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 4818 | 4818 | |
| 4819 | - $clear = $i == 0 ? true : false; |
|
| 4820 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 4821 | - } |
|
| 4819 | + $clear = $i == 0 ? true : false; |
|
| 4820 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 4821 | + } |
|
| 4822 | 4822 | |
| 4823 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4824 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4825 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4826 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4827 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4823 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4824 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4825 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4826 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4827 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4828 | 4828 | |
| 4829 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4830 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4831 | - } |
|
| 4829 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4830 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4831 | + } |
|
| 4832 | 4832 | |
| 4833 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4834 | - $json['total'] = $items_count; |
|
| 4835 | - $json['files'] = $chunk_file_paths; |
|
| 4836 | - } else {
|
|
| 4837 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 4838 | - } |
|
| 4839 | - } |
|
| 4840 | - wp_send_json( $json ); |
|
| 4841 | - } |
|
| 4842 | - } |
|
| 4843 | - break; |
|
| 4844 | - case 'prepare_import': |
|
| 4845 | - case 'import_cat': |
|
| 4846 | - case 'import_post': |
|
| 4847 | - case 'import_loc': {
|
|
| 4848 | - // WPML |
|
| 4849 | - $is_wpml = geodir_is_wpml(); |
|
| 4850 | - if ($is_wpml) {
|
|
| 4851 | - global $sitepress; |
|
| 4852 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4853 | - } |
|
| 4854 | - // WPML |
|
| 4833 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4834 | + $json['total'] = $items_count; |
|
| 4835 | + $json['files'] = $chunk_file_paths; |
|
| 4836 | + } else {
|
|
| 4837 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 4838 | + } |
|
| 4839 | + } |
|
| 4840 | + wp_send_json( $json ); |
|
| 4841 | + } |
|
| 4842 | + } |
|
| 4843 | + break; |
|
| 4844 | + case 'prepare_import': |
|
| 4845 | + case 'import_cat': |
|
| 4846 | + case 'import_post': |
|
| 4847 | + case 'import_loc': {
|
|
| 4848 | + // WPML |
|
| 4849 | + $is_wpml = geodir_is_wpml(); |
|
| 4850 | + if ($is_wpml) {
|
|
| 4851 | + global $sitepress; |
|
| 4852 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4853 | + } |
|
| 4854 | + // WPML |
|
| 4855 | 4855 | |
| 4856 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 4856 | + ini_set( 'auto_detect_line_endings', true ); |
|
| 4857 | 4857 | |
| 4858 | - $uploads = wp_upload_dir(); |
|
| 4859 | - $uploads_dir = $uploads['path']; |
|
| 4860 | - $uploads_subdir = $uploads['subdir']; |
|
| 4858 | + $uploads = wp_upload_dir(); |
|
| 4859 | + $uploads_dir = $uploads['path']; |
|
| 4860 | + $uploads_subdir = $uploads['subdir']; |
|
| 4861 | 4861 | |
| 4862 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 4863 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 4862 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 4863 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 4864 | 4864 | |
| 4865 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 4866 | - $csv_filename = end( $csv_file_arr ); |
|
| 4867 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 4865 | + $csv_file_arr = explode( '/', $csv_file ); |
|
| 4866 | + $csv_filename = end( $csv_file_arr ); |
|
| 4867 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 4868 | 4868 | |
| 4869 | - $json['file'] = $csv_file; |
|
| 4870 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4869 | + $json['file'] = $csv_file; |
|
| 4870 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4871 | 4871 | |
| 4872 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4873 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4872 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4873 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4874 | 4874 | |
| 4875 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4876 | - $json['error'] = NULL; |
|
| 4877 | - $json['rows'] = 0; |
|
| 4875 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4876 | + $json['error'] = NULL; |
|
| 4877 | + $json['rows'] = 0; |
|
| 4878 | 4878 | |
| 4879 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4880 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4881 | - if ( !empty( $data ) ) {
|
|
| 4882 | - $file[] = $data; |
|
| 4883 | - } |
|
| 4884 | - } |
|
| 4885 | - fclose($handle); |
|
| 4886 | - } |
|
| 4879 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4880 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4881 | + if ( !empty( $data ) ) {
|
|
| 4882 | + $file[] = $data; |
|
| 4883 | + } |
|
| 4884 | + } |
|
| 4885 | + fclose($handle); |
|
| 4886 | + } |
|
| 4887 | 4887 | |
| 4888 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4888 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4889 | 4889 | |
| 4890 | - if (!$json['rows'] > 0) {
|
|
| 4891 | - $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4892 | - } |
|
| 4893 | - } else {
|
|
| 4894 | - wp_send_json( $json ); |
|
| 4895 | - } |
|
| 4896 | - } else {
|
|
| 4897 | - wp_send_json( $json ); |
|
| 4898 | - } |
|
| 4890 | + if (!$json['rows'] > 0) {
|
|
| 4891 | + $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4892 | + } |
|
| 4893 | + } else {
|
|
| 4894 | + wp_send_json( $json ); |
|
| 4895 | + } |
|
| 4896 | + } else {
|
|
| 4897 | + wp_send_json( $json ); |
|
| 4898 | + } |
|
| 4899 | 4899 | |
| 4900 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4901 | - wp_send_json( $json ); |
|
| 4902 | - } |
|
| 4900 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4901 | + wp_send_json( $json ); |
|
| 4902 | + } |
|
| 4903 | 4903 | |
| 4904 | - $total = $json['rows']; |
|
| 4905 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4906 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4904 | + $total = $json['rows']; |
|
| 4905 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4906 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4907 | 4907 | |
| 4908 | - $count = $limit; |
|
| 4909 | - $requested_limit = $limit; |
|
| 4908 | + $count = $limit; |
|
| 4909 | + $requested_limit = $limit; |
|
| 4910 | 4910 | |
| 4911 | - if ($count < $total) {
|
|
| 4912 | - $count = $processed + $count; |
|
| 4913 | - if ($count > $total) {
|
|
| 4914 | - $count = $total; |
|
| 4915 | - } |
|
| 4916 | - } else {
|
|
| 4917 | - $count = $total; |
|
| 4918 | - } |
|
| 4911 | + if ($count < $total) {
|
|
| 4912 | + $count = $processed + $count; |
|
| 4913 | + if ($count > $total) {
|
|
| 4914 | + $count = $total; |
|
| 4915 | + } |
|
| 4916 | + } else {
|
|
| 4917 | + $count = $total; |
|
| 4918 | + } |
|
| 4919 | 4919 | |
| 4920 | - $created = 0; |
|
| 4921 | - $updated = 0; |
|
| 4922 | - $skipped = 0; |
|
| 4923 | - $invalid = 0; |
|
| 4924 | - $invalid_addr = 0; |
|
| 4925 | - $images = 0; |
|
| 4920 | + $created = 0; |
|
| 4921 | + $updated = 0; |
|
| 4922 | + $skipped = 0; |
|
| 4923 | + $invalid = 0; |
|
| 4924 | + $invalid_addr = 0; |
|
| 4925 | + $images = 0; |
|
| 4926 | 4926 | |
| 4927 | - $invalid_title = 0; |
|
| 4928 | - $customKeyarray = array(); |
|
| 4929 | - $gd_post_info = array(); |
|
| 4930 | - $post_location = array(); |
|
| 4931 | - $countpost = 0; |
|
| 4927 | + $invalid_title = 0; |
|
| 4928 | + $customKeyarray = array(); |
|
| 4929 | + $gd_post_info = array(); |
|
| 4930 | + $post_location = array(); |
|
| 4931 | + $countpost = 0; |
|
| 4932 | 4932 | |
| 4933 | - $post_types = geodir_get_posttypes(); |
|
| 4933 | + $post_types = geodir_get_posttypes(); |
|
| 4934 | 4934 | |
| 4935 | - if ( $task == 'import_cat' ) {
|
|
| 4936 | - if (!empty($file)) {
|
|
| 4937 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4935 | + if ( $task == 'import_cat' ) {
|
|
| 4936 | + if (!empty($file)) {
|
|
| 4937 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4938 | 4938 | |
| 4939 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4940 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4941 | - wp_send_json( $json ); |
|
| 4942 | - exit; |
|
| 4943 | - } |
|
| 4939 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4940 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4941 | + wp_send_json( $json ); |
|
| 4942 | + exit; |
|
| 4943 | + } |
|
| 4944 | 4944 | |
| 4945 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4946 | - $index = $processed + $i; |
|
| 4945 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4946 | + $index = $processed + $i; |
|
| 4947 | 4947 | |
| 4948 | - if (isset($file[$index])) {
|
|
| 4949 | - $row = $file[$index]; |
|
| 4950 | - $row = array_map( 'trim', $row ); |
|
| 4951 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4948 | + if (isset($file[$index])) {
|
|
| 4949 | + $row = $file[$index]; |
|
| 4950 | + $row = array_map( 'trim', $row ); |
|
| 4951 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4952 | 4952 | |
| 4953 | - $cat_id = ''; |
|
| 4954 | - $cat_name = ''; |
|
| 4955 | - $cat_slug = ''; |
|
| 4956 | - $cat_posttype = ''; |
|
| 4957 | - $cat_parent = ''; |
|
| 4958 | - $cat_description = ''; |
|
| 4959 | - $cat_schema = ''; |
|
| 4960 | - $cat_top_description = ''; |
|
| 4961 | - $cat_image = ''; |
|
| 4962 | - $cat_icon = ''; |
|
| 4963 | - $cat_language = ''; |
|
| 4953 | + $cat_id = ''; |
|
| 4954 | + $cat_name = ''; |
|
| 4955 | + $cat_slug = ''; |
|
| 4956 | + $cat_posttype = ''; |
|
| 4957 | + $cat_parent = ''; |
|
| 4958 | + $cat_description = ''; |
|
| 4959 | + $cat_schema = ''; |
|
| 4960 | + $cat_top_description = ''; |
|
| 4961 | + $cat_image = ''; |
|
| 4962 | + $cat_icon = ''; |
|
| 4963 | + $cat_language = ''; |
|
| 4964 | 4964 | |
| 4965 | - $c = 0; |
|
| 4966 | - foreach ($columns as $column ) {
|
|
| 4967 | - if ( $column == 'cat_id' ) {
|
|
| 4968 | - $cat_id = (int)$row[$c]; |
|
| 4969 | - } else if ( $column == 'cat_name' ) {
|
|
| 4970 | - $cat_name = $row[$c]; |
|
| 4971 | - } else if ( $column == 'cat_slug' ) {
|
|
| 4972 | - $cat_slug = $row[$c]; |
|
| 4973 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 4974 | - $cat_posttype = $row[$c]; |
|
| 4975 | - } else if ( $column == 'cat_parent' ) {
|
|
| 4976 | - $cat_parent = trim($row[$c]); |
|
| 4977 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4978 | - $cat_schema = $row[$c]; |
|
| 4979 | - } else if ( $column == 'cat_description' ) {
|
|
| 4980 | - $cat_description = $row[$c]; |
|
| 4981 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 4982 | - $cat_top_description = $row[$c]; |
|
| 4983 | - } else if ( $column == 'cat_image' ) {
|
|
| 4984 | - $cat_image = $row[$c]; |
|
| 4985 | - } else if ( $column == 'cat_icon' ) {
|
|
| 4986 | - $cat_icon = $row[$c]; |
|
| 4987 | - } |
|
| 4988 | - // WPML |
|
| 4989 | - if ($is_wpml && $column == 'cat_language') {
|
|
| 4990 | - $cat_language = geodir_strtolower(trim($row[$c])); |
|
| 4991 | - } |
|
| 4992 | - // WPML |
|
| 4993 | - $c++; |
|
| 4994 | - } |
|
| 4965 | + $c = 0; |
|
| 4966 | + foreach ($columns as $column ) {
|
|
| 4967 | + if ( $column == 'cat_id' ) {
|
|
| 4968 | + $cat_id = (int)$row[$c]; |
|
| 4969 | + } else if ( $column == 'cat_name' ) {
|
|
| 4970 | + $cat_name = $row[$c]; |
|
| 4971 | + } else if ( $column == 'cat_slug' ) {
|
|
| 4972 | + $cat_slug = $row[$c]; |
|
| 4973 | + } else if ( $column == 'cat_posttype' ) {
|
|
| 4974 | + $cat_posttype = $row[$c]; |
|
| 4975 | + } else if ( $column == 'cat_parent' ) {
|
|
| 4976 | + $cat_parent = trim($row[$c]); |
|
| 4977 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4978 | + $cat_schema = $row[$c]; |
|
| 4979 | + } else if ( $column == 'cat_description' ) {
|
|
| 4980 | + $cat_description = $row[$c]; |
|
| 4981 | + } else if ( $column == 'cat_top_description' ) {
|
|
| 4982 | + $cat_top_description = $row[$c]; |
|
| 4983 | + } else if ( $column == 'cat_image' ) {
|
|
| 4984 | + $cat_image = $row[$c]; |
|
| 4985 | + } else if ( $column == 'cat_icon' ) {
|
|
| 4986 | + $cat_icon = $row[$c]; |
|
| 4987 | + } |
|
| 4988 | + // WPML |
|
| 4989 | + if ($is_wpml && $column == 'cat_language') {
|
|
| 4990 | + $cat_language = geodir_strtolower(trim($row[$c])); |
|
| 4991 | + } |
|
| 4992 | + // WPML |
|
| 4993 | + $c++; |
|
| 4994 | + } |
|
| 4995 | 4995 | |
| 4996 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4997 | - $invalid++; |
|
| 4998 | - continue; |
|
| 4999 | - } |
|
| 4996 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4997 | + $invalid++; |
|
| 4998 | + continue; |
|
| 4999 | + } |
|
| 5000 | 5000 | |
| 5001 | - // WPML |
|
| 5002 | - if ($is_wpml && $cat_language != '') {
|
|
| 5003 | - $sitepress->switch_lang($cat_language, true); |
|
| 5004 | - } |
|
| 5005 | - // WPML |
|
| 5001 | + // WPML |
|
| 5002 | + if ($is_wpml && $cat_language != '') {
|
|
| 5003 | + $sitepress->switch_lang($cat_language, true); |
|
| 5004 | + } |
|
| 5005 | + // WPML |
|
| 5006 | 5006 | |
| 5007 | - $term_data = array(); |
|
| 5008 | - $term_data['name'] = $cat_name; |
|
| 5009 | - $term_data['slug'] = $cat_slug; |
|
| 5010 | - $term_data['description'] = $cat_description; |
|
| 5011 | - $term_data['cat_schema'] = $cat_schema; |
|
| 5012 | - $term_data['top_description'] = $cat_top_description; |
|
| 5013 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 5014 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 5007 | + $term_data = array(); |
|
| 5008 | + $term_data['name'] = $cat_name; |
|
| 5009 | + $term_data['slug'] = $cat_slug; |
|
| 5010 | + $term_data['description'] = $cat_description; |
|
| 5011 | + $term_data['cat_schema'] = $cat_schema; |
|
| 5012 | + $term_data['top_description'] = $cat_top_description; |
|
| 5013 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 5014 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 5015 | 5015 | |
| 5016 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5016 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5017 | 5017 | |
| 5018 | - $taxonomy = $cat_posttype . 'category'; |
|
| 5018 | + $taxonomy = $cat_posttype . 'category'; |
|
| 5019 | 5019 | |
| 5020 | - $term_data['taxonomy'] = $taxonomy; |
|
| 5020 | + $term_data['taxonomy'] = $taxonomy; |
|
| 5021 | 5021 | |
| 5022 | - $term_parent_id = 0; |
|
| 5023 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 5024 | - $term_parent = ''; |
|
| 5022 | + $term_parent_id = 0; |
|
| 5023 | + if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 5024 | + $term_parent = ''; |
|
| 5025 | 5025 | |
| 5026 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 5027 | - $term_parent = $term_parent; |
|
| 5028 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 5029 | - $term_parent = $term_parent; |
|
| 5030 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 5031 | - $term_parent = $term_parent; |
|
| 5032 | - } else {
|
|
| 5033 | - $term_parent_data = array(); |
|
| 5034 | - $term_parent_data['name'] = $cat_parent; |
|
| 5035 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 5036 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
| 5026 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 5027 | + $term_parent = $term_parent; |
|
| 5028 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 5029 | + $term_parent = $term_parent; |
|
| 5030 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 5031 | + $term_parent = $term_parent; |
|
| 5032 | + } else {
|
|
| 5033 | + $term_parent_data = array(); |
|
| 5034 | + $term_parent_data['name'] = $cat_parent; |
|
| 5035 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 5036 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
| 5037 | 5037 | |
| 5038 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 5039 | - } |
|
| 5038 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 5039 | + } |
|
| 5040 | 5040 | |
| 5041 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 5042 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 5043 | - } |
|
| 5044 | - } |
|
| 5045 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 5041 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 5042 | + $term_parent_id = (int)$term_parent->term_id; |
|
| 5043 | + } |
|
| 5044 | + } |
|
| 5045 | + $term_data['parent'] = (int)$term_parent_id; |
|
| 5046 | 5046 | |
| 5047 | - $term_id = NULL; |
|
| 5048 | - if ( $import_choice == 'update' ) {
|
|
| 5049 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5050 | - $term_data['term_id'] = $term['term_id']; |
|
| 5047 | + $term_id = NULL; |
|
| 5048 | + if ( $import_choice == 'update' ) {
|
|
| 5049 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5050 | + $term_data['term_id'] = $term['term_id']; |
|
| 5051 | 5051 | |
| 5052 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5053 | - $updated++; |
|
| 5054 | - } else {
|
|
| 5055 | - $invalid++; |
|
| 5056 | - } |
|
| 5057 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5058 | - $term_data['term_id'] = $term['term_id']; |
|
| 5052 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5053 | + $updated++; |
|
| 5054 | + } else {
|
|
| 5055 | + $invalid++; |
|
| 5056 | + } |
|
| 5057 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5058 | + $term_data['term_id'] = $term['term_id']; |
|
| 5059 | 5059 | |
| 5060 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5061 | - $updated++; |
|
| 5062 | - } else {
|
|
| 5063 | - $invalid++; |
|
| 5064 | - } |
|
| 5065 | - } else {
|
|
| 5066 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5067 | - $created++; |
|
| 5068 | - } else {
|
|
| 5069 | - $invalid++; |
|
| 5070 | - } |
|
| 5071 | - } |
|
| 5072 | - } else if ( $import_choice == 'skip' ) {
|
|
| 5073 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5074 | - $skipped++; |
|
| 5075 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5076 | - $skipped++; |
|
| 5077 | - } else {
|
|
| 5078 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5079 | - $created++; |
|
| 5080 | - } else {
|
|
| 5081 | - $invalid++; |
|
| 5082 | - } |
|
| 5083 | - } |
|
| 5084 | - } else {
|
|
| 5085 | - $invalid++; |
|
| 5086 | - } |
|
| 5060 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5061 | + $updated++; |
|
| 5062 | + } else {
|
|
| 5063 | + $invalid++; |
|
| 5064 | + } |
|
| 5065 | + } else {
|
|
| 5066 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5067 | + $created++; |
|
| 5068 | + } else {
|
|
| 5069 | + $invalid++; |
|
| 5070 | + } |
|
| 5071 | + } |
|
| 5072 | + } else if ( $import_choice == 'skip' ) {
|
|
| 5073 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5074 | + $skipped++; |
|
| 5075 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5076 | + $skipped++; |
|
| 5077 | + } else {
|
|
| 5078 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5079 | + $created++; |
|
| 5080 | + } else {
|
|
| 5081 | + $invalid++; |
|
| 5082 | + } |
|
| 5083 | + } |
|
| 5084 | + } else {
|
|
| 5085 | + $invalid++; |
|
| 5086 | + } |
|
| 5087 | 5087 | |
| 5088 | - if ( $term_id ) {
|
|
| 5089 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 5090 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 5091 | - } |
|
| 5088 | + if ( $term_id ) {
|
|
| 5089 | + if ( isset( $term_data['top_description'] ) ) {
|
|
| 5090 | + update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 5091 | + } |
|
| 5092 | 5092 | |
| 5093 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 5094 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 5095 | - } |
|
| 5093 | + if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 5094 | + update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 5095 | + } |
|
| 5096 | 5096 | |
| 5097 | - $attachment = false; |
|
| 5098 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 5099 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 5100 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5097 | + $attachment = false; |
|
| 5098 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 5099 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 5100 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5101 | 5101 | |
| 5102 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 5103 | - $attachment = true; |
|
| 5104 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 5105 | - } |
|
| 5106 | - } |
|
| 5102 | + if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 5103 | + $attachment = true; |
|
| 5104 | + update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 5105 | + } |
|
| 5106 | + } |
|
| 5107 | 5107 | |
| 5108 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 5109 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 5110 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5108 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 5109 | + $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 5110 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5111 | 5111 | |
| 5112 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 5113 | - $attachment = true; |
|
| 5114 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 5115 | - } |
|
| 5116 | - } |
|
| 5112 | + if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 5113 | + $attachment = true; |
|
| 5114 | + update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 5115 | + } |
|
| 5116 | + } |
|
| 5117 | 5117 | |
| 5118 | - if ( $attachment ) {
|
|
| 5119 | - $images++; |
|
| 5120 | - } |
|
| 5121 | - } |
|
| 5118 | + if ( $attachment ) {
|
|
| 5119 | + $images++; |
|
| 5120 | + } |
|
| 5121 | + } |
|
| 5122 | 5122 | |
| 5123 | - // WPML |
|
| 5124 | - if ($is_wpml && $cat_language != '') {
|
|
| 5125 | - $sitepress->switch_lang($active_lang, true); |
|
| 5126 | - } |
|
| 5127 | - // WPML |
|
| 5128 | - } |
|
| 5129 | - } |
|
| 5130 | - } |
|
| 5123 | + // WPML |
|
| 5124 | + if ($is_wpml && $cat_language != '') {
|
|
| 5125 | + $sitepress->switch_lang($active_lang, true); |
|
| 5126 | + } |
|
| 5127 | + // WPML |
|
| 5128 | + } |
|
| 5129 | + } |
|
| 5130 | + } |
|
| 5131 | 5131 | |
| 5132 | - $json = array(); |
|
| 5133 | - $json['processed'] = $limit; |
|
| 5134 | - $json['created'] = $created; |
|
| 5135 | - $json['updated'] = $updated; |
|
| 5136 | - $json['skipped'] = $skipped; |
|
| 5137 | - $json['invalid'] = $invalid; |
|
| 5138 | - $json['images'] = $images; |
|
| 5132 | + $json = array(); |
|
| 5133 | + $json['processed'] = $limit; |
|
| 5134 | + $json['created'] = $created; |
|
| 5135 | + $json['updated'] = $updated; |
|
| 5136 | + $json['skipped'] = $skipped; |
|
| 5137 | + $json['invalid'] = $invalid; |
|
| 5138 | + $json['images'] = $images; |
|
| 5139 | 5139 | |
| 5140 | - wp_send_json( $json ); |
|
| 5141 | - exit; |
|
| 5142 | - } else if ( $task == 'import_post' ) {
|
|
| 5140 | + wp_send_json( $json ); |
|
| 5141 | + exit; |
|
| 5142 | + } else if ( $task == 'import_post' ) {
|
|
| 5143 | 5143 | |
| 5144 | 5144 | //run some stuff to make the import quicker |
| 5145 | 5145 | wp_defer_term_counting( true ); |
@@ -5151,503 +5151,503 @@ discard block |
||
| 5151 | 5151 | //remove_all_actions('publish_future_post');
|
| 5152 | 5152 | |
| 5153 | 5153 | |
| 5154 | - if (!empty($file)) {
|
|
| 5155 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 5156 | - $default_status = 'publish'; |
|
| 5157 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 5154 | + if (!empty($file)) {
|
|
| 5155 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 5156 | + $default_status = 'publish'; |
|
| 5157 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 5158 | 5158 | |
| 5159 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5159 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5160 | 5160 | |
| 5161 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5162 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 5163 | - wp_send_json( $json ); |
|
| 5164 | - exit; |
|
| 5165 | - } |
|
| 5161 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5162 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 5163 | + wp_send_json( $json ); |
|
| 5164 | + exit; |
|
| 5165 | + } |
|
| 5166 | 5166 | |
| 5167 | 5167 | $processed_actual=0; |
| 5168 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 5169 | - $index = $processed + $i; |
|
| 5170 | - $gd_post = array(); |
|
| 5168 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 5169 | + $index = $processed + $i; |
|
| 5170 | + $gd_post = array(); |
|
| 5171 | 5171 | |
| 5172 | - if (isset($file[$index])) {$processed_actual++;
|
|
| 5173 | - $row = $file[$index]; |
|
| 5174 | - $row = array_map( 'trim', $row ); |
|
| 5175 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 5176 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 5172 | + if (isset($file[$index])) {$processed_actual++;
|
|
| 5173 | + $row = $file[$index]; |
|
| 5174 | + $row = array_map( 'trim', $row ); |
|
| 5175 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 5176 | + $row = array_map( 'addslashes_gpc', $row ); |
|
| 5177 | 5177 | |
| 5178 | - $post_id = ''; |
|
| 5179 | - $post_title = ''; |
|
| 5180 | - $post_author = ''; |
|
| 5181 | - $post_content = ''; |
|
| 5182 | - $post_category_arr = array(); |
|
| 5183 | - $default_category = ''; |
|
| 5184 | - $post_tags = array(); |
|
| 5185 | - $post_type = ''; |
|
| 5186 | - $post_status = ''; |
|
| 5187 | - $geodir_video = ''; |
|
| 5188 | - $post_address = ''; |
|
| 5189 | - $post_city = ''; |
|
| 5190 | - $post_region = ''; |
|
| 5191 | - $post_country = ''; |
|
| 5192 | - $post_zip = ''; |
|
| 5193 | - $post_latitude = ''; |
|
| 5194 | - $post_longitude = ''; |
|
| 5195 | - $geodir_timing = ''; |
|
| 5196 | - $geodir_contact = ''; |
|
| 5197 | - $geodir_email = ''; |
|
| 5198 | - $geodir_website = ''; |
|
| 5199 | - $geodir_twitter = ''; |
|
| 5200 | - $geodir_facebook = ''; |
|
| 5201 | - $geodir_twitter = ''; |
|
| 5202 | - $post_images = array(); |
|
| 5178 | + $post_id = ''; |
|
| 5179 | + $post_title = ''; |
|
| 5180 | + $post_author = ''; |
|
| 5181 | + $post_content = ''; |
|
| 5182 | + $post_category_arr = array(); |
|
| 5183 | + $default_category = ''; |
|
| 5184 | + $post_tags = array(); |
|
| 5185 | + $post_type = ''; |
|
| 5186 | + $post_status = ''; |
|
| 5187 | + $geodir_video = ''; |
|
| 5188 | + $post_address = ''; |
|
| 5189 | + $post_city = ''; |
|
| 5190 | + $post_region = ''; |
|
| 5191 | + $post_country = ''; |
|
| 5192 | + $post_zip = ''; |
|
| 5193 | + $post_latitude = ''; |
|
| 5194 | + $post_longitude = ''; |
|
| 5195 | + $geodir_timing = ''; |
|
| 5196 | + $geodir_contact = ''; |
|
| 5197 | + $geodir_email = ''; |
|
| 5198 | + $geodir_website = ''; |
|
| 5199 | + $geodir_twitter = ''; |
|
| 5200 | + $geodir_facebook = ''; |
|
| 5201 | + $geodir_twitter = ''; |
|
| 5202 | + $post_images = array(); |
|
| 5203 | 5203 | |
| 5204 | - $expire_date = 'Never'; |
|
| 5204 | + $expire_date = 'Never'; |
|
| 5205 | 5205 | |
| 5206 | - $language = ''; |
|
| 5207 | - $original_post_id = ''; |
|
| 5206 | + $language = ''; |
|
| 5207 | + $original_post_id = ''; |
|
| 5208 | 5208 | |
| 5209 | - $c = 0; |
|
| 5210 | - foreach ($columns as $column ) {
|
|
| 5211 | - $gd_post[$column] = $row[$c]; |
|
| 5209 | + $c = 0; |
|
| 5210 | + foreach ($columns as $column ) {
|
|
| 5211 | + $gd_post[$column] = $row[$c]; |
|
| 5212 | 5212 | |
| 5213 | - if ( $column == 'post_id' ) {
|
|
| 5214 | - $post_id = $row[$c]; |
|
| 5215 | - } else if ( $column == 'post_title' ) {
|
|
| 5216 | - $post_title = $row[$c]; |
|
| 5217 | - } else if ( $column == 'post_author' ) {
|
|
| 5218 | - $post_author = $row[$c]; |
|
| 5219 | - } else if ( $column == 'post_content' ) {
|
|
| 5220 | - $post_content = $row[$c]; |
|
| 5221 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 5222 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 5223 | - } else if ( $column == 'default_category' ) {
|
|
| 5224 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 5225 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 5226 | - $post_tags = explode( ',', $row[$c] ); |
|
| 5227 | - } else if ( $column == 'post_type' ) {
|
|
| 5228 | - $post_type = $row[$c]; |
|
| 5229 | - } else if ( $column == 'post_status' ) {
|
|
| 5230 | - $post_status = sanitize_key( $row[$c] ); |
|
| 5231 | - } else if ( $column == 'is_featured' ) {
|
|
| 5232 | - $is_featured = (int)$row[$c]; |
|
| 5233 | - } else if ( $column == 'geodir_video' ) {
|
|
| 5234 | - $geodir_video = $row[$c]; |
|
| 5235 | - } else if ( $column == 'post_address' ) {
|
|
| 5236 | - $post_address = $row[$c]; |
|
| 5237 | - } else if ( $column == 'post_city' ) {
|
|
| 5238 | - $post_city = $row[$c]; |
|
| 5239 | - } else if ( $column == 'post_region' ) {
|
|
| 5240 | - $post_region = $row[$c]; |
|
| 5241 | - } else if ( $column == 'post_country' ) {
|
|
| 5242 | - $post_country = $row[$c]; |
|
| 5243 | - } else if ( $column == 'post_zip' ) {
|
|
| 5244 | - $post_zip = $row[$c]; |
|
| 5245 | - } else if ( $column == 'post_latitude' ) {
|
|
| 5246 | - $post_latitude = $row[$c]; |
|
| 5247 | - } else if ( $column == 'post_longitude' ) {
|
|
| 5248 | - $post_longitude = $row[$c]; |
|
| 5249 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 5250 | - $geodir_timing = $row[$c]; |
|
| 5251 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 5252 | - $geodir_contact = $row[$c]; |
|
| 5253 | - } else if ( $column == 'geodir_email' ) {
|
|
| 5254 | - $geodir_email = $row[$c]; |
|
| 5255 | - } else if ( $column == 'geodir_website' ) {
|
|
| 5256 | - $geodir_website = $row[$c]; |
|
| 5257 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 5258 | - $geodir_twitter = $row[$c]; |
|
| 5259 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 5260 | - $geodir_facebook = $row[$c]; |
|
| 5261 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 5262 | - $geodir_twitter = $row[$c]; |
|
| 5263 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 5264 | - $post_images[] = $row[$c]; |
|
| 5265 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 5266 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 5267 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 5268 | - $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 5269 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 5270 | - } |
|
| 5271 | - // WPML |
|
| 5272 | - if ($is_wpml) {
|
|
| 5273 | - if ($column == 'language') {
|
|
| 5274 | - $language = geodir_strtolower(trim($row[$c])); |
|
| 5275 | - } else if ($column == 'original_post_id') {
|
|
| 5276 | - $original_post_id = (int)$row[$c]; |
|
| 5277 | - } |
|
| 5278 | - } |
|
| 5279 | - // WPML |
|
| 5280 | - $c++; |
|
| 5281 | - } |
|
| 5213 | + if ( $column == 'post_id' ) {
|
|
| 5214 | + $post_id = $row[$c]; |
|
| 5215 | + } else if ( $column == 'post_title' ) {
|
|
| 5216 | + $post_title = $row[$c]; |
|
| 5217 | + } else if ( $column == 'post_author' ) {
|
|
| 5218 | + $post_author = $row[$c]; |
|
| 5219 | + } else if ( $column == 'post_content' ) {
|
|
| 5220 | + $post_content = $row[$c]; |
|
| 5221 | + } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 5222 | + $post_category_arr = explode( ',', $row[$c] ); |
|
| 5223 | + } else if ( $column == 'default_category' ) {
|
|
| 5224 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 5225 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 5226 | + $post_tags = explode( ',', $row[$c] ); |
|
| 5227 | + } else if ( $column == 'post_type' ) {
|
|
| 5228 | + $post_type = $row[$c]; |
|
| 5229 | + } else if ( $column == 'post_status' ) {
|
|
| 5230 | + $post_status = sanitize_key( $row[$c] ); |
|
| 5231 | + } else if ( $column == 'is_featured' ) {
|
|
| 5232 | + $is_featured = (int)$row[$c]; |
|
| 5233 | + } else if ( $column == 'geodir_video' ) {
|
|
| 5234 | + $geodir_video = $row[$c]; |
|
| 5235 | + } else if ( $column == 'post_address' ) {
|
|
| 5236 | + $post_address = $row[$c]; |
|
| 5237 | + } else if ( $column == 'post_city' ) {
|
|
| 5238 | + $post_city = $row[$c]; |
|
| 5239 | + } else if ( $column == 'post_region' ) {
|
|
| 5240 | + $post_region = $row[$c]; |
|
| 5241 | + } else if ( $column == 'post_country' ) {
|
|
| 5242 | + $post_country = $row[$c]; |
|
| 5243 | + } else if ( $column == 'post_zip' ) {
|
|
| 5244 | + $post_zip = $row[$c]; |
|
| 5245 | + } else if ( $column == 'post_latitude' ) {
|
|
| 5246 | + $post_latitude = $row[$c]; |
|
| 5247 | + } else if ( $column == 'post_longitude' ) {
|
|
| 5248 | + $post_longitude = $row[$c]; |
|
| 5249 | + } else if ( $column == 'geodir_timing' ) {
|
|
| 5250 | + $geodir_timing = $row[$c]; |
|
| 5251 | + } else if ( $column == 'geodir_contact' ) {
|
|
| 5252 | + $geodir_contact = $row[$c]; |
|
| 5253 | + } else if ( $column == 'geodir_email' ) {
|
|
| 5254 | + $geodir_email = $row[$c]; |
|
| 5255 | + } else if ( $column == 'geodir_website' ) {
|
|
| 5256 | + $geodir_website = $row[$c]; |
|
| 5257 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 5258 | + $geodir_twitter = $row[$c]; |
|
| 5259 | + } else if ( $column == 'geodir_facebook' ) {
|
|
| 5260 | + $geodir_facebook = $row[$c]; |
|
| 5261 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 5262 | + $geodir_twitter = $row[$c]; |
|
| 5263 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 5264 | + $post_images[] = $row[$c]; |
|
| 5265 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 5266 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 5267 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 5268 | + $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 5269 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 5270 | + } |
|
| 5271 | + // WPML |
|
| 5272 | + if ($is_wpml) {
|
|
| 5273 | + if ($column == 'language') {
|
|
| 5274 | + $language = geodir_strtolower(trim($row[$c])); |
|
| 5275 | + } else if ($column == 'original_post_id') {
|
|
| 5276 | + $original_post_id = (int)$row[$c]; |
|
| 5277 | + } |
|
| 5278 | + } |
|
| 5279 | + // WPML |
|
| 5280 | + $c++; |
|
| 5281 | + } |
|
| 5282 | 5282 | |
| 5283 | - // WPML |
|
| 5284 | - if ($is_wpml && $language != '') {
|
|
| 5285 | - $sitepress->switch_lang($language, true); |
|
| 5286 | - } |
|
| 5287 | - // WPML |
|
| 5283 | + // WPML |
|
| 5284 | + if ($is_wpml && $language != '') {
|
|
| 5285 | + $sitepress->switch_lang($language, true); |
|
| 5286 | + } |
|
| 5287 | + // WPML |
|
| 5288 | 5288 | |
| 5289 | - $gd_post['IMAGE'] = $post_images; |
|
| 5289 | + $gd_post['IMAGE'] = $post_images; |
|
| 5290 | 5290 | |
| 5291 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 5292 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 5291 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 5292 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 5293 | 5293 | |
| 5294 | - $valid = true; |
|
| 5294 | + $valid = true; |
|
| 5295 | 5295 | |
| 5296 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 5297 | - $invalid++; |
|
| 5298 | - $valid = false; |
|
| 5299 | - } |
|
| 5296 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 5297 | + $invalid++; |
|
| 5298 | + $valid = false; |
|
| 5299 | + } |
|
| 5300 | 5300 | |
| 5301 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5302 | - if ( $location_allowed ) {
|
|
| 5303 | - $location_result = geodir_get_default_location(); |
|
| 5304 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 5305 | - $invalid_addr++; |
|
| 5306 | - $valid = false; |
|
| 5307 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 5308 | - if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
|
|
| 5309 | - $invalid_addr++; |
|
| 5310 | - $valid = false; |
|
| 5311 | - } else {
|
|
| 5312 | - if (!function_exists('geodir_location_plugin_activated')) {
|
|
| 5313 | - $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated. |
|
| 5314 | - } |
|
| 5315 | - } |
|
| 5316 | - } |
|
| 5317 | - } |
|
| 5301 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5302 | + if ( $location_allowed ) {
|
|
| 5303 | + $location_result = geodir_get_default_location(); |
|
| 5304 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 5305 | + $invalid_addr++; |
|
| 5306 | + $valid = false; |
|
| 5307 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 5308 | + if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
|
|
| 5309 | + $invalid_addr++; |
|
| 5310 | + $valid = false; |
|
| 5311 | + } else {
|
|
| 5312 | + if (!function_exists('geodir_location_plugin_activated')) {
|
|
| 5313 | + $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated. |
|
| 5314 | + } |
|
| 5315 | + } |
|
| 5316 | + } |
|
| 5317 | + } |
|
| 5318 | 5318 | |
| 5319 | - if ( !$valid ) {
|
|
| 5320 | - continue; |
|
| 5321 | - } |
|
| 5319 | + if ( !$valid ) {
|
|
| 5320 | + continue; |
|
| 5321 | + } |
|
| 5322 | 5322 | |
| 5323 | - $cat_taxonomy = $post_type . 'category'; |
|
| 5324 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 5323 | + $cat_taxonomy = $post_type . 'category'; |
|
| 5324 | + $tags_taxonomy = $post_type . '_tags'; |
|
| 5325 | 5325 | |
| 5326 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 5327 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 5328 | - } |
|
| 5326 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 5327 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 5328 | + } |
|
| 5329 | 5329 | |
| 5330 | - $post_category = array(); |
|
| 5331 | - $default_category_id = NULL; |
|
| 5332 | - if ( !empty( $post_category_arr ) ) {
|
|
| 5333 | - foreach ( $post_category_arr as $value ) {
|
|
| 5334 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 5330 | + $post_category = array(); |
|
| 5331 | + $default_category_id = NULL; |
|
| 5332 | + if ( !empty( $post_category_arr ) ) {
|
|
| 5333 | + foreach ( $post_category_arr as $value ) {
|
|
| 5334 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 5335 | 5335 | |
| 5336 | - if ( $category_name != '' ) {
|
|
| 5337 | - $term_category = array(); |
|
| 5336 | + if ( $category_name != '' ) {
|
|
| 5337 | + $term_category = array(); |
|
| 5338 | 5338 | |
| 5339 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 5340 | - $term_category = $term; |
|
| 5341 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 5342 | - $term_category = $term; |
|
| 5343 | - } else {
|
|
| 5344 | - $term_data = array(); |
|
| 5345 | - $term_data['name'] = $category_name; |
|
| 5346 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5347 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
| 5339 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 5340 | + $term_category = $term; |
|
| 5341 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 5342 | + $term_category = $term; |
|
| 5343 | + } else {
|
|
| 5344 | + $term_data = array(); |
|
| 5345 | + $term_data['name'] = $category_name; |
|
| 5346 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5347 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
| 5348 | 5348 | |
| 5349 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 5350 | - if ( $term_id ) {
|
|
| 5351 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 5352 | - } |
|
| 5353 | - } |
|
| 5349 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 5350 | + if ( $term_id ) {
|
|
| 5351 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 5352 | + } |
|
| 5353 | + } |
|
| 5354 | 5354 | |
| 5355 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 5356 | - //$post_category[] = $term_category->slug; |
|
| 5357 | - $post_category[] = intval($term_category->term_id); |
|
| 5355 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 5356 | + //$post_category[] = $term_category->slug; |
|
| 5357 | + $post_category[] = intval($term_category->term_id); |
|
| 5358 | 5358 | |
| 5359 | - if ($category_name == $default_category) {
|
|
| 5360 | - $default_category_id = intval($term_category->term_id); |
|
| 5361 | - } |
|
| 5362 | - } |
|
| 5363 | - } |
|
| 5364 | - } |
|
| 5365 | - } |
|
| 5359 | + if ($category_name == $default_category) {
|
|
| 5360 | + $default_category_id = intval($term_category->term_id); |
|
| 5361 | + } |
|
| 5362 | + } |
|
| 5363 | + } |
|
| 5364 | + } |
|
| 5365 | + } |
|
| 5366 | 5366 | |
| 5367 | - $save_post = array(); |
|
| 5368 | - $save_post['post_title'] = $post_title; |
|
| 5369 | - $save_post['post_content'] = $post_content; |
|
| 5370 | - $save_post['post_type'] = $post_type; |
|
| 5371 | - $save_post['post_author'] = $post_author; |
|
| 5372 | - $save_post['post_status'] = $post_status; |
|
| 5373 | - $save_post['post_category'] = $post_category; |
|
| 5374 | - $save_post['post_tags'] = $post_tags; |
|
| 5375 | - |
|
| 5376 | - $saved_post_id = NULL; |
|
| 5377 | - if ( $import_choice == 'update' ) {
|
|
| 5378 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5379 | - $save_post['ID'] = $post_id; |
|
| 5367 | + $save_post = array(); |
|
| 5368 | + $save_post['post_title'] = $post_title; |
|
| 5369 | + $save_post['post_content'] = $post_content; |
|
| 5370 | + $save_post['post_type'] = $post_type; |
|
| 5371 | + $save_post['post_author'] = $post_author; |
|
| 5372 | + $save_post['post_status'] = $post_status; |
|
| 5373 | + $save_post['post_category'] = $post_category; |
|
| 5374 | + $save_post['post_tags'] = $post_tags; |
|
| 5375 | + |
|
| 5376 | + $saved_post_id = NULL; |
|
| 5377 | + if ( $import_choice == 'update' ) {
|
|
| 5378 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5379 | + $save_post['ID'] = $post_id; |
|
| 5380 | 5380 | |
| 5381 | - if ( wp_update_post( $save_post ) ) {
|
|
| 5382 | - $saved_post_id = $post_id; |
|
| 5383 | - $updated++; |
|
| 5384 | - } |
|
| 5385 | - } else {
|
|
| 5386 | - if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5387 | - $created++; |
|
| 5388 | - } |
|
| 5389 | - } |
|
| 5381 | + if ( wp_update_post( $save_post ) ) {
|
|
| 5382 | + $saved_post_id = $post_id; |
|
| 5383 | + $updated++; |
|
| 5384 | + } |
|
| 5385 | + } else {
|
|
| 5386 | + if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5387 | + $created++; |
|
| 5388 | + } |
|
| 5389 | + } |
|
| 5390 | 5390 | |
| 5391 | - if ( !$saved_post_id > 0 ) {
|
|
| 5392 | - $invalid++; |
|
| 5393 | - } |
|
| 5394 | - } else if ( $import_choice == 'skip' ) {
|
|
| 5395 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5396 | - $skipped++; |
|
| 5397 | - } else {
|
|
| 5398 | - if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5399 | - $created++; |
|
| 5400 | - } else {
|
|
| 5401 | - $invalid++; |
|
| 5402 | - } |
|
| 5403 | - } |
|
| 5404 | - } else {
|
|
| 5405 | - $invalid++; |
|
| 5406 | - } |
|
| 5391 | + if ( !$saved_post_id > 0 ) {
|
|
| 5392 | + $invalid++; |
|
| 5393 | + } |
|
| 5394 | + } else if ( $import_choice == 'skip' ) {
|
|
| 5395 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5396 | + $skipped++; |
|
| 5397 | + } else {
|
|
| 5398 | + if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5399 | + $created++; |
|
| 5400 | + } else {
|
|
| 5401 | + $invalid++; |
|
| 5402 | + } |
|
| 5403 | + } |
|
| 5404 | + } else {
|
|
| 5405 | + $invalid++; |
|
| 5406 | + } |
|
| 5407 | 5407 | |
| 5408 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 5409 | - // WPML |
|
| 5410 | - if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 5411 | - $wpml_post_type = 'post_' . $post_type; |
|
| 5412 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 5413 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 5408 | + if ( (int)$saved_post_id > 0 ) {
|
|
| 5409 | + // WPML |
|
| 5410 | + if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 5411 | + $wpml_post_type = 'post_' . $post_type; |
|
| 5412 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 5413 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 5414 | 5414 | |
| 5415 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 5415 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 5416 | 5416 | |
| 5417 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 5418 | - } |
|
| 5419 | - // WPML |
|
| 5420 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 5417 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 5418 | + } |
|
| 5419 | + // WPML |
|
| 5420 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 5421 | 5421 | |
| 5422 | - $gd_post['post_id'] = $saved_post_id; |
|
| 5423 | - $gd_post['ID'] = $saved_post_id; |
|
| 5424 | - $gd_post['post_tags'] = $post_tags; |
|
| 5425 | - $gd_post['post_title'] = $post_title; |
|
| 5426 | - $gd_post['post_status'] = $post_status; |
|
| 5427 | - $gd_post['submit_time'] = time(); |
|
| 5428 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 5422 | + $gd_post['post_id'] = $saved_post_id; |
|
| 5423 | + $gd_post['ID'] = $saved_post_id; |
|
| 5424 | + $gd_post['post_tags'] = $post_tags; |
|
| 5425 | + $gd_post['post_title'] = $post_title; |
|
| 5426 | + $gd_post['post_status'] = $post_status; |
|
| 5427 | + $gd_post['submit_time'] = time(); |
|
| 5428 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 5429 | 5429 | |
| 5430 | - // post location |
|
| 5431 | - $post_location_id = 0; |
|
| 5432 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 5433 | - $post_location_info = array( |
|
| 5434 | - 'city' => $post_city, |
|
| 5435 | - 'region' => $post_region, |
|
| 5436 | - 'country' => $post_country, |
|
| 5437 | - 'geo_lat' => $post_latitude, |
|
| 5438 | - 'geo_lng' => $post_longitude |
|
| 5439 | - ); |
|
| 5440 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 5441 | - $post_location_id = $location_id; |
|
| 5442 | - } |
|
| 5443 | - } |
|
| 5444 | - $gd_post['post_location_id'] = $post_location_id; |
|
| 5430 | + // post location |
|
| 5431 | + $post_location_id = 0; |
|
| 5432 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 5433 | + $post_location_info = array( |
|
| 5434 | + 'city' => $post_city, |
|
| 5435 | + 'region' => $post_region, |
|
| 5436 | + 'country' => $post_country, |
|
| 5437 | + 'geo_lat' => $post_latitude, |
|
| 5438 | + 'geo_lng' => $post_longitude |
|
| 5439 | + ); |
|
| 5440 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 5441 | + $post_location_id = $location_id; |
|
| 5442 | + } |
|
| 5443 | + } |
|
| 5444 | + $gd_post['post_location_id'] = $post_location_id; |
|
| 5445 | 5445 | |
| 5446 | - // post package info |
|
| 5447 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 5448 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 5449 | - $package_id = $gd_post_info->package_id; |
|
| 5450 | - } |
|
| 5446 | + // post package info |
|
| 5447 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 5448 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 5449 | + $package_id = $gd_post_info->package_id; |
|
| 5450 | + } |
|
| 5451 | 5451 | |
| 5452 | - $package_info = array(); |
|
| 5453 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 5454 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 5452 | + $package_info = array(); |
|
| 5453 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 5454 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 5455 | 5455 | |
| 5456 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 5457 | - $package_info = array(); |
|
| 5458 | - } |
|
| 5459 | - } |
|
| 5456 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 5457 | + $package_info = array(); |
|
| 5458 | + } |
|
| 5459 | + } |
|
| 5460 | 5460 | |
| 5461 | - if (empty($package_info)) {
|
|
| 5462 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 5463 | - } |
|
| 5461 | + if (empty($package_info)) {
|
|
| 5462 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 5463 | + } |
|
| 5464 | 5464 | |
| 5465 | - if (!empty($package_info)) {
|
|
| 5466 | - $package_id = $package_info['pid']; |
|
| 5465 | + if (!empty($package_info)) {
|
|
| 5466 | + $package_id = $package_info['pid']; |
|
| 5467 | 5467 | |
| 5468 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 5469 | - $gd_post['expire_date'] = $expire_date; |
|
| 5470 | - } else {
|
|
| 5471 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 5472 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 5473 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 5474 | - } else {
|
|
| 5475 | - $gd_post['expire_date'] = 'Never'; |
|
| 5476 | - } |
|
| 5477 | - } |
|
| 5468 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 5469 | + $gd_post['expire_date'] = $expire_date; |
|
| 5470 | + } else {
|
|
| 5471 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 5472 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 5473 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 5474 | + } else {
|
|
| 5475 | + $gd_post['expire_date'] = 'Never'; |
|
| 5476 | + } |
|
| 5477 | + } |
|
| 5478 | 5478 | |
| 5479 | - $gd_post['package_id'] = $package_id; |
|
| 5480 | - } |
|
| 5479 | + $gd_post['package_id'] = $package_id; |
|
| 5480 | + } |
|
| 5481 | 5481 | |
| 5482 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5482 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5483 | 5483 | |
| 5484 | - if ($post_type == 'gd_event') {
|
|
| 5485 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 5486 | - } |
|
| 5484 | + if ($post_type == 'gd_event') {
|
|
| 5485 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 5486 | + } |
|
| 5487 | 5487 | |
| 5488 | - if (isset($gd_post['post_id'])) {
|
|
| 5489 | - unset($gd_post['post_id']); |
|
| 5490 | - } |
|
| 5491 | - |
|
| 5492 | - // Export franchise fields |
|
| 5493 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5494 | - if ($is_franchise_active) {
|
|
| 5495 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 5496 | - $gd_franchise_lock = array(); |
|
| 5488 | + if (isset($gd_post['post_id'])) {
|
|
| 5489 | + unset($gd_post['post_id']); |
|
| 5490 | + } |
|
| 5491 | + |
|
| 5492 | + // Export franchise fields |
|
| 5493 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5494 | + if ($is_franchise_active) {
|
|
| 5495 | + if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 5496 | + $gd_franchise_lock = array(); |
|
| 5497 | 5497 | |
| 5498 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 5499 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 5500 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 5501 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 5502 | - } |
|
| 5498 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 5499 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 5500 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 5501 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 5502 | + } |
|
| 5503 | 5503 | |
| 5504 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 5505 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 5506 | - } else {
|
|
| 5507 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 5508 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 5509 | - } |
|
| 5510 | - } |
|
| 5511 | - } |
|
| 5504 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 5505 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 5506 | + } else {
|
|
| 5507 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 5508 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 5509 | + } |
|
| 5510 | + } |
|
| 5511 | + } |
|
| 5512 | 5512 | |
| 5513 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 5514 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 5515 | - if ($default_category_id) {
|
|
| 5516 | - $save_post['post_default_category'] = $default_category_id; |
|
| 5517 | - $gd_post['default_category'] = $default_category_id; |
|
| 5518 | - } |
|
| 5519 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 5520 | - } |
|
| 5513 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 5514 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 5515 | + if ($default_category_id) {
|
|
| 5516 | + $save_post['post_default_category'] = $default_category_id; |
|
| 5517 | + $gd_post['default_category'] = $default_category_id; |
|
| 5518 | + } |
|
| 5519 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 5520 | + } |
|
| 5521 | 5521 | |
| 5522 | - // Save post info |
|
| 5523 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 5524 | - // post taxonomies |
|
| 5525 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 5526 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 5522 | + // Save post info |
|
| 5523 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 5524 | + // post taxonomies |
|
| 5525 | + if ( !empty( $save_post['post_category'] ) ) {
|
|
| 5526 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 5527 | 5527 | |
| 5528 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 5529 | - if ($default_category_id) {
|
|
| 5530 | - $post_default_category = $default_category_id; |
|
| 5531 | - } |
|
| 5532 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 5533 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 5534 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 5528 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 5529 | + if ($default_category_id) {
|
|
| 5530 | + $post_default_category = $default_category_id; |
|
| 5531 | + } |
|
| 5532 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 5533 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 5534 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 5535 | 5535 | |
| 5536 | - if ($post_category_str != '' && $post_default_category) {
|
|
| 5537 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 5538 | - } |
|
| 5536 | + if ($post_category_str != '' && $post_default_category) {
|
|
| 5537 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 5538 | + } |
|
| 5539 | 5539 | |
| 5540 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 5540 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 5541 | 5541 | |
| 5542 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 5543 | - } |
|
| 5542 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 5543 | + } |
|
| 5544 | 5544 | |
| 5545 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 5546 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 5547 | - } |
|
| 5545 | + if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 5546 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 5547 | + } |
|
| 5548 | 5548 | |
| 5549 | - // Post images |
|
| 5550 | - if ( !empty( $post_images ) ) {
|
|
| 5551 | - $post_images = array_unique($post_images); |
|
| 5549 | + // Post images |
|
| 5550 | + if ( !empty( $post_images ) ) {
|
|
| 5551 | + $post_images = array_unique($post_images); |
|
| 5552 | 5552 | |
| 5553 | - $old_post_images_arr = array(); |
|
| 5554 | - $saved_post_images_arr = array(); |
|
| 5553 | + $old_post_images_arr = array(); |
|
| 5554 | + $saved_post_images_arr = array(); |
|
| 5555 | 5555 | |
| 5556 | - $order = 1; |
|
| 5556 | + $order = 1; |
|
| 5557 | 5557 | |
| 5558 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 5559 | - if (!empty($old_post_images)) {
|
|
| 5560 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 5561 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 5562 | - $old_post_images_arr[] = $old_post_image->file; |
|
| 5563 | - } |
|
| 5564 | - } |
|
| 5565 | - } |
|
| 5558 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 5559 | + if (!empty($old_post_images)) {
|
|
| 5560 | + foreach( $old_post_images as $old_post_image ) {
|
|
| 5561 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 5562 | + $old_post_images_arr[] = $old_post_image->file; |
|
| 5563 | + } |
|
| 5564 | + } |
|
| 5565 | + } |
|
| 5566 | 5566 | |
| 5567 | - foreach ( $post_images as $post_image ) {
|
|
| 5568 | - $image_name = basename( $post_image ); |
|
| 5569 | - $saved_post_images_arr[] = $image_name; |
|
| 5567 | + foreach ( $post_images as $post_image ) {
|
|
| 5568 | + $image_name = basename( $post_image ); |
|
| 5569 | + $saved_post_images_arr[] = $image_name; |
|
| 5570 | 5570 | |
| 5571 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 5572 | - continue; // Skip if image already exists. |
|
| 5573 | - } |
|
| 5571 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 5572 | + continue; // Skip if image already exists. |
|
| 5573 | + } |
|
| 5574 | 5574 | |
| 5575 | - $image_name_parts = explode( '.', $image_name ); |
|
| 5576 | - array_pop( $image_name_parts ); |
|
| 5577 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 5575 | + $image_name_parts = explode( '.', $image_name ); |
|
| 5576 | + array_pop( $image_name_parts ); |
|
| 5577 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
| 5578 | 5578 | |
| 5579 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 5579 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
| 5580 | 5580 | |
| 5581 | - if ( !empty( $arr_file_type ) ) {
|
|
| 5582 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 5581 | + if ( !empty( $arr_file_type ) ) {
|
|
| 5582 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 5583 | 5583 | |
| 5584 | - $attachment = array(); |
|
| 5585 | - $attachment['post_id'] = $saved_post_id; |
|
| 5586 | - $attachment['title'] = $proper_image_name; |
|
| 5587 | - $attachment['content'] = ''; |
|
| 5588 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 5589 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 5590 | - $attachment['menu_order'] = $order; |
|
| 5591 | - $attachment['is_featured'] = 0; |
|
| 5592 | - |
|
| 5593 | - $attachment_set = ''; |
|
| 5594 | - foreach ( $attachment as $key => $val ) {
|
|
| 5595 | - if ( $val != '' ) {
|
|
| 5596 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 5597 | - } |
|
| 5598 | - } |
|
| 5599 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 5584 | + $attachment = array(); |
|
| 5585 | + $attachment['post_id'] = $saved_post_id; |
|
| 5586 | + $attachment['title'] = $proper_image_name; |
|
| 5587 | + $attachment['content'] = ''; |
|
| 5588 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 5589 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 5590 | + $attachment['menu_order'] = $order; |
|
| 5591 | + $attachment['is_featured'] = 0; |
|
| 5592 | + |
|
| 5593 | + $attachment_set = ''; |
|
| 5594 | + foreach ( $attachment as $key => $val ) {
|
|
| 5595 | + if ( $val != '' ) {
|
|
| 5596 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 5597 | + } |
|
| 5598 | + } |
|
| 5599 | + $attachment_set = trim( $attachment_set, ", " ); |
|
| 5600 | 5600 | |
| 5601 | - // Add new attachment |
|
| 5602 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 5601 | + // Add new attachment |
|
| 5602 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 5603 | 5603 | |
| 5604 | - $order++; |
|
| 5605 | - } |
|
| 5606 | - } |
|
| 5604 | + $order++; |
|
| 5605 | + } |
|
| 5606 | + } |
|
| 5607 | 5607 | |
| 5608 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 5609 | - // Remove previous attachment |
|
| 5610 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 5608 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 5609 | + // Remove previous attachment |
|
| 5610 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 5611 | 5611 | |
| 5612 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 5613 | - $menu_order = 1; |
|
| 5612 | + if ( !empty( $saved_post_images_arr ) ) {
|
|
| 5613 | + $menu_order = 1; |
|
| 5614 | 5614 | |
| 5615 | - foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 5616 | - $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) ); |
|
| 5615 | + foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 5616 | + $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) ); |
|
| 5617 | 5617 | |
| 5618 | - if( $menu_order == 1 ) {
|
|
| 5619 | - if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
|
|
| 5620 | - $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 5621 | - } |
|
| 5622 | - } |
|
| 5623 | - $menu_order++; |
|
| 5624 | - } |
|
| 5625 | - } |
|
| 5618 | + if( $menu_order == 1 ) {
|
|
| 5619 | + if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
|
|
| 5620 | + $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 5621 | + } |
|
| 5622 | + } |
|
| 5623 | + $menu_order++; |
|
| 5624 | + } |
|
| 5625 | + } |
|
| 5626 | 5626 | |
| 5627 | - if ( $order > 1 ) {
|
|
| 5628 | - $images++; |
|
| 5629 | - } |
|
| 5630 | - } |
|
| 5627 | + if ( $order > 1 ) {
|
|
| 5628 | + $images++; |
|
| 5629 | + } |
|
| 5630 | + } |
|
| 5631 | 5631 | |
| 5632 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 5633 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 5632 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 5633 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 5634 | 5634 | |
| 5635 | - if (isset($is_featured)) {
|
|
| 5636 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 5637 | - } |
|
| 5638 | - if (isset($gd_post['expire_date'])) {
|
|
| 5639 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 5640 | - } |
|
| 5641 | - } |
|
| 5635 | + if (isset($is_featured)) {
|
|
| 5636 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 5637 | + } |
|
| 5638 | + if (isset($gd_post['expire_date'])) {
|
|
| 5639 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 5640 | + } |
|
| 5641 | + } |
|
| 5642 | 5642 | |
| 5643 | - // WPML |
|
| 5644 | - if ($is_wpml && $language != '') {
|
|
| 5645 | - $sitepress->switch_lang($active_lang, true); |
|
| 5646 | - } |
|
| 5647 | - // WPML |
|
| 5648 | - } |
|
| 5649 | - } |
|
| 5650 | - } |
|
| 5643 | + // WPML |
|
| 5644 | + if ($is_wpml && $language != '') {
|
|
| 5645 | + $sitepress->switch_lang($active_lang, true); |
|
| 5646 | + } |
|
| 5647 | + // WPML |
|
| 5648 | + } |
|
| 5649 | + } |
|
| 5650 | + } |
|
| 5651 | 5651 | |
| 5652 | 5652 | //undo some stuff to make the import quicker |
| 5653 | 5653 | wp_defer_term_counting( false ); |
@@ -5655,111 +5655,111 @@ discard block |
||
| 5655 | 5655 | $wpdb->query( 'COMMIT;' ); |
| 5656 | 5656 | $wpdb->query( 'SET autocommit = 1;' ); |
| 5657 | 5657 | |
| 5658 | - $json = array(); |
|
| 5659 | - $json['processed'] = $processed_actual; |
|
| 5660 | - $json['created'] = $created; |
|
| 5661 | - $json['updated'] = $updated; |
|
| 5662 | - $json['skipped'] = $skipped; |
|
| 5663 | - $json['invalid'] = $invalid; |
|
| 5664 | - $json['invalid_addr'] = $invalid_addr; |
|
| 5665 | - $json['images'] = $images; |
|
| 5658 | + $json = array(); |
|
| 5659 | + $json['processed'] = $processed_actual; |
|
| 5660 | + $json['created'] = $created; |
|
| 5661 | + $json['updated'] = $updated; |
|
| 5662 | + $json['skipped'] = $skipped; |
|
| 5663 | + $json['invalid'] = $invalid; |
|
| 5664 | + $json['invalid_addr'] = $invalid_addr; |
|
| 5665 | + $json['images'] = $images; |
|
| 5666 | 5666 | |
| 5667 | - wp_send_json( $json ); |
|
| 5668 | - exit; |
|
| 5669 | - } else if ( $task == 'import_loc' ) {
|
|
| 5670 | - global $gd_post_types; |
|
| 5671 | - $gd_post_types = $post_types; |
|
| 5667 | + wp_send_json( $json ); |
|
| 5668 | + exit; |
|
| 5669 | + } else if ( $task == 'import_loc' ) {
|
|
| 5670 | + global $gd_post_types; |
|
| 5671 | + $gd_post_types = $post_types; |
|
| 5672 | 5672 | |
| 5673 | - if (!empty($file)) {
|
|
| 5674 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5673 | + if (!empty($file)) {
|
|
| 5674 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5675 | 5675 | |
| 5676 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5677 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 5678 | - wp_send_json( $json ); |
|
| 5679 | - } |
|
| 5676 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5677 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 5678 | + wp_send_json( $json ); |
|
| 5679 | + } |
|
| 5680 | 5680 | |
| 5681 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 5682 | - $index = $processed + $i; |
|
| 5681 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 5682 | + $index = $processed + $i; |
|
| 5683 | 5683 | |
| 5684 | - if (isset($file[$index])) {
|
|
| 5685 | - $row = $file[$index]; |
|
| 5686 | - $row = array_map( 'trim', $row ); |
|
| 5687 | - $data = array(); |
|
| 5684 | + if (isset($file[$index])) {
|
|
| 5685 | + $row = $file[$index]; |
|
| 5686 | + $row = array_map( 'trim', $row ); |
|
| 5687 | + $data = array(); |
|
| 5688 | 5688 | |
| 5689 | - foreach ($columns as $c => $column ) {
|
|
| 5690 | - if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
|
|
| 5691 | - $data[$column] = $row[$c]; |
|
| 5692 | - } |
|
| 5693 | - } |
|
| 5689 | + foreach ($columns as $c => $column ) {
|
|
| 5690 | + if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
|
|
| 5691 | + $data[$column] = $row[$c]; |
|
| 5692 | + } |
|
| 5693 | + } |
|
| 5694 | 5694 | |
| 5695 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 5696 | - $invalid++; |
|
| 5697 | - continue; |
|
| 5698 | - } |
|
| 5695 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 5696 | + $invalid++; |
|
| 5697 | + continue; |
|
| 5698 | + } |
|
| 5699 | 5699 | |
| 5700 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 5700 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 5701 | 5701 | |
| 5702 | - if ( $import_choice == 'update' ) {
|
|
| 5703 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5704 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5705 | - $updated++; |
|
| 5706 | - } else {
|
|
| 5707 | - $invalid++; |
|
| 5708 | - } |
|
| 5709 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5710 | - $data['location_id'] = (int)$location->location_id; |
|
| 5702 | + if ( $import_choice == 'update' ) {
|
|
| 5703 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5704 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5705 | + $updated++; |
|
| 5706 | + } else {
|
|
| 5707 | + $invalid++; |
|
| 5708 | + } |
|
| 5709 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5710 | + $data['location_id'] = (int)$location->location_id; |
|
| 5711 | 5711 | |
| 5712 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 5713 | - $data['location_id'] = (int)$location->location_id; |
|
| 5714 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 5715 | - $data['location_id'] = (int)$location->location_id; |
|
| 5716 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 5717 | - $data['location_id'] = (int)$location->location_id; |
|
| 5718 | - } |
|
| 5712 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 5713 | + $data['location_id'] = (int)$location->location_id; |
|
| 5714 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 5715 | + $data['location_id'] = (int)$location->location_id; |
|
| 5716 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 5717 | + $data['location_id'] = (int)$location->location_id; |
|
| 5718 | + } |
|
| 5719 | 5719 | |
| 5720 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5721 | - $updated++; |
|
| 5722 | - } else {
|
|
| 5723 | - $invalid++; |
|
| 5724 | - } |
|
| 5725 | - } else {
|
|
| 5726 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5727 | - $created++; |
|
| 5728 | - } else {
|
|
| 5729 | - $invalid++; |
|
| 5730 | - } |
|
| 5731 | - } |
|
| 5732 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 5733 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5734 | - $skipped++; |
|
| 5735 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5736 | - $skipped++; |
|
| 5737 | - } else {
|
|
| 5738 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5739 | - $created++; |
|
| 5740 | - } else {
|
|
| 5741 | - $invalid++; |
|
| 5742 | - } |
|
| 5743 | - } |
|
| 5744 | - } else {
|
|
| 5745 | - $invalid++; |
|
| 5746 | - } |
|
| 5747 | - } |
|
| 5748 | - } |
|
| 5749 | - } |
|
| 5720 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5721 | + $updated++; |
|
| 5722 | + } else {
|
|
| 5723 | + $invalid++; |
|
| 5724 | + } |
|
| 5725 | + } else {
|
|
| 5726 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5727 | + $created++; |
|
| 5728 | + } else {
|
|
| 5729 | + $invalid++; |
|
| 5730 | + } |
|
| 5731 | + } |
|
| 5732 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 5733 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5734 | + $skipped++; |
|
| 5735 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5736 | + $skipped++; |
|
| 5737 | + } else {
|
|
| 5738 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5739 | + $created++; |
|
| 5740 | + } else {
|
|
| 5741 | + $invalid++; |
|
| 5742 | + } |
|
| 5743 | + } |
|
| 5744 | + } else {
|
|
| 5745 | + $invalid++; |
|
| 5746 | + } |
|
| 5747 | + } |
|
| 5748 | + } |
|
| 5749 | + } |
|
| 5750 | 5750 | |
| 5751 | - $json = array(); |
|
| 5752 | - $json['processed'] = $limit; |
|
| 5753 | - $json['created'] = $created; |
|
| 5754 | - $json['updated'] = $updated; |
|
| 5755 | - $json['skipped'] = $skipped; |
|
| 5756 | - $json['invalid'] = $invalid; |
|
| 5757 | - $json['images'] = $images; |
|
| 5751 | + $json = array(); |
|
| 5752 | + $json['processed'] = $limit; |
|
| 5753 | + $json['created'] = $created; |
|
| 5754 | + $json['updated'] = $updated; |
|
| 5755 | + $json['skipped'] = $skipped; |
|
| 5756 | + $json['invalid'] = $invalid; |
|
| 5757 | + $json['images'] = $images; |
|
| 5758 | 5758 | |
| 5759 | - wp_send_json( $json ); |
|
| 5760 | - } |
|
| 5761 | - } |
|
| 5762 | - break; |
|
| 5759 | + wp_send_json( $json ); |
|
| 5760 | + } |
|
| 5761 | + } |
|
| 5762 | + break; |
|
| 5763 | 5763 | case 'import_finish':{
|
| 5764 | 5764 | /** |
| 5765 | 5765 | * Run an action when an import finishes. |
@@ -5773,9 +5773,9 @@ discard block |
||
| 5773 | 5773 | } |
| 5774 | 5774 | break; |
| 5775 | 5775 | |
| 5776 | - } |
|
| 5777 | - echo '0'; |
|
| 5778 | - wp_die(); |
|
| 5776 | + } |
|
| 5777 | + echo '0'; |
|
| 5778 | + wp_die(); |
|
| 5779 | 5779 | } |
| 5780 | 5780 | |
| 5781 | 5781 | /** |
@@ -5801,32 +5801,32 @@ discard block |
||
| 5801 | 5801 | * @return int|bool Term id when success, false when fail. |
| 5802 | 5802 | */ |
| 5803 | 5803 | function geodir_imex_insert_term( $taxonomy, $term_data ) {
|
| 5804 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5805 | - return false; |
|
| 5806 | - } |
|
| 5804 | + if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5805 | + return false; |
|
| 5806 | + } |
|
| 5807 | 5807 | |
| 5808 | - $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5809 | - $args = array(); |
|
| 5810 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5811 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5812 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5808 | + $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5809 | + $args = array(); |
|
| 5810 | + $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5811 | + $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5812 | + $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5813 | 5813 | |
| 5814 | - if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
|
|
| 5815 | - $term_args = array_merge( $term_data, $args ); |
|
| 5816 | - $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 5817 | - $term_args = wp_parse_args( $term_args, $defaults ); |
|
| 5818 | - $term_args = sanitize_term( $term_args, $taxonomy, 'db' ); |
|
| 5819 | - $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
|
| 5820 | - } |
|
| 5814 | + if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
|
|
| 5815 | + $term_args = array_merge( $term_data, $args ); |
|
| 5816 | + $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 5817 | + $term_args = wp_parse_args( $term_args, $defaults ); |
|
| 5818 | + $term_args = sanitize_term( $term_args, $taxonomy, 'db' ); |
|
| 5819 | + $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
|
| 5820 | + } |
|
| 5821 | 5821 | |
| 5822 | 5822 | if( !empty( $term ) ) {
|
| 5823 | - $result = wp_insert_term( $term, $taxonomy, $args ); |
|
| 5823 | + $result = wp_insert_term( $term, $taxonomy, $args ); |
|
| 5824 | 5824 | if( !is_wp_error( $result ) ) {
|
| 5825 | 5825 | return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
| 5826 | 5826 | } |
| 5827 | 5827 | } |
| 5828 | 5828 | |
| 5829 | - return false; |
|
| 5829 | + return false; |
|
| 5830 | 5830 | } |
| 5831 | 5831 | |
| 5832 | 5832 | /** |
@@ -5853,39 +5853,39 @@ discard block |
||
| 5853 | 5853 | * @return int|bool Term id when success, false when fail. |
| 5854 | 5854 | */ |
| 5855 | 5855 | function geodir_imex_update_term( $taxonomy, $term_data ) {
|
| 5856 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5857 | - return false; |
|
| 5858 | - } |
|
| 5856 | + if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5857 | + return false; |
|
| 5858 | + } |
|
| 5859 | 5859 | |
| 5860 | - $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5861 | - $term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0; |
|
| 5860 | + $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5861 | + $term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0; |
|
| 5862 | 5862 | |
| 5863 | - $args = array(); |
|
| 5864 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5865 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5866 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5863 | + $args = array(); |
|
| 5864 | + $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5865 | + $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5866 | + $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5867 | 5867 | |
| 5868 | - if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
|
|
| 5869 | - $term_data['term_id'] = $term_info['term_id']; |
|
| 5868 | + if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
|
|
| 5869 | + $term_data['term_id'] = $term_info['term_id']; |
|
| 5870 | 5870 | |
| 5871 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5871 | + $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5872 | 5872 | |
| 5873 | - if( !is_wp_error( $result ) ) {
|
|
| 5873 | + if( !is_wp_error( $result ) ) {
|
|
| 5874 | 5874 | return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
| 5875 | 5875 | } |
| 5876 | - } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5877 | - $term_data['term_id'] = $term_info['term_id']; |
|
| 5876 | + } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5877 | + $term_data['term_id'] = $term_info['term_id']; |
|
| 5878 | 5878 | |
| 5879 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5879 | + $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5880 | 5880 | |
| 5881 | - if( !is_wp_error( $result ) ) {
|
|
| 5881 | + if( !is_wp_error( $result ) ) {
|
|
| 5882 | 5882 | return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
| 5883 | 5883 | } |
| 5884 | - } else {
|
|
| 5885 | - return geodir_imex_insert_term( $taxonomy, $term_data ); |
|
| 5886 | - } |
|
| 5884 | + } else {
|
|
| 5885 | + return geodir_imex_insert_term( $taxonomy, $term_data ); |
|
| 5886 | + } |
|
| 5887 | 5887 | |
| 5888 | - return false; |
|
| 5888 | + return false; |
|
| 5889 | 5889 | } |
| 5890 | 5890 | |
| 5891 | 5891 | /** |
@@ -5898,21 +5898,21 @@ discard block |
||
| 5898 | 5898 | * @return int Posts count. |
| 5899 | 5899 | */ |
| 5900 | 5900 | function geodir_get_posts_count( $post_type ) {
|
| 5901 | - $posts_count = wp_count_posts( $post_type ); |
|
| 5902 | - $posts_count = array_sum( (array)$posts_count ); |
|
| 5901 | + $posts_count = wp_count_posts( $post_type ); |
|
| 5902 | + $posts_count = array_sum( (array)$posts_count ); |
|
| 5903 | 5903 | |
| 5904 | - /** |
|
| 5905 | - * Modify returned post counts for the current post type. |
|
| 5906 | - * |
|
| 5907 | - * @since 1.4.6 |
|
| 5904 | + /** |
|
| 5905 | + * Modify returned post counts for the current post type. |
|
| 5906 | + * |
|
| 5907 | + * @since 1.4.6 |
|
| 5908 | 5908 | * @package GeoDirectory |
| 5909 | - * |
|
| 5910 | - * @param int $posts_count Post counts. |
|
| 5911 | - * @param string $post_type Post type. |
|
| 5912 | - */ |
|
| 5913 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5909 | + * |
|
| 5910 | + * @param int $posts_count Post counts. |
|
| 5911 | + * @param string $post_type Post type. |
|
| 5912 | + */ |
|
| 5913 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5914 | 5914 | |
| 5915 | - return $posts_count; |
|
| 5915 | + return $posts_count; |
|
| 5916 | 5916 | } |
| 5917 | 5917 | |
| 5918 | 5918 | /** |
@@ -5929,18 +5929,18 @@ discard block |
||
| 5929 | 5929 | * @return int Posts count. |
| 5930 | 5930 | */ |
| 5931 | 5931 | function geodir_imex_count_events( $posts_count, $post_type ) {
|
| 5932 | - if ( $post_type == 'gd_event' ) {
|
|
| 5933 | - global $wpdb, $plugin_prefix; |
|
| 5932 | + if ( $post_type == 'gd_event' ) {
|
|
| 5933 | + global $wpdb, $plugin_prefix; |
|
| 5934 | 5934 | |
| 5935 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5936 | - $schedule_table = EVENT_SCHEDULE; |
|
| 5935 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5936 | + $schedule_table = EVENT_SCHEDULE; |
|
| 5937 | 5937 | |
| 5938 | - $query = "SELECT COUNT({$wpdb->posts}.ID) AS total FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s";
|
|
| 5938 | + $query = "SELECT COUNT({$wpdb->posts}.ID) AS total FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s";
|
|
| 5939 | 5939 | |
| 5940 | - $posts_count = (int)$wpdb->get_var( $wpdb->prepare( $query, $post_type ) ); |
|
| 5941 | - } |
|
| 5940 | + $posts_count = (int)$wpdb->get_var( $wpdb->prepare( $query, $post_type ) ); |
|
| 5941 | + } |
|
| 5942 | 5942 | |
| 5943 | - return $posts_count; |
|
| 5943 | + return $posts_count; |
|
| 5944 | 5944 | } |
| 5945 | 5945 | |
| 5946 | 5946 | /** |
@@ -5960,290 +5960,290 @@ discard block |
||
| 5960 | 5960 | * @return array Array of posts data. |
| 5961 | 5961 | */ |
| 5962 | 5962 | function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 5963 | - global $wp_filesystem; |
|
| 5963 | + global $wp_filesystem; |
|
| 5964 | 5964 | |
| 5965 | - $posts = geodir_get_export_posts( $post_type, $per_page, $page_no ); |
|
| 5965 | + $posts = geodir_get_export_posts( $post_type, $per_page, $page_no ); |
|
| 5966 | 5966 | |
| 5967 | - $csv_rows = array(); |
|
| 5967 | + $csv_rows = array(); |
|
| 5968 | 5968 | |
| 5969 | - if ( !empty( $posts ) ) {
|
|
| 5970 | - $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
|
| 5969 | + if ( !empty( $posts ) ) {
|
|
| 5970 | + $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
|
| 5971 | 5971 | |
| 5972 | - $csv_row = array(); |
|
| 5973 | - $csv_row[] = 'post_id'; |
|
| 5974 | - $csv_row[] = 'post_title'; |
|
| 5975 | - $csv_row[] = 'post_author'; |
|
| 5976 | - $csv_row[] = 'post_content'; |
|
| 5977 | - $csv_row[] = 'post_category'; |
|
| 5978 | - $csv_row[] = 'default_category'; |
|
| 5979 | - $csv_row[] = 'post_tags'; |
|
| 5980 | - $csv_row[] = 'post_type'; |
|
| 5981 | - if ( $post_type == 'gd_event' ) {
|
|
| 5982 | - $csv_row[] = 'event_date'; |
|
| 5983 | - $csv_row[] = 'event_enddate'; |
|
| 5984 | - $csv_row[] = 'starttime'; |
|
| 5985 | - $csv_row[] = 'endtime'; |
|
| 5972 | + $csv_row = array(); |
|
| 5973 | + $csv_row[] = 'post_id'; |
|
| 5974 | + $csv_row[] = 'post_title'; |
|
| 5975 | + $csv_row[] = 'post_author'; |
|
| 5976 | + $csv_row[] = 'post_content'; |
|
| 5977 | + $csv_row[] = 'post_category'; |
|
| 5978 | + $csv_row[] = 'default_category'; |
|
| 5979 | + $csv_row[] = 'post_tags'; |
|
| 5980 | + $csv_row[] = 'post_type'; |
|
| 5981 | + if ( $post_type == 'gd_event' ) {
|
|
| 5982 | + $csv_row[] = 'event_date'; |
|
| 5983 | + $csv_row[] = 'event_enddate'; |
|
| 5984 | + $csv_row[] = 'starttime'; |
|
| 5985 | + $csv_row[] = 'endtime'; |
|
| 5986 | 5986 | |
| 5987 | - $csv_row[] = 'is_recurring_event'; |
|
| 5988 | - $csv_row[] = 'event_duration_days'; |
|
| 5989 | - $csv_row[] = 'recurring_dates'; |
|
| 5990 | - $csv_row[] = 'is_whole_day_event'; |
|
| 5991 | - $csv_row[] = 'event_starttimes'; |
|
| 5992 | - $csv_row[] = 'event_endtimes'; |
|
| 5993 | - $csv_row[] = 'recurring_type'; |
|
| 5994 | - $csv_row[] = 'recurring_interval'; |
|
| 5995 | - $csv_row[] = 'recurring_week_days'; |
|
| 5996 | - $csv_row[] = 'recurring_week_nos'; |
|
| 5997 | - $csv_row[] = 'max_recurring_count'; |
|
| 5998 | - $csv_row[] = 'recurring_end_date'; |
|
| 5999 | - } |
|
| 6000 | - $csv_row[] = 'post_status'; |
|
| 6001 | - $csv_row[] = 'is_featured'; |
|
| 6002 | - if ($is_payment_plugin) {
|
|
| 6003 | - $csv_row[] = 'package_id'; |
|
| 6004 | - $csv_row[] = 'expire_date'; |
|
| 6005 | - } |
|
| 6006 | - $csv_row[] = 'geodir_video'; |
|
| 6007 | - $csv_row[] = 'post_address'; |
|
| 6008 | - $csv_row[] = 'post_city'; |
|
| 6009 | - $csv_row[] = 'post_region'; |
|
| 6010 | - $csv_row[] = 'post_country'; |
|
| 6011 | - $csv_row[] = 'post_zip'; |
|
| 6012 | - $csv_row[] = 'post_latitude'; |
|
| 6013 | - $csv_row[] = 'post_longitude'; |
|
| 6014 | - $csv_row[] = 'geodir_timing'; |
|
| 6015 | - $csv_row[] = 'geodir_contact'; |
|
| 6016 | - $csv_row[] = 'geodir_email'; |
|
| 6017 | - $csv_row[] = 'geodir_website'; |
|
| 6018 | - $csv_row[] = 'geodir_twitter'; |
|
| 6019 | - $csv_row[] = 'geodir_facebook'; |
|
| 6020 | - $csv_row[] = 'geodir_video'; |
|
| 6021 | - $csv_row[] = 'geodir_special_offers'; |
|
| 6022 | - // WPML |
|
| 6023 | - $is_wpml = geodir_is_wpml(); |
|
| 6024 | - if ($is_wpml) {
|
|
| 6025 | - $csv_row[] = 'language'; |
|
| 6026 | - $csv_row[] = 'original_post_id'; |
|
| 6027 | - } |
|
| 6028 | - // WPML |
|
| 5987 | + $csv_row[] = 'is_recurring_event'; |
|
| 5988 | + $csv_row[] = 'event_duration_days'; |
|
| 5989 | + $csv_row[] = 'recurring_dates'; |
|
| 5990 | + $csv_row[] = 'is_whole_day_event'; |
|
| 5991 | + $csv_row[] = 'event_starttimes'; |
|
| 5992 | + $csv_row[] = 'event_endtimes'; |
|
| 5993 | + $csv_row[] = 'recurring_type'; |
|
| 5994 | + $csv_row[] = 'recurring_interval'; |
|
| 5995 | + $csv_row[] = 'recurring_week_days'; |
|
| 5996 | + $csv_row[] = 'recurring_week_nos'; |
|
| 5997 | + $csv_row[] = 'max_recurring_count'; |
|
| 5998 | + $csv_row[] = 'recurring_end_date'; |
|
| 5999 | + } |
|
| 6000 | + $csv_row[] = 'post_status'; |
|
| 6001 | + $csv_row[] = 'is_featured'; |
|
| 6002 | + if ($is_payment_plugin) {
|
|
| 6003 | + $csv_row[] = 'package_id'; |
|
| 6004 | + $csv_row[] = 'expire_date'; |
|
| 6005 | + } |
|
| 6006 | + $csv_row[] = 'geodir_video'; |
|
| 6007 | + $csv_row[] = 'post_address'; |
|
| 6008 | + $csv_row[] = 'post_city'; |
|
| 6009 | + $csv_row[] = 'post_region'; |
|
| 6010 | + $csv_row[] = 'post_country'; |
|
| 6011 | + $csv_row[] = 'post_zip'; |
|
| 6012 | + $csv_row[] = 'post_latitude'; |
|
| 6013 | + $csv_row[] = 'post_longitude'; |
|
| 6014 | + $csv_row[] = 'geodir_timing'; |
|
| 6015 | + $csv_row[] = 'geodir_contact'; |
|
| 6016 | + $csv_row[] = 'geodir_email'; |
|
| 6017 | + $csv_row[] = 'geodir_website'; |
|
| 6018 | + $csv_row[] = 'geodir_twitter'; |
|
| 6019 | + $csv_row[] = 'geodir_facebook'; |
|
| 6020 | + $csv_row[] = 'geodir_video'; |
|
| 6021 | + $csv_row[] = 'geodir_special_offers'; |
|
| 6022 | + // WPML |
|
| 6023 | + $is_wpml = geodir_is_wpml(); |
|
| 6024 | + if ($is_wpml) {
|
|
| 6025 | + $csv_row[] = 'language'; |
|
| 6026 | + $csv_row[] = 'original_post_id'; |
|
| 6027 | + } |
|
| 6028 | + // WPML |
|
| 6029 | 6029 | |
| 6030 | - $custom_fields = geodir_imex_get_custom_fields( $post_type ); |
|
| 6031 | - if ( !empty( $custom_fields ) ) {
|
|
| 6032 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 6033 | - $csv_row[] = $custom_field->htmlvar_name; |
|
| 6034 | - } |
|
| 6035 | - } |
|
| 6030 | + $custom_fields = geodir_imex_get_custom_fields( $post_type ); |
|
| 6031 | + if ( !empty( $custom_fields ) ) {
|
|
| 6032 | + foreach ( $custom_fields as $custom_field ) {
|
|
| 6033 | + $csv_row[] = $custom_field->htmlvar_name; |
|
| 6034 | + } |
|
| 6035 | + } |
|
| 6036 | 6036 | |
| 6037 | - // Export franchise fields |
|
| 6038 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 6039 | - if ($is_franchise_active) {
|
|
| 6040 | - $csv_row[] = 'gd_is_franchise'; |
|
| 6041 | - $csv_row[] = 'gd_franchise_lock'; |
|
| 6042 | - $csv_row[] = 'franchise'; |
|
| 6043 | - } |
|
| 6037 | + // Export franchise fields |
|
| 6038 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 6039 | + if ($is_franchise_active) {
|
|
| 6040 | + $csv_row[] = 'gd_is_franchise'; |
|
| 6041 | + $csv_row[] = 'gd_franchise_lock'; |
|
| 6042 | + $csv_row[] = 'franchise'; |
|
| 6043 | + } |
|
| 6044 | 6044 | |
| 6045 | - $csv_rows[] = $csv_row; |
|
| 6045 | + $csv_rows[] = $csv_row; |
|
| 6046 | 6046 | |
| 6047 | - $images_count = 5; |
|
| 6047 | + $images_count = 5; |
|
| 6048 | 6048 | $xx=0; |
| 6049 | - foreach ( $posts as $post ) {$xx++;
|
|
| 6050 | - $post_id = $post['ID']; |
|
| 6049 | + foreach ( $posts as $post ) {$xx++;
|
|
| 6050 | + $post_id = $post['ID']; |
|
| 6051 | 6051 | |
| 6052 | - $gd_post_info = geodir_get_post_info( $post_id ); |
|
| 6053 | - $post_info = (array)$gd_post_info; |
|
| 6052 | + $gd_post_info = geodir_get_post_info( $post_id ); |
|
| 6053 | + $post_info = (array)$gd_post_info; |
|
| 6054 | 6054 | |
| 6055 | - $taxonomy_category = $post_type . 'category'; |
|
| 6056 | - $taxonomy_tags = $post_type . '_tags'; |
|
| 6055 | + $taxonomy_category = $post_type . 'category'; |
|
| 6056 | + $taxonomy_tags = $post_type . '_tags'; |
|
| 6057 | 6057 | |
| 6058 | - $post_category = ''; |
|
| 6059 | - $default_category_id = $gd_post_info->default_category; |
|
| 6060 | - $default_category = ''; |
|
| 6061 | - $post_tags = ''; |
|
| 6062 | - $terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6058 | + $post_category = ''; |
|
| 6059 | + $default_category_id = $gd_post_info->default_category; |
|
| 6060 | + $default_category = ''; |
|
| 6061 | + $post_tags = ''; |
|
| 6062 | + $terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6063 | 6063 | |
| 6064 | - if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
|
|
| 6065 | - $post_category = array(); |
|
| 6066 | - $post_tags = array(); |
|
| 6064 | + if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
|
|
| 6065 | + $post_category = array(); |
|
| 6066 | + $post_tags = array(); |
|
| 6067 | 6067 | |
| 6068 | - foreach ( $terms as $term ) {
|
|
| 6069 | - if ( $term->taxonomy == $taxonomy_category ) {
|
|
| 6070 | - $post_category[] = $term->name; |
|
| 6068 | + foreach ( $terms as $term ) {
|
|
| 6069 | + if ( $term->taxonomy == $taxonomy_category ) {
|
|
| 6070 | + $post_category[] = $term->name; |
|
| 6071 | 6071 | |
| 6072 | - if ($default_category_id == $term->term_id) {
|
|
| 6073 | - $default_category = $term->name; // Default category. |
|
| 6074 | - } |
|
| 6075 | - } |
|
| 6072 | + if ($default_category_id == $term->term_id) {
|
|
| 6073 | + $default_category = $term->name; // Default category. |
|
| 6074 | + } |
|
| 6075 | + } |
|
| 6076 | 6076 | |
| 6077 | - if ( $term->taxonomy == $taxonomy_tags ) {
|
|
| 6078 | - $post_tags[] = $term->name; |
|
| 6079 | - } |
|
| 6080 | - } |
|
| 6077 | + if ( $term->taxonomy == $taxonomy_tags ) {
|
|
| 6078 | + $post_tags[] = $term->name; |
|
| 6079 | + } |
|
| 6080 | + } |
|
| 6081 | 6081 | |
| 6082 | - if (empty($default_category) && !empty($post_category)) {
|
|
| 6083 | - $default_category = $post_category[0]; // Set first one as default category. |
|
| 6084 | - } |
|
| 6085 | - $post_category = !empty( $post_category ) ? implode( ',', $post_category ) : ''; |
|
| 6086 | - $post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : ''; |
|
| 6087 | - } |
|
| 6082 | + if (empty($default_category) && !empty($post_category)) {
|
|
| 6083 | + $default_category = $post_category[0]; // Set first one as default category. |
|
| 6084 | + } |
|
| 6085 | + $post_category = !empty( $post_category ) ? implode( ',', $post_category ) : ''; |
|
| 6086 | + $post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : ''; |
|
| 6087 | + } |
|
| 6088 | 6088 | |
| 6089 | - // Franchise data |
|
| 6090 | - $franchise_id = NULL; |
|
| 6091 | - $franchise_info = array(); |
|
| 6092 | - $locked_fields = array(); |
|
| 6089 | + // Franchise data |
|
| 6090 | + $franchise_id = NULL; |
|
| 6091 | + $franchise_info = array(); |
|
| 6092 | + $locked_fields = array(); |
|
| 6093 | 6093 | |
| 6094 | - if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
|
|
| 6095 | - $franchise_id = $post_info['franchise']; |
|
| 6096 | - $gd_franchise_info = geodir_get_post_info($franchise_id); |
|
| 6094 | + if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
|
|
| 6095 | + $franchise_id = $post_info['franchise']; |
|
| 6096 | + $gd_franchise_info = geodir_get_post_info($franchise_id); |
|
| 6097 | 6097 | |
| 6098 | - if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
|
|
| 6099 | - $franchise_info = (array)$gd_franchise_info; |
|
| 6100 | - $locked_fields = geodir_franchise_get_locked_fields($franchise_id, true); |
|
| 6098 | + if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
|
|
| 6099 | + $franchise_info = (array)$gd_franchise_info; |
|
| 6100 | + $locked_fields = geodir_franchise_get_locked_fields($franchise_id, true); |
|
| 6101 | 6101 | |
| 6102 | - if (!empty($locked_fields)) {
|
|
| 6103 | - foreach( $locked_fields as $locked_field) {
|
|
| 6104 | - if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
|
|
| 6105 | - $post_info[$locked_field] = $franchise_info[$locked_field]; |
|
| 6106 | - } |
|
| 6102 | + if (!empty($locked_fields)) {
|
|
| 6103 | + foreach( $locked_fields as $locked_field) {
|
|
| 6104 | + if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
|
|
| 6105 | + $post_info[$locked_field] = $franchise_info[$locked_field]; |
|
| 6106 | + } |
|
| 6107 | 6107 | |
| 6108 | - if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
|
|
| 6109 | - $franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6108 | + if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
|
|
| 6109 | + $franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6110 | 6110 | |
| 6111 | - if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
|
|
| 6112 | - $franchise_post_category = array(); |
|
| 6113 | - $franchise_post_tags = array(); |
|
| 6111 | + if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
|
|
| 6112 | + $franchise_post_category = array(); |
|
| 6113 | + $franchise_post_tags = array(); |
|
| 6114 | 6114 | |
| 6115 | - foreach ( $franchise_terms as $franchise_term ) {
|
|
| 6116 | - if ( $franchise_term->taxonomy == $taxonomy_category ) {
|
|
| 6117 | - $franchise_post_category[] = $franchise_term->name; |
|
| 6118 | - } |
|
| 6115 | + foreach ( $franchise_terms as $franchise_term ) {
|
|
| 6116 | + if ( $franchise_term->taxonomy == $taxonomy_category ) {
|
|
| 6117 | + $franchise_post_category[] = $franchise_term->name; |
|
| 6118 | + } |
|
| 6119 | 6119 | |
| 6120 | - if ( $franchise_term->taxonomy == $taxonomy_tags ) {
|
|
| 6121 | - $franchise_post_tags[] = $franchise_term->name; |
|
| 6122 | - } |
|
| 6123 | - } |
|
| 6120 | + if ( $franchise_term->taxonomy == $taxonomy_tags ) {
|
|
| 6121 | + $franchise_post_tags[] = $franchise_term->name; |
|
| 6122 | + } |
|
| 6123 | + } |
|
| 6124 | 6124 | |
| 6125 | - if (in_array($taxonomy_category, $locked_fields)) {
|
|
| 6126 | - $post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : ''; |
|
| 6127 | - } |
|
| 6128 | - if (in_array('post_tags', $locked_fields)) {
|
|
| 6129 | - $post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : ''; |
|
| 6130 | - } |
|
| 6131 | - } |
|
| 6132 | - } |
|
| 6133 | - } |
|
| 6134 | - } |
|
| 6135 | - } |
|
| 6136 | - } |
|
| 6125 | + if (in_array($taxonomy_category, $locked_fields)) {
|
|
| 6126 | + $post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : ''; |
|
| 6127 | + } |
|
| 6128 | + if (in_array('post_tags', $locked_fields)) {
|
|
| 6129 | + $post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : ''; |
|
| 6130 | + } |
|
| 6131 | + } |
|
| 6132 | + } |
|
| 6133 | + } |
|
| 6134 | + } |
|
| 6135 | + } |
|
| 6136 | + } |
|
| 6137 | 6137 | |
| 6138 | - $post_images = geodir_get_images( $post_id ); |
|
| 6139 | - $current_images = array(); |
|
| 6140 | - if ( !empty( $post_images ) ) {
|
|
| 6141 | - foreach ( $post_images as $post_image ) {
|
|
| 6142 | - $post_image = (array)$post_image; |
|
| 6143 | - $image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : ''; |
|
| 6144 | - if ( $image ) {
|
|
| 6145 | - $current_images[] = $image; |
|
| 6146 | - } |
|
| 6147 | - } |
|
| 6138 | + $post_images = geodir_get_images( $post_id ); |
|
| 6139 | + $current_images = array(); |
|
| 6140 | + if ( !empty( $post_images ) ) {
|
|
| 6141 | + foreach ( $post_images as $post_image ) {
|
|
| 6142 | + $post_image = (array)$post_image; |
|
| 6143 | + $image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : ''; |
|
| 6144 | + if ( $image ) {
|
|
| 6145 | + $current_images[] = $image; |
|
| 6146 | + } |
|
| 6147 | + } |
|
| 6148 | 6148 | |
| 6149 | - $images_count = max( $images_count, count( $current_images ) ); |
|
| 6150 | - } |
|
| 6149 | + $images_count = max( $images_count, count( $current_images ) ); |
|
| 6150 | + } |
|
| 6151 | 6151 | |
| 6152 | - $csv_row = array(); |
|
| 6153 | - $csv_row[] = $post_id; // post_id |
|
| 6154 | - $csv_row[] = $post_info['post_title']; // post_title |
|
| 6155 | - $csv_row[] = $post_info['post_author']; // post_author |
|
| 6156 | - $csv_row[] = $post_info['post_content']; // post_content |
|
| 6157 | - $csv_row[] = $post_category; // post_category |
|
| 6158 | - $csv_row[] = $default_category; // default_category |
|
| 6159 | - $csv_row[] = $post_tags; // post_tags |
|
| 6160 | - $csv_row[] = $post_type; // post_type |
|
| 6161 | - if ( $post_type == 'gd_event' ) {
|
|
| 6162 | - $event_data = geodir_imex_get_event_data($post, $gd_post_info); |
|
| 6163 | - $csv_row[] = $event_data['event_date']; // event_date |
|
| 6164 | - $csv_row[] = $event_data['event_enddate']; // enddate |
|
| 6165 | - $csv_row[] = $event_data['starttime']; // starttime |
|
| 6166 | - $csv_row[] = $event_data['endtime']; // endtime |
|
| 6152 | + $csv_row = array(); |
|
| 6153 | + $csv_row[] = $post_id; // post_id |
|
| 6154 | + $csv_row[] = $post_info['post_title']; // post_title |
|
| 6155 | + $csv_row[] = $post_info['post_author']; // post_author |
|
| 6156 | + $csv_row[] = $post_info['post_content']; // post_content |
|
| 6157 | + $csv_row[] = $post_category; // post_category |
|
| 6158 | + $csv_row[] = $default_category; // default_category |
|
| 6159 | + $csv_row[] = $post_tags; // post_tags |
|
| 6160 | + $csv_row[] = $post_type; // post_type |
|
| 6161 | + if ( $post_type == 'gd_event' ) {
|
|
| 6162 | + $event_data = geodir_imex_get_event_data($post, $gd_post_info); |
|
| 6163 | + $csv_row[] = $event_data['event_date']; // event_date |
|
| 6164 | + $csv_row[] = $event_data['event_enddate']; // enddate |
|
| 6165 | + $csv_row[] = $event_data['starttime']; // starttime |
|
| 6166 | + $csv_row[] = $event_data['endtime']; // endtime |
|
| 6167 | 6167 | |
| 6168 | - $csv_row[] = $event_data['is_recurring_event']; // is_recurring |
|
| 6169 | - $csv_row[] = $event_data['event_duration_days']; // duration_x |
|
| 6170 | - $csv_row[] = $event_data['recurring_dates']; // recurring_dates |
|
| 6171 | - $csv_row[] = $event_data['is_whole_day_event']; // all_day |
|
| 6172 | - $csv_row[] = $event_data['event_starttimes']; // starttimes |
|
| 6173 | - $csv_row[] = $event_data['event_endtimes']; // endtimes |
|
| 6174 | - $csv_row[] = $event_data['recurring_type']; // repeat_type |
|
| 6175 | - $csv_row[] = $event_data['recurring_interval']; // repeat_x |
|
| 6176 | - $csv_row[] = $event_data['recurring_week_days']; // repeat_days |
|
| 6177 | - $csv_row[] = $event_data['recurring_week_nos']; // repeat_weeks |
|
| 6178 | - $csv_row[] = $event_data['max_recurring_count']; // max_repeat |
|
| 6179 | - $csv_row[] = $event_data['recurring_end_date']; // repeat_end |
|
| 6180 | - } |
|
| 6181 | - $csv_row[] = $post_info['post_status']; // post_status |
|
| 6182 | - $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 6183 | - if ($is_payment_plugin) {
|
|
| 6184 | - $csv_row[] = (int)$post_info['package_id']; // package_id |
|
| 6185 | - $csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
|
|
| 6186 | - } |
|
| 6187 | - $csv_row[] = $post_info['geodir_video']; // geodir_video |
|
| 6188 | - $csv_row[] = $post_info['post_address']; // post_address |
|
| 6189 | - $csv_row[] = $post_info['post_city']; // post_city |
|
| 6190 | - $csv_row[] = $post_info['post_region']; // post_region |
|
| 6191 | - $csv_row[] = $post_info['post_country']; // post_country |
|
| 6192 | - $csv_row[] = $post_info['post_zip']; // post_zip |
|
| 6193 | - $csv_row[] = $post_info['post_latitude']; // post_latitude |
|
| 6194 | - $csv_row[] = $post_info['post_longitude']; // post_longitude |
|
| 6195 | - $csv_row[] = $post_info['geodir_timing']; // geodir_timing |
|
| 6196 | - $csv_row[] = $post_info['geodir_contact']; // geodir_contact |
|
| 6197 | - $csv_row[] = $post_info['geodir_email']; // geodir_email |
|
| 6198 | - $csv_row[] = $post_info['geodir_website']; // geodir_website |
|
| 6199 | - $csv_row[] = $post_info['geodir_twitter']; // geodir_twitter |
|
| 6200 | - $csv_row[] = $post_info['geodir_facebook']; // geodir_facebook |
|
| 6201 | - $csv_row[] = $post_info['geodir_video']; // geodir_video |
|
| 6202 | - $csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers |
|
| 6203 | - // WPML |
|
| 6204 | - if ($is_wpml) {
|
|
| 6205 | - $csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type ); |
|
| 6206 | - $csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type ); |
|
| 6207 | - } |
|
| 6208 | - // WPML |
|
| 6168 | + $csv_row[] = $event_data['is_recurring_event']; // is_recurring |
|
| 6169 | + $csv_row[] = $event_data['event_duration_days']; // duration_x |
|
| 6170 | + $csv_row[] = $event_data['recurring_dates']; // recurring_dates |
|
| 6171 | + $csv_row[] = $event_data['is_whole_day_event']; // all_day |
|
| 6172 | + $csv_row[] = $event_data['event_starttimes']; // starttimes |
|
| 6173 | + $csv_row[] = $event_data['event_endtimes']; // endtimes |
|
| 6174 | + $csv_row[] = $event_data['recurring_type']; // repeat_type |
|
| 6175 | + $csv_row[] = $event_data['recurring_interval']; // repeat_x |
|
| 6176 | + $csv_row[] = $event_data['recurring_week_days']; // repeat_days |
|
| 6177 | + $csv_row[] = $event_data['recurring_week_nos']; // repeat_weeks |
|
| 6178 | + $csv_row[] = $event_data['max_recurring_count']; // max_repeat |
|
| 6179 | + $csv_row[] = $event_data['recurring_end_date']; // repeat_end |
|
| 6180 | + } |
|
| 6181 | + $csv_row[] = $post_info['post_status']; // post_status |
|
| 6182 | + $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 6183 | + if ($is_payment_plugin) {
|
|
| 6184 | + $csv_row[] = (int)$post_info['package_id']; // package_id |
|
| 6185 | + $csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
|
|
| 6186 | + } |
|
| 6187 | + $csv_row[] = $post_info['geodir_video']; // geodir_video |
|
| 6188 | + $csv_row[] = $post_info['post_address']; // post_address |
|
| 6189 | + $csv_row[] = $post_info['post_city']; // post_city |
|
| 6190 | + $csv_row[] = $post_info['post_region']; // post_region |
|
| 6191 | + $csv_row[] = $post_info['post_country']; // post_country |
|
| 6192 | + $csv_row[] = $post_info['post_zip']; // post_zip |
|
| 6193 | + $csv_row[] = $post_info['post_latitude']; // post_latitude |
|
| 6194 | + $csv_row[] = $post_info['post_longitude']; // post_longitude |
|
| 6195 | + $csv_row[] = $post_info['geodir_timing']; // geodir_timing |
|
| 6196 | + $csv_row[] = $post_info['geodir_contact']; // geodir_contact |
|
| 6197 | + $csv_row[] = $post_info['geodir_email']; // geodir_email |
|
| 6198 | + $csv_row[] = $post_info['geodir_website']; // geodir_website |
|
| 6199 | + $csv_row[] = $post_info['geodir_twitter']; // geodir_twitter |
|
| 6200 | + $csv_row[] = $post_info['geodir_facebook']; // geodir_facebook |
|
| 6201 | + $csv_row[] = $post_info['geodir_video']; // geodir_video |
|
| 6202 | + $csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers |
|
| 6203 | + // WPML |
|
| 6204 | + if ($is_wpml) {
|
|
| 6205 | + $csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type ); |
|
| 6206 | + $csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type ); |
|
| 6207 | + } |
|
| 6208 | + // WPML |
|
| 6209 | 6209 | |
| 6210 | - if ( !empty( $custom_fields ) ) {
|
|
| 6211 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 6212 | - $csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 6213 | - } |
|
| 6214 | - } |
|
| 6210 | + if ( !empty( $custom_fields ) ) {
|
|
| 6211 | + foreach ( $custom_fields as $custom_field ) {
|
|
| 6212 | + $csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 6213 | + } |
|
| 6214 | + } |
|
| 6215 | 6215 | |
| 6216 | - // Franchise data |
|
| 6217 | - if ($is_franchise_active) {
|
|
| 6218 | - $gd_is_franchise = ''; |
|
| 6219 | - $locaked_fields = ''; |
|
| 6220 | - $franchise = ''; |
|
| 6216 | + // Franchise data |
|
| 6217 | + if ($is_franchise_active) {
|
|
| 6218 | + $gd_is_franchise = ''; |
|
| 6219 | + $locaked_fields = ''; |
|
| 6220 | + $franchise = ''; |
|
| 6221 | 6221 | |
| 6222 | - if (geodir_franchise_pkg_is_active($gd_post_info)) {
|
|
| 6223 | - $gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true ); |
|
| 6224 | - $locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : ''; |
|
| 6225 | - $locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
|
|
| 6226 | - $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id |
|
| 6227 | - } |
|
| 6222 | + if (geodir_franchise_pkg_is_active($gd_post_info)) {
|
|
| 6223 | + $gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true ); |
|
| 6224 | + $locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : ''; |
|
| 6225 | + $locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
|
|
| 6226 | + $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id |
|
| 6227 | + } |
|
| 6228 | 6228 | |
| 6229 | - $csv_row[] = (int)$gd_is_franchise; // gd_is_franchise |
|
| 6230 | - $csv_row[] = $locaked_fields; // gd_franchise_lock fields |
|
| 6231 | - $csv_row[] = (int)$franchise; // franchise id |
|
| 6232 | - } |
|
| 6229 | + $csv_row[] = (int)$gd_is_franchise; // gd_is_franchise |
|
| 6230 | + $csv_row[] = $locaked_fields; // gd_franchise_lock fields |
|
| 6231 | + $csv_row[] = (int)$franchise; // franchise id |
|
| 6232 | + } |
|
| 6233 | 6233 | |
| 6234 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6235 | - $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
|
| 6236 | - } |
|
| 6234 | + for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6235 | + $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
|
| 6236 | + } |
|
| 6237 | 6237 | |
| 6238 | - $csv_rows[] = $csv_row; |
|
| 6238 | + $csv_rows[] = $csv_row; |
|
| 6239 | 6239 | |
| 6240 | - } |
|
| 6240 | + } |
|
| 6241 | 6241 | |
| 6242 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6243 | - $csv_rows[0][] = 'IMAGE'; |
|
| 6244 | - } |
|
| 6245 | - } |
|
| 6246 | - return $csv_rows; |
|
| 6242 | + for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6243 | + $csv_rows[0][] = 'IMAGE'; |
|
| 6244 | + } |
|
| 6245 | + } |
|
| 6246 | + return $csv_rows; |
|
| 6247 | 6247 | } |
| 6248 | 6248 | |
| 6249 | 6249 | /** |
@@ -6262,48 +6262,48 @@ discard block |
||
| 6262 | 6262 | * @return array Array of posts data. |
| 6263 | 6263 | */ |
| 6264 | 6264 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 6265 | - global $wpdb, $plugin_prefix; |
|
| 6265 | + global $wpdb, $plugin_prefix; |
|
| 6266 | 6266 | |
| 6267 | - if ( ! post_type_exists( $post_type ) ) |
|
| 6268 | - return new stdClass; |
|
| 6267 | + if ( ! post_type_exists( $post_type ) ) |
|
| 6268 | + return new stdClass; |
|
| 6269 | 6269 | |
| 6270 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 6270 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 6271 | 6271 | |
| 6272 | - $limit = ''; |
|
| 6273 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6274 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 6272 | + $limit = ''; |
|
| 6273 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6274 | + $offset = ( $page_no - 1 ) * $per_page; |
|
| 6275 | 6275 | |
| 6276 | - if ( $offset > 0 ) {
|
|
| 6277 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 6278 | - } else {
|
|
| 6279 | - $limit = " LIMIT " . $per_page; |
|
| 6280 | - } |
|
| 6281 | - } |
|
| 6276 | + if ( $offset > 0 ) {
|
|
| 6277 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 6278 | + } else {
|
|
| 6279 | + $limit = " LIMIT " . $per_page; |
|
| 6280 | + } |
|
| 6281 | + } |
|
| 6282 | 6282 | |
| 6283 | - $query = "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ORDER BY {$wpdb->posts}.ID ASC" . $limit;
|
|
| 6284 | - /** |
|
| 6285 | - * Modify returned posts SQL query for the current post type. |
|
| 6286 | - * |
|
| 6287 | - * @since 1.4.6 |
|
| 6283 | + $query = "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ORDER BY {$wpdb->posts}.ID ASC" . $limit;
|
|
| 6284 | + /** |
|
| 6285 | + * Modify returned posts SQL query for the current post type. |
|
| 6286 | + * |
|
| 6287 | + * @since 1.4.6 |
|
| 6288 | 6288 | * @package GeoDirectory |
| 6289 | - * |
|
| 6290 | - * @param int $query The SQL query. |
|
| 6291 | - * @param string $post_type Post type. |
|
| 6292 | - */ |
|
| 6293 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 6294 | - |
|
| 6295 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 6296 | - |
|
| 6297 | - /** |
|
| 6298 | - * Modify returned post results for the current post type. |
|
| 6299 | - * |
|
| 6300 | - * @since 1.4.6 |
|
| 6289 | + * |
|
| 6290 | + * @param int $query The SQL query. |
|
| 6291 | + * @param string $post_type Post type. |
|
| 6292 | + */ |
|
| 6293 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 6294 | + |
|
| 6295 | + $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 6296 | + |
|
| 6297 | + /** |
|
| 6298 | + * Modify returned post results for the current post type. |
|
| 6299 | + * |
|
| 6300 | + * @since 1.4.6 |
|
| 6301 | 6301 | * @package GeoDirectory |
| 6302 | - * |
|
| 6303 | - * @param object $results An object containing all post ids. |
|
| 6304 | - * @param string $post_type Post type. |
|
| 6305 | - */ |
|
| 6306 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 6302 | + * |
|
| 6303 | + * @param object $results An object containing all post ids. |
|
| 6304 | + * @param string $post_type Post type. |
|
| 6305 | + */ |
|
| 6306 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 6307 | 6307 | } |
| 6308 | 6308 | |
| 6309 | 6309 | /** |
@@ -6321,16 +6321,16 @@ discard block |
||
| 6321 | 6321 | * @return string The SQL query. |
| 6322 | 6322 | */ |
| 6323 | 6323 | function geodir_imex_get_events_query( $query, $post_type ) {
|
| 6324 | - if ( $post_type == 'gd_event' ) {
|
|
| 6325 | - global $wpdb, $plugin_prefix; |
|
| 6324 | + if ( $post_type == 'gd_event' ) {
|
|
| 6325 | + global $wpdb, $plugin_prefix; |
|
| 6326 | 6326 | |
| 6327 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 6328 | - $schedule_table = EVENT_SCHEDULE; |
|
| 6327 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 6328 | + $schedule_table = EVENT_SCHEDULE; |
|
| 6329 | 6329 | |
| 6330 | - $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 6331 | - } |
|
| 6330 | + $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 6331 | + } |
|
| 6332 | 6332 | |
| 6333 | - return $query; |
|
| 6333 | + return $query; |
|
| 6334 | 6334 | } |
| 6335 | 6335 | |
| 6336 | 6336 | /** |
@@ -6343,16 +6343,16 @@ discard block |
||
| 6343 | 6343 | * @return int Total terms count. |
| 6344 | 6344 | */ |
| 6345 | 6345 | function geodir_get_terms_count( $post_type ) {
|
| 6346 | - $args = array( 'hide_empty' => 0 ); |
|
| 6346 | + $args = array( 'hide_empty' => 0 ); |
|
| 6347 | 6347 | |
| 6348 | - remove_all_filters( 'get_terms' ); |
|
| 6348 | + remove_all_filters( 'get_terms' ); |
|
| 6349 | 6349 | |
| 6350 | - $taxonomy = $post_type . 'category'; |
|
| 6350 | + $taxonomy = $post_type . 'category'; |
|
| 6351 | 6351 | |
| 6352 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 6353 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 6352 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 6353 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 6354 | 6354 | |
| 6355 | - return $count_terms; |
|
| 6355 | + return $count_terms; |
|
| 6356 | 6356 | } |
| 6357 | 6357 | |
| 6358 | 6358 | /** |
@@ -6368,76 +6368,76 @@ discard block |
||
| 6368 | 6368 | * @return array Array of terms data. |
| 6369 | 6369 | */ |
| 6370 | 6370 | function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 6371 | - $args = array( 'hide_empty' => 0, 'orderby' => 'id' ); |
|
| 6371 | + $args = array( 'hide_empty' => 0, 'orderby' => 'id' ); |
|
| 6372 | 6372 | |
| 6373 | - remove_all_filters( 'get_terms' ); |
|
| 6373 | + remove_all_filters( 'get_terms' ); |
|
| 6374 | 6374 | |
| 6375 | - $taxonomy = $post_type . 'category'; |
|
| 6375 | + $taxonomy = $post_type . 'category'; |
|
| 6376 | 6376 | |
| 6377 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6378 | - $args['offset'] = ( $page_no - 1 ) * $per_page; |
|
| 6379 | - $args['number'] = $per_page; |
|
| 6380 | - } |
|
| 6377 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6378 | + $args['offset'] = ( $page_no - 1 ) * $per_page; |
|
| 6379 | + $args['number'] = $per_page; |
|
| 6380 | + } |
|
| 6381 | 6381 | |
| 6382 | - $terms = get_terms( $taxonomy, $args ); |
|
| 6382 | + $terms = get_terms( $taxonomy, $args ); |
|
| 6383 | 6383 | |
| 6384 | - $csv_rows = array(); |
|
| 6384 | + $csv_rows = array(); |
|
| 6385 | 6385 | |
| 6386 | - if ( !empty( $terms ) ) {
|
|
| 6387 | - $csv_row = array(); |
|
| 6388 | - $csv_row[] = 'cat_id'; |
|
| 6389 | - $csv_row[] = 'cat_name'; |
|
| 6390 | - $csv_row[] = 'cat_slug'; |
|
| 6391 | - $csv_row[] = 'cat_posttype'; |
|
| 6392 | - $csv_row[] = 'cat_parent'; |
|
| 6393 | - $csv_row[] = 'cat_schema'; |
|
| 6394 | - $csv_row[] = 'cat_description'; |
|
| 6395 | - $csv_row[] = 'cat_top_description'; |
|
| 6396 | - $csv_row[] = 'cat_image'; |
|
| 6397 | - $csv_row[] = 'cat_icon'; |
|
| 6398 | - // WPML |
|
| 6399 | - $is_wpml = geodir_is_wpml(); |
|
| 6400 | - if ($is_wpml) {
|
|
| 6401 | - $csv_row[] = 'cat_language'; |
|
| 6402 | - } |
|
| 6403 | - // WPML |
|
| 6386 | + if ( !empty( $terms ) ) {
|
|
| 6387 | + $csv_row = array(); |
|
| 6388 | + $csv_row[] = 'cat_id'; |
|
| 6389 | + $csv_row[] = 'cat_name'; |
|
| 6390 | + $csv_row[] = 'cat_slug'; |
|
| 6391 | + $csv_row[] = 'cat_posttype'; |
|
| 6392 | + $csv_row[] = 'cat_parent'; |
|
| 6393 | + $csv_row[] = 'cat_schema'; |
|
| 6394 | + $csv_row[] = 'cat_description'; |
|
| 6395 | + $csv_row[] = 'cat_top_description'; |
|
| 6396 | + $csv_row[] = 'cat_image'; |
|
| 6397 | + $csv_row[] = 'cat_icon'; |
|
| 6398 | + // WPML |
|
| 6399 | + $is_wpml = geodir_is_wpml(); |
|
| 6400 | + if ($is_wpml) {
|
|
| 6401 | + $csv_row[] = 'cat_language'; |
|
| 6402 | + } |
|
| 6403 | + // WPML |
|
| 6404 | 6404 | |
| 6405 | - $csv_rows[] = $csv_row; |
|
| 6405 | + $csv_rows[] = $csv_row; |
|
| 6406 | 6406 | |
| 6407 | - foreach ( $terms as $term ) {
|
|
| 6408 | - $cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type ); |
|
| 6409 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 6407 | + foreach ( $terms as $term ) {
|
|
| 6408 | + $cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type ); |
|
| 6409 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 6410 | 6410 | |
| 6411 | - $cat_image = geodir_get_default_catimage( $term->term_id, $post_type ); |
|
| 6412 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 6411 | + $cat_image = geodir_get_default_catimage( $term->term_id, $post_type ); |
|
| 6412 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 6413 | 6413 | |
| 6414 | - $cat_parent = ''; |
|
| 6415 | - if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
|
|
| 6416 | - $parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy ); |
|
| 6417 | - $cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : ''; |
|
| 6418 | - } |
|
| 6414 | + $cat_parent = ''; |
|
| 6415 | + if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
|
|
| 6416 | + $parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy ); |
|
| 6417 | + $cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : ''; |
|
| 6418 | + } |
|
| 6419 | 6419 | |
| 6420 | - $csv_row = array(); |
|
| 6421 | - $csv_row[] = $term->term_id; |
|
| 6422 | - $csv_row[] = $term->name; |
|
| 6423 | - $csv_row[] = $term->slug; |
|
| 6424 | - $csv_row[] = $post_type; |
|
| 6425 | - $csv_row[] = $cat_parent; |
|
| 6426 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
|
| 6427 | - $csv_row[] = $term->description; |
|
| 6428 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type ); |
|
| 6429 | - $csv_row[] = $cat_image; |
|
| 6430 | - $csv_row[] = $cat_icon; |
|
| 6431 | - // WPML |
|
| 6432 | - if ($is_wpml) {
|
|
| 6433 | - $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
|
| 6434 | - } |
|
| 6435 | - // WPML |
|
| 6420 | + $csv_row = array(); |
|
| 6421 | + $csv_row[] = $term->term_id; |
|
| 6422 | + $csv_row[] = $term->name; |
|
| 6423 | + $csv_row[] = $term->slug; |
|
| 6424 | + $csv_row[] = $post_type; |
|
| 6425 | + $csv_row[] = $cat_parent; |
|
| 6426 | + $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
|
| 6427 | + $csv_row[] = $term->description; |
|
| 6428 | + $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type ); |
|
| 6429 | + $csv_row[] = $cat_image; |
|
| 6430 | + $csv_row[] = $cat_icon; |
|
| 6431 | + // WPML |
|
| 6432 | + if ($is_wpml) {
|
|
| 6433 | + $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
|
| 6434 | + } |
|
| 6435 | + // WPML |
|
| 6436 | 6436 | |
| 6437 | - $csv_rows[] = $csv_row; |
|
| 6438 | - } |
|
| 6439 | - } |
|
| 6440 | - return $csv_rows; |
|
| 6437 | + $csv_rows[] = $csv_row; |
|
| 6438 | + } |
|
| 6439 | + } |
|
| 6440 | + return $csv_rows; |
|
| 6441 | 6441 | } |
| 6442 | 6442 | |
| 6443 | 6443 | /** |
@@ -6450,9 +6450,9 @@ discard block |
||
| 6450 | 6450 | * @return string Path to the cache directory. |
| 6451 | 6451 | */ |
| 6452 | 6452 | function geodir_path_import_export( $relative = true ) {
|
| 6453 | - $upload_dir = wp_upload_dir(); |
|
| 6453 | + $upload_dir = wp_upload_dir(); |
|
| 6454 | 6454 | |
| 6455 | - return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache'; |
|
| 6455 | + return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache'; |
|
| 6456 | 6456 | } |
| 6457 | 6457 | |
| 6458 | 6458 | /** |
@@ -6469,29 +6469,29 @@ discard block |
||
| 6469 | 6469 | * @return bool true if success otherwise false. |
| 6470 | 6470 | */ |
| 6471 | 6471 | function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
|
| 6472 | - if ( empty( $csv_data ) ) {
|
|
| 6473 | - return false; |
|
| 6474 | - } |
|
| 6472 | + if ( empty( $csv_data ) ) {
|
|
| 6473 | + return false; |
|
| 6474 | + } |
|
| 6475 | 6475 | |
| 6476 | - global $wp_filesystem; |
|
| 6476 | + global $wp_filesystem; |
|
| 6477 | 6477 | |
| 6478 | - $mode = $clear ? 'w+' : 'a+'; |
|
| 6478 | + $mode = $clear ? 'w+' : 'a+'; |
|
| 6479 | 6479 | |
| 6480 | - if ( function_exists( 'fputcsv' ) ) {
|
|
| 6481 | - $file = fopen( $file_path, $mode ); |
|
| 6482 | - foreach( $csv_data as $csv_row ) {
|
|
| 6483 | - //$csv_row = array_map( 'utf8_decode', $csv_row ); |
|
| 6484 | - $write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' ); |
|
| 6485 | - } |
|
| 6486 | - fclose( $file ); |
|
| 6487 | - } else {
|
|
| 6488 | - foreach( $csv_data as $csv_row ) {
|
|
| 6489 | - //$csv_row = array_map( 'utf8_decode', $csv_row ); |
|
| 6490 | - $wp_filesystem->put_contents( $file_path, $csv_row ); |
|
| 6491 | - } |
|
| 6492 | - } |
|
| 6480 | + if ( function_exists( 'fputcsv' ) ) {
|
|
| 6481 | + $file = fopen( $file_path, $mode ); |
|
| 6482 | + foreach( $csv_data as $csv_row ) {
|
|
| 6483 | + //$csv_row = array_map( 'utf8_decode', $csv_row ); |
|
| 6484 | + $write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' ); |
|
| 6485 | + } |
|
| 6486 | + fclose( $file ); |
|
| 6487 | + } else {
|
|
| 6488 | + foreach( $csv_data as $csv_row ) {
|
|
| 6489 | + //$csv_row = array_map( 'utf8_decode', $csv_row ); |
|
| 6490 | + $wp_filesystem->put_contents( $file_path, $csv_row ); |
|
| 6491 | + } |
|
| 6492 | + } |
|
| 6493 | 6493 | |
| 6494 | - return true; |
|
| 6494 | + return true; |
|
| 6495 | 6495 | } |
| 6496 | 6496 | |
| 6497 | 6497 | /** |
@@ -6506,17 +6506,17 @@ discard block |
||
| 6506 | 6506 | * @return int No of file rows. |
| 6507 | 6507 | */ |
| 6508 | 6508 | function geodir_import_export_line_count( $file ) {
|
| 6509 | - global $wp_filesystem; |
|
| 6509 | + global $wp_filesystem; |
|
| 6510 | 6510 | |
| 6511 | - if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
|
|
| 6512 | - $contents = $wp_filesystem->get_contents_array( $file ); |
|
| 6511 | + if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
|
|
| 6512 | + $contents = $wp_filesystem->get_contents_array( $file ); |
|
| 6513 | 6513 | |
| 6514 | - if ( !empty( $contents ) && is_array( $contents ) ) {
|
|
| 6515 | - return count( $contents ) - 1; |
|
| 6516 | - } |
|
| 6517 | - } |
|
| 6514 | + if ( !empty( $contents ) && is_array( $contents ) ) {
|
|
| 6515 | + return count( $contents ) - 1; |
|
| 6516 | + } |
|
| 6517 | + } |
|
| 6518 | 6518 | |
| 6519 | - return NULL; |
|
| 6519 | + return NULL; |
|
| 6520 | 6520 | } |
| 6521 | 6521 | |
| 6522 | 6522 | /** |
@@ -6530,12 +6530,12 @@ discard block |
||
| 6530 | 6530 | * @return object Queried object. |
| 6531 | 6531 | */ |
| 6532 | 6532 | function geodir_imex_get_custom_fields( $post_type ) {
|
| 6533 | - global $wpdb; |
|
| 6533 | + global $wpdb; |
|
| 6534 | 6534 | |
| 6535 | - $sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
|
|
| 6536 | - $rows = $wpdb->get_results( $sql ); |
|
| 6535 | + $sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
|
|
| 6536 | + $rows = $wpdb->get_results( $sql ); |
|
| 6537 | 6537 | |
| 6538 | - return $rows; |
|
| 6538 | + return $rows; |
|
| 6539 | 6539 | } |
| 6540 | 6540 | |
| 6541 | 6541 | /** |
@@ -6546,11 +6546,11 @@ discard block |
||
| 6546 | 6546 | * @return True if WPML is active else False. |
| 6547 | 6547 | */ |
| 6548 | 6548 | function geodir_is_wpml() {
|
| 6549 | - if (function_exists('icl_object_id')) {
|
|
| 6550 | - return true; |
|
| 6551 | - } |
|
| 6549 | + if (function_exists('icl_object_id')) {
|
|
| 6550 | + return true; |
|
| 6551 | + } |
|
| 6552 | 6552 | |
| 6553 | - return false; |
|
| 6553 | + return false; |
|
| 6554 | 6554 | } |
| 6555 | 6555 | |
| 6556 | 6556 | /** |
@@ -6565,9 +6565,9 @@ discard block |
||
| 6565 | 6565 | * @return Language code. |
| 6566 | 6566 | */ |
| 6567 | 6567 | function geodir_get_language_for_element($element_id, $element_type) {
|
| 6568 | - global $sitepress; |
|
| 6568 | + global $sitepress; |
|
| 6569 | 6569 | |
| 6570 | - return $sitepress->get_language_for_element($element_id, $element_type); |
|
| 6570 | + return $sitepress->get_language_for_element($element_id, $element_type); |
|
| 6571 | 6571 | } |
| 6572 | 6572 | |
| 6573 | 6573 | /** |
@@ -6581,18 +6581,18 @@ discard block |
||
| 6581 | 6581 | * @param int $tr_post_id Translation Post ID. |
| 6582 | 6582 | */ |
| 6583 | 6583 | function geodir_icl_make_duplicate($master_post_id, $lang, $postarr, $tr_post_id) {
|
| 6584 | - $post_type = get_post_type($master_post_id); |
|
| 6584 | + $post_type = get_post_type($master_post_id); |
|
| 6585 | 6585 | |
| 6586 | - if (in_array($post_type, geodir_get_posttypes())) {
|
|
| 6587 | - // Duplicate post details |
|
| 6588 | - geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang); |
|
| 6586 | + if (in_array($post_type, geodir_get_posttypes())) {
|
|
| 6587 | + // Duplicate post details |
|
| 6588 | + geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang); |
|
| 6589 | 6589 | |
| 6590 | - // Duplicate taxonomies |
|
| 6591 | - geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang); |
|
| 6590 | + // Duplicate taxonomies |
|
| 6591 | + geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang); |
|
| 6592 | 6592 | |
| 6593 | - // Duplicate post images |
|
| 6594 | - geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang); |
|
| 6595 | - } |
|
| 6593 | + // Duplicate post images |
|
| 6594 | + geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang); |
|
| 6595 | + } |
|
| 6596 | 6596 | } |
| 6597 | 6597 | |
| 6598 | 6598 | /** |
@@ -6609,23 +6609,23 @@ discard block |
||
| 6609 | 6609 | * @return bool True for success, False for fail. |
| 6610 | 6610 | */ |
| 6611 | 6611 | function geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang) {
|
| 6612 | - global $wpdb, $plugin_prefix; |
|
| 6612 | + global $wpdb, $plugin_prefix; |
|
| 6613 | 6613 | |
| 6614 | - $post_type = get_post_type($master_post_id); |
|
| 6615 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 6614 | + $post_type = get_post_type($master_post_id); |
|
| 6615 | + $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 6616 | 6616 | |
| 6617 | - $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
|
| 6618 | - $data = (array)$wpdb->get_row($query); |
|
| 6617 | + $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
|
| 6618 | + $data = (array)$wpdb->get_row($query); |
|
| 6619 | 6619 | |
| 6620 | - if ( !empty( $data ) ) {
|
|
| 6621 | - $data['post_id'] = $tr_post_id; |
|
| 6622 | - unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
|
| 6620 | + if ( !empty( $data ) ) {
|
|
| 6621 | + $data['post_id'] = $tr_post_id; |
|
| 6622 | + unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
|
| 6623 | 6623 | |
| 6624 | - $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
|
|
| 6625 | - return true; |
|
| 6626 | - } |
|
| 6624 | + $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
|
|
| 6625 | + return true; |
|
| 6626 | + } |
|
| 6627 | 6627 | |
| 6628 | - return false; |
|
| 6628 | + return false; |
|
| 6629 | 6629 | } |
| 6630 | 6630 | |
| 6631 | 6631 | /** |
@@ -6642,40 +6642,40 @@ discard block |
||
| 6642 | 6642 | * @return bool True for success, False for fail. |
| 6643 | 6643 | */ |
| 6644 | 6644 | function geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang) {
|
| 6645 | - global $sitepress, $wpdb; |
|
| 6646 | - $post_type = get_post_type($master_post_id); |
|
| 6645 | + global $sitepress, $wpdb; |
|
| 6646 | + $post_type = get_post_type($master_post_id); |
|
| 6647 | 6647 | |
| 6648 | - remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6648 | + remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6649 | 6649 | |
| 6650 | - $taxonomies = get_object_taxonomies($post_type); |
|
| 6651 | - foreach ($taxonomies as $taxonomy) {
|
|
| 6652 | - $terms = get_the_terms($master_post_id, $taxonomy); |
|
| 6653 | - $terms_array = array(); |
|
| 6650 | + $taxonomies = get_object_taxonomies($post_type); |
|
| 6651 | + foreach ($taxonomies as $taxonomy) {
|
|
| 6652 | + $terms = get_the_terms($master_post_id, $taxonomy); |
|
| 6653 | + $terms_array = array(); |
|
| 6654 | 6654 | |
| 6655 | - if ($terms) {
|
|
| 6656 | - foreach ($terms as $term) {
|
|
| 6657 | - $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 6655 | + if ($terms) {
|
|
| 6656 | + foreach ($terms as $term) {
|
|
| 6657 | + $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 6658 | 6658 | |
| 6659 | - if (!is_null($tr_id)){
|
|
| 6660 | - // not using get_term - unfiltered get_term |
|
| 6661 | - $translated_term = $wpdb->get_row($wpdb->prepare("
|
|
| 6659 | + if (!is_null($tr_id)){
|
|
| 6660 | + // not using get_term - unfiltered get_term |
|
| 6661 | + $translated_term = $wpdb->get_row($wpdb->prepare("
|
|
| 6662 | 6662 | 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));
|
| 6663 | 6663 | |
| 6664 | - $terms_array[] = $translated_term->term_id; |
|
| 6665 | - } |
|
| 6666 | - } |
|
| 6664 | + $terms_array[] = $translated_term->term_id; |
|
| 6665 | + } |
|
| 6666 | + } |
|
| 6667 | 6667 | |
| 6668 | - if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 6669 | - $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 6670 | - } |
|
| 6668 | + if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 6669 | + $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 6670 | + } |
|
| 6671 | 6671 | |
| 6672 | - wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
|
| 6672 | + wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
|
| 6673 | 6673 | |
| 6674 | - if ($taxonomy == $post_type . 'category') {
|
|
| 6675 | - geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
| 6676 | - } |
|
| 6677 | - } |
|
| 6678 | - } |
|
| 6674 | + if ($taxonomy == $post_type . 'category') {
|
|
| 6675 | + geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
| 6676 | + } |
|
| 6677 | + } |
|
| 6678 | + } |
|
| 6679 | 6679 | } |
| 6680 | 6680 | |
| 6681 | 6681 | /** |
@@ -6691,29 +6691,29 @@ discard block |
||
| 6691 | 6691 | * @return bool True for success, False for fail. |
| 6692 | 6692 | */ |
| 6693 | 6693 | function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
|
| 6694 | - global $wpdb; |
|
| 6694 | + global $wpdb; |
|
| 6695 | 6695 | |
| 6696 | - $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 6697 | - $wpdb->query($query); |
|
| 6696 | + $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 6697 | + $wpdb->query($query); |
|
| 6698 | 6698 | |
| 6699 | - $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));
|
|
| 6700 | - $post_images = $wpdb->get_results($query); |
|
| 6699 | + $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));
|
|
| 6700 | + $post_images = $wpdb->get_results($query); |
|
| 6701 | 6701 | |
| 6702 | - if ( !empty( $post_images ) ) {
|
|
| 6703 | - foreach ( $post_images as $post_image) {
|
|
| 6704 | - $image_data = (array)$post_image; |
|
| 6705 | - unset($image_data['ID']); |
|
| 6706 | - $image_data['post_id'] = $tr_post_id; |
|
| 6702 | + if ( !empty( $post_images ) ) {
|
|
| 6703 | + foreach ( $post_images as $post_image) {
|
|
| 6704 | + $image_data = (array)$post_image; |
|
| 6705 | + unset($image_data['ID']); |
|
| 6706 | + $image_data['post_id'] = $tr_post_id; |
|
| 6707 | 6707 | |
| 6708 | - $wpdb->insert(GEODIR_ATTACHMENT_TABLE, $image_data); |
|
| 6708 | + $wpdb->insert(GEODIR_ATTACHMENT_TABLE, $image_data); |
|
| 6709 | 6709 | |
| 6710 | - geodir_set_wp_featured_image($tr_post_id); |
|
| 6711 | - } |
|
| 6710 | + geodir_set_wp_featured_image($tr_post_id); |
|
| 6711 | + } |
|
| 6712 | 6712 | |
| 6713 | - return true; |
|
| 6714 | - } |
|
| 6713 | + return true; |
|
| 6714 | + } |
|
| 6715 | 6715 | |
| 6716 | - return false; |
|
| 6716 | + return false; |
|
| 6717 | 6717 | } |
| 6718 | 6718 | |
| 6719 | 6719 | /** |
@@ -6727,141 +6727,141 @@ discard block |
||
| 6727 | 6727 | * @return array Event data array. |
| 6728 | 6728 | */ |
| 6729 | 6729 | function geodir_imex_get_event_data($post, $gd_post_info) {
|
| 6730 | - $event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : ''; |
|
| 6731 | - $event_enddate = $event_date; |
|
| 6732 | - $starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : ''; |
|
| 6733 | - $endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : ''; |
|
| 6730 | + $event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : ''; |
|
| 6731 | + $event_enddate = $event_date; |
|
| 6732 | + $starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : ''; |
|
| 6733 | + $endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : ''; |
|
| 6734 | 6734 | |
| 6735 | - $is_recurring_event = ''; |
|
| 6736 | - $event_duration_days = ''; |
|
| 6737 | - $is_whole_day_event = ''; |
|
| 6738 | - $recurring_dates = ''; |
|
| 6739 | - $event_starttimes = ''; |
|
| 6740 | - $event_endtimes = ''; |
|
| 6741 | - $recurring_type = ''; |
|
| 6742 | - $recurring_interval = ''; |
|
| 6743 | - $recurring_week_days = ''; |
|
| 6744 | - $recurring_week_nos = ''; |
|
| 6745 | - $max_recurring_count = ''; |
|
| 6746 | - $recurring_end_date = ''; |
|
| 6747 | - $recurring_dates = ''; |
|
| 6735 | + $is_recurring_event = ''; |
|
| 6736 | + $event_duration_days = ''; |
|
| 6737 | + $is_whole_day_event = ''; |
|
| 6738 | + $recurring_dates = ''; |
|
| 6739 | + $event_starttimes = ''; |
|
| 6740 | + $event_endtimes = ''; |
|
| 6741 | + $recurring_type = ''; |
|
| 6742 | + $recurring_interval = ''; |
|
| 6743 | + $recurring_week_days = ''; |
|
| 6744 | + $recurring_week_nos = ''; |
|
| 6745 | + $max_recurring_count = ''; |
|
| 6746 | + $recurring_end_date = ''; |
|
| 6747 | + $recurring_dates = ''; |
|
| 6748 | 6748 | |
| 6749 | - $recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array(); |
|
| 6750 | - if (!empty($recurring_data)) {
|
|
| 6751 | - $event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date; |
|
| 6752 | - $event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date; |
|
| 6753 | - $starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime; |
|
| 6754 | - $endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime; |
|
| 6755 | - $is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : ''; |
|
| 6756 | - $different_times = !empty($recurring_data['different_times']) ? true : false; |
|
| 6749 | + $recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array(); |
|
| 6750 | + if (!empty($recurring_data)) {
|
|
| 6751 | + $event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date; |
|
| 6752 | + $event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date; |
|
| 6753 | + $starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime; |
|
| 6754 | + $endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime; |
|
| 6755 | + $is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : ''; |
|
| 6756 | + $different_times = !empty($recurring_data['different_times']) ? true : false; |
|
| 6757 | 6757 | |
| 6758 | - $recurring_pkg = geodir_event_recurring_pkg( $gd_post_info ); |
|
| 6759 | - $is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true; |
|
| 6758 | + $recurring_pkg = geodir_event_recurring_pkg( $gd_post_info ); |
|
| 6759 | + $is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true; |
|
| 6760 | 6760 | |
| 6761 | - if ($recurring_pkg && $is_recurring) {
|
|
| 6762 | - $recurring_dates = $event_date; |
|
| 6763 | - $event_enddate = ''; |
|
| 6764 | - $is_recurring_event = 1; |
|
| 6761 | + if ($recurring_pkg && $is_recurring) {
|
|
| 6762 | + $recurring_dates = $event_date; |
|
| 6763 | + $event_enddate = ''; |
|
| 6764 | + $is_recurring_event = 1; |
|
| 6765 | 6765 | |
| 6766 | - $recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
|
|
| 6766 | + $recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
|
|
| 6767 | 6767 | |
| 6768 | - if (!empty($recurring_data['event_recurring_dates'])) {
|
|
| 6769 | - $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 6768 | + if (!empty($recurring_data['event_recurring_dates'])) {
|
|
| 6769 | + $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 6770 | 6770 | |
| 6771 | - if (!empty($event_recurring_dates)) {
|
|
| 6772 | - $recurring_dates = array(); |
|
| 6771 | + if (!empty($event_recurring_dates)) {
|
|
| 6772 | + $recurring_dates = array(); |
|
| 6773 | 6773 | |
| 6774 | - foreach ($event_recurring_dates as $date) {
|
|
| 6775 | - $recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) ); |
|
| 6776 | - } |
|
| 6774 | + foreach ($event_recurring_dates as $date) {
|
|
| 6775 | + $recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) ); |
|
| 6776 | + } |
|
| 6777 | 6777 | |
| 6778 | - $recurring_dates = implode(",", $recurring_dates);
|
|
| 6779 | - } |
|
| 6780 | - } |
|
| 6778 | + $recurring_dates = implode(",", $recurring_dates);
|
|
| 6779 | + } |
|
| 6780 | + } |
|
| 6781 | 6781 | |
| 6782 | - if ($recurring_type == 'custom') {
|
|
| 6783 | - if (!$is_whole_day_event) {
|
|
| 6784 | - $event_starttimes = $starttime; |
|
| 6785 | - $event_endtimes = $endtime; |
|
| 6782 | + if ($recurring_type == 'custom') {
|
|
| 6783 | + if (!$is_whole_day_event) {
|
|
| 6784 | + $event_starttimes = $starttime; |
|
| 6785 | + $event_endtimes = $endtime; |
|
| 6786 | 6786 | |
| 6787 | - if (!empty($recurring_data['starttimes'])) {
|
|
| 6788 | - $times = array(); |
|
| 6787 | + if (!empty($recurring_data['starttimes'])) {
|
|
| 6788 | + $times = array(); |
|
| 6789 | 6789 | |
| 6790 | - foreach ($recurring_data['starttimes'] as $time) {
|
|
| 6791 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6792 | - } |
|
| 6790 | + foreach ($recurring_data['starttimes'] as $time) {
|
|
| 6791 | + $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6792 | + } |
|
| 6793 | 6793 | |
| 6794 | - $event_starttimes = implode(",", $times);
|
|
| 6795 | - } |
|
| 6794 | + $event_starttimes = implode(",", $times);
|
|
| 6795 | + } |
|
| 6796 | 6796 | |
| 6797 | - if (!empty($recurring_data['endtimes'])) {
|
|
| 6798 | - $times = array(); |
|
| 6797 | + if (!empty($recurring_data['endtimes'])) {
|
|
| 6798 | + $times = array(); |
|
| 6799 | 6799 | |
| 6800 | - foreach ($recurring_data['endtimes'] as $time) {
|
|
| 6801 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6802 | - } |
|
| 6800 | + foreach ($recurring_data['endtimes'] as $time) {
|
|
| 6801 | + $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6802 | + } |
|
| 6803 | 6803 | |
| 6804 | - $event_endtimes = implode(",", $times);
|
|
| 6805 | - } |
|
| 6804 | + $event_endtimes = implode(",", $times);
|
|
| 6805 | + } |
|
| 6806 | 6806 | |
| 6807 | - if (!$different_times) {
|
|
| 6808 | - $event_starttimes = ''; |
|
| 6809 | - $event_endtimes = ''; |
|
| 6810 | - } |
|
| 6811 | - } |
|
| 6812 | - } else {
|
|
| 6813 | - $event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1; |
|
| 6814 | - $recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6807 | + if (!$different_times) {
|
|
| 6808 | + $event_starttimes = ''; |
|
| 6809 | + $event_endtimes = ''; |
|
| 6810 | + } |
|
| 6811 | + } |
|
| 6812 | + } else {
|
|
| 6813 | + $event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1; |
|
| 6814 | + $recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6815 | 6815 | |
| 6816 | - if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
|
|
| 6817 | - $week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
|
| 6816 | + if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
|
|
| 6817 | + $week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
|
| 6818 | 6818 | |
| 6819 | - $days = array(); |
|
| 6820 | - foreach ($recurring_data['repeat_days'] as $day) {
|
|
| 6821 | - if (isset($week_days[$day])) {
|
|
| 6822 | - $days[] = $week_days[$day]; |
|
| 6823 | - } |
|
| 6824 | - } |
|
| 6819 | + $days = array(); |
|
| 6820 | + foreach ($recurring_data['repeat_days'] as $day) {
|
|
| 6821 | + if (isset($week_days[$day])) {
|
|
| 6822 | + $days[] = $week_days[$day]; |
|
| 6823 | + } |
|
| 6824 | + } |
|
| 6825 | 6825 | |
| 6826 | - $recurring_week_days = implode(",", array_unique($days));
|
|
| 6827 | - } |
|
| 6826 | + $recurring_week_days = implode(",", array_unique($days));
|
|
| 6827 | + } |
|
| 6828 | 6828 | |
| 6829 | - $recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
|
|
| 6830 | - if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
|
|
| 6831 | - $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : ''; |
|
| 6832 | - $max_recurring_count = empty($recurring_end_date) ? 1 : ''; |
|
| 6833 | - } else {
|
|
| 6834 | - $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1); |
|
| 6835 | - } |
|
| 6836 | - } |
|
| 6837 | - } |
|
| 6838 | - } |
|
| 6839 | - if ($is_whole_day_event) {
|
|
| 6840 | - $starttime = ''; |
|
| 6841 | - $endtime = ''; |
|
| 6842 | - $event_starttimes = ''; |
|
| 6843 | - $event_endtimes = ''; |
|
| 6844 | - } |
|
| 6829 | + $recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
|
|
| 6830 | + if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
|
|
| 6831 | + $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : ''; |
|
| 6832 | + $max_recurring_count = empty($recurring_end_date) ? 1 : ''; |
|
| 6833 | + } else {
|
|
| 6834 | + $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1); |
|
| 6835 | + } |
|
| 6836 | + } |
|
| 6837 | + } |
|
| 6838 | + } |
|
| 6839 | + if ($is_whole_day_event) {
|
|
| 6840 | + $starttime = ''; |
|
| 6841 | + $endtime = ''; |
|
| 6842 | + $event_starttimes = ''; |
|
| 6843 | + $event_endtimes = ''; |
|
| 6844 | + } |
|
| 6845 | 6845 | |
| 6846 | - $data = array(); |
|
| 6847 | - $data['event_date'] = $event_date; |
|
| 6848 | - $data['event_enddate'] = $event_enddate; |
|
| 6849 | - $data['starttime'] = $starttime; |
|
| 6850 | - $data['endtime'] = $endtime; |
|
| 6851 | - $data['is_recurring_event'] = $is_recurring_event; |
|
| 6852 | - $data['recurring_dates'] = $recurring_dates; |
|
| 6853 | - $data['event_duration_days'] = $event_duration_days; |
|
| 6854 | - $data['is_whole_day_event'] = $is_whole_day_event; |
|
| 6855 | - $data['event_starttimes'] = $event_starttimes; |
|
| 6856 | - $data['event_endtimes'] = $event_endtimes; |
|
| 6857 | - $data['recurring_type'] = $recurring_type; |
|
| 6858 | - $data['recurring_interval'] = $recurring_interval; |
|
| 6859 | - $data['recurring_week_days'] = $recurring_week_days; |
|
| 6860 | - $data['recurring_week_nos'] = $recurring_week_nos; |
|
| 6861 | - $data['max_recurring_count'] = $max_recurring_count; |
|
| 6862 | - $data['recurring_end_date'] = $recurring_end_date; |
|
| 6846 | + $data = array(); |
|
| 6847 | + $data['event_date'] = $event_date; |
|
| 6848 | + $data['event_enddate'] = $event_enddate; |
|
| 6849 | + $data['starttime'] = $starttime; |
|
| 6850 | + $data['endtime'] = $endtime; |
|
| 6851 | + $data['is_recurring_event'] = $is_recurring_event; |
|
| 6852 | + $data['recurring_dates'] = $recurring_dates; |
|
| 6853 | + $data['event_duration_days'] = $event_duration_days; |
|
| 6854 | + $data['is_whole_day_event'] = $is_whole_day_event; |
|
| 6855 | + $data['event_starttimes'] = $event_starttimes; |
|
| 6856 | + $data['event_endtimes'] = $event_endtimes; |
|
| 6857 | + $data['recurring_type'] = $recurring_type; |
|
| 6858 | + $data['recurring_interval'] = $recurring_interval; |
|
| 6859 | + $data['recurring_week_days'] = $recurring_week_days; |
|
| 6860 | + $data['recurring_week_nos'] = $recurring_week_nos; |
|
| 6861 | + $data['max_recurring_count'] = $max_recurring_count; |
|
| 6862 | + $data['recurring_end_date'] = $recurring_end_date; |
|
| 6863 | 6863 | |
| 6864 | - return $data; |
|
| 6864 | + return $data; |
|
| 6865 | 6865 | } |
| 6866 | 6866 | |
| 6867 | 6867 | /** |
@@ -6877,12 +6877,12 @@ discard block |
||
| 6877 | 6877 | * @return doesn't Date. |
| 6878 | 6878 | */ |
| 6879 | 6879 | function geodir_imex_get_date_ymd($date) {
|
| 6880 | - if (strpos($date, '/') !== false) {
|
|
| 6881 | - $date = str_replace('/', '-', $date); // PHP doesn't work well with dd/mm/yyyy format.
|
|
| 6882 | - } |
|
| 6880 | + if (strpos($date, '/') !== false) {
|
|
| 6881 | + $date = str_replace('/', '-', $date); // PHP doesn't work well with dd/mm/yyyy format.
|
|
| 6882 | + } |
|
| 6883 | 6883 | |
| 6884 | - $date = date_i18n('Y-m-d', strtotime($date));
|
|
| 6885 | - return $date; |
|
| 6884 | + $date = date_i18n('Y-m-d', strtotime($date));
|
|
| 6885 | + return $date; |
|
| 6886 | 6886 | } |
| 6887 | 6887 | |
| 6888 | 6888 | /** |
@@ -6895,117 +6895,117 @@ discard block |
||
| 6895 | 6895 | * @return array Event data array. |
| 6896 | 6896 | */ |
| 6897 | 6897 | function geodir_imex_process_event_data($gd_post) {
|
| 6898 | - $recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post ); |
|
| 6899 | - |
|
| 6900 | - $is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6901 | - $event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : ''; |
|
| 6902 | - $event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date; |
|
| 6903 | - $all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false; |
|
| 6904 | - $starttime = isset($gd_post['starttime']) && !$all_day ? $gd_post['starttime'] : ''; |
|
| 6905 | - $endtime = isset($gd_post['endtime']) && !$all_day ? $gd_post['endtime'] : ''; |
|
| 6898 | + $recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post ); |
|
| 6899 | + |
|
| 6900 | + $is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6901 | + $event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : ''; |
|
| 6902 | + $event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date; |
|
| 6903 | + $all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false; |
|
| 6904 | + $starttime = isset($gd_post['starttime']) && !$all_day ? $gd_post['starttime'] : ''; |
|
| 6905 | + $endtime = isset($gd_post['endtime']) && !$all_day ? $gd_post['endtime'] : ''; |
|
| 6906 | 6906 | |
| 6907 | - $repeat_type = ''; |
|
| 6908 | - $different_times = ''; |
|
| 6909 | - $starttimes = ''; |
|
| 6910 | - $endtimes = ''; |
|
| 6911 | - $repeat_days = ''; |
|
| 6912 | - $repeat_weeks = ''; |
|
| 6913 | - $event_recurring_dates = ''; |
|
| 6914 | - $repeat_x = ''; |
|
| 6915 | - $duration_x = ''; |
|
| 6916 | - $repeat_end_type = ''; |
|
| 6917 | - $max_repeat = ''; |
|
| 6918 | - $repeat_end = ''; |
|
| 6907 | + $repeat_type = ''; |
|
| 6908 | + $different_times = ''; |
|
| 6909 | + $starttimes = ''; |
|
| 6910 | + $endtimes = ''; |
|
| 6911 | + $repeat_days = ''; |
|
| 6912 | + $repeat_weeks = ''; |
|
| 6913 | + $event_recurring_dates = ''; |
|
| 6914 | + $repeat_x = ''; |
|
| 6915 | + $duration_x = ''; |
|
| 6916 | + $repeat_end_type = ''; |
|
| 6917 | + $max_repeat = ''; |
|
| 6918 | + $repeat_end = ''; |
|
| 6919 | 6919 | |
| 6920 | - if ($recurring_pkg && $is_recurring) {
|
|
| 6921 | - $repeat_type = $gd_post['recurring_type']; |
|
| 6920 | + if ($recurring_pkg && $is_recurring) {
|
|
| 6921 | + $repeat_type = $gd_post['recurring_type']; |
|
| 6922 | 6922 | |
| 6923 | - if ($repeat_type == 'custom') {
|
|
| 6924 | - $starttimes = !$all_day && !empty($gd_post['event_starttimes']) ? explode(",", $gd_post['event_starttimes']) : array();
|
|
| 6925 | - $endtimes = !$all_day && !empty($gd_post['event_endtimes']) ? explode(",", $gd_post['event_endtimes']) : array();
|
|
| 6923 | + if ($repeat_type == 'custom') {
|
|
| 6924 | + $starttimes = !$all_day && !empty($gd_post['event_starttimes']) ? explode(",", $gd_post['event_starttimes']) : array();
|
|
| 6925 | + $endtimes = !$all_day && !empty($gd_post['event_endtimes']) ? explode(",", $gd_post['event_endtimes']) : array();
|
|
| 6926 | 6926 | |
| 6927 | - if (!empty($starttimes) || !empty($endtimes)) {
|
|
| 6928 | - $different_times = true; |
|
| 6929 | - } |
|
| 6927 | + if (!empty($starttimes) || !empty($endtimes)) {
|
|
| 6928 | + $different_times = true; |
|
| 6929 | + } |
|
| 6930 | 6930 | |
| 6931 | - $recurring_dates = isset($gd_post['recurring_dates']) && $gd_post['recurring_dates'] != '' ? explode(",", $gd_post['recurring_dates']) : array();
|
|
| 6932 | - if (!empty($recurring_dates)) {
|
|
| 6933 | - $event_recurring_dates = array(); |
|
| 6931 | + $recurring_dates = isset($gd_post['recurring_dates']) && $gd_post['recurring_dates'] != '' ? explode(",", $gd_post['recurring_dates']) : array();
|
|
| 6932 | + if (!empty($recurring_dates)) {
|
|
| 6933 | + $event_recurring_dates = array(); |
|
| 6934 | 6934 | |
| 6935 | - foreach ($recurring_dates as $recurring_date) {
|
|
| 6936 | - $recurring_date = trim($recurring_date); |
|
| 6935 | + foreach ($recurring_dates as $recurring_date) {
|
|
| 6936 | + $recurring_date = trim($recurring_date); |
|
| 6937 | 6937 | |
| 6938 | - if ($recurring_date != '') {
|
|
| 6939 | - $event_recurring_dates[] = geodir_imex_get_date_ymd($recurring_date); |
|
| 6940 | - } |
|
| 6941 | - } |
|
| 6938 | + if ($recurring_date != '') {
|
|
| 6939 | + $event_recurring_dates[] = geodir_imex_get_date_ymd($recurring_date); |
|
| 6940 | + } |
|
| 6941 | + } |
|
| 6942 | 6942 | |
| 6943 | - $event_recurring_dates = array_unique($event_recurring_dates); |
|
| 6944 | - $event_recurring_dates = implode(",", $event_recurring_dates);
|
|
| 6945 | - } |
|
| 6946 | - } else {
|
|
| 6947 | - $duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1; |
|
| 6948 | - $repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1; |
|
| 6949 | - $max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1; |
|
| 6950 | - $repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6943 | + $event_recurring_dates = array_unique($event_recurring_dates); |
|
| 6944 | + $event_recurring_dates = implode(",", $event_recurring_dates);
|
|
| 6945 | + } |
|
| 6946 | + } else {
|
|
| 6947 | + $duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1; |
|
| 6948 | + $repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1; |
|
| 6949 | + $max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1; |
|
| 6950 | + $repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6951 | 6951 | |
| 6952 | - $repeat_end_type = $repeat_end != '' ? 1 : 0; |
|
| 6953 | - $max_repeat = $repeat_end != '' ? '' : $max_repeat; |
|
| 6952 | + $repeat_end_type = $repeat_end != '' ? 1 : 0; |
|
| 6953 | + $max_repeat = $repeat_end != '' ? '' : $max_repeat; |
|
| 6954 | 6954 | |
| 6955 | - $week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
|
|
| 6955 | + $week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
|
|
| 6956 | 6956 | |
| 6957 | - $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6958 | - $repeat_days = array(); |
|
| 6959 | - if (!empty($a_repeat_days)) {
|
|
| 6960 | - foreach ($a_repeat_days as $repeat_day) {
|
|
| 6961 | - $repeat_day = geodir_strtolower(trim($repeat_day)); |
|
| 6957 | + $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6958 | + $repeat_days = array(); |
|
| 6959 | + if (!empty($a_repeat_days)) {
|
|
| 6960 | + foreach ($a_repeat_days as $repeat_day) {
|
|
| 6961 | + $repeat_day = geodir_strtolower(trim($repeat_day)); |
|
| 6962 | 6962 | |
| 6963 | - if ($repeat_day != '' && isset($week_days[$repeat_day])) {
|
|
| 6964 | - $repeat_days[] = $week_days[$repeat_day]; |
|
| 6965 | - } |
|
| 6966 | - } |
|
| 6963 | + if ($repeat_day != '' && isset($week_days[$repeat_day])) {
|
|
| 6964 | + $repeat_days[] = $week_days[$repeat_day]; |
|
| 6965 | + } |
|
| 6966 | + } |
|
| 6967 | 6967 | |
| 6968 | - $repeat_days = array_unique($repeat_days); |
|
| 6969 | - } |
|
| 6968 | + $repeat_days = array_unique($repeat_days); |
|
| 6969 | + } |
|
| 6970 | 6970 | |
| 6971 | - $a_repeat_weeks = isset($gd_post['recurring_week_nos']) && trim($gd_post['recurring_week_nos']) != '' ? explode(",", trim($gd_post['recurring_week_nos'])) : array();
|
|
| 6972 | - $repeat_weeks = array(); |
|
| 6973 | - if (!empty($a_repeat_weeks)) {
|
|
| 6974 | - foreach ($a_repeat_weeks as $repeat_week) {
|
|
| 6975 | - $repeat_weeks[] = (int)$repeat_week; |
|
| 6976 | - } |
|
| 6971 | + $a_repeat_weeks = isset($gd_post['recurring_week_nos']) && trim($gd_post['recurring_week_nos']) != '' ? explode(",", trim($gd_post['recurring_week_nos'])) : array();
|
|
| 6972 | + $repeat_weeks = array(); |
|
| 6973 | + if (!empty($a_repeat_weeks)) {
|
|
| 6974 | + foreach ($a_repeat_weeks as $repeat_week) {
|
|
| 6975 | + $repeat_weeks[] = (int)$repeat_week; |
|
| 6976 | + } |
|
| 6977 | 6977 | |
| 6978 | - $repeat_weeks = array_unique($repeat_weeks); |
|
| 6979 | - } |
|
| 6980 | - } |
|
| 6981 | - } |
|
| 6978 | + $repeat_weeks = array_unique($repeat_weeks); |
|
| 6979 | + } |
|
| 6980 | + } |
|
| 6981 | + } |
|
| 6982 | 6982 | |
| 6983 | - if (isset($gd_post['recurring_dates'])) {
|
|
| 6984 | - unset($gd_post['recurring_dates']); |
|
| 6985 | - } |
|
| 6983 | + if (isset($gd_post['recurring_dates'])) {
|
|
| 6984 | + unset($gd_post['recurring_dates']); |
|
| 6985 | + } |
|
| 6986 | 6986 | |
| 6987 | - $gd_post['is_recurring'] = $is_recurring; |
|
| 6988 | - $gd_post['event_date'] = $event_date; |
|
| 6989 | - $gd_post['event_start'] = $event_date; |
|
| 6990 | - $gd_post['event_end'] = $event_enddate; |
|
| 6991 | - $gd_post['all_day'] = $all_day; |
|
| 6992 | - $gd_post['starttime'] = $starttime; |
|
| 6993 | - $gd_post['endtime'] = $endtime; |
|
| 6987 | + $gd_post['is_recurring'] = $is_recurring; |
|
| 6988 | + $gd_post['event_date'] = $event_date; |
|
| 6989 | + $gd_post['event_start'] = $event_date; |
|
| 6990 | + $gd_post['event_end'] = $event_enddate; |
|
| 6991 | + $gd_post['all_day'] = $all_day; |
|
| 6992 | + $gd_post['starttime'] = $starttime; |
|
| 6993 | + $gd_post['endtime'] = $endtime; |
|
| 6994 | 6994 | |
| 6995 | - $gd_post['repeat_type'] = $repeat_type; |
|
| 6996 | - $gd_post['different_times'] = $different_times; |
|
| 6997 | - $gd_post['starttimes'] = $starttimes; |
|
| 6998 | - $gd_post['endtimes'] = $endtimes; |
|
| 6999 | - $gd_post['repeat_days'] = $repeat_days; |
|
| 7000 | - $gd_post['repeat_weeks'] = $repeat_weeks; |
|
| 7001 | - $gd_post['event_recurring_dates'] = $event_recurring_dates; |
|
| 7002 | - $gd_post['repeat_x'] = $repeat_x; |
|
| 7003 | - $gd_post['duration_x'] = $duration_x; |
|
| 7004 | - $gd_post['repeat_end_type'] = $repeat_end_type; |
|
| 7005 | - $gd_post['max_repeat'] = $max_repeat; |
|
| 7006 | - $gd_post['repeat_end'] = $repeat_end; |
|
| 7007 | - |
|
| 7008 | - return $gd_post; |
|
| 6995 | + $gd_post['repeat_type'] = $repeat_type; |
|
| 6996 | + $gd_post['different_times'] = $different_times; |
|
| 6997 | + $gd_post['starttimes'] = $starttimes; |
|
| 6998 | + $gd_post['endtimes'] = $endtimes; |
|
| 6999 | + $gd_post['repeat_days'] = $repeat_days; |
|
| 7000 | + $gd_post['repeat_weeks'] = $repeat_weeks; |
|
| 7001 | + $gd_post['event_recurring_dates'] = $event_recurring_dates; |
|
| 7002 | + $gd_post['repeat_x'] = $repeat_x; |
|
| 7003 | + $gd_post['duration_x'] = $duration_x; |
|
| 7004 | + $gd_post['repeat_end_type'] = $repeat_end_type; |
|
| 7005 | + $gd_post['max_repeat'] = $max_repeat; |
|
| 7006 | + $gd_post['repeat_end'] = $repeat_end; |
|
| 7007 | + |
|
| 7008 | + return $gd_post; |
|
| 7009 | 7009 | } |
| 7010 | 7010 | |
| 7011 | 7011 | /** |
@@ -7077,12 +7077,12 @@ discard block |
||
| 7077 | 7077 | * @return Original element id. |
| 7078 | 7078 | */ |
| 7079 | 7079 | function geodir_imex_original_post_id($element_id, $element_type) {
|
| 7080 | - global $sitepress; |
|
| 7080 | + global $sitepress; |
|
| 7081 | 7081 | |
| 7082 | - $original_element_id = $sitepress->get_original_element_id($element_id, $element_type); |
|
| 7083 | - $element_id = $element_id != $original_element_id ? $original_element_id : ''; |
|
| 7082 | + $original_element_id = $sitepress->get_original_element_id($element_id, $element_type); |
|
| 7083 | + $element_id = $element_id != $original_element_id ? $original_element_id : ''; |
|
| 7084 | 7084 | |
| 7085 | - return $element_id; |
|
| 7085 | + return $element_id; |
|
| 7086 | 7086 | } |
| 7087 | 7087 | |
| 7088 | 7088 | /* |
@@ -7162,15 +7162,15 @@ discard block |
||
| 7162 | 7162 | * @global object $sitepress Sitepress WPML object. |
| 7163 | 7163 | */ |
| 7164 | 7164 | function geodir_wpml_permalink_setting_notice() {
|
| 7165 | - if (geodir_is_wpml()) {
|
|
| 7166 | - global $sitepress; |
|
| 7167 | - $current_language = $sitepress->get_current_language(); |
|
| 7168 | - $default_language = $sitepress->get_default_language(); |
|
| 7169 | - if ($current_language != 'all' && $current_language != $default_language) {
|
|
| 7170 | - ?> |
|
| 7165 | + if (geodir_is_wpml()) {
|
|
| 7166 | + global $sitepress; |
|
| 7167 | + $current_language = $sitepress->get_current_language(); |
|
| 7168 | + $default_language = $sitepress->get_default_language(); |
|
| 7169 | + if ($current_language != 'all' && $current_language != $default_language) {
|
|
| 7170 | + ?> |
|
| 7171 | 7171 | <div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory');?></strong></p></div>
|
| 7172 | 7172 | <?php |
| 7173 | - } |
|
| 7174 | - } |
|
| 7173 | + } |
|
| 7174 | + } |
|
| 7175 | 7175 | } |
| 7176 | 7176 | ?> |
| 7177 | 7177 | \ No newline at end of file |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Design tab settings. |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - * @global array $geodir_settings Geodirectory settings array. |
|
| 8 | - */ |
|
| 3 | + * Design tab settings. |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + * @global array $geodir_settings Geodirectory settings array. |
|
| 8 | + */ |
|
| 9 | 9 | global $geodir_settings; |
| 10 | 10 | |
| 11 | 11 | |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | return $post_type_arr; |
| 49 | 49 | } |
| 50 | 50 | /** |
| 51 | - * Filter GD design settings array. |
|
| 52 | - * |
|
| 53 | - * @since 1.0.0 |
|
| 54 | - * @package GeoDirectory |
|
| 55 | - */ |
|
| 51 | + * Filter GD design settings array. |
|
| 52 | + * |
|
| 53 | + * @since 1.0.0 |
|
| 54 | + * @package GeoDirectory |
|
| 55 | + */ |
|
| 56 | 56 | $geodir_settings['design_settings'] = apply_filters('geodir_design_settings', array(
|
| 57 | 57 | |
| 58 | 58 | /* Home Layout Settings start */ |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | 'std' => '0' // Default value to show home top section |
| 413 | 413 | ), |
| 414 | 414 | |
| 415 | - array( |
|
| 415 | + array( |
|
| 416 | 416 | 'name' => __('Show advanced pagination details', 'geodirectory'),
|
| 417 | 417 | 'desc' => __('This will add extra pagination info like "Showing listings x-y of z" aftre/before pagination.', 'geodirectory'),
|
| 418 | 418 | 'id' => 'geodir_pagination_advance_info', |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | 'type' => 'select', |
| 422 | 422 | 'class' => 'chosen_select', |
| 423 | 423 | 'options' => array( |
| 424 | - '' => __('Never Display', 'geodirectory'),
|
|
| 425 | - 'after' => __('After Pagination', 'geodirectory'),
|
|
| 426 | - 'before' => __('Before Pagination', 'geodirectory')
|
|
| 427 | - ) |
|
| 424 | + '' => __('Never Display', 'geodirectory'),
|
|
| 425 | + 'after' => __('After Pagination', 'geodirectory'),
|
|
| 426 | + 'before' => __('Before Pagination', 'geodirectory')
|
|
| 427 | + ) |
|
| 428 | 428 | ), |
| 429 | 429 | |
| 430 | 430 | array('type' => 'sectionend', 'id' => 'geodir_search_layout'),
|
@@ -577,20 +577,20 @@ discard block |
||
| 577 | 577 | 'std' => '0', |
| 578 | 578 | 'value' => geodir_plugin_url() . '/geodirectory-assets/images/stars.png'// Default value to show home top section |
| 579 | 579 | ), |
| 580 | - array( |
|
| 581 | - 'name' => __('Enable Font Awesome', 'geodirectory'),
|
|
| 582 | - 'desc' => __('When enabled all rating images will be using font awesome rating icons as images.', 'geodirectory' ),
|
|
| 583 | - 'id' => 'geodir_reviewrating_enable_font_awesome', |
|
| 584 | - 'type' => 'checkbox', |
|
| 585 | - 'std' => '0' |
|
| 586 | - ), |
|
| 587 | - array( |
|
| 588 | - 'name' => __('Rating Icon Color', 'geodirectory'),
|
|
| 589 | - 'desc' => __('Enter hexadecimal color for font awesome rating icons. Default: #757575', 'geodirectory'),
|
|
| 590 | - 'id' => 'geodir_reviewrating_fa_full_rating_color', |
|
| 591 | - 'type' => 'color', |
|
| 592 | - 'std' => '#757575' |
|
| 593 | - ), |
|
| 580 | + array( |
|
| 581 | + 'name' => __('Enable Font Awesome', 'geodirectory'),
|
|
| 582 | + 'desc' => __('When enabled all rating images will be using font awesome rating icons as images.', 'geodirectory' ),
|
|
| 583 | + 'id' => 'geodir_reviewrating_enable_font_awesome', |
|
| 584 | + 'type' => 'checkbox', |
|
| 585 | + 'std' => '0' |
|
| 586 | + ), |
|
| 587 | + array( |
|
| 588 | + 'name' => __('Rating Icon Color', 'geodirectory'),
|
|
| 589 | + 'desc' => __('Enter hexadecimal color for font awesome rating icons. Default: #757575', 'geodirectory'),
|
|
| 590 | + 'id' => 'geodir_reviewrating_fa_full_rating_color', |
|
| 591 | + 'type' => 'color', |
|
| 592 | + 'std' => '#757575' |
|
| 593 | + ), |
|
| 594 | 594 | |
| 595 | 595 | array('type' => 'sectionend', 'id' => 'geodir_detail_page_tab_settings'),
|
| 596 | 596 | |
@@ -579,7 +579,7 @@ |
||
| 579 | 579 | ), |
| 580 | 580 | array( |
| 581 | 581 | 'name' => __('Enable Font Awesome', 'geodirectory'),
|
| 582 | - 'desc' => __('When enabled all rating images will be using font awesome rating icons as images.', 'geodirectory' ),
|
|
| 582 | + 'desc' => __('When enabled all rating images will be using font awesome rating icons as images.', 'geodirectory'),
|
|
| 583 | 583 | 'id' => 'geodir_reviewrating_enable_font_awesome', |
| 584 | 584 | 'type' => 'checkbox', |
| 585 | 585 | 'std' => '0' |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Comment related functions. |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Comment related functions. |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | add_filter('comment_row_actions', 'geodir_comment_meta_row_action', 11, 1);
|
| 10 | 10 | /** |
@@ -68,28 +68,28 @@ discard block |
||
| 68 | 68 | function geodir_comment_rating_meta($comment) |
| 69 | 69 | {
|
| 70 | 70 | $post_type = get_post_type($comment->comment_post_ID); |
| 71 | - if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0) {
|
|
| 72 | - $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 71 | + if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0) {
|
|
| 72 | + $rating = geodir_get_commentoverall($comment->comment_ID); |
|
| 73 | 73 | |
| 74 | - if ((int)get_option('geodir_reviewrating_enable_font_awesome') == 1) {
|
|
| 75 | - $star_texts = array(); |
|
| 76 | - $star_texts[] = __('Terrible', 'geodirectory');
|
|
| 77 | - $star_texts[] = __('Poor', 'geodirectory');
|
|
| 78 | - $star_texts[] = __('Average', 'geodirectory');
|
|
| 79 | - $star_texts[] = __('Very Good', 'geodirectory');
|
|
| 80 | - $star_texts[] = __('Excellent', 'geodirectory');
|
|
| 74 | + if ((int)get_option('geodir_reviewrating_enable_font_awesome') == 1) {
|
|
| 75 | + $star_texts = array(); |
|
| 76 | + $star_texts[] = __('Terrible', 'geodirectory');
|
|
| 77 | + $star_texts[] = __('Poor', 'geodirectory');
|
|
| 78 | + $star_texts[] = __('Average', 'geodirectory');
|
|
| 79 | + $star_texts[] = __('Very Good', 'geodirectory');
|
|
| 80 | + $star_texts[] = __('Excellent', 'geodirectory');
|
|
| 81 | 81 | |
| 82 | - echo geodir_font_awesome_rating_form_html('', $star_texts, $rating);
|
|
| 83 | - } else {
|
|
| 84 | - if ($rating) {
|
|
| 85 | - echo '<div class="gd_rating" data-average="' . $rating . '" data-id="5">'; |
|
| 86 | - |
|
| 87 | - } else {
|
|
| 88 | - echo '<div class="gd_rating" data-average="0" data-id="5"></div>'; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="' . $rating . '" />'; |
|
| 92 | - } |
|
| 82 | + echo geodir_font_awesome_rating_form_html('', $star_texts, $rating);
|
|
| 83 | + } else {
|
|
| 84 | + if ($rating) {
|
|
| 85 | + echo '<div class="gd_rating" data-average="' . $rating . '" data-id="5">'; |
|
| 86 | + |
|
| 87 | + } else {
|
|
| 88 | + echo '<div class="gd_rating" data-average="0" data-id="5"></div>'; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="' . $rating . '" />'; |
|
| 92 | + } |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | if (in_array($post->post_type, $post_types)) {
|
| 115 | 115 | $star_texts = array(); |
| 116 | - $star_texts[] = __('Terrible', 'geodirectory');
|
|
| 117 | - $star_texts[] = __('Poor', 'geodirectory');
|
|
| 118 | - $star_texts[] = __('Average', 'geodirectory');
|
|
| 119 | - $star_texts[] = __('Very Good', 'geodirectory');
|
|
| 120 | - $star_texts[] = __('Excellent', 'geodirectory');
|
|
| 116 | + $star_texts[] = __('Terrible', 'geodirectory');
|
|
| 117 | + $star_texts[] = __('Poor', 'geodirectory');
|
|
| 118 | + $star_texts[] = __('Average', 'geodirectory');
|
|
| 119 | + $star_texts[] = __('Very Good', 'geodirectory');
|
|
| 120 | + $star_texts[] = __('Excellent', 'geodirectory');
|
|
| 121 | 121 | |
| 122 | - $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
|
|
| 122 | + $gd_rating_html = apply_filters('gd_rating_form_html', '<div class="gd_rating" data-average="0" data-id="5"></div>', $star_texts);
|
|
| 123 | 123 | echo $gd_rating_html; |
| 124 | 124 | ?> |
| 125 | 125 | <input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="0"/><?php |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | if (isset($_REQUEST['geodir_overallrating'])) {
|
| 194 | 194 | $overall_rating = $_REQUEST['geodir_overallrating']; |
| 195 | 195 | |
| 196 | - if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 196 | + if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 197 | 197 | $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
| 198 | 198 | |
| 199 | 199 | $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
|
@@ -914,23 +914,23 @@ discard block |
||
| 914 | 914 | if ($small) {
|
| 915 | 915 | $r_html = '<div class="rating"><div class="gd_rating_map" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingColor" ></div><div class="geodir_RatingAverage_small" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star_small"></div></div></div>'; |
| 916 | 916 | } else {
|
| 917 | - if (function_exists('geodir_reviewrating_draw_overall_rating')) {
|
|
| 918 | - // Show rating stars from review rating manager |
|
| 919 | - $r_html = geodir_reviewrating_draw_overall_rating($rating); |
|
| 920 | - } else {
|
|
| 921 | - $rating_img = '<img alt="rating icon" src="' . get_option('geodir_default_rating_star_icon') . '" />';
|
|
| 917 | + if (function_exists('geodir_reviewrating_draw_overall_rating')) {
|
|
| 918 | + // Show rating stars from review rating manager |
|
| 919 | + $r_html = geodir_reviewrating_draw_overall_rating($rating); |
|
| 920 | + } else {
|
|
| 921 | + $rating_img = '<img alt="rating icon" src="' . get_option('geodir_default_rating_star_icon') . '" />';
|
|
| 922 | 922 | |
| 923 | - /* fix rating star for safari */ |
|
| 924 | - $star_width = 23 * 5; |
|
| 925 | - //global $is_safari, $is_iphone, $ios, $is_chrome; |
|
| 926 | - //$attach_style = ( $is_safari || $is_iphone || $ios || $is_chrome ) && $star_width > 0 ? 'width:' . $star_width . 'px;max-width:none' : ''; |
|
| 927 | - if ($star_width > 0) {
|
|
| 928 | - $attach_style = 'max-width:' . $star_width . 'px'; |
|
| 929 | - } else {
|
|
| 930 | - $attach_style = ''; |
|
| 931 | - } |
|
| 932 | - $r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>'; |
|
| 933 | - } |
|
| 923 | + /* fix rating star for safari */ |
|
| 924 | + $star_width = 23 * 5; |
|
| 925 | + //global $is_safari, $is_iphone, $ios, $is_chrome; |
|
| 926 | + //$attach_style = ( $is_safari || $is_iphone || $ios || $is_chrome ) && $star_width > 0 ? 'width:' . $star_width . 'px;max-width:none' : ''; |
|
| 927 | + if ($star_width > 0) {
|
|
| 928 | + $attach_style = 'max-width:' . $star_width . 'px'; |
|
| 929 | + } else {
|
|
| 930 | + $attach_style = ''; |
|
| 931 | + } |
|
| 932 | + $r_html = '<div class="geodir-rating" style="' . $attach_style . '"><div class="gd_rating_show" data-average="' . $rating . '" data-id="' . $post_id . '"><div class="geodir_RatingAverage" style="width: ' . $a_rating . '%;"></div><div class="geodir_Star">' . $rating_img . $rating_img . $rating_img . $rating_img . $rating_img . '</div></div></div>'; |
|
| 933 | + } |
|
| 934 | 934 | } |
| 935 | 935 | return apply_filters('geodir_get_rating_stars_html', $r_html, $rating, 5);
|
| 936 | 936 | } |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | function geodir_comment_rating_meta($comment) |
| 69 | 69 | {
|
| 70 | 70 | $post_type = get_post_type($comment->comment_post_ID); |
| 71 | - if (in_array($post_type, (array)geodir_get_posttypes()) && (int)$comment->comment_parent == 0) {
|
|
| 71 | + if (in_array($post_type, (array) geodir_get_posttypes()) && (int) $comment->comment_parent == 0) {
|
|
| 72 | 72 | $rating = geodir_get_commentoverall($comment->comment_ID); |
| 73 | 73 | |
| 74 | - if ((int)get_option('geodir_reviewrating_enable_font_awesome') == 1) {
|
|
| 74 | + if ((int) get_option('geodir_reviewrating_enable_font_awesome') == 1) {
|
|
| 75 | 75 | $star_texts = array(); |
| 76 | 76 | $star_texts[] = __('Terrible', 'geodirectory');
|
| 77 | 77 | $star_texts[] = __('Poor', 'geodirectory');
|
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | if (isset($_REQUEST['geodir_overallrating'])) {
|
| 194 | 194 | $overall_rating = $_REQUEST['geodir_overallrating']; |
| 195 | 195 | |
| 196 | - if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 196 | + if (isset($comment_info->comment_parent) && (int) $comment_info->comment_parent == 0) {
|
|
| 197 | 197 | $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
| 198 | 198 | |
| 199 | 199 | $sqlqry = $wpdb->prepare("INSERT INTO " . GEODIR_REVIEW_TABLE . " SET
|
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | $overall_rating = $_REQUEST['geodir_overallrating']; |
| 339 | 339 | |
| 340 | - if (isset($comment_info->comment_parent) && (int)$comment_info->comment_parent == 0) {
|
|
| 340 | + if (isset($comment_info->comment_parent) && (int) $comment_info->comment_parent == 0) {
|
|
| 341 | 341 | $overall_rating = $overall_rating > 0 ? $overall_rating : '0'; |
| 342 | 342 | |
| 343 | 343 | if (isset($old_rating)) {
|
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | * @package GeoDirectory |
| 458 | 458 | * @param int $post_id The post ID. |
| 459 | 459 | */ |
| 460 | - do_action('geodir_update_postrating',$post_id);
|
|
| 460 | + do_action('geodir_update_postrating', $post_id);
|
|
| 461 | 461 | |
| 462 | 462 | } |
| 463 | 463 | |
@@ -969,10 +969,10 @@ discard block |
||
| 969 | 969 | /* |
| 970 | 970 | * If Disqus plugin is active, do some fixes to show on blogs but no on GD post types |
| 971 | 971 | */ |
| 972 | -if(function_exists('dsq_can_replace')) {
|
|
| 972 | +if (function_exists('dsq_can_replace')) {
|
|
| 973 | 973 | remove_filter('comments_template', 'dsq_comments_template');
|
| 974 | 974 | add_filter('comments_template', 'dsq_comments_template', 100);
|
| 975 | - add_filter('pre_option_disqus_active', 'geodir_option_disqus_active',10,1);
|
|
| 975 | + add_filter('pre_option_disqus_active', 'geodir_option_disqus_active', 10, 1);
|
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | |
@@ -985,11 +985,11 @@ discard block |
||
| 985 | 985 | * @param string $disqus_active Hook called before DB call for option so this is empty. |
| 986 | 986 | * @return string `1` if active `0` if disabled. |
| 987 | 987 | */ |
| 988 | -function geodir_option_disqus_active($disqus_active){
|
|
| 988 | +function geodir_option_disqus_active($disqus_active) {
|
|
| 989 | 989 | global $post; |
| 990 | 990 | $all_postypes = geodir_get_posttypes(); |
| 991 | 991 | |
| 992 | - if(isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type,$all_postypes)){
|
|
| 992 | + if (isset($post->post_type) && is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
|
| 993 | 993 | $disqus_active = '0'; |
| 994 | 994 | } |
| 995 | 995 | |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Template functions |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Template functions |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Locates template based on the template type. |
@@ -29,21 +29,21 @@ discard block |
||
| 29 | 29 | case 'add-listing': |
| 30 | 30 | |
| 31 | 31 | $sc_post_type = ''; |
| 32 | - if (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 32 | + if (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 33 | 33 | $listing_page_id = $post->ID; |
| 34 | 34 | |
| 35 | - $regex_pattern = get_shortcode_regex(); |
|
| 36 | - preg_match('/'.$regex_pattern.'/s', $post->post_content, $regex_matches);
|
|
| 35 | + $regex_pattern = get_shortcode_regex(); |
|
| 36 | + preg_match('/'.$regex_pattern.'/s', $post->post_content, $regex_matches);
|
|
| 37 | 37 | |
| 38 | - if (!empty($regex_matches) && isset($regex_matches[2]) == 'gd_add_listing' && isset($regex_matches[3])) {
|
|
| 39 | - $shortcode_atts = shortcode_parse_atts($regex_matches[3]); |
|
| 40 | - $sc_post_type = !empty($shortcode_atts) && isset($shortcode_atts['listing_type']) && !empty($shortcode_atts['listing_type']) ? $shortcode_atts['listing_type'] : ''; |
|
| 41 | - } |
|
| 38 | + if (!empty($regex_matches) && isset($regex_matches[2]) == 'gd_add_listing' && isset($regex_matches[3])) {
|
|
| 39 | + $shortcode_atts = shortcode_parse_atts($regex_matches[3]); |
|
| 40 | + $sc_post_type = !empty($shortcode_atts) && isset($shortcode_atts['listing_type']) && !empty($shortcode_atts['listing_type']) ? $shortcode_atts['listing_type'] : ''; |
|
| 41 | + } |
|
| 42 | 42 | } else {
|
| 43 | 43 | $listing_page_id = geodir_add_listing_page_id(); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $is_wpml = function_exists('icl_object_id') ? true : false;
|
|
| 46 | + $is_wpml = function_exists('icl_object_id') ? true : false;
|
|
| 47 | 47 | |
| 48 | 48 | if ($listing_page_id != '' && (is_page($listing_page_id) || ($is_wpml && !empty($wp->query_vars['page_id']))) && isset($_REQUEST['listing_type']) |
| 49 | 49 | && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | if (!empty($post_types)) |
| 56 | 56 | $post_type = $post_types[0]; |
| 57 | 57 | |
| 58 | - if($sc_post_type != '' ) |
|
| 59 | - $post_type = $sc_post_type; |
|
| 58 | + if($sc_post_type != '' ) |
|
| 59 | + $post_type = $sc_post_type; |
|
| 60 | 60 | |
| 61 | 61 | if ($is_wpml && !empty($wp->query_vars['page_id'])) {
|
| 62 | - wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type)));
|
|
| 63 | - } else {
|
|
| 64 | - wp_redirect(trailingslashit(get_site_url()) . $pagename . '/?listing_type=' . $post_type); |
|
| 65 | - } |
|
| 62 | + wp_redirect(geodir_getlink(get_permalink($wp->query_vars['page_id']), array('listing_type' => $post_type)));
|
|
| 63 | + } else {
|
|
| 64 | + wp_redirect(trailingslashit(get_site_url()) . $pagename . '/?listing_type=' . $post_type); |
|
| 65 | + } |
|
| 66 | 66 | exit(); |
| 67 | 67 | } |
| 68 | 68 | return $template = locate_template(array("geodirectory/add-{$post_type}.php", "geodirectory/add-listing.php"));
|
@@ -481,21 +481,21 @@ discard block |
||
| 481 | 481 | */ |
| 482 | 482 | function geodir_display_message_not_found_on_listing($template_listview = 'listing-listview', $favorite = false) {
|
| 483 | 483 | if ($favorite) {
|
| 484 | - $message = __('No favorite listings found which match your selection.', 'geodirectory');
|
|
| 485 | - } else {
|
|
| 486 | - $message = __('No listings found which match your selection.', 'geodirectory');
|
|
| 487 | - } |
|
| 484 | + $message = __('No favorite listings found which match your selection.', 'geodirectory');
|
|
| 485 | + } else {
|
|
| 486 | + $message = __('No listings found which match your selection.', 'geodirectory');
|
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - /** |
|
| 490 | - * Filter the no listing found message. |
|
| 491 | - * |
|
| 492 | - * @since 1.5.5 |
|
| 493 | - * @param string $template_listview Listing listview template. |
|
| 494 | - * @param bool $favorite Are favorite listings results? |
|
| 495 | - */ |
|
| 496 | - $message = apply_filters('geodir_message_listing_not_found', $message, $template_listview, $favorite);
|
|
| 489 | + /** |
|
| 490 | + * Filter the no listing found message. |
|
| 491 | + * |
|
| 492 | + * @since 1.5.5 |
|
| 493 | + * @param string $template_listview Listing listview template. |
|
| 494 | + * @param bool $favorite Are favorite listings results? |
|
| 495 | + */ |
|
| 496 | + $message = apply_filters('geodir_message_listing_not_found', $message, $template_listview, $favorite);
|
|
| 497 | 497 | |
| 498 | - echo '<li class="no-listing">' . $message . '</li>'; |
|
| 498 | + echo '<li class="no-listing">' . $message . '</li>'; |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | /** |
@@ -509,9 +509,9 @@ discard block |
||
| 509 | 509 | * @return string Breadcrumb HTML. |
| 510 | 510 | */ |
| 511 | 511 | function geodir_strip_breadcrumb_li_wrappers($breadcrumb, $separator) {
|
| 512 | - $breadcrumb = str_replace(array('</li><li>', '</li> <li>'), '', $breadcrumb);
|
|
| 512 | + $breadcrumb = str_replace(array('</li><li>', '</li> <li>'), '', $breadcrumb);
|
|
| 513 | 513 | |
| 514 | - return $breadcrumb; |
|
| 514 | + return $breadcrumb; |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -522,30 +522,30 @@ discard block |
||
| 522 | 522 | * @return string Listing listview class. |
| 523 | 523 | */ |
| 524 | 524 | function geodir_convert_listing_view_class($columns = '') {
|
| 525 | - $class = ''; |
|
| 525 | + $class = ''; |
|
| 526 | 526 | |
| 527 | - switch ((int)$columns) {
|
|
| 528 | - case 1: |
|
| 529 | - $class = ''; |
|
| 530 | - break; |
|
| 531 | - case 2: |
|
| 532 | - $class = 'gridview_onehalf'; |
|
| 533 | - break; |
|
| 534 | - case 3: |
|
| 535 | - $class = 'gridview_onethird'; |
|
| 536 | - break; |
|
| 537 | - case 4: |
|
| 538 | - $class = 'gridview_onefourth'; |
|
| 539 | - break; |
|
| 540 | - case 5: |
|
| 541 | - $class = 'gridview_onefifth'; |
|
| 542 | - break; |
|
| 543 | - default: |
|
| 544 | - $class = ''; |
|
| 545 | - break; |
|
| 546 | - } |
|
| 527 | + switch ((int)$columns) {
|
|
| 528 | + case 1: |
|
| 529 | + $class = ''; |
|
| 530 | + break; |
|
| 531 | + case 2: |
|
| 532 | + $class = 'gridview_onehalf'; |
|
| 533 | + break; |
|
| 534 | + case 3: |
|
| 535 | + $class = 'gridview_onethird'; |
|
| 536 | + break; |
|
| 537 | + case 4: |
|
| 538 | + $class = 'gridview_onefourth'; |
|
| 539 | + break; |
|
| 540 | + case 5: |
|
| 541 | + $class = 'gridview_onefifth'; |
|
| 542 | + break; |
|
| 543 | + default: |
|
| 544 | + $class = ''; |
|
| 545 | + break; |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - return $class; |
|
| 548 | + return $class; |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | /** |
@@ -558,18 +558,18 @@ discard block |
||
| 558 | 558 | * @return bool Modified value for display the excerpt. |
| 559 | 559 | */ |
| 560 | 560 | function geodir_show_listing_post_excerpt($display, $view, $post) {
|
| 561 | - if ($view == 'listview') {
|
|
| 562 | - if (geodir_is_page('author')) {
|
|
| 563 | - $word_limit = get_option('geodir_author_desc_word_limit');
|
|
| 564 | - } else {
|
|
| 565 | - $word_limit = get_option('geodir_desc_word_limit');
|
|
| 566 | - } |
|
| 561 | + if ($view == 'listview') {
|
|
| 562 | + if (geodir_is_page('author')) {
|
|
| 563 | + $word_limit = get_option('geodir_author_desc_word_limit');
|
|
| 564 | + } else {
|
|
| 565 | + $word_limit = get_option('geodir_desc_word_limit');
|
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - if ($word_limit !== '' && ($word_limit == 0 || $word_limit == '0')) {
|
|
| 569 | - $display = false; |
|
| 570 | - } |
|
| 571 | - } |
|
| 572 | - return $display; |
|
| 568 | + if ($word_limit !== '' && ($word_limit == 0 || $word_limit == '0')) {
|
|
| 569 | + $display = false; |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | + return $display; |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | /** |
@@ -584,24 +584,24 @@ discard block |
||
| 584 | 584 | * @return string Rating icons html content. |
| 585 | 585 | */ |
| 586 | 586 | function geodir_font_awesome_rating_form_html($html, $star_texts = array(), $default = '') {
|
| 587 | - if (get_option('geodir_reviewrating_enable_font_awesome') == '1') {
|
|
| 588 | - $html = '<select class="gd-fa-rating">'; |
|
| 589 | - $html .= '<option value=""></option>'; |
|
| 590 | - if (!empty($star_texts) && is_array($star_texts)) {
|
|
| 591 | - foreach ($star_texts as $i => $text) {
|
|
| 592 | - $html .= '<option ' . selected((int)($i + 1), (int)$default, false) . ' value="' . (int)($i + 1) . '">' . $text . '</option>'; |
|
| 593 | - } |
|
| 594 | - } else {
|
|
| 595 | - $html .= '<option value="1">1</option>'; |
|
| 596 | - $html .= '<option value="2">2</option>'; |
|
| 597 | - $html .= '<option value="3">3</option>'; |
|
| 598 | - $html .= '<option value="4">4</option>'; |
|
| 599 | - $html .= '<option value="5">5</option>'; |
|
| 600 | - } |
|
| 601 | - $html .= '</select>'; |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - return $html; |
|
| 587 | + if (get_option('geodir_reviewrating_enable_font_awesome') == '1') {
|
|
| 588 | + $html = '<select class="gd-fa-rating">'; |
|
| 589 | + $html .= '<option value=""></option>'; |
|
| 590 | + if (!empty($star_texts) && is_array($star_texts)) {
|
|
| 591 | + foreach ($star_texts as $i => $text) {
|
|
| 592 | + $html .= '<option ' . selected((int)($i + 1), (int)$default, false) . ' value="' . (int)($i + 1) . '">' . $text . '</option>'; |
|
| 593 | + } |
|
| 594 | + } else {
|
|
| 595 | + $html .= '<option value="1">1</option>'; |
|
| 596 | + $html .= '<option value="2">2</option>'; |
|
| 597 | + $html .= '<option value="3">3</option>'; |
|
| 598 | + $html .= '<option value="4">4</option>'; |
|
| 599 | + $html .= '<option value="5">5</option>'; |
|
| 600 | + } |
|
| 601 | + $html .= '</select>'; |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + return $html; |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
@@ -616,20 +616,20 @@ discard block |
||
| 616 | 616 | * @return string Rating icons html content. |
| 617 | 617 | */ |
| 618 | 618 | function geodir_font_awesome_rating_stars_html($html, $rating, $star_count = 5) {
|
| 619 | - if (get_option('geodir_reviewrating_enable_font_awesome') == '1') {
|
|
| 620 | - $rating = min($rating, $star_count); |
|
| 621 | - $full_stars = floor( $rating ); |
|
| 622 | - $half_stars = ceil( $rating - $full_stars ); |
|
| 623 | - $empty_stars = $star_count - $full_stars - $half_stars; |
|
| 619 | + if (get_option('geodir_reviewrating_enable_font_awesome') == '1') {
|
|
| 620 | + $rating = min($rating, $star_count); |
|
| 621 | + $full_stars = floor( $rating ); |
|
| 622 | + $half_stars = ceil( $rating - $full_stars ); |
|
| 623 | + $empty_stars = $star_count - $full_stars - $half_stars; |
|
| 624 | 624 | |
| 625 | - $html = '<div class="gd-star-rating gd-fa-star-rating">'; |
|
| 626 | - $html .= str_repeat( '<i class="fa fa-star gd-full-star"></i>', $full_stars ); |
|
| 627 | - $html .= str_repeat( '<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars ); |
|
| 628 | - $html .= str_repeat( '<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
| 629 | - $html .= '</div>'; |
|
| 630 | - } |
|
| 631 | - |
|
| 632 | - return $html; |
|
| 625 | + $html = '<div class="gd-star-rating gd-fa-star-rating">'; |
|
| 626 | + $html .= str_repeat( '<i class="fa fa-star gd-full-star"></i>', $full_stars ); |
|
| 627 | + $html .= str_repeat( '<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars ); |
|
| 628 | + $html .= str_repeat( '<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
| 629 | + $html .= '</div>'; |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + return $html; |
|
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
@@ -639,12 +639,12 @@ discard block |
||
| 639 | 639 | * @package GeoDirectory |
| 640 | 640 | */ |
| 641 | 641 | function geodir_font_awesome_rating_css() {
|
| 642 | - // Font awesome rating style |
|
| 643 | - if (get_option('geodir_reviewrating_enable_font_awesome') == '1') {
|
|
| 644 | - $full_color = get_option('geodir_reviewrating_fa_full_rating_color', '#757575');
|
|
| 645 | - if ($full_color != '#757575') {
|
|
| 646 | - echo '<style type="text/css">.br-theme-fontawesome-stars .br-widget a.br-active:after,.br-theme-fontawesome-stars .br-widget a.br-selected:after, |
|
| 642 | + // Font awesome rating style |
|
| 643 | + if (get_option('geodir_reviewrating_enable_font_awesome') == '1') {
|
|
| 644 | + $full_color = get_option('geodir_reviewrating_fa_full_rating_color', '#757575');
|
|
| 645 | + if ($full_color != '#757575') {
|
|
| 646 | + echo '<style type="text/css">.br-theme-fontawesome-stars .br-widget a.br-active:after,.br-theme-fontawesome-stars .br-widget a.br-selected:after, |
|
| 647 | 647 | .gd-star-rating i.fa {color:' . stripslashes($full_color) . '!important;</style>';
|
| 648 | - } |
|
| 649 | - } |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | 650 | } |
| 651 | 651 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $listing_page_id = $post->ID; |
| 34 | 34 | |
| 35 | 35 | $regex_pattern = get_shortcode_regex(); |
| 36 | - preg_match('/'.$regex_pattern.'/s', $post->post_content, $regex_matches);
|
|
| 36 | + preg_match('/' . $regex_pattern . '/s', $post->post_content, $regex_matches);
|
|
| 37 | 37 | |
| 38 | 38 | if (!empty($regex_matches) && isset($regex_matches[2]) == 'gd_add_listing' && isset($regex_matches[3])) {
|
| 39 | 39 | $shortcode_atts = shortcode_parse_atts($regex_matches[3]); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if (!empty($post_types)) |
| 56 | 56 | $post_type = $post_types[0]; |
| 57 | 57 | |
| 58 | - if($sc_post_type != '' ) |
|
| 58 | + if ($sc_post_type != '') |
|
| 59 | 59 | $post_type = $sc_post_type; |
| 60 | 60 | |
| 61 | 61 | if ($is_wpml && !empty($wp->query_vars['page_id'])) {
|
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | */ |
| 411 | 411 | do_action("geodir_get_template_part_{$slug}", $slug, $name);
|
| 412 | 412 | $templates = array(); |
| 413 | - $name = (string)$name; |
|
| 413 | + $name = (string) $name; |
|
| 414 | 414 | if ('' !== $name) {
|
| 415 | 415 | $template_name = "{$slug}-{$name}.php";
|
| 416 | 416 | |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | function geodir_convert_listing_view_class($columns = '') {
|
| 525 | 525 | $class = ''; |
| 526 | 526 | |
| 527 | - switch ((int)$columns) {
|
|
| 527 | + switch ((int) $columns) {
|
|
| 528 | 528 | case 1: |
| 529 | 529 | $class = ''; |
| 530 | 530 | break; |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | $html .= '<option value=""></option>'; |
| 590 | 590 | if (!empty($star_texts) && is_array($star_texts)) {
|
| 591 | 591 | foreach ($star_texts as $i => $text) {
|
| 592 | - $html .= '<option ' . selected((int)($i + 1), (int)$default, false) . ' value="' . (int)($i + 1) . '">' . $text . '</option>'; |
|
| 592 | + $html .= '<option ' . selected((int) ($i + 1), (int) $default, false) . ' value="' . (int) ($i + 1) . '">' . $text . '</option>'; |
|
| 593 | 593 | } |
| 594 | 594 | } else {
|
| 595 | 595 | $html .= '<option value="1">1</option>'; |
@@ -618,14 +618,14 @@ discard block |
||
| 618 | 618 | function geodir_font_awesome_rating_stars_html($html, $rating, $star_count = 5) {
|
| 619 | 619 | if (get_option('geodir_reviewrating_enable_font_awesome') == '1') {
|
| 620 | 620 | $rating = min($rating, $star_count); |
| 621 | - $full_stars = floor( $rating ); |
|
| 622 | - $half_stars = ceil( $rating - $full_stars ); |
|
| 621 | + $full_stars = floor($rating); |
|
| 622 | + $half_stars = ceil($rating - $full_stars); |
|
| 623 | 623 | $empty_stars = $star_count - $full_stars - $half_stars; |
| 624 | 624 | |
| 625 | 625 | $html = '<div class="gd-star-rating gd-fa-star-rating">'; |
| 626 | - $html .= str_repeat( '<i class="fa fa-star gd-full-star"></i>', $full_stars ); |
|
| 627 | - $html .= str_repeat( '<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars ); |
|
| 628 | - $html .= str_repeat( '<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars); |
|
| 626 | + $html .= str_repeat('<i class="fa fa-star gd-full-star"></i>', $full_stars);
|
|
| 627 | + $html .= str_repeat('<i class="fa fa-star-o fa-star-half-full gd-half-star"></i>', $half_stars);
|
|
| 628 | + $html .= str_repeat('<i class="fa fa-star-o gd-empty-star"></i>', $empty_stars);
|
|
| 629 | 629 | $html .= '</div>'; |
| 630 | 630 | } |
| 631 | 631 | |
@@ -1134,9 +1134,9 @@ discard block |
||
| 1134 | 1134 | $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; |
| 1135 | 1135 | $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; |
| 1136 | 1136 | |
| 1137 | - $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
|
|
| 1137 | + $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
|
|
| 1138 | 1138 | |
| 1139 | - $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
|
|
| 1139 | + $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
|
|
| 1140 | 1140 | |
| 1141 | 1141 | $html .= '<span class="item">'; |
| 1142 | 1142 | $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
@@ -1250,13 +1250,13 @@ discard block |
||
| 1250 | 1250 | $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
|
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | - /** |
|
| 1254 | - * Filter the allowed image type extensions for post images. |
|
| 1255 | - * |
|
| 1256 | - * @since 1.4.7.1 |
|
| 1257 | - * @param string $allowed_img_types The image type extensions array. |
|
| 1258 | - */ |
|
| 1259 | - $allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png'));
|
|
| 1253 | + /** |
|
| 1254 | + * Filter the allowed image type extensions for post images. |
|
| 1255 | + * |
|
| 1256 | + * @since 1.4.7.1 |
|
| 1257 | + * @param string $allowed_img_types The image type extensions array. |
|
| 1258 | + */ |
|
| 1259 | + $allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png'));
|
|
| 1260 | 1260 | |
| 1261 | 1261 | $arr_alert_msg = array( |
| 1262 | 1262 | 'geodir_plugin_url' => geodir_plugin_url(), |
@@ -1304,13 +1304,13 @@ discard block |
||
| 1304 | 1304 | 'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
|
| 1305 | 1305 | 'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
|
| 1306 | 1306 | 'geodir_action_remove' => __('Remove', 'geodirectory'),
|
| 1307 | - 'geodir_txt_all_files' => __('Allowed files', 'geodirectory'),
|
|
| 1308 | - 'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'),
|
|
| 1309 | - 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
|
|
| 1310 | - 'geodir_txt_form_wait' => __('Wait...', 'geodirectory'),
|
|
| 1311 | - 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
|
|
| 1312 | - 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
|
|
| 1313 | - 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
|
|
| 1307 | + 'geodir_txt_all_files' => __('Allowed files', 'geodirectory'),
|
|
| 1308 | + 'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'),
|
|
| 1309 | + 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
|
|
| 1310 | + 'geodir_txt_form_wait' => __('Wait...', 'geodirectory'),
|
|
| 1311 | + 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
|
|
| 1312 | + 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
|
|
| 1313 | + 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
|
|
| 1314 | 1314 | ); |
| 1315 | 1315 | |
| 1316 | 1316 | /** |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | * @global object $gd_session GeoDirectory Session object. |
| 1497 | 1497 | */ |
| 1498 | 1498 | function geodir_after_main_form_fields() {
|
| 1499 | - global $gd_session; |
|
| 1499 | + global $gd_session; |
|
| 1500 | 1500 | |
| 1501 | 1501 | if (get_option('geodir_accept_term_condition')) {
|
| 1502 | 1502 | global $post; |
@@ -1569,13 +1569,13 @@ discard block |
||
| 1569 | 1569 | $is_display = (geodir_is_page('detail')) ? true : false;
|
| 1570 | 1570 | |
| 1571 | 1571 | if ($tab == 'related_listing') {
|
| 1572 | - $message = __('No listings found which match your selection.', 'geodirectory');
|
|
| 1572 | + $message = __('No listings found which match your selection.', 'geodirectory');
|
|
| 1573 | 1573 | |
| 1574 | - /** This action is documented in geodirectory-functions/template_functions.php */ |
|
| 1575 | - $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
|
|
| 1574 | + /** This action is documented in geodirectory-functions/template_functions.php */ |
|
| 1575 | + $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
|
|
| 1576 | 1576 | |
| 1577 | - $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
|
|
| 1578 | - } |
|
| 1577 | + $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
|
|
| 1578 | + } |
|
| 1579 | 1579 | |
| 1580 | 1580 | |
| 1581 | 1581 | return $is_display; |
@@ -1622,12 +1622,12 @@ discard block |
||
| 1622 | 1622 | function geodir_changes_in_custom_fields_table() {
|
| 1623 | 1623 | global $wpdb, $plugin_prefix; |
| 1624 | 1624 | |
| 1625 | - // Remove unused virtual page |
|
| 1626 | - $listings_page_id = (int)get_option('geodir_listing_page');
|
|
| 1627 | - if ($listings_page_id) {
|
|
| 1628 | - $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
|
|
| 1625 | + // Remove unused virtual page |
|
| 1626 | + $listings_page_id = (int)get_option('geodir_listing_page');
|
|
| 1627 | + if ($listings_page_id) {
|
|
| 1628 | + $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
|
|
| 1629 | 1629 | delete_option('geodir_listing_page');
|
| 1630 | - } |
|
| 1630 | + } |
|
| 1631 | 1631 | |
| 1632 | 1632 | // updated custom field table(add field to show custom field as a tab) |
| 1633 | 1633 | /*if (!$wpdb->get_var("SHOW COLUMNS FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE field = 'show_as_tab'")) {
|
@@ -1795,26 +1795,26 @@ discard block |
||
| 1795 | 1795 | |
| 1796 | 1796 | } |
| 1797 | 1797 | |
| 1798 | - // Update tag in detail table. |
|
| 1799 | - $taxonomy_obj = get_taxonomy($taxonomy); |
|
| 1800 | - $post_type = !empty($taxonomy_obj) ? $taxonomy_obj->object_type[0] : NULL; |
|
| 1798 | + // Update tag in detail table. |
|
| 1799 | + $taxonomy_obj = get_taxonomy($taxonomy); |
|
| 1800 | + $post_type = !empty($taxonomy_obj) ? $taxonomy_obj->object_type[0] : NULL; |
|
| 1801 | 1801 | |
| 1802 | - $post_types = geodir_get_posttypes(); |
|
| 1803 | - if ($post_type && in_array($post_type, $post_types) && $post_type . '_tags' == $taxonomy) {
|
|
| 1804 | - $posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM " . $wpdb->term_relationships . " WHERE term_taxonomy_id = %d", array($tt_id)));
|
|
| 1802 | + $post_types = geodir_get_posttypes(); |
|
| 1803 | + if ($post_type && in_array($post_type, $post_types) && $post_type . '_tags' == $taxonomy) {
|
|
| 1804 | + $posts_obj = $wpdb->get_results($wpdb->prepare("SELECT object_id FROM " . $wpdb->term_relationships . " WHERE term_taxonomy_id = %d", array($tt_id)));
|
|
| 1805 | 1805 | |
| 1806 | - if (!empty($posts_obj)) {
|
|
| 1807 | - foreach ($posts_obj as $post_obj) {
|
|
| 1808 | - $post_id = $post_obj->object_id; |
|
| 1806 | + if (!empty($posts_obj)) {
|
|
| 1807 | + foreach ($posts_obj as $post_obj) {
|
|
| 1808 | + $post_id = $post_obj->object_id; |
|
| 1809 | 1809 | |
| 1810 | - $raw_tags = wp_get_object_terms($post_id, $post_type . '_tags', array('fields' => 'names'));
|
|
| 1811 | - $post_tags = !empty($raw_tags) ? implode(',', $raw_tags) : '';
|
|
| 1810 | + $raw_tags = wp_get_object_terms($post_id, $post_type . '_tags', array('fields' => 'names'));
|
|
| 1811 | + $post_tags = !empty($raw_tags) ? implode(',', $raw_tags) : '';
|
|
| 1812 | 1812 | |
| 1813 | - $listing_table = $plugin_prefix . $post_type . '_detail'; |
|
| 1814 | - $wpdb->query($wpdb->prepare("UPDATE " . $listing_table . " SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id)));
|
|
| 1815 | - } |
|
| 1816 | - } |
|
| 1817 | - } |
|
| 1813 | + $listing_table = $plugin_prefix . $post_type . '_detail'; |
|
| 1814 | + $wpdb->query($wpdb->prepare("UPDATE " . $listing_table . " SET post_tags=%s WHERE post_id =%d", array($post_tags, $post_id)));
|
|
| 1815 | + } |
|
| 1816 | + } |
|
| 1817 | + } |
|
| 1818 | 1818 | } |
| 1819 | 1819 | |
| 1820 | 1820 | |
@@ -2037,14 +2037,14 @@ discard block |
||
| 2037 | 2037 | add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
|
| 2038 | 2038 | } |
| 2039 | 2039 | /** |
| 2040 | - * Set status from draft to publish. |
|
| 2041 | - * |
|
| 2042 | - * @since 1.0.0 |
|
| 2043 | - * @package GeoDirectory |
|
| 2044 | - * @global object $wp WordPress object. |
|
| 2045 | - * @param object $post Post object. |
|
| 2046 | - * @return object Modified post object. |
|
| 2047 | - */ |
|
| 2040 | + * Set status from draft to publish. |
|
| 2041 | + * |
|
| 2042 | + * @since 1.0.0 |
|
| 2043 | + * @package GeoDirectory |
|
| 2044 | + * @global object $wp WordPress object. |
|
| 2045 | + * @param object $post Post object. |
|
| 2046 | + * @return object Modified post object. |
|
| 2047 | + */ |
|
| 2048 | 2048 | function geodir_set_status_draft_to_publish_for_own_post($post) |
| 2049 | 2049 | {
|
| 2050 | 2050 | global $wp; |
@@ -2475,7 +2475,7 @@ discard block |
||
| 2475 | 2475 | foreach ($custom_fields as $field) {
|
| 2476 | 2476 | $field = stripslashes_deep($field); // strip slashes |
| 2477 | 2477 | |
| 2478 | - $type = $field; |
|
| 2478 | + $type = $field; |
|
| 2479 | 2479 | $field_name = $field['htmlvar_name']; |
| 2480 | 2480 | if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->$field_name) && isset($_REQUEST[$field_name])) {
|
| 2481 | 2481 | $post->$field_name = $_REQUEST[$field_name]; |
@@ -2563,11 +2563,11 @@ discard block |
||
| 2563 | 2563 | $field_icon = ''; |
| 2564 | 2564 | } |
| 2565 | 2565 | |
| 2566 | - $a_url = geodir_parse_custom_field_url($post->$type['htmlvar_name']); |
|
| 2566 | + $a_url = geodir_parse_custom_field_url($post->$type['htmlvar_name']); |
|
| 2567 | 2567 | |
| 2568 | - $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
|
| 2569 | - $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; |
|
| 2570 | - $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
|
| 2568 | + $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
|
| 2569 | + $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; |
|
| 2570 | + $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
|
| 2571 | 2571 | |
| 2572 | 2572 | $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
| 2573 | 2573 | |
@@ -2686,26 +2686,26 @@ discard block |
||
| 2686 | 2686 | break; |
| 2687 | 2687 | case 'radio': {
|
| 2688 | 2688 | |
| 2689 | - if ($post->$type['htmlvar_name'] != '') {
|
|
| 2690 | - if ($post->$type['htmlvar_name'] == 'f' || $post->$type['htmlvar_name'] == '0') {
|
|
| 2689 | + if ($post->$type['htmlvar_name'] != '') {
|
|
| 2690 | + if ($post->$type['htmlvar_name'] == 'f' || $post->$type['htmlvar_name'] == '0') {
|
|
| 2691 | 2691 | $html_val = __('No', 'geodirectory');
|
| 2692 | 2692 | } else if ($post->$type['htmlvar_name'] == 't' || $post->$type['htmlvar_name'] == '1') {
|
| 2693 | 2693 | $html_val = __('Yes', 'geodirectory');
|
| 2694 | 2694 | } else {
|
| 2695 | - $html_val = __($post->$type['htmlvar_name'], 'geodirectory'); |
|
| 2695 | + $html_val = __($post->$type['htmlvar_name'], 'geodirectory'); |
|
| 2696 | 2696 | |
| 2697 | - if (!empty($type['option_values'])) {
|
|
| 2698 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2697 | + if (!empty($type['option_values'])) {
|
|
| 2698 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2699 | 2699 | |
| 2700 | - if (!empty($cf_option_values)) {
|
|
| 2701 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2702 | - if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->$type['htmlvar_name']) {
|
|
| 2703 | - $html_val = $cf_option_value['label']; |
|
| 2704 | - } |
|
| 2705 | - } |
|
| 2706 | - } |
|
| 2707 | - } |
|
| 2708 | - } |
|
| 2700 | + if (!empty($cf_option_values)) {
|
|
| 2701 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2702 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->$type['htmlvar_name']) {
|
|
| 2703 | + $html_val = $cf_option_value['label']; |
|
| 2704 | + } |
|
| 2705 | + } |
|
| 2706 | + } |
|
| 2707 | + } |
|
| 2708 | + } |
|
| 2709 | 2709 | |
| 2710 | 2710 | if (strpos($field_icon, 'http') !== false) {
|
| 2711 | 2711 | $field_icon_af = ''; |
@@ -2771,19 +2771,19 @@ discard block |
||
| 2771 | 2771 | $field_icon = ''; |
| 2772 | 2772 | } |
| 2773 | 2773 | |
| 2774 | - $field_value = __($post->$type['htmlvar_name'], 'geodirectory'); |
|
| 2774 | + $field_value = __($post->$type['htmlvar_name'], 'geodirectory'); |
|
| 2775 | 2775 | |
| 2776 | - if (!empty($type['option_values'])) {
|
|
| 2777 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2776 | + if (!empty($type['option_values'])) {
|
|
| 2777 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2778 | 2778 | |
| 2779 | - if (!empty($cf_option_values)) {
|
|
| 2780 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2781 | - if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->$type['htmlvar_name']) {
|
|
| 2782 | - $field_value = $cf_option_value['label']; |
|
| 2783 | - } |
|
| 2784 | - } |
|
| 2785 | - } |
|
| 2786 | - } |
|
| 2779 | + if (!empty($cf_option_values)) {
|
|
| 2780 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2781 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->$type['htmlvar_name']) {
|
|
| 2782 | + $field_value = $cf_option_value['label']; |
|
| 2783 | + } |
|
| 2784 | + } |
|
| 2785 | + } |
|
| 2786 | + } |
|
| 2787 | 2787 | |
| 2788 | 2788 | $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
| 2789 | 2789 | |
@@ -2811,16 +2811,16 @@ discard block |
||
| 2811 | 2811 | $field_values = explode(',', trim($post->$type['htmlvar_name'], ","));
|
| 2812 | 2812 | |
| 2813 | 2813 | $option_values = array(); |
| 2814 | - if (!empty($type['option_values'])) {
|
|
| 2815 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2814 | + if (!empty($type['option_values'])) {
|
|
| 2815 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2816 | 2816 | |
| 2817 | - if (!empty($cf_option_values)) {
|
|
| 2818 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2819 | - if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
|
|
| 2820 | - $option_values[] = $cf_option_value['label']; |
|
| 2821 | - } |
|
| 2822 | - } |
|
| 2823 | - } |
|
| 2817 | + if (!empty($cf_option_values)) {
|
|
| 2818 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2819 | + if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
|
|
| 2820 | + $option_values[] = $cf_option_value['label']; |
|
| 2821 | + } |
|
| 2822 | + } |
|
| 2823 | + } |
|
| 2824 | 2824 | } |
| 2825 | 2825 | |
| 2826 | 2826 | $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
@@ -2908,9 +2908,9 @@ discard block |
||
| 2908 | 2908 | |
| 2909 | 2909 | if (!empty($files)) {
|
| 2910 | 2910 | $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; |
| 2911 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 2911 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 2912 | 2912 | |
| 2913 | - $file_paths = ''; |
|
| 2913 | + $file_paths = ''; |
|
| 2914 | 2914 | foreach ($files as $file) {
|
| 2915 | 2915 | if (!empty($file)) {
|
| 2916 | 2916 | $filetype = wp_check_filetype($file); |
@@ -2921,29 +2921,29 @@ discard block |
||
| 2921 | 2921 | |
| 2922 | 2922 | $arr_file_type = wp_check_filetype($filename); |
| 2923 | 2923 | if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
|
| 2924 | - continue; |
|
| 2925 | - } |
|
| 2926 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 2927 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
| 2924 | + continue; |
|
| 2925 | + } |
|
| 2926 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 2927 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
| 2928 | 2928 | |
| 2929 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 2930 | - continue; // Invalid file type. |
|
| 2931 | - } |
|
| 2929 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 2930 | + continue; // Invalid file type. |
|
| 2931 | + } |
|
| 2932 | 2932 | |
| 2933 | 2933 | //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
|
| 2934 | - $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
|
|
| 2934 | + $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
|
|
| 2935 | 2935 | |
| 2936 | 2936 | // If the uploaded file is image |
| 2937 | 2937 | if (in_array($uploaded_file_type, $image_file_types)) {
|
| 2938 | 2938 | $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
| 2939 | - $file_paths .= '<a href="'.$file.'">'; |
|
| 2940 | - $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
|
|
| 2941 | - $file_paths .= '</a>'; |
|
| 2942 | - $file_paths .= '</div>'; |
|
| 2939 | + $file_paths .= '<a href="'.$file.'">'; |
|
| 2940 | + $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
|
|
| 2941 | + $file_paths .= '</a>'; |
|
| 2942 | + $file_paths .= '</div>'; |
|
| 2943 | 2943 | } else {
|
| 2944 | - $ext_path = '_' . $html_var . '_'; |
|
| 2945 | - $filename = explode($ext_path, $filename); |
|
| 2946 | - $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; |
|
| 2944 | + $ext_path = '_' . $html_var . '_'; |
|
| 2945 | + $filename = explode($ext_path, $filename); |
|
| 2946 | + $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; |
|
| 2947 | 2947 | } |
| 2948 | 2948 | } |
| 2949 | 2949 | } |
@@ -3286,34 +3286,34 @@ discard block |
||
| 3286 | 3286 | * @return array Translation texts. |
| 3287 | 3287 | */ |
| 3288 | 3288 | function geodir_load_gd_options_text_translation($translation_texts = array()) {
|
| 3289 | - $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
| 3289 | + $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
| 3290 | 3290 | |
| 3291 | - $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content');
|
|
| 3291 | + $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content');
|
|
| 3292 | 3292 | |
| 3293 | - /** |
|
| 3294 | - * Filters the geodirectory option names that requires to add for translation. |
|
| 3295 | - * |
|
| 3296 | - * @since 1.5.7 |
|
| 3297 | - * @package GeoDirectory |
|
| 3298 | - * |
|
| 3299 | - * @param array $gd_options Array of option names. |
|
| 3300 | - */ |
|
| 3301 | - $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
|
|
| 3302 | - $gd_options = array_unique($gd_options); |
|
| 3293 | + /** |
|
| 3294 | + * Filters the geodirectory option names that requires to add for translation. |
|
| 3295 | + * |
|
| 3296 | + * @since 1.5.7 |
|
| 3297 | + * @package GeoDirectory |
|
| 3298 | + * |
|
| 3299 | + * @param array $gd_options Array of option names. |
|
| 3300 | + */ |
|
| 3301 | + $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
|
|
| 3302 | + $gd_options = array_unique($gd_options); |
|
| 3303 | 3303 | |
| 3304 | - if (!empty($gd_options)) {
|
|
| 3305 | - foreach ($gd_options as $gd_option) {
|
|
| 3306 | - if ($gd_option != '' && $option_value = get_option($gd_option)) {
|
|
| 3307 | - $option_value = is_string($option_value) ? stripslashes_deep($option_value) : ''; |
|
| 3304 | + if (!empty($gd_options)) {
|
|
| 3305 | + foreach ($gd_options as $gd_option) {
|
|
| 3306 | + if ($gd_option != '' && $option_value = get_option($gd_option)) {
|
|
| 3307 | + $option_value = is_string($option_value) ? stripslashes_deep($option_value) : ''; |
|
| 3308 | 3308 | |
| 3309 | - if ($option_value != '' && !in_array($option_value, $translation_texts)) {
|
|
| 3310 | - $translation_texts[] = stripslashes_deep($option_value); |
|
| 3311 | - } |
|
| 3312 | - } |
|
| 3313 | - } |
|
| 3314 | - } |
|
| 3309 | + if ($option_value != '' && !in_array($option_value, $translation_texts)) {
|
|
| 3310 | + $translation_texts[] = stripslashes_deep($option_value); |
|
| 3311 | + } |
|
| 3312 | + } |
|
| 3313 | + } |
|
| 3314 | + } |
|
| 3315 | 3315 | |
| 3316 | - $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 3316 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 3317 | 3317 | |
| 3318 | 3318 | return $translation_texts; |
| 3319 | 3319 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | /* ON TEMPLATE INCLUDE */ |
| 137 | 137 | ///////////////////////// |
| 138 | 138 | |
| 139 | -add_filter('template_include', 'geodir_template_loader',9);
|
|
| 139 | +add_filter('template_include', 'geodir_template_loader', 9);
|
|
| 140 | 140 | |
| 141 | 141 | ///////////////////////// |
| 142 | 142 | /* CATEGORY / TAXONOMY / CUSTOM POST ACTIONS */ |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | //////////////////////// |
| 178 | 178 | |
| 179 | 179 | add_action('geodir_update_postrating', 'geodir_term_review_count_force_update', 100);
|
| 180 | -add_action('transition_post_status', 'geodir_term_review_count_force_update', 100,3);
|
|
| 180 | +add_action('transition_post_status', 'geodir_term_review_count_force_update', 100, 3);
|
|
| 181 | 181 | add_action('created_term', 'geodir_term_review_count_force_update', 100);
|
| 182 | 182 | add_action('edited_term', 'geodir_term_review_count_force_update', 100);
|
| 183 | 183 | add_action('delete_term', 'geodir_term_review_count_force_update', 100);
|
@@ -319,8 +319,8 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | /////// GEO DIRECOTORY CUSTOM HOOKS /// |
| 321 | 321 | |
| 322 | -add_action('geodir_before_tab_content', 'geodir_before_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content
|
|
| 323 | -add_action('geodir_after_tab_content', 'geodir_after_tab_content');// this function is in custom_functions.php and it is used to wrap detail page tab content
|
|
| 322 | +add_action('geodir_before_tab_content', 'geodir_before_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content
|
|
| 323 | +add_action('geodir_after_tab_content', 'geodir_after_tab_content'); // this function is in custom_functions.php and it is used to wrap detail page tab content
|
|
| 324 | 324 | |
| 325 | 325 | // Detail page sidebar content |
| 326 | 326 | add_action('geodir_detail_page_sidebar', 'geodir_detail_page_sidebar_content_sorting', 1);
|
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | $content_html = ob_get_clean(); |
| 423 | 423 | if (trim($content_html) != '') |
| 424 | 424 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
| 425 | - if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
|
|
| 425 | + if ((int) get_option('geodir_disable_tfg_buttons_section') != 1) {
|
|
| 426 | 426 | /** |
| 427 | 427 | * Filter the geodir_social_sharing_buttons() function content. |
| 428 | 428 | * |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | $content_html = ob_get_clean(); |
| 470 | 470 | if (trim($content_html) != '') |
| 471 | 471 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-sharethis">' . $content_html . '</div>'; |
| 472 | - if ((int)get_option('geodir_disable_sharethis_button_section') != 1) {
|
|
| 472 | + if ((int) get_option('geodir_disable_sharethis_button_section') != 1) {
|
|
| 473 | 473 | /** |
| 474 | 474 | * Filter the geodir_share_this_button() function content. |
| 475 | 475 | * |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | $content_html = ob_get_clean(); |
| 529 | 529 | if (trim($content_html) != '') |
| 530 | 530 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
| 531 | - if ((int)get_option('geodir_disable_user_links_section') != 1) {
|
|
| 531 | + if ((int) get_option('geodir_disable_user_links_section') != 1) {
|
|
| 532 | 532 | /** |
| 533 | 533 | * Filter the geodir_edit_post_link() function content. |
| 534 | 534 | * |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | $id = trim(get_option('geodir_ga_id'));
|
| 559 | 559 | |
| 560 | - if(!$id){return;}//if no Google Analytics ID then bail.
|
|
| 560 | + if (!$id) {return; }//if no Google Analytics ID then bail.
|
|
| 561 | 561 | |
| 562 | 562 | ob_start(); // Start buffering; |
| 563 | 563 | /** |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * @since 1.0.0 |
| 567 | 567 | */ |
| 568 | 568 | do_action('geodir_before_google_analytics');
|
| 569 | - if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
|
|
| 569 | + if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id() == $post->post_author || current_user_can('manage_options'))) {
|
|
| 570 | 570 | $page_url = $_SERVER['REQUEST_URI']; |
| 571 | 571 | //$page_url = "/"; |
| 572 | 572 | ?> |
@@ -594,13 +594,13 @@ discard block |
||
| 594 | 594 | |
| 595 | 595 | function gdga_weekVSweek(){
|
| 596 | 596 | |
| 597 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=thisweek", success: function(result){
|
|
| 597 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=thisweek", success: function(result){
|
|
| 598 | 598 | ga_data1 = jQuery.parseJSON(result); |
| 599 | 599 | if(ga_data1.error){jQuery('#ga_stats').html(result);return;}
|
| 600 | 600 | gd_renderWeekOverWeekChart(); |
| 601 | 601 | }}); |
| 602 | 602 | |
| 603 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=lastweek", success: function(result){
|
|
| 603 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=lastweek", success: function(result){
|
|
| 604 | 604 | ga_data2 = jQuery.parseJSON(result); |
| 605 | 605 | gd_renderWeekOverWeekChart(); |
| 606 | 606 | }}); |
@@ -610,14 +610,14 @@ discard block |
||
| 610 | 610 | |
| 611 | 611 | function gdga_yearVSyear(){
|
| 612 | 612 | |
| 613 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=thisyear", success: function(result){
|
|
| 613 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=thisyear", success: function(result){
|
|
| 614 | 614 | ga_data3 = jQuery.parseJSON(result); |
| 615 | 615 | if(ga_data3.error){jQuery('#ga_stats').html(result);return;}
|
| 616 | 616 | |
| 617 | 617 | gd_renderYearOverYearChart() |
| 618 | 618 | }}); |
| 619 | 619 | |
| 620 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=lastyear", success: function(result){
|
|
| 620 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=lastyear", success: function(result){
|
|
| 621 | 621 | ga_data4 = jQuery.parseJSON(result); |
| 622 | 622 | gd_renderYearOverYearChart() |
| 623 | 623 | }}); |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | |
| 628 | 628 | function gdga_country(){
|
| 629 | 629 | |
| 630 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=country", success: function(result){
|
|
| 630 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=country", success: function(result){
|
|
| 631 | 631 | ga_data5 = jQuery.parseJSON(result); |
| 632 | 632 | if(ga_data5.error){jQuery('#ga_stats').html(result);return;}
|
| 633 | 633 | gd_renderTopCountriesChart(); |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | |
| 638 | 638 | function gdga_realtime(){
|
| 639 | 639 | |
| 640 | - jQuery.ajax({url: "<?php echo get_bloginfo('url').'/?ptype=ga&ga_page='.$page_url; ?>&ga_type=realtime", success: function(result){
|
|
| 640 | + jQuery.ajax({url: "<?php echo get_bloginfo('url') . '/?ptype=ga&ga_page=' . $page_url; ?>&ga_type=realtime", success: function(result){
|
|
| 641 | 641 | ga_data6 = jQuery.parseJSON(result); |
| 642 | 642 | if(ga_data6.error){jQuery('#ga_stats').html(result);return;}
|
| 643 | 643 | gd_renderRealTime(); |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | function gdga_noResults(){
|
| 711 | - jQuery('#gdga-chart-container').html('<?php _e('No results available','geodirectory');?>');
|
|
| 711 | + jQuery('#gdga-chart-container').html('<?php _e('No results available', 'geodirectory'); ?>');
|
|
| 712 | 712 | jQuery('#gdga-legend-container').html('');
|
| 713 | 713 | } |
| 714 | 714 | |
@@ -746,18 +746,18 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | |
| 748 | 748 | |
| 749 | - var labels = ['<?php _e('Jan', 'geodirectory');?>',
|
|
| 750 | - '<?php _e('Feb', 'geodirectory');?>',
|
|
| 751 | - '<?php _e('Mar', 'geodirectory');?>',
|
|
| 752 | - '<?php _e('Apr', 'geodirectory');?>',
|
|
| 753 | - '<?php _e('May', 'geodirectory');?>',
|
|
| 754 | - '<?php _e('Jun', 'geodirectory');?>',
|
|
| 755 | - '<?php _e('Jul', 'geodirectory');?>',
|
|
| 756 | - '<?php _e('Aug', 'geodirectory');?>',
|
|
| 757 | - '<?php _e('Sep', 'geodirectory');?>',
|
|
| 758 | - '<?php _e('Oct', 'geodirectory');?>',
|
|
| 759 | - '<?php _e('Nov', 'geodirectory');?>',
|
|
| 760 | - '<?php _e('Dec', 'geodirectory');?>'];
|
|
| 749 | + var labels = ['<?php _e('Jan', 'geodirectory'); ?>',
|
|
| 750 | + '<?php _e('Feb', 'geodirectory'); ?>',
|
|
| 751 | + '<?php _e('Mar', 'geodirectory'); ?>',
|
|
| 752 | + '<?php _e('Apr', 'geodirectory'); ?>',
|
|
| 753 | + '<?php _e('May', 'geodirectory'); ?>',
|
|
| 754 | + '<?php _e('Jun', 'geodirectory'); ?>',
|
|
| 755 | + '<?php _e('Jul', 'geodirectory'); ?>',
|
|
| 756 | + '<?php _e('Aug', 'geodirectory'); ?>',
|
|
| 757 | + '<?php _e('Sep', 'geodirectory'); ?>',
|
|
| 758 | + '<?php _e('Oct', 'geodirectory'); ?>',
|
|
| 759 | + '<?php _e('Nov', 'geodirectory'); ?>',
|
|
| 760 | + '<?php _e('Dec', 'geodirectory'); ?>'];
|
|
| 761 | 761 | |
| 762 | 762 | |
| 763 | 763 | // Ensure the data arrays are at least as long as the labels array. |
@@ -772,13 +772,13 @@ discard block |
||
| 772 | 772 | labels : labels, |
| 773 | 773 | datasets : [ |
| 774 | 774 | {
|
| 775 | - label: '<?php _e('Last Year', 'geodirectory');?>',
|
|
| 775 | + label: '<?php _e('Last Year', 'geodirectory'); ?>',
|
|
| 776 | 776 | fillColor : "rgba(220,220,220,0.5)", |
| 777 | 777 | strokeColor : "rgba(220,220,220,1)", |
| 778 | 778 | data : data2 |
| 779 | 779 | }, |
| 780 | 780 | {
|
| 781 | - label: '<?php _e('This Year', 'geodirectory');?>',
|
|
| 781 | + label: '<?php _e('This Year', 'geodirectory'); ?>',
|
|
| 782 | 782 | fillColor : "rgba(151,187,205,0.5)", |
| 783 | 783 | strokeColor : "rgba(151,187,205,1)", |
| 784 | 784 | data : data1 |
@@ -828,23 +828,23 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | <?php |
| 830 | 830 | // Here we list the shorthand days of the week so it can be used in translation. |
| 831 | - __("Mon",'geodirectory');
|
|
| 832 | - __("Tue",'geodirectory');
|
|
| 833 | - __("Wed",'geodirectory');
|
|
| 834 | - __("Thu",'geodirectory');
|
|
| 835 | - __("Fri",'geodirectory');
|
|
| 836 | - __("Sat",'geodirectory');
|
|
| 837 | - __("Sun",'geodirectory');
|
|
| 831 | + __("Mon", 'geodirectory');
|
|
| 832 | + __("Tue", 'geodirectory');
|
|
| 833 | + __("Wed", 'geodirectory');
|
|
| 834 | + __("Thu", 'geodirectory');
|
|
| 835 | + __("Fri", 'geodirectory');
|
|
| 836 | + __("Sat", 'geodirectory');
|
|
| 837 | + __("Sun", 'geodirectory');
|
|
| 838 | 838 | ?> |
| 839 | 839 | |
| 840 | 840 | labels = [ |
| 841 | - "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>",
|
|
| 842 | - "<?php _e(date('D', strtotime("+2 day")),'geodirectory'); ?>",
|
|
| 843 | - "<?php _e(date('D', strtotime("+3 day")),'geodirectory'); ?>",
|
|
| 844 | - "<?php _e(date('D', strtotime("+4 day")),'geodirectory'); ?>",
|
|
| 845 | - "<?php _e(date('D', strtotime("+5 day")),'geodirectory'); ?>",
|
|
| 846 | - "<?php _e(date('D', strtotime("+6 day")),'geodirectory'); ?>",
|
|
| 847 | - "<?php _e(date('D', strtotime("+7 day")),'geodirectory'); ?>"
|
|
| 841 | + "<?php _e(date('D', strtotime("+1 day")), 'geodirectory'); ?>",
|
|
| 842 | + "<?php _e(date('D', strtotime("+2 day")), 'geodirectory'); ?>",
|
|
| 843 | + "<?php _e(date('D', strtotime("+3 day")), 'geodirectory'); ?>",
|
|
| 844 | + "<?php _e(date('D', strtotime("+4 day")), 'geodirectory'); ?>",
|
|
| 845 | + "<?php _e(date('D', strtotime("+5 day")), 'geodirectory'); ?>",
|
|
| 846 | + "<?php _e(date('D', strtotime("+6 day")), 'geodirectory'); ?>",
|
|
| 847 | + "<?php _e(date('D', strtotime("+7 day")), 'geodirectory'); ?>"
|
|
| 848 | 848 | ]; |
| 849 | 849 | |
| 850 | 850 | |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | labels : labels, |
| 854 | 854 | datasets : [ |
| 855 | 855 | {
|
| 856 | - label: '<?php _e('Last Week', 'geodirectory');?>',
|
|
| 856 | + label: '<?php _e('Last Week', 'geodirectory'); ?>',
|
|
| 857 | 857 | fillColor : "rgba(220,220,220,0.5)", |
| 858 | 858 | strokeColor : "rgba(220,220,220,1)", |
| 859 | 859 | pointColor : "rgba(220,220,220,1)", |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | data : data2 |
| 862 | 862 | }, |
| 863 | 863 | {
|
| 864 | - label: '<?php _e('This Week', 'geodirectory');?>',
|
|
| 864 | + label: '<?php _e('This Week', 'geodirectory'); ?>',
|
|
| 865 | 865 | fillColor : "rgba(151,187,205,0.5)", |
| 866 | 866 | strokeColor : "rgba(151,187,205,1)", |
| 867 | 867 | pointColor : "rgba(151,187,205,1)", |
@@ -1053,18 +1053,18 @@ discard block |
||
| 1053 | 1053 | |
| 1054 | 1054 | |
| 1055 | 1055 | <span id="ga_stats"> |
| 1056 | - <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory');?></div>
|
|
| 1056 | + <div id="ga-analytics-title"><?php _e("Analytics", 'geodirectory'); ?></div>
|
|
| 1057 | 1057 | |
| 1058 | 1058 | <div id="gd-active-users-container"> |
| 1059 | - <div class="gd-ActiveUsers"><?php _e("Active Users:", 'geodirectory');?>
|
|
| 1059 | + <div class="gd-ActiveUsers"><?php _e("Active Users:", 'geodirectory'); ?>
|
|
| 1060 | 1060 | <b class="gd-ActiveUsers-value">0</b> |
| 1061 | 1061 | </div> |
| 1062 | 1062 | </div> |
| 1063 | 1063 | |
| 1064 | 1064 | <select id="gdga-select-analytic" onchange="gdga_select_option();" style="display: none;"> |
| 1065 | - <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory');?></option>
|
|
| 1066 | - <option value="years"><?php _e("This Year vs Last Year", 'geodirectory');?></option>
|
|
| 1067 | - <option value="country"><?php _e("Top Countries", 'geodirectory');?></option>
|
|
| 1065 | + <option value="weeks"><?php _e("Last Week vs This Week", 'geodirectory'); ?></option>
|
|
| 1066 | + <option value="years"><?php _e("This Year vs Last Year", 'geodirectory'); ?></option>
|
|
| 1067 | + <option value="country"><?php _e("Top Countries", 'geodirectory'); ?></option>
|
|
| 1068 | 1068 | </select> |
| 1069 | 1069 | <img alt="loader icon" id="gdga-loader-icon" src="<?php echo geodir_plugin_url() . '/geodirectory-assets/images/ajax-loader.gif'; ?>" /> |
| 1070 | 1070 | <div class="Chartjs-figure" id="gdga-chart-container"></div> |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | $content_html = ob_get_clean(); |
| 1083 | 1083 | if (trim($content_html) != '') |
| 1084 | 1084 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
| 1085 | - if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
|
|
| 1085 | + if ((int) get_option('geodir_disable_google_analytics_section') != 1) {
|
|
| 1086 | 1086 | /** |
| 1087 | 1087 | * Filter the geodir_edit_post_link() function content. |
| 1088 | 1088 | * |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | if (trim($content_html) != '') {
|
| 1179 | 1179 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
| 1180 | 1180 | } |
| 1181 | - if ((int)get_option('geodir_disable_rating_info_section') != 1) {
|
|
| 1181 | + if ((int) get_option('geodir_disable_rating_info_section') != 1) {
|
|
| 1182 | 1182 | /** |
| 1183 | 1183 | * Filter the geodir_detail_page_review_rating() function content. |
| 1184 | 1184 | * |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | $content_html = ob_get_clean(); |
| 1219 | 1219 | if (trim($content_html) != '') |
| 1220 | 1220 | $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
| 1221 | - if ((int)get_option('geodir_disable_listing_info_section') != 1) {
|
|
| 1221 | + if ((int) get_option('geodir_disable_listing_info_section') != 1) {
|
|
| 1222 | 1222 | /** |
| 1223 | 1223 | * Filter the output html for function geodir_detail_page_more_info(). |
| 1224 | 1224 | * |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
|
| 1310 | 1310 | 'geodir_txt_form_wait' => __('Wait...', 'geodirectory'),
|
| 1311 | 1311 | 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
|
| 1312 | - 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
|
|
| 1312 | + 'fa_rating' => (int) get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
|
|
| 1313 | 1313 | 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
|
| 1314 | 1314 | ); |
| 1315 | 1315 | |
@@ -1326,7 +1326,7 @@ discard block |
||
| 1326 | 1326 | foreach ($arr_alert_msg as $key => $value) {
|
| 1327 | 1327 | if (!is_scalar($value)) |
| 1328 | 1328 | continue; |
| 1329 | - $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
| 1329 | + $arr_alert_msg[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | 1332 | $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
@@ -1502,7 +1502,7 @@ discard block |
||
| 1502 | 1502 | global $post; |
| 1503 | 1503 | $term_condition = ''; |
| 1504 | 1504 | if (isset($_REQUEST['backandedit'])) {
|
| 1505 | - $post = (object)$gd_session->get('listing');
|
|
| 1505 | + $post = (object) $gd_session->get('listing');
|
|
| 1506 | 1506 | $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
| 1507 | 1507 | } |
| 1508 | 1508 | |
@@ -1516,7 +1516,7 @@ discard block |
||
| 1516 | 1516 | echo 'checked="checked"'; |
| 1517 | 1517 | } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
| 1518 | 1518 | class="geodir_textfield" value="1" |
| 1519 | - style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
|
|
| 1519 | + style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if ($terms_page) { echo get_permalink($terms_page); }?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
|
|
| 1520 | 1520 | </span> |
| 1521 | 1521 | </div> |
| 1522 | 1522 | <span class="geodir_message_error"><?php if (isset($required_msg)) {
|
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | global $wpdb, $plugin_prefix; |
| 1624 | 1624 | |
| 1625 | 1625 | // Remove unused virtual page |
| 1626 | - $listings_page_id = (int)get_option('geodir_listing_page');
|
|
| 1626 | + $listings_page_id = (int) get_option('geodir_listing_page');
|
|
| 1627 | 1627 | if ($listings_page_id) {
|
| 1628 | 1628 | $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
|
| 1629 | 1629 | delete_option('geodir_listing_page');
|
@@ -1885,43 +1885,43 @@ discard block |
||
| 1885 | 1885 | |
| 1886 | 1886 | |
| 1887 | 1887 | $gd_page = ''; |
| 1888 | - if(geodir_is_page('home')){
|
|
| 1888 | + if (geodir_is_page('home')) {
|
|
| 1889 | 1889 | $gd_page = 'home'; |
| 1890 | 1890 | $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
|
| 1891 | 1891 | } |
| 1892 | - elseif(geodir_is_page('detail')){
|
|
| 1892 | + elseif (geodir_is_page('detail')) {
|
|
| 1893 | 1893 | $gd_page = 'detail'; |
| 1894 | 1894 | $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
|
| 1895 | 1895 | } |
| 1896 | - elseif(geodir_is_page('pt')){
|
|
| 1896 | + elseif (geodir_is_page('pt')) {
|
|
| 1897 | 1897 | $gd_page = 'pt'; |
| 1898 | 1898 | $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
|
| 1899 | 1899 | } |
| 1900 | - elseif(geodir_is_page('listing')){
|
|
| 1900 | + elseif (geodir_is_page('listing')) {
|
|
| 1901 | 1901 | $gd_page = 'listing'; |
| 1902 | 1902 | $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
|
| 1903 | 1903 | } |
| 1904 | - elseif(geodir_is_page('location')){
|
|
| 1904 | + elseif (geodir_is_page('location')) {
|
|
| 1905 | 1905 | $gd_page = 'location'; |
| 1906 | 1906 | $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
|
| 1907 | 1907 | } |
| 1908 | - elseif(geodir_is_page('search')){
|
|
| 1908 | + elseif (geodir_is_page('search')) {
|
|
| 1909 | 1909 | $gd_page = 'search'; |
| 1910 | 1910 | $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
|
| 1911 | 1911 | } |
| 1912 | - elseif(geodir_is_page('add-listing')){
|
|
| 1912 | + elseif (geodir_is_page('add-listing')) {
|
|
| 1913 | 1913 | $gd_page = 'add-listing'; |
| 1914 | 1914 | $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
|
| 1915 | 1915 | } |
| 1916 | - elseif(geodir_is_page('author')){
|
|
| 1916 | + elseif (geodir_is_page('author')) {
|
|
| 1917 | 1917 | $gd_page = 'author'; |
| 1918 | 1918 | $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
|
| 1919 | 1919 | } |
| 1920 | - elseif(geodir_is_page('login')){
|
|
| 1920 | + elseif (geodir_is_page('login')) {
|
|
| 1921 | 1921 | $gd_page = 'login'; |
| 1922 | 1922 | $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
|
| 1923 | 1923 | } |
| 1924 | - elseif(geodir_is_page('listing-success')){
|
|
| 1924 | + elseif (geodir_is_page('listing-success')) {
|
|
| 1925 | 1925 | $gd_page = 'listing-success'; |
| 1926 | 1926 | $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
|
| 1927 | 1927 | } |
@@ -2185,7 +2185,7 @@ discard block |
||
| 2185 | 2185 | */ |
| 2186 | 2186 | function geodir_remove_template_redirect_actions() |
| 2187 | 2187 | {
|
| 2188 | - if (geodir_is_page('login')){
|
|
| 2188 | + if (geodir_is_page('login')) {
|
|
| 2189 | 2189 | remove_all_actions('template_redirect');
|
| 2190 | 2190 | remove_action('init', 'avia_modify_front', 10);
|
| 2191 | 2191 | } |
@@ -2636,8 +2636,8 @@ discard block |
||
| 2636 | 2636 | $date_format = $date_format['date_format']; |
| 2637 | 2637 | } |
| 2638 | 2638 | |
| 2639 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 2640 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 2639 | + $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format
|
|
| 2640 | + $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format
|
|
| 2641 | 2641 | |
| 2642 | 2642 | $date_format = str_replace($search, $replace, $date_format); |
| 2643 | 2643 | |
@@ -2732,7 +2732,7 @@ discard block |
||
| 2732 | 2732 | $html_var = $type['htmlvar_name']; |
| 2733 | 2733 | $html_val = $type['htmlvar_name']; |
| 2734 | 2734 | |
| 2735 | - if ((int)$post->$html_var == 1) {
|
|
| 2735 | + if ((int) $post->$html_var == 1) {
|
|
| 2736 | 2736 | |
| 2737 | 2737 | if ($post->$type['htmlvar_name'] == '1') {
|
| 2738 | 2738 | $html_val = __('Yes', 'geodirectory');
|
@@ -2908,7 +2908,7 @@ discard block |
||
| 2908 | 2908 | |
| 2909 | 2909 | if (!empty($files)) {
|
| 2910 | 2910 | $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; |
| 2911 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 2911 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : '';
|
|
| 2912 | 2912 | |
| 2913 | 2913 | $file_paths = ''; |
| 2914 | 2914 | foreach ($files as $file) {
|
@@ -2936,7 +2936,7 @@ discard block |
||
| 2936 | 2936 | // If the uploaded file is image |
| 2937 | 2937 | if (in_array($uploaded_file_type, $image_file_types)) {
|
| 2938 | 2938 | $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
| 2939 | - $file_paths .= '<a href="'.$file.'">'; |
|
| 2939 | + $file_paths .= '<a href="' . $file . '">'; |
|
| 2940 | 2940 | $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
|
| 2941 | 2941 | $file_paths .= '</a>'; |
| 2942 | 2942 | $file_paths .= '</div>'; |
@@ -3286,7 +3286,7 @@ discard block |
||
| 3286 | 3286 | * @return array Translation texts. |
| 3287 | 3287 | */ |
| 3288 | 3288 | function geodir_load_gd_options_text_translation($translation_texts = array()) {
|
| 3289 | - $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
| 3289 | + $translation_texts = !empty($translation_texts) && is_array($translation_texts) ? $translation_texts : array(); |
|
| 3290 | 3290 | |
| 3291 | 3291 | $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content');
|
| 3292 | 3292 | |
@@ -184,17 +184,17 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
| 186 | 186 | if ($is_detail_page) {
|
| 187 | - wp_enqueue_script('geodirectory-post-custom-js');
|
|
| 188 | - } |
|
| 187 | + wp_enqueue_script('geodirectory-post-custom-js');
|
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | 190 | // font awesome rating script |
| 191 | - if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
|
| 192 | - wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 193 | - wp_enqueue_script('geodir-barrating-js');
|
|
| 194 | - } else { // default rating script
|
|
| 195 | - wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 196 | - wp_enqueue_script('geodir-jRating-js');
|
|
| 197 | - } |
|
| 191 | + if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
|
| 192 | + wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 193 | + wp_enqueue_script('geodir-barrating-js');
|
|
| 194 | + } else { // default rating script
|
|
| 195 | + wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 196 | + wp_enqueue_script('geodir-jRating-js');
|
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | 199 | wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
| 200 | 200 | wp_enqueue_script('geodir-on-document-load');
|
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | function geodir_footer_scripts() |
| 232 | 232 | {
|
| 233 | - echo stripslashes(get_option('geodir_ga_tracking_code'));
|
|
| 233 | + echo stripslashes(get_option('geodir_ga_tracking_code'));
|
|
| 234 | 234 | echo stripslashes(get_option('geodir_footer_scripts'));
|
| 235 | 235 | } |
| 236 | 236 | |
@@ -363,9 +363,9 @@ discard block |
||
| 363 | 363 | return; |
| 364 | 364 | |
| 365 | 365 | if (!is_single()) {
|
| 366 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 367 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 368 | - } |
|
| 366 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 367 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 368 | + } |
|
| 369 | 369 | $numposts = $wp_query->found_posts; |
| 370 | 370 | |
| 371 | 371 | |
@@ -376,22 +376,22 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | if ($max_page > 1 || $always_show) {
|
| 379 | - // Extra pagination info |
|
| 380 | - $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
|
|
| 381 | - $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
| 382 | - $end_no = min($paged * $posts_per_page, $numposts); |
|
| 379 | + // Extra pagination info |
|
| 380 | + $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
|
|
| 381 | + $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
| 382 | + $end_no = min($paged * $posts_per_page, $numposts); |
|
| 383 | 383 | |
| 384 | - if ($geodir_pagination_more_info != '') {
|
|
| 385 | - $pagination_info = '<div class="gd-pagination-details">' . wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts) . '</div>';
|
|
| 384 | + if ($geodir_pagination_more_info != '') {
|
|
| 385 | + $pagination_info = '<div class="gd-pagination-details">' . wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts) . '</div>';
|
|
| 386 | 386 | |
| 387 | - if ($geodir_pagination_more_info == 'before') {
|
|
| 388 | - $before = $before . $pagination_info; |
|
| 389 | - } else if ($geodir_pagination_more_info == 'after') {
|
|
| 390 | - $after = $pagination_info . $after; |
|
| 391 | - } |
|
| 392 | - } |
|
| 387 | + if ($geodir_pagination_more_info == 'before') {
|
|
| 388 | + $before = $before . $pagination_info; |
|
| 389 | + } else if ($geodir_pagination_more_info == 'after') {
|
|
| 390 | + $after = $pagination_info . $after; |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - echo "$before <div class='Navi'>"; |
|
| 394 | + echo "$before <div class='Navi'>"; |
|
| 395 | 395 | if ($paged >= ($pages_to_show - 1)) {
|
| 396 | 396 | echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link()) . '">«</a>';
|
| 397 | 397 | } |
@@ -412,9 +412,9 @@ discard block |
||
| 412 | 412 | echo "</div> $after"; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 416 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 417 | - } |
|
| 415 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 416 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 417 | + } |
|
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | {
|
| 38 | 38 | $is_detail_page = false; |
| 39 | 39 | |
| 40 | - if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
|
|
| 40 | + if ((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview'))) {
|
|
| 41 | 41 | $is_detail_page = true; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | 'siteurl' => get_option('siteurl'),
|
| 52 | 52 | 'geodir_plugin_url' => geodir_plugin_url(), |
| 53 | 53 | 'geodir_ajax_url' => geodir_get_ajax_url(), |
| 54 | - 'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
|
|
| 54 | + 'geodir_gd_modal' => (int) get_option('geodir_disable_gb_modal'),
|
|
| 55 | 55 | 'is_rtl' => is_rtl() ? 1 : 0 // fix rtl issue |
| 56 | 56 | ); |
| 57 | 57 | |
@@ -72,25 +72,25 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * } |
| 74 | 74 | */ |
| 75 | - $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
|
|
| 75 | + $geodir_vars_data = apply_filters('geodir_vars_data', $geodir_vars_data);
|
|
| 76 | 76 | |
| 77 | 77 | wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 83 | - if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
|
|
| 82 | + wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 83 | + if ($is_detail_page) {wp_enqueue_script('geodirectory-jquery-flexslider-js'); }
|
|
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 87 | + wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 88 | 88 | wp_enqueue_script('geodirectory-lightbox-jquery');
|
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | |
| 92 | - wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 93 | - if($is_detail_page){wp_enqueue_script('geodirectory-jquery-simplemodal');}
|
|
| 92 | + wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 93 | + if ($is_detail_page) {wp_enqueue_script('geodirectory-jquery-simplemodal'); }
|
|
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | //if( get_option('geodir_enqueue_google_api_script')==1)
|
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | wp_enqueue_script( 'geodirectory-googlemap-script' ); |
| 112 | 112 | } |
| 113 | 113 | */ |
| 114 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 114 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 115 | 115 | wp_enqueue_script('geodirectory-goMap-script');
|
| 116 | 116 | |
| 117 | 117 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | wp_enqueue_script('plupload-all');
|
| 134 | 134 | wp_enqueue_script('jquery-ui-sortable');
|
| 135 | 135 | |
| 136 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
|
|
| 136 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
|
| 137 | 137 | wp_enqueue_script('geodirectory-plupload-script');
|
| 138 | 138 | |
| 139 | 139 | // SCRIPT FOR UPLOAD END |
@@ -245,12 +245,12 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | function geodir_add_async_forscript($url) |
| 247 | 247 | {
|
| 248 | - if (strpos($url, '#asyncload')===false) |
|
| 248 | + if (strpos($url, '#asyncload') === false) |
|
| 249 | 249 | return $url; |
| 250 | 250 | else if (is_admin()) |
| 251 | 251 | return str_replace('#asyncload', '', $url);
|
| 252 | 252 | else |
| 253 | - return str_replace('#asyncload', '', $url)."' async='async";
|
|
| 253 | + return str_replace('#asyncload', '', $url) . "' async='async";
|
|
| 254 | 254 | } |
| 255 | 255 | add_filter('clean_url', 'geodir_add_async_forscript', 11, 1);
|
| 256 | 256 | |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | {
|
| 265 | 265 | |
| 266 | 266 | |
| 267 | - if(get_option('geodir_scss_core')) {
|
|
| 267 | + if (get_option('geodir_scss_core')) {
|
|
| 268 | 268 | |
| 269 | 269 | |
| 270 | 270 | wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
| 299 | 299 | wp_enqueue_style('geodir-chosen-style');
|
| 300 | 300 | |
| 301 | - }else{
|
|
| 301 | + } else {
|
|
| 302 | 302 | wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
|
| 303 | 303 | wp_enqueue_style('geodir-core-scss');
|
| 304 | 304 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - if(is_rtl()){
|
|
| 309 | + if (is_rtl()) {
|
|
| 310 | 310 | wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
|
| 311 | 311 | wp_enqueue_style('geodirectory-frontend-rtl-style');
|
| 312 | 312 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | if ($max_page > 1 || $always_show) {
|
| 379 | 379 | // Extra pagination info |
| 380 | 380 | $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
|
| 381 | - $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
| 381 | + $start_no = ($paged - 1) * $posts_per_page + 1; |
|
| 382 | 382 | $end_no = min($paged * $posts_per_page, $numposts); |
| 383 | 383 | |
| 384 | 384 | if ($geodir_pagination_more_info != '') {
|
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | jQuery(function ($) {
|
| 446 | 446 | $("#distance_slider").slider({
|
| 447 | 447 | range: true, |
| 448 | - values: [0, <?php echo ($_REQUEST['sdist']!='') ? $_REQUEST['sdist'] : "0"; ?>], |
|
| 448 | + values: [0, <?php echo ($_REQUEST['sdist'] != '') ? $_REQUEST['sdist'] : "0"; ?>], |
|
| 449 | 449 | min: 0, |
| 450 | 450 | max: <?php echo $dist; ?>, |
| 451 | 451 | step: <?php echo $dist_dif; ?>, |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | |
| 511 | 511 | |
| 512 | 512 | <script type="text/javascript"> |
| 513 | - var default_location = '<?php if($search_location = geodir_get_default_location()) echo $search_location->city ;?>'; |
|
| 513 | + var default_location = '<?php if ($search_location = geodir_get_default_location()) echo $search_location->city; ?>'; |
|
| 514 | 514 | var latlng; |
| 515 | 515 | var Sgeocoder; |
| 516 | 516 | var address; |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | var $form = jQuery(this).closest('form');
|
| 524 | 524 | |
| 525 | 525 | if (jQuery("#sdist input[type='radio']:checked").length != 0) dist = jQuery("#sdist input[type='radio']:checked").val();
|
| 526 | - if (jQuery('.search_text', $form).val() == '' || jQuery('.search_text', $form).val() == '<?php echo $default_search_for_text;?>') jQuery('.search_text', $form).val(s);
|
|
| 526 | + if (jQuery('.search_text', $form).val() == '' || jQuery('.search_text', $form).val() == '<?php echo $default_search_for_text; ?>') jQuery('.search_text', $form).val(s);
|
|
| 527 | 527 | |
| 528 | 528 | // Disable location based search for disabled location post type. |
| 529 | 529 | if (jQuery('.search_by_post', $form).val() != '' && typeof gd_cpt_no_location == 'function') {
|
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - if (dist > 0 || (jQuery('select[name="sort_by"]').val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest') || (jQuery(".snear", $form).val() != '' && jQuery(".snear", $form).val() != '<?php echo $default_near_text;?>')) {
|
|
| 540 | + if (dist > 0 || (jQuery('select[name="sort_by"]').val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest') || (jQuery(".snear", $form).val() != '' && jQuery(".snear", $form).val() != '<?php echo $default_near_text; ?>')) {
|
|
| 541 | 541 | geodir_setsearch($form); |
| 542 | 542 | } else {
|
| 543 | 543 | jQuery(".snear", $form).val('');
|
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | }); |
| 558 | 558 | |
| 559 | 559 | function geodir_setsearch($form) {
|
| 560 | - if ((dist > 0 || (jQuery('select[name="sort_by"]', $form).val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest')) && (jQuery(".snear", $form).val() == '' || jQuery(".snear", $form).val() == '<?php echo $default_near_text;?>')) jQuery(".snear", $form).val(default_location);
|
|
| 560 | + if ((dist > 0 || (jQuery('select[name="sort_by"]', $form).val() == 'nearest' || jQuery('select[name="sort_by"]', $form).val() == 'farthest')) && (jQuery(".snear", $form).val() == '' || jQuery(".snear", $form).val() == '<?php echo $default_near_text; ?>')) jQuery(".snear", $form).val(default_location);
|
|
| 561 | 561 | geocodeAddress($form); |
| 562 | 562 | } |
| 563 | 563 | |
@@ -570,8 +570,8 @@ discard block |
||
| 570 | 570 | function geocodeAddress($form) {
|
| 571 | 571 | Sgeocoder = new google.maps.Geocoder(); // Call the geocode function |
| 572 | 572 | |
| 573 | - if (jQuery('.snear', $form).val() == '' || ( jQuery('.sgeo_lat').val() != '' && jQuery('.sgeo_lon').val() != '' ) || jQuery('.snear', $form).val().match("^<?php _e('In:','geodirectory');?>")) {
|
|
| 574 | - if (jQuery('.snear', $form).val().match("^<?php _e('In:','geodirectory');?>")) {
|
|
| 573 | + if (jQuery('.snear', $form).val() == '' || ( jQuery('.sgeo_lat').val() != '' && jQuery('.sgeo_lon').val() != '' ) || jQuery('.snear', $form).val().match("^<?php _e('In:', 'geodirectory'); ?>")) {
|
|
| 574 | + if (jQuery('.snear', $form).val().match("^<?php _e('In:', 'geodirectory'); ?>")) {
|
|
| 575 | 575 | jQuery(".snear", $form).val('');
|
| 576 | 576 | } |
| 577 | 577 | jQuery($form).submit(); |
@@ -579,24 +579,24 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | var address = jQuery(".snear", $form).val();
|
| 581 | 581 | |
| 582 | - if (jQuery('.snear', $form).val() == '<?php echo $default_near_text;?>') {
|
|
| 582 | + if (jQuery('.snear', $form).val() == '<?php echo $default_near_text; ?>') {
|
|
| 583 | 583 | initialise2(); |
| 584 | 584 | } else {
|
| 585 | 585 | |
| 586 | 586 | Sgeocoder.geocode({'address': address<?php
|
| 587 | - if($near_add = get_option('geodir_search_near_addition')){echo '+", '.$near_add.'"';}
|
|
| 588 | - if($near_add2 = |
|
| 587 | + if ($near_add = get_option('geodir_search_near_addition')) {echo '+", ' . $near_add . '"'; }
|
|
| 588 | + if ($near_add2 = |
|
| 589 | 589 | /** |
| 590 | 590 | * Adds any extra info to the near search box query when trying to geolocate it via google api. |
| 591 | 591 | * |
| 592 | 592 | * @since 1.0.0 |
| 593 | 593 | */ |
| 594 | - apply_filters('geodir_search_near_addition','')){echo $near_add2;}//gt_advanced_near_search();?>},
|
|
| 594 | + apply_filters('geodir_search_near_addition', '')) {echo $near_add2; }//gt_advanced_near_search();?>},
|
|
| 595 | 595 | function (results, status) {
|
| 596 | 596 | if (status == google.maps.GeocoderStatus.OK) {
|
| 597 | 597 | updateSearchPosition(results[0].geometry.location, $form); |
| 598 | 598 | } else {
|
| 599 | - alert("<?php _e('Search was not successful for the following reason:','geodirectory');?>" + status);
|
|
| 599 | + alert("<?php _e('Search was not successful for the following reason:', 'geodirectory'); ?>" + status);
|
|
| 600 | 600 | } |
| 601 | 601 | }); |
| 602 | 602 | } |
@@ -627,19 +627,19 @@ discard block |
||
| 627 | 627 | var msg; |
| 628 | 628 | switch (err.code) {
|
| 629 | 629 | case err.UNKNOWN_ERROR: |
| 630 | - msg = "<?php _e('Unable to find your location','geodirectory');?>";
|
|
| 630 | + msg = "<?php _e('Unable to find your location', 'geodirectory'); ?>";
|
|
| 631 | 631 | break; |
| 632 | 632 | case err.PERMISSION_DENINED: |
| 633 | - msg = "<?php _e('Permission denied in finding your location','geodirectory');?>";
|
|
| 633 | + msg = "<?php _e('Permission denied in finding your location', 'geodirectory'); ?>";
|
|
| 634 | 634 | break; |
| 635 | 635 | case err.POSITION_UNAVAILABLE: |
| 636 | - msg = "<?php _e('Your location is currently unknown','geodirectory');?>";
|
|
| 636 | + msg = "<?php _e('Your location is currently unknown', 'geodirectory'); ?>";
|
|
| 637 | 637 | break; |
| 638 | 638 | case err.BREAK: |
| 639 | - msg = "<?php _e('Attempt to find location took too long','geodirectory');?>";
|
|
| 639 | + msg = "<?php _e('Attempt to find location took too long', 'geodirectory'); ?>";
|
|
| 640 | 640 | break; |
| 641 | 641 | default: |
| 642 | - msg = "<?php _e('Location detection not supported in browser','geodirectory');?>";
|
|
| 642 | + msg = "<?php _e('Location detection not supported in browser', 'geodirectory'); ?>";
|
|
| 643 | 643 | } |
| 644 | 644 | jQuery('#info').html(msg);
|
| 645 | 645 | } |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | * @param object $post The post object. |
| 680 | 680 | * @param string $link The link to the post. |
| 681 | 681 | */ |
| 682 | - return apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img"> </span></a>',$post,$link);
|
|
| 682 | + return apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img"> </span></a>', $post, $link);
|
|
| 683 | 683 | break; |
| 684 | 684 | case 'new' : |
| 685 | 685 | /** |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | * @param object $post The post object. |
| 690 | 690 | * @param string $link The link to the post. |
| 691 | 691 | */ |
| 692 | - return apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing"> </span></a>',$post,$link);
|
|
| 692 | + return apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing"> </span></a>', $post, $link);
|
|
| 693 | 693 | break; |
| 694 | 694 | |
| 695 | 695 | } |