Yoast\WP\SEO\Task_List\Application\Tasks
Improve_Default_Meta_Descriptions::is_valid
Returns whether the task is valid.
The task is only shown when:
- Indexables are being indexed.
- The global meta description template for this post type is empty or contains only hardcoded text without replacevars. If it contains even one replacevar (%%...%%), descriptions can be considered customised in each post and the task is unnecessary.
Метод класса: Improve_Default_Meta_Descriptions{}
Хуков нет.
Возвращает
true|false.
Использование
$Improve_Default_Meta_Descriptions = new Improve_Default_Meta_Descriptions(); $Improve_Default_Meta_Descriptions->is_valid(): bool;
Код Improve_Default_Meta_Descriptions::is_valid() Improve Default Meta Descriptions::is valid Yoast 27.7
public function is_valid(): bool {
if ( ! $this->indexable_helper->should_index_indexables() ) {
return false;
}
$metadesc = $this->options_helper->get( 'metadesc-' . $this->get_post_type() );
if ( empty( $metadesc ) ) {
return true;
}
// If the template contains at least one replacevar (%%...%%), the task is not valid.
return ! (bool) \preg_match( '/%%[^%]+%%/', $metadesc );
}