wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



edit_post_link › WordPress Function

Seit1.0.0
Veraltetn/v
edit_post_link ( $text = null, $before = '', $after = '', $post = 0, $css_class = 'post-edit-link' )
Parameter: (5)
  • (string) $text Optional. Anchor text. If null, default is 'Edit This'. Default null.
    Erforderlich: Nein
    Standard: null
  • (string) $before Optional. Display before edit link. Default empty.
    Erforderlich: Nein
    Standard: (leer)
  • (string) $after Optional. Display after edit link. Default empty.
    Erforderlich: Nein
    Standard: (leer)
  • (int|WP_Post) $post Optional. Post ID or post object. Default is the global `$post`.
    Erforderlich: Nein
    Standard:
  • (string) $css_class Optional. Add custom class to link. Default 'post-edit-link'.
    Erforderlich: Nein
    Standard: 'post-edit-link'
Definiert in:
Codex:
Changelog:
  • 4.4.0

Displays the edit post link for post.



Quellcode

function edit_post_link( $text = null, $before = '', $after = '', $post = 0, $css_class = 'post-edit-link' ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return;
	}

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

	if ( ! $url ) {
		return;
	}

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

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

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