Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. add_action( 'propertyhive_property_imported_dezrez_xml', 'auto_flag_town_and_country', 10, 2 );
  2. function auto_flag_town_and_country($post_id, $property)
  3. {
  4. wp_suspend_cache_invalidation( false );
  5. wp_defer_term_counting( false );
  6. wp_defer_comment_counting( false );
  7.  
  8. wp_delete_object_term_relationships( $post_id, 'marketing_flag' );
  9.  
  10. $property_text = $property->text;
  11.  
  12. if ( isset($property_text->areas) )
  13. {
  14. foreach ($property_text->areas->area as $xml_area)
  15. {
  16. if (isset($xml_area->feature))
  17. {
  18. foreach ($xml_area->feature as $xml_feature)
  19. {
  20. if (
  21. strpos( strtolower((string)$xml_feature->heading), 'town and country' ) !== FALSE ||
  22. strpos( strtolower((string)$xml_feature->heading), 'town-and-country' ) !== FALSE ||
  23. strpos( strtolower((string)$xml_feature->heading), 'town & country' ) !== FALSE ||
  24. strpos( strtolower((string)$xml_feature->description), 'town and country' ) !== FALSE ||
  25. strpos( strtolower((string)$xml_feature->description), 'town-and-country' ) !== FALSE ||
  26. strpos( strtolower((string)$xml_feature->description), 'town & country' ) !== FALSE
  27. )
  28. {
  29. wp_set_post_terms( $post_id, 136, 'marketing_flag' );
  30. }
  31. }
  32. }
  33. }
  34. }
  35.  
  36. wp_suspend_cache_invalidation( true );
  37. wp_defer_term_counting( true );
  38. wp_defer_comment_counting( true );
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement