Ticket #2561: 2561j.diff
| File 2561j.diff, 59.8 KB (added by , 20 years ago) |
|---|
-
wp-includes/functions-formatting.php
101 101 $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text);- 102 102 $text = str_replace('<', '<', $text); 103 103 $text = str_replace('>', '>', $text); 104 if ( $quotes ) {104 if ( 'double' === $quotes ) { 105 105 $text = str_replace('"', '"', $text); 106 } elseif ( $quotes ) { 107 $text = str_replace('"', '"', $text); 106 108 $text = str_replace("'", ''', $text); 107 109 } 108 110 return $text; -
wp-includes/js/fat.js
11 11 b = b.toString(16); if (b.length == 1) b = '0' + b; 12 12 return "#" + r + g + b; 13 13 }, 14 fade_all : function ( )14 fade_all : function (dur) 15 15 { 16 16 var a = document.getElementsByTagName("*"); 17 17 for (var i = 0; i < a.length; i++) … … 21 21 if (r) 22 22 { 23 23 if (!r[1]) r[1] = ""; 24 if (o.id) Fat.fade_element(o.id,null, null,"#"+r[1]);24 if (o.id) Fat.fade_element(o.id,null,dur,"#"+r[1]); 25 25 } 26 26 } 27 27 }, … … 87 87 88 88 addLoadEvent(function () { 89 89 Fat.fade_all(); 90 }); 91 No newline at end of file 90 }); -
wp-includes/pluggable-functions.php
237 237 } 238 238 endif; 239 239 240 if ( !function_exists('check_ajax_referer') ) : 241 function check_ajax_referer() { 242 $cookie = explode(';', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie 243 foreach ( $cookie as $tasty ) { 244 if ( false !== strpos($tasty, USER_COOKIE) ) 245 $user = substr(strstr($tasty, '='), 1); 246 if ( false !== strpos($tasty, PASS_COOKIE) ) 247 $pass = substr(strstr($tasty, '='), 1); 248 } 249 if ( !wp_login( $user, $pass, true ) ) 250 die('-1'); 251 do_action('check_ajax_referer'); 252 } 253 endif; 254 240 255 // Cookie safe redirect. Works around IIS Set-Cookie bug. 241 256 // http://support.microsoft.com/kb/q176113/ 242 257 if ( !function_exists('wp_redirect') ) : -
wp-admin/custom-fields.js
1 addLoadEvent(customFieldsAddIn); 2 function customFieldsAddIn() { 3 if (!theList.theList) return false; 4 inputs = theList.theList.getElementsByTagName('input'); 5 for ( var i=0; i < inputs.length; i++ ) { 6 if ('text' == inputs[i].type) { 7 inputs[i].setAttribute('autocomplete', 'off'); 8 inputs[i].onkeypress = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.name.slice(5),10) + '");', e); }; 9 } 10 if ('updatemeta' == inputs[i].className) { 11 inputs[i].onclick = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.parentNode.parentNode.id.slice(5),10) + '");', e); }; 12 } 13 } 14 15 document.getElementById('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta", customFieldsOnComplete);', e); }; 16 document.getElementById('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta", customFieldsOnComplete);', e); }; 17 theList.clearInputs.push('metakeyselect','metakeyinput','metavalue'); 18 } 19 function customFieldsOnComplete() { 20 var pidEl = document.getElementById('post_ID'); 21 pidEl.name = 'post_ID'; 22 pidEl.value = getNodeValue(theList.ajaxAdd.responseXML, 'postid'); 23 var aEl = document.getElementById('hiddenaction') 24 if ( aEl.value == 'post' ) aEl.value = 'postajaxpost'; 25 } -
wp-admin/edit-comments.php
133 133 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p> 134 134 </li> 135 135 136 <?php } // end foreach ?>136 <?php } // end foreach($comment) ?> 137 137 </ol> 138 138 139 139 <div id="ajax-response"></div> 140 140 141 141 <?php 142 } else { 142 } else { //no comments to show 143 143 144 144 ?> 145 145 <p> … … 162 162 </tr>'; 163 163 foreach ($comments as $comment) { 164 164 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 165 $comment_status = wp_get_comment_status($comment->comment_ID); 165 166 $class = ('alternate' == $class) ? '' : 'alternate'; 167 $class .= ('unapproved' == $comment_status) ? ' unapproved' : ''; 166 168 ?> 167 <tr class='<?php echo $class; ?>'>169 <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'> 168 170 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td> 169 171 <td><?php comment_author_link() ?></td> 170 172 <td><?php comment_author_email_link() ?></td> 171 173 <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td> 172 174 <td><?php comment_excerpt(); ?></td> 173 <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td> 175 <td> 176 <?php if ('unapproved' == $comment_status) { ?> 177 (Unapproved) 178 <?php } else { ?> 179 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a> 180 <?php } ?> 181 </td> 174 182 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 175 183 echo "<a href='comment.php?action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> 176 184 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 177 echo "<a href=\"comment.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\" class='delete'>" . __('Delete') . "</a>"; } ?></td> 185 echo "<a href=\"comment.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars( $comment->comment_author, 1 )) . "' );\" class='edit'>" . __('Delete') . "</a> "; 186 } ?></td> 178 187 </tr> 179 188 <?php 180 189 } // end foreach … … 183 192 <p class="submit"><input type="submit" name="delete_button" value="<?php _e('Delete Checked Comments »') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php _e("Please select some comments to delete"); ?>'); return false } return confirm('<?php printf(__("You are about to delete %s comments permanently \\n \'Cancel\' to stop, \'OK\' to delete."), "' + numchecked + '"); ?>')" /> 184 193 <input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam »') ?>" onclick="return confirm('<?php _e("You are about to mark these comments as spam \\n \'Cancel\' to stop, \'OK\' to mark as spam.") ?>')" /></p> 185 194 </form> 195 <div id="ajax-response"></div> 186 196 <?php 187 197 } else { 188 198 ?> -
wp-admin/admin-ajax.php
1 <?php 2 require_once('../wp-config.php'); 3 require_once('admin-functions.php'); 4 require_once('admin-db.php'); 5 6 define('DOING_AJAX', true); 7 8 9 check_ajax_referer(); 10 if ( !is_user_logged_in() ) 11 die('-1'); 12 13 function get_out_now() { exit; } 14 add_action( 'shutdown', 'get_out_now', -1 ); 15 16 function wp_clean_ajax_input( $i ) { 17 global $wpdb; 18 $i = is_array($i) ? array_map('wp_clean_ajax_input', $i) : $wpdb->escape( rawurldecode(stripslashes($i)) ); 19 return $i; 20 } 21 22 function wp_ajax_echo_meta( $pid, $mid, $key, $value ) { 23 $value = wp_specialchars($value, true); 24 $key_js = addslashes(wp_specialchars($key, 'double')); 25 $key = wp_specialchars($key, true); 26 $r = "<meta><id>$mid</id><postid>$pid</postid><newitem><![CDATA[<table><tbody>"; 27 $r .= "<tr id='meta-$mid'><td valign='top'>"; 28 $r .= "<input name='meta[$mid][key]' tabindex='6' onkeypress='return killSubmit(\"theList.ajaxUpdater('meta','meta-$mid');\",event);' type='text' size='20' value='$key' />"; 29 $r .= "</td><td><textarea name='meta[$mid][value]' tabindex='6' rows='2' cols='30'>$value</textarea></td><td align='center'>"; 30 $r .= "<input name='updatemeta' type='button' class='updatemeta' tabindex='6' value='Update' onclick='return theList.ajaxUpdater('meta','meta-$mid');' /><br />"; 31 $r .= "<input name='deletemeta[$mid]' type='submit' onclick=\"return deleteSomething( 'meta', $mid, '"; 32 $r .= sprintf(__("You are about to delete the "%s" custom field on this post.\\n"OK" to delete, "Cancel" to stop."), $key_js); 33 $r .= "' );\" class='deletemeta' tabindex='6' value='Delete' />"; 34 $r .= "</td></tr></tbody></table>]]></newitem></meta>"; 35 return $r; 36 } 37 38 $_POST = wp_clean_ajax_input( $_POST ); 39 $id = (int) $_POST['id']; 40 switch ( $_POST['action'] ) : 41 case 'delete-comment' : 42 if ( !$comment = get_comment( $id ) ) 43 die('0'); 44 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 45 die('-1'); 46 47 if ( wp_delete_comment( $comment->comment_ID ) ) 48 die('1'); 49 else die('0'); 50 break; 51 case 'delete-comment-as-spam' : 52 if ( !$comment = get_comment( $id ) ) 53 die('0'); 54 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 55 die('-1'); 56 57 if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) ) 58 die('1'); 59 else die('0'); 60 break; 61 case 'delete-cat' : 62 if ( !current_user_can( 'manage_categories' ) ) 63 die('-1'); 64 65 if ( wp_delete_category( $id ) ) 66 die('1'); 67 else die('0'); 68 break; 69 case 'delete-link' : 70 if ( !current_user_can( 'manage_links' ) ) 71 die('-1'); 72 73 if ( wp_delete_link( $id ) ) 74 die('1'); 75 else die('0'); 76 break; 77 case 'delete-meta' : 78 if ( !$meta = get_post_meta_by_id( $id ) ) 79 die('0'); 80 if ( !current_user_can( 'edit_post', $meta->post_id ) ) 81 die('-1'); 82 if ( delete_meta( $meta->meta_id ) ) 83 die('1'); 84 die('0'); 85 break; 86 case 'delete-post' : 87 if ( !current_user_can( 'delete_post', $id ) ) 88 die('-1'); 89 90 if ( wp_delete_post( $id ) ) 91 die('1'); 92 else die('0'); 93 break; 94 case 'delete-page' : 95 if ( !current_user_can( 'delete_page', $id ) ) 96 die('-1'); 97 98 if ( wp_delete_post( $id ) ) 99 die('1'); 100 else die('0'); 101 break; 102 case 'dim-comment' : 103 if ( !$comment = get_comment( $id ) ) 104 die('0'); 105 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 106 die('-1'); 107 if ( !current_user_can( 'moderate_comments' ) ) 108 die('-1'); 109 110 if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) { 111 if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) 112 die('1'); 113 } else { 114 if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) 115 die('1'); 116 } 117 die('0'); 118 break; 119 case 'add-category' : // On the Fly 120 if ( !current_user_can( 'manage_categories' ) ) 121 die('-1'); 122 $names = explode(',', $_POST['newcat']); 123 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 124 foreach ( $names as $cat_name ) { 125 $cat_name = trim($cat_name); 126 if ( !$category_nicename = sanitize_title($cat_name) ) 127 die('0'); 128 if ( !$cat_id = category_exists( $cat_name ) ) 129 $cat_id = wp_create_category( $cat_name ); 130 $cat_name = wp_specialchars(stripslashes($cat_name)); 131 $r .= "<category><id>$cat_id</id><newitem><![CDATA["; 132 $r .= "<li id='category-$cat_id'><label for='in-category-$cat_id' class='selectit'>"; 133 $r .= "<input value='$cat_id' type='checkbox' checked='checked' name='post_category[]' id='in-category-$cat_id'/> $cat_name</label></li>"; 134 $r .= "]]></newitem></category>"; 135 } 136 $r .= '</ajaxresponse>'; 137 header('Content-type: text/xml'); 138 die($r); 139 break; 140 case 'add-cat' : // From Manage->Categories 141 if ( !current_user_can( 'manage_categories' ) ) 142 die('-1'); 143 if ( !$cat = wp_insert_category( $_POST ) ) 144 die('0'); 145 if ( !$cat = get_category( $cat ) ) 146 die('0'); 147 $pad = 0; 148 $_cat = $cat; 149 while ( $_cat->category_parent ) { 150 $_cat = get_category( $_cat->category_parent ); 151 $pad++; 152 } 153 $pad = str_repeat('— ', $pad); 154 155 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 156 $r .= "<cat><id>$cat->cat_ID</id><newitem><![CDATA[<table><tbody>"; 157 $r .= "<tr id='cat-$cat->cat_ID'><th scope='row'>$cat->cat_ID</th><td>$pad $cat->cat_name</td>"; 158 $r .= "<td>$cat->category_description</td><td>$cat->category_count</td><td>$cat->link_count</td>"; 159 $r .= "<td><a href='categories.php?action=edit&cat_ID=$cat->cat_ID' class='edit'>" . __('Edit') . "</a></td>"; 160 $r .= "<td><a href='categories.php?action=delete&cat_ID=$cat->cat_ID' onclick='return deleteSomething( \"cat\", $cat->cat_ID, \""; 161 $r .= sprintf(__('You are about to delete the category \"%s\". All of its posts and bookmarks will go to the default categories.\\n\"OK\" to delete, \"Cancel\" to stop.'), addslashes($cat->cat_name)); 162 $r .= "\" );' class='delete'>".__('Delete')."</a></td></tr>"; 163 $r .= "</tbody></table>]]></newitem></cat></ajaxresponse>"; 164 header('Content-type: text/xml'); 165 die($r); 166 167 break; 168 case 'add-meta' : 169 if ( !current_user_can( 'edit_post', $id ) ) 170 die('-1'); 171 if ( $id < 0 ) { 172 if ( $pid = write_post() ) 173 $meta = has_meta( $pid ); 174 else 175 die('0'); 176 $key = $meta[0]['meta_key']; 177 $value = $meta[0]['meta_value']; 178 $mid = (int) $meta[0]['meta_id']; 179 } else { 180 if ( $mid = add_meta( $id ) ) 181 $meta = get_post_meta_by_id( $mid ); 182 else 183 die('0'); 184 $key = $meta->meta_key; 185 $value = $meta->meta_value; 186 $pid = (int) $meta->post_id; 187 } 188 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 189 $r .= wp_ajax_echo_meta( $pid, $mid, $key, $value ); 190 $r .= '</ajaxresponse>'; 191 header('Content-type: text/xml'); 192 die($r); 193 break; 194 case 'update-meta' : 195 $mid = (int) array_pop(array_keys($_POST['meta'])); 196 $key = $_POST['meta'][$mid]['key']; 197 $value = $_POST['meta'][$mid]['value']; 198 if ( !$meta = get_post_meta_by_id( $mid ) ) 199 die('0'); 200 if ( !current_user_can( 'edit_post', $meta->post_id ) ) 201 die('-1'); 202 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 203 if ( $u = update_meta( $mid, $key, $value ) ) { 204 $key = stripslashes($key); 205 $value = stripslashes($value); 206 $r .= wp_ajax_echo_meta( $meta->post_id, $mid, $key, $value ); 207 } 208 $r .= '</ajaxresponse>'; 209 header('Content-type: text/xml'); 210 die($r); 211 break; 212 default : 213 die('0'); 214 break; 215 endswitch; 216 ?> -
wp-admin/list-manipulation.php
1 <?php2 require_once('../wp-config.php');3 require_once('admin-functions.php');4 require_once('admin-db.php');5 6 if ( !is_user_logged_in() )7 die('-1');8 9 function get_out_now() { exit; }10 add_action( 'shutdown', 'get_out_now', -1 );11 12 // check_admin_referer();13 14 $id = (int) $_POST['id'];15 switch ( $_POST['action'] ) :16 case 'delete-link' :17 if ( !current_user_can( 'manage_links' ) )18 die('-1');19 20 if ( wp_delete_link( $id ) )21 die('1');22 else die('0');23 break;24 case 'delete-post' :25 if ( !current_user_can( 'delete_post', $id ) )26 die('-1');27 28 if ( wp_delete_post( $id ) )29 die('1');30 else die('0');31 break;32 case 'delete-page' :33 if ( !current_user_can( 'delete_page', $id ) )34 die('-1');35 36 if ( wp_delete_post( $id ) )37 die('1');38 else die('0');39 break;40 case 'delete-cat' :41 if ( !current_user_can( 'manage_categories' ) )42 die('-1');43 44 if ( wp_delete_category( $id ) )45 die('1');46 else die('0');47 break;48 case 'delete-comment' :49 if ( !$comment = get_comment( $id ) )50 die('0');51 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )52 die('-1');53 54 if ( wp_delete_comment( $comment->comment_ID ) )55 die('1');56 else die('0');57 break;58 case 'delete-comment-as-spam' :59 if ( !$comment = get_comment( $id ) )60 die('0');61 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )62 die('-1');63 64 if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) )65 die('1');66 else die('0');67 break;68 endswitch;69 ?> -
wp-admin/edit-form-ajax-cat.php
1 <?php2 require_once('../wp-config.php');3 require_once('admin-functions.php');4 require_once('admin-db.php');5 6 if ( !current_user_can('manage_categories') )7 die('-1');8 9 function get_out_now() { exit; }10 11 add_action('shutdown', 'get_out_now', -1);12 13 $names = explode(',', rawurldecode($_GET['ajaxnewcat']) );14 $ids = array();15 16 foreach ($names as $cat_name) {17 $cat_name = trim( $cat_name );18 19 if ( !$category_nicename = sanitize_title($cat_name) )20 continue;21 if ( $already = category_exists($cat_name) ) {22 $ids[] = (string) $already;23 continue;24 }25 26 $new_cat_id = wp_create_category($cat_name);27 28 $ids[] = (string) $new_cat_id;29 }30 31 $return = join(',', $ids);32 33 die( (string) $return );34 35 ?>36 No newline at end of file -
wp-admin/wp-admin.css
91 91 padding: .1em .3em; 92 92 } 93 93 94 fieldset span.cat-nest {95 display: block;96 margin-left: 10px;97 }98 99 94 fieldset.options { 100 95 padding: 1em; 101 96 } … … 326 321 color: #009ef0; 327 322 } 328 323 324 .approve { 325 display: none; 326 } 327 328 .unapproved .approve { 329 display: inline; 330 } 331 332 .unapproved .unapprove { 333 display: none; 334 } 335 329 336 .updated { 330 337 background: #CFEBF7 url(images/notice.gif) no-repeat 1em ; 331 338 border: 1px solid #2580B2; … … 804 811 margin-top: .5em; 805 812 } 806 813 807 #categorydiv div div { 814 #categorydiv ul { 815 list-style: none; 816 padding: 0; 817 margin-left:10px; 818 } 819 #categorychecklist { 808 820 height: 12em; 809 821 overflow: auto; 822 margin-top: 8px; 810 823 } 811 824 #categorychecklist li { 825 margin: 0; 826 padding: 0; 827 } 812 828 #ajaxcat input { 813 829 border: 1px solid #ccc; 814 830 } … … 951 967 #jaxcat { 952 968 margin: 0; 953 969 padding: 0; 954 } 955 No newline at end of file 970 } -
wp-admin/post.php
17 17 } 18 18 } 19 19 } 20 21 20 if (isset($_POST['deletepost'])) 22 21 $action = "delete"; 23 22 24 23 switch($action) { 24 case 'postajaxpost': 25 25 case 'post': 26 26 check_admin_referer(); 27 27 28 $post_ID = write_post();28 $post_ID = 'post' == $action ? write_post() : edit_post(); 29 29 30 30 // Redirect. 31 31 if (!empty($_POST['mode'])) { -
wp-admin/admin.php
40 40 } 41 41 } 42 42 43 $xfn_js = $sack_js = $list_js = $cat_js = $dbx_js = $ editing = false;43 $xfn_js = $sack_js = $list_js = $cat_js = $dbx_js = $pmeta_js = $editing = false; 44 44 45 45 require(ABSPATH . '/wp-admin/menu.php'); 46 46 -
wp-admin/admin-functions.php
602 602 603 603 function write_nested_categories($categories) { 604 604 foreach ($categories as $category) { 605 echo '<l abel for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n";605 echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n"; 606 606 607 if ( isset ($category['children'])) {608 echo " \n<span class='cat-nest'>\n";607 if ( $category['children'] ) { 608 echo "<ul>\n"; 609 609 write_nested_categories($category['children']); 610 echo "</ span>\n";610 echo "</ul>\n"; 611 611 } 612 612 } 613 613 } … … 626 626 if ($categories) { 627 627 foreach ($categories as $category) { 628 628 if ($category->category_parent == $parent) { 629 $category->cat_name = wp_specialchars($category->cat_name );629 $category->cat_name = wp_specialchars($category->cat_name,'double'); 630 630 $pad = str_repeat('— ', $level); 631 631 if ( current_user_can('manage_categories') ) { 632 632 $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>"; … … 634 634 $default_link_cat_id = get_option('default_link_category'); 635 635 636 636 if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) ) 637 $edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts and bookmarks will go to the default categories.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>";637 $edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts and bookmarks will go to the default categories.\\n"OK" to delete, "Cancel" to stop."), addslashes($category->cat_name))."' );\" class='delete'>".__('Delete')."</a>"; 638 638 else 639 639 $edit .= "<td style='text-align:center'>".__("Default"); 640 640 } … … 684 684 <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td> 685 685 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 686 686 <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> 687 <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>687 <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> 688 688 </tr> 689 689 690 690 <?php … … 828 828 function list_meta($meta) { 829 829 global $post_ID; 830 830 // Exit if no meta 831 if (!$meta) 831 if (!$meta) { 832 echo '<tbody id="the-list"></tbody>'; //TBODY needed for list-manipulation JS 832 833 return; 834 } 833 835 $count = 0; 834 836 ?> 835 <table id='meta-list' cellpadding="3">837 <thead> 836 838 <tr> 837 839 <th><?php _e('Key') ?></th> 838 840 <th><?php _e('Value') ?></th> 839 841 <th colspan='2'><?php _e('Action') ?></th> 840 842 </tr> 843 </thead> 841 844 <?php 842 843 845 $r ="\n\t<tbody id='the-list'>"; 844 846 foreach ($meta as $entry) { 845 847 ++ $count; 846 848 if ($count % 2) … … 849 851 $style = ''; 850 852 if ('_' == $entry['meta_key'] { 0 }) 851 853 $style .= ' hidden'; 852 echo " 853 <tr class='$style'> 854 <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td> 855 <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td> 856 <td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br /> 857 <input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td> 858 </tr> 859 "; 854 $key_js = addslashes(wp_specialchars( $entry['meta_key'], 'double' )); 855 $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true ); 856 $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true ); 857 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; 858 $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>"; 859 $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; 860 $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />"; 861 $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '"; 862 $r .= sprintf(__("You are about to delete the "%s" custom field on this post.\\n"OK" to delete, "Cancel" to stop."), $key_js); 863 $r .= "' );\" class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>"; 864 $r .= "\n\t</tr>"; 860 865 } 861 echo " 862 </table> 863 "; 866 echo $r; 867 echo "\n\t</tbody>"; 864 868 } 865 869 866 870 // Get a list of previously defined keys … … 886 890 LIMIT 10"); 887 891 ?> 888 892 <h3><?php _e('Add a new custom field:') ?></h3> 889 <table cellspacing="3" cellpadding="3">893 <table id="newmeta" cellspacing="3" cellpadding="3"> 890 894 <tr> 891 895 <th colspan="2"><?php _e('Key') ?></th> 892 896 <th><?php _e('Value') ?></th> … … 910 914 </tr> 911 915 912 916 </table> 913 <p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p>917 <p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> 914 918 <?php 915 919 916 920 } 917 921 918 922 function add_meta($post_ID) { 919 923 global $wpdb; 924 $post_ID = (int) $post_ID; 920 925 921 926 $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect']))); 922 927 $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput']))); … … 926 931 // We have a key/value pair. If both the select and the 927 932 // input for the key have data, the input takes precedence: 928 933 929 if ('#NONE#' != $metakeyselect)934 if ('#NONE#' != $metakeyselect) 930 935 $metakey = $metakeyselect; 931 936 932 937 if ($metakeyinput) … … 937 942 (post_id,meta_key,meta_value) 938 943 VALUES ('$post_ID','$metakey','$metavalue') 939 944 "); 945 return $wpdb->insert_id; 940 946 } 947 return false; 941 948 } // add_meta 942 949 943 950 function delete_meta($mid) { 944 951 global $wpdb; 952 $mid = (int) $mid; 945 953 946 $result =$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");954 return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); 947 955 } 948 956 949 957 function update_meta($mid, $mkey, $mvalue) { 950 958 global $wpdb; 959 $mid = (int) $mid; 951 960 952 961 return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'"); 953 962 } 954 963 964 function get_post_meta_by_id($mid) { 965 global $wpdb; 966 $mid = (int) $mid; 967 968 return $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'"); 969 } 970 955 971 function touch_time($edit = 1, $for_post = 1) { 956 972 global $month, $post, $comment; 957 973 -
wp-admin/edit-page-form.php
6 6 if (0 == $post_ID) { 7 7 $form_action = 'post'; 8 8 $temp_ID = -1 * time(); 9 $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";9 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />"; 10 10 } else { 11 11 $form_action = 'editpost'; 12 $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";12 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />"; 13 13 } 14 14 15 15 $sendto = $_SERVER['HTTP_REFERER']; … … 209 209 <fieldset id="postcustom" class="dbx-box"> 210 210 <h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3> 211 211 <div id="postcustomstuff" class="dbx-content"> 212 <table cellpadding="3"> 212 213 <?php 213 if($metadata = has_meta($post_ID)) { 214 $metadata = has_meta($post_ID); 215 list_meta($metadata); 214 216 ?> 217 218 </table> 215 219 <?php 216 list_meta($metadata);217 ?>218 <?php219 }220 220 meta_form(); 221 221 ?> 222 222 </div> -
wp-admin/admin-db.php
174 174 $parent = $category->category_parent; 175 175 176 176 // Delete the category. 177 $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); 177 if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") ) 178 return 0; 178 179 179 180 // Update children to point to new parent. 180 181 $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); -
wp-admin/edit-form-advanced.php
21 21 if (0 == $post_ID) { 22 22 $form_action = 'post'; 23 23 $temp_ID = -1 * time(); 24 $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";24 $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />"; 25 25 } else { 26 26 $form_action = 'editpost'; 27 $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";27 $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />"; 28 28 } 29 29 30 30 $form_pingback = '<input type="hidden" name="post_pingback" value="' . get_option('default_pingback_flag') . '" id="post_pingback" />'; … … 49 49 ?> 50 50 51 51 <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" /> 52 <input type="hidden" name="action" value="<?php echo $form_action ?>" />52 <input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" /> 53 53 <input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" /> 54 54 <input type="hidden" name="post_type" value="post" /> 55 55 … … 72 72 <h3 class="dbx-handle"><?php _e('Categories') ?></h3> 73 73 <div class="dbx-content"> 74 74 <p id="jaxcat"></p> 75 < div id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></div></div>75 <ul id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></ul></div> 76 76 </fieldset> 77 77 78 78 <fieldset id="commentstatusdiv" class="dbx-box"> … … 248 248 <fieldset id="postcustom" class="dbx-box"> 249 249 <h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3> 250 250 <div id="postcustomstuff" class="dbx-content"> 251 <?php 252 if($metadata = has_meta($post_ID)) { 253 ?> 251 <table cellpadding="3"> 254 252 <?php 255 list_meta($metadata); 253 $metadata = has_meta($post_ID); 254 list_meta($metadata); 256 255 ?> 256 257 </table> 257 258 <?php 258 }259 259 meta_form(); 260 260 ?> 261 <div id="ajax-response"></div> 261 262 </div> 262 263 </fieldset> 263 264 -
wp-admin/categories.js
1 addLoadEvent(newCategoryAddIn); 2 function newCategoryAddIn() { 3 if (!theList.theList) return false; 4 document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; 5 theList.clearInputs.push('cat_name','category_parent','category_description'); 6 } -
wp-admin/admin-header.php
3 3 if (!isset($_GET["page"])) require_once('admin.php'); 4 4 if ( $editing ) { 5 5 $dbx_js = true; 6 if ( current_user_can('manage_categories') ) 6 $pmeta_js = true; 7 if ( current_user_can('manage_categories') ) { 8 $list_js = true; 7 9 $cat_js = true; 10 } 8 11 } 9 if ( $list_js || $cat_js)12 if ( $list_js ) 10 13 $sack_js = true; 11 14 ?> 12 15 <?php get_admin_page_title(); ?> … … 29 32 <script type="text/javascript" src="../wp-includes/js/tw-sack.js"></script> 30 33 <?php } ?> 31 34 <?php if ( $list_js ) { ?> 32 <script type="text/javascript" src="list-manipulation .js"></script>35 <script type="text/javascript" src="list-manipulation-js.php"></script> 33 36 <?php } ?> 37 <?php if ( $pmeta_js ) { ?> 38 <script type="text/javascript" src="custom-fields.js"></script> 39 <?php } ?> 40 <?php if ( 'categories.php' == $pagenow && 'edit' != $action ) { ?> 41 <script type="text/javascript" src="categories.js"></script> 42 <?php } ?> 34 43 <?php if ( $dbx_js ) { ?> 35 44 <script type="text/javascript" src="../wp-includes/js/dbx.js"></script> 36 45 <script type="text/javascript"> -
wp-admin/cat-js.php
2 2 require_once('../wp-config.php'); 3 3 header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true); 4 4 ?> 5 var ajaxCat = new sack(); 6 var newcat; 7 5 addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.clearInputs.push('newcat');}); 6 addLoadEvent(newCatAddIn); 8 7 function newCatAddIn() { 9 8 if ( !document.getElementById('jaxcat') ) return false; 10 9 var ajaxcat = document.createElement('span'); … … 16 15 newcat.id = 'newcat'; 17 16 newcat.size = '16'; 18 17 newcat.setAttribute('autocomplete', 'off'); 19 newcat.onkeypress = ajaxNewCatKeyPress;18 newcat.onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','categorydiv');", e); }; 20 19 21 20 var newcatSub = document.createElement('input'); 22 21 newcatSub.type = 'button'; 23 22 newcatSub.name = 'Button'; 24 23 newcatSub.id = 'catadd'; 25 newcatSub.value = ' <?php echo addslashes(__('Add')); ?>';26 newcatSub.onclick = ajaxNewCat;24 newcatSub.value = 'Add'; 25 newcatSub.onclick = function() { catList.ajaxAdder('category', 'categorydiv'); }; 27 26 28 27 ajaxcat.appendChild(newcat); 29 28 ajaxcat.appendChild(newcatSub); 30 29 document.getElementById('jaxcat').appendChild(ajaxcat); 31 30 32 31 howto = document.createElement('span'); 33 howto.innerHTML = '<?php echo addslashes(__('Separate multiple categories with commas.')); ?>';32 howto.innerHTML = "<?php _e('Separate multiple categories with commas.'); ?>"; 34 33 howto.id = 'howto'; 35 34 ajaxcat.appendChild(howto); 36 35 } 37 38 addLoadEvent(newCatAddIn);39 40 function getResponseElement() {41 var p = document.getElementById('ajaxcatresponse');42 if (!p) {43 p = document.createElement('span');44 document.getElementById('jaxcat').appendChild(p);45 p.id = 'ajaxcatresponse';46 }47 return p;48 }49 50 function newCatLoading() {51 var p = getResponseElement();52 p.innerHTML = '<?php echo addslashes(__('Sending Data...')); ?>';53 }54 55 function newCatLoaded() {56 var p = getResponseElement();57 p.innerHTML = '<?php echo addslashes(__('Data Sent...')); ?>';58 }59 60 function newCatInteractive() {61 var p = getResponseElement();62 p.innerHTML = '<?php echo addslashes(__('Processing Request...')); ?>';63 }64 65 function newCatCompletion() {66 var p = getResponseElement();67 var id = 0;68 var ids = new Array();69 var names = new Array();70 71 ids = myPload( ajaxCat.response );72 names = myPload( newcat.value );73 for ( i = 0; i < ids.length; i++ ) {74 id = ids[i].replace(/[\n\r]+/g, "");75 if ( id == '-1' ) {76 p.innerHTML = "<?php echo addslashes(__("You don't have permission to do that.")); ?>";77 return;78 }79 if ( id == '0' ) {80 p.innerHTML = "<?php echo addslashes(__('That category name is invalid. Try something else.')); ?>";81 return;82 }83 84 var exists = document.getElementById('category-' + id);85 86 if (exists) {87 var moveIt = exists.parentNode;88 var container = moveIt.parentNode;89 container.removeChild(moveIt);90 container.insertBefore(moveIt, container.firstChild);91 moveIt.id = 'new-category-' + id;92 exists.checked = 'checked';93 var nowClass = moveIt.className;94 moveIt.className = nowClass + ' fade';95 Fat.fade_all();96 moveIt.className = nowClass;97 } else {98 var catDiv = document.getElementById('categorychecklist');99 var newLabel = document.createElement('label');100 newLabel.setAttribute('for', 'category-' + id);101 newLabel.id = 'new-category-' + id;102 newLabel.className = 'selectit fade';103 104 var newCheck = document.createElement('input');105 newCheck.type = 'checkbox';106 newCheck.value = id;107 newCheck.name = 'post_category[]';108 newCheck.id = 'category-' + id;109 newLabel.appendChild(newCheck);110 111 var newLabelText = document.createTextNode(' ' + names[i]);112 newLabel.appendChild(newLabelText);113 114 catDiv.insertBefore(newLabel, catDiv.firstChild);115 newCheck.checked = 'checked';116 117 Fat.fade_all();118 newLabel.className = 'selectit';119 }120 newcat.value = '';121 }122 p.parentNode.removeChild(p);123 // var id = parseInt(ajaxCat.response, 10);124 }125 126 function ajaxNewCatKeyPress(e) {127 if (!e) {128 if (window.event) {129 e = window.event;130 } else {131 return;132 }133 }134 if (e.keyCode == 13) {135 ajaxNewCat();136 e.returnValue = false;137 e.cancelBubble = true;138 return false;139 }140 }141 142 function ajaxNewCat() {143 var newcat = document.getElementById('newcat');144 var split_cats = new Array(1);145 var catString = '';146 147 catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value);148 ajaxCat.requestFile = 'edit-form-ajax-cat.php';149 ajaxCat.method = 'GET';150 ajaxCat.onLoading = newCatLoading;151 ajaxCat.onLoaded = newCatLoaded;152 ajaxCat.onInteractive = newCatInteractive;153 ajaxCat.onCompletion = newCatCompletion;154 ajaxCat.runAJAX(catString);155 }156 157 function myPload( str ) {158 var fixedExplode = new Array();159 var comma = new String(',');160 var count = 0;161 var currentElement = '';162 163 for( x=0; x < str.length; x++) {164 andy = str.charAt(x);165 if ( comma.indexOf(andy) != -1 ) {166 currentElement = currentElement.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // trim167 fixedExplode[count] = currentElement;168 currentElement = "";169 count++;170 } else {171 currentElement += andy;172 }173 }174 175 if ( currentElement != "" )176 fixedExplode[count] = currentElement;177 return fixedExplode;178 }179 No newline at end of file -
wp-admin/list-manipulation-js.php
1 <?php 2 require_once('admin.php'); 3 header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true); 4 ?> 5 addLoadEvent(function(){theList=new listMan();}); 6 function deleteSomething(what,id,message){if(!message)message="<?php printf(__('Are you sure you want to delete this %s?'),"'+what+'"); ?>";if(confirm(message))return theList.ajaxDelete(what,id);else return false;} 7 function dimSomething(what,id,dimClass){return theList.ajaxDimmer(what,id,dimClass);} 8 9 function WPAjax(file, responseEl){//class WPAjax extends sack 10 this.getResponseElement=function(r){var p=document.getElementById(r+'-p');if(!p){p=document.createElement('span');p.id=r+'ajax-response-p';document.getElementById(r).appendChild(p);}this.myResponseElement=p; } 11 this.parseAjaxResponse=function(){ 12 if(isNaN(this.response)){this.myResponseElement.innerHTML="<?php _e('Error: '); ?>"+this.response;return false;} 13 this.response=parseInt(this.response,10); 14 if(-1==this.response){this.myResponseElement.innerHTML="<?php _e("You don't have permission to do that."); ?>";return false;} 15 else if(0==this.response){this.myResponseElement.innerHTML="<?php _e("Something odd happened. Try refreshing the page? Either that or what you tried to change never existed in the first place."); ?>";return false;} 16 return true; 17 } 18 this.parseAjaxResponseXML=function(){ 19 if(this.responseXML&&typeof this.responseXML=='object')return true; 20 if(isNaN(this.response)){this.myResponseElement.innerHTML="<?php _e('Error: '); ?>"+this.response;return false;} 21 var r=parseInt(this.response,10); 22 if(-1==r){this.myResponseElement.innerHTML="<?php _e("You don't have permission to do that."); ?>";} 23 else if(0==r){this.myResponseElement.innerHTML="<?php _e("Invalid Entry."); ?>";} 24 return false; 25 } 26 this.init(file,responseEl); 27 } WPAjax.prototype=new sack; 28 WPAjax.prototype.init=function(f,r){ 29 this.URLString=this.encVar('cookie', document.cookie); 30 this.requestFile=f;this.getResponseElement(r);this.method='POST'; 31 this.onLoading=function(){this.myResponseElement.innerHTML="<?php _e('Sending Data...'); ?>";}; 32 this.onLoaded=function(){this.myResponseElement.innerHTML="<?php _e('Data Sent...'); ?>";}; 33 this.onInteractive=function(){this.myResponseElement.innerHTML="<?php _e('Processing Data...'); ?>";}; 34 } 35 36 function listMan(theListId){ 37 this.theList=null; 38 this.ajaxRespEl=null; 39 this.inputData=''; 40 this.clearInputs=new Array(); 41 var reg_color='#FFFFFF'; 42 var alt_color='#F1F1F1'; 43 var listItems; 44 var listType; 45 self.aTrap=0; 46 47 this.ajaxAdder=function(what,where,onComplete,update){//for TR, server must wrap TR in TABLE TBODY. this.makeEl cleans it 48 if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300); 49 this.ajaxAdd=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response'); 50 if(this.ajaxAdd.failed)return true; 51 this.grabInputs(where); 52 var tempObj=this; 53 this.ajaxAdd.onCompletion=function(){ 54 if(!this.parseAjaxResponseXML())return; 55 var newItems=this.responseXML.getElementsByTagName(what); 56 if(newItems){for (c=0;c<newItems.length;c++){ 57 var id=parseInt(getNodeValue(newItems[c],'id'),10); 58 var exists=document.getElementById(what+'-'+id); 59 if(exists)tempObj.replaceListItem(exists.id,getNodeValue(newItems[c],'newitem'),update); 60 else tempObj.addListItem(getNodeValue(newItems[c],'newitem')); 61 }} 62 this.myResponseElement.innerHTML='';tempObj.inputData=''; 63 for(var i=0;i<tempObj.clearInputs.length;i++){try{var theI=document.getElementById(tempObj.clearInputs[i]);if(theI.tagName.match(/select/i))theI.selectedIndex=0;else theI.value='';}catch(e){}} 64 if(onComplete&&typeof onComplete=='function')onComplete(); 65 } 66 this.ajaxAdd.runAJAX('action='+(update?'update-':'add-')+what+this.inputData); 67 return false; 68 } 69 this.ajaxUpdater=function(what,where,onComplete){return this.ajaxAdder(what,where,onComplete,true);} 70 this.ajaxDelete=function(what,id,onComplete){ 71 if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300); 72 this.ajaxDel=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response'); 73 if(this.ajaxDel.failed)return true; 74 var tempObj=this; 75 this.ajaxDel.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.removeListItem(what.replace('-as-spam','')+'-'+id,tempObj);this.myResponseElement.innerHTML='';if(onComplete&&typeof onComplete=='function')onComplete();}}; 76 this.ajaxDel.runAJAX('action=delete-'+what+'&id='+id); 77 return false; 78 } 79 this.ajaxDimmer=function(what,id,dimClass,onComplete){ 80 if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300); 81 this.ajaxDim=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response'); 82 if(this.ajaxDim.failed)return true; 83 var tempObj=this; 84 this.ajaxDim.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.dimItem(what+'-'+id,dimClass);this.myResponseElement.innerHTML='';if(onComplete&&typeof onComplete=='function')onComplete();}}; 85 this.ajaxDim.runAJAX('action=dim-'+what+'&id='+id); 86 return false; 87 } 88 this.makeEl=function(h){var fakeItem=document.createElement('div');fakeItem.innerHTML=h;var r=fakeItem.firstChild;while(r.tagName.match(/(table|tbody)/i)){r=r.firstChild;}return r;} 89 this.addListItem=function(h){ 90 newItem=this.makeEl(h); 91 var firstItem=this.theList.getElementsByTagName('table'==listType?'tr':'li')[0]; 92 if(firstItem)firstItem.parentNode.insertBefore(newItem,firstItem); 93 else this.theList.appendChild(newItem); 94 listItems.unshift(newItem.id); 95 Fat.fade_element(newItem.id); 96 } 97 this.removeListItem=function(id,listObj,noFade){ 98 if(!listObj)listObj=this; 99 if(!noFade)Fat.fade_element(id,null,700,'#FF3333'); 100 var theItem=document.getElementById(id); 101 if(!noFade){var func=encloseFunc(function(a){a.parentNode.removeChild(a);},theItem);setTimeout(func,705);} 102 else{theItem.parentNode.removeChild(theItem);} 103 var pos=listObj.getListPos(id); 104 listItems.splice(pos,1); 105 if(!noFade)listObj.recolorList(pos,1000); 106 } 107 this.replaceListItem=function(id,h,update){ 108 if(!update){this.removeListItem(id,false,true);this.addListItem(h);return;} 109 var newItem=this.makeEl(h); 110 var oldItem=document.getElementById(id); 111 oldItem.parentNode.replaceChild(newItem,oldItem); 112 Fat.fade_element(newItem.id); 113 } 114 this.dimItem=function(id,dimClass,noFade){ 115 var theItem=document.getElementById(id); 116 if(theItem.className.match(dimClass)){if(!noFade)Fat.fade_element(id,null,700,null);theItem.className=theItem.className.replace(dimClass,'');} 117 else{if(!noFade)Fat.fade_element(id,null,700,'#FF3333');theItem.className=theItem.className+' '+dimClass;} 118 } 119 this.grabInputs=function(elId){//text,password,hidden,textarea,select 120 var theItem=document.getElementById(elId); 121 var inputs=new Array(); 122 inputs.push(theItem.getElementsByTagName('input'),theItem.getElementsByTagName('textarea'),theItem.getElementsByTagName('select')); 123 for(var a=0;a<inputs.length;a++){ 124 for(var i=0;i<inputs[a].length;i++){ 125 if('action'==inputs[a][i].name)continue; 126 if('text'==inputs[a][i].type||'password'==inputs[a][i].type||'hidden'==inputs[a][i].type||inputs[a][i].tagName.match(/textarea/i)){ 127 this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].value); 128 }else if(inputs[a][i].tagName.match(/select/i)){ 129 this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].options[inputs[a][i].selectedIndex].value); 130 } 131 } 132 } 133 } 134 this.getListPos=function(id){for(var i=0;i<listItems.length;i++){if(id==listItems[i]){var pos=i;break;}}return pos;} 135 this.getListItems=function(){ 136 if(this.theList)return; 137 listItems=new Array(); 138 if(theListId){this.theList=document.getElementById(theListId);if(!this.theList)return false;} 139 else{this.theList=document.getElementById('the-list');if(this.theList)theListId='the-list';} 140 if(this.theList){ 141 var items=this.theList.getElementsByTagName('tr');listType='table' 142 if(!items[0]){items=this.theList.getElementsByTagName('li');listType='list'} 143 for(var i=0;i<items.length;i++){listItems.push(items[i].id);} 144 } 145 } 146 this.recolorList=function(pos,dur){ 147 if(!pos)pos=0; 148 for(var i=pos;i<listItems.length;i++){var e=document.getElementById(listItems[i]);if(i%2)e.className=e.className.replace('alternate','fade-'+alt_color.slice(1));else e.className+=' alternate fade-'+reg_color.slice(1);e.style.backgroundColor='';} 149 Fat.fade_all(dur); 150 var func=encloseFunc(function(l){for(var i=0;i<l.length;i++){var e=document.getElementById(l[i]);e.className=e.className.replace(/fade-[a-f0-9]{6}/i,'');}},listItems); 151 setTimeout(func,dur+5); 152 } 153 this.getListItems(); 154 } 155 //No submit unless eval(code) returns true. 156 function killSubmit(code,e){if(!e){if(window.event)e=window.event;else return;}var t=e.target?e.target:e.srcElement;if(('text'==t.type&&e.keyCode==13)||('submit'==t.type&&'click'==e.type)){if(!eval(code));e.returnValue=false;e.cancelBubble=true;return false;}} 157 //Pretty func from ALA http://www.alistapart.com/articles/gettingstartedwithajax 158 function getNodeValue(tree,el){return tree.getElementsByTagName(el)[0].firstChild.nodeValue;} 159 //Generic but lame JS closure 160 function encloseFunc(f){var a=arguments[1];return function(){f(a);}} -
wp-admin/edit.php
114 114 <br style="clear:both;" /> 115 115 116 116 <?php 117 118 117 // define the columns to display, the syntax is 'internal name' => 'display name' 119 118 $posts_columns = array( 120 119 'id' => __('ID'), … … 133 132 134 133 ?> 135 134 136 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> 135 <table width="100%" cellpadding="3" cellspacing="3"> 136 <thead> 137 137 <tr> 138 138 139 139 <?php foreach($posts_columns as $column_display_name) { ?> … … 141 141 <?php } ?> 142 142 143 143 </tr> 144 </thead> 145 <tbody id="the-list"> 144 146 <?php 145 147 if ($posts) { 146 148 $bgcolor = ''; 147 149 foreach ($posts as $post) { start_wp(); 150 add_filter('the_title','wp_specialchars'); 148 151 $class = ('alternate' == $class) ? '' : 'alternate'; 149 152 ?> 150 153 <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'> … … 207 210 208 211 case 'control_delete': 209 212 ?> 210 <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='post.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post "%s".\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>213 <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='post.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post "%s".\\n"OK" to delete, "Cancel" to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> 211 214 <?php 212 215 break; 213 216 … … 229 232 </tr> 230 233 <?php 231 234 } // end if ($posts) 232 ?> 235 ?> 236 </tbody> 233 237 </table> 234 238 235 239 <div id="ajax-response"></div> … … 246 250 if ($comments) { 247 251 ?> 248 252 <h3><?php _e('Comments') ?></h3> 249 <ol id=" comments">253 <ol id="the-list"> 250 254 <?php 255 $i = 0; 251 256 foreach ($comments as $comment) { 252 $comment_status = wp_get_comment_status($comment->comment_ID); 257 $class = ( ++$i % 2 ) ? array('alternate') : array(); 258 if ( 'unapproved' == $comment_status = wp_get_comment_status($comment->comment_ID) ) 259 $class[] = 'unapproved'; 253 260 ?> 254 261 255 <li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?>>262 <li id='comment-<?php echo $comment->comment_ID; ?>'<?php if ( $class ) echo " class='" . join(' ', $class) . "'"; ?>> 256 263 <?php comment_date('Y-n-j') ?> 257 264 @ 258 265 <?php comment_time('g:m:s a') ?> 259 266 <?php 260 267 if ( current_user_can('edit_post', $post->ID) ) { 261 echo "[ <a href= \"post.php?action=editcomment&comment=".$comment->comment_ID."\">" . __('Edit') . "</a>";262 echo " - <a href=\"post.php?action=deletecomment&p=".$post->ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> ";268 echo "[ <a href='post.php?action=editcomment&comment=".$comment->comment_ID."\'>" . __('Edit') . '</a>'; 269 echo ' - <a href="post.php?action=deletecomment&p=' . $post->ID . '&comment=' . $comment->comment_ID . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($comment->comment_author, 1)) . "' );\">" . __('Delete') . '</a> '; 263 270 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { 264 if ('approved' == wp_get_comment_status($comment->comment_ID)) { 265 echo " - <a href=\"post.php?action=unapprovecomment&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> "; 266 } else { 267 echo " - <a href=\"post.php?action=approvecomment&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Approve') . "</a> "; 268 } 271 echo '<span class="unapprove"> - <a href="comment.php?action=unapprovecomment&p=' . $post->ID . '&comment=' . $comment->comment_ID . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\' );">' . __('Unapprove') . '</a> </span>'; 272 echo '<span class="approve"> - <a href="comment.php?action=approvecomment&p=' . $post->ID . '&comment=' . $comment->comment_ID . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\' );">' . __('Approve') . '</a> </span>'; 269 273 } 270 274 echo "]"; 271 275 } // end if any comments to show -
wp-admin/list-manipulation.js
1 var listItems;2 var reg_color = '#FFFFFF';3 var alt_color = '#F1F1F1';4 5 addLoadEvent(getListItems);6 7 function deleteSomething( what, id, message ) {8 what.replace('-', ' ');9 if (!message) message = 'Are you sure you want to delete this ' + what + '?';10 if ( confirm(message) ) {11 return ajaxDelete( what.replace(' ', '-'), id );12 } else {13 return false;14 }15 }16 17 function getResponseElement() {18 var p = document.getElementById('ajax-response-p');19 if (!p) {20 p = document.createElement('p');21 p.id = 'ajax-response-p';22 document.getElementById('ajax-response').appendChild(p);23 return p;24 }25 }26 27 function ajaxDelete(what, id) {28 ajaxDel = new sack('list-manipulation.php');29 if ( ajaxDel.failed ) return true;30 ajaxDel.myResponseElement = getResponseElement();31 ajaxDel.method = 'POST';32 ajaxDel.onLoading = function() { ajaxDel.myResponseElement.innerHTML = 'Sending Data...'; };33 ajaxDel.onLoaded = function() { ajaxDel.myResponseElement.innerHTML = 'Data Sent...'; };34 ajaxDel.onInteractive = function() { ajaxDel.myResponseElement.innerHTML = 'Processing Data...'; };35 ajaxDel.onCompletion = function() { removeThisItem( what.replace('-as-spam', '') + '-' + id ); };36 ajaxDel.runAJAX('action=delete-' + what + '&id=' + id);37 return false;38 }39 40 function removeThisItem(id) {41 var response = ajaxDel.response;42 if ( isNaN(response) ) { alert(response); }43 response = parseInt(response, 10);44 if ( -1 == response ) { ajaxDel.myResponseElement.innerHTML = "You don't have permission to do that."; }45 else if ( 0 == response ) { ajaxDel.myResponseElement.interHTML = "Something odd happened. Try refreshing the page? Either that or what you tried to delete never existed in the first place."; }46 else if ( 1 == response ) {47 theItem = document.getElementById(id);48 Fat.fade_element(id,null,700,'#FF3333');49 setTimeout('theItem.parentNode.removeChild(theItem)', 705);50 var pos = getListPos(id);51 listItems.splice(pos,1);52 recolorList(pos);53 ajaxDel.myResponseElement.parentNode.removeChild(ajaxDel.myResponseElement);54 55 }56 }57 58 function getListPos(id) {59 for (var i = 0; i < listItems.length; i++) {60 if (id == listItems[i]) {61 var pos = i;62 break;63 }64 }65 return pos;66 }67 68 function getListItems() {69 if (list) return;70 listItems = new Array();71 var extra = false;72 var list = document.getElementById('the-list');73 if (!list) { var list = document.getElementById('the-list-x'); extra = true; }74 if (list) {75 var items = list.getElementsByTagName('tr');76 if (!items[0]) { items = list.getElementsByTagName('li'); }77 for (var i=0; i<items.length; i++) { listItems.push(items[i].id); }78 if (extra) { listItems.splice(0,1); }79 }80 }81 82 function recolorList(pos,dur,from) {83 if (!pos) pos = 0;84 85 if (!from) {86 reg_from = alt_color;87 alt_from = reg_color;88 } else {89 reg_from = from;90 alt_from = from;91 }92 for (var i = pos; i < listItems.length; i++) {93 if (i % 2 == 1) Fat.fade_element(listItems[i],null,dur,reg_from,reg_color);94 else Fat.fade_element(listItems[i],null,dur,alt_from,alt_color);95 }96 } -
wp-admin/link-manager.php
114 114 <input type="hidden" name="action" value="" /> 115 115 <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" /> 116 116 <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> 117 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> 117 <table width="100%" cellpadding="3" cellspacing="3"> 118 <thead> 118 119 <tr> 119 120 <th width="15%"><?php _e('Name') ?></th> 120 121 <th><?php _e('URI') ?></th> … … 124 125 <th colspan="2"><?php _e('Action') ?></th> 125 126 <th><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th> 126 127 </tr> 128 </thead> 129 <tbody id="the-list"> 127 130 <?php 128 131 if ( 'all' == $cat_id ) 129 132 $cat_id = ''; … … 174 177 echo "\n </tr>\n"; 175 178 } 176 179 ?> 180 </tbody> 177 181 </table> 178 182 179 183 <div id="ajax-response"></div> … … 182 186 </div> 183 187 </form> 184 188 185 <?php include('admin-footer.php'); ?> 186 No newline at end of file 189 <?php include('admin-footer.php'); ?> -
wp-admin/edit-pages.php
28 28 29 29 if ($posts) { 30 30 ?> 31 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> 32 <tr> 33 <th scope="col"><?php _e('ID') ?></th> 34 <th scope="col"><?php _e('Title') ?></th> 31 <table width="100%" cellpadding="3" cellspacing="3"> 32 <thead> 33 <tr> 34 <th scope="col"><?php _e('ID') ?></th> 35 <th scope="col"><?php _e('Title') ?></th> 35 36 <th scope="col"><?php _e('Owner') ?></th> 36 37 <th scope="col"><?php _e('Updated') ?></th> 37 <th scope="col"></th> 38 <th scope="col"></th> 39 <th scope="col"></th> 40 </tr> 38 <th scope="col"></th> 39 <th scope="col"></th> 40 <th scope="col"></th> 41 </tr> 42 </thead> 43 <tbody id="the-list"> 41 44 <?php 42 45 page_rows(0, 0, $posts, $all); 43 46 ?> 44 </table> 47 </tbody> 48 </table> 45 49 46 50 <div id="ajax-response"></div> 47 51 -
wp-admin/categories.php
3 3 4 4 $title = __('Categories'); 5 5 $parent_file = 'edit.php'; 6 $list_js = true;7 6 8 7 $wpvarstoreset = array('action','cat'); 9 8 for ($i=0; $i<count($wpvarstoreset); $i += 1) { … … 104 103 105 104 default: 106 105 106 $list_js = true; 107 107 require_once ('admin-header.php'); 108 108 109 109 $messages[1] = __('Category added.'); … … 121 121 <?php else : ?> 122 122 <h2><?php _e('Categories') ?> </h2> 123 123 <?php endif; ?> 124 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> 124 <table width="100%" cellpadding="3" cellspacing="3"> 125 <thead> 125 126 <tr> 126 127 <th scope="col"><?php _e('ID') ?></th> 127 128 <th scope="col"><?php _e('Name') ?></th> … … 130 131 <th scope="col"><?php _e('# Bookmarks') ?></th> 131 132 <th colspan="2"><?php _e('Action') ?></th> 132 133 </tr> 134 </thead> 135 <tbody id="the-list"> 133 136 <?php 134 137 cat_rows(); 135 138 ?> 139 </tbody> 136 140 </table> 137 141 138 142 <div id="ajax-response"></div> … … 149 153 <form name="addcat" id="addcat" action="categories.php" method="post"> 150 154 151 155 <p><?php _e('Name:') ?><br /> 152 <input type="text" name="cat_name" value="" /></p>156 <input type="text" name="cat_name" id="cat_name" value="" /></p> 153 157 <p><?php _e('Category parent:') ?><br /> 154 <select name='category_parent' class='postform'>158 <select name='category_parent' id='category_parent' class='postform'> 155 159 <option value='0'><?php _e('None') ?></option> 156 160 <?php wp_dropdown_cats(0); ?> 157 161 </select></p> 158 162 <p><?php _e('Description: (optional)') ?> <br /> 159 <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>163 <textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p> 160 164 <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p> 161 165 </form> 162 166 </div>