0

I want to replace jquery date picker which I have now with this one: https://github.com/T00rk/bootstrap-material-datetimepicker What I need to change?

In my functions.php is this part of code:

function uep_admin_script_style( $hook ) {
    global $post_type;
if ( 'post.php' == $hook || 'post-new.php' == $hook ) {
    wp_enqueue_script(
        'upcoming-competitions',
        SCRIPTS . 'script.js',
        array( 'jquery', 'jquery-ui-datepicker' ),
        '1.0',
        true
    );

    wp_enqueue_style(
        'jquery-ui-calendar',
        STYLES . 'jquery-ui.css',
        false,
        '1.10.4',
        'all'
    );
    }
}
add_action( 'admin_enqueue_scripts', 'uep_admin_script_style' );

And script.js contain this code

(function( $ ) {

$( '#uep-competition-start-date' ).datepicker({
    dateFormat: 'MM dd, yy',
    onClose: function( selectedDate ){
        $( '#uep-competition-end-date' ).datepicker( 'option', 'minDate', selectedDate );
    }
});
$( '#uep-competition-end-date' ).datepicker({
    dateFormat: 'MM dd, yy',
    onClose: function( selectedDate ){
        $( '#uep-competition-start-date' ).datepicker( 'option', 'maxDate', selectedDate );
    }
});
$( '#uep-competition-entries-deadline' ).datepicker({
    dateFormat: 'MM dd, yy',
    onClose: function( selectedDate ){
        $( '#uep-competition-entries-deadline' ).datepicker( 'option', selectedDate );
    }
});
$( '#uep-class-start-date' ).datepicker({
    dateFormat: 'MM dd, yy',
    onClose: function( selectedDate ){
        $( '#uep-class-start-date' ).datepicker( 'option', selectedDate );
    }
});
})( jQuery );

1 Answer 1

0

If you don't need js datepicker then no need to keep that anymore. Use your desired plugin. Make sure your theme based on bootstrap latest version.

4
  • I need to use this github.com/T00rk/bootstrap-material-datetimepicker instead of old one
    – user86168
    May 13, 2017 at 21:33
  • is your theme based on bootstrap?than you can use bootstrap datetimepicker. It will not effect your theme. May 14, 2017 at 4:16
  • Yes it uses bootstrap, but I need to enque for wp-admin
    – user86168
    May 14, 2017 at 16:26
  • if you want to enque script for admin only then you can use this code bellow: add_action('init', 'admin_only'); function admin_only() { if( !is_admin() ) return; // filter assignemnts and such go here } May 14, 2017 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.