Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'propertyhive_property_imported_dezrez_xml', 'auto_flag_town_and_country', 10, 2 );
- function auto_flag_town_and_country($post_id, $property)
- {
- wp_suspend_cache_invalidation( false );
- wp_defer_term_counting( false );
- wp_defer_comment_counting( false );
- wp_delete_object_term_relationships( $post_id, 'marketing_flag' );
- $property_text = $property->text;
- if ( isset($property_text->areas) )
- {
- foreach ($property_text->areas->area as $xml_area)
- {
- if (isset($xml_area->feature))
- {
- foreach ($xml_area->feature as $xml_feature)
- {
- if (
- strpos( strtolower((string)$xml_feature->heading), 'town and country' ) !== FALSE ||
- strpos( strtolower((string)$xml_feature->heading), 'town-and-country' ) !== FALSE ||
- strpos( strtolower((string)$xml_feature->heading), 'town & country' ) !== FALSE ||
- strpos( strtolower((string)$xml_feature->description), 'town and country' ) !== FALSE ||
- strpos( strtolower((string)$xml_feature->description), 'town-and-country' ) !== FALSE ||
- strpos( strtolower((string)$xml_feature->description), 'town & country' ) !== FALSE
- )
- {
- wp_set_post_terms( $post_id, 136, 'marketing_flag' );
- }
- }
- }
- }
- }
- wp_suspend_cache_invalidation( true );
- wp_defer_term_counting( true );
- wp_defer_comment_counting( true );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement