函数参考/已检查显示已检查='已检查' [英] Function Reference/checked displaying checked='checked'

查看:32
本文介绍了函数参考/已检查显示已检查='已检查'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在处理 wordpress 选项页面,检查是否选中了选项.

I am currently working on a wordpress options page, checking if options are checked.

当我检查以下代码时,正确的复选框被选中,但在复选框旁边我得到以下内容:

When i check with the following code the correct check boxes are selected, but next to the checkbox i get the following:

checked='checked'

这是我的代码:

echo '<input name="wwo_enable_'.$lrole.'" type="checkbox" value="1" '.checked( '1', get_option( 'wwo_enable_'.$lrole ) ).' />';

还有一个屏幕截图来说明我的意思:

And a screen shot to show what i mean:

推荐答案

checked() 函数的最后一个参数是它是否被回显.由于默认情况下为 true,因此您需要将第三个参数添加为 false.

The last parameter of the checked() function is whether it's echo'd or not. Since it's true by default you need to add the third parameter as false.

应该可以切换这个:

checked( '1', get_option( 'wwo_enable_'.$lrole ) )

为此:

checked( '1', get_option( 'wwo_enable_'.$lrole ), false )

这篇关于函数参考/已检查显示已检查='已检查'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