Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_robots

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
23       *
24       * The meta tag will only be included as necessary.
25       *
26       * @since 5.7.0
27       *
28       * @param array $robots Associative array of directives. Every key must be the name of the directive, and the
29       *                      corresponding value must either be a string to provide as value for the directive or a
30       *                      boolean `true` if it is a boolean directive, i.e. without a value.
31       */
32      $robots = apply_filters( 'wp_robots', array() );
33
34      $robots_strings = array();
35      foreach ( $robots as $directive => $value ) {
36           if ( is_string( $value ) ) {
37                // If a string value, include it as value for the directive.
38                $robots_strings[] = "{$directive}:{$value}";
39           } elseif ( $value ) {
40                // Otherwise, include the directive if it is truthy.
41                $robots_strings[] = $directive;