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 }
/** * Register rental periods to be translatable by WPML */ function wpsight_wpml_rental_periods_register() { if (!function_exists('icl_register_string')) { return false; } $periods = wpsight_rental_periods(); foreach ($periods as $period => $label) { $rental_period = wpsight_get_rental_period($period); icl_register_string(WPSIGHT_NAME . ' - ' . __('Rental Periods', 'wpsight-wpml'), $period, $rental_period); } return false; }
/** * Get rental period value from period key * * @since 1.0 */ function wpsight_get_rental_period($period) { $rental_periods = wpsight_rental_periods(); return $rental_periods[$period]; }
/** * rental_periods_register() * * Register rental periods * for Polylang strings translation. * * @uses wpsight_rental_periods() * @uses wpsight_get_rental_period() * @uses pll_register_string() * * @since 1.0.0 */ public function rental_periods_register() { $periods = wpsight_rental_periods(); foreach ($periods as $period => $label) { $rental_period = wpsight_get_rental_period($period); pll_register_string('Listing Periods', $rental_period, WPSIGHT_NAME); } }
function wpsight_meta_box_listing_price() { // Listing price labels $labels_price = array('title' => __('Listing Price', 'wpsight'), 'price' => __('Price', 'wpsight'), 'price_note' => __('No currency symbols or thousands separators', 'wpsight'), 'status' => __('Status', 'wpsight'), 'period' => __('Period', 'wpsight'), 'availability' => __('Availability', 'wpsight'), 'not_available' => __('Item is no longer available', 'wpsight')); $labels_price = apply_filters('wpsight_listing_price_labels', $labels_price); // Set meta box $meta_box = array('id' => 'listing_price', 'title' => $labels_price['title'], 'pages' => array(wpsight_listing_post_type()), 'context' => 'normal', 'priority' => 'high', 'fields' => array('price' => array('name' => $labels_price['price'], 'id' => '_price', 'type' => 'text', 'desc' => $labels_price['price_note']), 'status' => array('name' => $labels_price['status'], 'id' => '_price_status', 'type' => 'select', 'options' => wpsight_listing_statuses()), 'period' => array('name' => $labels_price['period'], 'id' => '_price_period', 'type' => 'radio', 'options' => array_merge(array('' => __('None', 'wpsight')), wpsight_rental_periods())), 'availability' => array('name' => $labels_price['availability'], 'id' => '_price_sold_rented', 'type' => 'checkbox', 'desc' => $labels_price['not_available']))); // Apply filter to array $meta_box = apply_filters('wpsight_meta_box_listing_price', $meta_box); return $meta_box; }