$value ) { if ( isset($form_controls[$key]) ) continue; if ( $key == 'officeID' && isset($form_controls['office']) ) continue; if ( $key == 'paged' ) continue; if ( ( $key == 'minimum_price' || $key == 'maximum_price' ) && array_key_exists('price_slider', $form_controls) || ( $key == 'minimum_rent' || $key == 'maximum_rent' ) && array_key_exists('rent_slider', $form_controls) || ( $key == 'minimum_bedrooms' || $key == 'maximum_bedrooms' ) && array_key_exists('bedrooms_slider', $form_controls) ) continue; // we've received a field that isn't a standard form control so let's store it in a hidden field so it's not lost if ( is_array($value) ) { foreach ( $value as $i => $val ) { $form_controls[$key . '-' . $i] = array('type' => 'hidden', 'name' => $key . '[]', 'value' => stripslashes( ph_clean( $val) )); } } else { $form_controls[$key] = array('type' => 'hidden', 'value' => stripslashes( ph_clean( $value) )); } } $form_controls = apply_filters( 'propertyhive_search_form_fields_after_' . $id, $form_controls ); $form_controls = apply_filters( 'propertyhive_search_form_fields_after', $form_controls ); ph_get_template( 'global/search-form.php', array( 'form_controls' => $form_controls, 'id' => $id ) ); } /** * Get default fields to be shown on search forms * * @return array */ function ph_get_search_form_fields() { $fields = array(); $departments = ph_get_departments(); $department_options = array(); $default_value = ''; foreach ( $departments as $key => $value ) { if ( get_option( 'propertyhive_active_departments_' . str_replace("residential-", "", $key) ) == 'yes' ) { $department_options[$key] = $value; if ($default_value == '' && get_option( 'propertyhive_primary_department' ) == $key ) { $default_value = $key; } } } $sales_department_active = false; if ( array_key_exists('residential-sales', $departments) ) { $sales_department_active = true; } else { $custom_departments = ph_get_custom_departments(); if ( !empty($custom_departments) ) { foreach ( $custom_departments as $key => $department ) { if ( isset($department['based_on']) && $department['based_on'] == 'residential-sales' ) { $sales_department_active = true; } } } } $lettings_department_active = false; if ( array_key_exists('residential-lettings', $departments) ) { $lettings_department_active = true; } else { $custom_departments = ph_get_custom_departments(); if ( !empty($custom_departments) ) { foreach ( $custom_departments as $key => $department ) { if ( isset($department['based_on']) && $department['based_on'] == 'residential-lettings' ) { $lettings_department_active = true; } } } } $commercial_department_active = false; if ( array_key_exists('commercial', $departments) ) { $commercial_department_active = true; } else { $custom_departments = ph_get_custom_departments(); if ( !empty($custom_departments) ) { foreach ( $custom_departments as $key => $department ) { if ( isset($department['based_on']) && $department['based_on'] == 'commercial' ) { $commercial_department_active = true; } } } } $fields['department'] = array( 'type' => 'radio', 'options' => $department_options, 'value' => $default_value ); if ( $sales_department_active || $lettings_department_active ) { if ( $sales_department_active ) { $prices = array( '' => __( 'No preference', 'propertyhive' ), '100000' => '£100,000', '150000' => '£150,000', '200000' => '£200,000', '250000' => '£250,000', '300000' => '£300,000', '500000' => '£500,000', '750000' => '£750,000', '1000000' => '£1,000,000' ); $fields['minimum_price'] = array( 'type' => 'select', 'show_label' => true, 'label' => __( 'Min Price', 'propertyhive' ), 'before' => '
', 'options' => $prices ); $fields['maximum_price'] = array( 'type' => 'select', 'show_label' => true, 'label' => __( 'Max Price', 'propertyhive' ), 'before' => '
', 'options' => $prices ); } if ( $lettings_department_active ) { $prices = array( '' => __( 'No preference', 'propertyhive' ), '500' => '£500 PCM', '600' => '£600 PCM', '750' => '£750 PCM', '1000' => '£1000 PCM', '1250' => '£1250 PCM', '1500' => '£1500 PCM', '2000' => '£2000 PCM' ); $fields['minimum_rent'] = array( 'type' => 'select', 'show_label' => true, 'label' => __( 'Min Rent', 'propertyhive' ), 'before' => '
', 'options' => $prices ); $fields['maximum_rent'] = array( 'type' => 'select', 'show_label' => true, 'label' => __( 'Max Rent', 'propertyhive' ), 'before' => '
', 'options' => $prices ); } $fields['minimum_bedrooms'] = array( 'type' => 'select', 'show_label' => true, 'label' => __( 'Min Beds', 'propertyhive' ), 'before' => '
', 'options' => array( '' => __( 'No preference', 'propertyhive' ), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5) ); $fields['property_type'] = array( 'type' => 'property_type', 'show_label' => true, 'before' => '
', 'label' => __( 'Type', 'propertyhive' ), ); } if ( $commercial_department_active ) { $sizes = array( '' => __( 'No preference', 'propertyhive' ), '250' => '250 sq ft', '500' => '500 sq ft', '1000' => '1,000 sq ft', '2500' => '2,500 sq ft', '5000' => '5,000 sq ft', '10000' => '10,000 sq ft', '25000' => '25,000 sq ft', '50000' => '50,000 sq ft' ); $fields['minimum_floor_area'] = array( 'type' => 'select', 'show_label' => true, 'label' => __( 'Min Floor Area', 'propertyhive' ), 'before' => '
', 'options' => $sizes ); $fields['maximum_floor_area'] = array( 'type' => 'select', 'show_label' => true, 'label' => __( 'Max Floor Area', 'propertyhive' ), 'before' => '
', 'options' => $sizes ); $fields['commercial_property_type'] = array( 'type' => 'commercial_property_type', 'show_label' => true, 'before' => '
', 'label' => __( 'Type', 'propertyhive' ), ); } return $fields; } /** * Main function for drawing property enquiry form. * * @param string $property_id * @return void */ function propertyhive_enquiry_form( $property_id = '' ) { global $post; $form_controls = ph_get_property_enquiry_form_fields( $property_id ); $form_controls = apply_filters( 'propertyhive_property_enquiry_form_fields', $form_controls, $property_id ); $form_controls['property_id'] = array( 'type' => 'hidden', 'value' => ( $property_id != '' ? $property_id : $post->ID ) ); $utm_fields = array( 'utm_source', 'utm_medium', 'utm_term', 'utm_content', 'utm_campaign', 'gclid', 'fbclid' ); foreach ( $utm_fields as $utm_field ) { $form_controls[$utm_field] = array( 'type' => 'hidden', 'value' =>'' ); } if ( get_option( 'propertyhive_property_enquiry_form_disclaimer', '' ) != '' ) { $disclaimer = get_option( 'propertyhive_property_enquiry_form_disclaimer', '' ); $form_controls['disclaimer'] = array( 'type' => 'checkbox', 'label' => $disclaimer, 'label_style' => 'width:100%;', 'required' => true ); } ph_get_template( 'global/make-enquiry-form.php',array( 'form_controls' => $form_controls ) ); } /** * Get default fields to be shown on search forms * * @return array */ function ph_get_property_enquiry_form_fields( $property_id = '' ) { global $post; $fields = array(); $fields['name'] = array( 'type' => 'text', 'label' => __( 'Full Name', 'propertyhive' ), 'show_label' => true, 'before' => '
', 'required' => true ); if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); $fields['name']['value'] = $current_user->display_name; } $fields['email_address'] = array( 'type' => 'email', 'label' => __( 'Email Address', 'propertyhive' ), 'show_label' => true, 'before' => '