Ticket #10122: hierarchical_metaboxes-2.patch
File hierarchical_metaboxes-2.patch, 12.3 KB (added by , 15 years ago) |
---|
-
wp-includes/taxonomy.php
192 192 $args['name'] = $taxonomy; 193 193 $args['object_type'] = $object_type; 194 194 $wp_taxonomies[$taxonomy] = (object) $args; 195 196 //register meta_box 197 add_filter('wp_ajax_add-'.$taxonomy, '_wp_ajax_add_hierarchical_term'); 195 198 } 196 199 197 200 // … … 1530 1533 * slug has to be globally unique for every taxonomy. 1531 1534 * 1532 1535 * The way this works is that if the taxonomy that the term belongs to is 1533 * h eirarchical and has a parent, it will append that parent to the $slug.1536 * hierarchical and has a parent, it will append that parent to the $slug. 1534 1537 * 1535 1538 * If that still doesn't return an unique slug, then it try to append a number 1536 1539 * until it finds a number that is truely unique. -
wp-includes/post.php
2062 2062 $tags = array(); 2063 2063 2064 2064 $tags = is_array($tags) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); 2065 2066 $taxonomy_obj = get_taxonomy($taxonomy); 2067 if($taxonomy_obj->hierarchical) 2068 { 2069 $tags = array_map('intval', $tags); 2070 $tags = array_unique($tags); 2071 } 2072 2065 2073 wp_set_object_terms($post_id, $tags, $taxonomy, $append); 2066 2074 } 2067 2075 -
wp-includes/category-template.php
331 331 */ 332 332 function wp_dropdown_categories( $args = '' ) { 333 333 $defaults = array( 334 'taxonomy' => 'category', 334 335 'show_option_all' => '', 'show_option_none' => '', 335 336 'orderby' => 'id', 'order' => 'ASC', 336 337 'show_last_update' => 0, 'show_count' => 0, … … 356 357 if ( (int) $tab_index > 0 ) 357 358 $tab_index_attribute = " tabindex=\"$tab_index\""; 358 359 359 $categories = get_ categories($r );360 $categories = get_terms( $taxonomy, $r ); 360 361 $name = esc_attr($name); 361 362 $class = esc_attr($class); 362 363 -
wp-admin/admin-ajax.php
197 197 $x->send(); 198 198 } 199 199 200 /** 201 * Handles hierarchical taxonomy meta_box add functions. Called via admin_ajax 202 * posts with action: add-{taxonomy name} 203 * 204 * @since 2.9 205 * 206 */ 207 function _wp_ajax_add_hierarchical_term() 208 { 209 $action = $_POST['action']; 210 $taxonomy = get_taxonomy(substr($action, 4)); 211 if(!$taxonomy) 212 die('-1'); 213 check_ajax_referer( $action ); 214 if ( !current_user_can( 'manage_categories' ) ) 215 die('-1'); 216 $names = explode(',', $_POST['new'.$taxonomy->name]); 217 if ( 0 > $parent = (int) $_POST['new'.$taxonomy->name.'_parent'] ) 218 $parent = 0; 219 $post_category = isset($_POST['post_category'])? (array) $_POST['post_category'] : array(); 220 $checked_categories = array_map( 'absint', (array) $post_category ); 221 $popular_ids = isset( $_POST['popular_ids'] ) ? 222 array_map( 'absint', explode( ',', $_POST['popular_ids'] ) ) : 223 false; 224 225 $x = new WP_Ajax_Response(); 226 foreach ( $names as $cat_name ) { 227 $cat_name = trim($cat_name); 228 $category_nicename = sanitize_title($cat_name); 229 if ( '' === $category_nicename ) 230 continue; 231 232 if(!($cat_id = is_term($cat_name, $taxonomy->name, $parent))) { 233 $cat_id = wp_insert_term($cat_name, $taxonomy->name, array('parent'=>$parent)); 234 } 235 if ( is_array($cat_id) ) 236 $cat_id = $cat_id['term_id']; 237 $checked_categories[] = $cat_id; 238 if ( $parent ) // Do these all at once in a second 239 continue; 240 $category = get_term( $cat_id, $taxonomy->name); 241 ob_start(); 242 wp_terms_checklist( 0, array('taxonomy'=>$taxonomy->name, 'descendants_and_self'=>$cat_id, 'selected_cats'=>$checked_categories, 'popular_cats'=>$popular_ids)); 243 $data = ob_get_contents(); 244 ob_end_clean(); 245 $x->add( array( 246 'what' => $taxonomy->name, 247 'id' => $cat_id, 248 'data' => $data, 249 'position' => -1 250 ) ); 251 } 252 if ( $parent ) { // Foncy - replace the parent and all its children 253 $parent = get_term($parent, $taxonomy->name); 254 ob_start(); 255 global $post_ID; 256 wp_terms_checklist($post_ID, array('taxonomy' => $taxonomy->name)); 257 $data = ob_get_contents(); 258 ob_end_clean(); 259 $x->add( array( 260 'what' => $taxonomy->name, 261 'id' => $parent->term_id, 262 'old_id' => $parent->term_id, 263 'data' => $data, 264 'position' => -1 265 ) ); 266 267 } 268 $x->send(); 269 die(); 270 } 271 200 272 $id = isset($_POST['id'])? (int) $_POST['id'] : 0; 201 273 switch ( $action = $_POST['action'] ) : 202 274 case 'delete-comment' : // On success, die with time() instead of 1 -
wp-admin/includes/template.php
467 467 468 468 function start_el(&$output, $category, $depth, $args) { 469 469 extract($args); 470 if(empty($taxonomy)) 471 $taxonomy = 'category'; 470 472 473 if($taxonomy == 'category') 474 $name = 'post_category'; 475 else 476 $name = 'tax_input['.$taxonomy.']'; 471 477 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; 472 $output .= "\n<li id=' category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';478 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; 473 479 } 474 480 475 481 function end_el(&$output, $category, $depth, $args) { -
wp-admin/wp-admin.dev.css
1925 1925 1926 1926 /* Categories */ 1927 1927 1928 #category-adder {1928 .category-adder { 1929 1929 margin-left: 120px; 1930 1930 padding: 4px 0; 1931 1931 } 1932 1932 1933 #category-adder h4 {1933 .category-adder h4 { 1934 1934 margin: 0 0 8px; 1935 1935 } 1936 1936 1937 #side-sortables #category-adder {1937 #side-sortables .category-adder { 1938 1938 margin: 0; 1939 1939 } 1940 1940 1941 #post-body #category-add input, #category-add select {1941 #post-body .category-add input, .category-add select { 1942 1942 width: 30%; 1943 1943 } 1944 1944 1945 #side-sortables #category-add input {1945 #side-sortables .category-add input { 1946 1946 width: 94%; 1947 1947 } 1948 1948 1949 #side-sortables #category-add select {1949 #side-sortables .category-add select { 1950 1950 width: 100%; 1951 1951 } 1952 1952 1953 # category-add input#category-add-sumbit {1953 #side-sortables .category-add input.category-add-sumbit, #post-body .category-add input.category-add-sumbit { 1954 1954 width: auto; 1955 1955 } 1956 1956 1957 #post-body ul #category-tabs {1957 #post-body ul.category-tabs { 1958 1958 float: left; 1959 1959 width: 120px; 1960 1960 text-align: right; … … 1963 1963 padding: 0; 1964 1964 } 1965 1965 1966 #post-body ul #category-tabs li {1966 #post-body ul.category-tabs li { 1967 1967 padding: 8px; 1968 1968 } 1969 1969 1970 #post-body ul #category-tabs li.tabs {1970 #post-body ul.category-tabs li.tabs { 1971 1971 -moz-border-radius: 3px 0 0 3px; 1972 1972 -webkit-border-top-left-radius: 3px; 1973 1973 -webkit-border-bottom-left-radius: 3px; … … 1977 1977 border-bottom-left-radius: 3px; 1978 1978 } 1979 1979 1980 #post-body ul #category-tabs li.tabs a {1980 #post-body ul.category-tabs li.tabs a { 1981 1981 font-weight: bold; 1982 1982 text-decoration: none; 1983 1983 } 1984 1984 1985 #categorydiv div.tabs-panel,1985 .categorydiv div.tabs-panel, 1986 1986 #linkcategorydiv div.tabs-panel { 1987 1987 height: 200px; 1988 1988 overflow: auto; … … 1991 1991 border-width: 1px; 1992 1992 } 1993 1993 1994 #post-body #categorydiv div.tabs-panel,1994 #post-body .categorydiv div.tabs-panel, 1995 1995 #post-body #linkcategorydiv div.tabs-panel { 1996 1996 margin: 0 5px 0 125px; 1997 1997 } 1998 1998 1999 #side-sortables #category-tabs li {1999 #side-sortables .category-tabs li { 2000 2000 display: inline; 2001 2001 padding-right: 8px; 2002 2002 } 2003 2003 2004 #side-sortables #category-tabs a {2004 #side-sortables .category-tabs a { 2005 2005 text-decoration: none; 2006 2006 } 2007 2007 2008 #side-sortables #category-tabs {2008 #side-sortables .category-tabs { 2009 2009 margin-bottom: 3px; 2010 2010 } 2011 2011 2012 #categorydiv ul,2012 .categorydiv ul, 2013 2013 #linkcategorydiv ul { 2014 2014 list-style: none; 2015 2015 padding: 0; 2016 2016 margin: 0; 2017 2017 } 2018 2018 2019 #categorydiv ul.categorychecklist ul,2019 .categorydiv ul.categorychecklist ul, 2020 2020 #linkcategorydiv ul.categorychecklist ul { 2021 2021 margin-left: 18px; 2022 2022 } … … 2027 2027 line-height: 19px; 2028 2028 } 2029 2029 2030 #category-adder h4 {2030 .category-adder h4 { 2031 2031 margin-top: 4px; 2032 2032 margin-bottom: 0px; 2033 2033 } 2034 2034 2035 #categorydiv .tabs-panel {2035 .categorydiv .tabs-panel { 2036 2036 border-width: 3px; 2037 2037 border-style: solid; 2038 2038 } 2039 2039 2040 ul #category-tabs {2040 ul.category-tabs { 2041 2041 margin-top: 12px; 2042 2042 } 2043 2043 2044 ul #category-tabs li.tabs {2044 ul.category-tabs li.tabs { 2045 2045 border-style: solid solid none; 2046 2046 border-width: 1px 1px 0; 2047 2047 } 2048 2048 2049 #post-body #category-tabs li.tabs {2049 #post-body .category-tabs li.tabs { 2050 2050 border-style: solid none solid solid; 2051 2051 border-width: 1px 0 1px 1px; 2052 2052 margin-right: -1px; 2053 2053 } 2054 2054 2055 ul #category-tabs li {2055 ul.category-tabs li { 2056 2056 padding: 5px 8px; 2057 2057 -moz-border-radius: 3px 3px 0 0; 2058 2058 -webkit-border-top-left-radius: 3px; -
wp-admin/css/colors-classic.dev.css
105 105 } 106 106 107 107 div.tabs-panel, 108 ul #category-tabs li.tabs {108 ul.category-tabs li.tabs { 109 109 border-color: #dfdfdf; 110 110 } 111 111 112 ul #category-tabs li.tabs {112 ul.category-tabs li.tabs { 113 113 background-color: #f1f1f1; 114 114 } 115 115 … … 384 384 background:#faf9f7 !important; 385 385 } 386 386 387 #side-sortables #category-tabs .tabs a {387 #side-sortables .category-tabs .tabs a { 388 388 color: #333; 389 389 } 390 390 … … 1459 1459 background-color: #f5f5f5; 1460 1460 } 1461 1461 1462 #post-body ul #category-tabs li.tabs a {1462 #post-body ul.category-tabs li.tabs a { 1463 1463 color: #333; 1464 1464 } 1465 1465 -
wp-admin/css/press-this.dev.css
308 308 display: none; 309 309 } 310 310 311 #category-adder {311 .category-adder { 312 312 padding: 4px 0; 313 313 } 314 314 315 #category-adder h4 {315 .category-adder h4 { 316 316 margin: 0 0 8px; 317 317 } 318 318 … … 339 339 } 340 340 341 341 #category-add input, 342 #category-add-sumbit {342 .category-add-sumbit { 343 343 width: auto; 344 344 } 345 345 346 346 /* Categories */ 347 #categorydiv ul,347 .categorydiv ul, 348 348 #linkcategorydiv ul { 349 349 list-style: none; 350 350 padding: 0; 351 351 margin: 0; 352 352 } 353 353 354 #categorydiv ul.categorychecklist ul {354 .categorydiv ul.categorychecklist ul { 355 355 margin-left: 18px; 356 356 } 357 357 358 #categorydiv div.tabs-panel {358 .categorydiv div.tabs-panel { 359 359 height: 140px; 360 360 overflow: auto; 361 361 } -
wp-admin/css/colors-fresh.dev.css
105 105 } 106 106 107 107 div.tabs-panel, 108 ul #category-tabs li.tabs {108 ul.category-tabs li.tabs { 109 109 border-color: #dfdfdf; 110 110 } 111 111 112 ul #category-tabs li.tabs {112 ul.category-tabs li.tabs { 113 113 background-color: #f1f1f1; 114 114 } 115 115 … … 380 380 border-color: #dfdfdf; 381 381 } 382 382 383 #side-sortables #category-tabs .tabs a {383 #side-sortables .category-tabs .tabs a { 384 384 color: #333; 385 385 } 386 386 … … 1454 1454 background-color: #f5f5f5; 1455 1455 } 1456 1456 1457 #post-body ul #category-tabs li.tabs a {1457 #post-body ul.category-tabs li.tabs a { 1458 1458 color: #333; 1459 1459 } 1460 1460 -
wp-admin/rtl.dev.css
298 298 margin-left: 0; 299 299 margin-right: 120px; 300 300 } 301 #post-body ul #category-tabs li.tabs {301 #post-body ul.category-tabs li.tabs { 302 302 -moz-border-radius: 0 3px 3px 0; 303 303 -webkit-border-top-left-radius: 0; 304 304 -webkit-border-top-right-radius: 3px; … … 309 309 border-bottom-left-radius: 0; 310 310 border-bottom-right-radius: 3px; 311 311 } 312 #post-body ul #category-tabs {312 #post-body ul.category-tabs { 313 313 float: right; 314 314 text-align: left; 315 315 margin: 0 0 0 -120px; … … 320 320 } 321 321 /* 1800 - 2000 322 322 =================================== */ 323 #side-sortables #category-tabs li {323 #side-sortables .category-tabs li { 324 324 padding-right: 0; 325 325 padding-left: 8px; 326 326 }