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 badges
Add a comment  | 

1 Answer 1

Reset to default 50

WordPress 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 of false.
  • __return_true — Returns the Boolean value of true.
  • __return_empty_array — Returns an empty PHP array.
  • __return_zero — Returns the integer 0.
  • __return_null — Returns NULL.
  • __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