@@ -2362,10 +2362,10 @@ discard block |
||
2362 | 2362 | ?> |
2363 | 2363 | <input class="search_text" name="s" |
2364 | 2364 | value="<?php if ( isset( $_REQUEST['s'] ) && trim( $_REQUEST['s'] ) != '' ) { |
2365 | - echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) ); |
|
2366 | - } else { |
|
2367 | - echo $default_search_for_text; |
|
2368 | - } ?>" type="text" |
|
2365 | + echo esc_attr( stripslashes_deep( $_REQUEST['s'] ) ); |
|
2366 | + } else { |
|
2367 | + echo $default_search_for_text; |
|
2368 | + } ?>" type="text" |
|
2369 | 2369 | onblur="if (this.value.trim() == '') {this.value = '<?php echo esc_sql( $default_search_for_text ); ?>';}" |
2370 | 2370 | onfocus="if (this.value == '<?php echo esc_sql( $default_search_for_text ); ?>') {this.value = '';}" |
2371 | 2371 | onkeydown="javascript: if(event.keyCode == 13) geodir_click_search(this);"> |
@@ -2492,11 +2492,11 @@ discard block |
||
2492 | 2492 | * @return True if WPML is active else False. |
2493 | 2493 | */ |
2494 | 2494 | function geodir_is_wpml() { |
2495 | - if (function_exists('icl_object_id')) { |
|
2496 | - return true; |
|
2497 | - } |
|
2495 | + if (function_exists('icl_object_id')) { |
|
2496 | + return true; |
|
2497 | + } |
|
2498 | 2498 | |
2499 | - return false; |
|
2499 | + return false; |
|
2500 | 2500 | } |
2501 | 2501 | |
2502 | 2502 | /** |
@@ -2511,9 +2511,9 @@ discard block |
||
2511 | 2511 | * @return Language code. |
2512 | 2512 | */ |
2513 | 2513 | function geodir_get_language_for_element($element_id, $element_type) { |
2514 | - global $sitepress; |
|
2514 | + global $sitepress; |
|
2515 | 2515 | |
2516 | - return $sitepress->get_language_for_element($element_id, $element_type); |
|
2516 | + return $sitepress->get_language_for_element($element_id, $element_type); |
|
2517 | 2517 | } |
2518 | 2518 | |
2519 | 2519 | /** |
@@ -2530,31 +2530,31 @@ discard block |
||
2530 | 2530 | * Added to fix duplicate transaltion for front end. |
2531 | 2531 | */ |
2532 | 2532 | function geodir_icl_make_duplicate($master_post_id, $lang, $postarr, $tr_post_id, $after_save = false) { |
2533 | - global $sitepress; |
|
2533 | + global $sitepress; |
|
2534 | 2534 | |
2535 | - $post_type = get_post_type($master_post_id); |
|
2536 | - $icl_ajx_action = !empty($_REQUEST['icl_ajx_action']) && $_REQUEST['icl_ajx_action'] == 'make_duplicates' ? true : false; |
|
2537 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpml_duplicate_dashboard' && !empty($_REQUEST['duplicate_post_ids'])) { |
|
2538 | - $icl_ajx_action = true; |
|
2539 | - } |
|
2535 | + $post_type = get_post_type($master_post_id); |
|
2536 | + $icl_ajx_action = !empty($_REQUEST['icl_ajx_action']) && $_REQUEST['icl_ajx_action'] == 'make_duplicates' ? true : false; |
|
2537 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpml_duplicate_dashboard' && !empty($_REQUEST['duplicate_post_ids'])) { |
|
2538 | + $icl_ajx_action = true; |
|
2539 | + } |
|
2540 | 2540 | |
2541 | - if (in_array($post_type, geodir_get_posttypes())) { |
|
2542 | - if ($icl_ajx_action || $after_save) { |
|
2543 | - // Duplicate post details |
|
2544 | - geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang); |
|
2541 | + if (in_array($post_type, geodir_get_posttypes())) { |
|
2542 | + if ($icl_ajx_action || $after_save) { |
|
2543 | + // Duplicate post details |
|
2544 | + geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang); |
|
2545 | 2545 | |
2546 | - // Duplicate taxonomies |
|
2547 | - geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang); |
|
2546 | + // Duplicate taxonomies |
|
2547 | + geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang); |
|
2548 | 2548 | |
2549 | - // Duplicate post images |
|
2550 | - geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang); |
|
2551 | - } |
|
2549 | + // Duplicate post images |
|
2550 | + geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang); |
|
2551 | + } |
|
2552 | 2552 | |
2553 | - // Sync post reviews |
|
2554 | - if ($sitepress->get_setting('sync_comments_on_duplicates')) { |
|
2555 | - geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang); |
|
2556 | - } |
|
2557 | - } |
|
2553 | + // Sync post reviews |
|
2554 | + if ($sitepress->get_setting('sync_comments_on_duplicates')) { |
|
2555 | + geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang); |
|
2556 | + } |
|
2557 | + } |
|
2558 | 2558 | } |
2559 | 2559 | add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); |
2560 | 2560 | |
@@ -2568,18 +2568,18 @@ discard block |
||
2568 | 2568 | * @param array $request_info The post details in an array. |
2569 | 2569 | */ |
2570 | 2570 | function geodir_wpml_duplicate_listing($post_id, $request_info) { |
2571 | - global $sitepress; |
|
2571 | + global $sitepress; |
|
2572 | 2572 | |
2573 | - $icl_ajx_action = !empty($_REQUEST['icl_ajx_action']) && $_REQUEST['icl_ajx_action'] == 'make_duplicates' ? true : false; |
|
2574 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpml_duplicate_dashboard' && !empty($_REQUEST['duplicate_post_ids'])) { |
|
2575 | - $icl_ajx_action = true; |
|
2576 | - } |
|
2573 | + $icl_ajx_action = !empty($_REQUEST['icl_ajx_action']) && $_REQUEST['icl_ajx_action'] == 'make_duplicates' ? true : false; |
|
2574 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'wpml_duplicate_dashboard' && !empty($_REQUEST['duplicate_post_ids'])) { |
|
2575 | + $icl_ajx_action = true; |
|
2576 | + } |
|
2577 | 2577 | |
2578 | - if (!$icl_ajx_action && in_array(get_post_type($post_id), geodir_get_posttypes()) && $post_duplicates = $sitepress->get_duplicates($post_id)) { |
|
2579 | - foreach ($post_duplicates as $lang => $dup_post_id) { |
|
2580 | - geodir_icl_make_duplicate($post_id, $lang, $request_info, $dup_post_id, true); |
|
2581 | - } |
|
2582 | - } |
|
2578 | + if (!$icl_ajx_action && in_array(get_post_type($post_id), geodir_get_posttypes()) && $post_duplicates = $sitepress->get_duplicates($post_id)) { |
|
2579 | + foreach ($post_duplicates as $lang => $dup_post_id) { |
|
2580 | + geodir_icl_make_duplicate($post_id, $lang, $request_info, $dup_post_id, true); |
|
2581 | + } |
|
2582 | + } |
|
2583 | 2583 | } |
2584 | 2584 | |
2585 | 2585 | /** |
@@ -2595,17 +2595,17 @@ discard block |
||
2595 | 2595 | * @return bool True for success, False for fail. |
2596 | 2596 | */ |
2597 | 2597 | function geodir_wpml_duplicate_post_reviews($master_post_id, $tr_post_id, $lang) { |
2598 | - global $wpdb; |
|
2598 | + global $wpdb; |
|
2599 | 2599 | |
2600 | - $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A); |
|
2600 | + $reviews = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM " . GEODIR_REVIEW_TABLE . " WHERE post_id=%d ORDER BY id ASC", $master_post_id), ARRAY_A); |
|
2601 | 2601 | |
2602 | - if (!empty($reviews)) { |
|
2603 | - foreach ($reviews as $review) { |
|
2604 | - geodir_wpml_duplicate_post_review($review['comment_id'], $master_post_id, $tr_post_id, $lang); |
|
2605 | - } |
|
2606 | - } |
|
2602 | + if (!empty($reviews)) { |
|
2603 | + foreach ($reviews as $review) { |
|
2604 | + geodir_wpml_duplicate_post_review($review['comment_id'], $master_post_id, $tr_post_id, $lang); |
|
2605 | + } |
|
2606 | + } |
|
2607 | 2607 | |
2608 | - return false; |
|
2608 | + return false; |
|
2609 | 2609 | } |
2610 | 2610 | |
2611 | 2611 | /** |
@@ -2622,22 +2622,22 @@ discard block |
||
2622 | 2622 | * @return bool True for success, False for fail. |
2623 | 2623 | */ |
2624 | 2624 | function geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang) { |
2625 | - global $wpdb, $plugin_prefix; |
|
2625 | + global $wpdb, $plugin_prefix; |
|
2626 | 2626 | |
2627 | - $post_type = get_post_type($master_post_id); |
|
2628 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
2627 | + $post_type = get_post_type($master_post_id); |
|
2628 | + $post_table = $plugin_prefix . $post_type . '_detail'; |
|
2629 | 2629 | |
2630 | - $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id)); |
|
2631 | - $data = (array)$wpdb->get_row($query); |
|
2630 | + $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id)); |
|
2631 | + $data = (array)$wpdb->get_row($query); |
|
2632 | 2632 | |
2633 | - if ( !empty( $data ) ) { |
|
2634 | - $data['post_id'] = $tr_post_id; |
|
2635 | - unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category']); |
|
2636 | - $wpdb->update($post_table, $data, array('post_id' => $tr_post_id)); |
|
2637 | - return true; |
|
2638 | - } |
|
2633 | + if ( !empty( $data ) ) { |
|
2634 | + $data['post_id'] = $tr_post_id; |
|
2635 | + unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category']); |
|
2636 | + $wpdb->update($post_table, $data, array('post_id' => $tr_post_id)); |
|
2637 | + return true; |
|
2638 | + } |
|
2639 | 2639 | |
2640 | - return false; |
|
2640 | + return false; |
|
2641 | 2641 | } |
2642 | 2642 | |
2643 | 2643 | /** |
@@ -2654,40 +2654,40 @@ discard block |
||
2654 | 2654 | * @return bool True for success, False for fail. |
2655 | 2655 | */ |
2656 | 2656 | function geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang) { |
2657 | - global $sitepress, $wpdb; |
|
2658 | - $post_type = get_post_type($master_post_id); |
|
2657 | + global $sitepress, $wpdb; |
|
2658 | + $post_type = get_post_type($master_post_id); |
|
2659 | 2659 | |
2660 | - remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language |
|
2660 | + remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language |
|
2661 | 2661 | |
2662 | - $taxonomies = get_object_taxonomies($post_type); |
|
2663 | - foreach ($taxonomies as $taxonomy) { |
|
2664 | - $terms = get_the_terms($master_post_id, $taxonomy); |
|
2665 | - $terms_array = array(); |
|
2662 | + $taxonomies = get_object_taxonomies($post_type); |
|
2663 | + foreach ($taxonomies as $taxonomy) { |
|
2664 | + $terms = get_the_terms($master_post_id, $taxonomy); |
|
2665 | + $terms_array = array(); |
|
2666 | 2666 | |
2667 | - if ($terms) { |
|
2668 | - foreach ($terms as $term) { |
|
2669 | - $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
2667 | + if ($terms) { |
|
2668 | + foreach ($terms as $term) { |
|
2669 | + $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
2670 | 2670 | |
2671 | - if (!is_null($tr_id)){ |
|
2672 | - // not using get_term - unfiltered get_term |
|
2673 | - $translated_term = $wpdb->get_row($wpdb->prepare(" |
|
2671 | + if (!is_null($tr_id)){ |
|
2672 | + // not using get_term - unfiltered get_term |
|
2673 | + $translated_term = $wpdb->get_row($wpdb->prepare(" |
|
2674 | 2674 | 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)); |
2675 | 2675 | |
2676 | - $terms_array[] = $translated_term->term_id; |
|
2677 | - } |
|
2678 | - } |
|
2676 | + $terms_array[] = $translated_term->term_id; |
|
2677 | + } |
|
2678 | + } |
|
2679 | 2679 | |
2680 | - if (!is_taxonomy_hierarchical($taxonomy)){ |
|
2681 | - $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
2682 | - } |
|
2680 | + if (!is_taxonomy_hierarchical($taxonomy)){ |
|
2681 | + $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
2682 | + } |
|
2683 | 2683 | |
2684 | - wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
|
2684 | + wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
|
2685 | 2685 | |
2686 | - if ($taxonomy == $post_type . 'category') { |
|
2687 | - geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
2688 | - } |
|
2689 | - } |
|
2690 | - } |
|
2686 | + if ($taxonomy == $post_type . 'category') { |
|
2687 | + geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
2688 | + } |
|
2689 | + } |
|
2690 | + } |
|
2691 | 2691 | } |
2692 | 2692 | |
2693 | 2693 | /** |
@@ -2703,29 +2703,29 @@ discard block |
||
2703 | 2703 | * @return bool True for success, False for fail. |
2704 | 2704 | */ |
2705 | 2705 | function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) { |
2706 | - global $wpdb; |
|
2706 | + global $wpdb; |
|
2707 | 2707 | |
2708 | - $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id)); |
|
2709 | - $wpdb->query($query); |
|
2708 | + $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id)); |
|
2709 | + $wpdb->query($query); |
|
2710 | 2710 | |
2711 | - $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id)); |
|
2712 | - $post_images = $wpdb->get_results($query); |
|
2711 | + $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id)); |
|
2712 | + $post_images = $wpdb->get_results($query); |
|
2713 | 2713 | |
2714 | - if ( !empty( $post_images ) ) { |
|
2715 | - foreach ( $post_images as $post_image) { |
|
2716 | - $image_data = (array)$post_image; |
|
2717 | - unset($image_data['ID']); |
|
2718 | - $image_data['post_id'] = $tr_post_id; |
|
2714 | + if ( !empty( $post_images ) ) { |
|
2715 | + foreach ( $post_images as $post_image) { |
|
2716 | + $image_data = (array)$post_image; |
|
2717 | + unset($image_data['ID']); |
|
2718 | + $image_data['post_id'] = $tr_post_id; |
|
2719 | 2719 | |
2720 | - $wpdb->insert(GEODIR_ATTACHMENT_TABLE, $image_data); |
|
2720 | + $wpdb->insert(GEODIR_ATTACHMENT_TABLE, $image_data); |
|
2721 | 2721 | |
2722 | - geodir_set_wp_featured_image($tr_post_id); |
|
2723 | - } |
|
2722 | + geodir_set_wp_featured_image($tr_post_id); |
|
2723 | + } |
|
2724 | 2724 | |
2725 | - return true; |
|
2726 | - } |
|
2725 | + return true; |
|
2726 | + } |
|
2727 | 2727 | |
2728 | - return false; |
|
2728 | + return false; |
|
2729 | 2729 | } |
2730 | 2730 | |
2731 | 2731 | |
@@ -2744,73 +2744,73 @@ discard block |
||
2744 | 2744 | * @return bool True for success, False for fail. |
2745 | 2745 | */ |
2746 | 2746 | function geodir_wpml_duplicate_post_review($master_comment_id, $master_post_id, $tr_post_id, $lang) { |
2747 | - global $wpdb, $plugin_prefix, $sitepress; |
|
2748 | - |
|
2749 | - $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A); |
|
2750 | - |
|
2751 | - if (empty($review)) { |
|
2752 | - return false; |
|
2753 | - } |
|
2754 | - if ($review['post_id'] != $master_post_id) { |
|
2755 | - $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id)); |
|
2756 | - geodir_update_postrating($master_post_id, $post_type); |
|
2757 | - } |
|
2758 | - |
|
2759 | - $tr_comment_id = geodir_wpml_duplicate_comment_exists($tr_post_id, $master_comment_id); |
|
2760 | - |
|
2761 | - if (empty($tr_comment_id)) { |
|
2762 | - return false; |
|
2763 | - } |
|
2764 | - |
|
2765 | - $post_type = get_post_type($master_post_id); |
|
2766 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
2767 | - |
|
2768 | - $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM " . $post_table . " WHERE post_id = %d", $tr_post_id), ARRAY_A); |
|
2769 | - if (empty($translated_post)) { |
|
2770 | - return false; |
|
2771 | - } |
|
2772 | - |
|
2773 | - $review['comment_id'] = $tr_comment_id; |
|
2774 | - $review['post_id'] = $tr_post_id; |
|
2775 | - $review['post_title'] = $translated_post['post_title']; |
|
2776 | - $review['post_city'] = $translated_post['post_city']; |
|
2777 | - $review['post_region'] = $translated_post['post_region']; |
|
2778 | - $review['post_country'] = $translated_post['post_country']; |
|
2779 | - $review['post_latitude'] = $translated_post['post_latitude']; |
|
2780 | - $review['post_longitude'] = $translated_post['post_longitude']; |
|
2781 | - |
|
2782 | - if (isset($review['id'])) { |
|
2783 | - unset($review['id']); |
|
2784 | - } |
|
2785 | - |
|
2786 | - $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id)); |
|
2787 | - |
|
2788 | - if ($tr_review_id) { // update review |
|
2789 | - $wpdb->update(GEODIR_REVIEW_TABLE, $review, array('id' => $tr_review_id)); |
|
2790 | - } else { // insert review |
|
2791 | - $wpdb->insert(GEODIR_REVIEW_TABLE, $review); |
|
2792 | - $tr_review_id = $wpdb->insert_id; |
|
2793 | - } |
|
2794 | - |
|
2795 | - if ($tr_post_id) { |
|
2796 | - geodir_update_postrating($tr_post_id, $post_type); |
|
2747 | + global $wpdb, $plugin_prefix, $sitepress; |
|
2748 | + |
|
2749 | + $review = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d ORDER BY id ASC", $master_comment_id), ARRAY_A); |
|
2750 | + |
|
2751 | + if (empty($review)) { |
|
2752 | + return false; |
|
2753 | + } |
|
2754 | + if ($review['post_id'] != $master_post_id) { |
|
2755 | + $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_REVIEW_TABLE . " SET post_id=%d WHERE comment_id=%d", $master_post_id, $master_comment_id)); |
|
2756 | + geodir_update_postrating($master_post_id, $post_type); |
|
2757 | + } |
|
2758 | + |
|
2759 | + $tr_comment_id = geodir_wpml_duplicate_comment_exists($tr_post_id, $master_comment_id); |
|
2760 | + |
|
2761 | + if (empty($tr_comment_id)) { |
|
2762 | + return false; |
|
2763 | + } |
|
2764 | + |
|
2765 | + $post_type = get_post_type($master_post_id); |
|
2766 | + $post_table = $plugin_prefix . $post_type . '_detail'; |
|
2767 | + |
|
2768 | + $translated_post = $wpdb->get_row($wpdb->prepare("SELECT post_title, post_latitude, post_longitude, post_city, post_region, post_country FROM " . $post_table . " WHERE post_id = %d", $tr_post_id), ARRAY_A); |
|
2769 | + if (empty($translated_post)) { |
|
2770 | + return false; |
|
2771 | + } |
|
2772 | + |
|
2773 | + $review['comment_id'] = $tr_comment_id; |
|
2774 | + $review['post_id'] = $tr_post_id; |
|
2775 | + $review['post_title'] = $translated_post['post_title']; |
|
2776 | + $review['post_city'] = $translated_post['post_city']; |
|
2777 | + $review['post_region'] = $translated_post['post_region']; |
|
2778 | + $review['post_country'] = $translated_post['post_country']; |
|
2779 | + $review['post_latitude'] = $translated_post['post_latitude']; |
|
2780 | + $review['post_longitude'] = $translated_post['post_longitude']; |
|
2781 | + |
|
2782 | + if (isset($review['id'])) { |
|
2783 | + unset($review['id']); |
|
2784 | + } |
|
2785 | + |
|
2786 | + $tr_review_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_id=%d AND post_id=%d ORDER BY id ASC", $tr_comment_id, $tr_post_id)); |
|
2787 | + |
|
2788 | + if ($tr_review_id) { // update review |
|
2789 | + $wpdb->update(GEODIR_REVIEW_TABLE, $review, array('id' => $tr_review_id)); |
|
2790 | + } else { // insert review |
|
2791 | + $wpdb->insert(GEODIR_REVIEW_TABLE, $review); |
|
2792 | + $tr_review_id = $wpdb->insert_id; |
|
2793 | + } |
|
2794 | + |
|
2795 | + if ($tr_post_id) { |
|
2796 | + geodir_update_postrating($tr_post_id, $post_type); |
|
2797 | 2797 | |
2798 | - if (defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_review') && $sitepress->get_setting('sync_comments_on_duplicates')) { |
|
2799 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id = %d", array($tr_comment_id))); |
|
2800 | - $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A); |
|
2801 | - |
|
2802 | - if (!empty($likes)) { |
|
2803 | - foreach ($likes as $like) { |
|
2804 | - unset($like['like_id']); |
|
2805 | - $like['comment_id'] = $tr_comment_id; |
|
2798 | + if (defined('GEODIRREVIEWRATING_VERSION') && get_option('geodir_reviewrating_enable_review') && $sitepress->get_setting('sync_comments_on_duplicates')) { |
|
2799 | + $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id = %d", array($tr_comment_id))); |
|
2800 | + $likes = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_COMMENTS_REVIEWS_TABLE . " WHERE comment_id=%d ORDER BY like_date ASC", $master_comment_id, $tr_post_id), ARRAY_A); |
|
2801 | + |
|
2802 | + if (!empty($likes)) { |
|
2803 | + foreach ($likes as $like) { |
|
2804 | + unset($like['like_id']); |
|
2805 | + $like['comment_id'] = $tr_comment_id; |
|
2806 | 2806 | |
2807 | - $wpdb->insert(GEODIR_COMMENTS_REVIEWS_TABLE, $like); |
|
2808 | - } |
|
2809 | - } |
|
2810 | - } |
|
2811 | - } |
|
2807 | + $wpdb->insert(GEODIR_COMMENTS_REVIEWS_TABLE, $like); |
|
2808 | + } |
|
2809 | + } |
|
2810 | + } |
|
2811 | + } |
|
2812 | 2812 | |
2813 | - return $tr_review_id; |
|
2813 | + return $tr_review_id; |
|
2814 | 2814 | } |
2815 | 2815 | |
2816 | 2816 | /** |
@@ -2825,36 +2825,36 @@ discard block |
||
2825 | 2825 | * @param int $comment_id The Comment ID. |
2826 | 2826 | */ |
2827 | 2827 | function gepdir_wpml_sync_comment($comment_id) { |
2828 | - global $wpdb, $sitepress, $gd_wpml_posttypes; |
|
2829 | - |
|
2830 | - if (empty($gd_post_types)) { |
|
2831 | - $gd_wpml_posttypes = geodir_get_posttypes(); |
|
2832 | - } |
|
2833 | - |
|
2834 | - $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID=%d", $comment_id), ARRAY_A); |
|
2835 | - if (empty($comment)) { |
|
2836 | - return; |
|
2837 | - } |
|
2838 | - |
|
2839 | - $post_id = $comment['comment_post_ID']; |
|
2840 | - $post_type = $post_id ? get_post_type($post_id) : NULL; |
|
2841 | - |
|
2842 | - if (!($post_type && in_array($post_type, $gd_wpml_posttypes))) { |
|
2843 | - return; |
|
2844 | - } |
|
2845 | - |
|
2846 | - $post_duplicates = $sitepress->get_duplicates($post_id); |
|
2847 | - if (empty($post_duplicates)) { |
|
2848 | - return; |
|
2849 | - } |
|
2850 | - |
|
2851 | - foreach ($post_duplicates as $lang => $dup_post_id) { |
|
2852 | - if (empty($comment['comment_parent'])) { |
|
2853 | - geodir_wpml_duplicate_post_review($comment_id, $post_id, $dup_post_id, $lang); |
|
2854 | - } |
|
2855 | - } |
|
2828 | + global $wpdb, $sitepress, $gd_wpml_posttypes; |
|
2829 | + |
|
2830 | + if (empty($gd_post_types)) { |
|
2831 | + $gd_wpml_posttypes = geodir_get_posttypes(); |
|
2832 | + } |
|
2833 | + |
|
2834 | + $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_ID=%d", $comment_id), ARRAY_A); |
|
2835 | + if (empty($comment)) { |
|
2836 | + return; |
|
2837 | + } |
|
2838 | + |
|
2839 | + $post_id = $comment['comment_post_ID']; |
|
2840 | + $post_type = $post_id ? get_post_type($post_id) : NULL; |
|
2841 | + |
|
2842 | + if (!($post_type && in_array($post_type, $gd_wpml_posttypes))) { |
|
2843 | + return; |
|
2844 | + } |
|
2845 | + |
|
2846 | + $post_duplicates = $sitepress->get_duplicates($post_id); |
|
2847 | + if (empty($post_duplicates)) { |
|
2848 | + return; |
|
2849 | + } |
|
2850 | + |
|
2851 | + foreach ($post_duplicates as $lang => $dup_post_id) { |
|
2852 | + if (empty($comment['comment_parent'])) { |
|
2853 | + geodir_wpml_duplicate_post_review($comment_id, $post_id, $dup_post_id, $lang); |
|
2854 | + } |
|
2855 | + } |
|
2856 | 2856 | |
2857 | - return true; |
|
2857 | + return true; |
|
2858 | 2858 | } |
2859 | 2859 | |
2860 | 2860 | /** |
@@ -2869,11 +2869,11 @@ discard block |
||
2869 | 2869 | * @return int The duplicate comment ID. |
2870 | 2870 | */ |
2871 | 2871 | function geodir_wpml_duplicate_comment_exists($dup_post_id, $original_cid) { |
2872 | - global $wpdb; |
|
2872 | + global $wpdb; |
|
2873 | 2873 | |
2874 | - $duplicate = $wpdb->get_var( |
|
2875 | - $wpdb->prepare( |
|
2876 | - " SELECT comm.comment_ID |
|
2874 | + $duplicate = $wpdb->get_var( |
|
2875 | + $wpdb->prepare( |
|
2876 | + " SELECT comm.comment_ID |
|
2877 | 2877 | FROM {$wpdb->comments} comm |
2878 | 2878 | JOIN {$wpdb->commentmeta} cm |
2879 | 2879 | ON comm.comment_ID = cm.comment_id |
@@ -2881,12 +2881,12 @@ discard block |
||
2881 | 2881 | AND cm.meta_key = '_icl_duplicate_of' |
2882 | 2882 | AND cm.meta_value = %d |
2883 | 2883 | LIMIT 1", |
2884 | - $dup_post_id, |
|
2885 | - $original_cid |
|
2886 | - ) |
|
2887 | - ); |
|
2884 | + $dup_post_id, |
|
2885 | + $original_cid |
|
2886 | + ) |
|
2887 | + ); |
|
2888 | 2888 | |
2889 | - return $duplicate; |
|
2889 | + return $duplicate; |
|
2890 | 2890 | } |
2891 | 2891 | |
2892 | 2892 | /** |