Changeset 13184
- Timestamp:
- 02/17/2010 08:33:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r13172 r13184 2012 2012 } 2013 2013 2014 // Make sure we set a valid category 2014 if ( empty($post_type) ) 2015 $post_type = 'post'; 2016 2017 // Make sure we set a valid category. 2015 2018 if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) { 2016 $post_category = array(get_option('default_category')); 2017 } 2018 2019 //Set the default tag list 2019 // 'post' requires at least one category. 2020 if ( 'post' == $post_type ) 2021 $post_category = array( get_option('default_category') ); 2022 else 2023 $post_category = array(); 2024 } 2025 2026 // Set the default tag list 2020 2027 if ( !isset($tags_input) ) 2021 2028 $tags_input = array(); … … 2026 2033 if ( empty($post_status) ) 2027 2034 $post_status = 'draft'; 2028 2029 if ( empty($post_type) )2030 $post_type = 'post';2031 2035 2032 2036 $post_ID = 0; … … 2483 2487 function wp_set_post_categories($post_ID = 0, $post_categories = array()) { 2484 2488 $post_ID = (int) $post_ID; 2489 $post_type = get_post_type( $post_ID ); 2485 2490 // If $post_categories isn't already an array, make it one: 2486 if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories)) 2487 $post_categories = array(get_option('default_category')); 2488 else if ( 1 == count($post_categories) && '' == $post_categories[0] ) 2491 if ( !is_array($post_categories) || 0 == count($post_categories) || empty($post_categories) ) { 2492 if ( 'post' == $post_type ) 2493 $post_categories = array( get_option('default_category') ); 2494 else 2495 $post_categories = array(); 2496 } else if ( 1 == count($post_categories) && '' == $post_categories[0] ) { 2489 2497 return true; 2490 2491 $post_categories = array_map('intval', $post_categories); 2492 $post_categories = array_unique($post_categories); 2498 } 2499 2500 if ( !empty($post_categories) ) { 2501 $post_categories = array_map('intval', $post_categories); 2502 $post_categories = array_unique($post_categories); 2503 } 2493 2504 2494 2505 return wp_set_object_terms($post_ID, $post_categories, 'category');
Note: See TracChangeset
for help on using the changeset viewer.