}
/**
- * Update or insert a link using values provided in $_POST.
+ * Updates or inserts a link using values provided in $_POST.
*
* @since 2.0.0
*
- * @param int $link_id Optional. ID of the link to edit.
+ * @param int $link_id Optional. ID of the link to edit. Default 0.
* @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
*/
function edit_link( $link_id = 0 ) {
- if ( !current_user_can( 'manage_links' ) )
- wp_die( __( 'Cheatin’ uh?' ), 403 );
+ if ( ! current_user_can( 'manage_links' ) ) {
+ wp_die(
+ '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
+ '<p>' . __( 'You do not have sufficient permissions to edit the links for this site.' ) . '</p>',
+ 403
+ );
+ }
$_POST['link_url'] = esc_html( $_POST['link_url'] );
$_POST['link_url'] = esc_url($_POST['link_url']);
}
/**
- * Retrieve the default link for editing.
+ * Retrieves the default link for editing.
*
* @since 2.0.0
*
- * @return stdClass Default link
+ * @return stdClass Default link object.
*/
function get_default_link_to_edit() {
$link = new stdClass;
}
/**
- * Delete link specified from database.
+ * Deletes a specified link from the database.
*
* @since 2.0.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $link_id ID of the link to delete
- * @return true
+ * @return true Always true.
*/
function wp_delete_link( $link_id ) {
global $wpdb;
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.
*
}
/**
- * Retrieve link data based on ID.
+ * Retrieves link data based on its ID.
*
* @since 2.0.0
*
- * @param int $link_id ID of link to retrieve
- * @return object Link for editing
+ * @param int $link_id ID of link to retrieve.
+ * @return object Link object for editing.
*/
function get_link_to_edit( $link_id ) {
return get_bookmark( $link_id, OBJECT, 'edit' );
}
/**
- * This function inserts/updates links into/in the database.
+ * Inserts/updates links into/in the database.
*
* @since 2.0.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*
* @param array $linkdata Elements that make up the link to insert.
- * @param bool $wp_error Optional. If true return WP_Error object on failure.
+ * @param bool $wp_error Optional. Whether to return a WP_Error object on failure. Default false.
* @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
*/
function wp_insert_link( $linkdata, $wp_error = false ) {
$link_rel = ( ! empty( $r['link_rel'] ) ) ? $r['link_rel'] : '';
$link_category = ( ! empty( $r['link_category'] ) ) ? $r['link_category'] : array();
- // Make sure we set a valid category
+ // Make sure we set a valid category.
if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) {
$link_category = array( get_option( 'default_link_category' ) );
}
*
* @since 2.1.0
*
- * @param int $link_id ID of link to update
- * @param array $link_categories Array of categories to
+ * @param int $link_id ID of the link to update.
+ * @param array $link_categories Array of link categories to add the link to.
*/
function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
// If $link_categories isn't already an array, make it one:
}
/**
- * Update a link in the database.
+ * Updates a link in the database.
*
* @since 2.0.0
*
}
/**
+ * Outputs the 'disabled' message for the WordPress Link Manager.
+ *
* @since 3.5.0
* @access private
*