Skip to content

Commit

Permalink
fix: fix select2 ui conflict from wp dark mode plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayhardaha committed Jan 28, 2024
1 parent 513fb4f commit 694407e
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions includes/class-vhc-wc-sales-report-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -915,18 +915,36 @@ public function enqueue_assets() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$version = VHC_WC_SALES_REPORT_VERSION;

// Array of styles to remove.
$styles_to_remove = array(
'woocommerce_admin',
'woocommerce_admin_styles',
'wp-dark-mode-admin',
);

// Loop through each style and deregister/dequeue it.
foreach ( $styles_to_remove as $style ) {
wp_deregister_style( $style );
wp_dequeue_style( $style );
}

// Enqueue styles.
wp_deregister_style( 'woocommerce_admin' );
wp_dequeue_style( 'woocommerce_admin' );
wp_deregister_style( 'woocommerce_admin_styles' );
wp_dequeue_style( 'woocommerce_admin_styles' );
wp_enqueue_style( 'vhc-wc-sales-report', vhc_wc_sales_report()->plugin_url() . '/assets/css/admin' . $suffix . '.css', array(), $version );

// Array of scripts to remove.
$scripts_to_remove = array(
'wc-enhanced-select',
'woo-variation-swatches-admin',
'select2',
);

// Loop through each script and deregister/dequeue it.
foreach ( $scripts_to_remove as $script ) {
wp_deregister_script( $script );
wp_dequeue_script( $script );
}

// Enqueue scripts.
wp_deregister_script( 'wc-enhanced-select' );
wp_dequeue_script( 'wc-enhanced-select' );
wp_deregister_script( 'woo-variation-swatches-admin' );
wp_dequeue_script( 'woo-variation-swatches-admin' );
wp_enqueue_script( 'vhc-wc-sales-report-select2', vhc_wc_sales_report()->plugin_url() . '/assets/js/select2' . $suffix . '.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker' ), $version, true );
wp_enqueue_script( 'vhc-wc-sales-report-enhancedselect', vhc_wc_sales_report()->plugin_url() . '/assets/js/enhancedselect' . $suffix . '.js', array( 'vhc-wc-sales-report-select2' ), $version, true );
wp_enqueue_script( 'vhc-wc-sales-report-datatable', vhc_wc_sales_report()->plugin_url() . '/assets/js/datatable' . $suffix . '.js', array( 'vhc-wc-sales-report-enhancedselect' ), $version, true );
Expand Down

0 comments on commit 694407e

Please sign in to comment.