admin管理员组文章数量:1125966
I'm working with the WordPress Traveler theme. In the Tour option, there is a slider used for Max People. Max People will be used for another purpose and should work with a precision of 0.1 instead of integers. To achieve this, I made changes in the files: wp-content\plugins\traveler-code\st-option-tree\includes\ot-functions-option-types.php and wp-content\plugins\st-option-tree\includes\ot-functions-option-types.php.
I modified the ot_type_numeric_slider function:
function ot_type_numeric_slider($args = array())
{
extract($args); // phpcs:ignore
// Check for description.
$has_desc = !empty($field_desc);
// Min, max, step options.
$_options = explode(',', $field_min_max_step);
$min = isset($_options[0]) ? floatval($_options[0]) : 0;
$max = isset($_options[1]) ? floatval($_options[1]) : 100;
$step = isset($_options[2]) ? floatval($_options[2]) : 0.1;
// Format setting outer wrapper.
echo '<div class="format-setting type-numeric-slider ' . ($has_desc ? 'has-desc' : 'no-desc') . '">';
// Description.
echo $has_desc ? '<div class="description">' . wp_kses_post(htmlspecialchars_decode($field_desc)) . '</div>' : '';
// Format setting inner wrapper.
echo '<div class="format-setting-inner">';
echo '<div class="ot-numeric-slider-wrap">';
echo '<input type="hidden" name="' . esc_attr($field_name) . '" id="' . esc_attr($field_id) . '" class="ot-numeric-slider-hidden-input" value="' . esc_attr($field_value) . '" data-min="' . esc_attr($min) . '" data-max="' . esc_attr($max) . '" data-step="' . esc_attr($step) . '">';
echo '<input type="text" class="ot-numeric-slider-helper-input widefat option-tree-ui-input ' . esc_attr($field_class) . '" value="' . esc_attr($field_value) . '" readonly>';
echo '<div id="ot_numeric_slider_' . esc_attr($field_id) . '" class="ot-numeric-slider"></div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
So I changed below part:
$_options = explode(',', $field_min_max_step);
$min = isset($_options[0]) ? $_options[0] : 0;
$max = isset($_options[1]) ? $_options[1] : 100;
$step = isset($_options[2]) ? $_options[2] : 1;
To:
$_options = explode(',', $field_min_max_step);
$min = isset($_options[0]) ? floatval($_options[0]) : 0;
$max = isset($_options[1]) ? floatval($_options[1]) : 100;
$step = isset($_options[2]) ? floatval($_options[2]) : 0.1;
After implementing these changes, the slider still operates with integers. I don't see anything else related to the slider in this file, and the support mentioned that the changes should be made only in this file. What could have gone wrong?
本文标签: phpModifying Slider Function for Decimal Precision
版权声明:本文标题:php - Modifying Slider Function for Decimal Precision 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736671484a1946945.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论