duanmi1900
2017-01-22 20:44
浏览 128
已采纳

停止WordPress插件加载标题中的css文件

I'm using the plugin 'Ninja From' and I'm trying to stop it from loading a CSS file in the header.

The code that shows up when the wp_head() is called:

<link rel='stylesheet' id='nf-display-css'  href='http://example.com/wp-content/plugins/ninja-forms/assets/css/display-structure.css?ver=4.7.1' type='text/css' media='all' />

My code:

function remove_css_ninja_form(){
    wp_dequeue_style('nf-display-css');
    wp_deregister_style('nf-display-css');
    wp_dequeue_style('nf-display');
    wp_deregister_style('nf-display');
}

add_action( 'wp_enqueue_scripts', 'remove_css_ninja_form', 99999 );
add_action( 'wp_print_styles', 'remove_css_ninja_form', 99999 );
add_action( 'wp_head', 'remove_css_ninja_form', 9999 );

It is not working.

The PHP code from the plugin that's loading the CSS file:

wp_enqueue_style( 'nf-display', $css_dir . 'display-structure.css', array( 'dashicons' ) );

图片转代码服务由CSDN问答提供 功能建议

我正在使用插件'Ninja From',我试图阻止它加载CSS文件 标题。

调用 wp_head()时显示的代码:

 &lt;  link rel ='stylesheet'id ='nf-display-css'href ='http://example.com/wp-content/plugins/ninja-forms/assets/css/display-structure.css?ver = 4.7。  1'type ='text / css'media ='all'/&gt; 
   
 
 

我的代码:

  function remove_css_ninja_form(){
 wp_dequeue_style('nf-display-css'); 
 wp_deregister_style('nf-display-css'); 
 wp_dequeue_style('nf-display'); 
 wp_deregister_style('nf-  display'); 
} 
 
add_action('wp_enqueue_scripts','remove_css_ninja_form',99999); 
add_action('wp_print_styles','remove_css_ninja_form',99999); 
add_action('wp_head','remove_css_ninja_form',9999)  ; 
   
 
 

它无法正常工作。

插件中加载CSS文件的PHP代码:

 <代码> wp_enqueu  e_style('nf-display',$ css_dir。  'display-structure.css',array('dashicons')); 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douhao5280 2017-01-22 21:48
    已采纳

    Ninja Forms has a custom action you can use to dequeue the CSS.

    function wpse_nf_dequeue_styles() {
        wp_dequeue_style( 'nf-display' );
    }
    add_action( 'nf_display_enqueue_scripts', 'wpse_nf_dequeue_styles' );
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dsqdpn31467 2017-01-22 21:40
    function remove_ninjafrom_style() {
        wp_dequeue_style( "nf-display" );
    }
    add_action('wp_print_styles', 'remove_ninjafrom_style', 100);
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题