Advertisement
Guest User

Untitled

a guest
May 24th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. /**
  2. * Adds the datepicker settings to the admin footer.
  3. * Only loads on the plugin-name settings page
  4. */
  5. function admin_footer() {
  6.  
  7. $screen = get_current_screen();
  8.  
  9. if ( $screen->id == 'settings_page_plugin-name' ) {
  10.  
  11. ?><script type="text/javascript">
  12. jQuery(document).ready(function(){
  13. jQuery('.datepicker').datepicker({
  14. dateFormat : 'D, m/d/yy'
  15. });
  16. });
  17. </script><?php
  18.  
  19. }
  20.  
  21. } // admin_footer()
  22. add_action( 'admin_print_scripts', array( $this, 'admin_footer' ), 1000 );
  23.  
  24.  
  25.  
  26. /**
  27. * Enqueues the built-in Datepicker script
  28. * Only loads on the plugin-name settings page
  29. */
  30. function enqueue_scripts( $hook_suffix ) {
  31.  
  32. $screen = get_current_screen();
  33.  
  34. if ( $screen->id == $hook_suffix ) {
  35.  
  36. wp_enqueue_script( 'jquery-ui-datepicker' );
  37.  
  38. }
  39.  
  40. } // enqueue_scripts()
  41. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
  42.  
  43.  
  44.  
  45. /**
  46. * Enqueues a Datepicker theme
  47. * Only loads on the plugin-name settings page
  48. */
  49. function enqueue_styles( $hook_suffix ) {
  50.  
  51. $screen = get_current_screen();
  52.  
  53. if ( $screen->id == $hook_suffix ) {
  54.  
  55. wp_enqueue_style( 'jquery.ui.theme', plugin_dir_url( __FILE__ ) . '/css/datepicker.css' ), array( 'jquery-ui-core', 'jquery-ui-datepicker' ), $this->version, 'all' );
  56.  
  57. }
  58.  
  59. } // enqueue_styles()
  60. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement