function wpsight_search_form_details() { $standard_details = wpsight_standard_details(); $search_details = array('status' => array('label' => __('Status', 'wpsight'), 'key' => '_price_status', 'data' => wpsight_listing_statuses(), 'type' => 'select', 'data_compare' => '=', 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 10), 'location' => array('label' => __('Location', 'wpsight'), 'taxonomy' => 'location', 'data' => array('dropdown' => true), 'type' => 'taxonomy', 'data_compare' => false, 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 20), 'listing-type' => array('label' => __('Type', 'wpsight'), 'taxonomy' => 'listing-type', 'data' => array('dropdown' => true), 'type' => 'taxonomy', 'data_compare' => false, 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 30), $standard_details['details_1']['id'] => array('label' => $standard_details['details_1']['label'], 'key' => '_details_1', 'type' => 'text', 'data_compare' => '=', 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 40), $standard_details['details_2']['id'] => array('label' => $standard_details['details_2']['label'], 'key' => '_details_2', 'type' => 'text', 'data_compare' => '=', 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 50), 'min' => array('label' => __('Price (min)', 'wpsight'), 'key' => '_price', 'type' => 'text', 'data_compare' => '>=', 'data_type' => 'numeric', 'default' => false, 'advanced' => true, 'position' => 60), 'max' => array('label' => __('Price (max)', 'wpsight'), 'key' => '_price', 'type' => 'text', 'data_compare' => '<=', 'data_type' => 'numeric', 'default' => false, 'advanced' => true, 'position' => 70), 'orderby' => array('label' => __('Order by', 'wpsight'), 'key' => false, 'data_compare' => false, 'data_type' => false, 'type' => 'radio', 'data' => array('date' => __('Date', 'wpsight'), 'price' => __('Price', 'wpsight'), 'title' => __('Title', 'wpsight')), 'default' => 'date', 'advanced' => true, 'position' => 80), 'order' => array('label' => __('Order', 'wpsight'), 'key' => false, 'data_compare' => false, 'data_type' => false, 'type' => 'radio', 'data' => array('asc' => __('asc', 'wpsight'), 'desc' => __('desc', 'wpsight')), 'default' => 'desc', 'advanced' => true, 'position' => 90)); // Apply filter to array $search_details = apply_filters('wpsight_search_form_details', $search_details); // Sort array by position $search_details = wpsight_sort_array_by_position($search_details); // Return filtrable array return $search_details; }
function wpsight_wpcasa_search_form_details($details) { // Reset general listing type unset($details['listing-type']); // Add property type $details['property-type'] = array('label' => __('Type', 'wpsight'), 'taxonomy' => 'property-type', 'data' => array('dropdown' => true), 'type' => 'taxonomy', 'data_compare' => false, 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 30); // Get standard details $standard_details = wpsight_standard_details(); // Set standard details IDs $standard_details_1 = $standard_details['details_1']['id']; $standard_details_2 = $standard_details['details_2']['id']; $details[$standard_details_1] = array('label' => $standard_details['details_1']['label'], 'data' => $standard_details['details_1']['data'], 'key' => '_details_1', 'type' => 'select', 'data_compare' => '>=', 'data_type' => 'numeric', 'default' => false, 'advanced' => false, 'position' => 40); $details[$standard_details_2] = array('label' => $standard_details['details_2']['label'], 'data' => $standard_details['details_2']['data'], 'key' => '_details_2', 'type' => 'select', 'data_compare' => '>=', 'data_type' => 'numeric', 'default' => false, 'advanced' => false, 'position' => 50); // Apply filter to array $details = apply_filters('wpsight_wpcasa_search_form_details', $details); // Sort array by position $details = wpsight_sort_array_by_position($details); // Return array return $details; }
function wpsight_toggle_options() { ?> <script type='text/javascript'> jQuery(document).ready(function($) { var totoggle_currency = '#section-currency_other, #section-currency_other_ent'; $('#currency').change(function() { if( $(this).val() == 'other' ) { $(totoggle_currency).fadeIn(150); } else { $(totoggle_currency).fadeOut(150); } }); <?php // Gets the unique option id $wpsight_settings = get_option(WPSIGHT_DOMAIN); if (isset($wpsight_settings['id'])) { $option_name = $wpsight_settings['id']; } else { $option_name = WPSIGHT_DOMAIN; } ?> $('#<?php echo $option_name; ?> -currency-other').click(function() { $(totoggle_currency).fadeToggle(150); }); if ($('#<?php echo $option_name; ?> -currency-other:checked').val() !== undefined) { $(totoggle_currency).show(); } <?php /** Loop through standard details and hide them */ $totoggle_details = array(); foreach (wpsight_standard_details() as $feature => $value) { $totoggle_details[] = '#section-' . $feature; } $totoggle_details = implode(', ', $totoggle_details); ?> var totoggle_details = '<?php echo $totoggle_details; ?> '; $('#listing_features').click(function() { $(totoggle_details).fadeToggle(150); }); if ($('#listing_features:checked').val() !== undefined) { $(totoggle_details).show(); } <?php /** Loop through standard details and hide them */ $totoggle_periods = array(); foreach (wpsight_rental_periods() as $period_id => $value) { $totoggle_periods[] = '#section-' . $period_id; } $totoggle_periods = implode(', ', $totoggle_periods); ?> var totoggle_periods = '<?php echo $totoggle_periods; ?> '; $('#rental_periods').click(function() { $(totoggle_periods).fadeToggle(150); }); if ($('#rental_periods:checked').val() !== undefined) { $(totoggle_periods).show(); } var totoggle_template = '#section-email_subject, #section-email_body'; $('#email_template').click(function() { $(totoggle_template).fadeToggle(150); }); if ($('#email_template:checked').val() !== undefined) { $(totoggle_template).show(); } var totoggle_template_general = '#section-email_subject_general, #section-email_body_general'; $('#email_template_general').click(function() { $(totoggle_template_general).fadeToggle(150); }); if ($('#email_template_general:checked').val() !== undefined) { $(totoggle_template_general).show(); } var totoggle_template_favorites = '#section-email_subject_favorites, #section-email_body_favorites'; $('#email_template_favorites').click(function() { $(totoggle_template_favorites).fadeToggle(150); }); if ($('#email_template_favorites:checked').val() !== undefined) { $(totoggle_template_favorites).show(); } <?php /** Loop through number of filters */ $totoggle_filters = array(); $filters_nr = apply_filters('wpsight_listing_search_filters_nr', 8); for ($i = 1; $i <= $filters_nr; $i++) { $totoggle_filters[] = '#section-filter_' . $i; } $totoggle_filters = implode(', ', $totoggle_filters); ?> var totoggle_filters = '<?php echo $totoggle_filters; ?> '; var totoggle_search = '#section-search_advanced_options, #section-search_filters'; $('#search_advanced').click(function() { $(totoggle_search).fadeToggle(150); if ($('#search_filters:checked').val() !== undefined) { $(totoggle_filters).fadeToggle(150); } }); if ($('#search_advanced:checked').val() !== undefined) { $(totoggle_search).show(); } $('#search_filters').click(function() { $(totoggle_filters).fadeToggle(150); }); if ($('#search_filters:checked').val() !== undefined && $('#search_advanced:checked').val() !== undefined) { $(totoggle_filters).show(); } }); </script><?php }
function wpsight_restrict_manage_posts_detail() { global $wpdb, $typenow; if ($typenow != wpsight_listing_post_type()) { return; } $standard_details = wpsight_standard_details(); ?> <select name="wpsight-details"> <option value=""><?php _e('Listing Details', 'wpsight'); ?> </option><?php $current = isset($_GET['wpsight-details']) ? $_GET['wpsight-details'] : false; $current_v = isset($_GET['wpsight-details-value']) ? $_GET['wpsight-details-value'] : false; foreach ($standard_details as $detail) { echo '<option value="' . $detail['id'] . '"' . selected($detail['id'], $current, false) . '>' . $detail['label'] . '</option>'; } ?> </select> <input type="text" name="wpsight-details-value" size="8" value="<?php echo $current_v; ?> " style="margin-right:15px" /><?php }
/** * Function to create subpages' filter options * * @author anhbp */ function custom_subpages_filter_form_details() { $standard_details = wpsight_standard_details(); $search_details = array('status' => array('label' => __('Status', 'wpsight'), 'key' => '_price_status', 'data' => wpsight_listing_statuses(), 'type' => 'select', 'data_compare' => '=', 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 10), $standard_details['details_1']['id'] => array('label' => $standard_details['details_1']['label'], 'key' => '_details_1', 'type' => 'text', 'data_compare' => '=', 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 40), $standard_details['details_2']['id'] => array('label' => $standard_details['details_2']['label'], 'key' => '_details_2', 'type' => 'text', 'data_compare' => '=', 'data_type' => false, 'default' => false, 'advanced' => false, 'position' => 50), 'min' => array('label' => __('Price (min)', 'wpsight'), 'key' => '_price', 'type' => 'number', 'data_compare' => '>=', 'data_type' => 'numeric', 'default' => false, 'advanced' => false, 'position' => 55), 'max' => array('label' => __('Price (max)', 'wpsight'), 'key' => '_price', 'type' => 'number', 'data_compare' => '<=', 'data_type' => 'numeric', 'default' => false, 'advanced' => false, 'position' => 60), 'minsize' => array('label' => __('Min sqm', 'wpsight'), 'key' => '_details_3', 'type' => 'number', 'data_compare' => '>=', 'data_type' => 'numeric', 'default' => false, 'advanced' => false, 'position' => 70)); // Apply filter to array $search_details = apply_filters('wpsight_search_form_details', $search_details); // Sort array by position $search_details = wpsight_sort_array_by_position($search_details); if (isset($search_details['property-type'])) { unset($search_details['property-type']); } // Return filtrable array return $search_details; }
function wpsight_listing_details_table_shortcode($atts) { $defaults = array('id' => get_the_ID(), 'before' => '', 'after' => '', 'empty' => 'true', 'wrap' => 'div'); extract(shortcode_atts($defaults, $atts)); // Open table $details = '<table class="table table-striped table-compare">'; // Add listing ID first $details .= '<tr class="listing-details-sc-detail table-compare-id">'; $details .= '<td class="table-compare-label">' . __('ID', 'wpsight') . ':</td>'; $details .= '<td class="table-compare-value">' . wpsight_get_listing_id() . '</td>'; $details .= '</tr><!-- .table-compare-id -->'; // Loop through standard details foreach (wpsight_standard_details() as $detail => $v) { // Don't show detail if label is emtpy in options $standard_details_option = wpsight_get_option($detail); if (empty($standard_details_option['label'])) { continue; } // Apply filter to optionally deactivate single detail if (apply_filters('wpsight_listing_details_table_' . $detail, true) != true) { continue; } $detail_meta = get_post_meta($id, '_' . $detail, true); if (!$detail_meta && $empty != 'true') { continue; } $detail_value = $detail_meta ? $detail_meta . ' ' . wpsight_get_measurement_units($v['unit']) : __('n/d', 'wpsight'); $details .= '<tr class="listing-details-sc-detail ' . $detail . '">'; $details .= '<td class="table-compare-label">' . $v['label'] . ':</td>'; $details .= '<td class="table-compare-value">' . $detail_value . '</td>'; $details .= '</tr><!-- .listing-details-sc-' . $detail . ' -->'; } // Add listing price at the end $details .= '<tr class="listing-details-sc-detail table-compare-price">'; $details .= '<td class="table-compare-value" colspan="2">' . wpsight_get_price() . '</td>'; $details .= '</tr><!-- .table-compare-price -->'; // Close table $details .= '</table><!-- .table-compare -->'; $output = sprintf('%1$s%3$s%2$s', $before, $after, $details); // Optionally wrap shortcode in HTML tags if (!empty($wrap) && $wrap != 'false' && in_array($wrap, array_keys(wp_kses_allowed_html('post')))) { $output = sprintf('<%2$s class="listing-details-table-sc">%1$s</%2$s>', $output, $wrap); } return apply_filters('wpsight_listing_details_table_shortcode', $output, $atts); }
/** * Register standard details to be translatable by WPML */ function wpsight_wpml_standard_details_register() { if (!function_exists('icl_register_string')) { return false; } $details = wpsight_standard_details(); foreach ($details as $detail) { $listing_detail = wpsight_get_standard_detail($detail['id']); icl_register_string(WPSIGHT_NAME . ' - ' . __('Listing Details', 'wpsight-wpml'), $detail['id'], $listing_detail['label']); } return false; }
function form($instance) { $defaults = array('listing_type' => true, 'listing_location' => true, 'listing_id' => true); foreach (wpsight_standard_details() as $key => $values) { $defaults[$key] = true; } $instance = wp_parse_args((array) $instance, $defaults); ?> <p> <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('listing_type'); ?> " name="<?php echo $this->get_field_name('listing_type'); ?> " <?php checked($instance['listing_type'], true); ?> /> <label for="<?php echo $this->get_field_id('listing_type'); ?> "><?php _e('Display type', 'wpsight'); ?> </label> </p> <p> <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('listing_location'); ?> " name="<?php echo $this->get_field_name('listing_location'); ?> " <?php checked($instance['listing_location'], true); ?> /> <label for="<?php echo $this->get_field_id('listing_location'); ?> "><?php _e('Display location', 'wpsight'); ?> </label> </p> <p> <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id('listing_id'); ?> " name="<?php echo $this->get_field_name('listing_id'); ?> " <?php checked($instance['listing_id'], true); ?> /> <label for="<?php echo $this->get_field_id('listing_id'); ?> "><?php _e('Display ID', 'wpsight'); ?> </label> </p> <?php // Loop through standard details $standard_details = wpsight_standard_details(); foreach (wpsight_standard_details() as $key => $values) { ?> <p> <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id($key); ?> " name="<?php echo $this->get_field_name($key); ?> " <?php checked($instance[$key], 1); ?> /> <label for="<?php echo $this->get_field_id($key); ?> "><?php echo __('Display', 'wpsight') . ': <em>' . $values['label'] . '</em>'; ?> </label> </p><?php } }
function wpcasa_standard_details() { return wpsight_standard_details(); }
function wpsight_get_listing_details($post_id = '', $details_nr = '', $details = false) { // Get post ID from $post_id if (empty($post_id)) { $post_id = get_the_ID(); } // If still empty, return false if (empty($post_id)) { return false; } // Get post custom data $post_custom = get_post_custom($post_id); // Get standard details $standard_details = wpsight_standard_details(); // Create markup $listing_details = '<div class="listing-details-overview clearfix">'; // Loop through details if (empty($details_nr)) { $details_nr = apply_filters('wpsight_get_listing_details_nr', 3); } // Check if specific details $details = apply_filters('wpsight_get_listing_details', $details); if (is_array($details)) { foreach ($details as $detail) { $pos = strpos($detail, '_'); if ($pos !== false && $pos == 0) { $detail = substr_replace($detail, '', $pos, strlen('_')); } if (!empty($post_custom['_' . $detail][0])) { $i = 1; // Get listing detail $listing_detail = wpsight_get_standard_detail($detail); $listing_details .= '<span class="listing-' . wpsight_dashes($detail) . ' listing-details-detail" title="' . $listing_detail['label'] . '">'; $listing_details .= $post_custom['_' . $detail][0] . ' '; $listing_details .= wpsight_get_measurement_units($standard_details[$detail]['unit']); $listing_details .= '</span><!-- .listing-' . wpsight_dashes($detail) . ' -->' . "\n"; $i++; } } } else { for ($i = 1; $i <= $details_nr; $i++) { if (!isset($post_custom['_details_' . $i][0])) { continue; } $listing_detail_value = $post_custom['_details_' . $i][0]; if (!empty($listing_detail_value)) { // Get listing detail $listing_detail = wpsight_get_standard_detail('details_' . $i); $listing_details .= '<span class="listing-details-' . $i . ' listing-details-detail" title="' . $listing_detail['label'] . '">'; // Check if value is data key if (!empty($listing_detail['data'])) { $listing_detail_value = $listing_detail['data'][$listing_detail_value]; } $listing_details .= $listing_detail_value . ' '; $listing_details .= wpsight_get_measurement_units($standard_details['details_' . $i]['unit']); $listing_details .= '</span><!-- .listing-details-' . $i . ' -->' . "\n"; } } } // Display formatted listing price $listing_details .= '<span class="listing-price">' . wpsight_get_price($post_id) . '</span><!-- .listing-price -->' . "\n"; // Close markup $listing_details .= '</div><!-- .listing-details -->'; return apply_filters('wpsight_listing_details', $listing_details); }
function wpsight_meta_box_listing_details() { $details_labels = array('title' => __('Listing Details', 'wpsight'), 'id' => __('ID', 'wpsight')); // Get standard features and merge with title $standardDetails = wpsight_standard_details(); if (!is_array($standardDetails)) { $standardDetails = array(); } $details_labels = array_merge($details_labels, $standardDetails); $details_labels = apply_filters('wpsight_listing_details_labels', $details_labels); /** * Add backward compatibility * for old wpCasa _property_id * custom field value */ $listing_id = false; if (wpsight_get_listing_edit_id()) { // Get old wpCasa _property_id $property_id_meta = get_post_meta(wpsight_get_listing_edit_id(), '_property_id', true); // Get new wpSight _listing_id $listing_id_meta = get_post_meta(wpsight_get_listing_edit_id(), '_listing_id', true); if (!empty($property_id_meta) && empty($listing_id_meta)) { update_post_meta(wpsight_get_listing_edit_id(), '_listing_id', $property_id_meta, ''); } if (empty($property_id_meta) && empty($listing_id_meta)) { $listing_id = wpsight_get_listing_id(wpsight_get_listing_edit_id()); } } // Set meta box $meta_box = array('id' => 'listing_details', 'title' => $details_labels['title'], 'pages' => array(wpsight_listing_post_type()), 'context' => 'normal', 'priority' => 'high', 'fields' => array('id' => array('name' => $details_labels['id'], 'id' => '_listing_id', 'type' => 'text', 'std' => $listing_id))); /** * Add standard details */ $units = wpsight_measurement_units(); foreach ($standardDetails as $detail => $value) { $standard_details_option = wpsight_get_option($detail); // If details hasn't been set before, display default if (!isset($standard_details_option['label'])) { $standard_details_option = wpsight_get_option($detail, true); } // Don't show detail if label is emtpy in options if (empty($standard_details_option['label'])) { continue; } if (!empty($details_labels[$detail])) { // Optionally add measurement label to title $unit = ''; if (!empty($details_labels[$detail]['unit'])) { $unit = $details_labels[$detail]['unit']; $unit = $units[$unit]; $unit = ' (' . $unit . ')'; } // If there is select data, create select fields else text if (!empty($details_labels[$detail]['data'])) { $meta_box['fields'][$detail] = array('name' => $details_labels[$detail]['label'] . $unit, 'id' => '_' . $detail, 'type' => 'select', 'options' => $details_labels[$detail]['data'], 'desc' => $details_labels[$detail]['description']); } else { $meta_box['fields'][$detail] = array('name' => $details_labels[$detail]['label'] . $unit, 'id' => '_' . $detail, 'type' => 'text', 'desc' => $details_labels[$detail]['description']); } // end if } // end if } // end foreach // Apply filter to array $meta_box = apply_filters('wpsight_meta_box_listing_details', $meta_box); return $meta_box; }