Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. <?php
  2. function hkhk_options() {
  3. add_menu_page('Scrol Line Admin Settings', 'hk Settings','manage_options',
  4. 'hk_settings', 'hk_admin_options');
  5. }
  6. add_action('admin_menu', 'hkhk_options');
  7.  
  8.  
  9. function hk_defaults()
  10. {
  11. $hk_options = array(
  12. 'back_color' => '#ccc',
  13. );
  14.  
  15. }
  16. if ( is_admin() ) :
  17.  
  18. function hk_register_settings () {
  19. register_setting('hkhk_options', 'hk_options', 'hk_validate_options');
  20. }
  21. add_action('admin_init', 'hk_register_settings');
  22.  
  23. function hk_admin_options() {
  24. global $hk_options;
  25.  
  26. if ( ! isset( $_REQUEST['updated'] ) )
  27. $_REQUEST['updated'] = false;
  28. ?>
  29. <div class="wrap">
  30. <h2>Select Scrol Line Option</h2>
  31. <?php if ( false !== $_REQUEST['updated'] ) : ?>
  32. <div class="update fade"><p><strong><?php _e( 'Options saved' ); ?></strong></p></div>
  33. <?php endif; // If the form has just been submitted, this shows the notification ?>
  34.  
  35.  
  36. <form method="post" action="options.php">
  37. <?php $settings=get_option ( 'hk_options', $hk_options ); ?>
  38. <?php settings_fields('hkhk_options'); ?>
  39. <table class="form-table">
  40. <tr valign="top">
  41. <th scope="row"><label for="back_color"> Back Color </label></th>
  42. <td>
  43. <input id="back_color" type="text" name="hk_options[back_color]" value="<?php esc_attr_e($settings['back_color']); ?>" class="wp-picker-container" /><p class="description"> Choose any color from here for background color. </p>
  44. </td>
  45. </tr>
  46. </table>
  47. <p class="submit"><input type="submit" class="button-primary" value="Save Options" /> </p>
  48. </form>
  49. </div>
  50. <?php
  51. }
  52. function hk_validate_options( $input ){
  53. global $hk_options;
  54. $settings = get_option( 'hk_options', $hk_options );
  55. $input['back_color'] = wp_filter_post_kses( $input['back_color'] );
  56.  
  57. return $input;
  58. }
  59. endif;
  60. function scrol_line_active() {?>
  61. <?php global $hk_options; $hk_settings = get_option ( 'hk_options', $hk_options ); ?>
  62.  
  63. <script type="text/javascript">
  64. jQuery(document).ready(function($) {
  65. jQuery("body") .hk({
  66. backColor: "<?php echo $hk_settings['back_color']; ?>",
  67.  
  68. });
  69. });
  70. </script>
  71. <?php
  72. }
  73. add_action ('wp_head', 'scrol_line_active');
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement