知言 Tinection 主题中的小 Bug 及修复方法(更新到 7 个 Bug)

2018-01-23 11:10 5,667 123 条评论 龙笑天下
Dragon主题购买

这篇文章主要介绍知言的tinection主题的一些小bug以及相应的解决方法。当然,这些问题在Dragon 主题中已经都解决了,欢迎大家前往购买体验~

Dragon 主题:Wordpress 商城会员多功能高级主题 V4.9.0-BG
Dragon 主题:Wordpress 商城会员多功能高级主题 V4.9.0

Dragon 主题:Wordpress 商城会员多功能高级主题 V4.9.0[出售]

WordPress 个人博客 CMS 主题 Dragon,CMS、博客、自适应响应式、用户中心、商城,强大到窒息~

Bug 1:分页导航的问题

5 月 17 日,浏览同样使用 tinection 主题的博客时,发现分页导航有个小问题(如下图:1 和 5 之间不显示省略号“...”),于是看了看自己的,再返回知言的博客看了看,都有这个问题,那就应该是 tinection 主题的通病了。

知言 Tinection 主题中的小 Bug 及修复方法(更新到 7 个 Bug)

查看了下源代码,发现在主题的 functions.php 文件中(搜索关键字:分页导航),有关于分页导航的代码函数pagenavi(,试着改了改,得到了解决!可以点我看看效果。

以下是修复后的分页导航代码:

/* 首页分页导航 
/* -------------*/  
function pagenavi( $before = '', $after = '', $p = 2 ) {
    if ( is_singular() ) return;
    global $wp_query, $paged;
    $max_page = $wp_query->max_num_pages;
    if ( $max_page == 1 )
        return;
    if ( empty( $paged ) )
        $paged = 1;
    	// $before = "<span class='pg-item'><a href='".esc_html( get_pagenum_link( $i ) )."'>{$i}</a></span>";
    echo $before;
    if ( $paged > 1)
        p_link( $paged - 1, '上一页', '<span class="pg-item pg-nav-item pg-prev">' ,'上一页' );
    if ( $paged > $p + 1 )
        p_link( 1, '首页','<span class="pg-item">',1 );
		if ( $paged > 2 + $p ) echo '<span class="pg-item"> ... </span>';
    for( $i = $paged - $p; $i <= $paged + $p; $i++ ) {
        if ( $i > 0 && $i <= $max_page )
            $i == $paged ? print "<span class='pg-item pg-item-current'><span class='current'>{$i}</span></span>" : p_link( $i,'', '<span class="pg-item">',$i);
    }
    if ( $paged < $max_page - $p ) p_link( $max_page, __('末页','tinection'),'<span class="pg-item"> ... </span><span class="pg-item">',$max_page );
    if ( $paged < $max_page ) p_link( $paged + 1,__('下一页','tinection'), '<span class="pg-item pg-nav-item pg-next">' ,__('下一页','tinection'));
    echo $after;
}

相信大家也看出来了,其实就是在原代码中增加了第 17 行的代码:

if ( $paged > 2 + $p ) echo '<span class="pg-item"> ... </span>';

好了保存上传,刷新下,OK 了!

更多好看实用的分页导航的样式及实现方法详见下面这篇文章:

wordpress 自定义分页导航方法大全(全网最全版)-BG
wordpress 自定义分页导航方法大全(全网最全版)

wordpress 自定义分页导航方法大全(全网最全版)

wordpress 分页导航是用来切换文章的一个功能,添加了 wordpress 分页导航后,用户即可自由到达指定的页面数浏览分类文章,而这样的一个很简单功能却有很多朋友在用插件:WP-PageN...

Bug 2:用户中心里“收藏的文章”选项卡

问题描述:“收藏的文章”选项卡里的分页不能进入或点击出现 404。

解决方法:

打开主题根目录里的 author.php,将// 收藏 start// 收藏 end中的部分改为下面的内容:

// 收藏 start
if( $get_tab=='collect'){
	$item_html = '
  • '.__('共收藏了','tinection').$collects_count.'篇文章
  • '; echo '
    • '.$item_html.'
    '; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post__not_in'=>get_option('sticky_posts'), 'post__in' => $collects_array, 'post_status' => 'publish', 'paged' => $paged ) ); while ( have_posts() ) : the_post(); get_template_part('includes/content','archive'); endwhile; // end of the loop. tin_paginate(); wp_reset_query(); } // 收藏 end

    Bug 3:手机端下载收费积分文件问题

    问题描述:在手机端下载不了收费积分文件,弹出框不见了...

    状态:期待更完美的解决方法!

    初步解决方法:来自群友 @宅

    在 style.css 里以下关于弹出框的 css 的下一行加上一句 css,如下:

    .tinalert {
    	display:none;
    	position:fixed;
    	top:50%;
    	left:50%;
    	width:300px;
    	min-height:150px;
    	margin-top:-75px;
    	margin-left:-150px;
    	box-shadow:0 0 5px #aaa;
    	background:#fafafa;
    	border:1px solid #aaa;
    	z-index:99999;
    }
    @media screen and (max-width:640px) {
    	.page-template-page-download .tinalert {
    	position:absolute;
    	top:248px;
    }
    }
    

    Bug 4:下载页面登录或退出时链接重定向问题

    问题描述:在任意下载页面,如:https://www.ilxtx.com/download?pid=2316&code=47d041,当在此页面登录或退出时,登录成功后会默认跳转到这个页面:https://www.ilxtx.com/dl/

    状态:下面的方法解决了登录时的情况;退出时还是有问题~期待大神解决!

    解决方法:来自 @知言

    打开 functions.php 文件,搜索tin_get_current_page_url,会搜到 2 个函数tin_get_current_page_url()tin_get_current_page_url2(),将这 2 个函数及内容都删掉,然后改成下面这样:

    function tin_get_current_page_url(){
    	$scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
        $port_str = $_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '';
        $url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $port_str . $_SERVER["REQUEST_URI"];
        return $url;
    }

    Bug 5:部分主机上注册验证码不显示的问题

    问题描述:在某些主机上,点击注册时验证码不显示,或需要点一下验证码才显示。

    解决方法:来自 @知言

    首先,将主题里 includes\captcha.php 中的内容改成下面这个:

    <?php
    require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."wp-load.php");
    /**
    * 验证码
    * Class Captcha
    */
    class Captcha{
    /**
    * 验证码宽度
    *
    * @since 2.0.0
    * @access private
    * @var int
    */
    private $_width ;
    /**
    * 验证码高度
    *
    * @since 2.0.0
    * @access private
    * @var int
    */
    private $_height;
    /**
    * 验证码字符个数
    *
    * @since 2.0.0
    * @access private
    * @var int
    */
    private $_counts;
    /**
    * 允许的字符范围
    *
    * @since 2.0.0
    * @access private
    * @var string
    */
    private $_distrubcode;
    /**
    * 验证码字体
    *
    * @since 2.0.0
    * @access private
    * @var string
    */
    private $_font;
    /**
    * Session
    *
    * @since 2.0.0
    * @access private
    * @var string
    */
    private $_session;
    function __construct($width = 120, $height = 30, $counts = 5, $distrubcode='', $font=''){
    // Check for GD library
    if( !function_exists('gd_info') ) {
    throw new Exception('Required GD library is missing', 'tt');
    }
    $this->_width = $width;
    $this->_height = $height;
    $this->_counts = $counts;
    $this->_distrubcode = empty($distrubcode) ? "1235467890qwertyuipkjhgfdaszxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" : $distrubcode;
    $this->_font = empty($font) ? THEME_DIR.DIRECTORY_SEPARATOR."fonts".DIRECTORY_SEPARATOR."consolas".DIRECTORY_SEPARATOR."consolas-webfont.ttf" : $font;
    $this->_session = $this->sessioncode();
    session_start();
    $_SESSION['tin_captcha'] = $this->_session;
    $this->imageout();
    }
    /**
    * 产生随机的字符用于验证码
    *
    * @since 2.0.0
    * @access private
    * @return string
    */
    private function sessioncode(){
    $originalcode = $this->_distrubcode;
    $countdistrub = strlen($originalcode);
    $_dscode = "";
    $counts=$this->_counts;
    for($j=0; $j<$counts; $j++){
    $dscode = $originalcode[rand(0, $countdistrub-1)];
    $_dscode.=$dscode;
    }
    return $_dscode;
    }
    /**
    * 创建画布资源
    *
    * @since 2.0.0
    * @access private
    * @return resource
    */
    private function create_imagesource(){
    return imagecreate($this->_width,$this->_height);
    }
    /**
    * 设置背景色
    *
    * @since 2.0.0
    * @access private
    * @param resource $image 画布资源
    * @return void
    */
    private function set_backgroundcolor($image){
    $bgcolor = imagecolorallocate($image, rand(200,255), rand(200,255), rand(200,255));
    imagefill($image, 0, 0, $bgcolor);
    }
    /**
    * 添加验证码字符
    *
    * @since 2.0.0
    * @access private
    * @param resource $image 画布资源
    * @return void
    */
    private function set_code(&$image){
    $width=$this->_width;
    $counts=$this->_counts;
    $height=$this->_height;
    $scode=$this->_session;
    $y=floor($height/2) + floor($height/4);
    $fontsize=rand(20,25);
    $font=$this->_font;
    for($i=0; $i<$counts; $i++){
    $char=$scode[$i];
    $x=floor($width/$counts)*$i+8;
    $angle=rand(-20,30);
    $color = imagecolorallocate($image, rand(0,50), rand(50,100), rand(100,140));
    imagettftext($image, $fontsize, $angle, $x, $y, $color, $font, $char);
    }
    }
    /**
    * 添加验证码干扰字符
    *
    * @since 2.0.0
    * @access private
    * @param resource $image 画布资源
    * @return void
    */
    private function set_distrubecode(&$image){
    $count_h=$this->_height;
    $cou=floor($count_h*2);
    for($i=0; $i<$cou; $i++){
    $x=rand(0,$this->_width);
    $y=rand(0,$this->_height);
    $angle=rand(0,360);
    $fontsize=rand(4,6);
    $font=$this->_font;
    $originalcode = $this->_distrubcode;
    $countdistrub = strlen($originalcode);
    $dscode = $originalcode[rand(0, $countdistrub-1)];
    $color = imagecolorallocate($image, rand(40,140), rand(40,140), rand(40,140));
    imagettftext($image, $fontsize, $angle, $x, $y, $color, $font, $dscode);
    }
    }
    /**
    * 输出图像
    *
    * @since 2.0.0
    * @access private
    * @return void
    */
    private function imageout(){
    $im = $this->create_imagesource();
    $this->set_backgroundcolor($im);
    $this->set_code($im);
    $this->set_distrubecode($im);
    header("Content-Type: image/png");
    imagepng($im);
    imagedestroy($im);
    }
    }
    $captcha = new Captcha(90, 40, 4);

    然后,如果验证码需要点击一下才显示的话,就再将主题里的 includes\loginbox.php 中的如下内容(第 79 行):

    <img src="<?php echo THEME_URI.'/images/captcha-clk.png'; ?>" class="captcha_img inline" title="点击刷新验证码">

    改为:

    <img src="<?php echo THEME_URI.'/includes/captcha.php?t='.time(); ?>" class="captcha_img inline" title="点击刷新验证码" />

    修改后的效果请看本站

    下文是 Tinection 主题以及 UM 插件验证码关闭方法:

    首先打开主题的 includes/loginbox.php,定位至 75 行,将:

    <p id="captcha_inline">
                <input class="input-control inline" type="text" id="tin_captcha" name="tin_captcha" placeholder="输入验证码" required>
                <i mg src="<?php echo THEME_URI.'/images/captcha-clk.png'; ?>" class="captcha_img inline" title="点击刷新验证码">
                <input class="submit inline" type="submit" value="注册" name="submit">
            </p>

    修改为:

    <p>
        <input class="submit inline" type="submit" value="注册" name="submit">
    </p>

    再打开主题的 functions.php 文件,定位至大约 1645 行,寻找到下面的代码并删掉:

    /* 后台注册同时添加验证码
    /* ----------------------- */
    function tin_add_register_captcha(){
    $captcha = THEME_URI.'/includes/captcha.php';
    ?>
    <p style="overflow:hidden;">
    <label for="tin_captcha">验证码<br>
    <input type="text" name="tin_captcha" id="tin_captcha" aria-describedby="" class="input" value="" size="20" style="float:left;margin-right:10px;width:190px;">
    <i mg src="<?php echo $captcha; ?>" class="captcha_img inline" title="点击刷新验证码" onclick="this.src='<?php echo $captcha; ?>';" style="float:right;margin-top: 5px;"></label>
    </p>
    <?php
    }
    add_action('register_form','tin_add_register_captcha');
     
    function tin_add_register_captcha_verify($sanitized_user_login,$user_email,$errors){
    if(!isset($_POST['tin_captcha'])||empty($_POST['tin_captcha'])){
    return $errors->add( 'empty_captcha', __( '请填写验证码','tinection' ) );
    }else{
    $captcha = strtolower(trim($_POST['tin_captcha']));
    session_start();
    $session_captcha = strtolower($_SESSION['tin_captcha']);
    if($captcha!=$session_captcha){
    return $errors->add( 'wrong_captcha', __( '验证码错误','tinection' ) );
    }
    }
    }
    add_action('register_post','tin_add_register_captcha_verify',10,3);

    Bug 6:启用 https 后,从前台登录后,进不了后台问题

    请在 functions.php 文件和 functions/open-social.php 文件中定位wp_signonwp_set_auth_cookie这 2 个函数,然后参照下文方法来修改:

    WordPress 实现用户自动登录的方法-BG
    WordPress 实现用户自动登录的方法

    WordPress 实现用户自动登录的方法

    本文主要介绍 WordPress 实现用户自动登录的方法,wp_signon()和 wp_set_auth_cookie()函数,以及解决一个启用 https 后出现的进不了 wordpress 后台的问...

    Bug 8:搜索结果不显示商品问题

    今天有盆友问到这个问题,在此龙笑天下就记录下,要想使搜索结果能搜索到商品,则只需将以下代码加入到 functions.php 中即可:

    /**
     * 知言 Tinection 主题中的小 Bug 及修复方法(更新到 6 个 Bug) - 龙笑天下
     * https://www.ilxtx.com/bug-in-tinection.html
     * 让搜索结果能搜索到商品
     */
    function lxtx_search_filter_page($query) {
        if (!$query->is_admin && $query->is_search) {
            $query->set('post_type', array('post','store'));
        }
            return $query;
    }
    add_filter('pre_get_posts','lxtx_search_filter_page');

    「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!

    本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

    2017-12-26

    2018-02-02

    发表评论

    表情 格式 贴图 链接 私密 签到
    Dragon主题购买阿里云特价云服务器1核2G低至86元,N4共享型服务器3年仅需799元腾讯云特价云服务器1核2G 88元/年 2核4G3M688元/3年,更有千元代金券礼包免费领!
    评论
    正在努力加载中...
    扫一扫二维码分享
    ×
    We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. Learn more