Changeset 3170241
- Timestamp:
- 10/16/2024 04:09:34 PM (18 months ago)
- Location:
- mlsimport
- Files:
-
- 8 edited
- 1 copied
-
tags/5.8.4 (copied) (copied from mlsimport/trunk)
-
tags/5.8.4/admin/class-mlsimport-admin.php (modified) (10 diffs)
-
tags/5.8.4/admin/partials/mlsimport-administrative-options.php (modified) (1 diff)
-
tags/5.8.4/includes/ThemeImport.php (modified) (7 diffs)
-
tags/5.8.4/mlsimport.php (modified) (2 diffs)
-
trunk/admin/class-mlsimport-admin.php (modified) (10 diffs)
-
trunk/admin/partials/mlsimport-administrative-options.php (modified) (1 diff)
-
trunk/includes/ThemeImport.php (modified) (7 diffs)
-
trunk/mlsimport.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mlsimport/tags/5.8.4/admin/class-mlsimport-admin.php
r3134790 r3170241 543 543 public function mlsimport_hidden_fields() { 544 544 global $post; 545 545 546 $options = get_option( $this->plugin_name . '_admin_fields_select' ); 546 echo 'ListingKey: '.get_post_meta( $post->ID, 'ListingKey', true ).'<br>'; 547 548 $MLSimport_item_inserted = get_post_meta( $post->ID, 'MLSimport_item_inserted', true ); 549 $MLSimport_item_updated = get_post_meta( $post->ID, 'MLSimport_item_updated', true ); 550 $listing_key = get_post_meta( $post->ID, 'ListingKey', true ); 551 $mlsImportItemStatusDelete = get_post_meta($post->ID, 'mlsImportItemStatusDelete', true); 552 553 554 555 // Check if the ListingKey exists 556 if ( !empty( $listing_key ) ) { 557 echo 'ListingKey: ' . $listing_key . '<br>'; 558 } 559 560 // Check if MLSimport_item_inserted exists 561 if ( !empty( $MLSimport_item_inserted ) ) { 562 echo 'Added via MLS item id: ' . $MLSimport_item_inserted . ' - ' . get_the_title( $MLSimport_item_inserted ) . '<br>'; 563 } 564 565 // Check if MLSimport_item_updated exists 566 if ( !empty( $MLSimport_item_updated ) ) { 567 echo 'Updated via MLS item id: ' . $MLSimport_item_updated . ' - ' . get_the_title( $MLSimport_item_updated ) . '<br>'; 568 } 569 570 571 if(!empty($mlsImportItemStatusDelete)) { 572 if(is_array($mlsImportItemStatusDelete)) { 573 574 echo 'Do not delete if status: ' . implode(',' ,$mlsImportItemStatusDelete) . '<br>'; 575 } else { 576 577 echo 'Do not delete if status: ' . esc_html($mlsImportItemStatusDelete) . '<br>'; 578 579 } 580 581 } 582 547 583 foreach ( $options['mls-fields-admin'] as $key => $value ) { 548 584 if ( 1 === intval($options['mls-fields-admin'][ $key ] ) ) { … … 663 699 } 664 700 665 $mlsimport->admin->theme_importer->mlsimport _saas_delete_property_via_mysql( $delete_get_id, ' delete from tools ' );701 $mlsimport->admin->theme_importer->mlsimportSaasDeletePropertyViaMysql( $delete_get_id, ' delete from tools ' ); 666 702 } 667 703 … … 1355 1391 $last_date = $this->mlsimport_saas_update_last_date( $item_id ); 1356 1392 } 1357 1358 1393 return $last_date; 1359 1394 } … … 1368 1403 1369 1404 $unix_time = current_time( 'timestamp', 0 ) - ( 2 * 60 * 60 ); 1370 $last_date_to_save = date( 'Y-m-d\TH:i', $unix_time );1405 print $last_date_to_save = date( 'Y-m-d\TH:i', $unix_time ); 1371 1406 update_post_meta( $item_id, 'mlsimport_last_date', $last_date_to_save ); 1372 1407 … … 1384 1419 1385 1420 $last_date = $this->mlsimport_saas_get_last_date( $item_id ); 1386 1387 esc_html_e('we work with','mlsimport').' '. esc_html($last_date ). PHP_EOL; 1421 print 'MLSitem id: '.$item_id.' - '; 1422 esc_html_e('date to consider: ','mlsimport'); 1423 print esc_html($last_date ). '. '; 1388 1424 1389 1425 $mlsrequest = $this->mlsimport_make_listing_requests( $item_id, $last_date ); 1426 1390 1427 $found_items = 0; 1391 1428 if ( isset( $mlsrequest['results'] ) ) { … … 1395 1432 } 1396 1433 1397 print esc_html__(' we found ','mlsimport') .esc_html( $found_items ). '</br>' . PHP_EOL;1434 print esc_html__('We found ','mlsimport') .esc_html( $found_items ). ' listings.</br>' . PHP_EOL; 1398 1435 1399 1436 $attachments_to_move = array(); … … 1443 1480 return; 1444 1481 } 1445 1482 1446 1483 1447 1484 $mls_data = $this->mlsimport_saas_get_mls_reconciliation_data(); … … 1458 1495 $property_id = $item->iD; 1459 1496 ++$counter; 1497 1498 //print '</br>'.$counter. ' **************************</br>'; 1460 1499 1461 if ( in_array( $listingkey, $listingKey_in_MLS ) ) {1500 if ( in_array( $listingkey, $listingKey_in_MLS ) ) { 1462 1501 print wp_kses_post('</br>'.$listingkey . ' IS FOUND'); 1463 1502 } else { 1464 $delete_status= get_post_meta( $property_id, 'mlsImportItemStatusDelete', true ); 1465 1466 if($delete_status=='' || $delete_status=='delete'){ 1503 1504 $keep = $mlsimport->admin->theme_importer->check_if_delete_when_status($property_id); 1505 1506 if(!$keep){ 1467 1507 ++$to_delete; 1468 print wp_kses_post('</br>' .$listingkey. ' ------------------------- NOT FOUND delete: '.$property_id.' <-');1469 // $mlsimport->admin->theme_importer->mlsimport_saas_delete_property_via_mysql( $property_id, $listingkey );1508 print wp_kses_post('</br>' .$listingkey. ' ------------------------- NOT FOUND delete: '.$property_id.' /'.$post_status.'<-'); 1509 $mlsimport->admin->theme_importer->mlsimportSaasDeletePropertyViaMysql( $property_id, $listingkey ); 1470 1510 }else{ 1471 print wp_kses_post('</br>' .$listingkey. ' ------------------------- NOT FOUND BUT MARKED AS KEEP: '.$property_id.' / '.$delete_status.'<-');1511 print wp_kses_post('</br>' .$listingkey. ' ------------------------- NOT FOUND BUT MARKED AS KEEP: '.$property_id.' /'.$post_status.'<-'); 1472 1512 } 1473 1513 1474 1514 } 1515 1516 //print '</br> ************************** '; 1475 1517 } 1476 1518 … … 1832 1874 } 1833 1875 1876 1834 1877 $permited_status=array('active','active under contract','coming soon','activeundercontract','comingsoon','pending'); 1835 1878 $permited_status_lower = array_map('strtolower', $permited_status); 1836 1879 1837 1880 // Filter out permitted statuses from array1 values 1838 $standardstatus_delete_array = array_filter($standardstatus_delete_array, function ($value) use ($permited_status_lower) {1839 return !in_array(strtolower($value), $permited_status_lower);1840 }); 1881 // $standardstatus_delete_array = array_filter($standardstatus_delete_array, function ($value) use ($permited_status_lower) { 1882 // return !in_array(strtolower($value), $permited_status_lower); 1883 // }); 1841 1884 1842 1885 … … 1910 1953 'StandardStatusDelete' => array( 1911 1954 'label' => esc_html__( 'Delete Statuses', 'mlsimport' ), 1912 'description' => __( ' If you edit the Delete Statuses after importing listings, the changes will NOT apply to listings that have already been imported.', 'mlsimport' ),1955 'description' => __( 'Properties with these statuses will be deleted from your website after they are removed from MLS database. If you edit the field after importing, the changes will NOT apply to listings that have already been imported.', 'mlsimport' ), 1913 1956 'type' => 'select', 1914 1957 'multiple' => 'yes', -
mlsimport/tags/5.8.4/admin/partials/mlsimport-administrative-options.php
r3134790 r3170241 26 26 $options = get_option( $this->plugin_name . '_administrative_options' ); 27 27 $mlsimport->admin->mlsimport_saas_setting_up(); 28 //mlsimport_saas_event_mls_import_auto_function();29 //mlsimport_saas_reconciliation_event_function();28 //mlsimport_saas_event_mls_import_auto_function(); 29 //mlsimport_saas_reconciliation_event_function(); 30 30 ?> 31 31 32 32 <h1> Administrative Tools</h1> 33 33 -
mlsimport/tags/5.8.4/includes/ThemeImport.php
r3144187 r3170241 823 823 } 824 824 825 if (!isset($property['ListingKey']) ) {825 if (!isset($property['ListingKey']) || empty($property['ListingKey'])) { 826 826 $this->writeImportLogs('ERROR: No Listing Key ' . PHP_EOL, $tipImport); 827 827 return; … … 834 834 $propertyId = intval($this->mlsimportSaasRetrievePropertyById($ListingKey, $listingPostType)); 835 835 $status = isset($property['StandardStatus']) ? strtolower($property['StandardStatus']) : strtolower($property['extra_meta']['MlsStatus']); 836 837 838 $this->writeImportLogs('FIxing: on inserting ' .$status.'-->'.json_encode($mlsImportItemStatus). PHP_EOL, $tipImport); 839 840 836 841 $isInsert = $this->shouldInsertProperty($propertyId, $status, $mlsImportItemStatus, $tipImport); 837 842 … … 851 856 'post_author' => $newAuthor, 852 857 ]; 853 858 854 859 $propertyId = wp_insert_post($post); 855 860 if (is_wp_error($propertyId)) { … … 857 862 } else { 858 863 update_post_meta($propertyId, 'ListingKey', $ListingKey); 859 $keep_on_delete='delete'; 860 if( is_array($mlsImportItemStatusDelete) && !in_array($status,$mlsImportItemStatusDelete)){ 861 $keep_on_delete='keep'; 862 update_post_meta($propertyId, 'mlsImportItemStatusDelete', $keep_on_delete); 863 } 864 865 866 867 864 update_post_meta($propertyId, 'MLSimport_item_inserted', $itemIdArray['item_id'],); 865 update_post_meta($propertyId, 'mlsImportItemStatusDelete', $mlsImportItemStatusDelete); 866 867 868 868 869 869 $propertyHistory[] = date('F j, Y, g:i a') . ': We Inserted the property with Default title : ' . $submitTitle . ' and received id:' . $propertyId.'. The delete statuses are '.$keep_on_delete; … … 874 874 } elseif ($propertyId !== 0) { 875 875 876 $keep_on_delete='delete'; 877 if(is_array($mlsImportItemStatusDelete) && !in_array($status,$mlsImportItemStatusDelete)){ 878 $keep_on_delete='keep'; 879 update_post_meta($propertyId, 'mlsImportItemStatusDelete', $keep_on_delete); 880 } 881 882 $propertyHistory = $this->updateExistingProperty($propertyId,$mlsImportItemStatusDelete, $content, $listingPostType, $newAuthor, $status, $mlsImportItemStatus, $propertyHistory, $tipImport, $ListingKey); 883 } 876 $keep = $this->check_if_delete_when_status($property_id); 877 878 if(!$keep){ 879 $log = 'Property with ID ' . $propertyId . ' and with name ' . get_the_title($propertyId) . ' has a status of <strong>' . $status . ' / '.$post_status.'</strong> and will be deleted' . PHP_EOL; 880 $this->deleteProperty($propertyId, $ListingKey); 881 $this->writeImportLogs($log, $tipImport); 882 }else{ 883 update_post_meta($propertyId, 'mlsImportItemStatusDelete', $mlsImportItemStatusDelete); 884 $propertyHistory = $this->updateExistingProperty($propertyId,$mlsImportItemStatusDelete, $content, $listingPostType, $newAuthor, $status, $mlsImportItemStatus, $propertyHistory, $tipImport, $ListingKey); 885 } 886 } 887 888 889 890 891 884 892 885 893 if ($propertyId === 0) { … … 910 918 * @return string 'yes' or 'no' indicating if the property should be inserted. 911 919 */ 912 private function shouldInsertProperty($propertyId, $status, $mlsImportItemStatus, $tipImport) { 920 private function shouldInsertProperty($propertyId, $status, $mlsImportItemStatus, $tipImport): string{ 921 $this->writeImportLogs( 922 "Checking: on inserting {$propertyId}={$status} vs " . 923 json_encode($mlsImportItemStatus) . " -- {$tipImport}" . PHP_EOL, 924 $tipImport 925 ); 926 927 if ($propertyId !== 0 || !is_array($mlsImportItemStatus)) { 928 return 'no'; 929 } 930 931 $activeStatuses = [ 932 'active', 933 'active under contract', 934 'active with contract', 935 'activewithcontract', 936 'status', 937 'activeundercontract', 938 'comingsoon', 939 'coming soon', 940 'pending' 941 ]; 942 if(is_array($mlsImportItemStatus)){ 943 if (!in_array(strtolower($status), $mlsImportItemStatus, true)) { 944 return 'no'; 945 } 946 947 if ($tipImport === 'cron' && !in_array($status, $mlsImportItemStatus, true)) { 948 return 'no'; 949 } 950 951 }else{ 952 if(!in_array($status, $activeStatuses, true) ){ 953 return 'no'; 954 } 955 } 956 957 return 'yes'; 958 } 959 960 961 /** 962 * Check for property status agains mls item delete status to see if we keep or delete the listing 963 * 964 * 965 */ 966 967 public function check_if_delete_when_status($property_id){ 968 $delete_status= get_post_meta( $property_id, 'mlsImportItemStatusDelete', true ); 969 970 971 if (taxonomy_exists('property_status')) { 972 // wpresidence 973 $termObjList = get_the_terms($property_id, 'property_status'); 974 }else if(taxonomy_exists('property_label')){ 975 // houzez 976 $termObjList = get_the_terms($property_id, 'property_label'); 977 } else { 978 //real homes 979 $termObjList = get_post_meta( $property_id, 'inspiry_property_label', true ); 980 } 981 982 // property_label // houzez 983 // inspiry_property_label 913 984 914 if ($propertyId === 0) { 915 if (in_array($status, ['active', 'active under contract', 'active with contract', 'activewithcontract', 'status', 'activeundercontract', 'comingsoon', 'coming soon', 'pending'])) { 916 if ($tipImport === 'cron' && !in_array($status, $mlsImportItemStatus)) { 917 return 'no'; 918 } 919 return 'yes'; 920 } 921 return 'no'; 922 } 923 return 'no'; 924 925 } 985 if(isset($termObjList) && is_array($termObjList)){ 986 $post_status = $termObjList[0]->name; 987 } 988 989 990 $keep=true; 991 if(!empty($delete_status)){ 992 993 if(is_array($delete_status) && in_array($post_status, $delete_status)){ 994 $keep=false; 995 996 }else if($post_status==$delete_status){ 997 $keep=false; 998 } 999 1000 } 1001 1002 print wp_kses_post('</br></br>' .$property_id. ' ------------------------- Kept: '.$property_id.' /'.$post_status.'<-'); 1003 var_dump($delete_status); 1004 print '</br><br>'; 1005 1006 return $keep; 1007 } 1008 1009 1010 926 1011 927 1012 /** … … 941 1026 private function updateExistingProperty($propertyId,$mlsImportItemStatusDelete, $content, $listingPostType, $newAuthor, $status, $mlsImportItemStatus, &$propertyHistory, $tipImport, $ListingKey) { 942 1027 943 if (is_array($mlsImportItemStatusDelete)) { 944 $mlsImportItemStatusDelete = array_map('strtolower', $mlsImportItemStatusDelete); 945 } 946 947 if (is_array($mlsImportItemStatusDelete) && in_array($status, $mlsImportItemStatusDelete)) { 948 $log = 'Property with ID ' . $propertyId . ' and with name ' . get_the_title($propertyId) . ' has a status of <strong>' . $status . '</strong> and will be deleted' . PHP_EOL; 949 $this->deleteProperty($propertyId, $ListingKey); 950 $this->writeImportLogs($log, $tipImport); 1028 1029 $post = [ 1030 'ID' => $propertyId, 1031 'post_content' => $content, 1032 'post_type' => $listingPostType, 1033 'post_author' => $newAuthor, 1034 ]; 1035 1036 $log = 'Property with ID ' . $propertyId . ' and with name ' . get_the_title($propertyId) . ' has a status of <strong>' . $status . '</strong> and will be Edited</br>'; 1037 $this->writeImportLogs($log, $tipImport); 1038 1039 $propertyId = wp_update_post($post); 1040 if (is_wp_error($propertyId)) { 1041 $this->writeImportLogs('ERROR: on edit ' . PHP_EOL, $tipImport); 951 1042 } else { 952 $post = [ 953 'ID' => $propertyId, 954 'post_content' => $content, 955 'post_type' => $listingPostType, 956 'post_author' => $newAuthor, 957 ]; 958 959 $log = 'Property with ID ' . $propertyId . ' and with name ' . get_the_title($propertyId) . ' has a status of <strong>' . $status . '</strong> and will be Edited</br>'; 960 $this->writeImportLogs($log, $tipImport); 961 962 $propertyId = wp_update_post($post); 963 if (is_wp_error($propertyId)) { 964 $this->writeImportLogs('ERROR: on edit ' . PHP_EOL, $tipImport); 965 } else { 966 $submitTitle = get_the_title($propertyId); 967 $propertyHistory[] = gmdate('F j, Y, g:i a') . ': Property with title: ' . $submitTitle . ', id:' . $propertyId . ', ListingKey:' . $ListingKey . ', Status:' . $status . ' will be edited'; 968 } 969 clean_post_cache( $propertyId ); 970 } 971 1043 $submitTitle = get_the_title($propertyId); 1044 $propertyHistory[] = gmdate('F j, Y, g:i a') . ': Property with title: ' . $submitTitle . ', id:' . $propertyId . ', ListingKey:' . $ListingKey . ', Status:' . $status . ' will be edited'; 1045 } 1046 clean_post_cache( $propertyId ); 1047 972 1048 return $propertyHistory; 973 1049 } -
mlsimport/tags/5.8.4/mlsimport.php
r3144187 r3170241 4 4 * Plugin URI: https://mlsimport.com/ 5 5 * Description: "MLS Import - The MLSImport plugin facilitates the connection to your real estate MLS database, allowing you to download and synchronize real estate property data from the MLS. 6 * Version: 5.8. 36 * Version: 5.8.4 7 7 * Requires at least: 5.2 8 8 * Requires PHP: 7.2 … … 21 21 22 22 23 define( 'MLSIMPORT_VERSION', '5.8. 2' );23 define( 'MLSIMPORT_VERSION', '5.8.4' ); 24 24 define( 'MLSIMPORT_CLUBLINK', 'mlsimport.com' ); 25 25 define( 'MLSIMPORT_CLUBLINKSSL', 'https' ); -
mlsimport/trunk/admin/class-mlsimport-admin.php
r3134790 r3170241 543 543 public function mlsimport_hidden_fields() { 544 544 global $post; 545 545 546 $options = get_option( $this->plugin_name . '_admin_fields_select' ); 546 echo 'ListingKey: '.get_post_meta( $post->ID, 'ListingKey', true ).'<br>'; 547 548 $MLSimport_item_inserted = get_post_meta( $post->ID, 'MLSimport_item_inserted', true ); 549 $MLSimport_item_updated = get_post_meta( $post->ID, 'MLSimport_item_updated', true ); 550 $listing_key = get_post_meta( $post->ID, 'ListingKey', true ); 551 $mlsImportItemStatusDelete = get_post_meta($post->ID, 'mlsImportItemStatusDelete', true); 552 553 554 555 // Check if the ListingKey exists 556 if ( !empty( $listing_key ) ) { 557 echo 'ListingKey: ' . $listing_key . '<br>'; 558 } 559 560 // Check if MLSimport_item_inserted exists 561 if ( !empty( $MLSimport_item_inserted ) ) { 562 echo 'Added via MLS item id: ' . $MLSimport_item_inserted . ' - ' . get_the_title( $MLSimport_item_inserted ) . '<br>'; 563 } 564 565 // Check if MLSimport_item_updated exists 566 if ( !empty( $MLSimport_item_updated ) ) { 567 echo 'Updated via MLS item id: ' . $MLSimport_item_updated . ' - ' . get_the_title( $MLSimport_item_updated ) . '<br>'; 568 } 569 570 571 if(!empty($mlsImportItemStatusDelete)) { 572 if(is_array($mlsImportItemStatusDelete)) { 573 574 echo 'Do not delete if status: ' . implode(',' ,$mlsImportItemStatusDelete) . '<br>'; 575 } else { 576 577 echo 'Do not delete if status: ' . esc_html($mlsImportItemStatusDelete) . '<br>'; 578 579 } 580 581 } 582 547 583 foreach ( $options['mls-fields-admin'] as $key => $value ) { 548 584 if ( 1 === intval($options['mls-fields-admin'][ $key ] ) ) { … … 663 699 } 664 700 665 $mlsimport->admin->theme_importer->mlsimport _saas_delete_property_via_mysql( $delete_get_id, ' delete from tools ' );701 $mlsimport->admin->theme_importer->mlsimportSaasDeletePropertyViaMysql( $delete_get_id, ' delete from tools ' ); 666 702 } 667 703 … … 1355 1391 $last_date = $this->mlsimport_saas_update_last_date( $item_id ); 1356 1392 } 1357 1358 1393 return $last_date; 1359 1394 } … … 1368 1403 1369 1404 $unix_time = current_time( 'timestamp', 0 ) - ( 2 * 60 * 60 ); 1370 $last_date_to_save = date( 'Y-m-d\TH:i', $unix_time );1405 print $last_date_to_save = date( 'Y-m-d\TH:i', $unix_time ); 1371 1406 update_post_meta( $item_id, 'mlsimport_last_date', $last_date_to_save ); 1372 1407 … … 1384 1419 1385 1420 $last_date = $this->mlsimport_saas_get_last_date( $item_id ); 1386 1387 esc_html_e('we work with','mlsimport').' '. esc_html($last_date ). PHP_EOL; 1421 print 'MLSitem id: '.$item_id.' - '; 1422 esc_html_e('date to consider: ','mlsimport'); 1423 print esc_html($last_date ). '. '; 1388 1424 1389 1425 $mlsrequest = $this->mlsimport_make_listing_requests( $item_id, $last_date ); 1426 1390 1427 $found_items = 0; 1391 1428 if ( isset( $mlsrequest['results'] ) ) { … … 1395 1432 } 1396 1433 1397 print esc_html__(' we found ','mlsimport') .esc_html( $found_items ). '</br>' . PHP_EOL;1434 print esc_html__('We found ','mlsimport') .esc_html( $found_items ). ' listings.</br>' . PHP_EOL; 1398 1435 1399 1436 $attachments_to_move = array(); … … 1443 1480 return; 1444 1481 } 1445 1482 1446 1483 1447 1484 $mls_data = $this->mlsimport_saas_get_mls_reconciliation_data(); … … 1458 1495 $property_id = $item->iD; 1459 1496 ++$counter; 1497 1498 //print '</br>'.$counter. ' **************************</br>'; 1460 1499 1461 if ( in_array( $listingkey, $listingKey_in_MLS ) ) {1500 if ( in_array( $listingkey, $listingKey_in_MLS ) ) { 1462 1501 print wp_kses_post('</br>'.$listingkey . ' IS FOUND'); 1463 1502 } else { 1464 $delete_status= get_post_meta( $property_id, 'mlsImportItemStatusDelete', true ); 1465 1466 if($delete_status=='' || $delete_status=='delete'){ 1503 1504 $keep = $mlsimport->admin->theme_importer->check_if_delete_when_status($property_id); 1505 1506 if(!$keep){ 1467 1507 ++$to_delete; 1468 print wp_kses_post('</br>' .$listingkey. ' ------------------------- NOT FOUND delete: '.$property_id.' <-');1469 // $mlsimport->admin->theme_importer->mlsimport_saas_delete_property_via_mysql( $property_id, $listingkey );1508 print wp_kses_post('</br>' .$listingkey. ' ------------------------- NOT FOUND delete: '.$property_id.' /'.$post_status.'<-'); 1509 $mlsimport->admin->theme_importer->mlsimportSaasDeletePropertyViaMysql( $property_id, $listingkey ); 1470 1510 }else{ 1471 print wp_kses_post('</br>' .$listingkey. ' ------------------------- NOT FOUND BUT MARKED AS KEEP: '.$property_id.' / '.$delete_status.'<-');1511 print wp_kses_post('</br>' .$listingkey. ' ------------------------- NOT FOUND BUT MARKED AS KEEP: '.$property_id.' /'.$post_status.'<-'); 1472 1512 } 1473 1513 1474 1514 } 1515 1516 //print '</br> ************************** '; 1475 1517 } 1476 1518 … … 1832 1874 } 1833 1875 1876 1834 1877 $permited_status=array('active','active under contract','coming soon','activeundercontract','comingsoon','pending'); 1835 1878 $permited_status_lower = array_map('strtolower', $permited_status); 1836 1879 1837 1880 // Filter out permitted statuses from array1 values 1838 $standardstatus_delete_array = array_filter($standardstatus_delete_array, function ($value) use ($permited_status_lower) {1839 return !in_array(strtolower($value), $permited_status_lower);1840 }); 1881 // $standardstatus_delete_array = array_filter($standardstatus_delete_array, function ($value) use ($permited_status_lower) { 1882 // return !in_array(strtolower($value), $permited_status_lower); 1883 // }); 1841 1884 1842 1885 … … 1910 1953 'StandardStatusDelete' => array( 1911 1954 'label' => esc_html__( 'Delete Statuses', 'mlsimport' ), 1912 'description' => __( ' If you edit the Delete Statuses after importing listings, the changes will NOT apply to listings that have already been imported.', 'mlsimport' ),1955 'description' => __( 'Properties with these statuses will be deleted from your website after they are removed from MLS database. If you edit the field after importing, the changes will NOT apply to listings that have already been imported.', 'mlsimport' ), 1913 1956 'type' => 'select', 1914 1957 'multiple' => 'yes', -
mlsimport/trunk/admin/partials/mlsimport-administrative-options.php
r3134790 r3170241 26 26 $options = get_option( $this->plugin_name . '_administrative_options' ); 27 27 $mlsimport->admin->mlsimport_saas_setting_up(); 28 //mlsimport_saas_event_mls_import_auto_function();29 //mlsimport_saas_reconciliation_event_function();28 //mlsimport_saas_event_mls_import_auto_function(); 29 //mlsimport_saas_reconciliation_event_function(); 30 30 ?> 31 31 32 32 <h1> Administrative Tools</h1> 33 33 -
mlsimport/trunk/includes/ThemeImport.php
r3144187 r3170241 823 823 } 824 824 825 if (!isset($property['ListingKey']) ) {825 if (!isset($property['ListingKey']) || empty($property['ListingKey'])) { 826 826 $this->writeImportLogs('ERROR: No Listing Key ' . PHP_EOL, $tipImport); 827 827 return; … … 834 834 $propertyId = intval($this->mlsimportSaasRetrievePropertyById($ListingKey, $listingPostType)); 835 835 $status = isset($property['StandardStatus']) ? strtolower($property['StandardStatus']) : strtolower($property['extra_meta']['MlsStatus']); 836 837 838 $this->writeImportLogs('FIxing: on inserting ' .$status.'-->'.json_encode($mlsImportItemStatus). PHP_EOL, $tipImport); 839 840 836 841 $isInsert = $this->shouldInsertProperty($propertyId, $status, $mlsImportItemStatus, $tipImport); 837 842 … … 851 856 'post_author' => $newAuthor, 852 857 ]; 853 858 854 859 $propertyId = wp_insert_post($post); 855 860 if (is_wp_error($propertyId)) { … … 857 862 } else { 858 863 update_post_meta($propertyId, 'ListingKey', $ListingKey); 859 $keep_on_delete='delete'; 860 if( is_array($mlsImportItemStatusDelete) && !in_array($status,$mlsImportItemStatusDelete)){ 861 $keep_on_delete='keep'; 862 update_post_meta($propertyId, 'mlsImportItemStatusDelete', $keep_on_delete); 863 } 864 865 866 867 864 update_post_meta($propertyId, 'MLSimport_item_inserted', $itemIdArray['item_id'],); 865 update_post_meta($propertyId, 'mlsImportItemStatusDelete', $mlsImportItemStatusDelete); 866 867 868 868 869 869 $propertyHistory[] = date('F j, Y, g:i a') . ': We Inserted the property with Default title : ' . $submitTitle . ' and received id:' . $propertyId.'. The delete statuses are '.$keep_on_delete; … … 874 874 } elseif ($propertyId !== 0) { 875 875 876 $keep_on_delete='delete'; 877 if(is_array($mlsImportItemStatusDelete) && !in_array($status,$mlsImportItemStatusDelete)){ 878 $keep_on_delete='keep'; 879 update_post_meta($propertyId, 'mlsImportItemStatusDelete', $keep_on_delete); 880 } 881 882 $propertyHistory = $this->updateExistingProperty($propertyId,$mlsImportItemStatusDelete, $content, $listingPostType, $newAuthor, $status, $mlsImportItemStatus, $propertyHistory, $tipImport, $ListingKey); 883 } 876 $keep = $this->check_if_delete_when_status($property_id); 877 878 if(!$keep){ 879 $log = 'Property with ID ' . $propertyId . ' and with name ' . get_the_title($propertyId) . ' has a status of <strong>' . $status . ' / '.$post_status.'</strong> and will be deleted' . PHP_EOL; 880 $this->deleteProperty($propertyId, $ListingKey); 881 $this->writeImportLogs($log, $tipImport); 882 }else{ 883 update_post_meta($propertyId, 'mlsImportItemStatusDelete', $mlsImportItemStatusDelete); 884 $propertyHistory = $this->updateExistingProperty($propertyId,$mlsImportItemStatusDelete, $content, $listingPostType, $newAuthor, $status, $mlsImportItemStatus, $propertyHistory, $tipImport, $ListingKey); 885 } 886 } 887 888 889 890 891 884 892 885 893 if ($propertyId === 0) { … … 910 918 * @return string 'yes' or 'no' indicating if the property should be inserted. 911 919 */ 912 private function shouldInsertProperty($propertyId, $status, $mlsImportItemStatus, $tipImport) { 920 private function shouldInsertProperty($propertyId, $status, $mlsImportItemStatus, $tipImport): string{ 921 $this->writeImportLogs( 922 "Checking: on inserting {$propertyId}={$status} vs " . 923 json_encode($mlsImportItemStatus) . " -- {$tipImport}" . PHP_EOL, 924 $tipImport 925 ); 926 927 if ($propertyId !== 0 || !is_array($mlsImportItemStatus)) { 928 return 'no'; 929 } 930 931 $activeStatuses = [ 932 'active', 933 'active under contract', 934 'active with contract', 935 'activewithcontract', 936 'status', 937 'activeundercontract', 938 'comingsoon', 939 'coming soon', 940 'pending' 941 ]; 942 if(is_array($mlsImportItemStatus)){ 943 if (!in_array(strtolower($status), $mlsImportItemStatus, true)) { 944 return 'no'; 945 } 946 947 if ($tipImport === 'cron' && !in_array($status, $mlsImportItemStatus, true)) { 948 return 'no'; 949 } 950 951 }else{ 952 if(!in_array($status, $activeStatuses, true) ){ 953 return 'no'; 954 } 955 } 956 957 return 'yes'; 958 } 959 960 961 /** 962 * Check for property status agains mls item delete status to see if we keep or delete the listing 963 * 964 * 965 */ 966 967 public function check_if_delete_when_status($property_id){ 968 $delete_status= get_post_meta( $property_id, 'mlsImportItemStatusDelete', true ); 969 970 971 if (taxonomy_exists('property_status')) { 972 // wpresidence 973 $termObjList = get_the_terms($property_id, 'property_status'); 974 }else if(taxonomy_exists('property_label')){ 975 // houzez 976 $termObjList = get_the_terms($property_id, 'property_label'); 977 } else { 978 //real homes 979 $termObjList = get_post_meta( $property_id, 'inspiry_property_label', true ); 980 } 981 982 // property_label // houzez 983 // inspiry_property_label 913 984 914 if ($propertyId === 0) { 915 if (in_array($status, ['active', 'active under contract', 'active with contract', 'activewithcontract', 'status', 'activeundercontract', 'comingsoon', 'coming soon', 'pending'])) { 916 if ($tipImport === 'cron' && !in_array($status, $mlsImportItemStatus)) { 917 return 'no'; 918 } 919 return 'yes'; 920 } 921 return 'no'; 922 } 923 return 'no'; 924 925 } 985 if(isset($termObjList) && is_array($termObjList)){ 986 $post_status = $termObjList[0]->name; 987 } 988 989 990 $keep=true; 991 if(!empty($delete_status)){ 992 993 if(is_array($delete_status) && in_array($post_status, $delete_status)){ 994 $keep=false; 995 996 }else if($post_status==$delete_status){ 997 $keep=false; 998 } 999 1000 } 1001 1002 print wp_kses_post('</br></br>' .$property_id. ' ------------------------- Kept: '.$property_id.' /'.$post_status.'<-'); 1003 var_dump($delete_status); 1004 print '</br><br>'; 1005 1006 return $keep; 1007 } 1008 1009 1010 926 1011 927 1012 /** … … 941 1026 private function updateExistingProperty($propertyId,$mlsImportItemStatusDelete, $content, $listingPostType, $newAuthor, $status, $mlsImportItemStatus, &$propertyHistory, $tipImport, $ListingKey) { 942 1027 943 if (is_array($mlsImportItemStatusDelete)) { 944 $mlsImportItemStatusDelete = array_map('strtolower', $mlsImportItemStatusDelete); 945 } 946 947 if (is_array($mlsImportItemStatusDelete) && in_array($status, $mlsImportItemStatusDelete)) { 948 $log = 'Property with ID ' . $propertyId . ' and with name ' . get_the_title($propertyId) . ' has a status of <strong>' . $status . '</strong> and will be deleted' . PHP_EOL; 949 $this->deleteProperty($propertyId, $ListingKey); 950 $this->writeImportLogs($log, $tipImport); 1028 1029 $post = [ 1030 'ID' => $propertyId, 1031 'post_content' => $content, 1032 'post_type' => $listingPostType, 1033 'post_author' => $newAuthor, 1034 ]; 1035 1036 $log = 'Property with ID ' . $propertyId . ' and with name ' . get_the_title($propertyId) . ' has a status of <strong>' . $status . '</strong> and will be Edited</br>'; 1037 $this->writeImportLogs($log, $tipImport); 1038 1039 $propertyId = wp_update_post($post); 1040 if (is_wp_error($propertyId)) { 1041 $this->writeImportLogs('ERROR: on edit ' . PHP_EOL, $tipImport); 951 1042 } else { 952 $post = [ 953 'ID' => $propertyId, 954 'post_content' => $content, 955 'post_type' => $listingPostType, 956 'post_author' => $newAuthor, 957 ]; 958 959 $log = 'Property with ID ' . $propertyId . ' and with name ' . get_the_title($propertyId) . ' has a status of <strong>' . $status . '</strong> and will be Edited</br>'; 960 $this->writeImportLogs($log, $tipImport); 961 962 $propertyId = wp_update_post($post); 963 if (is_wp_error($propertyId)) { 964 $this->writeImportLogs('ERROR: on edit ' . PHP_EOL, $tipImport); 965 } else { 966 $submitTitle = get_the_title($propertyId); 967 $propertyHistory[] = gmdate('F j, Y, g:i a') . ': Property with title: ' . $submitTitle . ', id:' . $propertyId . ', ListingKey:' . $ListingKey . ', Status:' . $status . ' will be edited'; 968 } 969 clean_post_cache( $propertyId ); 970 } 971 1043 $submitTitle = get_the_title($propertyId); 1044 $propertyHistory[] = gmdate('F j, Y, g:i a') . ': Property with title: ' . $submitTitle . ', id:' . $propertyId . ', ListingKey:' . $ListingKey . ', Status:' . $status . ' will be edited'; 1045 } 1046 clean_post_cache( $propertyId ); 1047 972 1048 return $propertyHistory; 973 1049 } -
mlsimport/trunk/mlsimport.php
r3144187 r3170241 4 4 * Plugin URI: https://mlsimport.com/ 5 5 * Description: "MLS Import - The MLSImport plugin facilitates the connection to your real estate MLS database, allowing you to download and synchronize real estate property data from the MLS. 6 * Version: 5.8. 36 * Version: 5.8.4 7 7 * Requires at least: 5.2 8 8 * Requires PHP: 7.2 … … 21 21 22 22 23 define( 'MLSIMPORT_VERSION', '5.8. 2' );23 define( 'MLSIMPORT_VERSION', '5.8.4' ); 24 24 define( 'MLSIMPORT_CLUBLINK', 'mlsimport.com' ); 25 25 define( 'MLSIMPORT_CLUBLINKSSL', 'https' );
Note: See TracChangeset
for help on using the changeset viewer.