On this page
wp_delete_link( int $link_id ): true
Deletes a specified link from the database.
Parameters
$link_idint Required-
ID of the link to delete
Return
true Always true.
Source
File: wp-admin/includes/bookmark.php. View all references
function wp_delete_link( $link_id ) {
global $wpdb;
/**
* Fires before a link is deleted.
*
* @since 2.0.0
*
* @param int $link_id ID of the link to delete.
*/
do_action( 'delete_link', $link_id );
wp_delete_object_term_relationships( $link_id, 'link_category' );
$wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );
/**
* Fires after a link has been deleted.
*
* @since 2.2.0
*
* @param int $link_id ID of the deleted link.
*/
do_action( 'deleted_link', $link_id );
clean_bookmark_cache( $link_id );
return true;
}
Hooks
- do_action( 'deleted_link',
int $link_id ) -
Fires after a link has been deleted.
- do_action( 'delete_link',
int $link_id ) -
Fires before a link is deleted.
Related
Uses
| Uses | Description |
|---|---|
| wp_delete_object_term_relationships() wp-includes/taxonomy.php | Unlinks the object from the taxonomy or taxonomies. |
| clean_bookmark_cache() wp-includes/bookmark.php | Deletes the bookmark cache. |
| wpdb::delete() wp-includes/class-wpdb.php | Deletes a row in the table. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
Used By
| Used By | Description |
|---|---|
| wpmu_delete_user() wp-admin/includes/ms.php | Delete a user from the network and remove from all sites. |
| wp_delete_user() wp-admin/includes/user.php | Remove user and optionally reassign posts and links to another user. |
| wp_ajax_delete_link() wp-admin/includes/ajax-actions.php | Ajax handler for deleting a link. |
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_delete_link