Updates a link in the database.
Parameters
$linkdata
arrayrequired- Link data to update. See wp_insert_link() for accepted arguments.
More Arguments from wp_insert_link( … $linkdata )
Elements that make up the link to insert.
link_id
intOptional. The ID of the existing link if updating.link_url
stringThe URL the link points to.link_name
stringThe title of the link.link_image
stringOptional. A URL of an image.link_target
stringOptional. The target element for the anchor tag.link_description
stringOptional. A short description of the link.link_visible
stringOptional.'Y'
means visible, anything else means not.link_owner
intOptional. A user ID.link_rating
intOptional. A rating for the link.link_rel
stringOptional. A relationship of the link to you.link_notes
stringOptional. An extended description of or notes on the link.link_rss
stringOptional. A URL of an associated RSS feed.link_category
intOptional. The term ID of the link category.
If empty, uses default link category.
Source
function wp_update_link( $linkdata ) {
$link_id = (int) $linkdata['link_id'];
$link = get_bookmark( $link_id, ARRAY_A );
// Escape data pulled from DB.
$link = wp_slash( $link );
// Passed link category list overwrites existing category list if not empty.
if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] )
&& count( $linkdata['link_category'] ) > 0
) {
$link_cats = $linkdata['link_category'];
} else {
$link_cats = $link['link_category'];
}
// Merge old and new fields with new fields overwriting old ones.
$linkdata = array_merge( $link, $linkdata );
$linkdata['link_category'] = $link_cats;
return wp_insert_link( $linkdata );
}
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.