/** * Output the metabox */ public static function output($post) { global $post, $wpdb, $thepostid; wp_nonce_field('propertyhive_save_data', 'propertyhive_meta_nonce'); echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; propertyhive_wp_text_input(array('id' => '_address_name_number', 'label' => __('Building Name / Number', 'propertyhive'), 'desc_tip' => false, 'placeholder' => __('e.g. Thistle Cottage, or Flat 10', 'propertyhive'), 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_address_street', 'label' => __('Street', 'propertyhive'), 'desc_tip' => false, 'placeholder' => __('e.g. High Street', 'propertyhive'), 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_address_two', 'label' => __('Address Line 2', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_address_three', 'label' => __('Town / City', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_address_four', 'label' => __('County / State', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_address_postcode', 'label' => __('Postcode / Zip Code', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); // Country dropdown $countries = get_option('propertyhive_countries', array('GB')); $contact_country = get_post_meta($thepostid, '_address_country', TRUE); if ($contact_country == '') { $contact_country = get_option('propertyhive_default_country', 'GB'); } if (empty($countries) || count($countries) < 2) { propertyhive_wp_hidden_input(array('id' => '_address_country', 'value' => $contact_country)); } else { $ph_countries = new PH_Countries(); $country_options = array(); foreach ($countries as $country_code) { $country = $ph_countries->get_country($country_code); if ($country !== false) { $country_options[$country_code] = $country['name']; } } propertyhive_wp_select(array('id' => '_address_country', 'label' => __('Country', 'propertyhive'), 'desc_tip' => false, 'options' => $country_options, 'value' => $contact_country)); } do_action('propertyhive_contact_correspondence_address_fields'); echo '</div>'; echo '</div>'; }
/** * Output the metabox */ public static function output($post) { global $post, $wpdb, $thepostid; $enquiry_post = $post; wp_nonce_field('propertyhive_save_data', 'propertyhive_meta_nonce'); echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; $args = array('id' => '_status', 'label' => __('Status', 'propertyhive'), 'desc_tip' => false, 'options' => array('open' => __('Open', 'propertyhive'), 'closed' => __('Closed', 'propertyhive'))); propertyhive_wp_select($args); // Negotiator $negotiator_id = get_post_meta($post->ID, '_negotiator_id', TRUE); echo '<p class="form-field negotiator_id_field"> <label for="_negotiator_id">' . __('Negotiator', 'propertyhive') . '</label>'; $args = array('show_option_none' => '-- ' . __('Unassigned', 'propertyhive') . ' --', 'name' => '_negotiator_id', 'id' => '_negotiator_id', 'class' => 'select short', 'selected' => $negotiator_id); wp_dropdown_users($args); echo ' </p>'; $office_id = get_post_meta($post->ID, '_office_id', TRUE); if ($office_id == '') { // if neg isn't set then default to current users offices //$negotiator_id = get_current_user_id(); } echo '<p class="form-field office_id_field"> <label for="office_id">' . __('Office', 'propertyhive') . '</label> <select id="_office_id" name="_office_id" class="select short">'; $args = array('post_type' => 'office', 'nopaging' => true, 'orderby' => 'title', 'order' => 'ASC'); $office_query = new WP_Query($args); if ($office_query->have_posts()) { while ($office_query->have_posts()) { $office_query->the_post(); echo '<option value="' . $post->ID . '"'; if ($post->ID == $office_id) { echo ' selected'; } echo '>' . get_the_title() . '</option>'; } } wp_reset_postdata(); $post = $enquiry_post; echo '</select> </p>'; $args = array('id' => '_source', 'label' => __('Source', 'propertyhive'), 'desc_tip' => false, 'options' => array('office' => __('Office', 'propertyhive'), 'website' => __('Website', 'propertyhive'))); propertyhive_wp_select($args); do_action('propertyhive_enquiry_record_details_fields'); echo '</div>'; echo '</div>'; }
/** * Output the metabox */ public static function output($post) { echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; // On Market propertyhive_wp_checkbox(array('id' => '_on_market', 'label' => __('On Market', 'propertyhive'), 'desc_tip' => true, 'description' => __('Setting the property to be on the market means the property will be displayed on the website, and portals too if a <a href="http://wp-property-hive.com/add-ons/" target="_blank">portal add-on</a> is present.', 'propertyhive'))); // Availability $options = array(); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('availability', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; } $term_list = wp_get_post_terms($post->ID, 'availability', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => '_availability', 'label' => __('Availability', 'propertyhive'), 'options' => $options, 'desc_tip' => false); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); // Featured propertyhive_wp_checkbox(array('id' => '_featured', 'label' => __('Featured', 'propertyhive'))); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('marketing_flag', $args); if (!empty($terms) && !is_wp_error($terms)) { $options = array(); $selected_values = array(); foreach ($terms as $term) { $options[$term->term_id] = $term->name; $term_list = wp_get_post_terms($post->ID, 'marketing_flag', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { if (in_array($term->term_id, $term_list)) { $selected_values[] = $term->term_id; } } } propertyhive_wp_checkboxes(array('name' => '_marketing_flags', 'label' => __('Marketing Flags', 'propertyhive'), 'options' => $options, 'value' => $selected_values)); } do_action('propertyhive_property_marketing_fields'); echo '</div>'; echo '</div>'; }
/** * Output the metabox */ public static function output($post) { $parent_post = false; if (isset($_GET['post_parent']) && $_GET['post_parent'] != '') { $parent_post = $_GET['post_parent']; } echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; $available_as = array(); if (get_post_meta($post->ID, '_for_sale', true) == 'yes') { $available_as[] = 'sale'; } if (get_post_meta($post->ID, '_to_rent', true) == 'yes') { $available_as[] = 'rent'; } if ($parent_post !== FALSE && get_post_meta($parent_post, '_for_sale', TRUE)) { $available_as[] = 'sale'; } if ($parent_post !== FALSE && get_post_meta($parent_post, '_to_rent', TRUE)) { $available_as[] = 'rent'; } propertyhive_wp_checkboxes(array('id' => '_available_as', 'label' => __('Available As', 'propertyhive'), 'desc_tip' => false, 'value' => $available_as, 'options' => array('sale' => 'For Sale', 'rent' => 'To Rent'))); // Currency / Price $ph_countries = new PH_Countries(); $default_country = get_option('propertyhive_default_country', 'GB'); $countries = get_option('propertyhive_countries', array($default_country)); $currencies = array(); foreach ($countries as $country) { $country = $ph_countries->get_country($country); if (!isset($currencies[$country['currency_code']])) { $currencies[$country['currency_code']] = $country['currency_symbol']; } } $selected_sale_currency = get_post_meta($post->ID, '_commercial_price_currency', true); if ($selected_sale_currency == '') { $country = $ph_countries->get_country($default_country); $selected_sale_currency = $country['currency_code']; } $selected_rent_currency = get_post_meta($post->ID, '_commercial_rent_currency', true); if ($selected_rent_currency == '') { $country = $ph_countries->get_country($default_country); $selected_rent_currency = $country['currency_code']; } // Sale fields echo '<div class="commercial-sale-fields"' . (!in_array('sale', $available_as) ? ' style="display:none"' : '') . '>'; echo '<p class="form-field price_field"> <label for="_price_from">' . __('Price', 'propertyhive') . (empty($currencies) || count($currencies) <= 1 ? ' (<span class="currency-symbol">' . $currencies[$selected_sale_currency] . '</span>)' : '') . '</label>'; if (count($currencies) > 1) { echo '<select id="_commercial_price_currency" name="_commercial_price_currency" class="select" style="width:auto; float:left;">'; foreach ($currencies as $currency_code => $currency_sybmol) { echo '<option value="' . $currency_code . '"' . ($currency_code == $selected_sale_currency ? ' selected' : '') . '>' . $currency_sybmol . '</option>'; } echo '</select>'; } else { echo '<input type="hidden" name="_commercial_price_currency" value="' . $selected_sale_currency . '">'; } $price_options = get_commercial_price_units(); echo ' <input type="text" class="" name="_price_from" id="_price_from" value="' . get_post_meta($post->ID, '_price_from', true) . '" placeholder="" style="width:15%; min-width:85px;"> <span style="float:left"> - </span> <input type="text" class="" name="_price_to" id="_price_to" value="' . get_post_meta($post->ID, '_price_to', true) . '" placeholder="" style="width:15%; min-width:85px;"> <select name="_price_units" id="_price_units"> <option value=""></option>'; foreach ($price_options as $key => $value) { echo '<option value="' . $key . '"'; if ($key == get_post_meta($post->ID, '_price_units', true)) { echo ' selected'; } echo '>' . $value . '</option>'; } echo '</select> </p>'; // POA propertyhive_wp_checkbox(array('id' => '_commercial_price_poa', 'label' => __('Price On Application', 'propertyhive'), 'desc_tip' => false, 'value' => get_post_meta($post->ID, '_price_poa', true))); // Price Qualifier $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('price_qualifier', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; } $term_list = wp_get_post_terms($post->ID, 'price_qualifier', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => 'commercial_price_qualifier_id', 'label' => __('Price Qualifier', 'propertyhive'), 'desc_tip' => false, 'options' => $options); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); // Sale By $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('sale_by', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; } $term_list = wp_get_post_terms($post->ID, 'sale_by', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => 'commercial_sale_by_id', 'label' => __('Sale By', 'propertyhive'), 'desc_tip' => false, 'options' => $options); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); // Tenure $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('commercial_tenure', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; } $term_list = wp_get_post_terms($post->ID, 'commercial_tenure', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => 'commercial_tenure_id', 'label' => __('Tenure', 'propertyhive'), 'desc_tip' => false, 'options' => $options); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); do_action('propertyhive_property_commercial_sale_details_fields'); echo '</div>'; // Rent Fields echo '<div class="commercial-rent-fields"' . (!in_array('rent', $available_as) ? ' style="display:none"' : '') . '>'; echo '<p class="form-field price_field"> <label for="_rent_from">' . __('Rent', 'propertyhive') . (empty($currencies) || count($currencies) <= 1 ? ' (<span class="currency-symbol">' . $currencies[$selected_rent_currency] . '</span>)' : '') . '</label>'; if (count($currencies) > 1) { echo '<select id="_commercial_rent_currency" name="_commercial_rent_currency" class="select" style="width:auto; float:left;">'; foreach ($currencies as $currency_code => $currency_sybmol) { echo '<option value="' . $currency_code . '"' . ($currency_code == $selected_rent_currency ? ' selected' : '') . '>' . $currency_sybmol . '</option>'; } echo '</select>'; } else { echo '<input type="hidden" name="_commercial_rent_currency" value="' . $selected_rent_currency . '">'; } $rent_units = get_post_meta($post->ID, '_rent_units', true); echo ' <input type="text" class="" name="_rent_from" id="_rent_from" value="' . get_post_meta($post->ID, '_rent_from', true) . '" placeholder="" style="width:15%; min-width:85px;"> <span style="float:left; padding:0 5px"> - </span> <input type="text" class="" name="_rent_to" id="_rent_to" value="' . get_post_meta($post->ID, '_rent_to', true) . '" placeholder="" style="width:15%; min-width:85px;"> <select name="_rent_units" id="_rent_units"> <option value="pw"' . ($rent_units == 'pw' ? ' selected' : '') . '>' . __('Per Week', 'propertyhive') . '</option> <option value="pcm"' . ($rent_units == 'pcm' || $rent_units == '' ? ' selected' : '') . '>' . __('Per Calendar Month', 'propertyhive') . '</option> <option value="pq"' . ($rent_units == 'pq' ? ' selected' : '') . '>' . __('Per Quarter', 'propertyhive') . '</option> <option value="pa"' . ($rent_units == 'pa' ? ' selected' : '') . '>' . __('Per Annum', 'propertyhive') . '</option>'; foreach ($price_options as $key => $value) { echo '<option value="' . $key . '"'; if ($key == $rent_units) { echo ' selected'; } echo '>' . $value . '</option>'; } echo '</select> </p>'; // POA propertyhive_wp_checkbox(array('id' => '_commercial_rent_poa', 'label' => __('Rent On Application', 'propertyhive'), 'desc_tip' => false, 'value' => get_post_meta($post->ID, '_rent_poa', true))); do_action('propertyhive_property_commercial_rent_details_fields'); echo '</div>'; // end commercial-rent-fields ?> <p class="form-field"><label for="property_type_ids"><?php _e('Property Types', 'propertyhive'); ?> </label> <select id="property_type_ids" name="property_type_ids[]" multiple="multiple" data-placeholder="<?php _e('Select property types', 'propertyhive'); ?> " class="multiselect attribute_values"> <?php $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('commercial_property_type', $args); if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subterms = get_terms('commercial_property_type', $args); if (!empty($subterms) && !is_wp_error($subterms)) { foreach ($subterms as $subterm) { $options[$subterm->term_id] = '- ' . $subterm->name; $args = array('hide_empty' => false, 'parent' => $subterm->term_id); $subsubterms = get_terms('commercial_property_type', $args); if (!empty($subsubterms) && !is_wp_error($subsubterms)) { foreach ($subsubterms as $subsubterm) { $options[$subsubterm->term_id] = '- - ' . $subsubterm->name; } } } } } } $selected_values = array(); $term_list = wp_get_post_terms($post->ID, 'commercial_property_type', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { foreach ($term_list as $term_id) { $selected_values[] = $term_id; } } if (!empty($options) && !is_wp_error($options)) { foreach ($options as $key => $value) { echo '<option value="' . esc_attr($key) . '"'; if (in_array($key, $selected_values)) { echo ' selected'; } echo '>' . esc_html($value) . '</option>'; } } ?> </select> <?php $size_options = get_area_units(); $floor_area_units = get_post_meta($post->ID, '_floor_area_units', true); echo '<p class="form-field"> <label for="_floor_area_from">' . __('Floor Area', 'propertyhive') . '</label> <input type="text" class="" name="_floor_area_from" id="_floor_area_from" value="' . get_post_meta($post->ID, '_floor_area_from', true) . '" placeholder="" style="width:15%; min-width:85px;"> <span style="float:left; padding:0 5px"> - </span> <input type="text" class="" name="_floor_area_to" id="_floor_area_to" value="' . get_post_meta($post->ID, '_floor_area_to', true) . '" placeholder="" style="width:15%; min-width:85px;"> <select name="_floor_area_units" id="_floor_area_units">'; foreach ($size_options as $key => $value) { echo '<option value="' . $key . '"'; if ($key == $floor_area_units) { echo ' selected'; } echo '>' . $value . '</option>'; } echo '</select> </p>'; $site_area_units = get_post_meta($post->ID, '_site_area_units', true); echo '<p class="form-field"> <label for="_site_area_from">' . __('Site Area', 'propertyhive') . '</label> <input type="text" class="" name="_site_area_from" id="_site_area_from" value="' . get_post_meta($post->ID, '_site_area_from', true) . '" placeholder="" style="width:15%; min-width:85px;"> <span style="float:left; padding:0 5px"> - </span> <input type="text" class="" name="_site_area_to" id="_site_area_to" value="' . get_post_meta($post->ID, '_site_area_to', true) . '" placeholder="" style="width:15%; min-width:85px;"> <select name="_site_area_units" id="_site_area_units">'; foreach ($size_options as $key => $value) { echo '<option value="' . $key . '"'; if ($key == $site_area_units) { echo ' selected'; } echo '>' . $value . '</option>'; } echo '</select> </p>'; do_action('propertyhive_property_commercial_details_fields'); echo '</div>'; echo '</div>'; echo '<script> jQuery(document).ready(function() { jQuery(\'#_available_as_sale\').change(function() { console.log(jQuery(this).is(\':checked\')); if (jQuery(this).is(\':checked\')) { jQuery(\'.commercial-sale-fields\').slideDown(\'fast\'); } else { jQuery(\'.commercial-sale-fields\').slideUp(\'fast\'); } }); jQuery(\'#_available_as_rent\').change(function() { console.log(jQuery(this).is(\':checked\')); if (jQuery(this).is(\':checked\')) { jQuery(\'.commercial-rent-fields\').slideDown(\'fast\'); } else { jQuery(\'.commercial-rent-fields\').slideUp(\'fast\'); } }); }); </script>'; }
/** * Output the metabox */ public static function output($post, $args = array()) { global $wpdb, $thepostid; $original_post = $post; $original_thepostid = $thepostid; // Used in the scenario where this meta box isn't used on the property edit page if (isset($args['args']['property_post'])) { $post = $args['args']['property_post']; $thepostid = $post->ID; setup_postdata($post); } if (isset($_GET['owner_contact_id']) && !empty($_GET['owner_contact_id'])) { if (get_post_type($_GET['owner_contact_id']) == 'contact') { $owner_contact_id = $_GET['owner_contact_id']; } } else { $owner_contact_id = get_post_meta($post->ID, '_owner_contact_id', TRUE); } echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; echo '<input type="hidden" name="_owner_contact_id" id="_owner_contact_id" value="' . $owner_contact_id . '">'; // No owner currently selected echo '<div id="search_propertyhive_contacts"' . ($owner_contact_id != '' ? ' style="display:none"' : '') . '>'; echo '<p class="form-field search_propertyhive_contacts_keyword_field"> <label for="search_propertyhive_contacts_keyword">' . __('Search Existing Contacts', 'propertyhive') . '</label> <input type="text" class="short" name="search_propertyhive_contacts_keyword" id="search_propertyhive_contacts_keyword" value="" placeholder="' . __('Start typing to search...', 'propertyhive') . '"> </p>'; echo '<p class="form-field search_propertyhive_contacts_results"> <label for="search_propertyhive_contacts_results"></label> <span id="search_propertyhive_contacts_results"></span> </p>'; echo '<p class="form-field"><label> </label>'; echo __('Or', 'propertyhive') . '<br><br>'; echo '<a href="#" class="button add-new-property-owner-contact">' . __('Add New Contact', 'propertyhive') . '</a>'; echo '</p>'; echo '</div>'; echo '<script> function load_existing_owner_contact(contact_id) { // Do AJAX request var data = { action: \'propertyhive_load_existing_owner_contact\', contact_id: contact_id, security: \'' . wp_create_nonce("load-existing-owner-contact") . '\', }; jQuery.post( \'' . admin_url('admin-ajax.php') . '\', data, function(response) { jQuery(\'#existing-owner-details\').html( response ); }); jQuery(\'#_owner_contact_id\').val(contact_id); } jQuery(document).ready(function() { '; if ($owner_contact_id != '') { echo 'load_existing_owner_contact(' . $owner_contact_id . ');'; } echo ' jQuery(\'a.add-new-property-owner-contact\').click(function() { jQuery(\'#search_propertyhive_contacts\').fadeOut(\'fast\', function() { jQuery(\'#add_new_property_owner_contact\').fadeIn(); }); return false; }); jQuery(\'a.search-property-owner-contacts\').click(function() { jQuery(\'#add_new_property_owner_contact\').fadeOut(\'fast\', function() { jQuery(\'#search_propertyhive_contacts\').fadeIn(); jQuery(\'#search_propertyhive_contacts_keyword\').focus(); }); return false; }); jQuery(\'body\').on(\'click\', \'a[id^=\\\'search-contact-result-\\\']\', function() { var contact_id = jQuery(this).attr(\'id\'); contact_id = contact_id.replace(\'search-contact-result-\', \'\'); load_existing_owner_contact(contact_id); jQuery(\'#search_propertyhive_contacts\').fadeOut(\'fast\', function() { jQuery(\'#existing-owner-details\').fadeIn(); }); return false; }); jQuery(\'body\').on(\'click\', \'a#remove-owner-contact\', function() { jQuery(\'#existing-owner-details\').fadeOut(\'fast\', function() { jQuery(\'#search_propertyhive_contacts\').fadeIn(); }); jQuery(\'#_owner_contact_id\').val(\'\'); return false; }); // Existing contact search jQuery(\'#search_propertyhive_contacts_keyword\').keyup(function() { var keyword = jQuery(\'#search_propertyhive_contacts_keyword\').val(); if (keyword.length == 0) { // Clear existing results jQuery(\'#search_propertyhive_contacts_results\').stop(true, true).fadeOut(\'fast\'); } else { jQuery(\'#search_propertyhive_contacts_results\').stop(true, true).fadeIn(\'fast\'); if (keyword.length > 2) { // Do AJAX request var data = { action: \'propertyhive_search_contacts\', keyword: keyword, security: \'' . wp_create_nonce("search-contacts") . '\', }; jQuery.post( \'' . admin_url('admin-ajax.php') . '\', data, function(response) { if (response.length > 0) { var new_html = \'\'; for (var i in response) { new_html += \'<a href="#" id="search-contact-result-\' + response[i].ID + \'">\' + response[i].post_title + \'</a><br>\'; } jQuery(\'#search_propertyhive_contacts_results\').html(new_html); } else { jQuery(\'#search_propertyhive_contacts_results\').html(\'' . __('No contacts found', 'propertyhive') . '\'); } //$(\'ul.record_notes\').prepend( response ); //$(\'#propertyhive-property-notes\').unblock(); //$(\'#add_property_note\').val(\'\'); }); } else { jQuery(\'#search_propertyhive_contacts_results\').html(\'' . __('Keep on typing...', 'propertyhive') . '\'); } } }); }); </script>'; echo '<div id="add_new_property_owner_contact" style="display:none;">'; echo '<a href="#" class="button right search-property-owner-contacts">< ' . __('Search Existing Contacts', 'propertyhive') . '</a>'; echo '<h4>' . __('Name', 'propertyhive') . '</h4>'; propertyhive_wp_text_input(array('id' => '_owner_name', 'label' => __('Full Name', 'propertyhive'), 'desc_tip' => false, 'placeholder' => __('e.g. Mr & Mrs Jones, Ms Jane Smith', 'propertyhive'), 'type' => 'text')); echo '<h4>' . __('Correspondence Address', 'propertyhive') . ' (<a href="" class="use-property-address">Use Property Address</a>)</h4>'; propertyhive_wp_text_input(array('id' => '_owner_address_name_number', 'label' => __('Building Name / Number', 'propertyhive'), 'desc_tip' => false, 'placeholder' => __('e.g. Thistle Cottage, or Flat 10', 'propertyhive'), 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_owner_address_street', 'label' => __('Street', 'propertyhive'), 'desc_tip' => false, 'placeholder' => __('e.g. High Street', 'propertyhive'), 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_owner_address_two', 'label' => __('Address Line 2', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_owner_address_three', 'label' => __('Town / City', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_owner_address_four', 'label' => __('County / State', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_owner_address_postcode', 'label' => __('Postcode / Zip Code', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); $countries = get_option('propertyhive_countries', array('GB')); // Get all countries $owner_country = get_option('propertyhive_default_country', 'GB'); // get default if (empty($countries) || count($countries) < 2) { propertyhive_wp_hidden_input(array('id' => '_owner_address_country', 'value' => $owner_country)); } else { $ph_countries = new PH_Countries(); // Can't use $this->countries because we're inside a static method $country_options = array(); foreach ($countries as $country_code) { $country = $ph_countries->get_country($country_code); if ($country !== false) { $country_options[$country_code] = $country['name']; } } propertyhive_wp_select(array('id' => '_owner_address_country', 'label' => __('Country', 'propertyhive'), 'desc_tip' => false, 'options' => $country_options, 'value' => $owner_country)); } echo '<h4>' . __('Contact Details', 'propertyhive') . '</h4>'; propertyhive_wp_text_input(array('id' => '_owner_telephone_number', 'label' => __('Telephone Number', 'propertyhive'), 'desc_tip' => false, 'type' => 'text')); propertyhive_wp_text_input(array('id' => '_owner_email_address', 'label' => __('Email Address', 'propertyhive'), 'desc_tip' => true, 'description' => __('If the contact has multiple email addresses simply separate them using a comma', 'propertyhive'), 'type' => 'text')); echo '</div>'; do_action('propertyhive_property_owner_fields'); echo '<div id="existing-owner-details"' . ($owner_contact_id == '' ? ' style="display:none"' : '') . '>'; echo '</div>'; echo '</div>'; echo '</div>'; echo '<script> jQuery(document).ready(function() { jQuery(\'a.use-property-address\').click(function() { jQuery(\'#_owner_address_name_number\').val( jQuery(\'#_address_name_number\').val() ); jQuery(\'#_owner_address_street\').val( jQuery(\'#_address_street\').val() ); jQuery(\'#_owner_address_two\').val( jQuery(\'#_address_two\').val() ); jQuery(\'#_owner_address_three\').val( jQuery(\'#_address_three\').val() ); jQuery(\'#_owner_address_four\').val( jQuery(\'#_address_four\').val() ); jQuery(\'#_owner_address_postcode\').val( jQuery(\'#_address_postcode\').val() ); jQuery(\'#_owner_address_country\').val( jQuery(\'#_address_country\').val() ); return false; }); }); </script>'; $post = $original_post; $thepostid = $original_thepostid; setup_postdata($post); }
/** * Output the metabox */ public static function output($post, $args = array()) { global $wpdb, $thepostid; $thepostid = $post->ID; $original_post = $post; $original_thepostid = $thepostid; // Used in the scenario where this meta box isn't used on the property edit page if (isset($args['args']['property_post'])) { $post = $args['args']['property_post']; $thepostid = $post->ID; setup_postdata($post); } wp_nonce_field('propertyhive_save_data', 'propertyhive_meta_nonce'); echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; $post_parent_id = isset($post->post_parent) ? $post->post_parent : 0; $parent_post = false; if (isset($_GET['post_parent']) && $_GET['post_parent'] != '') { $post_parent_id = $_GET['post_parent']; $parent_post = $post_parent_id; } propertyhive_wp_hidden_input(array('id' => 'post_parent', 'value' => $post_parent_id)); $args = array('id' => '_reference_number', 'label' => __('Reference Number', 'propertyhive'), 'desc_tip' => false, 'type' => 'text'); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_reference_number', TRUE); } propertyhive_wp_text_input($args); $args = array('id' => '_address_name_number', 'label' => __('Building Name / Number', 'propertyhive'), 'desc_tip' => false, 'placeholder' => __('e.g. Thistle Cottage, or Flat 10', 'propertyhive'), 'type' => 'text'); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_address_name_number', TRUE); } propertyhive_wp_text_input($args); $args = array('id' => '_address_street', 'label' => __('Street', 'propertyhive'), 'desc_tip' => false, 'placeholder' => __('e.g. High Street', 'propertyhive'), 'type' => 'text'); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_address_street', TRUE); } propertyhive_wp_text_input($args); $args = array('id' => '_address_two', 'label' => __('Address Line 2', 'propertyhive'), 'desc_tip' => false, 'type' => 'text'); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_address_two', TRUE); } propertyhive_wp_text_input($args); $args = array('id' => '_address_three', 'label' => __('Town / City', 'propertyhive'), 'desc_tip' => false, 'type' => 'text'); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_address_three', TRUE); } propertyhive_wp_text_input($args); $args = array('id' => '_address_four', 'label' => __('County / State', 'propertyhive'), 'desc_tip' => false, 'type' => 'text'); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_address_four', TRUE); } propertyhive_wp_text_input($args); $args = array('id' => '_address_postcode', 'label' => __('Postcode / Zip Code', 'propertyhive'), 'desc_tip' => false, 'type' => 'text'); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_address_postcode', TRUE); } propertyhive_wp_text_input($args); // Country dropdown $countries = get_option('propertyhive_countries', array('GB')); $property_country = get_post_meta($thepostid, '_address_country', TRUE); $default_country = get_option('propertyhive_default_country', 'GB'); $country_js = array(); if ($property_country == '') { $property_country = $default_country; } // Make sure country is in list of countries we operate in if (!in_array($property_country, $countries)) { $property_country = $default_country; } if (empty($countries) || count($countries) < 2) { if (count($countries) == 1) { $ph_countries = new PH_Countries(); $country = $ph_countries->get_country($countries[0]); $country_js[$countries[0]] = $country; } $args = array('id' => '_address_country', 'value' => $property_country); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_address_country', TRUE); } propertyhive_wp_hidden_input($args); } else { $ph_countries = new PH_Countries(); // Can't use $this->countries because we're inside a static method $country_options = array(); foreach ($countries as $country_code) { $country = $ph_countries->get_country($country_code); if ($country !== false) { $country_options[$country_code] = $country['name']; $country_js[$country_code] = $country; } } $args = array('id' => '_address_country', 'label' => __('Country', 'propertyhive'), 'desc_tip' => false, 'options' => $country_options, 'value' => $property_country); if ($parent_post !== FALSE) { $args['value'] = get_post_meta($parent_post, '_address_country', TRUE); } propertyhive_wp_select($args); } // Location $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('location', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subterms = get_terms('location', $args); if (!empty($subterms) && !is_wp_error($subterms)) { foreach ($subterms as $term) { $options[$term->term_id] = '- ' . $term->name; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subsubterms = get_terms('location', $args); if (!empty($subsubterms) && !is_wp_error($subsubterms)) { foreach ($subsubterms as $term) { $options[$term->term_id] = '- ' . $term->name; } } } } } $term_list = wp_get_post_terms($post->ID, 'location', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } ?> <p class="form-field"><label for="location_id"><?php _e('Location', 'propertyhive'); ?> </label> <select id="location_id" name="location_id[]" multiple="multiple" data-placeholder="<?php _e('Select location(s)', 'propertyhive'); ?> " class="multiselect attribute_values"> <?php $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('location', $args); $selected_values = array(); $term_list = wp_get_post_terms($post->ID, 'location', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { foreach ($term_list as $term_id) { $selected_values[] = $term_id; } } if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>' . esc_html($term->name) . '</option>'; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subterms = get_terms('location', $args); if (!empty($subterms) && !is_wp_error($subterms)) { foreach ($subterms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>- ' . esc_html($term->name) . '</option>'; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subsubterms = get_terms('location', $args); if (!empty($subsubterms) && !is_wp_error($subsubterms)) { foreach ($subsubterms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>- - ' . esc_html($term->name) . '</option>'; } } } } } } ?> </select> <?php do_action('propertyhive_property_address_fields'); echo '</div>'; echo '</div>'; echo ' <script> var countries = ' . json_encode($country_js) . '; // Change currency symbol shown on sales and lettings details meta boxes function countryChange(country_code) { if (typeof countries[country_code] != \'undefined\') { jQuery(\'.currency-symbol\').html(countries[country_code].currency_symbol); } else { jQuery(\'.currency-symbol\').html(countries[jQuery(\'#_address_country\').val()].currency_symbol); } } jQuery(document).ready(function() { countryChange(jQuery(\'#_address_country\').val()); jQuery(\'select[id=\\\'_address_country\\\']\').change(function() { countryChange(jQuery(this).val()); }); if (jQuery(\'#title\').length > 0) { jQuery(\'#title\').change(function() { // Check title contains something if (jQuery(\'#title\').val() != \'\') { // Check all address fields are empty so we don\'t override anything should the user have customised it already if (jQuery(\'#_address_name_number\').val() == \'\' && jQuery(\'#_address_street\').val() == \'\' && jQuery(\'#_address_two\').val() == \'\' && jQuery(\'#_address_three\').val() == \'\' && jQuery(\'#_address_four\').val() == \'\' && jQuery(\'#_address_postcode\').val() == \'\') { // Yep. All address fields are empty // See if any of the locations can be set jQuery("#location_id > option").each(function() { if (this.text != \'\') { var text_to_search_for = this.text.replace(\'- \', \'\'); if (jQuery(\'#title\').val().indexOf(text_to_search_for) != -1) { this.selected = true; } } }); // Split address and fill related address field var address_fields = [ \'_address_name_number\', \'_address_street\', \'_address_two\', \'_address_three\', \'_address_four\', \'_address_postcode\' ]; // Split title by comma var explode_title = jQuery(\'#title\').val().split(\',\'); for (var i in explode_title) { var title_element = jQuery.trim(explode_title[i]); // Trim it to remove any white space either side if (title_element != \'\' && address_fields.length > 0) { if ( i == 0 ) { var split_title_element = title_element.split(\' \'); if (jQuery.isNumeric( title_element ) || jQuery.isNumeric( split_title_element[0] )) // check if this is a house number { jQuery(\'#\' + address_fields[0]).val(split_title_element[0]); title_element = title_element.replace(split_title_element[0], \'\', title_element); title_element = jQuery.trim(title_element); jQuery(\'#\' + address_fields[1]).val(title_element); address_fields.splice(0,2); } else { jQuery(\'#\' + address_fields[1]).val(title_element); address_fields.splice(0,2); } } else { var split_title_elements = title_element.split(\' \'); var numeric_matches = title_element.match(/\\d+/g); if (i == explode_title.length-1 && numeric_matches != null) { // We\'re on the last bit and it contains a number for (var j in split_title_elements) { var split_title_element = jQuery.trim(split_title_elements[j]); var numeric_matches = split_title_element.match(/\\d+/g); if (split_title_element.length >=2 && split_title_element.length <= 4 && numeric_matches != null) { // This bit of the address element definitely contains postcode bit var postcode = split_title_element; if (j == (split_title_elements.length - 2)) { var temp_title_element = jQuery.trim(split_title_elements[split_title_elements.length-1]); // Trim it to remove any white space either side if ((temp_title_element.length >=2 || temp_title_element.length <= 4)) { // We have one element left after this postcode += \' \' + temp_title_element; } } jQuery(\'#address_postcode\').val(postcode); break; } else { // General address element jQuery(\'#\' + address_fields[0]).val(title_element); address_fields.splice(0,1); } } } else { // General address element jQuery(\'#\' + address_fields[0]).val(title_element); address_fields.splice(0,1); } } } } jQuery(\'#_address_postcode\').trigger(\'change\'); } } }); } }); </script> '; $post = $original_post; $thepostid = $original_thepostid; setup_postdata($post); }
/** * Output the metabox */ public static function output($post) { echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; // Currency / Rent / Rent Frequency $ph_countries = new PH_Countries(); $default_country = get_option('propertyhive_default_country', 'GB'); $countries = get_option('propertyhive_countries', array($default_country)); $currencies = array(); foreach ($countries as $country) { $country = $ph_countries->get_country($country); if (!isset($currencies[$country['currency_code']])) { $currencies[$country['currency_code']] = $country['currency_symbol']; } } // Cater for when no currency selected or currencies have been updated in settings so existing currency doesn't exist $selected_currency = get_post_meta($post->ID, '_currency', true); if ($selected_currency == '' || !isset($currencies[$selected_currency])) { $country = $ph_countries->get_country($default_country); $selected_currency = $country['currency_code']; } $rent_frequency = get_post_meta($post->ID, '_rent_frequency', true); echo '<p class="form-field rent_field "> <label for="_rent">' . __('Rent', 'propertyhive') . (empty($currencies) || count($currencies) <= 1 ? ' (<span class="currency-symbol">' . $currencies[$selected_currency] . '</span>)' : '') . '</label>'; if (count($currencies) > 1) { echo '<select id="_rent_currency" name="_rent_currency" class="select" style="width:auto; float:left;">'; foreach ($currencies as $currency_code => $currency_sybmol) { echo '<option value="' . $currency_code . '"' . ($currency_code == $selected_currency ? ' selected' : '') . '>' . $currency_sybmol . '</option>'; } echo '</select>'; } else { echo '<input type="hidden" name="_rent_currency" value="' . $selected_currency . '">'; } echo '<input type="text" class="" name="_rent" id="_rent" value="' . get_post_meta($post->ID, '_rent', true) . '" placeholder="" style="width:20%;"> <select id="_rent_frequency" name="_rent_frequency" class="select" style="width:auto"> <option value="pppw"' . ($rent_frequency == 'pppw' ? ' selected' : '') . '>' . __('Per Person Per Week', 'propertyhive') . '</option> <option value="pw"' . ($rent_frequency == 'pw' ? ' selected' : '') . '>' . __('Per Week', 'propertyhive') . '</option> <option value="pcm"' . ($rent_frequency == 'pcm' || $rent_frequency == '' ? ' selected' : '') . '>' . __('Per Calendar Month', 'propertyhive') . '</option> <option value="pq"' . ($rent_frequency == 'pq' ? ' selected' : '') . '>' . __('Per Quarter', 'propertyhive') . '</option> <option value="pa"' . ($rent_frequency == 'pa' ? ' selected' : '') . '>' . __('Per Annum', 'propertyhive') . '</option> </select> </p>'; // POA propertyhive_wp_checkbox(array('id' => '_rent_poa', 'label' => __('Rent On Application', 'propertyhive'), 'desc_tip' => false, 'value' => get_post_meta($post->ID, '_poa', true))); // Deposit propertyhive_wp_text_input(array('id' => '_deposit', 'label' => __('Deposit', 'propertyhive'), 'desc_tip' => false, 'class' => '', 'custom_attributes' => array('style' => 'width:20%'))); // Furnished $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('furnished', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; } $term_list = wp_get_post_terms($post->ID, 'furnished', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => 'furnished_id', 'label' => __('Furnishing', 'propertyhive'), 'desc_tip' => false, 'options' => $options); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); // Available Date propertyhive_wp_text_input(array('id' => '_available_date', 'label' => __('Available Date', 'propertyhive'), 'desc_tip' => false, 'class' => 'short date-picker', 'placeholder' => 'YYYY-MM-DD', 'custom_attributes' => array('maxlength' => 10, 'pattern' => "[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])"))); do_action('propertyhive_property_residential_lettings_details_fields'); echo '</div>'; echo '</div>'; }
/** * Output the metabox */ public static function output($post) { echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; // Currency / Price $ph_countries = new PH_Countries(); $default_country = get_option('propertyhive_default_country', 'GB'); $countries = get_option('propertyhive_countries', array($default_country)); $currencies = array(); foreach ($countries as $country) { $country = $ph_countries->get_country($country); if (!isset($currencies[$country['currency_code']])) { $currencies[$country['currency_code']] = $country['currency_symbol']; } } // Cater for when no currency selected or currencies have been updated in settings so existing currency doesn't exist $selected_currency = get_post_meta($post->ID, '_currency', true); if ($selected_currency == '' || !isset($currencies[$selected_currency])) { $country = $ph_countries->get_country($default_country); $selected_currency = $country['currency_code']; } echo '<p class="form-field price_field "> <label for="_price">' . __('Price', 'propertyhive') . (empty($currencies) || count($currencies) <= 1 ? ' (<span class="currency-symbol">' . $currencies[$selected_currency] . '</span>)' : '') . '</label>'; if (count($currencies) > 1) { echo '<select id="_price_currency" name="_price_currency" class="select" style="width:auto; float:left;">'; foreach ($currencies as $currency_code => $currency_sybmol) { echo '<option value="' . $currency_code . '"' . ($currency_code == $selected_currency ? ' selected' : '') . '>' . $currency_sybmol . '</option>'; } echo '</select>'; } else { echo '<input type="hidden" name="_price_currency" value="' . $selected_currency . '">'; } echo '<input type="text" class="" name="_price" id="_price" value="' . get_post_meta($post->ID, '_price', true) . '" placeholder="" style="width:15%;"> </p>'; // POA propertyhive_wp_checkbox(array('id' => '_sale_poa', 'label' => __('Price On Application', 'propertyhive'), 'desc_tip' => false, 'value' => get_post_meta($post->ID, '_poa', true))); // Price Qualifier $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('price_qualifier', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; } $term_list = wp_get_post_terms($post->ID, 'price_qualifier', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => 'price_qualifier_id', 'label' => __('Price Qualifier', 'propertyhive'), 'desc_tip' => false, 'options' => $options); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); // Sale By $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('sale_by', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; } $term_list = wp_get_post_terms($post->ID, 'sale_by', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => 'sale_by_id', 'label' => __('Sale By', 'propertyhive'), 'desc_tip' => false, 'options' => $options); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); // Tenure $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('tenure', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; } $term_list = wp_get_post_terms($post->ID, 'tenure', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => 'tenure_id', 'label' => __('Tenure', 'propertyhive'), 'desc_tip' => false, 'options' => $options); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); do_action('propertyhive_property_residential_sales_details_fields'); echo '</div>'; echo '</div>'; }
/** * Output the metabox */ public static function output($post, $args = array()) { global $wpdb, $thepostid; $original_post = $post; $original_thepostid = $thepostid; // Used in the scenario where this meta box isn't used on the property edit page if (isset($args['args']['property_post'])) { $post = $args['args']['property_post']; $thepostid = $post->ID; setup_postdata($post); } echo '<div class="propertyhive_meta_box">'; echo '<div class="options_group">'; propertyhive_wp_text_input(array('id' => '_bedrooms', 'label' => __('Bedrooms', 'propertyhive'), 'desc_tip' => false, 'type' => 'number')); propertyhive_wp_text_input(array('id' => '_bathrooms', 'label' => __('Bathrooms', 'propertyhive'), 'desc_tip' => false, 'type' => 'number')); propertyhive_wp_text_input(array('id' => '_reception_rooms', 'label' => __('Reception Rooms', 'propertyhive'), 'desc_tip' => false, 'type' => 'number')); // Property Type $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('property_type', $args); $selected_value = ''; if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { $options[$term->term_id] = $term->name; $args = array('hide_empty' => false, 'parent' => $term->term_id); $subterms = get_terms('property_type', $args); if (!empty($subterms) && !is_wp_error($subterms)) { foreach ($subterms as $term) { $options[$term->term_id] = '- ' . $term->name; } } } $term_list = wp_get_post_terms($post->ID, 'property_type', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { $selected_value = $term_list[0]; } } $args = array('id' => 'property_type_id', 'label' => __('Property Type', 'propertyhive'), 'desc_tip' => false, 'options' => $options); if ($selected_value != '') { $args['value'] = $selected_value; } propertyhive_wp_select($args); ?> <p class="form-field"><label for="parking_ids"><?php _e('Parking', 'propertyhive'); ?> </label> <select id="parking_ids" name="parking_ids[]" multiple="multiple" data-placeholder="<?php _e('Select parking', 'propertyhive'); ?> " class="multiselect attribute_values"> <?php $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('parking', $args); $selected_values = array(); $term_list = wp_get_post_terms($post->ID, 'parking', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { foreach ($term_list as $term_id) { $selected_values[] = $term_id; } } if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>' . esc_html($term->name) . '</option>'; } } ?> </select> <p class="form-field"><label for="outside_space_ids"><?php _e('Outside Space', 'propertyhive'); ?> </label> <select id="outside_space_ids" name="outside_space_ids[]" multiple="multiple" data-placeholder="<?php _e('Select outside space', 'propertyhive'); ?> " class="multiselect attribute_values"> <?php $options = array('' => ''); $args = array('hide_empty' => false, 'parent' => 0); $terms = get_terms('outside_space', $args); $selected_values = array(); $term_list = wp_get_post_terms($post->ID, 'outside_space', array("fields" => "ids")); if (!is_wp_error($term_list) && is_array($term_list) && !empty($term_list)) { foreach ($term_list as $term_id) { $selected_values[] = $term_id; } } if (!empty($terms) && !is_wp_error($terms)) { foreach ($terms as $term) { echo '<option value="' . esc_attr($term->term_id) . '"'; if (in_array($term->term_id, $selected_values)) { echo ' selected'; } echo '>' . esc_html($term->name) . '</option>'; } } ?> </select> <?php do_action('propertyhive_property_residential_details_fields'); echo '</div>'; echo '</div>'; $post = $original_post; $thepostid = $original_thepostid; setup_postdata($post); }