edit_bookmark_link()WP 2.7.0

Outputs a link to edit the current bookmark (link) if the user is authorized and has permission to edit.

Must be used inside the Bookmark (link) Loop.

Hooks from the function

Returns

null. Outputs the HTML code for the link.

Usage

<?php edit_bookmark_link( $link, $before, $after, $bookmark ); ?>
$link(string)
Text of the link.
Default: '' - Edit This
$before(string)
Text before the link.
Default: ''
$after(string)
Text after the link.
Default: ''
$bookmark(number)
ID of the bookmark to display the link for.
Default: current ID in the loop

Examples

0

#1 Let's display a link to edit the bookmark

<?php edit_bookmark_link(); ?>
0

#2 Let's display the edit link with the text "edit link"

And wrap it in the html tag <p>:

<?php edit_bookmark_link( 'edit link', '<p>', '</p>'); ?>

Changelog

Since 2.7.0 Introduced.

edit_bookmark_link() code WP 6.9.1

function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) {
	$bookmark = get_bookmark( $bookmark );

	if ( ! current_user_can( 'manage_links' ) ) {
		return;
	}

	if ( empty( $link ) ) {
		$link = __( 'Edit This' );
	}

	$link = '<a href="' . esc_url( get_edit_bookmark_link( $bookmark ) ) . '">' . $link . '</a>';

	/**
	 * Filters the bookmark edit link anchor tag.
	 *
	 * @since 2.7.0
	 *
	 * @param string $link    Anchor tag for the edit link.
	 * @param int    $link_id Bookmark ID.
	 */
	echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after;
}