Ticket #2561: 2561f.diff
File 2561f.diff, 55.6 KB (added by , 18 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-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('updatemeta').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 if ( !is_user_logged_in() ) 9 die('-1'); 10 11 function get_out_now() { exit; } 12 add_action( 'shutdown', 'get_out_now', -1 ); 13 14 function wp_clean_ajax_input( $i ) { 15 global $wpdb; 16 $i = is_array($i) ? array_map('wp_clean_ajax_input', $i) : $wpdb->escape( rawurldecode(stripslashes($i)) ); 17 return $i; 18 } 19 20 function wp_ajax_echo_meta( $pid, $mid, $key, $value ) { 21 $r = "<meta><id>$mid</id><postid>$pid</postid><newitem><![CDATA[<table><tbody>"; 22 $r .= "<tr id='meta-$mid'><td valign='top'>"; 23 $r .= "<input name='meta[$mid][key]' tabindex='6' onkeypress='return killSubmit(\"theList.ajaxUpdater('meta','meta-$mid');\",event);' type='text' size='20' value='$key' />"; 24 $r .= "</td><td><textarea name='meta[$mid][value]' tabindex='6' rows='2' cols='30'>$value</textarea></td><td align='center'>"; 25 $r .= "<input name='updatemeta' type='button' class='updatemeta' tabindex='6' value='Update' onclick='return theList.ajaxUpdater('meta','meta-$mid');' /><br />"; 26 $r .= "<input name='deletemeta[$mid]' type='submit' onclick='return deleteSomething( \"meta\", $mid);' class='deletemeta' tabindex='6' value='Delete' />"; 27 $r .= "</td></tr></tbody></table>]]></newitem></meta>"; 28 return $r; 29 } 30 31 // check_admin_referer(); 32 33 $_POST = wp_clean_ajax_input( $_POST ); 34 $id = (int) $_POST['id']; 35 switch ( $_POST['action'] ) : 36 case 'delete-comment' : 37 if ( !$comment = get_comment( $id ) ) 38 die('0'); 39 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 40 die('-1'); 41 42 if ( wp_delete_comment( $comment->comment_ID ) ) 43 die('1'); 44 else die('0'); 45 break; 46 case 'delete-comment-as-spam' : 47 if ( !$comment = get_comment( $id ) ) 48 die('0'); 49 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 50 die('-1'); 51 52 if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) ) 53 die('1'); 54 else die('0'); 55 break; 56 case 'delete-cat' : 57 if ( !current_user_can( 'manage_categories' ) ) 58 die('-1'); 59 60 if ( wp_delete_category( $id ) ) 61 die('1'); 62 else die('0'); 63 break; 64 case 'delete-link' : 65 if ( !current_user_can( 'manage_links' ) ) 66 die('-1'); 67 68 if ( wp_delete_link( $id ) ) 69 die('1'); 70 else die('0'); 71 break; 72 case 'delete-meta' : 73 if ( !$meta = get_post_meta_by_id( $id ) ) 74 die('0'); 75 if ( !current_user_can( 'edit_post', $meta->post_id ) ) 76 die('-1'); 77 if ( delete_meta( $meta->meta_id ) ) 78 die('1'); 79 die('0'); 80 break; 81 case 'delete-post' : 82 if ( !current_user_can( 'delete_post', $id ) ) 83 die('-1'); 84 85 if ( wp_delete_post( $id ) ) 86 die('1'); 87 else die('0'); 88 break; 89 case 'delete-page' : 90 if ( !current_user_can( 'delete_page', $id ) ) 91 die('-1'); 92 93 if ( wp_delete_post( $id ) ) 94 die('1'); 95 else die('0'); 96 break; 97 case 'dim-comment' : 98 if ( !$comment = get_comment( $id ) ) 99 die('0'); 100 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 101 die('-1'); 102 if ( !current_user_can( 'moderate_comments' ) ) 103 die('-1'); 104 105 if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) { 106 if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) 107 die('1'); 108 } else { 109 if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) 110 die('1'); 111 } 112 die('0'); 113 break; 114 case 'add-category' : // On the Fly 115 if ( !current_user_can( 'manage_categories' ) ) 116 die('-1'); 117 $names = explode(',', $_POST['newcat']); 118 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 119 foreach ( $names as $cat_name ) { 120 $cat_name = trim($cat_name); 121 if ( !$category_nicename = sanitize_title($cat_name) ) 122 die('0'); 123 if ( !$cat_id = category_exists( $cat_name ) ) 124 $cat_id = wp_create_category( $cat_name ); 125 $cat_name = stripslashes($cat_name); 126 $r .= "<category><id>$cat_id</id><newitem><![CDATA["; 127 $r .= "<li id='category-$cat_id'><label for='in-category-$cat_id' class='selectit'>"; 128 $r .= "<input value='$cat_id' type='checkbox' checked='checked' name='post_category[]' id='in-category-$cat_id'/> $cat_name</label></li>"; 129 $r .= "]]></newitem></category>"; 130 } 131 $r .= '</ajaxresponse>'; 132 header('Content-type: text/xml'); 133 die($r); 134 break; 135 case 'add-cat' : // From Manage->Categories 136 if ( !current_user_can( 'manage_categories' ) ) 137 die('-1'); 138 if ( !$cat = wp_insert_category( $_POST ) ) 139 die('0'); 140 if ( !$cat = get_category( $cat ) ) 141 die('0'); 142 $pad = 0; 143 $_cat = $cat; 144 while ( $_cat->category_parent ) { 145 $_cat = get_category( $_cat->category_parent ); 146 $pad++; 147 } 148 $pad = str_repeat('— ', $pad); 149 150 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 151 $r .= "<cat><id>$cat->cat_ID</id><newitem><![CDATA[<table><tbody>"; 152 $r .= "<tr id='cat-$cat->cat_ID'><th scope='row'>$cat->cat_ID</th><td>$pad $cat->cat_name</td>"; 153 $r .= "<td>$cat->category_description</td><td>$cat->category_count</td><td>$cat->link_count</td>"; 154 $r .= "<td><a href='categories.php?action=edit&cat_ID=$cat->cat_ID' class='edit'>" . __('Edit') . "</a></td>"; 155 $r .= "<td><a href='categories.php?action=delete&cat_ID=$cat->cat_ID' onclick='return deleteSomething( \"cat\", $cat->cat_ID, \""; 156 $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)); 157 $r .= "\" );' class='delete'>".__('Delete')."</a></td></tr>"; 158 $r .= "</tbody></table>]]></newitem></cat></ajaxresponse>"; 159 header('Content-type: text/xml'); 160 die($r); 161 162 break; 163 case 'add-meta' : 164 if ( !current_user_can( 'edit_post', $id ) ) 165 die('-1'); 166 if ( $id < 0 ) { 167 if ( $pid = write_post() ) 168 $meta = has_meta( $pid ); 169 else 170 die('0'); 171 $key = wp_specialchars( $meta[0]['meta_key'], true ); 172 $value = wp_specialchars( $meta[0]['meta_value'], true ); 173 $mid = (int) $meta[0]['meta_id']; 174 } else { 175 if ( $mid = add_meta( $id ) ) 176 $meta = get_post_meta_by_id( $mid ); 177 else 178 die('0'); 179 $key = wp_specialchars($meta->meta_key, true); 180 $value = wp_specialchars($meta->meta_value, true); 181 $pid = (int) $meta->post_id; 182 } 183 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 184 $r .= wp_ajax_echo_meta( $pid, $mid, $key, $value ); 185 $r .= '</ajaxresponse>'; 186 header('Content-type: text/xml'); 187 die($r); 188 break; 189 case 'update-meta' : 190 $mid = (int) array_pop(array_keys($_POST['meta'])); 191 $key = $_POST['meta'][$mid]['key']; 192 $value = $_POST['meta'][$mid]['value']; 193 if ( !$meta = get_post_meta_by_id( $mid ) ) 194 die('0'); 195 if ( !current_user_can( 'edit_post', $meta->post_id ) ) 196 die('-1'); 197 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 198 if ( $u = update_meta( $mid, $key, $value ) ) { 199 $key = wp_specialchars(stripslashes($key), true); 200 $value = wp_specialchars(stripslashes($value), true); 201 $r .= wp_ajax_echo_meta( $meta->post_id, $mid, $key, $value ); 202 } 203 $r .= '</ajaxresponse>'; 204 header('Content-type: text/xml'); 205 die($r); 206 break; 207 default : 208 die('0'); 209 break; 210 endswitch; 211 ?> -
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 … … 832 832 return; 833 833 $count = 0; 834 834 ?> 835 <table id='meta-list' cellpadding="3">836 835 <tr> 837 836 <th><?php _e('Key') ?></th> 838 837 <th><?php _e('Value') ?></th> 839 838 <th colspan='2'><?php _e('Action') ?></th> 840 839 </tr> 841 840 <?php 842 843 841 $r =''; 844 842 foreach ($meta as $entry) { 845 843 ++ $count; 846 844 if ($count % 2) … … 849 847 $style = ''; 850 848 if ('_' == $entry['meta_key'] { 0 }) 851 849 $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 ";850 $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true ); 851 $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true ); 852 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; 853 $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>"; 854 $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; 855 $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />"; 856 $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick='return deleteSomething( \"meta\", {$entry['meta_id']});' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>"; 857 $r .= "\n\t</tr>"; 860 858 } 861 echo " 862 </table> 863 "; 859 echo $r; 864 860 } 865 861 866 862 // Get a list of previously defined keys … … 886 882 LIMIT 10"); 887 883 ?> 888 884 <h3><?php _e('Add a new custom field:') ?></h3> 889 <table cellspacing="3" cellpadding="3">885 <table id="newmeta" cellspacing="3" cellpadding="3"> 890 886 <tr> 891 887 <th colspan="2"><?php _e('Key') ?></th> 892 888 <th><?php _e('Value') ?></th> … … 910 906 </tr> 911 907 912 908 </table> 913 <p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p>909 <p class="submit"><input type="submit" id="updatemeta" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> 914 910 <?php 915 911 916 912 } 917 913 918 914 function add_meta($post_ID) { 919 915 global $wpdb; 916 $post_ID = (int) $post_ID; 920 917 921 918 $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect']))); 922 919 $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput']))); … … 926 923 // We have a key/value pair. If both the select and the 927 924 // input for the key have data, the input takes precedence: 928 925 929 if ('#NONE#' != $metakeyselect)926 if ('#NONE#' != $metakeyselect) 930 927 $metakey = $metakeyselect; 931 928 932 929 if ($metakeyinput) … … 937 934 (post_id,meta_key,meta_value) 938 935 VALUES ('$post_ID','$metakey','$metavalue') 939 936 "); 937 return $wpdb->insert_id; 940 938 } 939 return false; 941 940 } // add_meta 942 941 943 942 function delete_meta($mid) { 944 943 global $wpdb; 944 $mid = (int) $mid; 945 945 946 $result =$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");946 return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); 947 947 } 948 948 949 949 function update_meta($mid, $mkey, $mvalue) { 950 950 global $wpdb; 951 $mid = (int) $mid; 951 952 952 953 return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'"); 953 954 } 954 955 956 function get_post_meta_by_id($mid) { 957 global $wpdb; 958 $mid = (int) $mid; 959 960 return $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'"); 961 } 962 955 963 function touch_time($edit = 1, $for_post = 1) { 956 964 global $month, $post, $comment; 957 965 -
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 id='the-list-x' cellpadding="3"> 212 213 <?php 213 214 if($metadata = has_meta($post_ID)) { 214 215 ?> 215 216 <?php 216 217 list_meta($metadata); 217 218 ?> 219 218 220 <?php 219 221 } 222 ?> 223 </table> 224 <?php 220 225 meta_form(); 221 226 ?> 222 227 </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 <table id='the-list-x' cellpadding="3"> 251 252 <?php 252 253 if($metadata = has_meta($post_ID)) { 253 254 ?> 254 255 <?php 255 256 list_meta($metadata); 256 257 ?> 258 257 259 <?php 258 260 } 261 ?> 262 </table> 263 <?php 259 264 meta_form(); 260 265 ?> 266 <div id="ajax-response"></div> 261 267 </div> 262 268 </fieldset> 263 269 -
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 = '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='Are you sure you want to delete this '+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='Error: '+this.response;return false;} 13 this.response=parseInt(this.response,10); 14 if(-1==this.response){this.myResponseElement.innerHTML="You don't have permission to do that.";return false;} 15 else if(0==this.response){this.myResponseElement.innerHTML="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='Error: '+this.response;return false;} 21 var r=parseInt(this.response,10); 22 if(-1==r){this.myResponseElement.innerHTML="You don't have permission to do that.";} 23 else if(0==r){this.myResponseElement.innerHTML="Invalid Entry.";} 24 return false;//Anything else need to be caught? 25 } 26 this.init(file,responseEl); 27 } WPAjax.prototype=new sack; 28 WPAjax.prototype.init=function(f,r){ 29 this.requestFile=f; 30 this.getResponseElement(r); 31 this.method='POST'; 32 this.onLoading=function(){this.myResponseElement.innerHTML='Sending Data...';}; 33 this.onLoaded=function(){this.myResponseElement.innerHTML='Data Sent...';}; 34 this.onInteractive=function(){this.myResponseElement.innerHTML='Processing Data...';}; 35 } 36 37 function listMan(theListId,extraRows){ 38 this.theListId=theListId; 39 this.extraRows=extraRows; 40 this.theList=null; 41 this.ajaxRespEl=null; 42 this.inputData=''; 43 this.clearInputs=new Array(); 44 var reg_color='#FFFFFF'; 45 var alt_color='#F1F1F1'; 46 var listItems; 47 var listType; 48 self.aTrap=0; 49 50 this.ajaxAdder=function(what,where,onComplete,update){//if server returns TR, server must wrap it in TABLE TBODY. this.makeEl cleans it 51 if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300); 52 this.ajaxAdd=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response'); 53 if(this.ajaxAdd.failed)return true; 54 this.grabInputs(where); 55 var tempObj=this; 56 this.ajaxAdd.onCompletion=function(){ 57 if(!this.parseAjaxResponseXML())return; 58 var newItems=this.responseXML.getElementsByTagName(what); 59 if(newItems){for (c=0;c<newItems.length;c++){ 60 var id=parseInt(getNodeValue(newItems[c],'id'),10); 61 var exists=document.getElementById(what+'-'+id); 62 if(exists)tempObj.replaceListItem(exists.id,getNodeValue(newItems[c],'newitem'),update); 63 else tempObj.addListItem(getNodeValue(newItems[c],'newitem')); 64 }} 65 this.myResponseElement.innerHTML='';tempObj.inputData=''; 66 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){}} 67 if(onComplete&&typeof onComplete=='function')onComplete(); 68 } 69 this.ajaxAdd.runAJAX('action='+(update?'update-':'add-')+what+this.inputData); 70 return false; 71 } 72 this.ajaxUpdater=function(what,where,onComplete){return this.ajaxAdder(what,where,onComplete,true);} 73 this.ajaxDelete=function(what,id,onComplete){ 74 if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300); 75 this.ajaxDel=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response'); 76 if(this.ajaxDel.failed)return true; 77 var tempObj=this; 78 this.ajaxDel.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.removeListItem(what.replace('-as-spam','')+'-'+id,tempObj);this.myResponseElement.innerHTML='';if(onComplete&&typeof onComplete=='function')onComplete();}}; 79 this.ajaxDel.runAJAX('action=delete-'+what+'&id='+id); 80 return false; 81 } 82 this.ajaxDimmer=function(what,id,dimClass,onComplete){ 83 if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300); 84 this.ajaxDim=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response'); 85 if(this.ajaxDim.failed)return true; 86 var tempObj=this; 87 this.ajaxDim.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.dimItem(what+'-'+id,dimClass);this.myResponseElement.innerHTML='';if(onComplete&&typeof onComplete=='function')onComplete();}}; 88 this.ajaxDim.runAJAX('action=dim-'+what+'&id='+id); 89 return false; 90 } 91 this.makeEl=function(chunk){var fakeItem=document.createElement('div');fakeItem.innerHTML=chunk;var ret=fakeItem.firstChild;while(ret.tagName.match(/(table|tbody)/i)){ret=ret.firstChild;}return ret;} 92 this.addListItem=function(chunk){ 93 newItem=this.makeEl(chunk); 94 var firstItem=this.theList.getElementsByTagName('table'==listType?'tr':'li')[this.extraRows]; 95 if(firstItem)firstItem.parentNode.insertBefore(newItem,firstItem); 96 else this.theList.appendChild(newItem); 97 listItems.unshift(newItem.id); 98 Fat.fade_element(newItem.id); 99 } 100 this.removeListItem=function(id,listObj,noFade){ 101 if(!listObj)listObj=this; 102 if(!noFade)Fat.fade_element(id,null,700,'#FF3333'); 103 if(!self.theItem)self.theItem=new Array();//grumble:global 104 self.theItem[id]=document.getElementById(id); 105 if(!noFade)setTimeout('theItem["'+id+'"].parentNode.removeChild(theItem["'+id+'"]);delete(theItem["'+id+'"])',705); 106 else{self.theItem[id].parentNode.removeChild(theItem[id]);delete(theItem[id]);} 107 var pos=listObj.getListPos(id); 108 listItems.splice(pos,1); 109 if(!noFade)listObj.recolorList(pos); 110 } 111 this.replaceListItem=function(id,chunk,update){ 112 if(!update){this.removeListItem(id,false,true);this.addListItem(chunk);return;} 113 var newItem=this.makeEl(chunk); 114 var oldItem=document.getElementById(id); 115 oldItem.parentNode.replaceChild(newItem,oldItem); 116 Fat.fade_element(newItem.id); 117 } 118 this.dimItem=function(id,dimClass,noFade){ 119 var theItem=document.getElementById(id); 120 if(theItem.className.match(dimClass)){if(!noFade)Fat.fade_element(id,null,700,null);theItem.className=theItem.className.replace(dimClass,'');} 121 else{if(!noFade)Fat.fade_element(id,null,700,'#FF3333');theItem.className=theItem.className+' '+dimClass;} 122 } 123 this.grabInputs=function(elId){//text,password,hidden,textarea,select 124 var theItem=document.getElementById(elId); 125 var inputs=new Array(); 126 inputs.push(theItem.getElementsByTagName('input'),theItem.getElementsByTagName('textarea'),theItem.getElementsByTagName('select')); 127 for(var a=0;a<inputs.length;a++){ 128 for(var i=0;i<inputs[a].length;i++){ 129 if('action'==inputs[a][i].name)continue; 130 if('text'==inputs[a][i].type||'password'==inputs[a][i].type||'hidden'==inputs[a][i].type||inputs[a][i].tagName.match(/textarea/i)){ 131 this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].value); 132 }else if(inputs[a][i].tagName.match(/select/i)){ 133 this.inputData+='&'+inputs[a][i].name+'='+encodeURIComponent(inputs[a][i].options[inputs[a][i].selectedIndex].value); 134 } 135 } 136 } 137 } 138 this.getListPos=function(id){for(var i=0;i<listItems.length;i++){if(id==listItems[i]){var pos=i;break;}}return pos;} 139 this.getListItems=function(){ 140 if(this.theList)return; 141 listItems=new Array(); 142 if(isNaN(this.extraRows))this.extraRows=0; 143 if(this.theListId){this.theList=document.getElementById(this.theListId);if(!this.theList)return false;} 144 else{this.theList=document.getElementById('the-list');if(this.theList)this.theListId='the-list';} 145 if(!this.theList){this.theList=document.getElementById('the-list-x');this.extraRows+=1;if(this.theList)this.theListId='the-list-x';} 146 if(this.theList){ 147 var items=this.theList.getElementsByTagName('tr');listType='table' 148 if(!items[0]){items=this.theList.getElementsByTagName('li');listType='list'} 149 for(var i=0;i<items.length;i++){listItems.push(items[i].id);} 150 if(this.extraRows){listItems.splice(0,this.extraRows);} 151 } 152 } 153 this.recolorList=function(pos,dur,from){ 154 if(!pos)pos=0; 155 if(!from){reg_from=alt_color;alt_from=reg_color;} 156 else{reg_from=from;alt_from=from;} 157 var listItemsAsString=''; 158 for(var i=pos;i<listItems.length;i++){listItemsAsString+="'"+listItems[i]+"',";var theI=document.getElementById(listItems[i]);if(i%2)theI.className=theI.className.replace('alternate','fade-'+alt_color.slice(1));else theI.className+=' alternate fade-'+reg_color.slice(1);theI.style.backgroundColor='';} 159 listItemsAsString=listItemsAsString.slice(0,-1); 160 Fat.fade_all(1000);//fade_all seems to work better when many items in list, but necessitates ugly next line. 161 setTimeout("var listItems=new Array("+listItemsAsString+");for(var i=0;i<listItems.length;i++){var theI=document.getElementById(listItems[i]);theI.className=theI.className.replace(/fade-[a-f0-9]{6}/i,'');}",1005); 162 } 163 this.getListItems(); 164 } 165 //Don't submit, eval(code) instead 166 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)){eval(code);e.returnValue=false;e.cancelBubble=true;return false;}} 167 //Pretty function from ALA http://www.alistapart.com/articles/gettingstartedwithajax 168 function getNodeValue(tree,el){return tree.getElementsByTagName(el)[0].firstChild.nodeValue;} -
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'), … … 145 144 if ($posts) { 146 145 $bgcolor = ''; 147 146 foreach ($posts as $post) { start_wp(); 147 add_filter('the_title','wp_specialchars'); 148 148 $class = ('alternate' == $class) ? '' : 'alternate'; 149 149 ?> 150 150 <tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'> … … 207 207 208 208 case 'control_delete': 209 209 ?> 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>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."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> 211 211 <?php 212 212 break; 213 213 … … 246 246 if ($comments) { 247 247 ?> 248 248 <h3><?php _e('Comments') ?></h3> 249 <ol id=" comments">249 <ol id="the-list"> 250 250 <?php 251 $i = 0; 251 252 foreach ($comments as $comment) { 252 $comment_status = wp_get_comment_status($comment->comment_ID); 253 $class = ( ++$i % 2 ) ? array('alternate') : array(); 254 if ( 'unapproved' == $comment_status = wp_get_comment_status($comment->comment_ID) ) 255 $class[] = 'unapproved'; 253 256 ?> 254 257 255 <li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?>>258 <li id='comment-<?php echo $comment->comment_ID; ?>'<?php if ( $class ) echo " class='" . join(' ', $class) . "'"; ?>> 256 259 <?php comment_date('Y-n-j') ?> 257 260 @ 258 261 <?php comment_time('g:m:s a') ?> 259 262 <?php 260 263 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> ";264 echo "[ <a href='post.php?action=editcomment&comment=".$comment->comment_ID."\'>" . __('Edit') . '</a>'; 265 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 266 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 } 267 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>'; 268 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 269 } 270 270 echo "]"; 271 271 } // 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/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.'); … … 149 149 <form name="addcat" id="addcat" action="categories.php" method="post"> 150 150 151 151 <p><?php _e('Name:') ?><br /> 152 <input type="text" name="cat_name" value="" /></p>152 <input type="text" name="cat_name" id="cat_name" value="" /></p> 153 153 <p><?php _e('Category parent:') ?><br /> 154 <select name='category_parent' class='postform'>154 <select name='category_parent' id='category_parent' class='postform'> 155 155 <option value='0'><?php _e('None') ?></option> 156 156 <?php wp_dropdown_cats(0); ?> 157 157 </select></p> 158 158 <p><?php _e('Description: (optional)') ?> <br /> 159 <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>159 <textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p> 160 160 <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p> 161 161 </form> 162 162 </div>