PHP的新手, 正在尝试学习。我收到此错误:
由于文件wp-content / themes / softwarehill / customizer.php的第54行出现错误, 你的PHP代码更改已回滚。请修正并??尝试再次保存。
【将代码添加到Customizer的section出错】语法错误, 意外的’
if'(T_IF), 期望的函数(T_FUNCTION)或const(T_CONST)
似乎在代码的卫生部分中
class New_Customizer {private static $instance;
public function register_footer_input() {
add_action( 'wp_footer', array( $this, 'foot_html' ) );
}
public function add_item_to_customizer( $wp_customize ) {$wp_customize->
add_section( 'section_foot_html', array('title' =>
'Footer HTML', 'description'=>
'It is recommended to type code in a text editor and then paste it into the field below', ) );
$wp_customize->
add_setting( 'custom_foot_html', array('transport' =>
'refresh', 'sanitize_callback' =>
'sanitize_html', ) );
$wp_customize->
add_control( 'custom_foot_html', array('label' =>
'Custom footer HTML', 'description' =>
'Please copy and paste HTML Code Here', 'section' =>
'foot_html', 'settings' =>
'custom_foot_html', 'type'=>
'textarea', ) );
}public function foot_html() {$footer_html = get_theme_mod( 'custom_foot_html', '' );
if ( $footer_html !== '' ) { echo trim( $footer_html );
}
}/**
* Adds sanitization callback function: footer html code
*/if( ! function_exists( 'sanitize_html' ) ) {function sanitize_html( $input ) {
return trim( $input );
}
}new New_Customizer();
#1你可能忘记了关闭班级的括号
class New_Customizer {private static $instance;
public function register_footer_input() {
add_action( 'wp_footer', array( $this, 'foot_html' ) );
}public function add_item_to_customizer( $wp_customize ) {$wp_customize->
add_section( 'section_foot_html', array(
'title' =>
'Footer HTML', 'description'=>
'It is recommended to type code in a text editor and then paste it into the field below', ) );
$wp_customize->
add_setting( 'custom_foot_html', array(
'transport' =>
'refresh', 'sanitize_callback' =>
'sanitize_html', ) );
$wp_customize->
add_control( 'custom_foot_html', array(
'label' =>
'Custom footer HTML', 'description' =>
'Please copy and paste HTML Code Here', 'section' =>
'foot_html', 'settings' =>
'custom_foot_html', 'type'=>
'textarea', ) );
}
}
推荐阅读
- WordPress中视图页面源”冗余空白行”中的错误
- 将自定义脚本放入WordPress自定义程序中
- 空帖标题WordPress
- 嵌入式WordPress表单插件短代码未显示在页面中
- 元素超出其定义的宽度
- 在Gutenberg图像,封面和画廊中编辑srcset和size属性-块
- 编辑页面保存按钮未在wordpress中显示
- 编辑主题自定义菜单
- Java线上故障排查不会怎么办,p8大佬总结的套路清单带你轻松玩转!