Advertisements

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

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: