function cmb2_render_callback_for_number_field($field, $escaped_value, $object_id, $object_type, $field_type_object) { // get our options $scroll_progress_options = spb_get_options(); $value = isset($scroll_progress_options['progress_bar_top_offset']) ? $scroll_progress_options['progress_bar_top_offset'] : '0'; echo '<label><input type="number" max="9999" min="0" name="progress_bar_top_offset" value="' . $value . '"> <em>px</em></label>'; // display a description echo '<p class="cmb2-metabox-description">' . __('You can specify a top offset in the field above (px). This is useful if you have a sticky navigation that scrolls with the page.', 'scroll-progress') . '</p>'; }
function spb_smooth_scroll_scripts_and_styles() { $scroll_progress_options = spb_get_options(); $duration = isset($scroll_progress_options['smooth_scroll_scroll_time']) ? $scroll_progress_options['smooth_scroll_scroll_time'] : '.5'; $distance = isset($scroll_progress_options['smooth_scroll_pixel_offset']) ? $scroll_progress_options['smooth_scroll_pixel_offset'] : '300'; // enqueue our smooth scroll script from CDN wp_register_script('smooth-scroll', plugin_dir_url(__FILE__) . 'lib/js/TweenMax.min.js', array('jquery'), 'all'); wp_enqueue_script('smooth-scroll'); wp_register_script('scroll-to', plugin_dir_url(__FILE__) . 'lib/js/ScrollToPlugin.min.js', array('jquery'), 'all'); wp_enqueue_script('scroll-to'); // enqueue our smooth scroll script which handles the actual scrolling wp_register_script('smooth-scroll-handling', plugin_dir_url(__FILE__) . 'lib/js/smooth-scroll-handle.min.js', array('jquery', 'smooth-scroll', 'scroll-to'), 'all'); // localize data, pass to our scroll handling script $localized_array = array('scrollTime' => $duration, 'scrollDistance' => $distance); wp_localize_script('smooth-scroll-handling', 'smooth_scroll', $localized_array); wp_enqueue_script('smooth-scroll-handling'); }