[wp-trac] [WordPress Trac] #2519: Process writing of new entries with category exclusions

WordPress Trac wp-trac at lists.automattic.com
Tue Feb 28 21:31:51 GMT 2006


#2519: Process writing of new entries with category exclusions
----------------------------+-----------------------------------------------
       Id:  2519            |      Status:  new                     
Component:  Administration  |    Modified:  Tue Feb 28 21:31:51 2006
 Severity:  normal          |   Milestone:                          
 Priority:  normal          |     Version:  1.5                     
    Owner:  anonymous       |    Reporter:  coppit                  
----------------------------+-----------------------------------------------
 I'd like my Category Access plug-in to restrict not only reading entries
 based on category (which it does) but the writing of entries in restricted
 categories.

 In short, only restricted categories should appear in the list of
 available categories on the Admin-Write page. To make this happen, the
 Wordpress function needs to allow exclusions to be applied as shown below
 (only the ***-line is different in the SQL). The 'return' needs to get a
 column not a result too.

 Making this small change allows any plug-in to provide exclusions.

 wp-admin\admin-functions.php: line 513
 {{{
   // Original SQL line taken out to be replaced with 'extended' query>
 below.
   // Copied and modified from template-functions-category.php line 293,
 'list_cats()',
   // this is the line that calls the "Catagory Access" filter hook,
   // ensuring that the list is filtered by user access settings

   $exclusions = apply_filters('list_cats_exclusions', '' );
   $query = "
     SELECT cat_ID
     FROM $wpdb->categories
     WHERE category_parent = $parent
 ***   AND cat_ID > 0 $exclusions
     ORDER BY cat_ID ASC LIMIT 100";

   return $wpdb->get_col($query);  // get_results -> get_col
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2519>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list