如何修复已弃用的create_function [英] How to fix deprecated create_function
本文介绍了如何修复已弃用的create_function的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们最近更新了Wordpress,使其可以与 PHP 7.2
一起使用.遇到一些问题后,我打开了调试功能,以查看大部分问题是不推荐使用的代码.
We have recently updated our Wordpress to work with PHP 7.2
. After having a few issues I have turned on the debug to see that most of the issue is deprecated code.
我不是编码员,但是我浏览了论坛并找到了一些答案.以下是我遇到的无法解决的问题.
I am not a coder but I have look through the forums and found a couple of answers. The following is what I am stuck on and can't figure out.
代码1
if ( file_exists( self::$_plugin_path . '/controllers/activation.php' ) ) {
$escaped_plugin_path = preg_replace( '#^\\\\\\\\#', '\\\\\\\\\\\\\\\\', self::$_plugin_path );
register_activation_hook( self::$_plugin_path . '/' . pb_backupbuddy::settings( 'init' ), create_function( '', "require_once('" .
}
代码2
$section_callback = create_function('', 'echo "' . $desc . '";');
代码3
add_action( 'admin_enqueue_scripts', create_function( '',
"wp_enqueue_style( 'pb_backupbuddy-wp-admin', '" . pb_backupbuddy::plugin_url() . "/css/wp-admin.css', array(), pb_backupbuddy::settings( 'version' ) );"
)
感谢您能提供的任何帮助.
I appreciate any help I can get.
推荐答案
代码1:register_activation_hook
register_activation_hook( self::$_plugin_path . '/' . pb_backupbuddy::settings( 'init' ), function() { require_once(); } );
代码2:
$section_callback = function() {
echo $desc;
};
代码3:
add_action( 'admin_enqueue_scripts', function() { wp_enqueue_style( 'pb_backupbuddy-wp-admin', pb_backupbuddy::plugin_url().'/css/wp-admin.css', pb_backupbuddy::settings( 'version' ) ); } );
这篇关于如何修复已弃用的create_function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文