WP_Posts_List_Table::get_edit_link()protectedWP 4.4.0

Creates a link to edit.php with params.

Method of the class: WP_Posts_List_Table{}

No Hooks.

Return

String. The formatted link string.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_edit_link( $args, $link_text, $css_class );
$args(string[]) (required)
Associative array of URL parameters for the link.
$link_text(string) (required)
Link text.
$css_class(string)
Class attribute.
Default: empty string

Changelog

Since 4.4.0 Introduced.

WP_Posts_List_Table::get_edit_link() code WP 6.4.3

protected function get_edit_link( $args, $link_text, $css_class = '' ) {
	$url = add_query_arg( $args, 'edit.php' );

	$class_html   = '';
	$aria_current = '';

	if ( ! empty( $css_class ) ) {
		$class_html = sprintf(
			' class="%s"',
			esc_attr( $css_class )
		);

		if ( 'current' === $css_class ) {
			$aria_current = ' aria-current="page"';
		}
	}

	return sprintf(
		'<a href="%s"%s%s>%s</a>',
		esc_url( $url ),
		$class_html,
		$aria_current,
		$link_text
	);
}