WPSEO_Import_WPSEO::import_taxonomy_robots()
Imports the robot value to Yoast SEO.
Метод класса: WPSEO_Import_WPSEO{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->import_taxonomy_robots( $tax_meta, $taxonomy, $term_id );
- $tax_meta(массив) (обязательный) (передается по ссылке — &)
- The array with the current metadata.
- $taxonomy(строка) (обязательный)
- String with the name of the taxonomy.
- $term_id(строка) (обязательный)
- The ID of the current term.
Код WPSEO_Import_WPSEO::import_taxonomy_robots() WPSEO Import WPSEO::import taxonomy robots Yoast 24.6
private function import_taxonomy_robots( &$tax_meta, $taxonomy, $term_id ) { $wpseo_robots = get_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots', false ); if ( $wpseo_robots === false ) { return; } // The value 1, 2 and 6 are the index values in wpSEO. $new_robot_value = 'noindex'; if ( in_array( (int) $wpseo_robots, [ 1, 2, 6 ], true ) ) { $new_robot_value = 'index'; } $tax_meta[ $taxonomy ][ $term_id ]['wpseo_noindex'] = $new_robot_value; }