~canonical-sysadmins/wordpress/4.5.2

« back to all changes in this revision

Viewing changes to wp-admin/includes/bookmark.php

  • Committer: Manuel Seelaus
  • Date: 2015-12-09 17:47:18 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: manuel.seelaus@canonical.com-20151209174718-coxethm2swbeqksy
Merge WP4.4 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
}
19
19
 
20
20
/**
21
 
 * Update or insert a link using values provided in $_POST.
 
21
 * Updates or inserts a link using values provided in $_POST.
22
22
 *
23
23
 * @since 2.0.0
24
24
 *
25
 
 * @param int $link_id Optional. ID of the link to edit.
 
25
 * @param int $link_id Optional. ID of the link to edit. Default 0.
26
26
 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
27
27
 */
28
28
function edit_link( $link_id = 0 ) {
29
 
        if ( !current_user_can( 'manage_links' ) )
30
 
                wp_die( __( 'Cheatin’ uh?' ), 403 );
 
29
        if ( ! current_user_can( 'manage_links' ) ) {
 
30
                wp_die(
 
31
                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
 
32
                        '<p>' . __( 'You do not have sufficient permissions to edit the links for this site.' ) . '</p>',
 
33
                        403
 
34
                );
 
35
        }
31
36
 
32
37
        $_POST['link_url'] = esc_html( $_POST['link_url'] );
33
38
        $_POST['link_url'] = esc_url($_POST['link_url']);
46
51
}
47
52
 
48
53
/**
49
 
 * Retrieve the default link for editing.
 
54
 * Retrieves the default link for editing.
50
55
 *
51
56
 * @since 2.0.0
52
57
 *
53
 
 * @return stdClass Default link
 
58
 * @return stdClass Default link object.
54
59
 */
55
60
function get_default_link_to_edit() {
56
61
        $link = new stdClass;
70
75
}
71
76
 
72
77
/**
73
 
 * Delete link specified from database.
 
78
 * Deletes a specified link from the database.
74
79
 *
75
80
 * @since 2.0.0
76
81
 *
77
 
 * @global wpdb $wpdb
 
82
 * @global wpdb $wpdb WordPress database abstraction object.
78
83
 *
79
84
 * @param int $link_id ID of the link to delete
80
 
 * @return true
 
85
 * @return true Always true.
81
86
 */
82
87
function wp_delete_link( $link_id ) {
83
88
        global $wpdb;
93
98
        wp_delete_object_term_relationships( $link_id, 'link_category' );
94
99
 
95
100
        $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );
 
101
 
96
102
        /**
97
103
         * Fires after a link has been deleted.
98
104
         *
121
127
}
122
128
 
123
129
/**
124
 
 * Retrieve link data based on ID.
 
130
 * Retrieves link data based on its ID.
125
131
 *
126
132
 * @since 2.0.0
127
133
 *
128
 
 * @param int $link_id ID of link to retrieve
129
 
 * @return object Link for editing
 
134
 * @param int $link_id ID of link to retrieve.
 
135
 * @return object Link object for editing.
130
136
 */
131
137
function get_link_to_edit( $link_id ) {
132
138
        return get_bookmark( $link_id, OBJECT, 'edit' );
133
139
}
134
140
 
135
141
/**
136
 
 * This function inserts/updates links into/in the database.
 
142
 * Inserts/updates links into/in the database.
137
143
 *
138
144
 * @since 2.0.0
139
145
 *
140
 
 * @global wpdb $wpdb
 
146
 * @global wpdb $wpdb WordPress database abstraction object.
141
147
 *
142
148
 * @param array $linkdata Elements that make up the link to insert.
143
 
 * @param bool  $wp_error Optional. If true return WP_Error object on failure.
 
149
 * @param bool  $wp_error Optional. Whether to return a WP_Error object on failure. Default false.
144
150
 * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
145
151
 */
146
152
function wp_insert_link( $linkdata, $wp_error = false ) {
183
189
        $link_rel         = ( ! empty( $r['link_rel'] ) ) ? $r['link_rel'] : '';
184
190
        $link_category    = ( ! empty( $r['link_category'] ) ) ? $r['link_category'] : array();
185
191
 
186
 
        // Make sure we set a valid category
 
192
        // Make sure we set a valid category.
187
193
        if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) {
188
194
                $link_category = array( get_option( 'default_link_category' ) );
189
195
        }
238
244
 *
239
245
 * @since 2.1.0
240
246
 *
241
 
 * @param int $link_id ID of link to update
242
 
 * @param array $link_categories Array of categories to
 
247
 * @param int   $link_id         ID of the link to update.
 
248
 * @param array $link_categories Array of link categories to add the link to.
243
249
 */
244
250
function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
245
251
        // If $link_categories isn't already an array, make it one:
255
261
}
256
262
 
257
263
/**
258
 
 * Update a link in the database.
 
264
 * Updates a link in the database.
259
265
 *
260
266
 * @since 2.0.0
261
267
 *
285
291
}
286
292
 
287
293
/**
 
294
 * Outputs the 'disabled' message for the WordPress Link Manager.
 
295
 *
288
296
 * @since 3.5.0
289
297
 * @access private
290
298
 *