预计接下来会是一个转义函数:WordPress



我创建了自定义Wordpress主题并上传到 wordpress.org 目录中。但是当它被审查时,有一些错误,我找不到解决方案。

line 14 Expected next thing to be an escaping function (see Codex for 'Data 
Validation'), not 'the_post_thumbnail_url'
line 17 Expected next thing to be an escaping function (see Codex for 'Data 
Validation'), not '$post'
line 18 Expected next thing to be an escaping function (see Codex for 'Data 
Validation'), not 'substr'

文件中的代码

<img class="img-fluid" alt="<?php the_title() ?>" src="<?php the_post_thumbnail_url(); ?>" >
<p><?php echo substr($post->post_content, 0, 200).'..'; ?></p>
这意味着

如果要将任何字符串打印为属性值,则需要使用esc_attr函数。

喜欢

alt="<?php echo esc_attr(get_the_title()); ?>"
src="<?php echo esc_attr(get_the_post_thumbnail_url()); ?>"

而不是$post->post_content也使用 get_the_content(( 函数。

最新更新