From cb23290318b93b3ea1fd628afe902fa496cd6335 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 29 Mar 2006 01:51:55 +0000 Subject: [PATCH] AJAX, cause you love it. Props mdawaffe. fixes #2561 git-svn-id: https://develop.svn.wordpress.org/trunk@3660 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-ajax.php | 216 +++++++++++++++++++++++++++ wp-admin/admin-db.php | 3 +- wp-admin/admin-functions.php | 68 +++++---- wp-admin/admin-header.php | 15 +- wp-admin/admin.php | 2 +- wp-admin/cat-js.php | 155 +------------------ wp-admin/categories.js | 6 + wp-admin/categories.php | 14 +- wp-admin/custom-fields.js | 25 ++++ wp-admin/edit-comments.php | 20 ++- wp-admin/edit-form-advanced.php | 19 +-- wp-admin/edit-form-ajax-cat.php | 35 ----- wp-admin/edit-page-form.php | 14 +- wp-admin/edit-pages.php | 22 +-- wp-admin/edit.php | 32 ++-- wp-admin/link-manager.php | 8 +- wp-admin/list-manipulation-js.php | 160 ++++++++++++++++++++ wp-admin/list-manipulation.js | 96 ------------ wp-admin/list-manipulation.php | 69 --------- wp-admin/post.php | 4 +- wp-admin/wp-admin.css | 32 +++- wp-includes/functions-formatting.php | 4 +- wp-includes/js/fat.js | 6 +- wp-includes/pluggable-functions.php | 15 ++ 24 files changed, 595 insertions(+), 445 deletions(-) create mode 100644 wp-admin/admin-ajax.php create mode 100644 wp-admin/categories.js create mode 100644 wp-admin/custom-fields.js delete mode 100644 wp-admin/edit-form-ajax-cat.php create mode 100644 wp-admin/list-manipulation-js.php delete mode 100644 wp-admin/list-manipulation.js delete mode 100644 wp-admin/list-manipulation.php diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php new file mode 100644 index 0000000000..adf9bd8f6e --- /dev/null +++ b/wp-admin/admin-ajax.php @@ -0,0 +1,216 @@ +escape( rawurldecode(stripslashes($i)) ); + return $i; +} + +function wp_ajax_echo_meta( $pid, $mid, $key, $value ) { + $value = wp_specialchars($value, true); + $key_js = addslashes(wp_specialchars($key, 'double')); + $key = wp_specialchars($key, true); + $r = "$mid$pid"; + $r .= ""; + $r .= ""; + $r .= ""; + $r .= "
"; + $r .= ""; + $r .= "]]>
"; + return $r; +} + +$_POST = wp_clean_ajax_input( $_POST ); +$id = (int) $_POST['id']; +switch ( $_POST['action'] ) : +case 'delete-comment' : + if ( !$comment = get_comment( $id ) ) + die('0'); + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + die('-1'); + + if ( wp_delete_comment( $comment->comment_ID ) ) + die('1'); + else die('0'); + break; +case 'delete-comment-as-spam' : + if ( !$comment = get_comment( $id ) ) + die('0'); + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + die('-1'); + + if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) ) + die('1'); + else die('0'); + break; +case 'delete-cat' : + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + + if ( wp_delete_category( $id ) ) + die('1'); + else die('0'); + break; +case 'delete-link' : + if ( !current_user_can( 'manage_links' ) ) + die('-1'); + + if ( wp_delete_link( $id ) ) + die('1'); + else die('0'); + break; +case 'delete-meta' : + if ( !$meta = get_post_meta_by_id( $id ) ) + die('0'); + if ( !current_user_can( 'edit_post', $meta->post_id ) ) + die('-1'); + if ( delete_meta( $meta->meta_id ) ) + die('1'); + die('0'); + break; +case 'delete-post' : + if ( !current_user_can( 'delete_post', $id ) ) + die('-1'); + + if ( wp_delete_post( $id ) ) + die('1'); + else die('0'); + break; +case 'delete-page' : + if ( !current_user_can( 'delete_page', $id ) ) + die('-1'); + + if ( wp_delete_post( $id ) ) + die('1'); + else die('0'); + break; +case 'dim-comment' : + if ( !$comment = get_comment( $id ) ) + die('0'); + if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) + die('-1'); + if ( !current_user_can( 'moderate_comments' ) ) + die('-1'); + + if ( 'unapproved' == wp_get_comment_status($comment->comment_ID) ) { + if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) + die('1'); + } else { + if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) + die('1'); + } + die('0'); + break; +case 'add-category' : // On the Fly + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + $names = explode(',', $_POST['newcat']); + $r = ""; + foreach ( $names as $cat_name ) { + $cat_name = trim($cat_name); + if ( !$category_nicename = sanitize_title($cat_name) ) + die('0'); + if ( !$cat_id = category_exists( $cat_name ) ) + $cat_id = wp_create_category( $cat_name ); + $cat_name = wp_specialchars(stripslashes($cat_name)); + $r .= "$cat_id"; + $r .= "]]>"; + } + $r .= ''; + header('Content-type: text/xml'); + die($r); + break; +case 'add-cat' : // From Manage->Categories + if ( !current_user_can( 'manage_categories' ) ) + die('-1'); + if ( !$cat = wp_insert_category( $_POST ) ) + die('0'); + if ( !$cat = get_category( $cat ) ) + die('0'); + $pad = 0; + $_cat = $cat; + while ( $_cat->category_parent ) { + $_cat = get_category( $_cat->category_parent ); + $pad++; + } + $pad = str_repeat('— ', $pad); + + $r = ""; + $r .= "$cat->cat_ID"; + $r .= "$cat->cat_ID$pad $cat->cat_name"; + $r .= "$cat->category_description$cat->category_count$cat->link_count"; + $r .= "" . __('Edit') . ""; + $r .= "cat_name)); + $r .= "\" );' class='delete'>".__('Delete').""; + $r .= "]]>"; + header('Content-type: text/xml'); + die($r); + + break; +case 'add-meta' : + if ( !current_user_can( 'edit_post', $id ) ) + die('-1'); + if ( $id < 0 ) { + if ( $pid = write_post() ) + $meta = has_meta( $pid ); + else + die('0'); + $key = $meta[0]['meta_key']; + $value = $meta[0]['meta_value']; + $mid = (int) $meta[0]['meta_id']; + } else { + if ( $mid = add_meta( $id ) ) + $meta = get_post_meta_by_id( $mid ); + else + die('0'); + $key = $meta->meta_key; + $value = $meta->meta_value; + $pid = (int) $meta->post_id; + } + $r = ""; + $r .= wp_ajax_echo_meta( $pid, $mid, $key, $value ); + $r .= ''; + header('Content-type: text/xml'); + die($r); + break; +case 'update-meta' : + $mid = (int) array_pop(array_keys($_POST['meta'])); + $key = $_POST['meta'][$mid]['key']; + $value = $_POST['meta'][$mid]['value']; + if ( !$meta = get_post_meta_by_id( $mid ) ) + die('0'); + if ( !current_user_can( 'edit_post', $meta->post_id ) ) + die('-1'); + $r = ""; + if ( $u = update_meta( $mid, $key, $value ) ) { + $key = stripslashes($key); + $value = stripslashes($value); + $r .= wp_ajax_echo_meta( $meta->post_id, $mid, $key, $value ); + } + $r .= ''; + header('Content-type: text/xml'); + die($r); + break; +default : + die('0'); + break; +endswitch; +?> diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php index 62e7a0fc42..412a2f04b0 100644 --- a/wp-admin/admin-db.php +++ b/wp-admin/admin-db.php @@ -174,7 +174,8 @@ function wp_delete_category($cat_ID) { $parent = $category->category_parent; // Delete the category. - $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); + if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") ) + return 0; // Update children to point to new parent. $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 4b7d5d2d11..6abfd57135 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -602,12 +602,12 @@ function get_nested_categories($default = 0, $parent = 0) { function write_nested_categories($categories) { foreach ($categories as $category) { - echo '\n"; + echo '
  • \n"; - if (isset ($category['children'])) { - echo "\n\n"; + if ( $category['children'] ) { + echo "\n"; } } } @@ -626,7 +626,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { if ($categories) { foreach ($categories as $category) { if ($category->category_parent == $parent) { - $category->cat_name = wp_specialchars($category->cat_name); + $category->cat_name = wp_specialchars($category->cat_name,'double'); $pad = str_repeat('— ', $level); if ( current_user_can('manage_categories') ) { $edit = "".__('Edit').""; @@ -634,7 +634,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { $default_link_cat_id = get_option('default_link_category'); if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) ) - $edit .= "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').""; + $edit .= "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').""; else $edit .= "".__("Default"); } @@ -684,7 +684,7 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) { post_modified); ?> " . __('Edit') . ""; } ?> - " . __('Delete') . ""; } ?> + " . __('Delete') . ""; } ?> '; //TBODY needed for list-manipulation JS return; + } $count = 0; ?> - + + "; foreach ($meta as $entry) { ++ $count; if ($count % 2) @@ -849,18 +851,20 @@ function list_meta($meta) { $style = ''; if ('_' == $entry['meta_key'] { 0 }) $style .= ' hidden'; - echo " - - - - - - "; + $key_js = addslashes(wp_specialchars( $entry['meta_key'], 'double' )); + $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true ); + $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true ); + $r .= "\n\t"; + $r .= "\n\t\t"; + $r .= "\n\t\t"; + $r .= "\n\t\t"; + $r .= "\n\t"; } - echo " -

    -

    "; + $r .= "\n\t\t
    - "; + echo $r; + echo "\n\t"; } // Get a list of previously defined keys @@ -886,7 +890,7 @@ function meta_form() { LIMIT 10"); ?>

    - +
    @@ -910,13 +914,14 @@ function meta_form() {
    -

    +

    escape(stripslashes(trim($_POST['metakeyselect']))); $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput']))); @@ -926,7 +931,7 @@ function add_meta($post_ID) { // We have a key/value pair. If both the select and the // input for the key have data, the input takes precedence: - if ('#NONE#' != $metakeyselect) + if ('#NONE#' != $metakeyselect) $metakey = $metakeyselect; if ($metakeyinput) @@ -937,21 +942,32 @@ function add_meta($post_ID) { (post_id,meta_key,meta_value) VALUES ('$post_ID','$metakey','$metavalue') "); + return $wpdb->insert_id; } + return false; } // add_meta function delete_meta($mid) { global $wpdb; + $mid = (int) $mid; - $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); + return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); } function update_meta($mid, $mkey, $mvalue) { global $wpdb; + $mid = (int) $mid; return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'"); } +function get_post_meta_by_id($mid) { + global $wpdb; + $mid = (int) $mid; + + return $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'"); +} + function touch_time($edit = 1, $for_post = 1) { global $month, $post, $comment; diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 3d9e4ee1c8..ddc8915b97 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -3,10 +3,13 @@ if (!isset($_GET["page"])) require_once('admin.php'); if ( $editing ) { $dbx_js = true; - if ( current_user_can('manage_categories') ) + $pmeta_js = true; + if ( current_user_can('manage_categories') ) { + $list_js = true; $cat_js = true; + } } -if ( $list_js || $cat_js ) +if ( $list_js ) $sack_js = true; ?> @@ -29,7 +32,13 @@ function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}el - + + + + + + + diff --git a/wp-admin/admin.php b/wp-admin/admin.php index 6b04936cee..b80b1259b6 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -40,7 +40,7 @@ for ($i=0; $i -var ajaxCat = new sack(); -var newcat; - +addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.clearInputs.push('newcat');}); +addLoadEvent(newCatAddIn); function newCatAddIn() { if ( !document.getElementById('jaxcat') ) return false; var ajaxcat = document.createElement('span'); @@ -16,163 +15,21 @@ function newCatAddIn() { newcat.id = 'newcat'; newcat.size = '16'; newcat.setAttribute('autocomplete', 'off'); - newcat.onkeypress = ajaxNewCatKeyPress; + newcat.onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','categorydiv');", e); }; var newcatSub = document.createElement('input'); newcatSub.type = 'button'; newcatSub.name = 'Button'; newcatSub.id = 'catadd'; - newcatSub.value = ''; - newcatSub.onclick = ajaxNewCat; + newcatSub.value = 'Add'; + newcatSub.onclick = function() { catList.ajaxAdder('category', 'categorydiv'); }; ajaxcat.appendChild(newcat); ajaxcat.appendChild(newcatSub); document.getElementById('jaxcat').appendChild(ajaxcat); howto = document.createElement('span'); - howto.innerHTML = ''; + howto.innerHTML = ""; howto.id = 'howto'; ajaxcat.appendChild(howto); } - -addLoadEvent(newCatAddIn); - -function getResponseElement() { - var p = document.getElementById('ajaxcatresponse'); - if (!p) { - p = document.createElement('span'); - document.getElementById('jaxcat').appendChild(p); - p.id = 'ajaxcatresponse'; - } - return p; -} - -function newCatLoading() { - var p = getResponseElement(); - p.innerHTML = ''; -} - -function newCatLoaded() { - var p = getResponseElement(); - p.innerHTML = ''; -} - -function newCatInteractive() { - var p = getResponseElement(); - p.innerHTML = ''; -} - -function newCatCompletion() { - var p = getResponseElement(); - var id = 0; - var ids = new Array(); - var names = new Array(); - - ids = myPload( ajaxCat.response ); - names = myPload( newcat.value ); - for ( i = 0; i < ids.length; i++ ) { - id = ids[i].replace(/[\n\r]+/g, ""); - if ( id == '-1' ) { - p.innerHTML = ""; - return; - } - if ( id == '0' ) { - p.innerHTML = ""; - return; - } - - var exists = document.getElementById('category-' + id); - - if (exists) { - var moveIt = exists.parentNode; - var container = moveIt.parentNode; - container.removeChild(moveIt); - container.insertBefore(moveIt, container.firstChild); - moveIt.id = 'new-category-' + id; - exists.checked = 'checked'; - var nowClass = moveIt.className; - moveIt.className = nowClass + ' fade'; - Fat.fade_all(); - moveIt.className = nowClass; - } else { - var catDiv = document.getElementById('categorychecklist'); - var newLabel = document.createElement('label'); - newLabel.setAttribute('for', 'category-' + id); - newLabel.id = 'new-category-' + id; - newLabel.className = 'selectit fade'; - - var newCheck = document.createElement('input'); - newCheck.type = 'checkbox'; - newCheck.value = id; - newCheck.name = 'post_category[]'; - newCheck.id = 'category-' + id; - newLabel.appendChild(newCheck); - - var newLabelText = document.createTextNode(' ' + names[i]); - newLabel.appendChild(newLabelText); - - catDiv.insertBefore(newLabel, catDiv.firstChild); - newCheck.checked = 'checked'; - - Fat.fade_all(); - newLabel.className = 'selectit'; - } - newcat.value = ''; - } - p.parentNode.removeChild(p); -// var id = parseInt(ajaxCat.response, 10); -} - -function ajaxNewCatKeyPress(e) { - if (!e) { - if (window.event) { - e = window.event; - } else { - return; - } - } - if (e.keyCode == 13) { - ajaxNewCat(); - e.returnValue = false; - e.cancelBubble = true; - return false; - } -} - -function ajaxNewCat() { - var newcat = document.getElementById('newcat'); - var split_cats = new Array(1); - var catString = ''; - - catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value); - ajaxCat.requestFile = 'edit-form-ajax-cat.php'; - ajaxCat.method = 'GET'; - ajaxCat.onLoading = newCatLoading; - ajaxCat.onLoaded = newCatLoaded; - ajaxCat.onInteractive = newCatInteractive; - ajaxCat.onCompletion = newCatCompletion; - ajaxCat.runAJAX(catString); -} - -function myPload( str ) { - var fixedExplode = new Array(); - var comma = new String(','); - var count = 0; - var currentElement = ''; - - for( x=0; x < str.length; x++) { - andy = str.charAt(x); - if ( comma.indexOf(andy) != -1 ) { - currentElement = currentElement.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // trim - fixedExplode[count] = currentElement; - currentElement = ""; - count++; - } else { - currentElement += andy; - } - } - - if ( currentElement != "" ) - fixedExplode[count] = currentElement; - return fixedExplode; -} \ No newline at end of file diff --git a/wp-admin/categories.js b/wp-admin/categories.js new file mode 100644 index 0000000000..d339c5c6c3 --- /dev/null +++ b/wp-admin/categories.js @@ -0,0 +1,6 @@ +addLoadEvent(newCategoryAddIn); +function newCategoryAddIn() { + if (!theList.theList) return false; + document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; + theList.clearInputs.push('cat_name','category_parent','category_description'); +} diff --git a/wp-admin/categories.php b/wp-admin/categories.php index 63284014ac..14e63f7227 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -3,7 +3,6 @@ require_once('admin.php'); $title = __('Categories'); $parent_file = 'edit.php'; -$list_js = true; $wpvarstoreset = array('action','cat'); for ($i=0; $i

    - +
    + @@ -130,9 +131,12 @@ $messages[3] = __('Category updated.'); + + +
    @@ -149,14 +153,14 @@ cat_rows();


    -

    +


    -


    -

    +

    diff --git a/wp-admin/custom-fields.js b/wp-admin/custom-fields.js new file mode 100644 index 0000000000..5b9f479c4c --- /dev/null +++ b/wp-admin/custom-fields.js @@ -0,0 +1,25 @@ +addLoadEvent(customFieldsAddIn); +function customFieldsAddIn() { + if (!theList.theList) return false; + inputs = theList.theList.getElementsByTagName('input'); + for ( var i=0; i < inputs.length; i++ ) { + if ('text' == inputs[i].type) { + inputs[i].setAttribute('autocomplete', 'off'); + inputs[i].onkeypress = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.name.slice(5),10) + '");', e); }; + } + if ('updatemeta' == inputs[i].className) { + inputs[i].onclick = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.parentNode.parentNode.id.slice(5),10) + '");', e); }; + } + } + + document.getElementById('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta", customFieldsOnComplete);', e); }; + document.getElementById('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta", customFieldsOnComplete);', e); }; + theList.clearInputs.push('metakeyselect','metakeyinput','metavalue'); +} +function customFieldsOnComplete() { + var pidEl = document.getElementById('post_ID'); + pidEl.name = 'post_ID'; + pidEl.value = getNodeValue(theList.ajaxAdd.responseXML, 'postid'); + var aEl = document.getElementById('hiddenaction') + if ( aEl.value == 'post' ) aEl.value = 'postajaxpost'; +} diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 632f2099d8..b4e946a608 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -133,13 +133,13 @@ if ('view' == $mode) { |

    - +

    @@ -162,19 +162,28 @@ if ('view' == $mode) { '; foreach ($comments as $comment) { $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID")); + $comment_status = wp_get_comment_status($comment->comment_ID); $class = ('alternate' == $class) ? '' : 'alternate'; + $class .= ('unapproved' == $comment_status) ? ' unapproved' : ''; ?> - + comment_post_ID) ) { ?> - + + + (Unapproved) + + + + comment_post_ID) ) { echo "" . __('Edit') . ""; } ?> comment_post_ID) ) { - echo "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') . ""; } ?> + echo "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') . " "; + } ?> '); return false } return confirm('')" /> ')" />

    +
    diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 5ef39cc013..504a8565c6 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -21,10 +21,10 @@ $messages[3] = __('Custom field deleted.'); if (0 == $post_ID) { $form_action = 'post'; $temp_ID = -1 * time(); - $form_extra = ""; + $form_extra = ""; } else { $form_action = 'editpost'; - $form_extra = ""; + $form_extra = ""; } $form_pingback = ''; @@ -49,7 +49,7 @@ if (empty($post->post_status)) $post->post_status = 'draft'; ?> - + @@ -72,7 +72,7 @@ addLoadEvent(focusit);

    -
    +
    @@ -248,16 +248,17 @@ if ( ! empty($pings) )

    - + + +
    +
    diff --git a/wp-admin/edit-form-ajax-cat.php b/wp-admin/edit-form-ajax-cat.php deleted file mode 100644 index 1da142f852..0000000000 --- a/wp-admin/edit-form-ajax-cat.php +++ /dev/null @@ -1,35 +0,0 @@ - \ No newline at end of file diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index e10897ad3b..cbc00dc488 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -6,10 +6,10 @@ if (0 == $post_ID) { $form_action = 'post'; $temp_ID = -1 * time(); - $form_extra = ""; + $form_extra = ""; } else { $form_action = 'editpost'; - $form_extra = ""; + $form_extra = ""; } $sendto = $_SERVER['HTTP_REFERER']; @@ -209,14 +209,14 @@ if (current_user_can('upload_files')) {

    + + +
    -
    diff --git a/wp-admin/edit-pages.php b/wp-admin/edit-pages.php index 2e25f535dc..66196815b7 100644 --- a/wp-admin/edit-pages.php +++ b/wp-admin/edit-pages.php @@ -28,20 +28,24 @@ else if ($posts) { ?> - - - - +
    + + + + - - - - + + + + + + -
    + +
    diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 789675d2b6..fcf268d39f 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -114,7 +114,6 @@ if ( count($arc_result) ) { ?>
    'display name' $posts_columns = array( 'id' => __('ID'), @@ -133,7 +132,8 @@ $posts_columns['control_delete'] = ''; ?> - +
    + @@ -141,10 +141,13 @@ $posts_columns['control_delete'] = ''; + + @@ -207,7 +210,7 @@ foreach($posts_columns as $column_name=>$column_display_name) { case 'control_delete': ?> - + $column_display_name) { +?> +
    ID) ) { echo "" . __('Delete') . ""; } ?>ID) ) { echo "" . __('Delete') . ""; } ?>
    @@ -246,26 +250,26 @@ if ( 1 == count($posts) ) { if ($comments) { ?>

    -
      +
        comment_ID); +$class = ( ++$i % 2 ) ? array('alternate') : array(); +if ( 'unapproved' == $comment_status = wp_get_comment_status($comment->comment_ID) ) + $class[] = 'unapproved'; ?> -
      1. > +
      2. > @ ID) ) { - echo "[ comment_ID."\">" . __('Edit') . ""; - echo " - 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') . " "; + echo "[ " . __('Edit') . ''; + echo ' - comment_author, 1)) . "' );\">" . __('Delete') . ' '; if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { - if ('approved' == wp_get_comment_status($comment->comment_ID)) { - echo " - ID."&comment=".$comment->comment_ID."\">" . __('Unapprove') . " "; - } else { - echo " - ID."&comment=".$comment->comment_ID."\">" . __('Approve') . " "; - } + echo ' - ' . __('Unapprove') . ' '; + echo ' - ' . __('Approve') . ' '; } echo "]"; } // end if any comments to show diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index 8344d1a848..801b584c14 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -114,7 +114,8 @@ bookmarks ordered by - +
        + @@ -124,6 +125,8 @@ bookmarks ordered by + + \n"; } ?> +
        @@ -182,4 +186,4 @@ if ($links) - \ No newline at end of file + diff --git a/wp-admin/list-manipulation-js.php b/wp-admin/list-manipulation-js.php new file mode 100644 index 0000000000..0867b64bc1 --- /dev/null +++ b/wp-admin/list-manipulation-js.php @@ -0,0 +1,160 @@ + +addLoadEvent(function(){theList=new listMan();}); +function deleteSomething(what,id,message){if(!message)message="";if(confirm(message))return theList.ajaxDelete(what,id);else return false;} +function dimSomething(what,id,dimClass){return theList.ajaxDimmer(what,id,dimClass);} + +function WPAjax(file, responseEl){//class WPAjax extends sack + 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; } + this.parseAjaxResponse=function(){ + if(isNaN(this.response)){this.myResponseElement.innerHTML=""+this.response;return false;} + this.response=parseInt(this.response,10); + if(-1==this.response){this.myResponseElement.innerHTML="";return false;} + else if(0==this.response){this.myResponseElement.innerHTML="";return false;} + return true; + } + this.parseAjaxResponseXML=function(){ + if(this.responseXML&&typeof this.responseXML=='object')return true; + if(isNaN(this.response)){this.myResponseElement.innerHTML=""+this.response;return false;} + var r=parseInt(this.response,10); + if(-1==r){this.myResponseElement.innerHTML="";} + else if(0==r){this.myResponseElement.innerHTML="";} + return false; + } + this.init(file,responseEl); +} WPAjax.prototype=new sack; + WPAjax.prototype.init=function(f,r){ + this.URLString=this.encVar('cookie', document.cookie); + this.requestFile=f;this.getResponseElement(r);this.method='POST'; + this.onLoading=function(){this.myResponseElement.innerHTML="";}; + this.onLoaded=function(){this.myResponseElement.innerHTML="";}; + this.onInteractive=function(){this.myResponseElement.innerHTML="";}; + } + +function listMan(theListId){ + this.theList=null; + this.ajaxRespEl=null; + this.inputData=''; + this.clearInputs=new Array(); + var reg_color='#FFFFFF'; + var alt_color='#F1F1F1'; + var listItems; + var listType; + self.aTrap=0; + + this.ajaxAdder=function(what,where,onComplete,update){//for TR, server must wrap TR in TABLE TBODY. this.makeEl cleans it + if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300); + this.ajaxAdd=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response'); + if(this.ajaxAdd.failed)return true; + this.grabInputs(where); + var tempObj=this; + this.ajaxAdd.onCompletion=function(){ + if(!this.parseAjaxResponseXML())return; + var newItems=this.responseXML.getElementsByTagName(what); + if(newItems){for (c=0;ccomment_post_ID ) ) - die('-1'); - - if ( wp_delete_comment( $comment->comment_ID ) ) - die('1'); - else die('0'); - break; -case 'delete-comment-as-spam' : - if ( !$comment = get_comment( $id ) ) - die('0'); - if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) - die('-1'); - - if ( wp_set_comment_status( $comment->comment_ID, 'spam' ) ) - die('1'); - else die('0'); - break; -endswitch; -?> diff --git a/wp-admin/post.php b/wp-admin/post.php index 0ea17be8cd..46c0ff9a53 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -17,15 +17,15 @@ for ($i=0; $i', '>', $text); - if ( $quotes ) { + if ( 'double' === $quotes ) { + $text = str_replace('"', '"', $text); + } elseif ( $quotes ) { $text = str_replace('"', '"', $text); $text = str_replace("'", ''', $text); } diff --git a/wp-includes/js/fat.js b/wp-includes/js/fat.js index a16004e476..01f1b4221b 100644 --- a/wp-includes/js/fat.js +++ b/wp-includes/js/fat.js @@ -11,7 +11,7 @@ var Fat = { b = b.toString(16); if (b.length == 1) b = '0' + b; return "#" + r + g + b; }, - fade_all : function () + fade_all : function (dur) { var a = document.getElementsByTagName("*"); for (var i = 0; i < a.length; i++) @@ -21,7 +21,7 @@ var Fat = { if (r) { if (!r[1]) r[1] = ""; - if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]); + if (o.id) Fat.fade_element(o.id,null,dur,"#"+r[1]); } } }, @@ -87,4 +87,4 @@ var Fat = { addLoadEvent(function () { Fat.fade_all(); -}); \ No newline at end of file +}); diff --git a/wp-includes/pluggable-functions.php b/wp-includes/pluggable-functions.php index cc1030ae9e..944ab5e8e4 100644 --- a/wp-includes/pluggable-functions.php +++ b/wp-includes/pluggable-functions.php @@ -237,6 +237,21 @@ function check_admin_referer() { } endif; +if ( !function_exists('check_ajax_referer') ) : +function check_ajax_referer() { + $cookie = explode(';', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie + foreach ( $cookie as $tasty ) { + if ( false !== strpos($tasty, USER_COOKIE) ) + $user = substr(strstr($tasty, '='), 1); + if ( false !== strpos($tasty, PASS_COOKIE) ) + $pass = substr(strstr($tasty, '='), 1); + } + if ( !wp_login( $user, $pass, true ) ) + die('-1'); + do_action('check_ajax_referer'); +} +endif; + // Cookie safe redirect. Works around IIS Set-Cookie bug. // http://support.microsoft.com/kb/q176113/ if ( !function_exists('wp_redirect') ) :