Yoast\WP\SEO\Dashboard\Infrastructure\Score_Groups

Score_Group_Link_Collector{}Yoast 1.0

Getting links for score groups.

Хуков нет.

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

$Score_Group_Link_Collector = new Score_Group_Link_Collector();
// use class methods

Методы

  1. public get_view_link( Score_Groups_Interface $score_group, Content_Type $content_type, ?Taxonomy $taxonomy, ?int $term_id )

Код Score_Group_Link_Collector{} Yoast 24.3

class Score_Group_Link_Collector {

	/**
	 * Builds the view link of the score group.
	 *
	 * @param Score_Groups_Interface $score_group  The score group.
	 * @param Content_Type           $content_type The content type.
	 * @param Taxonomy|null          $taxonomy     The taxonomy of the term we might be filtering.
	 * @param int|null               $term_id      The ID of the term we might be filtering.
	 *
	 * @return string The view link of the score.
	 */
	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 === false ) {
			return null;
		}

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

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