Ticket #3130: quickcategories-001.diff
File quickcategories-001.diff, 5.4 KB (added by , 19 years ago) |
---|
-
wp-admin/admin-ajax.php
106 106 } 107 107 die('0'); 108 108 break; 109 case 'add-quickcategory' : // On the Fly 110 if ( !current_user_can( 'manage_categories' ) ) 111 die('-1'); 112 $names = explode(',', $_POST['newcat']); 113 $x = new WP_Ajax_Response(); 114 foreach ( $names as $cat_name ) { 115 $cat_name = trim($cat_name); 116 if ( !$category_nicename = sanitize_title($cat_name) ) 117 die('0'); 118 if ( !$cat_id = category_exists( $cat_name ) ) 119 $cat_id = wp_create_category( $cat_name ); 120 $cat_name = wp_specialchars(stripslashes($cat_name)); 121 $x->add( array( 122 'what' => 'quickcategory', 123 'id' => $cat_id, 124 'data' => "<li id='quickcategory-$cat_id'><span>[<a href='#' onclick='quickCatList.ajaxDelete(\"quickcategory\", \"$cat_id\"); return false;'>x</a>]</span> <b>$cat_name</b></li>" 125 ) ); 126 } 127 $x->send(); 128 break; 129 case 'delete-quickcategory' : 130 if ( !current_user_can( 'manage_categories') ) 131 die('-1'); 132 break; 109 133 case 'add-category' : // On the Fly 110 134 if ( !current_user_can( 'manage_categories' ) ) 111 135 die('-1'); -
wp-admin/wp-admin.css
1073 1073 background-position: 0 -28px; 1074 1074 } 1075 1075 1076 #moremeta h4 { 1077 margin: 0; 1078 background: #eee; 1079 position: relative; 1080 left: -5px; 1081 width: 182px; 1082 text-indent: 10px; 1083 color: #444; 1084 display: none; 1085 } 1086 1076 1087 #categorychecklist { 1077 1088 margin-right: 6px; 1078 1089 } 1079 1090 1091 #categorylist { 1092 font-size: 10px; 1093 color: #333; 1094 list-style: none; 1095 } 1096 1097 #categorylist a { 1098 color: #f00; 1099 border-bottom: 0; 1100 } 1101 1102 #categorylist b { 1103 color: #000; 1104 } 1105 1106 #categorylist span { 1107 display: block; 1108 position: absolute; 1109 left: -15px; 1110 color: #888; 1111 } 1112 1113 #categorylist li { 1114 left: -20px; 1115 position: relative; 1116 width: 155px; 1117 } 1118 1080 1119 /* additional clone styles */ 1081 1120 .dbx-clone { 1082 1121 opacity: 0.8; -
wp-admin/edit-form-advanced.php
71 71 <div id="moremeta"> 72 72 <div id="grabit" class="dbx-group"> 73 73 74 <fieldset id=" categorydiv" class="dbx-box">75 <h3 class="dbx-handle"><?php _e(' Categories') ?></h3>74 <fieldset id="quickcategorydiv" class="dbx-box" style="display: none;"> 75 <h3 class="dbx-handle"><?php _e('Quick Categories') ?></h3> 76 76 <div class="dbx-content"> 77 77 <p id="jaxcat"></p> 78 <ul id="categorychecklist"><?php dropdown_categories(get_option('default_category')); ?></ul></div> 78 <h4>Assigned categories</h4> 79 <ul id="categorylist"> 80 81 </ul> 82 <!-- 83 <li id="quickcategory-1"><span>[<a href="#">x</a>]</span> <b>Category name</b></li> 84 <li id="quickcategory-2"><span>[<a href="#">x</a>]</span> Parent » <b>Child</b></li> 85 <li id="quickcategory-3"><span>[<a href="#">x</a>]</span> Another Category » With » <b>a grandchild</b></li> 86 --> 87 </div> 79 88 </fieldset> 89 <script type="text/javascript"> 90 <!-- 91 document.getElementByID('quickcategorydiv').style.display = 'auto'; 92 //--> 93 </script> 80 94 95 <fieldset id="categorydiv" class="dbx-box"> 96 <h3 class="dbx-handle"><?php _e('Category Tree') ?></h3> 97 <div class="dbx-content"> 98 <ul id="categorychecklist"><?php dropdown_categories(get_option('default_category')); ?></ul> 99 </div> 100 </fieldset> 101 81 102 <fieldset id="commentstatusdiv" class="dbx-box"> 82 103 <h3 class="dbx-handle"><?php _e('Discussion') ?></h3> 83 104 <div class="dbx-content"> -
wp-admin/cat-js.php
2 2 require_once('../wp-config.php'); 3 3 cache_javascript_headers(); 4 4 ?> 5 addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;}); 5 addLoadEvent(function(){quickCatList=new listMan('categorylist');quickCatList.ajaxRespEl='jaxcat';quickCatList.topAdder=1;quickCatList.alt=0;quickCatList.showLink=0;}); 6 addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=0;catList.alt=0;catList.showLink=0;}); 6 7 addLoadEvent(newCatAddIn); 7 8 function newCatAddIn() { 8 9 var jaxcat = $('jaxcat'); 9 10 if ( !jaxcat ) 10 11 return false; 11 12 jaxcat.update('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="<?php _e('Add'); ?>"/><span id="howto"><?php _e('Separate multiple categories with commas.'); ?></span></span>'); 12 $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); }; 13 $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); }; 14 } 13 14 /* 15 killSubmit("catList.ajaxAdder('category','jaxcat');", e); 16 catList.ajaxAdder('category', 'jaxcat'); 17 18 I'm having problems sending both ajaxAdder() calls. The first one works, but the second has an error. 19 I think it is because the first one is "taking" the input field and blanking it and the second one gets 20 blank data. No idea how to fix it. 21 */ 22 $('newcat').onkeypress = function(e) { return killSubmit("quickCatList.ajaxAdder('quickcategory','jaxcat');", e); }; 23 $('catadd').onclick = function() { quickCatList.ajaxAdder('quickcategory', 'jaxcat'); }; 24 } 25 No newline at end of file