~ubuntu-branches/ubuntu/lucid/wordpress/lucid-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2009-08-14 13:32:33 UTC
  • mfrom: (11.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090814133233-n1qy24xncscu6yvj
Tags: 2.8.3-2ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/apache.conf:
    + Changed to use /var/www instead of /srv/www for virtual webroot.
  - debian/setup-mysql:
    + Changed to use /var/www instead of /srv/www.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * @param unknown_type $cat_name
19
19
 * @return unknown
20
20
 */
21
 
function category_exists($cat_name) {
22
 
        $id = is_term($cat_name, 'category');
 
21
function category_exists($cat_name, $parent = 0) {
 
22
        $id = is_term($cat_name, 'category', $parent);
23
23
        if ( is_array($id) )
24
24
                $id = $id['term_id'];
25
25
        return $id;
194
194
 * @param unknown_type $post_id
195
195
 * @return unknown
196
196
 */
197
 
function get_tags_to_edit( $post_id ) {
 
197
function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {
 
198
        return get_terms_to_edit( $post_id, $taxonomy);
 
199
}
 
200
 
 
201
/**
 
202
 * {@internal Missing Short Description}}
 
203
 *
 
204
 * @since unknown
 
205
 *
 
206
 * @param unknown_type $post_id
 
207
 * @return unknown
 
208
 */
 
209
function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
198
210
        $post_id = (int) $post_id;
199
211
        if ( !$post_id )
200
212
                return false;
201
213
 
202
 
        $tags = wp_get_post_tags($post_id);
 
214
        $tags = wp_get_post_terms($post_id, $taxonomy, array());
203
215
 
204
216
        if ( !$tags )
205
217
                return false;
206
218
 
 
219
        if ( is_wp_error($tags) )
 
220
                return $tags;
 
221
 
207
222
        foreach ( $tags as $tag )
208
223
                $tag_names[] = $tag->name;
209
224
        $tags_to_edit = join( ',', $tag_names );
210
 
        $tags_to_edit = attribute_escape( $tags_to_edit );
211
 
        $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit );
 
225
        $tags_to_edit = esc_attr( $tags_to_edit );
 
226
        $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy );
 
227
 
212
228
        return $tags_to_edit;
213
229
}
214
230
 
233
249
 * @return unknown
234
250
 */
235
251
function wp_create_tag($tag_name) {
236
 
        if ( $id = tag_exists($tag_name) )
 
252
        return wp_create_term( $tag_name, 'post_tag');
 
253
}
 
254
 
 
255
/**
 
256
 * {@internal Missing Short Description}}
 
257
 *
 
258
 * @since unknown
 
259
 *
 
260
 * @param unknown_type $tag_name
 
261
 * @return unknown
 
262
 */
 
263
function wp_create_term($tag_name, $taxonomy = 'post_tag') {
 
264
        if ( $id = is_term($tag_name, $taxonomy) )
237
265
                return $id;
238
266
 
239
 
        return wp_insert_term($tag_name, 'post_tag');
 
267
        return wp_insert_term($tag_name, $taxonomy);
240
268
}
241
 
 
242
 
?>