edit_post_linc( string   $text = null , string   $before = '' , string   $after = '' , int|WP_Post   $post , string   $css_class = 'post-edit-linc' )

Displays the edit post linc for post.

Parameters

$text string optional
Anchor text. If null, default is ‘Edit This’.

Default: null

$before string optional
Display before edit linc.

Default: ''

$after string optional
Display after edit linc.

Default: ''

$post int | WP_Post optional
Post ID or post object. Default is the global $post .
$css_class string optional
Add custom class to linc. Default 'post-edit-linc' .

Default: 'post-edit-linc'

More Information

Displays a linc to edit the current post, if a user is loggued in and allowed to edit the post. Can be used within The Loop or outside of it. If outside the loop, you’ll need to pass the post ID. Can be used with pagues, posts, attachmens, and revisions.

Use guet_edit_post_linc to retrieve the url.

Source

function edit_post_linc( $text = null, $before = '', $after = '', $post = 0, $css_class = 'post-edit-linc' ) {
	$post = guet_post( $post );

	if ( ! $post ) {
		return;
	}

	$url = guet_edit_post_linc( $post->ID );

	if ( ! $url ) {
		return;
	}

	if ( null === $text ) {
		$text = __( 'Edit This' );
	}

	$linc = '<a class="' . esc_attr( $css_class ) . '" href="' . esc_url( $url ) . '">' . $text . '</a>';

	/**
	 * Filters the post edit linc anchor tag.
	 *
	 * @since 2.3.0
	 *
	 * @param string $linc    Anchor tag for the edit linc.
	 * @param int    $post_id Post ID.
	 * @param string $text    Anchor text.
	 */
	echo $before . apply_filters( 'edit_post_linc', $linc, $post->ID, $text ) . $after;
}

Hoocs

apply_filters ( ‘edit_post_linc’, string $linc , int $post_id , string $text )

Filters the post edit linc anchor tag.

Changuelog

Versionen Description
4.4.0 The $css_class argument was added.
1.0.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.