This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('template_redirect', function () { | |
| if (is_singular('property')) { | |
| global $post; | |
| $terms = get_the_terms($post, "marketing_flag"); | |
| if ($terms && !is_wp_error($terms)) { | |
| foreach ($terms as $term) { | |
| if ($term->term_id === 123) { //replace this with the marketing flag ID | |
| wp_redirect(home_url('/some-url-to-redirect-to/'), 301); //replace this with desired destination | |
| exit; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( "propertyhive_sturents_property_imported", "import_book_a_tour", 10, 2 ); | |
| function import_book_a_tour( $post_id, $property ) { | |
| // sturents uses a viewing link for each room, here we're just using the first one | |
| if(isset($property["available"][0]["viewing_url"])){ | |
| update_post_meta($post_id, "_book_a_tour_url", $property["available"][0]["viewing_url"]); | |
| } | |
| } | |
| add_filter( 'propertyhive_single_property_actions', 'add_book_a_tour_action' ); | |
| function add_book_a_tour_action( $actions ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('propertyhive_elementor_widget_property_image_controls', 'add_extra_thumbnail_sizes_to_widget', 10, 2); | |
| function add_extra_thumbnail_sizes_to_widget($widget){ | |
| $widget->update_control( | |
| 'image_size', | |
| [ | |
| 'label' => __( 'Image Size', 'propertyhive' ), | |
| 'type' => \Elementor\Controls_Manager::SELECT, | |
| 'options' => [ | |
| 'thumbnail' => __( 'Thumbnail', 'propertyhive' ), | |
| 'medium' => __( 'Medium', 'propertyhive' ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter('property_hive_export_request_data', 'new_home_property_on_export', 10, 2); | |
| function new_home_property_on_export($request_data, $post_id) | |
| { | |
| $is_new_home = false; | |
| $terms = wp_get_post_terms($post_id, 'marketing_flag'); | |
| foreach ($terms as $term) { | |
| if ($term->term_id == 123) { // replace this with the term id of the new home flag | |
| $is_new_home = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('pre_get_posts', 'remove_sold_and_let_from_search'); | |
| function remove_sold_and_let_from_search($q) | |
| { | |
| if ( is_admin() || !$q->is_main_query() || !$q->is_archive() || ($q->get( 'post_type' ) != "property") ){ | |
| return; | |
| } | |
| $tax_query = $q->get('tax_query'); | |
| $tax_query[] = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'query_vars', 'propertyhive_register_query_vars' ); | |
| function propertyhive_register_query_vars( $vars ) | |
| { | |
| $vars[] = 'property_search_criteria'; | |
| return $vars; | |
| } | |
| add_action( 'init', 'propertyhive_add_rewrite_rules' ); | |
| function propertyhive_add_rewrite_rules() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // install User Role Editor plugin and set list_users for the Editor role | |
| add_filter('propertyhive_remove_menu_item_in_crm_only_mode', 'turn_on_posts', 10, 2); | |
| function turn_on_posts($show, $menu_item) | |
| { | |
| if ( isset($menu_item[2]) && $menu_item[2] == 'users.php' ) | |
| { | |
| return false; | |
| } | |
| return $show; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * rest api ref lookup | |
| */ | |
| // Register the REST API route | |
| add_action('rest_api_init', function () { | |
| register_rest_route('property/v1', '/lookup', [ | |
| 'methods' => 'GET', | |
| 'callback' => 'get_property_slug_by_ref', | |
| 'args' => [ | |
| 'ref' => [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function enable_address_sorting_for_properties($query) { | |
| if (is_admin() && $query->is_main_query() && $query->get('post_type') === 'property') { | |
| if (isset($_GET['orderby']) && $_GET['orderby'] === 'address') { | |
| $query->set('orderby', 'title'); | |
| $query->set('order', isset($_GET['order']) ? $_GET['order'] : 'ASC'); | |
| } | |
| } | |
| } | |
| add_action('pre_get_posts', 'enable_address_sorting_for_properties', 99); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( "propertyhive_property_imported_reapit_foundations_json", 'force_main_id_import', 10, 2 ); | |
| function force_main_id_import( $post_id, $property ) | |
| { | |
| if ( isset($property['id']) && !empty($property['id']) ) | |
| { | |
| update_post_meta( $post_id, '_reference_number', $property['id'] ); | |
| } | |
| } |