Ticket #2561: 2561.diff
| File 2561.diff, 42.9 KB (added by , 20 years ago) |
|---|
-
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('customFieldsUpdate(' + parseInt(this.name.slice(5),10) + ');', e); }; 9 } 10 if ('updatemeta' == inputs[i].className) { 11 inputs[i].onclick = function(e) {return killSubmit('customFieldsUpdate(' + parseInt(this.parentNode.parentNode.id.slice(5),10) + ');', e); }; 12 } 13 } 14 var loadingDock = document.createElement('input'); 15 loadingDock.type = 'hidden'; 16 loadingDock.id = 'loading-dock'; 17 document.getElementById('post').appendChild(loadingDock); 18 theList.newSource = 'loading-dock'; 19 } 20 21 function customFieldsUpdate(id) { //ToDo: abstract this by grabbing values of all input elements. 22 var theItem = document.getElementById('meta-' + id); 23 var key = theItem.getElementsByTagName('input')[0].value; 24 var value = theItem.getElementsByTagName('textarea')[0].value; 25 var loadingDock = document.getElementById('loading-dock'); 26 loadingDock.value = encodeURIComponent('id=' + id + '&key=' + key + '&value=' + value); 27 theList.ajaxUpdater('meta'); 28 } -
wp-admin/edit-comments.php
121 121 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p> 122 122 </li> 123 123 124 <?php } // end foreach ?>124 <?php } // end foreach($comment) ?> 125 125 </ol> 126 126 127 127 <div id="ajax-response"></div> 128 128 129 129 <?php 130 } else { 130 } else { //no comments to show 131 131 132 132 ?> 133 133 <p> … … 150 150 </tr>'; 151 151 foreach ($comments as $comment) { 152 152 $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); 153 $comment_status = wp_get_comment_status($comment->comment_ID); 153 154 $class = ('alternate' == $class) ? '' : 'alternate'; 155 $class .= ('unapproved' == $comment_status) ? ' unapproved' : ''; 154 156 ?> 155 <tr class='<?php echo $class; ?>'>157 <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'> 156 158 <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> 157 159 <td><?php comment_author_link() ?></td> 158 160 <td><?php comment_author_email_link() ?></td> 159 161 <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td> 160 162 <td><?php comment_excerpt(); ?></td> 161 <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td> 163 <td> 164 <?php if ('unapproved' == $comment_status) { ?> 165 (Unapproved) 166 <?php } else { ?> 167 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a> 168 <?php } ?> 169 </td> 162 170 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 163 171 echo "<a href='comment.php?action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> 164 172 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 165 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> 173 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> "; 174 } ?></td> 166 175 </tr> 167 176 <?php 168 177 } // end foreach … … 171 180 <p class="submit"><input type="submit" name="delete_button" value="<?php _e('Delete Checked Comments »') ?>" onclick="return confirm('<?php _e("You are about to delete these comments permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /> 172 181 <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> 173 182 </form> 183 <div id="ajax-response"></div> 174 184 <?php 175 185 } else { 176 186 ?> -
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/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 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 $info = rawurldecode($_POST['info']); 16 switch ( $_POST['action'] ) : 17 case 'delete-link' : 18 if ( !current_user_can( 'manage_links' ) ) 19 die('-1'); 20 21 if ( wp_delete_link( $id ) ) 22 die('1'); 23 else die('0'); 24 break; 25 case 'delete-post' : 26 if ( !current_user_can( 'delete_post', $id ) ) 27 die('-1'); 28 29 if ( wp_delete_post( $id ) ) 30 die('1'); 31 else die('0'); 32 break; 33 case 'delete-page' : 34 if ( !current_user_can( 'delete_page', $id ) ) 35 die('-1'); 36 37 if ( wp_delete_post( $id ) ) 38 die('1'); 39 else die('0'); 40 break; 41 case 'delete-cat' : 42 if ( !current_user_can( 'manage_categories' ) ) 43 die('-1'); 44 45 if ( wp_delete_category( $id ) ) 46 die('1'); 47 else die('0'); 48 break; 49 case 'delete-comment' : 50 if ( !$comment = get_comment( $id ) ) 51 die('0'); 52 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 53 die('-1'); 54 55 if ( wp_delete_comment( $comment->comment_ID ) ) 56 die('1'); 57 else die('0'); 58 break; 59 case 'delete-comment-as-spam' : 60 if ( !$comment = get_comment( $id ) ) 61 die('0'); 62 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 63 die('-1'); 64 65 if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) ) 66 die('1'); 67 else die('0'); 68 break; 69 case 'delete-meta' : 70 if ( !$meta = get_post_meta_by_id( $id ) ) 71 die('0'); 72 if ( !current_user_can( 'edit_post', $meta->post_id ) ) 73 die('-1'); 74 if ( delete_meta( $meta->meta_id ) ) 75 die('1'); 76 die('0'); 77 break; 78 case 'dim-comment' : 79 if ( !$comment = get_comment( $id ) ) 80 die('0'); 81 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) 82 die('-1'); 83 if ( !current_user_can( 'moderate_comments' ) ) 84 die('-1'); 85 86 if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) { 87 if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) 88 die('1'); 89 } else { 90 if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) 91 die('1'); 92 } 93 die('0'); 94 break; 95 case 'dim-plugin' : 96 if ( !current_user_can( 'activate_plugins' ) ) 97 die('-1'); 98 $id = urldecode(str_replace('---', '.', $_POST['id'])); 99 $current = get_settings( 'active_plugins' ); 100 if ( !in_array($id, $current) ) { 101 $current[] = trim($id); 102 sort($current); 103 update_option( 'active_plugins', $current ); 104 include(ABSPATH . 'wp-content/plugins/' . trim($id)); 105 do_action('activate_' . trim($id)); 106 } else { 107 array_splice($current, array_search($id, $current), 1); // Array-fu! 108 update_option( 'active_plugins', $current ); 109 do_action('deactivate_' . trim($id)); 110 } 111 die('1'); 112 break; 113 case 'add-category' : 114 if ( !current_user_can( 'manage_categories' ) ) 115 die('-1'); 116 $names = explode(',', $info); 117 $return = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 118 foreach ( $names as $cat_name ) { 119 $cat_name = trim($cat_name); 120 if ( !$category_nicename = sanitize_title($cat_name) ) 121 die('0'); 122 if ( !$cat_id = category_exists( $cat_name ) ) 123 $cat_id = wp_create_category( $cat_name ); 124 $return .= "<category><id>$cat_id</id><newitem><![CDATA[<li id='category-$cat_id'><label for='in-category-$cat_id' class='selectit'><input value='$cat_id' type='checkbox' checked='checked' name='post_category[]' id='in-category-$cat_id'/> $cat_name</label></li>]]></newitem></category>"; 125 } 126 $return .= '</ajaxresponse>'; 127 header('Content-type: text/xml'); 128 die($return); 129 break; 130 case 'add-meta' : 131 parse_str($info, $outfo); 132 if ( !$meta = get_post_meta_by_id( $outfo['id'] ) ) 133 die('0'); 134 if ( !current_user_can( 'edit_post', $meta->post_id ) ) 135 die('-1'); 136 $return = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 137 if ( update_meta( $outfo['id'], $outfo['key'], $outfo['value'] ) ) 138 $return .= "<meta><id>{$outfo['id']}</id><newitem><![CDATA[<table><tr id='meta-{$outfo['id']}'><td valign='top'><input name='meta[{$outfo['id']}][key]' tabindex='6' type='text' size='20' value='{$outfo['key']}' /></td><td><textarea name='meta[{$outfo['id']}][value]' tabindex='6' rows='2' cols='30'>{$outfo['value']}</textarea></td><td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='Update' /><br /><input name='deletemeta[{$outfo['id']}]' type='submit' onclick='return deleteSomething( \"meta\", {$outfo['id']});' class='deletemeta' tabindex='6' value='Delete' /></td></tr></table>]]></newitem></meta>"; 139 $return .= '</ajaxresponse>'; 140 header('Content-type: text/xml'); 141 die($return); 142 break; 143 default : 144 die('0'); 145 break; 146 endswitch; 147 ?> -
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; … … 709 716 background: #BEB; 710 717 } 711 718 .active .name { 719 font-weight: bold; 712 720 background: #9C9; 713 721 } 714 722 .alternate.active td { … … 717 725 .alternate.active .name { 718 726 background: #8B8; 719 727 } 728 .deactivate { 729 display: none; 730 } 731 .active .activate { 732 display: none; 733 } 734 .active .deactivate { 735 display: inline; 736 } 720 737 721 738 /* A handy div class for hiding controls. 722 739 Some browsers will disable them when you … … 804 821 margin-top: .5em; 805 822 } 806 823 807 #categorydiv div div { 824 #categorydiv ul { 825 list-style: none; 826 padding: 0; 827 margin-left:10px; 828 } 829 #categorychecklist { 808 830 height: 12em; 809 831 overflow: auto; 832 margin-top: 8px; 810 833 } 811 834 #categorychecklist li { 835 margin: 0; 836 padding: 0; 837 } 812 838 #ajaxcat input { 813 839 border: 1px solid #ccc; 814 840 } … … 951 977 #jaxcat { 952 978 margin: 0; 953 979 padding: 0; 954 } 955 No newline at end of file 980 } -
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 } … … 832 832 return; 833 833 $count = 0; 834 834 ?> 835 <table id=' meta-list' cellpadding="3">835 <table id='the-list-x' cellpadding="3"> 836 836 <tr> 837 837 <th><?php _e('Key') ?></th> 838 838 <th><?php _e('Value') ?></th> … … 850 850 if ('_' == $entry['meta_key'] { 0 }) 851 851 $style .= ' hidden'; 852 852 echo " 853 <tr class='$style'>853 <tr id='meta-{$entry['meta_id']}' class='$style'> 854 854 <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td> 855 855 <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td> 856 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>857 <input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick='return deleteSomething( \"meta\", {$entry['meta_id']});' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td> 858 858 </tr> 859 859 "; 860 860 } … … 917 917 918 918 function add_meta($post_ID) { 919 919 global $wpdb; 920 $post_ID = (int) $post_ID; 920 921 921 922 $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect']))); 922 923 $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput']))); … … 942 943 943 944 function delete_meta($mid) { 944 945 global $wpdb; 946 $mid = (int) $mid; 945 947 946 $result =$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");948 return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); 947 949 } 948 950 949 951 function update_meta($mid, $mkey, $mvalue) { 950 952 global $wpdb; 953 $mid = (int) $mid; 951 954 952 955 return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'"); 953 956 } 954 957 958 function get_post_meta_by_id($mid) { 959 global $wpdb; 960 $mid = (int) $mid; 961 962 return $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'"); 963 } 964 955 965 function touch_time($edit = 1, $for_post = 1) { 956 966 global $month, $post, $comment; 957 967 -
wp-admin/edit-form-advanced.php
93 93 <h3 class="dbx-handle"><?php _e('Categories') ?></h3> 94 94 <div class="dbx-content"> 95 95 <p id="jaxcat"></p> 96 < div id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></div></div>96 <ul id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></ul></div> 97 97 </fieldset> 98 98 99 99 <fieldset class="dbx-box"> … … 258 258 } 259 259 meta_form(); 260 260 ?> 261 <div id="ajax-response"></div> 261 262 </div> 262 263 </fieldset> 263 264 -
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 } ?> 34 40 <?php if ( $dbx_js ) { ?> 35 41 <script type="text/javascript" src="../wp-includes/js/dbx.js"></script> 36 42 <script type="text/javascript"> -
wp-admin/plugins.php
25 25 } 26 26 27 27 $title = __('Manage Plugins'); 28 $list_js = true; 28 29 require_once('admin-header.php'); 29 30 30 31 // Clean up options … … 95 96 uksort($plugins, 'sort_plugins'); 96 97 97 98 foreach($plugins as $plugin_file => $plugin_data) { 99 $sanitized_file = str_replace('.', '---', urlencode($plugin_file)); 98 100 $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate'; 99 101 100 if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { 101 $action = "<a href='plugins.php?action=deactivate&plugin=$plugin_file' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>"; 102 $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>"; 102 if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) 103 103 $style .= $style == 'alternate' ? ' active' : 'active'; 104 } else { 105 $action = "<a href='plugins.php?action=activate&plugin=$plugin_file' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>"; 106 } 104 $action = "<span class='deactivate'><a href='plugins.php?action=deactivate&plugin=$plugin_file' onclick='return dimSomething( \"plugin\", \"$sanitized_file\", \"active\" );' title='" . __('Deactivate this plugin') . "' class='delete'>" . __('Deactivate') . "</a></span><span class='activate'><a href='plugins.php?action=activate&plugin=$plugin_file' onclick='return dimSomething( \"plugin\", \"$sanitized_file\", \"active\" );' title='" . __('Activate this plugin') . "' class='edit'>" . __('Activate') . "</a></span>"; 107 105 $plugin_data['Description'] = wp_kses($plugin_data['Description'], array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()) ); ; 108 106 if ($style != '') $style = 'class="' . $style . '"'; 109 107 echo " 110 <tr $style >108 <tr $style id='plugin-$sanitized_file'> 111 109 <td class='name'>{$plugin_data['Title']}</td> 112 110 <td class='vers'>{$plugin_data['Version']}</td> 113 111 <td class='desc'>{$plugin_data['Description']} <cite>".sprintf(__('By %s'), $plugin_data['Author']).".</cite></td> … … 117 115 ?> 118 116 119 117 </table> 118 119 <div id='ajax-response'></div> 120 120 121 <?php 121 122 } 122 123 ?> -
wp-admin/cat-js.php
2 2 require_once('admin.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.newSource='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');", 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'); }; 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 ) { 7 what.replace('-', ' '); 8 if (!message) message = 'Are you sure you want to delete this ' + what + '?'; 9 if ( confirm(message) ) return theList.ajaxDelete( what.replace(' ', '-'), id ); 10 else return false; 11 } 12 function dimSomething( what, id, dimClass ) { return theList.ajaxDimmer( what, id, dimClass ); } 13 14 function WPAjax(file, responseEl) { // class WPAjax extends sack 15 this.getResponseElement = function(r) { 16 var p = document.getElementById(r + '-p'); 17 if (!p) { p = document.createElement('span'); p.id = r + 'ajax-response-p'; document.getElementById(r).appendChild(p); } 18 this.myResponseElement = p; 19 } 20 this.parseAjaxResponse = function() { 21 if ( isNaN(this.response) ) { this.myResponseElement.innerHTML = 'Error: ' + this.response; return false; } 22 this.response = parseInt(this.response, 10); 23 if ( -1 == this.response ) { this.myResponseElement.innerHTML = "You don't have permission to do that."; return false; } 24 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; } 25 return true; 26 } 27 this.parseAjaxResponseXML = function() { 28 if ( this.responseXML && typeof this.responseXML == 'object' ) return true; 29 if ( isNaN(this.response) ) { this.myResponseElement.innerHTML = 'Error: ' + this.response; return false; } 30 var r = parseInt(this.response, 10); 31 if ( -1 == r ) { this.myResponseElement.innerHTML = "You don't have permission to do that."; } 32 else if ( 0 == r ) { this.myResponseElement.innerHTML = "Invalid Entry."; } 33 return false; // Anything else need to be caught? 34 } 35 this.init(file, responseEl); 36 } WPAjax.prototype = new sack; 37 WPAjax.prototype.init = function(f, r) { 38 this.requestFile = f; 39 this.getResponseElement(r); 40 this.method = 'POST'; 41 this.onLoading = function() { this.myResponseElement.innerHTML = 'Sending Data...'; }; 42 this.onLoaded = function() { this.myResponseElement.innerHTML = 'Data Sent...'; }; 43 this.onInteractive = function() { this.myResponseElement.innerHTML = 'Processing Data...'; }; 44 } 45 46 function listMan(theListId) { 47 this.theListId = theListId; 48 this.theList = null; 49 this.ajaxRespEl = null; 50 this.newSource = null; 51 var reg_color = '#FFFFFF'; 52 var alt_color = '#F1F1F1'; 53 var listItems; 54 55 this.ajaxAdder = function(what, update) { //if server returns TR, server must wrap it in TABLE TBODY. this.makeEl cleans it 56 this.ajaxAdd = new WPAjax('admin-ajax.php', this.ajaxRespEl ? this.ajaxRespEl : 'ajax-response'); 57 if ( this.ajaxAdd.failed ) return true; 58 var newInfo = document.getElementById(this.newSource); 59 var tempObj = this; 60 this.ajaxAdd.onCompletion = function() { 61 if ( !this.parseAjaxResponseXML() ) return; 62 var newItems = this.responseXML.getElementsByTagName(what); 63 for ( c=0; c < newItems.length; c++ ) { 64 var id = parseInt(getNodeValue(newItems[c], 'id'),10); 65 var exists = document.getElementById(what + '-' + id); 66 if (exists) tempObj.replaceListItem(exists.id, getNodeValue(newItems[c], 'newitem'), update); 67 else tempObj.addListItem(getNodeValue(newItems[c], 'newitem')); 68 } 69 newInfo.value = ''; 70 this.myResponseElement.innerHTML = ''; 71 } 72 this.ajaxAdd.runAJAX('action=add-' + what + '&info=' + newInfo.value); 73 return false; 74 } 75 this.ajaxUpdater = function(what) { 76 return this.ajaxAdder(what, true); 77 } 78 this.ajaxDelete = function(what, id) { 79 this.ajaxDel = new WPAjax('admin-ajax.php', this.ajaxRespEl ? this.ajaxRespEl : 'ajax-response'); 80 if ( this.ajaxDel.failed ) return true; 81 var tempObj = this; 82 this.ajaxDel.onCompletion = function() { if ( this.parseAjaxResponse() ) { tempObj.removeListItem( what.replace('-as-spam', '') + '-' + id, tempObj ); this.myResponseElement.innerHTML = '';} }; 83 this.ajaxDel.runAJAX('action=delete-' + what + '&id=' + id); 84 return false; 85 } 86 this.ajaxDimmer = function(what, id, dimClass) { 87 this.ajaxDim = new WPAjax('admin-ajax.php', this.ajaxRespEl ? this.ajaxRespEl : 'ajax-response'); 88 if ( this.ajaxDim.failed ) return true; 89 var tempObj = this; 90 this.ajaxDim.onCompletion = function() { if ( this.parseAjaxResponse() ) { tempObj.dimItem( what + '-' + id, dimClass); this.myResponseElement.innerHTML = '';} }; 91 this.ajaxDim.runAJAX('action=dim-' + what + '&id=' + id); 92 return false; 93 } 94 this.makeEl = function(chunk) { 95 var fakeItem = document.createElement('div'); 96 fakeItem.innerHTML = chunk; 97 var ret = fakeItem.firstChild; 98 while ( ret.tagName.match(/(table|tbody)/i) ) { ret = ret.firstChild; } 99 return ret; 100 } 101 this.addListItem = function(chunk) { 102 newItem = this.makeEl(chunk); 103 this.theList.insertBefore(newItem, this.theList.firstChild); 104 listItems.unshift(newItem.id); 105 Fat.fade_element(newItem.id); 106 } 107 this.removeListItem = function(id, listObj,noFade) { 108 if (!listObj) listObj = this; 109 if (!noFade) Fat.fade_element(id,null,700,'#FF3333'); 110 if ( !self.theItem ) self.theItem = new Array(); //grumble: global 111 self.theItem[id] = document.getElementById(id); 112 if (!noFade) setTimeout('theItem["' + id + '"].parentNode.removeChild(theItem["' + id + '"]); delete(theItem["' + id + '"])', 705); 113 else { self.theItem[id].parentNode.removeChild(theItem[id]); delete(theItem[id]); } 114 var pos = listObj.getListPos(id); 115 listItems.splice(pos,1); 116 if (!noFade) listObj.recolorList(pos); 117 } 118 this.replaceListItem = function(id, chunk, update) { 119 if (!update) { this.removeListItem(id, false, true); this.addListItem(chunk); return; } 120 var newItem = this.makeEl(chunk); 121 var oldItem = document.getElementById(id); 122 oldItem.parentNode.replaceChild(newItem,oldItem); 123 Fat.fade_element(newItem.id); 124 } 125 this.dimItem = function(id, dimClass, noFade) { 126 var theItem = document.getElementById(id); 127 if ( theItem.className.match(dimClass) ) { if (!noFade) Fat.fade_element(id,null,700,null); theItem.className = theItem.className.replace(dimClass, ''); } 128 else { if (!noFade) Fat.fade_element(id,null,700,'#FF3333'); theItem.className = theItem.className + ' ' + dimClass; } 129 } 130 this.getListPos = function(id) { 131 for (var i = 0; i < listItems.length; i++) { if (id == listItems[i]) { var pos = i; break; } } 132 return pos; 133 } 134 this.getListItems = function(id,extraRows) { 135 if (this.theList) return; 136 listItems = new Array(); 137 if (isNaN(extraRows)) extraRows = 0; 138 if (id) { this.theList = document.getElementById(id); if (!this.theList) return false; } 139 else { this.theList = document.getElementById('the-list'); if (this.theList) this.theListId = 'the-list'; } 140 if (!this.theList) { this.theList = document.getElementById('the-list-x'); extraRows += 1; if (this.theList) this.theListId = 'the-list-x'; } 141 if (this.theList) { 142 var items = this.theList.getElementsByTagName('tr'); 143 if (!items[0]) { items = this.theList.getElementsByTagName('li'); } 144 for (var i=0; i<items.length; i++) { listItems.push(items[i].id); } 145 if (extraRows) { listItems.splice(0,extraRows); } 146 } 147 } 148 this.recolorList = function(pos,dur,from) { 149 if (!pos) pos = 0; 150 if (!from) { reg_from = alt_color; alt_from = reg_color; } 151 else { reg_from = from; alt_from = from; } 152 var listItemsAsString = '' 153 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 = ''; } 154 listItemsAsString = listItemsAsString.slice(0,-1); 155 Fat.fade_all(1000); // fade_all seems to work better when many categories, but necessitates ugly next line. 156 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); 157 } 158 this.getListItems(this.theListId); 159 } 160 //Don't submit, eval(code) instead 161 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;}} 162 //Pretty function from ALA http://www.alistapart.com/articles/gettingstartedwithajax 163 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'), … … 246 245 if ($comments) { 247 246 ?> 248 247 <h3><?php _e('Comments') ?></h3> 249 <ol id=" comments">248 <ol id="the-list"> 250 249 <?php 250 $i = 0; 251 251 foreach ($comments as $comment) { 252 $comment_status = wp_get_comment_status($comment->comment_ID); 252 $class = ( ++$i % 2 ) ? array('alternate') : array(); 253 if ( 'unapproved' == $comment_status = wp_get_comment_status($comment->comment_ID) ) 254 $class[] = 'unapproved'; 253 255 ?> 254 256 255 <li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?>>257 <li id='comment-<?php echo $comment->comment_ID; ?>'<?php if ( $class ) echo " class='" . join(' ', $class) . "'"; ?>> 256 258 <?php comment_date('Y-n-j') ?> 257 259 @ 258 260 <?php comment_time('g:m:s a') ?> 259 261 <?php 260 262 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> ";263 echo "[ <a href='post.php?action=editcomment&comment=".$comment->comment_ID."\'>" . __('Edit') . '</a>'; 264 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 265 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 } 266 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>'; 267 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 268 } 270 269 echo "]"; 271 270 } // 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 }