坚持五年分享整理阿里(ACA/ACP/ACE),腾讯(云从业者/TCA/TCP),华为(HCIA/HCIP/HCIE),AWS(SAA/SAP)等工程师考试认证,题库,视频,资料,成功帮助5W+学员获得专业认证!
    当前位置:
  • 首页
  • >
  • 认证大使发展历程及主题修改记录

认证大使发展历程及主题修改记录

2021.08.11 添加彩色信息框,/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#最后加入

/*短代码信息框 开始*/
function toz($atts, $content=null){
    return '<div id="sc_notice">'.$content.'</div>';
}
add_shortcode('v_notice','toz');
function toa($atts, $content=null){
    return '<div id="sc_error">'.$content.'</div>';
}
add_shortcode('v_error','toa');
function toc($atts, $content=null){
    return '<div id="sc_warn">'.$content.'</div>';
}
add_shortcode('v_warn','toc');
function tob($atts, $content=null){
    return '<div id="sc_tips">'.$content.'</div>';
}
add_shortcode('v_tips','tob');
function tod($atts, $content=null){
    return '<div id="sc_blue">'.$content.'</div>';
}
add_shortcode('v_blue','tod');
function toe($atts, $content=null){
    return '<div id="sc_black">'.$content.'</div>';
}
add_shortcode('v_black','toe');
function tof($atts, $content=null){
    return '<div id="sc_xuk">'.$content.'</div>';
}
add_shortcode('v_xuk','tof');
function tog($atts, $content=null){
    return '<div id="sc_lvb">'.$content.'</div>';
}
add_shortcode('v_lvb','tog');
function toh($atts, $content=null){
    return '<div id="sc_redb">'.$content.'</div>';
}
add_shortcode('v_redb','toh');
function toi($atts, $content=null){
    return '<div id="sc_orange">'.$content.'</div>';
}
add_shortcode('v_orange','toi');
/* 短代码信息框 完毕*/

/www/wwwroot/ls102/wp-content/themes/wpzt-just/static/css#最后加入

/*彩色信息框*/
#sc_notice {
    color: #7da33c;
    background: #ecf2d6 url('img/sc_notice.png') -1px -1px no-repeat;
    border: 1px solid #aac66d;
    overflow: hidden;
    margin: 10px 0;
    padding: 15px 15px 15px 35px;
 }
#sc_warn {
    color: #ad9948;
    background: #fff4b9 url('img/sc_warn.png') -1px -1px no-repeat;
    border: 1px solid #eac946;
    overflow: hidden;
    margin: 10px 0;
    padding: 15px 15px 15px 35px;
 }
#sc_error {
    color: #c66;
    background: #ffecea url('img/sc_error.png') -1px -1px no-repeat;
    border: 1px solid #ebb1b1;
    overflow: hidden;
    margin: 10px 0;
    padding: 15px 15px 15px 35px;
 }
#sc_tips {
    color: #777;
    background: #eaeaea url('img/sc_tips.png') -1px -1px no-repeat;
    border: 1px solid #ccc;
    overflow: hidden;
    margin: 10px 0;
    padding: 15px 15px 15px 35px;
}
#sc_blue {
    color: #1ba1e2;
    background: rgba(27, 161, 226, 0.26) url('img/sc_blue.png') -1px -1px no-repeat;
    border: 1px solid #1ba1e2;
    overflow: hidden;
    margin: 10px 0;
    padding: 15px 15px 15px 35px;
}
#sc_black {
    border-width: 1px 4px 4px 1px;
    border-style: solid;
    border-color: #3e3e3e;
    margin: 10px 0;
    padding: 15px 15px 15px 35px;
}
#sc_xuk {
    border: 2px dashed rgb(41, 170, 227);
    background-color: rgb(248, 247, 245);
    margin: 10px 0;
    padding: 15px 15px 15px 35px;
}
#sc_lvb {
    margin: 10px 0;
    padding: 10px 15px;
    border: 1px solid #e3e3e3;
    border-left: 2px solid #05B536;
    background: #FFF;
}
#sc_redb {
    margin: 10px 0;
    padding: 10px 15px;
    border: 1px solid #e3e3e3;
    border-left: 2px solid #ED0505;
    background: #FFF;
}
#sc_organge {
    margin: 10px 0;
    padding: 10px 15px;
    border: 1px solid #e3e3e3;
    border-left: 2px solid #EC8006;
    background: #FFF;
}
在文章编辑时插入以下代码即可,注意修改下括号。

{v_notice]绿色提示框[/v_notice}

{v_error]红色提示框[/v_error}

{v_warn]黄色提示框[/v_warn}

{v_tips]灰色提示框[/v_tips}

{v_blue]蓝色提示框[/v_blue}

{v_black]黑色提示框[/v_black}

{v_xuk]虚线提示框[/v_xuk}

{v_lvb]绿边提示框[/v_lvb}

{v_redb]红边提示框[/v_redb}

{v_orange]橙边提示框[/v_orange}

 

2021.08.11 包括管理员在内,所有用户只能看到自己发布的文章/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#最后加入

//所有用户只能看到自己后台的文章
function wpjam_parse_query_useronly( $wp_query ) {
    if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit.php' ) !== false ) {
        if ( !current_user_can( 'add_user' ) ) {
            global $current_user;
            $wp_query->set( 'author', $current_user->id );
        }
    }
}
add_filter('parse_query', 'wpjam_parse_query_useronly' );

 

2021.08.09 添加禁止普通用户访问后台/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#最后加入

//禁止普通用户访问后台
function wizhi_restrict_admin() {
    if ( ! current_user_can( 'manage_options' )  && $_SERVER['PHP_SELF'] != '/wp-admin/admin-ajax.php' ) { //判断是否为管理员
        wp_redirect( '/' ); //跳转到/界面
    }
}
add_action( 'admin_init', 'wizhi_restrict_admin', 1 );

 

2021.08.09 添加用管理员免密一键切换其他账号登录/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#最后加入

/** 
* WordPress 后台管理员免密一键切换其他账号登录
*/ 
function wpdx_user_switch_action($actions, $user){
    $capability = (is_multisite())?'manage_site':'manage_options';
    if(current_user_can($capability)){
        $actions['login_as'] = '<a title="以此身份登录" href="'.wp_nonce_url("users.php?action=login_as&users=$user->ID", 'bulk-users').'">以此身份登录</a>';
    }
    return $actions;
}
add_filter('user_row_actions', 'wpdx_user_switch_action', 10, 2);

function wpdx_handle_user_switch_action($sendback, $action, $user_ids){
    if($action == 'login_as'){
        wp_set_auth_cookie($user_ids, true);
        wp_set_current_user($user_ids);
    }
    return admin_url();
}
add_filter('handle_bulk_actions-users','wpdx_handle_user_switch_action', 10, 3);

 

2021.08.04 添加用户用户注册,并按照注册时间排序/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#最后加入

/*
*添加用户用户注册,并按照注册时间排序
*/
add_filter('manage_users_columns', function($column_headers){
	$column_headers['registered'] = '注册时间';
	return $column_headers;
});

add_filter('manage_users_custom_column', function($value, $column_name, $user_id){
	if($column_name=='registered'){
		$user = get_userdata($user_id);
		return get_date_from_gmt($user->user_registered);
	}else{
		return $value;
	}
},11,3);


add_filter('manage_users_sortable_columns', function($sortable_columns){
	$sortable_columns['reg_time'] = 'reg_time';
	return $sortable_columns;
});

add_action('pre_user_query', function($query){
	if(!isset($_REQUEST['orderby']) || $_REQUEST['orderby']=='reg_time' ){
		if( !in_array($_REQUEST['order'],array('asc','desc')) ){
			$_REQUEST['order'] = 'desc';
		}
		$query->query_orderby = "ORDER BY user_registered ".$_REQUEST['order']."";
	}
});

 

2021.07.27 更改标签页显示的标签数量/www/wwwroot/ls102/wp-content/themes/wpzt-just/page#37行

$number=72; 
更改为
$number=144;

 

2021.07.23 添加文章关键词自动添加内链链接代码/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#最后加入

