| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: Advanced scrollbar |
| 4 |
* Plugin URI: https://bPlugins.com |
| 5 |
* Description: Customize scrollbar of your website with unlimited styling and color using the plugin. |
| 6 |
* Version: 1.0 |
| 7 |
* Author: bPlugins LLC |
| 8 |
* Author URI: https://bPlugins.com |
| 9 |
* License: GPLv3 |
| 10 |
*/ |
| 11 |
|
| 12 |
/*-------------------------------------------------------------------------------*/ |
| 13 |
/* Rendering all javaScript |
| 14 |
/*-------------------------------------------------------------------------------*/ |
| 15 |
|
| 16 |
/* Latest jQuery of wordpress */ |
| 17 |
if ( ! function_exists( 'csb_wp_latest_jquery' ) ) : |
| 18 |
function csb_wp_latest_jquery() { |
| 19 |
wp_enqueue_script('jquery'); |
| 20 |
} |
| 21 |
add_action('init', 'csb_wp_latest_jquery'); |
| 22 |
endif; |
| 23 |
|
| 24 |
|
| 25 |
/* nicescroll js */ |
| 26 |
if ( ! function_exists( 'csb_get_jquerynicescroll_script' ) ) : |
| 27 |
function csb_get_jquerynicescroll_script(){ |
| 28 |
wp_enqueue_script( 'ppm-customscrollbar-js', plugin_dir_url( __FILE__ ) . 'js/jquery.nicescroll.min.js', array('jquery'), '20120206', false ); |
| 29 |
} |
| 30 |
add_action('wp_enqueue_scripts', 'csb_get_jquerynicescroll_script'); |
| 31 |
endif; |
| 32 |
/*-------------------------------------------------------------------------------*/ |
| 33 |
/* Include all require file |
| 34 |
/*-------------------------------------------------------------------------------*/ |
| 35 |
require_once("inc/class.settings-api.php"); |
| 36 |
require_once("inc/fields.php"); |
| 37 |
|
| 38 |
/*-------------------------------------------------------------------------------*/ |
| 39 |
/* Register a custom menu page. |
| 40 |
/*-------------------------------------------------------------------------------*/ |
| 41 |
add_action( 'admin_menu', 'csb_plg_menu_page' ); |
| 42 |
function csb_plg_menu_page() { |
| 43 |
add_menu_page( |
| 44 |
__( 'Custom color scrollbar', 'csb' ), |
| 45 |
'Custom color scrollbar', |
| 46 |
'manage_options', |
| 47 |
'options-general.php?page=c_s_b_setting', |
| 48 |
'', |
| 49 |
plugins_url( 'advanced-scrollbar/img/icn.png' ), |
| 50 |
6 |
| 51 |
); |
| 52 |
} |
| 53 |
/*-------------------------------------------------------------------------------*/ |
| 54 |
/* Active the jquery Nicescroll plugin |
| 55 |
/*-------------------------------------------------------------------------------*/ |
| 56 |
|
| 57 |
|
| 58 |
if ( ! function_exists( 'ppm_customscrollbar_active_js' ) ) : |
| 59 |
function ppm_customscrollbar_active_js(){ |
| 60 |
?> |
| 61 |
|
| 62 |
|
| 63 |
<?php |
| 64 |
function csb_retrive_option( $option, $section, $default = '' ) { |
| 65 |
|
| 66 |
$options = get_option( $section ); |
| 67 |
|
| 68 |
if ( isset( $options[$option] ) ) { |
| 69 |
return $options[$option]; |
| 70 |
} |
| 71 |
|
| 72 |
return $default; |
| 73 |
} |
| 74 |
$scrollbar_color = csb_retrive_option( 'asb_color', 'wedevs_basics', '#46b3e6' ); |
| 75 |
$scrollbar_width = csb_retrive_option( 'asb_width', 'wedevs_advanced', '10px' ); |
| 76 |
$scrollbar_border = csb_retrive_option( 'asb_border', 'wedevs_advanced', '1px solid #fff' ); |
| 77 |
$scrollbar_border_radius = csb_retrive_option( 'asb_border_radius', 'wedevs_advanced', '4px' ); |
| 78 |
$scrollbar_speed = csb_retrive_option( 'asb_scrollspeed', 'wedevs_basics', '60' ); |
| 79 |
$scrollbar_railalign= csb_retrive_option( 'asb_railalign', 'wedevs_basics','right' ); |
| 80 |
|
| 81 |
$scrollbar_mousescrollstep = csb_retrive_option( 'asb_mousescrollstep', 'wedevs_basics','40'); |
| 82 |
$scrollbar_autohidemode = csb_retrive_option( 'asb_autohidemode', 'wedevs_basics','false' ); |
| 83 |
$scrollbar_touchbehavior = csb_retrive_option( 'asb_touchbehavior', 'wedevs_basics','off' ); |
| 84 |
$scrollbar_background = csb_retrive_option( 'asb_background', 'wedevs_basics','' ); |
| 85 |
if ($scrollbar_touchbehavior=="off"){$scrollbar_touchbehavior='false';}else {$scrollbar_touchbehavior='true';}; |
| 86 |
if ($scrollbar_autohidemode=="true"){$scrollbar_autohidemode="true";}elseif($scrollbar_autohidemode=="false") {$scrollbar_autohidemode='false';}else{$scrollbar_autohidemode="\"cursor\"";}; |
| 87 |
?> |
| 88 |
<script> |
| 89 |
(function ($) { |
| 90 |
"use strict"; |
| 91 |
jQuery(document).ready(function($){ |
| 92 |
$("html").niceScroll({ |
| 93 |
|
| 94 |
hwacceleration:true, |
| 95 |
cursorcolor: "<?php echo $scrollbar_color; ?>", |
| 96 |
cursorwidth: "<?php echo $scrollbar_width; ?>", |
| 97 |
cursorborder: "<?php echo $scrollbar_border; ?>", |
| 98 |
cursorborderradius: "<?php echo $scrollbar_border_radius; ?>", |
| 99 |
scrollspeed: <?php echo $scrollbar_speed; ?>, |
| 100 |
railalign: "<?php echo $scrollbar_railalign; ?>", |
| 101 |
background: "<?php echo $scrollbar_background; ?>", |
| 102 |
touchbehavior:<?php echo $scrollbar_touchbehavior; ?>, |
| 103 |
mousescrollstep: <?php echo $scrollbar_mousescrollstep;?>, |
| 104 |
autohidemode: <?php echo $scrollbar_autohidemode;?>, // working |
| 105 |
}); |
| 106 |
}); |
| 107 |
}(jQuery)); |
| 108 |
</script> |
| 109 |
|
| 110 |
<?php |
| 111 |
} |
| 112 |
add_action('wp_footer', 'ppm_customscrollbar_active_js'); |
| 113 |
endif; |