Yoast\WP\SEO\Integrations\Front_End
WP_Robots_Integration::format_robots() protected Yoast 1.0
Formats our robots fields, to match the pattern WordPress is using.
Our format: ['index'=>'noindex','max-image-preview'=>'max-image-preview:large', ... ] WordPress format: ['noindex'=> true,'max-image-preview'=>'large', ... ]
{} Это метод класса: WP_Robots_Integration{}
Хуков нет.
Возвращает
Массив
. The formatted robots.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->format_robots( $robots );
- $robots(массив) (обязательный)
- Our robots value.
Код WP_Robots_Integration::format_robots() WP Robots Integration::format robots Yoast 16.1.1
protected function format_robots( $robots ) {
foreach ( $robots as $key => $value ) {
// When the entry represents for example: max-image-preview:large.
$colon_position = \strpos( $value, ':' );
if ( $colon_position !== false ) {
$robots[ $key ] = \substr( $value, ( $colon_position + 1 ) );
continue;
}
// When index => noindex, we want a separate noindex as entry in array.
if ( strpos( $value, 'no' ) === 0 ) {
$robots[ $key ] = false;
$robots[ $value ] = true;
continue;
}
// When the key is equal to the value, just make its value a boolean.
if ( $key === $value ) {
$robots[ $key ] = true;
}
}
return $robots;
}