白云优化网站建设,网站桥页怎么找,建设银行信用卡申请官方网站,小公司建设网站Wordpress报错怎么解决#xff1f;
一般常用的排查方法#xff1a;
暂时禁用所有插件#xff1b;将主题更改为默认主题#xff1b; 修改wp-config.php文件#xff1b;更新固定链接设置#xff0c;确保设置正确#xff1b;检查.htaccess文件是否存在且是否可写#xf…Wordpress报错怎么解决
一般常用的排查方法
暂时禁用所有插件将主题更改为默认主题 修改wp-config.php文件更新固定链接设置确保设置正确检查.htaccess文件是否存在且是否可写检查主题的页面模板文件是否存在7、检查wp-config.php文件的数据库凭据是否正确使用phpMyAdmin等工具检查数据库是否正常运行等。 wordpress报错 一报错NoticeUndefined indexsubmit in
原代码:
if( $_POST[submit] ){ }
新代码
if(isset($_POST[submit]) $_POST[submit]) { }别的相同类似报错都可以按这个方式来解决问题。
二已不建议给has_cap传入一个参数用户级别已被废弃请改用能力。
在插件或主题文件中搜索关键词add_options_page查找用户级别代码位置。
原代码
add_options_page(Delete-Revision, Delete-Revision,8, basename(__FILE__), my_options_delete_revision);新代码
add_options_page(Delete-Revision, Delete-Revision,manage_options, basename(__FILE__), my_options_delete_revision);主要是把红色的8修改为红色的manage_options。
三Notice: 自3.1.0版本起已不建议给WP_Query传入一个参数“caller_get_posts”不再被建议使用。请改用“ignore_sticky_posts” 这个直接搜索查找替换文件里的caller_get_posts 为 ignore_sticky_posts 即可。
四Notice: 为WP_Widget调用的构造方法已自版本4.3.0起废弃请改用 __construct()。 这个直接搜索查找替换文件里的parent::WP_Widget 或 $this-WP_Widget 为 parent::__construct 五create_function函数报错 php 7.3版本不推荐使用create_function函数在php 7.3中使用create_function()函数会有兼容性报错Deprecated: Function create_function() is deprecated解决方法是替换掉该函数。
以wordpress的代码为例原代码如下
add_action(widgets_init, create_function(, return register_widget(contact);)); 修改为
add_action(widgets_init, function(){register_widget(contact );});原代码
$callbacks[$delimiter] create_function($matches, return $delimiter . strtolower(\$matches[1]););修改为
$callbacks[$delimiter] function($matches) use ($delimiter) {return $delimiter . strtolower($matches[1]);
};问题描述运行一个旧的php项目时报错
PHP message: PHP Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback insteadWarning: preg_replace_callback(): Requires argument 2, ‘iconv(‘UCS-2’, ‘UTF-8’,Function create_function() is deprecated
原因分析
php 5.6之后的版本不再支持pre_replace()函数自PHP 7.2起函数create_function因为代码注入漏洞已被弃用。从PHP 5.3开始执行此操作的首选方法是使用匿名函数。要捕获外部变量的值请使用use声明。
解决方案 将
preg_replace(#\\\u([0-9a-f]{4})#ie, iconv(UCS-2BE, UTF-8, pack(H4, \\1)), json_encode($data));修改为
preg_replace_callback(/\\\\u([0-9a-f]{4})/i, function($matches){return iconv(UCS-2BE,UTF-8,pack(H*, $matches[1]));}, json_encode($data));或直接封装为一个函数可实现更好地复用 function decodeUnicode($str){return preg_replace_callback(/\\\\u([0-9a-f]{4})/i, function($matches){return iconv(UCS-2BE,UTF-8,pack(H*, $matches[1]));}, $str);}六、Deprecated: 自3.3.0版本起已不建议使用contextual_help 提示Deprecated: 自3.3.0版本起已不建议使用contextual_help请换用get_current_screen()-add_help_tab(), get_current_screen()-remove_help_tab()。
add_filter( contextual_help, __return_empty_string, 999 );
改为
function wp_remove_contextual_help() {$screen get_current_screen();$screen-remove_help_tabs();}add_action( admin_head, wp_remove_contextual_help );