/*
*Wordpress文章关键词自动添加内链链接代码
*/
//连接数量
 $match_num_from = 1; //一个关键字少于多少不替换
 $match_num_to = 1; //一个关键字最多替换次数
 //连接到WordPress的模块
 add_filter('the_content','tag_link',1);
 //按长度排序
 function tag_sort($a, $b){
 if ( $a->name == $b->name ) return 0;
 return ( strlen($a->name) > strlen($b->name) ) ? -1 : 1;
 }
 //改变标签关键字
 function tag_link($content){
 global $match_num_from,$match_num_to;
 $posttags = get_the_tags();
 if ($posttags) {
 usort($posttags, "tag_sort");
 foreach($posttags as $tag) {
 $link = get_tag_link($tag->term_id);
 $keyword = $tag->name;
 //连接代码
 $cleankeyword = stripslashes($keyword);
 $url = "<a href=\"$link\" title=\"".str_replace('%s',addcslashes($cleankeyword, '$'),__('查看所有文章关于 %s'))."\"";
 $url .= 'target="_blank"';
 $url .= ">".addcslashes($cleankeyword, '$')."</a>";
 $limit = rand($match_num_from,$match_num_to);
 //不连接的代码
 $content = preg_replace( '|(<a[^>]+>)(.*)('.$ex_word.')(.*)(</a[^>]*>)|U'.$case, '$1$2%&&&&&%$4$5', $content);
 $content = preg_replace( '|(<img)(.*?)('.$ex_word.')(.*?)(>)|U'.$case, '$1$2%&&&&&%$4$5', $content);
 $cleankeyword = preg_quote($cleankeyword,'\'');
 $regEx = '\'(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))\'s' . $case;
 $content = preg_replace($regEx,$url,$content,$limit);
 $content = str_replace( '%&&&&&%', stripslashes($ex_word), $content);
 }
 }
 return $content; 
 }

 

2021.07.22 给侧边栏小工具添加支持运行php及短代码/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#最后加入(暂未启用)

// 短代码功能
add_filter('widget_text', 'do_shortcode');

// 运行php代码
add_filter('widget_text','execute_php',100);
function execute_php($html){
     if(strpos($html,"<"."?php")!==false){
          ob_start();
          eval("?".">".$html);
          $html=ob_get_contents();
          ob_end_clean();
     }
     return $html;
}

 

2021.07.22 添加登录后查看功能,/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#最后加入

