admin管理员组文章数量:1122846
I was thinking of removing/hiding admin-bar from my wordpress (3.1.1) installation.
I visited following link:
I was surprised to see only a single line to remove/hide admin-bar
add_filter( 'show_admin_bar', '__return_false' );
My question is what is __return_false means? why __ and _?
I was thinking of removing/hiding admin-bar from my wordpress (3.1.1) installation.
I visited following link:
http://codex.wordpress.org/Plugin_API/Filter_Reference/show_admin_bar
I was surprised to see only a single line to remove/hide admin-bar
add_filter( 'show_admin_bar', '__return_false' );
My question is what is __return_false means? why __ and _?
Share Improve this question edited Apr 22, 2011 at 21:21 Brooke. 3,8931 gold badge27 silver badges34 bronze badges asked Apr 22, 2011 at 7:10 I-M-JMI-M-JM 5682 gold badges7 silver badges16 bronze badges1 Answer
Reset to default 50WordPress contains built in functions for quickly returning values.
They are intended to be used as a quick built in function that returns a common value to a filter hook such as true, false, or an empty array.
__return_false
— Returns the Boolean value offalse
.__return_true
— Returns the Boolean value oftrue
.__return_empty_array
— Returns an empty PHParray
.__return_zero
— Returns the integer0
.__return_null
— ReturnsNULL
.__return_empty_string
— Returns''
.
In older PHP versions, these can be more concise than typing out the equivalent function in full. Alternately, in PHP 7.4 and newer, you can use arrow functions for an even more concise equivalent with less indirection or risk of typos:
fn() => false
fn() => true
fn() => []
fn() => 0
fn() => null
fn() => ''
本文标签: admin barwhat is returnfalse in filters
版权声明:本文标题:admin bar - what is __return_false in filters 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736288211a1928046.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论