Yoast\WP\SEO\Dashboard\Infrastructure\Score_Groups

Score_Group_Link_Collector::get_view_linkpublicYoast 1.0

Builds the view link of the score group.

Метод класса: Score_Group_Link_Collector{}

Хуков нет.

Возвращает

Строку|null. The view link of the score.

Использование

$Score_Group_Link_Collector = new Score_Group_Link_Collector();
$Score_Group_Link_Collector->get_view_link( $score_group, $content_type, ?Taxonomy $taxonomy, ?int $term_id ): ?string;
$score_group(Score_Groups_Interface) (обязательный)
The score group.
$content_type(Content_Type) (обязательный)
The content type.
?Taxonomy $taxonomy(обязательный)
.
?int $term_id(обязательный)
.

Код Score_Group_Link_Collector::get_view_link() Yoast 26.9

public function get_view_link( Score_Groups_Interface $score_group, Content_Type $content_type, ?Taxonomy $taxonomy, ?int $term_id ): ?string {
	$posts_page = \admin_url( 'edit.php' );
	$args       = [
		'post_status'                  => 'publish',
		'post_type'                    => $content_type->get_name(),
		$score_group->get_filter_key() => $score_group->get_filter_value(),
	];

	if ( $taxonomy === null || $term_id === null ) {
		return \add_query_arg( $args, $posts_page );
	}

	$taxonomy_object = \get_taxonomy( $taxonomy->get_name() );
	$query_var       = $taxonomy_object->query_var;

	if ( ! $query_var ) {
		return null;
	}

	$term               = \get_term( $term_id );
	$args[ $query_var ] = $term->slug;

	return \add_query_arg( $args, $posts_page );
}