//部分内容登录可见 
function login_to_read($atts, $content=null) { extract(shortcode_atts(array("notice" => '
-----<span style="color: red;">
    温馨提示:</span>剩余更多内容,需要您<a title="登录后可见" href="https://shop.ls102.com/login/">登录</a>后才可继续查看!-----
    <br />没有账号?<a title="立即注册" href="https://shop.ls102.com/login/">立即注册</a>
    <br /><img src="https://www.ls102.com/wp-content/uploads/2021/07/202107271611532.jpg" />
'), $atts));
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
 return $content;
 return $notice;
}
add_shortcode('vip', 'login_to_read');

调用方法:

【vip】隐藏内容【/vip】   #注意此处需要将【】换成英文,直接输入不显示

 

2021.07.22 添加Quiz Cat测试插件,并做如下修改

1、修改前台显示语言#/www/wwwroot/ls102/wp-content/plugins/quiz-cat/includes/functions.php#最后加入

function my_quiz_callback_filter( $array ) {

    $array['no_quiz_found'] = "没有发现测试卷!";
    $array['correct'] = "回答正确!";
    $array['wrong'] = "出错了!";
    $array['your_answer'] = "你的答案:";
    $array['correct_answer'] = "正确答案:";
    $array['question'] = "新的试卷:";
    $array['next'] = "下一题";
    $array['you_got'] = "你的分数";
    $array['out_of'] = "总分";
    $array['your_answers'] = "你的答案";
    $array['start_quiz'] = "开始答题";
    $array['retake_quiz'] = "重新练习?";
    $array['share_results'] = "分享你的结果!";
    $array['i_got'] = "I gotz";
    $array['skip_this_step'] = "SKIP IT";
    $array['your_name'] = "姓名";
    $array['your_email'] = "电子邮件";

    return $array;
}
add_filter( 'fca_qc_quiz_text', 'my_quiz_callback_filter' );

2、取消前台文章标题显示#/www/wwwroot/ls102/wp-content/plugins/quiz-cat/includes/quiz/quiz.php#138行

<p class='fca_qc_quiz_title'><?php echo $title ?></p>

 

2021.07.05 取给主题页面添加SEO【自定义标题,关键词,描述】模块,/www/wwwroot/ls102/wp-content/themes/wpzt-just/inc/framework/config/metabox.php#6行

'post_type' => 'post',
修改为
'post_type' => ['post','page'],

 

2021.07.05 取消主题PC端导航栏登录注册按钮,已经重新开启登录注册按钮。

/www/wwwroot/ls102/wp-content/themes/wpzt-just/template-parts/header#59行去除

<a class="loginregbtn" rel="nofollow" href="<?php echo $login_url;?>">登录</a>	&nbsp;|&nbsp; <a class="loginregbtn" rel="nofollow" href="<?php echo $reg_url;?>">注册</a>	</div>
<?php }else{?>
<div class="loginregbtnline">
<a class="loginregbtn" rel="nofollow" href="<?php echo home_url('usercenter');?>">个人中心</a>	&nbsp;|&nbsp; <a class="loginregbtn" rel="nofollow" href="<?php echo wp_logout_url(home_url());?>">注销</a>

/www/wwwroot/ls102/wp-content/themes/wpzt-just/static/css/style.css #124行

.w-nav{
	width:70%;
}
修改为
.w-nav{
	width:84%;
}

 

2021.06.23 为WordPress主题添加文章自定义别名列/www/wwwroot/ls102/wp-content/themes/wpzt-just/functions.php#52-71行

//2添加自定义列尝试
//2.1获取文章别名数据
function the_slug() {
    $post_data = get_post($post->ID, ARRAY_A);
    $slug = $post_data['post_name'];
    return $slug; 
}
//2.2添加别名显示列显示文章别名
function add_xiaoxian_column($columns) {   
    $columns['xiaoxian'] = '别名';
    return $columns;   
}
add_filter('manage_posts_columns' , 'add_xiaoxian_column');
//2.3为别名列添加数据
function xiaoxian_column_content($column_name, $post_id) {   
    if ($column_name == 'xiaoxian') {   
        $xiaoxian_value = the_slug();
        echo $xiaoxian_value;
    }   
}   
add_action('manage_posts_custom_column', 'xiaoxian_column_content', 10, 2); 

 

2021.06.22 为WordPress主题添加文章字数和阅读时间

添加在当前使用wordpress主题的functions.php中
//1给文章添加字数和预计阅读时间
function count_words_read_time () {
	global $post;
	$text_num = mb_strlen(preg_replace('/\s/','',html_entity_decode(strip_tags($post->post_content))),'UTF-8');
	$read_time = ceil($text_num/300); // 修改数字300调整时间
	$output .= '本文共计' . $text_num . '个字,预计阅读时长' . $read_time  . '分钟。';
	return $output;
}

/www/wwwroot/ls102/wp-content/themes/wpzt-just/template-parts/single/single-pc.php#71行添加

<span><?php echo count_words_read_time(); ?></span>

 

2021.06.22 修改网站robots文件/www/wwwroot/ls102/wp-includes/functions.php#1661行

	$output  .= "Disallow: $path/wp-admin/\n";
修改为
	$output  .= "Disallow: $path/wp-admin/
Disallow: $path/wp-content/
Disallow: $path/wp-includes/
Disallow: $path/trackback/
Disallow: $path/comments/
Disallow: $path/attachment/
Disallow: $path/comments/feed
Disallow: $path/feed
Disallow: $path/*/feed
Disallow: $path/*/comment-page-*
Disallow: $path/*?replytocom=*
Disallow: $path/*/trackback
Disallow: $path/?s=*
Disallow: $path/wp-*.php
Disallow: /*/?s=*\
Disallow: $path/badlink.txt
\n";

 

2021.06.22 页脚版权信息样式调整

<p  style="font-weight:bold;">
Theme by
<a style="color: #008000;font-weight:bold;" rel="external nofollow" target="_blank" href="https://www.wpzt.net" marked="1"> 主题盒子 </a>
 | 托管于
<a  style="color: #008000;" rel="external nofollow" target="_blank"  href="https://www.aliyun.com" marked="1"> 阿里云 </a>
 | 网站已运行 
<span id="htmer_time" style="color: #008000;"></span>
<script>
function secondToDate(second) {
if (!second) {
return 0;
}
var time = new Array(0, 0, 0, 0, 0);
if (second >= 365 * 24 * 3600) {
time[0] = parseInt(second / (365 * 24 * 3600));
second %= 365 * 24 * 3600;
}
if (second >= 24 * 3600) {
time[1] = parseInt(second / (24 * 3600));
second %= 24 * 3600;
}
if (second >= 3600) {
time[2] = parseInt(second / 3600);
second %= 3600;
}
if (second >= 60) {
time[3] = parseInt(second / 60);
second %= 60;
}
if (second > 0) {
time[4] = second;
}
return time;
}
</script>
<script type="text/javascript" language="javascript">
function setTime() {
var create_time = Math.round(new Date(Date.UTC(2020, 00, 00, 0, 0, 1)).getTime() / 1000);
var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
currentTime = secondToDate((timestamp - create_time));
currentTimeHtml = currentTime[0] + '年' + currentTime[1] + '天'
+ currentTime[2] + '时' + currentTime[3] + '分' + currentTime[4]
+ '秒';
document.getElementById("htmer_time").innerHTML = currentTimeHtml;
}
setInterval(setTime, 1000);
</script>
<br />
</p>

 

2021.06.21 给合作伙伴添加 rel="nofollow",主题文件/www/wwwroot/ls102/wp-content/themes/wpzt-just/template-parts/index,主题已经彻底更新此问题

 

2021.06.19 添加404页面提交代码,推送百度站长

主题404.php最后添加

$error_url = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$error_log = "badlink.txt";
$entries = file($error_log);
$check=true;
foreach($entries as $f){
if($f == $error_url."\n")
$check = false;
}
if($check){
$fp = fopen($error_log,"a");
flock ($fp, LOCK_EX) ;
fwrite ($fp, $error_url."\n");
flock ($fp, LOCK_UN);
fclose ($fp);
}

百度站长提交死链 域名/badlink.txt  文件

 

2021.06.10 添加插件Pure Highlightjs,代码高亮插件

/www/wwwroot/ls102/wp-content/plugins/Pure-Highlightjs-master

 

2021.06.10 更新全站字体为宋体,/www/wwwroot/ls102/wp-content/themes/wpzt-just/static/css/style.css文件#9行

font-family: 'Microsoft Yahei',"Helvetica Neue", Helvetica, Arial, sans-serif;
更改为
font-family: '宋体',"Helvetica Neue", Helvetica, Arial, sans-serif;

 

2021.06.10 第二层页脚字体加粗,/www/wwwroot/ls102/wp-content/themes/wpzt-just/template-parts/footer/pc.php文件#62行

<div class="footer-bottom footer-bottom-color footer-bottom-bgcolor">
更换为
<div class="footer-bottom footer-bottom-color footer-bottom-bgcolor" style="font-weight:bold;">

 

2021.06.10 第二层页脚顶部间距调整,/www/wwwroot/ls102/wp-content/themes/wpzt-just/static/css/style.css文件#1991行及#1993行

.footer-bottom{text-align:center; padding:35px 0;font-size:14px;}
改为
.footer-bottom{text-align:center; padding:20px 0;font-size:14px;}
.friendlink,.copyright{margin-bottom:5px;line-height:1.8;opacity:0.8;}
改为
.friendlink,.copyright{margin-bottom:18px;line-height:1.8;opacity:0.8;}

 

2021.06.10 修改OPS技术联盟--->认证大使,重新整理变更网站