On this page
WP_Posts_List_Table::get_edit_link( string[] $args, string $link_text, string $css_class = '' ): string
Helper to create links to edit.php with params.
Parameters
$argsstring[] Required-
Associative array of URL parameters for the link.
$link_textstring Required-
Link text.
$css_classstring Optional-
Class attribute.
Default:
''
Return
string The formatted link string.
Source
File: wp-admin/includes/class-wp-posts-list-table.php. View all references
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
);
}
Related
Uses
| Uses | Description |
|---|---|
| esc_attr() wp-includes/formatting.php | Escaping for HTML attributes. |
| esc_url() wp-includes/formatting.php | Checks and cleans a URL. |
| add_query_arg() wp-includes/functions.php | Retrieves a modified URL query string. |
Used By
| Used By | Description |
|---|---|
| WP_Posts_List_Table::column_author() wp-admin/includes/class-wp-posts-list-table.php | Handles the post author column output. |
| WP_Posts_List_Table::column_default() wp-admin/includes/class-wp-posts-list-table.php | Handles the default column output. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_posts_list_table/get_edit_link