There are questions remain, We'll search for the answers together. But one thing we known for sure,the future is not set!

【原创文章】wordpress主题yusi搬迁PHP8.0环境后存在问题的解决办法

1,多个fatal error都是由替换函数变了引起的

header.php
pages/archives.php
pages/links.php
pages/page.php
pages/readers.php
pages/tags.php
pages/tougao.php

这些文件中,

ereg_replace(“<div[^>\]*><ul[^>\]*>”
替换成
preg_replace(“/<div[^>]*><ul[^>]*>/”

2,几个函数未申明变量

function.php文件

global $wpdb;中添加$post_id;
function baidu_check($url){
global $wpdb,$post_id;

function meta_SEO() { 添加$keywordarray
global $post,$keywordarray;

 

3,当没有缩微图,而是用默认随机缩微图,出现错误,是因为对变量是否为空没有做判断

function.php文件

function post_thumbnail_src(){

$post_thumbnail_src = $matches [1] [0]; //获取该图片 src

改为

$thumbnailcheck = $matches [1] [0] ?? ”;
$post_thumbnail_src = $thumbnailcheck; //获取该图片 src

 

4,wordpress的搜索按钮无法使用,是因为yusi主题默认用的百度的jquery.min.js,这个JS早失效了。

自己下载一个jquery.min.js,放到yusi主题目录的js文件夹下,然后修改代码

function.php文件

function footerScript() {
if ( !is_admin() ) {
wp_deregister_script( ‘jquery’ );
//wp_register_script( ‘jquery’,’//libs.baidu.com/jquery/1.8.3/jquery.min.js’, false,’1.0′);  //注释掉
wp_register_script( ‘jquery’,get_template_directory_uri() .’/js/jquery.min.js’, false,’1.0′);  //添加这行代码

 

5,提示PRC错误,函数未申明错误,还有一个找不到hunctionerr错误

comments.php

date_default_timezone_set(PRC);改为
date_default_timezone_set(‘PRC’);

 

$comment_ids[get_comment_id()] = ++$comment_i;
改为
$commentcheck = $comment_i ?? ”;
$comment_ids[get_comment_id()] = ++$commentcheck;

err (‘写点汉字吧,博主外语很捉急!You should type some Chinese word!’);
改为
echo (‘写点汉字吧,博主外语很捉急!You should type some Chinese word!’);
exit;

err (‘日文滚粗!Japanese Get out!日本語出て行け! You should type some Chinese word!’);
改为
echo (‘日文滚粗!Japanese Get out!日本語出て行け! You should type some Chinese word!’);
exit;

 

6,single.php
pages/archives.php
pages/links.php
pages/page.php
pages/readers.php
pages/tags.php
pages/tougao.php

get_comments_number(‘0’, ‘1’, ‘%’)
改为
get_comments_number($post)

 

7,admin/yusi.php

function mytheme_add_admin() {
global $themename, $options;
if ( isset($_GET[‘page’]) && $_GET[‘page’] == basename(__FILE__) ) { //添加一个判断isset($_GET[‘page’])
if ( isset($_REQUEST[‘action’]) && ‘save’ == $_REQUEST[‘action’] ) { //添加一个判断isset($_REQUEST[‘action’])
foreach ($options as $value) {
$valuecheck = $_REQUEST[$value] ?? ”; //先赋值
update_option( $value, $valuecheck);  //然后再调用
}
header(“Location: admin.php?page=Yusi.php&saved=true”);
die;
}
}

if ( $_REQUEST[‘saved’]) echo ‘<div class=”updated settings-error”><p>’.$themename.’修改已保存</p></div>’;
?>
修改为
if ( isset($_REQUEST[‘saved’])) echo ‘<div class=”updated settings-error”><p>’.$themename.’修改已保存</p></div>’;
?>

转载请注明:百蔬君 » 【原创文章】wordpress主题yusi搬迁PHP8.0环境后存在问题的解决办法

喜欢 (0)or分享 (0)

Warning: Attempt to read property "comment_author_email" on null in /www/wwwroot/baishujun.com/wp-content/themes/yusi1.0/comments.php on line 46
发表我的评论
取消评论
表情