我在我的网站上安装了Slicknav Menu插件。现在,当我访问我的网站的主页并运行源代码时,我看到了这个插件的css和脚本代码的一部分:
<head>
...
<style id='slicknavcss-inline-css' type='text/css'>
.slicknav_menu {
display: none;
}
@media screen and (max-width: 768px) {
#responsive-menu {
display: none;
}
.slicknav_menu {
display: block;
background: #8c8c8c;
}
.slicknav_btn {
background-color:#f7634c;
float:right;
}
a.slicknav_open {
background-color:#dd3333;
}
...
</head>
脚本代码也在脑中:
<script type='text/javascript'>
/* <![CDATA[ */
var slickNavVars = {"ng_slicknav":{"ng_slicknav_menu":"#responsive-menu","ng_slicknav_position":"body","ng_slicknav_parent_links":true,"ng_slicknav_close_click":true,"ng_slicknav_child_links":false,"ng_slicknav_speed":400,"ng_slicknav_label":"","ng_slicknav_fixhead":false,"ng_slicknav_brand":"","ng_slicknav_search":false,"ng_slicknav_search_text":"search...","ng_slicksearch":"http:\/\/ali-coupons.net\/","ng_slicknav_closedsymbol":"\u25ba","ng_slicknav_openedsymbol":"\u25bc","ng_slicknav_alt":""}};
/* ]]> */
</script>
是否有想法从源代码中的标题中删除此代码?
这是来自插件的php文件的代码,它在网站的源代码头中生成样式和脚本:
//All the user input CSS settings as set in SLicknav settings
$slicknav_custom_css = "
.slicknav_menu {
display: none;
}
@media screen and (max-width: {$ng_slicknav_width}px) {
{$ng_slicknav_menu} {
display: none;
}
.slicknav_menu {
display: block;
background: {$ng_slicknav_background};
}
.slicknav_btn {
background-color:{$ng_slicknav_button};
float:{$ng_slicknav_button_position};
}
a.slicknav_open {
background-color:{$ng_slicknav_button_expand};
}
.slicknav_nav .slicknav_arrow {
float:{$ng_slicknav_submenu_position};
}
.slicknav_menu .slicknav_menutxt {
color: {$ng_slicknav_label_color};
text-shadow: {$ng_slicknav_label_shadow};
font-size: {$ng_slicknav_label_size}px;
font-weight: {$ng_slicknav_label_weight};
}
.slicknav_menu .slicknav_icon-bar {
background-color: {$ng_slicknav_icon_color};
box-shadow: {$ng_slicknav_icon_shadow};
}
.slicknav_nav li a {
color: {$ng_slicknav_link_color};
text-transform: {$ng_slicknav_font_case};
font-size: {$ng_slicknav_font}px;
padding: 5px 10px;
}
.slicknav_nav a:hover,
.slicknav_nav .menu-item a:hover,
.slicknav_nav .slicknav_row:hover {
background: {$ng_slicknav_link_hover_color};
color: {$ng_slicknav_link_hover_text_color};
}
.slicknav_nav input[type='submit']{
background: {$ng_slicknav_search_color};
}
}";
//If Menu button is set to left, move brand logo to right, set in Slicknav settings
if( $ng_slicknav_button_position == "left" )
$slicknav_custom_css .= "
.slicknav_brand {
float: right;
}";
//Fix menu to position in header if set in Slicknav settings
if( $ng_slicknav_fixhead == true )
$slicknav_custom_css .= "
@media screen and (max-width: {$ng_slicknav_width}px) {
.slicknav_menu {
position: fixed;
width: 100%;
left: 0;
top: 0;
z-index: 999999;
}
html {
padding-top: 45px;
}
}";
//Hide header if option is clicked in SlickNav settings
if( $ng_slicknav_header == true )
$slicknav_custom_css .= "
@media screen and (max-width:{$ng_slicknav_width}px) {
.site-header {
display: none;
}
}";
}
//add the above custom CSS via wp_add_inline_style
wp_add_inline_style( 'slicknavcss', $slicknav_custom_css );
}
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\responsive_menucss' );
答案 0 :(得分:1)
SlickNav WordPress插件正在添加该代码。您可以以更正常,更正确的方式自行加载该代码:http://slicknav.com/。确保在加载jQuery后加载SlickNav js。