成语| 古诗大全| 扒知识| 扒知识繁体

当前位置:首页 > 运动户外

wordpress代码高亮插件

Q1:WordPress代码高亮插件SyntaxHighlighter Evolved,编辑代码时,如何实现缩进?

WordPress
先判断下是否登录,然后获取当前用户对象,然后获取当前用户对象的信息,需要哪些用哪些:
1、2、3、4、5、6、7、8、9、10、11、12、13、14、
if(is_user_logged_in()){
$current_user = wp_get_current_user();
/**
* @example Safe usage: $current_user = wp_get_current_user();
* if ( !($current_user instanceof WP_User) )
*return;
*/
echo Username: . $current_user->user_login .
;
echo User email: . $current_user->user_email .
;
echo User first name: . $current_user->user_firstname .
;
echo User last name: . $current_user->user_lastname .
;
echo User display name: . $current_user->display_name .
;
echo User ID: . $current_user->ID .
;
}

Q2:wordpress代码高亮用什么插件

WordPress有很多的代码高亮插件,但是效果和使用都不是很理想,后来也就找到了一款WP-Syntax的插件,感觉还是非常不错的。

但是由于WP-Syntax插件的默认样式有些怪异,所以可以使用一下css做一个美化

/*wp_syntaxupdate:2016/04/12*/
.wp_syntax{
color:#100;
background-color:#f9f9f9;
border:1pxsolid#EBEBEB;
margin:6px0;
overflow:auto;
}
.wp_syntax{
overflow-x:auto;
overflow-y:hidden;
padding-bottom:expression(this.scrollWidth>this.offsetWidth?15:0);
width:99%;
}
.wp_syntaxtable{
border:none;
border-collapse:collapse;
margin:0;
padding:0;
width:100%!important
}
.wp_syntaxcaption{
padding:2px;
width:100%;
background-color:#def;
text-align:left;
font-family:Monaco;
font-size:13px;
line-height:20px;
}
.wp_syntaxcaptiona{
color:#1982d1;
text-align:left;
font-family:Monaco;
font-size:13px;
line-height:20px;
text-decoration:none;
}
.wp_syntaxcaptiona:hover{
color:#1982d1;
text-decoration:underline;
}
.wp_syntaxdiv,.wp_syntaxtd{
border:none;
text-align:left;
padding:0;
vertical-align:top;
}
.wp_syntaxtd.code{
background:none;
line-height:normal;
white-space:normal;
padding-left:10px;
}
.wp_syntaxpre,.wp_syntaxspan{
background:transparent;
margin:0;
padding:0;
width:auto;
float:none;
clear:none;
overflow:visible;
font-family:Monaco;
font-size:13px;
line-height:26px;
white-space:pre;
font-family:Consolas,Monaco,MicrosoftYaHei,WenQuanYiMicroHei,LucidaConsole,monospace;
}
.wp_syntaxtd.line_numbers{
width:36px
}
.wp_syntaxtd.line_numberspre{
border-right:3pxsolid#666;
background-color:#E7E5DC;
color:gray;
padding:05px;
text-align:right;
}

你也可以将上面的代码添加到你主题的 style.css 文件中,然后在 functions.php 中添加下面的代码,取消 WP-Syntax 加载的css文件,这样,即使你以后升级了插件,也能保留你自己的样式。

if(has_action(wp_print_styles,wp_syntax_style)){
remove_action(wp_print_styles,wp_syntax_style);
};

这样就非常的好了。

以上代码

Q3:图中 wordpress 高亮代码插件是哪个?

CodeColorer

使用本插件您可以在日志中插入漂亮的语法高亮效果的代码片段,本插件基于GeSHi代码高亮库。启用本插件后请访问插件设置页面配置代码显示风格。

很抱歉,上传的附件已失效

Q4:wordpress博客 描写文章代码高亮问题 用的CodeColorer插件 或者求一款真正支持c#代码的高亮插件

代码高亮我没用插件,不喜欢用插件,可以试试灰底代码的方式,timle.cn/high-light-codes.html
还可以根据自己需要改样式

猜你喜欢

更多