WP_Posts_List_Table::get_edit_link() WordPress Method
The WP_Posts_List_Table::get_edit_link() method is used to get the edit link for a given post. This is useful for displaying a link to the edit screen for a given post on the front end of a WordPress site. The get_edit_link() method takes two parameters: the post ID and the post type. The post ID is the ID of the post to get the edit link for. The post type is the post type of the post to get the edit link for.
WP_Posts_List_Table::get_edit_link( string[] $args, string $link_text, string $css_class = '' ) #
Helper to create links to edit.php with params.
Parameters
- $args
(string[])(Required)Associative array of URL parameters for the link.
- $link_text
(string)(Required)Link text.
- $css_class
(string)(Optional) Class attribute.
Default value: ''
Return
(string) The formatted link string.
Source
File: wp-admin/includes/class-wp-posts-list-table.php
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 ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |