When the Events Calendar Plugin is used in conjunction with Advanced Custom Fields, the ECP hijacks that datepicker field within the admin. In my case, it also prevented new dates from saving.

This is what the date picker field calendar looks like normally with ACF.

ACF Datepicker Field Calendar

And here it is with the Events Calendar Plugin active.

This site only used the datepicker field on one ACF Options page, so I decided to remove some of the Event Calendar JavaScript that gets loaded specifically on this page, with wp_dequeue_script.

The dequeue function requires the use of the handle; to get the handle of third party scripts, you can use the wp_print_scripts action.

// Prints the handle names for all enqueued JS
function wpa54064_inspect_scripts() {
    global $wp_scripts;
    foreach( $wp_scripts->queue as $handle ) :
        echo '<div style="margin-left:4em;"><p>' . $handle . '</p></div>';
    endforeach;
}
add_action( 'wp_print_scripts', 'wpa54064_inspect_scripts' );

Then dequeue the Events Calendar scripts on that specific page. Add this to your mu-plugins folder.

class TempDisableECJS {

    public function remove_events_calendar_datepicker(){

        if(strpos($_SERVER['REQUEST_URI'], '[Distinguishable part of URL here]') ){

            wp_dequeue_script('tribe-common');
            wp_dequeue_script('tribe-admin-url-fragment-scroll');
            wp_dequeue_script('tribe-buttonset');
            wp_dequeue_script('tribe-validation');
            wp_dequeue_script('tribe-dependency');
            wp_dequeue_script('tribe-pue-notices');
            wp_dequeue_script('tribe-migrate-legacy-settings');
            wp_dequeue_script('tribe-events-admin');
            wp_dequeue_script('tribe-events-ecp-plugins');
            wp_dequeue_script('tribe-events-editor');
            wp_dequeue_script('tribe-events-dynamic');
            wp_dequeue_script('tribe-ignored-events');
            wp_dequeue_script('tribe-ea-fields');
            wp_dequeue_script('tribe-tooltip-js');
            wp_dequeue_script('tribe-onboarding-js');
            wp_dequeue_script('tribe-common-logging-controls');
            wp_dequeue_script('tribe-app-shop-js');
            wp_dequeue_script('tribe-events-pro-handlebars');
            wp_dequeue_script('tribe-events-settings');
            wp_dequeue_script('tribe-notice-dismiss');
            wp_dequeue_script('tribe-events-pro-admin-manager');
            wp_dequeue_script('tribe-admin-help-page');
        }
    }
}

$disable = new TempDisableECJS();
add_action( 'wp_print_scripts', [$disable, 'remove_events_calendar_datepicker'], 100 );

Leave a comment

Your email address will not be published.