Make WordPress Core


Ignore:
Timestamp:
12/07/2010 06:59:25 PM (16 years ago)
Author:
nacin
Message:

Use assign_terms cap for tag search and tag cloud in admin ajax. fixes #15437.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r16699 r16771  
    6767        break;
    6868case 'ajax-tag-search' :
    69         if ( !current_user_can( 'edit_posts' ) )
    70                 die('-1');
     69        if ( isset( $_GET['tax'] ) ) {
     70                $taxonomy = sanitize_key( $_GET['tax'] );
     71                $tax = get_taxonomy( $taxonomy );
     72                if ( ! $tax )
     73                        die( '0' );
     74                if ( ! current_user_can( $tax->cap->assign_terms ) )
     75                        die( '-1' );
     76        } else {
     77                die('0');
     78        }
    7179
    7280        $s = $_GET['q']; // is this slashed already?
    73 
    74         if ( isset($_GET['tax']) )
    75                 $taxonomy = sanitize_title($_GET['tax']);
    76         else
    77                 die('0');
    7881
    7982        if ( false !== strpos( $s, ',' ) ) {
     
    548551        break;
    549552case 'get-tagcloud' :
    550         if ( !current_user_can( 'edit_posts' ) )
    551                 die('-1');
    552 
    553         if ( isset($_POST['tax']) )
    554                 $taxonomy = sanitize_title($_POST['tax']);
    555         else
     553        if ( isset( $_POST['tax'] ) ) {
     554                $taxonomy = sanitize_key( $_POST['tax'] );
     555                $tax = get_taxonomy( $taxonomy );
     556                if ( ! $tax )
     557                        die( '0' );
     558                if ( ! current_user_can( $tax->cap->assign_terms ) )
     559                        die( '-1' );
     560        } else {
    556561                die('0');
     562        }
    557563
    558564        $tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
    559565
    560         if ( empty( $tags ) ) {
    561                 $tax = get_taxonomy( $taxonomy );
     566        if ( empty( $tags ) )
    562567                die( isset( $tax->no_tagcloud ) ? $tax->no_tagcloud : __('No tags found!') );
    563         }
    564 
    565         if ( is_wp_error($tags) )
    566                 die($tags->get_error_message());
     568
     569        if ( is_wp_error( $tags ) )
     570                die( $tags->get_error_message() );
    567571
    568572        foreach ( $tags as $key => $tag ) {
Note: See TracChangeset for help on using the changeset viewer.