edit_tag_link

Definition:
function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {}

Display or retrieve edit tag link with formatting.

Parameters

  • string $link: Optional. Anchor text.
  • string $before: Optional. Display before edit link.
  • string $after: Optional. Display after edit link.
  • int|object $tag: Tag object or ID

Return values

returns:HTML content.

Defined filters

  • edit_tag_link
    apply_filters( 'edit_tag_link', $link )

Source code

function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {

	$link = edit_term_link( $link, '', '', false, $tag );

	echo $before . apply_filters( 'edit_tag_link', $link ) . $after;

}

1006

edit_post_link

Definition:
function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {}

Display edit post link for post.

Parameters

  • string $link: Optional. Anchor text.
  • string $before: Optional. Display before edit link.
  • string $after: Optional. Display after edit link.
  • int $id: Optional. Post ID.

Defined filters

  • edit_post_link
    apply_filters( 'edit_post_link', $link, $post->ID )

Source code

function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {

	if ( !$post = &get_post( $id ) )

		return;



	if ( !$url = get_edit_post_link( $post->ID ) )

		return;



	if ( null === $link )

		$link = __('Edit This');



	$post_type_obj = get_post_type_object( $post->post_type );

	$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';

	echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;

}

1004

edit_post

Definition:
function edit_post( $post_data = null ) {}

Update an existing post with values provided in $_POST.

Parameters

  • array $post_data: Optional.

Return values

returns:Post ID.

Source code

function edit_post( $post_data = null ) {



	if ( empty($post_data) )

		$post_data = &$_POST;



	// Clear out any data in internal vars.

	unset( $post_data['filter'] );



	$post_ID = (int) $post_data['post_ID'];

	$post = get_post( $post_ID );

	$post_data['post_type'] = $post->post_type;

	$post_data['post_mime_type'] = $post->post_mime_type;



	$ptype = get_post_type_object($post_data['post_type']);

	if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) {

		if ( 'page' == $post_data['post_type'] )

			wp_die( __('You are not allowed to edit this page.' ));

		else

			wp_die( __('You are not allowed to edit this post.' ));

	}



	// Autosave shouldn't save too soon after a real save

	if ( 'autosave' == $post_data['action'] ) {

		$post =& get_post( $post_ID );

		$now = time();

		$then = strtotime($post->post_date_gmt . ' +0000');

		$delta = AUTOSAVE_INTERVAL / 2;

		if ( ($now - $then) < $delta )

			return $post_ID;

	}



	$post_data = _wp_translate_postdata( true, $post_data );

	if ( is_wp_error($post_data) )

		wp_die( $post_data->get_error_message() );

	if ( 'autosave' != $post_data['action']  && 'auto-draft' == $post_data['post_status'] )

		$post_data['post_status'] = 'draft';



	if ( isset($post_data['visibility']) ) {

		switch ( $post_data['visibility'] ) {

			case 'public' :

				$post_data['post_password'] = '';

				break;

			case 'password' :

				unset( $post_data['sticky'] );

				break;

			case 'private' :

				$post_data['post_status'] = 'private';

				$post_data['post_password'] = '';

				unset( $post_data['sticky'] );

				break;

		}

	}



	// Post Formats

	if ( current_theme_supports( 'post-formats' ) && isset( $post_data['post_format'] ) ) {

		$formats = get_theme_support( 'post-formats' );

		if ( is_array( $formats ) ) {

			$formats = $formats[0];

			if ( in_array( $post_data['post_format'], $formats ) ) {

				set_post_format( $post_ID, $post_data['post_format'] );

			} elseif ( '0' == $post_data['post_format'] ) {

				set_post_format( $post_ID, false );

			}

		}

	}



	// Meta Stuff

	if ( isset($post_data['meta']) && $post_data['meta'] ) {

		foreach ( $post_data['meta'] as $key => $value ) {

			if ( !$meta = get_post_meta_by_id( $key ) )

				continue;

			if ( $meta->post_id != $post_ID )

				continue;

			if ( is_protected_meta( $value['key'] ) )

				continue;

			update_meta( $key, $value['key'], $value['value'] );

		}

	}



	if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {

		foreach ( $post_data['deletemeta'] as $key => $value ) {

			if ( !$meta = get_post_meta_by_id( $key ) )

				continue;

			if ( $meta->post_id != $post_ID )

				continue;

			if ( is_protected_meta( $meta->meta_key ) )

				continue;

			delete_meta( $key );

		}

	}



	add_meta( $post_ID );



	update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );



	wp_update_post( $post_data );



	// Reunite any orphaned attachments with their parent

	if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )

		$draft_ids = array();

	if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )

		_relocate_children( $draft_temp_id, $post_ID );



	// Now that we have an ID we can fix any attachment anchor hrefs

	_fix_attachment_links( $post_ID );



	wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID );



	if ( current_user_can( $ptype->cap->edit_others_posts ) ) {

		if ( ! empty( $post_data['sticky'] ) )

			stick_post( $post_ID );

		else

			unstick_post( $post_ID );

	}



	return $post_ID;

}

1002

edit_link

Definition:
function edit_link( $link_id = 0 ) {}

Update or insert a link using values provided in $_POST.

Parameters

  • int $link_id: Optional. ID of the link to edit.

Return values

returns:Value 0 or WP_Error on failure. The link ID on success.

Source code

function edit_link( $link_id = 0 ) {

	if ( !current_user_can( 'manage_links' ) )

		wp_die( __( 'Cheatin’ uh?' ) );



	$_POST['link_url'] = esc_html( $_POST['link_url'] );

	$_POST['link_url'] = esc_url($_POST['link_url']);

	$_POST['link_name'] = esc_html( $_POST['link_name'] );

	$_POST['link_image'] = esc_html( $_POST['link_image'] );

	$_POST['link_rss'] = esc_url($_POST['link_rss']);

	if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )

		$_POST['link_visible'] = 'Y';



	if ( !empty( $link_id ) ) {

		$_POST['link_id'] = $link_id;

		return wp_update_link( $_POST );

	} else {

		return wp_insert_link( $_POST );

	}

}

1000

edit_comment_link

Definition:
function edit_comment_link( $link = null, $before = '', $after = '' ) {}

Display or retrieve edit comment link with formatting.

Parameters

  • string $link: Optional. Anchor text.
  • string $before: Optional. Display before edit link.
  • string $after: Optional. Display after edit link.

Return values

returns:HTML content, if $echo is set to false.

Defined filters

  • edit_comment_link
    apply_filters( 'edit_comment_link', $link, $comment->comment_ID )

Source code

function edit_comment_link( $link = null, $before = '', $after = '' ) {

	global $comment;



	if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )

		return;



	if ( null === $link )

		$link = __('Edit This');



	$link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . esc_attr__( 'Edit comment' ) . '">' . $link . '</a>';

	echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;

}

998