Yoast\WP\SEO\Dashboard\Infrastructure\Score_Results\Readability_Score_Results
Cached_Readability_Score_Results_Collector::get_score_results
Retrieves readability score results for a content type. Based on caching returns either the result or gets it from the collector.
Метод класса: Cached_Readability_Score_Results_Collector{}
Хуков нет.
Возвращает
Массив<Строку,. object|bool|float> The readability score results for a content type.
Использование
$Cached_Readability_Score_Results_Collector = new Cached_Readability_Score_Results_Collector(); $Cached_Readability_Score_Results_Collector->get_score_results( $score_groups, $content_type, ?int $term_id, ?bool $is_troubleshooting );
- $score_groups(Readability_Score_Groups_Interface[]) (обязательный)
- All readability score groups.
- $content_type(Content_Type) (обязательный)
- The content type.
- ?int $term_id(обязательный)
- .
- ?bool $is_troubleshooting(обязательный)
- .
Код Cached_Readability_Score_Results_Collector::get_score_results() Cached Readability Score Results Collector::get score results Yoast 27.3
public function get_score_results(
array $score_groups,
Content_Type $content_type,
?int $term_id,
?bool $is_troubleshooting
) {
$content_type_name = $content_type->get_name();
$transient_name = self::READABILITY_SCORES_TRANSIENT . '_' . $content_type_name . ( ( $term_id === null ) ? '' : '_' . $term_id );
$results = [];
$transient = \get_transient( $transient_name );
if ( $is_troubleshooting !== true && $transient !== false ) {
$results['scores'] = \json_decode( $transient, false );
$results['cache_used'] = true;
$results['query_time'] = 0;
return $results;
}
$results = $this->readability_score_results_collector->get_score_results( $score_groups, $content_type, $term_id, $is_troubleshooting );
$results['cache_used'] = false;
if ( $is_troubleshooting !== true ) {
\set_transient( $transient_name, WPSEO_Utils::format_json_encode( $results['scores'] ), \MINUTE_IN_SECONDS );
}
return $results;
}