最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Theme style overrides the plugin style

programmeradmin0浏览0评论

Website theme overrides the plugin style, I'm using Cars4Rent child theme and chauffeur-booking-system plugin. I would like the original look and style of the booking plugin but the theme overrides the styles of the plugin. I tried using wp_dequeue_style(), wp_deregister_style() and wp_enqueue_style() and it reorders the style sheets but I still don't get the original design of the plugin. Both Cars4Rent theme and booking plugin uses JQuery and don't know if there's any conflict. I can share the website link to see the page source if anyone help. Im new to the wordpress and would appreciate the input of the experts. Thanks in advance

UPDATE

I have tried this with Twenty Twenty theme as well and the result is same. The below is the plugin php file. Could you please point me out on where the change needed please?

load_plugin_textdomain('chauffeur-booking-system',false,dirname(plugin_basename(FILE)).'/languages/');

require_once('include.php');

$Plugin=new CHBSPlugin(); $WooCommerce=new CHBSWooCommerce();

register_activation_hook(FILE,array($Plugin,'pluginActivation'));

add_action('init',array($Plugin,'init')); add_action('after_setup_theme',array($Plugin,'afterSetupTheme')); add_filter('woocommerce_locate_template',array($WooCommerce,'locateTemplate'),1,3);

$WidgetBookingForm=new CHBSWidgetBookingForm(); $WidgetBookingForm->register();

Website theme overrides the plugin style, I'm using Cars4Rent child theme and chauffeur-booking-system plugin. I would like the original look and style of the booking plugin but the theme overrides the styles of the plugin. I tried using wp_dequeue_style(), wp_deregister_style() and wp_enqueue_style() and it reorders the style sheets but I still don't get the original design of the plugin. Both Cars4Rent theme and booking plugin uses JQuery and don't know if there's any conflict. I can share the website link to see the page source if anyone help. Im new to the wordpress and would appreciate the input of the experts. Thanks in advance

UPDATE

I have tried this with Twenty Twenty theme as well and the result is same. The below is the plugin php file. Could you please point me out on where the change needed please?

load_plugin_textdomain('chauffeur-booking-system',false,dirname(plugin_basename(FILE)).'/languages/');

require_once('include.php');

$Plugin=new CHBSPlugin(); $WooCommerce=new CHBSWooCommerce();

register_activation_hook(FILE,array($Plugin,'pluginActivation'));

add_action('init',array($Plugin,'init')); add_action('after_setup_theme',array($Plugin,'afterSetupTheme')); add_filter('woocommerce_locate_template',array($WooCommerce,'locateTemplate'),1,3);

$WidgetBookingForm=new CHBSWidgetBookingForm(); $WidgetBookingForm->register();

Share Improve this question edited Jun 12, 2020 at 17:29 faz asked Jun 12, 2020 at 15:28 fazfaz 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

In a plugin, you have hook add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ) to enqueue script and CSS. In this hook, there is third parameter $priority you can add the lowest priority to load that hook earlier in execution. So you have 2 options:

  • So if you do not have $priority added for plugin hook, it is 10. So you can add the higher priority for theme's hook. OR
  • You can add the less priority that 10 to plugin's hook.

This Priority option will work for you to load the script/css. for more information you can visit here: https://developer.wordpress/reference/functions/add_action/

Note**: Make sure plugin or theme update will not override this thing.

发布评论

评论列表(0)

  1. 暂无评论