Ticket #1605: dynamo7.diff
| File dynamo7.diff, 3.8 KB (added by mdawaffe, 7 years ago) |
|---|
-
wp-admin/edit-form-ajax-cat.php
12 12 $new_cat_id = func_get_arg(0); 13 13 } 14 14 15 function get_out_now() { exit; } 16 15 17 add_action('edit_category', 'grab_id'); 16 18 add_action('create_category', 'grab_id'); 19 add_action('shutdown', 'get_out_now', -1); 17 20 18 $cat_name = stripslashes($_GET['ajaxnewcat']);21 $cat_name = rawurldecode($_GET['ajaxnewcat']); 19 22 20 23 if ( !$category_nicename = sanitize_title($cat_name) ) 21 24 die('0'); … … 25 28 $cat_name = $wpdb->escape($cat_name); 26 29 $cat_array = compact('cat_name', 'category_nicename'); 27 30 wp_insert_category($cat_array); 28 echo $new_cat_id; 29 ?> 30 No newline at end of file 31 die($new_cat_id); 32 ?> -
wp-admin/admin-header.php
118 118 newcat.id = 'newcat'; 119 119 newcat.size = '16'; 120 120 newcat.setAttribute('autocomplete', 'off'); 121 newcat. setAttribute('onkeypress', 'return ajaxNewCatKeyPress(event);');121 newcat.onkeypress = ajaxNewCatKeyPress; 122 122 123 123 var newcatSub = document.createElement('input'); 124 124 newcatSub.type = 'button'; 125 125 newcatSub.name = 'Button'; 126 126 newcatSub.value = '+'; 127 newcatSub. setAttribute('onclick', 'ajaxNewCat();');127 newcatSub.onclick = ajaxNewCat; 128 128 129 129 ajaxcat.appendChild(newcat); 130 130 ajaxcat.appendChild(newcatSub); … … 160 160 161 161 function newCatCompletion() { 162 162 var p = getResponseElement(); 163 var id = ajaxCat.response;163 var id = parseInt(ajaxCat.response, 10); 164 164 if ( id == '-1' ) { 165 165 p.innerHTML = "You don't have permission to do that."; 166 166 return; … … 172 172 p.parentNode.removeChild(p); 173 173 var exists = document.getElementById('category-' + id); 174 174 if (exists) { 175 var moveIt = exists.parentNode; 176 var container = moveIt.parentNode; 177 container.removeChild(moveIt); 178 container.insertBefore(moveIt, container.firstChild); 179 moveIt.id = 'new-category-' + id; 175 180 exists.checked = 'checked'; 176 exists.parentNode.setAttribute('id', 'new-category-' + id); 177 var nowClass = exists.parentNode.getAttribute('class'); 178 exists.parentNode.setAttribute('class', nowClass + ' fade'); 181 var nowClass = moveIt.className; 182 moveIt.className = nowClass + ' fade'; 179 183 Fat.fade_all(); 180 exists.parentNode.setAttribute('class', nowClass);184 moveIt.className = nowClass; 181 185 } else { 182 186 var catDiv = document.getElementById('categorychecklist'); 183 187 var newLabel = document.createElement('label'); 184 catDiv.insertBefore(newLabel, catDiv.firstChild);185 188 newLabel.setAttribute('for', 'category-' + id); 186 newLabel. setAttribute('id', 'new-category-' + id);187 newLabel. setAttribute('class', 'selectit fade');189 newLabel.id = 'new-category-' + id; 190 newLabel.className = 'selectit fade'; 188 191 189 192 var newCheck = document.createElement('input'); 190 new Label.appendChild(newCheck);193 newCheck.type = 'checkbox'; 191 194 newCheck.value = id; 192 newCheck.type = 'checkbox';193 newCheck.checked = 'checked';194 195 newCheck.name = 'post_category[]'; 195 196 newCheck.id = 'category-' + id; 197 newLabel.appendChild(newCheck); 196 198 197 199 var newLabelText = document.createTextNode(' ' + newcat.value); 198 200 newLabel.appendChild(newLabelText); 201 202 catDiv.insertBefore(newLabel, catDiv.firstChild); 203 newCheck.checked = 'checked'; 204 199 205 Fat.fade_all(); 200 newLabel. setAttribute('class', 'selectit');206 newLabel.className = 'selectit'; 201 207 } 202 208 newcat.value = ''; 203 209 } … … 220 226 221 227 function ajaxNewCat() { 222 228 var newcat = document.getElementById('newcat'); 223 var catString = 'ajaxnewcat=' + newcat.value;229 var catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value); 224 230 ajaxCat.requestFile = 'edit-form-ajax-cat.php'; 225 231 ajaxCat.method = 'GET'; 226 232 ajaxCat.onLoading = newCatLoading;
