php - 如何修复 PHP 已弃用:函数 create_function() 已弃用。不工作
问题描述
我从 PHP 5.3 升级到 7.2 并在 2 行代码中收到以下错误。插件代码到此结束。
感谢帮助。
错误日志:16:20:58 GMT+0200 (stredoeurópsky letný čas) 函数 create_function() 已弃用类型:PHP 已弃用行:57 文件:/home/qa015000/getogether/wp-content/themes/eventbuilder/widgets/td_video_widget。 php
<?php
class td_video_widget extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'td_widget_video', 'description' => __( 'Insert your embedded code in here!', 'themesdojo') );
parent::__construct('td_video_widget', __('ThemesDojo - Embedded Video', 'themesdojo'), $widget_ops);
$this->alt_option_name = 'td_video_widget';
}
function form($instance) {
$title = ( isset($instance['title']) && !empty($instance['title']) ) ? esc_attr($instance['title']) : '';
$text = ( isset($instance['text']) && !empty($instance['text']) ) ? esc_attr($instance['text']) : '';
?>
<label><?php _e('Title', 'themesdojo'); ?>: <input type="text" style="width:100%;" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" value="<?php echo esc_attr($title); ?>" /></label>
<label><?php _e('Text', 'themesdojo'); ?>: <textarea class="widefat" rows="16" cols="20" id="<?php echo esc_attr($this->get_field_id('text')); ?>" name="<?php echo esc_attr($this->get_field_name('text')); ?>"><?php echo esc_attr($text); ?></textarea></label>
<?php
}
function update($new_instance, $old_instance) {
return $new_instance;
}
function widget( $args, $instance ){
extract( $args );
extract( $instance );
if( $title )
$title = $before_title.do_shortcode($title).$after_title;
$text = do_shortcode( $text );
$text = $title.'<div class="ut-video">'.$text.'</div>';
echo "$before_widget
$text
$after_widget";
}
}
add_action( 'widgets_init', create_function( '', 'return register_widget("td_video_widget");' ) );
}
解决方案
推荐阅读
- c - 它是可移植的编译库吗?
- typescript - 确保对象将每个枚举值作为键(Typescript)?
- python - pip安装后找不到python模块
- python-3.x - 如何修复烧瓶中的'TypeError:'module'对象不可调用'?
- hugo - 如何在 Hugo 的 [permalinks] 部分中使用自定义参数?
- c# - 通过使用代理 API 将多个文件上传到 Sharepoint 2013 以验证文件上传过程(使用 vti_bin/copy.asmx)
- c++ - 我找不到在同一编译屏幕上与线程同时运行此计数器 3 次的方法
- java - Tomcat 8 Docx4j 应用程序问题
- bash - 给定字符串:approximateLastUseTime:'2019-10-15T16:56:07.082500Z',我需要提取 T 之后和 Z 之前的所有内容(冒号之后)
- unity3d - Unity 服务器构建(无头)原生纹理指针返回 0